MDL-33843: Remove custom dirty form handling and use default behaviour in assignment

This commit is contained in:
Damyon Wiese 2012-06-19 15:10:28 +08:00
parent 1ee9b37880
commit 5382eabbec
3 changed files with 8 additions and 44 deletions

View File

@ -48,13 +48,15 @@ class mod_assign_grading_options_form extends moodleform {
$mform->addElement('header', 'general', get_string('gradingoptions', 'assign'));
// visible elements
$options = array(-1=>'All',10=>'10', 20=>'20', 50=>'50', 100=>'100');
$mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options, array('class'=>'ignoredirty'));
$options = array(''=>get_string('filternone', 'assign'), ASSIGN_FILTER_SUBMITTED=>get_string('filtersubmitted', 'assign'), ASSIGN_FILTER_REQUIRE_GRADING=>get_string('filterrequiregrading', 'assign'));
$mform->addElement('select', 'filter', get_string('filter', 'assign'), $options, array('class'=>'ignoredirty'));
$mform->addElement('select', 'perpage', get_string('assignmentsperpage', 'assign'), $options);
$options = array(''=>get_string('filternone', 'assign'),
ASSIGN_FILTER_SUBMITTED=>get_string('filtersubmitted', 'assign'),
ASSIGN_FILTER_REQUIRE_GRADING=>get_string('filterrequiregrading', 'assign'));
$mform->addElement('select', 'filter', get_string('filter', 'assign'), $options);
// quickgrading
if ($instance['showquickgrading']) {
$mform->addElement('checkbox', 'quickgrading', get_string('quickgrading', 'assign'), '', array('class'=>'ignoredirty'));
$mform->addElement('checkbox', 'quickgrading', get_string('quickgrading', 'assign'), '');
$mform->addHelpButton('quickgrading', 'quickgrading', 'assign');
$mform->setDefault('quickgrading', $instance['quickgrading']);
}

View File

@ -119,7 +119,7 @@ class assign_grading_table extends table_sql implements renderable {
// Select
$columns[] = 'select';
$headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" class="ignoredirty" name="selectall" title="' . get_string('selectall') . '"/></div>';
$headers[] = get_string('select') . '<div class="selectall"><input type="checkbox" name="selectall" title="' . get_string('selectall') . '"/></div>';
// Edit links
if (!$this->is_downloading()) {
@ -303,7 +303,7 @@ class assign_grading_table extends table_sql implements renderable {
* @return string
*/
function col_select(stdClass $row) {
return '<input type="checkbox" name="selectedusers" value="' . $row->userid . '" class="ignoredirty"/>';
return '<input type="checkbox" name="selectedusers" value="' . $row->userid . '"/>';
}
/**

View File

@ -110,24 +110,6 @@ M.mod_assign.init_grading_table = function(Y) {
});
};
M.mod_assign.check_dirty_quickgrading_form = function(e) {
if (!M.core_formchangechecker.get_form_dirty_state()) {
// the form is not dirty, so don't display any message
return;
}
// This is the error message that we'll show to browsers which support it
var warningmessage = 'There are unsaved quickgrading changes. Do you really wanto to leave this page?';
// Most browsers are happy with the returnValue being set on the event
// But some browsers do not consistently pass the event
if (e) {
e.returnValue = warningmessage;
}
// But some require it to be returned instead
return warningmessage;
}
M.mod_assign.init_grading_options = function(Y) {
Y.use('node', function(Y) {
@ -150,23 +132,3 @@ M.mod_assign.init_grading_options = function(Y) {
};
// override the default dirty form behaviour to ignore any input with the class "ignoredirty"
M.mod_assign.set_form_changed = M.core_formchangechecker.set_form_changed;
M.core_formchangechecker.set_form_changed = function(e) {
var target = e.currentTarget;
if (!target.hasClass('ignoredirty')) {
M.mod_assign.set_form_changed(e);
}
}
M.mod_assign.get_form_dirty_state = M.core_formchangechecker.get_form_dirty_state;
M.core_formchangechecker.get_form_dirty_state = function() {
var state = M.core_formchangechecker.stateinformation;
if (state.focused_element) {
if (state.focused_element.element.hasClass('ignoredirty')) {
state.focused_element.initial_value = state.focused_element.element.get('value')
}
}
return M.mod_assign.get_form_dirty_state();
}