moodle-mod_hvp
moodle-mod_hvp copied to clipboard
Grades on H5P activities not recovered when re-enrolling a student
DESCRIPTION A student completes H5P activities in a course. The student is then un-enrolled from the course. Later, the student is re-enrolled into the course. During re-enrollment the option "Recover user's old grades if possible" is selected. Grades for other types of activities like quiz and assign are recovered from grade history, but the H5P grades are not recovered.
STEPS TO REPLICATE
- Create a new course and enroll a user into the course as a student.
- Create a new H5P interactive content activity to the course.
- Configure any gradable content type, such as Drag the Words.
- Create a quiz activity with a single multiple choice or true/false question.
- Login as the student and complete both the quiz and the H5P activity.
- As an instructor, confirm that a grade for the user is displayed in the gradebook for each activity.
- Delete the student's enrollment from the course.
- Re-enroll the user and ensure that the "Recover user's old grades if possible" option is selected.
- Return to the gradebook.
OBSERVED BEHAVIOR: No grade appears for the H5P activity for the re-enrolled student. The student's grade for the quiz is displayed.
EXPECTED BEHAVIOR: The student's previous grade for both the quiz and H5P activity are displayed in the gradebook following re-enrollment.
REPLICATION LOCATIONS Moodle 3.5.3 with version 2019031301 of mod_hvp Moodle 3.6.3 with version 2019052100 of mod_hvp
ADDITIONAL INVESTIGATION NOTES After re-enrollment the student's score is also no longer displayed on the H5P results page either. The student's last attempt is still stored in the mdl_hvp_xapi_results. This data is not removed during un-enrollment and is undisturbed during re-enrollment.
The query used in function grade_recover_history_grades in /lib/gradelib.php to retrieve grades from grade history if ran manually before the user is re-enroll is able to return the H5P grades from grade history. The mdl_grade_grades_history actually shows the H5P grade being re-created, but then immediately afterwards there is an update from the H5P plugin and the recovered grade is removed.
This query can be used return the grade history.
select gi.itemtype, gi.itemname, gi.itemmodule, ggh.action, ggh.source,
ggh.finalgrade, from_unixtime(ggh.timemodified) grade_modified from mdl_grade_grades_history ggh
inner join mdl_grade_items gi on gi.id = ggh.itemid
where gi.itemmodule = 'hvp'
and gi.courseid = <enter courseid>
and ggh.userid = <enter userid>
order by gi.sortorder, ggh.id;
Example output with explanation:
itemtype|itemname|itemmodule|action|source|finalgrade|grade_modified|notes
mod|Module 1 activity|hvp|1||mod/hvp|3.33333|2019-06-25 11:50:17|Grade created from student's initial attempt
mod|Module 1 activity|hvp|2|mod/hvp|10.00000|2019-06-25 12:06:43|Grade updated from student re-attempting activity
mod|Module 1 activity|hvp|3|userdelete|10.00000|2019-06-25 12:10:21|Grade deleted from student being un-enrolled
mod|Module 1 activity|hvp|1|userdelete|10.00000|2019-06-25 12:13:07|Grade created from student being re-enrolled
mod|Module 1 activity|hvp|2|mod/hvp|NULL|2019-06-25 12:13:07|Grade updated and removed by H5P module during re-enrollment
USER IMPACT If a user is un-enrolled and re-enrolled in a course, no H5P grades are recovered. The information is still available in grade history, but would have to be manually re-entered.
Thanks for the very well-defined issue and extra information, it will surely help us expedite this at a quicker rate. I have created an issue for it in our public issue tracker: https://h5ptechnology.atlassian.net/browse/HFP-2779.
I had a quick look at it, and it looks like this is failing because hvp_update_grades()
in hvp/lib.php does not check if the grade is already set before resetting the grade, it only looks at the third parameter $nullifnone
, and resets the score if that is true.
We should check if there already exists a grade using something like:
SELECT gg.rawgrade
FROM mdl_grade_items gi
JOIN mdl_grade_grades gg ON gg.itemid = gi.id
WHERE gi.iteminstance = {$hvp->id}
AND gg.userid = {$userid}
and if it already exists, we should not set rawgrade to null, but rather send in the found grade to hvp_grade_item_update($hvp, $grade)
.
Is there an update on this issue? We are still having reports from clients that this issue is still occurring.
Hi! same here teachers are still reporting this issue in Moodle 3.9. Any idea when you plan on fixing this H5P team?
It's a pretty important usability bug...
Best Camille
Hi,
Is there any update of this bug?
Rehan Amjad
Hi guys,
We wrote a fix for this. I don't have time to do a proper submit of the fix. So here it is, it is a just one function. Bare in mind that this was done for the plugin HVP version 2022012000.
This is the rewrite in the lib.php file, the function hvp_update_grades (line 430) :
function hvp_update_grades($hvp=null, $userid=0, $nullifnone=true) {
global $DB;
if ($userid and $nullifnone) {
//first check if a grade exist in plugin table history before setting to null
$rawgrade=null;
//fix recover grades for re-enrol user
if($hvp!=null){
//get history from table hvp_xapi_results if exist return rawgrade value
$record = $DB->get_record('hvp_xapi_results', array('user_id' => $userid,'content_id' => $hvp->id));
if($record){
//to force hvp_grade_item_update($hvp, $grade) to recalculate proper scaled grade and import as final grade
$hvp->rawgrade = $record->raw_score;
$hvp->rawgrademax = $record->max_score;
}
}
$grade = new stdClass();
$grade->userid = $userid;
$grade->rawgrade = $rawgrade;
hvp_grade_item_update($hvp, $grade);
} else {
hvp_grade_item_update($hvp);
}
}
Hope this helps.
Best Cam