Removing unused grade items

Removing unused grade items

by Gordon Bateson -
Number of replies: 2
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Dear all,
my question concerns the gradebook in Moodle 1.9 and later:

spacer.gif

Should a module remove the grade item for an activity
if the grade for that activity will always be zero?

I am particularly interested in the HotPot module (yay!), but the question definitely applies to the Quiz module and the Glossary module too, and probably some other modules.

When these modules create an instance of the activity, they all call a function called something like "modulename_grade_item_update()". This function sets up some parameters and then calls the standard "grade_update()" function.

If the activity always has a grade of zero, e.g. $glossary->scale==0 or $quiz->grade==0 or $hotpot->grade==0, then these modules all use the following parameter setting:

  • $params['gradetype'] = GRADE_TYPE_NONE;

As a result, no grade item is created for the activity. Fair enough, so far.

Later on the activity may be edited and a non-zero grade becomes possible. The modules then use the following parameter setting:

  • $params['gradetype'] = GRADE_TYPE_VALUE;

At this point a grade item activity gets created. Great! That's what we would want.

But what happens if the activity is then edited again and the grade set back to zero? The "modulename_grade_item_update()" will again set "gradetype" to GRADE_TYPE_NONE and call "grade_update()", but the grade item will not be deleted from the gradebook and as a result the gradebook contains an entry for an activity that can only ever get a zero grade.

It seems to me that this could be confusing to the teachers. They may not remember or know the history of how an activity came to have a zero grade. They will just see that where one Quiz/Glossary/HotPot has a zero grade and no gradebook entry, another Quiz/Glossary/HotPot has a zero grade and does have an entry in the gradebook.

Does anyone know why we allow these activities which initially had a grade but later were edited to receive no grade, to remain in the gradebook?

thanks in advance
Gordon

Average of ratings: -
In reply to Gordon Bateson

Re: Removing unused grade items

by Gordon Bateson -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
After further investigation, I have clarified my understanding of how the "update_grade()" function (in lib/gradeslib.php) works.

It is indeed the case that this function does not initially create grade items for which gradetype=GRADE_TYPE_NONE. That's OK. It will create grade items if gradetype later changes to GRADE_TYPE_VALUE and that's OK too. However, it will not then remove the grade item if the gradetype later changes back to GRADE_TYPE_NONE. It is that final behavior which I think could lead to confusion.

There may be a good reason why the grade item is not deleted. Perhaps it has something to do with a teacher changing other settings on the grade item itself. However, from my limited understanding of how things work, there seems to be no need for these zero-grade grade items.

I would like to propose that the "update_grade()" be modified to remove these unwanted and possibly confusing grade items. This could be achieved by adding the following lines at line 94 in lib/gradelib.php:

if (grade_item && isset($itemdetails['gradetype']) && $itemdetails['gradetype']==GRADE_TYPE_NONE) {
$itemdetails['deleted'] = true;
}

However, probably we should also create a function (in lib/db/upgrade.php ?) to tidy up the grade items and remove any zero-grade grade items. I don't think I have time to rise to that challenge at the moment.

So for the time being, I will modify the HotPot module so that teachers can force the removal of the grade item if they set the maximum grade for a HotPot activity to zero.

thanks for reading!
Gordon