Skip to main content

get_course_students_page

Function get_course_students_page 

Source
pub async fn get_course_students_page(
    conn: &mut PgConnection,
    course_id: Uuid,
    pagination: Pagination,
    search: Option<&str>,
    sort_column: Option<&str>,
    sort_direction: Option<&str>,
    course_instance_id: Option<Uuid>,
    module_id: Option<Uuid>,
    grade: Option<&str>,
) -> ModelResult<StudentsListPage>
Expand description

Returns a filtered, sorted, paginated page of the course’s enrolled users (identity only).

sort_column (last_name | first_name | email | total_points) and sort_direction are narrowed to fixed literals and bound as parameters, never interpolated from raw input. search matches name/email substrings via the trigram name_search_helper / email_search_helper columns, plus an exact user-id match when it parses as a UUID. course_instance_id narrows to a single instance.

module_id + grade together narrow to students whose latest completion of that module matches: a numeric grade string (sis-0-5 scale), GRADE_FILTER_PASSED/GRADE_FILTER_FAILED (the sis-hyv-hyl scale, i.e. grade IS NULL), or GRADE_FILTER_NOT_COMPLETED (no completion row at all). A numerically graded module’s completions never match passed/failed – those only ever apply to modules that use the pass/fail scale, mirroring how CompletionsTab renders the grade column (a numeric grade takes precedence over passed/failed). grade is ignored unless module_id is also set.