Commit 55f60cd
committed
fix #1785 -- if you enable peer grading but don't have enough students you get an uncaught exception
diff --git a/src/packages/frontend/course/assignments/actions.ts b/src/packages/frontend/course/assignments/actions.ts
index 4f635db..9b1ffaf 100644
--- a/src/packages/frontend/course/assignments/actions.ts
+++ b/src/packages/frontend/course/assignments/actions.ts
@@ -909,7 +909,12 @@ ${details}
// in parallel, two will launch at about the same time and
// the *condition* to know if it is done depends on the store,
// which defers when it gets updated. Anyway, this line is critical:
- this.update_peer_assignment(assignment_id);
+ try {
+ this.update_peer_assignment(assignment_id);
+ } catch (err) {
+ this.course_actions.set_error(`${short_desc} -- ${err}`);
+ return;
+ }
await this.start_all_for_peer_grading();
// OK, now do the assignment... in parallel.
await this.assignment_action_all_students(
@@ -1037,7 +1042,15 @@ ${details}
desc: `Copying peer grading to ${student_name}`,
});
- const peer_map = this.update_peer_assignment(assignment_id); // synchronous
+ let peer_map;
+ try {
+ // synchronous, but could fail, e.g., not enough students
+ peer_map = this.update_peer_assignment(assignment_id);
+ } catch (err) {
+ this.course_actions.set_error(`peer copy to student: ${err}`);
+ finish();
+ return;
+ }
if (peer_map == null) {
finish();
diff --git a/src/packages/frontend/frame-editors/course-editor/course-panel-wrapper.tsx b/src/packages/frontend/frame-editors/course-editor/course-panel-wrapper.tsx
index 6e8b57d..7dcd4c3 100644
--- a/src/packages/frontend/frame-editors/course-editor/course-panel-wrapper.tsx
+++ b/src/packages/frontend/frame-editors/course-editor/course-panel-wrapper.tsx
@@ -19,7 +19,8 @@ import {
useRedux,
useTypedRedux,
} from "@cocalc/frontend/app-framework";
-import { Loading, ActivityDisplay, ErrorDisplay } from "../../components";
+import { Loading, ActivityDisplay } from "../../components";
+import ShowError from "@cocalc/frontend/components/error";
import {
AssignmentsMap,
CourseSettingsRecord,
@@ -73,20 +74,20 @@ const CoursePanelWrapper: React.FC<FrameProps> = React.memo(
const students: StudentsMap | undefined = useRedux(name, "students");
const assignments: AssignmentsMap | undefined = useRedux(
name,
- "assignments"
+ "assignments",
);
const handouts: HandoutsMap | undefined = useRedux(name, "handouts");
const settings: CourseSettingsRecord | undefined = useRedux(
name,
- "settings"
+ "settings",
);
const configuring_projects: boolean | undefined = useRedux(
name,
- "configuring_projects"
+ "configuring_projects",
);
const reinviting_students: boolean | undefined = useRedux(
name,
- "reinviting_students"
+ "reinviting_students",
);
const activity: Map<string, any> | undefined = useRedux(name, "activity");
const error: string | undefined = useRedux(name, "error");
@@ -188,12 +189,11 @@ const CoursePanelWrapper: React.FC<FrameProps> = React.memo(
}
function render_error(): Rendered {
- if (!error) return;
return (
- <ErrorDisplay
- banner={true}
+ <ShowError
+ style={{ margin: "15px" }}
error={error}
- onClose={() => {
+ setError={(error) => {
const actions = redux.getActions(name) as CourseActions;
if (actions != null) actions.set_error("");
}}
@@ -213,7 +213,7 @@ const CoursePanelWrapper: React.FC<FrameProps> = React.memo(
{render_panel()}
</div>
);
- }
+ },
);
export function wrap(Panel) {1 parent 5549b07 commit 55f60cd
File tree
2 files changed
+25
-12
lines changed- src/packages/frontend
- course/assignments
- frame-editors/course-editor
2 files changed
+25
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
909 | 909 | | |
910 | 910 | | |
911 | 911 | | |
912 | | - | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
913 | 918 | | |
914 | 919 | | |
915 | 920 | | |
| |||
1037 | 1042 | | |
1038 | 1043 | | |
1039 | 1044 | | |
1040 | | - | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
| 1050 | + | |
| 1051 | + | |
| 1052 | + | |
| 1053 | + | |
1041 | 1054 | | |
1042 | 1055 | | |
1043 | 1056 | | |
| |||
Lines changed: 10 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
| 22 | + | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
73 | 74 | | |
74 | 75 | | |
75 | 76 | | |
76 | | - | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
80 | 81 | | |
81 | | - | |
| 82 | + | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
85 | | - | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
89 | | - | |
| 90 | + | |
90 | 91 | | |
91 | 92 | | |
92 | 93 | | |
| |||
188 | 189 | | |
189 | 190 | | |
190 | 191 | | |
191 | | - | |
192 | 192 | | |
193 | | - | |
194 | | - | |
| 193 | + | |
| 194 | + | |
195 | 195 | | |
196 | | - | |
| 196 | + | |
197 | 197 | | |
198 | 198 | | |
199 | 199 | | |
| |||
213 | 213 | | |
214 | 214 | | |
215 | 215 | | |
216 | | - | |
| 216 | + | |
217 | 217 | | |
218 | 218 | | |
219 | 219 | | |
| |||
0 commit comments