Matrix input and grading

A matrix question can ask for one particular matrix, any basis of a space, or any matrix with a stated property. Choose the mathematical test first; the editor collects entries, while the answer test and response tree decide correctness and marks. Try the matrix questions before adapting one.

For teachers

Decisions for a question author

What the prompt asks Appropriate check Teacher value in the PRT
A particular matrix AlgEquiv compares dimensions and corresponding entries; EqualComAss also checks written form. The expected matrix.
Any basis of a null, column or row space PythonChecker selects basis with JSON space set to nullspace, columnspace or rowspace. The original matrix \(A\).
Integer entries, a given determinant or nonidentity Separate PythonChecker nodes select matrix_property with JSON property set to integer_entries, determinant or identity. The expected property result: true, an exact determinant such as 1, or false.
Another condition, such as Hermitian symmetry or positive definiteness A named PythonChecker function. Combine conditions in one PRT or give them separate marks in two PRTs. The value the function needs, such as true for the positive-definiteness examples.

An entry-by-entry check would reject many correct answers to “give any basis” or “give any matrix satisfying these conditions.” See Python answer tests for the choice and the positive-definiteness walkthrough for combined and separately weighted Hermitian-symmetry/positivity rules. The first question requires both; the second awards half for each. The example accepts exact integer or fractional real and imaginary parts, such as 1/2+%i/3. An equivalent native Moodle STACK question needs corresponding Maxima checks; these Python test names are specific to this port.

If the shape is part of the task, let learners choose a bounded number of columns for null or column-space bases, or rows for row-space bases. An empty basis cannot currently be entered because the editor needs positive dimensions. For a fixed-size task, the model answer determines the editor’s shape. The supplied basis and matrix_property functions require exact rational entries (integers or fractions); a custom PythonChecker function can choose another domain within the input limits. Set any partial credit in the response trees; neither correct cells nor green basis vectors earn marks by themselves.

What learners see

A learner fills matrix cells, presses Validate answers to inspect the interpreted matrix, then presses Check answer. Empty cells are invalid. The editor retains typed forms such as x+x or 1/2; resizing keeps cells that still fit and leaves new cells blank. Editing, resizing, resetting or switching variants clears an earlier result and requires validation again. After a basis check, vector colors explain membership and dependence, but the response tree still determines the score.

For developers

XML input and learner-selected dimensions

Use <input><type>matrix</type>... for a fixed-size matrix; the input model answer supplies its dimensions. For learner-selected columns, as in the basis examples, add:

<matrix>
  <rows initial="3" min="3" max="3" resizable="0"/>
  <cols initial="1" min="1" max="3" resizable="1"/>
</matrix>

Each axis requires initial, min, max and resizable. A fixed axis uses resizable="0" with equal initial, minimum and maximum. The product of the two maxima may not exceed 64. This sizing element is a CTM STACK extension and needs adaptation for native Moodle STACK. The input model and authored tests must fit the configured dimensions. For a matrix-defined space, the input model can use nullspace_basis(A), columnspace_basis(A) or rowspace_basis(A) while the PRT uses the original A.

Supported values and tests

Author expressions write a matrix as matrix([a,b],[c,d]), distinct from a nested list. Matrices must be rectangular and complete, with 1–16 rows and columns and at most 64 scalar entries. Cells cannot contain collections, equations or logical values. The supported native STACK matrix tests here are AlgEquiv, SameType and EqualComAss; other native matrix tests and general matrix arithmetic are outside this port’s current support.

Raw cells remain unchanged until validation interprets them. The editor does not create zeros for blank cells or compute marks. The reusable component and its provenance are recorded in the project source tree; question authors configure it through XML.