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

Merged

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
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 few more things that seem important here:

  • Clearly defining the role of the masterylogs for the retry behaviour completion notification generation
  • Reverting the change from 3 incorrect attempts on the same question to 4
  • Reverting the change from setUpTestData to setUp if at all possible

One tiny nit about variable name/casing - but this is not blocking.

kolibri/core/notifications/test/test_api.py Show resolved Hide resolved
kolibri/core/notifications/test/test_api.py Show resolved Hide resolved
kolibri/core/notifications/test/test_api.py Outdated Show resolved Hide resolved
kolibri/core/notifications/test/test_api.py Show resolved Hide resolved
kolibri/core/notifications/test/test_api.py Outdated Show resolved Hide resolved
kolibri/core/notifications/test/test_api.py Outdated Show resolved Hide resolved
kolibri/core/notifications/test/test_api.py Outdated Show resolved Hide resolved
@AlexVelezLl
Copy link
Member Author

Thank you @rtibbles! I have updated the PR :)

@rtibbles rtibbles dismissed their stale review July 18, 2024 15:07

All changes addressed

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.

This looks good to go from the code side @radinamatic if you could do final QA to confirm that the issue you reported is fixed, then we can merge this.

@pcenov
Copy link
Member

pcenov commented Aug 8, 2024

Hi @AlexVelezLl @radinamatic - the only issue I was able to identify while testing this is the following error in the console, with seemingly no user facing consequences but I'm going to mention it to be on the safe side:

TypeError: Cannot read properties of undefined (reading 'correct')

2024-08-08_14-32-43

Logs: LogsAndDB.zip

Other than that everything else is working properly and I am seeing all of the notifications.

@rtibbles
Copy link
Member

rtibbles commented Aug 8, 2024

Looking at the component in question, this looks like an attemptLog was somehow undefined? https://github.com/learningequality/kolibri/blob/develop/kolibri/core/assets/src/views/AttemptLogItem.vue#L83

This is probably not caused by the changes here - @AlexVelezLl if you feel like chasing this down, please do, otherwise we can file a follow up issue.

@AlexVelezLl
Copy link
Member Author

Im gonna give a try @rtibbles. If it becomes something too big we can file a follow up issue :)

@AlexVelezLl
Copy link
Member Author

I did a little research, and this issue is happening in the ExamReport page of exercise resources because in the AttemptLogList we iterate through the section.questions, but for a practice resource we dont have attemptLogs for every question, since we dont necessarily have attempted every question, so that why this attemptLog is undefined here https://github.com/AlexVelezLl/kolibri/blob/17ab6f78c8808dbd7ae2f40b49b9b16a1582fc03/kolibri/core/assets/src/views/AttemptLogList.vue#L135.

Im not sure what the order should be in the exercises attemptLog and how should it be iterated. So it will be better to file a new issue to solve Exam Reports of exercise resources @rtibbles @pcenov @radinamatic.
image

@rtibbles
Copy link
Member

rtibbles commented Aug 8, 2024

Thanks, @AlexVelezLl - seems like this is likely a regression from the EQM work.

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.

Unrelated regression has been filed as a follow up. This is good to go!

@rtibbles rtibbles merged commit 365ed24 into learningequality:release-v0.17.x Aug 8, 2024
33 checks passed
@AlexVelezLl AlexVelezLl deleted the fix-activity-list branch September 19, 2024 18:49
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
3 participants