Difference between revisions of "MatrixAnswer2"
Jump to navigation
Jump to search
Fabiangabel (talk | contribs) (PGML example link) |
(add historical tag and give links to newer problems.) |
||
Line 1: | Line 1: | ||
+ | {{historical}} |
||
+ | |||
+ | <p style="font-size: 120%;font-weight:bold">This problem has been replaced with [https://openwebwork.github.io/pg-docs/sample-problems/LinearAlgebra/MatrixAnswer2.html a newer version of this problem]</p> |
||
+ | |||
+ | |||
+ | |||
<h2>Matrix Answer 2</h2> |
<h2>Matrix Answer 2</h2> |
||
Latest revision as of 05:24, 18 July 2023
This problem has been replaced with a newer version of this problem
Matrix Answer 2
This PG code shows how to collect matrix answers using one textbox for the entire matrix a student enters.
- File location in OPL: FortLewis/Authoring/Templates/LinAlg/MatrixAnswer2.pg
- PGML location in OPL: FortLewis/Authoring/Templates/LinAlg/MatrixAnswer2_PGML.pg
PG problem file | Explanation |
---|---|
Problem tagging: |
|
DOCUMENT(); loadMacros( "PGstandard.pl", "MathObjects.pl", "PGcourse.pl", ); TEXT(beginproblem()); |
Initialization: |
Context('Matrix'); $example1 = Matrix([[1,2,3],[4,5,6]]); $example2 = $example1->column(1); $example3 = $example1->row(1); |
Setup 1: We construct a 2 by 3 matrix and extract its first column and first row. |
Context()->texStrings; BEGIN_TEXT The purpose of this question is to show you the syntax needed to enter matrices in WeBWorK when there is only one answer box for entering a matrix (which is not obvious) or when there are multiple answer boxes for entering a matrix (which is obvious). The examples below should be self-explanatory, so you can jump to them if you want; however, a detailed explanation follows if you want to read more. $BR $BR Matrices use square brackets to enclose items in lists. A matrix with one row, such as a row vector, is a comma separated list enclosed by square brackets. A matrix with more than one row or a column vector is a comma separated list of lists, where each list uses square brackets to enclose its items. Your answers must use square brackets to enclose each row in a matrix or in a column vector. Also, a pair of square brackets is needed to enclose a matrix with more than one row (e.g., a \( 2 \times 3 \) matrix and a \( 2 \times 1 \) column vector have multiple rows so they need extra square brackets, but a \( 1 \times 3 \) row vector has only one row so it does not need extra square brackets). Your answers may have spaces and line breaks in them, such as $PAR $BCENTER [ [1, 2, 3], $BR [4, 5, 6] ] $ECENTER $BR $BR Enter the matrix \( $example1 \) as \{ $example1->string \} $BR \{ ans_box(3,30) \} $BR $BR Enter the column vector \( $example2 \) as \{ $example2->string \} $BR \{ ans_box(3,30) \} $BR $BR Enter the row vector \( $example3 \) as \{ $example3->string \} $BR \{ ans_box(3,30) \} END_TEXT Context()->normalStrings; |
Main Text 1:
Use |
$showPartialCorrectAnswers = 1; ANS( $example1->cmp() ); ANS( $example2->cmp() ); ANS( $example3->cmp() ); |
Answer Evaluation 1: |
Context('Matrix'); $example1 = Matrix([[1,2,3],[4,5,6]]); |
Setup 2:
Reset the context by calling |
Context()->texStrings; BEGIN_TEXT $BR $BR Entering a matrix using multiple answer blanks is straightforward -- just put each matrix entry into its own answer blank. $BR Enter the matrix \( $example1 \) with one matrix entry per answer box. $BR \{ $example1->ans_array \} END_TEXT Context()->normalStrings; |
Main Text 2: |
ANS( $example1->cmp() ); COMMENT('MathObject version.'); ENDDOCUMENT(); |
Answer Evaluation 2: |