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

SMS notifications: Implement SMS as a new notification method and set up for Assignment notifications

XMLWordPrintable

    • MOODLE_500_STABLE
    • MOODLE_500_STABLE
    • MDL-83518-main
    • Hide

      When it comes to testing, this resource for testing SMS sending in AWS will likely come in handy: https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html

      Prerequisites

      To test this issue you'll need a Moodle that you have admin access to.

      You will need a resource for testing SMS sending in AWS.

      Having an admin account makes it easier to move through all of the test settings.
      If you don't have cli access to the instance make sure you have access to two separate admin accounts. As part of the testing, it will lock out a user.

      Set up your SMS Sandbox

      1. Access to https://signin.aws.amazon.com with your credentials.
      2. From your AWS Console go to Amazon SNS / Mobile / Text messaging(SMS) and enable it.
      3. Include some "Sandbox destination phone numbers"
      4. From Security credentials: create a new Access key for this and save the "Key", "Secret" and Region for the configuration in Moodle. 

      More information about SMS sandbox can be found 

      It might also be helpful to ensure your timezone is set correctly as the times we will be testing with are very tight. Site admin -> Location -> Location settings -> Default timezone

      Scheduled task setup

      1. Log in as admin
      2. Go to Site admin->Server->Tasks->Scheduled tasks
      3. CONFIRM there is a task called 'Notify user of an assignment that is overdue'
      4. CONFIRM that it is set to run on a random minute, every hour.

      SMS processor setup

      1. Login as admin
      2. Go to site admin > Messaging > Notification settings
      3. Enable SMS processor
      4. Enable SMS for assignment
      5. Setup an SMS gateway in SMS gateway management page in: site admin > plugins > Manage SMS gateways

      Also, make sure users have a Mobile phone number in their profile. You can use one mobile number as all you need to test is you are getting the SMS for the correct user and notification.

      Testing scenario 1

      1. Log in as an admin and create a course.
      2. Log in as a teacher.
      3. Enroll a student (student1).
      4. Create an assignment with a due date two hour ago.
      5. Log in as student1 and go to User -> Preferences -> Notification preferences.
      6. CONFIRM there is a notification preference called 'Assignment overdue notification' and SMS is enabled.
      7. Run this scheduled task: 

        php admin/cli/scheduled_task.php --execute=\\mod_assign\\task\\queue_all_assignment_overdue_notification_tasks 

      8. Run cron (there are multiple ad-hoc tasks involved to send notifications and SMS, please run a couple of times if not received the first time): 

        php admin/cli/cron.php

      9. CONFIRM you got an SMS about this notification.

      Testing scenario 3

      1. Log back in as the teacher.
      2. Enrol another student (student3).
      3. Go to the assignment.
      4. Go to More->Overrides.
      5. Add a user override for student3 and set the 'Due date' one week from now and save changes.
      6. Run the scheduled task again (see above).
      7. Run cron (see above).
      8. Log in as student3
      9. CONFIRM that you do not have a new notification.
      10. Log in as the teacher
      11. Adjust the override date for the user to 30 minutes ago.
      12. Run the scheduled task again (see above).
      13. Run cron (see above).
      14. CONFIRM you got an SMS about this notification.

      Testing scenario 4

      1. Log back in as the teacher.
      2. Enrol two more students (student4 and student5)
      3. Assign these two users to a group (group1)
      4. Go to the assignment.
      5. Go to More->Overrides.
      6. Add a group override for group1 and set the 'Due date' one week from now.
      7. Run the scheduled task again (see above).
      8. Run cron (see above).
      9. Log in as student4 and student 5
      10. CONFIRM that you do not have a new notifications for either of them.
      11. Log in as the teacher
      12. Adjust the override date for the group to 30 minutes ago.
      13. Run the scheduled task again (see above).
      14. Run cron (see above).
      15. CONFIRM you got an SMS about this notification.

      Testing scenario 5

      1. Log in as student1.
      2. Submit the assignment.
      3. Log back in as the teacher.
      4. Go the assignment settings.
      5. Edit the 'Due date' to 30 mins ago.
      6. Run the scheduled task again (see above).
      7. Run cron (see above).
      8. Log in as student1
      9. CONFIRM that you do not have a new SMS about the due date soon (ignore the one you will probably have regarding submission).
      10. Enrol another student (student2).
      11. Log in as student2.
      12. CONFIRM that you have a new SMS notification about the overdue assignment with the updated date.

      Testing scenario 6

      1. Log back in as the teacher.
      2. Go to the assignment settings.
      3. Edit the 'Due date' to 15 mins ago.
      4. Add a 'Cut-off date' of 7 days from now.
      5. Run the scheduled task again (see above).
      6. Run cron (see above).
      7. Log in as student2.
      8. CONFIRM you got an SMS about this notification.
      9. Log back in as the teacher
      10. Go to the assignment settings page
      11. Edit the 'Due date' to 5 mins ago.
      12. Edit the 'Cut-off date' to 5 mins ago too.
      13. Run the scheduled task again (see above).
      14. Run cron (see above).
      15. Log in as student2.
      16. CONFIRM that you do not have a new SMS notification.
      Show
      When it comes to testing, this resource for testing SMS sending in AWS will likely come in handy: https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox.html Prerequisites To test this issue you'll need a Moodle that you have admin access to. You will need a resource for testing SMS sending in AWS. Having an admin account makes it easier to move through all of the test settings. If you don't have cli access to the instance make sure you have access to two separate admin accounts. As part of the testing, it will lock out a user. Set up your SMS Sandbox Access to https://signin.aws.amazon.com with your credentials. From your AWS Console go to Amazon SNS / Mobile / Text messaging(SMS) and enable it. Include some "Sandbox destination phone numbers" From Security credentials: create a new Access key for this and save the "Key", "Secret" and Region for the configuration in Moodle.  More information about SMS sandbox can be found  https://aws.amazon.com/blogs/compute/introducing-the-sms-sandbox-for-amazon-sns/ https://docs.aws.amazon.com/sns/latest/dg/sns-sms-sandbox-verifying-phone-numbers.html https://docs.aws.amazon.com/sns/latest/dg/sns-getting-started.html It might also be helpful to ensure your timezone is set correctly as the times we will be testing with are very tight. Site admin -> Location -> Location settings -> Default timezone Scheduled task setup Log in as admin Go to  Site admin->Server->Tasks->Scheduled tasks CONFIRM there is a task called 'Notify user of an assignment that is overdue' CONFIRM that it is set to run on a random minute, every hour. SMS processor setup Login as admin Go to site admin > Messaging > Notification settings Enable SMS processor Enable SMS for assignment Setup an SMS gateway in SMS gateway management page in: site admin > plugins > Manage SMS gateways Also, make sure users have a Mobile phone number in their profile. You can use one mobile number as all you need to test is you are getting the SMS for the correct user and notification. Testing scenario 1 Log in as an admin and create a course. Log in as a teacher. Enroll a student (student1). Create an assignment with a due date two hour ago. Log in as student1 and go to  User -> Preferences -> Notification preferences. CONFIRM there is a notification preference called 'Assignment overdue notification' and SMS is enabled. Run this scheduled task:  php admin/cli/scheduled_task.php --execute=\\mod_assign\\task\\queue_all_assignment_overdue_notification_tasks Run cron (there are multiple ad-hoc tasks involved to send notifications and SMS, please run a couple of times if not received the first time):  php admin/cli/cron.php CONFIRM you got an SMS about this notification. Testing scenario 3 Log back in as the teacher. Enrol another student (student3). Go to the assignment. Go to  More->Overrides. Add a user override for student3 and set the 'Due date' one week from now and save changes. Run the scheduled task again (see above). Run cron (see above). Log in as student3 CONFIRM  that you  do not  have a new notification. Log in as the teacher Adjust the override date for the user to 30 minutes ago. Run the scheduled task again (see above). Run cron (see above). CONFIRM you got an SMS about this notification. Testing scenario 4 Log back in as the teacher. Enrol two more students (student4 and student5) Assign these two users to a group (group1) Go to the assignment. Go to  More->Overrides. Add a group override for group1 and set the 'Due date' one week from now. Run the scheduled task again (see above). Run cron (see above). Log in as student4 and student 5 CONFIRM  that you  do not  have a new notifications for either of them. Log in as the teacher Adjust the override date for the group to 30 minutes ago. Run the scheduled task again (see above). Run cron (see above). CONFIRM you got an SMS about this notification. Testing scenario 5 Log in as student1. Submit the assignment. Log back in as the teacher. Go the assignment settings. Edit the 'Due date' to 30 mins ago. Run the scheduled task again (see above). Run cron (see above). Log in as student1 CONFIRM that you do not have a new SMS about the due date soon (ignore the one you will probably have regarding submission). Enrol another student (student2). Log in as student2. CONFIRM that you have a new SMS notification about the overdue assignment with the updated date. Testing scenario 6 Log back in as the teacher. Go to the assignment settings. Edit the 'Due date' to 15 mins ago. Add a 'Cut-off date' of 7 days from now. Run the scheduled task again (see above). Run cron (see above). Log in as student2. CONFIRM you got an SMS about this notification. Log back in as the teacher Go to the assignment settings page Edit the 'Due date' to 5 mins ago. Edit the 'Cut-off date' to 5 mins ago too. Run the scheduled task again (see above). Run cron (see above). Log in as student2. CONFIRM that you do not have a new SMS notification.
    • Show
      Fails against automated checks. Checked MDL-83518 using repository: https://github.com/safatshahin/moodle.git main (1 errors / 7 warnings) [branch: MDL-83518-main | CI Job ] overview (0/0) , phplint (0/0) , phpcs (0/0) , js (0/0) , css (0/0) , phpdoc (0/0) , commit (1/1) , savepoint (0/0) , thirdparty (0/0) , externalbackup (0/0) , grunt (0/0) , shifter (0/0) , mustache (0/6) , gherkin (0/0) , Should these errors be fixed? Built on: Tue Jan 28 03:56:37 AM UTC 2025
    • Show
      Launching automatic jobs for branch MDL-83518 -main https://ci.moodle.org/view/Testing/job/DEV.02%20-%20Developer-requested%20PHPUnit/18782/ PHPUnit (sqlsrv / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64326/ Behat (NonJS - boost and classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64327/ Behat (Firefox - boost / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64328/ Behat (Firefox - classic / complete) https://ci.moodle.org/view/Testing/job/DEV.01%20-%20Developer-requested%20Behat/64329/ App tests (stable app version) / complete) Built on: Tue Mar 25 06:41:42 UTC 2025
    • 0
    • Team Dragons 2025 Sprint 1.2, Team Dragons 2025 Sprint 1.3

      Requirements:

      1. Add the ability to define an SMS version of notifications (currently we have HTML and plain).
      2. Add SMS as an admin configurable notification method (consistent with other notification methods).
      3. Add SMS as a notifications type on the notifications toggle page (where users control which methods they'd like to receive each notification type from).
      4. Implement SMS notifications for all of the existing notifications under "Assignment" (ie all of the notifications controlled by the existing Assignment notification options to be sent by email/web/mobile).
      5. Implementing logic to handle reducing the length of messages that exceed the provider's max length. At this stage it should just truncate the message when it hits the max length.

      Out of scope:

      • Including URLs at the end of the notifications. This requires an inbuilt URL shortener which has not yet been implemented.
      • Implementing logic to handle reducing the length of messages that exceed the provider's max length using the logic/findings of the technical spike in MDL-81469.

      Note: I've created this as a single issue initially to capture the scope and requirements breakdown. These requirements may be broken down into several issues before being pulled into an active sprint. That may not be possible due to inter-dependencies of all the pieces, but if we do decide to break it down, we can collect and land the functionality within this issue, since it will all need to land together.

            safat.shahin@moodle.com Safat Shahin
            michaelh Michael Hawkins
            Meirza Meirza
            Andrew Lyons Andrew Lyons
            Mikel Martín Corrales Mikel Martín Corrales
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved:

                Estimated:
                Original Estimate - 0 minutes
                0m
                Remaining:
                Remaining Estimate - 0 minutes
                0m
                Logged:
                Time Spent - 3 hours, 23 minutes
                3h 23m

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