I would like to display a 2x2 table of graphs with a labeled answer box below each graph.

Adapting the example in http://webwork.maa.org/wiki/GraphsInTables

\{ BeginTable() .

AlignedRow([$fig[0],$fig[1]]) .

TableSpace(5,0) .

AlignedRow(["A","B"]) .

EndTable(); \}

by including ans_rule(5) in the second AlignedRow (in several fashions) has not worked.

http://webwork.maa.org/wiki/TableOfValues1 shows an easy way to get unlabeled answer boxes into a table.

I seek suggestions about improving on my current hack:

TEXT( $BCENTER,

begintable(2) ,

row($fig[0],$fig[1]) ,

row(EV2("A = \{ ans_rule(5) \}"),EV2("B = \{ ans_rule(5) \}")) ,

row($fig[2],$fig[3]) ,

row(EV2("C = \{ ans_rule(5) \}"),EV2("D = \{ ans_rule(5) \}")) ,

endtable() ,

$ECENTER ) ;

In reply to Dick Lane
Thursday, 1 March 2012, 2:10 PM

### Re: labeled answer boxes within table of graphs

by Michael Gage -
Hi Dick,

Is what is in the figure below what you want? (I didn't troubleshoot getting the figures into the problem.)

-- Mike

In reply to Michael Gage
Thursday, 1 March 2012, 4:43 PM

### Re: labeled answer boxes within table of graphs

by Paul Pearson -
Hi,

You might consider using this as a template.

Best Regards,

Paul Pearson

###############################

# Initialization

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"unionTables.pl",

"parserPopUp.pl",

);

TEXT(beginproblem());

###############################

# Setup

Context("Numeric");

@fig = ();

$fig[0] = "Figure 0 goes here";

$fig[1] = "Figure 1 goes here";

$fig[2] = "Figure 2 goes here";

$fig[3] = "Figure 3 goes here";

@popup = ();

$popup[0] = PopUp(["?","A","B","C","D"],"A");

$popup[1] = PopUp(["?","A","B","C","D"],"B");

$popup[2] = PopUp(["?","A","B","C","D"],"C");

$popup[3] = PopUp(["?","A","B","C","D"],"D");

####################################

# Main text

Context()->texStrings;

BEGIN_TEXT

Here is the problem text. The answers below could be strings, numbers

or formulas.

$PAR

\{

BeginTable() .

AlignedRow([$fig[0],$fig[1]]) .

TableSpace(5,0) .

AlignedRow(["A = ".ans_rule(10),"B = ".ans_rule(10)]) .

TableSpace(26,5) .

AlignedRow([$fig[2],$fig[3]]) .

TableSpace(5,0) .

AlignedRow(["C = ".ans_rule(10),"D = ".ans_rule(10)]) .

EndTable();

\}

$PAR

If the answers are strings, it would be preferable to use drop-down

menus (popups).

$PAR

\{

BeginTable() .

AlignedRow([$fig[0],$fig[1]]) .

TableSpace(5,0) .

AlignedRow(["A = ".$popup[0]->menu(),"B = ".$popup[1]->menu()]) .

TableSpace(26,5) .

AlignedRow([$fig[2],$fig[3]]) .

TableSpace(5,0) .

AlignedRow(["C = ".$popup[2]->menu(),"D = ".$popup[3]->menu()]) .

EndTable();

\}

END_TEXT

Context()->normalStrings;

###########################################

# Answer Evaluation

$showPartialCorrectAnswers = 1;

ANS( Compute("0")->cmp() );

ANS( Compute("1")->cmp() );

ANS( Compute("2")->cmp() );

ANS( Compute("3")->cmp() );

foreach my $i (0..3) {

ANS( $popup[$i]->cmp() );

}

COMMENT('MathObject version');

ENDDOCUMENT();

You might consider using this as a template.

Best Regards,

Paul Pearson

###############################

# Initialization

DOCUMENT();

loadMacros(

"PGstandard.pl",

"MathObjects.pl",

"unionTables.pl",

"parserPopUp.pl",

);

TEXT(beginproblem());

###############################

# Setup

Context("Numeric");

@fig = ();

$fig[0] = "Figure 0 goes here";

$fig[1] = "Figure 1 goes here";

$fig[2] = "Figure 2 goes here";

$fig[3] = "Figure 3 goes here";

@popup = ();

$popup[0] = PopUp(["?","A","B","C","D"],"A");

$popup[1] = PopUp(["?","A","B","C","D"],"B");

$popup[2] = PopUp(["?","A","B","C","D"],"C");

$popup[3] = PopUp(["?","A","B","C","D"],"D");

####################################

# Main text

Context()->texStrings;

BEGIN_TEXT

Here is the problem text. The answers below could be strings, numbers

or formulas.

$PAR

\{

BeginTable() .

AlignedRow([$fig[0],$fig[1]]) .

TableSpace(5,0) .

AlignedRow(["A = ".ans_rule(10),"B = ".ans_rule(10)]) .

TableSpace(26,5) .

AlignedRow([$fig[2],$fig[3]]) .

TableSpace(5,0) .

AlignedRow(["C = ".ans_rule(10),"D = ".ans_rule(10)]) .

EndTable();

\}

$PAR

If the answers are strings, it would be preferable to use drop-down

menus (popups).

$PAR

\{

BeginTable() .

AlignedRow([$fig[0],$fig[1]]) .

TableSpace(5,0) .

AlignedRow(["A = ".$popup[0]->menu(),"B = ".$popup[1]->menu()]) .

TableSpace(26,5) .

AlignedRow([$fig[2],$fig[3]]) .

TableSpace(5,0) .

AlignedRow(["C = ".$popup[2]->menu(),"D = ".$popup[3]->menu()]) .

EndTable();

\}

END_TEXT

Context()->normalStrings;

###########################################

# Answer Evaluation

$showPartialCorrectAnswers = 1;

ANS( Compute("0")->cmp() );

ANS( Compute("1")->cmp() );

ANS( Compute("2")->cmp() );

ANS( Compute("3")->cmp() );

foreach my $i (0..3) {

ANS( $popup[$i]->cmp() );

}

COMMENT('MathObject version');

ENDDOCUMENT();

In reply to Paul Pearson
Thursday, 1 March 2012, 6:54 PM

### Re: labeled answer boxes within table of graphs

by Dick Lane -
AHA !

Q: When is . more than just a speck, a period, a full-stop, one-third of ...?

A: When it is a Perl concatenation.

Thanks Paul !!

(I agree with the recommendation to use a popup menu when the plausible answers are technical words or phrases. OTOH, I disagree with the occasionally-seen practice of randomizing presentation order within a collection of such menus whose contents use the same strings.)

PS --- immediate context for my query:

Most of the graphs will be for periodic functions but a few will not. Instructions are to enter the period (a number) for each which is periodic, but "NONE" (a special string) for those which are not. For this problem, each figure will now have a prompt "period = " . ans_rule(5) aligned (nicely !) beneath it.

OTOH, I have preliminary design for some problems where those prompts will vary among the figures.

Q: When is . more than just a speck, a period, a full-stop, one-third of ...?

A: When it is a Perl concatenation.

Thanks Paul !!

(I agree with the recommendation to use a popup menu when the plausible answers are technical words or phrases. OTOH, I disagree with the occasionally-seen practice of randomizing presentation order within a collection of such menus whose contents use the same strings.)

PS --- immediate context for my query:

Most of the graphs will be for periodic functions but a few will not. Instructions are to enter the period (a number) for each which is periodic, but "NONE" (a special string) for those which are not. For this problem, each figure will now have a prompt "period = " . ans_rule(5) aligned (nicely !) beneath it.

OTOH, I have preliminary design for some problems where those prompts will vary among the figures.

In reply to Michael Gage
Thursday, 1 March 2012, 6:32 PM

### Re: labeled answer boxes within table of graphs

by Dick Lane -
Thanks Mike,

I don't need named answers (where the checking uses those names). I just want a textual prompt to precede each answer box (more details in my response to Paul).

dick

I don't need named answers (where the checking uses those names). I just want a textual prompt to precede each answer box (more details in my response to Paul).

dick