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

External functions view_attempt and view_attempt_summary are missing the parameter preflightdata

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 3.1
    • Fix Version/s: 3.1
    • Component/s: Quiz
    • Labels:
    • Testing Instructions:
      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"
    • Affected Branches:
      MOODLE_31_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-53976-master

      Description

      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 Dani Palou for spotting this

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Pau Ferrer
              Integrator:
              Andrew Nicols
              Tester:
              Jake Dallimore
              Participants:
              Component watchers:
              Tim Hunt, Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

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