diff --git a/services/course-material/src/components/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerOrSelfReviewViewImpl.tsx b/services/course-material/src/components/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerOrSelfReviewViewImpl.tsx index 17394012241..8ed78d41f36 100644 --- a/services/course-material/src/components/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerOrSelfReviewViewImpl.tsx +++ b/services/course-material/src/components/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerOrSelfReviewViewImpl.tsx @@ -149,7 +149,15 @@ const PeerOrSelfReviewViewImpl: React.FC { - reportMutation.mutate({ reason, description }) + reportMutation.mutate( + { reason, description }, + { + onSuccess: () => { + setAnswers(new Map()) + query.refetch() + }, + }, + ) } if (query.isError) { diff --git a/services/course-material/src/components/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerRevireMarkingSpam/MarkAsSpamDialog.tsx b/services/course-material/src/components/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerRevireMarkingSpam/MarkAsSpamDialog.tsx index 3e6e3e2e0d1..a7c3490f59d 100644 --- a/services/course-material/src/components/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerRevireMarkingSpam/MarkAsSpamDialog.tsx +++ b/services/course-material/src/components/ContentRenderer/moocfi/ExerciseBlock/PeerOrSelfReviewView/PeerRevireMarkingSpam/MarkAsSpamDialog.tsx @@ -60,7 +60,8 @@ const MarkAsSpamDialog: React.FC<{ setSelectedReason(e.target.value)} > diff --git a/services/headless-lms/models/.sqlx/query-2a2f7d900ec3ce47be59da8b9a874aa1bc7ac567323b25476e766e95d32c7ed1.json b/services/headless-lms/models/.sqlx/query-2a2f7d900ec3ce47be59da8b9a874aa1bc7ac567323b25476e766e95d32c7ed1.json new file mode 100644 index 00000000000..dad2c2b5ec1 --- /dev/null +++ b/services/headless-lms/models/.sqlx/query-2a2f7d900ec3ce47be59da8b9a874aa1bc7ac567323b25476e766e95d32c7ed1.json @@ -0,0 +1,58 @@ +{ + "db_name": "PostgreSQL", + "query": "\n SELECT\n id,\n submission_id,\n flagged_user,\n flagged_by,\n reason,\n description,\n created_at,\n updated_at,\n deleted_at\n FROM flagged_answers\n WHERE flagged_by = $1\n AND deleted_at IS NULL\n ", + "describe": { + "columns": [ + { + "ordinal": 0, + "name": "id", + "type_info": "Uuid" + }, + { + "ordinal": 1, + "name": "submission_id", + "type_info": "Uuid" + }, + { + "ordinal": 2, + "name": "flagged_user", + "type_info": "Uuid" + }, + { + "ordinal": 3, + "name": "flagged_by", + "type_info": "Uuid" + }, + { + "ordinal": 4, + "name": "reason", + "type_info": "Text" + }, + { + "ordinal": 5, + "name": "description", + "type_info": "Text" + }, + { + "ordinal": 6, + "name": "created_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 7, + "name": "updated_at", + "type_info": "Timestamptz" + }, + { + "ordinal": 8, + "name": "deleted_at", + "type_info": "Timestamptz" + } + ], + "parameters": { + "Left": ["Uuid"] + }, + "nullable": [false, false, false, false, false, true, false, false, true] + }, + "hash": "2a2f7d900ec3ce47be59da8b9a874aa1bc7ac567323b25476e766e95d32c7ed1" +} diff --git a/services/headless-lms/models/src/exercise_slide_submissions.rs b/services/headless-lms/models/src/exercise_slide_submissions.rs index 56c69e26dce..36cd9e4b57d 100644 --- a/services/headless-lms/models/src/exercise_slide_submissions.rs +++ b/services/headless-lms/models/src/exercise_slide_submissions.rs @@ -242,6 +242,38 @@ pub async fn get_flagged_answers_by_submission_id( Ok(results) } +pub async fn get_flagged_answers_submission_ids_by_flaggers_id( + conn: &mut PgConnection, + flagged_by: Uuid, +) -> ModelResult> { + let flagged_submissions = sqlx::query_as!( + FlaggedAnswer, + r#" + SELECT + id, + submission_id, + flagged_user, + flagged_by, + reason, + description, + created_at, + updated_at, + deleted_at + FROM flagged_answers + WHERE flagged_by = $1 + AND deleted_at IS NULL + "#, + flagged_by + ) + .fetch_all(conn) + .await?; + + Ok(flagged_submissions + .into_iter() + .map(|row| row.submission_id) + .collect()) +} + pub async fn insert_exercise_slide_submission( conn: &mut PgConnection, exercise_slide_submission: NewExerciseSlideSubmission, diff --git a/services/headless-lms/models/src/library/peer_or_self_reviewing.rs b/services/headless-lms/models/src/library/peer_or_self_reviewing.rs index dd8693e48a0..04489de6a82 100644 --- a/services/headless-lms/models/src/library/peer_or_self_reviewing.rs +++ b/services/headless-lms/models/src/library/peer_or_self_reviewing.rs @@ -412,7 +412,7 @@ pub async fn try_to_select_exercise_slide_submission_for_peer_review( return Ok(data) } - let excluded_exercise_slide_submission_ids = + let mut excluded_exercise_slide_submission_ids = peer_or_self_review_submissions::get_users_submission_ids_for_exercise_and_course_instance( conn, reviewer_user_exercise_state.user_id, @@ -420,6 +420,14 @@ pub async fn try_to_select_exercise_slide_submission_for_peer_review( course_instance_id, ) .await?; + let reported_submissions = + crate::exercise_slide_submissions::get_flagged_answers_submission_ids_by_flaggers_id( + conn, + reviewer_user_exercise_state.user_id, + ) + .await?; + excluded_exercise_slide_submission_ids.extend(reported_submissions); + let candidate_submission_id = try_to_select_peer_review_candidate_from_queue( conn, reviewer_user_exercise_state.exercise_id,