mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-47062 Grades: Add an upgrade step to warn about changes in upgrade.
Puts a notice on the grader report about the change in aggregation method from "Sum of grades" to "Natural". Part of: MDL-46576
This commit is contained in:
parent
837b92897d
commit
a9937aec06
@ -458,6 +458,48 @@ function grade_get_graded_users_select($report, $course, $userid, $groupid, $inc
|
||||
return $select;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide warning about changed grades during upgrade to 2.8.
|
||||
*
|
||||
* @param int $courseid The current course id.
|
||||
*/
|
||||
function hide_natural_aggregation_upgrade_notice($courseid) {
|
||||
set_config('show_sumofgrades_upgrade_' . $courseid, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print warning about changed grades during upgrade to 2.8.
|
||||
*
|
||||
* @param int $courseid The current course id.
|
||||
* @param context $context The course context.
|
||||
* @param boolean $return return as string
|
||||
*
|
||||
* @return nothing or string if $return true
|
||||
*/
|
||||
function print_natural_aggregation_upgrade_notice($courseid, $context, $return=false) {
|
||||
global $OUTPUT;
|
||||
$html = '';
|
||||
$show = get_config('core', 'show_sumofgrades_upgrade_' . $courseid);
|
||||
|
||||
if ($show) {
|
||||
$message = get_string('sumofgradesupgradedgrades', 'grades');
|
||||
$hidemessage = get_string('sumofgradesupgradedgradeshidemessage', 'grades');
|
||||
$urlparams = array( 'id' => $courseid,
|
||||
'seensumofgradesupgradedgrades' => true,
|
||||
'sesskey' => sesskey());
|
||||
$goawayurl = new moodle_url('/grade/report/grader/index.php', $urlparams);
|
||||
$goawaybutton = $OUTPUT->single_button($goawayurl, $hidemessage, 'get');
|
||||
$html .= $OUTPUT->notification($message, 'notifysuccess');
|
||||
$html .= $goawaybutton;
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
return $html;
|
||||
} else {
|
||||
echo $html;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print grading plugin selection popup form.
|
||||
*
|
||||
|
@ -128,6 +128,13 @@ $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);
|
||||
|
@ -669,6 +669,8 @@ $string['studentsperpagereduced'] = 'Reduced maximum students per page from {$a-
|
||||
$string['subcategory'] = 'Normal category';
|
||||
$string['submissions'] = 'Submissions';
|
||||
$string['submittedon'] = 'Submitted: {$a}';
|
||||
$string['sumofgradesupgradedgrades'] = 'A recent upgrade has changed the aggregation method "Sum of grades" to "Natural". Please review the grades in this course as it was previously using "Sum of grades".';
|
||||
$string['sumofgradesupgradedgradeshidemessage'] = 'Got it';
|
||||
$string['switchtofullview'] = 'Switch to full view';
|
||||
$string['switchtosimpleview'] = 'Switch to simple view';
|
||||
$string['tabs'] = 'Tabs';
|
||||
|
@ -3903,6 +3903,26 @@ function xmldb_main_upgrade($oldversion) {
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2014092200.01);
|
||||
}
|
||||
if ($oldversion < 2014100300.00) {
|
||||
// Set flags so we can display a notice on all courses that might
|
||||
// be affected by the uprade to natural aggregation.
|
||||
if (!get_config('grades_sumofgrades_upgrade_flagged', 'core')) {
|
||||
// 13 == SUM_OF_GRADES.
|
||||
$sql = 'SELECT DISTINCT courseid
|
||||
FROM {grade_categories}
|
||||
WHERE aggregation = ?';
|
||||
$courses = $DB->get_records_sql($sql, array(13));
|
||||
|
||||
foreach ($courses as $course) {
|
||||
set_config('show_sumofgrades_upgrade_' . $course->courseid, 1);
|
||||
}
|
||||
|
||||
set_config('grades_sumofgrades_upgrade_flagged', 1);
|
||||
}
|
||||
|
||||
// Main savepoint reached.
|
||||
upgrade_main_savepoint(true, 2014100300.00);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
$version = 2014100200.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
$version = 2014100300.00; // YYYYMMDD = weekly release date of this DEV branch.
|
||||
// RR = release increments - 00 in DEV branches.
|
||||
// .XX = incremental changes.
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user