Hazel supports three kinds of exercises, captured by the Exercise.t sum
type in src/web/exercises/Exercise.re. Logic common to all exercise kinds
lives in Exercise.re; logic specific to each kind lives in its own
<Kind>Exercise*.re / <Kind>ExerciseMode.re / <Kind>Grading.re modules:
| Constructor | Kind | Spec module | Editor/View module | Template file |
|---|---|---|---|---|
Code |
Programming | CodeExercise |
CodeExerciseMode |
src/web/exercises/examples/BlankCodeExercise.ml |
Derivation |
Derivations | DerivationExercise |
DerivationExerciseMode |
src/web/exercises/examples/BlankDerivationExercise.ml |
Theorem |
Proofs | TheoremExercise |
TheoremExerciseMode |
src/web/exercises/examples/BlankTheoremExercise.ml |
Shared grading primitives (score, percentage, score_view, ...) live in
src/web/exercises/Grading.re; code-exercise-specific grading (test
validation, mutation testing, syntax checks, impl grading) lives in
CodeGrading.re. Batch grade report generation is exposed via the Hazel
CLI (src/CLI/Grade.re), which dispatches over each exercise kind and
is invoked by the grade-json / grade-report subcommands.
The cycle for creating an exercise of any kind is the same:
-
Copy the appropriate template file from
src/web/exercises/examples/(or any other subdirectory of your choosing undersrc/web/exercises) and rename it to match your exercise module name, e.g.Ex_MyNewExercise. Use the.mlextension (for technical reasons). Make sure themodule_namefield in the file matches your exercise module name (without the extension). -
Add your exercise to the
exerciseslist insrc/web/exercises/settings/ExerciseSettings_base.re, e.g.let exercises: list(Exercise.t) = [ ... Ex_MyNewExercise.exercise, ];
-
Compile and load Hazel (
make serve), select your exercise, and make sure Instructor Mode is on (graduation-cap toggle in the top bar). -
When satisfied, click the "Export Exercise Module" button in the File menu. This downloads a replacement for your
.mlfile that you can drop in, blowing away the stub in the blank template. -
Compile and run again; your exercise will load in the state you exported. Keep iterating until the exercise is ready.
make and make release create instructor mode versions of Hazel.
make student and make student-release create student mode versions, which obviously don't let you enter instructor mode.
Notably, student and instructor mode have a different serialization format, so it probably won't work to go between the two without clearing your local storage (in browser dev tools).
Grade reports are generated by the Hazel CLI (see src/CLI/README.md).
Two subcommands are available:
./hazel grade-json <submission.json> --output <out.json>— writes the raw grading data as JSON (one section per exercise, each withname,summary, andoverall=[earned, max])../hazel grade-report <submission.json> --output <out.txt>— writes a human-readable text report with per-exercise summaries and a total at the bottom.
Omit --output to write to stdout instead.