Skip to content

Commit

Permalink
Implemented the storing/exporting of new changes
Browse files Browse the repository at this point in the history
  • Loading branch information
facundoy committed Sep 28, 2024
1 parent 49d91b4 commit 5514fc5
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 6 deletions.
24 changes: 21 additions & 3 deletions src/haz3lschool/Exercise.re
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,8 @@ module F = (ExerciseEnv: ExerciseEnv) => {
~spec: spec,
~instructor_mode: bool,
~editing_prompt: bool,
~editing_point_dist: bool,
~editing_test_num: bool,
~settings: CoreSettings.t,
)
: state => {
Expand Down Expand Up @@ -658,7 +660,9 @@ module F = (ExerciseEnv: ExerciseEnv) => {
},
instructor_mode,
);
set_editing_prompt(state, editing_prompt);
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);
};

// # Stitching
Expand Down Expand Up @@ -1039,11 +1043,25 @@ 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_point_dist,
~editing_test_num,
) => {
data
|> Sexplib.Sexp.of_string
|> persistent_state_of_sexp
|> unpersist_state(~spec, ~instructor_mode, ~editing_prompt);
|> unpersist_state(
~spec,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
);
};

let deserialize_exercise_export = data => {
Expand Down
2 changes: 2 additions & 0 deletions src/haz3lschool/Gradescope.re
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ module Main = {
~spec,
~instructor_mode=true,
~editing_prompt=false,
~editing_point_dist=false,
~editing_test_num=false,
);
let report = exercise |> gen_grading_report;
{id, report};
Expand Down
4 changes: 4 additions & 0 deletions src/haz3lweb/Export.re
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,17 @@ 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;
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,
);
Log.import(all.log);
};
6 changes: 6 additions & 0 deletions src/haz3lweb/Model.re
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ let load_editors =
~mode: Settings.mode,
~instructor_mode: bool,
~editing_prompt: bool,
~editing_point_dist: bool,
~editing_test_num: bool,
)
: (Editors.t, ModelResults.t) =>
switch (mode) {
Expand All @@ -75,6 +77,8 @@ let load_editors =
~specs=ExerciseSettings.exercises,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
);
(Exercises(n, specs, exercise), ModelResults.empty);
};
Expand All @@ -99,6 +103,8 @@ 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,
);
let ui_state = init_model.ui_state;
{editors, settings, results, explainThisModel, ui_state};
Expand Down
34 changes: 32 additions & 2 deletions src/haz3lweb/Store.re
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,14 @@ module Exercise = {
};

let load_exercise =
(~settings: CoreSettings.t, spec, ~instructor_mode, ~editing_prompt)
(
~settings: CoreSettings.t,
spec,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
)
: Exercise.state => {
let keystring = Id.to_string(spec.id);
switch (JsUtil.get_localstore(keystring)) {
Expand All @@ -292,6 +299,8 @@ module Exercise = {
~spec,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
~settings,
)
) {
Expand Down Expand Up @@ -325,7 +334,14 @@ module Exercise = {
};

let load =
(~settings: CoreSettings.t, ~specs, ~instructor_mode, ~editing_prompt)
(
~settings: CoreSettings.t,
~specs,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
)
: (int, list(p(ZipperBase.t)), state) => {
switch (JsUtil.get_localstore(cur_exercise_key)) {
| Some(keystring) =>
Expand All @@ -342,6 +358,8 @@ module Exercise = {
~spec,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
~settings,
)
) {
Expand All @@ -365,6 +383,8 @@ module Exercise = {
first_spec,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
~settings,
),
);
Expand All @@ -381,6 +401,8 @@ module Exercise = {
~instructor_mode: bool,
~settings: CoreSettings.t,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
)
: exercise_export => {
{
Expand All @@ -400,6 +422,8 @@ module Exercise = {
~instructor_mode,
~settings,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
)
|> Exercise.persistent_state_of_state(~instructor_mode);
(key, exercise);
Expand All @@ -414,6 +438,8 @@ module Exercise = {
~instructor_mode,
~settings,
~editing_prompt=false,
~editing_point_dist=false,
~editing_test_num=false,
)
|> sexp_of_exercise_export
|> Sexplib.Sexp.to_string;
Expand All @@ -430,6 +456,8 @@ module Exercise = {
~instructor_mode: bool,
~settings: CoreSettings.t,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
) => {
let exercise_export = data |> deserialize_exercise_export;
save_exercise_id(exercise_export.cur_exercise);
Expand All @@ -446,6 +474,8 @@ module Exercise = {
~spec,
~instructor_mode,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
~settings,
),
~instructor_mode,
Expand Down
11 changes: 10 additions & 1 deletion src/haz3lweb/Update.re
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,8 @@ let switch_scratch_slide =
~instructor_mode,
idx: int,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
)
: option(Editors.t) =>
switch (editors) {
Expand All @@ -301,6 +303,8 @@ let switch_scratch_slide =
~instructor_mode,
~settings,
~editing_prompt,
~editing_point_dist,
~editing_test_num,
);
Some(Exercises(idx, specs, exercise));
};
Expand Down Expand Up @@ -497,7 +501,12 @@ let apply =
| SwitchScratchSlide(n) =>
let instructor_mode = model.settings.instructor_mode;
let editors = Editors.set_editing_prompt(model.editors, false);
let settings = {...model.settings, editing_prompt: false, editing_point_dist: false, editing_test_num: false};
let settings = {
...model.settings,
editing_prompt: false,
editing_point_dist: false,
editing_test_num: false,
};
switch (
switch_scratch_slide(
editors,
Expand Down

0 comments on commit 5514fc5

Please sign in to comment.