Skip to content

Commit

Permalink
Fixed a bug where points were not being displayed correctly and anoth…
Browse files Browse the repository at this point in the history
…er were information between editors was not being shared correctly
  • Loading branch information
facundoy committed Dec 8, 2024
1 parent cdf0b59 commit 616033f
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 45 deletions.
39 changes: 9 additions & 30 deletions src/haz3lschool/Tutorial.re
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down Expand Up @@ -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
};

Expand All @@ -147,7 +145,6 @@ module D = (TutorialEnv: TutorialEnv) => {
your_impl: editor,
},
}
| YourTestsValidation
| HiddenTests => {
...state,
eds: {
Expand All @@ -165,16 +162,15 @@ 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));

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) =>
Expand Down Expand Up @@ -264,7 +260,6 @@ module D = (TutorialEnv: TutorialEnv) => {
let visible_in = (pos, ~instructor_mode) => {
switch (pos) {
| YourImpl => true
| YourTestsValidation => true
| HiddenTests => instructor_mode
};
};
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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),
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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
};

Expand All @@ -515,7 +503,6 @@ module D = (TutorialEnv: TutorialEnv) => {
)
: stitched(DynamicsItem.t) => {
let {
test_validation,
user_impl,
// user_tests,
// prelude,
Expand All @@ -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)};
Expand All @@ -549,7 +531,6 @@ module D = (TutorialEnv: TutorialEnv) => {
result: result_of(hidden_tests_key),
};
{
test_validation,
user_impl,
// user_tests,
instructor,
Expand All @@ -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),
Expand All @@ -581,7 +561,6 @@ module D = (TutorialEnv: TutorialEnv) => {
};
} else {
{
test_validation: DynamicsItem.empty,
user_impl: DynamicsItem.empty,
// user_tests: DynamicsItem.empty,
instructor: DynamicsItem.empty,
Expand Down
5 changes: 2 additions & 3 deletions src/haz3lschool/TutorialGrading.re
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
};

Expand Down Expand Up @@ -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;
Expand Down
23 changes: 21 additions & 2 deletions src/haz3lweb/view/Page.re
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
12 changes: 2 additions & 10 deletions src/haz3lweb/view/TutorialMode.re
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -132,7 +124,7 @@ let view =
TutorialGrading.ImplGradingReport.view(
~inject,
~report=grading_report.impl_grading_report,
~max_points=4,
~max_points=1,
),
);

Expand Down

0 comments on commit 616033f

Please sign in to comment.