Failed to run tests.

Failed to run tests.

by Richard Lobb -
Number of replies: 0

A user posted the following comment on https://moodle.org/plugins/qtype_coderunner. It's a common question, so I thought I'd answer it here.

I installed coderunner on Moodle 4.2 and I even installed the jobe server. I can confirm that the jobe server is running, but whenever I add a new question using coderunner and I try to save my question the "answer" field will diplay "Failed to run tests". Is there a fix for this, should I downgrade my moodle?

The latest CodeRunner (V5.2) works fine with Moodle 4.2. It's probably a networking issue. Here are some things to try.

  • If you uncheck "Validate on save", save the question and preview it, do you see a "URL blocked" message, or the generic "An unexpected error occurred The sandbox may be down. Try again shortly."?
    • If you get "URL blocked" you probably need to change Moodle's HTML security settings (Site admin > General > Security > HTTP security).
      • This situation occurs if you're running a Jobe server on other than port 80 or (via a reverse proxy) 443.
      • It can also occur if you're running JobeInABox on the same host as Moodle or you're running a containerised Moodle.
  • Does CodeRunner work with the default Jobe server (jobe2.cosc.canterbury.ac.nz) and Jobe API key (2AAA7A5415B4A9B394B54BF1D2E9D)? If not, something must be blocking outgoing connections on port 80. If that does work, something is blocking access to your Jobe server but not to jobe2.cosc.canterbury.ac.nz.
  • Download testsubmit.py from github onto your Moodle server. Run it from the command line there, as explained in the Jobe install documentation on github (https://github.com/trampgeek/jobe/blob/master/README.md#testing-the-install). You need to use the --host option and possibly --port if not using port 80.
    • If that works but CodeRunner doesn't, the plugin's settings (Site administration > Plugins > CodeRunner) would seem the most likely cause. 

There are unfortunately lots of things that can stop Moodle talking to Jobe. Please share your symptoms and solutions here.

See also the forum thread "An unexpected error occurred".