Prettify 2D-lists (and dictionary output) #6002
-
When working with dictionaries, the default output in Dodona is quite ugly:
While I would prefer:
The same is true for 2d lists: Now it shows: >>> transponeer([[6, 7, 6], [3, 7, 7], [7, 6, 4], [7, 4, 3]])
[[6, 3, 7, 7], [7, 7, 6, 4], [6, 7, 4, 3]] While I would prefer: >>> transponeer([[6, 7, 6],
[3, 7, 7],
[7, 6, 4],
[7, 4, 3]])
[[6, 3, 7, 7],
[7, 7, 6, 4],
[6, 7, 4, 3]] I know I can write the custom oracle function where the output can be formatted. But are there already some example oracles ready where this is already implemented? Or is there another way to realize this easily? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Pretty printing of (nested) collections is on our roadmap for the TESTed judge: dodona-edu/universal-judge#350. Once implemented, pretty printing should ideally come automatically. So should not be a concern of exercise authors. We once had this feature in our Python judge, with a result exactly like you’ve shown. We removed it as its implementation did not blend well with other features whose responsability moved from the judge to Dodona (diffing of expected and actual output, syntax highlighting). If done well, it definitely helps students in finding differences between actual and expected return values. |
Beta Was this translation helpful? Give feedback.
-
Small follow-up question: Now I used a custom oracle to format the output as follows: Can I also format the expression? (in a yaml TESTed plan) |
Beta Was this translation helpful? Give feedback.
In addition to an
expression
or astatement
you can also add adescription
to a testcase. Theexpression
/statement
is what will be evaluated/executed. Thedescription
is what will be shown to the student when generating feedback.Try adding a
descripton
with a multiline string to see if that works. Since the description is not parsed, it should not change, but you will loose the syntax highlighting. You can format thedescription
using the Python syntax highlighter with(I haven't check whether the …