@@ -532,6 +532,7 @@ let sync_exercise token ?answer ?editor id on_sync =
532532 raise e)
533533 | None -> set_state_from_save_file save_file;
534534 handle_serverless () ;
535+ on_sync () ;
535536 Lwt. return save_file
536537
537538let string_of_seconds seconds =
@@ -948,15 +949,15 @@ module Editor_button (E : Editor_info) = struct
948949 ~id_menu
949950 ~items: [
950951 H. ul [
951- H. li ~a: [ H. a_onclick (fun _ ->
952+ H. li ~a: [ H. a_id (id_menu ^ " -graded " ); H. a_onclick (fun _ ->
952953 confirm ~title: [% i" Reload latest graded code" ]
953954 [H. txt [% i" This will replace your code with your last graded code. Are you sure?" ]]
954955 (fun () ->
955956 let graded = Learnocaml_local_storage. (retrieve (graded_solution id)) in
956957 Ace. set_contents E. ace graded; Ace. focus E. ace) ; true ) ]
957958 [ H. txt [% i" Reload latest graded code" ] ];
958959
959- H. li ~a: [ H. a_onclick (fun _ ->
960+ H. li ~a: [ H. a_id (id_menu ^ " -draft " ); H. a_onclick (fun _ ->
960961 confirm ~title: [% i" Reload latest saved draft" ]
961962 [H. txt [% i" This will replace your code with your last saved draft. Are you sure?" ]]
962963 (fun () ->
@@ -979,8 +980,23 @@ module Editor_button (E : Editor_info) = struct
979980 though there is already this code in learnocaml_exercise_main.ml:
980981 {| if has_server then EB.reload ... else EB.cleanup ... |}. *)
981982 Lwt. return_unit
982- | Some tok -> fetch_draft_solution tok () > |= fun _save -> ()
983-
983+ | Some tok ->
984+ let found f =
985+ match f () with
986+ | _val -> true
987+ | exception Not_found -> false
988+ in
989+ fetch_draft_solution tok () > |= fun _save ->
990+ let menu_draft = find_component (id_menu ^ " -draft" ) in
991+ Manip.SetCss. display menu_draft
992+ (if found (fun () ->
993+ Learnocaml_local_storage. (retrieve (exercise_state id)).Answer. solution)
994+ then " " else " none" );
995+ let menu_graded = find_component (id_menu ^ " -graded" ) in
996+ Manip.SetCss. display menu_graded
997+ (if found (fun () ->
998+ Learnocaml_local_storage. (retrieve (graded_solution id)))
999+ then " " else " none" )
9841000 let download id =
9851001 editor_button
9861002 ~icon: " download" [% i" Download" ] @@ fun () ->
0 commit comments