Skip to content

Commit

Permalink
check for undefined user_answers
Browse files Browse the repository at this point in the history
  • Loading branch information
anadis504 committed Mar 28, 2024
1 parent 27d2f07 commit 878cd55
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/components/PdfDownload/PdfGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,8 +292,9 @@ const MyDoc: React.FC<React.PropsWithChildren<CustomViewIframeState>> = (props)
.flatMap((exercise) => {
return exercise.exercise_tasks.flatMap((task) => {
const grading = task.grading as CustomViewExerciseTaskGrading
const answer = (task.user_answer as CustomViewExerciseTaskSubmission[])[0]
.data_json as UserAnswer
const answer =
!!task.user_answer &&
((task.user_answer as CustomViewExerciseTaskSubmission[])[0].data_json as UserAnswer)
const pubSpec = task.public_spec as PublicSpec
const gradingFeedback = grading.feedback_json
? (grading.feedback_json as ExerciseFeedback)
Expand Down Expand Up @@ -346,13 +347,15 @@ const MyDoc: React.FC<React.PropsWithChildren<CustomViewIframeState>> = (props)
gradingFeedback={exercise.gradingFeedback}
userVariables={user_vars}
></PDFFactorReport>
<PDFSumFactorReport
key={exercise.task_id}
gradingFeedback={null}
userVariables={user_vars}
publicSpec={exercise.pubSpec}
answer={exercise.answer}
></PDFSumFactorReport>
{exercise.answer && (
<PDFSumFactorReport
key={exercise.task_id}
gradingFeedback={null}
userVariables={user_vars}
publicSpec={exercise.pubSpec}
answer={exercise.answer}
></PDFSumFactorReport>
)}
</View>
)
})}
Expand Down

0 comments on commit 878cd55

Please sign in to comment.