From 5382eabbec3a70dd9f59d58a8b0f4a8caded8a29 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 19 Jun 2012 15:10:28 +0800 Subject: [PATCH] MDL-33843: Remove custom dirty form handling and use default behaviour in assignment --- mod/assign/gradingoptionsform.php | 10 ++++---- mod/assign/gradingtable.php | 4 ++-- mod/assign/module.js | 38 ------------------------------- 3 files changed, 8 insertions(+), 44 deletions(-) diff --git a/mod/assign/gradingoptionsform.php b/mod/assign/gradingoptionsform.php index d9abe0fb35a..eea466c1c25 100644 --- a/mod/assign/gradingoptionsform.php +++ b/mod/assign/gradingoptionsform.php @@ -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']); } diff --git a/mod/assign/gradingtable.php b/mod/assign/gradingtable.php index ad00b800ea4..9e1c9ce7b1e 100644 --- a/mod/assign/gradingtable.php +++ b/mod/assign/gradingtable.php @@ -119,7 +119,7 @@ class assign_grading_table extends table_sql implements renderable { // Select $columns[] = 'select'; - $headers[] = get_string('select') . '
'; + $headers[] = get_string('select') . '
'; // 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 ''; + return ''; } /** diff --git a/mod/assign/module.js b/mod/assign/module.js index 5786e1e79b4..0dbacdc184a 100644 --- a/mod/assign/module.js +++ b/mod/assign/module.js @@ -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(); -} -