Following on from yesterday’s start of using the blog to record fixes to software, here comes another one.
Awarding a student a mark of 0 for a post, doesn’t work
Identify the cause
First, re-create the problem, log in and try and give the student a mark of 0 – yep doesn’t work.
Check the database, there is a mark of 0 recorded. However the textbox in which the mark should be displayed, is empty.
Let’s try changing it to a non-zero mark and then back again – I’m wondering if 0 is the default mark. Ahh, giving the student a mark of 5 and then changing it back to 0 results in the 0 appearing in the box. Seems to be some screwy code.
Looking further it seems that the following is happening
- A post’s database entry starts with a mark of 0 and a status of Submitted.
- When displaying this type of entry the 0.000 in the database is modified to the empty string by the view code.
I’m assuming this is to stop the marker thinking that a mark of 0 has already been awarded.
- The code processing the submitted form (i.e. I’ve entered a mark of 0 and hit submit) is comparing fields in form to data in database. If a mark of 0 is awarded in the form it will equal the default value in the database and hence not spark a change.
If the mark in the form is 0 and not empty, then a change must be made.