Announcing CodeRunner V4.0.0

Announcing CodeRunner V4.0.0

by Richard Lobb -
Number of replies: 3

I'm pleased to announce that I have just pushed CodeRunner V4.0.0 to github. Changes since V3.7.9+ (October 2020):

  • Add a template parameter preprocessing capability that allows uses of languages other than Twig for generating the JSON template parameter set. [Experimental feature. Has potential to overload Jobe server at the start of tests and exams if misused.]
  • Separate UI-plugin parameters from template parameters and provide an improved UI that lists all available UI parameters and their meanings for the currently selected UI.
  • Update Twig to the latest version (3.1).
  • Add QUESTION.stepinfo to the Twig environment. This is a record with attributes
    preferredbehaviour, numchecks, numprechecks and fraction allowing authors
    to provide more elaborate feedback according to quiz mode and previous submissions.
  • Add a macro ___textareaId___ to the HTML-UI that gets replaced by the id of the textarea element that the HTML-UI is operating on.
  • Add special __twigprefix__ template parameter that, if defined in a question’s prototype, provides content (e.g. Twig macros) that is inserted at the start of all Twig-expanded question fields.
  • Reduce unnecessary calls to the Jobe server to get its list of supported languages when there is only one sandbox available (the usual case nowadays).
  • Bug fix: nodejs programs in ESM style were breaking. So change filename extension  to .js
  • Bug fix: Ace plugin was generating duplicate (and wrong) ids when multiple ace editors were present in a form.
  • Bug fix: Ace editor was not being initialised to the correct language with multilanguage questions for which a default language was specified.
  • Bug fix: some non-inherited fields were being mistakenly loaded from the prototype when changing question type via Ajax.
  • Bug fix: %h formats for columns were being ignored in the “For example” table.
In reply to Richard Lobb

Re: Announcing CodeRunner V4.0.0

by Hongchuan Liu -
A template parameter preprocessing capability is a function I've always wanted.
In reply to Richard Lobb

Re: Announcing CodeRunner V4.0.0 --- numchecks

by Carroll Morgan -

Hello --- I'm trying to access "numchecks" within a Python-marked Moodle queston. Could you tell me how to do that?

The code I have is

numChecks= {{QUESTION.stepinfo.numchecks}}

but it leads to "Stored results cannot be deserialised...". Changing it to

numChecks= '''{{QUESTION.stepinfo.numchecks}}''' == ""

gives "1" when I view it by putting it in the results table. Changing it to 

numChecks= '''{{QUESTION.stepinfo.rubbish}}''' == ""

also gives 1, suggesting I am not asking for it in the right way.

===

I have asked our admins what version of CodeRunner we have, but have not yet heard back. (I don't know how to ask CodeRunner itself for te version number.)

Thanks, Carroll Morgan




In reply to Carroll Morgan

Re: Announcing CodeRunner V4.0.0 --- numchecks

by Richard Lobb -

I'm not sure how the "can't deserialise" error came about. You shouldn't generally be able to get that except when viewing a cached result from an earlier version of CodeRunner. So that's a "dunno".

The other two results imply that you don't have version 4.0 installed. If you evaluate a non-existing Twig expression like {{ BLAH }} you just get an empty string. [This was a bad design decision I made about 10 years ago, sorry, but I fear I'd break a lot of questions by fixing it now.]

You can't currently get the CodeRunner version installed through the question authoring interface, though I did just add that capability as a result of your posting :-) However, you can see the entire QUESTION object in user-friendly format by inserting the following code into your template somewhere suitable:

import pprint, json
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(json.loads("""{{ QUESTION | json_encode | e('py') }}"""))

If you have a version of CodeRunner that includes stepinfo you'll see something like the following:

{   'acelang': None,
    'allornothing': '1',
    'allowmultiplestdins': '0',
    'answer': 'print("Hello world!")',
... (snipping stuff out here) ...
    'resultcolumns': None,
    'sandbox': None,
    'sandboxparams': None,
    'stepinfo': {   'fraction': 0,
                    'numchecks': 1,
                    'numprechecks': 0,
                    'preferredbehaviour': 'adaptive'},
    'testcases': [   {   'display': 'SHOW',
                         'expected': 'Hello world!',
                         'extra': '',
                         'hiderestiffail': '0',
                         'id': '1',
                         'mark': '1.000',
                         'questionid': '23',
                         'stdin': '',
                         'testcode': '',
                         'testtype': '0',
                         'useasexample': '0'}],
    'uiparameters': [],
    'uiplugin': 'ace',
    'useace': '1'}

If you don't see a stepinfo field, you're running an older CodeRunner.

BTW: when conducting tests like this, be aware that CodeRunner caches run outcomes, so if you change the question in any way, you also need to change the question (e.g. add a trailing space somewhere) before clicking Check again if you want to see the effect of your change.