Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix list activity notifications #12386

Open
wants to merge 16 commits into
base: release-v0.17.x
Choose a base branch
from

Conversation

AlexVelezLl
Copy link
Member

@AlexVelezLl AlexVelezLl commented Jul 1, 2024

Summary

There have been a large number of inconsistencies between generating notifications on an original device, and creating notifications when a device is importing a facility from another device. Mainly because the notifications are not created in chronological order, but are created as the log records are imported. Which leads to the main assumption that notifications are created in a chronological order being incorrect. This PR fixes the following:

  • In the ClassroomNotifications API, Filter and return notifications in chronological order instead of sorting them by id.
    • Updated the before and after params to receive timestamps instead of an id.
    • A new desc index was created on the timestamp field of the learnerprogressnotification table.
    • A new ClassroomNotificationsFilter class was created to update the way to filter records to use filtersets.
  • Until now, if a notification already existed, creating/updating the notification generated by other resources/attempts was avoided. But now the notifications are updated in the following cases:
    • The lesson completed notification is updated if a resource is processed that has a greater completion_time than the existing notification had. So we always keep the latest resource completion_time as the lesson completion_time.
    • (for exercise resources) The resource started notification is updated if an attempt is processed that has a lower start_time than the existing notification had. So we always keep the earliest attempt start_time as the resource start_time.
    • The lesson started notification is updated if a resource is processed that has a lower start_time than the existing notification had. So we always keep the earliest resource start_time as the lesson start_time.
    • The help needed notification is updated if the student has newer attempts and keeps having incorrect interactions. So we always keep the timestamp of the most recent attempt that has an incorrect interaction. (This is also a change for the original device).
  • Avoid creating notifications when a content summary log is created (in batch) for an exercise resource, as the resource started time for exercise resources is determined by the first attempt and not by the content summary log.
  • Now the resource completion time for exercise resources is determined by the earliest attempt completion_time logged in the MasteryLog, rather than using the content summary log end_time.
  • Until now, completion notifications were avoided if the contentsummarylog of a resource had progress <1. But this was not true in cases where the student clicked on "try again" and the progress was = 0, but the notification should still be created when importing. So now the summarylog progress and completion_time are taken into account to determine whether or not to:
    • Create a resource completed notification.
    • Determine if all lesson resources are completed, to create a lesson completed notification (this last one is a bug that could also happen on the original device).
  • Some refactor and code reuse to avoid many parts of repeated code in the notifications api.
  • In the frontend, in the coachnotifications module:
    • the list of notifications was not properly being sorted.
    • We now sort notifications, allNotifications by timestamp.
    • If the first load of notifications returned just Answered notifications, an empty notifications list was rendered without option for the user to see more notifications. So now we load more notifications until the user could see the latests notifications.

References

Closes #11782.

Reviewer guidance

Set up a device with multiiple lessons/resources/quizes and play with it to have different types of notifications. Then import the facility to a new device and check that notificatoins match.


Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • Automated test coverage is satisfactory
  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added DEV: backend Python, databases, networking, filesystem... APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) labels Jul 1, 2024
@AlexVelezLl AlexVelezLl added work-in-progress Not ready for review labels Jul 2, 2024
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A good start, but I think we can make the changeover to timestamp a bit more systematically.

One other thing that would be important to investigate in this changeover, is whether we need to add a db_index to the timestamp field: https://github.com/learningequality/kolibri/blob/develop/kolibri/core/notifications/models.py#L117 the primary key (id) is indexed by default, so querying solely by timestamp may be considerably less performant.

kolibri/core/logger/api.py Outdated Show resolved Hide resolved
kolibri/plugins/coach/api.py Outdated Show resolved Hide resolved
kolibri/plugins/coach/api.py Outdated Show resolved Hide resolved
@@ -154,9 +154,6 @@
const params = {
...this.filterParam,
};
if (this.notifications.length) {
params.before = this.notifications.slice(-1)[0].id;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this been removed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The before param is already set inside the moreNotificationsForClass action https://github.com/AlexVelezLl/kolibri/blob/cdb559e453c0c6468ef95d4c97ad7bfdb342d9ec/kolibri/plugins/coach/assets/src/modules/coachNotifications/index.js#L104. So it was repeated code and thought it was better to keep the one in the moreNotificationsForClass action,

@AlexVelezLl AlexVelezLl added TODO: needs review Waiting for review and removed work-in-progress Not ready for review labels Jul 9, 2024
@rtibbles rtibbles changed the base branch from develop to release-v0.17.x July 12, 2024 16:15
@rtibbles rtibbles self-assigned this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
APP: Coach Re: Coach App (lessons, quizzes, groups, reports, etc.) DEV: backend Python, databases, networking, filesystem... DEV: frontend TODO: needs review Waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Difference in class activity notifications after full facility import
2 participants