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

mod_quiz_get_attempt_data web service should return some question settings as well as the rendered question

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide
      1. As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings
      2. Create a new course and enrol a user (u1) as student
      3. Create a new quiz in the course using the default configuration except: Layout -> New page -> Every 3 questions
      4. Add 3 questions to the quiz:
        • 1: Essay configured to use "HTML Editor" as response format, "Allow attachments" set to NO
        • 2: Essay configured to use "No online text" as response format, "Allow attachments" set to 1 and "require attachments" to 1
        • 3: Numerical
      5. Access with the student user u1 to the site, go to the course and open the quiz
      6. Add some text in the first question, attach a file in the second question and reply the last question
      7. Click "Finish attempt" and nothing else, you will see the summary of the attempt
      8. In the browser URL you will see an URL like this: mod/quiz/summary.php?attempt=X&cmid=Y. You have to copy the X value somewhere because you will use it later
      9. Create a Token in the mobile app service for the user1 in the site (not an admin account)
        • Click on Site administration ► Plugins ► Web services ► Manage tokens
      10. Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. the ATTEMPT_ID value has to be replaced with the attempt value (the X value) you annotated before

        curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_quiz_get_attempt_summary&wstoken=3af67232a7596ceb658df4db329e5ad6&attemptid=ATTEMPT_ID' | python -m "json.tool"

      11. Confirm that:
        • In the curl request response (that is huge) you will see that 3 questions are returned
        • For the first two questions, the essay ones, you will see a "settings" field (json formatted) containing an array of configuration options with different values
        • In the first question, the settings->responseformat will be set to editor
        • In the second question, the settings->attachment and settings->attachmentsrequired value will be 1
        • For the last question, the numerical one, you will see also a settings field containing an array with the following configuration options: units, unitsgradingtype, unitpenalty, unitdisplay, unitsleft
      Show
      As admin, enable "Mobile services": Site administration ► Mobile app ► Mobile settings Create a new course and enrol a user (u1) as student Create a new quiz in the course using the default configuration except: Layout -> New page -> Every 3 questions Add 3 questions to the quiz: 1: Essay configured to use "HTML Editor" as response format, "Allow attachments" set to NO 2: Essay configured to use "No online text" as response format, "Allow attachments" set to 1 and "require attachments" to 1 3: Numerical Access with the student user u1 to the site, go to the course and open the quiz Add some text in the first question, attach a file in the second question and reply the last question Click "Finish attempt" and nothing else, you will see the summary of the attempt In the browser URL you will see an URL like this: mod/quiz/summary.php?attempt=X&cmid=Y. You have to copy the X value somewhere because you will use it later Create a Token in the mobile app service for the user1 in the site (not an admin account) Click on Site administration ► Plugins ► Web services ► Manage tokens Open the console an execute this new curl request, replacing wstoken with the token you just created and the site url with yours. the ATTEMPT_ID value has to be replaced with the attempt value (the X value) you annotated before curl 'http://localhost/m/stable_master/webservice/rest/server.php?moodlewsrestformat=json' --data 'wsfunction=mod_quiz_get_attempt_summary&wstoken=3af67232a7596ceb658df4db329e5ad6&attemptid=ATTEMPT_ID' | python -m "json.tool" Confirm that: In the curl request response (that is huge) you will see that 3 questions are returned For the first two questions, the essay ones, you will see a "settings" field (json formatted) containing an array of configuration options with different values In the first question, the settings->responseformat will be set to editor In the second question, the settings->attachment and settings->attachmentsrequired value will be 1 For the last question, the numerical one, you will see also a settings field containing an array with the following configuration options: units, unitsgradingtype, unitpenalty, unitdisplay, unitsleft
    • Affected Branches:
      MOODLE_39_STABLE
    • Fixed Branches:
      MOODLE_310_STABLE
    • Pull from Repository:
    • Pull 3.10 Branch:
      MDL-69823-310
    • Pull Master Branch:
      MDL-69823-master

      Description

      This web service is used when rendering quiz questions in the mobile app. However, at present it just returns the rendered HTML of the question. It does not return any of the question options as structured data. (This was discussed, long ago, in https://moodle.org/mod/forum/discuss.php?d=382348.)

      For example, the essay question type is not returning the file extensions allowed to be submitted as part of the user's response.

      However, the was this web service is designed to work, it must only send data that the student is allowed to know. So, for example, it would be wrong to sent the entire question_definition object data, because that includes things such as the right answer, and all feedback, which the student should to be able to see until the question is finished.

      Therefore, in order to fix this, we need a new method on the question class, to return the important options for the question in its current state, but without giving away any inappropriate information to a student who accessed the raw data.
       

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jleyva Juan Leyva
              Reporter:
              jleyva Juan Leyva
              Peer reviewer:
              Tim Hunt
              Integrator:
              Sara Arjona (@sarjona)
              Tester:
              Janelle Barcega
              Participants:
              Component watchers:
              Tim Hunt, Andrew Nicols, Dongsheng Cai, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
              Votes:
              1 Vote for this issue
              Watchers:
              7 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Fix Release Date:
                18/Jan/21

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 day, 2 hours, 52 minutes
                  1d 2h 52m