Skip to content

Commit

Permalink
User can't peer review answers they have reported
Browse files Browse the repository at this point in the history
  • Loading branch information
Maija Y committed Jan 17, 2025
1 parent 81a9db8 commit b5f8bdc
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ const PeerOrSelfReviewViewImpl: React.FC<React.PropsWithChildren<PeerOrSelfRevie
)

const handleReportSubmit = (reason: string, description: string) => {
reportMutation.mutate({ reason, description })
reportMutation.mutate(
{ reason, description },
{
onSuccess: () => {
setAnswers(new Map())
query.refetch()
},
},
)
}

if (query.isError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ const MarkAsSpamDialog: React.FC<{
<FieldContainer>
<RadioButton
label={t("flagging-reason-ai-generated")}
value={t("flagging-reason-ai-generated")} // eslint-disable-next-line i18next/no-literal-string
value={t("flagging-reason-ai-generated")}
// eslint-disable-next-line i18next/no-literal-string
name={"reason"}
onChange={(e) => setSelectedReason(e.target.value)}
></RadioButton>
Expand Down

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

32 changes: 32 additions & 0 deletions services/headless-lms/models/src/exercise_slide_submissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Vec<Uuid>> {
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,14 +412,22 @@ 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,
reviewer_user_exercise_state.exercise_id,
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,
Expand Down

0 comments on commit b5f8bdc

Please sign in to comment.