CodeRunner Documentation (V3.0.0)

2.3 Preliminary testing of the CodeRunner question type

Once you have installed the CodeRunner question type, you should be able to run CodeRunner questions using the University of Canterbury's Jobe Server as a sandbox. It is recommended that you do this before proceeding to install and configure your own sandbox. Using the standard Moodle web interface, either as a Moodle administrator or as a teacher in a course you have set up, go to the Question Bank and try creating a new CodeRunner question. A simple Python3 test question is: "Write a function sqr(n) that returns the square of its parameter n.". Test cases for this might be:

TestExpected
print(sqr(-7))49
print(sqr(5))25
print(sqr(-1))1
print(sqr(0))0
print(sqr(-100))10000

You could check the 'UseAsExample' checkbox on the first two (which results in the student seeing a simple "For example" table) and perhaps make the last case a hidden test case. (It is recommended that all questions have at least one hidden test case to prevent students synthesising code that works just for the known test cases).

Save your new question, then preview it, entering both correct and incorrect answers.

IMPORTANT: CodeRunner is designed to work only in an Adaptive Mode so you must set the How questions behave dropdown under Attempt Options to Adaptive mode. If you fail to do this, you'll receive a message like "Detailed test results unavailable. Perhaps an empty answer, or question behaviour not set to Adaptive Mode?". When setting quizzes using CodeRunner questions, you should run the entire quiz in Adaptive Mode, again using the 'Question behaviour' dropdown under Quiz Settings. If you are using a Moodle server set up specifically to run CodeRunner questions, it is recommended that you set the default question behaviour for the whole site to Adaptive Mode. An Moodle administrator does this by going to Site administration > Plugins > Activity Modules > Quiz and selecting Adaptive Mode from the How questions behave dropdown.

If you want a few more CodeRunner questions to play with, try importing the files MoodleHome>/question/type/coderunner/db/simpledemoquestions.xml and/or MoodleHome>/question/type/coderunner/db/python3demoquestions.xml These contains all the questions from the two tutorial quizzes on the demo site. Note, though, that some of the questions from the python3demoquestions file make use of the University of Canterbury prototypes in uoc_prototypes.xml, so you'd need to import them, too.