Having a hard time with a custom marking algorithm

已查看 20 次
跳至第一个未读帖子

Andreas Vohns

未读,
2020年12月17日 01:17:282020/12/17
收件人 Numbas Users
This is in regards to this expplore mode question (which is in German, sorry):

What I am trying to do is in Part 1 the studnet might enter a whole number betwenn 10,000 and 1,000,000 and if this is entered correctly, the xplore mode should switch a predifend random value with the students answer.

Tihs works just fine in case the student enters a number from that range, but fails with an error saying: "
  • There was an error in this part's marking algorithm. Please report this. Error evaluating variable mark: Cannot read property 'type' of null

this is the custom marking algorithm I am using:

mark:
     assert(interpreted_answer[0] >10000,
         fail("Bitte größer als 10000!"));
     assert(interpreted_answer[0] <1000000,
         fail("Bitte kleiner als 1000000!"));
     assert(interpreted_answer[0] = floor(interpreted_answer[0]),
         fail("Bitte nur ganzzahlige Angaben!"));
     if(interpreted_answer[0] > 10000 and interpreted_answer[0] < 1000000,assert(floor(sqrt(interpreted_answer[0])/100) <> sqrt(interpreted_answer[0])/100,
     fail("Diese Zahl hat eine durch 100 teilbare Wurzel ("+sqrt(interpreted_answer[0])+"), daher wird der Zufallswert ("+square+ ") verwendet.")));
     if(interpreted_answer[0] > 10000 and interpreted_answer[0] < 1000000,add_credit(1,"Ihre Zahl ("+interpreted_answer[0]+") ist im passenden Bereich und wird verwendet."),fail("Zahl außerhalb des zulässigen Bereichs, Zufallswert wird verwendet."))

Andreas Vohns

未读,
2020年12月17日 01:18:192020/12/17
收件人 Numbas Users

Ulrich Goertz

未读,
2020年12月17日 04:14:512020/12/17
收件人 Numbas Users
I only took a quick look but I think the problem is that you have custom marking algorithms for both the gap and the part, and for an answer outside the desired range the marking algorithm for the gap returns null, which causes the complaint in the part's marking algorithm. Probably it would suffice to only have a custom marking algorithm for the gap, and move the handling of correct answers there.
Best, Ulrich

Andreas Vohns

未读,
2020年12月17日 04:39:222020/12/17
收件人 Numbas Users
Thanks for taking a look at it. I moved the marking algorithm to the gap and also tried to substitute interpreted_answer to studentnumber:

mark:
     assert(studentnumber >10000,
         fail("Bitte größer als 10000!"));
     assert(studentnumber <1000000,
         fail("Bitte kleiner als 100000!"));
     assert(studentnumber = floor(studentnumber),
         fail("Bitte nur ganzzahlige Angaben!"));
     if(studentnumber > 10000 and studentnumber < 1000000,assert(floor(sqrt(studentnumber)/100) <> sqrt(studentnumber)/100,
     fail("Diese Zahl hat eine durch 100 teilbare Wurzel ("+sqrt(studentnumber)+"), daher wird der Zufallswert ("+square+ ") verwendet.")));
     if(studentnumber > 10000 and studentnumber < 1000000,add_credit(1,"Ihre Zahl ("+studentnumber+") ist im passenden Bereich und wird verwendet."),fail("Zahl außerhalb des zulässigen Bereichs, Zufallswert ("+square+ ") wird verwendet."))

However, this still throws me an error when the number ist not in the desired range (Error when computing the mark note: Error evaluating variable mark: Cannot read property 'type' of null).

Andreas Vohns

未读,
2020年12月17日 05:00:342020/12/17
收件人 Numbas Users
Okay, I think I have fixed it myself: The trick was moving the base algorithm into the extended field and then moving some parts around inside the base algorithm itself, now everything works as intended: 
Something within the "numberInRange"-Part seems to have conflicted with the "mark"-part...

Christian Lawson-Perfect

未读,
2020年12月17日 05:05:522020/12/17
收件人 numbas...@googlegroups.com
In the marking algorithm for the gap-fill part, your first if statement has no 'else' case. Numbas should have caught that, but adding any value for the else case, or changing the if to an assert, fixes the problem.

In fact, you don't need those if statements at all: they're repeating the checks that you did in the previous lines, so if the test is not satisfied then any following feedback won't be applied anyway. And as Ulrich said, you don't need to do this twice: just doing the check in the marking algorithm for the number entry gap would suffice.

I prefer to have separate marking notes for each of the conditions I'm checking, to make the marking algorithm easier to debug in the editor. Here's a rearranged version of your gap-fill algorithm, complete with schoolboy German for the note names:

nicht_zu_klein:
  assert(interpreted_answer[0] >10000,fail("Bitte größer als 10000!"))

nicht_zu_gross:
  assert(interpreted_answer[0] <1000000,fail("Bitte kleiner als 1000000!"))

ist_ganzzahl:

  assert(interpreted_answer[0] = floor(interpreted_answer[0]),
    fail("Bitte nur ganzzahlige Angaben!")
  )

hundert_kein_wurzelfaktor:

  assert(floor(sqrt(interpreted_answer[0])/100) <> sqrt(interpreted_answer[0])/100,
     fail("Diese Zahl hat eine durch 100 teilbare Wurzel ("+sqrt(interpreted_answer[0])+"), daher wird der Zufallswert ("+square+ ") verwendet.")
  )

mark:
  apply(nicht_zu_klein);
  apply(nicht_zu_gross);
  apply(ist_ganzzahl);
  apply(hundert_kein_wurzelfaktor);
  correct("Ihre Zahl ("+interpreted_answer[0]+") ist im passenden Bereich und wird verwendet.")

   


--
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/6d007e55-18bc-4418-87da-f1d0b1480905n%40googlegroups.com.

Andreas Vohns

未读,
2020年12月17日 05:09:392020/12/17
收件人 Numbas Users
No else statement seems like a really dumb error ... thanks a bunch!

Andreas Vohns

未读,
2020年12月17日 06:00:452020/12/17
收件人 Numbas Users
And by the way: Your German is spot on and the custom marking algorithm is a mighty powerful tool.
Having the checks in the algorithm twice and having the marking algorithm both within the gap and on the level above were both artefacts of me trying to solve the initial error (which, unfortnuately, was in the if-statement...).
So thanks again, I have been using NUMBAS this semester quite extensively in two of my courses (history of mathematics and an introductory course to discrete mathematics for pre-service math teachers), student feedback is really positive and I might use some NUMBAS examples in a remote exam in January, so I am very grateful for this powerful tool.

回复全部
回复作者
转发
0 个新帖子