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

New WS to allow removing submissions

XMLWordPrintable

    • MOODLE_311_STABLE, MOODLE_404_STABLE
    • MOODLE_405_STABLE
    • MDL-74050-main
    • Hide
      1. As admin, enable "Mobile services":
        • Enable “Web services for mobile devices” on Site administration ► Advanced features
      2. Create course, users and assignments:
        • Create a course
        • Create two users (student1, student2) and save the user ids
        • Create one editing teacher (teacher) and save the user id
        • Create two assign modules (assign1, assign2) and save the assign ids
      3. Create submissions:
        • In assign1 create submissions for student1 and student2
        • In assign2 create submissions for student1
      4. As admin, create users tokens:
        • Server ► Web Services ► Manage tokens:
          • Create a Token for teacher and save the teachertoken.
          • Create a Token for the student1 and save the student1token.
          • Create a Token for the student2 and save the student2token.
      5. Next, make CURL REST calls simulating a WS client.
        • You need to replace MOODLE_URL and make different calls changing $wstoken, $userid, and $assignid:
          curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_assign_remove_submission&wstoken=$wstoken&userid=$userid&assignid=$assignid' --compressed
          • Run the CURL with student1token, student1id and assign1id
            • Confirm that you receive a "true" response and the submission has been deleted on campus.
          • Run the CURL with student1token, student2id and assign1id
            • Confirm that you receive a "false" response, the warningcode is “couldnotremovesubmission” and the submission has not been deleted on campus
          • Run the CURL with teachertoken, student2id and assign1id
            • Confirm that you receive a "false" response, the warningcode is “couldnotremovesubmission” and the submission has not been deleted on campus
          • Run the CURL with student2token, student2id and assign2id
            • Confirm that you receive a "false" response, the warningcode is “submissionnotfoundtoremove” and the submission not exists.
          • Run the CURL with student1token, an non-existing user id and assign2id
            • Confirm that you receive a "false" response, the warningcode is “submissionnotfoundtoremove” and the submission not exists.
          • Run the CURL with student1token, student1id and an non-existing assign id
            • Confirm that you receive an “invalidrecord” exception.
      Show
      As admin, enable "Mobile services": Enable “Web services for mobile devices” on Site administration ► Advanced features Create course, users and assignments: Create a course Create two users (student1, student2) and save the user ids Create one editing teacher (teacher) and save the user id Create two assign modules (assign1, assign2) and save the assign ids Create submissions: In assign1 create submissions for student1 and student2 In assign2 create submissions for student1 As admin, create users tokens: Server ► Web Services ► Manage tokens: Create a Token for teacher and save the teachertoken. Create a Token for the student1 and save the student1token. Create a Token for the student2 and save the student2token. Next, make CURL REST calls simulating a WS client. You need to replace MOODLE_URL and make different calls changing $wstoken, $userid, and $assignid: curl 'MOODLE_URL/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_assign_remove_submission&wstoken=$wstoken&userid=$userid&assignid=$assignid' --compressed Run the CURL with student1token, student1id and assign1id Confirm that you receive a "true" response and the submission has been deleted on campus. Run the CURL with student1token, student2id and assign1id Confirm that you receive a "false" response, the warningcode is “couldnotremovesubmission” and the submission has not been deleted on campus Run the CURL with teachertoken, student2id and assign1id Confirm that you receive a "false" response, the warningcode is “couldnotremovesubmission” and the submission has not been deleted on campus Run the CURL with student2token, student2id and assign2id Confirm that you receive a "false" response, the warningcode is “submissionnotfoundtoremove” and the submission not exists. Run the CURL with student1token, an non-existing user id and assign2id Confirm that you receive a "false" response, the warningcode is “submissionnotfoundtoremove” and the submission not exists. Run the CURL with student1token, student1id and an non-existing assign id Confirm that you receive an “invalidrecord” exception.

      As mentioned in MOBILE-3893 we should allow the user to remove submissions.

      New WS name: mod_assign_remove_submission($userid)

      The WS should:

      • Get the instance $assign = new assign($context, $cm, $course);
      • Check if the current user has permission to remove the indicated submission ($assign->can_edit_submission($userid, $USER->id))
      • Then remove the submission ($assign->remove_submission($userid)), this function will return true/false
      • Return a "status" field, true means success (submission was removed)

            daniure Dani Ureña
            jleyva Juan Leyva
            Juan Leyva Juan Leyva
            Mihail Geshoski Mihail Geshoski
            Kim Jared Lucas Kim Jared Lucas
            Votes:
            0 Vote for this issue
            Watchers:
            13 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 2 weeks, 2 days, 7 hours, 27 minutes
                2w 2d 7h 27m

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