Skip to content

Commit

Permalink
Make peer review updater to handle answers that teacher has not revie…
Browse files Browse the repository at this point in the history
…wed in 3 months (#1371)

- Introduced a new SQL query in `peer_review_queue_entries.rs` to fetch entries that have been waiting for teacher review longer than a specified timestamp.
- Added a new JSON file defining the query structure and its parameters.
- Updated the peer review updater logic to utilize the new query for processing entries that require manual grading.
  • Loading branch information
nygrenh authored Jan 23, 2025
1 parent bd08694 commit 40facbd
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 2 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions services/headless-lms/models/src/peer_review_queue_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,36 @@ WHERE course_instance_id = $1
Ok(res)
}

/// Returns entries that have been waiting for teacher to review them for more than `timestamp`. The teacher is supposed to review an answer when the `user_exercise_states` `reviewing_stage` is `WaitingForManualGrading`.
pub async fn get_entries_that_need_teacher_review_and_are_older_than_with_course_instance_id(
conn: &mut PgConnection,
course_instance_id: Uuid,
timestamp: DateTime<Utc>,
) -> ModelResult<Vec<PeerReviewQueueEntry>> {
let res = sqlx::query_as!(
PeerReviewQueueEntry,
"
SELECT prqe.*
FROM peer_review_queue_entries prqe
JOIN user_exercise_states ues ON (
prqe.user_id = ues.user_id
AND prqe.exercise_id = ues.exercise_id
AND prqe.course_instance_id = ues.course_instance_id
)
WHERE prqe.course_instance_id = $1
AND ues.reviewing_stage = 'waiting_for_manual_grading'
AND prqe.created_at < $2
AND prqe.deleted_at IS NULL
AND ues.deleted_at IS NULL
",
course_instance_id,
timestamp
)
.fetch_all(conn)
.await?;
Ok(res)
}

pub async fn get_entries_that_need_reviews_and_are_older_than_with_exercise_id(
conn: &mut PgConnection,
exercise_id: Uuid,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ async fn process_course_instance(
let pass_automatically_cutoff = earliest_manual_review_cutoff - chrono::Duration::days(90);

// Process automatic pass cases
let should_pass = headless_lms_models::peer_review_queue_entries::get_entries_that_need_reviews_and_are_older_than(conn, course_instance.id, pass_automatically_cutoff).await?;
let should_pass = headless_lms_models::peer_review_queue_entries::get_entries_that_need_teacher_review_and_are_older_than_with_course_instance_id(conn, course_instance.id, pass_automatically_cutoff).await?;
if !should_pass.is_empty() {
info!(course_instance_id = ?course_instance.id, "Found {:?} answers that have been added to the peer review queue before {:?} and have not received enough peer reviews or have not been reviewed manually. Giving them full points.", should_pass.len(), pass_automatically_cutoff);
info!(course_instance_id = ?course_instance.id, "Found {:?} answers that have been added to the peer review queue before {:?}. The teacher has not reviewed the answers manually after 3 months. Giving them full points.", should_pass.len(), pass_automatically_cutoff);
for peer_review_queue_entry in should_pass {
let _res = peer_review_queue_entries::remove_from_queue_and_give_full_points(
conn,
Expand Down

0 comments on commit 40facbd

Please sign in to comment.