--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * 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;
+}
$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));
$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);
$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]);
}
$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'),
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));
}
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)