Skip to content

Commit 79cdcc8

Browse files
committed
set answer_id as empty
1 parent 35020d4 commit 79cdcc8

File tree

3 files changed

+11
-118
lines changed

3 files changed

+11
-118
lines changed

src/components/ExercisePreview.tsx

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import React from "react";
22
import { ExerciseData, ExerciseQuestionData, StepBase } from "src/types";
33
import { Exercise } from "./Exercise";
44
import styled from "styled-components";
5-
import { colors } from "../theme";
65

76
export interface ExercisePreviewProps {
87
exercise: ExerciseData;
@@ -46,6 +45,7 @@ export const ExercisePreview = (
4645
return {
4746
...acc,
4847
[id]: {
48+
answer_id: '',
4949
correct_answer_id,
5050
is_completed: showCorrectAnswer,
5151
solution: {
@@ -91,12 +91,6 @@ export const ExercisePreview = (
9191
& > div {
9292
display: none;
9393
}
94-
}
95-
96-
.answer-letter-wrapper::before {
97-
color: ${colors.palette.neutralThin} !important;
98-
border-color: #c6c6c6 !important;
99-
background: ${colors.palette.white} !important;
10094
}`
10195
}
10296
`;

src/components/Print.stories.tsx

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +0,0 @@
1-
import { ExerciseData, ExerciseQueryData, ExerciseQuestionData, StepBase } from '../../src/types';
2-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
3-
// @ts-ignore
4-
import data from '../../exercises.json';
5-
import styled from 'styled-components';
6-
import { Exercise } from './Exercise';
7-
8-
const ExerciseWrapper = styled.div`
9-
break-inside: avoid;
10-
11-
.step-card-body {
12-
padding: 24px 48px !important;
13-
}
14-
15-
.step-card-footer {
16-
display: none;
17-
}
18-
19-
.exercise-id {
20-
height: auto;
21-
}
22-
23-
.exercise-step {
24-
min-height: auto;
25-
}
26-
27-
.question-feedback {
28-
box-shadow: none !important;
29-
}
30-
31-
.openstax-answer {
32-
break-inside: avoid;
33-
34-
.answer-letter-wrapper::after {
35-
content: '' !important;
36-
}
37-
}
38-
`;
39-
40-
const exercises = (data as ExerciseQueryData).exercises as ExerciseData[];
41-
42-
const firstQuestionNumByExercise = exercises.reduce((acc, ex) => ({
43-
...acc,
44-
[ex.uuid]: acc.questionCounter + 1,
45-
questionCounter: acc.questionCounter + ex.questions.length
46-
}), {questionCounter: 0});
47-
48-
// placeholder until exercise data contains correct answer IDs
49-
const formatAnswerData = (questions: ExerciseQuestionData[]) => questions.map((q) => (
50-
{id: q.id, correct_answer_id: (q.answers.find((a) => a.correctness === '1.0')?.id || '')}));
51-
52-
const questionStateFields = {
53-
available_points: '1.0',
54-
is_completed: true,
55-
answer_id: '1',
56-
free_response: '',
57-
feedback_html: '',
58-
correct_answer_feedback_html: '',
59-
attempts_remaining: 0,
60-
attempt_number: 1,
61-
incorrectAnswerId: 0
62-
}
63-
64-
export const Default = () => (
65-
<>
66-
{data.title && <h2>Exercises for {data.title}</h2>}
67-
{exercises.map(((exercise) => {
68-
69-
const step: StepBase = {
70-
id: 1,
71-
uid: exercise.uid,
72-
available_points: '1.0',
73-
};
74-
75-
const questionStates = formatAnswerData(exercise.questions).reduce((acc, answer) => {
76-
const {id, correct_answer_id} = answer;
77-
return {...acc, [id]: {...questionStateFields, correct_answer_id}};
78-
}, {});
79-
80-
return (
81-
<ExerciseWrapper key={exercise.uid}>
82-
<Exercise
83-
key={exercise.uid}
84-
canAnswer={true}
85-
needsSaved={true}
86-
hasMultipleAttempts={false}
87-
onAnswerChange={() => undefined}
88-
onAnswerSave={() => undefined}
89-
onNextStep={() => undefined}
90-
apiIsPending={false}
91-
canUpdateCurrentStep={false}
92-
exercise={exercise}
93-
step={step}
94-
questionNumber={firstQuestionNumByExercise[exercise.uuid]}
95-
numberOfQuestions={exercises.length}
96-
questionStates={questionStates}
97-
show_all_feedback={true} />
98-
</ExerciseWrapper>
99-
)
100-
}))}
101-
</>);

src/components/__snapshots__/ExercisePreview.spec.tsx.snap

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,10 @@ exports[`ExercisePreview using step data matches snapshot with overlay and corre
7979
className="openstax-answer"
8080
>
8181
<section
82-
className="answers-answer disabled answer-selected answer-correct"
82+
className="answers-answer disabled answer-correct"
8383
>
8484
<input
85-
checked={true}
85+
checked={false}
8686
className="answer-input-box"
8787
disabled={true}
8888
id="1234@5-option-0"
@@ -95,7 +95,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and corre
9595
htmlFor="1234@5-option-0"
9696
>
9797
<span
98-
aria-label="Selected Choice A:"
98+
aria-label="Choice A:"
9999
className="answer-letter-wrapper"
100100
data-answer-choice="A"
101101
data-test-id="answer-choice-A"
@@ -199,7 +199,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and selec
199199
data-task-step-id={1}
200200
>
201201
<div
202-
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-bjUoiL QazMO hChJgc preview-card is-selected"
202+
className="sc-bczRLJ LfjAZ exercise-step sc-breuTD dSaRVj sc-hAZoDl sc-bjUoiL QazMO cePIaL preview-card is-selected"
203203
>
204204
<div
205205
onBlur={[Function]}
@@ -453,10 +453,10 @@ exports[`ExercisePreview using step data matches snapshot with overlay and selec
453453
className="openstax-answer"
454454
>
455455
<section
456-
className="answers-answer disabled answer-selected answer-correct"
456+
className="answers-answer disabled answer-correct"
457457
>
458458
<input
459-
checked={true}
459+
checked={false}
460460
className="answer-input-box"
461461
disabled={true}
462462
id="1234@5-option-0"
@@ -469,7 +469,7 @@ exports[`ExercisePreview using step data matches snapshot with overlay and selec
469469
htmlFor="1234@5-option-0"
470470
>
471471
<span
472-
aria-label="Selected Choice A:"
472+
aria-label="Choice A:"
473473
className="answer-letter-wrapper"
474474
data-answer-choice="A"
475475
data-test-id="answer-choice-A"
@@ -638,11 +638,11 @@ exports[`ExercisePreview using step data matches snapshot without overlay 1`] =
638638
className="openstax-answer"
639639
>
640640
<section
641-
className="answers-answer disabled answer-selected answer-correct"
641+
className="answers-answer disabled answer-correct"
642642
>
643643
<input
644644
aria-details="feedback-1234@5-0"
645-
checked={true}
645+
checked={false}
646646
className="answer-input-box"
647647
disabled={true}
648648
id="1234@5-option-0"
@@ -655,7 +655,7 @@ exports[`ExercisePreview using step data matches snapshot without overlay 1`] =
655655
htmlFor="1234@5-option-0"
656656
>
657657
<span
658-
aria-label="Selected Choice A:"
658+
aria-label="Choice A:"
659659
className="answer-letter-wrapper"
660660
data-answer-choice="A"
661661
data-test-id="answer-choice-A"

0 commit comments

Comments
 (0)