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

Create new tables for messages and notifications and convert existing API to use these

    XMLWordPrintable

    Details

    • Testing Instructions:
      Hide

      Testing the Messaging UI

      Pre-requisites.
      1. A site with multiple users (50+).
      2. A site with multiple courses, each course containing enrolled users as students (50+).
      3. A main user you will be using for testing that is enrolled in a course as a student, who has no existing messages or contacts.
      Test 1 - Searching and adding contacts.
      1. Log in as the your main user and click on the user menu and then 'Messages'.
      2. Confirm you see 'No messages'.
      3. Click on the 'Contacts' tab.
      4. Confirm you see 'No contacts'.
      5. Perform a search that will return nothing (eg 'asdzxce1412414').
      6. Confirm you see 'No results'.
      7. Perform a search that will return multiple users and courses (eg. 'a' which may be in many users' names).
      8. Confirm there are only 'Courses' and 'Non-contacts' displayed.
      9. Click on a non-contact.
      10. Click on 'Add contact'.
      11. Click on the 'Contacts' tab.
      12. Confirm the user is display there.
      13. Perform a search that will return multiple users and courses (eg. 'a' which may be in many users' names).
      14. Confirm there are now 'Contacts', 'Courses' and 'Non-contacts' displayed.
      15. Click on a 'Course' name'.
      16. Confirm you are shown a list of users in that course.
      17. Scroll down the list and confirm it infinitely loads.
      18. Perform another search and confirm it only shows users in the course matching your search.
      19. Click on a user and add them as a contact.
      20. Click on the 'Contacts' tab.
      21. Confirm you now have two contacts shown.
      22. Perform a few more detailed searches and confirm the results are correct.
      Test 2 - Sending a message to a contact.
      1. Log in as the your main user and click on the user menu and then 'Messages'.
      2. Click on the 'Contacts' tab.
      3. Click on one of the 'Contacts' you added in the earlier test.
      4. Click on 'View messages'.
      5. Send them a message.
      6. Ensure you are now on the 'Messages' tab and can see the message you sent.
      7. Send them another 49 messages.
      8. Refresh the page.
      9. Ensure you are shown the latest messages in the convo and are taken to the bottom of the messaging window.
      10. Scroll up and confirm the messages are infinitely loaded and are in the right order.
      11. Log in as the user you sent the messages to and confirm in the 'Messaging' icon at the top of the page you can see that there are unread messages.
      12. Click to view the message, ensure it is no longer marked as unread.
      13. Send a reply to your main user.
      14. Now, log in as another completely different user and send the main user a message as well (use the search to find the user).
      15. Log in as your main user and confirm you are notified that there are unread messages.
      16. Click on the user menu and then 'Messages'.
      17. Confirm the most recent conversation is loaded.
      18. Confirm the other conversation is marked as unread.
      19. Click on that and confirm it is marked as read as well.
      20. Now, send 50 people messages using the search functionality.
      21. Confirm on the messages tab you can infinitely scroll through the conversations.
      Test 3 - Searching messages
      1. Log in as the your main user and click on the user menu and then 'Messages'.
      2. Perform a search that will return nothing (eg 'asdzxce1412414').
      3. Confirm you see 'No results'.
      4. Perform a search on the messages and confirm it works as expected (Messages sent from yourself should show the string 'You:' and others shouldn't).
      Test 4 - Deleting messages
      1. Log in as the your main user and click on the user menu and then 'Messages'.
      2. Click on 'Edit' in the top right of the conversation you are viewing.
      3. Confirm that you can click on messages to highlight them.
      4. Select a few random messages.
      5. Click on 'Delete selected messages'
      6. Confirm they are removed.
      7. Refresh the page and revisit the conversation and confirm they are still no longer present.
      8. Log in as the user who is on the receiving end of the messages.
      9. Confirm the messages are not deleted for him.
      Test 5 - Deleting all messages
      1. Log in as the your main user and click on the user menu and then 'Messages'.
      2. Click on 'Edit' in the top right.
      3. Click on 'Delete all'.
      4. Confirm a dialogue confirmation appears.
      5. Click 'No' and confirm it disappears and you are back to normal.
      6. Click on 'Delete all'.
      7. Confirm a dialogue confirmation appears.
      8. Click 'Yes' and confirm it disappears and the conversation is no longer listed.
      9. Refresh the page and confirm the conversation is still no longer present.
      10. Log in as the user who is on the receiving end of the messages.
      11. Confirm the conversation is not deleted for them.
      Test 6 - Play around
      1. Have a play around and explore.

      Notifications, popovers and preferences

      A couple of ways I've found to generate a notifications

      • Add a submission to an assignment (I generally use online text). This should result in an immediate notifications.
      • Modify a submission to an assignment, This should result in an immediate notification.
      • Grade an assignment as a teacher. This requires cron to be run in order to generate the notification.
      • See the attached "create_notifications.php" script which will generate 20 notifications to user with id 3 from user with id 2. These are just junk data notifications to be used to test the infinite scrolling. Please generate real notifications (see above) for the other testing.

      Notification preferences

      The notification preferences page allows a user to customise which types of notifications they would like to get from Moodle and how they would like to receive them.

      You can access the notification preference page in two ways:

      1. Click the notification popover in the nav bar > click the cog
      2. user menu > preferences > notification preferences

      All modifications made on the preferences page should be saved via ajax.

      To test:
      • The Disabling all notifications setting will stop moodle from notifying the user of all notifications that occurs while it is enabled. Those notifications are never shown to the user, even after notifications are enabled again. Once notifications are enabled again the user should be notified as normal.
      • Disabling online notifications for a particular notification type will stop the user from receiving those notifications while they are logged in to Moodle (or within 5 minutes of them logging out, I think). They should receive those notifications as normal while they are logged in however.
      • Disabling offline notifications should behave opposite to the above.
      • Disabling both online and offline should result in no notifications of that type being received by the user at all.
      • Disabling/enabling notifications will not change any previously received data. If the user has previously received a notification of a given type then they will still see it even if that notification has since been disabled. The settings on affect future notifications.
      • You should be able to configure some of the notification processors directly. The processors that are configurable (e.g. email) should appear as a link and have a cog next to their name. Clicking it should open a modal with configuration options. Not all processors as configurable (e.g. Web).
      • As an admin you are able to lock/disallow certain notifications for the entire site. These can be configured here: site admin > plugins > message outputs > default message outputs. These notifications should be displayed as "Locked" and "Disallowed" respectively and are not modifiable by the user on their preferences page.

      Message preferences

      This page allows the user to configure any settings relating to messages.

      It currently only allows the user to prevent non-contacts from messages them and to configure how they would like to be notified about messages.

      Note: The "web" process (e.g. the popovers in the nav bar) can no be disabled for messaging.

      You can access the message preference page in two ways:

      1. Click the message popover in the nav bar > click the cog
      2. user menu > preferences > message preferences
      To test:
      • All form elements are saved via ajax
      • Should behave similarly to the notification preferences page.

      Notification popover

      The notification popover is the little bell that appears in the nav bar. It tells the user of any new notifications they've received, according to the rules they've configured on their notification preferences page. This is designed to only provide a summarised version of the notification with more detail provided on the full notifications page.

      Note: The popover doesn't currently poll the server for new notifications. You'll need to reload the page in order to see any new notifications.

      To test:
      • The notification count badge when the popover is closed should accurately represent the number of unread notifications.
      • When the menu is open it should list all notifications from newest to oldest. Unread notifications should be styled differently.
      • The notification list should infinitely scroll (it loads the notifications in chunks of 20).
      • Clicking a notification should take you to the resource the notification was concerning (e.g. the relevant assignment or what ever).
      • Clicking an unread notification should mark it as read
      • Clicking "view more" on a notification should take you to the notifications page and load the full notification information. It should also mark that notification as read.
      • Clicking the "mark all as read" button should mark all notification as read
      • The popover should not appear if you're not logged in or if you're a guest user.

      Notifications page

      This page is to display the notifications in more detail, with the popover providing the summarised view. It looks similar to the messages page and shows the complete list of notifications on the left and a full detailed view of the selected notification on the right panel.

      To test:
      • The notifications appear in order of newest to oldest in the left panel
      • Selecting a notification should show you the full notification detail in the right panel including the subject, body and a link to the relevant resource at the bottom (the "Go to: <blah>" link)
      • The notification list is infinitely scrollable (loaded in batches of 20 notifications).
      • Clicking on an unread notification should mark it as read and should also decrement the unread notification count in the notification popover (and also remove the unread styling of the notification in the popover).

      Messages popover

      The message popover is the little message bubble that appears in the nav bar. It tells the user of any new messages they've received, according to the rules they've configured on their messages preferences page.

      Note: The popover doesn't currently poll the server for new notifications. You'll need to reload the page in order to see any new messages.

      To test:
      • The messages count badge when the popover is closed should accurately represent the number of unread conversations the user has, not the number of unread messages. That means if the user has 20 unread messages from user 2, it will only show as a 1 in the popover badge (e.g. they have one unread conversation).
      • When the menu is open it should list all conversations from newest to oldest.
      • Unread conversations should be styled differently and should have a badge that indicates the number of unread messages within that unread conversation (in the example above it would have "20" in it).
      • The conversations list should infinitely scroll (it loads the conversations in chunks of 20).
      • Clicking a conversation should take you to the full conversation on the messages page.
      • Clicking an unread message should mark it as read
      • Clicking the "mark all as read" button should mark all messages as read
      • The popover should not appear if you're not logged in or if you're a guest user.
      Show
      Testing the Messaging UI Pre-requisites. A site with multiple users (50+). A site with multiple courses, each course containing enrolled users as students (50+). A main user you will be using for testing that is enrolled in a course as a student, who has no existing messages or contacts. Test 1 - Searching and adding contacts. Log in as the your main user and click on the user menu and then 'Messages'. Confirm you see 'No messages'. Click on the 'Contacts' tab. Confirm you see 'No contacts'. Perform a search that will return nothing (eg 'asdzxce1412414'). Confirm you see 'No results'. Perform a search that will return multiple users and courses (eg. 'a' which may be in many users' names). Confirm there are only 'Courses' and 'Non-contacts' displayed. Click on a non-contact. Click on 'Add contact'. Click on the 'Contacts' tab. Confirm the user is display there. Perform a search that will return multiple users and courses (eg. 'a' which may be in many users' names). Confirm there are now 'Contacts', 'Courses' and 'Non-contacts' displayed. Click on a 'Course' name'. Confirm you are shown a list of users in that course. Scroll down the list and confirm it infinitely loads. Perform another search and confirm it only shows users in the course matching your search. Click on a user and add them as a contact. Click on the 'Contacts' tab. Confirm you now have two contacts shown. Perform a few more detailed searches and confirm the results are correct. Test 2 - Sending a message to a contact. Log in as the your main user and click on the user menu and then 'Messages'. Click on the 'Contacts' tab. Click on one of the 'Contacts' you added in the earlier test. Click on 'View messages'. Send them a message. Ensure you are now on the 'Messages' tab and can see the message you sent. Send them another 49 messages. Refresh the page. Ensure you are shown the latest messages in the convo and are taken to the bottom of the messaging window. Scroll up and confirm the messages are infinitely loaded and are in the right order. Log in as the user you sent the messages to and confirm in the 'Messaging' icon at the top of the page you can see that there are unread messages. Click to view the message, ensure it is no longer marked as unread. Send a reply to your main user. Now, log in as another completely different user and send the main user a message as well (use the search to find the user). Log in as your main user and confirm you are notified that there are unread messages. Click on the user menu and then 'Messages'. Confirm the most recent conversation is loaded. Confirm the other conversation is marked as unread. Click on that and confirm it is marked as read as well. Now, send 50 people messages using the search functionality. Confirm on the messages tab you can infinitely scroll through the conversations. Test 3 - Searching messages Log in as the your main user and click on the user menu and then 'Messages'. Perform a search that will return nothing (eg 'asdzxce1412414'). Confirm you see 'No results'. Perform a search on the messages and confirm it works as expected (Messages sent from yourself should show the string 'You:' and others shouldn't). Test 4 - Deleting messages Log in as the your main user and click on the user menu and then 'Messages'. Click on 'Edit' in the top right of the conversation you are viewing. Confirm that you can click on messages to highlight them. Select a few random messages. Click on 'Delete selected messages' Confirm they are removed. Refresh the page and revisit the conversation and confirm they are still no longer present. Log in as the user who is on the receiving end of the messages. Confirm the messages are not deleted for him. Test 5 - Deleting all messages Log in as the your main user and click on the user menu and then 'Messages'. Click on 'Edit' in the top right. Click on 'Delete all'. Confirm a dialogue confirmation appears. Click 'No' and confirm it disappears and you are back to normal. Click on 'Delete all'. Confirm a dialogue confirmation appears. Click 'Yes' and confirm it disappears and the conversation is no longer listed. Refresh the page and confirm the conversation is still no longer present. Log in as the user who is on the receiving end of the messages. Confirm the conversation is not deleted for them. Test 6 - Play around Have a play around and explore. Notifications, popovers and preferences A couple of ways I've found to generate a notifications Add a submission to an assignment (I generally use online text). This should result in an immediate notifications. Modify a submission to an assignment, This should result in an immediate notification. Grade an assignment as a teacher. This requires cron to be run in order to generate the notification. See the attached "create_notifications.php" script which will generate 20 notifications to user with id 3 from user with id 2. These are just junk data notifications to be used to test the infinite scrolling. Please generate real notifications (see above) for the other testing. Notification preferences The notification preferences page allows a user to customise which types of notifications they would like to get from Moodle and how they would like to receive them. You can access the notification preference page in two ways: Click the notification popover in the nav bar > click the cog user menu > preferences > notification preferences All modifications made on the preferences page should be saved via ajax. To test: The Disabling all notifications setting will stop moodle from notifying the user of all notifications that occurs while it is enabled. Those notifications are never shown to the user, even after notifications are enabled again. Once notifications are enabled again the user should be notified as normal. Disabling online notifications for a particular notification type will stop the user from receiving those notifications while they are logged in to Moodle (or within 5 minutes of them logging out, I think). They should receive those notifications as normal while they are logged in however. Disabling offline notifications should behave opposite to the above. Disabling both online and offline should result in no notifications of that type being received by the user at all. Disabling/enabling notifications will not change any previously received data. If the user has previously received a notification of a given type then they will still see it even if that notification has since been disabled. The settings on affect future notifications. You should be able to configure some of the notification processors directly. The processors that are configurable (e.g. email) should appear as a link and have a cog next to their name. Clicking it should open a modal with configuration options. Not all processors as configurable (e.g. Web). As an admin you are able to lock/disallow certain notifications for the entire site. These can be configured here: site admin > plugins > message outputs > default message outputs. These notifications should be displayed as "Locked" and "Disallowed" respectively and are not modifiable by the user on their preferences page. Message preferences This page allows the user to configure any settings relating to messages. It currently only allows the user to prevent non-contacts from messages them and to configure how they would like to be notified about messages. Note: The "web" process (e.g. the popovers in the nav bar) can no be disabled for messaging. You can access the message preference page in two ways: Click the message popover in the nav bar > click the cog user menu > preferences > message preferences To test: All form elements are saved via ajax Should behave similarly to the notification preferences page. Notification popover The notification popover is the little bell that appears in the nav bar. It tells the user of any new notifications they've received, according to the rules they've configured on their notification preferences page. This is designed to only provide a summarised version of the notification with more detail provided on the full notifications page. Note: The popover doesn't currently poll the server for new notifications. You'll need to reload the page in order to see any new notifications. To test: The notification count badge when the popover is closed should accurately represent the number of unread notifications. When the menu is open it should list all notifications from newest to oldest. Unread notifications should be styled differently. The notification list should infinitely scroll (it loads the notifications in chunks of 20). Clicking a notification should take you to the resource the notification was concerning (e.g. the relevant assignment or what ever). Clicking an unread notification should mark it as read Clicking "view more" on a notification should take you to the notifications page and load the full notification information. It should also mark that notification as read. Clicking the "mark all as read" button should mark all notification as read The popover should not appear if you're not logged in or if you're a guest user. Notifications page This page is to display the notifications in more detail, with the popover providing the summarised view. It looks similar to the messages page and shows the complete list of notifications on the left and a full detailed view of the selected notification on the right panel. To test: The notifications appear in order of newest to oldest in the left panel Selecting a notification should show you the full notification detail in the right panel including the subject, body and a link to the relevant resource at the bottom (the "Go to: <blah>" link) The notification list is infinitely scrollable (loaded in batches of 20 notifications). Clicking on an unread notification should mark it as read and should also decrement the unread notification count in the notification popover (and also remove the unread styling of the notification in the popover). Messages popover The message popover is the little message bubble that appears in the nav bar. It tells the user of any new messages they've received, according to the rules they've configured on their messages preferences page. Note: The popover doesn't currently poll the server for new notifications. You'll need to reload the page in order to see any new messages. To test: The messages count badge when the popover is closed should accurately represent the number of unread conversations the user has, not the number of unread messages. That means if the user has 20 unread messages from user 2, it will only show as a 1 in the popover badge (e.g. they have one unread conversation). When the menu is open it should list all conversations from newest to oldest. Unread conversations should be styled differently and should have a badge that indicates the number of unread messages within that unread conversation (in the example above it would have "20" in it). The conversations list should infinitely scroll (it loads the conversations in chunks of 20). Clicking a conversation should take you to the full conversation on the messages page. Clicking an unread message should mark it as read Clicking the "mark all as read" button should mark all messages as read The popover should not appear if you're not logged in or if you're a guest user.
    • Affected Branches:
      MOODLE_23_STABLE, MOODLE_29_STABLE, MOODLE_33_STABLE, MOODLE_34_STABLE
    • Fixed Branches:
      MOODLE_35_STABLE
    • Pull from Repository:
    • Pull Master Branch:
      MDL-36941_master

      Description

      Currently we have message and message_read. These could be a single table with a "read" column. Some amount of profiling will be necessary to check that the check for unread messages does not unduly burden the server if the message table is large.

        Attachments

        1. create_notifications.php
          2 kB
        2. index_with_patch.png
          index_with_patch.png
          129 kB
        3. index_without_patch.png
          index_without_patch.png
          113 kB
        4. testmessage_after.php
          2 kB
        5. testmessage_after2.php
          2 kB
        6. testmessage_before.php
          2 kB

          Issue Links

            Activity

              People

              • Votes:
                4 Vote for this issue
                Watchers:
                18 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  17/May/18

                  Time Tracking

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