Where to place the helper method? There is signal handler in CMS for course grade update and there are signal handlers in LMS for subsection grade changes when learner attempts to score a problem.
We can either
update each of the celery tasks that update grades, or
just raise an exception within the write methods of PersistentCourseGrade and PersistentSubsectionGrade, or
update grades.config.should_persist_grades to check for the course's end date.
The latter, however, will require accessing course date information at a lower layer.
Have 2 points of defense:
At the grades core level - possibly in the celery tasks.
Eventually, also at the higher layers - possibly in the Django Signal handlers.
We do not want this to be enabled for all courses (right away or even long term?)
So use a CourseWaffleFlag for now.
Maybe eventually make it an advanced setting (or a date setting).
Continue to update Subsection Grades - only if it's easier to implement this way - otherwise, it's preferable to not update subsection grades as well.
In the future, if we want to automatically update course grades when Course End changes, we can do so easily with the updated subsection grades.
Stop updating Course Grades 1 month after Course End.
Get the Course End date from the CourseOverview model.
For self-paced courses, we will just use the Course End date as well.
If a course has no Course End date, then continue updating the grade(s).
Put this change behind a CourseWaffleFlag since some courses will want to opt-out of this.
Record whenever the course end date changes → tracking logs + Splunk.
Create CourseWaffleFlag for this change.
Update grades-related celery tasks to exit when now > (Course End + 1 month).
If simpler, do this for all tasks - including update of Subsection grades.
Add log message when course end date changes.
Possibly in course_overview.signals._check_for_course_date_changes.
from datetime import timedelta
from django.utils import timezone
some_waffle_switch = True // Some waffle switch which we can pull information from for active/inactive?
course = CourseOverview.get_from_id(course_key)
if some_waffle_switch and course.end: // Not sure if we are ok for self paced courses with ends dates to be the part of the change
grade_update_offset = course.end + timedelta(30) // There should some good place to store `30`. A config model/settings/static variable?
now = timezone.now()
if now > offset: