From: John J. <jj...@as...> - 2005-07-14 16:24:47
|
This sounds like it is my fault since I changed field types from all being strings to being types related to what was being stored. What you suggest is probably the best course of action. I wonder if all instances of "" should be demoted to NULL, or if it should only be done for fields with type integer. Another possibility would be to revert part of my change so that integer types would not be used in the future which would avoid the promotion problem for courses created after that. John P Gavin LaRose wrote: >Hi all, > >In the course of adding the GatewayQuiz module to the HEAD branch in the >CVS, I've found that when I look at StudentProgress all student scores are >being reported as zero (regardless of how many correct problems they have >in the set). > >I think what's happening is that when we get NULL values out of the >database they are promoted to empty strings, but when we put an empty >string back into an integer field in the database that gets stored as >zero. > >In particular, when a set is assigned to a student the appropriate entries >in the problem_user table are created. For those the value field is set >to NULL. When we get() the problems out of the table (with >$db->{problem_user}->get()), the NULL is promoted to "", so that >$userProblem->value() is then the empty string. > >As the user problem is processed by Problem.pm (or GatewayQuiz.pm), >$userProblem->value() isn't changed. Then, when we put the problem back >into the database after grading (with $db->{problem_user}->put()), we're >putting an empty string into the integer value field, which is stored as >zero. > >When we then get the merged problem out again, $db->getMergedProblem() >checks for empty fields to decide whether to use the global problem's >value. However the entry in problem_user now has value == 0, so the >global problem's value (== 1) isn't used. This means that when >StudentProgress.pm (et al.) calculate the student's score (by taking >$userProblem->status() * $userProblem->value()), the score is zero. > >Does that sound right? If so, the work-around/solution may be to make >$db->{}->put() demote empty strings to NULL. Comments? > >Thanks, >Gavin > > > |