-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
answerHints - Fix for the first issue reported in #1170 #1171
base: develop
Are you sure you want to change the base?
Conversation
checkCorrect was set before triggering a hint when "wrong" is not a subroutine.
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.
This looks good. I didn't notice that so much was removed in #974 on this. It doesn't seem that this should have been removed.
I would like to look into this further, but haven't had the chance. Please wait before merging. Thanks! |
I think the AnswerHints code is correct as it stands, and I would object to this change. My reasoning for removing the conditions in #974 was that if an answer is given explicitly, it should be checked, regardless of whether it or the student answer is correct. If it is explicitly in the As you have noticed, the checker function as written will never work with In your case, if the student answer is correct, then every answer in the return $correct == $student unless $correct == $ans6c; but your test for the answer filter name is probably better. Most Note, however, that this still is not enough to make your Also note that the I also noticed in my testing that entering the correct answer One either needs to adjust the zero-level tolerance, or to do the test differently. Rather than testing if ANS( $ans6c->cmp(
bypass_equivalence_test => 1,
checker => sub {
my ( $correct, $student, $ans ) = @_;
return $correct == $student if $ans->{_filter_name} eq 'Answer Hints Post Filter';
return 0 if $student->type eq 'String';
# Try to see if it satisfies the ODE
$Y0 = Formula( $student );
$Y1 = $Y0->D('x');
$Y2 = $Y1->D('x');
$toCheck = $Y2 + 3 * $Y1 - 4 * $Y0 ;
return 1 if Formula('-2 exp(-5x)') == $toCheck;
$ans->{ans_message} = "That is not a solution of the non-homogeneous equation" unless $ans->{isPreview};
return 0;
}
)->withPostFilter(AnswerHints(
Compute("DNE") => 'There is a solution.',
Formula('sin(x)') => [ 'Junk message - sin(x).', replaceMessage => 1 ],
Formula('exp(x)') => [ 'Junk message - exp(x).', replaceMessage => 1 ],
)) I agree with @somiaj in his comment that if you are using a There is another approach, however, that avoids the need for loadMacros('PGstandard.pl', 'MathObjects.pl', 'answerHints.pl');
Context("Numeric");
$ans6c = Compute('(-1/3)*exp(-5x)'); # Needs grader as solution of non-homogeneous ODE
Context()->texStrings;
BEGIN_TEXT
Find a solution to:
\[ y'' + 3 y' - 4 y = -2 e^{-5x} \]
\{ $ans6c->ans_rule(10) \}
END_TEXT
Context()->normalStrings;
ANS( $ans6c->cmp(
bypass_equivalence_test => 1,
checker => sub {
my ( $correct, $student, $ans ) = @_;
return $correct == $student if $ans->{_filter_name} eq 'Answer Hints Post Filter';
return 0 if $student->type eq 'String';
# Try to see if it satisfies the ODE
$Y0 = Formula( $student );
$Y1 = $Y0->D('x');
$Y2 = $Y1->D('x');
$toCheck = $Y2 + 3 * $Y1 - 4 * $Y0 ;
return 1 if Formula('-2 exp(-5x)') == $toCheck;
$ans->{non_solution} = 1;
return 0;
}
)->withPostFilter(AnswerHints(
Compute("DNE") => 'There is a solution.',
Formula('sin(x)') => 'Junk message - sin(x).',
Formula('exp(x)') => 'Junk message - exp(x).',
))->withPostFilter(sub {
my $ans = shift;
$ans->{ans_message} = "That is not a solution of the non-homogeneous equation"
if $ans->{non_solution} && !$ans->{isPreview} && !$ans->{ans_message};
return $ans;
})); So there are several ways to address this issue within the If you all do decide to make this change, I'd recommend moving the test to before the loop over the wrong list, since it gets used by both conditions in the code below. It would also be good to move the answer message check to above the loop as well, since it is in both conditions, too. I agree that the documentation for |
@dpvc - Thanks for all the feedback, especially the advice about avoiding the comparisons to 0. I'll need to run over quite a number of questions and make the suggested improvements, also ODE questions without any use of answer hints. BTW the messages about sin(x) and exp(x) were just samples to show that under the circumstances the first message would be triggered. In one of the questions where I ran into trouble on 2.19 I was getting messages which were intended to be triggered for more complicated "wrong answers" which were expected to be checked by answerHints only if the original answer was not correct. I'm not sure if they were actually being triggered when needed in the past, but the first one in the list was certainly were getting triggered incorrectly for correct answers on 2.19. For now, I'm leaving my server running the "patch" as it at least prevents correct answers from getting "hints" incorrectly until I can work on revising all the potentially effected problems. I'm still not that happy with the change to PG "breaking" problems that worked "well enough" before, but since it is certainly an edge case, and a non-standard use of answerHints - I guess that it makes sense to make answerHints work as you recommend and to close this PR and instead remark on the matter in the release notes and work to improve the documentation and sample problems. I'm not closing the PR for now, so it can be a reminder to work on the documentation matters. |
The old problems were broken, as the answer hints were never working properly. You just weren't noticing it, but they were never doing what they were supposed to. That may be "well enough", but I would think that being able to identify and fix them is more important than giving the impression that they are working and that there are functional hints. I explained above that if the In your case, if the student answer was correct, no answer-hint checks were made, and so there would be no answer hints, but if the student answer was incorrect, then no answer-hint answer would match, so again, not answer hints would be made. Also, in this case, the checker produced an answer message itself, which also blocked checking of answers. The only exception was when the student answer was The upshot is that the answer hints for that problem would never be produced under any circumstances, as far as I can see, with your change here. With the current version of While I understand the desire not to change the behavior of working problems, and agree with trying to maintain backward compatibility whenever possible, making other people have to add |
PS, sorry if that came off as harsh, but I was just trying to be clear. |
Thanks - it was pretty clear before. It was a petulant of me to complain about the change breaking "my" problems when they certainly were not really correctly coded. I was aware that the hints in these problems did not work properly (there were comments about that in several of them) but did not know why at the time. I had not understood that answerHints used the custom checkers when "checking" against the list of "answers" to trigger messages, and had not considered that this would be the case. Bottom line - the "rush" to move from my old system to WeBWorK when these problems were coded created "technical debt" of various sorts, and this is one case where this has become a pretty serious issue for content on my system. I am grateful that the "true issue" is now clear, and hopefully both I and other in the future will be able to be lazy and sue answerHints together with custom grades in a proper manner, when that seems a decent idea. And yes, I agree in than in most cases it makes more sense to just add the messages directly in the custom grader. |
This is meant to fix the first issue reported in #1170
I put back the test that either the score is less than 1 or that
checkCorrect
was set before triggering a hint when "wrong" is not a subroutine.The intention is to fix the backwards compatibility for existing content. The "price" is that any very new problems which did not set
checkCorrect
and expect the answerHint code to process an non-code option will need to add it in explictly.Note: The older version of this test had a third "option" (another '||'). Based on the discussion in #964 (comment) the
|| AnswerHints::Compare($correct, $wrong, $ans)
portion of the old test was removed. @dpvc noted there that it was missing a negation, but felt it could be removed anyway. He removed even more - but the removal of the entire conditional about score < 1 is what is causing my problem.