Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ All notable changes to lectern are documented here.
- **`reg-lab-report` — lectern Layer 3 (instructor report + feedback delivery).** Two subcommands. `render` consumes the recon bundle + the digest-merged cohort + optional gradebook standing and deterministically produces the canonical instructor `REPORT.md` — distribution stats, Unicode **agate charts** (grade distribution, score histogram, ward-clear funnel), the ➊ grade table, a four-bucket **grading-recommendations** engine (confirm / edge-cases / low-confidence / upward-adjustment candidates), a roster-ordered Canvas entry sheet, and the Part-A-facts / Part-B-advisory firewall. This supersedes the agent-assembled `docs/recon-report-workflow.md` as the REPORT producer. `deliver` posts a sanitized, GPG-signed `FEEDBACK.md` (grade breakdown + student-facing comment) to each repo's `feedback` branch, closes the feedback PR, **then merges `feedback` into the default branch (`main`) so the file is visible on the student's repo home** — a signed merge commit, with a signed direct-add fallback for Classroom repos whose `main`/`feedback` have unrelated histories (no common ancestor). **`--dry-run` by default**, signing mandatory on both the feedback commit and the merge (refuses unsigned), idempotent on the feedback branch *and* on main independently (`--no-merge-main` opts out), and it emits a verbatim `FEEDBACK_LOG.md` record. Golden-tested against the CECS 378 Su26 Lab 1 (Spellbreaker) cohort.
- **Sanitization lint (`lectern.feedback_sanitize`).** Deterministic guard that withholds any student-facing comment leaking internal jargon (triage verdicts, honor-gate, advisory framing) or another student's name. Deliberately excludes crypto-colliding words (`oracle`, `digest`) so legitimate feedback isn't censored.

### Fixed
- **`reg-lab-report deliver --from-note` now reads the block `reg-lab-report render` writes.** The renderer's comments promised that the note parser keyed on its blocks, but the parser only knew the hand-authored grammar (an id line, a score line, `_Comments:_`). A rendered block wrapped its score line in `*github: … · [Feedback PR](…)*` and put the comment in a block quote, so the parser kept the total and silently dropped the comment and every component score. The delivered `FEEDBACK.md` would have shown the grade with no breakdown and no feedback. Found while delivering Fa26 Lab 1 extension feedback on 2026-10-27, where the notes were converted by hand before delivery. The score line now skips the `github:` lead and link tokens, the comment falls back to the block quote, and the rendered `_no submission_` quote reads as no comment. Prose containing a `·` is still never taken for a score line. `deliver --from-note` also warns, before anything ships, about a graded block with no comment or no score line. Checked against all six Fa26 recon reports: 173 graded blocks, none missing a comment or scores.

### Changed
- **Exam booklet layout in `references/reference_exam.tex`.** Exams print double-sided, so the scaffold now produces a closed booklet. Page 1 is a cover with no exam material: the name/ID block, an *Exam Information* block (points, questions, time, page range, note-card and device rules), the directions, and an honor pledge with a signature line and "sign the pledge before you open this exam". An unsigned pledge is not graded, and the cover says so. The last page is always a blank back cover on an even page; when the questions end on an even page a *scratch work* page fills the odd one. The header centre prints the student ID (never the name) on every page of a pre-filled copy, so a page separated from the cover is still identifiable, and the footer centre reads *Page N of X*. Blank copies and the key leave the header centre empty. Template-only: existing exam `.tex` are not backfilled, and the `\item ... \textit{(N pts)}` pattern is untouched, so `exam_pack` parsing is unaffected. Documented in `docs/design/exam-tex-format.md`. First used on CECS 378 Fa26 Exam 1.
- **`reg-exam-build` prints the combined stack in surname order.** The single-layout combined PDF and `build/register.csv` were ordered by the full display name, first name first, so the stack came off the printer in an order that matched no class list. Both now sort by surname, then given names. When the exam roster carries the registrar's `lms_name` column (`Last,First Middle`, as `reg-lms-roster-import` writes it), the surname comes from there, which keeps a multi-word surname whole. Without that column the last word of the name is the surname, as before. `gradescope_roster.csv` uses the same split, so its *Last Name* column is right for multi-word surnames too. The per-student serials and the verifier are unchanged; only the order moves. Surfaced on the CECS 378 Fa26 Exam 1 print run.
Expand Down
5 changes: 5 additions & 0 deletions docs/design/feedback-from-note.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ _Comments:_ <student-facing prose, until the next ### / ## / EOF>
`parse_feedback_note(path) -> [{github_id, student, total, grand, components, comment, graded}]`.
Tolerant of `__`/blank cells and pre-filled HTML-comment placeholders.

The block `reg-lab-report render` writes is accepted as well (since 2026-10-27):
a score line wrapped in `*…*` whose `github: [`id`](url)` lead and `[Feedback PR](url)`
link are skipped as decoration, and a comment taken from the block quote when there
is no `_Comments:_` marker. The rendered `> _no submission_` quote is not a comment.

## 3. Surface

```
Expand Down
9 changes: 9 additions & 0 deletions lectern/feedback_deliver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"""
import os
import subprocess
import sys

MERGE_MSG = "Merge feedback branch: add FEEDBACK.md (grade + comments)"
_ADD_MSG = "Add FEEDBACK.md (grade + comments)"
Expand Down Expand Up @@ -212,6 +213,14 @@ def main(argv=None):
from lectern.feedback_note import parse_feedback_note
rows = [r for r in parse_feedback_note(a.from_note) if r["graded"]]
render = render_feedback_md_from_note
# A graded block the parser read no comment or scores from is almost
# always a block shape it does not know; say so before anything ships.
for r in rows:
missing = [w for w, ok in (("comment", r["comment"]),
("score line", r["components"])) if not ok]
if missing:
print(f"warning: {r['github_id']}: no {' or '.join(missing)} found in "
f"{a.from_note}", file=sys.stderr)
else:
with open(a.cohort) as f:
rows = list(csv.DictReader(f))
Expand Down
53 changes: 47 additions & 6 deletions lectern/feedback_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@
`__` (or `—`) anywhere a number is expected means "not graded yet": the row is
returned with ``graded=False`` so callers can skip it (delivery only ships graded
rows). A leading ``+`` on a component marks extra credit.

The block `reg-lab-report render` writes is also accepted, so a rendered
`REPORT.md` can be delivered without hand conversion:

### <github_id> — **<total> / <grand>**
*github: [`<github_id>`](<url>) · Auto <n>/<max> · Writeup <n>/<max> · [Feedback PR](<url>)*

> <student-facing prose, every line quoted>

<!-- internal: … -->

The `github:` and link tokens on the score line are decoration, and the comment
is the block quote when there is no `_Comments:_` marker. The rendered
non-submission quote `_no submission_` is not a comment.
"""
import re

Expand All @@ -26,16 +40,30 @@
_GID = re.compile(r"`([^`]+)`")
_COMPTOK = re.compile(r"^\s*(.+?)\s+(\+?)(\d+|__|—)\s*/\s*(\d+)\s*$")
_HTML_COMMENT = re.compile(r"<!--.*?-->", re.S)
# Rendered score-line decoration: the `github: [`id`](url)` lead and bare
# markdown links such as `[Feedback PR](url)`. Skipped, not parsed as components.
_DECOR = re.compile(r"^\s*(?:github:\s*\S.*|\[[^\]]*\]\([^)]*\))\s*$")
_NO_SUBMISSION = "_no submission_"


def _num(s):
return None if s in ("__", "—") else int(s)


def _parse_scoreline(line):
"""A '·'-delimited line of `Label n/max` tokens → component dicts, or None."""
"""A '·'-delimited line of `Label n/max` tokens → component dicts, or None.

A rendered line wrapped in `*…*` with decoration tokens is accepted; any
other token that is not a component rejects the whole line, so prose with a
`·` in it is never mistaken for scores.
"""
s = line.strip()
if len(s) > 1 and s.startswith("*") and s.endswith("*") and not s.startswith("**"):
s = s[1:-1]
comps = []
for tok in line.split("·"):
for tok in s.split("·"):
if _DECOR.match(tok):
continue
m = _COMPTOK.match(tok)
if not m:
return None
Expand All @@ -45,6 +73,22 @@ def _parse_scoreline(line):
return comps or None


def _unquote(text):
"""Drop a block-quote prefix from every line (`> x` → `x`, `>` → blank)."""
return "\n".join(re.sub(r"^\s*>\s?", "", ln) for ln in text.splitlines())


def _comment(block):
"""The student-facing comment: after `_Comments:_`, else the block quote."""
text = _HTML_COMMENT.sub("", block)
cm = re.search(r"^([ \t]*>?)[ \t]*_Comments:_[ \t]*(.*)", text, re.S | re.M)
if cm: # a quoted marker (the rendered placeholder) quotes its prose too
return (_unquote(cm.group(2)) if ">" in cm.group(1) else cm.group(2)).strip()
quoted = [ln for ln in text.splitlines() if ln.lstrip().startswith(">")]
comment = _unquote("\n".join(quoted)).strip()
return "" if comment == _NO_SUBMISSION else comment


def parse_feedback_note(path):
"""Return one row dict per `###` student block found in the note.

Expand All @@ -70,10 +114,7 @@ def parse_feedback_note(path):
gidm = _GID.search(block) # first backtick token = the gid line
gid = gidm.group(1).strip() if gidm else None
components = next((c for c in (_parse_scoreline(ln) for ln in body) if c), None)
comment = ""
cm = re.search(r"_Comments:_\s*(.*)", block, re.S)
if cm:
comment = _HTML_COMMENT.sub("", cm.group(1)).strip()
comment = _comment(block)
graded = "_" not in total_s and "—" not in total_s
if gid:
rows.append({"github_id": gid, "student": name,
Expand Down
69 changes: 69 additions & 0 deletions tests/test_feedback_note.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,72 @@ def test_head_with_trailing_suffix_parses(tmp_path):
assert rows["hdent"]["graded"] is True
assert rows["hdent"]["components"][-1] == {"label": "ACE", "score": 14,
"max": 15, "ec": True}


# The block shape `reg-lab-report render` writes (lectern/report_render.py).
RENDERED = """\
## Per-student feedback & grades

> [!note] callout under the section heading, not a student block

### bwayne — **51 / 60**
*github: [`bwayne`](https://example.com/bwayne) · Auto 45/45 · Writeup 6/15 · [Feedback PR](https://example.com/bwayne/pull/1)*

> Your code now builds.
> Q1 needs the full trace: `x = x + 1` is three steps.
>
> Come to office hours.

<!-- internal: forensic notes, never shipped -->

### skyle — **__ / 60**
*github: [`skyle`](https://example.com/skyle) · Auto 45/45 · Writeup __/15*

> _Comments:_

### flawton — **0 / 60**
*github: `flawton` · Auto 0/45 · Writeup 0/15*

> _no submission_

## Canvas entry sheet
"""


def _rendered(tmp_path):
p = tmp_path / "RENDERED.md"
p.write_text(RENDERED)
return {r["github_id"]: r for r in parse_feedback_note(str(p))}


def test_rendered_block_components_and_comment(tmp_path):
bw = _rendered(tmp_path)["bwayne"]
assert bw["graded"] is True and (bw["total"], bw["grand"]) == (51, 60)
assert [(c["label"], c["score"], c["max"]) for c in bw["components"]] == [
("Auto", 45, 45), ("Writeup", 6, 15)]
assert bw["comment"] == ("Your code now builds.\n"
"Q1 needs the full trace: `x = x + 1` is three steps.\n\n"
"Come to office hours.")
assert "internal" not in bw["comment"]


def test_rendered_placeholder_and_non_submission(tmp_path):
rows = _rendered(tmp_path)
assert rows["skyle"]["graded"] is False and rows["skyle"]["comment"] == ""
assert rows["flawton"]["comment"] == ""
assert rows["flawton"]["components"][0]["label"] == "Auto"


def test_scoreline_decoration_only_skipped_on_rendered_lines():
assert _parse_scoreline("*github: [`x`](u) · Auto 1/2 · [Feedback PR](p)*") == [
{"label": "Auto", "score": 1, "max": 2, "ec": False}]
# Prose with a `·` still is not a score line.
assert _parse_scoreline("Nice work · see the notes below") is None
assert _parse_scoreline("github: me") is None # decoration alone carries no scores


def test_plain_comment_keeps_its_own_quote(tmp_path):
p = tmp_path / "Q.md"
p.write_text("### A — **5 / 10**\n`a1` · [repo](u)\nScore 5/10\n"
"_Comments:_ You wrote:\n> it works\nwhich is not a mechanism.\n")
assert "> it works" in parse_feedback_note(str(p))[0]["comment"]
Loading