[ww-bugs] Bug 3237: PGML and parserRadioButtons throw warnings

bugzilla-daemon at webwork.maa.org bugzilla-daemon at webwork.maa.org
Wed Aug 31 11:58:05 EDT 2016


http://bugs.webwork.maa.org/show_bug.cgi?id=3237





--- Comment #2 from Paul Pearson <paultpearson at gmail.com>  2016-08-31 11:58:04 ---
Inside the getCorrectChoice() subroutine of parserRadioButtons.pl, there is a
line

  $value = ($self->flattenChoices)[$value] if $value =~ m/^\d+$/;

The Perl regular expression m/^\d+$/ essentially says to match a string that
consists only of two or more digits (i.e., it says to match anything beginning
with any digit followed by one or more digits until the string ends).  If
correct answer is a natural number like '75', then $value = '75' and the
conditional $value =~ m/^\d+$/ returns true, so the line of code above gets
interpreted as

  $value = ($self->flattenChoices)[75];

For my webwork question, the array of choices has 4 elements in it, so
($self->flattenChoices)[75] is empty and thus $value is empty, hence the
warning message that gets generated.

Now, how to fix it?

-- 
Configure bugmail: http://bugs.webwork.maa.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.


More information about the webwork-bugs mailing list