## PREP 2015 Question Authoring - Archived

### Testing "alttext"/Error Message when "testing" randomization ### Testing "alttext"/Error Message when "testing" randomization

by Regina Souza -
Number of replies: 4
1) Any idea on how would one test whether the "alttext" for the graph
in the problem below is working? (Here at UM they are very concerned about accessibility issues).
2) I'm not sure how to interpret the error (see attachment)
I got when "testing the randomization" of the following problem:

# DESCRIPTION
# Recognizing values of the parameters k and p from the graph of y=k x^p (with p<0)
# ENDDESCRIPTION
#Right now stored at MAA-PREP2015
# Homework/Workshop3/Souza/problem4.pg
## DBsubject(’Precalculus’)
## DBchapter(’’)
## DBsection(’’)
## Date(’mm/dd/15’)
## Level(’’)
## Keywords(’’)
## Author(’Regina Souza’)
## Institution(’University of Montana, Missoula’)
## TitleText1(’Functions Modeling Change’)
## EditionText1(5)
## AuthorText1(’Connally’)
## Section1(11.1)
## Problem1()

DOCUMENT();
"MathObjects.pl",
"PGgraphmacros.pl",
"parserPopUp.pl",
"PGML.pl",
"PGcourse.pl");
Context("Numeric");
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;$refreshCachedImages = 1;
Context("Numeric");
$pixels = 200; # Create the canvas$gr = init_graph(-1,-1,6,6, # xmin, ymin, xmax, ymax
axes=>[0,0], grid=>[7,7], size=>[$pixels,$pixels]);
$gr -> lb('reset'); # remove default labels # axes labels$gr->lb( new Label(5.5,0,'x', 'black', 'center', 'bottom'));
$gr->lb( new Label(0.1,5.5,'y', 'black', 'left', 'middle')); # axes labels foreach my$i (1..5) {
$gr->lb( new Label($i,0, $i, 'black', 'center', 'top'));$gr->lb( new Label(-0.1,$i,$i, 'black', 'right', 'middle'));
}
# randomize the graph
$c = random(2,4,0.5); # plot a function$f = Formula("$c/x"); add_functions($gr, "$f for x in <0,6> using color:blue and weight:2"); install_problem_grader(~~&std_problem_grader);$showPartialCorrectAnswers = 0;
$popup1 = PopUp( ["choose","a linear function","a quadratic function","an exponential function","a power function"], "a power function", );$popup2 = PopUp(
["choose","0","1","2","2.5","3","3.5","4.0"],
"$c", );$popup3 = PopUp(
["choose","d is less than 0", "d is between 0 and 1", "d is greater than 1"],
"d is less than 0",
);
BEGIN_PGML
Consider the function given by the following graph:
>> [@ image(insertGraph($gr), width=>$pixels, height=>$pixels, tex_size=>900,extra_html_tags=>'alt="Graph of a decreasing, concave up function in quadrant I, which passes through (1,'.$c.') " ' ) @]*
[ f(x)=c\cdot x^d ] <<
a. Which type of function is this? This is [_________]{$popup1} b. What is the value of [ c ] ? [ c = ][____]{$popup2}
c. Choose the best option for [ d ]: [_________]{$popup3} END_PGML BEGIN_PGML_SOLUTION *SOLUTION* a. This is [@$popup1->correct_ans() @]* .
b. [ c = [$c] ], the value of the function at 1, and c. [@$popup3->correct_ans() @]* , since [ c>0 ] and the power function is decreasing when [ x>0 ].
END_PGML_SOLUTION
ENDDOCUMENT();  ### Re: Testing "alttext"/Error Message when "testing" randomization

by Regina Souza -
I was able to identify that seed 1119 was the culprit. Still don't understand the error message. It seems to have something to do with
The correct choice must be one of the PopUp menu items

The correct choice for popup2 is $c, which is randomly chosen between 2 and 4 with interval 0.5. In reply to Regina Souza ### Re: Testing "alttext"/Error Message when "testing" randomization by Paul Pearson - Hi Regina, PopUps use string comparison, so if you set$c = random(2,4,0.5); and $popup2 = PopUp(["choose","0","1","2","2.5","3","3.5","4.0"],"$c",); it is possible to have $c equal to the (numerical) scalar 4, which is not the same as "4.0" when the comparison between "4" and "4.0" is done as strings (not numbers), thus the correct answer is not one of the PopUp choices. I would suggest using$c = list_random("2","2.5","3","3.5","4");
$popup2 = PopUp(["choose","0","1","2","2.5","3","3.5","4"],$c);

so that the value for $c will always be a string that is one of the choices for$popup2.  If you use the scalar $c in any computations, Perl will be smart enough to interpret$c as a numerical scalar rather than a string.

Also, you had multiple Context("Numeric") and $showPartialCorrectAnswers statements in your problem, and removing such things will make the problem into a better template that is easier to maintain. I have included pg source code below. Also, you should look in the Open Problem Library directory LoyolaChicago/Precalc for problems from the Connally textbook you are using, as Adam Spiegler and I have written / co-written a bunch of problems for that book already. https://github.com/openwebwork/webwork-open-problem-library/tree/master/OpenProblemLibrary/LoyolaChicago/Precalc Best regards, Paul Pearson ###### pg code below ############# # DESCRIPTION # Recognizing values of the parameters k and p from the graph of y=k x^p (with p<0) # ENDDESCRIPTION #Right now stored at MAA-PREP2015 # Homework/Workshop3/Souza/problem4.pg ## DBsubject(’Precalculus’) ## DBchapter(’’) ## DBsection(’’) ## Date(’mm/dd/15’) ## Level(’’) ## Keywords(’’) ## Author(’Regina Souza’) ## Institution(’University of Montana, Missoula’) ## TitleText1(’Functions Modeling Change’) ## EditionText1(5) ## AuthorText1(’Connally’) ## Section1(11.1) ## Problem1() DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGgraphmacros.pl", "parserPopUp.pl", "PGML.pl", "PGcourse.pl" ); TEXT(beginproblem());$showPartialCorrectAnswers = 1;
$refreshCachedImages = 1; Context("Numeric");$pixels = 200;
# Create the canvas
$gr = init_graph(-1,-1,6,6, # xmin, ymin, xmax, ymax axes=>[0,0], grid=>[7,7], size=>[$pixels, $pixels]);$gr -> lb('reset'); # remove default labels
# axes labels
$gr->lb( new Label(5.5,0,'x', 'black', 'center', 'bottom'));$gr->lb( new Label(0.1,5.5,'y', 'black', 'left', 'middle'));
# axes labels
foreach my $i (1..5) {$gr->lb( new Label($i,0,$i, 'black', 'center', 'top'));
$gr->lb( new Label(-0.1,$i, $i, 'black', 'right', 'middle')); } # randomize the graph #$c = random(2,4,0.5);
$c = list_random("2","2.5","3","3.5","4"); # plot a function$f = Formula("$c/x"); add_functions($gr, "$f for x in <0,6> using color:blue and weight:2"); install_problem_grader(~~&std_problem_grader);$popup1 = PopUp(
["choose","a linear function","a quadratic function","an exponential function","a power function"],
"a power function",
);

$popup2 = PopUp( ["choose","0","1","2","2.5","3","3.5","4"],$c
);

$popup3 = PopUp( ["choose","d is less than 0", "d is between 0 and 1", "d is greater than 1"], "d is less than 0", ); BEGIN_PGML Consider the function given by the following graph: >> [@ image(insertGraph($gr), width=>$pixels, height=>$pixels, tex_size=>900,extra_html_tags=>'alt="Graph of a decreasing, concave up function in quadrant I, which passes through (1,'.$c.') " ' ) @]* [ f(x)=c\cdot x^d ] << a. Which type of function is this? This is [_________]{$popup1}
b. What is the value of [ c ] ? [ c = ][____]{$popup2} c. Choose the best option for [ d ]: [_________]{$popup3}
END_PGML

BEGIN_PGML_SOLUTION
*SOLUTION*
a. This is [@ $popup1->correct_ans() @]* . b. [ c = [$c] ], the value of the function at 1, and
c. [@ $popup3->correct_ans() @]* , since [ c>0 ] and the power function is decreasing when [ x>0 ]. END_PGML_SOLUTION ENDDOCUMENT(); In reply to Paul Pearson ### Re: Testing "alttext"/strings in popup/using OPL by Regina Souza - Question 1 from last time: any words of wisdom regarding the "robustness" of the "alt-text" I included in the problem above? Is there a way of "testing" to see if it *is* accessible? Question 2 from last time: "Strings in pop-up" Thanks! Living and learning! Additional Questions (Regarding the OPL): OPL-1) I would like some pointers on how to use the OPL. I have been using the problems for Connally. I'm having trouble finding what is out there. For example, in the github link you sent, I see that you have created problems Ch9-Tools (Ch9,3e which correspond to Ch11,4e). When I search (advanced search according to the text), this option is not available. Is there a way of directly accessing these problems with the library browser? OPL-2) When I searched FMC4e, Ch 11, Section 1 there were 44 problems (most of them were listed multiple times). Is this a problem with the way my library browser is set up or is there are problem with the advanced search library browser? In reply to Regina Souza ### Re: Testing "alttext"/strings in popup/using OPL by Paul Pearson - Hi Regina, Searching the internet for "chrome Image Alt Text Viewer" you can easily find an extension for the Google Chrome browser that will display the Alt Text in place of an image. Also, Alex Jordan at Portland Community College would be a good person to ask about this since he has done many things to make webwork more accessible. You should consider asking this question on the webwork problems forum: http://webwork.maa.org/moodle/mod/forum/view.php?f=3 Generally, it's best to ask one question per discussion thread so that the discussions are more concise and on point. You can view OPL problems directly using the "NPL Directory" button in the Library Browser and then choosing a directory such as LoyolaChicago/Precalc/... If you do not have a button that says "NPL Directory" or "OPL Directory", add the line$courseFiles{problibs}{Library} = "OPL Directory";

to the course.conf file.

I would recommend searching the problem library by directory for precalc questions from Connally.  The directory structure such as "LoyolaChicago/Precalc/Chap3/Sec2" may refer to an older edition of the book, but should be relatively easy to follow otherwise.  With more than 25,000 problems in the OPL, keeping tags up to date with the latest and greatest version of a textbook is quite a large task, so advanced features like search by textbook can easily be out of date.  But, the directory structure and location of files is basically static in the OPL, so using the Library Browser to hunt for problems by OPL directory is good.

Best regards,

Paul Pearson