## WeBWorK Problems

### Matrix answers and custom checkers

by Bob Hasson -
Number of replies: 1
I am trying to write problems that take matrix answers in a somewhat open ended way.  The problem I am working on asks the student for a matrix with a column space spanned by two given column vectors and a null space spanned by another given vector.  Obviously there are many matrices that will work.

Questions:

1.  To get the student's response I am setting up a matrix A by

$A = Matrix ([0,0,0],[0,0,0],[0,0,0]); and then prompting for it in the BEGIN_TEXT, END_TEXT block with \{$A->ans_array (10)\}

Is there a better way to get the student response?

2.  Since many matrices answer the above question, I need a custom answer checker.  I have a Perl subroutine that I call that starts as

sub mycheck{
my ($correct,$student, $ansHash) = @_; and gets called by ANS ($A->cmp(checker=>~~&mycheck));

I think that $student ends up with a pointer to the student's answer. But what are$correct and $ansHash? Also, can any of these be a pointer to a matrix? Do any of them point to matrix A above? In reply to Bob Hasson ### Re: Matrix answers and custom checkers by Davide Cervone - I know this is way past when you asked, but I'm trying to respond to past questions so that people who find this page by searching will get an answer. For question 1, that is a reasonable way to ask for the matrix. Make sure, however, that your $A is actually a solution to the problem, because if (after the due date) the student asks to show answers, this is the value that will be displayed. Just because you are providing a custom checker doesn't mean you can get away without giving a correct answer yourself.

For question 2, you are right that $student is the MathObject that represents the student's answer. This will be a reference to a Matrix object because the student is forced to enter a matrix by your use of ans_array in $a->ans_array(10). The $correct variable will be a reference to the correct answer, in this case $A (it is passed to the checker so that you can use the same custom checker for more than one answer blank). The \$ansHash is a reference to an AnswerHash object, which stores data about the answer checker (like the flags that were set for it, and other information). In general, you don't have to worry about that.

Hope that helps.

Davide