Developers' Forum

maybe error in documentation section 9.1

maybe error in documentation section 9.1

by Jim Newton -
Number of replies: 3

I'm trying to understand section 9.1 of the documentation: https://coderunner.org.nz/mod/book/view.php?id=198&chapterid=820

The example code prints a json string with fields: got, comment, and fraction.  However, the suggestion is to use a Results Columns value of 

  [["Expected", "expected"], ["Got", "got"], ["Comment", "comment"], ["Mark", "awarded"]]
Is this really correct?   Shouldn't the Results columns match the json string produced by the program code?   Or are there really some special names such as "expected" and "awarded" which are independent of the json string printed by the template code?
In reply to Jim Newton

Re: maybe error in documentation section 9.1

by Richard Lobb -

That bit needs to be read in the context of the earlier explanation of Per-test-case template grading:

When the template is a per-test template and a TemplateGrader is selected, the output from the program must be a JSON string that defines one row of the test results table. [Remember that per-test templates are expanded and run once for each test case.] The JSON object must contain at least a 'fraction' field, which is multiplied by TEST.mark to decide how many marks the test case is awarded. It should usually also contain a 'got' field, which is the value displayed in the 'Got' column of the results table. The other columns of the results table (testcode, stdin, expected) can, if desired, also be defined by the template grader and will then be used instead of the values from the test case. 

The settings of the Result Columns must have names that match the standard result table column names, possibly extended by any additional columns, e.g. comment in the example. The standard result table column names are documented in the section Customising the result table.
In reply to Richard Lobb

Re: maybe error in documentation section 9.1

by Jim Newton -

I think I understand the basics here, now.  Thanks.

One thing that is still a bit confusing.  The grading template is expected to print a JSON string with some particular fields.  Some of the files are required by CodeRunner itself, (fraction, got), and some are expected by the particular Result Columns which the question author has installed.   But there are also some specific JSON keys https://github.com/trampgeek/moodle-qtype_coderunner/blob/master/Readme.md#customising-the-result-table with special meaning.

What I don't understand is what happens to extra keys which the template generate to stdout?   is the template free to generate whatever keys it wants and CodeRunner happily ignores them?  Or is it expected to ONLY generate known keys plus those specified in the Result Columns?

Is there any way for debug purpose to find out what exact JSON string the template generated?

In reply to Jim Newton

Re: maybe error in documentation section 9.1

by Jim Newton -

I've added a question on the Authors forum about how the debugging model.