Wiris

Documentation / WirisQuizzes

  • Demos
  • Visit our website
  • Contact us
  • MathType

    • WirisQuizzes

      • Nubric

        • CalcMe

          • MathPlayer

            • Store FAQ

              • MathFlow

                • BF FAQ

                  • Miscellaneous

                    • Wiris Integrations

                      • Home
                      • WirisQuizzes
                      • Validation Options
                      • Grading functions

                      Answering vectors

                      Reading time: 2min

                      It's essential to read this section if you wish to create questions involving vectors. The critical point is that vectors are passed to the grading function as matrices, so we need to de-index them inside the function body to do normal vector operations with them. This should all be clear with the following basic example.

                      What this all essentially means is that if we pass [...] to a grading function, it will be taken as [ [...] ] (a list with the original vector as its only element). As a result, we cannot do vector operations with it. For example, the vector
                      gf_vector_ex1.1_calcme.png
                      will be converted to
                      gf_vector_ex1.2_calcme.png
                      How do we access the original vector? It is the first (and only) element of a list, so as with any list, we may access the first element with the subindex "1", as so:
                      gf_vector_ex1.3_calcme.png
                      So if "v" was the original vector given by the student and passed to the grading function, to treat it as a vector, we simply need to write "v1" wherever we would like to use "v". Let's look at this with some examples.

                      Example 1
                      gf_ex_4.1.png

                      The matrix has rank 2, so there will be infinite solutions, meaning that we have to use a grading function if we want to allow any possible solution. The procedure itself is pretty simple, but observe that we used the subindex as described above:
                      programming.gf_vector1.calc.png
                      The other case we need to cover is allowing students to answer with a row or column vectors (until now, we've only assumed row vectors). We'll illustrate what needs to be done with an example. Using the same question as before, let's say the student responds like so:
                      gf_vector_ex_2.3.png
                      This is a column vector, and it is treated differently. All we need to do, though, is transpose it, and we are back to the previous case. We most likely want to allow both types of answers, so at the beginning of the original grading function, we might add the following:
                      programming.gf_vector2.calc.png
                      We've added an if statement that simply detects if the input is a column vector (by seeing if the number of columns is 1) and transposes it in that case. If not, then nothing is done to "v". The result is that in all circumstances ", v" will be of the form [ [...] ], and after that, we can use subindices precisely as described previously.

                      Example 2

                      Imagine we want to ask the students the following question:
                      gf_vector_example2_statement.png
                      This example clearly needs a grading function since there are infinite correct answers.

                      The first answer is a point, but it is understood as a matrix as before. We need to specify the corresponding element is a point and check whether it belongs to the corresponding line or not. The first part of the grading function would be:
                      programming.gf_vector_example2.gf1.calc.png
                      The second answer is a vector and is also understood as a matrix. Similarly, we have to access its first row with a grading function as the following:
                      programming.gf_vector_example2.algorithm.calc.png

                      Was this article helpful?

                      Give feedback about this article

                      Related Articles

                      • Basic grading function
                      • Custom marks
                      • Compound answers
                      • Student's answers to the same question
                      • Keep arguments unevaluated

                      Answering vectors

                      Example 1 Example 2

                      Empowering STEM education

                      MathType

                      • Office Tools
                      • LMS
                      • XML
                      • HTML

                      WirisQuizzes

                      Nubric

                      Integrations

                      Solutions

                      • Education
                      • Publishing houses – platforms and interactive
                      • Publishing houses – Print and digital
                      • Technical writers

                      Pricing

                      Downloads

                      Blog

                      • Success stories

                      About us

                      • Careers
                      • Partnership

                      Contact Us

                      Contact Sales

                      European union (European Regional Development Fund) and 1EdTech (TrustEd Apps Certified)
                      • Cookie Policy
                      • Terms of Use
                      • Privacy Policy / GDPR
                      • Student Data Privacy
                      • Compliance
                      • Cookie Settings

                      © Wiris 2026

                      Expand