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

Quiz message sending: contexturl passed to messages is a mdl_url not a string

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 4.2.1
    • 4.2
    • Quiz
    • MOODLE_402_STABLE
    • MOODLE_402_STABLE
    • MDL-78307-master
    • Hide

      Setup LMS

      1. Ensure that your site is available globally (e.g. use ngrok)
      2. Register with the Airnotifier service (https://apps.moodle.com/).
      3. Navigate to Site administration -> Messaging -> Mobile
      4. Put the Airnotifier access key in place
      5. In this same page, ensure that the setting `message_airnotifier | encryptnotifications` is off
      6. Navigate to Site administration -> General -> Advanced features
      7. Ensure the setting `enablemobilewebservice` is on.
      8. Ensure that you have a course with a student enrolled.
      9. In this course, create a new quiz with the following settings:
        1. "Timing > Time limit" set to 1 minute.
        2. "Timing > When time expires" set to "There is a grace period when open attempts ...".
        3. "Timing > Submission grace period" set to 2 minutes.
      10. Add 1 question to this quiz (any question is ok).
      11. Grant the student user all the capabilities starting with "mod/quiz:email". E.g. you can just grant them to the Authenticated user role in "Site administration > Users > Define roles".

      Setup app

      1. Install the Moodle app from Google Play or App Store (depending on your device) in a mobile device.
      2. In the app, login in your site using the student account.
      3. Click your profile image at the top-right or top-left and click "Preferences".
      4. Open "Notifications".
      5. Select "Mobile" in "Type of notification" (it should be selected by default) and enable all the notifications under the Quiz section. If you don't see a Quiz section or you don't see the option "Warning when your quiz attempt becomes overdue" then it means the user lacks some of the capabilities specified in the last step of the previous section.
      6. Click the 3 dots button at the top (kebab button) and click "Configure devices". Check that your device appears in the list and is enabled.
      7. Go back to the Notification preferences page, select "Web" in "Type of notification" and enable all the notifications under the Quiz section.

      Test

      1. In browser, login as the student.
      2. Open the quiz and start a new attempt.
      3. Don't submit the quiz, just wait for the time to expire.
      4. When the time reaches 0, you should receive a notification in the mobile device saying "Attempt now overdue...".
      5. Click the notification. Check that the quiz is opened in the app.
      Show
      Setup LMS Ensure that your site is available globally (e.g. use ngrok) Register with the Airnotifier service ( https://apps.moodle.com/ ). Navigate to Site administration -> Messaging -> Mobile Put the Airnotifier access key in place In this same page, ensure that the setting `message_airnotifier | encryptnotifications` is off Navigate to Site administration -> General -> Advanced features Ensure the setting `enablemobilewebservice` is on. Ensure that you have a course with a student enrolled. In this course, create a new quiz with the following settings: "Timing > Time limit" set to 1 minute. "Timing > When time expires" set to "There is a grace period when open attempts ...". "Timing > Submission grace period" set to 2 minutes. Add 1 question to this quiz (any question is ok). Grant the student user all the capabilities starting with "mod/quiz:email". E.g. you can just grant them to the Authenticated user role in "Site administration > Users > Define roles". Setup app Install the Moodle app from Google Play or App Store (depending on your device) in a mobile device. In the app, login in your site using the student account. Click your profile image at the top-right or top-left and click "Preferences". Open "Notifications". Select "Mobile" in "Type of notification" (it should be selected by default) and enable all the notifications under the Quiz section. If you don't see a Quiz section or you don't see the option "Warning when your quiz attempt becomes overdue" then it means the user lacks some of the capabilities specified in the last step of the previous section. Click the 3 dots button at the top (kebab button) and click "Configure devices". Check that your device appears in the list and is enabled. Go back to the Notification preferences page, select "Web" in "Type of notification" and enable all the notifications under the Quiz section. Test In browser, login as the student. Open the quiz and start a new attempt. Don't submit the quiz, just wait for the time to expire. When the time reaches 0, you should receive a notification in the mobile device saying "Attempt now overdue...". Click the notification. Check that the quiz is opened in the app.

      This is a regression caused by MDL-76614.

      In quiz locallib.php, the contexturl is set to the result of $attemptobj->view_url(). In Moodle 4.1, this function returned a string (it returned $this->quizobj->view_url(), and this function returned a string). After the refactor done in MDL-76614, the quizobj instance now returns a moodle_url instead of a string.

      The contexturl supplied to message_send is supposed to be a string (or at least it was until now, and I guess it still is for all the notifications that aren't quiz related). This data is passed to Airnotifier and then to the app as a push notification. This causes problems in the app, because the app expects to receive a string but it receives an empty object instead.  

      There might be other places affected by this change, this is the one we noticed during our QA tests. It would be good to review all the usages of view_url to make sure it's being used as expected with the new return type.

            dpalou Dani Palou
            dpalou Dani Palou
            Juan Leyva Juan Leyva
            Tim Hunt Tim Hunt
            Carlos Escobedo Carlos Escobedo
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 4 hours, 43 minutes
                4h 43m

                  Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.