Forum archive 2000-2006

Barbra Bannon - More than one answer for a field

Barbra Bannon - More than one answer for a field

by Arnold Pizer -
Number of replies: 0
inactiveTopicMore than one answer for a field topic started 10/2/2001; 2:19:53 PM
last post 10/10/2001; 2:28:06 PM
userBarbra Bannon - More than one answer for a field  blueArrow
10/2/2001; 2:19:53 PM (reads: 1236, responses: 3)
Hello there,

I was wondering if there is a way for a field to accept 2 forms of an answer? For example: c/a + c/b or (ca+cb)/ab.

Thank you for any assistance you may be able to provide! -Barbra Bannon

<| Post or View Comments |>


userJohn Jones - Re: More than one answer for a field  blueArrow
10/10/2001; 2:21:14 PM (reads: 1470, responses: 0)
Depending on what you want, you might be able to solve your problem by taking this as a multivariable function and let WeBWork test it as such. Then it should accept any algebraically equivalent form.

If you don't want to do that, here is an answer evaluator which might do what you want. It allows the problem writer to specify several answer evaluators. It will test them in turn until it hits one where the student would get some credit and uses that. If they all fail, the student gets no credit.

You can also specify a weight for each answer. For example, a match against one answer might be worth full credit, but if that fails, another match should be worth half credit. One might use this if they were going to ask students to simplify a numerical answer, but give partial credit for an unsimplified answer.

And that's not all. You also can specify a comment to go with each answer. In the scenerio of the last paragraph, a student who gets half credit might appreciate a comment saying that if they go back and simplify the number themselves they can get full credit.

So, the input to this answer evaluator is basically a list of triples (answer evaluator, weight for partial credit, comment). Technically it is not a list but a perl reference to an array. So, you might call it with:

&ANS(pc_evaluator([[std_num_cmp(3), 1, 'Full Credit!'], [std_num_cmp(2),0.5,'Half'], [std_num_cmp(1), 0.1, 'Barely any credit :(']]));

The pc stands for partial credit. The code is below. Comments and suggestions are welcome.

John Jones -------------------------------


 


sub pc_evaluator {
my ($evaluator_list) = @_;

my $ans_evaluator = sub {
my $tried = shift;
my $ans_hash;
for($j=0;$j<scalar(@{$evaluator_list}); $j++) {
my $old_evaluator = $evaluator_list->[$j][0];
my $cmt = $evaluator_list->[$j][2];
my $weight = $evaluator_list->[$j][1];



if ( ref($old_evaluator) eq 'AnswerEvaluator' ) { # new style
$ans_hash = $old_evaluator->evaluate($tried);
} elsif (ref($old_evaluator) eq 'CODE' ) { #old style
$ans_hash = &$old_evaluator($tried);
} else {
warn "There is a problem using the answer evaluator";
}

if($ans_hash->{score}>0) {
$ans_hash -> setKeys( 'ans_message' => $cmt);
$ans_hash->{score} *= $weight;
return $ans_hash;
};
};
return $ans_hash;
};

$ans_evaluator;
}

<| Post or View Comments |>


userJohn Jones - Re: More than one answer for a field  blueArrow
10/10/2001; 2:22:44 PM (reads: 1478, responses: 0)
Oops, the web posting messed up the code. The only serious problem should be the #new style comment which also kills part of the next line.

John

<| Post or View Comments |>


userMichael Gage - Re: More than one answer for a field  blueArrow
10/10/2001; 2:28:06 PM (reads: 1515, responses: 0)
Enclose code in "<pre>" tags

<pre>

code goes here

</pre>

and line breaks are respected. You can also enclose the code in <code>... </code> which changes the font.

-- Mike

<| Post or View Comments |>