Forums
Search results: 135
For your second example, it would be possible to do that using a multi-part (sometimes referred to as a "compound") problem. This is an advanced technique that will not be covered in detail in this workshop. The tools for doing this are still actively being developed.
One option that doesn't require multi-part problems would be to allow the student to enter the array in a single large rectangle either using the MathObject matrix notation (brackets around comma-separated entries for the rows, with rows separated by commas and enclosed in brackets), or as an array of numbers separated by spaces and newlines that you turn into an array by hand within a custom answer checker. The latter would require a little extra work, but is probably preferable.
Here's one version that might do what you need:
loadMacros("contextArbitraryString.pl"); Context("ArbitraryString"); $A = Matrix([1,2,3],[4,5,6]); Context()->texStrings; BEGIN_TEXT \($A\) = \(\Bigg[\) \{ans_box(4,12)\} \(\Biggr]\) END_TEXT Context()->normalStrings; ANS(Compute("1 2 3~~n4 5 6")->cmp(checker => sub { my ($correct,$student,$ans) = @_; my $M = $student->value; $M =~ s/ +/ /g; # remove multiple spaces $M =~ s/(~~n|^) /~~1/g; $M =~ s/ (~~n|$)/~~1/g; # remove leading and trailing spaces $M =~ s/~~n~~n+/~~n/g; # remove blank lines $M =~ s/^~~n+//; $M =~ s/~~n+$//; # remove leading and trailing blank lines my @M = map {[split(/ /,$_)]} split(/~~n/,$M); # break into an array of arrays $M = Matrix(@M); # form MathObject matrix $ans->{preview_latex_string} = $M->TeX; # format the answer preview $ans->{correct_ans_latex_string} = $A->TeX; # format the correct answer return $A == $M; # check the answers }));You can paste this into the Interactive Problem Lab to see how it works (or insert it into a problem file ad add the problem to a set). The main idea is that you get the student's answer as a string and then manipulate that string to form a MathObject Matrix. That will already perform some error checking (like that the rows are the same length and that the entries are numbers).
In any case, this is a starting point for that type of answer.

Does this: http://webwork.maa.org/wiki/CompoundProblems do what you want?
Gavin
But please do send me the version you're using and let me try. If nothing else, it will give us impetus to upgrade in December when classes are over.
Thanks!!
Several years ago when you upgraded, compoundProblem.pl stopped working correctly and Mike gave me a klugy fix that allows me to continue using the problems I've authored. I am still having to tell students to erase the answers that appear in the next page's boxes and scoring is all messed up (although I do believe that the final score is right if someone gets 100%).
Any chance that this will get fixed before I retire (approximately a year from now) and want to bequeath you all my problems for multivariable and linear algebra? Or has it been fixed in the latest version and do we need to upgrade here at UGA?
Thanks!
Or as a compromise, at least display the forbidden symbol in the "answer preview", meaning: it would say something like "neg. p" in the problem, yet display properly as "~p".