@@ -90,17 +90,27 @@ let asak_partition prof fun_name sol by_grade =
90
90
(ans.Partition. bad_type @ bad_type, (i,ans.Partition. clusters) :: res)
91
91
) by_grade ([] ,[] )
92
92
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
+
93
102
let partition exo_name fun_name prof =
94
103
Learnocaml_store.Exercise. get exo_name
95
104
>> = fun exo ->
96
105
let prelude = Learnocaml_exercise. (access File. prelude_ml exo) in
97
106
let prepare = Learnocaml_exercise. (decipher File. prepare_ml exo) in
98
107
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
101
111
get_all_saves exo_name prelude
102
112
> |= fun saves ->
103
113
let not_graded,lst = partition_was_graded saves in
104
114
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
106
116
{not_graded; bad_type; partition_by_grade}
0 commit comments