Closed ChristopherChudzicki closed 6 years ago
@jolyonb Cool, I'll fix those typos!
One of the things on your checklist for #65 was validation. Two comments about this:
I suspect the most common configuration error would be something like:
grader = listGrader(
answers=['1', 'sibling_1 + 1'],
subgraders=FormulaGrader()
) # instantiated OK
grader(None, ['1', '2']) # throws InvalidInput: sibling_1 undefined
The issue is that the author forgot to declare the ListGrader as being ordered. FormulaGrader validates itself without any knowledge of sibling variables or the ListGrader's answers, so the error doesn't arise until check time.
input_k
variables without declaring dependent_inputs
). You avoided number 2 by checking for cyclic dependencies in dependent_inputs
.Authors can set up ridiculous things like
grader = ListGrader(
answers=['sibling_1 + 1'],
subgraders=FormulaGrader(),
ordered=True
)
Nothing would ever be marked correct, since the answer cannot be 1 bigger than itself.
Mostly: I think avoiding the extra key (dependent_inputs
) and allowing reuse of the subgrader is worth the trouble of these less-than-helpful error messages.
I'm also not super worried about it for what I suspect will be an uncommonly used feature.
A hacky but fast resolution to the first issue would be to raise a special error if the undefined variable contains 'siblings'
. Students might see this, but why would they be entering 'sibling_k' as a variable name....
Anyway, I think the PR is fine, but I wanted you to be aware of those issues.
@jolyonb Typos fixed. I need to figure out a good way to spellcheck my code in Atom... sorry about that :)
Ah, I responded to your comment in #65...
This PR addresses #46 by passing a
siblings
keyword argument to thecheck
function of subgraders in aListGrader
. This parameter is only available whenordered=true
.Currently only FormulaGrader makes any use of
siblings
in its check function. Example:Some notes:
input_k
tosibling_k
to stress that the relationship is relative; particularly relevant when used with grouping / nested ListGraders.