@@ -90,17 +90,27 @@ let asak_partition prof fun_name sol by_grade =
9090 (ans.Partition. bad_type @ bad_type, (i,ans.Partition. clusters) :: res)
9191 ) by_grade ([] ,[] )
9292
93+ let read_cmi_from_file cmi_str =
94+ (* Cmi_format.input_cmi only supports reading from a channel *)
95+ let magic_len = String. length Config. cmi_magic_number in
96+ if String. length cmi_str < magic_len ||
97+ String. sub cmi_str 0 magic_len <> Config. cmi_magic_number then
98+ Printf. ksprintf failwith " Bad cmi file" ;
99+ (* we ignore crc and flags *)
100+ (Marshal. from_string cmi_str magic_len : (string*Types.signature_item list ))
101+
93102let partition exo_name fun_name prof =
94103 Learnocaml_store.Exercise. get exo_name
95104 >> = fun exo ->
96105 let prelude = Learnocaml_exercise. (access File. prelude_ml exo) in
97106 let prepare = Learnocaml_exercise. (decipher File. prepare_ml exo) in
98107 let prelude = prelude ^ " \n " ^ prepare in
99- let solution = Learnocaml_exercise. (decipher File. solution exo) in
100- let solution = prelude ^ " \n " ^ solution in
108+ let (_,solution) =
109+ read_cmi_from_file (Learnocaml_exercise. (decipher File. solution_cmi exo)) in
110+ let sol_typ = Asak.Partition. find_value_type_from_signature fun_name solution in
101111 get_all_saves exo_name prelude
102112 > |= fun saves ->
103113 let not_graded,lst = partition_was_graded saves in
104114 let by_grade = partition_by_grade fun_name lst in
105- let bad_type,partition_by_grade = asak_partition prof fun_name solution by_grade in
115+ let bad_type,partition_by_grade = asak_partition prof fun_name sol_typ by_grade in
106116 {not_graded; bad_type; partition_by_grade}
0 commit comments