Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-73073

New attempt timing feature in assignment is lacking Web Service support

XMLWordPrintable

    • MOODLE_400_STABLE
    • MOODLE_400_STABLE
    • MDL-73073-master_assign_timing_web_services
    • Hide

      All of the new functionality is related to web services. There are no ways to test it directly in the UI. The best way to test this would be to set up a course with an assignment activity and call the external functions directly using your preferred method such as postman or curl.

      Setup

      1. Log in as admin
      2. Create a new user with shortname: student1.
      3. Create a new user with shortname: teacher1.
      4. Create a new course.
      5. Enrol 'student1' in a student role.
      6. Enrol 'teacher1' in a editing teacher role.
      7. Create a course module 'assignment'.
      8. Enable web services and your desired web protocol.
      9. Enable web services for mobile devices
      10. Create a new web service that includes the following external functions:
        1. mod_assign_get_assignments
        2. mod_assign_get_submissions
        3. mod_assign_get_submission_status
      11. Create a web service token for both student1 and teacher1.

      Test mod_assign_get_assignments

      1. Log in as admin
      2. Go to course
      3. Go to assignment and open settings
      4. Empty the 'Activity' textbox
      5. Disable 'Only show files during submission'
      6. Make a request to mod_assign_get_assignments using student1 token.

        curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&wsfunction=mod_assign_get_assignments' | json_pp > output.json
        

      7. The following fieldsĀ not present:
        1. activity
        2. activityformat
        3. activityattachments
      8. You should see the following fields for the assignment:
        1. timelimit
        2. submissionattachments
      9. Go to assignment settings
      10. Add some text in the 'Activity' box
      11. Make a request to mod_assign_get_assignments using student1 token.

        curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&wsfunction=mod_assign_get_assignments' | json_pp > output.json
        

      12. Open output.json file
      13. You should see the following fields for the assignment:
        1. timelimit
        2. submissionattachments
        3. activity
        4. activityformat
        5. activityattachments

      Test mod_assign_get_submissions

      1. Log in as admin
      2. Go to Site administration -> Plugins -> Assignment settings
      3. Disable assign | enabletimelimit
      4. Go to course
      5. Go to assignment and open settings
      6. Disable 'Only show files during submission'
      7. Log in as student1
      8. Go to course
      9. Click on assignment
      10. Click 'Add assignment'
      11. Get the assignment id. You may need to get this directly from DB table 'prefix_course_modules'. So smth like

        select instance from mdl_course_modules cm join mdl_modules m on m.id = cm.module where course = 300 and m.name = 'assign';
        

      12. Make a request to mod_assign_get_submissions using teacher1 token and 'assignmentids[]={id from step 12}'

        curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assignmentids[0]=ASSIGNMENTID&wsfunction=mod_assign_get_submissions' | json_pp > output.json
        

      13. Open output.json file
      14. You should see the 'timestarted' field
      15. The 'timestarted' field should be null.
      16. Log in as admin
      17. Go to Site administration -> Plugins -> Assignment settings
      18. Enable assign | enabletimelimit
      19. Go to course
      20. Go to assignment and open settings.
      21. Enable 'Time limit' and set it to 5 minutes.
      22. Log in as student1
      23. Go to course
      24. Click on assignment
      25. Click 'Begin assignment'
      26. Click 'Begin assignment' in popup
      27. Make a request to mod_assign_get_submission using teacher1 token and 'assignmentids[]={id from step 12}'

        curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assignmentids[0]=ASSIGNMENTID&wsfunction=mod_assign_get_submissions' | json_pp > output.json
        

      28. You should see the 'timestarted' field
      29. The 'timestarted' field should be the timestamp of when you clicked the being assignment popup button.

      Test mod_assign_get_submission_status

      1. Log in as admin
      2. Go to course
      3. Go to assignment and open settings
      4. Disable time limit
      5. Go to Site administration -> Plugins -> Assignment settings
      6. Disable assign | enabletimelimit
      7. Go to course
      8. Go to assignment and open settings
      9. Disable 'Only show files during submission'
      10. Empty the 'Activity' textbox
      11. Empty the 'Extra attachments' field
      12. Get the assign id and user id for 'student1'. You may need to get this directly from DB table 'prefix_course_modules'. User id can be found in URL on student1 profile page.
      13. Go to assignment and click 'View submissions'
      14. Click the checkbox for student1 and select mass action 'Remove submission', then click go to remove all submissions for student1.
      15. Log in as student1
      16. Go to course
      17. Click on assignment
      18. Click 'Add assignment'
      19. Make a request to mod_assign_get_submission_status using teacher1 token and params: assignid:{assign id}, userid:{student1 user id}

        curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assigntid=ASSIGNMENTID&userid=USERID&wsfunction=mod_assign_get_submission_status' | json_pp > output.json
        

      20. You should see the 'timelimit' field in the 'lastattempt' array
      21. You should see the 'assignmentdata' field
      22. You should see the 'intro' field that is empty in the 'assignmentdata[attachments]'
      23. You should not see 'activity' or 'activityformat' data in 'assignmentdata'
      24. Log in as admin
      25. Go to Site administration -> Plugins -> Assignment settings
      26. Enable assign | enabletimelimit
      27. Go to course
      28. Go to assignment and open settings
      29. Disable 'Only show files during submission'
      30. Enable 'Time limit' and set it to 5 minutes.
      31. Add text to the 'Activity' textbox and add an image.
      32. Upload a file to 'Extra files'.
      33. Make a request to mod_assign_get_submission using teacher1 token and params: assignid:{assign id}, userid:{student1 user id}

        curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assigntid=ASSIGNMENTID&userid=USERID&wsfunction=mod_assign_get_submission_status' | json_pp > output.json
        

      34. You should see the 'timelimit' field in the 'lastattempt' array equal to '300'
      35. You should see the 'assignmentdata' field
      36. You should see the 'intro' field that is not empty in the 'assignmentdata[attachments]'
      37. You should see the 'activity' and 'activityformat' field that is not empty in the 'assignmentdata'
      38. You should see the 'activity' field that is not empty in the 'assignmentdata[attachments]'

      Test mod_assign_get_submission_status with 'Only show files during submission'

      1. Log in as admin
      2. Go to course
      3. Go to assignment and open settings
      4. Enable 'Only show files during submission'
      5. Add text to the 'Activity' textbox and add an image.
      6. Upload a file to 'Extra files'.
      7. Enable 'Allow submissions from' and set it do a date in the future.
      8. Get the assign id and user id for 'student1'. You may need to get this directly from DB table 'prefix_course_modules'. User id can be found in URL on student1 profile page.
      9. Go to assignment and click 'View submissions'
      10. Click the checkbox for student1 and select mass action 'Remove submission', then click go to remove all submissions for student1.
      11. Make a request to mod_assign_get_submission_status using student1 token and params: assignid:{assign id}
      12. You should see the 'assignmentdata' field
      13. You should see there is no 'intro' field in the 'assignmentdata[attachments]'
      14. You should see the 'activity' and 'activityformat' field is not empty in 'assignmentdata'
      15. You should see the 'activity' field is not empty in the 'assignmentdata[attachments]'
      16. Make a request to mod_assign_get_submission_status using teacher1 token and params: assignid:{assign id}, userid:{student1 id}

        curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assigntid=ASSIGNMENTID&userid=USERID&wsfunction=mod_assign_get_submission_status' | json_pp > output.json
        

      17. You should see the 'assignmentdata' field
      18. You should see the 'intro' field is not empty in the 'assignmentdata[attachments]'
      19. You should see the 'activity' and 'activityformat' field is not empty in 'assignmentdata'
      20. You should see the 'activity' field is not empty in the 'assignmentdata[attachments]'
      21. Go to assignment and open settings
      22. Set 'Allow submissions from' to a date in the past.
      23. Make a request to mod_assign_get_submission_status using student1 token and params: assignid:{assign id}

        curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assigntid=ASSIGNMENTID&userid=USERID&wsfunction=mod_assign_get_submission_status' | json_pp > output.json
        

      24. You should see the 'assignmentdata' field
      25. You should see the 'intro' field is not empty in the 'assignmentdata[attachments]'
      26. You should see the 'activity' and 'activityformat' field is not empty in the 'assignmentdata'
      27. You should see the 'activity' field is not empty in the 'assignmentdata[attachments]'
      Show
      All of the new functionality is related to web services. There are no ways to test it directly in the UI. The best way to test this would be to set up a course with an assignment activity and call the external functions directly using your preferred method such as postman or curl. Setup Log in as admin Create a new user with shortname: student1. Create a new user with shortname: teacher1. Create a new course. Enrol 'student1' in a student role. Enrol 'teacher1' in a editing teacher role. Create a course module 'assignment'. Enable web services and your desired web protocol. Enable web services for mobile devices Create a new web service that includes the following external functions: mod_assign_get_assignments mod_assign_get_submissions mod_assign_get_submission_status Create a web service token for both student1 and teacher1. Test mod_assign_get_assignments Log in as admin Go to course Go to assignment and open settings Empty the 'Activity' textbox Disable 'Only show files during submission' Make a request to mod_assign_get_assignments using student1 token. curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&wsfunction=mod_assign_get_assignments' | json_pp > output.json The following fieldsĀ  not present : activity activityformat activityattachments You should see the following fields for the assignment: timelimit submissionattachments Go to assignment settings Add some text in the 'Activity' box Make a request to mod_assign_get_assignments using student1 token. curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&wsfunction=mod_assign_get_assignments' | json_pp > output.json Open output.json file You should see the following fields for the assignment: timelimit submissionattachments activity activityformat activityattachments Test mod_assign_get_submissions Log in as admin Go to Site administration -> Plugins -> Assignment settings Disable assign | enabletimelimit Go to course Go to assignment and open settings Disable 'Only show files during submission' Log in as student1 Go to course Click on assignment Click 'Add assignment' Get the assignment id. You may need to get this directly from DB table 'prefix_course_modules'. So smth like select instance from mdl_course_modules cm join mdl_modules m on m.id = cm.module where course = 300 and m.name = 'assign' ; Make a request to mod_assign_get_submissions using teacher1 token and 'assignmentids[]={id from step 12}' curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assignmentids[0]=ASSIGNMENTID&wsfunction=mod_assign_get_submissions' | json_pp > output.json Open output.json file You should see the 'timestarted' field The 'timestarted' field should be null. Log in as admin Go to Site administration -> Plugins -> Assignment settings Enable assign | enabletimelimit Go to course Go to assignment and open settings. Enable 'Time limit' and set it to 5 minutes. Log in as student1 Go to course Click on assignment Click 'Begin assignment' Click 'Begin assignment' in popup Make a request to mod_assign_get_submission using teacher1 token and 'assignmentids[]={id from step 12}' curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assignmentids[0]=ASSIGNMENTID&wsfunction=mod_assign_get_submissions' | json_pp > output.json You should see the 'timestarted' field The 'timestarted' field should be the timestamp of when you clicked the being assignment popup button. Test mod_assign_get_submission_status Log in as admin Go to course Go to assignment and open settings Disable time limit Go to Site administration -> Plugins -> Assignment settings Disable assign | enabletimelimit Go to course Go to assignment and open settings Disable 'Only show files during submission' Empty the 'Activity' textbox Empty the 'Extra attachments' field Get the assign id and user id for 'student1'. You may need to get this directly from DB table 'prefix_course_modules'. User id can be found in URL on student1 profile page. Go to assignment and click 'View submissions' Click the checkbox for student1 and select mass action 'Remove submission', then click go to remove all submissions for student1. Log in as student1 Go to course Click on assignment Click 'Add assignment' Make a request to mod_assign_get_submission_status using teacher1 token and params: assignid:{assign id}, userid:{student1 user id} curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assigntid=ASSIGNMENTID&userid=USERID&wsfunction=mod_assign_get_submission_status' | json_pp > output.json You should see the 'timelimit' field in the 'lastattempt' array You should see the 'assignmentdata' field You should see the 'intro' field that is empty in the 'assignmentdata [attachments] ' You should not see 'activity' or 'activityformat' data in 'assignmentdata' Log in as admin Go to Site administration -> Plugins -> Assignment settings Enable assign | enabletimelimit Go to course Go to assignment and open settings Disable 'Only show files during submission' Enable 'Time limit' and set it to 5 minutes. Add text to the 'Activity' textbox and add an image. Upload a file to 'Extra files'. Make a request to mod_assign_get_submission using teacher1 token and params: assignid:{assign id}, userid:{student1 user id} curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assigntid=ASSIGNMENTID&userid=USERID&wsfunction=mod_assign_get_submission_status' | json_pp > output.json You should see the 'timelimit' field in the 'lastattempt' array equal to '300' You should see the 'assignmentdata' field You should see the 'intro' field that is not empty in the 'assignmentdata [attachments] ' You should see the 'activity' and 'activityformat' field that is not empty in the 'assignmentdata' You should see the 'activity' field that is not empty in the 'assignmentdata [attachments] ' Test mod_assign_get_submission_status with 'Only show files during submission' Log in as admin Go to course Go to assignment and open settings Enable 'Only show files during submission' Add text to the 'Activity' textbox and add an image. Upload a file to 'Extra files'. Enable 'Allow submissions from' and set it do a date in the future. Get the assign id and user id for 'student1'. You may need to get this directly from DB table 'prefix_course_modules'. User id can be found in URL on student1 profile page. Go to assignment and click 'View submissions' Click the checkbox for student1 and select mass action 'Remove submission', then click go to remove all submissions for student1. Make a request to mod_assign_get_submission_status using student1 token and params: assignid:{assign id} You should see the 'assignmentdata' field You should see there is no 'intro' field in the 'assignmentdata [attachments] ' You should see the 'activity' and 'activityformat' field is not empty in 'assignmentdata' You should see the 'activity' field is not empty in the 'assignmentdata [attachments] ' Make a request to mod_assign_get_submission_status using teacher1 token and params: assignid:{assign id}, userid:{student1 id} curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assigntid=ASSIGNMENTID&userid=USERID&wsfunction=mod_assign_get_submission_status' | json_pp > output.json You should see the 'assignmentdata' field You should see the 'intro' field is not empty in the 'assignmentdata [attachments] ' You should see the 'activity' and 'activityformat' field is not empty in 'assignmentdata' You should see the 'activity' field is not empty in the 'assignmentdata [attachments] ' Go to assignment and open settings Set 'Allow submissions from' to a date in the past. Make a request to mod_assign_get_submission_status using student1 token and params: assignid:{assign id} curl --location -g --request GET 'http://PATHTOMOODLE/webservice/rest/server.php?moodlewsrestformat=json&wstoken=TOKEN&assigntid=ASSIGNMENTID&userid=USERID&wsfunction=mod_assign_get_submission_status' | json_pp > output.json You should see the 'assignmentdata' field You should see the 'intro' field is not empty in the 'assignmentdata [attachments] ' You should see the 'activity' and 'activityformat' field is not empty in the 'assignmentdata' You should see the 'activity' field is not empty in the 'assignmentdata [attachments] '

      In MDL-68913 a new feature was introduced to support time-limited submissions, similar to quiz.

      New fields were included in the database, but they are not being exported via Web Services (so it won't be possible to support this feature in the mobile app).

      Additional security checks should be also performed to check if submission via WS is not affected by the changes, continue working and it is not possible to bypass the time limit by doing WS requests.

      Also, we'll need a new WebService to start an attempt.

            andrewmadden Andrew Madden
            jleyva Juan Leyva
            Juan Leyva Juan Leyva
            Ilya Tregubov Ilya Tregubov
            Angelia Dela Cruz Angelia Dela Cruz
            Votes:
            3 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 6 hours, 21 minutes
                6h 21m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.