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/assignments/skip.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
/*
7
Skip assigning or collecting an assignment, so next step can be attempted.
8
*/
9
10
import { CourseActions } from "../actions";
11
import { AssignmentRecord } from "../store";
12
import { Icon, Gap, Tip } from "../../components";
13
import { Button } from "antd";
14
15
interface SkipCopyProps {
16
assignment: AssignmentRecord;
17
step: string;
18
actions: CourseActions;
19
}
20
21
export function SkipCopy({ assignment, step, actions }: SkipCopyProps) {
22
function click() {
23
actions.assignments.set_skip(
24
assignment.get("assignment_id"),
25
step,
26
!assignment.get(`skip_${step}` as any),
27
);
28
}
29
30
function icon_extra() {
31
let icon;
32
let extra: JSX.Element | undefined = undefined;
33
if (assignment.get(`skip_${step}` as any)) {
34
icon = "check-square-o";
35
if (assignment.getIn(["peer_grade", "enabled"])) {
36
// don't bother even trying to implement skip and peer grading at once.
37
extra = (
38
<span>
39
<Gap /> (Please disable this or peer grading.)
40
</span>
41
);
42
}
43
} else {
44
icon = "square-o";
45
}
46
return { icon, extra };
47
}
48
49
const { icon, extra } = icon_extra();
50
51
return (
52
<Tip
53
placement="left"
54
title="Skip step in workflow"
55
tip="Click this checkbox to enable doing the next step after this step, e.g., you can try to collect assignments that you never explicitly assigned (maybe the students put them in place some other way)."
56
>
57
<Button onClick={click}>
58
<Icon name={icon} /> Skip {step} {extra}
59
</Button>
60
</Tip>
61
);
62
}
63
64