« Formules: Variables dans le texte et dans les équations du texte » : différence entre les versions

De MoodleDocs
Aller à :navigation, rechercher
Ligne 12 : Ligne 12 :
</pre>
</pre>


==Using variables in text equations==
==Utilisation de variables dans des équations du texte==


Text equations are mathematical expressions or equations that are displayed in the text using math syntax such as:
Text equations are mathematical expressions or equations that are displayed in the text using math syntax such as:

Version du 20 janvier 2018 à 02:57

Remarque : la traduction de cette page n'est pas terminée. N'hésitez pas à traduire tout ou partie de cette page ou à la compléter. Vous pouvez aussi utiliser la page de discussion pour vos recommandations et suggestions d'améliorations.


Utiliser des variables dans le texte

Il est facile d'insérer des valeurs de variable directement dans le texte. Tout ce qui est nécessaire est d'entourer les noms de variable avec {}. Chaque champ de texte a une portée de variables. Toutes les variables x de nombre ou de chaîne dans la portée du texte peuvent être utilisées pour remplacer l'espace réservé {x} correspondant dans le texte.

Il est également possible d'évaluer une expression et d'insérer sa valeur directement dans le texte en ajoutant un signe égal au début de l'accolade tel que {=x/1000}. Cette méthode est plus simple si les variables nommées ne sont pas requises. Cependant, aucune vérification d'erreur n'est effectuée à moins que la question ne soit instanciée dans le test. Un exemple est la mise à l'échelle des mètres en kilomètres ci-dessous :

Quelle est la vitesse de la fusée si elle parcourt {=x/1000} km en {t} s ?

Utilisation de variables dans des équations du texte

Text equations are mathematical expressions or equations that are displayed in the text using math syntax such as:

See Equation Construction and Display for additional information on writing mathematical expressions.

Values of variables can be inserted in text equations in the same way as in the text, that is, by enclosing the variable names with {}. Values of expressions such as {=x/1000} can also be inserted.

Example

Write the following equation in TeX syntax. Upon display, {a}, {b} and {c} will be substituted by the value of these variables:

{a}x2 + {b}x + {c} = 0
\( {a} x^2 + {b} x + {c} = 0 \)
Example

Write the following equation in MathML syntax. Upon display, {a}, {b} and {c} will be substituted by the value of these variables:

{a}x2 + {b}x + {c} = 0
«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»
  «mn»{a}«/mn»
  «msup»«mi»x«/mi»«mn»2«/mn»«/msup»
  «mo»+«/mo»
  «mn»{b}«/mn»
  «mi»x«/mi»
  «mo»+«/mo»
  «mn»{c}«/mn»
  «mo»=«/mo»
  «mn»0«/mn»
«/math»

MathML equations are usually created with the aid of an editor. When creating the equation with an editor, it is easier to write a number, say 99, in lieu of the variables, for example:

«math xmlns=¨http://www.w3.org/1998/Math/MathML¨»
  «mn»99«/mn»
  «msup»«mi»x«/mi»«mn»2«/mn»«/msup»
  «mo»+«/mo»
  «mn»99«/mn»
  «mi»x«/mi»
  «mo»+«/mo»
  «mn»99«/mn»
  «mo»=«/mo»
  «mn»0«/mn»
«/math»

and then replace the numbers 99 by the variables {a}, {b} and {c} in the HTML code.

Example

Write the following equation in the AsciiMath syntax. Upon display, {a}, {b} and {c} will be substituted by the value of these variables:

{a}x2 + {b}x + {c} = 0
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=AM_HTMLorMML"></script>
`{a} x^2 + {b} x + {c} = 0`
Example

Use variables and expressions in text equations that appear in the main question text, the general feedback and the part's feedback of a Formulas question. Use MathML syntax.

Downloadable question file: QuadraticEquation.xml

This Formulas question looks like this:

Fichier:QuadraticEquation.png


Accéder au haut de la page

← QUESTION DE TYPE FORMULES

Autres langues

English
Español