Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/course/common/copy-run-all-messages.ts
10799 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
import type { IntlShape } from "react-intl";
7
8
import type { CopyStep } from "../types";
9
10
export function runAllIntro(intl: IntlShape, step: CopyStep): string {
11
const description =
12
"Intro line in the run-all popover; this text is immediately followed by a button label like 'All 23 students'";
13
switch (step) {
14
case "assignment":
15
return intl.formatMessage({
16
id: "course.copy-run-all.assign.intro",
17
defaultMessage: "Assign this assignment to",
18
description,
19
});
20
case "distribution":
21
return intl.formatMessage({
22
id: "course.copy-run-all.distribute.intro",
23
defaultMessage: "Distribute this handout to",
24
description,
25
});
26
case "collect":
27
return intl.formatMessage({
28
id: "course.copy-run-all.collect.intro",
29
defaultMessage: "Collect this assignment from",
30
description,
31
});
32
case "peer_assignment":
33
return intl.formatMessage({
34
id: "course.copy-run-all.peer_assign.intro",
35
defaultMessage: "Assign for peer grading to",
36
description,
37
});
38
case "peer_collect":
39
return intl.formatMessage({
40
id: "course.copy-run-all.peer_collect.intro",
41
defaultMessage: "Collect peer feedback from",
42
description,
43
});
44
case "return_graded":
45
return intl.formatMessage({
46
id: "course.copy-run-all.return.intro",
47
defaultMessage: "Return this assignment to",
48
description,
49
});
50
}
51
}
52
53
export function remainingStudents(
54
intl: IntlShape,
55
step: CopyStep,
56
count: number,
57
): string {
58
const description =
59
"Button label in run-all dialog; continues the intro phrase above and includes a student count";
60
switch (step) {
61
case "assignment":
62
return intl.formatMessage(
63
{
64
id: "course.copy-run-all.assign.remaining",
65
defaultMessage:
66
"The {count, plural, one {# student not already assigned} other {# students not already assigned}}",
67
description,
68
},
69
{ count },
70
);
71
case "distribution":
72
return intl.formatMessage(
73
{
74
id: "course.copy-run-all.distribute.remaining",
75
defaultMessage:
76
"The {count, plural, one {# student not already distributed} other {# students not already distributed}}",
77
description,
78
},
79
{ count },
80
);
81
case "collect":
82
return intl.formatMessage(
83
{
84
id: "course.copy-run-all.collect.remaining",
85
defaultMessage:
86
"The {count, plural, one {# student not already collected} other {# students not already collected}}",
87
description,
88
},
89
{ count },
90
);
91
case "peer_assignment":
92
return intl.formatMessage(
93
{
94
id: "course.copy-run-all.peer_assign.remaining",
95
defaultMessage:
96
"The {count, plural, one {# student not yet assigned for peer grading} other {# students not yet assigned for peer grading}}",
97
description,
98
},
99
{ count },
100
);
101
case "peer_collect":
102
return intl.formatMessage(
103
{
104
id: "course.copy-run-all.peer_collect.remaining",
105
defaultMessage:
106
"The {count, plural, one {# student not yet peer-collected} other {# students not yet peer-collected}}",
107
description,
108
},
109
{ count },
110
);
111
case "return_graded":
112
return intl.formatMessage(
113
{
114
id: "course.copy-run-all.return.remaining",
115
defaultMessage:
116
"The {count, plural, one {# student not already returned} other {# students not already returned}}",
117
description,
118
},
119
{ count },
120
);
121
}
122
}
123
124
export function allStudents(
125
intl: IntlShape,
126
step: CopyStep,
127
count: number,
128
): string {
129
const description =
130
"Button label in run-all dialog; continues the intro phrase above and includes a student count";
131
switch (step) {
132
case "assignment":
133
case "distribution":
134
return intl.formatMessage(
135
{
136
id: "course.copy-run-all.all.to",
137
defaultMessage:
138
"All {count, plural, one {# student} other {# students}}",
139
description,
140
},
141
{ count },
142
);
143
case "collect":
144
return intl.formatMessage(
145
{
146
id: "course.copy-run-all.all.from_collect",
147
defaultMessage:
148
"All {count, plural, one {# student who has already received it} other {# students who have already received it}}",
149
description,
150
},
151
{ count },
152
);
153
case "peer_assignment":
154
return intl.formatMessage(
155
{
156
id: "course.copy-run-all.all.peer_assignment",
157
defaultMessage:
158
"All {count, plural, one {# student for peer grading} other {# students for peer grading}}",
159
description,
160
},
161
{ count },
162
);
163
case "peer_collect":
164
return intl.formatMessage(
165
{
166
id: "course.copy-run-all.all.peer_collect",
167
defaultMessage:
168
"All {count, plural, one {# student who should have peer graded it} other {# students who should have peer graded it}}",
169
description,
170
},
171
{ count },
172
);
173
case "return_graded":
174
return intl.formatMessage(
175
{
176
id: "course.copy-run-all.all.return",
177
defaultMessage:
178
"All {count, plural, one {# student whose work you have graded} other {# students whose work you have graded}}",
179
description,
180
},
181
{ count },
182
);
183
}
184
}
185
186
export function commonMsgs(intl: IntlShape, overwriteToken: string) {
187
return {
188
typeOverwrite: intl.formatMessage(
189
{
190
id: "course.copy-run-all.type_overwrite",
191
defaultMessage:
192
'Type "{token}" in the box below if you are sure you want to overwrite any work the students may have done.',
193
description:
194
"Prompt in dangerous overwrite flow: user must type literal confirmation token to confirm replacing student files",
195
},
196
{
197
token: overwriteToken,
198
},
199
),
200
confirmWithoutBackup: intl.formatMessage({
201
id: "course.copy-run-all.confirm_without_backup",
202
defaultMessage: "Confirm replacing files",
203
description:
204
"Final dangerous confirmation button label after typing the required confirmation token",
205
}),
206
withBackup: intl.formatMessage({
207
id: "course.copy-run-all.with_backup",
208
defaultMessage: "Yes, do it (with backup)",
209
description:
210
"Safer confirmation button: run copy for all and keep backups of overwritten files",
211
}),
212
withoutBackup: intl.formatMessage({
213
id: "course.copy-run-all.without_backup",
214
defaultMessage: "Replace student files!",
215
description:
216
"Dangerous button label that opens overwrite confirmation flow without backups",
217
}),
218
back: intl.formatMessage({
219
id: "course.copy-run-all.back",
220
defaultMessage: "Back",
221
description: "Back button in run-all confirmation dialogs",
222
}),
223
studentSubdirInfo: intl.formatMessage(
224
{
225
id: "course.copy-run-all.assignment.student_subdir",
226
defaultMessage:
227
"Only the {subdir} subdirectory will be copied to the students.",
228
description:
229
"Info message in assignment run-all popover; {subdir} is a literal directory name and should not be translated",
230
},
231
{
232
subdir: "student/",
233
},
234
),
235
nbgraderDocs: intl.formatMessage(
236
{
237
id: "course.copy-run-all.docs.nbgrader",
238
defaultMessage: "{pkg} docs",
239
description:
240
"Link label to package documentation; {pkg} is a package name and should not be translated",
241
},
242
{
243
pkg: "nbgrader",
244
},
245
),
246
};
247
}
248
249