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

New Web Service mod_quiz_save_attempt

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.0.2
    • Fix Version/s: 3.1
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      Hide
      1. Bump your /version.php file to force Moodle to reload the Mobile service
      2. Create a course with a one student
      3. Create a mod_quiz activity with one numerical question
      4. Go to Site administration ▶︎ Plugins ▶︎ Activity modules ▶︎ Quiz and set the Auto-save delay to 0 seconds
      5. Enable "Mobile services": Plugins ► Web Services ► Mobile
      6. Create a Token for the student
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. Now, as the student, open in Moodle the quiz and start and attempt (please, do not answer any question)
      8. With the inspect tool, display all the form fields in the question, and replace the q15:3_answer names and values of the following command with the correct name and values from the form (you need to replace the following elements: name, sequencecheck and q:_answer for the q:*_answer use as value for example 5)
      9. Replace the wstoken and attemptid (and your site URL) and execute the following curl command

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'attemptid=15&wsfunction=mod_quiz_save_attempt&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&data%5B0%5D%5Bname%5D=slots&data%5B0%5D%5Bvalue%5D=3&data%5B1%5D%5Bname%5D=q15:3_:sequencecheck&data%5B1%5D%5Bvalue%5D=1&data%5B2%5D%5Bname%5D=q15:3_answer&data%5B2%5D%5Bvalue%5D=5'

      10. Confirm that you see a response containing status equal to true
      11. Now, reload the question page in Moodle, you should see now that the question is marked as saved with the value you used (the suggested was 5)
      Show
      Bump your /version.php file to force Moodle to reload the Mobile service Create a course with a one student Create a mod_quiz activity with one numerical question Go to Site administration ▶︎ Plugins ▶︎ Activity modules ▶︎ Quiz and set the Auto-save delay to 0 seconds Enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the student Click on Site administration ► Plugins ► Web services ► Manage tokens Now, as the student, open in Moodle the quiz and start and attempt (please, do not answer any question) With the inspect tool, display all the form fields in the question, and replace the q15:3_answer names and values of the following command with the correct name and values from the form (you need to replace the following elements: name, sequencecheck and q : _answer for the q :*_answer use as value for example 5) Replace the wstoken and attemptid (and your site URL) and execute the following curl command curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'attemptid=15&wsfunction=mod_quiz_save_attempt&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&data%5B0%5D%5Bname%5D=slots&data%5B0%5D%5Bvalue%5D=3&data%5B1%5D%5Bname%5D=q15:3_:sequencecheck&data%5B1%5D%5Bvalue%5D=1&data%5B2%5D%5Bname%5D=q15:3_answer&data%5B2%5D%5Bvalue%5D=5' Confirm that you see a response containing status equal to true Now, reload the question page in Moodle, you should see now that the question is marked as saved with the value you used (the suggested was 5)
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-52852-master

      Description

      Processes save requests during the quiz. This function is intended for the quiz auto-save feature.

      Parameters:
      attemptid
      data (the post data to be saved)

      Returns:
      status: true on success

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  23/May/16