How turn off "preprocessing and error detection" of/in student answers before handing to custom grader? (giving errors)
by Christian Seberino - Number of replies: 3How set Webwork to NOT do ANY preprocessing of the student answers and just send the raw text exactly as it appears to the custom grader?
(The context of the question is that I'm trying to write a Webwork problem that accepts source code and can grade it. (See below.) As you can imagine, entering source code for an answer confused Webwork which thinks there are all kinds of botched implied mutliplications and other errors in the answer.)
DOCUMENT();
loadMacros(
"PGstandard.pl",
"PGML.pl",
"MathObjects.pl",
"PGcourse.pl",
"parserNumberWithUnits.pl",
"contextArbitraryString.pl",
"parserMultiAnswer.pl",
"parserPopUp.pl",
"contextInequalities.pl",
"PGgraphmacros.pl",
);
TEXT(beginproblem());
$showPartialCorrectAnswers = 1;
######################################################################
Context("ArbitraryString");
@answers = ("<source code>");
$ans = Compute(@answers[0])->cmp(checker => sub {
my ($temp1, $response, $temp2) = @_;
$x = SourceCodeGrader::sourcecodegrader($response);
return 1;
});
BEGIN_PGML
Text of question goes here.
[@ ANS($ans), ans_box(30, 90) @]*
END_PGML
######################################################################
ENDDOCUMENT();
Re: How turn off "preprocessing and error detection" of/in student answers before handing to custom grader? (giving errors)
by Michael Gage -I think what you want to do is to avoid MathObjects all together and create and AnswerEvaluator -- somewhat lower level machinery
The answerHash is just a hash with a bunch of information -- it's what you see when you use PGLabs -- The AnswerEvaluator allows you to take a string of filters which input the answer Hash, process the information in it and then out the answer hash to be passed on to the next filter. This is how the basic evaluators were created. The MathObject evaluators were created somewhat separately but hook in to this mechanism. You want to hook into this mechanism directly since you want to by pass the features provided by the MathObjects class.
Looking at the code in the files labeled PG***evaluators.pl will give you some ideas. The old macros num_cmp() and fun_cmp() used the AnswerEvaluators directly but they have been modified to use the MathObjects routines in order to provide the students with superior feedback.
Value/AnswerChecker.pm the cmp() method around line 79 gives you another example of creating the answer evaluator and using it.
Re: How turn off "preprocessing and error detection" of/in student answers before handing to custom grader? (giving errors)
by Davide Cervone -This can be fixed by adding
Context()->strings->{patterns}{'(.|~~n)*'} = [-25,str]; Context()->update;right after the
Context("ArbitraryString");command. This will let the arbitrary string span newlines. I think that should work for you.
Davide
PS, if you want to include this within a macro file, change ~~n
to \n
in the pattern above.
Re: How turn off "preprocessing and error detection" of/in student answers before handing to custom grader? (giving errors)
by Christian Seberino -If anyone reads this and needs to still pursue Prof. Gage's idea to write an answer evaluator, the easiest way to get started is probably to just add a copy of std_cs_str_cmp next to the original in pg/macros/PGstringevalators.pl, rename it, and start tweaking that.
Sincerely,
Chris