Workshop Grades Not Appearing in Grades Report in Moodle 1.9

Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by Phil Ventura -
Number of replies: 12
Hi all,

I just upgraded to Moodle 1.9 (from 1.8) this morning. However, when I went to view the grades in the grade report the first thing I noticed was that the workshop names were not carried over to the grade report. So, I clicked the synchronise from legacy button, now the names appear but the grades have still not been brought over.

--Phil
Average of ratings: -
In reply to Phil Ventura

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by Lael ... -
I'm having a similar problem.

Anyone know how to get workshop grades into the 1.9 gradebook? ...

is workshop officially unsupported core now? (ie - will vanish in time or continue to atrophy to a state of unusability?)

Lael
In reply to Lael ...

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by e klopfer -
I'm running into the same problem. Now at the end of the semester I notice that all of my workshop grades come up empty in 1.9.

Has anyone figured out a solution?
In reply to e klopfer

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by Phil Ventura -
Ok, so I figured out a fix. In the file moode/lib/gradelib.php, in the function named grade_update, down near the end of the function is the code:
if (empty($g['userid']) or ($k != $g['userid'])) {
 debugging('Incorrect grade array index, must be user id! Grade
 ignored.');
Add this code before the code above:
 if (!empty($g['userid']) and ($k != $g['userid'])) {
 debugging('Reindexing!');
 if (array_key_exists($g['userid'], $grades)) {
 debugging('Entry in $grades exists for uid ' . $g['userid']);
 }
 else {
 $grades[$g['userid']] = $g;
 }
 }
Once you've done that, then go to the gradebook and select Categories and items from the drop-down menu:
0406719f-4808-438f-b933-72da59f65395_b2a0292a-1d62-43cb-bfa1-5e98a7b714c9_static_0_0_2008-05-14_0839.png

Then, click the Synchronize legacy grades button:
9d38fcbf-9d04-4940-a8f1-22b2f085aa68_b2a0292a-1d62-43cb-bfa1-5e98a7b714c9_static_0_0_2008-05-14_0842.png

In reply to Phil Ventura

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by e klopfer -
Fantastic. That fix worked just fine.
In reply to Phil Ventura

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by Séverin Terrier -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Testers Picture of Translators
You should fill a bug report in the tracker (or find and existing one) and give the solution there smile

Séverin
In reply to Lael ...

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by John Isner -
will [it] vanish in time or continue to atrophy to a state of unusability?

Yes, unless someone volunteers to support it.
In reply to John Isner

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by David Monllaó -
I've written this code to be added to the workshop module so that the gradebook won't need to be synchronized in order to show its grades. The modification is for moodle 1.9.1 but I've reviewd the version changes file and it seems it haven't changed since 1.9.

I attach the lib.php to be overwritten (v 1.9.1). The modification is to be applied to mod/workshop/lib.php file.

2 new functions:

function workshop_grade_item_update($workshop, $grades=NULL){
global $CFG;
if (!function_exists('grade_update')) {
require_once($CFG->libdir.'/gradelib.php');
}

if (array_key_exists('coursemodule', $workshop)) {
$cmidnumber = get_field("course_modules", "idnumber", "id", $workshop->coursemodule);
$params = array('itemname'=>$workshop->name, 'needsupdate'=>1, 'idnumber'=>$cmidnumber);
} else {
$params = array('itemname'=>$workshop->name, 'needsupdate'=>1);
}

if ($workshop->visible == 0) {
$params['hidden'] = 1;
} else {
$releasetime = make_timestamp($workshop->releaseyear, $workshop->releasemonth, $workshop->releaseday, $workshop->releasehour, $workshop->releaseminute);
if($releasetime > time()){
$params['hidden'] = $releasetime;
}
}

if ($workshop->gradingstrategy == 0 OR ($workshop->grade == 0 AND $workshop->gradinggrade == 0)) {
$params['gradetype'] = GRADE_TYPE_NONE;
} else {
$params['gradetype'] = GRADE_TYPE_VALUE;
$params['grademax'] = $workshop->grade + $workshop->gradinggrade;
$params['grademin'] = 0;
}

if ($grades === 'reset') {
$params['reset'] = true;
$grades = NULL;
}

return grade_update('mod/workshop', $workshop->course, 'mod', 'workshop', $workshop->id, 0, $grades, $params);
}

function workshop_grade_item_delete($workshop) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');

return grade_update('mod/workshop', $workshop->course, 'mod', 'workshop', $workshop->id, 0, NULL, array('deleted'=>1));
}


And a modification in add/update/delete module instance functions:

In function workshop_add_instance (+/- line 140) you find

add_event($event);
}


After that, and before the return it should be added:

$workshop = stripslashes_recursive($workshop);
$workshop->id = $returnid;
workshop_grade_item_update($workshop);



In function workshop_update_instance (+/- line 917) where you find

if (time() > $workshop->assessmentstart) {
// regrade all the submissions...
set_field("workshop_submissions", "nassessments", 0, "workshopid", $workshop->id);
workshop_grade_assessments($workshop);
}


This should be added before the return

$workshop = stripslashes_recursive($workshop);
workshop_grade_item_update($workshop);



In function workshop_delete_instance (+/- line 512) you find

if (! delete_records('event', 'modulename', 'workshop', 'instance', $workshop->id)) {
$result = false;
}


The following should be added:

workshop_grade_item_delete($workshop);



In reply to David Monllaó

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by Lenka Orzelova -
We have Moodle 1.9.3+ and this fix doesn´t work sad
In reply to Lenka Orzelova

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by Mat Cannings -
Same problem here [Moodle 1.9.3+ (Build: 20081029)], fixed by doing both
the post by Phil Ventura on Wednesday, 14 May 2008, 09:02 PM ( #p429094 )
and the post by David Monllaó - Tuesday, 1 July 2008, 08:09 PM ( #p443664 )

My many thanks to both Phil and David
In reply to Mat Cannings

Re: Workshop Grades Not Appearing in Grades Report in Moodle 1.9

by Mat Cannings -

I have been patching in this fix for the last few upgrades but have just upgraded to 1.9.5+ (with the new gradebook) and have noticed a new problem and wondered if anyone else has experienced it.

Some of the workshops that have been used allow for resubmission, previously I could press the synchronise legacy button and it would update the value in the grade book but this does not seem to work with the new grade book.

Has any one else experienced any difficulties with resubmissions?