CodeRunner Documentation (V3.2.1)

2.4 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.". The introductory quick-start guide in the incomplete Question Authoring Guide gives step-by-step instructions for creating such a question. Alternatively you can just try to create a question using the on-line help in the question authoring form. Test cases for the question 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.

If you want a few more CodeRunner questions to play with, try importing the files MoodleHome>/question/type/coderunner/samples/simpledemoquestions.xml and/or MoodleHome>/question/type/coderunner/samples/python3demoquestions.xml. These contains most of the questions from the two tutorial quizzes on the demo site. If you wish to run the questions in the file python3demoquestions.xml, you will also need to import the file MoodleHome>/question/type/coderunner/samples/uoc_prototypes.xml or you will receive a "Missing prototype" error.

Also included in the samples folder is a prototype question, prototype\_c\_via\_python.xml that defines a new question type, equivalent to the built-in c_program type, by scripting in Python the process of compiling and running the student code. This is a useful template for authors who wish to implement their own question types or who need to support non-built-in languages. It is discussed in detail in the section "Supporting or implementing new languages".