[OCaml] High Intensity Training Online
fix Restore feedback choices when revisiting
Use the saved feedback flow answers to mark the matching score radio as checked when the modal moves backward to a previous factor. This keeps the selected choice visible and editable without changing the existing flow state.
lib/web/pages.ml
@@ -1037,19 +1037,22 @@
1037
1037
1038
1038
(* Each subjective metric uses five unselected radio buttons styled as inline
1039
1039
buttons. The server shows one metric at a time. *)
1040
Removed:
let feedback_level_buttons field label =
1040
Added:
let feedback_level_buttons field label ~selected =
1041
1041
let choice code text =
1042
1042
tag "label"
1043
1043
[ class_ "feedback-choice" ]
1044
1044
[
1045
1045
void "input"
1046
Removed:
[
1047
Removed:
type_ "radio";
1048
Removed:
Dream_html.string_attr "name" "choice";
1049
Removed:
Dream_html.string_attr "value" "%s" code;
1050
Removed:
Dream_html.string_attr "id" "%s-%s" field code;
1051
Removed:
Dream_html.attr "data-hito-feedback-choice";
1052
Removed:
];
1046
Added:
([
1047
Added:
type_ "radio";
1048
Added:
Dream_html.string_attr "name" "choice";
1049
Added:
Dream_html.string_attr "value" "%s" code;
1050
Added:
Dream_html.string_attr "id" "%s-%s" field code;
1051
Added:
Dream_html.attr "data-hito-feedback-choice";
1052
Added:
]
1053
Added:
@
1054
Added:
if String.equal code selected then [ Dream_html.attr "checked" ]
1055
Added:
else []);
1053
1056
tag "span" [] [ txt "%s" text ];
1054
1057
]
1055
1058
in
@@ -1137,7 +1140,9 @@
1137
1140
fields
1138
1141
@ [
1139
1142
tag "h3" [] [ txt "%s" label ];
1140
Removed:
feedback_level_buttons field label;
1143
Added:
feedback_level_buttons field label
1144
Added:
~selected:
1145
Added:
(Option.value (List.assoc_opt field flow.answers) ~default:"");
1141
1146
feedback_progress (step + 1);
1142
1147
tag "div"
1143
1148
[ class_ "feedback-actions" ]