"Reward" for correct solution

"Reward" for correct solution

by Tilman Schieber -
Number of replies: 7

TLDR: I need the easiest way to present a text snippet to the student once all tests pass.

I love Coderunner and most of the questions in my python course now use it.

We are using a gamification concept (using the stash plugin) and students get little collectible rewards (coins) when they successfully solve certain questions.

What I need to do is to show a shortcode to them, i.e. 

[stashdrop secret="5Fx4vL" text="Take coin" image]

For all other question types that is no problem but as there is no specific feedback field in CR and the general feedback does not work I found no way to accomplish this.
I have searched in this forum and found related discussions that all lead to some very complicated solutions.
Before I look into this, I would like to confirm if it is really necessary to code custom test evaluation or question templates to accomplish this goal.


In reply to Tilman Schieber

Re: "Reward" for correct solution

by Richard Lobb -
I think General Feedback does work, but because CodeRunner forces an adaptive mode, students don't get to see the feedback until after they've submitted the quiz. See https://www.google.com/url?q=https://moodle.org/mod/forum/discuss.php%3Fd%3D386755&sa=U&ved=2ahUKEwjcsf7xjeWDAxUonK8BHSPkDwwQFnoECAYQAg&usg=AOvVaw03h-be_Jsfva-e-TmqDgBz

However, if you enable the Stop button, students get to see the general feedback when they click it. You might be able to use that (though it's not what it was intended for)?
In reply to Richard Lobb

Re: "Reward" for correct solution

by Tilman Schieber -

Thank you for you answer, Richard.

The general feedback might work when the question is used as part of a quiz, however I am embedding the questions using the embed_questions filter and the feedback is not shown in this case.

There also is not visible stop button as far as I can see.

I will probably have to rethink this and put the coderunner questions in a quiz so I can give proper feedback.


Regards

Tilman

In reply to Tilman Schieber

Re: "Reward" for correct solution

by Tilman Schieber -
What I am trying to do now is to get a custom grader that runs all tests exactly like the normal grader does but adds the shortcode at the end so after all testcases pass, it shows the reward.
I added the key 'prologuehtml' with value `[stashdrop secret="5Fx4vL" text="Take coin" image]` to the output dict that returns the custom grader results but it always aborts with an error.

Is there a way to see the json return of the default grader so I can modify it to just add one line of text?
In reply to Tilman Schieber

Re: "Reward" for correct solution

by Richard Lobb -
Firstly, regarding your previous posting, the stop button is shown only if you turn it on in the question authoring panel, assuming you have a sufficiently up-to-date version of coderunner (November 2021 or later). It works in embedded questions as well as quiz questions. You'd want to set it to "Available once mark cannot be improved", which would be true once they had passed all tests. However, you'd need a penalty regime that never took their mark to zero, e.g. 0, 10, 20, 30, 30, ... I think that would work but the UI is poor: "Stop and read feedback" doesn't sound like it means "Please give me my reward now". You'd have to explain that to the students in advance.

It sounds like you're trying to use a combinator grader output, which is the "correct" solution. But it does take a fair bit of work as you have to build the result table yourself. The python3_stage1 question type has a ResultTable class that you could use. But you can't just tweak the default grader.

Another much easier option might be to have a final test case that always passes and that displays the reward. Then set all other test cases to "Hide rest if fail". That way the final row of the result table will given them their reward. They'll only get to see the first failing case but we often do that anyway.

In reply to Richard Lobb

Re: "Reward" for correct solution

by Tilman Schieber -

Thanks for your answer. I am not sure if a combinator grader would even accomplish what I want.

What I need is a feedback field that -- like the feedback of normal moodle questions questions -- gets processed by moodle's filters. That's necessary so the stash filter can convert the shortcode to the icon&button to pick up the reward.

> Another much easier option might be to have a final test case that always passes and that displays the reward. 

Perhaps I am missing something but the reward is a moodle shortcode for a stash item. I can display the code as a string but that won't pass through the moodle filter that converts it to a gold coin the students can pick up. 


In reply to Tilman Schieber

Re: "Reward" for correct solution

by Richard Lobb -
Ah, I see. I've never used the stash filter so I didn't appreciate your problem.

You're right that in the version of the code currently in the Moodle plugin repository the specific feedback for a CodeRunner question isn't being passed through Moodle filters. That will affect both the combinator grader output and the simple approach of having a final test case that displays the reward. This bug has been fixed in the version on github but hasn't been pulled into the Moodle repository.

So I think you're right that the only clean way at present is to use a quiz rather than embedded questions, or to use the Stop button and accept the confusing name for the button ("Stop and read final feedback"). I suppose could put some JavaScript in the page to change that button text but that's pretty ugly.
In reply to Richard Lobb

Re: "Reward" for correct solution

by Tilman Schieber -

It's fine I can come up with a creative solution.
e.g. The result of the final test case is a password that must be entered in another embedded question
That question then displays the stash coin as feedback.

Thanks for the insights!