## Certificate (plugin)

### linking a certificate to a sco

This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.
linking a certificate to a sco

Are there any problems in having completion of a sco as a linked dependancy? Or is it possible?

Average of ratings: -
Re: linking a certificate to a sco
I have a course in which getting the certificate is dependent on 14 SCORM activities achieving a certain score on each one. It work s fine except for one item I mentioned in a previous post. If I manually edit those score then the certificate will not display even though the student gradebook shows the student having met all requirements. Still haven't found a solution to that one.

Dave

Average of ratings: -
Re: linking a certificate to a sco
in the certificate lib file, try replacing this code:

} else if ($cm->module ==$scormid) {
require_once($CFG->dirroot.'/mod/scorm/locallib.php');$scorm = get_record('scorm', 'id', $cm->instance);$score = scorm_grade_user($scorm,$userid);
if (($scorm->grademethod % 10) == 0) { // GRADESCOES if (!$scorm->maxgrade = count_records_select('scorm_scoes',"scorm='$scormid' AND " . sql_isnotempty('scorm_scoes', 'launch', false, true))) { return NULL; } } else {$return->maxgrade = $scorm->maxgrade;$grade = (int)(((float)$score / (float)$scorm->maxgrade) * 100.0);
return ($grade >= (int)$activity->linkgrade);

with this:

} else if ($cm->module ==$scormid) {
require_once($CFG->libdir.'/gradelib.php');$grading_info = grade_get_grades($cm->course, 'mod', 'scorm',$cm->instance, $userid); if (empty($grading_info)) {
return false;
}
$grade =$grading_info->items[0]->grades[$userid]->grade; return ($grade >= (int)$activity->linkgrade); Average of ratings: Useful (1) Re: linking a certificate to a sco Thanks Chardelle. I tried that code and when I went to access the Certificate activity the page did not load at all. All I saw was a white window with nothing on it or in it (and no error message). Dave Average of ratings: - Re: linking a certificate to a sco I should have included the last } after the return in the top code. If you have an extra one there, delete it. It should look like this: return (get_record('survey_answers', 'id',$cm->instance, 'userid', $userid) !== false); } else if ($cm->module == $scormid) { require_once($CFG->libdir.'/gradelib.php');
$grading_info = grade_get_grades($cm->course, 'mod', 'scorm', $cm->instance,$userid);
if (empty($grading_info)) { return false; }$grade = $grading_info->items[0]->grades[$userid]->grade;
return ($grade >= (int)$activity->linkgrade);

} else if ($cm->module ==$lessid) {

Average of ratings: Useful (1)
Re: linking a certificate to a sco
That fixed it. Thanks!!

Dave

Average of ratings: -
Re: linking a certificate to a sco

Does this resolve this issue with the certificate module not recognizing the 100% gradebook score of a completed SCORM activity? It works with quiz dependency only. See screenshot.

Average of ratings: -
Re: linking a certificate to a sco

I'm also wondering if this fixes the issue that Tristan referenced above.  Anybody figure it out?  I'm still in 1.9 and the certificate won't work with SCORM pieces (multiple).

Thanks, Bill

Average of ratings: -
Re: linking a certificate to a sco

I modified my certificate lib.php file and it still doesn't work with the Quiz activity.  I attached screenshots and a copy of my lib.php file.

Once I get it working with teh quiz activity, I will try it with the SCORM activity.

Average of ratings: -
Re: linking a certificate to a sco

I noticed that the code i replaced was referencing the SCORM activity type.  If I'm having troubles with manual grades for quiz activity types, shouldn't we tweak the code below?

if ($cm->module ==$quizid) {
require_once($CFG->dirroot.'/mod/quiz/locallib.php');$quiz = get_record('quiz', 'id', $cm->instance);$score = quiz_get_best_grade($quiz,$userid);
$grade = (int)(((float)$score / (float)$quiz->grade) * 100.0); return ($grade >= (int)$activity->linkgrade); Average of ratings: - Re: linking a certificate to a sco I did a little more research, mostly because I'm bored while I sit here on a Saturday and watch "Intervention" on netflix, lol. SOURCE OF PROBLEM???: The function, quiz_get_best_grade, looks in the table, "quiz_grades". This table is not populated if we manually enter grades into the gradebook. To verify this, I searched for a user that has never taken a quiz, but has data manually entered in his gradebook. That user doesn't have any entries in the table, "Quiz_Grades". SOLUTION???: The table "grade_grades" is populated with quiz data, whether it's typed into the gradebook or comes from a user completing the quiz. Could we may$grade = finalgrade / rawgrademax (both from the grade_grades table)?  I wish there was a value that is the same, whether the grade was entered into the gradebook or if it was populated by a user completing the quiz manually.

What do you all think?

Also, last Q for the day:  I looked at the function, "grades_get_grades".  In the comments it says the following:
335  * Manual, course or category items can not be queried.

Does this mean that this function can't be used to gather grades for manually entered grades, and would this explain why the code insert didn't work for me?

thank you all for your help.  let me know if you need me to give you any more information.

Average of ratings: -
Re: linking a certificate to a sco

Hey guys,

There is an open issue regarding this problem: http://server3.moodle.com/browse/CONTRIB-2760

Could you please upload your patches?

Thanks,
Maiquel

Average of ratings: -