diff --git a/src/components/PdfDownload/PdfGenerator.tsx b/src/components/PdfDownload/PdfGenerator.tsx index 3ced911..aedd3ae 100644 --- a/src/components/PdfDownload/PdfGenerator.tsx +++ b/src/components/PdfDownload/PdfGenerator.tsx @@ -292,8 +292,9 @@ const MyDoc: React.FC> = (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) @@ -346,13 +347,15 @@ const MyDoc: React.FC> = (props) gradingFeedback={exercise.gradingFeedback} userVariables={user_vars} > - + {exercise.answer && ( + + )} ) })}