Combinator Graders and the Show Differences button

Combinator Graders and the Show Differences button

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

A correspondent writes:

1) I am writing a template grader with combinator option, in which I
want to use 'showdifferences' option. Moodle 3.9 on which I work has two
languages: Polish (main) and English; users can change language in the
top bar of the page. From what I've seen the 'Show differences' button
appears when there are columns named 'Expected' and 'Got' in the table
or name of columns are translated according to the language set (I read
the discussion https://coderunner.org.nz/mod/forum/discuss.php?d=115).

I wanted to make a universal template grader that returns a table with
'Expected' and 'Got' column names depending on what language the user
(student) has set (Polish: 'Oczekiwane' and 'Otrzymane', English:
'Expected' and 'Got'). I thought I could find such information in one of
the pre-defined Twig variables, but checking {{ _context | json_encode
}} I didn't find anything like that. Is this goal even possible to achieve?

Going further, we may have for example an English-speaking student who
should see the 'Expected' and 'Got' columns, and a teacher using the
Polish version of Moodle who should see the 'Oczekiwane' and 'Otrzymane'
columns in the student's solution. Does the template grader with the
combinator option assume that the column names are fixed?

2) Is it possible in template grader with combinator to hide result
table header (and actually whole result table) only for a student if all
test cases are hidden? Well, actually I did it by some HTML and
JavaScript in 'epiloguehtml' but I wonder if there is a better option.

Question (1): this is relatively easy to solve if you have a single-language site. The Combinator Template grader prints a JSON object defining the feedback. One of the possible attributes of that object is 'showdifferences'. If this has a true value (i.e. {"showdifferences": true, ... } the Show Differences button is enabled. The associated JavaScript looks in the result table header for the values of 'Expected' and 'Got' in whatever language Moodle is currently running. So if all your students are Polish, your returned result table can have your Polish column titles in it, and Show differences (which will of course display in Polish too) should work.

If you have different students using different languages it's more problematic.

With a combinator template grader you have complete control over the feedback you provide the student but because the grader is running on the Jobe server, completely separate from Moodle, you don't have access to the usual Moodle language strings. So you can't deliver feedback that depends on the language of the Moodle site as selected by a particular student. One thing I could do is add to the STUDENT record a field specifying the chosen language. That isn't hard and can go on my TODO list. But you will have to implement your own language translations. There's really no way of avoiding that in general since the combinator grader gives complete control to the question author and I wouldn't wish to constrain it to use only strings from the Moodle language-string set.

Question (2): the fact the result table was printed when all rows were empty was a bug, which was fixed in May 2021 by Matthew Toohey. The updated code is on github but hasn't yet been released to the Moodle plugin repository.  I hope to do that some time this week.


Ca răspuns la Richard Lobb

Re: Combinator Graders and the Show Differences button

de către Andrzej Wójtowicz-

> One thing I could do is add to the STUDENT record a field specifying the chosen language. That isn't hard and can go on my TODO list.

This would be sufficient.

> The associated JavaScript looks in the result table header for the values of 'Expected' and 'Got' in whatever language Moodle is currently running.

I have one more thought on this issue. Assuming that the template grader generates the table header for the student in his language (e.g. English), then the teacher with another language set (e.g. Polish) would have to change the language to English to display the 'Show Differences' button. A more convenient solution would be to extend the returned JSON with some parameter (similar to testresults, columnformats, etc.) indicating the column indexes to be always treated as 'Expected' and 'Got' for the JavaScript displaying the button. In this situation, automatic detection is rigidly overridden. Of course all returned messages are still in the language that the student has set, but this problem is probably not solvable and is not particularly troublesome.

Ca răspuns la Andrzej Wójtowicz

Re: Combinator Graders and the Show Differences button

de către Richard Lobb-

Thanks for the suggestion. You're right that extending the returned JSON in that way would be a more general solution. However, it does add further complication to what's already a rather complicated interface. The Show Differences button should still be displayed to the teacher with the current interface (assuming the showdifferences attribute is set). However it won't actually work if the teacher's language is different from the student's because the specified column headers won't be present. But does that really matter? I don't recall ever using the Show Differences button when reviewing student's submissions.

If you really do want to use it, logging in as the student (using the Log in as...) function in Moodle is probably the best way. That way you see exactly what the student sees, not some partially translated version.