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

New Web Service mod_quiz_process_attempt

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1
    • 3.0.2
    • Quiz
    • MOODLE_30_STABLE
    • MOODLE_31_STABLE
    • MDL-52863-master
    • 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 at least 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. As student do the quiz and check that the value is correctly saved and you can finish succesfully the attempt
      8. Now, as the student, open in Moodle the quiz and start another new attempt (please, do not answer any question)
      9. 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), you can also replace the flagged elements
      10. 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_process_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'

      11. Confirm that you see a response containing state equal to 'inprogress'
      12. Now, reload the question page in Moodle, you should see now that the question is marked as saved
      13. Edit the curl request and append: &finishattempt=1, execute the curl request and confirm that in Moodle the attempt is now marked as finished (the curl response should indicate state = 'finished')
      14. Now, start a new attempt
      15. As admin add the quiz settings, add a passed timeopen/timeclose date (at leask one week agao)
      16. Run the last command replacing the attemptid and the question names/values and check that now the state is abandoned
      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 at least 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 As student do the quiz and check that the value is correctly saved and you can finish succesfully the attempt Now, as the student, open in Moodle the quiz and start another new 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), you can also replace the flagged elements 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_process_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 state equal to 'inprogress' Now, reload the question page in Moodle, you should see now that the question is marked as saved Edit the curl request and append: &finishattempt=1, execute the curl request and confirm that in Moodle the attempt is now marked as finished (the curl response should indicate state = 'finished') Now, start a new attempt As admin add the quiz settings, add a passed timeopen/timeclose date (at leask one week agao) Run the last command replacing the attemptid and the question names/values and check that now the state is abandoned

      Process responses during an attempt at a quiz

      Parameters:
      attemptid - The attempt id
      finishattempt - Whether to finish or not the attempt
      timeup - Whether the WS was called by a timer
      data - the data to be processed, post format

      Returns:
      state - the quiz attempt state after the processing: quiz_attempt::IN_PROGRESS, quiz_attempt::OVERDUE, quiz_attempt::FINISHED, quiz_attempt::ABANDONED

            jleyva Juan Leyva
            jleyva Juan Leyva
            Tim Hunt Tim Hunt
            Dan Poltawski Dan Poltawski
            Ryan Wyllie Ryan Wyllie
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

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