From 6deb0344c57e0661c09c08892b9eabe2ccb199bd Mon Sep 17 00:00:00 2001 From: Zachary Durber Date: Wed, 15 Oct 2014 13:39:36 +0800 Subject: [PATCH] MDL-47575 gradebook: Show weights and contribution by default. --- grade/report/user/db/upgrade.php | 39 ++++++++++++++++++++++++++++++++ grade/report/user/lib.php | 10 ++++---- grade/report/user/settings.php | 9 ++++++-- grade/report/user/version.php | 2 +- 4 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 grade/report/user/db/upgrade.php diff --git a/grade/report/user/db/upgrade.php b/grade/report/user/db/upgrade.php new file mode 100644 index 00000000000..1af7b28b936 --- /dev/null +++ b/grade/report/user/db/upgrade.php @@ -0,0 +1,39 @@ +. + +/** + * Gradereport user plugin upgrade code + * + * @package gradereport_user + * @copyright 2014 Zachary Durber + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +/** + * @param int $oldversion the version we are upgrading from + * @return bool result + */ +function xmldb_gradereport_user_upgrade($oldversion) { + + if ($oldversion < 2014101500) { + // Need to always show weight and contribution to course total. + set_config('grade_report_user_showweight', 1); + + // User savepoint reached. + upgrade_plugin_savepoint(true, 2014101500, 'gradereport', 'user'); + } + return true; +} diff --git a/grade/report/user/lib.php b/grade/report/user/lib.php index 3d4c7e64a23..39d79880eca 100644 --- a/grade/report/user/lib.php +++ b/grade/report/user/lib.php @@ -207,10 +207,10 @@ class grade_report_user extends grade_report { $this->showfeedback = grade_get_setting($this->courseid, 'report_user_showfeedback', !empty($CFG->grade_report_user_showfeedback)); $this->showweight = grade_get_setting($this->courseid, 'report_user_showweight', - empty($CFG->grade_report_user_showweight)); + !empty($CFG->grade_report_user_showweight)); $this->showcontributiontocoursetotal = grade_get_setting($this->courseid, 'report_user_showcontributiontocoursetotal', - empty($CFG->grade_report_user_showcontributiontocoursetotal)); + !empty($CFG->grade_report_user_showcontributiontocoursetotal)); $this->showlettergrade = grade_get_setting($this->courseid, 'report_user_showlettergrade', !empty($CFG->grade_report_user_showlettergrade)); $this->showaverage = grade_get_setting($this->courseid, 'report_user_showaverage', !empty($CFG->grade_report_user_showaverage)); @@ -1023,9 +1023,9 @@ function grade_report_user_settings_definition(&$mform) { $mform->addElement('select', 'report_user_showfeedback', get_string('showfeedback', 'grades'), $options); if (empty($CFG->grade_report_user_showweight)) { - $options[-1] = get_string('defaultprev', 'grades', $options[1]); - } else { $options[-1] = get_string('defaultprev', 'grades', $options[0]); + } else { + $options[-1] = get_string('defaultprev', 'grades', $options[1]); } $mform->addElement('select', 'report_user_showweight', get_string('showweight', 'grades'), $options); @@ -1047,7 +1047,7 @@ function grade_report_user_settings_definition(&$mform) { $mform->addElement('select', 'report_user_showlettergrade', get_string('showlettergrade', 'grades'), $options); if (empty($CFG->grade_report_user_showcontributiontocoursetotal)) { - $options[-1] = get_string('defaultprev', 'grades', $options[1]); + $options[-1] = get_string('defaultprev', 'grades', $options[0]); } else { $options[-1] = get_string('defaultprev', 'grades', $options[$CFG->grade_report_user_showcontributiontocoursetotal]); } diff --git a/grade/report/user/settings.php b/grade/report/user/settings.php index c85f4c899ab..134cb18ff57 100644 --- a/grade/report/user/settings.php +++ b/grade/report/user/settings.php @@ -31,7 +31,10 @@ if ($ADMIN->fulltree) { $settings->add(new admin_setting_configcheckbox('grade_report_user_showgrade', get_string('showgrade', 'grades'), get_string('showgrade_help', 'grades'), 1)); $settings->add(new admin_setting_configcheckbox('grade_report_user_showfeedback', get_string('showfeedback', 'grades'), get_string('showfeedback_help', 'grades'), 1)); $settings->add(new admin_setting_configcheckbox('grade_report_user_showrange', get_string('showrange', 'grades'), get_string('showrange_help', 'grades'), 1)); - $settings->add(new admin_setting_configcheckbox('grade_report_user_showweight', get_string('showweight', 'grades'), get_string('showweight_help', 'grades'), 0)); + + $settings->add(new admin_setting_configcheckbox('grade_report_user_showweight', + get_string('showweight', 'grades'), get_string('showweight_help', 'grades'), 1)); + $settings->add(new admin_setting_configcheckbox('grade_report_user_showaverage', get_string('showaverage', 'grades'), get_string('showaverage_help', 'grades'), 0)); $settings->add(new admin_setting_configcheckbox('grade_report_user_showlettergrade', get_string('showlettergrade', 'grades'), get_string('showlettergrade_help', 'grades'), 0)); $settings->add(new admin_setting_configselect('grade_report_user_rangedecimals', get_string('rangedecimals', 'grades'), @@ -47,5 +50,7 @@ if ($ADMIN->fulltree) { array(GRADE_REPORT_HIDE_TOTAL_IF_CONTAINS_HIDDEN => get_string('hide'), GRADE_REPORT_SHOW_TOTAL_IF_CONTAINS_HIDDEN => get_string('hidetotalshowexhiddenitems', 'grades'), GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN => get_string('hidetotalshowinchiddenitems', 'grades')))); - $settings->add(new admin_setting_configcheckbox('grade_report_user_showcontributiontocoursetotal', get_string('showcontributiontocoursetotal', 'grades'), get_string('showcontributiontocoursetotal_help', 'grades'), 0)); + + $settings->add(new admin_setting_configcheckbox('grade_report_user_showcontributiontocoursetotal', + get_string('showcontributiontocoursetotal', 'grades'), get_string('showcontributiontocoursetotal_help', 'grades'), 1)); } diff --git a/grade/report/user/version.php b/grade/report/user/version.php index 8e44488ba02..e6b9299b68b 100644 --- a/grade/report/user/version.php +++ b/grade/report/user/version.php @@ -24,6 +24,6 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2014101400; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2014101500; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2014050800; // Requires this Moodle version $plugin->component = 'gradereport_user'; // Full name of the plugin (used for diagnostics)