mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
MDL-10481 minor form cleanup - added prefix for preferences in element names, added header + temporary debug delay before redirect
This commit is contained in:
parent
501e0e346e
commit
83ae2001b9
@ -25,14 +25,16 @@ $mform = new edit_item_form(null, array('gpr'=>$gpr));
|
|||||||
|
|
||||||
if ($mform->is_cancelled()) {
|
if ($mform->is_cancelled()) {
|
||||||
redirect($returnurl);
|
redirect($returnurl);
|
||||||
|
|
||||||
} else if (!$mform->is_submitted()) {
|
} else if (!$mform->is_submitted()) {
|
||||||
if ($item = get_record('grade_items', 'id', $id, 'courseid', $course->id)) {
|
if ($item = get_record('grade_items', 'id', $id, 'courseid', $course->id)) {
|
||||||
// Get Item preferences
|
// Get Item preferences
|
||||||
$item->gradedisplaytype = get_user_preferences('grade_report_gradedisplaytype' . $id, 'default');
|
$item->pref_gradedisplaytype = get_user_preferences('grade_report_gradedisplaytype' . $id, 'default');
|
||||||
$item->decimalpoints = get_user_preferences('grade_report_decimalpoints' . $id, 'default');
|
$item->pref_decimalpoints = get_user_preferences('grade_report_decimalpoints' . $id, 'default');
|
||||||
|
|
||||||
$item->calculation = grade_item::denormalize_formula($item->calculation, $course->id);
|
$item->calculation = grade_item::denormalize_formula($item->calculation, $course->id);
|
||||||
$mform->set_data($item);
|
$mform->set_data($item);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$mform->set_data(array('courseid'=>$course->id, 'itemtype'=>'manual'));
|
$mform->set_data(array('courseid'=>$course->id, 'itemtype'=>'manual'));
|
||||||
}
|
}
|
||||||
@ -56,25 +58,19 @@ if ($mform->is_cancelled()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Handle user preferences
|
// Handle user preferences
|
||||||
if (!empty($data->gradedisplaytype)) {
|
if (!empty($data->pref_gradedisplaytype)) {
|
||||||
if (!grade_report::set_pref('gradedisplaytype', $data->gradedisplaytype, $id)) {
|
if (!grade_report::set_pref('gradedisplaytype', $data->pref_gradedisplaytype, $grade_item->id)) {
|
||||||
$errors[] = "Could not set preference gradedisplaytype to $value for this grade item";
|
error("Could not set preference gradedisplaytype to $value for this grade item");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($data->decimalpoints)) {
|
if (!empty($data->pref_decimalpoints)) {
|
||||||
if (!grade_report::set_pref('decimalpoints', $data->decimalpoints, $id)) {
|
if (!grade_report::set_pref('decimalpoints', $data->pref_decimalpoints, $grade_item->id)) {
|
||||||
$errors[] = "Could not set preference decimalpoints to $value for this grade item";
|
errors("Could not set preference decimalpoints to $value for this grade item");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($errors)) {
|
redirect($returnurl, 'temporary debug delay', 10);
|
||||||
// redirect($returnurl);
|
|
||||||
} else {
|
|
||||||
foreach ($errors as $error) {
|
|
||||||
error($error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$strgrades = get_string('grades');
|
$strgrades = get_string('grades');
|
||||||
|
@ -72,19 +72,22 @@ class edit_item_form extends moodleform {
|
|||||||
$mform->addElement('date_time_selector', 'locktime', get_string('locktime', 'grades'), array('optional'=>true));
|
$mform->addElement('date_time_selector', 'locktime', get_string('locktime', 'grades'), array('optional'=>true));
|
||||||
$mform->disabledIf('locktime', 'gradetype', 'eq', GRADE_TYPE_NONE);
|
$mform->disabledIf('locktime', 'gradetype', 'eq', GRADE_TYPE_NONE);
|
||||||
|
|
||||||
$mform->addElement('select', 'gradedisplaytype', get_string('gradedisplaytype', 'grades'),
|
/// user preferences
|
||||||
|
$mform->addElement('header', 'general', get_string('userpreferences', 'grades'));
|
||||||
|
|
||||||
|
$mform->addElement('select', 'pref_gradedisplaytype', get_string('gradedisplaytype', 'grades'),
|
||||||
array('default' => get_string('default', 'grades'),
|
array('default' => get_string('default', 'grades'),
|
||||||
GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW => get_string('raw', 'grades'),
|
GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW => get_string('raw', 'grades'),
|
||||||
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades')));
|
GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades')));
|
||||||
$mform->setHelpButton('gradedisplaytype', array(false, get_string('gradedisplaytype', 'grades'),
|
$mform->setHelpButton('pref_gradedisplaytype', array(false, get_string('gradedisplaytype', 'grades'),
|
||||||
false, true, false, get_string("config_gradedisplaytype", 'grades')));
|
false, true, false, get_string("config_gradedisplaytype", 'grades')));
|
||||||
$mform->setDefault('gradedisplaytype', 'default');
|
$mform->setDefault('pref_gradedisplaytype', 'default');
|
||||||
|
|
||||||
$mform->addElement('select', 'decimalpoints', get_string('decimalpoints', 'grades'),
|
$mform->addElement('select', 'pref_decimalpoints', get_string('decimalpoints', 'grades'),
|
||||||
array('default' => get_string('default', 'grades'), 0, 1, 2, 3, 4, 5));
|
array('default' => get_string('default', 'grades'), 0, 1, 2, 3, 4, 5));
|
||||||
$mform->setHelpButton('decimalpoints', array(false, get_string('decimalpoints', 'grades'),
|
$mform->setHelpButton('pref_decimalpoints', array(false, get_string('decimalpoints', 'grades'),
|
||||||
false, true, false, get_string("config_decimalpoints", 'grades')));
|
false, true, false, get_string("config_decimalpoints", 'grades')));
|
||||||
$mform->setDefault('decimalpoints', 'default');
|
$mform->setDefault('pref_decimalpoints', 'default');
|
||||||
|
|
||||||
/// hidden params
|
/// hidden params
|
||||||
$mform->addElement('hidden', 'id', 0);
|
$mform->addElement('hidden', 'id', 0);
|
||||||
@ -130,7 +133,7 @@ class edit_item_form extends moodleform {
|
|||||||
function validation($data){
|
function validation($data){
|
||||||
$errors= array();
|
$errors= array();
|
||||||
|
|
||||||
if ($data['calculation'] != '') {
|
if (array_key_exists('calculation', $data) and $data['calculation'] != '') {
|
||||||
$grade_item = new grade_item(array('id'=>$data['id'], 'itemtype'=>$data['itemtype'], 'courseid'=>$data['courseid']));
|
$grade_item = new grade_item(array('id'=>$data['id'], 'itemtype'=>$data['itemtype'], 'courseid'=>$data['courseid']));
|
||||||
$result = $grade_item->validate_formula($data['calculation']);
|
$result = $grade_item->validate_formula($data['calculation']);
|
||||||
if ($result !== true) {
|
if ($result !== true) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user