-
Notifications
You must be signed in to change notification settings - Fork 0
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
Constraint and Or Graders #2
Open
T-Brick
wants to merge
3
commits into
master
Choose a base branch
from
constraint-or-functors
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
functor ConstraintGrader (structure Constraint : GRADER | ||
structure Standard : GRADER | ||
val threshold : Rational.t | ||
val message : string) :> GRADER = | ||
struct | ||
structure Rubric = | ||
struct | ||
val description = 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
functor OrGrader (val description : string | ||
structure Grader1 : GRADER | ||
structure Grader2 : GRADER) :> GRADER = | ||
struct | ||
structure Rubric = | ||
struct | ||
val description = 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 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 | ||
| _ => Rubric.Result1 process1 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 : GRADER
rather 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
bool
or 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.).