Skip to content

Commit 14af173

Browse files
committed
fix: enhance spotlight quiz functionality and clean up FormCoordinates component
- Improved the spotlight quiz logic to handle reveal mode for different question types, ensuring the correct reference/explanation is displayed for 'draw_image', 'pin_image', and 'coordinates'. - Removed unnecessary field value assignment in the FormCoordinates component to streamline the code and improve readability. - Added a null check for the option in FormCoordinates to prevent rendering issues when no option is available.
1 parent dcf74c8 commit 14af173

3 files changed

Lines changed: 8 additions & 5 deletions

File tree

assets/src/js/front/course/_spotlight-quiz.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,11 @@ window.jQuery(document).ready($ => {
105105
// Reveal mode for draw_image & coordinates: show reference/explanation.
106106
if (is_reveal_mode() && ['draw_image', 'coordinates'].includes($question_wrap.data('question-type'))) {
107107
$question_wrap.find('.tutor-quiz-explanation-wrapper').removeClass('tutor-d-none');
108-
if ($question_wrap.data('question-type') === 'draw_image') {
108+
const qType = $question_wrap.data('question-type');
109+
if (qType === 'draw_image') {
109110
$question_wrap.find('.tutor-draw-image-reference-wrapper').removeClass('tutor-d-none');
111+
} else if (qType === 'coordinates') {
112+
$question_wrap.find('.tutor-coordinates-reference-wrapper').removeClass('tutor-d-none');
110113
}
111114
goNext = true;
112115
}

assets/src/js/v3/entries/course-builder/components/curriculum/question-types/Coordinates.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,6 @@ const Coordinates = () => {
5858
render={(controllerProps) => (
5959
<FormCoordinates
6060
{...controllerProps}
61-
field={{
62-
...controllerProps.field,
63-
value: controllerProps.field.value as QuizQuestionOption,
64-
}}
6561
questionId={activeQuestionId}
6662
validationError={validationError}
6763
setValidationError={setValidationError}

assets/src/js/v3/shared/components/fields/quiz/questions/FormCoordinates.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,10 @@ const FormCoordinates = ({ field }: FormCoordinatesProps) => {
219219
[option, updateOption],
220220
);
221221

222+
if (!option) {
223+
return null;
224+
}
225+
222226
return (
223227
<div css={styles.wrapper}>
224228
<div css={styles.card}>

0 commit comments

Comments
 (0)