SQL Grader — LLM grading for SQL assignments

2025Data + AI

Grades a class's SQL submissions against a solution key with partial credit, then writes the results as CSV reports.

Pipeline diagram: solution key and submissions, parse and align, Gemini grading, CSV reports
PythonGeminiSQLLLM-as-judgeGoogle Colab

Problem

Grading SQL by hand is slow, and checking for an exact match is unfair: there are many correct ways to write the same query. Teaching assistants needed something that gives partial credit and explains why.

What I built

  • Parsing: student submissions arrive as messy text files ("Q1)", "1)", "Question 1:"). A parser lines each answer up with the right question in the solution key.
  • Grading: each answer goes to Gemini with the reference query and a rubric covering logic, syntax, and equivalent approaches. It returns a score and specific feedback as structured output.
  • Rate limits: calls are paced to stay inside the free tier, so a class of 4 students × 12 questions (48 calls) runs in about four minutes for nothing.
  • Reports: three CSVs: a question-by-question breakdown, a grade summary with class statistics, and per-student feedback.
  • Runs in Colab, so a TA only needs to upload files and click run.

What I learned

An LLM judge needs a strict output format and a rubric, or its scores drift between runs. Pinning both made the grades consistent enough to compare across students.