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

External functions view_attempt and view_attempt_summary are missing the parameter preflightdata

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • 3.1
    • 3.1
    • Quiz
    • MOODLE_31_STABLE
    • MOODLE_31_STABLE
    • MDL-53976-master
    • Hide
      1. Create a course with a student
      2. Create a mod_quiz activity requiring password, use "abc" as password
      3. Log in as the student and open the quiz activity, start a new attempt (do not finish it)
      4. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      5. Create a Token for the student user
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      6. Next, you can do a CURL REST call simulating a WS client with the student user .
        • You need to replace the wstoken, attemptid and the URL of your moodle instance

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

      7. Confirm that
        • You can see new entries in the course log (quiz attempt viewed) for that course and the user. The origin for the new log entries is "ws"
        • If you use an incorrect password, you see an error as the ws response
      8. Now, execute the same curl request but removing &page=0 and replacing, mod_quiz_view_attempt with mod_quiz_view_attempt_summary
      9. Check that there is a new entry in the course log (quiz attempt summary viewed) with origin "ws"
      Show
      Create a course with a student Create a mod_quiz activity requiring password, use "abc" as password Log in as the student and open the quiz activity, start a new attempt (do not finish it) As admin, enable "Mobile services": Plugins ► Web Services ► Mobile Create a Token for the student user Click on Site administration ► Plugins ► Web services ► Manage tokens Next, you can do a CURL REST call simulating a WS client with the student user . You need to replace the wstoken, attemptid and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'attemptid=2&wsfunction=mod_quiz_view_attempt&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&page=0&preflightdata%5B0%5D%5Bname%5D=quizpassword&preflightdata%5B0%5D%5Bvalue%5D=abc'' Confirm that You can see new entries in the course log (quiz attempt viewed) for that course and the user. The origin for the new log entries is "ws" If you use an incorrect password, you see an error as the ws response Now, execute the same curl request but removing &page=0 and replacing, mod_quiz_view_attempt with mod_quiz_view_attempt_summary Check that there is a new entry in the course log (quiz attempt summary viewed) with origin "ws"

      Those functions are validating the attempt using the internal static method validate_attempt where preflightdata is required.

      This Web Services are not going to work when the quiz requires a password or another access rule that requires user input.

      Thanks dpalou for spotting this

            jleyva Juan Leyva
            jleyva Juan Leyva
            Pau Ferrer Pau Ferrer
            Andrew Lyons Andrew Lyons
            Jake Dallimore Jake Dallimore
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

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