-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* WIP * Split exercise block into more blocks * Add new fields to the database * Include only the latest completion in completions export * Update document schema processor * WIP * Fix focus handling * State handling * Saving fixes * Add self review checkbox * WIP * Change hardcoded instructions to a label in peer review view * Update state_deriver * Fix for reviews received * Rename database tables and columns * Fixes on the typescript side * Fixes * Fixes * Fix * WIP tests * Bug fix * Bug fix * Update snapshots * Test fixes * Test fixes * System test fixes * Clippy fixes * Peer reviews in the seed should require to receive one peer review * Test fixes * Fix AutomaticallyGradeOrManualReviewByAverage test * Fix ManualReviewEverything test * Remove not needed screenshots * Eslint fixes * Update snapshots * Finalize peer and self review spec * Finalize more self review tests * Label self reviews in the teacher's view * Show count of answers requiring attention in the top bar
- Loading branch information
Showing
282 changed files
with
5,421 additions
and
3,703 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -166,6 +166,7 @@ module.exports = { | |
"weight", | ||
"action", | ||
"tagName", | ||
"templateLock", | ||
], | ||
}, | ||
words: { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
services/cms/src/blocks/Exercise/ExerciseSettings/ExerciseSettingsEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
import { css } from "@emotion/css" | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
import { useContext } from "react" | ||
import { useTranslation } from "react-i18next" | ||
|
||
import PeerReviewEditor from "../../../components/PeerReviewEditor" | ||
import ExerciseBlockContext from "../../../contexts/ExerciseBlockContext" | ||
import PageContext from "../../../contexts/PageContext" | ||
import Accordion from "../../../shared-module/components/Accordion" | ||
import CheckBox from "../../../shared-module/components/InputFields/CheckBox" | ||
import TextField from "../../../shared-module/components/InputFields/TextField" | ||
import { baseTheme } from "../../../shared-module/styles" | ||
import { respondToOrLarger } from "../../../shared-module/styles/respond" | ||
|
||
const ALLOWED_NESTED_BLOCKS = ["core/image", "core/paragraph", "core/list", "moocfi/latex"] | ||
|
||
const ExerciseSettingsEditor = () => { | ||
const { t } = useTranslation() | ||
const courseId = useContext(PageContext)?.page.course_id | ||
const { attributes, setAttributes } = useContext(ExerciseBlockContext) | ||
|
||
if (!attributes) { | ||
return null | ||
} | ||
|
||
return ( | ||
<div | ||
className={css` | ||
background-color: white; | ||
border: 1px solid ${baseTheme.colors.clear[100]}; | ||
border-radius: 2px; | ||
padding: 1rem 2rem; | ||
margin-bottom: 1rem; | ||
`} | ||
> | ||
<TextField | ||
label={t("exercise-name")} | ||
placeholder={t("exercise-name")} | ||
value={attributes.name} | ||
onChangeByValue={(value) => setAttributes({ name: value })} | ||
className={css` | ||
margin-bottom: 1rem !important; | ||
`} | ||
/> | ||
<TextField | ||
label={t("exercise-max-points")} | ||
placeholder={t("exercise-max-points")} | ||
value={attributes.score_maximum?.toString() ?? ""} | ||
type="number" | ||
onChangeByValue={(value) => { | ||
const parsed = parseInt(value) | ||
if (isNaN(parsed)) { | ||
// empty | ||
setAttributes({ score_maximum: undefined }) | ||
return | ||
} | ||
setAttributes({ score_maximum: parsed }) | ||
}} | ||
className={css` | ||
margin-bottom: 1rem !important; | ||
`} | ||
/> | ||
<div | ||
className={css` | ||
display: flex; | ||
flex-direction: column; | ||
margin-bottom: 1rem; | ||
${respondToOrLarger.md} { | ||
align-items: center; | ||
flex-direction: row; | ||
} | ||
`} | ||
> | ||
<CheckBox | ||
label={t("limit-number-of-tries")} | ||
checked={attributes.limit_number_of_tries} | ||
onChangeByValue={function (checked: boolean): void { | ||
setAttributes({ limit_number_of_tries: checked }) | ||
}} | ||
className={css` | ||
flex: 1; | ||
padding-top: 1.3rem; | ||
`} | ||
/> | ||
<TextField | ||
label={t("tries-per-slide")} | ||
placeholder={t("tries-per-slide")} | ||
value={attributes.max_tries_per_slide?.toString() ?? ""} | ||
disabled={!attributes.limit_number_of_tries} | ||
type="number" | ||
onChangeByValue={(value) => { | ||
const parsed = parseInt(value) | ||
if (isNaN(parsed)) { | ||
// empty | ||
setAttributes({ max_tries_per_slide: undefined }) | ||
return | ||
} | ||
setAttributes({ max_tries_per_slide: parsed }) | ||
}} | ||
className={css` | ||
flex: 1; | ||
`} | ||
/> | ||
</div> | ||
{courseId && ( | ||
<Accordion variant="detail"> | ||
<details> | ||
<summary>{t("peer-and-self-review-configuration")}</summary> | ||
<PeerReviewEditor | ||
attributes={attributes} | ||
setAttributes={setAttributes} | ||
exerciseId={attributes.id} | ||
courseId={courseId} | ||
courseGlobalEditor={false} | ||
instructionsEditor={ | ||
<div | ||
className={css` | ||
border: 1px solid ${baseTheme.colors.gray[100]}; | ||
padding: 1rem; | ||
`} | ||
> | ||
<InnerBlocks allowedBlocks={ALLOWED_NESTED_BLOCKS} templateLock={false} /> | ||
</div> | ||
} | ||
/> | ||
</details> | ||
</Accordion> | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export default ExerciseSettingsEditor |
11 changes: 11 additions & 0 deletions
11
services/cms/src/blocks/Exercise/ExerciseSettings/ExerciseSettingsSave.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { InnerBlocks } from "@wordpress/block-editor" | ||
|
||
const ExerciseSettingsSave: React.FC<unknown> = () => { | ||
return ( | ||
<div> | ||
<InnerBlocks.Content /> | ||
</div> | ||
) | ||
} | ||
|
||
export default ExerciseSettingsSave |
19 changes: 19 additions & 0 deletions
19
services/cms/src/blocks/Exercise/ExerciseSettings/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* eslint-disable i18next/no-literal-string */ | ||
import { BlockConfiguration } from "@wordpress/blocks" | ||
|
||
import { MOOCFI_CATEGORY_SLUG } from "../../../utils/Gutenberg/modifyGutenbergCategories" | ||
|
||
import ExerciseSettingsEditor from "./ExerciseSettingsEditor" | ||
import ExerciseSettingsSave from "./ExerciseSettingsSave" | ||
|
||
const ExerciseSettingsConfiguration: BlockConfiguration<Record<string, never>> = { | ||
title: "ExerciseSettings", | ||
description: "Wrapper block for exercise settings, required for the exercise block to work", | ||
category: MOOCFI_CATEGORY_SLUG, | ||
parent: ["moocfi/exercise"], | ||
attributes: {}, | ||
edit: ExerciseSettingsEditor, | ||
save: ExerciseSettingsSave, | ||
} | ||
|
||
export default ExerciseSettingsConfiguration |
Oops, something went wrong.