No 'got' column for println

No 'got' column for println

de Anton Dil -
Número de respuestas: 2

I've written a question which results in a println() when students get it wrong. However, the output only shows an 'expected' answer and not a 'got' answer in this case. I'd rather not have to add some fixed text like 'answer:' to the output. How else could we have a 'got' column in this case?

Thanks!

En respuesta a Anton Dil

Re: No 'got' column for println

de Richard Lobb -

CodeRunner suppresses display of empty columns in the results table. That's why you don't see a "Test" column with write-a-program questions nor an "Input" column when there's no standard input in any of the tests. It sounds like this behaviour is what's troubling you but I don't fully understand your situation nor the use case.

You say the Expected column is showing but not the Got column. This puzzles me. If there is output only when there's an error, why is the Expected column not blank, too?

I take it the output is being generated by your test code not from the student's code? In such cases I usually have the test print OK, and make that the Expected value.

If I'm misunderstanding the test environment and you really do need to display an empty column, you could achieve this by using the column specifiers to specify html format (%h) and have your test code print, say '<span></span>' when there were no errors. You'd probably also want to change the column header to something like 'Errors' rather than 'Got', too. But this is all sounding rather convoluted. Are you sure there's not an easier way to frame your tests?

En respuesta a Richard Lobb

Re: No 'got' column for println

de Anton Dil -

Thank you Richard, you've made me rethink the question, which had something like this in the Preload box.

System.out.println( //student's answer here// );

If the student just presses Check straightaway, we get System.out.println(); , which of course produces "\n" (not empty). The Got column was then empty, while the expected column showed the expected output.

I've now rearranged this so that the println appears in the test case, and that works out fine. I'm assuming that "\n" is stripped from the output.