Tipo de pregunta álgebra

Saltar a: navegación, buscar

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

Tipo de pregunta álgebra
Tipo tipo de pregunta
Conjunto N/A
Descargas https://moodle.org/plugins/view.php?plugin=qtype_algebra
Problemas Tracker issues
Discusión https://moodle.org/mod/forum/discuss.php?d=98670
Mantenedor(es) Jean-Michel Védrine

El tipo de pregunta álgebra permite expresiones algebraicas como respuestas de estudiantes, las que son evaluadas por respuestas proporcionadas por el instructor usando las reglas básicas del álgebra. Se ofreció como código contribuído inicialmente en Julio del 2009. Actualmente es mantenida por Jean-Michel Védrine

Vista general

Este es un tipo de pregunta para Moodle.

Implementa un tipo de pregunta algebraica en donde las respuestas de los estudiantes son tratadas como una expresión algebraica y son comparadas con las respuestas proporcionadas por el instructor usando las reglas básicas del álgebraIt implements an algebraic question type where student responses are treated as an algebraic expression and compared to instructor provided answers using the b.

Por ejemplo, si la respuesta proporcionada por el instructor es , entonces un estudiante que ingrese tendrá su respuesta tratada como correcta.

¡El código ha sido probado en producción con ~230 estudantes de física de primer año sin problemas (usando solamente el método de comparación de evaluación) - principalmente gracias a una excelente retroalimentación y pruebas de usuarios de Moodle del foro de Exámen antes de ser implementada!


Para que funcione la visualización, Usted necesitará tener activada alguna manera para mostrar expresiones TeX en su sitio Moodle: ya sea el Filtro TeX o el Filtro MathJax habilitado.

Tome nota de que el nuevo método para mostrar una fórmula de respuesta formateada "Usando solicitud AJAX dinámica" solamente funciona con el Filtro MathJax.

Formulación de la pregunta

To create a new Algebra question, go to the Question Bank and click on "Create a new question ..."

Some fields (Question name, Question text, Default Mark, General Feedback) on the question edit page are common to all question types so they don't need special explanation.

But some other are specific to the Algebra question type.

Expand the Options section.

Algoritmo de comparación

First you define which comparison method is used to determinate if the student answer is correct or not and grade it, three method are provided:

  1. Evaluation
  2. Sage
  3. Equivalence


This is the default and best tested method. It's also the easier to understand. It "cheats" by evaluating both the answer and the student response for various random combinations of the variable's values and ensures that both match to within tolerance at all points.

You can specify the number of random values that will be generated for the test (more is better but also slower !) in the Number of Evaluation Checks field (default: 10) and the tolerance in the Tolerance for Evaluation Checks field (default 0.001).

If you plan to use this method, you must understand that it is not bulletproof and maybe not what you want.

As long as the student entered answer and the teacher provided answer take the same values for all random values of the variables generated by the plugin, the student answer will be considered as correct. For instance 2*x and x+x are considered as identical.


This method requires the external, open source Sage symbolic algebra system to be installed on a server. A simple XMLRPC server script in Python is included in the package, sage_server.py, and this provides a method to symbolically compare two expressions.

From a theorical point of view this method is surely the best one. But it's also the uneasiest one because it require an external server and depending on the way your Moodle server is hosted this may or may not be possible.

If you absolutely need that sort of mathematic question and answer verification, it is suggested that you look at a more modern, more secure and more powerful question type, the Tipo de pregunta STACK


This uses the internal PHP algebra parser included in the parser to compare the two expressions. It was intended for use in "expand..." and "factor..." type questions where a full symbollic comparison would allow the student to enter the unexpanded (or unfactorized) expression.

The usage of this comparison method has received few testing and no users of the Moodle Quiz forum reported using it. So it is suggested to be very cautious if you plan to use it on a production server.

As a general rule it is recommended that you stick with the Evaluation comparison method unless very special need and that you know what you are doing.

Prefijo de caja de respuesta

If you want some text displayed before the answer input box, you can type it here. For instance in a question about functions you can type f(x) = so that the student knows what to answer. See an example on one of the screenshots bellow.

Respuesta prohibida

You can type here a comma separated list of words that will be forbidden in student's answers. For instance if you type here pi, max students will not receive any grade for answer including one of these words.

Funciones Permitidas

Here you can choose what functions will be allowed (default: All) in student answer.


All Algebra question must include at least one variable and all defined variable must be used in at least one answer.

You must provide a variable name and if you use the Evaluation method a Minimum and Maximum value (SAGE and Equivalence methods don't use these values they are only used by the Evaluation method)

El nombre de la variable debe de escribirse usando sintaxis lineal, no la sintaxis TeX. Si el nombre d ela variable tiene más de un carcater, el resto es usado como subscripto, por lo que la variable definida como xp será mostrada como , y entonces x1 será mostrada como

You can also use greek names as variables names with or without a subscript, theta1 for instance will be displayed as


This is where you defines the answer and their matching grade. Nuevamente, Usted deberá usar notación sintaxis lineal.

You may choose to give different answers with different values for the grade, but it is required that an answer with the highest grade is included.

Answer can only use varables names defined in the Variables section of the form and all defined variables must be used by at least one answer.


We create a new Algebra question entering these values in the General section

edit algebra question 1.png

The formulas in the Question text and General feedback were typed using The Equation editor and will be latter rendered by the MathJax or TeX filter.

We now expand the Options section and enter the following values (most of them are default)

edit algebra question 2.png

We now create one variable named x that will take values between -5 and 5 when the Evaluation comparison method will be used to grade student answers

edit algebra question 3.png

And finally we create 2 answers the first one is for the correct answer and the second one for students that forgot the 2 and we choose to give them some little reward anyway :-)

edit algebra question 4.png

The student answer does not have to be exactly this, only shall be evaluated to (very similar) values. For instance, the equivalent answer x + x would evaluate correctly and gives full mark.

The question is now finished we can save it and test it

Si Usted usa la configuración antigua de "Usando un iframe" ´para mostrar fórmula, se verá de este modo:

algebra question test.png

Y si Usted usa la nueva configuración "Usando solicitud AJAX dinámica" para mostrar fórmula, se verá así:

qtype algebra attempt.png

Características Actuales

  • The students enter responses in a text box, like calculated and numeric questions. They use the sintaxis lineal notation. They don't need to know the TeX syntax and they must not use the equation editor.
  • The formula they entered is rendered in the box below by clicking on the Display response button.
  • Option of three different comparison methods: SAGE, Evaluation or Equivalence.
  • Support for multiple answers so partial credit or assistance can be provided to students.
  • Except for the SAGE comparison method core functionality works entirely within Moodle, so it can be used without installing any other program.
  • Works with Moodle 2.8 and up to Moodle 3.4.

Nuevas Características que aparecerán pronto

Nota: Pendiente de Traducir. ¡Anímese a traducir esta página!.     ( y otras páginas pendientes)

The original documentation listed here some new features that Roger Moore planned to add. But this was never done so they have been removed. If you ave any idea on how to improve this question type, please create an issue in the tracker.

Uso de Álgebra en preguntas combinadas

Since version 1.9 it is possible to include Algebra questions as parts of a combined question. You will need to install the combined question type. The placeholder for the algebra subquestion in the combined question text follow the


pattern where <identifier> may be alphanumeric up to 8 characters and <type> is algebra. After you press the "Verify the question text and update the form" button, you will be able to edit the details of the algebra subquestion. There are some limitations from a standalone algebra question:

  • There is no Answer box prefix because you can write what you want in the combined question text before the algebra subquestion.
  • Allowed Functions is always "All" as this feature was never implemented
  • Each answer grade is always 100% and there is no answer feedback, only a global feedback for the subquestion when the student response is not correct

In the mobile app

Since version 1.9 the Algebra question type includes code for the Mobile App. If you access a quiz with the mobile app that contains Algebra questions it will be automatically loaded as a remote addon. Unfortunately currently there is only a field to enter the response, and no display of the result as a LaTeX formula. This is only working with Moodle 3.5 and ulterior versions.

En la App mobile

Since version 1.9 the Algebra question type includes code for the Mobile App. If you access a quiz with the mobile app that contains Algebra questions it will be automatically loaded as a remote addon. Unfortunately currently there is only a field to enter the response, and no display of the result as a LaTeX formula. This is only working with Moodle 3.5 and ulterior versions.

Instalación del tipo de pregunta

El tipo de pregunta Algebra es un plugin de Moodle, por lo que Usterd o su administrador necesita instalarla.

Installing from the Moodle Plugins directory (this is the recommanded and easiest method)

The Algebra question type is available from the Moodle Plugins drectory. Install the Algebra question type as any other Moodle question type plugin.

Installing from GitHub

The Algebra question is available at the maintainer's Github repository. To install the question, type the following commands in the root of your Moodle install:

  git clone git://github.com/jmvedrine/moodle-qtype_algebra.git question/type/algebra echo '/question/type/algebra/' >> .git/info/exclude
  echo '/question/type/algebra/' >> .git/info/exclude

Installing from a zip file

Download the zip file from GitHub. Unzip the file in the 'question/type' folder and then rename the new folder to just 'algebra'.

During installation you will be prompted for new Administrator settings algebra settings.png

It is suggested that you don't change the Default comparison method (Teachers can change it on a per question basis if they want and an Administrator can change the default later)

You can ignore the 3 settings related to SAGE server unless you plan to use the SAGE comparison method and you know what you do.

According to the way LaTeX and TeX formulas are displayed on your website it may be necessary to change the delimiters for TeX expressions from the default $$ ... $$ to \[ ...\] or $ ... $ or \( ... \). This setting is only used used to display the formatted answer on the question view during attempt, and also to display the formatted correct answer after the question is submitted. It is not used to display formulas in question text, General feedback and everywhere else

The TeX operator for multiplication setting control the symbol used to display multiplication either times or cdot .

NB: If you wish to test the current Sage functionality you will also need to install Sage on a server as well as run the python server code with the command "sage - python sage_server.py".

Solución de problemas

  • Failed to load question options from the table qtype_algebra_options for questionid <n>: this usually occurs because you tried to add an algebra question into Moodle without having propertly installed the algebra plugin, so the tables for the question type have not been added to the database. Any existing algebra questions that were added (via editing or import) before this is corrected will need to be deleted since they are missing important information and are broken.

Sintaxis Lineal

To use this question type, you must understand that there are 2 very different syntax that are used.

When creating the question, when you type something into the different editors on the question edit page (Question text, General feedback, ...), you do as usual, if you want to enter some mathematical formula, you use the equation editor or you type some TeX formulas as you would do in a forum post, a lesson or a description.

But when you enter a formula in the Answer 1, Answer 2, ... fields the situation is quite different . These formulas must be parsed by the formula question code so a special syntax is used here and TeX syntax must not be used here.,

El tipo de pregunta algebra usa lo que se llama sintaxis lineal para ingresar fórmulas matemáticas : *, +, -, /, /, (, [, ], ), pi, e, y las funciones conocidad sqrt, log, ln, sin, cos, tan, cosh, sinh, asin, acos, atan son usadas.

Variables can be uppercase and lowercase letters, Greek letters are recognized and subscripts too, for instance if you type u1 it will be interpreted as and alpha3 will be recognized as

Obviously e and pi can't be variables names as they are already constants but they can be used in answer formulas.

Currently a bug in the parser prevent the use of the Greek letter epsilon as a variable name because the first letter is confused with the e constant.

Some examples:

  • 2 x (equivalent to 2*x)
  • e^x
  • 2*pi*x
  • cos(x)+sin(y)
  • sqrt(b^2 - 4 a c)
  • alpha^3-beta^3

When they attempt the Algebra question , your students will need to use the same sintaxis lineal. Don't be afraid of that, they are already using it when they are talking about math and exchanging answers with their phones ;-)

Vea también