Skip to content

Commit

Permalink
Small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maija Y committed Jan 20, 2025
1 parent 8a30fc6 commit 2e076b5
Show file tree
Hide file tree
Showing 17 changed files with 43 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,19 +145,17 @@ const PeerOrSelfReviewViewImpl: React.FC<React.PropsWithChildren<PeerOrSelfRevie
})
},
{ notify: true, method: "POST" },
{},
{
onSuccess: () => {
setIsReportDialogOpen(false)
setAnswers(new Map())
query.refetch()
},
},
)

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

if (query.isError) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const MarkAsSpamDialog: React.FC<{
}

return (
<Dialog open={isOpen} onClose={onClose}>
<Dialog open={isOpen} onClose={onClose} aria-labelledby="report-dialog-title">
<h1> {t("title-report-dialog")}</h1>

<div
Expand Down Expand Up @@ -78,7 +78,13 @@ const MarkAsSpamDialog: React.FC<{
padding: 10px 12px;
`}
/>
<Button variant="primary" onClick={handleSubmit} disabled={!selectedReason} size={"small"}>
<Button
variant="primary"
onClick={handleSubmit}
disabled={!selectedReason}
size={"small"}
aria-label={t("submit-button")}
>
{t("submit-button")}
</Button>
</Dialog>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ ADD COLUMN flag_count INTEGER NOT NULL DEFAULT 0;
COMMENT ON COLUMN exercise_slide_submissions.flag_count IS 'The number of times the submission has been flagged.';

ALTER TABLE courses
ADD COLUMN flagged_answers_threshold INTEGER NOT NULL DEFAULT 5;
ADD COLUMN flagged_answers_threshold INTEGER NOT NULL DEFAULT 3 CHECK (flagged_answers_threshold > 0);

COMMENT ON COLUMN courses.flagged_answers_threshold IS 'The amount of flags required to trigger a teacher review for an answer.';
2 changes: 1 addition & 1 deletion services/headless-lms/models/src/chapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ mod tests {
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
},
user,
|_, _, _| unimplemented!(),
Expand Down
2 changes: 1 addition & 1 deletion services/headless-lms/models/src/courses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ mod test {
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion services/headless-lms/models/src/library/copying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ mod tests {
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions services/headless-lms/models/src/library/grading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ pub struct AnswerRequiringAttentionWithTasks {
pub tasks: Vec<CourseMaterialExerciseTask>,
pub given_peer_reviews: Vec<PeerReviewWithQuestionsAndAnswers>,
pub received_peer_or_self_reviews: Vec<PeerReviewWithQuestionsAndAnswers>,
pub reveived_peer_flagging_reports: Vec<FlaggedAnswer>,
pub received_peer_review_flagging_reports: Vec<FlaggedAnswer>,
}

/// Gets submissions that require input from the teacher to continue processing.
Expand Down Expand Up @@ -574,7 +574,7 @@ pub async fn get_paginated_answers_requiring_attention_for_exercise(
answer.submission_id,
)
.await?;
let reveived_peer_flagging_reports: Vec<FlaggedAnswer> =
let received_peer_review_flagging_reports: Vec<FlaggedAnswer> =
exercise_slide_submissions::get_flagged_answers_by_submission_id(
conn,
answer.submission_id,
Expand All @@ -594,7 +594,7 @@ pub async fn get_paginated_answers_requiring_attention_for_exercise(
tasks,
given_peer_reviews,
received_peer_or_self_reviews,
reveived_peer_flagging_reports,
received_peer_review_flagging_reports,
};
answers.push(new_answer);
}
Expand Down
2 changes: 1 addition & 1 deletion services/headless-lms/models/src/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ macro_rules! insert_data {
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent:false,
flagged_answers_threshold: Some(5)
flagged_answers_threshold: Some(3)
},
$user,
|_, _, _| unimplemented!(),
Expand Down
10 changes: 5 additions & 5 deletions services/headless-lms/server/src/programs/seed/seed_courses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ pub async fn seed_sample_course(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};
let (course, _front_page, default_instance, default_module) =
library::content_management::create_new_course(
Expand Down Expand Up @@ -2033,7 +2033,7 @@ pub async fn create_glossary_course(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};

let (course, _front_page, _default_instance, default_module) =
Expand Down Expand Up @@ -2161,7 +2161,7 @@ pub async fn seed_cs_course_material(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};
let (course, front_page, default_instance, default_module) =
library::content_management::create_new_course(
Expand Down Expand Up @@ -3042,7 +3042,7 @@ pub async fn seed_course_without_submissions(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};
let (course, _front_page, _, default_module) = library::content_management::create_new_course(
&mut conn,
Expand Down Expand Up @@ -4451,7 +4451,7 @@ pub async fn seed_peer_review_course_without_submissions(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};

let (course, _front_page, _, default_module) = library::content_management::create_new_course(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ pub async fn seed_organization_uh_cs(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};
let (cs_course, _cs_front_page, _cs_default_course_instance, _cs_default_course_module) =
library::content_management::create_new_course(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ pub async fn seed_organization_uh_mathstat(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};
let (
statistics_course,
Expand Down Expand Up @@ -139,7 +139,7 @@ pub async fn seed_organization_uh_mathstat(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};
library::content_management::create_new_course(
&mut conn,
Expand Down Expand Up @@ -171,7 +171,7 @@ pub async fn seed_organization_uh_mathstat(
"zARvZARjYhESMPVceEgZyJGQZZuUHVVgcUepyzEqzSqCMdbSCDrTaFhkJTxBshWU".to_string(),
),
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
};
library::content_management::create_new_course(
&mut conn,
Expand Down Expand Up @@ -223,7 +223,7 @@ pub async fn seed_organization_uh_mathstat(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
},
true,
admin_user_id,
Expand Down
2 changes: 1 addition & 1 deletion services/headless-lms/server/src/test_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ macro_rules! insert_data {
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent:false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
},
$user,
|_, _, _| unimplemented!(),
Expand Down
2 changes: 1 addition & 1 deletion services/headless-lms/server/tests/study_registry_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ async fn insert_data(
is_joinable_by_code_only: false,
join_code: None,
ask_marketing_consent: false,
flagged_answers_threshold: Some(5),
flagged_answers_threshold: Some(3),
},
user_1,
models_requests::make_spec_fetcher(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const UpdateCourseForm: React.FC<React.PropsWithChildren<UpdateCourseFormProps>>
const [testStatus, setTestStatus] = useState(course.is_test_mode)
const [isUnlisted, setIsUnlisted] = useState(course.is_unlisted)
const [peerReviewFlaggingThreshold, setPeerReviewFlaggingThreshold] = useState(
course.flagged_answers_threshold ?? 5,
course.flagged_answers_threshold ?? 3,
)
const [joinableByCodeOnlyStatus, setjoinableByCodeOnlyStatus] = useState(
course.is_joinable_by_code_only,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ const AnswersRequiringAttentionItem: React.FC<Props> = ({
/>

<FlaggedPeerReviewAccordion
reports={answerRequiringAttention.reveived_peer_flagging_reports}
reports={answerRequiringAttention.received_peer_review_flagging_reports}
title={t("label-received-reports")}
/>
</div>
Expand Down
6 changes: 4 additions & 2 deletions shared-module/packages/common/src/bindings.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1989,8 +1989,10 @@ export function isAnswerRequiringAttentionWithTasks(
typedObj["received_peer_or_self_reviews"].every(
(e: any) => isPeerReviewWithQuestionsAndAnswers(e) as boolean,
) &&
Array.isArray(typedObj["reveived_peer_flagging_reports"]) &&
typedObj["reveived_peer_flagging_reports"].every((e: any) => isFlaggedAnswer(e) as boolean)
Array.isArray(typedObj["received_peer_review_flagging_reports"]) &&
typedObj["received_peer_review_flagging_reports"].every(
(e: any) => isFlaggedAnswer(e) as boolean,
)
)
}

Expand Down
2 changes: 1 addition & 1 deletion shared-module/packages/common/src/bindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ export interface AnswerRequiringAttentionWithTasks {
tasks: Array<CourseMaterialExerciseTask>
given_peer_reviews: Array<PeerReviewWithQuestionsAndAnswers>
received_peer_or_self_reviews: Array<PeerReviewWithQuestionsAndAnswers>
reveived_peer_flagging_reports: Array<FlaggedAnswer>
received_peer_review_flagging_reports: Array<FlaggedAnswer>
}

export interface AnswersRequiringAttention {
Expand Down

0 comments on commit 2e076b5

Please sign in to comment.