Show
Please note that this issue comes with some refactors in Moodle code core, refactors are minor because is basically moving code to new functions (no changes in the code), in any case testing requires both test the Web version and the WS version of the module.
Create a new course, enrol two students and one teacher. The course should be configured with visible groups, not forced.
Create a new group, enrol the two students there.
Now, create 3 assignment activities:
A1 - Set the group mode to 'None', assignment submission types: check all, feedback types: check all. The teacher must be able to reopen attempts (Attempts reopened setting set to manually). The user can upload up to 2 files.
A2 - Same as A1 but setting the group mode to visible groups, with the setting "Student submit in groups" on and Require all group members submit set to NO
A3 - Same as A2 but with Require all group members submit set to Yes
As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
Create a Token for both students and the teacher user:
Click on Site administration ► Plugins ► Web services ► Manage tokens
Now, access in the Web Interface to the assignment A1 with one of the students you created the token for and check that the submission status is no attempt and grading status is not graded
Next, you can do a CURL REST call simulating a WS client with one of the student users.
You need to replace the wstoken, assignid (with the instance id, not the cmid) and the URL of your moodle instance
curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'assignid=32&wsfunction=mod_assign_get_submission_status&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' | python -m "json.tool"
Now, check that in the JSON response you see: "gradingstatus": "notgraded" and "status": "new", "canedit": true and "cansubmit": false (cansubmit is used in combination with draftattemps so a false here is correct)
In the web interface now, do a submission attaching 2 files and text
Check in the web interface that the status is now Submitted for grading and the text and files submitted are displayed
Execute again the CURL request and check that the JSON response match the data displayed in the Web Interface: "status": "submitted", and the text and files submitted are correctly listed in the submission.plugins attribute (some information like the due date and time remaining is not returned because that information can be retrieved using the general mod_assign_get_assignments web service)
Now, as the teacher in the web interface grade the submission: add a grade, some feedback text, a feedback file and set Allow another attempt to Yes
In the web interface check now that you see that the submission was reopened, you see your previous submission including the feedback text, file and grade.
Execute the CURL request and check that:
Submission status is reopened
lastattempt "gradingstatus": "notgraded",
You see now a feedback attribute, with the formatted grade
You see now a previousattempts structure, including the previous attempt and the feedback text and files, the grade object and the submission for that attempt data (including files)
Now, as the student in the web interface submit the assignment again
As a teacher, grade and provide feedback for this las attempt, DO NOT set to Yes this time the Allow another attempt field.
Execute the CURL call again and check that now you see in the feedback structure the complete feedback and the grade object.
Execute the same CURL call as a teacher (need to change the token in the curl request to the one you created for the teacher), appending &userid=THE_STUDENT_ID to the curl call, you should see the same information plus a "gradingsummary" structure that matches the same information in the web interface
Now, using the token for the other student run the same CURL command, you should see an exception because that user shouldn't be able to view other user's attempts.
Now, repeat the same steps for A2 and A3, the only differences in that cases is that you should see an additional submission object (teamsubmission) and the submissiongroupmemberswhoneedtosubmit filled only for case A3.
Fetching the data for student 2 should give the same info as student1 for A2/A3 but they should not be able to view the data for student 1.