Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Jan 9, 2024
1 parent 9f322d9 commit 5272c13
Show file tree
Hide file tree
Showing 44 changed files with 331 additions and 160 deletions.
56 changes: 41 additions & 15 deletions services/cms/src/components/PeerReviewEditor.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* eslint-disable i18next/no-literal-string */
import { css } from "@emotion/css"
import styled from "@emotion/styled"
import { useQuery } from "@tanstack/react-query"
Expand Down Expand Up @@ -161,11 +160,11 @@ const PeerReviewEditor: React.FC<PeerReviewEditorProps> = ({
value: PeerReviewProcessingStrategy
}[] = [
{
label: "Automatically accept or reject by average",
label: "Automatically grade by average",
value: "AutomaticallyGradeByAverage",
},
{
label: "Automatically accept or manual review by average",
label: "Automatically grade or manual review by average",
value: "AutomaticallyGradeOrManualReviewByAverage",
},
{
Expand All @@ -177,8 +176,8 @@ const PeerReviewEditor: React.FC<PeerReviewEditorProps> = ({
const handlePeerReviewValueChange = (value: string, field: keyof CmsPeerReviewConfig) => {
let peerReviewConfig
switch (field) {
case "accepting_strategy":
peerReviewConfig = { ...parsedPeerReviewConfig, accepting_strategy: value }
case "processing_strategy":
peerReviewConfig = { ...parsedPeerReviewConfig, processing_strategy: value }
break
case "accepting_threshold":
peerReviewConfig = { ...parsedPeerReviewConfig, accepting_threshold: Number(value) }
Expand All @@ -189,6 +188,12 @@ const PeerReviewEditor: React.FC<PeerReviewEditorProps> = ({
case "peer_reviews_to_receive":
peerReviewConfig = { ...parsedPeerReviewConfig, peer_reviews_to_receive: Number(value) }
break
case "points_are_all_or_nothing":
peerReviewConfig = {
...parsedPeerReviewConfig,
points_are_all_or_nothing: value === "true",
}
break
default:
break
}
Expand Down Expand Up @@ -235,10 +240,11 @@ const PeerReviewEditor: React.FC<PeerReviewEditorProps> = ({
id: v4(),
course_id: courseId,
exercise_id: exerciseId ?? null,
accepting_strategy: "AutomaticallyGradeOrManualReviewByAverage",
processing_strategy: "AutomaticallyGradeOrManualReviewByAverage",
accepting_threshold: 2.1,
peer_reviews_to_give: 3,
peer_reviews_to_receive: 2,
points_are_all_or_nothing: true,
}
setExerciseAttributes({
...exerciseAttributes,
Expand Down Expand Up @@ -385,24 +391,43 @@ const PeerReviewEditor: React.FC<PeerReviewEditorProps> = ({
t("peer-reviews-to-receive-and-give-error-message")}
</p>
<SelectField
id={`peer-review-accepting-strategy-${id}`}
label={t("peer-review-accepting-strategy")}
id={`peer-review-processing-strategy-${id}`}
label={t("peer-review-processing-strategy")}
onChangeByValue={(value) => {
handlePeerReviewValueChange(value, "accepting_strategy")
handlePeerReviewValueChange(value, "processing_strategy")
}}
options={PeerReviewProcessingStrategyOptions}
defaultValue={parsedPeerReviewConfig.accepting_strategy}
defaultValue={parsedPeerReviewConfig.processing_strategy}
/>
<CheckBox
label={t("label-points-are-all-or-nothing")}
checked={parsedPeerReviewConfig.points_are_all_or_nothing}
onChangeByValue={(checked) =>
handlePeerReviewValueChange(checked.toString(), "points_are_all_or_nothing")
}
disabled={parsedPeerReviewConfig.processing_strategy === "ManualReviewEverything"}
/>
{!parsedPeerReviewConfig.points_are_all_or_nothing && (
<div
className={css`
margin-bottom: 1rem;
margin-top: -0.5rem;
padding: 1rem;
background-color: ${baseTheme.colors.red[100]};
color: ${baseTheme.colors.red[700]};
font-weight: bold;
`}
>
Warning: foo
</div>
)}
<TextField
label={t("peer-review-accepting-threshold")}
type={"number"}
step="0.01"
min={0}
required
disabled={
parsedPeerReviewConfig.accepting_strategy.toString() ===
"ManualReviewEverything"
}
disabled={parsedPeerReviewConfig.processing_strategy === "ManualReviewEverything"}
value={parsedPeerReviewConfig.accepting_threshold}
onChangeByValue={(value) => {
handlePeerReviewValueChange(value, "accepting_threshold")
Expand Down Expand Up @@ -488,10 +513,11 @@ function defaultPeerReviewConfig(
id: v4(),
exercise_id: exerciseId ? exerciseId : null,
course_id: courseId,
accepting_strategy: "AutomaticallyGradeOrManualReviewByAverage",
processing_strategy: "AutomaticallyGradeOrManualReviewByAverage",
accepting_threshold: 2.1,
peer_reviews_to_give: 3,
peer_reviews_to_receive: 2,
points_are_all_or_nothing: true,
}
}

Expand Down
5 changes: 3 additions & 2 deletions services/cms/tests/utils/documentSchemaProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ const exampleCMSPageUpdate: CmsPageUpdate = {
id: "f0ae5814-927d-4a38-a0c0-db66f08c2bee",
course_id: "",
exercise_id: "dd46fb67-d168-4554-b912-0018f812166d",
accepting_strategy: "AutomaticallyGradeOrManualReviewByAverage",
processing_strategy: "AutomaticallyGradeOrManualReviewByAverage",
accepting_threshold: 0.5,
peer_reviews_to_give: 1,
peer_reviews_to_receive: 1,
points_are_all_or_nothing: true,
},
peer_review_questions: [
{
Expand Down Expand Up @@ -129,7 +130,7 @@ const exampleUnnormalizedDocumentExerciseAttributes: ExerciseAttributes = {
limit_number_of_tries: true,
needs_peer_review: true,
peer_review_config:
'[{"id":"f0ae5814-927d-4a38-a0c0-db66f08c2bee","course_id":"","exercise_id":"dd46fb67-d168-4554-b912-0018f812166d","accepting_strategy":"AutomaticallyGradeOrManualReviewByAverage","accepting_threshold":"0.5","peer_reviews_to_give":"1","peer_reviews_to_receive":"1"}]',
'[{"id":"f0ae5814-927d-4a38-a0c0-db66f08c2bee","course_id":"","exercise_id":"dd46fb67-d168-4554-b912-0018f812166d","processing_strategy":"AutomaticallyGradeOrManualReviewByAverage","accepting_threshold":"0.5","peer_reviews_to_give":"1","peer_reviews_to_receive":"1"}]',
peer_review_questions_config:
'[{"id":"f3c8eadd-75ca-409f-b1c6-31db65701930","peer_review_config_id":"f0ae5814-927d-4a38-a0c0-db66f08c2bee","answer_required":"true","order_number":"0","question":"how about...","question_type":"Essay"}]',
use_course_default_peer_review: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ ALTER TYPE peer_review_accepting_strategy
RENAME VALUE 'automatically_grade_by_average' TO 'automatically_accept_or_reject_by_average';
ALTER TYPE peer_review_accepting_strategy
RENAME VALUE 'automatically_grade_or_manual_review_by_average' TO 'automatically_accept_or_manual_review_by_average';
ALTER TABLE peer_review_configs
RENAME COLUMN processing_strategy TO accepting_strategy;
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ALTER TABLE peer_review_configs
ADD COLUMN points_are_all_or_nothing BOOLEAN NOT NULL DEFAULT TRUE;
COMMENT ON COLUMN peer_review_configs.points_are_all_or_nothing IS 'True by default and recommended to keep it that way for most courses. If set to true, the student will always receive either full points or no points from the peer reviewed exercise. If set to false, the points will be weighted according to a weight in each peer review question.';
ALTER TABLE peer_review_questions
ADD COLUMN weight INTEGER NOT NULL DEFAULT 1;
ADD COLUMN weight REAL NOT NULL DEFAULT 0;
COMMENT ON COLUMN peer_review_questions.weight IS 'The weight of the question in the peer review. The weight is used to calculate the points the student receives from the peer review. The points are calculated by multiplying the weight of the question with the points the student gave to the answer. The points are then summed up and divided by the sum of the weights of all questions in the peer review. The result is rounded to the nearest integer.';
ALTER TYPE peer_review_accepting_strategy
RENAME TO peer_review_processing_strategy;
Expand All @@ -11,3 +11,5 @@ RENAME VALUE 'automatically_accept_or_reject_by_average' TO 'automatically_grade
ALTER TYPE peer_review_processing_strategy
RENAME VALUE 'automatically_accept_or_manual_review_by_average' TO 'automatically_grade_or_manual_review_by_average';
COMMENT ON COLUMN peer_review_configs.accepting_threshold IS 'The threshold on the average review received for "passing" a peer reviewed exercise. If points_are_all_or_nothing is true, this threshold tells whether to give full points or zero points. If points_are_all_or_nothing is false and peer_review_processing_strategy is automatically_grade_or_manual_review_by average all averages under this threshold will cause an answer to be sent to manual review. In all other cases, this column will be ignored. Peer review questions are on a scale from 1 to 5.';
ALTER table peer_review_configs
RENAME COLUMN accepting_strategy TO processing_strategy;

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

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

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

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

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

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

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

Loading

0 comments on commit 5272c13

Please sign in to comment.