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

New Web Service mod_quiz_get_attempt_data

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Fixed
    • Icon: Minor Minor
    • 3.1
    • 3.0.2
    • Quiz, Web Services
    • MOODLE_30_STABLE
    • MOODLE_31_STABLE
    • MDL-52813-master
    • Hide
      1. Bump your /version.php file to force Moodle to reload the Mobile service
      2. Create a course with a couple of students (s1 and s2).
      3. Create a mod_quiz activity with a couple of questions (true or false, or numerical)
      4. Now, as the s1, open the quiz and start and attempt (please, do not finish it)
      5. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      6. Create a Token for s1 and s2
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      7. First of all, we are going to check all the access and capabilities controls, you will use this curl command but need to replace the wstoken, attemptid (the attempt id) and the URL of your moodle instance

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'attemptid=11&page=1&wsfunction=mod_quiz_get_attempt_data&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&preflightdata%5B0%5D%5Bname%5D=quizpassword'

      8. As admin, edit the quiz and add a passed timeopen/timeclose (so the quiz is close in dates)
      9. Run the curl command to confirm that you see errors or warnings
      10. Now, remove the timeopen/timeclose restrictions and add a password
      11. Run the curl command to confirm that you see errors or warnings
      12. Now, remove the password and replace the wstoken with the s2 user one
      13. Run the curl command to confirm that you see errors or warnings
      14. Now, relace the wstoken with the s1 one, and edit the curl command replacing page=1 with page=5
      15. Run the curl command to confirm that you see errors or warnings
      16. Now, use page=1 again, but go to the web interface and as user s1 finish the attempt you started
      17. Run the curl command again and confirm that you see errors (the attempt is finished)
      18. In the web interface as user s1 again, start a new attempt in the quiz (you will have to replace the attemptid in the curl command)
      19. Now, as an admin add a passowr "abc" and run the curl command using the new attempt id and a valid page

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'attemptid=11&page=1&wsfunction=mod_quiz_get_attempt_data&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&preflightdata%5B0%5D%5Bname%5D=quizpassword&preflightdata%5B0%5D%5Bvalue%5D=abc'

      20. Everything should work as expected, you should receive the attempt object, empty messages, a value for nextpage (-1 if the page is the last one) and the questions array with one question
      21. As an admin now, edit the quiz settings again and choose to display 2 questions per page
      22. Run the curl command again using page = 0, you should see now that the 2 pages are returned
      23. Now, confirm that the html rendered for the question that you receive is correct (is match with the one in the web interface)
      Show
      Bump your /version.php file to force Moodle to reload the Mobile service Create a course with a couple of students (s1 and s2). Create a mod_quiz activity with a couple of questions (true or false, or numerical) Now, as the s1, open the quiz and start and attempt (please, do not finish it) As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for s1 and s2 Click on Site administration ► Plugins ► Web services ► Manage tokens First of all, we are going to check all the access and capabilities controls, you will use this curl command but need to replace the wstoken, attemptid (the attempt id) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'attemptid=11&page=1&wsfunction=mod_quiz_get_attempt_data&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&preflightdata%5B0%5D%5Bname%5D=quizpassword' As admin, edit the quiz and add a passed timeopen/timeclose (so the quiz is close in dates) Run the curl command to confirm that you see errors or warnings Now, remove the timeopen/timeclose restrictions and add a password Run the curl command to confirm that you see errors or warnings Now, remove the password and replace the wstoken with the s2 user one Run the curl command to confirm that you see errors or warnings Now, relace the wstoken with the s1 one, and edit the curl command replacing page=1 with page=5 Run the curl command to confirm that you see errors or warnings Now, use page=1 again, but go to the web interface and as user s1 finish the attempt you started Run the curl command again and confirm that you see errors (the attempt is finished) In the web interface as user s1 again, start a new attempt in the quiz (you will have to replace the attemptid in the curl command) Now, as an admin add a passowr "abc" and run the curl command using the new attempt id and a valid page curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'attemptid=11&page=1&wsfunction=mod_quiz_get_attempt_data&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&preflightdata%5B0%5D%5Bname%5D=quizpassword&preflightdata%5B0%5D%5Bvalue%5D=abc' Everything should work as expected, you should receive the attempt object, empty messages, a value for nextpage (-1 if the page is the last one) and the questions array with one question As an admin now, edit the quiz settings again and choose to display 2 questions per page Run the curl command again using page = 0, you should see now that the 2 pages are returned Now, confirm that the html rendered for the question that you receive is correct (is match with the one in the web interface)

      Returns information for the given attempt page for a quiz attempt in progress

      Parameters:

      • attemptid
      • pageid
      • preflightdata (optional) We need this because we don have a session object persistent between Web Service requests

      Returns:

      • Attempt object (with the attempt information)
      • Next page number
      • A list of access messages
      • A list of questions rendered

            jleyva Juan Leyva
            jleyva Juan Leyva
            Tim Hunt Tim Hunt
            Dan Poltawski Dan Poltawski
            Simey Lameze Simey Lameze
            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.