WeBWorK Problems

Predicting products of a Reaction

by Eric Stroyan -
Number of replies: 0
I am trying to set up problems where a student is given the reactants of a chemical reaction and asked to predict the products. Some of the cases involve complex ions that contextReaction is not too happy with. I have attached a (modified) version of an old .cgi I used to use that would accept a student answer, strip whitespace, split at +, and compare (using perl sort) to an array of correct answers. This .cgi worked for all cases fed it. I have tried to make a custom answer checker, but I do not seem able to handle the strings properly. I'm shot as to where to take this. Any help would be appreciated.
Perhaps some sort of filtering of student answer, the feeding to unordered_cs_str_cmp_list?
I've pasted the checking subroutine (and attached a working perl example.
sub mycheck {
#
# Check student input of products
# Student inputs in 'standard' form, e.g. Fe + Cr(NO_{3})_{3} then..
# Strip spaces
#
$student =~ s/\s+//g; # # Split at + # @student_answers = split(/\+/,$student);
$num_ans =$#ans+1;
$num_stu =$#student_answers+1;
if($num_stu !=$num_ans){print"Not enough, too many, or no answer.\n"; return 0}
#
# Sort student input and answer
#
@sort_ans = sort@ans;