Skip to content

Commit 043f813

Browse files
nobrakalAltGr
authored andcommitted
fix(teacher_tab): use newer asak compatible with precompilation
asak 0.4 is now released on opam
1 parent 5f7347a commit 043f813

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

learn-ocaml.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ homepage: "https://github.com/ocaml-sf/learn-ocaml"
1818
bug-reports: "https://github.com/ocaml-sf/learn-ocaml/issues"
1919
dev-repo: "git+https://github.com/ocaml-sf/learn-ocaml"
2020
depends: [
21-
"asak"
21+
"asak" { >= "0.4"}
2222
"base64"
2323
"base" {>= "v0.9.4"}
2424
"cmdliner" {>= "1.1.0"}

src/utils/learnocaml_partition_create.ml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
93102
let 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

Comments
 (0)