/** * Update grades in central gradebook * * @param object $offlinequiz the offline quiz settings. * @param int $userid specific user only, 0 means all users. */ function offlinequiz_update_grades($offlinequiz, $userid = 0, $nullifnone = true) { global $CFG, $DB; require_once $CFG->libdir . '/gradelib.php'; if ($offlinequiz->grade == 0) { offlinequiz_grade_item_update($offlinequiz); } else { if ($grades = offlinequiz_get_user_grades($offlinequiz, $userid)) { offlinequiz_grade_item_update($offlinequiz, $grades); } else { if ($userid && $nullifnone) { $grade = new stdClass(); $grade->userid = $userid; $grade->rawgrade = null; offlinequiz_grade_item_update($offlinequiz, $grade); } else { offlinequiz_grade_item_update($offlinequiz); } } } }
} $showing = 'grades'; } } $table = new html_table(); $table->head = $headings; $table->align = $align; // Populate the table with the list of instances. $currentsection = ''; foreach ($offlinequizzes as $offlinequiz) { $cm = get_coursemodule_from_instance('offlinequiz', $offlinequiz->id); $context = context_module::instance($cm->id); $data = array(); $grades = array(); if ($showing == 'grades') { if ($gradearray = offlinequiz_get_user_grades($offlinequiz, $USER->id)) { $grades[$offlinequiz->id] = $gradearray[$USER->id]['rawgrade']; } else { $grades[$offlinequiz->id] = null; } } // Section number if necessary. $strsection = ''; if ($offlinequiz->section != $currentsection) { if ($offlinequiz->section) { $strsection = $offlinequiz->section; $strsection = get_section_name($course, $offlinequiz->section); } if ($currentsection) { $learningtable->data[] = 'hr'; }