Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/frontend/course/common/student-assignment-info-header.tsx
Views: 687
/*1* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.2* License: MS-RSL – see LICENSE.md for details3*/45import { Col, Row } from "antd";6import { useIntl } from "react-intl";78import { Tip } from "@cocalc/frontend/components";9import { capitalize, unreachable } from "@cocalc/util/misc";10import { AssignmentCopyStep } from "../types";11import { course } from "@cocalc/frontend/i18n";1213interface StudentAssignmentInfoHeaderProps {14title: "Assignment" | "Handout" | "Student";15peer_grade?: boolean;16}1718export function StudentAssignmentInfoHeader({19title,20peer_grade,21}: StudentAssignmentInfoHeaderProps) {22const intl = useIntl();2324function tip_title(key: AssignmentCopyStep | "grade"): {25tip: string;26title: string;27} {28switch (key) {29case "assignment":30return {31title: intl.formatMessage({32id: "course.student-assignment-info-header.assign.label",33defaultMessage: "Assign to Student",34description: "Student in an online course",35}),36tip: intl.formatMessage({37id: "course.student-assignment-info-header.assign.tooltip",38defaultMessage:39"This column gives the status of making homework available to students, and lets you copy homework to one student at a time.",40description: "Student in an online course",41}),42};43case "collect":44return {45title: intl.formatMessage({46id: "course.student-assignment-info-header.collect.label",47defaultMessage: "Collect from Student",48description: "Student in an online course",49}),50tip: intl.formatMessage({51id: "course.student-assignment-info-header.collect.tooltip",52defaultMessage:53"This column gives status information about collecting homework from students, and lets you collect from one student at a time.",54description: "Student in an online course",55}),56};57case "grade":58return {59title: intl.formatMessage({60id: "course.student-assignment-info-header.grade.label",61defaultMessage: "Record Homework Grade",62description: "For a student in an online course",63}),64tip: intl.formatMessage({65id: "course.student-assignment-info-header.grade.tooltip",66defaultMessage:67"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.",68description: "For a student in an online course",69}),70};71case "peer_assignment":72return {73title: intl.formatMessage({74id: "course.student-assignment-info-header.peer_assignment.label",75defaultMessage: "Assign Peer Grading",76description: "For a group of students in an online course",77}),78tip: intl.formatMessage({79id: "course.student-assignment-info-header.peer_assignment.tooltip",80defaultMessage:81"This column gives the status of sending out collected homework to students for peer grading.",82description: "For a group of students in an online course",83}),84};8586case "peer_collect":87return {88title: intl.formatMessage({89id: "course.student-assignment-info-header.peer_collect.label",90defaultMessage: "Collect Peer Grading",91description: "For a group of students in an online course",92}),93tip: intl.formatMessage({94id: "course.student-assignment-info-header.peer_collect.tooltip",95defaultMessage:96"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.",97description: "For a group of students in an online course",98}),99};100101case "return_graded":102return {103title: intl.formatMessage({104id: "course.student-assignment-info-header.return.label",105defaultMessage: "Return to Student",106description: "For a student in an online course",107}),108tip: intl.formatMessage({109id: "course.student-assignment-info-header.return.tooltip",110defaultMessage: "Return to Student",111description:112"This column gives status information about when you returned homework to the students. Once you have entered a grade, you can return the assignment.",113}),114};115default:116unreachable(key);117}118throw new Error(`unknown key: ${key}`);119}120121function render_col(122number: number,123key: AssignmentCopyStep | "grade",124width: 4 | 6,125) {126const { tip, title } = tip_title(key);127128return (129<Col md={width} key={key}>130<Tip title={title} tip={tip}>131<b>132{number}. {title}133</b>134</Tip>135</Col>136);137}138139function render_headers() {140const w = 6;141return (142<Row>143{render_col(1, "assignment", w)}144{render_col(2, "collect", w)}145{render_col(3, "grade", w)}146{render_col(4, "return_graded", w)}147</Row>148);149}150151function render_headers_peer() {152const w = 4;153return (154<Row>155{render_col(1, "assignment", w)}156{render_col(2, "collect", w)}157{render_col(3, "peer_assignment", w)}158{render_col(4, "peer_collect", w)}159{render_col(5, "grade", w)}160{render_col(6, "return_graded", w)}161</Row>162);163}164165const tooltip = intl.formatMessage(166{167id: "course.student-assignment-info-header.row.tooltip",168defaultMessage: `{key, select,169Assignment {This column gives the directory name of the assignment.}170other {This column gives the name of the student.}}`,171description: "student in an online course",172},173{ key: title },174);175176function titleIntl(): string {177switch (title) {178case "Assignment":179return intl.formatMessage(course.assignment);180case "Handout":181return intl.formatMessage(course.handout);182case "Student":183return intl.formatMessage(course.student);184default:185return title;186}187}188189return (190<div>191<Row style={{ borderBottom: "2px solid #aaa" }}>192<Col md={4} key="title">193<Tip title={title} tip={tooltip}>194<b>{capitalize(titleIntl())}</b>195</Tip>196</Col>197<Col md={20} key="rest">198{peer_grade ? render_headers_peer() : render_headers()}199</Col>200</Row>201</div>202);203}204205206