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

New Web Service mod_quiz_start_attempt

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-52788-master
    • 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

      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)

            jleyva Juan Leyva
            jleyva Juan Leyva
            Tim Hunt Tim Hunt
            David Monllaó David Monllaó
            David Monllaó David Monllaó
            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.