<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/310/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kordan</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/310/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Kordan"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/Special:Contributions/Kordan"/>
	<updated>2026-10-06T12:23:24Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development_talk:Survey_2_brainstorm&amp;diff=82677</id>
		<title>Development talk:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development_talk:Survey_2_brainstorm&amp;diff=82677"/>
		<updated>2011-04-09T07:04:23Z</updated>

		<summary type="html">&lt;p&gt;Kordan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jenny Gray wrote &amp;quot;once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it? &amp;quot;&lt;br /&gt;
&lt;br /&gt;
I do not see the necessity for having the &amp;quot;edit responses&amp;quot; capability for any-one (admin / teacher or student) in a survey-type activity. Once responses have been submitted, they should remain as they are...&lt;br /&gt;
&lt;br /&gt;
--[[User:Joseph Rézeau|Joseph Rézeau]] 08:59, 8 April 2011 (CDT)&lt;br /&gt;
&lt;br /&gt;
Ciao Joseph&lt;br /&gt;
I am the author of the text you cited.&lt;br /&gt;
You are right until we talk about the questionnaire intended as a &amp;quot;pure&amp;quot; educational tool but in a wider sense the list of permissions I reported may become useful. I add some cases, sadly very common to me, in which reported permissions may become important.&lt;br /&gt;
As you know, I am the collector of requests of users asking for web services through moodle at the Italian National Institute of Health.&lt;br /&gt;
&lt;br /&gt;
example 1.&lt;br /&gt;
At national level, we need to collect information about a topic.&lt;br /&gt;
Infos come from hospitals. In each hospital there is administrative staff (group of few persons). Each people in that group needs: to enter info, to update info with the time, to see the record added by his/her colleagues (AND NOT COMING FROM OTHER HOSPITALS) and, maybe, to edit/delete their own records.&lt;br /&gt;
&lt;br /&gt;
example 2.&lt;br /&gt;
At national level, we need to collect information about a topic.&lt;br /&gt;
Infos come from hospitals. In each hospital there is administrative staff (group of few persons). At a defined deadline, data entry has to be denied and people from hospitals is no longer allowed to add/edit/delete records BUT people from NIH is supposed to add some NIH specific additional info and maybe, edit/delete ALL entered records.&lt;br /&gt;
&lt;br /&gt;
Even this, it is a long time I believe the first permissions item (ALL/ALL/ALL) has no sense and is completely useless.&lt;br /&gt;
&lt;br /&gt;
As usual, sorry for my English.&lt;br /&gt;
&lt;br /&gt;
--[[User:Daniele Cordella 2|Daniele Cordella 2]] 02:03, 9 April 2011 (CDT)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development_talk:Survey_2_brainstorm&amp;diff=82676</id>
		<title>Development talk:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development_talk:Survey_2_brainstorm&amp;diff=82676"/>
		<updated>2011-04-09T07:04:03Z</updated>

		<summary type="html">&lt;p&gt;Kordan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jenny Gray wrote &amp;quot;once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it? &amp;quot;&lt;br /&gt;
&lt;br /&gt;
I do not see the necessity for having the &amp;quot;edit responses&amp;quot; capability for any-one (admin / teacher or student) in a survey-type activity. Once responses have been submitted, they should remain as they are...&lt;br /&gt;
&lt;br /&gt;
--[[User:Joseph Rézeau|Joseph Rézeau]] 08:59, 8 April 2011 (CDT)&lt;br /&gt;
&lt;br /&gt;
Ciao Joseph&lt;br /&gt;
I am the author of the text you cited.&lt;br /&gt;
You are right until we talk about the questionnaire intended as a &amp;quot;pure&amp;quot; educational tool but in a wider sense the list of permissions I reported may become useful. I add some cases, sadly very common to me, in which reported permissions may become important.&lt;br /&gt;
As you know, I am the collector of requests of users asking for web services through moodle at the Italian National Institute of Health.&lt;br /&gt;
&lt;br /&gt;
example 1.&lt;br /&gt;
At national level, we need to collect information about a topic.&lt;br /&gt;
Infos come from hospitals. In each hospital there is administrative staff (group of few persons). Each people in that group needs: to enter info, to update info with the time, to see the record added by his/her colleagues (AND NOT COMING FROM OTHER HOSPITALS) and, maybe, to edit/delete their own records.&lt;br /&gt;
&lt;br /&gt;
example 2.&lt;br /&gt;
At national level, we need to collect information about a topic.&lt;br /&gt;
Infos come from hospitals. In each hospital there is administrative staff (group of few persons). At a defined deadline, data entry has to be denied and people from hospitals is no longer allowed to add/edit/delete records BUT people from NIH is supposed to add some NIH specific additional info and maybe, edit/delete ALL entered records.&lt;br /&gt;
&lt;br /&gt;
Even this, it is a long time I believe the first permissions item (ALL/ALL/ALL) has no sense and is completely useless.&lt;br /&gt;
&lt;br /&gt;
As usual, sorry for my English.&lt;br /&gt;
--[[User:Daniele Cordella 2|Daniele Cordella 2]] 02:03, 9 April 2011 (CDT)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development_talk:Survey_2_brainstorm&amp;diff=82675</id>
		<title>Development talk:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development_talk:Survey_2_brainstorm&amp;diff=82675"/>
		<updated>2011-04-09T07:03:00Z</updated>

		<summary type="html">&lt;p&gt;Kordan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Jenny Gray wrote &amp;quot;once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it? &amp;quot;&lt;br /&gt;
&lt;br /&gt;
I do not see the necessity for having the &amp;quot;edit responses&amp;quot; capability for any-one (admin / teacher or student) in a survey-type activity. Once responses have been submitted, they should remain as they are...&lt;br /&gt;
&lt;br /&gt;
--[[User:Joseph Rézeau|Joseph Rézeau]] 08:59, 8 April 2011 (CDT)&lt;br /&gt;
&lt;br /&gt;
Ciao Joseph&lt;br /&gt;
I am the author of the text you cited.&lt;br /&gt;
You are right until we talk about the questionnaire intended as a &amp;quot;pure&amp;quot; educational tool but in a wider sense the list of permissions I reported may become useful. I add some cases, sadly very common to me, in which reportd permissions may become important.&lt;br /&gt;
As you know, I am the collector of requests of users asking for web services through moodle at the Italian National Institute of Health.&lt;br /&gt;
&lt;br /&gt;
example 1.&lt;br /&gt;
At national level, we need to collect information about a topic.&lt;br /&gt;
Infos come from hospitals. In each hospital there is administrative staff (group of few persons). Each people in that group needs: to enter info, to update info with the time, to see the record added by his/her coleegues (AND NOT COMING FROM OTHER HOSPITALS) and, maybe, to edit/delete their own records.&lt;br /&gt;
&lt;br /&gt;
example 2.&lt;br /&gt;
At national level, we need to collect information about a topic.&lt;br /&gt;
Infos come from hospitals. In each hospital there is administrative staff (group of few persons). At a defined deadline, data entry has to be denied and people from hospitals is no longer allowed to add/edit/delete records BUT people from NIH is supposed to add some NIH specific additional info and maybe, edit/delete ALL entered records.&lt;br /&gt;
&lt;br /&gt;
Even this, it is a long time I believe the first permissions item (ALL/ALL/ALL) has no sense and is completely useless.&lt;br /&gt;
&lt;br /&gt;
As usual, sorry for my English.&lt;br /&gt;
--[[User:Daniele Cordella 2|Daniele Cordella 2]] 02:03, 9 April 2011 (CDT)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82364</id>
		<title>Development:Themes 2.0 adding upgrade code</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82364"/>
		<updated>2011-03-29T09:15:02Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Step 2: upgrade.php */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As theme&#039;s have got considerably more advanced in Moodle 2 there is now on occasion a need to write upgrade code for a theme. This quick tutorial looks at just how to do that.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
As part of the Moodle 2 revamp theme&#039;s have been given the same abilities as many of the other plugin types within Moodle. They are now able to have settings pages, database tables, they can override renderers, and they can do all sorts of great things.&lt;br /&gt;
&lt;br /&gt;
Unfortunately this change has its positives and negatives, on the positive you can now really get some cool stuff happening within a theme, the downside is just like any other plugin you need to think about those who are already using your theme when you make changes.&lt;br /&gt;
&lt;br /&gt;
If you are changing the name of a setting, or if you are changing the database schema for the theme you will need to add upgrade code to your theme so that those who are already using your theme are moved along nicely and don&#039;t lose the effort they&#039;ve put into customising and setting up your theme.&lt;br /&gt;
&lt;br /&gt;
==Step 1: version.php==&lt;br /&gt;
For those of you who are already familiar with writing Moodle plugins you will be familiar with the version.php, however for many themer&#039;s the reality is that they&#039;ve never gone beyond adding a settings page so this will be new.&lt;br /&gt;
&lt;br /&gt;
The version.php file is a requirement for many plugin types, however for theme&#039;s it is optional. The idea is that it contains just two or three lines of code that tell Moodle what version the plugin is and a little bit about where it is meant to be, or what version of Moodle it requires. The version.php file for a theme should be created within the theme&#039;s base directory e.g. &#039;&#039;moodle/theme/mythemename/version.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The following is an example of what a version.php file for a theme looks like.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This is the version.php file for my theme.&lt;br /&gt;
 */&lt;br /&gt;
defined(&#039;MOODLE_INTERNAL&#039;) || die;&lt;br /&gt;
&lt;br /&gt;
$plugin-&amp;gt;version   = 2011032900;&lt;br /&gt;
$plugin-&amp;gt;component = &#039;theme_mythemename&#039;;&lt;br /&gt;
$plugin-&amp;gt;requires  = 2010122500;&lt;br /&gt;
$plugin-&amp;gt;maturity  = MATURITY_STABLE;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first thing to notice here is that we are setting properties of an object called $plugin, this object will be used to describe our theme.&lt;br /&gt;
We are setting four properties here, version, component, requires, and maturity. The version property is required and the rest are optional however it is best practice to put them in as well.&lt;br /&gt;
===The version property===&lt;br /&gt;
The version property is the version number of our theme and needs to be an integer, although you can set it to any integer value you want it is &#039;&#039;&#039;HIGHLY&#039;&#039;&#039; recommended to use the date format shown above as it is used everywhere else throughout Moodle.&lt;br /&gt;
&lt;br /&gt;
The format is YYYYMMDDXX :&lt;br /&gt;
# YYYY is the four digit year, e.g. 2011&lt;br /&gt;
# MM is the month with preceding 0 if required, e.g. 03&lt;br /&gt;
# DD is the day with preceding 0 is required, e.g. 28&lt;br /&gt;
# XX is an incrementing value starting at 00, you can increment this if you add several upgrade code blocks on the same day.&lt;br /&gt;
&lt;br /&gt;
As a hint its easiest just to set the version property to today&#039;s date when adding upgrade code, or releasing a version of your theme that introduces something new such as a database table, or config setting.&lt;br /&gt;
&lt;br /&gt;
===The component property===&lt;br /&gt;
The component is used to describe the plugin and its type. In our case we are working with themes and the theme name I have used in my example is mythemename, therefore the component is theme_mythemename.&lt;br /&gt;
&lt;br /&gt;
When installing or upgrading a plugin Moodle checks the component and uses it to make sure that the plugin has been installed in the correct location. This is particularly helpful for the end user as it prevents nasty accidents where they accidentally put a plugin in the wrong place.&lt;br /&gt;
&lt;br /&gt;
If you are working on other types of plugins the component of course will differ, its best to refer to the docs for those plugin types to find out what you would have to use there.&lt;br /&gt;
&lt;br /&gt;
===The requires property===&lt;br /&gt;
The requires property sets the version of Moodle that is required by this plugin. This is particularly handy if your plugin makes use of a feature that was introduced in a specific version of Moodle, or if your plugin relies on a bug fix that was introduced in a specific version.&lt;br /&gt;
&lt;br /&gt;
You can find the current Moodle version by looking at main Moodle version.php file. In the example above I have set my theme to require Moodle 2.0.1 by setting the requires property to Moodle&#039;s version number when that was released. If you are trying to find out a specific version number you can do so by heading to https://github.com/moodle/moodle, changing the tag drop down to the version you desire, then inspecting the version.php file at the bottom of the files list. You should see $version = XXXXXXXXXX;.&lt;br /&gt;
&lt;br /&gt;
===The maturity property===&lt;br /&gt;
This is a property that is expected to be fully supported in Moodle 2.1. It informs Moodle about the state of the code and can be one of the following values:&lt;br /&gt;
; MATURITY_STABLE : Use this when the theme is stable and works well.&lt;br /&gt;
; MATURITY_RC : This marks the theme as a release candidate, users can expect the theme to contain one or two bugs but be largely stable and usable.&lt;br /&gt;
; MATURITY_BETA : This marks the theme as a beta release, users can expect the theme to contain several bugs and for it to be likely to change still.&lt;br /&gt;
; MATURITY_ALPHA : This marks the theme as an alpha release, this is the first release of a new theme and users will expect to find a lot still needs to be done.&lt;br /&gt;
&lt;br /&gt;
==Step 2: upgrade.php==&lt;br /&gt;
This is the main upgrade file. It should be located in a directory called &#039;&#039;db&#039;&#039; located within your theme&#039;s directory, for example &#039;&#039;&#039;moodle/theme/mythemename/db/upgrade.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The upgrade.php file should contain just a single function that needs to be named following a strict naming scheme. In the case of my theme that for this example I&#039;ve called mythemename that function will be as follows:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
defined(&#039;MOODLE_INTERNAL&#039;) || die();&lt;br /&gt;
&lt;br /&gt;
function xmldb_theme_mythemename_upgrade($oldversion) {&lt;br /&gt;
    // We&#039;ll look at what is in here shortly.&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This special function gets called when ever the admin is upgrading the site and gives our theme the opportunity to run any upgrade code it requires.&lt;br /&gt;
&lt;br /&gt;
Upgrade code within this function should be written in a special style where each operation is written as a block and the theme version is upgraded incrementally after each operation.&lt;br /&gt;
&lt;br /&gt;
For the following example lets assume I have two settings for my theme, &#039;&#039;mythemename_settingone&#039;&#039;, and &#039;&#039;mythemename_settingtwo&#039;&#039;. As part of my upgrade I want to rename the settings to mythemename_settinga, and mythemename_settingb.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
defined(&#039;MOODLE_INTERNAL&#039;) || die();&lt;br /&gt;
&lt;br /&gt;
function xmldb_theme_mythemename_upgrade($oldversion) {&lt;br /&gt;
    &lt;br /&gt;
    if ($oldversion &amp;lt; 2011032900) {&lt;br /&gt;
        $currentsetting = get_config(&#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settinga and give it settingone&#039;s value.&lt;br /&gt;
        set_config(&#039;settinga&#039;, $currentsetting-&amp;gt;settingone, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingone&lt;br /&gt;
        unset_config(&#039;settingone&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settingb and give it settingtwo&#039;s value.&lt;br /&gt;
        set_config(&#039;settingb&#039;, $currentsetting-&amp;gt;settingtwo, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingtwo&lt;br /&gt;
        unset_config(&#039;settingtwo&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Upgrade the version that Moodle knows is installed so that this upgrade&lt;br /&gt;
        // isn&#039;t run again.&lt;br /&gt;
        upgrade_plugin_savepoint(true, 2011032900, &#039;theme&#039;, &#039;mythemename&#039;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at this code it does the following things:&lt;br /&gt;
# It compares and the &#039;&#039;&#039;$oldversion&#039;&#039;&#039; to the version we set (2011032900) and our version is newer it runs the upgrade code.&lt;br /&gt;
# The upgrade code gets the current settings so that we can change them.&lt;br /&gt;
# It creates a new setting called settinga and we give it settingb&#039;s value.&lt;br /&gt;
# It deletes settingone as we no longer want it.&lt;br /&gt;
# It repeats the last two steps for settingb/settingtwo.&lt;br /&gt;
# It updates the version Moodle knows is installed by calling &#039;&#039;upgrade_plugin_savepoint&#039;&#039;&lt;br /&gt;
# Finally the function returns true so that the rest of the upgrade continues.&lt;br /&gt;
&lt;br /&gt;
==Done==&lt;br /&gt;
Just like that we have added upgrade code to our theme that renames two settings. To do that we had to add a version.php file and a upgrade.php file.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [[Development:Themes 2.0]]&lt;br /&gt;
* [[Development:Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Development:Themes 2.0 adding a settings page]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82360</id>
		<title>Development:Themes 2.0 adding upgrade code</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82360"/>
		<updated>2011-03-29T07:58:01Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Step 2: upgrade.php */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As theme&#039;s have got considerably more advanced in Moodle 2 there is now on occasion a need to write upgrade code for a theme. This quick tutorial looks at just how to do that.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
As part of the Moodle 2 revamp theme&#039;s have been given the same abilities as many of the other plugin types within Moodle. They are now able to have settings pages, database tables, they can override renderers, and they can do all sorts of great things.&lt;br /&gt;
&lt;br /&gt;
Unfortunately this change has its positives and negatives, on the positive you can now really get some cool stuff happening within a theme, the downside is just like any other plugin you need to think about those who are already using your theme when you make changes.&lt;br /&gt;
&lt;br /&gt;
If you are changing the name of a setting, or if you are changing the database schema for the theme you will need to add upgrade code to your theme so that those who are already using your theme are moved along nicely and don&#039;t lose the effort they&#039;ve put into customising and setting up your theme.&lt;br /&gt;
&lt;br /&gt;
==Step 1: version.php==&lt;br /&gt;
For those of you who are already familiar with writing Moodle plugins you will be familiar with the version.php, however for many themer&#039;s the reality is that they&#039;ve never gone beyond adding a settings page so this will be new.&lt;br /&gt;
&lt;br /&gt;
The version.php file is a requirement for many plugin types, however for theme&#039;s it is optional. The idea is that it contains just two or three lines of code that tell Moodle what version the plugin is and a little bit about where it is meant to be, or what version of Moodle it requires. The version.php file for a theme should be created within the theme&#039;s base directory e.g. &#039;&#039;moodle/theme/mythemename/version.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The following is an example of what a version.php file for a theme looks like.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This is the version.php file for my theme.&lt;br /&gt;
 */&lt;br /&gt;
defined(&#039;MOODLE_INTERNAL&#039;) || die;&lt;br /&gt;
&lt;br /&gt;
$plugin-&amp;gt;version   = 2011032900;&lt;br /&gt;
$plugin-&amp;gt;component = &#039;theme_mythemename&#039;;&lt;br /&gt;
$plugin-&amp;gt;requires  = 2010122500;&lt;br /&gt;
$plugin-&amp;gt;maturity  = MATURITY_STABLE;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first thing to notice here is that we are setting properties of an object called $plugin, this object will be used to describe our theme.&lt;br /&gt;
We are setting four properties here, version, component, requires, and maturity. The version property is required and the rest are optional however it is best practice to put them in as well.&lt;br /&gt;
===The version property===&lt;br /&gt;
The version property is the version number of our theme and needs to be an integer, although you can set it to any integer value you want it is &#039;&#039;&#039;HIGHLY&#039;&#039;&#039; recommended to use the date format shown above as it is used everywhere else throughout Moodle.&lt;br /&gt;
&lt;br /&gt;
The format is YYYYMMDDXX :&lt;br /&gt;
# YYYY is the four digit year, e.g. 2011&lt;br /&gt;
# MM is the month with preceding 0 if required, e.g. 03&lt;br /&gt;
# DD is the day with preceding 0 is required, e.g. 28&lt;br /&gt;
# XX is an incrementing value starting at 00, you can increment this if you add several upgrade code blocks on the same day.&lt;br /&gt;
&lt;br /&gt;
As a hint its easiest just to set the version property to today&#039;s date when adding upgrade code, or releasing a version of your theme that introduces something new such as a database table, or config setting.&lt;br /&gt;
&lt;br /&gt;
===The component property===&lt;br /&gt;
The component is used to describe the plugin and its type. In our case we are working with themes and the theme name I have used in my example is mythemename, therefore the component is theme_mythemename.&lt;br /&gt;
&lt;br /&gt;
When installing or upgrading a plugin Moodle checks the component and uses it to make sure that the plugin has been installed in the correct location. This is particularly helpful for the end user as it prevents nasty accidents where they accidentally put a plugin in the wrong place.&lt;br /&gt;
&lt;br /&gt;
If you are working on other types of plugins the component of course will differ, its best to refer to the docs for those plugin types to find out what you would have to use there.&lt;br /&gt;
&lt;br /&gt;
===The requires property===&lt;br /&gt;
The requires property sets the version of Moodle that is required by this plugin. This is particularly handy if your plugin makes use of a feature that was introduced in a specific version of Moodle, or if your plugin relies on a bug fix that was introduced in a specific version.&lt;br /&gt;
&lt;br /&gt;
You can find the current Moodle version by looking at main Moodle version.php file. In the example above I have set my theme to require Moodle 2.0.1 by setting the requires property to Moodle&#039;s version number when that was released. If you are trying to find out a specific version number you can do so by heading to https://github.com/moodle/moodle, changing the tag drop down to the version you desire, then inspecting the version.php file at the bottom of the files list. You should see $version = XXXXXXXXXX;.&lt;br /&gt;
&lt;br /&gt;
===The maturity property===&lt;br /&gt;
This is a property that is expected to be fully supported in Moodle 2.1. It informs Moodle about the state of the code and can be one of the following values:&lt;br /&gt;
; MATURITY_STABLE : Use this when the theme is stable and works well.&lt;br /&gt;
; MATURITY_RC : This marks the theme as a release candidate, users can expect the theme to contain one or two bugs but be largely stable and usable.&lt;br /&gt;
; MATURITY_BETA : This marks the theme as a beta release, users can expect the theme to contain several bugs and for it to be likely to change still.&lt;br /&gt;
; MATURITY_ALPHA : This marks the theme as an alpha release, this is the first release of a new theme and users will expect to find a lot still needs to be done.&lt;br /&gt;
&lt;br /&gt;
==Step 2: upgrade.php==&lt;br /&gt;
This is the main upgrade file. It should be located in a directory called &#039;&#039;db&#039;&#039; located within your theme&#039;s directory, for example &#039;&#039;&#039;moodle/theme/mythemename/db/upgrade.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The upgrade.php file should contain just a single function that needs to be named following a strict naming scheme. In the case of my theme that for this example I&#039;ve called mythemename that function will be as follows:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_theme_mythemename_upgrade($oldversion) {&lt;br /&gt;
    // We&#039;ll look at what is in here shortly.&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This special function gets called when ever the admin is upgrading the site and gives our theme the opportunity to run any upgrade code it requires.&lt;br /&gt;
&lt;br /&gt;
Upgrade code within this function should be written in a special style where each operation is written as a block and the theme version is upgraded incrementally after each operation.&lt;br /&gt;
&lt;br /&gt;
For the following example lets assume I have two settings for my theme, &#039;&#039;mythemename_settingone&#039;&#039;, and &#039;&#039;mythemename_settingtwo&#039;&#039;. As part of my upgrade I want to rename the settings to mythemename_settinga, and mythemename_settingb.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_theme_mythemename_upgrade($oldversion) {&lt;br /&gt;
    &lt;br /&gt;
    if ($oldversion &amp;lt; 2011032900) {&lt;br /&gt;
        $currentsetting = get_config(&#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settinga and give it settingone&#039;s value.&lt;br /&gt;
        set_config(&#039;settinga&#039;, $currentsetting-&amp;gt;settingone, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingone&lt;br /&gt;
        unset_config(&#039;settingone&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settingb and give it settingtwo&#039;s value.&lt;br /&gt;
        set_config(&#039;settingb&#039;, $currentsetting-&amp;gt;settingtwo, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingtwo&lt;br /&gt;
        unset_config(&#039;settingtwo&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Upgrade the version that Moodle knows is installed so that this upgrade&lt;br /&gt;
        // isn&#039;t run again.&lt;br /&gt;
        upgrade_plugin_savepoint(true, 2011032900, &#039;theme&#039;, &#039;mythemename&#039;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at this code it does the following things:&lt;br /&gt;
# It compares and the &#039;&#039;&#039;$oldversion&#039;&#039;&#039; to the version we set (2011032900) and our version is newer it runs the upgrade code.&lt;br /&gt;
# The upgrade code gets the current settings so that we can change them.&lt;br /&gt;
# It creates a new setting called settinga and we give it settingb&#039;s value.&lt;br /&gt;
# It deletes settingone as we no longer want it.&lt;br /&gt;
# It repeats the last two steps for settingb/settingtwo.&lt;br /&gt;
# It updates the version Moodle knows is installed by calling &#039;&#039;upgrade_plugin_savepoint&#039;&#039;&lt;br /&gt;
# Finally the function returns true so that the rest of the upgrade continues.&lt;br /&gt;
&lt;br /&gt;
==Done==&lt;br /&gt;
Just like that we have added upgrade code to our theme that renames two settings. To do that we had to add a version.php file and a upgrade.php file.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [[Development:Themes 2.0]]&lt;br /&gt;
* [[Development:Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Development:Themes 2.0 adding a settings page]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82359</id>
		<title>Development:Themes 2.0 adding upgrade code</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82359"/>
		<updated>2011-03-29T07:56:28Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Step 2: upgrade.php */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As theme&#039;s have got considerably more advanced in Moodle 2 there is now on occasion a need to write upgrade code for a theme. This quick tutorial looks at just how to do that.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
As part of the Moodle 2 revamp theme&#039;s have been given the same abilities as many of the other plugin types within Moodle. They are now able to have settings pages, database tables, they can override renderers, and they can do all sorts of great things.&lt;br /&gt;
&lt;br /&gt;
Unfortunately this change has its positives and negatives, on the positive you can now really get some cool stuff happening within a theme, the downside is just like any other plugin you need to think about those who are already using your theme when you make changes.&lt;br /&gt;
&lt;br /&gt;
If you are changing the name of a setting, or if you are changing the database schema for the theme you will need to add upgrade code to your theme so that those who are already using your theme are moved along nicely and don&#039;t lose the effort they&#039;ve put into customising and setting up your theme.&lt;br /&gt;
&lt;br /&gt;
==Step 1: version.php==&lt;br /&gt;
For those of you who are already familiar with writing Moodle plugins you will be familiar with the version.php, however for many themer&#039;s the reality is that they&#039;ve never gone beyond adding a settings page so this will be new.&lt;br /&gt;
&lt;br /&gt;
The version.php file is a requirement for many plugin types, however for theme&#039;s it is optional. The idea is that it contains just two or three lines of code that tell Moodle what version the plugin is and a little bit about where it is meant to be, or what version of Moodle it requires. The version.php file for a theme should be created within the theme&#039;s base directory e.g. &#039;&#039;moodle/theme/mythemename/version.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The following is an example of what a version.php file for a theme looks like.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This is the version.php file for my theme.&lt;br /&gt;
 */&lt;br /&gt;
defined(&#039;MOODLE_INTERNAL&#039;) || die;&lt;br /&gt;
&lt;br /&gt;
$plugin-&amp;gt;version   = 2011032900;&lt;br /&gt;
$plugin-&amp;gt;component = &#039;theme_mythemename&#039;;&lt;br /&gt;
$plugin-&amp;gt;requires  = 2010122500;&lt;br /&gt;
$plugin-&amp;gt;maturity  = MATURITY_STABLE;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first thing to notice here is that we are setting properties of an object called $plugin, this object will be used to describe our theme.&lt;br /&gt;
We are setting four properties here, version, component, requires, and maturity. The version property is required and the rest are optional however it is best practice to put them in as well.&lt;br /&gt;
===The version property===&lt;br /&gt;
The version property is the version number of our theme and needs to be an integer, although you can set it to any integer value you want it is &#039;&#039;&#039;HIGHLY&#039;&#039;&#039; recommended to use the date format shown above as it is used everywhere else throughout Moodle.&lt;br /&gt;
&lt;br /&gt;
The format is YYYYMMDDXX :&lt;br /&gt;
# YYYY is the four digit year, e.g. 2011&lt;br /&gt;
# MM is the month with preceding 0 if required, e.g. 03&lt;br /&gt;
# DD is the day with preceding 0 is required, e.g. 28&lt;br /&gt;
# XX is an incrementing value starting at 00, you can increment this if you add several upgrade code blocks on the same day.&lt;br /&gt;
&lt;br /&gt;
As a hint its easiest just to set the version property to today&#039;s date when adding upgrade code, or releasing a version of your theme that introduces something new such as a database table, or config setting.&lt;br /&gt;
&lt;br /&gt;
===The component property===&lt;br /&gt;
The component is used to describe the plugin and its type. In our case we are working with themes and the theme name I have used in my example is mythemename, therefore the component is theme_mythemename.&lt;br /&gt;
&lt;br /&gt;
When installing or upgrading a plugin Moodle checks the component and uses it to make sure that the plugin has been installed in the correct location. This is particularly helpful for the end user as it prevents nasty accidents where they accidentally put a plugin in the wrong place.&lt;br /&gt;
&lt;br /&gt;
If you are working on other types of plugins the component of course will differ, its best to refer to the docs for those plugin types to find out what you would have to use there.&lt;br /&gt;
&lt;br /&gt;
===The requires property===&lt;br /&gt;
The requires property sets the version of Moodle that is required by this plugin. This is particularly handy if your plugin makes use of a feature that was introduced in a specific version of Moodle, or if your plugin relies on a bug fix that was introduced in a specific version.&lt;br /&gt;
&lt;br /&gt;
You can find the current Moodle version by looking at main Moodle version.php file. In the example above I have set my theme to require Moodle 2.0.1 by setting the requires property to Moodle&#039;s version number when that was released. If you are trying to find out a specific version number you can do so by heading to https://github.com/moodle/moodle, changing the tag drop down to the version you desire, then inspecting the version.php file at the bottom of the files list. You should see $version = XXXXXXXXXX;.&lt;br /&gt;
&lt;br /&gt;
===The maturity property===&lt;br /&gt;
This is a property that is expected to be fully supported in Moodle 2.1. It informs Moodle about the state of the code and can be one of the following values:&lt;br /&gt;
; MATURITY_STABLE : Use this when the theme is stable and works well.&lt;br /&gt;
; MATURITY_RC : This marks the theme as a release candidate, users can expect the theme to contain one or two bugs but be largely stable and usable.&lt;br /&gt;
; MATURITY_BETA : This marks the theme as a beta release, users can expect the theme to contain several bugs and for it to be likely to change still.&lt;br /&gt;
; MATURITY_ALPHA : This marks the theme as an alpha release, this is the first release of a new theme and users will expect to find a lot still needs to be done.&lt;br /&gt;
&lt;br /&gt;
==Step 2: upgrade.php==&lt;br /&gt;
This is the main upgrade file. It should be located in a directory called &#039;&#039;db&#039;&#039; located within your theme&#039;s directory, for example &#039;&#039;&#039;moodle/theme/mythemename/db/upgrade.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The upgrade.php file should contain just a single function that needs to be named following a strict naming scheme. In the case of my theme that for this example I&#039;ve called mythemename that function will be as follows:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_mythemename_upgrade($oldversion) {&lt;br /&gt;
    // We&#039;ll look at what is in here shortly.&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This special function gets called when ever the admin is upgrading the site and gives our theme the opportunity to run any upgrade code it requires.&lt;br /&gt;
&lt;br /&gt;
Upgrade code within this function should be written in a special style where each operation is written as a block and the theme version is upgraded incrementally after each operation.&lt;br /&gt;
&lt;br /&gt;
For the following example lets assume I have two settings for my theme, &#039;&#039;mythemename_settingone&#039;&#039;, and &#039;&#039;mythemename_settingtwo&#039;&#039;. As part of my upgrade I want to rename the settings to mythemename_settinga, and mythemename_settingb.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_theme_mythemename_upgrade($oldversion) {&lt;br /&gt;
    &lt;br /&gt;
    if ($oldversion &amp;lt; 2011032900) {&lt;br /&gt;
        $currentsetting = get_config(&#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settinga and give it settingone&#039;s value.&lt;br /&gt;
        set_config(&#039;settinga&#039;, $currentsetting-&amp;gt;settingone, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingone&lt;br /&gt;
        unset_config(&#039;settingone&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settingb and give it settingtwo&#039;s value.&lt;br /&gt;
        set_config(&#039;settingb&#039;, $currentsetting-&amp;gt;settingtwo, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingtwo&lt;br /&gt;
        unset_config(&#039;settingtwo&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Upgrade the version that Moodle knows is installed so that this upgrade&lt;br /&gt;
        // isn&#039;t run again.&lt;br /&gt;
        upgrade_plugin_savepoint(true, 2011032900, &#039;theme&#039;, &#039;mythemename&#039;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at this code it does the following things:&lt;br /&gt;
# It compares and the &#039;&#039;&#039;$oldversion&#039;&#039;&#039; to the version we set (2011032900) and our version is newer it runs the upgrade code.&lt;br /&gt;
# The upgrade code gets the current settings so that we can change them.&lt;br /&gt;
# It creates a new setting called settinga and we give it settingb&#039;s value.&lt;br /&gt;
# It deletes settingone as we no longer want it.&lt;br /&gt;
# It repeats the last two steps for settingb/settingtwo.&lt;br /&gt;
# It updates the version Moodle knows is installed by calling &#039;&#039;upgrade_plugin_savepoint&#039;&#039;&lt;br /&gt;
# Finally the function returns true so that the rest of the upgrade continues.&lt;br /&gt;
&lt;br /&gt;
==Done==&lt;br /&gt;
Just like that we have added upgrade code to our theme that renames two settings. To do that we had to add a version.php file and a upgrade.php file.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [[Development:Themes 2.0]]&lt;br /&gt;
* [[Development:Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Development:Themes 2.0 adding a settings page]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82358</id>
		<title>Development:Themes 2.0 adding upgrade code</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82358"/>
		<updated>2011-03-29T07:52:11Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Step 1: version.php */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As theme&#039;s have got considerably more advanced in Moodle 2 there is now on occasion a need to write upgrade code for a theme. This quick tutorial looks at just how to do that.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
As part of the Moodle 2 revamp theme&#039;s have been given the same abilities as many of the other plugin types within Moodle. They are now able to have settings pages, database tables, they can override renderers, and they can do all sorts of great things.&lt;br /&gt;
&lt;br /&gt;
Unfortunately this change has its positives and negatives, on the positive you can now really get some cool stuff happening within a theme, the downside is just like any other plugin you need to think about those who are already using your theme when you make changes.&lt;br /&gt;
&lt;br /&gt;
If you are changing the name of a setting, or if you are changing the database schema for the theme you will need to add upgrade code to your theme so that those who are already using your theme are moved along nicely and don&#039;t lose the effort they&#039;ve put into customising and setting up your theme.&lt;br /&gt;
&lt;br /&gt;
==Step 1: version.php==&lt;br /&gt;
For those of you who are already familiar with writing Moodle plugins you will be familiar with the version.php, however for many themer&#039;s the reality is that they&#039;ve never gone beyond adding a settings page so this will be new.&lt;br /&gt;
&lt;br /&gt;
The version.php file is a requirement for many plugin types, however for theme&#039;s it is optional. The idea is that it contains just two or three lines of code that tell Moodle what version the plugin is and a little bit about where it is meant to be, or what version of Moodle it requires. The version.php file for a theme should be created within the theme&#039;s base directory e.g. &#039;&#039;moodle/theme/mythemename/version.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The following is an example of what a version.php file for a theme looks like.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This is the version.php file for my theme.&lt;br /&gt;
 */&lt;br /&gt;
defined(&#039;MOODLE_INTERNAL&#039;) || die;&lt;br /&gt;
&lt;br /&gt;
$plugin-&amp;gt;version   = 2011032900;&lt;br /&gt;
$plugin-&amp;gt;component = &#039;theme_mythemename&#039;;&lt;br /&gt;
$plugin-&amp;gt;requires  = 2010122500;&lt;br /&gt;
$plugin-&amp;gt;maturity  = MATURITY_STABLE;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first thing to notice here is that we are setting properties of an object called $plugin, this object will be used to describe our theme.&lt;br /&gt;
We are setting four properties here, version, component, requires, and maturity. The version property is required and the rest are optional however it is best practice to put them in as well.&lt;br /&gt;
===The version property===&lt;br /&gt;
The version property is the version number of our theme and needs to be an integer, although you can set it to any integer value you want it is &#039;&#039;&#039;HIGHLY&#039;&#039;&#039; recommended to use the date format shown above as it is used everywhere else throughout Moodle.&lt;br /&gt;
&lt;br /&gt;
The format is YYYYMMDDXX :&lt;br /&gt;
# YYYY is the four digit year, e.g. 2011&lt;br /&gt;
# MM is the month with preceding 0 if required, e.g. 03&lt;br /&gt;
# DD is the day with preceding 0 is required, e.g. 28&lt;br /&gt;
# XX is an incrementing value starting at 00, you can increment this if you add several upgrade code blocks on the same day.&lt;br /&gt;
&lt;br /&gt;
As a hint its easiest just to set the version property to today&#039;s date when adding upgrade code, or releasing a version of your theme that introduces something new such as a database table, or config setting.&lt;br /&gt;
&lt;br /&gt;
===The component property===&lt;br /&gt;
The component is used to describe the plugin and its type. In our case we are working with themes and the theme name I have used in my example is mythemename, therefore the component is theme_mythemename.&lt;br /&gt;
&lt;br /&gt;
When installing or upgrading a plugin Moodle checks the component and uses it to make sure that the plugin has been installed in the correct location. This is particularly helpful for the end user as it prevents nasty accidents where they accidentally put a plugin in the wrong place.&lt;br /&gt;
&lt;br /&gt;
If you are working on other types of plugins the component of course will differ, its best to refer to the docs for those plugin types to find out what you would have to use there.&lt;br /&gt;
&lt;br /&gt;
===The requires property===&lt;br /&gt;
The requires property sets the version of Moodle that is required by this plugin. This is particularly handy if your plugin makes use of a feature that was introduced in a specific version of Moodle, or if your plugin relies on a bug fix that was introduced in a specific version.&lt;br /&gt;
&lt;br /&gt;
You can find the current Moodle version by looking at main Moodle version.php file. In the example above I have set my theme to require Moodle 2.0.1 by setting the requires property to Moodle&#039;s version number when that was released. If you are trying to find out a specific version number you can do so by heading to https://github.com/moodle/moodle, changing the tag drop down to the version you desire, then inspecting the version.php file at the bottom of the files list. You should see $version = XXXXXXXXXX;.&lt;br /&gt;
&lt;br /&gt;
===The maturity property===&lt;br /&gt;
This is a property that is expected to be fully supported in Moodle 2.1. It informs Moodle about the state of the code and can be one of the following values:&lt;br /&gt;
; MATURITY_STABLE : Use this when the theme is stable and works well.&lt;br /&gt;
; MATURITY_RC : This marks the theme as a release candidate, users can expect the theme to contain one or two bugs but be largely stable and usable.&lt;br /&gt;
; MATURITY_BETA : This marks the theme as a beta release, users can expect the theme to contain several bugs and for it to be likely to change still.&lt;br /&gt;
; MATURITY_ALPHA : This marks the theme as an alpha release, this is the first release of a new theme and users will expect to find a lot still needs to be done.&lt;br /&gt;
&lt;br /&gt;
==Step 2: upgrade.php==&lt;br /&gt;
This is the main upgrade file. It should be located in a directory called &#039;&#039;db&#039;&#039; located within your theme&#039;s directory, for example &#039;&#039;&#039;moodle/theme/mythemename/db/upgrade.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The upgrade.php file should contain just a single function that needs to be named following a strict naming scheme. In the case of my theme that for this example I&#039;ve called mythemename that function will be as follows:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_mythemename_anomaly_upgrade($oldversion) {&lt;br /&gt;
    // We&#039;ll look at what is in here shortly.&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This special function gets called when ever the admin is upgrading the site and gives our theme the opportunity to run any upgrade code it requires.&lt;br /&gt;
&lt;br /&gt;
Upgrade code within this function should be written in a special style where each operation is written as a block and the theme version is upgraded incrementally after each operation.&lt;br /&gt;
&lt;br /&gt;
For the following example lets assume I have two settings for my theme, &#039;&#039;mythemename_settingone&#039;&#039;, and &#039;&#039;mythemename_settingtwo&#039;&#039;. As part of my upgrade I want to rename the settings to mythemename_settinga, and mythemename_settingb.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_theme_mythemename_upgrade($oldversion) {&lt;br /&gt;
    &lt;br /&gt;
    if ($oldversion &amp;lt; 2011032900) {&lt;br /&gt;
        $currentsetting = get_config(&#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settinga and give it settingone&#039;s value.&lt;br /&gt;
        set_config(&#039;settinga&#039;, $currentsetting-&amp;gt;settingone, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingone&lt;br /&gt;
        unset_config(&#039;settingone&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settingb and give it settingtwo&#039;s value.&lt;br /&gt;
        set_config(&#039;settingb&#039;, $currentsetting-&amp;gt;settingtwo, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingtwo&lt;br /&gt;
        unset_config(&#039;settingtwo&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Upgrade the version that Moodle knows is installed so that this upgrade&lt;br /&gt;
        // isn&#039;t run again.&lt;br /&gt;
        upgrade_plugin_savepoint(true, 2011032900, &#039;theme&#039;, &#039;mythemename&#039;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at this code it does the following things:&lt;br /&gt;
# It compares and the &#039;&#039;&#039;$oldversion&#039;&#039;&#039; to the version we set (2011032900) and our version is newer it runs the upgrade code.&lt;br /&gt;
# The upgrade code gets the current settings so that we can change them.&lt;br /&gt;
# It creates a new setting called settinga and we give it settingb&#039;s value.&lt;br /&gt;
# It deletes settingone as we no longer want it.&lt;br /&gt;
# It repeats the last two steps for settingb/settingtwo.&lt;br /&gt;
# It updates the version Moodle knows is installed by calling &#039;&#039;upgrade_plugin_savepoint&#039;&#039;&lt;br /&gt;
# Finally the function returns true so that the rest of the upgrade continues.&lt;br /&gt;
&lt;br /&gt;
==Done==&lt;br /&gt;
Just like that we have added upgrade code to our theme that renames two settings. To do that we had to add a version.php file and a upgrade.php file.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [[Development:Themes 2.0]]&lt;br /&gt;
* [[Development:Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Development:Themes 2.0 adding a settings page]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82357</id>
		<title>Development:Themes 2.0 adding upgrade code</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82357"/>
		<updated>2011-03-29T07:51:22Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Step 1: version.php */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As theme&#039;s have got considerably more advanced in Moodle 2 there is now on occasion a need to write upgrade code for a theme. This quick tutorial looks at just how to do that.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
As part of the Moodle 2 revamp theme&#039;s have been given the same abilities as many of the other plugin types within Moodle. They are now able to have settings pages, database tables, they can override renderers, and they can do all sorts of great things.&lt;br /&gt;
&lt;br /&gt;
Unfortunately this change has its positives and negatives, on the positive you can now really get some cool stuff happening within a theme, the downside is just like any other plugin you need to think about those who are already using your theme when you make changes.&lt;br /&gt;
&lt;br /&gt;
If you are changing the name of a setting, or if you are changing the database schema for the theme you will need to add upgrade code to your theme so that those who are already using your theme are moved along nicely and don&#039;t lose the effort they&#039;ve put into customising and setting up your theme.&lt;br /&gt;
&lt;br /&gt;
==Step 1: version.php==&lt;br /&gt;
For those of you who are already familiar with writing Moodle plugins you will be familiar with the version.php, however for many themer&#039;s the reality is that they&#039;ve never gone beyond adding a settings page so this will be new.&lt;br /&gt;
&lt;br /&gt;
The version.php file is a requirement for many plugin types, however for theme&#039;s it is optional. The idea is that it contains just two or three lines of code that tell Moodle what version the plugin is and a little bit about where it is meant to be, or what version of Moodle it requires. The version.php file for a theme should be created within the theme&#039;s base directory e.g. &#039;&#039;moodle/theme/mythemename/version.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The following is an example of what a version.php file for a theme looks like.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This is the version.php file for my theme.&lt;br /&gt;
 */&lt;br /&gt;
defined(&#039;MOODLE_INTERNAL&#039;) || die;&lt;br /&gt;
&lt;br /&gt;
$plugin-&amp;gt;version   = 2011032900;&lt;br /&gt;
$plugin-&amp;gt;component = &#039;theme_mythemename&#039;;&lt;br /&gt;
$plugin-&amp;gt;requires  = 2010122500;&lt;br /&gt;
$plugin-&amp;gt;maturity  = MATURITY_STABLE;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first thing to notice here is that we are setting properties of an object called $plugin, this object will be used to describe our theme.&lt;br /&gt;
We are setting four properties here, version, component, requires, and maturity. The version property is required and the rest are optional however it is best practice to put the in as well.&lt;br /&gt;
===The version property===&lt;br /&gt;
The version property is the version number of our theme and needs to be an integer, although you can set it to any integer value you want it is &#039;&#039;&#039;HIGHLY&#039;&#039;&#039; recommended to use the date format shown above as it is used everywhere else throughout Moodle.&lt;br /&gt;
&lt;br /&gt;
The format is YYYYMMDDXX :&lt;br /&gt;
# YYYY is the four digit year, e.g. 2011&lt;br /&gt;
# MM is the month with preceding 0 if required, e.g. 03&lt;br /&gt;
# DD is the day with preceding 0 is required, e.g. 28&lt;br /&gt;
# XX is an incrementing value starting at 00, you can increment this if you add several upgrade code blocks on the same day.&lt;br /&gt;
&lt;br /&gt;
As a hint its easiest just to set the version property to today&#039;s date when adding upgrade code, or releasing a version of your theme that introduces something new such as a database table, or config setting.&lt;br /&gt;
&lt;br /&gt;
===The component property===&lt;br /&gt;
The component is used to describe the plugin and its type. In our case we are working with themes and the theme name I have used in my example is mythemename, therefore the component is theme_mythemename.&lt;br /&gt;
&lt;br /&gt;
When installing or upgrading a plugin Moodle checks the component and uses it to make sure that the plugin has been installed in the correct location. This is particularly helpful for the end user as it prevents nasty accidents where they accidentally put a plugin in the wrong place.&lt;br /&gt;
&lt;br /&gt;
If you are working on other types of plugins the component of course will differ, its best to refer to the docs for those plugin types to find out what you would have to use there.&lt;br /&gt;
&lt;br /&gt;
===The requires property===&lt;br /&gt;
The requires property sets the version of Moodle that is required by this plugin. This is particularly handy if your plugin makes use of a feature that was introduced in a specific version of Moodle, or if your plugin relies on a bug fix that was introduced in a specific version.&lt;br /&gt;
&lt;br /&gt;
You can find the current Moodle version by looking at main Moodle version.php file. In the example above I have set my theme to require Moodle 2.0.1 by setting the requires property to Moodle&#039;s version number when that was released. If you are trying to find out a specific version number you can do so by heading to https://github.com/moodle/moodle, changing the tag drop down to the version you desire, then inspecting the version.php file at the bottom of the files list. You should see $version = XXXXXXXXXX;.&lt;br /&gt;
&lt;br /&gt;
===The maturity property===&lt;br /&gt;
This is a property that is expected to be fully supported in Moodle 2.1. It informs Moodle about the state of the code and can be one of the following values:&lt;br /&gt;
; MATURITY_STABLE : Use this when the theme is stable and works well.&lt;br /&gt;
; MATURITY_RC : This marks the theme as a release candidate, users can expect the theme to contain one or two bugs but be largely stable and usable.&lt;br /&gt;
; MATURITY_BETA : This marks the theme as a beta release, users can expect the theme to contain several bugs and for it to be likely to change still.&lt;br /&gt;
; MATURITY_ALPHA : This marks the theme as an alpha release, this is the first release of a new theme and users will expect to find a lot still needs to be done.&lt;br /&gt;
&lt;br /&gt;
==Step 2: upgrade.php==&lt;br /&gt;
This is the main upgrade file. It should be located in a directory called &#039;&#039;db&#039;&#039; located within your theme&#039;s directory, for example &#039;&#039;&#039;moodle/theme/mythemename/db/upgrade.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The upgrade.php file should contain just a single function that needs to be named following a strict naming scheme. In the case of my theme that for this example I&#039;ve called mythemename that function will be as follows:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_mythemename_anomaly_upgrade($oldversion) {&lt;br /&gt;
    // We&#039;ll look at what is in here shortly.&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This special function gets called when ever the admin is upgrading the site and gives our theme the opportunity to run any upgrade code it requires.&lt;br /&gt;
&lt;br /&gt;
Upgrade code within this function should be written in a special style where each operation is written as a block and the theme version is upgraded incrementally after each operation.&lt;br /&gt;
&lt;br /&gt;
For the following example lets assume I have two settings for my theme, &#039;&#039;mythemename_settingone&#039;&#039;, and &#039;&#039;mythemename_settingtwo&#039;&#039;. As part of my upgrade I want to rename the settings to mythemename_settinga, and mythemename_settingb.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_theme_mythemename_upgrade($oldversion) {&lt;br /&gt;
    &lt;br /&gt;
    if ($oldversion &amp;lt; 2011032900) {&lt;br /&gt;
        $currentsetting = get_config(&#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settinga and give it settingone&#039;s value.&lt;br /&gt;
        set_config(&#039;settinga&#039;, $currentsetting-&amp;gt;settingone, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingone&lt;br /&gt;
        unset_config(&#039;settingone&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settingb and give it settingtwo&#039;s value.&lt;br /&gt;
        set_config(&#039;settingb&#039;, $currentsetting-&amp;gt;settingtwo, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingtwo&lt;br /&gt;
        unset_config(&#039;settingtwo&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Upgrade the version that Moodle knows is installed so that this upgrade&lt;br /&gt;
        // isn&#039;t run again.&lt;br /&gt;
        upgrade_plugin_savepoint(true, 2011032900, &#039;theme&#039;, &#039;mythemename&#039;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at this code it does the following things:&lt;br /&gt;
# It compares and the &#039;&#039;&#039;$oldversion&#039;&#039;&#039; to the version we set (2011032900) and our version is newer it runs the upgrade code.&lt;br /&gt;
# The upgrade code gets the current settings so that we can change them.&lt;br /&gt;
# It creates a new setting called settinga and we give it settingb&#039;s value.&lt;br /&gt;
# It deletes settingone as we no longer want it.&lt;br /&gt;
# It repeats the last two steps for settingb/settingtwo.&lt;br /&gt;
# It updates the version Moodle knows is installed by calling &#039;&#039;upgrade_plugin_savepoint&#039;&#039;&lt;br /&gt;
# Finally the function returns true so that the rest of the upgrade continues.&lt;br /&gt;
&lt;br /&gt;
==Done==&lt;br /&gt;
Just like that we have added upgrade code to our theme that renames two settings. To do that we had to add a version.php file and a upgrade.php file.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [[Development:Themes 2.0]]&lt;br /&gt;
* [[Development:Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Development:Themes 2.0 adding a settings page]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82356</id>
		<title>Development:Themes 2.0 adding upgrade code</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_adding_upgrade_code&amp;diff=82356"/>
		<updated>2011-03-29T07:49:18Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Step 1: version.php */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;As theme&#039;s have got considerably more advanced in Moodle 2 there is now on occasion a need to write upgrade code for a theme. This quick tutorial looks at just how to do that.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
As part of the Moodle 2 revamp theme&#039;s have been given the same abilities as many of the other plugin types within Moodle. They are now able to have settings pages, database tables, they can override renderers, and they can do all sorts of great things.&lt;br /&gt;
&lt;br /&gt;
Unfortunately this change has its positives and negatives, on the positive you can now really get some cool stuff happening within a theme, the downside is just like any other plugin you need to think about those who are already using your theme when you make changes.&lt;br /&gt;
&lt;br /&gt;
If you are changing the name of a setting, or if you are changing the database schema for the theme you will need to add upgrade code to your theme so that those who are already using your theme are moved along nicely and don&#039;t lose the effort they&#039;ve put into customising and setting up your theme.&lt;br /&gt;
&lt;br /&gt;
==Step 1: version.php==&lt;br /&gt;
For those of you who are already familiar with writing Moodle plugins you will be familiar with the version.php, however for many themer&#039;s the reality is that they&#039;ve never gone beyond adding a settings page so this will be new.&lt;br /&gt;
&lt;br /&gt;
The version.php file is a requirement for many plugin types, however for theme&#039;s it is optional. The idea is that it contains just two or three lines of code that tell Moodle what version the plugin is and a little bit about where it is meant to be, or what version of Moodle it requires. The version.php file for a theme should be created within the theme&#039;s base directory e.g. &#039;&#039;moodle/theme/mythemename/version.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The following is an example of what a version.php file for a theme looks like.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
/**&lt;br /&gt;
 * This is the version.php file for my theme.&lt;br /&gt;
 */&lt;br /&gt;
$plugin-&amp;gt;version   = 2011032900;&lt;br /&gt;
$plugin-&amp;gt;component = &#039;theme_mythemename&#039;;&lt;br /&gt;
$plugin-&amp;gt;requires  = 2010122500;&lt;br /&gt;
$plugin-&amp;gt;maturity  = MATURITY_STABLE;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first thing to notice here is that we are setting properties of an object called $plugin, this object will be used to describe our theme.&lt;br /&gt;
We are setting four properties here, version, component, requires, and maturity. The version property is required and the rest are optional however it is best practice to put the in as well.&lt;br /&gt;
===The version property===&lt;br /&gt;
The version property is the version number of our theme and needs to be an integer, although you can set it to any integer value you want it is &#039;&#039;&#039;HIGHLY&#039;&#039;&#039; recommended to use the date format shown above as it is used everywhere else throughout Moodle.&lt;br /&gt;
&lt;br /&gt;
The format is YYYYMMDDXX :&lt;br /&gt;
# YYYY is the four digit year, e.g. 2011&lt;br /&gt;
# MM is the month with preceding 0 if required, e.g. 03&lt;br /&gt;
# DD is the day with preceding 0 is required, e.g. 28&lt;br /&gt;
# XX is an incrementing value starting at 00, you can increment this if you add several upgrade code blocks on the same day.&lt;br /&gt;
&lt;br /&gt;
As a hint its easiest just to set the version property to today&#039;s date when adding upgrade code, or releasing a version of your theme that introduces something new such as a database table, or config setting.&lt;br /&gt;
&lt;br /&gt;
===The component property===&lt;br /&gt;
The component is used to describe the plugin and its type. In our case we are working with themes and the theme name I have used in my example is mythemename, therefore the component is theme_mythemename.&lt;br /&gt;
&lt;br /&gt;
When installing or upgrading a plugin Moodle checks the component and uses it to make sure that the plugin has been installed in the correct location. This is particularly helpful for the end user as it prevents nasty accidents where they accidentally put a plugin in the wrong place.&lt;br /&gt;
&lt;br /&gt;
If you are working on other types of plugins the component of course will differ, its best to refer to the docs for those plugin types to find out what you would have to use there.&lt;br /&gt;
&lt;br /&gt;
===The requires property===&lt;br /&gt;
The requires property sets the version of Moodle that is required by this plugin. This is particularly handy if your plugin makes use of a feature that was introduced in a specific version of Moodle, or if your plugin relies on a bug fix that was introduced in a specific version.&lt;br /&gt;
&lt;br /&gt;
You can find the current Moodle version by looking at main Moodle version.php file. In the example above I have set my theme to require Moodle 2.0.1 by setting the requires property to Moodle&#039;s version number when that was released. If you are trying to find out a specific version number you can do so by heading to https://github.com/moodle/moodle, changing the tag drop down to the version you desire, then inspecting the version.php file at the bottom of the files list. You should see $version = XXXXXXXXXX;.&lt;br /&gt;
&lt;br /&gt;
===The maturity property===&lt;br /&gt;
This is a property that is expected to be fully supported in Moodle 2.1. It informs Moodle about the state of the code and can be one of the following values:&lt;br /&gt;
; MATURITY_STABLE : Use this when the theme is stable and works well.&lt;br /&gt;
; MATURITY_RC : This marks the theme as a release candidate, users can expect the theme to contain one or two bugs but be largely stable and usable.&lt;br /&gt;
; MATURITY_BETA : This marks the theme as a beta release, users can expect the theme to contain several bugs and for it to be likely to change still.&lt;br /&gt;
; MATURITY_ALPHA : This marks the theme as an alpha release, this is the first release of a new theme and users will expect to find a lot still needs to be done.&lt;br /&gt;
&lt;br /&gt;
==Step 2: upgrade.php==&lt;br /&gt;
This is the main upgrade file. It should be located in a directory called &#039;&#039;db&#039;&#039; located within your theme&#039;s directory, for example &#039;&#039;&#039;moodle/theme/mythemename/db/upgrade.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The upgrade.php file should contain just a single function that needs to be named following a strict naming scheme. In the case of my theme that for this example I&#039;ve called mythemename that function will be as follows:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_mythemename_anomaly_upgrade($oldversion) {&lt;br /&gt;
    // We&#039;ll look at what is in here shortly.&lt;br /&gt;
&lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This special function gets called when ever the admin is upgrading the site and gives our theme the opportunity to run any upgrade code it requires.&lt;br /&gt;
&lt;br /&gt;
Upgrade code within this function should be written in a special style where each operation is written as a block and the theme version is upgraded incrementally after each operation.&lt;br /&gt;
&lt;br /&gt;
For the following example lets assume I have two settings for my theme, &#039;&#039;mythemename_settingone&#039;&#039;, and &#039;&#039;mythemename_settingtwo&#039;&#039;. As part of my upgrade I want to rename the settings to mythemename_settinga, and mythemename_settingb.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function xmldb_theme_mythemename_upgrade($oldversion) {&lt;br /&gt;
    &lt;br /&gt;
    if ($oldversion &amp;lt; 2011032900) {&lt;br /&gt;
        $currentsetting = get_config(&#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settinga and give it settingone&#039;s value.&lt;br /&gt;
        set_config(&#039;settinga&#039;, $currentsetting-&amp;gt;settingone, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingone&lt;br /&gt;
        unset_config(&#039;settingone&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Create a new config called settingb and give it settingtwo&#039;s value.&lt;br /&gt;
        set_config(&#039;settingb&#039;, $currentsetting-&amp;gt;settingtwo, &#039;theme_mythemename&#039;);&lt;br /&gt;
        // Remove settingtwo&lt;br /&gt;
        unset_config(&#039;settingtwo&#039;, &#039;theme_mythemename&#039;);&lt;br /&gt;
        &lt;br /&gt;
        // Upgrade the version that Moodle knows is installed so that this upgrade&lt;br /&gt;
        // isn&#039;t run again.&lt;br /&gt;
        upgrade_plugin_savepoint(true, 2011032900, &#039;theme&#039;, &#039;mythemename&#039;);&lt;br /&gt;
    }&lt;br /&gt;
    &lt;br /&gt;
    return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Looking at this code it does the following things:&lt;br /&gt;
# It compares and the &#039;&#039;&#039;$oldversion&#039;&#039;&#039; to the version we set (2011032900) and our version is newer it runs the upgrade code.&lt;br /&gt;
# The upgrade code gets the current settings so that we can change them.&lt;br /&gt;
# It creates a new setting called settinga and we give it settingb&#039;s value.&lt;br /&gt;
# It deletes settingone as we no longer want it.&lt;br /&gt;
# It repeats the last two steps for settingb/settingtwo.&lt;br /&gt;
# It updates the version Moodle knows is installed by calling &#039;&#039;upgrade_plugin_savepoint&#039;&#039;&lt;br /&gt;
# Finally the function returns true so that the rest of the upgrade continues.&lt;br /&gt;
&lt;br /&gt;
==Done==&lt;br /&gt;
Just like that we have added upgrade code to our theme that renames two settings. To do that we had to add a version.php file and a upgrade.php file.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [[Development:Themes 2.0]]&lt;br /&gt;
* [[Development:Themes 2.0 creating your first theme]]&lt;br /&gt;
* [[Development:Themes 2.0 adding a settings page]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82297</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82297"/>
		<updated>2011-03-26T07:15:49Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Uncategorised requested features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (custom html and css, as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons (horizontal &amp;amp; vertical display)&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* checkbox&lt;br /&gt;
* drop down menu&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* date (Example: When were you born?)&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
* short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
* time&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
* &amp;quot;static text&amp;quot;/&amp;quot;read only&amp;quot; fields (auto filled by the software) like, current_date, user_name, record_ID, counter...&lt;br /&gt;
* allocation (Drag and drop)&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* report per survey, per user and per question&lt;br /&gt;
* report about non-respondent users&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use [maybe later]&lt;br /&gt;
* question sets can be used across multiple courses [maybe later]&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a template&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82296</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82296"/>
		<updated>2011-03-26T07:12:35Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Question management */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (custom html and css, as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons (horizontal &amp;amp; vertical display)&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* checkbox&lt;br /&gt;
* drop down menu&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* date (Example: When were you born?)&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
* short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
* time&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
* &amp;quot;static text&amp;quot;/&amp;quot;read only&amp;quot; fields (auto filled by the software) like, current_date, user_name, record_ID, counter...&lt;br /&gt;
* allocation (Drag and drop)&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* report per survey, per user and per question&lt;br /&gt;
* report about non-respondent users&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use [maybe later]&lt;br /&gt;
* question sets can be used across multiple courses [maybe later]&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a template&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82295</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82295"/>
		<updated>2011-03-26T06:58:12Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Result display */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (custom html and css, as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons (horizontal &amp;amp; vertical display)&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* checkbox&lt;br /&gt;
* drop down menu&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* date (Example: When were you born?)&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
* short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
* time&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
* &amp;quot;static text&amp;quot;/&amp;quot;read only&amp;quot; fields (auto filled by the software) like, current_date, user_name, record_ID, counter...&lt;br /&gt;
* allocation (Drag and drop)&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* report per survey, per user and per question&lt;br /&gt;
* report about non-respondent users&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82294</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82294"/>
		<updated>2011-03-26T06:57:32Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Instance settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (custom html and css, as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons (horizontal &amp;amp; vertical display)&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* checkbox&lt;br /&gt;
* drop down menu&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* date (Example: When were you born?)&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
* short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
* time&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
* &amp;quot;static text&amp;quot;/&amp;quot;read only&amp;quot; fields (auto filled by the software) like, current_date, user_name, record_ID, counter...&lt;br /&gt;
* allocation (Drag and drop)&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82293</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82293"/>
		<updated>2011-03-26T06:55:56Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* General features of the Module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (custom html and css, as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons (horizontal &amp;amp; vertical display)&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* checkbox&lt;br /&gt;
* drop down menu&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* date (Example: When were you born?)&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
* short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
* time&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
* &amp;quot;static text&amp;quot;/&amp;quot;read only&amp;quot; fields (auto filled by the software) like, current_date, user_name, record_ID, counter...&lt;br /&gt;
* allocation (Drag and drop)&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82292</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82292"/>
		<updated>2011-03-26T06:55:07Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* General features of the Module */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons (horizontal &amp;amp; vertical display)&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* checkbox&lt;br /&gt;
* drop down menu&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* date (Example: When were you born?)&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
* short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
* time&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
* &amp;quot;static text&amp;quot;/&amp;quot;read only&amp;quot; fields (auto filled by the software) like, current_date, user_name, record_ID, counter...&lt;br /&gt;
* allocation (Drag and drop)&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82291</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82291"/>
		<updated>2011-03-26T06:53:09Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Instance settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons (horizontal &amp;amp; vertical display)&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* checkbox&lt;br /&gt;
* drop down menu&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* date (Example: When were you born?)&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
* short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
* time&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
* &amp;quot;static text&amp;quot;/&amp;quot;read only&amp;quot; fields (auto filled by the software) like, current_date, user_name, record_ID, counter...&lt;br /&gt;
* allocation (Drag and drop)&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82290</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82290"/>
		<updated>2011-03-26T06:51:54Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Question types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: anonymous survey or named responses&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons (horizontal &amp;amp; vertical display)&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* checkbox&lt;br /&gt;
* drop down menu&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* date (Example: When were you born?)&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
* short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
* time&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
* &amp;quot;static text&amp;quot;/&amp;quot;read only&amp;quot; fields (auto filled by the software) like, current_date, user_name, record_ID, counter...&lt;br /&gt;
* allocation (Drag and drop)&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82289</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82289"/>
		<updated>2011-03-26T06:48:52Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Instance settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: anonymous survey or named responses&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons&lt;br /&gt;
** horizontal &amp;amp; vertical&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* allocation&lt;br /&gt;
* checkbox&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82288</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82288"/>
		<updated>2011-03-26T06:48:22Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Field level settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: anonymous survey or named responses&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons&lt;br /&gt;
** horizontal &amp;amp; vertical&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* allocation&lt;br /&gt;
* checkbox&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82287</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82287"/>
		<updated>2011-03-26T06:47:37Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Field level settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: anonymous survey or named responses&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
===Field level settings===&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
* define a range of valid answers for fields allowing this&lt;br /&gt;
&lt;br /&gt;
(Example 1: Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
Example 2: Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
* define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
* optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
&lt;br /&gt;
(Example for drop down: Where were you born? If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons&lt;br /&gt;
** horizontal &amp;amp; vertical&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* allocation&lt;br /&gt;
* checkbox&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82286</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82286"/>
		<updated>2011-03-26T06:44:11Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Instance settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: anonymous survey or named responses&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
* option: allow/deny save without submission (save and restart)&lt;br /&gt;
* option: anonymous survey or named responses&lt;br /&gt;
* option: allow access to records any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
* opening and closing submission dates&lt;br /&gt;
* number of maximun allowed submission&lt;br /&gt;
===Field level settings===&lt;br /&gt;
* type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields). This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example: Please, enter your card ID: _______ This field should be defined, for instance, as char(7))&lt;br /&gt;
* option: mandatory/non mandatory field&lt;br /&gt;
* free text description field for further description and advices to the completer&lt;br /&gt;
* define a range of valid answers for fields allowing this&lt;br /&gt;
&lt;br /&gt;
(Example 1: Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
Example 2: Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
* define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
* optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
&lt;br /&gt;
(Example for drop down: Where were you born? If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.)&lt;br /&gt;
* custom question numbers&lt;br /&gt;
* question name to name columns header in the downloaded document&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*free text description field for further description and advice to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
* option: allow access to results any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons&lt;br /&gt;
** horizontal &amp;amp; vertical&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* allocation&lt;br /&gt;
* checkbox&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82285</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=82285"/>
		<updated>2011-03-26T06:40:05Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Module settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is for collecting feature requests for a new Survey module that replaces Survey, Questionnaire and Feedback.&lt;br /&gt;
&lt;br /&gt;
==General features of the Module==&lt;br /&gt;
* translate previously built survery1, feedback and questionnaire at installation time&lt;br /&gt;
* upload exported feedback or questionnaires (survey1 doesn&#039;t export questionnaires templates)&lt;br /&gt;
* save instances of survey2 as a template to reuse it or export it&lt;br /&gt;
* import saved survey2 templates&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* custom user survey2 page layout (as it already is in database module)&lt;br /&gt;
* download of submissions in txt, xls and ods&lt;br /&gt;
* conditional branching&lt;br /&gt;
* handle more than one input form layout (and find a way to allow this or that layout to this or that user).&lt;br /&gt;
* order survey fields in editing mode&lt;br /&gt;
* group fields in the page layout with fieldset&lt;br /&gt;
* relations between tables (Example: one record for the profile of my company one related record for each intervention request submitted by my company)&lt;br /&gt;
* email submissions to students/teachers/both/none&lt;br /&gt;
==Instance settings page==&lt;br /&gt;
* Access section: 20 types of survey, distinguished by:&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/O,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to R/W,&lt;br /&gt;
:-&amp;gt; ppl who is allowed to delete a record&lt;br /&gt;
The reationale is: once a record has been submitted by a user, who is allowed to see it (R/O access)?, who is allowed to edit it (R/W access)?, who is allowed to delete it?&lt;br /&gt;
&lt;br /&gt;
Combining all the options the come out 20 cases are defined as follows where:&lt;br /&gt;
:ALL means, all the people accessing the survey;&lt;br /&gt;
:GROUP means people belonging to the group of the user who submitted the record;&lt;br /&gt;
:OWNER is the user who submitted the record;&lt;br /&gt;
:NONE is none.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! type&lt;br /&gt;
! R/O&lt;br /&gt;
! R/W&lt;br /&gt;
! delete&lt;br /&gt;
|-&lt;br /&gt;
| 1&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
|-&lt;br /&gt;
| 2&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 3&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 4&lt;br /&gt;
| ALL&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 5&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 6&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 7&lt;br /&gt;
| ALL&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 8&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 9&lt;br /&gt;
| ALL&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 10&lt;br /&gt;
| ALL&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 11&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
|-&lt;br /&gt;
| 12&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 13&lt;br /&gt;
| GROUP&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 14&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 15&lt;br /&gt;
| GROUP&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 16&lt;br /&gt;
| GROUP&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 17&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
|-&lt;br /&gt;
| 18&lt;br /&gt;
| OWNER&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 19&lt;br /&gt;
| OWNER&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|-&lt;br /&gt;
| 20&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
| NONE&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: anonymous survey or named responses&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
* option: allow access to results any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
** fine-grain control for result display at question level also&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check. (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates (displayed on calendar)&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
=== Standard module settings ===&lt;br /&gt;
&lt;br /&gt;
* support for groups and groupings&lt;br /&gt;
* permission control for which roles can create surveys&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*free text description field for further description and advice to the completer&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
* option: allow access to results any time/after you&#039;ve submitted/after close date/never&lt;br /&gt;
&lt;br /&gt;
==Question types==&lt;br /&gt;
&lt;br /&gt;
Question types should be plug-ins so that they can be extended locally if required.  The following list covers types which exist in at least one of the current survey modules.&lt;br /&gt;
&lt;br /&gt;
* radio buttons&lt;br /&gt;
** horizontal &amp;amp; vertical&lt;br /&gt;
* short text entry&lt;br /&gt;
* long text entry&lt;br /&gt;
* allocation&lt;br /&gt;
* checkbox&lt;br /&gt;
* customisable likert scale for rating&lt;br /&gt;
* ranking&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===New question types===&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Result display==&lt;br /&gt;
&lt;br /&gt;
* choose for a question whether to display results as&lt;br /&gt;
** a table&lt;br /&gt;
** a bar chart&lt;br /&gt;
** a pie chart&lt;br /&gt;
* option whether to show results immediately after submission, or a thank you message with link to results.&lt;br /&gt;
&lt;br /&gt;
==Question management==&lt;br /&gt;
&lt;br /&gt;
* questions can be copied within an activity&lt;br /&gt;
* question sets can be created as templates for re-use&lt;br /&gt;
* question sets can be used across multiple courses&lt;br /&gt;
* questions can be re-ordered within an activity&lt;br /&gt;
* question sets can be combined to create a questionnaire&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow update of submitted questionnaire as an option (not just a clean slate on the next go-round)&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Answer Piping &amp;amp; Conditional Questions==&lt;br /&gt;
&lt;br /&gt;
*Allow follow on questions related to the previous.&lt;br /&gt;
*Do You Smoke? Yes/No If Yes is selected a conditional question appears, How Many per Day, if No is selected move on to question 6 appears&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Answer Piping such as:&lt;br /&gt;
*Q1 Which dog breed do you prefer?&lt;br /&gt;
*Labrador&lt;br /&gt;
*Spaniel&lt;br /&gt;
*Collie&lt;br /&gt;
*Other&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Q2 In question 1 you stated you prefer the (Q1 Answer) as a breed, what do you like about it. [Where (Q1 Answer) is replaced with the chosen answer such as &#039;Labrador&#039;&lt;br /&gt;
*Temperament&lt;br /&gt;
*Looks&lt;br /&gt;
*Colour&lt;br /&gt;
*Other&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81049</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81049"/>
		<updated>2011-02-03T11:23:09Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Field level settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check. (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this (see next examples)&lt;br /&gt;
(Example 1:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example 2:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81048</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81048"/>
		<updated>2011-02-03T11:22:22Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Uncategorised requested features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check. (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years) (see next example)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching (see next example)&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81047</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81047"/>
		<updated>2011-02-03T11:22:04Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* New fields types */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check. (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years) (see next example)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81046</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81046"/>
		<updated>2011-02-03T11:21:41Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Field level settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check. (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years) (see next example)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box. (see next example)&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81045</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81045"/>
		<updated>2011-02-03T11:21:16Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Module settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submission&lt;br /&gt;
*option: allow/deny record modification after submission&lt;br /&gt;
*option: allow/deny the read only access to submitted records (see next example)&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available/visible &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check. (see next example)&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81044</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81044"/>
		<updated>2011-02-03T11:15:52Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Module settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny the access to submitted records&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81043</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81043"/>
		<updated>2011-02-03T11:15:28Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Module settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny the access to submitted records&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81042</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=81042"/>
		<updated>2011-02-03T11:15:03Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Module settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny the access to submitted answers&lt;br /&gt;
*option: allow/deny submitted record deletion&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*custom form and css&lt;br /&gt;
*download of submitted records in some standard format&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80839</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80839"/>
		<updated>2011-01-26T14:31:09Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Debian Lenny */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MSSQL Support&lt;br /&gt;
! enabled&lt;br /&gt;
|-&lt;br /&gt;
| Library version &lt;br /&gt;
| FreeTDS &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Once FreeTDS is correctly installed, don not forget to set it up following explanations in https://docs.moodle.org/en/FreeTDS&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] a new SQL Server 2005 Driver for PHP. This is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts and it overcomes the problems with the native SQL Server extension that was previously included with PHP.&lt;br /&gt;
&lt;br /&gt;
This driver is the standard database layer for running Moodle 2 under Microsoft SQL Server databases. See [[Using the Microsoft SQL Server Driver for PHP]] the installation and configuration details.&lt;br /&gt;
&lt;br /&gt;
This driver is only supported in Moodle 2.0 and up. You should use FreeTDS if you are installing an older version of Moodle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
MDL-16497&lt;br /&gt;
&lt;br /&gt;
MDL-15093&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80830</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80830"/>
		<updated>2011-01-26T11:16:49Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Debian Lenny */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! MSSQL Support&lt;br /&gt;
! enabled&lt;br /&gt;
|-&lt;br /&gt;
| Library version &lt;br /&gt;
| FreeTDS &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80829</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80829"/>
		<updated>2011-01-26T11:13:06Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Debian Lenny */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the end of the process, if all goes fine, you will find in the mssql section of phpinfo();&lt;br /&gt;
Library version: FreeTDS&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80828</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80828"/>
		<updated>2011-01-26T11:12:42Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Debian Lenny */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the end of the process, if all goes fine, you will find in teh mssql section of phpinfo();&lt;br /&gt;
Library version: FreeTDS&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80827</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80827"/>
		<updated>2011-01-26T11:11:59Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Debian Lenny */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
At the and you will find in teh mssql section of phpinfo();&lt;br /&gt;
Library version 	FreeTDS&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80826</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80826"/>
		<updated>2011-01-26T11:10:04Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Debian Lenny */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
I found the following solution using:&lt;br /&gt;
* PHP Version 5.2.6-1+lenny9&lt;br /&gt;
* Microsoft SQL Server Enterprise Edition, version: 9.00.4053.00&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80825</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80825"/>
		<updated>2011-01-26T10:57:01Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Debian Lenny */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
&amp;lt;pre&amp;gt;apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80824</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80824"/>
		<updated>2011-01-26T10:55:44Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Debian Lenny */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
&lt;br /&gt;
/etc/init.d/apache2 restart&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80823</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80823"/>
		<updated>2011-01-26T10:55:16Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Ubuntu by compiling an mssql.so extension */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Debian Lenny ==&lt;br /&gt;
apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80822</id>
		<title>Installing MSSQL for PHP</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Installing_MSSQL_for_PHP&amp;diff=80822"/>
		<updated>2011-01-26T10:54:38Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Using FreeTDS on Ubuntu by compiling an mssql.so extension */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.7}}{{Moodle 1.9}}{{Moodle 2.0}}&lt;br /&gt;
== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This short manual is suitable if you are trying to run Moodle 1.7 (and upwards) using the SQL*Server (MSSQL) RDBMS. Steps detailed below must be performed &#039;&#039;&#039;before&#039;&#039;&#039; installing Moodle itself.&lt;br /&gt;
&lt;br /&gt;
Some of this may also apply if you wish to access an MSSQL server for external db authentication/enrollment. &lt;br /&gt;
&lt;br /&gt;
First of all, minimum required version of MSSQL has been stabilised to MSSQL 2005 (v.9), although it &#039;&#039;&#039;might work with MSSQL 2000 (v.8) or newer&#039;&#039;&#039;. All the development process has been performed using MSSQL 2005 and there could be some &#039;&#039;&#039;unknown problems&#039;&#039;&#039; with previous releases.&lt;br /&gt;
&lt;br /&gt;
While PHP comes with one, more or less, standard extension (mssql) that provides access to MSSQL databases, early we found some hard limits on it. Basically such default extension has some limits that prevent us to use it at all (you can find more info about these problems [[Development:XMLDB problems#MSSQL, PHP, UTF-8 and UCS-2|here]]).&lt;br /&gt;
&lt;br /&gt;
So, in order to allow PHP (i.e. Moodle) to access to MSSQL DBs properly we have to install a &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; to save us from the problems related above. See the sections below for details about the various options.&lt;br /&gt;
&lt;br /&gt;
== Installation overview ==&lt;br /&gt;
&lt;br /&gt;
1. Get MSSQL Server installed and running. ([http://www.microsoft.com/sql/editions/express/default.mspx A free limited version, SQL Server Express Edition] is available for testing.)&lt;br /&gt;
:Make sure that you choose mixed authentication (Windows and local accounts) to keep things simpler later.  You&#039;ll be asked to define the  &amp;quot;sa&amp;quot; account password (it&#039;s the default System Administrator account which has full access to all databases by default).&lt;br /&gt;
&lt;br /&gt;
2. Make sure MS SQL Server can accept incoming TCP/IP connections on port 1433 (the standard one).&lt;br /&gt;
:You might need to explicitly allow this in your Windows firewall (see the Control Panel).  You may also need to edit options in the :&#039;&#039;&#039;SQL Server Configuration Manager&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Network Configuration&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;Protocols&#039;&#039;&#039; -&amp;gt; &#039;&#039;&#039;TCP/IP enabled&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Open the &amp;quot;SQL Server Management Studio&amp;quot; and create a new empty database.  If you are using the &amp;quot;sa&amp;quot; account then you don&#039;t need to do anything else here.&lt;br /&gt;
&lt;br /&gt;
4. Configure these settings in your created (and still empty) database:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true (ALTER DATABASE xxxx SET ANSI_NULLS ON)&lt;br /&gt;
:* Quoted Identifiers Enabled = true (ALTER DATABASE xxxx SET QUOTED_IDENTIFIER ON)&lt;br /&gt;
:* Moodle 2.0 only: Row Versioning Enabled (ALTER DATABASE xxxx SET READ_COMMITTED_SNAPSHOT ON)&lt;br /&gt;
&lt;br /&gt;
5. Get PHP installed with a web server.   Unless you want to do it under IIS or some other way, the packages on the [http://download.moodle.org Moodle download page] are a good solution.&lt;br /&gt;
&lt;br /&gt;
6. Choose one of the following specific sections for your server to install the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; installed and running properly on your PHP box.&lt;br /&gt;
&lt;br /&gt;
7. Set the following settings in your php.ini file&lt;br /&gt;
:* mssql.textlimit = 20971520&lt;br /&gt;
:* mssql.textsize = 20971520&lt;br /&gt;
:Also, don&#039;t forget to set one of the following &#039;&#039;&#039;alternatives&#039;&#039;&#039;, in order to get all the data properly &amp;quot;slashed&amp;quot;:&lt;br /&gt;
:* magic_quotes_gpc = Off  &#039;&#039;&#039;or&#039;&#039;&#039;&lt;br /&gt;
:* magic_quotes_gpc = On &#039;&#039;&#039;and&#039;&#039;&#039; magic_quotes_sybase = On &lt;br /&gt;
&lt;br /&gt;
8. With all this properly configured, you can continue with a [[Installing Moodle|standard Moodle installation]].&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Windows ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;&#039;&#039;&#039;Important Note 1:&#039;&#039;&#039; Due to some previous bugs it&#039;s highly recommendable to use PHP &amp;gt;= 5.2.6 and FreeTDS 0.82 + post-release patches ([http://tracker.moodle.org/browse/MDL-14725 more info]).&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your web server is on Windows, use &#039;&#039;&#039;php_dblib.dll&#039;&#039;&#039;. Despite the name, it&#039;s FreeTDS compiled for Windows. (Go to this page for information on [https://docs.moodle.org/en/FreeTDS Using FreeTDS for Unix].) &lt;br /&gt;
&lt;br /&gt;
Originally we were using the DLLs available at [http://kromann.info/article.php?Id=11062598797760000 Frank Kromann&#039;s site], but they are outdated (using old versions of FreeTDS) and that has caused [http://tracker.moodle.org/browse/MDL-14725 some problems] in the past.&lt;br /&gt;
&lt;br /&gt;
So, right now, the recommended way to use FreeTDS under Windows is to use PHP 5.2.x following the following instructions:&lt;br /&gt;
&lt;br /&gt;
1. Download the appropriate copy of php_dblib.dll from the list below, and save it into your /PHP/ext directory.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot; align=&amp;quot;center&amp;quot; cellpadding=&amp;quot;5&amp;quot; style=&amp;quot;text-align: center;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! PHP version !! [http://www.iis-aid.com/articles/my_word/difference_between_php_thread_safe_and_non_thread_safe_binaries Thread Safe]  !! FreeTDS version !! Download URL&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.2.x (vc6) || Yes || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090302 patches || [http://download.moodle.org/download.php/dblib/php52/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| rowspan=&amp;quot;2&amp;quot; | PHP 5.3.x (vc9) || Yes || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_TS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| No || 0.82 + 20090904 patches || [http://download.moodle.org/download.php/dblib/php53/DBLIB_NOTS.zip Download!]&lt;br /&gt;
|-&lt;br /&gt;
| colspan=&amp;quot;4&amp;quot; |  Thanks to [http://remote-learner.net/ Remote-Learner]] (Moodle [http://moodle.com/partners/ Partner]) and specially to Bryan Williams, donating one Visual C++ 6.0 Pro license to Moodle. Thanks to Trevor Johnson and his builds of the dblib extensions. Thanks to Daniele, Doug, Luis, Sean and many others by their collaboration in MDL-14725. Thanks to Frediano Ziglio and James K. Lowden from [http://freetds.org freetds.org] by their support. Thanks to Alastair Hole by providing the PHP 5.3 builds of the libraries. Thanks!&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
(alternatively here you can find some [[Development:Compiling FreeTDS under Windows|instructions to build those freetds extensions under win32]] yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
2. FreeTDS requires the .NET Framework v1.1 to be installed.  You can [http://www.microsoft.com/downloads/details.aspx?FamilyID=262d25e3-f589-4842-8157-034d1e7cf3a3&amp;amp;DisplayLang=en download it from the Microsoft website] along with its [http://www.microsoft.com/downloads/details.aspx?FamilyID=a8f5654f-088e-40b2-bbdb-a83353618b38&amp;amp;DisplayLang=en service pack].  Alternatively, if you do not wish to install this framework, you can [http://kromann.info/ms-libs/msvcr71.dll download the required DLL] from Frank&#039;s site, and save it into your /PHP root directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
3. Edit your /PHP/php.ini file and add this line:&lt;br /&gt;
&lt;br /&gt;
  extension=php_dblib.dll &lt;br /&gt;
&lt;br /&gt;
Make sure that any lines referring to the php_mssql.dll extension are DISABLED (commented out).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
4. When the PHP engine loads the FreeTDS extension it needs to be passed certain infiormation in order to be able to connect to your Moodle database. To retrieve this information FreeTDS looks for a file called &#039;&#039;&#039;freetds.conf&#039;&#039;&#039; in the root folder of the server that PHP installed on (e.g. C:\).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;freetds.conf&#039;&#039;&#039; should have the following structure:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you want to connect to a particular [http://msdn.microsoft.com/en-us/library/aa174516(SQL.80).aspx instance] of MSSQL you should specify the instance name:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
      host = xxx.xxx.xxx.xxx (host name or ip of the MSSQL server)&lt;br /&gt;
      instance = xxx (instance name, e.g. INST2)&lt;br /&gt;
      port = 1433&lt;br /&gt;
      client charset = UTF-8&lt;br /&gt;
      tds version = 8.0&lt;br /&gt;
      text size = 20971520&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Notes:&#039;&#039;&#039;&lt;br /&gt;
*You can configure FreeTDS to look for the freetds.conf file in any directory that you want - you don&#039;t have to use C:\. To do this create a SYSTEM environment variable called &#039;&#039;&#039;FREETDS&#039;&#039;&#039; and point it to the directory where you have installed the freetds.conf file. If you do not set this environment variable FreeTDS will look for the freetds.conf file in the C:\ folder, which is the default. One possible benefit of setting the FREETDS environment variable and using a different installation directory for freetds.conf is that C:\ is very predictable to a hacker that knows anything about FreeTDS and that is the first place that he would look if he wanted to compromise your system. So, using a different installation directory would just make your system stronger. See the FreeTDS [http://www.freetds.org/userguide/envvar.htm Setting the environment variables] documentation for more information about this FREETDS environment variable.&lt;br /&gt;
&lt;br /&gt;
*Alternatively, you can [[Development:Compiling FreeTDS under Windows|recompile]] the FreeTDS extension yourself and change the default location to your preferred location at compile time. Then it is not necessary to create any environment variable. You must just ensure that freetds.conf is in the same folder that you specify when you compile php_dblib.dll.&lt;br /&gt;
&lt;br /&gt;
*MSSQL is usually installed with port 1433 as the default. However, if the port was changed on your server when you installed MSSQL then you need to specify the correct port number.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
5. Your Moodle &#039;&#039;&#039;config.php&#039;&#039;&#039; should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer. Alternatively you can use the config-dist.php file that comes with the Moodle package to create your own config.php file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
6. Restart or start your web server.  If Moodle still cannot communicate with the database server, please turn display_startup_errors to &amp;quot;On&amp;quot; in your /PHP/php.ini file, then restart the web server and check for any errors that may indicate incorrect DLL versions or missing dependencies.  These error reports, turned off by default in PHP, can be vital in locating a problem with new extension installations.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. Database conection test, try this PHP script, just put in a text file called test.php change (&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;) to suite your setup, and load from local host (http://localhost/test.php)...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	$link = mssql_connect(&#039;localhost&#039;, &#039;db_user&#039;, &#039;db_password&#039;);&lt;br /&gt;
	if(!$link) {&lt;br /&gt;
		echo&#039;Could not connect&#039;;&lt;br /&gt;
		die(&#039;Could not connect: &#039; . mssql_error());&lt;br /&gt;
	}&lt;br /&gt;
	echo&#039;Successful connection&#039;;&lt;br /&gt;
	mssql_close($link);&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
8. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
If you encounter some problems you can try:&lt;br /&gt;
*check that you have DotNet framework 1.1 installed (later version are installed on Vista, but you could need this specific one)&amp;lt;br /&amp;gt;&lt;br /&gt;
*enable TCP/IP for MSSQL: SQL Server 2005 Network Configuration -&amp;gt; Protocols for MSSQLSERVER -&amp;gt; TCP/IP (Enable) -&amp;gt; Properties -&amp;gt; Ip Addresses -&amp;gt; 127.0.0.1 (Active+Enable)&amp;lt;br /&amp;gt;&lt;br /&gt;
*if you are using SQL Server 2005 and you have the error &#039;&#039;4004: Unicode data in a Unicode-only collation or ntext data cannot be sent to clients using DB-Library (such as ISQL) or ODBC version 3.7 or earlier&#039;&#039;, try the ODBTP method (next chapter). The SQL Server complaining that it doesn&#039;t support pure Unicode via TDS or older versions of ODBC. Microsoft has deprecated DB-Library a long ago, in favor of ODBC, OLE DB, or SQL Native Client. Many new features of SQL 2005 aren&#039;t accessible via DB-Library so if you need them, you could have to switch away from tools based on TDS and DB-Library :(&lt;br /&gt;
&lt;br /&gt;
== Using FreeTDS on Ubuntu by compiling an mssql.so extension ==&lt;br /&gt;
This is a good read to [http://www.robert-gonzalez.com/2009/02/18/building-the-php-ms-sql-server-extension-from-source-on-ubuntu-810/ building a FreeTDS based mssql extension for apache on Ubuntu].&lt;br /&gt;
== Using FreeTDS on Debian&lt;br /&gt;
apt-get install libsybdb5 freetds-common php5-sybase&lt;br /&gt;
/etc/init.d/apache2 restart&lt;br /&gt;
&lt;br /&gt;
== Using ODBTP on Unix or Windows ==&lt;br /&gt;
&lt;br /&gt;
You can download ODBTP from http://odbtp.sourceforge.net/. Also you will access to the documentation from the same page.&lt;br /&gt;
&lt;br /&gt;
The downloaded package includes both the source code and some binaries to be installed in the server and some ready-to-use &#039;&#039;&#039;mssql extension alternatives&#039;&#039;&#039; for some platforms/PHP versions (so you won&#039;t need to compile it if your PHP server/version binary package is present).&lt;br /&gt;
&lt;br /&gt;
First of all, we have to install the Win32 service that comes with the package. Let&#039;s assume that it&#039;s going to run in the same Win32 machine where your MSSQL server is running (although it can run in any other Win32 server in your network).&lt;br /&gt;
&lt;br /&gt;
To do do, following the instructions present in http://odbtp.sourceforge.net/install.html, you must:&lt;br /&gt;
&lt;br /&gt;
Do the following on the MSSQL server:&lt;br /&gt;
# Create a directory on the Windows host where the service program files will reside, i.e., md odbtp.&lt;br /&gt;
# Copy the files odbtpctl.exe, odbtpsrv.exe and odbtpsrv.ini files from the winservice directory into the directory created in step 1.&lt;br /&gt;
# Edit the file odbtpsrv.ini of the previous step and this line: &amp;lt;pre&amp;gt;MaxRequestSize=20971520&amp;lt;/pre&amp;gt;&lt;br /&gt;
# Open a command prompt (cmd) window on the Windows host.&lt;br /&gt;
# Change to the directory to which the service program files were copied, i.e., cd odbtp.&lt;br /&gt;
# Run the following commands to install and start the service:&lt;br /&gt;
#*   odbtpctl install&lt;br /&gt;
#*   odbtpctl start&lt;br /&gt;
# With these steps you should have one new service running in your host called &amp;quot;odbtp&amp;quot;. Verify it&#039;s present and running in the &amp;quot;Services&amp;quot; control panel.&lt;br /&gt;
# Don&#039;t forget to enable TCP/IP incoming connections to port 2799 in the host you have installed the service!&lt;br /&gt;
&lt;br /&gt;
Now it&#039;s time to build the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039;. First of all, verify if, in the downloaded package, under the &amp;quot;php&amp;quot; dir, there is one extension suitable for your PHP server/version. If it&#039;s present, you can simply copy it to the php/extensions dir in your PHP server and skip next points about compiling it from source. It&#039;s important to point that, inside each directory, you&#039;ll find &#039;&#039;&#039;two different&#039;&#039;&#039; libraries/dll files. The one that must be copied to the extensions dir is the one called &#039;&#039;&#039;&amp;quot;php_odbtp_mssql.xxx&amp;quot;&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
If in the downloaded package isn&#039;t present the extension matching your PHP platform/version, you should build if from source files. To do that, just &#039;&#039;&#039;&amp;quot;configure, make, make install&amp;quot;&#039;&#039;&#039;. That will create some stuff under &amp;quot;/usr/local&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Now that you&#039;ve successfully built ODBTP is time to create the &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; that will provide us with the capacity of handling MSSQL DBs from within Moodle. To do so, just configure your PHP server adding this new option to the usual ones:&lt;br /&gt;
&lt;br /&gt;
  --with-odbtp-mssql&lt;br /&gt;
&lt;br /&gt;
then, after the standard &amp;quot;make and make install&amp;quot; steps, your PHP server will be built with MSSQL support provided by ODBTP.&lt;br /&gt;
&lt;br /&gt;
Do the following on the moodle webserver:&lt;br /&gt;
Finally, independently if we are using the binary extension provided in the download or if you have built it from source files, it&#039;s time to configure the extension. &lt;br /&gt;
1. To do so, add this lines, if no present, to your php.ini file:&lt;br /&gt;
&lt;br /&gt;
  extension=php_odbtp_mssql.dll&lt;br /&gt;
&lt;br /&gt;
(only for Win32 PHP servers!)&lt;br /&gt;
&lt;br /&gt;
2. And, for all the server platforms: &lt;br /&gt;
&lt;br /&gt;
  [odbtp]&lt;br /&gt;
  odbtp.interface_file = &amp;quot;/path/to/your/odbtp.conf&amp;quot;&lt;br /&gt;
  odbtp.datetime_format = mdyhmsf&lt;br /&gt;
  odbtp.detach_default_queries = yes&lt;br /&gt;
&lt;br /&gt;
(where &#039;&#039;&amp;quot;/path/to/your/odbtp.conf&amp;quot;&#039;&#039; is usually &#039;&#039;&#039;&amp;quot;/usr/local/etc/odbtp.conf&amp;quot;&#039;&#039;&#039; for Unix systems and &#039;&#039;&#039;&amp;quot;C:\odbtp\odbtp.conf&amp;quot;&#039;&#039;&#039; for Windows systems)&lt;br /&gt;
&lt;br /&gt;
Then, edit such &amp;quot;odbtp.conf&amp;quot; file and put there these contents:&lt;br /&gt;
&lt;br /&gt;
  [global]&lt;br /&gt;
  odbtp host = xxx.xxx.xxx (ip or hostname of the Win32 box running the ODBTP service i.e MSSQL server)&lt;br /&gt;
  type = mssql&lt;br /&gt;
  unicode sql = yes&lt;br /&gt;
  use row cache = yes&lt;br /&gt;
  right trim text = yes&lt;br /&gt;
  var data size = 20971520&lt;br /&gt;
&lt;br /&gt;
With this, your PHP server will be able to connect with the MSSQL DB server using ODBTP. From here, just continue with the installation.&lt;br /&gt;
&lt;br /&gt;
Finally, if you find the ODBTP executables and &#039;&#039;&#039;mssql extension alternative&#039;&#039;&#039; in binary formats, it only will be necessary to install them in your server (binary packages...) without the need to recompile anything (just the php.ini and odbtp.conf edition steps above will be necessary). Of course, it will be really welcome to have all those binary alternatives documented here.&lt;br /&gt;
&lt;br /&gt;
Once ODBTP is working, Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;mssql_n&#039;;        // Required&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;localhost&#039;;      // assuming MS SQL is on the same server, otherwise use an IP&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;moodle&#039;;         // or whatever you called the database you created&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t have a config.php file yet, it can be generated as normal from the Moodle installer.&lt;br /&gt;
&lt;br /&gt;
== Using ODBC on Windows ==&lt;br /&gt;
[[ODBC]] allows communication with an SQL database.&lt;br /&gt;
{{Not for production sites}}&lt;br /&gt;
&lt;br /&gt;
1. Go to the &#039;&#039;&#039;Administrative Tools&#039;&#039;&#039;  control panel, then the &#039;&#039;&#039;Data Sources (ODBC)&#039;&#039;&#039; panel.&lt;br /&gt;
&lt;br /&gt;
2. Configure one new System/User DSN (call it, for example &amp;quot;moodle&amp;quot;). Dont forget to enable these options if the driver asks for them:&lt;br /&gt;
&lt;br /&gt;
:* ANSI NULLS Enabled = true&lt;br /&gt;
:* Quoted Identifiers Enabled = true&lt;br /&gt;
&lt;br /&gt;
3. Your Moodle config.php should include lines like these:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dbtype    = &#039;odbc_mssql&#039;;     // Note this is different to all the other configs on this page!&lt;br /&gt;
$CFG-&amp;gt;dbhost    = &#039;moodle&#039;;         // Where this matches the Data source name you chose above&lt;br /&gt;
$CFG-&amp;gt;dbname    = &#039;&#039;;               // Keep it blank!!&lt;br /&gt;
$CFG-&amp;gt;dbuser    = &#039;yourusername&#039;;   // I usually use the &#039;sa&#039; account (dbowner perms are enough)&lt;br /&gt;
$CFG-&amp;gt;dbpass    = &#039;yourpassword&#039;;&lt;br /&gt;
$CFG-&amp;gt;dbpersist =  false;&lt;br /&gt;
$CFG-&amp;gt;prefix    = &#039;mdl_&#039;;            //Prefix, you can change it, but NEVER leave it blank.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
4. Install Moodle as usual.  Good luck!&lt;br /&gt;
&lt;br /&gt;
== Using the SQL Server 2005 Driver for PHP from Microsoft ==&lt;br /&gt;
In July 2008 Microsoft [http://social.msdn.microsoft.com/forums/en-US/sqldriverforphp/thread/a10e5202-9e41-4ff8-a33e-fbcc7b951be2/ released] their new SQL Server 2005 Driver for PHP. It is a PHP extension that allows for the reading and writing of SQL Server data from within PHP scripts. However there are some limitations with this driver that make it incompatible with Moodle, e.g.:&lt;br /&gt;
&lt;br /&gt;
* limitations with how it handles UTF-8 strings and &lt;br /&gt;
* it does not support the legacy mssql php driver function names&lt;br /&gt;
&lt;br /&gt;
For more info see MDL-16497 and MDL-15093.&lt;br /&gt;
&lt;br /&gt;
So, for now, you should not use this driver with Moodle 1.9.&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
* [[Installing Moodle]]&lt;br /&gt;
* [[Errors FAQ]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]&lt;br /&gt;
* [[Beginning Administration FAQ]]&lt;br /&gt;
* [[Installing Oracle for PHP]]&lt;br /&gt;
&lt;br /&gt;
* [[Category:FAQ]]&lt;br /&gt;
* [[Category:Installation]]&lt;br /&gt;
* [[Category:Developer]]&lt;br /&gt;
* [[Category:XMLDB]]&lt;br /&gt;
* [[Category:DB]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=78321</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=78321"/>
		<updated>2010-11-26T10:26:51Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Uncategorised requested features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.1}}For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny public submitted answers&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;radio&amp;quot; name=&amp;quot;gender&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75126</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75126"/>
		<updated>2010-08-24T09:03:32Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Uncategorised requested features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny public submitted answers&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;F&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;M&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == F)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select disabled=&amp;quot;disabled&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75125</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75125"/>
		<updated>2010-08-24T09:00:27Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Module settings page */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny public submitted answers&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
)&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;F&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;M&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75124</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75124"/>
		<updated>2010-08-24T08:59:56Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Field level settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny public submitted answers&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
 Where were you born? &amp;lt;code&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;Spain&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other, please specify&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;  &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the drop down menu the field will be enabled and become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;F&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;M&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75123</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75123"/>
		<updated>2010-08-24T08:55:38Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Uncategorised requested features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny public submitted answers&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
Where were you born?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt; &amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;Spain&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the &amp;quot;dropdown_14&amp;quot; drop down menu the field &amp;quot;dropdown_14_other&amp;quot; will become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;F&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;M&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75122</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75122"/>
		<updated>2010-08-24T08:55:14Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Uncategorised requested features */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny public submitted answers&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
Where were you born?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt; &amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;Spain&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the &amp;quot;dropdown_14&amp;quot; drop down menu the field &amp;quot;dropdown_14_other&amp;quot; will become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
&lt;br /&gt;
 1. Gender: &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;F&amp;quot; value=&amp;quot;0&amp;quot; checked=&amp;quot;checked&amp;quot;/&amp;gt;&amp;lt;/code&amp;gt;F  &amp;lt;code&amp;gt;&amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;M&amp;quot; value=&amp;quot;1&amp;quot; /&amp;gt;&amp;lt;/code&amp;gt;M&lt;br /&gt;
 1a. How many pregnancies have you had? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;0&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;0&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;1&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;2&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;more&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;br /&gt;
 1b. Question relevant only for males? &amp;lt;code&amp;gt;&amp;lt;select&amp;gt;&amp;lt;option value=&amp;quot;aa&amp;quot; selected=&amp;quot;selected&amp;quot;&amp;gt;aa&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;bb&amp;quot;&amp;gt;bb&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;cc&amp;quot;&amp;gt;cc&amp;lt;/option&amp;gt;&amp;lt;option value=&amp;quot;more&amp;quot;&amp;gt;other&amp;lt;/option&amp;gt;&amp;lt;/select&amp;gt;&amp;lt;/code&amp;gt; (should be disabled when answer 1 == M)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75120</id>
		<title>Development:Survey 2 brainstorm</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Survey_2_brainstorm&amp;diff=75120"/>
		<updated>2010-08-24T08:18:52Z</updated>

		<summary type="html">&lt;p&gt;Kordan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;For notes, discussion and eventually a full spec of the new Survey module for 2.1 that combines all the features of &lt;br /&gt;
&lt;br /&gt;
# Survey &lt;br /&gt;
# Questionnaire &lt;br /&gt;
# Feedback &lt;br /&gt;
&lt;br /&gt;
into one module.&lt;br /&gt;
&lt;br /&gt;
This is the list of the frequently asked features request that moodle users addressed to me over last few years.&lt;br /&gt;
It may be a good starting point. The following list is NOT ordered by feature relevance.&lt;br /&gt;
&lt;br /&gt;
==Module settings page==&lt;br /&gt;
*option: allow/deny save without submit&lt;br /&gt;
*option: allow/deny record modification after submit&lt;br /&gt;
*option: allow/deny public submitted answers&lt;br /&gt;
(Example: This option should appear like:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;Submitted answers are available &amp;lt;select name=&amp;quot;dropdown_7&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt;to all users&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;to submitter only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;to submitter group only&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
*type of field (char(n), text, number, alphanumeric, boolean, date, picture, file, email, url...) with type check at submit time (and number of digit check for char(n) fields).&lt;br /&gt;
&lt;br /&gt;
This information may not be used at field definition time but is useful for data verification/check.&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your card ID: _______&lt;br /&gt;
This field should be defined, for instance, as char(7))&lt;br /&gt;
*opening and closing submission dates&lt;br /&gt;
*relations between tables&lt;br /&gt;
(Example:&lt;br /&gt;
one record for the profile of my company&lt;br /&gt;
one related record for each intervention request submitted by my company)&lt;br /&gt;
&lt;br /&gt;
==Field level settings==&lt;br /&gt;
*mandatory/non mandatory field option&lt;br /&gt;
*define a range of valid answers for fields allowing this&lt;br /&gt;
(Example:&lt;br /&gt;
Please, enter your seniority. (limited between 0 and 50 years)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
Date of birth: (limited between 18 and 100 years ago))&lt;br /&gt;
*define fields default to be loaded at &amp;quot;new record&amp;quot; display time&lt;br /&gt;
*optional &amp;quot;other&amp;quot; text field for drop down menu/radio button/check box.&lt;br /&gt;
(Example for drop down:&lt;br /&gt;
&lt;br /&gt;
Where were you born?&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&amp;lt;select name=&amp;quot;dropdown_14&amp;quot; size=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;0&amp;quot;&amp;gt; &amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;1&amp;quot; &amp;gt;Spain&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;2&amp;quot; &amp;gt;France&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;option value=&amp;quot;3&amp;quot; &amp;gt;other&amp;lt;/option&amp;gt;&lt;br /&gt;
&amp;lt;/select&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;dropdown_14_other&amp;quot; size=&amp;quot;10&amp;quot; maxlength=&amp;quot;10&amp;quot; value=&amp;quot;&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
If you choose &amp;quot;other&amp;quot; in the &amp;quot;dropdown_14&amp;quot; drop down menu the field &amp;quot;dropdown_14_other&amp;quot; will become mandatory, otherwise it will be disabled.&lt;br /&gt;
)&lt;br /&gt;
*define read-only fields (auto filled by the software) like, current_date, user_name, record_ID...&lt;br /&gt;
&lt;br /&gt;
==New fields types==&lt;br /&gt;
*short date (with month and years only, to answer question like: When had you the first evidence of this disease?)&lt;br /&gt;
*order list. A list of available items and the answer is supposed to order them.&lt;br /&gt;
*time&lt;br /&gt;
&lt;br /&gt;
(Example:&lt;br /&gt;
When do you usually take breakfast?&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
==Uncategorised requested features==&lt;br /&gt;
*handle more than one view_single/view_list/find/input layout (and allow this or that layout to users on the basis of capabilities).&lt;br /&gt;
&lt;br /&gt;
The idea is: On the basis of capability you will access your specific layout with only a field subset.&lt;br /&gt;
If you have this capability, you will find all the fields of the survey, otherwise you will find only a subset of them.&lt;br /&gt;
&lt;br /&gt;
The same feature may be provided in the following way:&lt;br /&gt;
At fields level definition the course creator should be allowed to mark the field &amp;quot;field1&amp;quot; as&lt;br /&gt;
#visible and enabled to all&lt;br /&gt;
#visible to all but enabled to users with view_field1 capability only&lt;br /&gt;
#visible and enabled to users with view_field1 capability only&lt;br /&gt;
&lt;br /&gt;
*allow course creator to add custom number to question inside layouts (i.e.: 1, 2, 2a, 2b, 3...) to respect questions hierarchy&lt;br /&gt;
*allow course creator to indent questions inside layouts to respect questions hierarchy (as it is already possible the indent of resources inside courses)&lt;br /&gt;
*conditional branching&lt;br /&gt;
(Example:&lt;br /&gt;
Gender: M  F&lt;br /&gt;
&lt;br /&gt;
if female: question for females only&lt;br /&gt;
&lt;br /&gt;
if male:  question for males only)&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Moodle_version_history&amp;diff=72813</id>
		<title>Moodle version history</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Moodle_version_history&amp;diff=72813"/>
		<updated>2010-06-10T05:32:51Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Moodle 1.9 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Moodle 1.0==&lt;br /&gt;
*Moodle 1.0 - 20 August 2002&lt;br /&gt;
*Moodle 1.0.1 - 26 August 2002&lt;br /&gt;
*Moodle 1.0.2 - 2 September 2002&lt;br /&gt;
*Moodle 1.0.3 - 5 September 2002&lt;br /&gt;
*Moodle 1.0.4 - 10 September 2002&lt;br /&gt;
*Moodle 1.0.5 - 27 September 2002&lt;br /&gt;
*Moodle 1.0.6 - 26 October 2002&lt;br /&gt;
:: 1.0.6.1 - 6 Nov&lt;br /&gt;
:: 1.0.6.2 - 11 Nov&lt;br /&gt;
:: 1.0.6.3 - 14 Nov&lt;br /&gt;
:: 1.0.6.4 - 25 Nov&lt;br /&gt;
*Moodle 1.0.7 - 9 December 2002&lt;br /&gt;
*Moodle 1.0.8 - 7 January 2003&lt;br /&gt;
*Moodle 1.0.9 - 30 May 2003&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.1==&lt;br /&gt;
*Moodle 1.1 - 29 August 2003&lt;br /&gt;
*Moodle 1.1.1 - 11 September 2003&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.2==&lt;br /&gt;
*Moodle 1.2 - 20 March 2004&lt;br /&gt;
*Moodle 1.2.1 - 25 March 2004&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.3==&lt;br /&gt;
*Moodle 1.3 - 25 May 2004&lt;br /&gt;
*Moodle 1.3.1 - 4 June 2004&lt;br /&gt;
*Moodle 1.3.2 - 9 July 2004&lt;br /&gt;
*Moodle 1.3.3 - 16 July 2004&lt;br /&gt;
*Moodle 1.3.4 - 11 August 2004&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.4==&lt;br /&gt;
*Moodle 1.4 - 31 August 2004&lt;br /&gt;
*Moodle 1.4.1 - 12 September 2004&lt;br /&gt;
*Moodle 1.4.2 - 5 November 2004&lt;br /&gt;
*Moodle 1.4.3 - 21 December 2004&lt;br /&gt;
*Moodle 1.4.4 - 7 March 2005 &lt;br /&gt;
*[[Moodle 1.4.5 release notes|Moodle 1.4.5]] - 7 May 2005&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.5==&lt;br /&gt;
*[[Moodle 1.5 release notes|Moodle 1.5]] - 5 June 2005&lt;br /&gt;
*[[Moodle 1.5.1 release notes|Moodle 1.5.1]] - 8 July 2005&lt;br /&gt;
*[[Moodle 1.5.2 release notes|Moodle 1.5.2]] - 16 July 2005&lt;br /&gt;
*[[Moodle 1.5.3 release notes|Moodle 1.5.3]] - 11 November 2005&lt;br /&gt;
*[[Moodle 1.5.4 release notes|Moodle 1.5.4]] - 21 May 2006&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.6==&lt;br /&gt;
*[[Moodle 1.6 release notes|Moodle 1.6]] - 20 June 2006&lt;br /&gt;
*[[Moodle 1.6.1 release notes|Moodle 1.6.1]] - 20 July 2006&lt;br /&gt;
*[[Moodle 1.6.2 release notes|Moodle 1.6.2]] - 12 September 2006&lt;br /&gt;
*[[Moodle 1.6.3 release notes|Moodle 1.6.3]] - 10 October 2006&lt;br /&gt;
*[[Moodle 1.6.4 release notes|Moodle 1.6.4]] - 17 January 2007&lt;br /&gt;
*[[Moodle 1.6.5 release notes|Moodle 1.6.5]] - 30 March 2007&lt;br /&gt;
*Moodle 1.6.6 - 11 January 2008&lt;br /&gt;
*Moodle 1.6.7 - 11 July 2008&lt;br /&gt;
*[[Moodle 1.6.8 release notes|Moodle 1.6.8]] - 15 October 2008&lt;br /&gt;
*[[Moodle 1.6.9 release notes|Moodle 1.6.9]] - 28 January 2009&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.7==&lt;br /&gt;
*[[Moodle 1.7 release notes|Moodle 1.7]] - 7 November 2006&lt;br /&gt;
*[[Moodle 1.7.1 release notes|Moodle 1.7.1]] - 17 January 2007&lt;br /&gt;
*[[Moodle 1.7.2 release notes|Moodle 1.7.2]] - 30 March 2007&lt;br /&gt;
*[[Moodle 1.7.3 release notes|Moodle 1.7.3]] - 11 October 2007&lt;br /&gt;
*[[Moodle 1.7.4 release notes|Moodle 1.7.4]] - 11 January 2008&lt;br /&gt;
*[[Moodle 1.7.5 release notes|Moodle 1.7.5]] - 11 July 2008&lt;br /&gt;
*[[Moodle 1.7.6 release notes|Moodle 1.7.6]] - 15 October 2008&lt;br /&gt;
*[[Moodle 1.7.7 release notes|Moodle 1.7.7]] - 28 January 2009&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.8==&lt;br /&gt;
*[[Moodle 1.8 release notes|Moodle 1.8]] - 30 March 2007&lt;br /&gt;
*[[Moodle 1.8.1 release notes|Moodle 1.8.1]] - 14 June 2007&lt;br /&gt;
*[[Moodle 1.8.2 release notes|Moodle 1.8.2]] - 8 July 2007&lt;br /&gt;
*[[Moodle 1.8.3 release notes|Moodle 1.8.3]] - 11 October 2007&lt;br /&gt;
*[[Moodle 1.8.4 release notes|Moodle 1.8.4]] - 11 January 2008&lt;br /&gt;
*[[Moodle 1.8.5 release notes|Moodle 1.8.5]] - 8 April 2008&lt;br /&gt;
*[[Moodle 1.8.6 release notes|Moodle 1.8.6]] - 11 July 2008&lt;br /&gt;
*[[Moodle 1.8.7 release notes|Moodle 1.8.7]] - 15 October 2008&lt;br /&gt;
*[[Moodle 1.8.8 release notes|Moodle 1.8.8]] - 28 January 2009&lt;br /&gt;
*[[Moodle 1.8.9 release notes|Moodle 1.8.9]] - 15 May 2009&lt;br /&gt;
*[[Moodle 1.8.10 release notes|Moodle 1.8.10]] - 26 October 2009&lt;br /&gt;
*[[Moodle 1.8.11 release notes|Moodle 1.8.11]] - 25 November 2009&lt;br /&gt;
*[[Moodle 1.8.12 release notes|Moodle 1.8.12]] - 27 March 2010&lt;br /&gt;
&lt;br /&gt;
==Moodle 1.9==&lt;br /&gt;
*[[Moodle 1.9 release notes|Moodle 1.9]] - 3 March 2008&lt;br /&gt;
*[[Moodle 1.9.1 release notes|Moodle 1.9.1]] - 15 May 2008&lt;br /&gt;
*[[Moodle 1.9.2 release notes|Moodle 1.9.2]] - 11 July 2008&lt;br /&gt;
*[[Moodle 1.9.3 release notes|Moodle 1.9.3]] - 15 October 2008&lt;br /&gt;
*[[Moodle 1.9.4 release notes|Moodle 1.9.4]] - 28 January 2009&lt;br /&gt;
*[[Moodle 1.9.5 release notes|Moodle 1.9.5]] - 13 May 2009&lt;br /&gt;
*[[Moodle 1.9.6 release notes|Moodle 1.9.6]] - 21 October 2009&lt;br /&gt;
*[[Moodle 1.9.7 release notes|Moodle 1.9.7]] - 25 November 2009&lt;br /&gt;
*[[Moodle 1.9.8 release notes|Moodle 1.9.8]] - 25 March 2010&lt;br /&gt;
*[[Moodle 1.9.9 release notes|Moodle 1.9.9]] - 8 June 2010&lt;br /&gt;
&lt;br /&gt;
[[Category:Release notes]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Historique des versions]]&lt;br /&gt;
[[es:Historia de las versiones]]&lt;br /&gt;
[[de:Versionshistorie]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_creating_your_first_theme&amp;diff=72117</id>
		<title>Development:Themes 2.0 creating your first theme</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_creating_your_first_theme&amp;diff=72117"/>
		<updated>2010-05-14T14:20:38Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Starting to write excitement.css */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Themes}}{{Moodle 2.0}}This document describes how to create a theme for Moodle 2.0. It assumes you have some understanding of how themes within Moodle work as well as a good understanding of HTML and CSS.&lt;br /&gt;
&lt;br /&gt;
===Theme designer mode===&lt;br /&gt;
&lt;br /&gt;
Under normal operation Moodle does several things in the name of performance, one of these is to combine all of the CSS into one file, minimize it, cache it on the server, and then serve it. After the first request the cached version is served to greatly improve page performance. &lt;br /&gt;
&lt;br /&gt;
What this means for you as a themer? When you make changes they will not be seen immediately. In fact you will need to tell Moodle to rebuild the cache that it is serving.&lt;br /&gt;
This isn&#039;t practical for designing themes of course so the &#039;&#039;&#039;theme designer mode&#039;&#039;&#039; was added. When enabled it tells Moodle not to combine or cache the CSS that gets delivered. This has the downside that page load times will take significantly longer, however you will see you changes immediately every time.&lt;br /&gt;
&lt;br /&gt;
Theme designer mode may be enabled via &#039;&#039;Administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; [[Theme settings]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: Internet Explorer versions 6 and 7 have BIG problems when a site attempts to link to more than 31 stylesheets, in which case either a limited number or no styles get applied. Because Moodle sends up all of the CSS all of the time with theme designer mode turned on there is a very high chance you will get more than 31 stylesheets being included. This will of course cause major problems for Internet Explorer until theme designer mode is turned off.&lt;br /&gt;
&lt;br /&gt;
==Getting started==&lt;br /&gt;
&lt;br /&gt;
The first thing you need to do is create the directories and files you will be using, the first thing to create is the actual directory for your theme. This should be the name of your theme, in my case its &#039;excitement&#039;. The directory should be located within the theme directory of Moodle, ./moodle/theme/excitement/ will be the directory I create.&lt;br /&gt;
&lt;br /&gt;
Now within that directory we can immediately create several files that we know we are going to need. &lt;br /&gt;
&lt;br /&gt;
So the files that we want to create are:&lt;br /&gt;
; config.php :  All of our settings will go here.&lt;br /&gt;
; /style/ : This directory will contain all of our stylesheets.&lt;br /&gt;
; /style/excitement.css : All of our css will go in here.&lt;br /&gt;
; /pix/ : Into this directory we&#039;ll put a screen shot of our theme as well as our favicon and any images we use in CSS.&lt;br /&gt;
; /layout/ : Our layout files will end up in this directory.&lt;br /&gt;
; /layout/standard.php : This will be our one basic layout file.&lt;br /&gt;
&lt;br /&gt;
So after this setup step you should have a directory structure similar to what is shown below.&lt;br /&gt;
&lt;br /&gt;
[[image:Learn_to_theme_01.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Configuring our theme==&lt;br /&gt;
&lt;br /&gt;
Open config.php in you favourite editor and start by adding the opening PHP tags &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;?php&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now we need to add the settings:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$THEME-&amp;gt;name = &#039;excitement&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Very simply this tells the Moodle the name of your theme, and if you ever have several config.php files open this will be help you identify which one you are looking at.&lt;br /&gt;
&lt;br /&gt;
Next the parents for this theme.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$THEME-&amp;gt;parents = array(&#039;base&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This tells Moodle that my new theme &#039;&#039;`excitement`&#039; wants to extend the base theme. &lt;br /&gt;
&lt;br /&gt;
A theme can extend any number of themes. Rather than creating an entirely new theme and copying all of the CSS, you can simply create a new theme, extend the theme you like and just add the changes you want to your theme. &lt;br /&gt;
&lt;br /&gt;
Also worth noting is the purpose of the base theme: it provides us with a basic layout and just enough CSS to make everything fall into place.&lt;br /&gt;
&lt;br /&gt;
Now we will tell Moodle about our stylesheets:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$THEME-&amp;gt;sheets = array(&#039;excitement&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The final thing we need to add into our themes config.php file is the definition of the layouts for our theme:&lt;br /&gt;
&amp;lt;div style=&amp;quot;height:400px;overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$THEME-&amp;gt;layouts = array(&lt;br /&gt;
    &#039;base&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;standard&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;course&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;coursecategory&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;incourse&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;frontpage&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;admin&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-pre&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;mydashboard&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;langmenu&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;mypublic&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;login&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;langmenu&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;popup&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;nofooter&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;frametop&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;nofooter&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;maintenance&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;nofooter&#039;=&amp;gt;true, &#039;nonavbar&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
/** List of javascript files that need to be included on each page */&lt;br /&gt;
$THEME-&amp;gt;javascripts = array();&lt;br /&gt;
$THEME-&amp;gt;javascripts_footer = array();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What you are looking at is the different layouts for our theme. Why are there so many? because that is how many there are in Moodle, there is one for every general type of page. With my &#039;&#039;`excitement`&#039;&#039; theme I have chosen to use my own layout, unless there was specific reason to do so normally you would not need to create your own layouts, you could of course extend the base theme and use its layouts meaning you would only have to write CSS to achieve your desired look.&lt;br /&gt;
&lt;br /&gt;
For each layout above you will notice the following four things are being set:&lt;br /&gt;
; file : This is the name of the layout file we want to use, it should always be located in the above themes layout directory. For us this is of course standard.php as we only have one layout file.&lt;br /&gt;
; regions : This is an array of block regions that our theme has. Each entry in here can be used to put blocks in when that layout is being used.&lt;br /&gt;
; defaultregion : If a layout has regions it should have a default region, this is where blocks get put when first added.&lt;br /&gt;
; options : These are special settings, anything that gets put into the options array is available later on when we are writing our layout file.&lt;br /&gt;
&lt;br /&gt;
There are additional settings that can be defined in the config.php file - see [[Development:Themes 2.0|Themes 2.0]] for the full list.&lt;br /&gt;
&lt;br /&gt;
==Writing the layout file==&lt;br /&gt;
&lt;br /&gt;
The excitement theme has just one layout file.&lt;br /&gt;
&lt;br /&gt;
The downside of this is that I have to make the layout file do everything I want which means I need to make use of some options (as defined in the layouts in config.php). &lt;br /&gt;
&lt;br /&gt;
The upside is that I only need to maintain one file. &lt;br /&gt;
&lt;br /&gt;
Other than maintenance, using multiple layout files provides many advantages to real world themes in that you can easily tweak and customise specific layouts to achieve the goals of the organisation using the theme.&lt;br /&gt;
&lt;br /&gt;
So lets start writing standard.php, the layout file for my &#039;&#039;`excitement`&#039;&#039; theme.&lt;br /&gt;
&lt;br /&gt;
===The top of the layout file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo $OUTPUT-&amp;gt;doctype(); ?&amp;gt;&lt;br /&gt;
&amp;lt;html &amp;lt;?php echo $OUTPUT-&amp;gt;htmlattributes() ?&amp;gt;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;title ?&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $OUTPUT-&amp;gt;standard_head_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets look at the code that goes into this section:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo $OUTPUT-&amp;gt;doctype(); ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This is very important and is required to go at the very top of the page. This tells Moodle to print out the document type tag that is determined by the settings within Moodle.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;html &amp;lt;?php echo $OUTPUT-&amp;gt;htmlattributes() ?&amp;gt;&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we open the HTML tag and then ask Moodle to print the attributes that should go inside it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;title ?&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Simply creates the title tag and asks Moodle to fill it in.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $OUTPUT-&amp;gt;standard_head_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we are asking Moodle to print all of the other tags and content that need to go into the head. This includes stylesheets, script tags, and inline JavaScript code.&lt;br /&gt;
&lt;br /&gt;
===The page header===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;body id=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyid; ?&amp;gt;&amp;quot; class=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyclasses; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_top_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;page&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php if ($PAGE-&amp;gt;heading || (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar())) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-header&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;?php if ($PAGE-&amp;gt;heading) { ?&amp;gt;&lt;br /&gt;
            &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
            &amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
                echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
                if (!empty($PAGE-&amp;gt;layout_options[&#039;langmenu&#039;])) {&lt;br /&gt;
                    echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
                }&lt;br /&gt;
                echo $PAGE-&amp;gt;headingmenu&lt;br /&gt;
            ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
        &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar()) { ?&amp;gt;&lt;br /&gt;
            &amp;lt;div class=&amp;quot;navbar clearfix&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;breadcrumb&amp;quot;&amp;gt;&amp;lt;?php echo $OUTPUT-&amp;gt;navbar(); ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;navbutton&amp;quot;&amp;gt; &amp;lt;?php echo $PAGE-&amp;gt;button; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So there is a bit more going on here obviously.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;body id=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyid; ?&amp;gt;&amp;quot; class=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyclasses; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Again much like what we did for the opening HTML tag in the head we have started writing the opening body tag and are then asking Moodle to give us the ID we should use for the body tag as well as the classes we should use.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_top_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This very important call writes some critical bits of JavaScript into the page. It should always be located after the body tag as soon as possible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php if ($PAGE-&amp;gt;heading || (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar())) { ?&amp;gt;&lt;br /&gt;
......&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we are checking whether or not we need to print the header for the page. There are three checks we need to make here:&lt;br /&gt;
# &#039;&#039;&#039;$PAGE-&amp;gt;heading&#039;&#039;&#039; : This checks to make sure that there is a heading for the page. This will have been set by the script and normally describes the page in a couple of words.&lt;br /&gt;
# &#039;&#039;&#039;empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;])&#039;&#039;&#039; : Now this check is looking at the layout options that we set in our config.php file. It is looking to see if the layout set &#039;nonavbar&#039; =&amp;gt; true.&lt;br /&gt;
# &#039;&#039;&#039;$PAGE-&amp;gt;has_navbar()&#039;&#039;&#039; The third check is to check with the page whether it has a navigation bar to display.&lt;br /&gt;
If either there is a heading for this page or there is a navigation bar to display then we will display a heading.&lt;br /&gt;
&lt;br /&gt;
Leading on from this lets assume that there is a header to print.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php if ($PAGE-&amp;gt;heading) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    .....&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This line is simply saying if the page has a heading print it. In this case we run the first check above again just to make sute there is a heading, we then open a heading tag that we choose and ask the page to print the heading.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
    echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
    if (!empty($PAGE-&amp;gt;layout_options[&#039;langmenu&#039;])) {&lt;br /&gt;
        echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
    }&lt;br /&gt;
    echo $PAGE-&amp;gt;headingmenu&lt;br /&gt;
?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we are looking to print the menu and content that you see at the top of the page (usually to the right). We start by getting Moodle to print the login information for the current user. If the user is logged in this will be their name and a link to their profile, if not then it will be a link to login.&lt;br /&gt;
&lt;br /&gt;
Next we check our page options to see whether a language menu should be printed. If in the layout definition within config.php it sets &#039;&#039;&#039;langmenu =&amp;gt; true&#039;&#039;&#039; then we will print the language menu, a drop down box that lets the user change the language that Moodle displays in.&lt;br /&gt;
&lt;br /&gt;
Finally the page also has a heading menu that can be printed. This heading menu is special HTML that the page you are viewing wants to add. It can be anything from drop down boxes to buttons and any number of each.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar()) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;navbar clearfix&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;breadcrumb&amp;quot;&amp;gt;&amp;lt;?php echo $OUTPUT-&amp;gt;navbar(); ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;navbutton&amp;quot;&amp;gt; &amp;lt;?php echo $PAGE-&amp;gt;button; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The final part of the header.&lt;br /&gt;
&lt;br /&gt;
Here we want to print the navigation bar for the page if there is one. To find out if there is one we run checks number 2 and 3 again and proceed if they pass.&lt;br /&gt;
&lt;br /&gt;
Assuming there is a header then there are two things that we need to print. The first is the navigation bar. This is a component that the OUTPUT library knows about. The second is a button to shown on the page.&lt;br /&gt;
&lt;br /&gt;
In both cases we can choose to wrap them in a div to make our life as a themer easier.&lt;br /&gt;
&lt;br /&gt;
Well that is it for the header. There is a lot of PHP compared to the other sections of the layout file but it does not change and can be copied and pasted between themes.&lt;br /&gt;
&lt;br /&gt;
===The page content===&lt;br /&gt;
&lt;br /&gt;
I am going with the default two block regions plus the main content.&lt;br /&gt;
&lt;br /&gt;
Because I have based this theme and layout file on the base theme the HTML looks a little intense. This is because it is a floating div layout where the content comes first and then we get the columns (even though one column will be to the left of the content.) Don&#039;t worry too much about it. When it comes to writing your own theme you can go about it as you choose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;page-content&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;region-main-box&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div id=&amp;quot;region-post-box&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;div id=&amp;quot;region-main-wrap&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div id=&amp;quot;region-main&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;?php echo core_renderer::MAIN_CONTENT_TOKEN ?&amp;gt;&lt;br /&gt;
                    &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;div id=&amp;quot;region-pre&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-pre&#039;) ?&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;div id=&amp;quot;region-post&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-post&#039;) ?&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In regards to PHP this section is very easy. There are only three lines for the whole section one to get the main content and one for each block region.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo core_renderer::MAIN_CONTENT_TOKEN ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This line prints the main content for the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-pre&#039;) ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This line gets all of the blocks and more particularly the content for the block region &#039;&#039;&#039;side-pre&#039;&#039;&#039;. This block region will be displayed to the left of the content.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-post&#039;) ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we are getting the other block region &#039;&#039;&#039;side-post&#039;&#039;&#039; which will be displayed to the right of the content.&lt;br /&gt;
&lt;br /&gt;
===The page footer===&lt;br /&gt;
Here we want to print the footer for the page, any content required by Moodle, and then close the last tags.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nofooter&#039;])) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-footer&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;p class=&amp;quot;helplink&amp;quot;&amp;gt;&amp;lt;?php echo page_doc_link(get_string(&#039;moodledocslink&#039;)) ?&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
        &amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;home_link();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;standard_footer_html();&lt;br /&gt;
        ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_end_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The section of code is responsible for printing the footer for the page.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nofooter&#039;])) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-footer&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;p class=&amp;quot;helplink&amp;quot;&amp;gt;&amp;lt;?php echo page_doc_link(get_string(&#039;moodledocslink&#039;)) ?&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
        &amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;home_link();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;standard_footer_html();&lt;br /&gt;
        ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The first thing we do before printing the footer is check that we actually want to print it. This is done by checking the options for the layout as defined in the config.php file. If &#039;&#039;&#039;nofooter =&amp;gt; true&#039;&#039;&#039; is set the we don&#039;t want to print the footer and should skip over this body of code.&lt;br /&gt;
&lt;br /&gt;
Assuming we want to print a footer we proceed to create a div to house its content and then print the bits of the content that will make it up.&lt;br /&gt;
There are four things that the typical page footer will want to print:&lt;br /&gt;
; echo page_doc_link(get_string(&#039;moodledocslink&#039;)) : This will print a link to the Moodle.org help page for this particular page.&lt;br /&gt;
; echo $OUTPUT-&amp;gt;login_info(); : This is the same as at the top of the page and will print the login information for the current user.&lt;br /&gt;
; echo $OUTPUT-&amp;gt;home_link(); : This prints a link back to the Moodle home page for this site.&lt;br /&gt;
; echo $OUTPUT-&amp;gt;standard_footer_html(); : This prints special HTML that is determined by the settings for the site. Things such as performance information or debugging will be printed by this line if they are turned on.&lt;br /&gt;
&lt;br /&gt;
And the final line of code for our layout file is:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_end_of_body_html(); ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This is one of the most important lines of code in the layout file. It asks Moodle to print any required content into the page, and there will likely be a lot although most of it will not be visual.&lt;br /&gt;
&lt;br /&gt;
It will instead be things such as inline scripts and JavaScript files required to go at the bottom of the page. If you forget this line its likely no JavaScript will work!&lt;br /&gt;
&lt;br /&gt;
We&#039;ve now written our layout file and it is all set to go. The complete source is below for reference. Remember if you want more practical examples simply look at the layout files located within the layout directory of other themes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;height:400px;overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo $OUTPUT-&amp;gt;doctype() ?&amp;gt;&lt;br /&gt;
&amp;lt;html &amp;lt;?php echo $OUTPUT-&amp;gt;htmlattributes() ?&amp;gt;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;title; ?&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=&amp;quot;shortcut icon&amp;quot; href=&amp;quot;&amp;lt;?php echo $OUTPUT-&amp;gt;pix_url(&#039;favicon&#039;, &#039;theme&#039;)?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $OUTPUT-&amp;gt;standard_head_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body id=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyid; ?&amp;gt;&amp;quot; class=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyclasses; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_top_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;page&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php if ($PAGE-&amp;gt;heading || (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar())) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-header&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;?php if ($PAGE-&amp;gt;heading) { ?&amp;gt;&lt;br /&gt;
        &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
            echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
            if (!empty($PAGE-&amp;gt;layout_options[&#039;langmenu&#039;])) {&lt;br /&gt;
                echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
            }&lt;br /&gt;
            echo $PAGE-&amp;gt;headingmenu&lt;br /&gt;
        ?&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
        &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar()) { ?&amp;gt;&lt;br /&gt;
            &amp;lt;div class=&amp;quot;navbar clearfix&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;breadcrumb&amp;quot;&amp;gt;&amp;lt;?php echo $OUTPUT-&amp;gt;navbar(); ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;navbutton&amp;quot;&amp;gt; &amp;lt;?php echo $PAGE-&amp;gt;button; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-content&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div id=&amp;quot;region-main-box&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;div id=&amp;quot;region-post-box&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div id=&amp;quot;region-main-wrap&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;div id=&amp;quot;region-main&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;?php echo core_renderer::MAIN_CONTENT_TOKEN ?&amp;gt;&lt;br /&gt;
                        &amp;lt;/div&amp;gt;&lt;br /&gt;
                    &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;div id=&amp;quot;region-pre&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-pre&#039;) ?&amp;gt;&lt;br /&gt;
                    &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;div id=&amp;quot;region-post&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-post&#039;) ?&amp;gt;&lt;br /&gt;
                    &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nofooter&#039;])) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-footer&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;p class=&amp;quot;helplink&amp;quot;&amp;gt;&amp;lt;?php echo page_doc_link(get_string(&#039;moodledocslink&#039;)) ?&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
        &amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;home_link();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;standard_footer_html();&lt;br /&gt;
        ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_end_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Adding some CSS==&lt;br /&gt;
With config.php and standard.php both complete the theme is now usable and starting to look like a real theme, however if you change to it using the theme selector you will notice that it still lacks any style.&lt;br /&gt;
&lt;br /&gt;
This of course is where CSS comes in. When writing code Moodle developers are strongly encouraged to not use inline styles anywhere. This is fantastic for us as themers because there is nothing (or at least very little) in Moodle that cannot be styled using CSS.&lt;br /&gt;
&lt;br /&gt;
===Moodle CSS basics===&lt;br /&gt;
&lt;br /&gt;
In Moodle 2.0 all of the CSS for the whole of Moodle is delivered all of the time! This was done for performance reasons. Moodle now reads in all of the CSS, combines it into one file, shrinks it removing any white space, caches it, and then delivers it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What this means for you as a themer?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You will need to write good CSS that won&#039;t clash with any other CSS within Moodle.&lt;br /&gt;
&lt;br /&gt;
Moodle is so big and complex,there is no way to ensure that classes don&#039;t get reused. What we can control however is the classes and id that get added to the body tag for every page. When writing CSS it is highly encouraged to make full use of these body classes, using them will help ensure the CSS you write has the least chance of causing conflicts.&lt;br /&gt;
&lt;br /&gt;
You should also take the time to look at how the Moodle themes use CSS. Look at their use of the body classes and how they separate the CSS for the theme into separate files based on the region of Moodle it applies to.&lt;br /&gt;
&lt;br /&gt;
Check out [[Development:Themes 2.0|Themes 2.0]] for more information about writing good CSS.&lt;br /&gt;
&lt;br /&gt;
===Starting to write excitement.css===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
a {text-decoration: none;}&lt;br /&gt;
.addcoursebutton .singlebutton {text-align: center;}&lt;br /&gt;
&lt;br /&gt;
h1.headermain {color: #fff;}&lt;br /&gt;
h2.main {border-bottom: 3px solid #013D6A;color: #013D6A;text-align: center;}&lt;br /&gt;
h2.headingblock {font-size: 18pt;margin-top: 0;background-color: #013D6A;color: #FFF;text-align: center;}&lt;br /&gt;
#page-header {background-color: #013D6A;}&lt;br /&gt;
#page-header .headermenu  {color: #FFF;}&lt;br /&gt;
#page-header .headermenu a {color: #FDFF2A;}&lt;br /&gt;
&lt;br /&gt;
.navbar {padding-left: 1em;}&lt;br /&gt;
.breadcrumb li {color: #FFF;}&lt;br /&gt;
.breadcrumb li a {color: #FFF;}&lt;br /&gt;
&lt;br /&gt;
.block {background-color: #013D6A;}&lt;br /&gt;
.block .header .title {color: #FFF;}&lt;br /&gt;
.block .header .title .block_action input {background-color: #FFF;}&lt;br /&gt;
.block .content {border: 1px solid #000;padding: 5px;background-color: #FFF;}&lt;br /&gt;
.block .content .block_tree p {font-size: 80%;}&lt;br /&gt;
&lt;br /&gt;
.block_settings_navigation_tree .content .footer {text-align: center;}&lt;br /&gt;
.block_settings_navigation_tree .content .footer .adminsearchform {margin-left: 5%;width: 90%;font-size: 9pt;}&lt;br /&gt;
.block_settings_navigation_tree .content .footer .adminsearchform #adminsearchquery {width: 95%;}&lt;br /&gt;
&lt;br /&gt;
.block_calendar_month .content .calendar-controls a {color: #013D6A;font-weight: bold;}&lt;br /&gt;
.block_calendar_month .content .minicalendar td {border-color: #FFF;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .day {color: #FFF;background-color: #013D6A;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .day a {color: #FFF000;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .weekdays th {border-width: 0;font-weight: bold;color: #013D6A;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .weekdays abbr {border-width: 0;text-decoration: none;}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
[[image:Learn_to_theme_02.jpg|400px|thumb|Excitement theme screenshot]]&lt;br /&gt;
This isn&#039;t all of the CSS for the theme, but just enough to style the front page when the user is not logged in.&lt;br /&gt;
Remember this theme extends the base theme so there is already CSS for layout as well.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
* The CSS is laid out in a single line format. This is done within the core themes for Moodle. It makes it quicker to read the selectors and see what is being styled.&lt;br /&gt;
* I have written my selectors to take into account the structure of the HTML (more than just the one tag I want to style). This helps further to reduce the conflicts that I may encounter.&lt;br /&gt;
* I use generic classes like &#039;&#039;.sideblock&#039;&#039; only where I want to be generic, as soon as I want to be specific I use the unique classes such as &#039;&#039;.block_calendar_month&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:right;&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using images within CSS===&lt;br /&gt;
&lt;br /&gt;
I will add two image files to the pix directory of my theme:&lt;br /&gt;
; /theme/excitement/pix/background.png : This will be the background image for my theme.&lt;br /&gt;
; /theme/excitement/pix/gradient.jpg : This will be a gradient I use for the header and headings.&lt;br /&gt;
I quickly created both of these images using gimp and simply saved them to the pix directory.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
html {background-image:url([[pix:theme|background]]);}&lt;br /&gt;
&lt;br /&gt;
h2.headingblock,&lt;br /&gt;
#page-header,&lt;br /&gt;
.sideblock,&lt;br /&gt;
.block_calendar_month .content .minicalendar .day {background-image:url([[pix:theme|gradient]]);background-repeat:repeat-x;background-color: #0273C8;}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
[[image:Learn_to_theme_03.jpg‎|400px|thumb|Excitement theme screenshot]]&lt;br /&gt;
The CSS above is the two new rules that I had to write to use my images within CSS.&lt;br /&gt;
&lt;br /&gt;
The first rule sets the background image for the page to background.png&lt;br /&gt;
&lt;br /&gt;
The second rule sets the background for headings, and the sideblocks to use gradient.jpg&lt;br /&gt;
&lt;br /&gt;
You will notice that I did not need to write a path to the image. This is because Moodle has this special syntax that can be used and will be replaced when the CSS is parsed before delivery.&lt;br /&gt;
The advantage of using this syntax over writing the path in is that the path may change depending on where you are or what theme is being used.&lt;br /&gt;
&lt;br /&gt;
Other themers may choose to extend your theme with their own; if you use this syntax then all they need to do to override the image is to create one with the same name in their themes directory.&lt;br /&gt;
&lt;br /&gt;
You will also notice that I don&#039;t need to add the image files extension. This is because Moodle is smart enough to work out what extension the file uses. It also allows themers to override images with different formats.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:right&amp;quot; /&amp;gt;&lt;br /&gt;
The following is the complete CSS for my theme:&lt;br /&gt;
&amp;lt;div style=&amp;quot;overflow:auto;height:400px;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
a {text-decoration: none;}&lt;br /&gt;
.addcoursebutton .singlebutton {text-align: center;}&lt;br /&gt;
&lt;br /&gt;
h1.headermain {color: #fff;}&lt;br /&gt;
h2.main {border-bottom: 3px solid #013D6A;color: #013D6A;text-align: center;}&lt;br /&gt;
h2.headingblock {font-size: 18pt;margin-top: 0;background-color: #013D6A;color: #FFF;text-align: center;}&lt;br /&gt;
#page-header {background-color: #013D6A;border-bottom:5px solid #013D6A;}&lt;br /&gt;
#page-header .headermenu  {color: #FFF;}&lt;br /&gt;
#page-header .headermenu a {color: #FDFF2A;}&lt;br /&gt;
&lt;br /&gt;
.sideblock {background-color: #013D6A;}&lt;br /&gt;
.sideblock .header .title {color: #FFF;}&lt;br /&gt;
.sideblock .header .title .block_action input {background-color: #FFF;}&lt;br /&gt;
.sideblock .content {border: 1px solid #000;padding: 5px;background-color: #FFF;}&lt;br /&gt;
.sideblock .content .block_tree p {font-size: 80%;}&lt;br /&gt;
&lt;br /&gt;
.block_settings_navigation_tree .content .footer {text-align: center;}&lt;br /&gt;
.block_settings_navigation_tree .content .footer .adminsearchform {margin-left: 5%;width: 90%;font-size: 9pt;}&lt;br /&gt;
.block_settings_navigation_tree .content .footer .adminsearchform #adminsearchquery {width: 95%;}&lt;br /&gt;
&lt;br /&gt;
.block_calendar_month .content .calendar-controls a {color: #013D6A;font-weight: bold;}&lt;br /&gt;
.block_calendar_month .content .minicalendar td {border-color: #FFF;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .day {color: #FFF;background-color: #013D6A;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .day a {color: #FFF000;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .weekdays th {border-width: 0;font-weight: bold;color: #013D6A;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .weekdays abbr {border-width: 0;text-decoration: none;}&lt;br /&gt;
&lt;br /&gt;
html {background-image:url([[pix:theme|background]]);}&lt;br /&gt;
&lt;br /&gt;
h2.headingblock,&lt;br /&gt;
#page-header,&lt;br /&gt;
.sideblock,&lt;br /&gt;
.block_calendar_month .content .minicalendar .day {background-image:url([[pix:theme|gradient]]);background-repeat:repeat-x;background-color: #0273C8;}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Adding a screenshot and favicon==&lt;br /&gt;
The final thing to do at this point is add both a screenshot for this theme as well as a favicon for it.&lt;br /&gt;
The screenshot will be shown in the theme selector screen and should be named &#039;&#039;screenshot.jpg&#039;&#039;.&lt;br /&gt;
The favicon will be used when someone bookmarks this page.&lt;br /&gt;
Both images should be located in your themes pix directory as follows:&lt;br /&gt;
* /theme/excitement/pix/screenshot.jpg&lt;br /&gt;
* /theme/excitement/pix/favicon.ico&lt;br /&gt;
&lt;br /&gt;
In the case of my theme I have taken a screenshot and added it to that directory, and because I don&#039;t really want to do anything special with the favicon I have copied it from /theme/base/pix/favicon.ico so that at least it will be recognisable as Moodle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Development:Themes 2.0]]&lt;br /&gt;
* [[Development:Themes 2.0 overriding a renderer]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Themes]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_creating_your_first_theme&amp;diff=72116</id>
		<title>Development:Themes 2.0 creating your first theme</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/310/en/index.php?title=Development:Themes_2.0_creating_your_first_theme&amp;diff=72116"/>
		<updated>2010-05-14T14:13:48Z</updated>

		<summary type="html">&lt;p&gt;Kordan: /* Starting to write excitement.css */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Themes}}{{Moodle 2.0}}This document describes how to create a theme for Moodle 2.0. It assumes you have some understanding of how themes within Moodle work as well as a good understanding of HTML and CSS.&lt;br /&gt;
&lt;br /&gt;
===Theme designer mode===&lt;br /&gt;
&lt;br /&gt;
Under normal operation Moodle does several things in the name of performance, one of these is to combine all of the CSS into one file, minimize it, cache it on the server, and then serve it. After the first request the cached version is served to greatly improve page performance. &lt;br /&gt;
&lt;br /&gt;
What this means for you as a themer? When you make changes they will not be seen immediately. In fact you will need to tell Moodle to rebuild the cache that it is serving.&lt;br /&gt;
This isn&#039;t practical for designing themes of course so the &#039;&#039;&#039;theme designer mode&#039;&#039;&#039; was added. When enabled it tells Moodle not to combine or cache the CSS that gets delivered. This has the downside that page load times will take significantly longer, however you will see you changes immediately every time.&lt;br /&gt;
&lt;br /&gt;
Theme designer mode may be enabled via &#039;&#039;Administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; [[Theme settings]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: Internet Explorer versions 6 and 7 have BIG problems when a site attempts to link to more than 31 stylesheets, in which case either a limited number or no styles get applied. Because Moodle sends up all of the CSS all of the time with theme designer mode turned on there is a very high chance you will get more than 31 stylesheets being included. This will of course cause major problems for Internet Explorer until theme designer mode is turned off.&lt;br /&gt;
&lt;br /&gt;
==Getting started==&lt;br /&gt;
&lt;br /&gt;
The first thing you need to do is create the directories and files you will be using, the first thing to create is the actual directory for your theme. This should be the name of your theme, in my case its &#039;excitement&#039;. The directory should be located within the theme directory of Moodle, ./moodle/theme/excitement/ will be the directory I create.&lt;br /&gt;
&lt;br /&gt;
Now within that directory we can immediately create several files that we know we are going to need. &lt;br /&gt;
&lt;br /&gt;
So the files that we want to create are:&lt;br /&gt;
; config.php :  All of our settings will go here.&lt;br /&gt;
; /style/ : This directory will contain all of our stylesheets.&lt;br /&gt;
; /style/excitement.css : All of our css will go in here.&lt;br /&gt;
; /pix/ : Into this directory we&#039;ll put a screen shot of our theme as well as our favicon and any images we use in CSS.&lt;br /&gt;
; /layout/ : Our layout files will end up in this directory.&lt;br /&gt;
; /layout/standard.php : This will be our one basic layout file.&lt;br /&gt;
&lt;br /&gt;
So after this setup step you should have a directory structure similar to what is shown below.&lt;br /&gt;
&lt;br /&gt;
[[image:Learn_to_theme_01.jpg]]&lt;br /&gt;
&lt;br /&gt;
==Configuring our theme==&lt;br /&gt;
&lt;br /&gt;
Open config.php in you favourite editor and start by adding the opening PHP tags &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;&amp;lt;?php&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now we need to add the settings:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$THEME-&amp;gt;name = &#039;excitement&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Very simply this tells the Moodle the name of your theme, and if you ever have several config.php files open this will be help you identify which one you are looking at.&lt;br /&gt;
&lt;br /&gt;
Next the parents for this theme.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$THEME-&amp;gt;parents = array(&#039;base&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This tells Moodle that my new theme &#039;&#039;`excitement`&#039; wants to extend the base theme. &lt;br /&gt;
&lt;br /&gt;
A theme can extend any number of themes. Rather than creating an entirely new theme and copying all of the CSS, you can simply create a new theme, extend the theme you like and just add the changes you want to your theme. &lt;br /&gt;
&lt;br /&gt;
Also worth noting is the purpose of the base theme: it provides us with a basic layout and just enough CSS to make everything fall into place.&lt;br /&gt;
&lt;br /&gt;
Now we will tell Moodle about our stylesheets:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$THEME-&amp;gt;sheets = array(&#039;excitement&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The final thing we need to add into our themes config.php file is the definition of the layouts for our theme:&lt;br /&gt;
&amp;lt;div style=&amp;quot;height:400px;overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$THEME-&amp;gt;layouts = array(&lt;br /&gt;
    &#039;base&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;standard&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;course&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;coursecategory&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;incourse&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;frontpage&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;admin&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-pre&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;mydashboard&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;langmenu&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;mypublic&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(&#039;side-pre&#039;, &#039;side-post&#039;),&lt;br /&gt;
        &#039;defaultregion&#039; =&amp;gt; &#039;side-post&#039;,&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;login&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;langmenu&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;popup&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;nofooter&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;frametop&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;nofooter&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
    &#039;maintenance&#039; =&amp;gt; array(&lt;br /&gt;
        &#039;file&#039; =&amp;gt; &#039;standard.php&#039;,&lt;br /&gt;
        &#039;regions&#039; =&amp;gt; array(),&lt;br /&gt;
        &#039;options&#039; =&amp;gt; array(&#039;nofooter&#039;=&amp;gt;true, &#039;nonavbar&#039;=&amp;gt;true),&lt;br /&gt;
    ),&lt;br /&gt;
);&lt;br /&gt;
&lt;br /&gt;
/** List of javascript files that need to be included on each page */&lt;br /&gt;
$THEME-&amp;gt;javascripts = array();&lt;br /&gt;
$THEME-&amp;gt;javascripts_footer = array();&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What you are looking at is the different layouts for our theme. Why are there so many? because that is how many there are in Moodle, there is one for every general type of page. With my &#039;&#039;`excitement`&#039;&#039; theme I have chosen to use my own layout, unless there was specific reason to do so normally you would not need to create your own layouts, you could of course extend the base theme and use its layouts meaning you would only have to write CSS to achieve your desired look.&lt;br /&gt;
&lt;br /&gt;
For each layout above you will notice the following four things are being set:&lt;br /&gt;
; file : This is the name of the layout file we want to use, it should always be located in the above themes layout directory. For us this is of course standard.php as we only have one layout file.&lt;br /&gt;
; regions : This is an array of block regions that our theme has. Each entry in here can be used to put blocks in when that layout is being used.&lt;br /&gt;
; defaultregion : If a layout has regions it should have a default region, this is where blocks get put when first added.&lt;br /&gt;
; options : These are special settings, anything that gets put into the options array is available later on when we are writing our layout file.&lt;br /&gt;
&lt;br /&gt;
There are additional settings that can be defined in the config.php file - see [[Development:Themes 2.0|Themes 2.0]] for the full list.&lt;br /&gt;
&lt;br /&gt;
==Writing the layout file==&lt;br /&gt;
&lt;br /&gt;
The excitement theme has just one layout file.&lt;br /&gt;
&lt;br /&gt;
The downside of this is that I have to make the layout file do everything I want which means I need to make use of some options (as defined in the layouts in config.php). &lt;br /&gt;
&lt;br /&gt;
The upside is that I only need to maintain one file. &lt;br /&gt;
&lt;br /&gt;
Other than maintenance, using multiple layout files provides many advantages to real world themes in that you can easily tweak and customise specific layouts to achieve the goals of the organisation using the theme.&lt;br /&gt;
&lt;br /&gt;
So lets start writing standard.php, the layout file for my &#039;&#039;`excitement`&#039;&#039; theme.&lt;br /&gt;
&lt;br /&gt;
===The top of the layout file===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo $OUTPUT-&amp;gt;doctype(); ?&amp;gt;&lt;br /&gt;
&amp;lt;html &amp;lt;?php echo $OUTPUT-&amp;gt;htmlattributes() ?&amp;gt;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;title ?&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $OUTPUT-&amp;gt;standard_head_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Lets look at the code that goes into this section:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo $OUTPUT-&amp;gt;doctype(); ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This is very important and is required to go at the very top of the page. This tells Moodle to print out the document type tag that is determined by the settings within Moodle.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;html &amp;lt;?php echo $OUTPUT-&amp;gt;htmlattributes() ?&amp;gt;&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we open the HTML tag and then ask Moodle to print the attributes that should go inside it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;title ?&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Simply creates the title tag and asks Moodle to fill it in.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $OUTPUT-&amp;gt;standard_head_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we are asking Moodle to print all of the other tags and content that need to go into the head. This includes stylesheets, script tags, and inline JavaScript code.&lt;br /&gt;
&lt;br /&gt;
===The page header===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;body id=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyid; ?&amp;gt;&amp;quot; class=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyclasses; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_top_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;page&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php if ($PAGE-&amp;gt;heading || (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar())) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-header&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;?php if ($PAGE-&amp;gt;heading) { ?&amp;gt;&lt;br /&gt;
            &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
            &amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
                echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
                if (!empty($PAGE-&amp;gt;layout_options[&#039;langmenu&#039;])) {&lt;br /&gt;
                    echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
                }&lt;br /&gt;
                echo $PAGE-&amp;gt;headingmenu&lt;br /&gt;
            ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
        &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar()) { ?&amp;gt;&lt;br /&gt;
            &amp;lt;div class=&amp;quot;navbar clearfix&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;breadcrumb&amp;quot;&amp;gt;&amp;lt;?php echo $OUTPUT-&amp;gt;navbar(); ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;navbutton&amp;quot;&amp;gt; &amp;lt;?php echo $PAGE-&amp;gt;button; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
So there is a bit more going on here obviously.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;body id=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyid; ?&amp;gt;&amp;quot; class=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyclasses; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Again much like what we did for the opening HTML tag in the head we have started writing the opening body tag and are then asking Moodle to give us the ID we should use for the body tag as well as the classes we should use.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_top_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This very important call writes some critical bits of JavaScript into the page. It should always be located after the body tag as soon as possible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php if ($PAGE-&amp;gt;heading || (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar())) { ?&amp;gt;&lt;br /&gt;
......&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we are checking whether or not we need to print the header for the page. There are three checks we need to make here:&lt;br /&gt;
# &#039;&#039;&#039;$PAGE-&amp;gt;heading&#039;&#039;&#039; : This checks to make sure that there is a heading for the page. This will have been set by the script and normally describes the page in a couple of words.&lt;br /&gt;
# &#039;&#039;&#039;empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;])&#039;&#039;&#039; : Now this check is looking at the layout options that we set in our config.php file. It is looking to see if the layout set &#039;nonavbar&#039; =&amp;gt; true.&lt;br /&gt;
# &#039;&#039;&#039;$PAGE-&amp;gt;has_navbar()&#039;&#039;&#039; The third check is to check with the page whether it has a navigation bar to display.&lt;br /&gt;
If either there is a heading for this page or there is a navigation bar to display then we will display a heading.&lt;br /&gt;
&lt;br /&gt;
Leading on from this lets assume that there is a header to print.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php if ($PAGE-&amp;gt;heading) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
    .....&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This line is simply saying if the page has a heading print it. In this case we run the first check above again just to make sute there is a heading, we then open a heading tag that we choose and ask the page to print the heading.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
    echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
    if (!empty($PAGE-&amp;gt;layout_options[&#039;langmenu&#039;])) {&lt;br /&gt;
        echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
    }&lt;br /&gt;
    echo $PAGE-&amp;gt;headingmenu&lt;br /&gt;
?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we are looking to print the menu and content that you see at the top of the page (usually to the right). We start by getting Moodle to print the login information for the current user. If the user is logged in this will be their name and a link to their profile, if not then it will be a link to login.&lt;br /&gt;
&lt;br /&gt;
Next we check our page options to see whether a language menu should be printed. If in the layout definition within config.php it sets &#039;&#039;&#039;langmenu =&amp;gt; true&#039;&#039;&#039; then we will print the language menu, a drop down box that lets the user change the language that Moodle displays in.&lt;br /&gt;
&lt;br /&gt;
Finally the page also has a heading menu that can be printed. This heading menu is special HTML that the page you are viewing wants to add. It can be anything from drop down boxes to buttons and any number of each.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar()) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div class=&amp;quot;navbar clearfix&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;breadcrumb&amp;quot;&amp;gt;&amp;lt;?php echo $OUTPUT-&amp;gt;navbar(); ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;navbutton&amp;quot;&amp;gt; &amp;lt;?php echo $PAGE-&amp;gt;button; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The final part of the header.&lt;br /&gt;
&lt;br /&gt;
Here we want to print the navigation bar for the page if there is one. To find out if there is one we run checks number 2 and 3 again and proceed if they pass.&lt;br /&gt;
&lt;br /&gt;
Assuming there is a header then there are two things that we need to print. The first is the navigation bar. This is a component that the OUTPUT library knows about. The second is a button to shown on the page.&lt;br /&gt;
&lt;br /&gt;
In both cases we can choose to wrap them in a div to make our life as a themer easier.&lt;br /&gt;
&lt;br /&gt;
Well that is it for the header. There is a lot of PHP compared to the other sections of the layout file but it does not change and can be copied and pasted between themes.&lt;br /&gt;
&lt;br /&gt;
===The page content===&lt;br /&gt;
&lt;br /&gt;
I am going with the default two block regions plus the main content.&lt;br /&gt;
&lt;br /&gt;
Because I have based this theme and layout file on the base theme the HTML looks a little intense. This is because it is a floating div layout where the content comes first and then we get the columns (even though one column will be to the left of the content.) Don&#039;t worry too much about it. When it comes to writing your own theme you can go about it as you choose.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;page-content&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;region-main-box&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div id=&amp;quot;region-post-box&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;div id=&amp;quot;region-main-wrap&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div id=&amp;quot;region-main&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;?php echo core_renderer::MAIN_CONTENT_TOKEN ?&amp;gt;&lt;br /&gt;
                    &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;div id=&amp;quot;region-pre&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-pre&#039;) ?&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;div id=&amp;quot;region-post&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-post&#039;) ?&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In regards to PHP this section is very easy. There are only three lines for the whole section one to get the main content and one for each block region.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo core_renderer::MAIN_CONTENT_TOKEN ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This line prints the main content for the page.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-pre&#039;) ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This line gets all of the blocks and more particularly the content for the block region &#039;&#039;&#039;side-pre&#039;&#039;&#039;. This block region will be displayed to the left of the content.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-post&#039;) ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Here we are getting the other block region &#039;&#039;&#039;side-post&#039;&#039;&#039; which will be displayed to the right of the content.&lt;br /&gt;
&lt;br /&gt;
===The page footer===&lt;br /&gt;
Here we want to print the footer for the page, any content required by Moodle, and then close the last tags.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nofooter&#039;])) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-footer&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;p class=&amp;quot;helplink&amp;quot;&amp;gt;&amp;lt;?php echo page_doc_link(get_string(&#039;moodledocslink&#039;)) ?&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
        &amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;home_link();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;standard_footer_html();&lt;br /&gt;
        ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_end_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The section of code is responsible for printing the footer for the page.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
    &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nofooter&#039;])) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-footer&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;p class=&amp;quot;helplink&amp;quot;&amp;gt;&amp;lt;?php echo page_doc_link(get_string(&#039;moodledocslink&#039;)) ?&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
        &amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;home_link();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;standard_footer_html();&lt;br /&gt;
        ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
The first thing we do before printing the footer is check that we actually want to print it. This is done by checking the options for the layout as defined in the config.php file. If &#039;&#039;&#039;nofooter =&amp;gt; true&#039;&#039;&#039; is set the we don&#039;t want to print the footer and should skip over this body of code.&lt;br /&gt;
&lt;br /&gt;
Assuming we want to print a footer we proceed to create a div to house its content and then print the bits of the content that will make it up.&lt;br /&gt;
There are four things that the typical page footer will want to print:&lt;br /&gt;
; echo page_doc_link(get_string(&#039;moodledocslink&#039;)) : This will print a link to the Moodle.org help page for this particular page.&lt;br /&gt;
; echo $OUTPUT-&amp;gt;login_info(); : This is the same as at the top of the page and will print the login information for the current user.&lt;br /&gt;
; echo $OUTPUT-&amp;gt;home_link(); : This prints a link back to the Moodle home page for this site.&lt;br /&gt;
; echo $OUTPUT-&amp;gt;standard_footer_html(); : This prints special HTML that is determined by the settings for the site. Things such as performance information or debugging will be printed by this line if they are turned on.&lt;br /&gt;
&lt;br /&gt;
And the final line of code for our layout file is:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_end_of_body_html(); ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
This is one of the most important lines of code in the layout file. It asks Moodle to print any required content into the page, and there will likely be a lot although most of it will not be visual.&lt;br /&gt;
&lt;br /&gt;
It will instead be things such as inline scripts and JavaScript files required to go at the bottom of the page. If you forget this line its likely no JavaScript will work!&lt;br /&gt;
&lt;br /&gt;
We&#039;ve now written our layout file and it is all set to go. The complete source is below for reference. Remember if you want more practical examples simply look at the layout files located within the layout directory of other themes.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div style=&amp;quot;height:400px;overflow:auto;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
echo $OUTPUT-&amp;gt;doctype() ?&amp;gt;&lt;br /&gt;
&amp;lt;html &amp;lt;?php echo $OUTPUT-&amp;gt;htmlattributes() ?&amp;gt;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;title; ?&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;
    &amp;lt;link rel=&amp;quot;shortcut icon&amp;quot; href=&amp;quot;&amp;lt;?php echo $OUTPUT-&amp;gt;pix_url(&#039;favicon&#039;, &#039;theme&#039;)?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;?php echo $OUTPUT-&amp;gt;standard_head_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;body id=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyid; ?&amp;gt;&amp;quot; class=&amp;quot;&amp;lt;?php echo $PAGE-&amp;gt;bodyclasses; ?&amp;gt;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_top_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;page&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;?php if ($PAGE-&amp;gt;heading || (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar())) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-header&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;?php if ($PAGE-&amp;gt;heading) { ?&amp;gt;&lt;br /&gt;
        &amp;lt;h1 class=&amp;quot;headermain&amp;quot;&amp;gt;&amp;lt;?php echo $PAGE-&amp;gt;heading ?&amp;gt;&amp;lt;/h1&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;headermenu&amp;quot;&amp;gt;&amp;lt;?php&lt;br /&gt;
            echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
            if (!empty($PAGE-&amp;gt;layout_options[&#039;langmenu&#039;])) {&lt;br /&gt;
                echo $OUTPUT-&amp;gt;lang_menu();&lt;br /&gt;
            }&lt;br /&gt;
            echo $PAGE-&amp;gt;headingmenu&lt;br /&gt;
        ?&amp;gt;&amp;lt;/div&amp;gt;&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
        &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nonavbar&#039;]) &amp;amp;&amp;amp; $PAGE-&amp;gt;has_navbar()) { ?&amp;gt;&lt;br /&gt;
            &amp;lt;div class=&amp;quot;navbar clearfix&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;breadcrumb&amp;quot;&amp;gt;&amp;lt;?php echo $OUTPUT-&amp;gt;navbar(); ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;div class=&amp;quot;navbutton&amp;quot;&amp;gt; &amp;lt;?php echo $PAGE-&amp;gt;button; ?&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-content&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div id=&amp;quot;region-main-box&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;div id=&amp;quot;region-post-box&amp;quot;&amp;gt;&lt;br /&gt;
                &amp;lt;div id=&amp;quot;region-main-wrap&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;div id=&amp;quot;region-main&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                            &amp;lt;?php echo core_renderer::MAIN_CONTENT_TOKEN ?&amp;gt;&lt;br /&gt;
                        &amp;lt;/div&amp;gt;&lt;br /&gt;
                    &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;div id=&amp;quot;region-pre&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-pre&#039;) ?&amp;gt;&lt;br /&gt;
                    &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;div id=&amp;quot;region-post&amp;quot;&amp;gt;&lt;br /&gt;
                    &amp;lt;div class=&amp;quot;region-content&amp;quot;&amp;gt;&lt;br /&gt;
                        &amp;lt;?php echo $OUTPUT-&amp;gt;blocks_for_region(&#039;side-post&#039;) ?&amp;gt;&lt;br /&gt;
                    &amp;lt;/div&amp;gt;&lt;br /&gt;
                &amp;lt;/div&amp;gt;&lt;br /&gt;
            &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;?php if (empty($PAGE-&amp;gt;layout_options[&#039;nofooter&#039;])) { ?&amp;gt;&lt;br /&gt;
    &amp;lt;div id=&amp;quot;page-footer&amp;quot; class=&amp;quot;clearfix&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;p class=&amp;quot;helplink&amp;quot;&amp;gt;&amp;lt;?php echo page_doc_link(get_string(&#039;moodledocslink&#039;)) ?&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
        &amp;lt;?php&lt;br /&gt;
        echo $OUTPUT-&amp;gt;login_info();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;home_link();&lt;br /&gt;
        echo $OUTPUT-&amp;gt;standard_footer_html();&lt;br /&gt;
        ?&amp;gt;&lt;br /&gt;
    &amp;lt;/div&amp;gt;&lt;br /&gt;
    &amp;lt;?php } ?&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;?php echo $OUTPUT-&amp;gt;standard_end_of_body_html() ?&amp;gt;&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Adding some CSS==&lt;br /&gt;
With config.php and standard.php both complete the theme is now usable and starting to look like a real theme, however if you change to it using the theme selector you will notice that it still lacks any style.&lt;br /&gt;
&lt;br /&gt;
This of course is where CSS comes in. When writing code Moodle developers are strongly encouraged to not use inline styles anywhere. This is fantastic for us as themers because there is nothing (or at least very little) in Moodle that cannot be styled using CSS.&lt;br /&gt;
&lt;br /&gt;
===Moodle CSS basics===&lt;br /&gt;
&lt;br /&gt;
In Moodle 2.0 all of the CSS for the whole of Moodle is delivered all of the time! This was done for performance reasons. Moodle now reads in all of the CSS, combines it into one file, shrinks it removing any white space, caches it, and then delivers it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What this means for you as a themer?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You will need to write good CSS that won&#039;t clash with any other CSS within Moodle.&lt;br /&gt;
&lt;br /&gt;
Moodle is so big and complex,there is no way to ensure that classes don&#039;t get reused. What we can control however is the classes and id that get added to the body tag for every page. When writing CSS it is highly encouraged to make full use of these body classes, using them will help ensure the CSS you write has the least chance of causing conflicts.&lt;br /&gt;
&lt;br /&gt;
You should also take the time to look at how the Moodle themes use CSS. Look at their use of the body classes and how they separate the CSS for the theme into separate files based on the region of Moodle it applies to.&lt;br /&gt;
&lt;br /&gt;
Check out [[Development:Themes 2.0|Themes 2.0]] for more information about writing good CSS.&lt;br /&gt;
&lt;br /&gt;
===Starting to write excitement.css===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
a {text-decoration: none;}&lt;br /&gt;
.addcoursebutton .singlebutton {text-align: center;}&lt;br /&gt;
&lt;br /&gt;
h1.headermain {color: #fff;}&lt;br /&gt;
h2.main {border-bottom: 3px solid #013D6A;color: #013D6A;text-align: center;}&lt;br /&gt;
h2.headingblock {font-size: 18pt;margin-top: 0;background-color: #013D6A;color: #FFF;text-align: center;}&lt;br /&gt;
#page-header {background-color: #013D6A;}&lt;br /&gt;
#page-header .headermenu  {color: #FFF;}&lt;br /&gt;
#page-header .headermenu a {color: #FDFF2A;}&lt;br /&gt;
&lt;br /&gt;
.block {background-color: #013D6A;}&lt;br /&gt;
.block .header .title {color: #FFF;}&lt;br /&gt;
.block .header .title .block_action input {background-color: #FFF;}&lt;br /&gt;
.block .content {border: 1px solid #000;padding: 5px;background-color: #FFF;}&lt;br /&gt;
.block .content .block_tree p {font-size: 80%;}&lt;br /&gt;
&lt;br /&gt;
.block_settings_navigation_tree .content .footer {text-align: center;}&lt;br /&gt;
.block_settings_navigation_tree .content .footer .adminsearchform {margin-left: 5%;width: 90%;font-size: 9pt;}&lt;br /&gt;
.block_settings_navigation_tree .content .footer .adminsearchform #adminsearchquery {width: 95%;}&lt;br /&gt;
&lt;br /&gt;
.block_calendar_month .content .calendar-controls a {color: #013D6A;font-weight: bold;}&lt;br /&gt;
.block_calendar_month .content .minicalendar td {border-color: #FFF;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .day {color: #FFF;background-color: #013D6A;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .day a {color: #FFF000;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .weekdays th {border-width: 0;font-weight: bold;color: #013D6A;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .weekdays abbr {border-width: 0;text-decoration: none;}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
[[image:Learn_to_theme_02.jpg|400px|thumb|Excitement theme screenshot]]&lt;br /&gt;
This isn&#039;t all of the CSS for the theme, but just enough to style the front page when the user is not logged in.&lt;br /&gt;
Remember this theme extends the base theme so there is already CSS for layout as well.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
* The CSS is laid out in a single line format. This is done within the core themes for Moodle. It makes it quicker to read the selectors and see what is being styled.&lt;br /&gt;
* I have written my selectors to take into account the structure of the HTML (more than just the one tag I want to style). This helps further to reduce the conflicts that I may encounter.&lt;br /&gt;
* I use generic classes like &#039;&#039;.sideblock&#039;&#039; only where I want to be generic, as soon as I want to be specific I use the unique classes such as &#039;&#039;.block_calendar_month&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:right;&amp;quot; /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Using images within CSS===&lt;br /&gt;
&lt;br /&gt;
I will add two image files to the pix directory of my theme:&lt;br /&gt;
; /theme/excitement/pix/background.png : This will be the background image for my theme.&lt;br /&gt;
; /theme/excitement/pix/gradient.jpg : This will be a gradient I use for the header and headings.&lt;br /&gt;
I quickly created both of these images using gimp and simply saved them to the pix directory.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
html {background-image:url([[pix:theme|background]]);}&lt;br /&gt;
&lt;br /&gt;
h2.headingblock,&lt;br /&gt;
#page-header,&lt;br /&gt;
.sideblock,&lt;br /&gt;
.block_calendar_month .content .minicalendar .day {background-image:url([[pix:theme|gradient]]);background-repeat:repeat-x;background-color: #0273C8;}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
[[image:Learn_to_theme_03.jpg‎|400px|thumb|Excitement theme screenshot]]&lt;br /&gt;
The CSS above is the two new rules that I had to write to use my images within CSS.&lt;br /&gt;
&lt;br /&gt;
The first rule sets the background image for the page to background.png&lt;br /&gt;
&lt;br /&gt;
The second rule sets the background for headings, and the sideblocks to use gradient.jpg&lt;br /&gt;
&lt;br /&gt;
You will notice that I did not need to write a path to the image. This is because Moodle has this special syntax that can be used and will be replaced when the CSS is parsed before delivery.&lt;br /&gt;
The advantage of using this syntax over writing the path in is that the path may change depending on where you are or what theme is being used.&lt;br /&gt;
&lt;br /&gt;
Other themers may choose to extend your theme with their own; if you use this syntax then all they need to do to override the image is to create one with the same name in their themes directory.&lt;br /&gt;
&lt;br /&gt;
You will also notice that I don&#039;t need to add the image files extension. This is because Moodle is smart enough to work out what extension the file uses. It also allows themers to override images with different formats.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br style=&amp;quot;clear:right&amp;quot; /&amp;gt;&lt;br /&gt;
The following is the complete CSS for my theme:&lt;br /&gt;
&amp;lt;div style=&amp;quot;overflow:auto;height:400px;&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
a {text-decoration: none;}&lt;br /&gt;
.addcoursebutton .singlebutton {text-align: center;}&lt;br /&gt;
&lt;br /&gt;
h1.headermain {color: #fff;}&lt;br /&gt;
h2.main {border-bottom: 3px solid #013D6A;color: #013D6A;text-align: center;}&lt;br /&gt;
h2.headingblock {font-size: 18pt;margin-top: 0;background-color: #013D6A;color: #FFF;text-align: center;}&lt;br /&gt;
#page-header {background-color: #013D6A;border-bottom:5px solid #013D6A;}&lt;br /&gt;
#page-header .headermenu  {color: #FFF;}&lt;br /&gt;
#page-header .headermenu a {color: #FDFF2A;}&lt;br /&gt;
&lt;br /&gt;
.sideblock {background-color: #013D6A;}&lt;br /&gt;
.sideblock .header .title {color: #FFF;}&lt;br /&gt;
.sideblock .header .title .block_action input {background-color: #FFF;}&lt;br /&gt;
.sideblock .content {border: 1px solid #000;padding: 5px;background-color: #FFF;}&lt;br /&gt;
.sideblock .content .block_tree p {font-size: 80%;}&lt;br /&gt;
&lt;br /&gt;
.block_settings_navigation_tree .content .footer {text-align: center;}&lt;br /&gt;
.block_settings_navigation_tree .content .footer .adminsearchform {margin-left: 5%;width: 90%;font-size: 9pt;}&lt;br /&gt;
.block_settings_navigation_tree .content .footer .adminsearchform #adminsearchquery {width: 95%;}&lt;br /&gt;
&lt;br /&gt;
.block_calendar_month .content .calendar-controls a {color: #013D6A;font-weight: bold;}&lt;br /&gt;
.block_calendar_month .content .minicalendar td {border-color: #FFF;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .day {color: #FFF;background-color: #013D6A;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .day a {color: #FFF000;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .weekdays th {border-width: 0;font-weight: bold;color: #013D6A;}&lt;br /&gt;
.block_calendar_month .content .minicalendar .weekdays abbr {border-width: 0;text-decoration: none;}&lt;br /&gt;
&lt;br /&gt;
html {background-image:url([[pix:theme|background]]);}&lt;br /&gt;
&lt;br /&gt;
h2.headingblock,&lt;br /&gt;
#page-header,&lt;br /&gt;
.sideblock,&lt;br /&gt;
.block_calendar_month .content .minicalendar .day {background-image:url([[pix:theme|gradient]]);background-repeat:repeat-x;background-color: #0273C8;}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Adding a screenshot and favicon==&lt;br /&gt;
The final thing to do at this point is add both a screenshot for this theme as well as a favicon for it.&lt;br /&gt;
The screenshot will be shown in the theme selector screen and should be named &#039;&#039;screenshot.jpg&#039;&#039;.&lt;br /&gt;
The favicon will be used when someone bookmarks this page.&lt;br /&gt;
Both images should be located in your themes pix directory as follows:&lt;br /&gt;
* /theme/excitement/pix/screenshot.jpg&lt;br /&gt;
* /theme/excitement/pix/favicon.ico&lt;br /&gt;
&lt;br /&gt;
In the case of my theme I have taken a screenshot and added it to that directory, and because I don&#039;t really want to do anything special with the favicon I have copied it from /theme/base/pix/favicon.ico so that at least it will be recognisable as Moodle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Development:Themes 2.0]]&lt;br /&gt;
* [[Development:Themes 2.0 overriding a renderer]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Themes]]&lt;/div&gt;</summary>
		<author><name>Kordan</name></author>
	</entry>
</feed>