FIX course specific visuals in visuals cron
from datetime import datetime, timedelta
from typing import List
-from anubis.models import Assignment
+from anubis.models import Assignment, Course
from anubis.utils.data import with_context
from anubis.utils.visuals.assignments import get_assignment_sundial
from anubis.utils.visuals.usage import get_usage_plot
@@ -9,13 +9,22 @@ from anubis.utils.visuals.usage import get_usage_plot
@with_context
def main():
- get_usage_plot()
+ # Get courses with visuals enabled
+ courses_with_visuals: List[Course] = Course.query.filter(
+ Course.display_visuals == True
+ ).all()
+
+ # Generate usage plot for each course
+ for course in courses_with_visuals:
+ get_usage_plot(course.id)
+ # Get recent assignments
recent_assignments: List[Assignment] = Assignment.query.filter(
Assignment.release_date > datetime.now(),
Assignment.due_date < datetime.now() - timedelta(weeks=4)
).all()
+ # Generate sundial for each
for assignment in recent_assignments:
get_assignment_sundial(assignment.id)
