Checking student answer correct for currency


I’m using this code:

check3= when this.latex="\pounds 64.75" 1 otherwise 0
correct: check3=1

to check a students answer is correct including the “£” sign. However this latex doesn’t seem to work as its marking a correct answer as incorrect.

Am I missing something?


Using simply this.latex="£64.75" seems to do the trick, as far as I can tell.

It was giving an incorrect mark when I used that as if the student puts a space at the start or end it marks it incorrcect


check3= when this.latex=\pounds 64.75 1 otherwise 0
correct: check3=1

doesn’t work

Why aren’t the single quotes showing?

To display your CL code correctly in this forum use triple backticks on the line before and after your code:

check3= when this.latex=`\pounds 64.75` 1 otherwise 0
correct: check3=1

But that is true of any attempt to match latex to an exact string, is it not? That is not unique to having the £ symbol.

It is a shame that you cannot do wildcard/regex matching, to match this.latex to “£*” for example and use countNumberUsage / numericValue to check the value. Maybe doable with pattern matching?

Actually no. Matching a string must be exact, while latex will resolve extra spaces and whatnot. However, I think in this case /pound is not supported.

In another situation (for evaluating a function that wasn’t supported in CL, but worked in graph), I have converted a student’s latex into text and then used that text. Maybe that strategy will work here? Like this?

when "${this.latex}"="\pounds64.75"

Ah, useful to know - thanks.

Does not seem to work, unfortunately. (Nor ="£64.75")

Again probably doesn’t work because the special character isn’t recognized. Maybe with a text input, but then that wouldn’t yield correctness on the dashboard.

If it recognises the £ through strict text matching (which it does) then maybe on this occasion, it will just have to be a series of ors to accommodate students maybe introducing a space at the start or end or between.

check=this.latex="£64.75" or this.latex=" £64.75" or this.latex="£ 64.75" or ...