-
-
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
Bug with AnswerHash.pm #872
Comments
No, you are running the filter in both cases. The $rh_ans = Parser::Eval(sub {&$filter($rh_ans, @array)});
warn $@ if $@; or something similar in order to find the actual error that is occurring. |
I have traced the error when the correct answer is entered with the MWE provided. What happens is that If I change line 276 of This may not be due to a change in pg at all. This may be a change in perl itself. Presumably the use feature 'say';
use Scalar::Util qw(refaddr);
my $first = { a => 'a' };
my $second = $first;
say refaddr($first);
say refaddr($second);
say sprintf('%p', $first);
say sprintf('%p', $second); Executing this script you will see that |
@drgrice1 I tested your perl script in older perl releases. I am testing these in older debian chroots. I tested all the way back to jessie (2015) with perl 5.20.2. In all of my tests the last two lines, |
Yeah, I didn't do any checking with older perl versions. I am just assuming that the |
If the goal is to determine if two references point to the same thing, I did find this stackexchange question: https://stackoverflow.com/questions/37220558/how-can-i-check-for-reference-equality-in-perl Adding Though this may not explain why this was working in 2.16 but not 2.18. |
@somiaj: That won't work here. |
FWIW, we see the issue on the 2.17 Runestone server, which IIRC has perl
5.20.3 running, intentionally old enough to not have issues with modperl.
The instructor claims they did not have these issues last summer, on a 2.16
server. Not sure what the perl version was there.
…On Tue, Jul 18, 2023 at 7:42 AM Glenn Rice ***@***.***> wrote:
@somiaj
<https://protect2.fireeye.com/v1/url?k=31323334-501d2dca-3132feb7-454455534531-973a77f48ef391cd&q=1&e=df4efdd3-6e00-49fb-b70a-79e3e4b5a2b7&u=https%3A%2F%2Fgithub.com%2Fsomiaj>:
That won't work here. == is overridden for MathObjects. That means that $first
== $second will not compare the variables as reference values, but as
MathObjects.
—
Reply to this email directly, view it on GitHub
<https://protect2.fireeye.com/v1/url?k=31323334-501d2dca-3132feb7-454455534531-9912f9effb5bb314&q=1&e=df4efdd3-6e00-49fb-b70a-79e3e4b5a2b7&u=https%3A%2F%2Fgithub.com%2Fopenwebwork%2Fpg%2Fissues%2F872%23issuecomment-1640363710>,
or unsubscribe
<https://protect2.fireeye.com/v1/url?k=31323334-501d2dca-3132feb7-454455534531-180eeaf6d469c898&q=1&e=df4efdd3-6e00-49fb-b70a-79e3e4b5a2b7&u=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABEDOABGWZPYHFUQAAY5ZC3XQ2OFTANCNFSM6AAAAAA2MHQ3U4>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Alex Jordan
Mathematics Instructor
Portland Community College
|
I just tried the original MWE on develop. At this point in time there is still an error message but it is different: |
I think this is related to the Note, however, that the You could, however add another post filter that creates a $cmp = $ans->cmp->withPostFilter(sub {
my $ansHash = shift;
if ($ansHash->{student_ans} =~ m/^\s*(?:\d+(?:\.\d*)?|\.\d+)\s*$/) {
$ansHash->{student_value} = main::Real($ansHash->{student_ans});
$ansHash->{student_formula} = main::Formula($ansHash->{student_value});
};
return $ans;
})->withPostFilter(AnswerHints(2 => ["no", replaceMessage => 1])); Note that you need to either use the |
This is fixed now. |
I reopened this. #974 clears up the perl warning, but there is another issue with the original MWE. It still doesn't actually show answer hints unless you do something like add the postFilter in @dpvc 's recent comment. That's a good thing to know about but in the long term it would be better to just make the first MWE work somehow. |
I first posted about this in the forums.
The following MWE illustrates a bug. If you enter the correct answer, it is not accepted and there is a perl warning "The evaluated answer is not an answer hash : ||."
This came to my attention from an instructor who previously used certain problems in 2.16, and they worked. But now they do not work on 2.17. And this MWE does not work on 2.18. So it is possibly a bug introduced between 2.16 and 2.17.
Note that if you change $ans to a Real, there is no issue. I also tried making $ans an Interval and there was no issue. It seems to have to do with $ans being a NumberWithUnits. Also there is no issue if I remove the withPostFilter or pass an empty hash to AnswerHints. So it also seems to have to do with AnswerHints.
I have done some sleuthing. First, it does not help to revert the two macro libraries here to earlier (say 2.16) versions. The change in behavior is something deeper. Things go bad inside
lib/AnswerHash.pm
. There is this loop, where I have insertedwarn
statements while debuggingRunning the MWE, I get an "A" without a "B". Something about trying to access
&$filter
(in the particular case when it is an AnswerHints filter involving a NumberWithUnits as in the MWE) terminates not only this loop, but also the ambient subroutine. That's what leads to the error message; the ambient subroutine then returns nothing at all, which is "not an answer hash".I can even change
warn('A');
towarn('A' . &$filter);
, and then I don't even get an "A". This suggests it's not so much something about executing that filter code, but just accessing it at all.The text was updated successfully, but these errors were encountered: