From: Damyon Wiese Date: Fri, 12 Oct 2012 03:58:11 +0000 (+0800) Subject: MDL-35726: Use a different form identifier for each form when using "Save and next" X-Git-Tag: v2.3.3~88^2 X-Git-Url: http://git.moodle.org/gw?p=moodle.git;a=commitdiff_plain;h=0e8aa5027eb7cb2bfa66e55f164c2d3409a8e02b;hp=f2c33d0b69a5d49781c0ce21fc4df98e8e2c362d MDL-35726: Use a different form identifier for each form when using "Save and next" This prevents a bug where the next student feedback will default to the values that were on the last submitted form. This is a similar case to having multiple instances of the same form on the same page - each one needs a unique identifier to distinguish between them. In this case I include the $rownum which changes as you go to each student in the list. --- diff --git a/mod/assign/gradeform.php b/mod/assign/gradeform.php index 8f73ac1bf0b..366d5d8b0e0 100644 --- a/mod/assign/gradeform.php +++ b/mod/assign/gradeform.php @@ -59,6 +59,17 @@ class mod_assign_grade_form extends moodleform { } } + /** + * This is required so when using "Save and next", each form is not defaulted to the previous form. + * Giving each form a unique identitifer is enough to prevent this (include the rownum in the form name). + * + * @return string - The unique identifier for this form. + */ + protected function get_form_identifier() { + $params = $this->_customdata[2]; + return get_class($this) . '_' . $params['rownum']; + } + /** * Perform minimal validation on the grade form * @param array $data