diff --git a/mod/assign/locallib.php b/mod/assign/locallib.php index 8c035d72bfc..c9aee3700ce 100644 --- a/mod/assign/locallib.php +++ b/mod/assign/locallib.php @@ -2843,7 +2843,9 @@ class assign { $this->get_course_module()->id, $this->get_return_action(), $this->get_return_params(), - true); + true, + $useridlistid, + $rownum); $o .= $this->get_renderer()->render($history); } @@ -3701,7 +3703,9 @@ class assign { $this->get_course_module()->id, $this->get_return_action(), $this->get_return_params(), - false); + false, + 0, + 0); $o .= $this->get_renderer()->render($history); } diff --git a/mod/assign/renderable.php b/mod/assign/renderable.php index 6b033237676..72d5b96084f 100644 --- a/mod/assign/renderable.php +++ b/mod/assign/renderable.php @@ -476,22 +476,26 @@ class assign_submission_status implements renderable { */ class assign_attempt_history implements renderable { - /** @var array submissions */ + /** @var array submissions - The list of previous attempts */ public $submissions = array(); - /** @var array grades */ + /** @var array grades - The grades for the previous attempts */ public $grades = array(); - /** @var array submissionplugins */ + /** @var array submissionplugins - The list of submission plugins to render the previous attempts */ public $submissionplugins = array(); - /** @var array feedbackplugins */ + /** @var array feedbackplugins - The list of feedback plugins to render the previous attempts */ public $feedbackplugins = array(); - /** @var int coursemoduleid */ + /** @var int coursemoduleid - The cmid for the assignment */ public $coursemoduleid = 0; - /** @var string returnaction */ + /** @var string returnaction - The action for the next page. */ public $returnaction = ''; - /** @var string returnparams */ + /** @var string returnparams - The params for the next page. */ public $returnparams = array(); - /** @var bool cangrade */ + /** @var bool cangrade - Does this user have grade capability? */ public $cangrade = false; + /** @var string useridlistid - Id of the useridlist stored in cache, this plus rownum determines the userid */ + public $useridlistid = 0; + /** @var int rownum - The rownum of the user in the useridlistid - this plus useridlistid determines the userid */ + public $rownum = 0; /** * Constructor @@ -504,6 +508,8 @@ class assign_attempt_history implements renderable { * @param string $returnaction * @param array $returnparams * @param bool $cangrade + * @param int $useridlistid + * @param int $rownum */ public function __construct($submissions, $grades, @@ -512,7 +518,9 @@ class assign_attempt_history implements renderable { $coursemoduleid, $returnaction, $returnparams, - $cangrade) { + $cangrade, + $useridlistid, + $rownum) { $this->submissions = $submissions; $this->grades = $grades; $this->submissionplugins = $submissionplugins; @@ -521,6 +529,8 @@ class assign_attempt_history implements renderable { $this->returnaction = $returnaction; $this->returnparams = $returnparams; $this->cangrade = $cangrade; + $this->useridlistid = $useridlistid; + $this->rownum = $rownum; } } diff --git a/mod/assign/renderer.php b/mod/assign/renderer.php index 595f926c4e1..8633c819fed 100644 --- a/mod/assign/renderer.php +++ b/mod/assign/renderer.php @@ -815,10 +815,10 @@ class mod_assign_renderer extends plugin_renderer_base { // Edit previous feedback. $returnparams = http_build_query($history->returnparams); $urlparams = array('id' => $history->coursemoduleid, - 'userid'=>$grade->userid, + 'rownum'=>$history->rownum, + 'useridlistid'=>$history->useridlistid, 'attemptnumber'=>$grade->attemptnumber, 'action'=>'grade', - 'rownum'=>0, 'returnaction'=>$history->returnaction, 'returnparams'=>$returnparams); $url = new moodle_url('/mod/assign/view.php', $urlparams); diff --git a/mod/assign/tests/behat/edit_previous_feedback.feature b/mod/assign/tests/behat/edit_previous_feedback.feature new file mode 100644 index 00000000000..81f5bfd16ca --- /dev/null +++ b/mod/assign/tests/behat/edit_previous_feedback.feature @@ -0,0 +1,74 @@ +@mod @mod_assign +Feature: In an assignment, teachers can edit feedback for a students previous submission attempt + In order to correct feedback for a previous submission attempt + As a teacher + I need to be able to edit the feedback for a students previous submission attempt. + + @javascript + Scenario: Edit feedback for a students previous attempt. + Given the following "courses" exists: + | fullname | shortname | category | groupmode | + | Course 1 | C1 | 0 | 1 | + And the following "users" exists: + | username | firstname | lastname | email | + | teacher1 | Teacher | 1 | teacher1@asd.com | + | student1 | Student | 1 | student1@asd.com | + | student2 | Student | 2 | student2@asd.com | + And the following "course enrolments" exists: + | user | course | role | + | teacher1 | C1 | editingteacher | + | student1 | C1 | student | + | student2 | C1 | student | + And I log in as "teacher1" + And I follow "Course 1" + And I turn editing mode on + And I add a "Assignment" to section "1" and I fill the form with: + | Assignment name | Test assignment name | + | Description | Submit your online text | + | assignsubmission_onlinetext_enabled | 1 | + | assignfeedback_comments_enabled | 1 | + | Attempts reopened | Manually | + And I log out + And I log in as "student2" + And I follow "Course 1" + And I follow "Test assignment name" + And I press "Add submission" + And I fill the moodle form with: + | Online text | I'm the student first submission | + And I press "Save changes" + And I log out + And I log in as "teacher1" + And I follow "Course 1" + And I follow "Test assignment name" + And I follow "View/grade all submissions" + And I click on "Grade Student 2" "link" in the "Student 2" "table_row" + And I fill the moodle form with: + | Grade | 49 | + | Feedback comments | I'm the teacher first feedback | + | Allow another attempt | Yes | + And I press "Save changes" + And I log out + And I log in as "student2" + And I follow "Course 1" + And I follow "Test assignment name" + And I click on ".mod-assign-history-link" "css_element" + And I should see "I'm the teacher first feedback" in the "Feedback comments" "table_row" + And I log out + When I log in as "teacher1" + And I follow "Course 1" + And I follow "Test assignment name" + And I follow "View/grade all submissions" + And I click on "Grade Student 2" "link" in the "Student 2" "table_row" + And I click on ".mod-assign-history-link" "css_element" + And I follow "Edit the grade and feedback for attempt number 1" + And I fill the moodle form with: + | Grade | 50 | + | Feedback comments | I'm the teacher second feedback | + And I press "Save changes" + And I log out + Then I log in as "student2" + And I follow "Course 1" + And I follow "Test assignment name" + And I click on ".mod-assign-history-link" "css_element" + And I should see "I'm the teacher second feedback" in the "Feedback comments" "table_row" + And I should see "50.00"