diff --git a/api/anubis/lms/students.py b/api/anubis/lms/students.py index 396f27efc..3c1e6ca30 100644 --- a/api/anubis/lms/students.py +++ b/api/anubis/lms/students.py @@ -5,7 +5,7 @@ from anubis.utils.data import is_debug, is_job -@cache.memoize(timeout=-1, forced_update=is_debug, unless=is_debug) +@cache.memoize(timeout=-1, forced_update=is_debug, unless=is_debug, source_check=True) def get_students(course_id: str = None) -> List[Dict[str, dict]]: """ Get students by course code. If no course code is specified, @@ -18,13 +18,13 @@ def get_students(course_id: str = None) -> List[Dict[str, dict]]: """ # List of sqlalchemy filters - filters = [] - if course_id is not None: - filters.append(InCourse.course_id == course_id) + users = User.query.join(InCourse).filter(InCourse.course_id == course_id).all() + else: + users = User.query.all() # Get all users, and break them into their data props - return [s.data for s in User.query.join(InCourse).filter(*filters).all()] + return [s.data for s in users] @cache.memoize(timeout=60, unless=is_debug) diff --git a/api/anubis/views/super/students.py b/api/anubis/views/super/students.py index 95f61d271..16fd4eff0 100644 --- a/api/anubis/views/super/students.py +++ b/api/anubis/views/super/students.py @@ -1,17 +1,11 @@ -from typing import List +from flask import Blueprint from flask import Blueprint -from anubis.lms.courses import assert_course_context, assert_course_superuser, course_context -from anubis.lms.repos import get_repos from anubis.lms.students import get_students -from anubis.lms.theia import get_recent_sessions -from anubis.models import Assignment, Course, InCourse, Submission, User, db -from anubis.utils.auth.http import require_admin, require_superuser -from anubis.utils.auth.user import current_user -from anubis.utils.data import req_assert -from anubis.utils.http import get_number_arg, success_response -from anubis.utils.http.decorators import json_endpoint, json_response +from anubis.utils.auth.http import require_superuser +from anubis.utils.http import success_response +from anubis.utils.http.decorators import json_response students_ = Blueprint("super-students", __name__, url_prefix="/super/students") @@ -19,7 +13,7 @@ @students_.route("/list") @require_superuser() @json_response -def admin_students_list(): +def super_students_list(): """ List all users within the current course context @@ -27,7 +21,7 @@ def admin_students_list(): """ # Get all students - students = [s.data for s in User.query.all()] + students = get_students(None) # Pass back the students return success_response({"students": students}) diff --git a/api/jobs/reaper.py b/api/jobs/reaper.py index 0ced19ff4..1c677ed36 100644 --- a/api/jobs/reaper.py +++ b/api/jobs/reaper.py @@ -120,6 +120,7 @@ def update_student_lists(): # Iterate through courses, updating student list for course in courses: get_students(course.id) + get_students(None) @with_context