parserAssignment chokes when previous answer is undefined on the domain#609
Conversation
That's actually not true. The super class (which is Lines 1653 to 1661 in 37637e2 and it returns The current is issued. With the changes in this PR, however, the answer will be marked incorrect silently (no helpful message). There are also other differences. The current So this PR changes the functionality of the Assignment object from its current form in a way that I would not support. It's true that the Assignment sub typeMatch {
my $self = shift; my $other = shift; my $ans = shift;
return 0 unless $self->type eq $other->type;
my $typeMatch = $self->getTypicalValue($self)->{data}[1];
$other = $self->getTypicalValue($other,1)->{data}[1];
return 1 unless defined($other); # can't really tell, so don't report type mismatch
return 1 if $typeMatch->classMatch('String') && Value::isFormula($ans->{typeMatch}); # avoid infinite loop
$typeMatch->typeMatch($other,$ans);
}though I haven't actually tried it out. |
dpvc
left a comment
There was a problem hiding this comment.
See my comments above for suggested changes.
|
Following @dpvc's suggestion, the parserAssignment override of Instead of using the line that is commented with 'avoid infinite loops', we instead check for Strings during object creation and throw an error. |
|
There seems to be a problem created by this pull request. I have problems that use parserAssignment.pl and PGML's parsing to display equations. For example, one problem has If I revert this pull request, the error does not occur. |
|
Here is a minimal example for which this issue occurs: DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"parserAssignment.pl",
"PGcourse.pl"
);
TEXT(beginproblem());
parser::Assignment->Allow;
BEGIN_PGML
>>[::2/5 x + 1/7 = 1/3 x - 1/11::]<<
END_PGML
ENDDOCUMENT(); |
…in PGML via `[:: ::]` now fail to parse.
…in PGML via `[:: ::]` now fail to parse.
…in PGML via `[:: ::]` now fail to parse.
…in PGML via `[:: ::]` now fail to parse.
Fix an issue with parserAssignment.pl introduced in #609
…in PGML via `[:: ::]` now fail to parse.
Fix an issue with parserAssignment.pl introduced in #609 - develop
If a problem sets the answer to be a formula with an assigment,
(something like `Formula("x = 5")` then all answers are counted
incorrect and a warning is displayed that the evaluated answer is not an
answer hash. This worked prior to openwebwork#609. The cause of this was the
removal of a line that should not have been removed that converts the
other answer being compared to to a Formula if it is not already.
Note that the original issue that was attempted to be fixed by openwebwork#609
still is fixed with this change.
This fixes issue openwebwork#644 that I just submitted about this.
If a problem sets the answer to be a formula with an assigment,
(something like `Formula("x = 5")` then all answers are counted
incorrect and a warning is displayed that the evaluated answer is not an
answer hash. This worked prior to openwebwork#609. The cause of this was the
removal of a line that should not have been removed that converts the
other answer being compared to to a Formula if it is not already.
Note that the original issue that was attempted to be fixed by openwebwork#609
still is fixed with this change.
This fixes issue openwebwork#644 that I just submitted about this.
Fix another regression caused by #609 (for develop).
Fix another regression caused by #609.
See #607 for details (incl. a MWE)
Submitting an answer whose domain is incompatible with the limits for the available variables causes an appropriate error message:
The domain of your function doesn't match that of the correct answerHowever, when followed up with an answer whose domain is compatible, you will get an error:
The evaluated answer is not an answer hash : ||.(This happens only based on domain, and is independent of whether or not the submitted answer is correct.)The failure to complete the processing of the answer hash is due to the cmp_postfilter which compares the current and previous answers.
Note: So long as the submitted answer generates a feedback message, the comparison between the current and previous submissions is skipped.
Specifically, the
typeMatchmethod call (which ensures that the current and previous responses are comparable objects before actually comparing them) dies because the previous submission fails to generate valid points.The solution is to simply remove
typeMatchfromparser::Assignment::Formula. It's not doing anything more than what (the superclass)Value::Formulais already doing. AndValue::Formula::typeMatchis structured to handle situations where the generation of valid points fails. (Interesting to note: this looks like a bug that was fixed not long after parserAssignment was introduced -- but it was fixed for Value::Formula and the changes never made their way into parserAssignment... see 2e1ed6b)TL;DR -- parser::Assignment::Formula doesn't need to override
typeMatchpostfilter: 🍻 to @dlglin for finding a teenaged bug!