// The student's grades: each lesson's best quiz grade, and each real test's exercise tests and simulation (best grade, tries, last date). // Assignments will add their rows later. import { swr } from "./api.js"; import { esc, fmt } from "./math.js"; import { forSubject, shortDate, tabs } from "./ui.js"; const day = iso => iso ? new Date(iso).toLocaleDateString("he-IL", { day: "numeric", month: "numeric" }) : ""; const tries = n => `${n} ${n === 1 ? "ניסיון" : "ניסיונות"}`; function row({ attrs, href, title, best, attempts, last }) { return `
  • ${title} ${best} ${tries(attempts)}${last ? ` · האחרון ב־${day(last)}` : ""}
  • `; } const testTitle = (t, suffix) => `מבחן ב־${shortDate(t.date)}: ${suffix}${t.removed ? " (הוסר)" : ""}`; export const show = view => swr(forSubject("/api/grades"), data => draw(view, data)); function draw(view, { quizzes, exercise_tests: exercises = [], simulations = [], assignments = [] }) { const none = !quizzes.length && !exercises.length && !simulations.length && !assignments.length; view(`${tabs("grades")}

    הציונים שלי

    ${none ? `

    עוד אין ציונים. הבוחן של כל שיעור מחכה בסוף השיעור במסלול.

    ` : ""} ${quizzes.length ? `

    בחנים

    ` : ""} ${exercises.length ? `

    מבחני תרגול

    ` : ""} ${assignments.length ? `

    משימות

    ` : ""} ${simulations.length ? `

    מבחני סימולציה

    ` : ""}
    `); }