Generate file from answer for use in question?

Re: Generate file from answer for use in question?

de către Richard Lobb-
Număr de răspunsuri: 3

It's not possible at present. I do have a working prototype of CodeRunner in which the template parameters field is either pure JSON, Twigged-JSON or Python. Extension to other sandbox languages should be trivial. In all cases the code is expected to yield JSON when evaluated. As at present, that JSON provides the environment for Twig expansion of all other fields of the question if Twig-All is checked. That should do what you want. But ... 

Except for Twig, evaluation takes place on Jobe, and must be done before the question is rendered to the student. To accommodate randomisation or per-student question customisation (which I saw as the principal drivers for the functionality), this evaluation takes place at the start of the question attempt, for each student. I've held off implementing this capability for years because of the likelihood (certainty?) that it will result in question authors overloading the jobe server at the start of tests and exams. Consider 500 students in a test with 20 questions using this capability: that's 10,000 jobs hitting the Jobe server in the first few seconds of the test. No way it'll survive that! Our 8-core Jobe server has a throughput of at most 80 jobs per second and reports an overload if a received job cannot be allocated resources (user/cpu) within 6 seconds.

I'm now a bit torn because, having implemented it I've realised how powerful and useful it is. But also how potentially lethal. So it may or may not ever actually get released! My current thoughts are to include it in the next release but to issue a warning to anyone using it. 

It occurs to me that your particular use case might not require randomisation or the use of the STUDENT variable. In which case the JSON could be evaluated when the question is saved, not every time a student started an attempt on the question. So I'll see if I can find a way to enable once-only evaluation of the template parameters, when the author saves the question.

Comments/suggestions welcome.

Ca răspuns la Richard Lobb

Re: Generate file from answer for use in question?

de către Michael Backus-

Just checking in to see if you have released a new version that incorporates this functionality.

Ca răspuns la Michael Backus

Re: Generate file from answer for use in question?

de către Richard Lobb-

I've mostly finished the latest burst of CodeRunner development and the feature you want is (more or less) present in the current development version. I have to get back into teaching at the start of February, and hope to install the latest version on our 2021 production server then, ready for the new teaching year later that month. I hope to officially release the new version (4.0) mid-February. 

But I'd love to have someone help with testing, so if you're keen to get to play with it and have a server on which you can install the development version, please let me know. I'll tell you when the development version is good to go - probably in a couple of days.

Just FYI, here's how the new feature works.

The role of the template parameters field is unchanged - it still yields a set of variables that provide the context in which the template and the rest of the question (assuming TwigAll is set) is expanded. But now you get to specify a preprocessor - one of None, Twig, Python3, Java, ... - that is applied to the template parameters to yield the actual JSON. If this is a program in a language other than Twig, it is run on the sandbox server before the question is rendered. But note that the preprocessor doesn't have access to the QUESTION object (since this doesn't even exist yet). So it can't access the answer field of the question (which likely includes Twig variables anyway). To achieve your goals you must embed the answer in the (say) Python template parameter field and then include that as one of the output variables so that the answer field in the form can be filled in as just  (say) {{ sample_answer }}.

Richard

Ca răspuns la Richard Lobb

Re: Generate file from answer for use in question?

de către Michael Backus-

Thanks for the offer. I'll have to wait for you to release it as all I have is my production server.