1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
(* Copyright (C) 2017 Ryan Kavanagh <rkavanagh@cs.cmu.edu> *)
(* Distributed under the ISC license, see COPYING for details. *)
(************************************************************)
(* Make sure you put the tutch sources under support/tutch. *)
(************************************************************)
functor ChecksHelper (structure H : HELPER) : CHECKS where type checks = H.checks =
struct
datatype checks = datatype H.checks
(*****************************************************)
(********** CONFIGURE ME HERE *******)
(*****************************************************)
val tutchPath = "./support/tutch/bin/tutch"
val thePDF = "hw3.pdf"
val requiredFiles = [ thePDF
, "hw3_6a.tut"
, "hw3_6b.tut"
, "hw3_6c.tut" ]
(* Compile tutch *)
(* Surely one should be able to call CM.make or something... *)
fun compileTutch () =
case H.runCmd "make -C ./support/tutch > /dev/null"
of 0 => ()
| _ => (H.abortWithMessage o H.stringsInBox)
[ "Unable to compile tutch."
, "Contact course staff." ]
(* Runs tutch on requirements file "req" and tutch file "tut". *)
(* Awards maxScore if tutch succeeds, 0 otherwise. *)
fun runTutch req tut maxScore =
case H.runCmd (tutchPath ^ " -r " ^ req ^ " " ^ (H.joinHandinPath tut))
of 0 => maxScore
| _ => let val _ = H.printInBox [ "Tutch thinks something went wrong!"
, "Please fix and try again." ]
in 0.0 end
(* We first make sure all of the required files exist. *)
(* Then we check that the PDF is a valid PDF. *)
(* Finally, we grade the tutch problems 6a--6c at 2 points each. *)
val checks = [ H.Check ("all files present", fn _ => H.checkFilesExist requiredFiles)
, H.Check (thePDF, fn _ => H.checkPDF thePDF)
, H.Check ("tutch compile", fn _ => compileTutch ()) ]
@ (List.map (fn (n,s) =>
H.Problem (n, fn _ => runTutch ("./support/hw3_" ^ n ^ ".req")
("hw3_" ^ n ^ ".tut")
s))
[("6a", 2.0), ("6b", 2.0), ("6c", 2.0)])
(* Empty scoreboard *)
fun scoreboard _ = NONE
(*****************************************************)
(********** END CONFIGURATION *******)
(*****************************************************)
end
|