<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/37/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hig</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/37/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hig"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/Special:Contributions/Hig"/>
	<updated>2026-04-09T07:52:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/37/en/index.php?title=MySQL&amp;diff=134858</id>
		<title>MySQL</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/index.php?title=MySQL&amp;diff=134858"/>
		<updated>2019-07-28T03:48:14Z</updated>

		<summary type="html">&lt;p&gt;Hig: /* Configure full UTF-8 support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
MySQL is one of the supported databases that underpins a Moodle installation. &lt;br /&gt;
&lt;br /&gt;
== Installing MySQL ==&lt;br /&gt;
&lt;br /&gt;
* If you are running Linux your preference should be to install using your distribution&#039;s package manager. This ensures you will get any available updates.  However, you can also use apt-get or yum depending on the distribution that you are running.&lt;br /&gt;
* There are installers available for most popular operating systems at http://www.mysql.com/downloads/mysql/.&lt;br /&gt;
* It is possible and reasonably straightforward to build mysql from source but it is not recommended (the pre-built binaries are supposedly better optimised).&lt;br /&gt;
* Make sure you set a password for the &#039;root&#039; user (see http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html).&lt;br /&gt;
* Consider installing and configuring my.cnf (the MySQL settings file) to suit your needs. The default configuration is usually very conservative in respect of memory usage versus performance. Increase the &#039;max_allowed_packet&#039; setting to at least 4 megabytes.&lt;br /&gt;
* If you are going to use Master/Slave replication, you must add binlog_format = &#039;ROW&#039; into your my.cnf within [mysqld]. Otherwise, Moodle will not be able to write to the database.&lt;br /&gt;
&lt;br /&gt;
=== Configure full UTF-8 support ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s recommended that you have full UTF-8 support configured in MySQL. If this is not done some character sets, notably emojis, cannot be used. It is possible to do this after your site is installed but it is much easier before installation.&lt;br /&gt;
&lt;br /&gt;
First check if this is already configured by running the following statement, e.g. at the &#039;&#039;&#039;mysql&amp;gt;&#039;&#039;&#039; prompt or in phpMyAdmin:&lt;br /&gt;
&amp;lt;pre&amp;gt;SHOW GLOBAL VARIABLES WHERE variable_name IN (&#039;innodb_file_format&#039;, &#039;innodb_large_prefix&#039;, &#039;innodb_file_per_table&#039;);&amp;lt;/pre&amp;gt;&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Variable_name&lt;br /&gt;
! Value&lt;br /&gt;
|-&lt;br /&gt;
| innodb_file_format&lt;br /&gt;
| Barracuda&lt;br /&gt;
|-&lt;br /&gt;
| innodb_file_per_table&lt;br /&gt;
| ON&lt;br /&gt;
|-&lt;br /&gt;
| innodb_large_prefix&lt;br /&gt;
| ON&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
If the three settings you see match the above list then no further configuration changes are needed and you can skip to [[#Creating_Moodle_database| Creating Moodle database]].&lt;br /&gt;
&lt;br /&gt;
If your settings do not match this list then you will have to edit your MySQL configuration file. On Linux this may be the file &#039;&#039;&#039;/etc/my.cnf&#039;&#039;&#039; or &#039;&#039;&#039;/etc/mysql/my.cnf&#039;&#039;&#039;, on Microsoft Windows it may be &#039;&#039;&#039;my.ini&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
* Note: You should back up your configuration file before changing it.&lt;br /&gt;
* Note: You should back up your databases before making this change.&lt;br /&gt;
* Note: Other systems using databases on this server may be impacted by this change.&lt;br /&gt;
&lt;br /&gt;
Add the following settings to the configuration file:&lt;br /&gt;
&amp;lt;pre&amp;gt;[client]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&lt;br /&gt;
[mysqld]&lt;br /&gt;
innodb_file_format = Barracuda&lt;br /&gt;
innodb_file_per_table = 1&lt;br /&gt;
innodb_large_prefix = 1&lt;br /&gt;
&lt;br /&gt;
character-set-server = utf8mb4&lt;br /&gt;
collation-server = utf8mb4_unicode_ci&lt;br /&gt;
skip-character-set-client-handshake&lt;br /&gt;
&lt;br /&gt;
[mysql]&lt;br /&gt;
default-character-set = utf8mb4&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Restart MySQL to apply these settings.&lt;br /&gt;
&lt;br /&gt;
If you have any difficulty applying these settings, see [[MySQL_full_unicode_support]] for further information.&lt;br /&gt;
&lt;br /&gt;
If for some reason you cannot change to the recommended settings as described here you can continue to install Moodle, however you must select &#039;&#039;&#039;utf8&#039;&#039;&#039; and &#039;&#039;&#039;utf8_unicode_ci&#039;&#039;&#039; for the default character set and collation respectively.&lt;br /&gt;
&lt;br /&gt;
== Creating Moodle database ==&lt;br /&gt;
&lt;br /&gt;
These are the steps to create an empty Moodle database. Substitute your own database name, user name and password as appropriate.&lt;br /&gt;
&lt;br /&gt;
The instructions assume that the web server and MySQL server are on the same machine. In this case the &#039;dbhost&#039; is &#039;localhost&#039;. If they are on different machines substitute the name of the web server for &#039;localhost&#039; in the following instructions and the &#039;dbhost&#039; setting will be the name of the database server. &lt;br /&gt;
Databases have a &amp;quot;Character set&amp;quot; and a &amp;quot;Collation&amp;quot;. For Moodle, we recommend the Character Set be set to &#039;&#039;&#039;utf8mb4&#039;&#039;&#039; and the Collation &#039;&#039;&#039;utf8mb4_unicode_ci&#039;&#039;&#039;. You may get the option to set these values when you create the database. If you are not given a choice, the default options are probably good. An install on an old server may have the wrong settings.&lt;br /&gt;
&lt;br /&gt;
=== Command line === &lt;br /&gt;
&lt;br /&gt;
* To create a database using the &#039;mysql&#039; command line client, first log into MySQL&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ mysql -u root -p&lt;br /&gt;
Enter password: &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(Enter the password you previously set - or been given - for the MySQL &#039;root&#039; user). After some pre-amble this should take you to the &#039;&#039;mysql&amp;gt;&#039;&#039; prompt.&lt;br /&gt;
* Create a new database (called &#039;moodle&#039; - substitute your own name if required).&lt;br /&gt;
If you have successfully configured the recommended full UTF-8 support as described above run:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you do not have the recommended full UTF-8 support run:&lt;br /&gt;
&amp;lt;pre&amp;gt;mysql&amp;gt; CREATE DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Add a user/password with the minimum needed permissions:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO moodleuser@localhost IDENTIFIED BY &#039;yourpassword&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
...which creates a user called &#039;moodleuser&#039; with a password &#039;yourpassword&#039;. Make sure you invent a strong password and resist the temptation to &#039;GRANT ALL&#039;.&lt;br /&gt;
* Exit from mysql:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; quit&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
[http://www.phpmyadmin.net/ phpMyAdmin] is a web based administration tool for MySQL. If this is available you can use it to create a new database. If you have successfully configured the recommended full UTF-8 support as described above select collation &#039;&#039;&#039;utf8mb4_unicode_ci&#039;&#039;&#039;. If you do not have the recommended full UTF-8 support select collation &#039;&#039;&#039;utf8_unicode_ci&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Which database belongs to which Moodle==&lt;br /&gt;
If you have installed several Moodle installations on the same server, there will be several databases in your MySQL server. The names might be quite poor reflections of the content like  _mdl1 _mdl2 _mdl3 . So how do I see which database goes with which Moodle installation? You can go in with phpMyAdmin and in the various databases check for the table &amp;quot;mdl_course&amp;quot;. There you will easily see the name of that Moodle Installation. In table mdl_config you can see the Moodle version. The main URL for the site is not in the database except where there are absolute links.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[MariaDB]]&lt;br /&gt;
* [[MySQL full unicode support]]&lt;br /&gt;
* [http://www.mysql.com/ The MySQL homepage]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/MySQL Wikipedia article about &#039;&#039;MySQL&#039;&#039;]&lt;br /&gt;
* [http://forums.mysql.com/read.php?24,92131,92131 List of articles on MySQL performance tuning]&lt;br /&gt;
&lt;br /&gt;
[[Category:SQL databases]]&lt;br /&gt;
&lt;br /&gt;
[[ja:MySQL]]&lt;br /&gt;
[[de:MySQL]]&lt;br /&gt;
[[es:MySQL]]&lt;/div&gt;</summary>
		<author><name>Hig</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/37/en/index.php?title=Calculated_question_type&amp;diff=129278</id>
		<title>Calculated question type</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/index.php?title=Calculated_question_type&amp;diff=129278"/>
		<updated>2017-11-10T23:04:41Z</updated>

		<summary type="html">&lt;p&gt;Hig: /* Page 1. Editing a Calculated question */ Reflect the text description above in this page and the code https://github.com/moodle/moodle/blob/master/question/type/numerical/question.php&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questions}}&lt;br /&gt;
Calculated questions offer a way to create individual numerical questions by the use of wildcards  (i.e you can use common variables names as &#039;&#039;&#039;x&#039;&#039;&#039; , &#039;&#039;&#039;y&#039;&#039;&#039;  enclosed  in curly braces  to create the  wildcards &#039;&#039;&#039;{x}&#039;&#039;&#039; and &#039;&#039;&#039;{y}&#039;&#039;&#039;) that are substituted with random values when the quiz is taken.&lt;br /&gt;
 &lt;br /&gt;
For example, if you want to create a large number of &#039;&#039;&#039;&amp;quot;Calculate the area of a rectangle&amp;quot;&#039;&#039;&#039; problems to drill your students, you could create a question with two wildcards (i.e. &#039;&#039;&#039;{base}&#039;&#039;&#039;, &#039;&#039;&#039;{height}&#039;&#039;&#039; created from the common &#039;&#039;&#039;base&#039;&#039;&#039;, &#039;&#039;&#039;height&#039;&#039;&#039; variable names)  and put in the &amp;quot;&#039;&#039;&#039;Correct Answer Formula=&#039;&#039;&#039;&amp;quot; input field  &#039;&#039;&#039;{base}&#039;&#039;&#039; * &#039;&#039;&#039;{height}&#039;&#039;&#039; ( * being the multiplication sign ).&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;Correct Answer Formula=&#039;&#039;&#039; {base}*{height}&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
When a student takes the test, Moodle will randomly select values for &#039;&#039;&#039;{base}&#039;&#039;&#039; and &#039;&#039;&#039;{height}&#039;&#039;&#039; and grade the response using the result of the &#039;&#039;&#039;Correct Answer Formula&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
The test will very rarely appear the same way twice.&lt;br /&gt;
&lt;br /&gt;
== Is this really the question type for you? ==&lt;br /&gt;
The main purpose of the calculated question is to create multiple versions of a question with different numerical values. This means you must have &#039;&#039;&#039;at least one&#039;&#039;&#039; wildcard in one of the answers.&lt;br /&gt;
 &lt;br /&gt;
If you don&#039;t need a random element, use the [[Numerical question type]] instead.&lt;br /&gt;
== Simple calculated question type   ==&lt;br /&gt;
&lt;br /&gt;
The [[Simple calculated question type|simple calculated]] question offers the most used features of the calculated question with a much simpler creation interface.&lt;br /&gt;
&lt;br /&gt;
==Wildcards and datasets==&lt;br /&gt;
&lt;br /&gt;
When Moodle delivers a Calculated question to the student, the wildcards are replaced with randomly-selected values. However, these values are not completely random - rather, they are randomly selected from a pre-defined &#039;&#039;dataset&#039;&#039; of possible values. This allows you some control over the possible values chosen - for example, in order to make sure the numbers are realistic.&lt;br /&gt;
&lt;br /&gt;
These datasets can be &#039;&#039;private&#039;&#039; or &#039;&#039;shared&#039;&#039; - private datasets are used by one wildcard within one calculated question; shared datasets are used by one wildcard within all calculated questions that use it.&lt;br /&gt;
&lt;br /&gt;
==Question set-up==&lt;br /&gt;
To create (or modify) a calculated question there are three pages to work through. The instructions below take you through the pages, step by step:&lt;br /&gt;
&lt;br /&gt;
===Page 1. Editing a Calculated question ===&lt;br /&gt;
&lt;br /&gt;
#Select the question &#039;&#039;&#039;category&#039;&#039;&#039;&lt;br /&gt;
#Any shared wildcards for this category are listed beneath. If you change category, you&#039;ll need to click the &amp;quot;Update the category&amp;quot; button to refresh this list. There may not be any shared wildcards yet - if not, you can create them later if you wish.&lt;br /&gt;
#Give the question a descriptive &#039;&#039;&#039;name&#039;&#039;&#039; - this allows you to identify it in the question bank.&lt;br /&gt;
#Enter the &#039;&#039;&#039;question text&#039;&#039;&#039;. This should be the question you want the student to answer, and it must include all the information they need to calculate an answer. Therefore it must contain at least one wildcard, inside curly braces. For example, if you wanted the student to sum numbers A and B, the question text might read: &amp;quot;What is {A} + {B}?&amp;quot; You may also include quantities computed from wildcards using the syntax &amp;quot;{=...}: for example, the question &amp;quot;What is {={A}+{B}} - {A}?&amp;quot; with wildcard values A=4 and B=3 would display as &amp;quot;What is 7 - 4?&amp;quot;&lt;br /&gt;
#Select an image to display if you want to add a picture to the question. For the student, it appears immediately after the question text and before the choices. If you want more control over how the image appears, include it in the question text above, using the HTML editor.&lt;br /&gt;
#Set the &#039;&#039;&#039;default question grade&#039;&#039;&#039; (i.e. the maximum number of marks for this question).&lt;br /&gt;
#Set the &#039;&#039;&#039;Penalty factor&#039;&#039;&#039; (see [[Calculated_question_type#Penalty_factor|Penalty factor]] below).&lt;br /&gt;
#&#039;&#039;Moodle 1.7+:&#039;&#039; If you wish, add general feedback. This is text that appears to the student after he/she has answered the question.&lt;br /&gt;
#Next add the &#039;&#039;&#039;formula for the answer&#039;&#039;&#039;. This formula must contain at least the wildcards that appear in the question text. See [[Calculated_question_type#Correct_answer_formula_syntax|Correct answer formula syntax]] for further details.&lt;br /&gt;
# Choose the &#039;&#039;&#039;grade&#039;&#039;&#039; that the student will get for this question if they give this answer. This should be a percentage of the total marks available. For example, you could give 100% for a correct answer, and 50% for an answer that is nearly right. &#039;&#039;&#039;One of the answers must have a 100% grade&#039;&#039;&#039;.&lt;br /&gt;
#Determine the &#039;&#039;&#039;tolerance&#039;&#039;&#039; for error that you will accept in the answer. The tolerance and tolerance type settings combine to give a range of acceptable scores. So, if tolerance = t, correct answer = x and the difference between the user&#039;s answer and the correct answer is dx, then the tolerance types are as follows:&lt;br /&gt;
##Nominal - mark correct if |dx| &amp;lt;= t&lt;br /&gt;
##Relative - mark correct if |dx| / x &amp;lt;= t&lt;br /&gt;
##Geometric - mark correct if x/(1+t) &amp;lt;= (x+dx) &amp;lt;= x*(1+t) &lt;br /&gt;
# The next 2 settings, &amp;quot;Correct answer shows&amp;quot; and &amp;quot;Format&amp;quot; determine the &#039;&#039;&#039;precision&#039;&#039;&#039; of the answer. Use these to select the number of decimal places or significant figures you want to use.&lt;br /&gt;
# Add some &#039;&#039;&#039;feedback&#039;&#039;&#039; which the student will see if they enter this answer.&lt;br /&gt;
# You can specify as many answer formulae as you like - click &amp;quot;Add another answer blank&amp;quot; to add more.&lt;br /&gt;
# You can also specify units for the answers. For example, if you enter a unit of &#039;cm&#039; here, and the accepted answer is 15, then the answers &#039;15cm&#039; and &#039;15&#039; are both accepted as correct. If you add more than one unit, you can also specify a multiplier. So, if your main answer was 5500 with unit W, you can also add the unit kW with a multiplier of 0.001. This means that the answers &#039;5500&#039;, &#039;5500W&#039; or &#039;5.5kW&#039; would all be marked correct. Note that the accepted error is also multiplied, so an allowed error of 100W would become an error of 0.1kW.&lt;br /&gt;
# Finally (!) you can click &amp;quot;Next page&amp;quot; to save what you&#039;ve done and move on. If you are editing an existing question, you can click &amp;quot;Next page (new question)&amp;quot; to create a completely new question based on an existing one.&lt;br /&gt;
&lt;br /&gt;
==== Penalty factor ====&lt;br /&gt;
&lt;br /&gt;
The &#039;penalty factor&#039; only applies when the question is used in a quiz using adaptive mode - i.e. where the student is allowed multiple attempts at a question even within the same attempt at the quiz. If the penalty factor is more than 0, then the student will lose that proportion of the &#039;&#039;&#039;maximum&#039;&#039;&#039; grade upon each successive attempt. For example, if the default question grade is 10, and the penalty factor is 0.2, then each successive attempt after the first one will incur a penalty of 0.2 x 10 = 2 points.&lt;br /&gt;
&lt;br /&gt;
===Tolerance===&lt;br /&gt;
&lt;br /&gt;
As for numerical questions it is possible to allow a margin within which all responses are accepted as correct. The &amp;quot;Tolerance&amp;quot; field is used for this. However, there are three different types of tolerances. These are Relative, Nominal and Geometric. If we say that the correct answer at quiz time is calculated to 200 and the tolerance is set to 0.5 then the different tolerance types work like this:&lt;br /&gt;
&lt;br /&gt;
Relative: A tolerance interval is calculated by multiplying the correct answer with 0.5, ie in this case we get 100 so for this tolerance the correct response must be between 100 and 300. (200 ± 100)&lt;br /&gt;
This is useful if the magnitude of the correct answer can differ greatly between different wildcard values.&lt;br /&gt;
&lt;br /&gt;
Nominal: This is the simplest tolerance type but not very powerful. The correct response must be between 199.5 and 200.5 (200 ± 0.5)&lt;br /&gt;
This tolerance type can be useful if the differences between different correct answers are small.&lt;br /&gt;
&lt;br /&gt;
Geometric: The upper limit of the tolerance interval is calculated as 200 + 0.5*200 and is the same as for the relative case. The lower limit is calculated as 200/(1 + 0.5). The correct response must then be between 133.33 and 300.&lt;br /&gt;
This is useful for complex calculation that must have great tolerances where relative tolerances of 1 or more would be used for the upper limit but clearly not acceptable for the lower limit as it would make zero a correct answer for all cases.&lt;br /&gt;
&lt;br /&gt;
The field Significant Figures does only relate to how the correct answer should be presented in the review or the reports. Examples: If it is set to 3 then the correct answer 13.333 would be presented as 13.3; 1236 would be presented as 1240; 23 would be presented as 23.0 etc. &lt;br /&gt;
&lt;br /&gt;
===Page 2. Choose dataset properties ===&lt;br /&gt;
&lt;br /&gt;
Each wildcard that you specify in the answer formula must have an associated set of possible values - this is its &#039;&#039;dataset&#039;&#039;. Each of the wildcards is listed on this page along with a choice of dataset:&lt;br /&gt;
*&#039;&#039;&#039;private&#039;&#039;&#039; i.e. only used by this question&lt;br /&gt;
*&#039;&#039;&#039;shared&#039;&#039;&#039; i.e shared with other calculated questions in the same category&lt;br /&gt;
&lt;br /&gt;
Using a shared dataset can save time when you are creating a lot of similar calculated questions.&lt;br /&gt;
&lt;br /&gt;
Note that even when creating a question for the first time, this page may say that your wildcard &amp;quot;will use the same existing private dataset as before.&amp;quot; This just means that Moodle has already tentatively created a private data set for that wildcard: if a private dataset is what you want, leave this choice selected.&lt;br /&gt;
&lt;br /&gt;
If there is anything in the question text that looks like a wildcard, but does not appear in any of the answer formulae, you can specify whether or not this is meant to be a wildcard. If it is, you can choose whether it should use a private or shared dataset.&lt;br /&gt;
&lt;br /&gt;
To continue, simply choose your preferred dataset for each wildcard, then click &amp;quot;Next Page&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Page 3. Edit the datasets ===&lt;br /&gt;
&lt;br /&gt;
Now we need to create the set of possible values that each wildcard can take. &#039;&#039;Warning&#039;&#039; - this page is a bit confusing!&lt;br /&gt;
&lt;br /&gt;
There are two ways of creating values - you can type them in yourself and add them to the list, or you can have Moodle generate them for you.&lt;br /&gt;
&lt;br /&gt;
==== Adding/deleting your own values ====&lt;br /&gt;
&lt;br /&gt;
Adding individual values to the list is easy:&lt;br /&gt;
&lt;br /&gt;
# In the &#039;Param&#039; field for each wildcard, enter the value you want&lt;br /&gt;
# Scroll down to the &#039;Add&#039; section and click the Add button (leaving the number of items set to 1)&lt;br /&gt;
# Repeat the above steps as many times as necessary (the maximum number of items is 100)&lt;br /&gt;
&lt;br /&gt;
To delete values from the list:&lt;br /&gt;
&lt;br /&gt;
# In the &#039;Delete&#039; section, select the number of items to delete&lt;br /&gt;
# Click the Delete button&lt;br /&gt;
&lt;br /&gt;
==== Letting Moodle create values ====&lt;br /&gt;
&lt;br /&gt;
# Start with the &amp;quot;Range of Values&amp;quot; fields, and enter the lower and upper limits for the values you would accept&lt;br /&gt;
# Choose a number of decimal places for the value&lt;br /&gt;
# Choose the distribution of values between the limits - &#039;uniform&#039; means any value between the limits is equally likely to be generated; &#039;loguniform&#039; means that values towards the lower limit are more likely.&lt;br /&gt;
# Now move down to the &#039;Add&#039; section and click on &amp;quot;force regeneration&amp;quot;&lt;br /&gt;
# In the menu next to the Add button, choose the number of sets of random values (items) you wish to add to the list. (Note that the maximum total number of items in your list is 100.)&lt;br /&gt;
# Finally, click Add to append the new values to the list&lt;br /&gt;
# &#039;&#039;&#039;Note:&#039;&#039;&#039; If you want more control over the items that Moodle adds, you can do them one at a time and preview the values before you add them. Click the &amp;quot;Get New Item to Add&amp;quot; button to make Moodle generate new values in the &amp;quot;Item to Add&amp;quot; section at the top. If you like them, click &amp;quot;Add&amp;quot; for 1 item; if not, click &amp;quot;Get New Item to Add&amp;quot; again to get new values.&lt;br /&gt;
&lt;br /&gt;
==== Finishing off ====&lt;br /&gt;
&lt;br /&gt;
Once your list of items (values) is complete, you are finished. It&#039;s up to you how many values you add - the more values you add, the more a question can be used by the students without them seeing the same values repeatedly.&lt;br /&gt;
&lt;br /&gt;
Note that if you delete values from the list, you can put them back again. Change the &amp;quot;Next Item to Add&amp;quot; option to &amp;quot;reuse previous value if available&amp;quot;, then the next time you add items, Moodle will restore your previously-deleted items from the dataset. &lt;br /&gt;
&lt;br /&gt;
Once your list of values is complete, you can click &#039;Save changes&#039; to finish.&lt;br /&gt;
&lt;br /&gt;
==== What does the &#039;Update the datasets parameters&#039; button do? ====&lt;br /&gt;
&lt;br /&gt;
Warning: This button can affect several questions, so be careful before using it.&lt;br /&gt;
Assume you have selected dataset parameter for {a} to be any value between 1-10 and generated a question. In the second question also you decide to use a SHARED wildcard called {a}. Inherently, it will show a value between 1-10. However, your need here changes and you want to make it 11-100 instead. Then, you change them in the range and click this button. Voila! the values change and you can add new items here using the &#039;Get New item to add&#039;. However, if you go back to your previous question, you will see that values would change there too, because it is a shared dataset. If you do not update parameters, then this may not happen and will generate a new set of values and displays them in the &amp;quot;Item to Add&amp;quot; section.&lt;br /&gt;
&lt;br /&gt;
==Correct answer formula syntax==&lt;br /&gt;
 &lt;br /&gt;
=== DO NOT PUT THE = sign in the formula. ===&lt;br /&gt;
 &lt;br /&gt;
* In the recent versions of the calculated question type, you could have more than one answer formula and applied a specific grading value to each of them as long as there is at least one 100% correct answer formula.&lt;br /&gt;
 If more than one correct answer formula input field are displayed when editing, &lt;br /&gt;
 your site has the multiple answer feature. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* As a general rule, write these formulas like you would in a calculator e.g. &amp;lt;code&amp;gt;3 + 5 * sin(3/{x})&amp;lt;/code&amp;gt; A notable exception is exponentiation, where x&amp;lt;sup&amp;gt;3&amp;lt;/sup&amp;gt; cannot be entered as &amp;lt;code&amp;gt;{x}^3&amp;lt;/code&amp;gt;, but instead should be entered as &amp;lt;code&amp;gt;pow({x}, 3)&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Each function&#039;s placeholders and other arguments should be in parentheses (brackets). For example, if you want students to calculate the sine of one angle and cosine of two times another angle, you would enter &amp;lt;code&amp;gt;sin({a}) + cos({b}*2)&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;sin({a}) + cos(2*{b})&amp;lt;/code&amp;gt;.&lt;br /&gt;
* It&#039;s usually better to have too many parentheses (brackets) than too few.  The server won&#039;t care, and the more specific you are about what you mean, the more likely it will like your complex formulas.&lt;br /&gt;
* There is no implicit multiplication.  To you, the human editor, &amp;quot;5(23)&amp;quot; or &amp;quot;5x&amp;quot; may seem perfectly obvious.  To the server doing the math, it&#039;s crazy talk and won&#039;t be understood.  Always use the &amp;quot;*&amp;quot; for multiplication.&lt;br /&gt;
* Any special mathematical function must have parentheses around its values.  Take the sine function in the first bullet point for instance.  Notice that the &#039;&#039;3 / x&#039;&#039; is wrapped in parentheses (brackets)--this is so the server can understand it properly.  Without those parentheses, the server won&#039;t know if you mean &amp;quot;(sin 3) / x&amp;quot; or &amp;quot;sin (3 / x)&amp;quot; and will reject the entire formula accordingly.&lt;br /&gt;
&lt;br /&gt;
==Available functions==&lt;br /&gt;
&lt;br /&gt;
Calculated questions can use more than simple arithmetic operators. The following functions are allowed in versions 1.5 and newer.&lt;br /&gt;
&lt;br /&gt;
{| width=&amp;quot;97%&amp;quot; border=&amp;quot;1px&amp;quot;&lt;br /&gt;
!Function&lt;br /&gt;
!Explanation&lt;br /&gt;
|-&lt;br /&gt;
|abs&lt;br /&gt;
|Absolute value&lt;br /&gt;
|-&lt;br /&gt;
|acos&lt;br /&gt;
|Arc cosine -- output in radians.&lt;br /&gt;
|-&lt;br /&gt;
|acosh&lt;br /&gt;
|Inverse hyperbolic cosine -- output in radians.&lt;br /&gt;
|-&lt;br /&gt;
|asin&lt;br /&gt;
|Arc sine -- output in radians.&lt;br /&gt;
|-&lt;br /&gt;
|asinh&lt;br /&gt;
|Inverse hyperbolic sine.-- output in radians.&lt;br /&gt;
|-&lt;br /&gt;
|atan2&lt;br /&gt;
|Arc tangent of two variables -- pass in two values like (y, x), and you&#039;ll get the atan(y/x), adjusted to the proper quadrant. (Note: The variables are in the reverse order to atan2(x,y) in Excel) Output is radians.&lt;br /&gt;
|-&lt;br /&gt;
|atan&lt;br /&gt;
|Arc tangent -- output in radians.   &lt;br /&gt;
|-&lt;br /&gt;
|atanh&lt;br /&gt;
|Inverse hyperbolic tangent-- output in radians.&lt;br /&gt;
|-&lt;br /&gt;
|bindec&lt;br /&gt;
|Binary to decimal&lt;br /&gt;
|-&lt;br /&gt;
|ceil&lt;br /&gt;
|Round fractions up&lt;br /&gt;
|-&lt;br /&gt;
|cos&lt;br /&gt;
|Cosine -- in radians!!!  Convert your degree measurement to radians before you take the cos of it.&lt;br /&gt;
|-&lt;br /&gt;
|cosh&lt;br /&gt;
|Hyperbolic cosine -- in radians!!!  Convert your degree measurement to radians before you take the cosh of it.&lt;br /&gt;
|-&lt;br /&gt;
|decbin&lt;br /&gt;
|Decimal to binary&lt;br /&gt;
|-&lt;br /&gt;
|decoct&lt;br /&gt;
|Decimal to octal&lt;br /&gt;
|-&lt;br /&gt;
|deg2rad&lt;br /&gt;
|Converts the number in degrees to the radian equivalent&lt;br /&gt;
|-&lt;br /&gt;
|exp&lt;br /&gt;
|Calculates the exponent of e&lt;br /&gt;
|-&lt;br /&gt;
|expm1&lt;br /&gt;
|Returns exp(number) - 1, computed in a way that is accurate even when the value of number is close to zero&lt;br /&gt;
|-&lt;br /&gt;
|floor&lt;br /&gt;
|Round fractions down&lt;br /&gt;
|-&lt;br /&gt;
|fmod&lt;br /&gt;
|Returns the floating-point modulus of two numbers - i.e. the remainder when the first is divided by the second.&lt;br /&gt;
|-&lt;br /&gt;
|is_finite&lt;br /&gt;
|Finds whether a value is a legal finite number&lt;br /&gt;
|-&lt;br /&gt;
|is_infinite&lt;br /&gt;
|Finds whether a value is infinite&lt;br /&gt;
|-&lt;br /&gt;
|is_nan&lt;br /&gt;
|Finds whether a value is not a number&lt;br /&gt;
|-&lt;br /&gt;
|log10&lt;br /&gt;
|Base-10 logarithm&lt;br /&gt;
|-&lt;br /&gt;
|log1p&lt;br /&gt;
|Returns log(1 + number), computed in a way that is accurate even when the value of number is close to zero&lt;br /&gt;
|-&lt;br /&gt;
|log&lt;br /&gt;
|Natural logarithm (&#039;&#039;ln&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|max&lt;br /&gt;
|Find highest value&lt;br /&gt;
|-&lt;br /&gt;
|min&lt;br /&gt;
|Find lowest value&lt;br /&gt;
|-&lt;br /&gt;
|octdec&lt;br /&gt;
|Octal to decimal&lt;br /&gt;
|-&lt;br /&gt;
|pi()&lt;br /&gt;
|Get value of pi - the function does not take an argument, like in Excel.&lt;br /&gt;
|-&lt;br /&gt;
|pow (numberToRaise, NumberRaisedTo)&lt;br /&gt;
|Exponential expression&lt;br /&gt;
|-&lt;br /&gt;
|rad2deg&lt;br /&gt;
|Converts the radian number to the equivalent number in degrees&lt;br /&gt;
|-&lt;br /&gt;
|rand&lt;br /&gt;
|Generate a random integer&lt;br /&gt;
|-&lt;br /&gt;
|round&lt;br /&gt;
|Rounds a float&lt;br /&gt;
|-&lt;br /&gt;
|sin&lt;br /&gt;
|Sine -- in radians!!!  Convert your degree measurement to radians before you take the sin of it.&lt;br /&gt;
|-&lt;br /&gt;
|sinh&lt;br /&gt;
|Hyperbolic sine -- in radians!!!  Convert your degree measurement to radians before you take the sinh of it.&lt;br /&gt;
|-&lt;br /&gt;
|sqrt&lt;br /&gt;
|Square root&lt;br /&gt;
|-&lt;br /&gt;
|tan&lt;br /&gt;
|Tangent -- in radians!!!  Convert your degree measurement to radians before you take the tan of it.&lt;br /&gt;
|-&lt;br /&gt;
|tanh&lt;br /&gt;
|Hyperbolic tangent -- in radians!!!  Convert your degree measurement to radians before you take the tanh of it.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Predefined constants==&lt;br /&gt;
Actually there is NO Predefined constant that is allowed other than pi() as a function without parameter.&lt;br /&gt;
&lt;br /&gt;
==Synchronization==&lt;br /&gt;
&lt;br /&gt;
You could use shared wild cards to get the same values across questions in a quiz.&lt;br /&gt;
&lt;br /&gt;
A simple example will be to use the same radius in a first question asking for the perimiter of a circle of {radius}cm and a second question asking for the surface of a circle of {radius}cm.&lt;br /&gt;
&lt;br /&gt;
When the quiz will be shown to the student the two questions will shown the same {radius} value.&lt;br /&gt;
&lt;br /&gt;
However the synchronization will work &#039;&#039;&#039;ONLY&#039;&#039;&#039; if the questions are kept in the &#039;&#039;&#039;SAME&#039;&#039;&#039; category and have the &#039;&#039;&#039;SAME NUMBER OF DATASETS&#039;&#039;&#039; .&lt;br /&gt;
&lt;br /&gt;
If you need to move the synchronized questions to another category, you need to do it by editing the questions.&lt;br /&gt;
&lt;br /&gt;
(This restriction should be released by sept. 2010).&lt;br /&gt;
&lt;br /&gt;
== I have a problem: The wild card values are reset when trying to add a new parameter==&lt;br /&gt;
* As described in MDL-37744 and [https://moodle.org/mod/forum/discuss.php?d=337851 this forum thread].&lt;br /&gt;
* You should perhaps take a look at the [[Formulas question type]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=150923 couple questions about &amp;quot;edit datasets page&amp;quot; in calculated questions] &lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=230558 Capital vs lower case letters with units]&lt;br /&gt;
&lt;br /&gt;
[[Category:Mathematics]]&lt;br /&gt;
&lt;br /&gt;
[[de:Berechnungsfragen]]&lt;br /&gt;
[[es:question/type/calculated]]&lt;br /&gt;
[[fr:Question calculée]]&lt;br /&gt;
[[zh:計算題]]&lt;br /&gt;
[[ja:計算問題タイプ]]&lt;/div&gt;</summary>
		<author><name>Hig</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/37/en/index.php?title=Using_web_services&amp;diff=117764</id>
		<title>Using web services</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/37/en/index.php?title=Using_web_services&amp;diff=117764"/>
		<updated>2015-03-29T09:41:58Z</updated>

		<summary type="html">&lt;p&gt;Hig: Update the old block name &amp;quot;Settings&amp;quot; to &amp;quot;Administration&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Web services}}&lt;br /&gt;
This document explains how an administrator can set up a web service for users to access a service. Each user will have a specific and unique security key (also known as a &amp;quot;token&amp;quot;) to access the service.&lt;br /&gt;
&lt;br /&gt;
== Enabling web services==&lt;br /&gt;
[[Image:Enable_web_service.jpg|thumb|Enabling web services]]&lt;br /&gt;
# Access &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Advanced features&#039;&#039;&lt;br /&gt;
# Check &#039;Enable web services&#039; then click &#039;Save Changes&#039;&lt;br /&gt;
&lt;br /&gt;
Note: For security reasons, web services should only be enabled if you intend to make use of it.&lt;br /&gt;
&lt;br /&gt;
== Enabling protocols ==&lt;br /&gt;
[[Image:Enable_protocol.jpg|thumb|left|Enabling protocols]]&lt;br /&gt;
Usually external applications that users wish to use dictate which protocols should be enabled. &lt;br /&gt;
&lt;br /&gt;
# Access &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Web services &amp;gt; Manage protocols&#039;&#039;&lt;br /&gt;
# Enable the protocols (SOAP, REST, XMLRPC, AMF, ...) as required&lt;br /&gt;
&lt;br /&gt;
== Enabling web service function documentation ==&lt;br /&gt;
[[Image:Security keys and documentation.jpg|thumb|Security keys page with documentation link]]&lt;br /&gt;
Enabling web service function documentation (also on the Manage protocols page) results in user-specific web service documentation being available for each user on their [[Security keys]] page. This option is mainly useful to web service client developers. If nobody is creating a web service client, there is no need to enable this feature.&lt;br /&gt;
&lt;br /&gt;
== Creating a service ==&lt;br /&gt;
If none of the pre-build web services match your needs, you can create a custom service i.e. select which of the standard web service functions are available via that service.&lt;br /&gt;
&lt;br /&gt;
You can enable only the specific functions that you need to expose, so not compromising on security.&lt;br /&gt;
[[Image:Create a service.jpg|thumb|Creating a service|left]]&lt;br /&gt;
# Access &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Web services &amp;gt; External services&#039;&#039;&lt;br /&gt;
# Click Add new custom service&lt;br /&gt;
#* &#039;Authorised users only&#039; - If enabled, you will need to select the authorised users manually. Otherwise all users with appropriate permissions are allowed&lt;br /&gt;
#* &#039;Required capability&#039; - If enabled, any user accessing the web service will be checked against this selected capability. (This is just an additional optional security layer.)&lt;br /&gt;
# Enter a name and check Enabled&lt;br /&gt;
# Click the button &#039;Add service&#039;&lt;br /&gt;
&lt;br /&gt;
==Adding functions to the service==&lt;br /&gt;
[[Image:Select a web service function.jpg|thumb|Adding functions to the service]]Your service is currently empty and doesn&#039;t do anything. Web service functions need to be added. Your choice will be dictated by what you allow the external application to do. For this example, select &#039;Create group&#039;.&lt;br /&gt;
&lt;br /&gt;
# Click &#039;Add functions&#039; link&lt;br /&gt;
# Select &#039;create group&#039; function and click the &#039;Add functions&#039; button&lt;br /&gt;
&lt;br /&gt;
You should be back to the service functions list. &#039;Required capabilities&#039; are indicated for each function. Users need the required capabilities to run a function. The function descriptions in the API Documentation can also give you more information about the required capabilities (&#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Web services &amp;gt; API Documentation&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==Enabling capabilities==&lt;br /&gt;
&lt;br /&gt;
The final step is to grant appropriate permissions. The following capabilities should be allowed:&lt;br /&gt;
&lt;br /&gt;
* [[Capabilities/moodle/webservice:createtoken|moodle/webservice:createtoken]] - for allowing users to generate a security key&lt;br /&gt;
* [[Capabilities/webservice/rest:use | webservice/rest:use]], [[Capabilities/webservice/soap:use | webservice/soap:use]], [[Capabilities/webservice/xmlrpc:use | webservice/xmlrpc:use]], [[Capabilities/webservice/amf:use | webservice/amf:use]] which match the enabled protocols.&lt;br /&gt;
* The service &#039;&#039;Required capability&#039;&#039; if set (&#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Web services &amp;gt; Manage services &amp;gt;&#039;&#039;&#039;Edit&#039;&#039;&#039; link&#039;&#039;).&lt;br /&gt;
* The required capabilities for the web service functions. These required capabilities are listed when you add a function to the service. For more information about roles and capabilities, read the [[Manage roles]] documentation.&lt;br /&gt;
&lt;br /&gt;
Once done, the web service should be set up. Users should be able to [[Security keys|obtain a personal security key]].&lt;br /&gt;
&lt;br /&gt;
= Alternative settings = &lt;br /&gt;
&lt;br /&gt;
== Authorise only specific users==&lt;br /&gt;
[[Image:Authorised users link.jpg|thumb]] [[Image:Authorised user selection page.jpg|thumb]]&lt;br /&gt;
# &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Plugins &amp;gt; Web services &amp;gt; External Services&#039;&#039;&lt;br /&gt;
# Select &#039;&#039;&#039;Authorised users&#039;&#039;&#039; link (the service must have been set as &#039;&#039;&#039;Authorised users only&#039;&#039;&#039; in the &#039;&#039;&#039;Edit&#039;&#039;&#039; link)&lt;br /&gt;
# Select some users and click &#039;&#039;&#039;Add&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Moodle indicates if some capabilities need to be assigned to an authorised user. Moreover if you click on the authorised user fullname, you can set up some specific options: &#039;&#039;IP restriction&#039;&#039; and &#039;&#039;Valid until&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Create a token  ==&lt;br /&gt;
[[Image:Create_token.jpg|thumb]]&lt;br /&gt;
This feature allows you to create a token for specific user. It can be useful if a user doesn&#039;t have the moodle/create:token capability. This is also the only way to create a token for an administrator. For security reason, tokens are not automatically generated in the administrator security  keys page.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Plugins &amp;gt; Web services &amp;gt; Manage tokens&#039;&#039;&lt;br /&gt;
# Click on &#039;&#039;&#039;Add&#039;&#039;&#039;&lt;br /&gt;
# Select the created user and service&lt;br /&gt;
# Click on &#039;&#039;&#039;Saves changes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
As you created a token for this user, you do not need to assign &amp;quot;&#039;&#039;moodle/webservice:createtoken&#039;&#039;&amp;quot; to him/her.&lt;br /&gt;
Finally, note that, as for authorised users, you can also set &#039;&#039;IP restriction&#039;&#039; and &#039;&#039;Valid until&#039;&#039; on a token.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
 		&lt;br /&gt;
*[http://www.joomdle.com/wiki/Preparing_Moodle_20#Setting_up_Moodle_Web_services Joomdle documentation about setting Moodle web services]&lt;/div&gt;</summary>
		<author><name>Hig</name></author>
	</entry>
</feed>