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

New Web Service mod_quiz_start_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, Web Services
    • Labels:
    • Testing Instructions:
      Hide
      1. Bump your /version.php file to force Moodle to reload the Mobile service
      2. Create a course with a student.
      3. Create a mod_quiz activity without questions
      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, quizid (the quiz instance value) and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'quizid=2&wsfunction=mod_quiz_start_attempt&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed

      7. Confirm that you see an exception with the text: noquestionsfound
      8. Now, as admin in Moodle add at least one question (true/false for example)
      9. Configure the quiz to use a passed timeopen and timeclose (the quiz must be close)
      10. Run the curl command again and confirm that you see warnings and an empty attemp
      11. Now, set timeopen and timeclose to 0 and add a password "abc"
      12. Run the curl command:

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'quizid=9&wsfunction=mod_quiz_start_attempt&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&preflightdata%5B0%5D%5Bname%5D=quizpassword&preflightdata%5B0%5D%5Bvalue%5D=badpassword'

      13. Confirm that you see "Exception expected due to invalid passwod"
      14. Now, replace "badpassword" with the correct password "abc"
      15. Confirm that after running the curl command you see a new attempt created
      16. Now, execute the command again, you should see an exception: attemptstillinprogress (you annot start a new attempt because theres one in progress)
      17. Go to the Moodle web interface using the student account, open the quiz, and finish the attempt that we just created
      18. Execute the curl command again, a new empty attempt should be created
      Show
      Bump your /version.php file to force Moodle to reload the Mobile service Create a course with a student. Create a mod_quiz activity without questions 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, quizid (the quiz instance value) and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'quizid=2&wsfunction=mod_quiz_start_attempt&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed Confirm that you see an exception with the text: noquestionsfound Now, as admin in Moodle add at least one question (true/false for example) Configure the quiz to use a passed timeopen and timeclose (the quiz must be close) Run the curl command again and confirm that you see warnings and an empty attemp Now, set timeopen and timeclose to 0 and add a password "abc" Run the curl command: curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'quizid=9&wsfunction=mod_quiz_start_attempt&wstoken=ffbe3a3002f235bf9d01fd9369e10b66&preflightdata%5B0%5D%5Bname%5D=quizpassword&preflightdata%5B0%5D%5Bvalue%5D=badpassword' Confirm that you see "Exception expected due to invalid passwod" Now, replace "badpassword" with the correct password "abc" Confirm that after running the curl command you see a new attempt created Now, execute the command again, you should see an exception: attemptstillinprogress (you annot start a new attempt because theres one in progress) Go to the Moodle web interface using the student account, open the quiz, and finish the attempt that we just created Execute the curl command again, a new empty attempt should be created
    • Affected Branches:
      MOODLE_30_STABLE
    • Fixed Branches:
      MOODLE_31_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-52788-master

      Description

      Starts a new attempt at a quiz.

      Parameters:

      • quizid
      • forcenew - to force a new attempt in review mode

      Returns:

      • attempt id
      • attempt unique id
      • attempt number
      • page (in cases like last attempt page)

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jleyva Juan Leyva
                Reporter:
                jleyva Juan Leyva
                Peer reviewer:
                Tim Hunt
                Integrator:
                David Monllaó
                Tester:
                David Monllaó
                Participants:
                Component watchers:
                Tim Hunt, Andrew Nicols, Mathew May, Michael Hawkins, Shamim Rezaie, Simey Lameze, Juan Leyva, Jake Dallimore, Jun Pataleta, Ryan Wyllie
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

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