Template Grader

Template Grader

by Jens Allmer -
Number of replies: 1

Hi,

I just discovered cr in our Moodle system. So I managed to implement a few simple questions for the C programming language. 

The problem I ran into is that I couldn't figure out how to parse __STUDENT_ANSWER__ or {{STUDENT_ANSWER}} in C.

This leads me to the question of whether it would be possible to use a different programming language to implement the Template Grader than the language which is graded.

E.g., I would like to use JS to do the job. Python would also be fine although I have no prior experience with it. In my opinion, C is just not convenient for such a task. 

Thank you



In reply to Jens Allmer

Re: Template Grader

by Richard Lobb -

Sure. In the Advanced Customisation panel, set "Sandbox language" to whatever language you want for the template (nodejs for JavaScript). Then set "Ace Language" to the target language, i.e the language that the student's answer will be in.

However, if the template language is different from the target language, the template must explicitly compile (if required) and execute the student code, after checking is complete. The section Implementing new Languages in the documentation shows how for Python - same principles apply in JavaScript.