WeBWorK Main Forum

Are custom graders the best/only way to strip whitespace & allow multiple answers for ArbitraryString context?

Are custom graders the best/only way to strip whitespace & allow multiple answers for ArbitraryString context?

by Christian Seberino -
Number of replies: 1
Are custom graders the best/only way to strip whitespace & allow multiple answers for ArbitraryString context?

This extra flexiblity is needed because students will inevitably add spaces to the end of words and/or capitalize things differently than Webwork is expecting.

cs
In reply to Christian Seberino

Re: Are custom graders the best/only way to strip whitespace & allow multiple answers for ArbitraryString context?

by Jason Aubrey -
Yes, it looks like it.  Here's the comment at the top of the macro:

####################################################################
#
# Implements a context in which the student's answer is treated as a
# literal string, and not parsed further. The real answer checking
# should be performed in a custom checker passed to the answer
# string's cmp() method. E.g.,
#
# loadMacros("contextArbitraryString.pl");
# Context("ArbitraryString");
#
# ANS(Compute("The string I want")->cmp(checker => sub {
# my ($correct,$student,$ans) = @_;
# $correct = $correct->value; # get perl string from String object
# $student = $student->value; # ditto
# ##
# ## do your checking here, and return true if correct
# ## or false if incorrect. For example
# ## return $correct eq $student;
# ##
# return $score;
# }));