<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="sv">
	<id>https://docs.moodle.org/4x/sv/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fulano2040</id>
	<title>MoodleDocs - Användarbidrag [sv]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/4x/sv/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fulano2040"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/Special:Bidrag/Fulano2040"/>
	<updated>2026-05-15T22:56:32Z</updated>
	<subtitle>Användarbidrag</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24748</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24748"/>
		<updated>2007-06-30T00:42:21Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* question_dataset_definitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===question_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the question table, because the question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
 this can be 1=LITERAL 2=FILE 3=LINK&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===question_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The dataset_items table stores these possible values for the variables defined in the dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The question_datasets table is used by dataset dependent question types (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id from the question table&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id from the question_dataset_definitions table&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24747</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24747"/>
		<updated>2007-06-30T00:41:07Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* question_datasets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===question_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the question table, because the question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===question_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The dataset_items table stores these possible values for the variables defined in the dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The question_datasets table is used by dataset dependent question types (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id from the question table&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id from the question_dataset_definitions table&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24198</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24198"/>
		<updated>2007-06-13T17:52:29Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* question_dataset_items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===question_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the question table, because the question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===question_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The dataset_items table stores these possible values for the variables defined in the dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The question_datasets table is used by dataset dependent question types (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id from the question table&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id form the question_dataset_definitions&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24197</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24197"/>
		<updated>2007-06-13T17:51:40Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* question_dataset_items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===question_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the question table, because the question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===question_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The question_datasets table is used by dataset dependent question types (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id from the question table&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id form the question_dataset_definitions&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24196</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24196"/>
		<updated>2007-06-13T17:51:12Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* question_datasets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===question_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the question table, because the question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===question_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the quiz_dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The question_datasets table is used by dataset dependent question types (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id from the question table&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id form the question_dataset_definitions&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24195</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24195"/>
		<updated>2007-06-13T17:47:08Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* question_dataset_definitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===question_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the question table, because the question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===question_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the quiz_dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The quiz_question_datasets table is used by dataset dependent questionypes (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24194</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24194"/>
		<updated>2007-06-13T17:45:22Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* quiz_dataset_items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===question_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the quiz_questions table, because the quiz_question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===question_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the quiz_dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The quiz_question_datasets table is used by dataset dependent questionypes (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24193</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24193"/>
		<updated>2007-06-13T17:45:09Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* quiz_dataset_definitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===question_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the quiz_questions table, because the quiz_question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the quiz_dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The quiz_question_datasets table is used by dataset dependent questionypes (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24192</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24192"/>
		<updated>2007-06-13T17:44:47Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* quiz_question_datasets */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the quiz_questions table, because the quiz_question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the quiz_dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===question_datasets=== Many-many relation between questions and dataset definitions&lt;br /&gt;
&lt;br /&gt;
The quiz_question_datasets table is used by dataset dependent questionypes (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24191</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24191"/>
		<updated>2007-06-13T17:42:50Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* quiz_dataset_items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the quiz_questions table, because the quiz_question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_items=== Individual dataset items&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the quiz_dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 id corresponding to the question_dataset_definitions table&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===quiz_question_datasets===&lt;br /&gt;
&lt;br /&gt;
The quiz_question_datasets table is used by dataset dependent questionypes (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24190</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24190"/>
		<updated>2007-06-13T17:40:16Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* quiz_dataset_definitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_definitions=== Organises and stores properties for dataset items&lt;br /&gt;
&lt;br /&gt;
This table is an indirect extension to the quiz_questions table, because the quiz_question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_items===&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the quiz_dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===quiz_question_datasets===&lt;br /&gt;
&lt;br /&gt;
The quiz_question_datasets table is used by dataset dependent questionypes (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24177</id>
		<title>Dataset dependent</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Dataset_dependent&amp;diff=24177"/>
		<updated>2007-06-13T01:04:26Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* quiz_dataset_definitions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Questiontype developer docs}}&lt;br /&gt;
&lt;br /&gt;
==Database tables==&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_definitions=== &lt;br /&gt;
This table is an indirect extension to the quiz_questions table, because the quiz_question_datasets table can link a question to one or more datasets. Each dataset represents a variable, that is used either in the questiontext or in the answer to a dataset dependent question.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;category :int(10) unsigned NOT NULL default &#039;0&#039;, &lt;br /&gt;
 when this is a shared dataset the value is the category id &lt;br /&gt;
 when this is a private dataset the value is 0&lt;br /&gt;
;name :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
;type :int(10) NOT NULL default &#039;0&#039;,&lt;br /&gt;
;options :varchar(255) NOT NULL default &#039;&#039;, &lt;br /&gt;
 the options for this dataset separated by &#039;:&#039;(distribution:min:max:decimals)&lt;br /&gt;
;itemcount :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
 the number of dataset items&lt;br /&gt;
&lt;br /&gt;
===quiz_dataset_items===&lt;br /&gt;
&lt;br /&gt;
Dataset items can be created for each dataset. The quiz_dataset_items table stores these possible values for the variables defined in the quiz_dataset_definitions table.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;definition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;number :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;value :varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
&lt;br /&gt;
===quiz_question_datasets===&lt;br /&gt;
&lt;br /&gt;
The quiz_question_datasets table is used by dataset dependent questionypes (i.e. calculated) to link datasets to questions.&lt;br /&gt;
&lt;br /&gt;
;id :int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
;question :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
;datasetdefinition :int(10) unsigned NOT NULL default &#039;0&#039;,&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
==Question-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
==State-&amp;gt;options==&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Broken/Question_engine&amp;diff=24176</id>
		<title>Broken/Question engine</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Broken/Question_engine&amp;diff=24176"/>
		<updated>2007-06-13T00:13:58Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* Sessions, States, Events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Moodle has a powerful question engine with a modular structure to allow question type plug-ins. The question engine is responsible for rendering the questions and for processing student responses. It is used by the [[Quiz developer docs|quiz module]] and it is planned that in future it will be used by the Lesson and other modules.&lt;br /&gt;
&lt;br /&gt;
Historically the question engine started as a part of the quiz module. Only since Moodle 1.6 is it a separate core component of Moodle that can be used by any other Moodle component or module. During this restructuring the code was moved from mod/quiz/ to question/ and the tables and functions were renamed. Wherever the old table or function name contained &#039;quiz_&#039; the new one will contain &#039;question_&#039;&lt;br /&gt;
&lt;br /&gt;
==Terminology==&lt;br /&gt;
&lt;br /&gt;
When talking about the question engine there are certain terms that can cause confusion because they can be used with different meanings. In Moodle we have adopted a certain terminology that will be explained below.&lt;br /&gt;
&lt;br /&gt;
===Questions===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;question&#039;&#039;&#039; is the set of definitions (question name, question text, possible answers, grading rules, feedback, etc.) that constitute a reusable assessment item. So it includes much more than what one would in everyday language call a question.&lt;br /&gt;
In the terminology of the QTI specification a &#039;question&#039; is more appropriately called an &#039;&#039;&#039;assessment item&#039;&#039;&#039; or just &#039;item&#039; for short. &lt;br /&gt;
&lt;br /&gt;
There are different types of questions, like for example multiple-choice questions or numerical questions. These are referred to as &#039;&#039;&#039;[[Question engine#Question types|question types]]&#039;&#039;&#039; in Moodle.&lt;br /&gt;
&lt;br /&gt;
Since version 1.5 Moodle is able to handle so-called &#039;&#039;&#039;[[Adaptive questions]]&#039;&#039;&#039;, also known as &#039;adaptive items&#039; in QTI speak. These are questions that interact with the student by going through several states depending on the student responses. For example a complicated mathematical question that is answered incorrectly, but is likely to be incorrect because of a common mistake, could provide the user with a hint towards this mistake, apply a penalty and allow a second attempt at this question. Quizzes can be run in &#039;adaptive mode&#039;, in which case Moodle provides buttons to mark each question individually.&lt;br /&gt;
&lt;br /&gt;
===Answers===&lt;br /&gt;
&lt;br /&gt;
In Moodle the term &#039;&#039;&#039;&#039;answer&#039;&#039;&#039;&#039; is used exclusively for the &#039;&#039;&#039;teacher-defined answers&#039;&#039;&#039; of a question. It is easy to get confused between these teacher-defined answers and the answers that the students actually give. We have therefore adopted the convention to refer to the student-supplied answers as &#039;responses&#039; and to reserve the term &#039;answers&#039; to apply to teacher-defined answers. In question types that rely on teacher-supplied answers these are used in the grading process by comparing them with the student responses. Of course not all question types use teacher-defined answers but use some more intelligent way to process the student responses. &lt;br /&gt;
&lt;br /&gt;
Perhaps one should also stress that &#039;answer&#039; is not always used in the sense of &#039;correct answer&#039;. For example every choice in a multiple-choice question is referred to as an answer. Other systems use the term &#039;distractor&#039; for wrong answers. &lt;br /&gt;
&lt;br /&gt;
In Moodle we always use the term &#039;&#039;&#039;&#039;responses&#039;&#039;&#039;&#039; to refer to the students&#039; responses to a question. This term is always used in plural, although for some questiontypes there is only one possible response.&lt;br /&gt;
&lt;br /&gt;
There is unfortunately, for historical reasons, one exception to the above rule: The question_states table has a field &#039;answer&#039; whose purpose it actually is to hold the student&#039;s responses.&lt;br /&gt;
&lt;br /&gt;
===Attempts===&lt;br /&gt;
&lt;br /&gt;
In Moodle the term &#039;&#039;&#039;&#039;attempt&#039;&#039;&#039;&#039; is used in the sense of &amp;quot;Attempt at a quiz&amp;quot; (or another activity involving questions). Depending on the quiz settings, a student may be allowed several attempts at a quiz. An attempt is finished when the student clicks on the corresponding button on the attempt page. Students do not have to complete an attempt in one visit. They can navigate away from the quiz page and return later to continue the same attempt.&lt;br /&gt;
&lt;br /&gt;
Each module that uses the question engine should hold its own data for the attempts in its own tables. When the module calls the question engine functions it is often expected to pass an attempt object.&lt;br /&gt;
&lt;br /&gt;
Within one and the same quiz attempt a student may make several attempts at answering a particular question, at least if the questiontype allows it and the quiz is set up in adaptive mode. These will always be referred to as &#039;&#039;&#039;&#039;question sessions&#039;&#039;&#039;&#039; or sometimes &#039;attempts at a question, never just as &#039;attempts&#039;.&lt;br /&gt;
&lt;br /&gt;
===Sessions, States, Events===&lt;br /&gt;
&lt;br /&gt;
When a new attempt is started, a new &#039;&#039;&#039;session&#039;&#039;&#039; is started for each question. So in a sense a session is for a question what an attempt is for a whole quiz. A question session lasts no longer than an attempt and for each question there can only by one session within one attempt.&lt;br /&gt;
&lt;br /&gt;
Moodle allows the student to interact with a question repeatedly within one session and each such interaction leads to a new &#039;&#039;&#039;state&#039;&#039;&#039;. The first state is created when the session is created. A new state is then created when a student saves, validates or submits an answer or .... The student&#039;s responses and, if appropriate, the results of response processing (grading) are stored in the new state that gets created.&lt;br /&gt;
&lt;br /&gt;
The type of &#039;&#039;&#039;event&#039;&#039;&#039; that led to the creation of a particular state is saved along with the state. The types of events currently used are:&lt;br /&gt;
;open :A new session has just been created and this is the opening state. Usually it doesn&#039;t hold student responses yet (except where a quiz attempt is based on a previous attempt because the &#039;attemptonlast&#039; option is set).&lt;br /&gt;
;save:The student has clicked the save button.&lt;br /&gt;
;validate:The student has asked for his responses to be validated. This means it is checked that they are valid responses. In the case of mathematical questions which requires the input of a mathematical expression in some linear format the question type may want to display the validated result back to the student in typeset form. Similar things may apply to other subject-specific question types. If a student response is found to be invalid the student is told so but no penalty is applied. The invalid response is stored with the state.&lt;br /&gt;
;grade:The student has pressed the submit button. The grade is calculated and stored with the attempt.&lt;br /&gt;
;duplicategrade:The student has pressed the submit button but the response to this question has not actually changed. This happens a lot in quizzes with several questions on one page where the student may have changed the responses for one question only. I believe that states created by this type of event are not stored in the database.&lt;br /&gt;
;close:The last state in a session which is now closed. Currently a session closes only when the attempt closes, either because the student requests it or because the timelimit elapses.&lt;br /&gt;
&lt;br /&gt;
There are now plans to introduce another event type&lt;br /&gt;
;submit:The student has submitted his responses for grading but grading has not yet taken place. This will be used by teacher-marked question types like the essay questions for example.&lt;br /&gt;
&lt;br /&gt;
==Code documentation==&lt;br /&gt;
&lt;br /&gt;
The code is documented according to [http://www.phpdoc.org/ PHPdocumentor] conventions. The explanations here in the wiki are meant to complement this.&lt;br /&gt;
&lt;br /&gt;
Inline comments should be used liberally in the code. The following conventions make it easier to search for comments with special meaning:&lt;br /&gt;
* use TODO in comments about things that need to be done&lt;br /&gt;
* use ??? in comments that are questions about the code&lt;br /&gt;
&lt;br /&gt;
Code is organised into packages&lt;br /&gt;
* Package questionbank - code that relates to the questionbank system&lt;br /&gt;
** Subpackage questiontypes - code that relates to the question types, including the question type base class.&lt;br /&gt;
** Subpackage importexport - code that relates to importing and exporting questions.&lt;br /&gt;
&lt;br /&gt;
Generally, the base classes default_questiontype and qformat_default should contain most of the documentation, since all question types should follow the same interface. There is no value in repeating the same information on all the various subclasses. The subclasses should concentrate on describing any new methods they have that do not come from the base class.&lt;br /&gt;
&lt;br /&gt;
See the [http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.quickstart.pkg.html#coding.phpcomments PHPdocumentor manual] for more advice on writing good comments.&lt;br /&gt;
&lt;br /&gt;
Moodle PHPdocs can be seen here: http://phpdocs.moodle.org/.&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The library lib/questionlib.php contains all functions that need to be available to any module wanting to use questions (this is new in Moodle 1.6, in Moodle 1.5 this was part of mod/quiz/locallib.php). Loading this library instantiates all questiontype classes by loading the questiontype.php files&lt;br /&gt;
&lt;br /&gt;
A description of the API still needs to be written. Also lib/questionlib.php should be cleaned up a bit to distinguish between the API functions and the helper functions.&lt;br /&gt;
&lt;br /&gt;
==Organisation==&lt;br /&gt;
The default questiontype class is defined in &#039;&#039;&#039;question/type/questiontype.php&#039;&#039;&#039; (in Moodle 1.5 this was still in mod/quiz/locallib.php). The individual questiontypes extend this class in their own questiontype.php file. For documentation of the questiontype classes one should often look at the documentation of the default question type because much of the documentation that is in the default class is not repeated in the other questiontype classes.&lt;br /&gt;
&lt;br /&gt;
While questiontypes are realized as classes, the question engine is not written in a truly object-oriented way. Instead it follows the Moodle model of using objects mostly only as alternatives to arrays to hold database records. So none of the question, attempt, and state objects that play a central role in the module have any methods. Only the questiontype objects have methods. Strangely enough the quiz module instantiates one object of each questiontype class at the start and then reuses their methods for the different questions. If one is used to the Moodle way of programming then this is easy enough to handle.&lt;br /&gt;
&lt;br /&gt;
==Objects and data structures==&lt;br /&gt;
&lt;br /&gt;
Key to understanding how the question engine works is to understand how the different kinds of object work together. The most important ones are:&lt;br /&gt;
&lt;br /&gt;
*Questions&lt;br /&gt;
*Attempts&lt;br /&gt;
*States&lt;br /&gt;
&lt;br /&gt;
Questions are data created by the teacher. Attempts and States are data created by the student when interacting with a quiz. &lt;br /&gt;
&lt;br /&gt;
The Moodle quiz module allows students to make several attempts at a quiz. Data about such an &#039;&#039;&#039;attempt&#039;&#039;&#039; is stored in an attempt object. The Moodle question engine was optimized to deal with such attempts and therefore every module wanting to use the question engine also has to implement the attempt object and pass it to many of the question engine functions. The attempt object holds for example information about how the quiz was randomized for this attempt and the ordering of the questions and answers.&lt;br /&gt;
&lt;br /&gt;
Moodle allows students to interact repeatedly with a single question. So for example the student might initially just save an answer, later mark it, then correct it if it was marked incorrect. When the student first views a question within a particular attempt a &#039;&#039;&#039;question session&#039;&#039;&#039; and the first question state is created. Each time the student interacts with the question a new &#039;&#039;&#039;question state&#039;&#039;&#039; is created. So states are indexed by user id, attempt id and question id.&lt;br /&gt;
&lt;br /&gt;
===Database structure===&lt;br /&gt;
All this data needs to be kept in Moodle&#039;s database. How this is achieved is explained on a separate page about the &#039;&#039;&#039;[[Quiz database structure]]&#039;&#039;&#039;, which also contains a useful diagram.&lt;br /&gt;
&lt;br /&gt;
As is customary in Moodle, most runtime objects simply represent the data from a particular database record. So for example a $quiz object has fields corresponding to all the fields in the [[Quiz database structure#quiz|quiz table]]. In some cases the objects have some additional fields that are added at runtime. This is particularly the case for $question and $state objects. These additional fields are also described on the page about the &#039;&#039;&#039;[[Quiz database structure]]&#039;&#039;&#039;. Many functions that are used to process these objects make use of the additional fields and it is therefore necessary to use the correct functions for creating these objects.&lt;br /&gt;
&lt;br /&gt;
===Runtime objects===&lt;br /&gt;
Some objects used by the quiz module are purely runtime object and do not correspond to a database table. The structure of these objects is explained in detail on a separate page about the &#039;&#039;&#039;[[Quiz runtime objects]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The main script of the quiz module is attempt.php which will have to deal with all these objects. Studying the &#039;&#039;&#039;[[Quiz attempt|explanation of attempt.php]]&#039;&#039;&#039; is therefore a good way to start to study the quiz module code.&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
The student&#039;s responses to a question are stored in &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt;. Questiontypes are completely free to implement the storage mechanism of their responses (and other state information) the way they want. Still, the standard questiontypes all follow a similar model. The default storage model and the questiontype specific variations are explained below.&lt;br /&gt;
&lt;br /&gt;
The flexibility for the questiontypes to choose their response storage mechanism freely and to convert from the storage model to the runtime model is provided by a set of three functions, which allow to initialise the runtime &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; field, to convert from the runtime to the storage model and vice versa:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;create_session_and_responses()&amp;lt;/code&amp;gt;&lt;br /&gt;
:Initializes the $state object, in particular the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; field&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;restore_session_and_responses()&amp;lt;/code&amp;gt;&lt;br /&gt;
:Loads the question type specific session data from the database into the &amp;lt;code&amp;gt;$state&amp;lt;/code&amp;gt; object, in particular it loads the responses that have been saved for the given &amp;lt;code&amp;gt;$state&amp;lt;/code&amp;gt; into the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; field.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;save_session_and_responses()&amp;lt;/code&amp;gt;&lt;br /&gt;
:Saves the question type specific session data from the $state object to the database. In particular, for most questiontypes, it saves the responses from the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; to the database.&lt;br /&gt;
&lt;br /&gt;
The generic quiz module code saves the contents form the &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$state-&amp;gt;responses[&#039;&#039;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; field to the answer field in the [[Quiz database structure#quiz_states|quiz_states table]] and also automatically restores the contents of this field to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$state-&amp;gt;responses[&#039;&#039;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. This means that any questiontype, which only expects a single value as its response can skip the implementation of the three methods described above. All questiontypes that have multiple value responses need to implement these methods. &lt;br /&gt;
&lt;br /&gt;
The default questiontypes handle this problem by serializing/de-serializing the responses to/from the answer field in the quiz_states table. However, it is also possible (and may be better practice) to extend the quiz_states table with a questiontype specific table, i.e. take the id of the quiz_states record as a foreign key in the questiontype specific table. Because the value of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$state-&amp;gt;responses[&#039;&#039;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; is set to the value of the answer field, questiontypes that serialize their response need to overwrite (in &amp;lt;code&amp;gt;save_session_and_responses()&amp;lt;/code&amp;gt;) whatever value the generic code set this field to with their serialized value (usually achieved with a simple set_field). &lt;br /&gt;
&lt;br /&gt;
In the method &amp;lt;code&amp;gt;restore_session_and_responses()&amp;lt;/code&amp;gt; the serialized value can be read from &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$state-&amp;gt;responses[&#039;&#039;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; because this is where the value from answer field of the quiz_states table has been moved. Care needs to be taken that this array value is then unset or the whole array overwritten, so that the array does not accidentally contain a value with the empty string index.&lt;br /&gt;
&lt;br /&gt;
==Response processing==&lt;br /&gt;
&lt;br /&gt;
The runtime model for responses dictates the structure of the $state-&amp;gt;responses array. Starting with the names of the form elements this section goes through the relevant processing steps and thus attempts to clarify why the keys of the $state-&amp;gt;responses array can differ for different questiontypes; even more, it explains how the array keys are chosen and set.&lt;br /&gt;
&lt;br /&gt;
Although it may initially seem strange to start with the naming convention of the form fields, the reason for this will become clear later on. The controls (i.e. the form fields) of a question get printed by the method &amp;lt;code&amp;gt;print_question_formulation_and_controls()&amp;lt;/code&amp;gt;. The convention only dictates that the name of the control element(s) must begin with the value of &amp;lt;code&amp;gt;$question-&amp;gt;name_prefix&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;$question-&amp;gt;name_prefix&amp;lt;/code&amp;gt; is a string starting with &amp;quot;resp&amp;quot; followed by the question id and an underscore, e.g. &amp;lt;code&amp;gt;resp56_&amp;lt;/code&amp;gt;. In the default case, when there is only a single control element (this includes the case of a list of equally named radio buttons), no postfix is appended to the name prefix. For questiontypes that allow or require multiple form elements, an arbitrary string can be appended to the name prefix to form the name of these form elements. The postfix must not include any relational data (i.e. ids of records in the quiz_answers table), because this can lead to problems with regrading of versioned questions.&lt;br /&gt;
&lt;br /&gt;
After the printing of the question the server only sees it again when it is submitted. So the submitted data will contain several values indexed by strings starting with &amp;lt;code&amp;gt;respXX_&amp;lt;/code&amp;gt;. Upon submission, the function &amp;lt;code&amp;gt;quiz_process_responses()&amp;lt;/code&amp;gt; is called, which assigns the submitted responses to the state of the question with id XX, using the postfix (i.e. everything after the underscore) as array keys. In the default case with only one control element the name only consists of the name prefix. This explains why the default index of the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; array is the empty string. The value of each array element is obviously the value that was submitted by the form, basically a raw response.&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;quiz_process_responses()&amp;lt;/code&amp;gt; in turn calls the questiontype specific method &amp;lt;code&amp;gt;grade_responses()&amp;lt;/code&amp;gt; to assign a grade to the submitted responses and &amp;lt;code&amp;gt;compare_responses()&amp;lt;/code&amp;gt; to determine whether the response was identical to the previous submission and to avoid regrading the same responses repeatedly. These questiontype specific functions need to be aware of the expected keys of the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; array.&lt;br /&gt;
&lt;br /&gt;
Finally, the methods &amp;lt;code&amp;gt;restore_session_and_responses()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;save_session_and_responses()&amp;lt;/code&amp;gt; also need to know the questiontype specific layout of the &amp;lt;code&amp;gt;$state-&amp;gt;responses array&amp;lt;/code&amp;gt; and restore or save the information, e.g. by converting from or to the data representation.&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
{{Questiontype developer docs}}&lt;br /&gt;
The quiz module is itself modular and allows question type plug-ins. For each question type there should be a page, accessible via the menu at the right, which provides at least the details about&lt;br /&gt;
*Database tables&lt;br /&gt;
*Response storage&lt;br /&gt;
*Question options object&lt;br /&gt;
*State options object&lt;br /&gt;
[[Development:Question type code flow]]&lt;br /&gt;
&lt;br /&gt;
It is hoped that Moodlers will contribute a lot of non-core question types in the future. For this it would be good to start a [[How to write a question type plugin]].&lt;br /&gt;
&lt;br /&gt;
==Grades==&lt;br /&gt;
&lt;br /&gt;
The handling of grades is a bit complicated because there are so many different grades around that get rescaled and combined in various ways. This section should summarize how this is done and why.&lt;br /&gt;
&lt;br /&gt;
The following grade fields are being used:&lt;br /&gt;
*$question-&amp;gt;defaultgrade&lt;br /&gt;
::This is the default value for the maximum grade for this question. This is set up when the teacher creates the question and it is stored in an int(10) field in the [[Quiz database structure#quiz_questions|quiz_questions]] table. However when the question is actually used in a particular quiz the teacher can overrule this default and this is stored in:&lt;br /&gt;
*$question-&amp;gt;maxgrade&lt;br /&gt;
::This is the maximum grade that the teacher has assigned to this question in the context of the current quiz. This is by default equal to $questions-&amp;gt;defaultgrade but the teacher can change this when editing the quiz. In the database it is stored in an int(10) field in the [[Quiz database structure#quiz_question_instances|quiz_question_instances table]].&lt;br /&gt;
*$question-&amp;gt;penalty&lt;br /&gt;
&lt;br /&gt;
*$state-&amp;gt;raw_grade&lt;br /&gt;
*$state-&amp;gt;grade&lt;br /&gt;
*$state-&amp;gt;penalty&lt;br /&gt;
*$state-&amp;gt;sumpenalty&lt;br /&gt;
&lt;br /&gt;
*$attempt-&amp;gt;sumgrades&lt;br /&gt;
&lt;br /&gt;
The maximum grades set by the teacher, $question-&amp;gt;defaultgrade and $question-&amp;gt;maxgrade, are integers. All student-obtained grades are in principle floating point numbers. For historical reasons they are stored in the database as varchar(10) fields. Care has to be taken when writing to the database to make sure all grades are correctly rounded and squeezed into a string of no more than 10 characters, otherwise the writing to database will fail, see bug 4220.&lt;br /&gt;
&lt;br /&gt;
The final outcome of the calculation of the grade for a user at a particular quiz is stored in the &#039;grade&#039; field of the [[Quiz database structure#quiz_grades|quiz_grades table]]. This field has type double.&lt;br /&gt;
&lt;br /&gt;
==Penalty mechanism==&lt;br /&gt;
&lt;br /&gt;
===What it is for===&lt;br /&gt;
&lt;br /&gt;
When the quiz is run in adaptive mode the student can interact with a question repeatedly. So in particular the student can try again when he gets a wrong answer. Clearly the final mark for the question must reflect the fact that the student did not get it right originally. Therefore a penalty is subtracted from the final mark.&lt;br /&gt;
&lt;br /&gt;
===How the penalty is determined===&lt;br /&gt;
&lt;br /&gt;
First of all penalties are relevant only if a quiz is run in adaptive mode. Only in this case can a student have a second attempt and therefore only in this mode can there be any occasion to subtract a penalty.&lt;br /&gt;
&lt;br /&gt;
Even in adaptive mode the penalty mechanism is only used when it is selected in the quiz options. If &amp;quot;Apply penalties&amp;quot; is set to &amp;quot;No&amp;quot; then the final mark for the question is the mark for the last graded response.&lt;br /&gt;
&lt;br /&gt;
Each question has a &#039;penalty&#039; field (which should really be called &#039;penaltyfactor&#039;) which is a number between 0 and 1. The penalty for a wrong response is calculated as the product ($quiz-&amp;gt;penalty * $quiz-&amp;gt;grade), i.e., as the product of the penaltyfactor with the maximum achievable grade for the question. This product is stored in $state-&amp;gt;penalty. So $quiz-&amp;gt;penalty is the fraction of the maximum grade that is subtracted as a penalty for each wrong response.&lt;br /&gt;
&lt;br /&gt;
The $quiz-&amp;gt;penalty field has a default value of 0.1, both in the database and in mod/quiz/defaults.php. This default can of course be overwritten by the admin on the quiz configuration page. This admin-selected default is (as usual for admin defaults) stored in $CFG-&amp;gt;quiz_penalty. The teacher can choose a different penalty factor for each individual question when adding or editing a question.&lt;br /&gt;
&lt;br /&gt;
Now if a student makes repeated wrong attempts (or partially correct attempts) the penalties for all these attempts are added up in $state-&amp;gt;sumpenalties. The mark for the question is then calculated as the mark for the last graded response minus the sum of the penalties.&lt;br /&gt;
&lt;br /&gt;
One curious fact about $state-&amp;gt;sumpenalties is that, for efficiency reasons, it is not stored in the quiz_states table but instead in the &#039;sumpenalty&#039; field of the quiz_newest_states table. That way it only has to be stored once per attempt rather than once per response.&lt;br /&gt;
&lt;br /&gt;
===Where it is done in the code===&lt;br /&gt;
&lt;br /&gt;
The function quiz_apply_penalty_and_timelimit() subtracts the penalty in $state-&amp;gt;sumpenalty from the raw grade in $state-&amp;gt;raw_grade to obtain $state-&amp;gt;grade for the response. However it is ensured that the grade of a new attempt at the question never falls below the previously achieved grade. This function also increases $state-&amp;gt;sumpenalty by the amount in $state-&amp;gt;penalty. The assumption is that $state-&amp;gt;penalty has just been set appropriately by the code calling this function, e.g., quiz_process_responses.&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Broken/Question_engine&amp;diff=24175</id>
		<title>Broken/Question engine</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Broken/Question_engine&amp;diff=24175"/>
		<updated>2007-06-13T00:03:22Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* Sessions, States, Events */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Moodle has a powerful question engine with a modular structure to allow question type plug-ins. The question engine is responsible for rendering the questions and for processing student responses. It is used by the [[Quiz developer docs|quiz module]] and it is planned that in future it will be used by the Lesson and other modules.&lt;br /&gt;
&lt;br /&gt;
Historically the question engine started as a part of the quiz module. Only since Moodle 1.6 is it a separate core component of Moodle that can be used by any other Moodle component or module. During this restructuring the code was moved from mod/quiz/ to question/ and the tables and functions were renamed. Wherever the old table or function name contained &#039;quiz_&#039; the new one will contain &#039;question_&#039;&lt;br /&gt;
&lt;br /&gt;
==Terminology==&lt;br /&gt;
&lt;br /&gt;
When talking about the question engine there are certain terms that can cause confusion because they can be used with different meanings. In Moodle we have adopted a certain terminology that will be explained below.&lt;br /&gt;
&lt;br /&gt;
===Questions===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;question&#039;&#039;&#039; is the set of definitions (question name, question text, possible answers, grading rules, feedback, etc.) that constitute a reusable assessment item. So it includes much more than what one would in everyday language call a question.&lt;br /&gt;
In the terminology of the QTI specification a &#039;question&#039; is more appropriately called an &#039;&#039;&#039;assessment item&#039;&#039;&#039; or just &#039;item&#039; for short. &lt;br /&gt;
&lt;br /&gt;
There are different types of questions, like for example multiple-choice questions or numerical questions. These are referred to as &#039;&#039;&#039;[[Question engine#Question types|question types]]&#039;&#039;&#039; in Moodle.&lt;br /&gt;
&lt;br /&gt;
Since version 1.5 Moodle is able to handle so-called &#039;&#039;&#039;[[Adaptive questions]]&#039;&#039;&#039;, also known as &#039;adaptive items&#039; in QTI speak. These are questions that interact with the student by going through several states depending on the student responses. For example a complicated mathematical question that is answered incorrectly, but is likely to be incorrect because of a common mistake, could provide the user with a hint towards this mistake, apply a penalty and allow a second attempt at this question. Quizzes can be run in &#039;adaptive mode&#039;, in which case Moodle provides buttons to mark each question individually.&lt;br /&gt;
&lt;br /&gt;
===Answers===&lt;br /&gt;
&lt;br /&gt;
In Moodle the term &#039;&#039;&#039;&#039;answer&#039;&#039;&#039;&#039; is used exclusively for the &#039;&#039;&#039;teacher-defined answers&#039;&#039;&#039; of a question. It is easy to get confused between these teacher-defined answers and the answers that the students actually give. We have therefore adopted the convention to refer to the student-supplied answers as &#039;responses&#039; and to reserve the term &#039;answers&#039; to apply to teacher-defined answers. In question types that rely on teacher-supplied answers these are used in the grading process by comparing them with the student responses. Of course not all question types use teacher-defined answers but use some more intelligent way to process the student responses. &lt;br /&gt;
&lt;br /&gt;
Perhaps one should also stress that &#039;answer&#039; is not always used in the sense of &#039;correct answer&#039;. For example every choice in a multiple-choice question is referred to as an answer. Other systems use the term &#039;distractor&#039; for wrong answers. &lt;br /&gt;
&lt;br /&gt;
In Moodle we always use the term &#039;&#039;&#039;&#039;responses&#039;&#039;&#039;&#039; to refer to the students&#039; responses to a question. This term is always used in plural, although for some questiontypes there is only one possible response.&lt;br /&gt;
&lt;br /&gt;
There is unfortunately, for historical reasons, one exception to the above rule: The question_states table has a field &#039;answer&#039; whose purpose it actually is to hold the student&#039;s responses.&lt;br /&gt;
&lt;br /&gt;
===Attempts===&lt;br /&gt;
&lt;br /&gt;
In Moodle the term &#039;&#039;&#039;&#039;attempt&#039;&#039;&#039;&#039; is used in the sense of &amp;quot;Attempt at a quiz&amp;quot; (or another activity involving questions). Depending on the quiz settings, a student may be allowed several attempts at a quiz. An attempt is finished when the student clicks on the corresponding button on the attempt page. Students do not have to complete an attempt in one visit. They can navigate away from the quiz page and return later to continue the same attempt.&lt;br /&gt;
&lt;br /&gt;
Each module that uses the question engine should hold its own data for the attempts in its own tables. When the module calls the question engine functions it is often expected to pass an attempt object.&lt;br /&gt;
&lt;br /&gt;
Within one and the same quiz attempt a student may make several attempts at answering a particular question, at least if the questiontype allows it and the quiz is set up in adaptive mode. These will always be referred to as &#039;&#039;&#039;&#039;question sessions&#039;&#039;&#039;&#039; or sometimes &#039;attempts at a question, never just as &#039;attempts&#039;.&lt;br /&gt;
&lt;br /&gt;
===Sessions, States, Events===&lt;br /&gt;
&lt;br /&gt;
When a new attempt is started, a new &#039;&#039;&#039;session&#039;&#039;&#039; is started for each question. So in a sense a session is for a question what an attempt is for a whole quiz. A question session lasts no longer than an attempt and for each question there can only by one session within one attempt.&lt;br /&gt;
&lt;br /&gt;
Moodle allows the student to interact with a question repeatedly within one session and each such interaction leads to a new &#039;&#039;&#039;state&#039;&#039;&#039;. The first state is created when the session is created. A new state is then created when a student saves, validates or submits an answer or .... The student&#039;s responses and, if appropriate, the results of response processing (grading) are stored in the new state that gets created.&lt;br /&gt;
&lt;br /&gt;
The type of &#039;&#039;&#039;event&#039;&#039;&#039; that led to the creation of a particular state is saved along with the state. The types of events currently used are:&lt;br /&gt;
;open :A new session has just been created and this is the opening state. Usually it doesn&#039;t hold student responses yet (except where a quiz attempt is based on a previous attempt because the &#039;attemptonlast&#039; option is set).&lt;br /&gt;
;save:The student has clicked the save button.&lt;br /&gt;
;validate:The student has asked for his responses to be validated. This means it is checked that they are valid responses. In the case of mathematical questions which requires the input of a mathematical expression in some linear format the question type may want to display the validated result back to the student in typeset form. Similar things may apply to other subject-specific question types. If a student response is found to be invalid the student is told so but no penalty is applied. The invalid response is stored with the state.&lt;br /&gt;
;grade:The student has pressed the submit button. The grade is calculated and stored with the attempt.&lt;br /&gt;
;duplicategrade:The student has pressed the submit button but the response to this question has not actually changed. This happens a lot in quizzes with several questions on on page where the student may have changed the responses for one question only. I believe that states created by this type of event are not stored in the database.&lt;br /&gt;
;close:The last state in a session which is now closed. Currently a session closes only when the attempt closes, either because the student requests it or because the timelimit elapses.&lt;br /&gt;
&lt;br /&gt;
There are now plans to introduce another event type&lt;br /&gt;
;submit:The student has submitted his responses for grading but grading has not yet taken place. This will be used by teacher-marked question types like the essay questions for example.&lt;br /&gt;
&lt;br /&gt;
==Code documentation==&lt;br /&gt;
&lt;br /&gt;
The code is documented according to [http://www.phpdoc.org/ PHPdocumentor] conventions. The explanations here in the wiki are meant to complement this.&lt;br /&gt;
&lt;br /&gt;
Inline comments should be used liberally in the code. The following conventions make it easier to search for comments with special meaning:&lt;br /&gt;
* use TODO in comments about things that need to be done&lt;br /&gt;
* use ??? in comments that are questions about the code&lt;br /&gt;
&lt;br /&gt;
Code is organised into packages&lt;br /&gt;
* Package questionbank - code that relates to the questionbank system&lt;br /&gt;
** Subpackage questiontypes - code that relates to the question types, including the question type base class.&lt;br /&gt;
** Subpackage importexport - code that relates to importing and exporting questions.&lt;br /&gt;
&lt;br /&gt;
Generally, the base classes default_questiontype and qformat_default should contain most of the documentation, since all question types should follow the same interface. There is no value in repeating the same information on all the various subclasses. The subclasses should concentrate on describing any new methods they have that do not come from the base class.&lt;br /&gt;
&lt;br /&gt;
See the [http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_phpDocumentor.quickstart.pkg.html#coding.phpcomments PHPdocumentor manual] for more advice on writing good comments.&lt;br /&gt;
&lt;br /&gt;
Moodle PHPdocs can be seen here: http://phpdocs.moodle.org/.&lt;br /&gt;
&lt;br /&gt;
==API==&lt;br /&gt;
&lt;br /&gt;
The library lib/questionlib.php contains all functions that need to be available to any module wanting to use questions (this is new in Moodle 1.6, in Moodle 1.5 this was part of mod/quiz/locallib.php). Loading this library instantiates all questiontype classes by loading the questiontype.php files&lt;br /&gt;
&lt;br /&gt;
A description of the API still needs to be written. Also lib/questionlib.php should be cleaned up a bit to distinguish between the API functions and the helper functions.&lt;br /&gt;
&lt;br /&gt;
==Organisation==&lt;br /&gt;
The default questiontype class is defined in &#039;&#039;&#039;question/type/questiontype.php&#039;&#039;&#039; (in Moodle 1.5 this was still in mod/quiz/locallib.php). The individual questiontypes extend this class in their own questiontype.php file. For documentation of the questiontype classes one should often look at the documentation of the default question type because much of the documentation that is in the default class is not repeated in the other questiontype classes.&lt;br /&gt;
&lt;br /&gt;
While questiontypes are realized as classes, the question engine is not written in a truly object-oriented way. Instead it follows the Moodle model of using objects mostly only as alternatives to arrays to hold database records. So none of the question, attempt, and state objects that play a central role in the module have any methods. Only the questiontype objects have methods. Strangely enough the quiz module instantiates one object of each questiontype class at the start and then reuses their methods for the different questions. If one is used to the Moodle way of programming then this is easy enough to handle.&lt;br /&gt;
&lt;br /&gt;
==Objects and data structures==&lt;br /&gt;
&lt;br /&gt;
Key to understanding how the question engine works is to understand how the different kinds of object work together. The most important ones are:&lt;br /&gt;
&lt;br /&gt;
*Questions&lt;br /&gt;
*Attempts&lt;br /&gt;
*States&lt;br /&gt;
&lt;br /&gt;
Questions are data created by the teacher. Attempts and States are data created by the student when interacting with a quiz. &lt;br /&gt;
&lt;br /&gt;
The Moodle quiz module allows students to make several attempts at a quiz. Data about such an &#039;&#039;&#039;attempt&#039;&#039;&#039; is stored in an attempt object. The Moodle question engine was optimized to deal with such attempts and therefore every module wanting to use the question engine also has to implement the attempt object and pass it to many of the question engine functions. The attempt object holds for example information about how the quiz was randomized for this attempt and the ordering of the questions and answers.&lt;br /&gt;
&lt;br /&gt;
Moodle allows students to interact repeatedly with a single question. So for example the student might initially just save an answer, later mark it, then correct it if it was marked incorrect. When the student first views a question within a particular attempt a &#039;&#039;&#039;question session&#039;&#039;&#039; and the first question state is created. Each time the student interacts with the question a new &#039;&#039;&#039;question state&#039;&#039;&#039; is created. So states are indexed by user id, attempt id and question id.&lt;br /&gt;
&lt;br /&gt;
===Database structure===&lt;br /&gt;
All this data needs to be kept in Moodle&#039;s database. How this is achieved is explained on a separate page about the &#039;&#039;&#039;[[Quiz database structure]]&#039;&#039;&#039;, which also contains a useful diagram.&lt;br /&gt;
&lt;br /&gt;
As is customary in Moodle, most runtime objects simply represent the data from a particular database record. So for example a $quiz object has fields corresponding to all the fields in the [[Quiz database structure#quiz|quiz table]]. In some cases the objects have some additional fields that are added at runtime. This is particularly the case for $question and $state objects. These additional fields are also described on the page about the &#039;&#039;&#039;[[Quiz database structure]]&#039;&#039;&#039;. Many functions that are used to process these objects make use of the additional fields and it is therefore necessary to use the correct functions for creating these objects.&lt;br /&gt;
&lt;br /&gt;
===Runtime objects===&lt;br /&gt;
Some objects used by the quiz module are purely runtime object and do not correspond to a database table. The structure of these objects is explained in detail on a separate page about the &#039;&#039;&#039;[[Quiz runtime objects]]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The main script of the quiz module is attempt.php which will have to deal with all these objects. Studying the &#039;&#039;&#039;[[Quiz attempt|explanation of attempt.php]]&#039;&#039;&#039; is therefore a good way to start to study the quiz module code.&lt;br /&gt;
&lt;br /&gt;
==Response storage==&lt;br /&gt;
&lt;br /&gt;
The student&#039;s responses to a question are stored in &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt;. Questiontypes are completely free to implement the storage mechanism of their responses (and other state information) the way they want. Still, the standard questiontypes all follow a similar model. The default storage model and the questiontype specific variations are explained below.&lt;br /&gt;
&lt;br /&gt;
The flexibility for the questiontypes to choose their response storage mechanism freely and to convert from the storage model to the runtime model is provided by a set of three functions, which allow to initialise the runtime &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; field, to convert from the runtime to the storage model and vice versa:&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;create_session_and_responses()&amp;lt;/code&amp;gt;&lt;br /&gt;
:Initializes the $state object, in particular the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; field&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;restore_session_and_responses()&amp;lt;/code&amp;gt;&lt;br /&gt;
:Loads the question type specific session data from the database into the &amp;lt;code&amp;gt;$state&amp;lt;/code&amp;gt; object, in particular it loads the responses that have been saved for the given &amp;lt;code&amp;gt;$state&amp;lt;/code&amp;gt; into the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; field.&lt;br /&gt;
&lt;br /&gt;
;&amp;lt;code&amp;gt;save_session_and_responses()&amp;lt;/code&amp;gt;&lt;br /&gt;
:Saves the question type specific session data from the $state object to the database. In particular, for most questiontypes, it saves the responses from the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; to the database.&lt;br /&gt;
&lt;br /&gt;
The generic quiz module code saves the contents form the &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$state-&amp;gt;responses[&#039;&#039;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; field to the answer field in the [[Quiz database structure#quiz_states|quiz_states table]] and also automatically restores the contents of this field to &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$state-&amp;gt;responses[&#039;&#039;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. This means that any questiontype, which only expects a single value as its response can skip the implementation of the three methods described above. All questiontypes that have multiple value responses need to implement these methods. &lt;br /&gt;
&lt;br /&gt;
The default questiontypes handle this problem by serializing/de-serializing the responses to/from the answer field in the quiz_states table. However, it is also possible (and may be better practice) to extend the quiz_states table with a questiontype specific table, i.e. take the id of the quiz_states record as a foreign key in the questiontype specific table. Because the value of &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$state-&amp;gt;responses[&#039;&#039;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; is set to the value of the answer field, questiontypes that serialize their response need to overwrite (in &amp;lt;code&amp;gt;save_session_and_responses()&amp;lt;/code&amp;gt;) whatever value the generic code set this field to with their serialized value (usually achieved with a simple set_field). &lt;br /&gt;
&lt;br /&gt;
In the method &amp;lt;code&amp;gt;restore_session_and_responses()&amp;lt;/code&amp;gt; the serialized value can be read from &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$state-&amp;gt;responses[&#039;&#039;]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; because this is where the value from answer field of the quiz_states table has been moved. Care needs to be taken that this array value is then unset or the whole array overwritten, so that the array does not accidentally contain a value with the empty string index.&lt;br /&gt;
&lt;br /&gt;
==Response processing==&lt;br /&gt;
&lt;br /&gt;
The runtime model for responses dictates the structure of the $state-&amp;gt;responses array. Starting with the names of the form elements this section goes through the relevant processing steps and thus attempts to clarify why the keys of the $state-&amp;gt;responses array can differ for different questiontypes; even more, it explains how the array keys are chosen and set.&lt;br /&gt;
&lt;br /&gt;
Although it may initially seem strange to start with the naming convention of the form fields, the reason for this will become clear later on. The controls (i.e. the form fields) of a question get printed by the method &amp;lt;code&amp;gt;print_question_formulation_and_controls()&amp;lt;/code&amp;gt;. The convention only dictates that the name of the control element(s) must begin with the value of &amp;lt;code&amp;gt;$question-&amp;gt;name_prefix&amp;lt;/code&amp;gt;. The &amp;lt;code&amp;gt;$question-&amp;gt;name_prefix&amp;lt;/code&amp;gt; is a string starting with &amp;quot;resp&amp;quot; followed by the question id and an underscore, e.g. &amp;lt;code&amp;gt;resp56_&amp;lt;/code&amp;gt;. In the default case, when there is only a single control element (this includes the case of a list of equally named radio buttons), no postfix is appended to the name prefix. For questiontypes that allow or require multiple form elements, an arbitrary string can be appended to the name prefix to form the name of these form elements. The postfix must not include any relational data (i.e. ids of records in the quiz_answers table), because this can lead to problems with regrading of versioned questions.&lt;br /&gt;
&lt;br /&gt;
After the printing of the question the server only sees it again when it is submitted. So the submitted data will contain several values indexed by strings starting with &amp;lt;code&amp;gt;respXX_&amp;lt;/code&amp;gt;. Upon submission, the function &amp;lt;code&amp;gt;quiz_process_responses()&amp;lt;/code&amp;gt; is called, which assigns the submitted responses to the state of the question with id XX, using the postfix (i.e. everything after the underscore) as array keys. In the default case with only one control element the name only consists of the name prefix. This explains why the default index of the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; array is the empty string. The value of each array element is obviously the value that was submitted by the form, basically a raw response.&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;quiz_process_responses()&amp;lt;/code&amp;gt; in turn calls the questiontype specific method &amp;lt;code&amp;gt;grade_responses()&amp;lt;/code&amp;gt; to assign a grade to the submitted responses and &amp;lt;code&amp;gt;compare_responses()&amp;lt;/code&amp;gt; to determine whether the response was identical to the previous submission and to avoid regrading the same responses repeatedly. These questiontype specific functions need to be aware of the expected keys of the &amp;lt;code&amp;gt;$state-&amp;gt;responses&amp;lt;/code&amp;gt; array.&lt;br /&gt;
&lt;br /&gt;
Finally, the methods &amp;lt;code&amp;gt;restore_session_and_responses()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;save_session_and_responses()&amp;lt;/code&amp;gt; also need to know the questiontype specific layout of the &amp;lt;code&amp;gt;$state-&amp;gt;responses array&amp;lt;/code&amp;gt; and restore or save the information, e.g. by converting from or to the data representation.&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
{{Questiontype developer docs}}&lt;br /&gt;
The quiz module is itself modular and allows question type plug-ins. For each question type there should be a page, accessible via the menu at the right, which provides at least the details about&lt;br /&gt;
*Database tables&lt;br /&gt;
*Response storage&lt;br /&gt;
*Question options object&lt;br /&gt;
*State options object&lt;br /&gt;
[[Development:Question type code flow]]&lt;br /&gt;
&lt;br /&gt;
It is hoped that Moodlers will contribute a lot of non-core question types in the future. For this it would be good to start a [[How to write a question type plugin]].&lt;br /&gt;
&lt;br /&gt;
==Grades==&lt;br /&gt;
&lt;br /&gt;
The handling of grades is a bit complicated because there are so many different grades around that get rescaled and combined in various ways. This section should summarize how this is done and why.&lt;br /&gt;
&lt;br /&gt;
The following grade fields are being used:&lt;br /&gt;
*$question-&amp;gt;defaultgrade&lt;br /&gt;
::This is the default value for the maximum grade for this question. This is set up when the teacher creates the question and it is stored in an int(10) field in the [[Quiz database structure#quiz_questions|quiz_questions]] table. However when the question is actually used in a particular quiz the teacher can overrule this default and this is stored in:&lt;br /&gt;
*$question-&amp;gt;maxgrade&lt;br /&gt;
::This is the maximum grade that the teacher has assigned to this question in the context of the current quiz. This is by default equal to $questions-&amp;gt;defaultgrade but the teacher can change this when editing the quiz. In the database it is stored in an int(10) field in the [[Quiz database structure#quiz_question_instances|quiz_question_instances table]].&lt;br /&gt;
*$question-&amp;gt;penalty&lt;br /&gt;
&lt;br /&gt;
*$state-&amp;gt;raw_grade&lt;br /&gt;
*$state-&amp;gt;grade&lt;br /&gt;
*$state-&amp;gt;penalty&lt;br /&gt;
*$state-&amp;gt;sumpenalty&lt;br /&gt;
&lt;br /&gt;
*$attempt-&amp;gt;sumgrades&lt;br /&gt;
&lt;br /&gt;
The maximum grades set by the teacher, $question-&amp;gt;defaultgrade and $question-&amp;gt;maxgrade, are integers. All student-obtained grades are in principle floating point numbers. For historical reasons they are stored in the database as varchar(10) fields. Care has to be taken when writing to the database to make sure all grades are correctly rounded and squeezed into a string of no more than 10 characters, otherwise the writing to database will fail, see bug 4220.&lt;br /&gt;
&lt;br /&gt;
The final outcome of the calculation of the grade for a user at a particular quiz is stored in the &#039;grade&#039; field of the [[Quiz database structure#quiz_grades|quiz_grades table]]. This field has type double.&lt;br /&gt;
&lt;br /&gt;
==Penalty mechanism==&lt;br /&gt;
&lt;br /&gt;
===What it is for===&lt;br /&gt;
&lt;br /&gt;
When the quiz is run in adaptive mode the student can interact with a question repeatedly. So in particular the student can try again when he gets a wrong answer. Clearly the final mark for the question must reflect the fact that the student did not get it right originally. Therefore a penalty is subtracted from the final mark.&lt;br /&gt;
&lt;br /&gt;
===How the penalty is determined===&lt;br /&gt;
&lt;br /&gt;
First of all penalties are relevant only if a quiz is run in adaptive mode. Only in this case can a student have a second attempt and therefore only in this mode can there be any occasion to subtract a penalty.&lt;br /&gt;
&lt;br /&gt;
Even in adaptive mode the penalty mechanism is only used when it is selected in the quiz options. If &amp;quot;Apply penalties&amp;quot; is set to &amp;quot;No&amp;quot; then the final mark for the question is the mark for the last graded response.&lt;br /&gt;
&lt;br /&gt;
Each question has a &#039;penalty&#039; field (which should really be called &#039;penaltyfactor&#039;) which is a number between 0 and 1. The penalty for a wrong response is calculated as the product ($quiz-&amp;gt;penalty * $quiz-&amp;gt;grade), i.e., as the product of the penaltyfactor with the maximum achievable grade for the question. This product is stored in $state-&amp;gt;penalty. So $quiz-&amp;gt;penalty is the fraction of the maximum grade that is subtracted as a penalty for each wrong response.&lt;br /&gt;
&lt;br /&gt;
The $quiz-&amp;gt;penalty field has a default value of 0.1, both in the database and in mod/quiz/defaults.php. This default can of course be overwritten by the admin on the quiz configuration page. This admin-selected default is (as usual for admin defaults) stored in $CFG-&amp;gt;quiz_penalty. The teacher can choose a different penalty factor for each individual question when adding or editing a question.&lt;br /&gt;
&lt;br /&gt;
Now if a student makes repeated wrong attempts (or partially correct attempts) the penalties for all these attempts are added up in $state-&amp;gt;sumpenalties. The mark for the question is then calculated as the mark for the last graded response minus the sum of the penalties.&lt;br /&gt;
&lt;br /&gt;
One curious fact about $state-&amp;gt;sumpenalties is that, for efficiency reasons, it is not stored in the quiz_states table but instead in the &#039;sumpenalty&#039; field of the quiz_newest_states table. That way it only has to be stored once per attempt rather than once per response.&lt;br /&gt;
&lt;br /&gt;
===Where it is done in the code===&lt;br /&gt;
&lt;br /&gt;
The function quiz_apply_penalty_and_timelimit() subtracts the penalty in $state-&amp;gt;sumpenalty from the raw grade in $state-&amp;gt;raw_grade to obtain $state-&amp;gt;grade for the response. However it is ensured that the grade of a new attempt at the question never falls below the previously achieved grade. This function also increases $state-&amp;gt;sumpenalty by the amount in $state-&amp;gt;penalty. The assumption is that $state-&amp;gt;penalty has just been set appropriately by the code calling this function, e.g., quiz_process_responses.&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;br /&gt;
[[Category:Quiz]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Groups_FAQ&amp;diff=24074</id>
		<title>Groups FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Groups_FAQ&amp;diff=24074"/>
		<updated>2007-06-06T00:41:04Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* Can I use the same groups for more than one course? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==General==&lt;br /&gt;
===What is the &#039;groups mode&#039; setting?===&lt;br /&gt;
&lt;br /&gt;
There are three different groups modes – No groups, Separate Groups, Visible Groups. In ‘Separate groups’ mode, each group can only see their own group – other groups are invisible. In ‘Visible groups’ mode, each group works in their own group, but can also see other groups.&lt;br /&gt;
&lt;br /&gt;
===What is the &#039;force&#039; setting?===&lt;br /&gt;
&lt;br /&gt;
If force is set to yes, then all activities are group activities. This overrides any settings for individual activities.  If force is set to no, then activities are only group activities if they have been set to group mode.  In this case, each activity requires to be set to group mode individually.&lt;br /&gt;
&lt;br /&gt;
===How do I assign a teacher to a group? Can a teacher be in more than one group?===&lt;br /&gt;
&lt;br /&gt;
You can assign a teacher to a group in exactly the same way that you assign a student to a group. In 1.5, a teacher cannot be in more than one group. This has changed in 1.6.&lt;br /&gt;
&lt;br /&gt;
===How do I restrict a teacher to view only information about the groups that they are in?===&lt;br /&gt;
&lt;br /&gt;
For Separate Groups mode, if a teacher has edit rights set to yes, then they can see all groups. If a teacher has edit rights set to no, then they can see only the groups of which they are a member. &lt;br /&gt;
&lt;br /&gt;
===What determines whether students can see a teacher&#039;s profile?===&lt;br /&gt;
&lt;br /&gt;
A student can see the profile of all teachers that are members of their group or that have edit rights. &lt;br /&gt;
&lt;br /&gt;
===I have two groups that meet on different days. Can I set up activities for different times for the two groups?===&lt;br /&gt;
&lt;br /&gt;
Not currently. You can create a separate course for each class using backup and restore, though you do then have to update both courses. &lt;br /&gt;
&lt;br /&gt;
===Can I use the same groups for more than one course?===&lt;br /&gt;
&lt;br /&gt;
Not currently. There are two possible workarounds for this. The first is to give the students group enrolment keys, so they enrol themselves into the right group for each course. The other alternative is to create a master course with all the students enrolled and in the correct groups, and then to make each of the courses a metacourse based on that master course (although the metacourse documentation claims that metacourses do not preserve groups, this seems to have been used by some people). See the documentation on [[Metacourses]].&lt;br /&gt;
&lt;br /&gt;
===Can a student be a member of more than one group? Is it possible to have students not in any group?===&lt;br /&gt;
&lt;br /&gt;
In 1.5, a student cannot be a member of more than one group. This has changed in 1.6 - a student can be in more than one group. A student does not need to be in a group.&lt;br /&gt;
&lt;br /&gt;
===If I have several groups, can I make a specific activity visible to just one of those groups?===&lt;br /&gt;
&lt;br /&gt;
Not currently. You can however make a forum post visible to just one group. &lt;br /&gt;
&lt;br /&gt;
===Can I have one set of groups for Activity A and another set of groups for Activity B?===&lt;br /&gt;
&lt;br /&gt;
Not currently. &lt;br /&gt;
&lt;br /&gt;
===Is it possible to view all the groups in a course as a list to print out?===&lt;br /&gt;
&lt;br /&gt;
Not currently. &lt;br /&gt;
&lt;br /&gt;
===When I try to add a student, they are always added to the first group, whichever group I select?===&lt;br /&gt;
&lt;br /&gt;
Make sure that the students name does not include any punctuation. There is also a workaround – give each group a temporary name at the start of the alphabet, put your students in the group and then rename the group. &lt;br /&gt;
&lt;br /&gt;
===How can I import a list of students into a group?===&lt;br /&gt;
&lt;br /&gt;
Please check [[Upload users]].&lt;br /&gt;
&lt;br /&gt;
===How can I sort students automatically into groups during enrolment?===&lt;br /&gt;
&lt;br /&gt;
You can make use of enrolment keys. Set an enrolment key on the course settings page (to enforce the enrolment key dialog form when students enrol). That key is only for students who should not be in a group. On the screen for administering groups, you create your groups and by editing the settings of each group, you can add a different enrolment key for each group. When a student enrols, using an enrolment key that is connected to a certain group, the student will automatically be part of that group.&lt;br /&gt;
&lt;br /&gt;
===How can I change the sort order of the participants?===&lt;br /&gt;
&lt;br /&gt;
The admin can change the &amp;quot;fullnamedisplay&amp;quot; which will affect the sort order of participants.&lt;br /&gt;
&lt;br /&gt;
Have your admin go to:&lt;br /&gt;
&lt;br /&gt;
Administration  &amp;gt;&amp;gt;  Configuration &amp;gt;&amp;gt; Variables&lt;br /&gt;
&lt;br /&gt;
Then under &amp;quot;User,&amp;quot; see &amp;quot;fullnamedisplay.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
(Tested using Moodle 1.6.3.)&lt;br /&gt;
&lt;br /&gt;
===Groupings===&lt;br /&gt;
{{Moodle 1.9}}&lt;br /&gt;
In Moodle 1.9+, groupings will be introduced as a hierarchical entity one higher above groups. Groups normally exist within a grouping, but can also be orphan groups. However, administrators and course creators are advised to create all their groups within groupings.&lt;br /&gt;
&lt;br /&gt;
===Orphan groups===&lt;br /&gt;
{{Moodle 1.8}}&lt;br /&gt;
An orphan group is simply a group that doesn&#039;t belong to any grouping.&lt;br /&gt;
&lt;br /&gt;
==Activity modules and groups==&lt;br /&gt;
&lt;br /&gt;
Different activity modules vary as to how they treat groups – some have better support for groups than others! In general if you have questions about how an activity supports groups, you’re advised to post in the forum for the activity module, and not the groups forum. &lt;br /&gt;
&lt;br /&gt;
===What happens if I switch an activity from being in non-groups mode to being in groups mode?===&lt;br /&gt;
&lt;br /&gt;
This depends on the activity module in question.&lt;br /&gt;
&lt;br /&gt;
For forums, posts made before the forum is put into groups mode are visible to all students after you have put the forum into group mode. However students cannot reply to these posts if they have no group (i.e. blank). &lt;br /&gt;
&lt;br /&gt;
===What happens if I change the groups for an activity in groups mode e.g. if I move a student from one group to another?===&lt;br /&gt;
&lt;br /&gt;
Again this depends on the activity module. You may find that grades or activity logs are lost, so check for the specific activity module first. &lt;br /&gt;
&lt;br /&gt;
===How do I post a message in a forum that only one group can see?===&lt;br /&gt;
&lt;br /&gt;
Before you click &#039;Add a new topic&#039;, you need to choose the group from the Separate groups drop-down menu at the top left. &lt;br /&gt;
&lt;br /&gt;
===As a teacher I want to put the same post in each group&#039;s forum with students able to reply to that post. How can I do this?===&lt;br /&gt;
&lt;br /&gt;
You need to post the same message into the forum for each group. There is currently no way to do this in one go if you want students to be able to reply to your post. If you don&#039;t mind students not being able to reply, then you can of course just post the message to all participants.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Teacher]]&lt;br /&gt;
[[Category:Groups]]&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[fr:FAQ des groupes]]&lt;br /&gt;
[[ru:FAQ по группам]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Developer_FAQ&amp;diff=21790</id>
		<title>Developer FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Developer_FAQ&amp;diff=21790"/>
		<updated>2007-03-25T07:30:57Z</updated>

		<summary type="html">&lt;p&gt;Fulano2040: /* How do I insert/retrieve records in the database, without creating my own database connections? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{FAQ}}&lt;br /&gt;
&lt;br /&gt;
==Help for new coders==&lt;br /&gt;
&lt;br /&gt;
===Where can &amp;quot;newbies&amp;quot; to Moodle get help?===&lt;br /&gt;
&lt;br /&gt;
The [http://moodle.org/mod/forum/view.php?f=33 General developer forum]! Feel free to ask any question, no matter how basic or advanced. Many people ask different levels of question every day, and the community is generally welcoming and quick to respond.&lt;br /&gt;
&lt;br /&gt;
==Moodle&#039;s database==&lt;br /&gt;
&lt;br /&gt;
===Where can I see a schema for the structure of the Moodle database?===&lt;br /&gt;
&lt;br /&gt;
When installing Moodle, the database tables are generated and updated by various db-handling scripts located in various places. There is no canonical schema representation, although the [[Coding#Database_structures | coding guidelines for database structure]] give an outline of the general approach.&lt;br /&gt;
&lt;br /&gt;
The reason that the database information isn&#039;t stored in one place is because of Moodle&#039;s &#039;&#039;&#039;modular structure&#039;&#039;&#039;. Each activity module, for example, comes as a folder with script files inside. If the module needs to store information in the database, it must include scripts in a &amp;quot;db&amp;quot; subfolder which define and update the database structure.&lt;br /&gt;
&lt;br /&gt;
==How to get/set information when writing new Moodle code==&lt;br /&gt;
&lt;br /&gt;
===How do I find out the currently-logged-on user?===&lt;br /&gt;
&lt;br /&gt;
The global object $USER, which contains the numeric $USER-&amp;gt;id among other things.&lt;br /&gt;
&lt;br /&gt;
===How do I find out the current course?===&lt;br /&gt;
The global object $COURSE, which contains the numeric $COURSE-&amp;gt;id&lt;br /&gt;
&lt;br /&gt;
===How do I insert/retrieve records in the database, without creating my own database connections?===&lt;br /&gt;
&lt;br /&gt;
Always use the &amp;quot;datalib&amp;quot; functions, such as insert_record() or get_record(). Since Moodle 1.7 these are found in lib/dmllib.php. Using these functions helps with database abstraction (e.g. running on either MySQL or Postgres) as well as maintaining a single database connection. Moodle uses ADODB for database abstraction.&lt;br /&gt;
&lt;br /&gt;
Look at [http://phpdocs.moodle.org/moodlecore/_lib---datalib.php.html  the documentation for datalib.php] for the list of functions and details of use.&lt;br /&gt;
&lt;br /&gt;
===How do I get/set configuration settings?===&lt;br /&gt;
&lt;br /&gt;
To get config values you would typically access the global $CFG object directly, which is automatically created by the core Moodle scripts. To set these &amp;quot;main&amp;quot; config values use set_config($name, $value). The values are stored in the Moodle &amp;quot;config&amp;quot; database table, but these functions take care of cacheing on your behalf, so you should always use these rather than fetching the records directly.&lt;br /&gt;
&lt;br /&gt;
There is also a second table of config settings specifically for plugins (&amp;quot;config_plugin&amp;quot;). These are not automatically loaded into the $CFG object, so to fetch these you would use get_config($plugin, $name). To set them use set_config($name, $value, $plugin).&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=55719 How does date / time in DB convert to real Date / Time?] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category: Developer]]&lt;br /&gt;
[[Category: FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[es:FAQ Desarrollador]]&lt;br /&gt;
[[fr:FAQ de développement]]&lt;/div&gt;</summary>
		<author><name>Fulano2040</name></author>
	</entry>
</feed>