Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grading Requirements Editor #1398

Merged
merged 13 commits into from
Nov 9, 2024
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
190 changes: 181 additions & 9 deletions src/haz3lschool/Exercise.re
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ module F = (ExerciseEnv: ExerciseEnv) => {
};

[@deriving (show({with_path: false}), sexp, yojson)]
type persistent_state = (pos, list((pos, PersistentZipper.t)), string);
type persistent_state = (
pos,
list((pos, PersistentZipper.t)),
string,
point_distribution,
int,
string,
);

let editor_of_state: state => Editor.t =
({pos, eds, _}) =>
Expand Down Expand Up @@ -493,6 +500,131 @@ module F = (ExerciseEnv: ExerciseEnv) => {
},
};

let set_editing_test_val_rep = ({eds, _} as state: state, editing: bool) => {
...state,
eds: {
...eds,
prelude: Editor.set_read_only(eds.prelude, editing),
correct_impl: Editor.set_read_only(eds.correct_impl, editing),
your_tests: {
let tests = Editor.set_read_only(eds.your_tests.tests, editing);
{
tests,
required: eds.your_tests.required,
provided: eds.your_tests.provided,
};
},
your_impl: Editor.set_read_only(eds.your_impl, editing),
},
};

let update_test_val_rep =
(
{eds, _} as state: state,
new_test_num: int,
new_dist: int,
new_prov: int,
) => {
...state,
eds: {
...eds,
your_tests: {
...eds.your_tests,
required: new_test_num,
provided: new_prov,
},
point_distribution: {
...eds.point_distribution,
test_validation: new_dist,
},
},
};

let set_editing_mut_test_rep = ({eds, _} as state: state, editing: bool) => {
...state,
eds: {
...eds,
prelude: Editor.set_read_only(eds.prelude, editing),
correct_impl: Editor.set_read_only(eds.correct_impl, editing),
your_tests: {
let tests = Editor.set_read_only(eds.your_tests.tests, editing);
{
tests,
required: eds.your_tests.required,
provided: eds.your_tests.provided,
};
},
your_impl: Editor.set_read_only(eds.your_impl, editing),
},
};

let update_mut_test_rep = ({eds, _} as state: state, new_dist: int) => {
...state,
eds: {
...eds,
point_distribution: {
...eds.point_distribution,
mutation_testing: new_dist,
},
},
};

let set_editing_impl_grd_rep = ({eds, _} as state: state, editing: bool) => {
...state,
eds: {
...eds,
prelude: Editor.set_read_only(eds.prelude, editing),
correct_impl: Editor.set_read_only(eds.correct_impl, editing),
your_tests: {
let tests = Editor.set_read_only(eds.your_tests.tests, editing);
{
tests,
required: eds.your_tests.required,
provided: eds.your_tests.provided,
};
},
your_impl: Editor.set_read_only(eds.your_impl, editing),
},
};

let update_impl_grd_rep = ({eds, _} as state: state, new_dist: int) => {
...state,
eds: {
...eds,
point_distribution: {
...eds.point_distribution,
impl_grading: new_dist,
},
},
};

let set_editing_module_name = ({eds, _} as state: state, editing: bool) => {
...state,
eds: {
...eds,
prelude: Editor.set_read_only(eds.prelude, editing),
correct_impl: Editor.set_read_only(eds.correct_impl, editing),
your_tests: {
let tests = Editor.set_read_only(eds.your_tests.tests, editing);
{
tests,
required: eds.your_tests.required,
provided: eds.your_tests.provided,
};
},
your_impl: Editor.set_read_only(eds.your_impl, editing),
},
};

let update_module_name =
({eds, _} as state: state, new_module_name: string) => {
...state,
eds: {
...eds,
module_name: new_module_name,
},
};

let visible_in = (pos, ~instructor_mode) => {
switch (pos) {
| Prelude => instructor_mode
Expand All @@ -519,15 +651,33 @@ module F = (ExerciseEnv: ExerciseEnv) => {
|> List.map(((pos, editor)) => {
(pos, PersistentZipper.persist(Editor.(editor.state.zipper)))
});
(pos, zippers, eds.prompt);
(
pos,
zippers,
eds.prompt,
eds.point_distribution,
eds.your_tests.required,
eds.module_name,
);
};

let unpersist_state =
(
(pos, positioned_zippers, prompt): persistent_state,
(
pos,
positioned_zippers,
prompt,
point_distribution,
required,
module_name,
): persistent_state,
~spec: spec,
~instructor_mode: bool,
~editing_prompt: bool,
~editing_test_val_rep: bool,
~editing_mut_test_rep: bool,
~editing_impl_grd_rep: bool,
~editing_module_name: bool,
~settings: CoreSettings.t,
)
: state => {
Expand Down Expand Up @@ -562,14 +712,14 @@ module F = (ExerciseEnv: ExerciseEnv) => {
id: spec.id,
title: spec.title,
version: spec.version,
module_name: spec.module_name,
module_name,
prompt,
point_distribution: spec.point_distribution,
point_distribution,
prelude,
correct_impl,
your_tests: {
tests: your_tests_tests,
required: spec.your_tests.required,
required,
provided: spec.your_tests.provided,
},
your_impl,
Expand All @@ -583,7 +733,11 @@ module F = (ExerciseEnv: ExerciseEnv) => {
},
instructor_mode,
);
set_editing_prompt(state, editing_prompt);
let state = set_editing_prompt(state, editing_prompt);
let state = set_editing_test_val_rep(state, editing_test_val_rep);
let state = set_editing_mut_test_rep(state, editing_mut_test_rep);
let state = set_editing_module_name(state, editing_module_name);
set_editing_impl_grd_rep(state, editing_impl_grd_rep);
};

// # Stitching
Expand Down Expand Up @@ -964,11 +1118,29 @@ module F = (ExerciseEnv: ExerciseEnv) => {
|> Sexplib.Sexp.to_string;
};

let deserialize_exercise = (data, ~spec, ~instructor_mode, ~editing_prompt) => {
let deserialize_exercise =
(
data,
~spec,
~instructor_mode,
~editing_prompt,
~editing_test_val_rep,
~editing_mut_test_rep,
~editing_impl_grd_rep,
~editing_module_name,
) => {
data
|> Sexplib.Sexp.of_string
|> persistent_state_of_sexp
|> unpersist_state(~spec, ~instructor_mode, ~editing_prompt);
|> unpersist_state(
~spec,
~instructor_mode,
~editing_prompt,
~editing_test_val_rep,
~editing_mut_test_rep,
~editing_impl_grd_rep,
~editing_module_name,
);
};

let deserialize_exercise_export = data => {
Expand Down
4 changes: 4 additions & 0 deletions src/haz3lschool/Gradescope.re
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@ module Main = {
~spec,
~instructor_mode=true,
~editing_prompt=false,
~editing_test_val_rep=false,
~editing_mut_test_rep=false,
~editing_impl_grd_rep=false,
~editing_module_name=false,
);
let report = exercise |> gen_grading_report;
{id, report};
Expand Down
78 changes: 78 additions & 0 deletions src/haz3lweb/Editors.re
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,84 @@ let update_exercise_prompt = (editors: t, new_prompt: string): t =>
)
};

let set_editing_test_val_rep = (editors: t, editing: bool): t =>
switch (editors) {
| Scratch(_)
| Documentation(_) => editors
| Exercises(n, specs, exercise) =>
Exercises(n, specs, Exercise.set_editing_test_val_rep(exercise, editing))
};

let update_test_val_rep =
(editors: t, new_test_num: int, new_dist: int, new_prov: int): t =>
switch (editors) {
| Scratch(_)
| Documentation(_) => editors
| Exercises(n, specs, exercise) =>
Exercises(
n,
specs,
Exercise.update_test_val_rep(
exercise,
new_test_num,
new_dist,
new_prov,
),
)
};

let set_editing_mut_test_rep = (editors: t, editing: bool): t =>
switch (editors) {
| Scratch(_)
| Documentation(_) => editors
| Exercises(n, specs, exercise) =>
Exercises(n, specs, Exercise.set_editing_mut_test_rep(exercise, editing))
};

let update_mut_test_rep = (editors: t, new_dist: int): t =>
switch (editors) {
| Scratch(_)
| Documentation(_) => editors
| Exercises(n, specs, exercise) =>
Exercises(n, specs, Exercise.update_mut_test_rep(exercise, new_dist))
};

let set_editing_impl_grd_rep = (editors: t, editing: bool): t =>
switch (editors) {
| Scratch(_)
| Documentation(_) => editors
| Exercises(n, specs, exercise) =>
Exercises(n, specs, Exercise.set_editing_impl_grd_rep(exercise, editing))
};

let update_impl_grd_rep = (editors: t, new_dist: int): t =>
switch (editors) {
| Scratch(_)
| Documentation(_) => editors
| Exercises(n, specs, exercise) =>
Exercises(n, specs, Exercise.update_impl_grd_rep(exercise, new_dist))
};

let set_editing_module_name = (editors: t, editing: bool): t =>
switch (editors) {
| Scratch(_)
| Documentation(_) => editors
| Exercises(n, specs, exercise) =>
Exercises(n, specs, Exercise.set_editing_module_name(exercise, editing))
};

let update_module_name = (editors: t, new_module_name: string): t =>
switch (editors) {
| Scratch(_)
| Documentation(_) => editors
| Exercises(n, specs, exercise) =>
Exercises(
n,
specs,
Exercise.update_module_name(exercise, new_module_name),
)
};

let reset_nth_slide = (~settings: CoreSettings.t, n, slides): list(Editor.t) => {
let (_, init_editors, _) = Init.startup.scratch;
let data = List.nth(init_editors, n);
Expand Down
8 changes: 8 additions & 0 deletions src/haz3lweb/Export.re
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ let import_all = (data, ~specs) => {
Store.ExplainThisModel.import(all.explainThisModel);
let instructor_mode = settings.instructor_mode;
let editing_prompt = settings.editing_prompt;
let editing_test_val_rep = settings.editing_test_val_rep;
let editing_mut_test_rep = settings.editing_mut_test_rep;
let editing_impl_grd_rep = settings.editing_impl_grd_rep;
let editing_module_name = settings.editing_module_name;
Store.Scratch.import(~settings=settings.core, all.scratch);
Store.Exercise.import(
~settings=settings.core,
all.exercise,
~specs,
~instructor_mode,
~editing_prompt,
~editing_test_val_rep,
~editing_mut_test_rep,
~editing_impl_grd_rep,
~editing_module_name,
);
Log.import(all.log);
};
Loading
Loading