Custom feedback for question

13 views
Skip to first unread message

David Wishart

unread,
Oct 12, 2022, 11:54:54 AM10/12/22
to Numbas Users
I have a "Choose several from a list" question that uses custom feedback. I've linked to a cut down version below.


It was written about 3/4 years ago and used to work (and indeed if I load up an old exam package it still does) but no longer works with the feedback script that I have if I generate a new version of the exam. I'm guessing that I'm using something that has been deprecated between whatever version of Numbas that I wrote this with and the current version.

If I comment out my script so it doesn't run then the question works albeit I don't get the custom feedback. With the script I see the correct red/green underlining of the answers but no marks are awarded. The script I'm using is below. 

this.calculateScore()
if(this.score==2){
   this.markingComment('Your answer is correct.')
   this.markingComment('Both quadrants are correct.')
} else if (this.score==1){
   this.markingComment('Your answer is partially correct.')
   this.markingComment('Only one of your quadrants is correct.')
} else {this.markingComment('Both of your quadrants are incorrect')}

I'm guessing that this.score is no longer used (at least in this format) as this always zero but what do I replace it with?

Christian Lawson-Perfect

unread,
Oct 20, 2022, 10:27:35 AM10/20/22
to numbas...@googlegroups.com
Thanks for reporting this.
When I added in the backwards-compatibility code to continue supporting questions which had javascript marking scripts, I didn't consider the case that both the built-in marking script and your custom one would produce feedback items. I've fixed the code to combine the two sets of feedback, and I think your question now works as intended. Please give it a go and tell me if it's not right.

--
You received this message because you are subscribed to the Google Groups "Numbas Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to numbas-users...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/numbas-users/98b1495a-f07c-4d01-ad52-b2e7d8ffe67bn%40googlegroups.com.

David Wishart

unread,
Oct 20, 2022, 1:34:05 PM10/20/22
to Numbas Users
Hello Christian,
Thanks for your reply, it now runs but it is still not picking up this.score correctly, it has this as zero regardless.

Christian Lawson-Perfect

unread,
Oct 26, 2022, 8:47:06 AM10/26/22
to numbas...@googlegroups.com
Oh, you're right! I didn't look closely at the feedback it was producing, just that the final score was correct.
I think it will be really tricky to make this work how it used to.
How many questions like this do you have? If you don't have too many, then I think the best thing is to replace the javascript with a JME marking algorithm. Here's a modified 'mark' note which does what you want:

mark:
  apply(base_mark);
  switch(
    total_score = 2/2,
      positive_feedback("Both quadrants are correct."),
    total_score = 1/2,
      feedback("Only one of your quadrants is correct.")
    , // otherwise
      negative_feedback("Both of your quadrants are incorrect.")
  )

David Wishart

unread,
Oct 26, 2022, 12:06:14 PM10/26/22
to Numbas Users
Thanks that works. I'll have quite a few questions using javascript marking algorithms (although not that many distinct algorithms) but I do have archived SCORM packages for old exams so this will only show up if I am regenerating a new exam from old questions (which was the case here). I'll just need to rememeber to check for any scripts whenever I do this. Weaning myself off javascript marking algorithms and onto JME ones has been on my things to do list for a several years now (as you have repeatedly advised me to do!) so this can be my motivation to update them as I go along.
Reply all
Reply to author
Forward
0 new messages