Expected solution computed with a call to teacher function

Re: Expected solution computed with a call to teacher function

de Richard Lobb -
Número de respuestas: 0

Using the sample answer as a reference solution with which to test the student's submission isn't impossible but it is a bit difficult. CodeRunner was originally built to mimic a "test-driven development" model of programming: "here are all the tests, now write the program". In software engineering you don't usually have a reference solution to test against!

However, it is possible to use the sample answer for testing and indeed we sometimes do this. The template for the question is usually written in a scripting language like Python, along the lines of the "c_via_python" question type supplied with CodeRunner and documented here. The sample answer is available to the Twig template author as {{ QUESTION.answer }} (see here). So the template can first run that code, collect the output, then run the student answer and compare the two outputs. It requires quite a lot of CodeRunner experience to get this all working, though. And you need to be very sure that your sample answer is correct, as there's now no built-in validation.

Note that if you adopt this approach in conjunction with randomisation, you still have a problem with presenting the student with a "For example" table. You usually need to construct at least one or two sample answers with Twig code. If you wished to use your sample answer to generate the example table, the job would have to be sent to the Jobe server before the question could be displayed to the student. In large tests and exams, with multiple questions displayed on each page, that approach would result in hundreds or even thousands of jobs hitting the Jobe server in the first few seconds of the exam, which is why I don't support such a capability.