Download mathly2/static/submissions.js from wzender/mathly: direct link, hf CLI and curl.
- Browser
- Download file 2.15 kB
-
https://huggingface.co/spaces/wzender/mathly/resolve/main/mathly2/static/submissions.js
- Command line
-
hf download hf://spaces/wzender/mathly/mathly2/static/submissions.js
-
curl -L -o submissions.js https://huggingface.co/spaces/wzender/mathly/resolve/main/mathly2/static/submissions.js
2.15 kB
| // "讛讙砖讜转": every assignment from the student's teachers, grouped by state, and (on a phone) the switch for notifications. | |
| import { swr } from "./api.js"; | |
| import { assignmentHref, assignmentState } from "./home.js"; | |
| import { esc, fmt } from "./math.js"; | |
| import * as notifications from "./notifications.js"; | |
| import { shortDate, tabs } from "./ui.js"; | |
| /** The groups, in the order a student needs them: what to do first, then what waits, then what is done. */ | |
| const GROUPS = [ | |
| { id: "new", title: "讞讚砖讜转: 注讜讚 诇讗 讛讜讙砖讜", states: ["not_handed", "not_done"] }, | |
| { id: "returned", title: "讛讜讞讝专讜 诇转讬拽讜谉", states: ["returned"] }, | |
| { id: "waiting", title: "讛讜讙砖讜 讜诪诪转讬谞讜转 诇讘讚讬拽讛", states: ["handed_in"] }, | |
| { id: "checked", title: "谞讘讚拽讜", states: ["graded", "done"] }, | |
| ]; | |
| function item(a) { | |
| const s = assignmentState(a); | |
| const note = a.teacher_note ? `<span class="muted gr-note">讛注专转 讛诪讜专讛: ${fmt(a.teacher_note)}</span>` : ""; | |
| return `<li data-assignment="${a.id}" data-state="${esc(a.state)}"><a href="${assignmentHref(a)}"><b>${fmt(a.title)}</b></a> | |
| <span class="muted">${esc(a.class.name)} 路 注讚 ${shortDate(a.due_date)}</span><span class="tag st-${esc(a.state)}"><span aria-hidden="true">${s.symbol}</span> ${s.word}</span>${note}</li>`; | |
| } | |
| export const show = view => swr("/api/assignments", list => draw(view, list)); | |
| function draw(view, list) { | |
| const groups = GROUPS.map(g => ({ ...g, items: list.filter(a => g.states.includes(a.state)) })).filter(g => g.items.length); | |
| view(`${tabs("submissions")}<section class="card" id="submissions"><h2>讛讙砖讜转</h2> | |
| ${groups.length ? groups.map(g => `<section class="group" id="group-${g.id}" data-group="${g.id}"><h3>${g.title} <span class="tab-count">${g.items.length}</span></h3> | |
| <ul class="plain assignments">${g.items.map(item).join("")}</ul></section>`).join("") | |
| : `<p class="muted" id="no-assignments">讛诪讜专讬诐 注讜讚 诇讗 谞转谞讜 诪砖讬诪讜转.</p>`}</section> | |
| <section class="card" id="notifications" hidden></section>`); | |
| notifications.setup(document.getElementById("notifications")); | |
| } | |