From edac142df78894a23bb47fa73b51cdd21e63fad0 Mon Sep 17 00:00:00 2001 From: jomcarvajal Date: Wed, 29 Jan 2025 14:59:14 -0600 Subject: [PATCH] change props in storybook of Exercise --- src/components/Exercise.stories.tsx | 8 +-- src/components/Print.stories.tsx | 99 ----------------------------- 2 files changed, 4 insertions(+), 103 deletions(-) diff --git a/src/components/Exercise.stories.tsx b/src/components/Exercise.stories.tsx index b3ee2c97..27597867 100644 --- a/src/components/Exercise.stories.tsx +++ b/src/components/Exercise.stories.tsx @@ -958,14 +958,14 @@ export const OverlayCard = () => {

Exercise Preview cards

diff --git a/src/components/Print.stories.tsx b/src/components/Print.stories.tsx index 8d2a3ada..e69de29b 100644 --- a/src/components/Print.stories.tsx +++ b/src/components/Print.stories.tsx @@ -1,99 +0,0 @@ -import { ExerciseData, ExerciseQueryData, ExerciseQuestionData, StepBase } from '../../src/types'; -import data from '../../exercises.json'; -import styled from 'styled-components'; -import { Exercise } from './Exercise'; - -const ExerciseWrapper = styled.div` - break-inside: avoid; - - .step-card-body { - padding: 24px 48px !important; - } - - .step-card-footer { - display: none; - } - - .exercise-id { - height: auto; - } - - .exercise-step { - min-height: auto; - } - - .question-feedback { - box-shadow: none !important; - } - - .openstax-answer { - break-inside: avoid; - - .answer-letter-wrapper::after { - content: '' !important; - } - } -`; - -const exercises = (data as ExerciseQueryData).exercises as ExerciseData[]; - -const firstQuestionNumByExercise = exercises.reduce((acc, ex) => ({ - ...acc, - [ex.uuid]: acc.questionCounter + 1, - questionCounter: acc.questionCounter + ex.questions.length - }), {questionCounter: 0}); - -// placeholder until exercise data contains correct answer IDs -const formatAnswerData = (questions: ExerciseQuestionData[]) => questions.map((q) => ( - {id: q.id, correct_answer_id: (q.answers.find((a) => a.correctness === '1.0')?.id || '')})); - -const questionStateFields = { - available_points: '1.0', - is_completed: true, - answer_id: '1', - free_response: '', - feedback_html: '', - correct_answer_feedback_html: '', - attempts_remaining: 0, - attempt_number: 1, - incorrectAnswerId: 0 -} - -export const Default = () => ( - <> - {data.title &&

Exercises for {data.title}

} - {exercises.map(((exercise) => { - - const step: StepBase = { - id: 1, - uid: exercise.uid, - available_points: '1.0', - }; - - const questionStates = formatAnswerData(exercise.questions).reduce((acc, answer) => { - const {id, correct_answer_id} = answer; - return {...acc, [id]: {...questionStateFields, correct_answer_id}}; - }, {}); - - return ( - - undefined} - onAnswerSave={() => undefined} - onNextStep={() => undefined} - apiIsPending={false} - canUpdateCurrentStep={false} - exercise={exercise} - step={step} - questionNumber={firstQuestionNumByExercise[exercise.uuid]} - numberOfQuestions={exercises.length} - questionStates={questionStates} - show_all_feedback={true} /> - - ) - }))} - );