From 0e8aa5027eb7cb2bfa66e55f164c2d3409a8e02b Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 12 Oct 2012 11:58:11 +0800 Subject: [PATCH] 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. --- mod/assign/gradeform.php | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 -- 2.17.1