SUEN

AI 能不能判作業


AGrader (Seiue Auto‑Grader)

Version: v0.3

當然能,但都是在論壇裡。畢竟當初選擇 Discourse,關鍵就是看中了 AI 整合能力。問題是,開學至今,還是有學生更適應學校那個希悅。
這個週末就都砸上了。任務很明確:任意一台 VPS 上,一個腳本,把希悅內學生提交的任何一次乃至多次作業,提取文本和附件,遞交 AI 做結構化回覆,之後將 AI 的作業分數和評語,寫回希悅。AI 批閱的內容和結果,都 Tele 實時通知。

從考勤項目到通知項目到這個 AI 作業項目,這次抓完數據包,現希悅的整體結構,不想知道也刻到腦子裡了⋯⋯
一個教務平台可以做教學嗎?當然不能。
骨子裏這個平台是沒什麼出息的,從最初見 LCH 至今,我一直沒改過這看法。


1) What this is / current status

AGrader is an API‑first auto‑grading pipeline for Seiue/Chalk (希悦). It consists of:

Today’s result (verified logs): Full‑score mode completed 38/38 for a live task, with item ID validated upfront and each review+score written then verified. An existing score was detected for one student and respected (no overwrite).


2) Architecture at a glance

text
+--------------------------+       +-------------------------+
|  agrader.sh (installer)  | ----> |  /opt/agrader structure |
+--------------------------+       +-------------------------+
        |                                |
        v                                v
  System deps, venv,              main.py  +  requirements.txt
  env file, service               ├─ item_id resolver (TTL + refresh signals)
  orchestration                   ├─ review poster
                                  ├─ score poster (array endpoint)
                                  └─ verifier (readback)

3) Seiue API framework (what we rely on)

All endpoints below are documented as templates. Do not invent IDs. When needed, reconfirm with live capture.

3.1 Auth surface

3.2 Task / assignee context

3.3 Scoring (write)

3.4 Scoring (verify)

3.5 Error meanings we treat specially


4) agrader.sh logic (installer/runner)

Idempotent steps (safe to re‑run):

  1. Install deps: Python 3 + venv, jq, OCR stack (Tesseract + poppler + ghostscript).
  2. Create /opt/agrader and write:
    • requirements.txt, main.py, prompt.txt (if missing), .env scaffolding.
  3. Patch .env defaults (add keys only if missing; preserve your values).
  4. Create venv and pip install -r requirements.txt.
  5. Linux: write systemd unit agrader.service; enable+start. macOS: create LaunchAgent plist; load on demand.
  6. Prompt for:
    • Task IDs (comma‑separated or pasted URLs).
    • Mode: full‑score to all vs. normal workflow (AI flow to be added next).
  7. Start and tail logs.

Signals / safeguards included in this version:


5) Install

5.1 Linux (Debian/Ubuntu, RHEL/Fedora, Alpine)

bash
# As root (or with sudo):
bash <(curl -Ls https://raw.githubusercontent.com/ieduer/bdfz/main/agrader.sh)

5.2 macOS (Homebrew)

bash
# In Terminal as your user (admin recommended):
bash <(curl -Ls https://raw.githubusercontent.com/ieduer/bdfz/main/agrader.sh)

6) Environment variables (definitive reference)

The installer adds defaults only if not present. Your values are preserved.
Never place secrets in scripts; keep them in .env. Use placeholders like <TASK_ID> in docs.

6.1 Core runtime

6.2 Seiue headers / auth

6.3 Reviews and scoring endpoints (templates)

6.4 Scoring strategy / cache

6.5 Full‑score mode (today’s run)

6.6 AI (for upcoming “review by model”)

6.7 Concurrency & attachments

6.8 Logging

6.9 Optional Telegram


7) Operating the service

7.1 Set tasks and mode

bash
# Re-run installer to (re)prompt, or edit /opt/agrader/.env directly:
sudo nano /opt/agrader/.env
# Example (placeholders only):
MONITOR_TASK_IDS=<TASK_ID_1>,<TASK_ID_2>
FULL_SCORE_MODE=all
FULL_SCORE_COMMENT=Remember to review the sample answers.

7.2 Start / stop / logs (Linux)

bash
sudo systemctl restart agrader.service
journalctl -u agrader.service -f
# graceful stop
sudo systemctl stop agrader.service
# resume
sudo systemctl start agrader.service

7.3 Expected log lines (today’s run)


8) Troubleshooting & pitfalls


9) Roadmap / next steps


10) Quick command crib sheet

bash
# Install / reconfigure
bash <(curl -Ls https://raw.githubusercontent.com/ieduer/bdfz/main/agrader.sh)

# Edit env
sudo nano /opt/agrader/.env

# Restart service and watch logs (Linux)
sudo systemctl restart agrader.service
journalctl -u agrader.service -f

# One-shot run (set in .env)
RUN_MODE=oneshot
STOP_CRITERIA=score_and_review

Maintainer’s note (2025‑11‑02):
This version successfully executed a full‑score cycle end‑to‑end. Next milestone is AI‑assisted review, built on the same verified API surfaces above.