Skip to content

Commit 28b8536

Browse files
committed
upgrade nextjs, fix security vulnerability in dependency, and try not to crash so spectacularly in failing to render create grading screen
1 parent ac518c3 commit 28b8536

File tree

3 files changed

+109
-56
lines changed

3 files changed

+109
-56
lines changed

components/teacher/grade/perform.js

+27-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ListGroupItem from 'react-bootstrap/ListGroupItem';
33
import { Card, Col, Row } from 'react-bootstrap';
44
import dynamic from 'next/dynamic';
55
import { useRef, useState } from 'react';
6+
import { ErrorBoundary } from 'react-error-boundary';
67
import RTE from './rte';
78

89
const FlatEditor = dynamic(() => import('../../flatEditor'), {
@@ -40,6 +41,20 @@ export default function GradePerform({ submissions }) {
4041
submissions.map((submission, submissionIdx) => {
4142
let rte;
4243
let reflection;
44+
let parsedScore;
45+
46+
if (
47+
submission?.assignment?.activity?.activity_type?.category ===
48+
'Create' &&
49+
submission?.content
50+
) {
51+
try {
52+
parsedScore = JSON.parse(submission.content);
53+
} catch (e) {
54+
console.error(e, submission.content);
55+
}
56+
}
57+
4358
if (
4459
submission?.assignment?.activity?.activity_type?.category ===
4560
'Respond' &&
@@ -121,9 +136,18 @@ export default function GradePerform({ submissions }) {
121136
?.category === 'Create' &&
122137
submission?.content && (
123138
<ListGroupItem>
124-
<FlatEditor
125-
scoreJSON={JSON.parse(submission.content)}
126-
/>
139+
{parsedScore ? (
140+
<ErrorBoundary
141+
fallback={<div>Something went wrong</div>}
142+
>
143+
<FlatEditor scoreJSON={parsedScore} />
144+
</ErrorBoundary>
145+
) : (
146+
<div>
147+
<p>no score/erroneous score</p>
148+
<pre>{submission.content}</pre>
149+
</div>
150+
)}
127151
</ListGroupItem>
128152
)}
129153
<ListGroupItem>

package-lock.json

+80-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@
1414
"date-fns": "^2.28.0",
1515
"flat-embed": "^1.4.0",
1616
"mic-recorder-to-mp3": "^2.2.2",
17-
"next": "^14.2.3",
17+
"next": "^14.2.5",
1818
"next-auth": "^4.2.1",
1919
"next-redux-wrapper": "^8.1.0",
2020
"react": "^18.3.1",
2121
"react-bootstrap": "^2.10.2",
2222
"react-dom": "^18.3.1",
23+
"react-error-boundary": "^4.0.13",
2324
"react-icons": "^4.3.1",
2425
"react-query": "^3.34.17",
2526
"react-redux": "^7.1.0",

0 commit comments

Comments
 (0)