From a837b8ad5236c1063937991f322e0edf4caf8622 Mon Sep 17 00:00:00 2001 From: TBrick Date: Tue, 26 Oct 2021 12:14:14 -0400 Subject: [PATCH 1/3] Constraint and Or Graders --- src/ConstraintGrader.fun | 29 +++++++++++++++++++++++++++++ src/OrGrader.fun | 30 ++++++++++++++++++++++++++++++ src/sources.cm | 6 ++++++ 3 files changed, 65 insertions(+) create mode 100644 src/ConstraintGrader.fun create mode 100644 src/OrGrader.fun diff --git a/src/ConstraintGrader.fun b/src/ConstraintGrader.fun new file mode 100644 index 0000000..df32e2a --- /dev/null +++ b/src/ConstraintGrader.fun @@ -0,0 +1,29 @@ +functor ConstraintGrader (structure Constraint : GRADER + structure Standard : GRADER + val threshold : Rational.t + val message : string) :> GRADER = + struct + structure Rubric = + struct + val description = "ConstraintGrader: " ^ Constraint.Rubric.description + ^ " and " ^ Standard.Rubric.description + + datatype t = Violation + | Result of Standard.Rubric.t + + val toString = fn Violation => message + | Result r => Standard.Rubric.toString r + + val score = fn Violation => Rational.zero + | Result r => Standard.Rubric.score r + end + + val process = fn () => + let + val score = Constraint.Rubric.score (Constraint.process ()) + in + case Rational.compare (threshold, score) of + GREATER => Rubric.Violation + | _ => Rubric.Result (Standard.process ()) + end + end diff --git a/src/OrGrader.fun b/src/OrGrader.fun new file mode 100644 index 0000000..3197337 --- /dev/null +++ b/src/OrGrader.fun @@ -0,0 +1,30 @@ +functor OrGrader (structure Grader1 : GRADER + structure Grader2 : GRADER) :> GRADER = + struct + structure Rubric = + struct + val description = "ConstraintGrader: " ^ Constraint.Rubric.description + ^ " and " ^ Standard.Rubric.description + + datatype t = Result1 of Grader1.Rubric.t + | Result2 of Grader2.Rubric.t + + val toString = fn Result1 r => Grader1.Rubric.toString r + | Result2 r => Grader2.Rubric.toString r + + val score = fn Result1 r => Grader1.Rubric.score r + | Result2 r => Grader2.Rubric.score r + end + + val process = fn () => + let + val process1 = Grader1.process () + val score1 = Grader1.Rubric.score process1 + val process2 = Grader2.process () + val score2 = Grader2.Rubric.score process2 + in + case Rational.compare (score1, score2) of + LESS => Rubric.Result2 process2 + | _ => Rubric.Result1 process1 + end + end diff --git a/src/sources.cm b/src/sources.cm index 8d2c025..cfd4060 100644 --- a/src/sources.cm +++ b/src/sources.cm @@ -19,6 +19,9 @@ Library functor EquivGraderBucketList functor EquivGraderList + functor ConstraintGrader + functor OrGrader + functor Preamble structure FormatUtil @@ -49,6 +52,9 @@ is EquivGraderBucket.fun EquivGrader.fun + ConstraintGrader.fun + OrGrader.fun + Preamble.fun FormatUtil.sml From 6d3c78f63be4811a5d6754b6e21b124a9ccb866f Mon Sep 17 00:00:00 2001 From: Thea Brick Date: Tue, 26 Oct 2021 18:29:16 -0400 Subject: [PATCH 2/3] renaming OrGrader variables Co-authored-by: Harrison Grodin --- src/OrGrader.fun | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/OrGrader.fun b/src/OrGrader.fun index 3197337..c02d7c8 100644 --- a/src/OrGrader.fun +++ b/src/OrGrader.fun @@ -18,10 +18,10 @@ functor OrGrader (structure Grader1 : GRADER val process = fn () => let - val process1 = Grader1.process () - val score1 = Grader1.Rubric.score process1 - val process2 = Grader2.process () - val score2 = Grader2.Rubric.score process2 + val rubric1 = Grader1.process () + val score1 = Grader1.Rubric.score rubric1 + val rubric2 = Grader2.process () + val score2 = Grader2.Rubric.score rubric2 in case Rational.compare (score1, score2) of LESS => Rubric.Result2 process2 From 2f8ffa558b1e099d75cfc8dc02223479cd7d1503 Mon Sep 17 00:00:00 2001 From: TBrick Date: Tue, 26 Oct 2021 18:44:14 -0400 Subject: [PATCH 3/3] description changes --- src/ConstraintGrader.fun | 3 +-- src/OrGrader.fun | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ConstraintGrader.fun b/src/ConstraintGrader.fun index df32e2a..b4e2daa 100644 --- a/src/ConstraintGrader.fun +++ b/src/ConstraintGrader.fun @@ -5,8 +5,7 @@ functor ConstraintGrader (structure Constraint : GRADER struct structure Rubric = struct - val description = "ConstraintGrader: " ^ Constraint.Rubric.description - ^ " and " ^ Standard.Rubric.description + val description = Standard.Rubric.description datatype t = Violation | Result of Standard.Rubric.t diff --git a/src/OrGrader.fun b/src/OrGrader.fun index c02d7c8..c8e6687 100644 --- a/src/OrGrader.fun +++ b/src/OrGrader.fun @@ -1,10 +1,10 @@ -functor OrGrader (structure Grader1 : GRADER +functor OrGrader (val description : string + structure Grader1 : GRADER structure Grader2 : GRADER) :> GRADER = struct structure Rubric = struct - val description = "ConstraintGrader: " ^ Constraint.Rubric.description - ^ " and " ^ Standard.Rubric.description + val description = description datatype t = Result1 of Grader1.Rubric.t | Result2 of Grader2.Rubric.t