Code below. Image attached. The vectors (n x 1 matrices) display beautifully in the text before the Yes/No questions, but in the Yes/No questions they display horizontally. I can get around this by listing the vectors in the questions before the questions, but I'd like to know what the issue is here.
Thanks.
Murphy
## DESCRIPTION
## True or False problem concerning for elementary row operations and solving systems of linear equations
##
##
## Note: all questions and explanations are from David Lay's Linear Algebra and its Applications 4ed except where noted. Other explanations were written by Martha Ellen Waggoner (MEW).
##
##
## Warning: There are specific references to the Lay Linear Algebra text in the explanations, and thus, would make these questions difficult to use as is for a different textbook.
##
## ENDDESCRIPTION
## DBsubject(Linear Algebra)
###########################
# Initialization
DOCUMENT();
loadMacros(
"PGstandard.pl",
"MathObjects.pl",
"PGchoicemacros.pl",
"PGgraders.pl",
"problemRandomize.pl"
);
TEXT(beginproblem());
ProblemRandomize(when=>"Always"); # always can reseed (after due date)
###########################
# Setup
Context("Matrix");
$a = Matrix([[2],[-2],[4]]);
$b = Matrix([-3],[3],[-6]);
$c = Matrix([0],[4],[-3]);
$d = Matrix([2],[4],[6]);
$e = Matrix([-2],[6],[-7]);
# Create and use pop up lists
$tf = new_select_list();
$tf->rf_print_q(~~&pop_up_list_print_q);
# Choices presented to students
$tf->ra_pop_up_list( [
"No answer" => "?",
"Yes" => "Yes",
"No" => "No",
]);
# Questions and answers
$tf -> qa (
"Is \(\mathbf{d} = $d\) in \(\text{Span}\lbrace \mathbf{a}, \mathbf{b}, \mathbf{c}\rbrace\)?",
"No",
"Does \(\lbrace \mathbf{a}, \mathbf{b}, \mathbf{c}\rbrace\) span \(\mathbb{R}^3\).",
"No",
"Is \(\mathbf{e} = $e\) in the image of \(T(\mathbf{x}) = A\mathbf{x}\)? ",
"Yes",
"Is \(A\mathbf{x} = \mathbf{g}\) consistent for all possible \(\mathbf{g}\)?",
"No",
"Is \(A\mathbf{x} = \mathbf{0}\) consistent?",
"Yes",
);
# How many questions to use
# The grader and solution below assumes that this number is 5
$tf->choose(5);
###########################
# Main text
Context()->texStrings;
BEGIN_TEXT
Consider the vectors \(\mathbf{a} = $a\), \(\mathbf{b} = $b\), \(\mathbf{c} = $c\), and the matrix \(A = [\mathbf{a}\ \ \mathbf{b}\ \ \mathbf{c}]\). Answer these questions.
Mark the following statements True or False
$BR
\{ $tf -> print_q() \}
END_TEXT
Context()->normalStrings;
############################
# Answer evaluation
$showPartialCorrectAnswers = 1;
#
# Incremental grader
# Note that as originally written this grading statement assumes there will be 5 questions
#
install_problem_grader(~~&custom_problem_grader_fluid);
$ENV{'grader_numright'} = [3,5,7];
$ENV{'grader_scores'} = [0.3,0.6,1];
$ENV{'grader_message'} = "You can earn " .
"30% partial credit for 3 correct answers, and " .
"60% partial credit for 5 correct answers.";
#
# All or nothing grader
#
# install_problem_grader(~~&std_problem_grader);
ANS( str_cmp( $tf->ra_correct_ans() ) );
# the remainder of the code is included to
# provide a sensible solution for the
# student.
# the answers to the questions that were
# asked, in order, are
@correctAns = @{$tf->ra_correct_ans};
# the following becomes necessary if we want
# to figure out what questions were asked
# so that we can give explanations for
# them.
# it's useful to define an array of
# explanations that correspond to the
# list of questions we might have asked
@explanations = (
"The system \(A\mathbf{x} = \mathbf{d}\) has no solution because the matrix reduction of \([ \mathbf{a\ \ b\ \ c\ |\ d}]\) has a pivot in the right-most column.",
"By Theorem 4 in Section 1.4, not(d) => not(c).",
"The system \(A\mathbf{x} = \mathbf{e}\) has infinitely many solutions because the matrix reduction of \([ \mathbf{a\ \ b\ \ c\ |\ e}]\) does not have a pivot in the right-most column and the matrix reduction of \([ \mathbf{a\ \ b\ \ c\}]\) has a pivotless column .",
"By Theorem 4 in Section 1.4, not(d) => not(a).",
"All homogeneous systems are consistent."
);
# then find the questions that were asked
@askedQuestions = ();
foreach $q ( @{$tf->selected_q} ) {
$i = 0;
foreach $mq ( @{$tf->questions} ) {
if ( $q eq $mq ) {
push(@askedQuestions, $i);
last;
}
$i++;
}
}
# now we know which questions were asked,
# and can print the corresponding
# explanations for the solution
#
# MEW: as written this assumes there were 5 questions asked
#
#SOLUTION(EV3(<<'END_SOLUTION'));
BEGIN_SOLUTION
$PAR SOLUTION $PAR
Question 1: $correctAns[0].
$explanations[$askedQuestions[0]]
$PAR
Question 2: $correctAns[1].
$explanations[$askedQuestions[1]]
$PAR
Question 3: $correctAns[2].
$explanations[$askedQuestions[2]]
$PAR
Question 4:
$correctAns[3].
$explanations[$askedQuestions[3]]
$PAR
Question 5:
$correctAns[4].
$explanations[$askedQuestions[4]]
END_SOLUTION
COMMENT("MathObject version.");
ENDDOCUMENT();