Skip to content

Commit

Permalink
Fix course cloning where peer review configs point to deleted exercises
Browse files Browse the repository at this point in the history
  • Loading branch information
nygrenh committed Dec 18, 2024
1 parent 7352caa commit 4566b7f
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 43 deletions.

This file was deleted.

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

This file was deleted.

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

42 changes: 24 additions & 18 deletions services/headless-lms/models/src/library/copying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,16 +780,18 @@ INSERT INTO peer_or_self_review_configs (
processing_strategy,
accepting_threshold
)
SELECT uuid_generate_v5($1, id::text),
SELECT uuid_generate_v5($1, posrc.id::text),
$1,
uuid_generate_v5($1, exercise_id::text),
peer_reviews_to_give,
peer_reviews_to_receive,
processing_strategy,
accepting_threshold
FROM peer_or_self_review_configs
WHERE course_id = $2
AND deleted_at IS NULL;
uuid_generate_v5($1, posrc.exercise_id::text),
posrc.peer_reviews_to_give,
posrc.peer_reviews_to_receive,
posrc.processing_strategy,
posrc.accepting_threshold
FROM peer_or_self_review_configs posrc
LEFT JOIN exercises e ON (e.id = posrc.exercise_id)
WHERE posrc.course_id = $2
AND posrc.deleted_at IS NULL
AND e.deleted_at IS NULL;
",
namespace_id,
parent_id,
Expand All @@ -815,16 +817,20 @@ INSERT INTO peer_or_self_review_questions (
answer_required,
weight
)
SELECT uuid_generate_v5($1, id::text),
uuid_generate_v5($1, peer_or_self_review_config_id::text),
order_number,
question,
question_type,
answer_required,
weight
FROM peer_or_self_review_questions
SELECT uuid_generate_v5($1, q.id::text),
uuid_generate_v5($1, q.peer_or_self_review_config_id::text),
q.order_number,
q.question,
q.question_type,
q.answer_required,
q.weight
FROM peer_or_self_review_questions q
JOIN peer_or_self_review_configs posrc ON (posrc.id = q.peer_or_self_review_config_id)
JOIN exercises e ON (e.id = posrc.exercise_id)
WHERE peer_or_self_review_config_id = $2
AND deleted_at IS NULL;
AND q.deleted_at IS NULL
AND e.deleted_at IS NULL
AND posrc.deleted_at IS NULL;
",
namespace_id,
parent_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { normalizePath } from "../../utils/normalizePath"

import { Course, NewCourse } from "@/shared-module/common/bindings"
import Button from "@/shared-module/common/components/Button"
import ErrorBanner from "@/shared-module/common/components/ErrorBanner"
import CheckBox from "@/shared-module/common/components/InputFields/CheckBox"
import RadioButton from "@/shared-module/common/components/InputFields/RadioButton"
import SelectField from "@/shared-module/common/components/InputFields/SelectField"
Expand Down Expand Up @@ -169,7 +170,7 @@ const NewCourseForm: React.FC<React.PropsWithChildren<NewCourseFormProps>> = ({
`}
>
<div>
{error && <pre>{error}</pre>}
{error && <ErrorBanner error={error} variant="readOnly" />}
<FieldContainer>
<TextField
required
Expand Down

0 comments on commit 4566b7f

Please sign in to comment.