Let's take This Wiki page introduces a simple CodeRunner example, where the task is to write a program that calculates the volume of ideal gas (TODO: link the XML file for the question. The XML file can be imported to Moodle).
Table of contents
Table of Contents style none
Here is how the simple exercise looks like inside a Quiz:
If the student submits an incorrect answer, the output looks as below. The Show differences button is very helpful as it highlights the differences in the expected output and the output from the student.
Settings for a CodeRunner question
Let's see how simple CodeRunner questions are set up.
MyCourses opens a new page Editing a CodeRunner question. The question type is well-documented and you can click the question mark symbols for context-based help. Here we will go through the very basic settings needed to set up a simple exercise.
CodeRunner question type
Question type: python3
Customization: Do not check any boxes. This setting is explained in the Wiki pages dealing with more advanced questions.
Answer box: You can set the number or rows in the student answer box. For our example here, it is 15. For a very short code of just few rows, you could make the box even smaller. And for longer codes, a larger box might be helpful so that students can properly see their code before they submit it for checking. But always make it clear for the students that they should write and test their answers in a separate code editor, not directly in the CodeRunner answer box. It is very important that the students learn to use a proper code editor and learn to test their own code.
Twig controls: For simple python3 programming exercises, there is no need to change these options. Typically, Hoist template parameters is checked and Twig all unchecked. Twig all setting will be checked if you do randomization of CodeRunner questions.
Question type details
CodeRunner documentation on the selected question type (python3 in this case)
Answer box preload