Skip to content

Commit

Permalink
Changed actions from edited data to edited section
Browse files Browse the repository at this point in the history
  • Loading branch information
facundoy committed Sep 28, 2024
1 parent 5514fc5 commit 824969a
Show file tree
Hide file tree
Showing 13 changed files with 234 additions and 130 deletions.
91 changes: 56 additions & 35 deletions src/haz3lschool/Exercise.re
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ module F = (ExerciseEnv: ExerciseEnv) => {
},
};

let set_editing_test_num = ({eds, _} as state: state, editing: bool) => {
let set_editing_test_val_rep = ({eds, _} as state: state, editing: bool) => {
...state,
eds: {
...eds,
Expand All @@ -511,18 +511,23 @@ module F = (ExerciseEnv: ExerciseEnv) => {
},
};

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

let set_editing_point_dist = ({eds, _} as state: state, editing: bool) => {
let set_editing_mut_test_rep = ({eds, _} as state: state, editing: bool) => {
...state,
eds: {
...eds,
Expand All @@ -540,32 +545,44 @@ module F = (ExerciseEnv: ExerciseEnv) => {
},
};

let update_point_dist =
({eds, _} as state: state, new_point_dist: int, dist: string) => {
let updated_point_distribution =
switch (dist) {
| "test_validation" => {
...eds.point_distribution,
test_validation: new_point_dist,
}
| "mutation_testing" => {
...eds.point_distribution,
mutation_testing: new_point_dist,
}
| "impl_grading" => {
...eds.point_distribution,
impl_grading: new_point_dist,
}
| _ => eds.point_distribution
};
let update_mut_test_rep = ({eds, _} as state: state, new_dist: int) => {
...state,
eds: {
...eds,
point_distribution: {
...eds.point_distribution,
mutation_testing: new_dist,
},
},
};

{
...state,
eds: {
...eds,
point_distribution: updated_point_distribution,
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 visible_in = (pos, ~instructor_mode) => {
Expand Down Expand Up @@ -603,8 +620,9 @@ module F = (ExerciseEnv: ExerciseEnv) => {
~spec: spec,
~instructor_mode: bool,
~editing_prompt: bool,
~editing_point_dist: bool,
~editing_test_num: bool,
~editing_test_val_rep: bool,
~editing_mut_test_rep: bool,
~editing_impl_grd_rep: bool,
~settings: CoreSettings.t,
)
: state => {
Expand Down Expand Up @@ -661,8 +679,9 @@ module F = (ExerciseEnv: ExerciseEnv) => {
instructor_mode,
);
let state = set_editing_prompt(state, editing_prompt);
let state = set_editing_point_dist(state, editing_point_dist);
set_editing_test_num(state, editing_test_num);
let state = set_editing_test_val_rep(state, editing_test_val_rep);
let state = set_editing_mut_test_rep(state, editing_mut_test_rep);
set_editing_impl_grd_rep(state, editing_impl_grd_rep);
};

// # Stitching
Expand Down Expand Up @@ -1049,8 +1068,9 @@ module F = (ExerciseEnv: ExerciseEnv) => {
~spec,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
~editing_test_val_rep,
~editing_mut_test_rep,
~editing_impl_grd_rep,
) => {
data
|> Sexplib.Sexp.of_string
Expand All @@ -1059,8 +1079,9 @@ module F = (ExerciseEnv: ExerciseEnv) => {
~spec,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
~editing_test_val_rep,
~editing_mut_test_rep,
~editing_impl_grd_rep,
);
};

Expand Down
5 changes: 3 additions & 2 deletions src/haz3lschool/Gradescope.re
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ module Main = {
~spec,
~instructor_mode=true,
~editing_prompt=false,
~editing_point_dist=false,
~editing_test_num=false,
~editing_test_val_rep=false,
~editing_mut_test_rep=false,
~editing_impl_grd_rep=false,
);
let report = exercise |> gen_grading_report;
{id, report};
Expand Down
40 changes: 28 additions & 12 deletions src/haz3lweb/Editors.re
Original file line number Diff line number Diff line change
Expand Up @@ -137,40 +137,56 @@ let update_exercise_prompt = (editors: t, new_prompt: string): t =>
)
};

let set_editing_test_num = (editors: t, editing: bool): 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_num(exercise, editing))
Exercises(n, specs, Exercise.set_editing_test_val_rep(exercise, editing))
};

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

let set_editing_point_dist = (editors: t, editing: bool): t =>
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_point_dist(exercise, editing))
Exercises(n, specs, Exercise.set_editing_mut_test_rep(exercise, editing))
};

let update_point_dist = (editors: t, new_point_dist: int, dist: string): t =>
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_point_dist(exercise, new_point_dist, dist),
)
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 reset_nth_slide = (~settings: CoreSettings.t, n, slides): list(Editor.t) => {
Expand Down
10 changes: 6 additions & 4 deletions src/haz3lweb/Export.re
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,19 @@ let import_all = (data, ~specs) => {
Store.ExplainThisModel.import(all.explainThisModel);
let instructor_mode = settings.instructor_mode;
let editing_prompt = settings.editing_prompt;
let editing_point_dist = settings.editing_point_dist;
let editing_test_num = settings.editing_test_num;
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;
Store.Scratch.import(~settings=settings.core, all.scratch);
Store.Exercise.import(
~settings=settings.core,
all.exercise,
~specs,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
~editing_test_val_rep,
~editing_mut_test_rep,
~editing_impl_grd_rep,
);
Log.import(all.log);
};
24 changes: 24 additions & 0 deletions src/haz3lweb/Grading.re
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,18 @@ module TestValidationReport = {
};
};

// let update_requirements = _ => {
// let new_prompt =
// Obj.magic(
// Js_of_ocaml.Js.some(JsUtil.get_elem_by_id("prompt-input-box")),
// )##.value;
// let update_events = [
// inject(Set(EditingPrompt)),
// inject(UpdatePrompt(new_prompt)),
// ];
// Virtual_dom.Vdom.Effect.Many(update_events);
// };

let view = (~inject, report: t, max_points: int) => {
Cell.report_footer_view([
div(
Expand Down Expand Up @@ -236,6 +248,18 @@ module MutationTestingReport = {
// };
// };

// let update_requirements = _ => {
// let new_prompt =
// Obj.magic(
// Js_of_ocaml.Js.some(JsUtil.get_elem_by_id("prompt-input-box")),
// )##.value;
// let update_events = [
// inject(Set(EditingPrompt)),
// inject(UpdatePrompt(new_prompt)),
// ];
// Virtual_dom.Vdom.Effect.Many(update_events);
// };

let view = (~inject, report: t, max_points: int) =>
if (max_points == 0) {
Node.div([]);
Expand Down
5 changes: 3 additions & 2 deletions src/haz3lweb/Init.ml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/haz3lweb/Log.re
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ let is_action_logged: UpdateAction.t => bool =
| Redo
| UpdateResult(_)
| UpdatePrompt(_)
| UpdatePointDist(_)
| UpdateTestNum(_)
| UpdateTestValRep(_)
| UpdateMutTestRep(_)
| UpdateImplGrdRep(_)
| ToggleStepper(_)
| StepperAction(_, StepForward(_) | StepBackward)
| UpdateExplainThisModel(_) => true;
Expand Down
15 changes: 9 additions & 6 deletions src/haz3lweb/Model.re
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ let load_editors =
~mode: Settings.mode,
~instructor_mode: bool,
~editing_prompt: bool,
~editing_point_dist: bool,
~editing_test_num: bool,
~editing_test_val_rep: bool,
~editing_mut_test_rep: bool,
~editing_impl_grd_rep: bool,
)
: (Editors.t, ModelResults.t) =>
switch (mode) {
Expand All @@ -77,8 +78,9 @@ let load_editors =
~specs=ExerciseSettings.exercises,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
~editing_test_val_rep,
~editing_mut_test_rep,
~editing_impl_grd_rep,
);
(Exercises(n, specs, exercise), ModelResults.empty);
};
Expand All @@ -103,8 +105,9 @@ let load = (init_model: t): t => {
~mode=settings.mode,
~instructor_mode=settings.instructor_mode,
~editing_prompt=settings.editing_prompt,
~editing_point_dist=settings.editing_point_dist,
~editing_test_num=settings.editing_test_num,
~editing_test_val_rep=settings.editing_test_val_rep,
~editing_mut_test_rep=settings.editing_mut_test_rep,
~editing_impl_grd_rep=settings.editing_impl_grd_rep,
);
let ui_state = init_model.ui_state;
{editors, settings, results, explainThisModel, ui_state};
Expand Down
5 changes: 3 additions & 2 deletions src/haz3lweb/Settings.re
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ type t = {
context_inspector: bool,
instructor_mode: bool,
editing_prompt: bool,
editing_point_dist: bool,
editing_test_num: bool,
editing_test_val_rep: bool,
editing_mut_test_rep: bool,
editing_impl_grd_rep: bool,
benchmark: bool,
explainThis: ExplainThisModel.Settings.t,
mode,
Expand Down
Loading

0 comments on commit 824969a

Please sign in to comment.