From 616033fb5459e3ac5f26783a6cc1c96fae46d625 Mon Sep 17 00:00:00 2001 From: facundoy Date: Sat, 7 Dec 2024 21:25:07 -0500 Subject: [PATCH] Fixed a bug where points were not being displayed correctly and another were information between editors was not being shared correctly --- src/haz3lschool/Tutorial.re | 39 +++++++----------------------- src/haz3lschool/TutorialGrading.re | 5 ++-- src/haz3lweb/view/Page.re | 23 ++++++++++++++++-- src/haz3lweb/view/TutorialMode.re | 12 ++------- 4 files changed, 34 insertions(+), 45 deletions(-) diff --git a/src/haz3lschool/Tutorial.re b/src/haz3lschool/Tutorial.re index 8292af2764..4656e4ebc5 100644 --- a/src/haz3lschool/Tutorial.re +++ b/src/haz3lschool/Tutorial.re @@ -90,7 +90,6 @@ module D = (TutorialEnv: TutorialEnv) => { [@deriving (show({with_path: false}), sexp, yojson)] type pos = | YourImpl - | YourTestsValidation | HiddenTests; [@deriving (show({with_path: false}), sexp, yojson)] @@ -134,7 +133,6 @@ module D = (TutorialEnv: TutorialEnv) => { ({pos, eds, _}) => switch (pos) { | YourImpl => eds.your_impl - | YourTestsValidation => eds.hidden_tests.tests | HiddenTests => eds.hidden_tests.tests }; @@ -147,7 +145,6 @@ module D = (TutorialEnv: TutorialEnv) => { your_impl: editor, }, } - | YourTestsValidation | HiddenTests => { ...state, eds: { @@ -165,7 +162,7 @@ module D = (TutorialEnv: TutorialEnv) => { eds.hidden_tests.tests, ]; - let editor_positions = [YourImpl, HiddenTests, YourTestsValidation]; + let editor_positions = [YourImpl, HiddenTests]; let positioned_editors = state => List.combine(editor_positions, editors(state)); @@ -173,8 +170,7 @@ module D = (TutorialEnv: TutorialEnv) => { let idx_of_pos = (pos, p: p('code)) => switch (pos) { | YourImpl => 0 - | YourTestsValidation => 1 - | HiddenTests => 1 + List.length(p.hidden_tests.tests) + | HiddenTests => 0 + List.length(p.hidden_tests.tests) }; let pos_of_idx = (p: p('code), idx: int) => @@ -264,7 +260,6 @@ module D = (TutorialEnv: TutorialEnv) => { let visible_in = (pos, ~instructor_mode) => { switch (pos) { | YourImpl => true - | YourTestsValidation => true | HiddenTests => instructor_mode }; }; @@ -346,7 +341,6 @@ module D = (TutorialEnv: TutorialEnv) => { // }; type stitched('a) = { - test_validation: 'a, // prelude + correct_impl + your_tests user_impl: 'a, // prelude + your_impl instructor: 'a, // prelude + correct_impl + hidden_tests.tests // TODO only needs to run in instructor mode hidden_tests: 'a, @@ -389,22 +383,20 @@ module D = (TutorialEnv: TutorialEnv) => { EditorUtil.append_exp(term_of(ed1)); let stitch_term = ({eds, _}: state): stitched(UExp.t) => { - let instructor = eds.hidden_tests.tests |> term_of; + let instructor = + EditorUtil.append_exp( + term_of(eds.your_impl), + term_of(eds.hidden_tests.tests), + ); let user_impl_term = { eds.your_impl |> term_of |> wrap_filter(FilterAction.Step); }; - let test_validation_term = eds.hidden_tests.tests |> term_of; // No combining of your_impl_term with hidden_tests let hidden_tests_term = EditorUtil.append_exp(user_impl_term, term_of(eds.hidden_tests.tests)); - { - user_impl: user_impl_term, - instructor, - test_validation: test_validation_term, - hidden_tests: hidden_tests_term, - }; + {user_impl: user_impl_term, instructor, hidden_tests: hidden_tests_term}; }; let stitch_term = Core.Memo.general(stitch_term); @@ -425,7 +417,6 @@ module D = (TutorialEnv: TutorialEnv) => { }; let instructor = mk(t.instructor); { - test_validation: mk(t.test_validation), user_impl: mk(t.user_impl), instructor, hidden_tests: mk(t.hidden_tests), @@ -458,20 +449,18 @@ module D = (TutorialEnv: TutorialEnv) => { let key_for_statics = (state: state): string => switch (state.pos) { | YourImpl => user_impl_key - | YourTestsValidation => test_validation_key | HiddenTests => hidden_tests_key }; let spliced_elabs = (settings: CoreSettings.t, state: state) : list((ModelResults.key, Elaborator.Elaboration.t)) => { - let {test_validation, user_impl, instructor, hidden_tests} = + let {user_impl, instructor, hidden_tests} = stitch_static(settings, stitch_term(state)); let elab = (s: Editor.CachedStatics.t): Elaborator.Elaboration.t => { d: Interface.elaborate(~settings, s.info_map, s.term), }; [ - (test_validation_key, elab(test_validation)), (user_impl_key, elab(user_impl)), (instructor_key, elab(instructor)), (hidden_tests_key, elab(hidden_tests)), @@ -500,7 +489,6 @@ module D = (TutorialEnv: TutorialEnv) => { (state: state, s: stitched(DynamicsItem.t)): Editor.CachedStatics.t => switch (state.pos) { | YourImpl => s.user_impl.statics - | YourTestsValidation => s.test_validation.statics | HiddenTests => s.hidden_tests.statics }; @@ -515,7 +503,6 @@ module D = (TutorialEnv: TutorialEnv) => { ) : stitched(DynamicsItem.t) => { let { - test_validation, user_impl, // user_tests, // prelude, @@ -531,11 +518,6 @@ module D = (TutorialEnv: TutorialEnv) => { ModelResults.lookup(results, key) |> Option.value(~default=ModelResult.NoElab) }; - let test_validation = - DynamicsItem.{ - statics: test_validation, - result: result_of(test_validation_key), - }; let user_impl = DynamicsItem.{statics: user_impl, result: result_of(user_impl_key)}; @@ -549,7 +531,6 @@ module D = (TutorialEnv: TutorialEnv) => { result: result_of(hidden_tests_key), }; { - test_validation, user_impl, // user_tests, instructor, @@ -571,7 +552,6 @@ module D = (TutorialEnv: TutorialEnv) => { } else if (settings.statics) { let t = stitch_static(settings, stitch_term(state)); { - test_validation: DynamicsItem.statics_only(t.test_validation), user_impl: DynamicsItem.statics_only(t.user_impl), // user_tests: DynamicsItem.statics_only(t.user_tests), instructor: DynamicsItem.statics_only(t.instructor), @@ -581,7 +561,6 @@ module D = (TutorialEnv: TutorialEnv) => { }; } else { { - test_validation: DynamicsItem.empty, user_impl: DynamicsItem.empty, // user_tests: DynamicsItem.empty, instructor: DynamicsItem.empty, diff --git a/src/haz3lschool/TutorialGrading.re b/src/haz3lschool/TutorialGrading.re index bcf3368660..7496be673c 100644 --- a/src/haz3lschool/TutorialGrading.re +++ b/src/haz3lschool/TutorialGrading.re @@ -59,7 +59,7 @@ module D = (TutorialEnv: Tutorial.TutorialEnv) => { if (total == 0.0) { 0.0; // Avoid division by zero } else { - 100.0 *. (passed /. total); // Return percentage as a float + passed /. total; // Return percentage as a float }; }; @@ -131,11 +131,10 @@ module D = (TutorialEnv: Tutorial.TutorialEnv) => { // MutationTestingReport.percentage(mutation_testing_report), // point_distribution.mutation_testing, // ); - let max_impl_grading = 100; let (ig_points, ig_max) = score_of_percent( ImplGradingReport.percentage(impl_grading_report), - max_impl_grading, + 1, ); let total_points = ig_points; let max_points = ig_max; diff --git a/src/haz3lweb/view/Page.re b/src/haz3lweb/view/Page.re index d2585076fd..a458732ec9 100644 --- a/src/haz3lweb/view/Page.re +++ b/src/haz3lweb/view/Page.re @@ -124,17 +124,36 @@ let main_view = switch (matching_slide) { | None => [] | Some((_, tutorial_state)) => + let stitched_dynamics = + Tutorial.stitch_dynamic( + settings.core, + tutorial_state, + settings.core.dynamics ? Some(results) : None, + ); + let statics = + Tutorial.statics_of_stiched_dynamics( + tutorial_state, + stitched_dynamics, + ); + let cursor_info = + Indicated.ci_of(editor.state.zipper, statics.info_map); + let highlights = + ExplainThis.get_color_map( + ~settings, + ~explainThisModel, + cursor_info, + ); TutorialMode.view( ~inject, ~ui_state, ~settings, ~highlights, - ~results, + ~stitched_dynamics, ~tutorial=tutorial_state, // ~results, // ~highlights, // ~editor, - ) + ); }; (info @ result, cursor_info); diff --git a/src/haz3lweb/view/TutorialMode.re b/src/haz3lweb/view/TutorialMode.re index 587a027f32..7203ffb68d 100644 --- a/src/haz3lweb/view/TutorialMode.re +++ b/src/haz3lweb/view/TutorialMode.re @@ -24,22 +24,14 @@ let view = ~ui_state: Model.ui_state, ~settings: Settings.t, ~tutorial, - ~results, - // ~stitched_dynamics, + ~stitched_dynamics, ~highlights, ) => { // editor : Editor.t, // let result = ModelResults.lookup(results, result_key); let Tutorial.{eds, pos} = tutorial; - let stitched_dynamics = - Tutorial.stitch_dynamic( - settings.core, - tutorial, - settings.core.dynamics ? Some(results) : None, - ); let { - test_validation, user_impl, // user_tests, // prelude, @@ -132,7 +124,7 @@ let view = TutorialGrading.ImplGradingReport.view( ~inject, ~report=grading_report.impl_grading_report, - ~max_points=4, + ~max_points=1, ), );