From 9b7d7ab01e3ef1047c3de209a5e289ddb749dad9 Mon Sep 17 00:00:00 2001 From: reevafaisal Date: Fri, 27 Sep 2024 12:11:47 -0500 Subject: [PATCH] fixed the editor linkage issue, working on making sure user progress is saved --- src/haz3lschool/DocumentationEnv.re | 215 ++++++----- src/haz3lschool/Exercise.re | 6 +- src/haz3lweb/Editors.re | 21 +- src/haz3lweb/Log.re | 5 +- src/haz3lweb/Main.re | 1 + src/haz3lweb/Model.re | 21 +- src/haz3lweb/ScratchSlide.re | 346 ------------------ src/haz3lweb/Store.re | 6 +- src/haz3lweb/Update.re | 36 +- .../view/assistant/UpdateAssistant.re | 6 +- 10 files changed, 175 insertions(+), 488 deletions(-) diff --git a/src/haz3lschool/DocumentationEnv.re b/src/haz3lschool/DocumentationEnv.re index caa43a3946..df5ad4e518 100644 --- a/src/haz3lschool/DocumentationEnv.re +++ b/src/haz3lschool/DocumentationEnv.re @@ -159,58 +159,29 @@ module D = (DocEnv: DocEnv) => { // | CorrectImpl => eds.correct_impl // | YourTestsValidation => eds.your_tests.tests // | YourTestsTesting => eds.your_tests.tests - | YourImpl => eds.your_impl + | YourImpl => + // print_endline("grabs YourImpl"); + eds.your_impl // | HiddenBugs(i) => List.nth(eds.hidden_bugs, i).impl - | HiddenTests => eds.hidden_tests.tests + | HiddenTests => + // print_endline("grabs HiddenTests"); + eds.hidden_tests.tests }; - let put_editor = ({pos, eds, _} as state: state, editor: Editor.t) => + let put_editor = ({pos, eds} as state: state, editor: Editor.t) => switch (pos) { - // | Prelude => { - // ...state, - // eds: { - // ...eds, - // prelude: editor, - // }, - // } - // | CorrectImpl => { - // ...state, - // eds: { - // ...eds, - // correct_impl: editor, - // }, - // } - // | YourTestsValidation - // | YourTestsTesting => { - // ...state, - // eds: { - // ...eds, - // your_tests: { - // ...eds.your_tests, - // tests: editor, - // }, - // }, - // } - | YourImpl => { + | YourImpl => + // print_endline("YourImpl"); + { ...state, eds: { ...eds, your_impl: editor, }, } - // | HiddenBugs(n) => { - // ...state, - // eds: { - // ...eds, - // hidden_bugs: - // Util.ListUtil.put_nth( - // n, - // {...List.nth(eds.hidden_bugs, n), impl: editor}, - // eds.hidden_bugs, - // ), - // }, - // } - | HiddenTests => { + | HiddenTests => + // print_endline("HiddenTests"); + { ...state, eds: { ...eds, @@ -222,21 +193,22 @@ module D = (DocEnv: DocEnv) => { } }; - let editors = ({eds, _}: state) => - [ - // eds.prelude, - // eds.correct_impl, - // eds.your_tests.tests, - // eds.your_tests.tests, - eds.your_impl, - ] - // @ List.map(wrong_impl => wrong_impl.impl, eds.hidden_bugs) - @ [eds.hidden_tests.tests]; - - let editor_positions = - [YourImpl] - // @ List.mapi((i, _) => HiddenBugs(i), eds.hidden_bugs) - @ [HiddenTests]; + let editors = ({eds, _}: state) => [ + // eds.prelude, + // eds.correct_impl, + // eds.your_tests.tests, + // eds.your_tests.tests, + eds.your_impl, + eds.hidden_tests.tests, + ]; + // @ List.map(wrong_impl => wrong_impl.impl, eds.hidden_bugs) + // @ [eds.hidden_tests.tests]; + + // let editor_positions = + // [YourImpl] + // // @ List.mapi((i, _) => HiddenBugs(i), eds.hidden_bugs) + // @ [HiddenTests]; + let editor_positions = [YourImpl, HiddenTests]; let positioned_editors = state => List.combine(editor_positions, editors(state)); @@ -281,35 +253,41 @@ module D = (DocEnv: DocEnv) => { let switch_editor = (~pos, instructor_mode, ~documentation) => if (!instructor_mode) { switch (pos) { - | HiddenTests => - // Update the `hidden_tests` editor when position is HiddenTests - let updated_hidden_tests = documentation.eds.hidden_tests.tests; - { - // ...documentation, - eds: { - ...documentation.eds, - hidden_tests: { - ...documentation.eds.hidden_tests, - tests: updated_hidden_tests, - }, - }, - pos: HiddenTests, - }; - | YourImpl => - // Update the `your_impl` editor when position is YourImpl - let updated_your_impl = documentation.eds.your_impl; - { - // ...documentation, - eds: { - ...documentation.eds, - your_impl: updated_your_impl, - }, - pos: YourImpl, - }; - // | _ => { - // // Handle other cases by just updating the position - // {eds: documentation.eds, pos}; - // } + | HiddenTests + // => + // Update the `hidden_tests` editor when position is HiddenTests + // print_endline("Updating HiddenTests editor"); + // let updated_hidden_tests = documentation.eds.hidden_tests.tests; + // { + // // ...documentation, + // eds: { + // ...documentation.eds, + // hidden_tests: { + // ...documentation.eds.hidden_tests, + // tests: updated_hidden_tests, + // }, + // your_impl: documentation.eds.your_impl, + // }, + // pos: HiddenTests, + // }; + // | YourImpl => + // // Update the `your_impl` editor when position is YourImpl + // print_endline("Updating YourImpl editor"); + // let updated_your_impl = documentation.eds.your_impl; + // { + // // ...documentation, + // eds: { + // ...documentation.eds, + // your_impl: updated_your_impl, + // hidden_tests: documentation.eds.hidden_tests, + // }, + // pos: YourImpl, + // }; + | _ => { + // Handle other cases by just updating the position + eds: documentation.eds, + pos, + } }; } else { { @@ -478,6 +456,11 @@ module D = (DocEnv: DocEnv) => { }; }; + // let state_of_spec = (spec, ~instructor_mode: bool): state => { + // let eds = eds_of_spec(spec); + // set_instructor_mode({pos: HiddenTests, eds}, instructor_mode); + // }; + let state_of_spec = (spec, ~instructor_mode: bool): state => { let eds = eds_of_spec(spec); set_instructor_mode({pos: HiddenTests, eds}, instructor_mode); @@ -608,33 +591,48 @@ module D = (DocEnv: DocEnv) => { // term_of(ed3), // ); + // let stitch_term = ({eds, _}: state): stitched(TermItem.t) => { + // let instructor = eds.hidden_tests.tests |> term_of; + // let user_impl_term = { + // // let your_impl_term = + // eds.your_impl |> term_of |> wrap_filter(FilterAction.Step); // let prelude_term = + // // EditorUtil.append_exp(your_impl_term); + // }; + // // let test_validation_term = + // // stitch3(eds.prelude, eds.correct_impl, eds.your_tests.tests); + // // let user_tests_term = + // // EditorUtil.append_exp(user_impl_term, term_of(eds.your_tests.tests)); + // let hidden_tests_term = + // EditorUtil.append_exp(user_impl_term, term_of(eds.hidden_tests.tests)); + // { + // // test_validation: wrap(test_validation_term, eds.your_tests.tests), + // user_impl: wrap(user_impl_term, eds.your_impl), + // // user_tests: wrap(user_tests_term, eds.your_tests.tests), + // // instructor works here as long as you don't shadow anything in the prelude + // // prelude: wrap(instructor, eds.prelude), + // instructor: wrap(instructor, eds.hidden_tests.tests), + // // hidden_bugs: + // // List.map( + // // (t): TermItem.t => + // // // term_of(t.impl), + // // wrap(stitch3(eds.prelude, t.impl, eds.your_tests.tests), t.impl), + // // eds.hidden_bugs, + // // ), + // hidden_tests: wrap(hidden_tests_term, eds.hidden_tests.tests), + // }; + // }; let stitch_term = ({eds, _}: state): stitched(TermItem.t) => { let instructor = eds.hidden_tests.tests |> term_of; let user_impl_term = { - // let your_impl_term = - eds.your_impl |> term_of |> wrap_filter(FilterAction.Step); // let prelude_term = - // EditorUtil.append_exp(your_impl_term); + eds.your_impl |> term_of |> wrap_filter(FilterAction.Step); }; - // let test_validation_term = - // stitch3(eds.prelude, eds.correct_impl, eds.your_tests.tests); - // let user_tests_term = - // EditorUtil.append_exp(user_impl_term, term_of(eds.your_tests.tests)); - let hidden_tests_term = - EditorUtil.append_exp(user_impl_term, term_of(eds.hidden_tests.tests)); + + // No combining of your_impl_term with hidden_tests + let hidden_tests_term = term_of(eds.hidden_tests.tests); + { - // test_validation: wrap(test_validation_term, eds.your_tests.tests), user_impl: wrap(user_impl_term, eds.your_impl), - // user_tests: wrap(user_tests_term, eds.your_tests.tests), - // instructor works here as long as you don't shadow anything in the prelude - // prelude: wrap(instructor, eds.prelude), instructor: wrap(instructor, eds.hidden_tests.tests), - // hidden_bugs: - // List.map( - // (t): TermItem.t => - // // term_of(t.impl), - // wrap(stitch3(eds.prelude, t.impl, eds.your_tests.tests), t.impl), - // eds.hidden_bugs, - // ), hidden_tests: wrap(hidden_tests_term, eds.hidden_tests.tests), }; }; @@ -647,6 +645,7 @@ module D = (DocEnv: DocEnv) => { Stitching is necessary to concatenate terms from different editors, which are then typechecked. */ + let stitch_static = (settings: CoreSettings.t, t: stitched(TermItem.t)): stitched_statics => { let mk = ({term, term_ranges, _}: TermItem.t): StaticsItem.t => { @@ -953,7 +952,7 @@ module D = (DocEnv: DocEnv) => { // let prelude = Zipper.next_blank(); // let correct_impl = Zipper.next_blank(); // let your_tests_tests = Zipper.next_blank(); - let your_impl = Zipper.next_blank(); + let your_impl_m = Zipper.next_blank(); // let hidden_bugs = // List.init( // num_wrong_impls, @@ -977,7 +976,7 @@ module D = (DocEnv: DocEnv) => { // required: required_tests, // provided: provided_tests, // }, - your_impl, + your_impl: your_impl_m, // hidden_bugs, hidden_tests: { tests: hidden_tests_tests, diff --git a/src/haz3lschool/Exercise.re b/src/haz3lschool/Exercise.re index 86fdd4ce99..4cebe46f94 100644 --- a/src/haz3lschool/Exercise.re +++ b/src/haz3lschool/Exercise.re @@ -272,7 +272,11 @@ module F = (ExerciseEnv: ExerciseEnv) => { | _ => {eds: exercise.eds, pos} }; } else { - {eds: exercise.eds, pos}; + { + // print_endline("im exercise"); + eds: exercise.eds, + pos, + }; }; let zipper_of_code = code => { diff --git a/src/haz3lweb/Editors.re b/src/haz3lweb/Editors.re index 8f11affd61..19c4b7b3f4 100644 --- a/src/haz3lweb/Editors.re +++ b/src/haz3lweb/Editors.re @@ -21,11 +21,11 @@ type t = | Documentation(string, list((string, DocumentationEnv.state))) | Exercises(int, list(Exercise.spec), Exercise.state); -[@deriving (show({with_path: false}), sexp, yojson)] -type cur_state = - | ScratchState(ScratchSlide.state) - | DocumentationState(DocumentationEnv.state) - | ExerciseState(Exercise.state); +// [@deriving (show({with_path: false}), sexp, yojson)] +// type cur_state = +// | ScratchState(ScratchSlide.state) +// | DocumentationState(DocumentationEnv.state) +// | ExerciseState(Exercise.state); let get_editor = (editors: t): Editor.t => switch (editors) { @@ -120,10 +120,19 @@ let put_editor = (editor: Editor.t, eds: t): t => (hint: string, state: DocumentationEnv.state) : (string, DocumentationEnv.state) => if (hint == name) { + // print_endline("hint == name"); + print_endline(hint); + print_endline(name); + let updatedState = DocumentationEnv.put_editor(state, editor); + (hint, updatedState); } else { - (hint, state); + ( + // print_endline("different_slide"); + hint, + state, + ); }; // Map the update function over the slides diff --git a/src/haz3lweb/Log.re b/src/haz3lweb/Log.re index 59b3163b59..c7c37ca1ee 100644 --- a/src/haz3lweb/Log.re +++ b/src/haz3lweb/Log.re @@ -110,7 +110,10 @@ let import = (data: string): unit => let update = (action: UpdateAction.t): unit => if (is_action_logged(action)) { - Entry.save(Entry.mk(action)); + // print_endline("Log Updating" ++ UpdateAction.show(action)); + Entry.save( + Entry.mk(action), + ); }; let get_and = (f: string => unit): unit => diff --git a/src/haz3lweb/Main.re b/src/haz3lweb/Main.re index e1268431af..6de813e553 100644 --- a/src/haz3lweb/Main.re +++ b/src/haz3lweb/Main.re @@ -63,6 +63,7 @@ let apply = (model, action, state, ~schedule_action): Model.t => { | Error(FailedToPerform(err)) => // TODO(andrew): reinstate this history functionality print_endline(Update.Failure.show(FailedToPerform(err))); + // print_endline("ERROR IN MAIN UPDATE"); //{...model, history: ActionHistory.failure(err, model.history)}; model; | Error(err) => diff --git a/src/haz3lweb/Model.re b/src/haz3lweb/Model.re index b970f1fbb1..0aa84cf8f3 100644 --- a/src/haz3lweb/Model.re +++ b/src/haz3lweb/Model.re @@ -74,23 +74,13 @@ let load_editors = (Scratch(idx, slides), results); | Documentation => let (name, slides, results) = Store.Documentation.load(~settings); - // let toEditor = (state: DocumentationEnv.state): Editor.t => { - // switch (state) { - // | s => s.eds.hidden_tests.tests - // }; - // }; - // let from_tup = ((word: string, status: DocumentationEnv.state)) => ( - // word, - // toEditor(status), - // ); - // let slides = List.map(from_tup, slides); - // let slides = reset_named_slide(name, slides); + let fromEditor = (editor: Editor.t): DocumentationEnv.state => { pos: DocumentationEnv.YourImpl, eds: { title: "", description: "", - your_impl: editor, + your_impl: Editor.init(Zipper.init()), hidden_tests: { tests: editor, hints: [], @@ -101,7 +91,14 @@ let load_editors = word, fromEditor(editor), ); + print_endline("inside load editors"); let slides = List.map(to_tup, slides); + // let (n, specs, exercise) = + // Store.Exercise.load( + // ~specs=ExerciseSettings.exercises, + // ~instructor_mode, + // ); + // (Exercises(n, specs, exercise), ModelResults.empty); (Documentation(name, slides), results); | Exercises => diff --git a/src/haz3lweb/ScratchSlide.re b/src/haz3lweb/ScratchSlide.re index d54fac3090..40234eeaff 100644 --- a/src/haz3lweb/ScratchSlide.re +++ b/src/haz3lweb/ScratchSlide.re @@ -155,349 +155,3 @@ let mk_statics = Statics.Map.error_ids(editor.state.meta.term_ranges, info_map); {term, info_map, error_ids}; }; - -//// CREATING MODULE - -// module type ScratchSlideEnv = { -// type node; -// let default: node; -// let output_header: string => string; -// }; - -// let output_header_grading = _module_name => -// "module Documentation = GradePrelude.Documentation\n" ++ "let prompt = ()\n"; - -// module S = (ScratchSlideEnv: ScratchSlideEnv) => { -// [@deriving (show({with_path: false}), sexp, yojson)] -// type hidden_tests('code) = { -// tests: 'code, -// hints: list(string), -// }; - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type p('code) = { -// title: string, -// description: string, -// hidden_tests: hidden_tests('code), -// }; - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type state = p(Editor.t); - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type persistent_state = p(PersistentZipper.t); - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type hint = string; - -// let toEditor = (state: state): Editor.t => { -// switch (state) { -// | s => s.hidden_tests.tests -// }; -// }; - -// let fromEditor = (editor: Editor.t): state => { -// title: "", -// description: "", -// hidden_tests: { -// tests: editor, -// hints: [], -// }, -// }; - -// let scratch_key = n => "scratch_" ++ n; - -// let persist = (editor: Editor.t) => { -// PersistentZipper.persist(editor.state.zipper); -// }; - -// // let persist = (editor: p(Editor.t)) => { -// // let zip = editor.hidden_tests.tests.state.zipper; -// // PersistentZipper.persist(zip); -// // }; - -// let unpersist = (zipper: persistent_state) => { -// let zipper = PersistentZipper.unpersist(zipper.hidden_tests.tests); -// Editor.init(zipper, ~read_only=false); -// }; - -// let serialize = (state: state) => { -// let editor = persist(state.hidden_tests.tests); -// let persistent_state: persistent_state = { -// title: state.title, -// description: state.description, -// hidden_tests: { -// tests: editor, -// hints: state.hidden_tests.hints, -// }, -// }; -// // Sexplib.Sexp.to_string (sexp_of_persistent_state persistent_state) -// persistent_state |> sexp_of_persistent_state |> Sexplib.Sexp.to_string; -// // Persist(editor) |> sexp_of_persistent_state |> Sexplib.Sexp.to_string; -// }; - -// let deserialize = (data: string) => { -// Sexplib.Sexp.of_string(data) |> persistent_state_of_sexp |> unpersist; -// }; - -// let deserialize_opt = (data: string) => { -// let sexp = -// try(Some(Sexplib.Sexp.of_string(data) |> persistent_state_of_sexp)) { -// | _ => None -// }; -// sexp |> Option.map(sexp => sexp |> unpersist); -// }; - -// let export = (state: state) => { -// let editor = persist(state.hidden_tests.tests); -// let persistent_state: persistent_state = { -// title: state.title, -// description: state.description, -// hidden_tests: { -// tests: editor, -// hints: state.hidden_tests.hints, -// }, -// }; -// persistent_state |> yojson_of_persistent_state; -// }; - -// let import = (data: string) => { -// data |> Yojson.Safe.from_string |> persistent_state_of_yojson |> unpersist; -// }; - -// let export_init = (state: state) => { -// let editor = persist(state.hidden_tests.tests); -// let persistent_state: persistent_state = { -// title: state.title, -// description: state.description, -// hidden_tests: { -// tests: editor, -// hints: state.hidden_tests.hints, -// }, -// }; -// persistent_state |> show_persistent_state; -// }; - -// let mk_statics = -// (~settings: Settings.t, editor: Editor.t, ctx_init: Ctx.t) -// : CachedStatics.statics => { -// let term = MakeTerm.from_zip_for_sem(editor.state.zipper) |> fst; -// let info_map = Interface.Statics.mk_map_ctx(settings.core, ctx_init, term); -// let error_ids = -// Statics.Map.error_ids(editor.state.meta.term_ranges, info_map); -// {term, info_map, error_ids}; -// }; - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type key = (string, int); - -// let key_of = p => { -// (p.title); -// }; - -// let find_key_opt = (key, specs: list(p('code))) => { -// specs |> Util.ListUtil.findi_opt(spec => key_of(spec) == key); -// }; - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type pos = -// // | YourImpl -// | HiddenTests; - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type slide_state = { -// pos : pos, -// eds : state, -// }; - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type spec = p(Zipper.t); - -// [@deriving (show({with_path: false}), sexp, yojson)] -// type transitionary_spec = p(CodeString.t); - -// let map = (p: p('a), _: 'a => 'b): p('b) => { -// { -// title: p.title, -// description: p.description, -// // point_distribution: p.point_distribution, -// // your_tests: { -// // tests: f(p.your_tests.tests), -// // required: p.your_tests.required, -// // provided: p.your_tests.provided, -// // }, -// // your_impl: f(p.your_impl), -// hidden_tests: { -// tests: PersistentZipper.persist(p.hidden_tests.tests), -// hints: p.hidden_tests.hints, -// }, -// // syntax_tests: p.syntax_tests, -// }; -// }; - -// // [@deriving (show({with_path: false}), sexp, yojson)] -// // type eds = p(Editor.t); - -// // let key_of_state = ({eds, _}) => key_of(eds); - -// // [@deriving (show({with_path: false}), sexp, yojson)] -// // type persistent_state = (pos, list((pos, PersistentZipper.t))); - -// let editor_of_state = (state : state) : Editor.t => { -// state.hidden_tests.tests -// // switch (pos) { -// // | YourImpl => eds.your_impl -// // | HiddenTests => eds.hidden_tests.tests -// }; - -// let put_editor = ({pos, eds} as state: slide_state, editor: Editor.t) => -// switch (pos) { -// // | YourImpl => { -// // ...state, -// // eds: { -// // ...eds, -// // your_impl: editor, -// // }, -// // } -// | HiddenTests => { -// ...state, -// eds: { -// ...eds, -// hidden_tests: { -// ...eds.hidden_tests, -// tests: editor, -// }, -// }, -// } -// }; - -// let editors = ({eds, _}: slide_state) => -// // [ -// // eds.your_impl, -// // ] -// // @ List.map(wrong_impl => wrong_impl.impl, eds.hidden_bugs) -// // @ -// [eds.hidden_tests.tests]; - -// let editor_positions = -// // ({eds, _}: slide_state) => -// // [YourImpl] -// // @ List.mapi((i, _) => HiddenBugs(i), eds.hidden_bugs) -// // @ -// [HiddenTests]; - -// let positioned_editors = state => -// List.combine(editor_positions, editors(state)); - -// let idx_of_pos = (pos, p: p('code)) => -// switch (pos) { -// // | YourImpl => 4 -// | HiddenTests => 0 -// }; - -// let pos_of_idx = (idx: int) => -// switch (idx) { -// // | 4 => YourImpl -// | _ => -// if (idx < 0) { -// failwith("negative idx"); -// } else if (idx == 5) { -// HiddenTests; -// } else { -// failwith("element idx"); -// } -// }; - -// let switch_editor = (~pos, instructor_mode, ~exercise) => -// if (!instructor_mode) { -// switch (pos) { -// | HiddenTests -// // | HiddenBugs(_) => exercise -// | _ => {eds: exercise.eds, pos} -// }; -// } else { -// {eds: exercise.eds, pos}; -// }; - -// let zipper_of_code = code => { -// switch (Printer.zipper_of_string(code)) { -// | None => failwith("Transition failed.") -// | Some(zipper) => zipper -// }; -// }; - -// let transition: transitionary_spec => spec = -// ( -// { -// title, -// description, -// // your_impl, -// hidden_tests, -// }, -// ) => { -// // let your_impl = zipper_of_code(your_impl); -// // let hidden_bugs = -// // List.fold_left( -// // (acc, {impl, hint}) => { -// // let impl = zipper_of_code(impl); -// // acc @ [{impl, hint}]; -// // }, -// // [], -// // hidden_bugs, -// // ); -// let hidden_tests = { -// let {tests, hints} = hidden_tests; -// let tests = zipper_of_code(tests); -// {tests, hints}; -// }; -// { -// title, -// description, -// // your_impl, -// hidden_tests, -// }; -// }; - -// type eds = {eds : state}; -// let editor_of_serialization = zipper => Editor.init(zipper); -// let eds_of_spec: spec => eds = -// ( -// { -// title, -// description, -// // your_impl, -// hidden_tests, -// }, -// ) => { -// // let your_impl = editor_of_serialization(your_impl); -// let hidden_tests = { -// let {tests, hints} = hidden_tests; -// let tests = editor_of_serialization(tests); -// {tests, hints}; -// }; -// { -// title, -// description, -// hidden_tests, -// }; -// }; - -// let set_instructor_mode = ({eds, _} as state: slide_state, new_mode: bool) => { -// ...state, -// eds: { -// ...eds, -// // hidden_tests: _, -// }, -// }; - -// let visible_in = (pos, ~instructor_mode) => { -// switch (pos) { -// // | YourImpl => true -// | HiddenTests => instructor_mode -// }; -// }; - -// let state_of_spec = (spec, _: bool): state => { -// let eds = eds_of_spec(spec); -// // set_instructor_mode({pos: YourImpl, eds}, instructor_mode); -// }; diff --git a/src/haz3lweb/Store.re b/src/haz3lweb/Store.re index 119e37def5..2477174a52 100644 --- a/src/haz3lweb/Store.re +++ b/src/haz3lweb/Store.re @@ -187,7 +187,11 @@ module Documentation = { type persistent = PersistentData.documentation; let persist = ((name, editor: Editor.t)) => { - (name, PersistentZipper.persist(editor.state.zipper)); + ( + name, + PersistentZipper.persist(editor.state.zipper), + // dunno if this is correct + ); }; let unpersist = ((name, zipper)) => { diff --git a/src/haz3lweb/Update.re b/src/haz3lweb/Update.re index 3d609d149f..19b39e171d 100644 --- a/src/haz3lweb/Update.re +++ b/src/haz3lweb/Update.re @@ -263,6 +263,7 @@ let perform_action = (model: Model.t, a: Action.t): Result.t(Model.t) => ) { | Error(err) => Error(FailedToPerform(err)) | Ok(ed) => + // print_endline("editor.perform_action2: " ++ Action.show(a)); let model = {...model, editors: Editors.put_editor(ed, model.editors)}; /* Note: Not saving here as saving is costly to do each keystroke, we wait a second after the last edit action (see Main.re) */ @@ -302,15 +303,18 @@ let switch_doc_editor = | Documentation(name, slides) => let tutorial_states = List.map( - ((name, tutorial_state)) => { - let updated_state = - DocumentationEnv.switch_editor( - ~pos, - instructor_mode, - ~documentation=tutorial_state, - ); - (name, updated_state); - }, + ((hint, tutorial_state)) => + if (hint == name) { + let updated_state = + DocumentationEnv.switch_editor( + ~pos, + instructor_mode, + ~documentation=tutorial_state, + ); + (hint, updated_state); + } else { + (hint, tutorial_state); + }, slides, ); Some(Documentation(name, tutorial_states)); @@ -453,6 +457,8 @@ let rec apply = | PerformAction(a) when model.settings.core.assist && model.settings.core.statics => let model = UpdateAssistant.reset_buffer(model); + // print_endline("perform 1"); + // print_endline("Action type: " ++ Action.show(a)); switch (perform_action(model, a)) { | Ok(model) when Action.is_edit(a) => UpdateAssistant.apply( @@ -462,7 +468,9 @@ let rec apply = ~state, ~main=apply, ) - | x => x + | x => + print_endline("not ok"); + x; }; | PerformAction(a) => perform_action(model, a) | ReparseCurrentEditor => @@ -477,6 +485,7 @@ let rec apply = | Some(z) => //TODO: add correct action to history (Pick_up is wrong) let editor = Haz3lcore.Editor.new_state(Pick_up, z, ed); + print_endline("editor.reset_curr_editor"); let editors = Editors.put_editor(editor, model.editors); Ok({...model, editors}); }; @@ -494,6 +503,7 @@ let rec apply = | Some(z) => //HACK(andrew): below is not strictly a insert action... let ed = Haz3lcore.Editor.new_state(Insert(clipboard), z, ed); + print_endline("editor.paste"); let editors = Editors.put_editor(ed, model.editors); Ok({...model, editors}); }; @@ -502,14 +512,16 @@ let rec apply = switch (Haz3lcore.Editor.undo(ed)) { | None => Error(CantUndo) | Some(ed) => - Ok({...model, editors: Editors.put_editor(ed, model.editors)}) + print_endline("editor.undo"); + Ok({...model, editors: Editors.put_editor(ed, model.editors)}); }; | Redo => let ed = Editors.get_editor(model.editors); switch (Haz3lcore.Editor.redo(ed)) { | None => Error(CantRedo) | Some(ed) => - Ok({...model, editors: Editors.put_editor(ed, model.editors)}) + print_endline("editor.redo"); + Ok({...model, editors: Editors.put_editor(ed, model.editors)}); }; | MoveToNextHole(d) => perform_action(model, Move(Goal(Piece(Grout, d)))) diff --git a/src/haz3lweb/view/assistant/UpdateAssistant.re b/src/haz3lweb/view/assistant/UpdateAssistant.re index b30b22bdf4..1dc6e96e6d 100644 --- a/src/haz3lweb/view/assistant/UpdateAssistant.re +++ b/src/haz3lweb/view/assistant/UpdateAssistant.re @@ -30,7 +30,9 @@ let perform_action = (model: Model.t, a: Action.t): Result.t(Model.t) => { let ed_init = Editors.get_editor(model.editors); switch (Haz3lcore.Perform.go(~settings=model.settings.core, a, ed_init)) { | Error(err) => Error(FailedToPerform(err)) - | Ok(ed) => Ok({...model, editors: Editors.put_editor(ed, model.editors)}) + | Ok(ed) => + print_endline("editor.perform_action"); + Ok({...model, editors: Editors.put_editor(ed, model.editors)}); }; }; @@ -44,6 +46,7 @@ let reset_buffer = (model: Model.t) => { | Ok(z) => let ed = Editor.new_state(Destruct(Left), z, ed); //TODO(andrew): fix double action + print_endline("editor.reset_buffer"); {...model, editors: Editors.put_editor(ed, model.editors)}; } | _ => model @@ -69,6 +72,7 @@ let apply = | Some(z) => let ed = Editor.new_state(Pick_up, z, editor); //TODO: add correct action to history (Pick_up is wrong) + print_endline("editor.apply"); let editors = Editors.put_editor(ed, model.editors); Ok({...model, editors}); };