WeBWorK Main Forum

Answer checking order is weird

Answer checking order is weird

by Lijuan Cao -
Number of replies: 2

I am making a scaffolding problem. The first step of the problem includes some fill-in-the-blank questions, and the second step asks students to fill in a table. When I tested the problem, the answer checker checks the answers from the first step at the end, and it checks the answers of the table first. As a result, it does not check properly. If the fill-in-the-blank questions come after the table, there is no issue. Here is my code:

DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGML.pl",
"scaffold.pl",
"PGcourse.pl"
);

TEXT(beginproblem());

###########################
# Setup
Context()->strings->add(T => {}, F => {});

$table1 = $BCENTER.begintable(3) .
row( "\(p\)", "\(q\)", " \(p \vee q\) ") .
row( ans_rule(5), ans_rule(5), ans_rule(5),) .
row( ans_rule(5), ans_rule(5), ans_rule(5),) .
row( ans_rule(5), ans_rule(5), ans_rule(5),) .
row( ans_rule(5), ans_rule(5), ans_rule(5),) .
endtable().$ECENTER;

@answer1 = ("T", "T", "T",
"T", "F", "T",
"F", "T", "T",
"F", "F", "F",
);

###########################
# Main text

Scaffold::Begin();
Section::Begin("Step 1");

BEGIN_PGML


[`x = `] [__________]{1}

[`y = `] [__________]{0}

END_PGML

Section::End();
Section::Begin("Step 2");

BEGIN_PGML

[@ $table1 @]***

END_PGML

foreach my $i (0..$#answer1) {
ANS( String($answer1[$i])->cmp() );
}

Section::End();
Scaffold::End();

ENDDOCUMENT();

 Is there a way to fix this? Thank you.


In reply to Lijuan Cao

Re: Answer checking order is weird

by Glenn Rice -
Since you are calling ans_rule for the table before the first part of the scaffold, those answer rules are recorded first, and are listed first.

Move the definition of $table after the first Section::End() and before the next Section::Begin(), and then it will work.
In reply to Glenn Rice

Re: Answer checking order is weird

by Lijuan Cao -
I did not know that the order of the answer rules matter. Thank you for clarifying this for me. The problem works fine now.