Skip to content

Commit 230c134

Browse files
committed
course: more menu items
1 parent c21f925 commit 230c134

File tree

3 files changed

+95
-64
lines changed

3 files changed

+95
-64
lines changed

src/packages/frontend/course/configuration/actions-panel.tsx

Lines changed: 57 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { Card, Row, Col } from "antd";
6+
import { Button, Card, Row, Col, Space } from "antd";
77
// React libraries and Components
88
import {
99
React,
1010
Rendered,
1111
useActions,
1212
useStore,
1313
} from "@cocalc/frontend/app-framework";
14-
import { Button, ButtonGroup } from "@cocalc/frontend/antd-bootstrap";
1514
import { plural } from "@cocalc/util/misc";
1615
import { Icon } from "@cocalc/frontend/components";
1716
import { CourseActions } from "../actions";
@@ -43,62 +42,6 @@ export const ActionsPanel: React.FC<Props> = React.memo(
4342
}) => {
4443
const actions = useActions<CourseActions>({ name });
4544

46-
/*
47-
* Grade export
48-
*/
49-
function render_grades_header() {
50-
return (
51-
<>
52-
<Icon name="table" /> Export Grades
53-
</>
54-
);
55-
}
56-
57-
async function save_grades_to_csv() {
58-
await actions.export.to_csv();
59-
}
60-
61-
async function save_grades_to_py() {
62-
await actions.export.to_py();
63-
}
64-
65-
async function save_grades_to_json() {
66-
await actions.export.to_json();
67-
}
68-
69-
function render_export_grades() {
70-
return (
71-
<Card title={render_grades_header()}>
72-
<div style={{ marginBottom: "10px" }}>Save grades to... </div>
73-
<ButtonGroup>
74-
<Button onClick={save_grades_to_csv}>
75-
<Icon name="csv" /> CSV file...
76-
</Button>
77-
<Button onClick={save_grades_to_json}>
78-
<Icon name="file-code" /> JSON file...
79-
</Button>
80-
<Button onClick={save_grades_to_py}>
81-
<Icon name="file-code" /> Python file...
82-
</Button>
83-
</ButtonGroup>
84-
<hr />
85-
<div style={{ color: "#666" }}>
86-
Export all the grades you have recorded for students in your course
87-
to a csv or Python file.
88-
<br />
89-
In Microsoft Excel, you can{" "}
90-
<a
91-
target="_blank"
92-
href="https://support.office.com/en-us/article/Import-or-export-text-txt-or-csv-files-5250ac4c-663c-47ce-937b-339e391393ba"
93-
>
94-
import the CSV file
95-
</a>
96-
.
97-
</div>
98-
</Card>
99-
);
100-
}
101-
10245
function render_resend_outstanding_email_invites(): Rendered {
10346
return (
10447
<Card
@@ -177,19 +120,15 @@ export const ActionsPanel: React.FC<Props> = React.memo(
177120
);
178121
}
179122

180-
function render_terminal_command() {
181-
return <TerminalCommandPanel name={name} />;
182-
}
183-
184123
return (
185124
<div className="smc-vfill" style={{ overflowY: "scroll" }}>
186125
<Row>
187126
<Col md={12} style={{ padding: "15px 15px 15px 0" }}>
188127
<StartAllProjects name={name} project_map={project_map} />
189128
<br />
190-
{render_terminal_command()}
129+
<TerminalCommandPanel name={name} />
191130
<br />
192-
{render_export_grades()}
131+
<ExportGrades actions={actions} />
193132
</Col>
194133
<Col md={12} style={{ padding: "15px" }}>
195134
<ReconfigureAllProjects
@@ -228,6 +167,60 @@ export function StartAllProjects({ name, project_map }) {
228167
);
229168
}
230169

170+
export function ExportGrades({ actions, close }: { actions; close? }) {
171+
async function save_grades_to_csv() {
172+
await actions.export.to_csv();
173+
close?.();
174+
}
175+
176+
async function save_grades_to_py() {
177+
await actions.export.to_py();
178+
close?.();
179+
}
180+
181+
async function save_grades_to_json() {
182+
await actions.export.to_json();
183+
close?.();
184+
}
185+
186+
return (
187+
<Card
188+
title={
189+
<>
190+
<Icon name="table" /> Export Grades
191+
</>
192+
}
193+
>
194+
<div style={{ marginBottom: "10px" }}>Save grades to... </div>
195+
<Space>
196+
<Button onClick={save_grades_to_csv}>
197+
<Icon name="csv" /> CSV file...
198+
</Button>
199+
<Button onClick={save_grades_to_json}>
200+
<Icon name="file-code" /> JSON file...
201+
</Button>
202+
<Button onClick={save_grades_to_py}>
203+
<Icon name="file-code" /> Python file...
204+
</Button>
205+
</Space>
206+
<hr />
207+
<div style={{ color: "#666" }}>
208+
Export all the grades you have recorded for students in your course to a
209+
csv or Python file.
210+
<br />
211+
In Microsoft Excel, you can{" "}
212+
<a
213+
target="_blank"
214+
href="https://support.office.com/en-us/article/Import-or-export-text-txt-or-csv-files-5250ac4c-663c-47ce-937b-339e391393ba"
215+
>
216+
import the CSV file
217+
</a>
218+
.
219+
</div>
220+
</Card>
221+
);
222+
}
223+
231224
export function ReconfigureAllProjects({
232225
actions,
233226
configuring_projects,

src/packages/frontend/course/modals.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ import { Icon } from "@cocalc/frontend/components/icon";
66
import {
77
ReconfigureAllProjects,
88
StartAllProjects,
9+
ExportGrades,
910
} from "@cocalc/frontend/course/configuration/actions-panel";
1011
import type { ProjectMap } from "@cocalc/frontend/todo-types";
12+
import { TerminalCommandPanel } from "@cocalc/frontend/course/configuration/terminal-command";
1113

1214
interface Props {
1315
frameActions;
@@ -53,6 +55,7 @@ export default function Modals(props: Props) {
5355
students={students}
5456
user_map={user_map}
5557
project_map={project_map}
58+
close={close}
5659
/>
5760
</Modal>
5861
);
@@ -63,14 +66,23 @@ function getModal(modal: string) {
6366
switch (modal) {
6467
case "add-students":
6568
return { Body: AddStudents, title: "Add Students", icon: "users" };
69+
6670
case "start-all-projects":
6771
return {
6872
Body: StartAllProjects,
6973
};
74+
75+
case "terminal-command":
76+
return { Body: TerminalCommandPanel };
77+
7078
case "reconfigure-all-projects":
7179
return {
7280
Body: ReconfigureAllProjects,
7381
};
82+
83+
case "export-grades":
84+
return { Body: ExportGrades };
85+
7486
default:
7587
return {
7688
Body: () => (

src/packages/frontend/frame-editors/course-editor/editor.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,10 @@ const COURSE_MENUS = {
4848
entries: {
4949
projects: [
5050
"course-start-all-projects",
51+
"course-terminal-command",
5152
"course-reconfigure-all-projects",
5253
],
54+
export: ["course-export-grades"],
5355
},
5456
},
5557
};
@@ -79,6 +81,18 @@ const COMMANDS = {
7981
actions.setModal("start-all-projects");
8082
},
8183
},
84+
"course-terminal-command": {
85+
icon: "terminal",
86+
label: "Run Terminal Command in all Student Projects",
87+
button: "Terminal",
88+
title:
89+
"Run a bash terminal command in the home directory of all student projects. Up to 30 commands run in parallel, with a timeout of 1 minutes.",
90+
onClick: ({ props }) => {
91+
const { id, actions } = props;
92+
actions.set_frame_type(id, "course_actions");
93+
actions.setModal("terminal-command");
94+
},
95+
},
8296
"course-reconfigure-all-projects": {
8397
icon: "mail",
8498
label: "Reconfigure all Projects",
@@ -90,6 +104,18 @@ const COMMANDS = {
90104
actions.setModal("reconfigure-all-projects");
91105
},
92106
},
107+
"course-export-grades": {
108+
icon: "table",
109+
label: "Export Grades",
110+
button: "Grades",
111+
title:
112+
"Export all the grades you have recorded for students in your course to a csv or Python file.",
113+
onClick: ({ props }) => {
114+
const { id, actions } = props;
115+
actions.set_frame_type(id, "course_actions");
116+
actions.setModal("export-grades");
117+
},
118+
},
93119
};
94120

95121
function initMenus() {

0 commit comments

Comments
 (0)