MDL-52506 mod_assign: Fix return links for atto auto save
authorRyan Wyllie <ryan@moodle.com>
Fri, 6 May 2016 04:36:19 +0000 (04:36 +0000)
committerRyan Wyllie <ryan@moodle.com>
Tue, 10 May 2016 01:22:48 +0000 (01:22 +0000)
mod/assign/locallib.php
mod/assign/tests/behat/online_submissions.feature

index de28b24..16acbca 100644 (file)
@@ -3899,6 +3899,12 @@ class assign {
         // Need submit permission to submit an assignment.
         $userid = optional_param('userid', $USER->id, PARAM_INT);
         $user = $DB->get_record('user', array('id'=>$userid), '*', MUST_EXIST);
+
+        // This variation on the url will link direct to this student.
+        // The benefit is the url will be the same every time for this student, so Atto autosave drafts can match up.
+        $returnparams = array('userid' => $userid, 'rownum' => 0, 'useridlistid' => 0);
+        $this->register_return_link('editsubmission', $returnparams);
+
         if ($userid == $USER->id) {
             if (!$this->can_edit_submission($userid, $USER->id)) {
                 print_error('nopermission');
index 08f58b2..f2d154f 100644 (file)
@@ -49,3 +49,41 @@ Feature: In an assignment, students can add and edit text online
     Then I should see "Submitted for grading"
     And I should see "I'm the student second submission"
     And I should not see "I'm the student first submission"
+
+  @javascript
+  Scenario: Auto-draft save online text submission
+    Given the following "courses" exist:
+      | fullname | shortname | category | groupmode |
+      | Course 1 | C1 | 0 | 1 |
+    And the following "users" exist:
+      | username | firstname | lastname | email |
+      | teacher1 | Teacher | 1 | teacher1@example.com |
+      | student1 | Student | 1 | student1@example.com |
+    And the following "course enrolments" exist:
+      | user | course | role |
+      | teacher1 | C1 | editingteacher |
+      | student1 | C1 | student |
+    And the following config values are set as admin:
+      | autosavefrequency | 1 | editor_atto |
+    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 |
+      | assignsubmission_file_enabled | 0 |
+    And I log out
+    And I log in as "student1"
+    And I follow "Course 1"
+    And I follow "Test assignment name"
+    When I press "Add submission"
+    And I set the following fields to these values:
+      | Online text | text submission |
+    # Wait for the draft auto save.
+    And I wait "2" seconds
+    And I follow "Course 1"
+    And I follow "Test assignment name"
+    When I press "Add submission"
+    # Confirm draft was restored.
+    Then I should see "text submission" in the "#id_onlinetext_editoreditable" "css_element"