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;
@sort_stu = sort@student_answers;
#
# Check for match and leave
#
if (@sort_ans~~@sort_stu){
print "Correct = [@ans] and your answer = [@student_answers] match. Good job!\n"; return 1}
if (@sorted!~~@sorted2){
print "Not Quite. Try again.\n"; return 0}
}
WeBWorK Problems
Predicting products of a Reaction
This forum has a limit to the number of forum postings you can make in a given time period - this is currently set at 10 posting(s) in 1 day