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

Changes in the quiz module for supporting offline quizzes in the Mobile app

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. You will have go to administration -> notifications to upgrade the quiz module and install the new access rule
      2. Enable mobile services in Plugins -> Webservices -< Mobile
        # Create a course with a student.
      3. Create a mod_quiz activity, in the access restriction section check the "Allow offline attempts in the mobile app" setting", confirm that:
        • The new setting is correctly stored in the database
      4. Now disable mobile services
      5. Go to the quiz module settings, check that the the previous setting is not visible anymore
      6. Add a couple of questions to the quiz
      7. As admin, enable "Mobile services": Plugins ► Web Services ► Mobile
      8. Create a Token for the student user
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      9. Next, you can do a CURL REST call simulating a WS client with the student user.
        • You need to replace the wstoken, course id and the URL of your moodle instance

          curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseids%5B0%5D=4&wsfunction=mod_quiz_get_quizzes_by_courses&wstoken=1b9cc9f44630b554bb2c9428b8744338'

      10. Check that the values for that setting is correctly retrieved: allowofflineattempts
      11. 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&preflightdata%5B0%5D%5Bname%5D=confirmdatasaved&preflightdata%5B0%5D%5Bvalue%5D=1&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed

      12. Go to the Moodle web interface and check that now there's a new attempt for the student user in the quiz
      13. Now, log in in the site using the student user account
      14. Open the quiz and click to continue the attempt
      15. You should see a warning: You have worked on this attempt in a mobile device, and that data was last saved to this site XY ago.....?
      16. Check the chexbock and Accept
      17. You should be able to continue the attempt, please don't finish it
      18. Now, do a new curl request for getting the attempt information:

        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=confirmdatasaved&preflightdata%5B0%5D%5Bvalue%5D=1'

      19. Check that in the response, for each question you see now this new three fields: sequencecheck, lastactiontime and hasautosavedstep
      Show
      You will have go to administration -> notifications to upgrade the quiz module and install the new access rule Enable mobile services in Plugins -> Webservices -< Mobile # Create a course with a student. Create a mod_quiz activity, in the access restriction section check the "Allow offline attempts in the mobile app" setting", confirm that: The new setting is correctly stored in the database Now disable mobile services Go to the quiz module settings, check that the the previous setting is not visible anymore Add a couple of questions to the quiz 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, course id and the URL of your moodle instance curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'courseids%5B0%5D=4&wsfunction=mod_quiz_get_quizzes_by_courses&wstoken=1b9cc9f44630b554bb2c9428b8744338' Check that the values for that setting is correctly retrieved: allowofflineattempts 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&preflightdata%5B0%5D%5Bname%5D=confirmdatasaved&preflightdata%5B0%5D%5Bvalue%5D=1&wstoken=ffbe3a3002f235bf9d01fd9369e10b66' --compressed Go to the Moodle web interface and check that now there's a new attempt for the student user in the quiz Now, log in in the site using the student user account Open the quiz and click to continue the attempt You should see a warning: You have worked on this attempt in a mobile device, and that data was last saved to this site XY ago.....? Check the chexbock and Accept You should be able to continue the attempt, please don't finish it Now, do a new curl request for getting the attempt information: 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=confirmdatasaved&preflightdata%5B0%5D%5Bvalue%5D=1' Check that in the response, for each question you see now this new three fields: sequencecheck, lastactiontime and hasautosavedstep
    • Affected Branches:
      MOODLE_30_STABLE, MOODLE_31_STABLE, MOODLE_32_STABLE
    • Fixed Branches:
      MOODLE_32_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-53870-master

      Description

      In order to support offline quizzes in the Mobile app several changes are required (see spec here):

      Add two new options for enabling quizzes offline and for forcing a quiz to be attempted only in Moodle web.

      • Allow quiz to be attempted offline in the mobile app (allowofflineattempts)
      • Don't allow quiz to be attempted in the mobile app (forbidmobileattempts)

      This options won't be displayed if the Mobile service is not enabled in the site (in this way we don't add additional options to the quiz)

      Add a new field in the quiz_attempts table to keep track of the last time a quiz was attempted via the app (web services): timemodifiedws

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  5/Dec/16