// "הגשות": 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 ? `הערת המורה: ${fmt(a.teacher_note)}` : ""; return `
  • ${fmt(a.title)} ${esc(a.class.name)} · עד ${shortDate(a.due_date)} ${s.word}${note}
  • `; } 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")}

    הגשות

    ${groups.length ? groups.map(g => `

    ${g.title} ${g.items.length}

    `).join("") : `

    המורים עוד לא נתנו משימות.

    `}
    `); notifications.setup(document.getElementById("notifications")); }