-
Notifications
You must be signed in to change notification settings - Fork 0
Constraint and Or Graders #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| functor OrGrader (structure Grader1 : GRADER | ||
HarrisonGrodin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| structure Grader2 : GRADER) :> GRADER = | ||
| struct | ||
| structure Rubric = | ||
| struct | ||
| val description = "ConstraintGrader: " ^ Constraint.Rubric.description | ||
| ^ " and " ^ Standard.Rubric.description | ||
HarrisonGrodin marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 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 | ||
T-Brick marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| in | ||
| case Rational.compare (score1, score2) of | ||
| LESS => Rubric.Result2 process2 | ||
| | _ => Rubric.Result1 process1 | ||
| end | ||
| end | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity - what's the benefit of having
structure Constraint : GRADERrather than, say,constraint : bool(orunit -> bool)?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure how you would do this with just
boolor aunit->bool?My idea was that it simply runs the Constraint grader and if it passes that then it would run the normal grader (rather than running the normal grader and having a TA manually grade the code). I'm unsure of any other clean way to use the existing infrastructure to run student code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, gotcha. I was thinking you could use
Result.evaluate, but I guess you'd have to rewrite some boilerplate (run a list of tests, etc.).