Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/course/commands.ts
5800 views
1
/*
2
* This file is part of CoCalc: Copyright © 2024 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import type { IconName } from "@cocalc/frontend/components/icon";
7
8
import { defineMessage } from "react-intl";
9
10
import type { CourseEditorActions } from "@cocalc/frontend/frame-editors/course-editor/actions";
11
import { course, IntlMessage, labels } from "@cocalc/frontend/i18n";
12
import { ENV_VARS_ICON } from "@cocalc/frontend/project/settings/environment";
13
14
// ATTN: the COMMANDS configuration is not only used in the menu (using ManageCommands),
15
// but also directly in some dialogs. Hence this is a subset from the Command type.
16
type Command = {
17
title: string | IntlMessage;
18
label: string | IntlMessage;
19
onClick: (arg: { props: { actions: CourseEditorActions } }) => void;
20
icon: IconName;
21
button: string | IntlMessage;
22
};
23
24
export const COMMANDS: { [name: string]: Command } = {
25
"add-students": {
26
icon: "users",
27
label: course.add_students,
28
button: defineMessage({
29
id: "course.commands.add-students.button",
30
defaultMessage: "+Student",
31
description:
32
"Adding Students in a course. A short label on a button, starting with a + sign.",
33
}),
34
title: course.add_students_tooltip,
35
onClick: ({ props }) => {
36
const { actions } = props;
37
actions.setModal("add-students");
38
},
39
},
40
"add-assignments": {
41
icon: "share-square",
42
label: course.add_assignments,
43
button: defineMessage({
44
id: "course.commands.add-assignments.button",
45
defaultMessage: "+Assignment",
46
description:
47
"Adding an assignment in a course. A short label on a button, starting with a + sign.",
48
}),
49
title: defineMessage({
50
id: "course.commands.add-assignments.tooltip",
51
defaultMessage: "Add one or more assignments to this course.",
52
}),
53
onClick: ({ props }) => {
54
const { actions } = props;
55
actions.setModal("add-assignments");
56
},
57
},
58
"add-handouts": {
59
icon: "text1",
60
label: defineMessage({
61
id: "course.commands.add-handouts.label",
62
defaultMessage: "Add Handouts",
63
description: "Adding a handout in a course.",
64
}),
65
button: defineMessage({
66
id: "course.commands.add-handouts.button",
67
defaultMessage: "+Handouts",
68
description:
69
"Adding a handout in a course. A short label on a button, starting with a + sign.",
70
}),
71
title: defineMessage({
72
id: "course.commands.add-handouts.tooltip",
73
defaultMessage: "Add one or more handouts to this course.",
74
}),
75
onClick: ({ props }) => {
76
const { actions } = props;
77
actions.setModal("add-handouts");
78
},
79
},
80
"title-and-description": {
81
icon: "header",
82
label: course.title_and_description_label,
83
button: labels.title,
84
title: defineMessage({
85
id: "course.commands.title-and-description.tooltip",
86
defaultMessage: "Set the course title and description.",
87
description: "title and description of a course for students.",
88
}),
89
onClick: ({ props }) => {
90
const { actions } = props;
91
actions.setModal("title-and-description");
92
},
93
},
94
"email-invitation": {
95
icon: "mail",
96
label: course.email_invitation_label,
97
button: labels.invite,
98
title: defineMessage({
99
id: "course.commands.email-invitation.tooltip",
100
defaultMessage:
101
"If you add a student to this course using their email address, and they do not have a CoCalc account, then they will receive this email invitation.",
102
}),
103
onClick: ({ props }) => {
104
const { actions } = props;
105
actions.setModal("email-invitation");
106
},
107
},
108
"copy-limit": {
109
icon: "users",
110
label: defineMessage({
111
id: "course.commands.copy-limit.label",
112
defaultMessage: "Parallel Copy Limit",
113
}),
114
button: labels.limit,
115
title: defineMessage({
116
id: "course.commands.copy-limit.tooltip",
117
defaultMessage:
118
"Max number of students to copy and collect files from in parallel.",
119
}),
120
onClick: ({ props }) => {
121
const { actions } = props;
122
actions.setModal("copy-limit");
123
},
124
},
125
"collaborator-policy": {
126
icon: "mail",
127
label: course.collaborator_policy,
128
button: defineMessage({
129
id: "course.commands.collaborator-policy.button",
130
defaultMessage: "Collab",
131
description: "Short label on a button, abbrivation of 'Collaborators'",
132
}),
133
title: defineMessage({
134
id: "course.commands.collaborator-policy.tooltip",
135
defaultMessage:
136
"Control if the owner and any collaborator on this student project may add collaborators to this project.",
137
}),
138
onClick: ({ props }) => {
139
const { actions } = props;
140
actions.setModal("collaborator-policy");
141
},
142
},
143
"restrict-student-projects": {
144
icon: "lock",
145
label: course.restrict_student_projects,
146
button: labels.restrict,
147
title: defineMessage({
148
id: "course.commands.restrict-student-projects.toolteip",
149
defaultMessage: "Remove functionality from student projects",
150
}),
151
onClick: ({ props }) => {
152
const { actions } = props;
153
actions.setModal("restrict-student-projects");
154
},
155
},
156
nbgrader: {
157
icon: "graduation-cap",
158
label: defineMessage({
159
id: "course.commands.nbgrader.label",
160
defaultMessage: "Configure nbgrader",
161
}),
162
button: labels.nbgrader,
163
title: defineMessage({
164
id: "course.commands.nbgrader.tooltip",
165
defaultMessage: "Configure how nbgrader works.",
166
}),
167
onClick: ({ props }) => {
168
const { actions } = props;
169
actions.setModal("nbgrader");
170
},
171
},
172
"software-environment": {
173
icon: "laptop",
174
label: labels.software_environment,
175
button: labels.software,
176
title: defineMessage({
177
id: "course.commands.software-environment.tooltip",
178
defaultMessage:
179
"Configure the software environment that all student projects will use.",
180
}),
181
onClick: ({ props }) => {
182
const { actions } = props;
183
actions.setModal("software-environment");
184
},
185
},
186
"network-file-systems": {
187
icon: "database",
188
label: labels.cloud_storage_remote_filesystems,
189
button: labels.nbgrader,
190
title: defineMessage({
191
id: "course.commands.network-file-systems.tooltip",
192
defaultMessage:
193
"Give all student projects read-only access to the same cloud stores and remote file systems as this instructor project.",
194
}),
195
onClick: ({ props }) => {
196
const { actions } = props;
197
actions.setModal("network-file-systems");
198
},
199
},
200
"env-variables": {
201
icon: ENV_VARS_ICON,
202
label: defineMessage({
203
id: "course.commands.env-variables.label",
204
defaultMessage: "Configure Environment Variables",
205
}),
206
button: labels.environment,
207
title: defineMessage({
208
id: "course.commands.env-variables.tooltip",
209
defaultMessage:
210
"Configure whether or not student projects inherit the environment variables of this instructor project.",
211
}),
212
onClick: ({ props }) => {
213
const { actions } = props;
214
actions.setModal("env-variables");
215
},
216
},
217
"configuration-copying": {
218
icon: "copy",
219
label: defineMessage({
220
id: "course.commands.configuration-copying.label",
221
defaultMessage: "Copy Course Configuration",
222
}),
223
button: labels.config,
224
title: defineMessage({
225
id: "course.commands.configuration-copying.tooltip",
226
defaultMessage: "Copy configuration from this course to other courses.",
227
}),
228
onClick: ({ props }) => {
229
const { actions } = props;
230
actions.setModal("configuration-copying");
231
},
232
},
233
upgrades: {
234
icon: "gears",
235
label: defineMessage({
236
id: "course.commands.upgrades.label",
237
defaultMessage: "Configure Upgrades (Student or Instructor Pay)",
238
}),
239
button: labels.upgrades,
240
title: defineMessage({
241
id: "course.commands.upgrades.tooltip",
242
defaultMessage:
243
"Use a license to upgrade all projects, or require your students to purchase a specific license.",
244
}),
245
onClick: ({ props }) => {
246
const { actions } = props;
247
actions.setModal("upgrades");
248
},
249
},
250
"start-all-projects": {
251
icon: "bolt",
252
label: defineMessage({
253
id: "course.commands.start-all-projects.label",
254
defaultMessage: "Start or Stop all Student Projects",
255
}),
256
button: labels.start_all,
257
title: defineMessage({
258
id: "course.commands.start-all-projects.tooltip",
259
defaultMessage:
260
"You can start all projects associated with this course so they are immediately ready for your students to use.",
261
}),
262
onClick: ({ props }) => {
263
const { actions } = props;
264
actions.setModal("start-all-projects");
265
},
266
},
267
"terminal-command": {
268
icon: "terminal",
269
label: defineMessage(course.run_terminal_command_title),
270
button: labels.terminal,
271
title: defineMessage({
272
id: "course.commands.terminal-command.tooltip",
273
defaultMessage:
274
"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.",
275
}),
276
onClick: ({ props }) => {
277
const { actions } = props;
278
actions.setModal("terminal-command");
279
},
280
},
281
"reconfigure-all-projects": {
282
icon: "mail",
283
label: course.reconfigure_all_projects,
284
button: labels.reconfigure,
285
title: defineMessage({
286
id: "course.commands.reconfigure-all-projects.tooltip",
287
defaultMessage:
288
"Update all projects with correct students, descriptions, etc.",
289
}),
290
onClick: ({ props }) => {
291
const { actions } = props;
292
actions.setModal("reconfigure-all-projects");
293
},
294
},
295
"export-grades": {
296
icon: "table",
297
label: course.export_grades,
298
button: course.grades,
299
title: defineMessage({
300
id: "course.commands.export-grades.tooltip",
301
defaultMessage:
302
"Export all the grades you have recorded for students in your course to a csv or Python file.",
303
}),
304
onClick: ({ props }) => {
305
const { actions } = props;
306
actions.setModal("export-grades");
307
},
308
},
309
"resend-invites": {
310
icon: "mail",
311
label: course.resend_invites,
312
button: labels.invites,
313
title: defineMessage({
314
id: "course.commands.resend-invites.tooltip",
315
defaultMessage:
316
"Send another email to every student who didn't sign up yet. This sends a maximum of one email every 1 day.",
317
}),
318
onClick: ({ props }) => {
319
const { actions } = props;
320
actions.setModal("resend-invites");
321
},
322
},
323
"copy-missing-handouts-and-assignments": {
324
icon: "graph",
325
label: course.copy_missing_handouts_assignments,
326
button: defineMessage({
327
id: "course.commands.copy-missing-handouts-and-assignments.button",
328
defaultMessage: "Copy Missing",
329
}),
330
title: defineMessage({
331
id: "course.commands.copy-missing-handouts-and-assignments.tooltip",
332
defaultMessage:
333
"If you add new students to your course, you can ensure they have all the assignments and handouts that you have already assigned to other students in the course.",
334
}),
335
onClick: ({ props }) => {
336
const { actions } = props;
337
actions.setModal("copy-missing-handouts-and-assignments");
338
},
339
},
340
"empty-trash": {
341
icon: "trash",
342
label: labels.empty_trash,
343
button: labels.trash,
344
title: defineMessage({
345
id: "course.commands.empty-trash.tooltip",
346
defaultMessage:
347
"Empty trash by purging deleted students, assignments, and handouts.",
348
}),
349
onClick: ({ props }) => {
350
const { actions } = props;
351
actions.setModal("empty-trash");
352
},
353
},
354
"delete-student-projects": {
355
icon: "trash",
356
label: defineMessage(course.delete_student_projects),
357
button: labels.delete,
358
title: defineMessage({
359
id: "course.commands.delete-student-projects.tooltip",
360
defaultMessage:
361
"If for some reason you would like to delete all the student projects created for this course, you may do so by clicking above.",
362
}),
363
onClick: ({ props }) => {
364
const { actions } = props;
365
actions.setModal("delete-student-projects");
366
},
367
},
368
"delete-students": {
369
icon: "trash",
370
label: defineMessage({
371
id: "course.commands.delete-students.label",
372
defaultMessage: "Delete Students",
373
}),
374
button: labels.delete,
375
title: defineMessage({
376
id: "course.commands.delete-students.tooltip",
377
defaultMessage:
378
"Student projects will not be deleted. If you make a mistake, students can still be undeleted from the Student tab or using TimeTravel.",
379
}),
380
onClick: ({ props }) => {
381
const { actions } = props;
382
actions.setModal("delete-students");
383
},
384
},
385
"delete-shared-project": {
386
icon: "trash",
387
label: course.delete_shared_project,
388
button: labels.delete,
389
title: defineMessage({
390
id: "course.commands.delete-shared-project.tooltip",
391
defaultMessage:
392
"If it exists, delete the common shared project, which everybody has access to.",
393
}),
394
onClick: ({ props }) => {
395
const { actions } = props;
396
actions.setModal("delete-shared-project");
397
},
398
},
399
"create-shared-project": {
400
icon: "users",
401
label: course.create_shared_project,
402
button: defineMessage({
403
id: "course.commands.create-shared-project.button",
404
defaultMessage: "Shared",
405
}),
406
title: defineMessage({
407
id: "course.commands.create-shared-project.tooltip",
408
defaultMessage:
409
"Create a single common shared project, which everybody – students and all collaborators on this project (your TAs and other instructors) – have write access to.",
410
}),
411
onClick: ({ props }) => {
412
const { actions } = props;
413
actions.setModal("create-shared-project");
414
},
415
},
416
} as const;
417
418