/** * Print warning about changed grades during upgrade to 2.8. * * @param int $courseid The current course id. * @param context $context The course context. * @param string $thispage The relative path for the current page. E.g. /grade/report/user/index.php * @param boolean $return return as string * * @return nothing or string if $return true */ function print_natural_aggregation_upgrade_notice($courseid, $context, $thispage, $return = false) { global $OUTPUT; $html = ''; $hidesubcatswarning = optional_param('seenaggregatesubcatsupgradedgrades', false, PARAM_BOOL) && confirm_sesskey(); $showsubcatswarning = get_config('core', 'show_aggregatesubcats_upgrade_' . $courseid); $hidenaturalwarning = optional_param('seensumofgradesupgradedgrades', false, PARAM_BOOL) && confirm_sesskey(); $shownaturalwarning = get_config('core', 'show_sumofgrades_upgrade_' . $courseid); // Do not do anything if they are not a teacher. if ($hidesubcatswarning || $showsubcatswarning || $hidenaturalwarning || $shownaturalwarning) { if (!has_capability('moodle/grade:manage', $context)) { return ''; } } // Hide the warning if the user told it to go away. if ($hidenaturalwarning) { hide_natural_aggregation_upgrade_notice($courseid); } // Hide the warning if the user told it to go away. if ($hidesubcatswarning) { hide_aggregatesubcats_upgrade_notice($courseid); } if (!$hidenaturalwarning && $shownaturalwarning) { $message = get_string('sumofgradesupgradedgrades', 'grades'); $hidemessage = get_string('upgradedgradeshidemessage', 'grades'); $urlparams = array('id' => $courseid, 'seensumofgradesupgradedgrades' => true, 'sesskey' => sesskey()); $goawayurl = new moodle_url($thispage, $urlparams); $goawaybutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get'); $html .= $OUTPUT->notification($message, 'notifysuccess'); $html .= $goawaybutton; } if (!$hidesubcatswarning && $showsubcatswarning) { $message = get_string('aggregatesubcatsupgradedgrades', 'grades'); $hidemessage = get_string('upgradedgradeshidemessage', 'grades'); $urlparams = array('id' => $courseid, 'seenaggregatesubcatsupgradedgrades' => true, 'sesskey' => sesskey()); $goawayurl = new moodle_url($thispage, $urlparams); $goawaybutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get'); $html .= $OUTPUT->notification($message, 'notifysuccess'); $html .= $goawaybutton; } if ($return) { return $html; } else { echo $html; } }
// Handle toggle change request if (!is_null($toggle) && !empty($toggle_type)) { set_user_preferences(array('grade_report_show' . $toggle_type => $toggle)); } //first make sure we have proper final grades - this must be done before constructing of the grade tree grade_regrade_final_grades($courseid); // Perform actions if (!empty($target) && !empty($action) && confirm_sesskey()) { grade_report_grader::do_process_action($target, $action, $courseid); } $reportname = get_string('pluginname', 'gradereport_grader'); // Print header print_grade_page_head($COURSE->id, 'report', 'grader', $reportname, false, $buttons); // Hide the following warning if the user told it to go away. if (optional_param('seensumofgradesupgradedgrades', false, PARAM_BOOL) && confirm_sesskey()) { hide_natural_aggregation_upgrade_notice($courseid); } // This shows a notice about the upgrade to Natural aggregation. print_natural_aggregation_upgrade_notice($COURSE->id, $context); //Initialise the grader report object that produces the table //the class grade_report_grader_ajax was removed as part of MDL-21562 $report = new grade_report_grader($courseid, $gpr, $context, $page, $sortitemid); $numusers = $report->get_numusers(true, true); // make sure separate group does not prevent view if ($report->currentgroup == -2) { echo $OUTPUT->heading(get_string("notingroup")); echo $OUTPUT->footer(); exit; } // processing posted grades & feedback here if ($data = data_submitted() and confirm_sesskey() and has_capability('moodle/grade:edit', $context)) {
/** * Print warning about changed grades during upgrade to 2.8. * * @param int $courseid The current course id. * @param context $context The course context. * @param string $thispage The relative path for the current page. E.g. /grade/report/user/index.php * @param boolean $return return as string * * @return nothing or string if $return true */ function print_natural_aggregation_upgrade_notice($courseid, $context, $thispage, $return = false) { global $CFG, $OUTPUT; $html = ''; // Do not do anything if they cannot manage the grades of this course. if (!has_capability('moodle/grade:manage', $context)) { return $html; } $hidesubcatswarning = optional_param('seenaggregatesubcatsupgradedgrades', false, PARAM_BOOL) && confirm_sesskey(); $showsubcatswarning = get_config('core', 'show_aggregatesubcats_upgrade_' . $courseid); $hidenaturalwarning = optional_param('seensumofgradesupgradedgrades', false, PARAM_BOOL) && confirm_sesskey(); $shownaturalwarning = get_config('core', 'show_sumofgrades_upgrade_' . $courseid); $hideminmaxwarning = optional_param('seenminmaxupgradedgrades', false, PARAM_BOOL) && confirm_sesskey(); $showminmaxwarning = get_config('core', 'show_min_max_grades_changed_' . $courseid); $useminmaxfromgradeitem = optional_param('useminmaxfromgradeitem', false, PARAM_BOOL) && confirm_sesskey(); $useminmaxfromgradegrade = optional_param('useminmaxfromgradegrade', false, PARAM_BOOL) && confirm_sesskey(); $minmaxtouse = grade_get_setting($courseid, 'minmaxtouse', $CFG->grade_minmaxtouse); $gradebookcalculationsfreeze = get_config('core', 'gradebook_calculations_freeze_' . $courseid); $acceptgradebookchanges = optional_param('acceptgradebookchanges', false, PARAM_BOOL) && confirm_sesskey(); // Hide the warning if the user told it to go away. if ($hidenaturalwarning) { hide_natural_aggregation_upgrade_notice($courseid); } // Hide the warning if the user told it to go away. if ($hidesubcatswarning) { hide_aggregatesubcats_upgrade_notice($courseid); } // Hide the min/max warning if the user told it to go away. if ($hideminmaxwarning) { grade_hide_min_max_grade_upgrade_notice($courseid); $showminmaxwarning = false; } if ($useminmaxfromgradegrade) { // Revert to the new behaviour, we now use the grade_grade for min/max. grade_upgrade_use_min_max_from_grade_grade($courseid); grade_hide_min_max_grade_upgrade_notice($courseid); $showminmaxwarning = false; } else { if ($useminmaxfromgradeitem) { // Apply the new logic, we now use the grade_item for min/max. grade_upgrade_use_min_max_from_grade_item($courseid); grade_hide_min_max_grade_upgrade_notice($courseid); $showminmaxwarning = false; } } if (!$hidenaturalwarning && $shownaturalwarning) { $message = get_string('sumofgradesupgradedgrades', 'grades'); $hidemessage = get_string('upgradedgradeshidemessage', 'grades'); $urlparams = array('id' => $courseid, 'seensumofgradesupgradedgrades' => true, 'sesskey' => sesskey()); $goawayurl = new moodle_url($thispage, $urlparams); $goawaybutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get'); $html .= $OUTPUT->notification($message, 'notifysuccess'); $html .= $goawaybutton; } if (!$hidesubcatswarning && $showsubcatswarning) { $message = get_string('aggregatesubcatsupgradedgrades', 'grades'); $hidemessage = get_string('upgradedgradeshidemessage', 'grades'); $urlparams = array('id' => $courseid, 'seenaggregatesubcatsupgradedgrades' => true, 'sesskey' => sesskey()); $goawayurl = new moodle_url($thispage, $urlparams); $goawaybutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get'); $html .= $OUTPUT->notification($message, 'notifysuccess'); $html .= $goawaybutton; } if ($showminmaxwarning) { $hidemessage = get_string('upgradedgradeshidemessage', 'grades'); $urlparams = array('id' => $courseid, 'seenminmaxupgradedgrades' => true, 'sesskey' => sesskey()); $goawayurl = new moodle_url($thispage, $urlparams); $hideminmaxbutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get'); $moreinfo = html_writer::link(get_docs_url(get_string('minmaxtouse_link', 'grades')), get_string('moreinfo'), array('target' => '_blank')); if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_ITEM) { // Show the message that there were min/max issues that have been resolved. $message = get_string('minmaxupgradedgrades', 'grades') . ' ' . $moreinfo; $revertmessage = get_string('upgradedminmaxrevertmessage', 'grades'); $urlparams = array('id' => $courseid, 'useminmaxfromgradegrade' => true, 'sesskey' => sesskey()); $reverturl = new moodle_url($thispage, $urlparams); $revertbutton = $OUTPUT->single_button($reverturl, $revertmessage, 'get'); $html .= $OUTPUT->notification($message); $html .= $revertbutton . $hideminmaxbutton; } else { if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE) { // Show the warning that there are min/max issues that have not be resolved. $message = get_string('minmaxupgradewarning', 'grades') . ' ' . $moreinfo; $fixmessage = get_string('minmaxupgradefixbutton', 'grades'); $urlparams = array('id' => $courseid, 'useminmaxfromgradeitem' => true, 'sesskey' => sesskey()); $fixurl = new moodle_url($thispage, $urlparams); $fixbutton = $OUTPUT->single_button($fixurl, $fixmessage, 'get'); $html .= $OUTPUT->notification($message); $html .= $fixbutton . $hideminmaxbutton; } } } if ($gradebookcalculationsfreeze) { if ($acceptgradebookchanges) { // Accept potential changes in grades caused by extra credit bug MDL-49257. hide_gradebook_calculations_freeze_notice($courseid); $courseitem = grade_item::fetch_course_item($courseid); $courseitem->force_regrading(); grade_regrade_final_grades($courseid); $html .= $OUTPUT->notification(get_string('gradebookcalculationsuptodate', 'grades'), 'notifysuccess'); } else { // Show the warning that there may be extra credit weights problems. $a = new stdClass(); $a->gradebookversion = $gradebookcalculationsfreeze; if (preg_match('/(\\d{8,})/', $CFG->release, $matches)) { $a->currentversion = $matches[1]; } else { $a->currentversion = $CFG->release; } $a->url = get_docs_url('Gradebook_calculation_changes'); $message = get_string('gradebookcalculationswarning', 'grades', $a); $fixmessage = get_string('gradebookcalculationsfixbutton', 'grades'); $urlparams = array('id' => $courseid, 'acceptgradebookchanges' => true, 'sesskey' => sesskey()); $fixurl = new moodle_url($thispage, $urlparams); $fixbutton = $OUTPUT->single_button($fixurl, $fixmessage, 'get'); $html .= $OUTPUT->notification($message); $html .= $fixbutton; } } if (!empty($html)) { $html = html_writer::tag('div', $html, array('class' => 'core_grades_notices')); } if ($return) { return $html; } else { echo $html; } }
/** * Print warning about changed grades during upgrade to 2.8. * * @param int $courseid The current course id. * @param context $context The course context. * @param string $thispage The relative path for the current page. E.g. /grade/report/user/index.php * @param boolean $return return as string * * @return nothing or string if $return true */ function print_natural_aggregation_upgrade_notice($courseid, $context, $thispage, $return = false) { global $CFG, $OUTPUT; $html = ''; // Do not do anything if they cannot manage the grades of this course. if (!has_capability('moodle/grade:manage', $context)) { return $html; } $hidesubcatswarning = optional_param('seenaggregatesubcatsupgradedgrades', false, PARAM_BOOL) && confirm_sesskey(); $showsubcatswarning = get_config('core', 'show_aggregatesubcats_upgrade_' . $courseid); $hidenaturalwarning = optional_param('seensumofgradesupgradedgrades', false, PARAM_BOOL) && confirm_sesskey(); $shownaturalwarning = get_config('core', 'show_sumofgrades_upgrade_' . $courseid); $hideminmaxwarning = optional_param('seenminmaxupgradedgrades', false, PARAM_BOOL) && confirm_sesskey(); $showminmaxwarning = get_config('core', 'show_min_max_grades_changed_' . $courseid); $useminmaxfromgradeitem = optional_param('useminmaxfromgradeitem', false, PARAM_BOOL) && confirm_sesskey(); $useminmaxfromgradegrade = optional_param('useminmaxfromgradegrade', false, PARAM_BOOL) && confirm_sesskey(); $showlockedgradebook = get_config('core', 'show_lockedgradebook_upgrade_' . $courseid); $minmaxtouse = grade_get_setting($courseid, 'minmaxtouse', $CFG->grade_minmaxtouse); // Hide the warning if the user told it to go away. if ($hidenaturalwarning) { hide_natural_aggregation_upgrade_notice($courseid); } // Hide the warning if the user told it to go away. if ($hidesubcatswarning) { hide_aggregatesubcats_upgrade_notice($courseid); } // Hide the min/max warning if the user told it to go away. if ($hideminmaxwarning) { grade_hide_min_max_grade_upgrade_notice($courseid); $showminmaxwarning = false; } if ($useminmaxfromgradegrade) { // Revert to the new behaviour, we now use the grade_grade for min/max. grade_upgrade_use_min_max_from_grade_grade($courseid); grade_hide_min_max_grade_upgrade_notice($courseid); $showminmaxwarning = false; } else { if ($useminmaxfromgradeitem) { // Apply the new logic, we now use the grade_item for min/max. grade_upgrade_use_min_max_from_grade_item($courseid); grade_hide_min_max_grade_upgrade_notice($courseid); $showminmaxwarning = false; } } if (!$hidenaturalwarning && $shownaturalwarning) { $message = get_string('sumofgradesupgradedgrades', 'grades'); $hidemessage = get_string('upgradedgradeshidemessage', 'grades'); $urlparams = array('id' => $courseid, 'seensumofgradesupgradedgrades' => true, 'sesskey' => sesskey()); $goawayurl = new moodle_url($thispage, $urlparams); $goawaybutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get'); $html .= $OUTPUT->notification($message, 'notifysuccess'); $html .= $goawaybutton; } if (!$hidesubcatswarning && $showsubcatswarning) { $message = get_string('aggregatesubcatsupgradedgrades', 'grades'); $hidemessage = get_string('upgradedgradeshidemessage', 'grades'); $urlparams = array('id' => $courseid, 'seenaggregatesubcatsupgradedgrades' => true, 'sesskey' => sesskey()); $goawayurl = new moodle_url($thispage, $urlparams); $goawaybutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get'); $html .= $OUTPUT->notification($message, 'notifysuccess'); $html .= $goawaybutton; } if ($showminmaxwarning) { $hidemessage = get_string('upgradedgradeshidemessage', 'grades'); $urlparams = array('id' => $courseid, 'seenminmaxupgradedgrades' => true, 'sesskey' => sesskey()); $goawayurl = new moodle_url($thispage, $urlparams); $hideminmaxbutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get'); $moreinfo = html_writer::link(get_docs_url(get_string('minmaxtouse_link', 'grades')), get_string('moreinfo'), array('target' => '_blank')); if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_ITEM) { // Show the message that there were min/max issues that have been resolved. $message = get_string('minmaxupgradedgrades', 'grades') . ' ' . $moreinfo; $revertmessage = get_string('upgradedminmaxrevertmessage', 'grades'); $urlparams = array('id' => $courseid, 'useminmaxfromgradegrade' => true, 'sesskey' => sesskey()); $reverturl = new moodle_url($thispage, $urlparams); $revertbutton = $OUTPUT->single_button($reverturl, $revertmessage, 'get'); $html .= $OUTPUT->notification($message, 'notifywarning'); $html .= $revertbutton . $hideminmaxbutton; } else { if ($minmaxtouse == GRADE_MIN_MAX_FROM_GRADE_GRADE) { // Show the warning that there are min/max issues that have not be resolved. $message = get_string('minmaxupgradewarning', 'grades') . ' ' . $moreinfo; $fixmessage = get_string('minmaxupgradefixbutton', 'grades'); $urlparams = array('id' => $courseid, 'useminmaxfromgradeitem' => true, 'sesskey' => sesskey()); $fixurl = new moodle_url($thispage, $urlparams); $fixbutton = $OUTPUT->single_button($fixurl, $fixmessage, 'get'); $html .= $OUTPUT->notification($message, 'notifywarning'); $html .= $fixbutton . $hideminmaxbutton; } } } if ($showlockedgradebook) { $message = get_string('lockedgradebook', 'grades'); $html .= $OUTPUT->notification($message, 'notifysuccess'); } if (!empty($html)) { $html = html_writer::tag('div', $html, array('class' => 'core_grades_notices')); } if ($return) { return $html; } else { echo $html; } }