numbas / Numbas

A completely browser-based e-assessment/e-learning system, with an emphasis on mathematics
http://www.numbas.org.uk
Apache License 2.0
198 stars 118 forks source link

An empty 'marks' field should default to 0 #979

Closed christianp closed 1 year ago

christianp commented 1 year ago

At the moment, it seems that leaving the field completely empty leads to the part's marks attribute being the empty string, which then produces NaN credit when the part is submitted.

likileads commented 1 year ago

Hi @christianp I wish to work on this issue. Can you please guide me where to get started with.

christianp commented 1 year ago

Hi @likileads, thanks for offering to help! First you should set up a development environment. There are some instructions at https://docs.numbas.org.uk/en/latest/development/installation.html.

Once you've done that, I think that adding a line like this.marks = this.marks || 0 to Numbas.Part.finaliseLoad would resolve this.

To test this, use the editor to create a question with a single part, and empty the "Marks" field. When you run the question, Numbas.exam.currentQuestion.parts[0].marks should evaluate to 0 instead of ''.