CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/course/common/student-assignment-info-header.tsx
Views: 687
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 { Col, Row } from "antd";
7
import { useIntl } from "react-intl";
8
9
import { Tip } from "@cocalc/frontend/components";
10
import { capitalize, unreachable } from "@cocalc/util/misc";
11
import { AssignmentCopyStep } from "../types";
12
import { course } from "@cocalc/frontend/i18n";
13
14
interface StudentAssignmentInfoHeaderProps {
15
title: "Assignment" | "Handout" | "Student";
16
peer_grade?: boolean;
17
}
18
19
export function StudentAssignmentInfoHeader({
20
title,
21
peer_grade,
22
}: StudentAssignmentInfoHeaderProps) {
23
const intl = useIntl();
24
25
function tip_title(key: AssignmentCopyStep | "grade"): {
26
tip: string;
27
title: string;
28
} {
29
switch (key) {
30
case "assignment":
31
return {
32
title: intl.formatMessage({
33
id: "course.student-assignment-info-header.assign.label",
34
defaultMessage: "Assign to Student",
35
description: "Student in an online course",
36
}),
37
tip: intl.formatMessage({
38
id: "course.student-assignment-info-header.assign.tooltip",
39
defaultMessage:
40
"This column gives the status of making homework available to students, and lets you copy homework to one student at a time.",
41
description: "Student in an online course",
42
}),
43
};
44
case "collect":
45
return {
46
title: intl.formatMessage({
47
id: "course.student-assignment-info-header.collect.label",
48
defaultMessage: "Collect from Student",
49
description: "Student in an online course",
50
}),
51
tip: intl.formatMessage({
52
id: "course.student-assignment-info-header.collect.tooltip",
53
defaultMessage:
54
"This column gives status information about collecting homework from students, and lets you collect from one student at a time.",
55
description: "Student in an online course",
56
}),
57
};
58
case "grade":
59
return {
60
title: intl.formatMessage({
61
id: "course.student-assignment-info-header.grade.label",
62
defaultMessage: "Record Homework Grade",
63
description: "For a student in an online course",
64
}),
65
tip: intl.formatMessage({
66
id: "course.student-assignment-info-header.grade.tooltip",
67
defaultMessage:
68
"Use this column to record the grade the student received on the assignment. Once the grade is recorded, you can return the assignment. You can also export grades to a file in the Configuration tab. Enter anything here; it does not have to be a number.",
69
description: "For a student in an online course",
70
}),
71
};
72
case "peer_assignment":
73
return {
74
title: intl.formatMessage({
75
id: "course.student-assignment-info-header.peer_assignment.label",
76
defaultMessage: "Assign Peer Grading",
77
description: "For a group of students in an online course",
78
}),
79
tip: intl.formatMessage({
80
id: "course.student-assignment-info-header.peer_assignment.tooltip",
81
defaultMessage:
82
"This column gives the status of sending out collected homework to students for peer grading.",
83
description: "For a group of students in an online course",
84
}),
85
};
86
87
case "peer_collect":
88
return {
89
title: intl.formatMessage({
90
id: "course.student-assignment-info-header.peer_collect.label",
91
defaultMessage: "Collect Peer Grading",
92
description: "For a group of students in an online course",
93
}),
94
tip: intl.formatMessage({
95
id: "course.student-assignment-info-header.peer_collect.tooltip",
96
defaultMessage:
97
"This column gives status information about collecting the peer grading work that students did, and lets you collect peer grading from one student at a time.",
98
description: "For a group of students in an online course",
99
}),
100
};
101
102
case "return_graded":
103
return {
104
title: intl.formatMessage({
105
id: "course.student-assignment-info-header.return.label",
106
defaultMessage: "Return to Student",
107
description: "For a student in an online course",
108
}),
109
tip: intl.formatMessage({
110
id: "course.student-assignment-info-header.return.tooltip",
111
defaultMessage: "Return to Student",
112
description:
113
"This column gives status information about when you returned homework to the students. Once you have entered a grade, you can return the assignment.",
114
}),
115
};
116
default:
117
unreachable(key);
118
}
119
throw new Error(`unknown key: ${key}`);
120
}
121
122
function render_col(
123
number: number,
124
key: AssignmentCopyStep | "grade",
125
width: 4 | 6,
126
) {
127
const { tip, title } = tip_title(key);
128
129
return (
130
<Col md={width} key={key}>
131
<Tip title={title} tip={tip}>
132
<b>
133
{number}. {title}
134
</b>
135
</Tip>
136
</Col>
137
);
138
}
139
140
function render_headers() {
141
const w = 6;
142
return (
143
<Row>
144
{render_col(1, "assignment", w)}
145
{render_col(2, "collect", w)}
146
{render_col(3, "grade", w)}
147
{render_col(4, "return_graded", w)}
148
</Row>
149
);
150
}
151
152
function render_headers_peer() {
153
const w = 4;
154
return (
155
<Row>
156
{render_col(1, "assignment", w)}
157
{render_col(2, "collect", w)}
158
{render_col(3, "peer_assignment", w)}
159
{render_col(4, "peer_collect", w)}
160
{render_col(5, "grade", w)}
161
{render_col(6, "return_graded", w)}
162
</Row>
163
);
164
}
165
166
const tooltip = intl.formatMessage(
167
{
168
id: "course.student-assignment-info-header.row.tooltip",
169
defaultMessage: `{key, select,
170
Assignment {This column gives the directory name of the assignment.}
171
other {This column gives the name of the student.}}`,
172
description: "student in an online course",
173
},
174
{ key: title },
175
);
176
177
function titleIntl(): string {
178
switch (title) {
179
case "Assignment":
180
return intl.formatMessage(course.assignment);
181
case "Handout":
182
return intl.formatMessage(course.handout);
183
case "Student":
184
return intl.formatMessage(course.student);
185
default:
186
return title;
187
}
188
}
189
190
return (
191
<div>
192
<Row style={{ borderBottom: "2px solid #aaa" }}>
193
<Col md={4} key="title">
194
<Tip title={title} tip={tooltip}>
195
<b>{capitalize(titleIntl())}</b>
196
</Tip>
197
</Col>
198
<Col md={20} key="rest">
199
{peer_grade ? render_headers_peer() : render_headers()}
200
</Col>
201
</Row>
202
</div>
203
);
204
}
205
206