<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/502/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Josepuib</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/502/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Josepuib"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/Special:Contributions/Josepuib"/>
	<updated>2026-04-19T06:37:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:XMLDB_introduction&amp;diff=74250</id>
		<title>Development:XMLDB introduction</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:XMLDB_introduction&amp;diff=74250"/>
		<updated>2010-07-28T12:40:48Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: Wrong verbal tense&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Development:XMLDB Documentation|XMLDB Documentation]] &amp;gt; Introduction&lt;br /&gt;
----&lt;br /&gt;
__NOTOC__&lt;br /&gt;
One of the main upcoming features in Moodle 1.7 will be its ability to work with some more [[wikipedia:RDBMS|RDBMS]] ([[wikipedia:MSSQL|MSSQL]] and [[wikipedia:Oracle database|Oracle]]) while maintaining everything working properly with both [[MySQL]] and [[PostgreSQL]]. As Moodle core uses [http://adodb.sourceforge.net/ ADOdb] internally, this possibility has been present since the beginning and, with the current maturity of the project (5 year old baby!), this can be a good moment to sort all this out.&lt;br /&gt;
&lt;br /&gt;
Initially, all our tests and preliminary work was to inspect how [http://adodb.sourceforge.net/ ADOdb] was doing its work, and how we could mix together all those 4 RDBMS, whose SQL dialects, although pretty similar, have some differences and idiosyncrasies that force us to do some important changes to our current database code (formerly &#039;&#039;&#039;datalib.php&#039;&#039;&#039;) and how it&#039;s used by the rest of Moodle.&lt;br /&gt;
&lt;br /&gt;
All the changes to be performed, which primary objective is to enable Moodle to work with more RDBMS, must be fulfilled by following these non-functional requirements: &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Provide one layer (new) for DB creation/upgrade&#039;&#039;&#039; ([[wikipedia:Data_Definition_Language|DDL]]): With this, developers will create their structures in one neutral form, independent of the exact implementation to be used by each RDBMS.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Provide one layer (existing) for DB handling&#039;&#039;&#039; ([[wikipedia:Data_Manipulation_Language|DML]]): With this, developers will request/store information also in one neutral form, independent of the RDBMS being used.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Easy migration path from previous versions&#039;&#039;&#039;: The current installation/upgrade system will work until, at least, Moodle 2.0, allowing 3rd party developers to migrate to the new system.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Simple, usable and effective&#039;&#039;&#039;: Until now, the way to upgrade Moodle has been really cool and it has worked pretty fine since the beginning. However, it has forced developers to maintain at least two installation and two upgrade scripts for each module/plugin. The new alternative will have only one file to install and one file to upgrade (per module/plugin too), reducing the possibility of mistakes drastically.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Conditional code usage must be minimised&#039;&#039;&#039;: Database libraries must accept 99% of potential SQL sentences, building/transforming them as necessary to work properly under any RDBMS. The number of places using custom (per DB) code should be minimum.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Well documented&#039;&#039;&#039;: All the functions defined, both at DML and DDL level must be well documented, helping the developer to find and use the correct one in each situation.&lt;br /&gt;
&lt;br /&gt;
== The Stack ==&lt;br /&gt;
&lt;br /&gt;
The next stack shows how Moodle 1.7 code will interact with the underlying RDBMS. It will help us understand a bit more what we are trying to do and will explain some of the points related in the Roadmap (below in this page).&lt;br /&gt;
&lt;br /&gt;
[[Image:MoodleDBStack.png|center]]&lt;br /&gt;
&lt;br /&gt;
Moodle code will use two &#039;&#039;languages&#039;&#039; to perform its DB actions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;XMLDB neutral description files&#039;&#039;&#039;: To create, modify and delete database objects (DDL: create/alter/drop tables, fields, indexes, constraints...). It consists of a collection of validated, standard, XML files. They will be used to define all the DB objects. New for 1.7.&lt;br /&gt;
* &#039;&#039;&#039;Moodle SQL neutral statements&#039;&#039;&#039;: To add, modify, delete and select database information (DML: insert/update/delete/select records). To modify for 1.7.&lt;br /&gt;
&lt;br /&gt;
Please note the &#039;&#039;&#039;neutral&#039;&#039;&#039; keyword used in the expressions above. It means that both &#039;&#039;&#039;languages&#039;&#039;&#039; will be 100% the same, independent of the underlying RDBMS being used. And this must be particularly true for the XMLDB part.&lt;br /&gt;
&lt;br /&gt;
Obviously it&#039;s possible that in the SQL part we find some specialised queries (using complex joins, regular expressions...) that will force us to do some &#039;&#039;&#039;Exceptions&#039;&#039;&#039;. Well, they can exist (in fact, they exist), but we always must try to provide an alternate path to minimise them using neutral statements and standard libraries.&lt;br /&gt;
&lt;br /&gt;
Each one of the &#039;&#039;&#039;languages&#039;&#039;&#039; above will use its own library to do the work:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Moodle DDL Library&#039;&#039;&#039; ([[Development:DDL functions|ddllib.php]]): Where all the functions needed to handle DB objects will exist. This library is new for 1.7 and will provide developers with a high level of abstraction. As input it will accept some well defined objects and actions and it will execute the proper commands for the RDBMS being used.&lt;br /&gt;
* &#039;&#039;&#039;Moodle DML Library&#039;&#039;&#039; ([[Development:DML functions|dmllib.php]]): Where all the functions needed to handle DB contents will exist. This library is new for 1.7, although its contents are, basically, functions currently present in &#039;&#039;&#039;datalib.php&#039;&#039;&#039; (moved from there). All those DML functions will offer cross-db support for insert/update/delete/select statements using a common behaviour.&lt;br /&gt;
&lt;br /&gt;
Also note that &#039;&#039;&#039;datalib.php&#039;&#039;&#039; is still present in the schema above. It will contain all the functions that haven&#039;t been moved to the new &#039;&#039;&#039;ddllib.php&#039;&#039;&#039; and &#039;&#039;&#039;dmllib.php&#039;&#039;&#039; libraries. Only some common functions will remain there, and these will disappear (it&#039;s considered a legacy library) in upcoming &#039;&#039;&#039;Moodle&#039;&#039;&#039; releases (after 1.7) by moving all those functions to their proper library (course/lib.php, user/lib.php....). &lt;br /&gt;
&lt;br /&gt;
Both of these libraries (plus the small &#039;&#039;&#039;Exceptions&#039;&#039;&#039; bar) will perform all their actions using the &#039;&#039;&#039;ADOdb Database Abstraction Library for PHP&#039;&#039;&#039; that will receive all the requests from them, communicate with the DB (&#039;&#039;&#039;MySQL&#039;&#039;&#039;, &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;, &#039;&#039;&#039;Oracle&#039;&#039;&#039; or &#039;&#039;&#039;SQL*Server&#039;&#039;&#039;), retrieve results and forward them back to originator library.&lt;br /&gt;
&lt;br /&gt;
== The process ==&lt;br /&gt;
&lt;br /&gt;
This section points to the main areas of information about the &#039;&#039;&#039;process of design and implementation&#039;&#039;&#039; of the new XMLDB layer:&lt;br /&gt;
&lt;br /&gt;
* [[XMLDB Roadmap|Roadmap]]: Where the whole process is defined. It has been split into small chunks to be performed and tested easily. Also, such documents should be used to track what&#039;s done and what&#039;s pending, while using easy nomenclature.&lt;br /&gt;
&lt;br /&gt;
* [[XMLDB Problems|Problems]]: A comprehensive list of issues that need to be determined/solved prior to incorporating them into the [[XMLDB Roadmap|roadmap]].&lt;br /&gt;
&lt;br /&gt;
== The documentation ==&lt;br /&gt;
&lt;br /&gt;
This section points to the &#039;&#039;&#039;main documentation index&#039;&#039;&#039; about the implemented XMLDB:&lt;br /&gt;
&lt;br /&gt;
* [[Development:XMLDB Documentation|Documentation]]: Where you&#039;ll find quick links to different parts of the XMLDB documentation.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
=== XMLDB related ===&lt;br /&gt;
&lt;br /&gt;
* [[Development:XMLDB preliminary links|XMLDB preliminary links]] - A collection of links about general info, searched and analysed at the initial stages of the project&lt;br /&gt;
* [[Development:XMLDB preliminary notes|XMLDB preliminary notes]] - A collection of notes collected in the early stages of this project, pointing both to some changes required and some problems to solve.&lt;br /&gt;
&lt;br /&gt;
=== Database related ===&lt;br /&gt;
&lt;br /&gt;
* [[Development:DDL functions|DDL functions]] - Documentation for all the Data Definition Language (DDL) functions available inside Moodle.&lt;br /&gt;
* [[Development:DML functions|DML functions]] - Documentation for all the Data Manipulation Language (DML) functions available inside Moodle.&lt;br /&gt;
&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
&lt;br /&gt;
[[zh:开发:XML数据库计划]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:XMLDB_introduction&amp;diff=74249</id>
		<title>Development:XMLDB introduction</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:XMLDB_introduction&amp;diff=74249"/>
		<updated>2010-07-28T12:32:20Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: Spelling mistake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Development:XMLDB Documentation|XMLDB Documentation]] &amp;gt; Introduction&lt;br /&gt;
----&lt;br /&gt;
__NOTOC__&lt;br /&gt;
One of the main upcoming features in Moodle 1.7 will be its ability to work with some more [[wikipedia:RDBMS|RDBMS]] ([[wikipedia:MSSQL|MSSQL]] and [[wikipedia:Oracle database|Oracle]]) while maintaining everything working properly with both [[MySQL]] and [[PostgreSQL]]. As Moodle core uses [http://adodb.sourceforge.net/ ADOdb] internally, this possibility has been present since the beginning and, with the current maturity of the project (5 year old baby!), this can be a good moment to sort all this out.&lt;br /&gt;
&lt;br /&gt;
Initially, all our tests and preliminary work was to inspect how [http://adodb.sourceforge.net/ ADOdb] was doing its work, and how we could mix together all those 4 RDBMS, whose SQL dialects, although pretty similar, have some differences and idiosyncrasies that force us to do some important changes to our current database code (formerly &#039;&#039;&#039;datalib.php&#039;&#039;&#039;) and how it&#039;s used by the rest of Moodle.&lt;br /&gt;
&lt;br /&gt;
All the changes to be performed, which primary objective is to enable Moodle to work with more RDBMS, must be fulfilled by following these non-functional requirements: &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Provide one layer (new) for DB creation/upgrade&#039;&#039;&#039; ([[wikipedia:Data_Definition_Language|DDL]]): With this, developers will create their structures in one neutral form, independent of the exact implementation to be used by each RDBMS.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Provide one layer (existing) for DB handling&#039;&#039;&#039; ([[wikipedia:Data_Manipulation_Language|DML]]): With this, developers will request/store information also in one neutral form, independent of the RDBMS being used.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Easy migration path from previous versions&#039;&#039;&#039;: The current installation/upgrade system will work until, at least, Moodle 2.0, allowing 3rd party developers to migrate to the new system.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Simple, usable and effective&#039;&#039;&#039;: Until now, the way to upgrade Moodle has been really cool and it has worked pretty fine since the beginning. However, it has forced developers to maintain at least two installation and two upgrade scripts for each module/plugin. The new alternative will have only one file to install and one file to upgrade (per module/plugin too), reducing the possibility of mistakes drastically.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Conditional code usage must be minimised&#039;&#039;&#039;: Database libraries must accept 99% of potential SQL sentences, building/transforming them as necessary to work properly under any RDBMS. The number of places using custom (per DB) code should be minimum.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Well documented&#039;&#039;&#039;: All the functions defined, both at DML and DDL level must be well documented, helping the developer to find and use the correct one in each situation.&lt;br /&gt;
&lt;br /&gt;
== The Stack ==&lt;br /&gt;
&lt;br /&gt;
The next stack shows how Moodle 1.7 code will interact with the underlying RDBMS. It will help us understand a bit more what we are trying to do and will explain some of the points related in the Roadmap (below in this page).&lt;br /&gt;
&lt;br /&gt;
[[Image:MoodleDBStack.png|center]]&lt;br /&gt;
&lt;br /&gt;
Moodle code will use two &#039;&#039;languages&#039;&#039; to perform its DB actions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;XMLDB neutral description files&#039;&#039;&#039;: To create, modify and delete database objects (DDL: create/alter/drop tables, fields, indexes, constraints...). It consists of a collection of validated, standard, XML files. They will be used to define all the DB objects. New for 1.7.&lt;br /&gt;
* &#039;&#039;&#039;Moodle SQL neutral statements&#039;&#039;&#039;: To add, modify, delete and select database information (DML: insert/update/delete/select records). To modify for 1.7.&lt;br /&gt;
&lt;br /&gt;
Please note the &#039;&#039;&#039;neutral&#039;&#039;&#039; keyword used in the expressions above. It means that both &#039;&#039;&#039;languages&#039;&#039;&#039; will be 100% the same, independent of the underlying RDBMS being used. And this must be particularly true for the XMLDB part.&lt;br /&gt;
&lt;br /&gt;
Obviously it&#039;s possible that in the SQL part we found some specialised queries (using complex joins, regular expressions...) that will force us to do some &#039;&#039;&#039;Exceptions&#039;&#039;&#039;. Well, they can exist (in fact, they exist), but we always must try to provide an alternate path to minimise them using neutral statements and standard libraries.&lt;br /&gt;
&lt;br /&gt;
Each one of the &#039;&#039;&#039;languages&#039;&#039;&#039; above will use its own library to do the work:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Moodle DDL Library&#039;&#039;&#039; ([[Development:DDL functions|ddllib.php]]): Where all the functions needed to handle DB objects will exist. This library is new for 1.7 and will provide developers with a high level of abstraction. As input it will accept some well defined objects and actions and it will execute the proper commands for the RDBMS being used.&lt;br /&gt;
* &#039;&#039;&#039;Moodle DML Library&#039;&#039;&#039; ([[Development:DML functions|dmllib.php]]): Where all the functions needed to handle DB contents will exist. This library is new for 1.7, although its contents are, basically, functions currently present in &#039;&#039;&#039;datalib.php&#039;&#039;&#039; (moved from there). All those DML functions will offer cross-db support for insert/update/delete/select statements using a common behaviour.&lt;br /&gt;
&lt;br /&gt;
Also note that &#039;&#039;&#039;datalib.php&#039;&#039;&#039; is still present in the schema above. It will contain all the functions that haven&#039;t been moved to the new &#039;&#039;&#039;ddllib.php&#039;&#039;&#039; and &#039;&#039;&#039;dmllib.php&#039;&#039;&#039; libraries. Only some common functions will remain there, and these will disappear (it&#039;s considered a legacy library) in upcoming &#039;&#039;&#039;Moodle&#039;&#039;&#039; releases (after 1.7) by moving all those functions to their proper library (course/lib.php, user/lib.php....). &lt;br /&gt;
&lt;br /&gt;
Both of these libraries (plus the small &#039;&#039;&#039;Exceptions&#039;&#039;&#039; bar) will perform all their actions using the &#039;&#039;&#039;ADOdb Database Abstraction Library for PHP&#039;&#039;&#039; that will receive all the requests from them, communicate with the DB (&#039;&#039;&#039;MySQL&#039;&#039;&#039;, &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;, &#039;&#039;&#039;Oracle&#039;&#039;&#039; or &#039;&#039;&#039;SQL*Server&#039;&#039;&#039;), retrieve results and forward them back to originator library.&lt;br /&gt;
&lt;br /&gt;
== The process ==&lt;br /&gt;
&lt;br /&gt;
This section points to the main areas of information about the &#039;&#039;&#039;process of design and implementation&#039;&#039;&#039; of the new XMLDB layer:&lt;br /&gt;
&lt;br /&gt;
* [[XMLDB Roadmap|Roadmap]]: Where the whole process is defined. It has been split into small chunks to be performed and tested easily. Also, such documents should be used to track what&#039;s done and what&#039;s pending, while using easy nomenclature.&lt;br /&gt;
&lt;br /&gt;
* [[XMLDB Problems|Problems]]: A comprehensive list of issues that need to be determined/solved prior to incorporating them into the [[XMLDB Roadmap|roadmap]].&lt;br /&gt;
&lt;br /&gt;
== The documentation ==&lt;br /&gt;
&lt;br /&gt;
This section points to the &#039;&#039;&#039;main documentation index&#039;&#039;&#039; about the implemented XMLDB:&lt;br /&gt;
&lt;br /&gt;
* [[Development:XMLDB Documentation|Documentation]]: Where you&#039;ll find quick links to different parts of the XMLDB documentation.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
=== XMLDB related ===&lt;br /&gt;
&lt;br /&gt;
* [[Development:XMLDB preliminary links|XMLDB preliminary links]] - A collection of links about general info, searched and analysed at the initial stages of the project&lt;br /&gt;
* [[Development:XMLDB preliminary notes|XMLDB preliminary notes]] - A collection of notes collected in the early stages of this project, pointing both to some changes required and some problems to solve.&lt;br /&gt;
&lt;br /&gt;
=== Database related ===&lt;br /&gt;
&lt;br /&gt;
* [[Development:DDL functions|DDL functions]] - Documentation for all the Data Definition Language (DDL) functions available inside Moodle.&lt;br /&gt;
* [[Development:DML functions|DML functions]] - Documentation for all the Data Manipulation Language (DML) functions available inside Moodle.&lt;br /&gt;
&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
&lt;br /&gt;
[[zh:开发:XML数据库计划]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Pedagogy&amp;diff=71988</id>
		<title>Pedagogy</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Pedagogy&amp;diff=71988"/>
		<updated>2010-05-10T19:30:19Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: spelling mistake (I think it was) /* Social Constructionism as a Referent */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Let&#039;s sit back and really reflect on the pedagogy that is at the core of what we, as online educators, are trying to do.&lt;br /&gt;
&lt;br /&gt;
==Definition of Pedagogy==&lt;br /&gt;
One definition of [http://en.wiktionary.org/wiki/Pedagogy pedagogy] in Wiktionary says&lt;br /&gt;
#The profession of teaching&lt;br /&gt;
#The activities of educating, teaching or instructing&lt;br /&gt;
&lt;br /&gt;
Wikipedia has a much longer page on [http://en.wikipedia.org/wiki/Pedagogy Pedagogy].  At one point it said Pedagogy is the art or science of being a teacher, generally refers to strategies of instruction, or a style of instruction. The word comes from the Ancient Greek παιδαγωγέω (paidagōgeō; from παῖς (child) and ἄγω (lead)): literally, &amp;quot;to lead the child”.&lt;br /&gt;
&lt;br /&gt;
==Moodle in three short paragraphs==&lt;br /&gt;
&lt;br /&gt;
The heart of Moodle is courses that contain activities and resources. There are about 20 different types of activities available (forums, glossaries, wikis, assignments, quizzes, choices (polls), scorm players, databases etc) and each can be customised quite a lot. The main power of this activity-based model comes in combining the activities into sequences and groups, which can help you guide participants through learning paths. Thus, each activity can build on the outcomes of previous ones.&lt;br /&gt;
&lt;br /&gt;
There are a number of other tools that make it easier to build communities of learners, including blogs, messaging, participant lists etc, as well useful tools like grading, reports, integration with other systems and so on.&lt;br /&gt;
&lt;br /&gt;
For more about Moodle, see http://moodle.org, and particularly the main community “course” called [http://moodle.org/course/view.php?id=5 Using Moodle]. It&#039;s crowded and busy these days, but jump in and you&#039;ll soon find interesting stuff I&#039;m sure. The developers and the users are deliberately forced to mix in the same forums. The other great place to start is our [https://docs.moodle.org/ online documentation] which is a community-developed wiki site.&lt;br /&gt;
&lt;br /&gt;
==Social Constructionism as a Referent==&lt;br /&gt;
&lt;br /&gt;
I have these five points on a slide which I use in every presentation I do. They are useful referents taken from research that apply to education in general, boiled down into a simple list that I carry around under the moniker of &amp;quot;social constructionism&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;All of us are potential teachers as well as learners - in a true collaborative environment we are both&#039;&#039;&#039;.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; It&#039;s so important to recognise and remember this.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; I think this perspective helps us retain some humility as teachers and fight the (very natural!) tendency to consolidate all your history and assume the revered position of “wise source of knowledge”.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; It helps us keep our eyes open for opportunities to allow the other participants in our learning situation to share their ideas with us and to remind us to listen carefully and ask good questions that elicit more from others.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; I find I need to constantly remind myself of this point, especially when the culture of a situation pushes me into a central role (like now!)&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;We learn particularly well from the act of creating or expressing something for others to see.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; For most of us this is basically “learning by doing”, and is fairly obvious, yet it&#039;s worth reminding ourselves of it. &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; It&#039;s surprising how much online learning is still just presenting static information, giving students little opportunity to practice the activities they are learning about. I often see online teachers spending a great deal of time constructing perfect resources for their course, which no doubt is a terrific learning experience for them, but then they deny their students that same learning experience. Even textbooks often do a better job, with exercises after every chapter and so on.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Most importantly, such learning is best when you are expressing and presenting posts, projects, assignments, constructions etc &#039;&#039;&#039;for others to see&#039;&#039;&#039;. In this situation your personal “stakes” are a lot higher, and a lot of self-checking and reflection takes place that increases learning. Seymour Papert (the inventor of logo) famously described the process of constructing something for others to see as a very powerful learning experience, and really this sort of thinking goes right back to Socrates and beyond.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;We learn a lot by just observing the activity of our peers&#039;&#039;&#039;.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Basically this is about “classroom culture”, or learning by osmosis. Humans are good at watching each other and learning what to do in a given situation through cues from others. &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; For example, if you walk into a lecture theatre where everyone is sitting in seats, facing the front, listening quietly to the teacher at the front and taking notes, then that&#039;s most likely what you are going to do too, right?&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; If you are in a less rigid class where people are asking questions all the time, then it&#039;s likely you&#039;ll feel freer to do so too. By doing so you&#039;ll be learning about both the subject itself and the meta-subject of how learning occurs from overhearing the discussions of your peers and the kinds of questions that get asked, leading to a richer multi-dimensional immersion in learning.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;By understanding the contexts of others, we can teach in a more transformational way (constructivism)&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; As you probably know from experience, advice from a mentor or friend can provide better, more timely and customised learning experience than with someone who doesn&#039;t know you and is speaking to a hundred people.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; If we understand the background of the people we are speaking to then we can customise our language and our expression of concepts in ways that are best suited to the audience. You can choose metaphors that you know the audience will relate to. You can use jargon where it helps or avoid jargon when it gets in the way.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Again this is a pretty basic idea - every guide to public speaking talks about knowing your audience - but in online learning we need to be particular mindful of this because we often have not met these people in person and don&#039;t have access to many visual and auditory cues.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;A learning environment needs to be flexible and adaptable, so that it can quickly respond to the needs of the participants within it&#039;&#039;&#039;.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Combining all the above, if you as a learning facilitator want to take advantage of your growing knowledge about your participants, giving them tailored opportunities to share ideas, ask questions and express their knowledge, then you need an environment which is flexible, both in time and space.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; If you discover that you need to throw your schedule out the window because your participants know a lot less than you&#039;d expected when you first designed the course, you should be able to readjust the schedule, and easily add new activities to help everyone (or just one group) catch up. Likewise, some great ideas for a simulation or something may have come up during discussions, so you should be able to add those later in the course.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Timewise, your participants may be spread over different timezones, or maybe they live in the same timezone but have differing free time, so you should be able to offer asynchronous activities where people can work together but at different times.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Jason Cole from Open University recently referred to these as “Martin&#039;s five laws” (ha!) but really they are referents: guiding concepts that I personally find useful to refer to whenever I need to make a decision in any given educational situation. In particular I find them useful for building &#039;&#039;&#039;communities of learners&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
I guess you probably find a lot of this familiar, even if you use different terms. If not there is a lot of research about constructionism, constructivism and social Constructionism which you can find out more about in some of [http://dougiamas.com/writing/ my more formal papers].&lt;br /&gt;
&lt;br /&gt;
==How Moodle tries to support a Social Constructionist view==&lt;br /&gt;
&lt;br /&gt;
I&#039;m going to go through the earlier list again, this time pointing out existing features in Moodle. Pedagogy and software design are closely intertwined in online learning - the &amp;quot;shape&amp;quot; of the software can help or hinder the teacher in what they are trying to do.&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;All of us are potential teachers as well as learners - in a true collaborative environment we are both&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Many of the activities in Moodle are designed to allow students to control common content, such as forums, wikis, glossaries, databases, messaging and so on. This encourages students to add to the total course experience for others.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; In Moodle 1.7 we&#039;ve made a huge step of a whole new Roles implementation which further breaks down the distinction of teachers and students, allowing Moodle system administrators and teachers to create new roles with any mix of capabilities they like. If you want students to be allowed to facilitate forums, create quiz questions or even control the course layout then you can. There is a very fine degree of control – for example you can allow students the ability to delete posts in just one single forum if you like.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; I hope that people will take these new features and experiment with control in their courses, allowing students more flexibility to do things that were previously thought of as something teachers should do.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;We learn particularly well from the act of creating or expressing something for others to see&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Moodle has a wide range of ways in which people can create representations of their knowledge and share them.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
#* The course structure itself is terrific way to construct a shared and active representation of the learning journey that everyone is going through.&lt;br /&gt;
#* Forums of course are the core of this, providing spaces for discussion and sharing of media and documents (using the media plugin filters, attachments or simply links).&lt;br /&gt;
#* Wikis are collaboratively-built pages useful for group work and other negotiations.&lt;br /&gt;
#* Glossaries are collaboratively-built lists of definitions that can then appear throughout the course.&lt;br /&gt;
#* Databases are an extension of this idea allowing participants to enter structured media of any type (for example a collection of digital photos or a library of references). &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;We learn a lot by just observing the activity of our peers&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; The participants page is the main place where you can see everyone in your course. It shows a lot of information about your participants and how recently they&#039;ve been there.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; An Online Users block is the best way to see everyone else who might be on right now.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; The Recent Activity block shows a great deal of information about what has happened recently, and via link you can see reports with more detail. Things that happened not only include changes to the course and forum posts, etc, but also things like assignment submissions and quiz attempts. Students can&#039;t see the results that other students got from these activities, but they do get some sense that everyone is submitting Assignment 1 now and this peer pressure hopefully helps those who need it.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; Finally, almost all the modules will &amp;quot;tag&amp;quot; an entry or change with the name of the user, so that you can see who did what and when. For example, wiki pages all have a history link with full details on every edit.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;By understanding the contexts of others, we can teach in a more transformational way (constructivism)&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt; There are many different ways to find out about people. Access to these can be decided on a site basis (different sites have different privacy policies): &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
#* The user profile contains several fields where people can provide information about their background, etc. In particular there is a user profile photograph, which appears throughout Moodle whenever that person writes something. The photo links back to the profile page.&lt;br /&gt;
#* A compendium of forum posts (and discussion starters) by that person in that course (or across the site).&lt;br /&gt;
#* Individual blogs allow people to express things in a public but reflective way, often providing access to thinking that might not normally expressed in, say, a forum.&lt;br /&gt;
#* Overall activity reports show all the contributions from a user in a course, including assignment submissions, glossary entries, etc.&lt;br /&gt;
#* User log reports show detailed logs of every action taken by a person in Moodle, as well as graphs showing overall activity statistics.&lt;br /&gt;
#* The survey module provides a variety of proven questionnaire instruments for discovering interesting information about the state of mind of the group.&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
# &#039;&#039;&#039;A learning environment needs to be flexible and adaptable, so that it can quickly respond to the needs of the participants within it&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
#* The course page itself is the main tool for a teacher, allowing them to add/remove and structure activities as necessary. Changing the course is one button click away at any time, so the teacher can change it on a whim. In Moodle 1.7 we have now added AJAX features, so that activities, sections and blocks can all be simply dragged-and-dropped.&lt;br /&gt;
#* The roles in Moodle 1.7 can be applied individually in every context across the site, and can be further tweaked with overrides. So if you want to create one single quiz where everyone has access to everybody&#039;s results, or allow parents of students to see parts of your course, then you can.&lt;br /&gt;
#* Navigation around the course and site is automatically generated.&lt;br /&gt;
#* The gradebook is automatically maintained, and reflects the activities in the course at any given time.&lt;br /&gt;
#* There are preferences for many aspects of appearance and behaviour, at site, course and activity levels, allowing educators to fine-tune the behaviour of Moodle in many ways.&lt;br /&gt;
#* External systems can be integrated easily, to maintain authentication, enrolments and other things, allowing Moodle to react smoothly as data in other systems is modified. &amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Finding a balance==&lt;br /&gt;
&lt;br /&gt;
Before I talk about about where we are going, let me talk a little about the balance that a Course Management System (aka VLE) like Moodle needs to achieve. One thing I found out quickly in a community like ours is that people have a wide range of expectations of online learning.&lt;br /&gt;
&lt;br /&gt;
At the fascist extreme there are those who want students to be highly controlled: reading resources that are revealed at set times and later sitting quizzes to prove they read those resources. I call this the rat-in-the-maze approach, or dump-and-pump.&lt;br /&gt;
&lt;br /&gt;
At the techno-hippy end of that spectrum there are those who want to devolve management completely, with every user running their own portfolio site, streaming blogs and files to each other using RSS and trackbacks. It&#039;s an interesting dream that really opens up thinking about education but I think the problems to be solved are many (such as security, accountability, the structure of institutions etc).&lt;br /&gt;
&lt;br /&gt;
The vast majority of people that I meet fall somewhere between these two extremes. Many of them are new to online learning, and are looking for the next step beyond what they were being paid to do offline, while being accepting of gentle guidance to improving their online techniques. These people are on a steep learning curve already without facing the aggregation of 100 different blogs.&lt;br /&gt;
&lt;br /&gt;
==Progression==&lt;br /&gt;
&lt;br /&gt;
Moodle needs to be flexible to cater for a wide variety of needs while remaining simple enough for ordinary teachers to start making good use of the power of the internet for community building and collaborative learning. My hope is that Moodle can be seen as a toolbox where they can start simply and naturally, and then progress to more and more advanced community facilitation over time.  Ultimately, we&#039;d like to see teachers being involved with and supported by a community of their peers.&lt;br /&gt;
&lt;br /&gt;
Let&#039;s look at a typical progression that a teacher might go through as they learn to use the Moodle tools:&lt;br /&gt;
&lt;br /&gt;
# Putting up the handouts (Resources, SCORM)&lt;br /&gt;
# Having a passive forum &lt;br /&gt;
# Using Quizzes and Assignments (less management)&lt;br /&gt;
# Using the Wiki, Glossary and Database tools (interactive content)&lt;br /&gt;
# Using the Forum seriously and actively&lt;br /&gt;
# Combining activities into sequences, where results feed later activities&lt;br /&gt;
# Think deeper about each activity, advanced features, unusual applications&lt;br /&gt;
# Using the Survey module to study and reflect on course activity&lt;br /&gt;
# Using peer-review modules like Workshop &lt;br /&gt;
# Conducting active research on oneself, sharing ideas in a community of peers&lt;br /&gt;
&lt;br /&gt;
==Where Moodle can do better and what we&#039;re doing about it==&lt;br /&gt;
&lt;br /&gt;
Keeping in mind the theme of this paper and the conference stream, here are a few of the upcoming plans for things that are more related to pedagogy:&lt;br /&gt;
&lt;br /&gt;
===Repositories and Portfolios===&lt;br /&gt;
&lt;br /&gt;
Currently only teachers can upload and manage &#039;&#039;&#039;collections&#039;&#039;&#039; of files into Moodle, using the Files tool in each course. There is no easy way to share files between courses, and no way for ordinary users to keep a portfolio, say.&lt;br /&gt;
&lt;br /&gt;
This is changing in Moodle 2.0 with the addition of a [[Development:Repository API|Repository API]] (which allows any external repository to be used as a source of files and data) and a [[Development:Portfolio API|Portfolio API]] (which will allow all users to capture things in Moodle and store them in any external repository of their choice). &lt;br /&gt;
&lt;br /&gt;
Special-purpose repositories are a growing area, and it means institutions can keep their valuable data where they want to, even if they switch front-end systems like VLEs.&lt;br /&gt;
&lt;br /&gt;
Most importantly, this will allow the development of e-Portfolios to explode, and these are something I think a lot of us really want to see as a very positive pedagogical enhancement.&lt;br /&gt;
&lt;br /&gt;
===Community Hubs===&lt;br /&gt;
&lt;br /&gt;
We want to improve the way teachers and users of Moodle communicate with each other, not only about e-learning and Moodle, but also in their subject areas. For example, imagine a Biology 101 teacher finding a &amp;quot;community&amp;quot; button in their course, taking them straight to a place where their peers are all discussing best practice for teaching Biology 101, sharing and browsing repositories of course materials and learning designs.&lt;br /&gt;
&lt;br /&gt;
A major focus for Moodle 2.0 is the creation of networking between Moodles, allowing anyone to turn their Moodle site into a Moodle Community Hub. Login between Moodles will be transparent but secure and fully controlled by site administrators. The peer-to-peer nature of the design will allow all sorts of interesting scenarios to develop.&lt;br /&gt;
&lt;br /&gt;
===Better interaction between tools===&lt;br /&gt;
&lt;br /&gt;
Currently Moodle already sends an email as notification of a lot of different types of events, but it can be difficult to manage. By piping all the messaging from throughout the system via the Messaging module that we already have, users will have a much finer control over exactly what sorts of messages they want to see. We can also allow email to come back into Moodle.&lt;br /&gt;
&lt;br /&gt;
Similarly, we&#039;ll be integrating the existing blogging much more tightly with the whole system, by adding &amp;quot;blog this&amp;quot; buttons everywhere that allow users to capture and comment on items of interest.&lt;br /&gt;
&lt;br /&gt;
===Metadata and outcome statements===&lt;br /&gt;
&lt;br /&gt;
Currently Moodle courses need to be manually connected to state learning standards. In many places of the world such reporting is mandatory, so it can take a lot of time.&lt;br /&gt;
&lt;br /&gt;
Moodle 1.9 introduced a mechanism so that:&lt;br /&gt;
&lt;br /&gt;
# admins can import a long list of outcome statements (as tags)&lt;br /&gt;
# teachers can relate a subset of these to their course&lt;br /&gt;
# teachers can connect each activity to an even smaller subset&lt;br /&gt;
&lt;br /&gt;
This helps course design by providing teachers with a tool to ensure the requirements for the course are being met, while also providing much better reporting for admins and students on what has been achieved.&lt;br /&gt;
&lt;br /&gt;
Moodle 2.0 will build on this with [[Development:Progress_tracking|Progress Tracking]] which allows these things to be guided by individual learning plans for each student.&lt;br /&gt;
&lt;br /&gt;
===Role-playing and scenario simulations===&lt;br /&gt;
&lt;br /&gt;
A popular and effective technique in face-to-face teaching is that of role-playing in scenarios, and this can be difficult to do online. You could imagine an Environmental Science course running a role-playing simulation where some students play the government, some as Greenpeace, some as industry for a particular scenario.&lt;br /&gt;
&lt;br /&gt;
The plans for this have been around for a long time, but I hope it can be developed soon. It would be a module where people can be assigned roles within a simulated situation and appear to others anonymously in those roles, interacting in forums, wikis, and all the other tools in Moodle according to the rules of the simulation.&lt;br /&gt;
&lt;br /&gt;
==What else would you like to see?==&lt;br /&gt;
&lt;br /&gt;
I hope this has stimulated some thoughts about the sorts of things you would like to see in your ideal online learning environment. If so, please join in with the discussions on http://moodle.org and let&#039;s brainstorm them a bit. I hope we can come up with some new ideas to put in the [http://tracker.moodle.org Moodle Tracker], or at least some support or modifications for old ones.&lt;br /&gt;
&lt;br /&gt;
[[Category:Pedagogy]]&lt;br /&gt;
[[fr:Pédagogie]][[es:Pedagogia]][[ru:Педагогика]]&lt;br /&gt;
[[de:Pädagogik]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Course_settings&amp;diff=71275</id>
		<title>Course settings</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Course_settings&amp;diff=71275"/>
		<updated>2010-04-21T09:16:57Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: spelling mistake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Course admin}}&lt;br /&gt;
&lt;br /&gt;
[[Image:Settings.gif]]&#039;&#039;&#039;Course settings&#039;&#039;&#039; control how the things appear to the participants in a course. It is the first page viewed after creating a course. It can be edited through the &#039;&#039;&#039;Settings&#039;&#039;&#039; link in the [[Course administration block]] menu.  This page has links to other pages that may describe a setting in more detail. Different versions of Moodle may not have all the settings listed below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==General==&lt;br /&gt;
[[Image:generalsettings1.gif|thumb|General settings]]&lt;br /&gt;
===Category===&lt;br /&gt;
&lt;br /&gt;
The site administrator may have created course categories to help teachers and students find their courses easily.&lt;br /&gt;
&lt;br /&gt;
The capability [[Capabilities/moodle/course:changecategory|moodle/course:changecategory]] controls whether a user can edit the course category.&lt;br /&gt;
&lt;br /&gt;
===Short name===&lt;br /&gt;
Many institutions have a shorthand way of referring to a course, such as BP102 or COMMS.  Even if you do not already have such a name for your course, make one up here.  It will be used in several places where the long name is not appropriate.  The most common use is in the navigation bar that is at the top of most pages and this provides an active link to the course home page.&lt;br /&gt;
&lt;br /&gt;
[[Image:Assignment nav trail.jpg|Point to Assignment, part of the Features course, in a site called Moodle]]&lt;br /&gt;
&lt;br /&gt;
The above example has the short course name, &amp;quot;Features&amp;quot;, in the navigation links (breadcrumb). The short name also appears in the subject line of email messages that are part of the course.&lt;br /&gt;
&lt;br /&gt;
The capability [[Capabilities/moodle/course:changeshortname|moodle/course:changeshortname]] controls whether a user can edit the short name field.&lt;br /&gt;
&lt;br /&gt;
===ID number===&lt;br /&gt;
The ID number is an alphanumeric field.  It has several potential uses.  Generally, it is not displayed to students.  However, it can be used to match this course against an external system&#039;s ID, as your course catalog ID or can be used in the certificate module as a printed field.&lt;br /&gt;
&lt;br /&gt;
The capability [[Capabilities/moodle/course:changeidnumber|moodle/course:changeidnumber]] controls whether a user can edit the ID number.&lt;br /&gt;
&lt;br /&gt;
===Summary===&lt;br /&gt;
&lt;br /&gt;
The summary appears on the course listings page.&lt;br /&gt;
&lt;br /&gt;
The capability [[Capabilities/moodle/course:changesummary|moodle/course:changesummary]] controls whether a user can edit the course summary.&lt;br /&gt;
&lt;br /&gt;
===Format===&lt;br /&gt;
[[Image:generalsettings3.gif|thumb|Format section in course settings]]&lt;br /&gt;
See [[Course formats]]&lt;br /&gt;
&lt;br /&gt;
===Number of weeks/topics===&lt;br /&gt;
This setting is only used by the &#039;weekly&#039; and &#039;topics&#039; course formats.  In the &#039;weekly&#039; format, it specifies the number of weeks that the course will run for, starting from the course starting date.  In the &#039;topics&#039; format, it specifies the number of topics in the course.  Both of these translate to the number of &amp;quot;boxes&amp;quot; down the middle of the course page.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
===Course start date===&lt;br /&gt;
This is where you specify the starting time of the course (in your own time zone). The first week will start on the date you set here when you use the &amp;quot;Weekly&amp;quot; course format.&lt;br /&gt;
&lt;br /&gt;
This setting will not affect courses using the &#039;social&#039; or &#039;topics&#039; formats.&lt;br /&gt;
&lt;br /&gt;
However, this setting will have an effect on the display of logs, which use this date as the earliest possible date you can display. It can also make your course not visible to students even if when the course is available to students (see below).  &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; If your institution runs on a weekly schedule, you may want to consider setting the start date for courses on the first day of the week, like a Monday.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; In general, if your course does not have a real starting date then set the date to yesterday and use the availability setting to reveal the course to students.&lt;br /&gt;
&lt;br /&gt;
===Hidden sections===&lt;br /&gt;
This option allows you to decide how the hidden sections in your course are displayed to students.  By default, a small area is shown (in collapsed form, usually gray) to indicate where the hidden section is, though they still cannot actually see the hidden activities and texts.  This is particularly useful in the Weekly format, so that non-class weeks are clear, or if you have quizes you don&#039;t want your students to see.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; If you choose, these non-available items can be completely hidden, so that students do not even know  that sections or an activity in the course are hidden.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
===Show grades===&lt;br /&gt;
Many of the activities allow [[Grades|grades]] to be set.  By default, the results of all grades within the course can be seen in the Grades page, available from the main course page for students and teachers.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; If a teacher is not interested in using grades in a course, or just wants to hide grades from students, then they can disable the display of grades with this option.  This does not prevent the teacher using or setting grades for an individual activities, it just disables the results from being displayed to students.&lt;br /&gt;
&lt;br /&gt;
===Show activity reports===&lt;br /&gt;
[[Activity_report#Individual_Activity_Report|Activity reports]] are available to each student. These reports or logs show their activity and contributions in the current course.  These reports include their detailed access log.&lt;br /&gt;
&lt;br /&gt;
Student access to their own reports is controlled by the teacher via this course setting.  For some courses, these reports can be a useful tool for a student to reflect on their involvement and appearance within the online environment, but for some courses, this may not be necessary.&lt;br /&gt;
&lt;br /&gt;
Teachers always have access to these reports.  Teachers can use the button or tab visible on each person’s profile page or use the [[Reports]] link in the course administration block.&lt;br /&gt;
&lt;br /&gt;
Your site administrator may ask you to turn this feature off.  Showing activity reports can place a load on the server, slowing it down at times.  For large or long classes it may be more efficient to keep it off.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
===Maximum upload size===&lt;br /&gt;
[[Image:Changeupload.jpg|thumb|Maximum upload size setting]]&lt;br /&gt;
This setting defines the largest size of file that can be uploaded by students in this course.  The site administrator can determine [[Site_policies#Maximum_uploaded_file_sizefile |sizes available]] for the teacher to select.  Teachers should be aware of a course&#039;s [[Files|file structure]].&lt;br /&gt;
&lt;br /&gt;
It is possible to further restrict this size through settings within each activity module.&lt;br /&gt;
&lt;br /&gt;
===Force theme===&lt;br /&gt;
If the site administrator has allowed the teacher to set a course [[Themes|theme]], this pull down menu will appear with a list of themes on the site.&lt;br /&gt;
&lt;br /&gt;
===Is this a meta course?===&lt;br /&gt;
A [[Metacourses|metacourse]] only gets its enrollments from one or more other courses.  Many metacourses can get their enrollment from the same course.  A metacourse can get its enrollment information from many other courses. &lt;br /&gt;
&#039;&#039;TIP:&#039;&#039; Turning this on prematurely before the meta courses are properly setup will cause Moodle to return &#039;This course does not allow public access&#039; when users would ordinarily be able to access through internal enrollment. Verify that the linked course(s) exists.  Remember a meta course ONLY gets its enrollment from other courses.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
==Enrolments==&lt;br /&gt;
[[Image:generalsetting4.gif|thumb|Enrolment settings]]&lt;br /&gt;
===Enrolment plugins===&lt;br /&gt;
This setting allows you to choose an interactive [[Enrolment plugins|enrolment plugin]], such as [[Internal enrolment|internal enrolment]] or [[Paypal]]. If you use a non-interactive enrolment plugin, this setting has no effect.&lt;br /&gt;
&lt;br /&gt;
===Default role===&lt;br /&gt;
&lt;br /&gt;
From Moodle 1.7 onwards, a default course role, such as student, may be set.&lt;br /&gt;
&lt;br /&gt;
===Course enrollable===&lt;br /&gt;
This setting only affects interactive enrolment plugins, such as [[Internal enrolment|internal enrolment]] and [[Paypal]]. It has no affect at all on non-interactive plugins (e.g. External Database, LDAP). Setting it to &amp;quot;no&amp;quot; or if it is outside the specified date range will result in the student being told the course is &amp;quot;Not enrollable&amp;quot; and being returned to the front page, if they are attempting to enroll using an interactive plugin.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; If you are using Internal enrolment and you have not set an enrolment key, you should seriously consider setting this to &#039;&#039;No&#039;&#039; otherwise any user can enrol on your course.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
===Enrolment duration===&lt;br /&gt;
This setting specifies the number of days a student can be enrolled in this course (starting from the moment they enroll).  Set this value with care - setting it when not required is a common origin of the complaint,  &amp;quot;my students keep disappearing after n days&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; This is useful for rolling courses without a specific start or end time. Students are automatically unenrolled after the number of days has expired in this setting.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; This setting can be used as an alternative to a manually unenrolling students or using a clean-up function to remove defunct students at some future time.&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; If this course is a metacourse, the enrolment period will not be used.&lt;br /&gt;
&lt;br /&gt;
==Enrolment expiry notification==&lt;br /&gt;
[[Image:generalsettings5.gif|thumb|Enrolment expiry notification settings]]&lt;br /&gt;
These settings determine whether teachers and/or students are notified that their enrolment is about to expire and how much notice they should be given.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==Groups==&lt;br /&gt;
[[Image:generalsettings6.gif|thumb|Groups settings]]&lt;br /&gt;
===Group mode===&lt;br /&gt;
Here you can define the [[Groups|group mode]] at the course level by a pull down menu. &amp;quot;[[Groups#No_groups|No groups]]&amp;quot;, &amp;quot;[[Groups#Separate_groups|Separate groups]]&amp;quot; and &amp;quot;[[Groups#Visible_groups|Visible groups]]&amp;quot; are the choices. The selected setting will be the default group mode for all activities defined within that course.  The group setting can affect what users see in the [[Participants]] list. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; You may leave it set to &amp;quot;No groups&amp;quot; and still have specific activities use groups. In this case the force setting below should be set to &amp;quot;no&amp;quot;. For example, the teacher can use a group setting to completely separate cohorts of students such that each group is unaware of the other in the course.&lt;br /&gt;
&lt;br /&gt;
===Force===&lt;br /&gt;
If the group mode is &amp;quot;forced&amp;quot; at a course-level, then this particular group mode will be applied to every activity in that course. This will override any activities that may have a special group setting.  &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039;The force setting is useful when the teacher wants to set up a course and not have to change each activities group settings.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
===Default grouping===&lt;br /&gt;
&lt;br /&gt;
{{Moodle 1.9}}If [[Groupings|groupings]] are enabled (in Moodle 1.9 onwards), a default grouping for course activities and resources may be set.&lt;br /&gt;
&lt;br /&gt;
==Availability==&lt;br /&gt;
&lt;br /&gt;
[[Image:generalsettings7.gif|thumb|Availability settings]]&lt;br /&gt;
This option allows you to &amp;quot;hide&amp;quot; your course completely. It will not appear on any course listings, except to teachers of the course and administrators. Even if students try to access the course URL directly, they will not be allowed to enter.  &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; The [[Course_settings#Course_start_date|Start Date]] of the course can also effect course visibility. &lt;br /&gt;
 &lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
===Enrolment key===&lt;br /&gt;
A course [[Enrolment key|enrolment key]] enables access to courses to be restricted to those who know the key. This feature is typically used on sites which encourage self enrolments or use an external database process to register students in a course.  The idea is that Teachers or course administrators will supply the key to authorized people using another means like private email, snail mail, on the phone or even verbally in a face-to-face class.&lt;br /&gt;
&lt;br /&gt;
When the key is left blank and [[Course_settings#Course_enrollable|self enrolment]] is allowed, then anyone who has a Moodle username on the site will be able to enrol in the course.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; A student can be manually enroled in the course and will not have to supply the required key when they enter the course for the first time. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; If this password &amp;quot;gets out&amp;quot; and you have unwanted people enrolling, you can unenrol them (see their user profile page or unassign them from the [[Assign roles|student role]] in the course) and change this key. Any legitimate students who have already enrolled will not be affected, but the unwanted people will not be able to get back in.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; If you are using a non-interactive enrolment, system (e.g., External Database, LDAP) and you do not want students who fail the initial check to be asked for an enrolment key that they will not have, set &#039;&#039;Course Enrolable&#039;&#039; to &#039;&#039;No&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; You can control who is displayed as providing the Key when someone is requested to supply the key. See [[Internal enrolment]]&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
===Guest access===&lt;br /&gt;
&lt;br /&gt;
Allows any authenticated user (i.e. logged in) to access the course (as a [[Guest role|guest]]), including those who have logged in &amp;quot;as guest&amp;quot;. You can choose if they need an enrolment key or may enter without one. &lt;br /&gt;
&lt;br /&gt;
People can log in as guests using the &amp;quot;Login as a guest&amp;quot; button on a login screen, where that feature is enabled for the site. When the user tries to enter a course, they will see the [[Log in|login screen]]. If you only need people authenticated via your normal authentication method to access courses (as Guest or not) it is probably wise to disable &amp;quot;Login as a guest&amp;quot; for a slight improvement in site security. See [[Manage authentication]].&lt;br /&gt;
&lt;br /&gt;
Guests in a course ALWAYS have &amp;quot;read-only&amp;quot; access - meaning they cannot leave any posts or otherwise mess up the course for real students.  No use information is stored for a guest.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; This can be handy when you want to let a colleague in to look around at your work, or to let students see a course before they have decided to enroll.&lt;br /&gt;
:&#039;&#039;TIP:&#039;&#039; You have a choice between two types of guest access: with the enrolment key or without. If you choose to allow guests who have the key, then the guest will need to provide the current enrolment key EVERY TIME they log in (unlike students who only need to do it once). This lets you restrict your guests. If you choose to allow guests without a key, then anyone can get straight into your course.&lt;br /&gt;
&lt;br /&gt;
For more information see [[Guest role]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
===Cost===&lt;br /&gt;
&lt;br /&gt;
If [[Paypal]] or [[Authorize.net Payment Gateway]] is set as the [[Enrolment plugins|enrolment plugin]], then the course cost can be set in the cost field.&lt;br /&gt;
&lt;br /&gt;
==Language==&lt;br /&gt;
[[Image:generalsettings8.gif|thumb|Language settings]]&lt;br /&gt;
&lt;br /&gt;
If you force a language in a course, the interface of Moodle in this course will be in this particular language, even if a student has selected a different preferred language in his/her personal profile.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==Role renaming==&lt;br /&gt;
[[Image:rolesimages.gif|thumb|Role renaming settings]]&lt;br /&gt;
{{Moodle 1.9}}In Moodle 1.9 onwards, you can rename the [[Roles|roles]] used in your course. For example, you may wish to rename the [[Teacher role]] as &amp;quot;Facilitator&amp;quot;, &amp;quot;Tutor&amp;quot; or &amp;quot;Guide&amp;quot;. These new role names will appear within the course. For example on the [[Participants|participants]] and the override permissions pages. &lt;br /&gt;
&lt;br /&gt;
Please note that the site administrator or a [[Course managers|course manager]] may have changed the names or added new roles.  These names will appear and the teacher may rename them.&lt;br /&gt;
&lt;br /&gt;
[[Roles FAQ]] contains information on changing the name for teacher in Moodle 1.7 and 1.8. Prior to Moodle 1.7, the words for teacher and student may be changed in the course settings.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip&#039;&#039;: Do not worry about changing every role name. Only change the site roles which are  used in your course. For example, you may want to ignore renaming roles such as the [[Administrator role]] or the [[Authenticated user role]].&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip&#039;&#039;: To include new role names in a course backup, users should be included in the backup.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==Default course settings==&lt;br /&gt;
&lt;br /&gt;
An administrator can set course settings defaults in &#039;&#039;Administration &amp;gt; Courses &amp;gt; [[Course default settings]]&#039;&#039; in Moodle 1.9.5 onwards.&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[http://www.youtube.com/watch?v=zWOp1oq-TvI Video showing how to create a course in Moodle]&lt;br /&gt;
&lt;br /&gt;
[[Category:Course]]&lt;br /&gt;
&lt;br /&gt;
[[de:Kurseinstellungen]]&lt;br /&gt;
[[es:Administración del curso]]&lt;br /&gt;
[[eu:Ikastaroaren_ezarpenak]]&lt;br /&gt;
[[fr:Paramètres]]&lt;br /&gt;
[[ja:コース設定]]&lt;br /&gt;
[[ru:course/edit]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Installation_FAQ&amp;diff=68391</id>
		<title>Installation FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Installation_FAQ&amp;diff=68391"/>
		<updated>2010-02-09T18:16:07Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&lt;br /&gt;
== System information needed for Installation problems forum ==&lt;br /&gt;
When posting questions to the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum], try to provide as much background information as possible about your Moodle system. Use this template to copy and paste into your post:&lt;br /&gt;
* Server Operating System name (version also if possible): &lt;br /&gt;
* Browser name (version also if possible):&lt;br /&gt;
* Moodle version:&lt;br /&gt;
* Moodle install type? (New/Upgrade):&lt;br /&gt;
* Moodle config.php attached?(Y/N):&lt;br /&gt;
* Phpinfo attached? (Y/N):&lt;br /&gt;
&lt;br /&gt;
For the last two items, try to include the following in your post as an attachment:&lt;br /&gt;
* A copy of your phpinfo output as shown in your browser (see the instructions above for an explanation of how to obtain this, or see [[phpinfo]]).&lt;br /&gt;
* A copy of the Moodle configuration file (with secret info like database password deleted, of course). This is located in the main Moodle directory (by default called moodle), and is named config.php&lt;br /&gt;
&lt;br /&gt;
Copy and paste both of these into a single text file (using vi, Notepad, etc) and attach this to your post. If your PC is a Windows box and config.php looks messy (line breaks missing or in the wrong places) in Notepad, try Wordpad.&lt;br /&gt;
&lt;br /&gt;
If you cannot provide your phpinfo, try to copy &amp;amp; paste and complete these in your post:&lt;br /&gt;
* Webserver (e.g. Apache/IIS) version:&lt;br /&gt;
* Database server (e.g. MySQL, PostgreSQL) version:&lt;br /&gt;
* PHP version:&lt;br /&gt;
&lt;br /&gt;
For installation on web hosting accounts: contact your support desk who should be able to tell you this information.&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Security Warning&#039;&#039;&#039;: Make sure you edit any files and delete any passwords before posting onto the forum.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
==PHP - is it installed and what version do I have?==&lt;br /&gt;
&lt;br /&gt;
Make a new file on your web site called &#039;&#039;info.php&#039;&#039;, containing the following text, and call it from your browser:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?PHP phpinfo() ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If nothing happens then you don&#039;t have PHP installed or your webserver is not configured to handle .php files properly. See the installation docs for some information about where to download it for your computer. See the [[phpinfo]] page for details about the content of this page.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
==What &amp;amp; where are Moodle&#039;s configuration settings stored?==&lt;br /&gt;
Configuration settings are stored in the config.php file stored in your moodle folder. This file is created during the installation process. If there is a problem and the installation cannot create the file, you can try creating it manually from the [[Configuration file]] docs. Please remember that manually editing the file is not recommended and may lead to blank pages, especially if there are additional spaces and/or lines after the final php closing tag &amp;quot;?&amp;gt;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==Downloading previous releases of Moodle==&lt;br /&gt;
It is possible to download previous versions of Moodle that are not found on the  [http://download.moodle.org Standard Moodle Download page].  There are zip and tgz compressed located at &amp;lt;nowiki&amp;gt;http://download.moodle.org/stable[version_number]&amp;lt;/nowiki&amp;gt; (see links below). &lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;width:75%; height:75px&amp;quot; border=&amp;quot;0&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
| 2.0 Versions || [http://download.moodle.org/stable19 1.9 Versions]  || [http://download.moodle.org/stable18 1.8 Versions] &lt;br /&gt;
|- &lt;br /&gt;
|[http://download.moodle.org/stable17 1.7 Versions] || [http://download.moodle.org/stable16 1.6 Versions] || [http://download.moodle.org/stable15/ 1.5 Versions] &lt;br /&gt;
|-&lt;br /&gt;
| [http://download.moodle.org/stable14 1.4 Versions] || [http://download.moodle.org/stable13 1.3 Versions]  || &lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
You can download previous releases by using wget, lynx or curl with this URL:&lt;br /&gt;
&amp;lt;nowiki&amp;gt;http://download.moodle.org/stable[version_number]&amp;lt;/nowiki&amp;gt;. &lt;br /&gt;
:For example: to download Moodle version 1.5, use &amp;lt;nowiki&amp;gt;http://download.moodle.org/stable15&amp;lt;/nowiki&amp;gt;. You&#039;ll see a directory tree with the files displayed. Click on the one you want and download as normal - if you require the latest update of the version, scroll to the end of the list and download the &amp;quot;moodle-latest&amp;quot; file.&lt;br /&gt;
* &#039;&#039;&#039;Windows Packages&#039;&#039;&#039;: To download other releases not found in [http://download.moodle.org/windows/ Moodle packages for Windows], use this URL:&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;http://download.moodle.org/windows/MoodleWindowsInstaller-latest-[version_number].zip&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Mac Packages&#039;&#039;&#039;: To download other releases not found in [http://download.moodle.org/macosx/ Mac pacakges], use either of these URLs (depending on whether you need the Intel or PPC package):&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;http://download.moodle.org/macosx/Moodle4Mac-Intel-[version_number].dmg&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
:&amp;lt;nowiki&amp;gt;http://download.moodle.org/macosx/Moodle4Mac-PPC-[version_number}.dmg&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* &#039;&#039;&#039;Using CVS&#039;&#039;&#039;: You can also use CVS to download older releases and incremental releases of the Moodle generic packages, e.g. Moodle 1.5.4 - see the [[CVS_for_Administrators | CVS documentation]].&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
== How to enable and check PHP error logs==&lt;br /&gt;
PHP can be set up to log errors in a variety of different ways: two of these involve the use of the php.ini file and the ini_set command.  See [[PHP error logs]].&lt;br /&gt;
&lt;br /&gt;
==Email copies are not being sent from my forums==&lt;br /&gt;
&lt;br /&gt;
You &#039;&#039;must&#039;&#039; set up cron properly if you want Moodle to send out automatic email from forums, assignments etc. This same process also performs a number of clean-up tasks such as deleting old unconfirmed users, unenrolling old students and so on.&lt;br /&gt;
&lt;br /&gt;
Basically, you need to set up a process to regularly call the script &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://yoursite/admin/cron.php&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;. Please refer to the [[Cron|cron instructions]].&lt;br /&gt;
&lt;br /&gt;
Tips:&lt;br /&gt;
* Try the default settings in &#039;&#039;Administration &amp;gt; Server &amp;gt; Email&#039;&#039;. This generally works.&lt;br /&gt;
*Make sure that &#039;&#039;allowuseremailcharset&#039;&#039; in &#039;&#039;Administration &amp;gt; Server &amp;gt; Email&#039;&#039; is set to No. Setting this to Yes can cause a problem in some versions of Moodle.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==I can&#039;t log in - I just stay stuck on the login screen==&lt;br /&gt;
&lt;br /&gt;
This may also apply if you are seeing  “Your session has timed out. Please login again” and cannot log in.&lt;br /&gt;
&lt;br /&gt;
The following are possible causes and actions you can take (in no particular order):&lt;br /&gt;
&lt;br /&gt;
* Sessions may not be configured properly on the server. You can test this by calling the script &amp;lt;nowiki&amp;gt;http://yourserver/moodle/lib/session-test.php&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
* If your server is on shared hosting check that you have not reached your disk space quota. This will prevent new sessions being created and nobody will be able to log in. &lt;br /&gt;
* Carefully check the permissions in your &#039;moodledata&#039; area. The web server needs to be able to write to the &#039;sessions&#039; subdirectory.&lt;br /&gt;
* Your own computer (not your Moodle server) may have a firewall that is stripping referrer information from the browser. Here are some instructions for fixing [http://service1.symantec.com/SUPPORT/nip.nsf/46f26a2d6dafb0a788256bc7005c3fa3/b9b47ad7eddd343b88256c6b006a85a8?OpenDocument&amp;amp;src=bar_sch_nam Norton firewall products].&lt;br /&gt;
* Try deleting the &#039;&#039;sessions&#039;&#039; folder in your moodledata directory (anybody currently logged in will be thrown out)&lt;br /&gt;
* Try deleting cookies on your computer and/or try another browser or another client computer&lt;br /&gt;
* In Site Administration &amp;gt; Server &amp;gt; Session handling, try setting a value for &#039;Cookie prefix&#039;. You can also do this by setting &amp;lt;code&amp;gt;$CFG-&amp;gt;sessioncookie=&#039;something&#039;;&amp;lt;/code&amp;gt; in config.php. This is especially true if you are using multiple Moodles on the same browser. &lt;br /&gt;
* You are using the correct username and password, yes?&lt;br /&gt;
&lt;br /&gt;
If you are still having problems, read the [[Can_not_log_in | Cannot log in]] page.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
==I log in but the login link doesn&#039;t change. I am logged in and can navigate freely.==&lt;br /&gt;
&lt;br /&gt;
Make sure the URL in your &amp;lt;code&amp;gt;$CFG-&amp;gt;wwwroot&amp;lt;/code&amp;gt; setting is exactly the same as the one you are actually using to access the site.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==Uploaded files give &amp;quot;File not found&amp;quot;==&lt;br /&gt;
&lt;br /&gt;
For example: Not Found: The requested URL /moodle/file.php/2/myfile.jpg was not found on this server.&lt;br /&gt;
&lt;br /&gt;
Your web server needs to be configured to allow the part of the URL after a script name to be passed directly to the script. This is usually enabled in Apache 1, but is usually disabled by default in Apache 2. To turn it on, add this line to your &#039;&#039;httpd.conf&#039;&#039;, or to a &#039;&#039;.htaccess&#039;&#039; file in your local directory (see [[Installing Moodle]] for more details):&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;AcceptPathInfo&#039;&#039;&#039; on&lt;br /&gt;
&lt;br /&gt;
Note, this will ONLY work for Apache versions 2.x.&lt;br /&gt;
&lt;br /&gt;
For IIS you need to configure URL rewriting. This feature is not available from Microsoft, you need to install a 3rd party IIS extension - see http://msdn.microsoft.com/en-us/library/ms972974.aspx&lt;br /&gt;
The recommended rewriting rule is&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;RewriteRule&#039;&#039;&#039; ^([^\?]+?\.php)(\/.+)$ $1\?file=$2 [QSA]&lt;br /&gt;
&lt;br /&gt;
In theory you could try to use path info on IIS too, but it is not reliable, especially when using unicode file names.&lt;br /&gt;
&lt;br /&gt;
If you are unable to configure your server properly then you can switch Moodle to use an alternative method. The major disadvantages is that you will not be able to use SCORM packages at all and some Adobe Flash and Java applets will not work either.&lt;br /&gt;
&lt;br /&gt;
To use this alternative method, you should change the &#039;&#039;slasharguments&#039;&#039; variable. For moodle versions &amp;lt; 1.7, this is located in the Operating System section of &#039;&#039;Administration &amp;gt; Configuration &amp;gt; [[admin/config|Variables]]&#039;&#039;. In later versions, this option is located in &#039;&#039;Site Administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;. You should now be able to access your uploaded files.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==Why are all my pages blank?==&lt;br /&gt;
&lt;br /&gt;
Check the dirroot variable in &#039;&#039;config.php&#039;&#039;. You must use complete, absolute pathnames e.g. (for a Windows installation)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dirroot = &amp;quot;d:\inetpub\sites\www.yoursite.com\web\moodle&amp;quot;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Another reason might be that PHP has not been configured to support MySQL. This is common on RedHat and OpenBSD installations. In this case, an error is generated, but since error displays are often disabled by default, all that is seen on the browser is a blank screen. To enable PHP error displays see [[Installation_FAQ#How_to_enable_and_check_PHP_error_logs | How to enable and check PHP error logs]].&lt;br /&gt;
&lt;br /&gt;
To determine if MySQL support is your problem, insert this as the second line in your &#039;&#039;config.php&#039;&#039; file&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
phpinfo();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
then reload the web page. Examine the output closely to see if MySQL is supported. If not, look for a package you are missing.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
== Why is a particular page blank or incomplete? ==&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Check your web server log files!!&#039;&#039;&#039; &lt;br /&gt;
:If a particular page is blank or incomplete (it doesn&#039;t display the footer), before you do anything else switch on [[Debugging]] and  [[Installation_FAQ#How_to_enable_and_check_PHP_error_logs | check your PHP error logs]]. Having established that PHP error logging is working, reproduce the error. Immediately check the error log file right at the end. Hopefully you will see a PHP error message at or very near the end of the file. This may solve your problem directly or makes it a lot easier to diagnose the problem in the Moodle forums.&lt;br /&gt;
&lt;br /&gt;
*If you are &#039;&#039;&#039;upgrading to a new version of Moodle&#039;&#039;&#039;, check that you do not have an old version of a non-standard block or module installed. Remove any such blocks or modules installed using the admin settings page and start the install process again. However, do also make sure that you have included all optional plugins that were required by your courses. This is particularly common with &amp;quot;editing on&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
*If you &#039;&#039;&#039;do not see any blocks listed&#039;&#039;&#039;, turn editing on and remove any blocks that you have added to that page and try reloading.&lt;br /&gt;
&lt;br /&gt;
*You may get this error immediately after &#039;&#039;&#039;selecting a language&#039;&#039;&#039;. At this stage of the installation process your Moodle computer may need to connect to the Internet and download a language pack, so check that the computer can access the Internet by using a browser. Check also that your PHP settings are as given in the Moodle [[Installing_Moodle#Requirements | Moodle Requirements]] page.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See also&#039;&#039;&#039;:&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=97734 PHP configuration error] forum discussion&lt;br /&gt;
&lt;br /&gt;
==Installation hangs when setting-up database tables==&lt;br /&gt;
Sometimes the installation will hang when setting up tables, where only half the page displayed in the browser and/or other outputs are removed.  You may see truncated MySQL statements, or the “Scroll to continue” link is displayed but no “Continue” button is there. &lt;br /&gt;
&lt;br /&gt;
See [[Unexpected installation halts]] for more about solutions that involve:&lt;br /&gt;
*Checking for MySQL limits&lt;br /&gt;
*Checking the .htaccess files &lt;br /&gt;
*Code customizations issues&lt;br /&gt;
*Checking memory limit &lt;br /&gt;
*Upgrade incrementally&lt;br /&gt;
*Fix fopen function&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
==Why can&#039;t I upload a new image into my profile?==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t see anything on your user profile pages to let you upload user images then it&#039;s usually because GD is not enabled on your server. GD is a library that allows image processing.&lt;br /&gt;
&lt;br /&gt;
1. Make sure &#039;&#039;&#039;GD has been included in your PHP installation&#039;&#039;&#039;. You can check this by going to &#039;&#039;Site Administration &amp;gt; Server &amp;gt; [[PHP info]]&#039;&#039; and looking for the gdversion setting. This setting is chosen automatically every time you visit that page. If it shows GD version 1 or version 2 then everything should be fine. Save that configuration page and go back to your user profile.&lt;br /&gt;
&lt;br /&gt;
2. If Moodle thinks GD is not installed, then you will need to &#039;&#039;&#039;install the GD library&#039;&#039;&#039;. &lt;br /&gt;
*On Unix you may need to re-compile PHP with arguments something like this:&lt;br /&gt;
&lt;br /&gt;
 ./configure --with-apxs=/usr/local/apache/bin/apxs --with-xml --with-gd &lt;br /&gt;
 --with-jpeg-dir=/usr/local --with-png-dir=/usr --with-ttf --enable-gd-native-ttf &lt;br /&gt;
 --enable-magic-quotes --with-mysql --enable-sockets --enable-track-vars &lt;br /&gt;
 --enable-versioning --with-zlib&lt;br /&gt;
&lt;br /&gt;
* On Windows this is usually a matter of &amp;quot;turning on&amp;quot; the extension in PHP by editing your php.ini file. To do this remove the semicolon for the php_gd2.dll extension - check that this file is actually present in your php extensions  folder first (search your php.ini for extension_dir to determine where this points to on your hard disk). You should then have a line that looks like this:&lt;br /&gt;
 extension=php_gd2.dll&lt;br /&gt;
&lt;br /&gt;
:Windows users should see the [[Installing AMP|installation instructions]] for further help. &lt;br /&gt;
&lt;br /&gt;
3. Remember to &#039;&#039;&#039;restart your webserver&#039;&#039;&#039; (if possible) and re-visit the Moodle configuration page after making any changes to PHP so it can pick up the correct version of GD.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;See also&#039;&#039;&#039;: Using Moodle forum discussion [http://moodle.org/mod/forum/discuss.php?d=44271 Profile pictures] for additional information.&lt;br /&gt;
&lt;br /&gt;
== Why doesn&#039;t my Moodle site display the time and date correctly? ==&lt;br /&gt;
&lt;br /&gt;
Each language requires a specific language code (called a &#039;&#039;&#039;locale&#039;&#039;&#039; code) to allow dates to be displayed correctly. The language packs contain default standard codes, but sometimes these don&#039;t work on Windows servers.&lt;br /&gt;
&lt;br /&gt;
You can find the correct locale codes for Windows on these two pages: [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_language_strings.asp Language codes] and [http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_crt_country_strings.asp Country/region] codes (e.g. &amp;quot;esp_esp&amp;quot; for spanish)&lt;br /&gt;
&lt;br /&gt;
These new locale codes can be entered on the Administration &amp;gt;&amp;gt; Configuration &amp;gt;&amp;gt; [[admin/config|Variables]] page, where they override the ones in the currently chosen language pack.&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
== How do I uninstall Moodle?==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Webhost/manual installation&#039;&#039;&#039;: If you have installed Moodle manually or have installed onto a webhost, follow these steps:&lt;br /&gt;
*Delete the moodle database using this mysql command (or delete using your mysql client, e.g. PHPMyAdmin):&lt;br /&gt;
&amp;lt;pre&amp;gt;sql&amp;gt;DROP DATABASE moodle;&amp;lt;/pre&amp;gt;&lt;br /&gt;
:In the above example replace &#039;moodle&#039; with the name of the moodle database you created when installing.&lt;br /&gt;
*Delete the moodledata directory. If you, or your users, have uploaded materials into this directory take a copy of these before deleting this directory.&lt;br /&gt;
*Delete the moodle directory itself. This will delete all of the moodle PHP script files.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;XAMPP windows installation&#039;&#039;&#039;: If you have installed Moodle on windows through the XAMPP package, follow these steps:&lt;br /&gt;
*Open cmd.exe and navigate to this directory within your installation directory:&lt;br /&gt;
&amp;lt;pre&amp;gt;server/mysql/bin&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Run this command, replacing USERNAME with your database username (the default is &amp;quot;root&amp;quot;) and DATABASE with your database name (the default is &amp;quot;moodle&amp;quot;):&lt;br /&gt;
&amp;lt;pre&amp;gt;mysqladmin.exe -u USERNAME -p drop DATABASE&amp;lt;/pre&amp;gt;&lt;br /&gt;
*Enter your database password at the prompt (the default is &amp;quot;&amp;quot; [blank]).&lt;br /&gt;
*Enter &amp;quot;y&amp;quot; to confirm the database drop.&lt;br /&gt;
*Delete the moodledata directory. If you, or your users, have uploaded materials into this directory take a copy of these before deleting this directory.&lt;br /&gt;
*Delete the moodle directory itself. This will delete all of the moodle PHP script files.&lt;br /&gt;
&lt;br /&gt;
==How do I upgrade Moodle? Do I just overwrite the files?==&lt;br /&gt;
Do not overwrite files, it may cause strange errors. You should read the [[Upgrade]] documentation before proceeding.&lt;br /&gt;
&lt;br /&gt;
==I obtain the message &amp;quot;Upgrade already running in this session, please wait!&amp;quot;==&lt;br /&gt;
&lt;br /&gt;
Most likely you refreshed the page before the completion message. If you are absolutely sure that there are no upgrade processes active (php and/or mysql), you can click on &amp;quot;!!!&amp;quot; and restart the upgrade.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Note&#039;&#039;: If you click on &amp;quot;&#039;!!!&amp;quot; or try to restart the upgrade from another browser, there is a chance that your data in the database could be corrupted. If this happens, you will need to restore the database from sql dump and then restart the upgrade and wait - the process can take several hours on large sites.&lt;br /&gt;
&lt;br /&gt;
==Migrating Moodle to a new site or server==&lt;br /&gt;
Migrating Moodle means that you have to move the current installation to a new server, and so may have to change IP addresses or DNS entries. To do this you will need to change the $CFG-&amp;gt;wwwroot value in the config.php on the new server. You will also have to change any absolute links stored in the database backup file (before restoring the file on the new server) either using the admin/replace.php script, your text editor or another &amp;quot;search and replace&amp;quot; tool, e.g. sed. For more details see the [[Moodle_migration | Moodle Migration]] page.&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==Why does my new installation display correctly on the server, but when I view it from a different machine, styles and images are missing?==&lt;br /&gt;
In the installation instructions, one of the suggested settings for &#039;webroot&#039; is &#039;localhost&#039;. This is fine if all you want to do is some local testing of your new Moodle installation. If, however, you want to view your new installation from another machine on the same local area network, or view your site on the internet, you will have to change this setting:&lt;br /&gt;
*For local testing, &#039;localhost&#039; is fine for the webroot ($CFG-&amp;gt;wwwroot in config.php). &lt;br /&gt;
*If you want to test your site from other machines on the same local area network (LAN), then you will have to use the private ip address of the serving machine, (e.g. 192.168.1.2/moodle) or the network name of the serving computer (e.g. network_name_of_serving_machine/moodle) as the web root. Depending on your LAN setup, it may be better to use the network name of the computer rather than its (private) ip address, because the ip address can and will change from time to time. If you don&#039;t want to use the network name, then you will have to speak to your network administrator and have them assign a permanent ip address to the serving machine.&lt;br /&gt;
*Finally, if you want to test your new installation across the internet, you will have to use either a domain name or a permanent (public) ip address/moodle as your web root. To handle both types of access, see [https://docs.moodle.org/en/masquerading masquerading].&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
==Maximum upload file size - how to change it?==&lt;br /&gt;
There are several places to change the maximum file upload size. The first place to check is the Administration block.   Security -&amp;gt; Site Policies -&amp;gt; and look for &amp;quot;Maximum Uploaded File Size&amp;quot;.  This is the &amp;quot;maxbyte&amp;quot; variable found in older versions of Moodle (under Admin &amp;gt; Variables). Teachers may also set the maximum file size by the [[Course_settings#Maximum_upload_size|course administration block]].&lt;br /&gt;
&lt;br /&gt;
The second place to check are the server files.  The php.ini file has a limit which will override any other setting. The relevant php variables are upload_max_filesize and post_max_size.  (Hint: remember to restart your server for changes to take effect). On Ubuntu, you must also change these variables in the apache.conf file, located in /etc/moodle/ on a standard install.  Actually, the file need only be reread, which,  if you are using phpCGI, happens when you invoke php.  For more help see:&lt;br /&gt;
*[[Administration_FAQ#How_do_the_limits_on_uploaded_files_work.3F]]&lt;br /&gt;
*[[Installing_Moodle#Recheck_PHP_settings]]&lt;br /&gt;
*[[Installing_Moodle#Using_a_.htaccess_file_for_webserver_and_PHP_settings]]&lt;br /&gt;
*[[Site_policies#Maximum_uploaded_file_size]]&lt;br /&gt;
*These forum posts: http://moodle.org/mod/forum/discuss.php?d=63840#287960 and http://moodle.org/mod/forum/discuss.php?d=93882#p414650&lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
==How do I install Moodle on Windows Vista?==&lt;br /&gt;
&lt;br /&gt;
See [[Installing Moodle on Windows Vista]].&lt;br /&gt;
&lt;br /&gt;
==Moodle claims PHP float handling is not compatible==&lt;br /&gt;
&lt;br /&gt;
The symptom is that when you try to install or upgrade your Moodle, you get a message &amp;quot;Detected unexpected problem in handling of PHP float numbers&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[http://moodle.org/mod/forum/discuss.php?d=114945 This forum thread] and MDL-18253 have more information. In short, this problem should not happen, you can help us by telling posting information about exactly which version of PHP, and OS you are using. That may let us find a way to work around this problem.&lt;br /&gt;
&lt;br /&gt;
You may be able to solve this issue by installing a more recent PHP versions. If you compile PHP yourself from source, changing the compilation options may help. However, since we don&#039;t understand the cause, we don&#039;t really know. If you do find a solution that works for you, please do tell us about it.&lt;br /&gt;
&lt;br /&gt;
Update: we have a guess that the problem may be the [http://au2.php.net/manual/en/ini.core.php#ini.precision &#039;precision&#039; setting in your php.ini file]. In a default PHP install this is set of 14. On at least one server that exhibited this problem it had been changed to a smaller value. So, if you see this problem, please try adding &lt;br /&gt;
 ini_set(&#039;precision&#039;, 14);&lt;br /&gt;
to your config.php file, and report your success in MDL-18253.&lt;br /&gt;
&lt;br /&gt;
==When upgrading Moodle claims my database is not UTF8 when I&#039;m sure it is==&lt;br /&gt;
&lt;br /&gt;
The symptom is that you are upgrading a post-1.6 Moodle to a newer version. The Environment check tells you that your database is not UTF8 and refuses to upgrade. &lt;br /&gt;
&lt;br /&gt;
The database may not have it&#039;s character encoding set quite correctly. You can safely try this command on the database&lt;br /&gt;
&lt;br /&gt;
    ALTER DATABASE moodle DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;&lt;br /&gt;
&lt;br /&gt;
(Change &#039;moodle&#039; for the name of your database). You need to copy this into your MySQL client program that comes packaged with it. Alternatively, a web client, phpmyadmin, is available as a plugin for Moodle or may be available through your hosting control panel.&lt;br /&gt;
&lt;br /&gt;
If your Moodle site is version 1.5 or older then it&#039;s telling the truth. &lt;br /&gt;
&lt;br /&gt;
[[#top|Top]]&lt;br /&gt;
&lt;br /&gt;
== How do I run multiple instances of Moodle without duplicating base code? ==&lt;br /&gt;
&lt;br /&gt;
See [http://moodle.org/mod/forum/discuss.php?d=13211 this thread] for a detailed explanation by [[User:Martin_Langhoff| Martin Langhoff]].&lt;br /&gt;
&lt;br /&gt;
== What is FreeTDS and how can I use it in my installation? ==&lt;br /&gt;
[[FreeTDS]] is an open source implementation of the Tabular Data Stream protocol used by Microsoft SQL Server and Sybase for their databases. Unfortunately, Microsoft servers don&#039;t usually accept TDS 5.0 connections. FreeTDS allows your Unix/Linux applications to talk to these other database products and import and export data between different systems successfully.    &lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&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;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[es:FAQ Instalación]]&lt;br /&gt;
[[fr:FAQ d&#039;installation]]&lt;br /&gt;
[[nl:Installatie FAQ]]&lt;br /&gt;
[[ja:インストールFAQ]]&lt;br /&gt;
[[ru:FAQ по установке]]&lt;br /&gt;
[[pl:Instalacja FAQ]]&lt;br /&gt;
[[de:Installation FAQ]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:lib/formslib.php_Usage&amp;diff=64639</id>
		<title>Development:lib/formslib.php Usage</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:lib/formslib.php_Usage&amp;diff=64639"/>
		<updated>2009-10-23T18:02:58Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: missing word&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Formslib}}&lt;br /&gt;
==Usage of Formslib==&lt;br /&gt;
&lt;br /&gt;
There are many phpdoc style comments in lib/formslib.php&lt;br /&gt;
&lt;br /&gt;
course/edit.php and the included course/edit_form.php provide a good example of usage of this library.&lt;br /&gt;
&lt;br /&gt;
Also see the PEAR docs for [http://pear.php.net/package/HTML_QuickForm/ HTML_QuickForm docs] I found this [http://pear.php.net/manual/en/package.html.html-quickform.tutorial.php quick tutorial] and this [http://www.midnighthax.com/quickform.php slightly longer one] particularly useful.&lt;br /&gt;
&lt;br /&gt;
We created some special wrapper functions for moodle. $mform-&amp;gt;get_data() returns null if no data has been submitted or validation fails or returns an object with the contents of the submitted data.&lt;br /&gt;
&lt;br /&gt;
===Basic Usage in A Normal Page===&lt;br /&gt;
&lt;br /&gt;
Generally the structure of a page with a form on it looks like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once(&#039;pathtoformdescription&#039;);&lt;br /&gt;
//you&#039;ll process some page parameters at the top here and get the info about&lt;br /&gt;
//what instance of your module and what course you&#039;re in etc. Make sure you&lt;br /&gt;
//include hidden variable in your forms which have their defaults set in set_data&lt;br /&gt;
//which pass these variables from page to page&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$mform = new yourmod_formfunction_form();//name of the form you defined in file above.&lt;br /&gt;
//default &#039;action&#039; for form is strip_querystring(qualified_me())&lt;br /&gt;
if ($mform-&amp;gt;is_cancelled()){&lt;br /&gt;
    //you need this section if you have a cancel button on your form&lt;br /&gt;
    //here you tell php what to do if your user presses cancel&lt;br /&gt;
    //probably a redirect is called for!&lt;br /&gt;
} else if ($fromform=$mform-&amp;gt;get_data()){&lt;br /&gt;
//this branch is where you process validated data.&lt;br /&gt;
&lt;br /&gt;
} else {&lt;br /&gt;
// this branch is executed if the form is submitted but the data doesn&#039;t validate and the form should be redisplayed&lt;br /&gt;
// or on the first display of the form.&lt;br /&gt;
    //setup strings for heading&lt;br /&gt;
    print_header_simple($streditinga, &#039;&#039;,&lt;br /&gt;
     &amp;quot;&amp;lt;a href=\&amp;quot;$CFG-&amp;gt;wwwroot/mod/$module-&amp;gt;name/index.php?id=$course-&amp;gt;id\&amp;quot;&amp;gt;$strmodulenameplural&amp;lt;/a&amp;gt; -&amp;gt;&lt;br /&gt;
     $strnav $streditinga&amp;quot;, $mform-&amp;gt;focus(), &amp;quot;&amp;quot;, false);&lt;br /&gt;
    //notice use of $mform-&amp;gt;focus() above which puts the cursor &lt;br /&gt;
    //in the first form field or the first field with an error.&lt;br /&gt;
&lt;br /&gt;
    //call to print_heading_with_help or print_heading? then :&lt;br /&gt;
    &lt;br /&gt;
    //put data you want to fill out in the form into array $toform here then :&lt;br /&gt;
&lt;br /&gt;
    $mform-&amp;gt;set_data($toform);&lt;br /&gt;
    $mform-&amp;gt;display();&lt;br /&gt;
    print_footer($course);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Defining Your Form Class===&lt;br /&gt;
&lt;br /&gt;
The form class tells us about the structure of the form. You are encouraged to put this in a file called {function}_form.php probably in the same folder in which the page that uses it is located. The name of your class should be {modname}_{function}_form eg. forum_post_form or course_edit_form. These classes will extend class moodleform.&lt;br /&gt;
&lt;br /&gt;
Note the name you give the class is used as the id attribute of your form in html (any trailing &#039;_form&#039; is chopped off&#039;). Your form class name should be unique in order for it to be selectable in CSS by theme designers who may want to tweak the css just for that form.&lt;br /&gt;
&lt;br /&gt;
====definition()====&lt;br /&gt;
&lt;br /&gt;
[[Development:lib/formslib.php_Form_Definition|Help is here for defining your form]] by defining a function definition() in your form class that sets up your form structure.&lt;br /&gt;
&lt;br /&gt;
===Use in Activity Modules Add / Update Forms===&lt;br /&gt;
&lt;br /&gt;
Syntax is the same in activity modules to create your update / add page. We are still supporting mod.html but if you want to use the new formslib then you can in Moodle 1.8 just include in your module directory the file mod_form.php instead of mod.html and it will be automatically detected. Inside this file you define a class with class name &#039;{modname}__mod_form&#039; which extends the class &#039;moodleform_mod&#039;. See many examples of the core modules which have been converted to use formslib already.&lt;br /&gt;
&lt;br /&gt;
====defaults_preprocessing====&lt;br /&gt;
&lt;br /&gt;
For activity modules you use the same syntax to define your form. You may also want to override method defaults_preprocessing this can be used to take the data from the data base and tell the form how to fill out defaults in the form with this data. For example in the forum module in forum/mod_form.php we needed to tick an enable check box if a date had been selected in the date select. Normally data is loaded from the database and directly loaded into form fields with the same name as the database record you only need to use defaults_preprocessing if there isn&#039;t this one to one relationship. Another example is the lesson/mod_form.php which takes the data from the database and unserializes it. choice/mod_form.php shows an exampe of loading data from another db table referred to by a foreign key, to include in the form.&lt;br /&gt;
&lt;br /&gt;
====Post Processing Still Done in lib.php Functions====&lt;br /&gt;
&lt;br /&gt;
Post processing of data is done in lib.php functions modname_add_instance and modname_update_instance after the data has been validated. When migrating a form often little changes need to be made in the post processing. An exception is that date and date_time_selector fields automatically have their submitted data turned into timestamps so you don&#039;t need to do this in your add and update functions anymore.&lt;br /&gt;
&lt;br /&gt;
====Automatically Including Standard Activity Module Form Elements====&lt;br /&gt;
&lt;br /&gt;
Standard activity module form elements are automatically included using the moodleform_mod method standard_coursemodule_elements(). The default is to include a visibility and groupsmode select box and to include all necessary hidden fields. You can pass a parameter false to tell the method that your module doesn&#039;t support groups and so you don&#039;t want the groupsmode select button.&lt;br /&gt;
&lt;br /&gt;
[[Category:Formslib]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:Assignment_development&amp;diff=64172</id>
		<title>Development:Assignment development</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:Assignment_development&amp;diff=64172"/>
		<updated>2009-10-09T16:47:24Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: spelling mistakes&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
This was a proposition of Assignment module development from POAS department of Volgograd State Technical University. &lt;br /&gt;
We don&#039;t want to fork from core, but was forced to do it by Moodle team. So it will be a separate module, that you can use instead of standard assignment. There may be a convertor some time ago.&lt;br /&gt;
&lt;br /&gt;
New module name will be a poasassignment.&lt;br /&gt;
== Assignment 1.9 improvements ==&lt;br /&gt;
Just several simple, but useful improvements that can be done in stable version too:&lt;br /&gt;
# Usability improvement: on submission.php add a combo box to filter the content of the table: Show all/with submissions/await grading. That speed up grading much. See MDL-14238&lt;br /&gt;
# New capability: viewownsubmission. Setting it to Deny makes assignment module useful in exam context - collect student&#039;s work without their further access to it. See MDL-15356&lt;br /&gt;
# Replace link with the number of submissions (for the teacher) with more informative &amp;quot;The ___ of ___ submissions needs grading&amp;quot;. MDL-17613&lt;br /&gt;
&lt;br /&gt;
== Refactoring ==&lt;br /&gt;
Some areas of assignment can be reworked for greater flexibility and reducing code duplication. Assignment base is actualy an awful, bloated class where all things are intermixed. And any plugin inherits it fully. Some plugins have similar features too, implemented separately. Overall issue for this is MDL-17329.&lt;br /&gt;
&lt;br /&gt;
Some major improvments:&lt;br /&gt;
* &#039;types&#039; will be no longer considered separate activities, just a option in the mod_form&lt;br /&gt;
* &#039;type&#039; plugins, which defines what can be submitted, will be reduced to just that purpose, all workflow would be controlled from main module (reducing numerous duplicates and inconsistences)&lt;br /&gt;
* there will be two basic &#039;type&#039; plugins (text and files), which can be used in any combination (from no one to both)&lt;br /&gt;
** no one is effectively an offline task&lt;br /&gt;
** files (reworked upload) can serve for both single and multiple files uploads&lt;br /&gt;
* there will be possible to create new activities based on this module, inheriting it&#039;s main classes, for major workflow customisations, and they will have full access to &#039;type&#039; plugins&lt;br /&gt;
== New Features ==&lt;br /&gt;
&lt;br /&gt;
=== Teams ===&lt;br /&gt;
  This feature is on hold and may wait for a second version of module. Right now we are more focused on task distribution&lt;br /&gt;
&lt;br /&gt;
One main assumption in the assignment module is need to be eliminated is &amp;quot;one user=one submission=one grade&amp;quot;. The quite common practice is grouped assignments, where students can work in small groups on a task. So we need a teams support there. (Well, quite big work as many functions use this assumption).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Team&#039;&#039;&#039; is a group of students whose work will results in one submission. Teams features:&lt;br /&gt;
* submission is one per team, but a grade can be given on per-team or per-student basis&lt;br /&gt;
* teacher can define a minimum and maximum number of students in the team&lt;br /&gt;
* self-organization (with possibility of confirmation by teacher) or forced by teacher teams&lt;br /&gt;
* maximum date of team membership editing&lt;br /&gt;
* teacher can add themselves to teamas a mentor, then he only will be notified of events in this team&lt;br /&gt;
* &#039;roles&#039; (or workroles to avoid confusion with Moodle Roles) of people in team (either teacher or student defined) - this is a way to explain who in group will do what&lt;br /&gt;
** teacher-defined roles is a list, from which one or several roles can be selected for students&lt;br /&gt;
** if teacher doesn&#039;t want do define specific roles, students can enter text, explaining their role in the group&lt;br /&gt;
&lt;br /&gt;
=== Individual tasks ===&lt;br /&gt;
Individual tasks is quite common situation in the educational process. The module can handle tasks selection and completion.&lt;br /&gt;
&lt;br /&gt;
Individual tasks features:&lt;br /&gt;
* adding/editing/deleting of tasks by the teacher&lt;br /&gt;
* standart fields: name, description, grade factor (1 by default), min/max teamnumber (if teams activated)&lt;br /&gt;
* custom fields, which can be added in any given assignment, of several types: string, text, number, date, menu, file&lt;br /&gt;
* some fields can only be accessible to the student once he is selected a task (and it will be approved by a teacher if necessary)&lt;br /&gt;
* student&#039;s selection (with optional teacher approval), teacher-forced selection or random selection based on a student&#039;s selection of subset of tasks fields (number or menu mainly, i.e. some sort of &#039;complexity&#039; field for example)&lt;br /&gt;
* maximum dates of selection (and approval if necessary)&lt;br /&gt;
* column with task name (link to the task) when grading&lt;br /&gt;
* random filling of some task fields (number or menu mainly) on selection or approval&lt;br /&gt;
** there is some problem of misuse of random generator; they are mainly dealt with fact that student&#039;s can change task and select new without teacher&lt;br /&gt;
&lt;br /&gt;
=== User interface - tabs ===&lt;br /&gt;
Currently assignment have only two main pages: intro/submit (view.php) and grading (submission.php), so it can go away with the link in upper right corner.&lt;br /&gt;
&lt;br /&gt;
New features will require more pages, so it&#039;s better to use tabs for them. Tabs visibility will be based on user&#039;s capabilities.&lt;br /&gt;
&lt;br /&gt;
Urgent reminders will be places on top (or bottom?) of every tab with color highlighting;&lt;br /&gt;
* for students&lt;br /&gt;
** if he is late to select a task/become a member of team&lt;br /&gt;
** if he is late to submit work&lt;br /&gt;
* for teachers&lt;br /&gt;
** if student from his/her group asks to delete him from team (or task change)&lt;br /&gt;
** if there are students without task/team after date of last approval&lt;br /&gt;
&lt;br /&gt;
=== Grading semi-plugins ===&lt;br /&gt;
Sometimes assignments allow for automatic, or semi-automatic grading. It&#039;s nice to have options to have a plugin system for this.&lt;br /&gt;
&lt;br /&gt;
=== &#039;&#039;maybe&#039;&#039; One user can get several tasks ===&lt;br /&gt;
That needs further discussion. It&#039;s something not very uncommon in real word teaching, but somewhat difficult to cope with &amp;quot;one course module=one grade&amp;quot; thing.&lt;br /&gt;
&lt;br /&gt;
=== Tasks workflow ===&lt;br /&gt;
Let&#039;s see a task workflow in most complicated case (maximum features will be used). States names are somewhat awkward and is subject to change (can anyone propose better names?)&lt;br /&gt;
&lt;br /&gt;
* initially task is &#039;&#039;&#039;free&#039;&#039;&#039; (1)&lt;br /&gt;
* (1) student or teacher can create a team -&amp;gt; &#039;&#039;&#039;creating team&#039;&#039;&#039; (2)&lt;br /&gt;
* (2) student(s) can add themselves to the team, teacher can add students to the team (in last case student notified that he/she was added)&lt;br /&gt;
* (2) students can plead to free them from team/task, teacher can disapprove (if allowed) members or task (students is notified if they are disapproved)&lt;br /&gt;
* (2) after the team will have at least minimum number of participants -&amp;gt; &#039;&#039;&#039;have enough people&#039;&#039;&#039; (3)&lt;br /&gt;
* (3) all (2) operations still available&lt;br /&gt;
* (3) students can confirm his will to work with team(now that he knows all it&#039;s members), teacher can approve a team - approvment automatically cleared if team membership changes (people that have approves is notified)&lt;br /&gt;
* (3) after the date of last approval, no more changes in teams available for students, (for teachers it&#039;s depends on capabilities), if there is an unapproved team the teacher will be shown (and sent) urgent reminder&lt;br /&gt;
* (3) after the students (if allowed) approved a team and task -&amp;gt; &#039;&#039;&#039;ready&#039;&#039;&#039; (4) (if teacher approvment needed) or &#039;&#039;&#039;working&#039;&#039;&#039; (5) (students and teacher notified)&lt;br /&gt;
* (4) after teacher approval -&amp;gt; &#039;&#039;&#039;working&#039;&#039;&#039; (5) (students notified)&lt;br /&gt;
* (4) in case of teacher disapproval -&amp;gt; &#039;&#039;&#039;have enough people&#039;&#039;&#039; (3) (students notified)&lt;br /&gt;
* (5) any student in the team can submit work with flag &#039;please check our progress&#039; (if allowed), then teacher is notified and able to give comment but not grade (teacher notified, student&#039;s notified of comment)&lt;br /&gt;
* (5) any student in team can make a normal submit, but it (optionally) may need an approval from other members for grading -&amp;gt; &#039;&#039;&#039;await grading&#039;&#039;&#039; (6) (teacher notified)&lt;br /&gt;
* (6) the teacher can only grade a team in &#039;&#039;&#039;await grading&#039;&#039;&#039; status&lt;br /&gt;
* (6) teacher grades, but grade isn&#039;t final -&amp;gt; &#039;&#039;&#039;reworking&#039;&#039;&#039; (5) (students notified)&lt;br /&gt;
* (6) teacher gives final grade -&amp;gt; &#039;&#039;&#039;graded&#039;&#039;&#039; (7) (students notified)&lt;br /&gt;
* (7) person of higher authority will be able to override grade and add something to comment (but maybe not freely edit it, the name of the first grader and regrader will be saved in comment). (students and teacher notified)&lt;br /&gt;
&lt;br /&gt;
Well it&#039;s probably looked worse than is. The actual user will see only part of options, and all forms of approval can be disabled.&lt;br /&gt;
&lt;br /&gt;
=== Files handling ===&lt;br /&gt;
There is some confusion about files handling in current version of assignment module. This is need to be corrected. So there should be a several types of files:&lt;br /&gt;
&lt;br /&gt;
# &#039;&#039;&#039;assignment&#039;&#039;&#039; files - files that is showed and accessible to all, and associated with assignment in general even if individual tasks is used (such as guidelines for it&#039;s completion that apply to all regardless of individual task);&lt;br /&gt;
# &#039;&#039;&#039;task&#039;&#039;&#039; files - some file(s) that teacher want to give students before they start to work on particular task;&lt;br /&gt;
# &#039;&#039;&#039;submission&#039;&#039;&#039; files - files that was submitted by a particular student (team);&lt;br /&gt;
# &#039;&#039;&#039;reply&#039;&#039;&#039; (comment) files - files that was uploaded by a teacher when grading submitted work, usually rewised versions of submitted files (thanks to A.T. Wyatt comment there)&lt;br /&gt;
&lt;br /&gt;
== Implementation ==&lt;br /&gt;
&lt;br /&gt;
=== New options ===&lt;br /&gt;
Let&#039;s see an assignment creation/editing screen. Assignment module will keep all existing options.&lt;br /&gt;
&lt;br /&gt;
New options that will be added:&lt;br /&gt;
* use individual tasks&lt;br /&gt;
* use teams&lt;br /&gt;
* last date of approval - active if tasks or teams used, time to which all considerations about group memebrship and tasks selections must be done&lt;br /&gt;
* team options (active only if teams selected)&lt;br /&gt;
** min and max count of members of team&lt;br /&gt;
** the grade will be individual or one per team&lt;br /&gt;
** if students must confirm it will to work with team (first student, who create a team, may not be happy with someone who add yourself to it later)&lt;br /&gt;
** if teacher must confirm team membership&lt;br /&gt;
** if all team members must confirm a submission before grading&lt;br /&gt;
* individual task options (active only if tasks is selected)&lt;br /&gt;
** allow using same tasks - can several students do one task or all tasks must be different?&lt;br /&gt;
** allow using same tasks in one group&lt;br /&gt;
** individual date - allow individual due dates to the task&lt;br /&gt;
** individual team members count - if teams used, can particular task override min/max number of students in team&lt;br /&gt;
** teacher must confirm task selection&lt;br /&gt;
** random task assignment&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== DB structure ===&lt;br /&gt;
[[Image:db_shema.jpg]]&lt;br /&gt;
&lt;br /&gt;
The new db structure have such tables:&lt;br /&gt;
* &#039;&#039;&#039;poasassignment&#039;&#039;&#039; - main table which have new options :&lt;br /&gt;
*# maxmembersontask - maximum count of members which must to do the task&lt;br /&gt;
*# minmembersontask - minimum count of members which must to do the task&lt;br /&gt;
*# mintaskonmember - minimum count of tasks for one member(needs discussion)&lt;br /&gt;
*# maxtaskonmember - maximum count of tasks for one member(needs discussion)&lt;br /&gt;
*# timedistrib - initial time for task distribution&lt;br /&gt;
*# timeconfirmation - the date after that a student not may create/come into new working group&lt;br /&gt;
*# timereception - start time for tasks reception&lt;br /&gt;
*# flags - all binary options&lt;br /&gt;
* &#039;&#039;&#039;poasassignment_tasks&#039;&#039;&#039; - table for task list of instance of activity:&lt;br /&gt;
*# name - the name of task&lt;br /&gt;
*# descripiton - task &amp;quot;body&amp;quot;&lt;br /&gt;
*# deadline - individual date for task reception&lt;br /&gt;
*# factor - factor for grade&lt;br /&gt;
*# maxmembers - maximum workgroup members on task&lt;br /&gt;
*# minmembers - minimum workgroup members on task&lt;br /&gt;
* &#039;&#039;&#039;poasassignment_fields&#039;&#039;&#039; - define list of custom fields:&lt;br /&gt;
*# ftype - type of the field&lt;br /&gt;
*# name - name of the field&lt;br /&gt;
*# showintable - additional column in table of tasks&lt;br /&gt;
*# maxvalue - maximum value for the field(only numbers)&lt;br /&gt;
*# minvalue - minimum value for the field(only numbers)&lt;br /&gt;
*# optional - optional field?&lt;br /&gt;
*# rndparam - if this field used to define filter for random selection of task&lt;br /&gt;
*# rndshow - if this field will get random value on task selection (number or menu fields only)&lt;br /&gt;
* &#039;&#039;&#039;poasassignment_field_consts&#039;&#039;&#039; - define consts for the fields type of list&lt;br /&gt;
* &#039;&#039;&#039;poasassignment_values&#039;&#039;&#039; - values for particular task/workgroup&lt;br /&gt;
* &#039;&#039;&#039;poasassignment_workgroups&#039;&#039;&#039; - table for teams, also submissions stuff go there&lt;br /&gt;
* &#039;&#039;&#039;poasassignment_workgroup_members&#039;&#039;&#039; - members of teams, grade stuff go there:&lt;br /&gt;
*# userid - &lt;br /&gt;
*# grade - this is the grade for submission&lt;br /&gt;
*# submissioncomment - &lt;br /&gt;
*# format,teacher,timemarked,mailed - old fields of assignment_submissions&lt;br /&gt;
*# ownrole - role which student want implement during task execution&lt;br /&gt;
*# finalgrade - final grade(yes/no)?&lt;br /&gt;
*# deletefrom - please kick me from this working group (or task)&lt;br /&gt;
*# deletecomment - explanation why student needs to delete from this working group&lt;br /&gt;
* &#039;&#039;&#039;poasassignment_role&#039;&#039;&#039; - roles for the task:&lt;br /&gt;
*# one task have many roles&lt;br /&gt;
*# one student perform many roles&lt;br /&gt;
  Rethink tables/columns, define how a type plugin can use db, rename workgroups into teams everywhere --[[User:Oleg Sychev|Oleg Sychev]] 11:12, 11 September 2009 (UTC)&lt;br /&gt;
=== Tabs ===&lt;br /&gt;
&lt;br /&gt;
==== Info/submit ====&lt;br /&gt;
This is an initial tab, that will work basically the same as before.&lt;br /&gt;
&lt;br /&gt;
New abilities:&lt;br /&gt;
* show additional dates (i.e. dates of last approval and so on)&lt;br /&gt;
* student: show individual task (?tasks?) when the individual tasks is selected&lt;br /&gt;
* student: show task status (see workflow of the task above)&lt;br /&gt;
* student: show team members (when teams used)&lt;br /&gt;
* student: can approve team and submission, select or type his roles&lt;br /&gt;
* teacher: the number of submissions will be shown JFI as there is a tab for grading now (maybe as a link, just as in quiz now - it must be moved to down center area)&lt;br /&gt;
* teacher: the number of submissions will be showed as &amp;lt;need grading&amp;gt;/&amp;lt;all submissions&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Custom fields ====&lt;br /&gt;
This tab is for managing custom fields for the tasks. The author can add/edit/delete fields there.&lt;br /&gt;
&lt;br /&gt;
==== Tasks ====&lt;br /&gt;
New tab, accessible when individual task feature activated.&lt;br /&gt;
&lt;br /&gt;
Abilities:&lt;br /&gt;
* teacher: adding, editing, deleting a task (editing and deleting assigned tasks may be prohibited)&lt;br /&gt;
* student: browsing task list, viewing task details&lt;br /&gt;
* student (without teams): selecting a task&lt;br /&gt;
* student (in team mode): see current teams(at least incomplete), create team for a task, apply for team membership&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Grading ====&lt;br /&gt;
This is an evolved grading page (submission.php), for teachers use.&lt;br /&gt;
&lt;br /&gt;
New abilities:&lt;br /&gt;
* the table will reflect a status of task (maybe with icons)&lt;br /&gt;
* individual tasks: the table will additionally reflect task name (as a link to popup with it&#039;s description) and a grade factor&lt;br /&gt;
* teams: the table (and popup for grading too) will have two modes:&lt;br /&gt;
* teams and/or individual tasks: in case any form of teacher approvment is needed, columns for approvment will be showed&lt;br /&gt;
* grade columns/popus will be showed only when grading is allowed (or if person has mod/assignment:manageanything capability)&lt;br /&gt;
*# team grades - each string represent a team&lt;br /&gt;
*# individual grades - each string represents a student, but they are sorted by team and teams is spaced somehow&lt;br /&gt;
* make an option for the teachers to make any grade final, forbidding further re-submissions and/or regrading (a person with mod/assignment:manageanything can still regrade); in teams with individual grading mode re-submission will be forbidden only when all team members receive final grade&lt;br /&gt;
* dropdown to choose whom to display in the table (and in the popup): all, with submissions only, needs grading only&lt;br /&gt;
&lt;br /&gt;
=== Capabilities ===&lt;br /&gt;
Current capabilities&lt;br /&gt;
* mod/poasassignment:view - actually quite strange capability that can completely block you from assignment&lt;br /&gt;
* mod/poasassignment:submit - ability to submit a work&lt;br /&gt;
* mod/poasassignment:grade - ability to grade submissions&lt;br /&gt;
&lt;br /&gt;
New capabilities&lt;br /&gt;
* mod/poasassignment:viewownsubmission (can be backported to 1.9) - sometimes we need to not allowing the student to see own submission (exams cases mostly)&lt;br /&gt;
* mod/poasassignment:manageanything - person with high authority, for whom don&#039;t apply usual restrictions: he can edit/delete tasks on which people worked right now, manage group membership and their tasks after an approval, override final grades and so on&lt;br /&gt;
* mod/poasassignment:managetasks - ability to create, edit and delete tasks&lt;br /&gt;
* mod/poasassignment:managefields - ability to manage custom fields of tasks&lt;br /&gt;
* mod/poasassignment:finalgrades - can make grades final&lt;br /&gt;
* mod/poasassignment:manageteams - ability to create, force students to the team, approve students (teacher&#039;s ability)&lt;br /&gt;
* mod/poasassignment:managetaskselection - ability to manage tasks selection for any student (teacher&#039;s ability)&lt;br /&gt;
* mod/poasassignment:manageownteam - ability to create new team, apply to existing one, confirm memebership of the others in this team (student&#039;s ability, setting it to Deny will create an task where only teachers can manage teams membership)&lt;br /&gt;
* mod/poasassignment:selectowntask - student&#039;s ability to select task (setting to Deny allows for teachers-only tasks selection)&lt;br /&gt;
* mod/poasassignment:seeotherstasks - student&#039;s ability - if he/she is able to see what tasks are selected by other people, or he can see only if it free for selection&lt;br /&gt;
&lt;br /&gt;
[[Category:Assignment]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:XHTML&amp;diff=63498</id>
		<title>Development:XHTML</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:XHTML&amp;diff=63498"/>
		<updated>2009-09-24T07:55:34Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: missing words added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==XHTML Strict 1.0==&lt;br /&gt;
&lt;br /&gt;
Moodle output must be compliant with XHTML Strict 1.0. This means it must be:&lt;br /&gt;
&lt;br /&gt;
===Well-formed XML===&lt;br /&gt;
&lt;br /&gt;
In a well-formed XML document, every opening tag has a matching close tag; tags are properly nested, attributes are properly quoted, and the file contains no syntax errors. See [http://www.w3.org/TR/xml/#sec-well-formed the XML specification for a formal definition].&lt;br /&gt;
&lt;br /&gt;
While developing, you should have the option Administration ► Server ► Debugging ► XML strict headers turned on. With this option on, your web browser will refuse to display any page that is not well-formed. This makes such problems easy to find and fix.&lt;br /&gt;
&lt;br /&gt;
===Valid XHTML Strict===&lt;br /&gt;
&lt;br /&gt;
This means that the XML of your page follows the particular rules from the [http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict XHTML-1.0-Strict DTD]. &amp;lt;nowiki&amp;gt;For example, the first tag in the file must be &amp;lt;html&amp;gt;, a &amp;lt;form&amp;gt; tag must have an action=&amp;quot;&amp;quot; attribute, an &amp;lt;li&amp;gt; can only appear inside an &amp;lt;ol&amp;gt; or &amp;lt;ul&amp;gt;, you cannot use &amp;lt;frame&amp;gt; tags, and so on.&amp;lt;/nowiki&amp;gt; and so on.&lt;br /&gt;
&lt;br /&gt;
You can check whether the HTML you output is valid by using a HTML validator, for example the [https://addons.mozilla.org/en-US/firefox/addon/249 Html Validator] add-on for Firefox.&lt;br /&gt;
&lt;br /&gt;
===Semantic markup===&lt;br /&gt;
&lt;br /&gt;
That is, HTML tags should be used only to mark up the appropriate types of content. For example:&lt;br /&gt;
* tables should not be used for page layout, just to display tabular information,&lt;br /&gt;
* if something is a heading, it should be marked up using &amp;lt;h&#039;&#039;n&#039;&#039;&amp;gt; tags, for an appropriate &#039;&#039;n&#039;&#039;,&lt;br /&gt;
* &amp;lt;nowiki&amp;gt;if something is a list, it should be marked up using &amp;lt;ol&amp;gt;, &amp;lt;ul&amp;gt; or &amp;lt;dl&amp;gt;,&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* see [[Semantic HTML]] for further details&lt;br /&gt;
&lt;br /&gt;
==Styling==&lt;br /&gt;
&lt;br /&gt;
How the HTML is laid out should be controlled by CSS in whichever theme is currently selected.&lt;br /&gt;
&lt;br /&gt;
* Ensure that the HTML contains enough id=&amp;quot;...&amp;quot; and class=&amp;quot;...&amp;quot; attributes so that theme designers can easily control how it is displayed.&lt;br /&gt;
* Never embed inline styles in the HTML (that is, do not use the style=&amp;quot;...&amp;quot; attribute).&lt;br /&gt;
* As you change core Moodle code, you must update the standard theme so that Moodle looks OK out of the box.&lt;br /&gt;
* If you need to make basic style definitions for a module (or some other sorts of plugin), put them in a file called styles.php in that module. This will be included into every theme.&lt;br /&gt;
&lt;br /&gt;
== Moodle API ==&lt;br /&gt;
&lt;br /&gt;
* Use the functions in lib/weblib to do as much as possible (print_header(), print_box() etc)&lt;br /&gt;
* This API will change a lot in Moodle 2.0.  See:  [[Development:Navigation_2.0]]&lt;br /&gt;
&lt;br /&gt;
== See also: ==&lt;br /&gt;
&lt;br /&gt;
* [http://developer.apple.com/internet/webcontent/bestwebdev.html Web Page Development: Best Practices] by the Safari development team at Apple.&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:XHTML&amp;diff=63497</id>
		<title>Development:XHTML</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:XHTML&amp;diff=63497"/>
		<updated>2009-09-24T07:53:26Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: missing word added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==XHTML Strict 1.0==&lt;br /&gt;
&lt;br /&gt;
Moodle output must be compliant with XHTML Strict 1.0. This means it must be:&lt;br /&gt;
&lt;br /&gt;
===Well-formed XML===&lt;br /&gt;
&lt;br /&gt;
In a well-formed XML document, every opening tag has a matching close tag; tags are properly nested, attributes are properly quoted, and the file contains no syntax errors. See [http://www.w3.org/TR/xml/#sec-well-formed the XML specification for a formal definition].&lt;br /&gt;
&lt;br /&gt;
While developing, you should have the option Administration ► Server ► Debugging ► XML strict headers turned on. With this option on, your web browser will refuse to display any page that is not well-formed. This makes such problems easy to find and fix.&lt;br /&gt;
&lt;br /&gt;
===Valid XHTML Strict===&lt;br /&gt;
&lt;br /&gt;
This means that the XML of your page follows the particular rules from the [http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict XHTML-1.0-Strict DTD]. &amp;lt;nowiki&amp;gt;For example, the first tag in the file must be &amp;lt;html&amp;gt;, a &amp;lt;form&amp;gt; tag must have an action=&amp;quot;&amp;quot; attribute, an &amp;lt;li&amp;gt; can only appear inside an &amp;lt;ol&amp;gt; or &amp;lt;ul&amp;gt;, you cannot use &amp;lt;frame&amp;gt; tags, and so on.&amp;lt;/nowiki&amp;gt; and so on.&lt;br /&gt;
&lt;br /&gt;
You can check whether the HTML you output is valid by using a HTML validator, for example the [https://addons.mozilla.org/en-US/firefox/addon/249 Html Validator] add-on for Firefox.&lt;br /&gt;
&lt;br /&gt;
===Semantic markup===&lt;br /&gt;
&lt;br /&gt;
That is, HTML tags should be used only to mark up the appropriate types of content. For example:&lt;br /&gt;
* tables should not be used for page layout, just to display tabular information,&lt;br /&gt;
* if something is a heading, it should be marked up using &amp;lt;h&#039;&#039;n&#039;&#039;&amp;gt; tags, for an appropriate &#039;&#039;n&#039;&#039;,&lt;br /&gt;
* &amp;lt;nowiki&amp;gt;if something is a list, it should be marked up using &amp;lt;ol&amp;gt;, &amp;lt;ul&amp;gt; or &amp;lt;dl&amp;gt;,&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* see [[Semantic HTML]] for further details&lt;br /&gt;
&lt;br /&gt;
==Styling==&lt;br /&gt;
&lt;br /&gt;
How the HTML is laid out should be controlled by CSS in whichever theme is currently selected.&lt;br /&gt;
&lt;br /&gt;
* Ensure that the HTML contains enough id=&amp;quot;...&amp;quot; and class=&amp;quot;...&amp;quot; attributes so that theme designers can easily control how &lt;br /&gt;
* Never embed inline styles in the HTML (that is, do not use the style=&amp;quot;...&amp;quot; attribute).&lt;br /&gt;
* As you change core Moodle code, you must update the standard theme so that Moodle looks OK out of the box.&lt;br /&gt;
* If you need to make basic style definitions for a module (or some other sorts of plugin), put them in a file called styles.php in that module. This will be included into every theme.&lt;br /&gt;
&lt;br /&gt;
== Moodle API ==&lt;br /&gt;
&lt;br /&gt;
* Use the functions in lib/weblib to do as much as possible (print_header(), print_box() etc)&lt;br /&gt;
* This API will change a lot in Moodle 2.0.  See:  [[Development:Navigation_2.0]]&lt;br /&gt;
&lt;br /&gt;
== See also: ==&lt;br /&gt;
&lt;br /&gt;
* [http://developer.apple.com/internet/webcontent/bestwebdev.html Web Page Development: Best Practices] by the Safari development team at Apple.&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:JavaScript_guidelines&amp;diff=63484</id>
		<title>Development:JavaScript guidelines</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:JavaScript_guidelines&amp;diff=63484"/>
		<updated>2009-09-23T17:33:25Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: spelling mistake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
&lt;br /&gt;
These guidelines can only be applied fully from Moodle 2.0 onwards, because they rely on our new API to facilitate use of JavaScript.&lt;br /&gt;
&lt;br /&gt;
When writing JavaScript for earlier versions of Moodle, please try to follow these guidelines in spirit and use the &#039;&#039;&#039;require_js&#039;&#039;&#039; function in place of $PAGE-&amp;gt;requires-&amp;gt;js/yui_lib.&lt;br /&gt;
&lt;br /&gt;
==General principles==&lt;br /&gt;
&lt;br /&gt;
===Moodle should be usable without JavaScript===&lt;br /&gt;
&lt;br /&gt;
Everything in Moodle should work with JavaScript turned off. This is important for accessibility, and in line with the principles of [[Development:Unobtrusive_Javascript|unobtrusive JavaScript]] and [[Development:Progressive_enhancement|progressive enhancement]].&lt;br /&gt;
&lt;br /&gt;
===Minimise inline JavaScript===&lt;br /&gt;
&lt;br /&gt;
Almost all JavaScript code should be in separate .js files. There should be the smallest possible amount of JavaScript inline in the HTML code of pages.&lt;br /&gt;
&lt;br /&gt;
The only &amp;amp;lt;script&amp;gt; tags in the HTML should be&lt;br /&gt;
# &amp;amp;lt;script src=... tags to include the necessary .js files.&lt;br /&gt;
# Simple function calls to trigger initialisation. For example &amp;amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;initialise_my_widget(&#039;some&#039;, &#039;data&#039;, 123);&amp;amp;lt;/script&amp;gt;.&lt;br /&gt;
# Variable definitions to transfer data from the PHP code to JavaScript. For example &amp;amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;var moodle_cfg = {&amp;quot;modpixpath&amp;quot;:&amp;quot;http:\/\/tim.moodle.local\/moodle\/mod&amp;quot;,&amp;quot;sesskey&amp;quot;:&amp;quot;ZVNQiq7pHu&amp;quot;,&amp;quot;developerdebug&amp;quot;:true};&amp;amp;lt;/script&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
You should not use old-fashioned onXXX=&amp;quot;event_handler&amp;quot; attributes in the HTML. Use Modern DOM events. The YUI events library makes this easy.&lt;br /&gt;
&lt;br /&gt;
=== JavaScript libraries ===&lt;br /&gt;
&lt;br /&gt;
* The official JavaScript library for Moodle is [[Development:YUI|YUI]]. That may not be your favourite, but it&#039;s the one that was chosen after careful research, so live with it.&lt;br /&gt;
&lt;br /&gt;
* Moodle also has its own JavaScript library code, principally in lib/javascript-static.js.&lt;br /&gt;
&lt;br /&gt;
* Moodle uses the &#039;&#039;&#039;TinyMCE&#039;&#039;&#039; HTML editor.&lt;br /&gt;
&lt;br /&gt;
===When to include the JavaScript===&lt;br /&gt;
&lt;br /&gt;
As per [http://developer.yahoo.com/performance/rules.html Yahoo&#039;s best practice guidelines], load and execute the JavaScript as late as possible, ideally the script tags should be the last thing before the &amp;amp;lt;/body&amp;gt; close tag. (This is the default behaviour with Moodle&#039;s JavaScript handling functions.)&lt;br /&gt;
&lt;br /&gt;
Since everything should work without JavaScript, load and initialising your scripts only after everything else on the page has loaded should not be a problem and will increase the perceived page-load performance for users.&lt;br /&gt;
&lt;br /&gt;
===Minimise the number of .js files===&lt;br /&gt;
&lt;br /&gt;
Try not to use too many different .js files. Each separate file that the browser has to load incurs an overhead.&lt;br /&gt;
&lt;br /&gt;
On the other hand, organise the JavaScript logically to ease maintenance, and don&#039;t include large amounts of irrelevant JavaScript code. Code that is loaded but never used is a waste of time.&lt;br /&gt;
&lt;br /&gt;
So, if you are writing a new module that needs its own JavaScript, try starting with with a single file mod/mymod/mymod.js. If you find that you are writing a lot of JavaScript that is only needed when the teacher edits your module, but is not needed by students, then consider splitting that code into a separate file like mod/mymod/edit.js, and only including it where needed.&lt;br /&gt;
&lt;br /&gt;
==How to achive these general principles in Moodle==&lt;br /&gt;
&lt;br /&gt;
The rest of this page explains how you can achieve the above goals.&lt;br /&gt;
&lt;br /&gt;
===Getting Moodle to load your JavaScript files===&lt;br /&gt;
&lt;br /&gt;
Everything required by the current page is tracked by the $PAGE-&amp;gt;requires object, which is an instance of the [http://phpdocs.moodle.org/HEAD/moodlecore/page_requirements_manager.html page_requirements_manager] class. You use it like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt; &lt;br /&gt;
$PAGE-&amp;gt;requires-&amp;gt;js(&#039;mod/mymod/scripts.js&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By default, this will put the &amp;amp;lt;script&amp;gt; tag that loads the script at the end of the &amp;amp;lt;body&amp;gt; tag, as recommended. If you really must load the script sooner, use one of the following&lt;br /&gt;
&amp;lt;code php&amp;gt; &lt;br /&gt;
// Load the js file from head.&lt;br /&gt;
// (This will throw an exception if head has already been output.)&lt;br /&gt;
$PAGE-&amp;gt;requires-&amp;gt;js(&#039;mod/mymod/scripts.js&#039;)-&amp;gt;in_head();&lt;br /&gt;
&lt;br /&gt;
// Loads the js file as soon as possible (from head, if that has&lt;br /&gt;
// not been output yet, otherwise output the script tag right here.)&lt;br /&gt;
echo $PAGE-&amp;gt;requires-&amp;gt;js(&#039;mod/mymod/scripts.js&#039;)-&amp;gt;asap();&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$PAGE-&amp;gt;requires keeps track of which files have been included, so even if two different pieces of code request the same library, it is only loaded once.&lt;br /&gt;
&lt;br /&gt;
===Getting Moodle to load YUI libraries===&lt;br /&gt;
&lt;br /&gt;
Because YUI is the official JavaScript library for Moodle, there  is a short cut syntax for loading the YUI libraries.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$PAGE-&amp;gt;requires-&amp;gt;yui_lib(&#039;autocomplete&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This knows about the dependencies between the JavaScript libraries, so the above code will actually load the five libraries yahoo, dom, event, datasource and autocomplete. It will also load the required CSS file autocomplete/assets/skins/sam/autocomplete.css.&lt;br /&gt;
&lt;br /&gt;
Because some YUI libraries rely on associated CSS, and because CSS can only be included in the &amp;amp;lt;head&amp;gt; section of the HTML, you should try to call $PAGE-&amp;gt;requires-&amp;gt;yui_lib before &amp;amp;lt;head&amp;gt; is output, if at all possible. If your code does try to require a YUI library after the header has been printed, and if that YUI library requires some CSS, and exception will be thrown explaining the problem, so you will know it happened.&lt;br /&gt;
&lt;br /&gt;
===JavaScript coding style===&lt;br /&gt;
&lt;br /&gt;
Moodle JavaScript code should should follow the same [[Development:Coding_style|coding style as Moodle PHP code]], allowing for the differences between PHP and JavaScript.&lt;br /&gt;
&lt;br /&gt;
For example, all the rules on &#039;&#039;function_names&#039;&#039;, &#039;&#039;class_names&#039;&#039; and &#039;&#039;variablenames&#039;&#039; apply. You should document your code with [http://jsdoc.sourceforge.net/ JSDoc] comments. Layout your JavaScript expressions and statements like the equivalent PHP ones.&lt;br /&gt;
&lt;br /&gt;
Normally, your .js files should simply define things like functions, classes and variables. When the file is loaded, no JavaScript code should actually be executed that has any effect unless it is the sort of code that can safely be executed once per HTML page. This is so that it plays nicely with the require_once-like behaviour of $PAGE-&amp;gt;requires-&amp;gt;js.&lt;br /&gt;
&lt;br /&gt;
Try to add as few things as possible to the global JavaScript name-space - use a few objects in the global name-space with properties and methods.&lt;br /&gt;
&lt;br /&gt;
(An extreme example of this practice is the YUI libraries which only add a single YAHOO object to the global scope and put everything inside that. Moodle code does not need to go to that extreme - and do not add Moodle-specific code to the YAHOO namespace!)&lt;br /&gt;
&lt;br /&gt;
===Activating your JavaScript===&lt;br /&gt;
&lt;br /&gt;
Since your .js files should not actually do anything when they are loaded, you need some way to trigger them into action. Normally the best way to do this is to put a simple inline script in the HTML that just calls an initialisation function. Typically, you want the HTML page you generate to look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code xml&amp;gt;&lt;br /&gt;
&amp;lt;!-- HTML code that will work with JavaScript disabled,&lt;br /&gt;
     perhaps with an id=&amp;quot;mything&amp;quot; attribute on the main HTML tag. --&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
    init_my_script(&#039;perhaps some data&#039;, &#039;for example&#039;, &#039;mything&#039;);&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The best way to generate this initialisation script is to use another feature of $PAGE-&amp;gt;requires:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$PAGE-&amp;gt;requires-&amp;gt;js_function_call(&#039;init_my_script&#039;,&lt;br /&gt;
        array(&#039;perhaps some data&#039;, &#039;for example&#039;, &#039;mything&#039;));&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Once again, by default the &amp;amp;lt;script&amp;gt; tag will be generated at the end of the HTML, but you can change that with modifiers like -&amp;gt;asap() or -&amp;gt;on_dom_ready() (which uses the YUI onDomReady event). Note that the data passed from PHP to JavaScript is automatically escaped using json_encode, so you can pass arrays, objects, and strings containing special characters without worrying.&lt;br /&gt;
&lt;br /&gt;
===Getting more variables from PHP to JavaScript===&lt;br /&gt;
&lt;br /&gt;
The arguments you pass to the initialisation function are one way to get specific data from your PHP code to your JavaScript. However, when you need to initialise several things on the page and they all need the same data, there is a better way:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$data = array(&lt;br /&gt;
    &#039;value1&#039; =&amp;gt; $value1,&lt;br /&gt;
    &#039;value2&#039; =&amp;gt; $value2,&lt;br /&gt;
);&lt;br /&gt;
$PAGE-&amp;gt;requires-&amp;gt;data_for_js(&#039;mymod_config&#039;, $data);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you do that, then in JavaScript, mymod_config.value1 will contain the value of the PHP variable $value1.&lt;br /&gt;
&lt;br /&gt;
===Getting language strings from PHP to JavaScript===&lt;br /&gt;
&lt;br /&gt;
One type of value you frequently need to get from PHP to JavaScript is the translation of some language strings into the current language. Because this is a common requirement, there is a special syntax for this:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
$PAGE-&amp;gt;requires-&amp;gt;string_for_js(&#039;tooltip&#039;, &#039;mymod&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
If you make this call, then the JavaScript variable mstr.mymod.tooltip will hold the value of get_string(&#039;tooltip&#039;, &#039;mymod&#039;).&lt;br /&gt;
&lt;br /&gt;
===Different in content when JavaScript is on or off===&lt;br /&gt;
&lt;br /&gt;
Remember the overriding principals that everything should work with JavaScript off, and we should adopt a [[Progressive enhancement]] approach. However, there are valid reasons why sometimes you need different content with JavaScript is on or off. We can break it down into three cases:&lt;br /&gt;
&lt;br /&gt;
====Content that should only be visible with JavaScript off====&lt;br /&gt;
&lt;br /&gt;
An example of this is the automatic search when you are looking for a user to assign a role to. With JavaScript on, the search automatically starts after a delay. With JavaScript off, we want an explicit Search button visible.&lt;br /&gt;
&lt;br /&gt;
To handle this case, Moodle automatically add a class &#039;jsenabled&#039; to the body tag using JavaScript. So you just need to add a rule like&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
body.jsenebled .mywidget .submitbutton {&lt;br /&gt;
    display: none;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
to the stylesheet, and the button will be invisible if JavaScript is enabled.&lt;br /&gt;
&lt;br /&gt;
An alternative strategy is to remove the particular bits of HTML from the page using DOM methods. However, if your JavaScript is only loaded at the end of the page, it may take some time for the extra content to disappear, which leads to a disconcerting flicker in the page.&lt;br /&gt;
&lt;br /&gt;
Yet another approach is the old-fashioned &amp;lt;noscript&amp;gt; tag.&lt;br /&gt;
&lt;br /&gt;
====Content that needs to be visible right away when JavaScript is on====&lt;br /&gt;
&lt;br /&gt;
An example is the &amp;lt;nowiki&amp;gt;[+] or [-]&amp;lt;/nowiki&amp;gt; icon that can be used to expand/collapse each block if JavaScript is on.&lt;br /&gt;
&lt;br /&gt;
We can divide this into two subcases:&lt;br /&gt;
&lt;br /&gt;
=====Content generated by PHP code=====&lt;br /&gt;
&lt;br /&gt;
Where the HTML for the JavaScript only widget is generated by PHP, we can make it invisible when JavaScript is off using just CSS:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.mywidget {&lt;br /&gt;
    display: none;&lt;br /&gt;
}&lt;br /&gt;
body.jsenabled .mywidget {&lt;br /&gt;
    display: block;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
However, it could be argued that this approach is not really progressive enhancement.&lt;br /&gt;
&lt;br /&gt;
=====Content generated by JavaScript code=====&lt;br /&gt;
&lt;br /&gt;
This is more in keeping with progressive enhancement, and this is the way that the expand/collapse block icon is handled.&lt;br /&gt;
&lt;br /&gt;
We build the icon using DOM methods. The only problem is that as the JavaScript is loaded in the footer, there is a small delay before the icons appear. Since when the icons appear, they do not cause other content on the page to move around, that is OK. Also, this delayed appearance is becoming more common on the web. For example, on http://twitter.com/, some things only appear a moment after the main part of the page has finished loading.&lt;br /&gt;
&lt;br /&gt;
However, it the delayed appearance is really a problem, then the only solution is to embed the JavaScript that generates the extra content in the middle of the HTML, using $PAGE-&amp;gt;requires-&amp;gt;js_function_call(...)-&amp;gt;now();.&lt;br /&gt;
&lt;br /&gt;
====Content that only appears when the user does something, when JavaScript is on====&lt;br /&gt;
&lt;br /&gt;
An example of this is something like file picker dialog that appears when you add an image to some content in the HTML editor, or the one that pops up when you click &#039;Add new question&#039; in the quiz editing interface.&lt;br /&gt;
&lt;br /&gt;
We have the same two sub-cases:&lt;br /&gt;
&lt;br /&gt;
=====Content generated by PHP code=====&lt;br /&gt;
&lt;br /&gt;
In this case, you need to make sure the content is always covered by a display: none; rule in the CSS, but then when the user takes an action like clicking a button to reveal the extra content, you need to override that class name some how, perhaps my adding or removing a className using JavaScript.&lt;br /&gt;
&lt;br /&gt;
=====Content generated by JavaScript code=====&lt;br /&gt;
&lt;br /&gt;
In this case, there is no problem. When the use triggers the extra content to appear, it is constructed using DOM methods. There may be a tiny delay, but the chances are that it will hardly be noticeable to the human eye.&lt;br /&gt;
&lt;br /&gt;
In the content generation may be slow (perhaps because it is waiting for an Ajax request) then you should display a progress icon. See, for example, the loading of the tooltip for help icons.&lt;br /&gt;
&lt;br /&gt;
===Don&#039;t break XHTML strict!===&lt;br /&gt;
&lt;br /&gt;
Remember that all Moodle output must be [[Development:XHTML|XHTML strict]], and that means that the HTML output must be well-formed XML. Inline JavaScript is a great way to break that. (JavaScript uses the &amp;lt; and &amp;amp; symbols that must be escaped in XML.) Therefore any JavaScript inline in the HTML should be escaped in a CDATA section:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code xml&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
//&amp;lt;![CDATA[&lt;br /&gt;
&lt;br /&gt;
   // Your JavaScript code goes here.&lt;br /&gt;
&lt;br /&gt;
//]]&amp;gt;&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Of course, if you are following the above guidelines and putting most of your JavaScript in separate .js files, and using $PAGE-&amp;gt;requiers-&amp;gt;js_function_call/string_for_js/data_for_js for the rest, then you do not need to worry about this section.&lt;br /&gt;
&lt;br /&gt;
==Testing==&lt;br /&gt;
&lt;br /&gt;
JavaScript support varies a lot between browsers. JavaScript needs to be tested in IE, Firefox and Safari. Ideally, Moodle will support [http://developer.yahoo.com/yui/articles/gbs/ all the browsers that YUI does].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Development:Coding|The rest of Moodle coding guidelines]]&lt;br /&gt;
* [http://developer.yahoo.com/yui/ YUI documentation]&lt;br /&gt;
* [[Javascript FAQ]]&lt;br /&gt;
* [[Development:Unobtrusive Javascript]]&lt;br /&gt;
* [[Development:JavaScript functions]]&lt;br /&gt;
* [http://developer.yahoo.com/performance/rules.html Yahoo&#039;s Best Practices for Speeding Up Your Web Site]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=106312 Forum thread for discussing this proposal]&lt;br /&gt;
&lt;br /&gt;
{{CategoryDeveloper}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Javascript|JavaScript guidelines]]&lt;br /&gt;
[[Category:AJAX|JavaScript guidelines]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:lib/formslib.php_Usage&amp;diff=63471</id>
		<title>Development:lib/formslib.php Usage</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:lib/formslib.php_Usage&amp;diff=63471"/>
		<updated>2009-09-23T07:22:34Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: spelling mistake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Formslib}}&lt;br /&gt;
==Usage of Formslib==&lt;br /&gt;
&lt;br /&gt;
There are many phpdoc style comments in lib/formslib.php&lt;br /&gt;
&lt;br /&gt;
course/edit.php and the included course/edit_form.php provide a good example of usage of this library.&lt;br /&gt;
&lt;br /&gt;
Also see the PEAR docs for [http://pear.php.net/package/HTML_QuickForm/ HTML_QuickForm docs] I found this [http://pear.php.net/manual/en/package.html.html-quickform.tutorial.php quick tutorial] and this [http://www.midnighthax.com/quickform.php slightly longer one] particularly useful.&lt;br /&gt;
&lt;br /&gt;
We created some special wrapper functions for moodle. $mform-&amp;gt;get_data() returns null if no data has been submitted or validation fails or returns an object with the contents of the submitted data.&lt;br /&gt;
&lt;br /&gt;
===Basic Usage in A Normal Page===&lt;br /&gt;
&lt;br /&gt;
Generally the structure of a page with a form on it looks like this :&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once(&#039;pathtoformdescription&#039;);&lt;br /&gt;
//you&#039;ll process some page parameters at the top here and get the info about&lt;br /&gt;
//what instance of your module and what course you&#039;re in etc. Make sure you&lt;br /&gt;
//include hidden variable in your forms which have their defaults set in set_data&lt;br /&gt;
//which pass these variables from page to page&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$mform = new yourmod_formfunction_form();//name of the form you defined in file above.&lt;br /&gt;
//default &#039;action&#039; for form is strip_querystring(qualified_me())&lt;br /&gt;
if ($mform-&amp;gt;is_cancelled()){&lt;br /&gt;
    //you need this section if you have a cancel button on your form&lt;br /&gt;
    //here you tell php what to do if your user presses cancel&lt;br /&gt;
    //probably a redirect is called for!&lt;br /&gt;
} else if ($fromform=$mform-&amp;gt;get_data()){&lt;br /&gt;
//this branch is where you process validated data.&lt;br /&gt;
&lt;br /&gt;
} else {&lt;br /&gt;
// this branch is executed if the form is submitted but the data doesn&#039;t validate and the form should be redisplayed&lt;br /&gt;
// or on the first display of the form.&lt;br /&gt;
    //setup strings for heading&lt;br /&gt;
    print_header_simple($streditinga, &#039;&#039;,&lt;br /&gt;
     &amp;quot;&amp;lt;a href=\&amp;quot;$CFG-&amp;gt;wwwroot/mod/$module-&amp;gt;name/index.php?id=$course-&amp;gt;id\&amp;quot;&amp;gt;$strmodulenameplural&amp;lt;/a&amp;gt; -&amp;gt;&lt;br /&gt;
     $strnav $streditinga&amp;quot;, $mform-&amp;gt;focus(), &amp;quot;&amp;quot;, false);&lt;br /&gt;
    //notice use of $mform-&amp;gt;focus() above which puts the cursor &lt;br /&gt;
    //in the first form field or the first field with an error.&lt;br /&gt;
&lt;br /&gt;
    //call to print_heading_with_help or print_heading? then :&lt;br /&gt;
    &lt;br /&gt;
    //put data you want to fill out in the form into array $toform here then :&lt;br /&gt;
&lt;br /&gt;
    $mform-&amp;gt;set_data($toform);&lt;br /&gt;
    $mform-&amp;gt;display();&lt;br /&gt;
    print_footer($course);&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Defining Your Form Class===&lt;br /&gt;
&lt;br /&gt;
The form class tells us about the structure of the form. You are encouraged to put this in a file called {function}_form.php probably in the same folder in which the page that uses it is located. The name of your class should be {modname}_{function}_form eg. forum_post_form or course_edit_form. These classes will extend class moodleform.&lt;br /&gt;
&lt;br /&gt;
Note the name you give the class is used as the id attribute of your form in html (any trailing &#039;_form&#039; is chopped off&#039;). Your form class name should be unique in order for it to selectable in CSS by theme designers who may want to tweak the css just for that form.&lt;br /&gt;
&lt;br /&gt;
====definition()====&lt;br /&gt;
&lt;br /&gt;
[[Development:lib/formslib.php_Form_Definition|Help is here for defining your form]] by defining a function definition() in your form class that sets up your form structure.&lt;br /&gt;
&lt;br /&gt;
===Use in Activity Modules Add / Update Forms===&lt;br /&gt;
&lt;br /&gt;
Syntax is the same in activity modules to create your update / add page. We are still supporting mod.html but if you want to use the new formslib then you can in Moodle 1.8 just include in your module directory the file mod_form.php instead of mod.html and it will be automatically detected. Inside this file you define a class with class name &#039;{modname}__mod_form&#039; which extends the class &#039;moodleform_mod&#039;. See many examples of the core modules which have been converted to use formslib already.&lt;br /&gt;
&lt;br /&gt;
====defaults_preprocessing====&lt;br /&gt;
&lt;br /&gt;
For activity modules you use the same syntax to define your form. You may also want to override method defaults_preprocessing this can be used to take the data from the data base and tell the form how to fill out defaults in the form with this data. For example in the forum module in forum/mod_form.php we needed to tick an enable check box if a date had been selected in the date select. Normally data is loaded from the database and directly loaded into form fields with the same name as the database record you only need to use defaults_preprocessing if there isn&#039;t this one to one relationship. Another example is the lesson/mod_form.php which takes the data from the database and unserializes it. choice/mod_form.php shows an exampe of loading data from another db table referred to by a foreign key, to include in the form.&lt;br /&gt;
&lt;br /&gt;
====Post Processing Still Done in lib.php Functions====&lt;br /&gt;
&lt;br /&gt;
Post processing of data is done in lib.php functions modname_add_instance and modname_update_instance after the data has been validated. When migrating a form often little changes need to be made in the post processing. An exception is that date and date_time_selector fields automatically have their submitted data turned into timestamps so you don&#039;t need to do this in your add and update functions anymore.&lt;br /&gt;
&lt;br /&gt;
====Automatically Including Standard Activity Module Form Elements====&lt;br /&gt;
&lt;br /&gt;
Standard activity module form elements are automatically included using the moodleform_mod method standard_coursemodule_elements(). The default is to include a visibility and groupsmode select box and to include all necessary hidden fields. You can pass a parameter false to tell the method that your module doesn&#039;t support groups and so you don&#039;t want the groupsmode select button.&lt;br /&gt;
&lt;br /&gt;
[[Category:Formslib]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:Blocks&amp;diff=63263</id>
		<title>Development:Blocks</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:Blocks&amp;diff=63263"/>
		<updated>2009-09-19T17:31:54Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: blank space deleted&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039; A Step-by-step Guide To Creating Blocks &#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Original Author: Jon Papaioannou (pj@moodle.org)&lt;br /&gt;
&lt;br /&gt;
The present document serves as a guide to developers who want to create their own blocks for use in Moodle. It applies to the 1.5 development version of Moodle (and any newer) &#039;&#039;&#039;only&#039;&#039;&#039;, as the blocks subsystem was rewritten and expanded for the 1.5 release. However, you can also find it useful if you want to modify blocks written for Moodle 1.3 and 1.4 to work with the latest versions (look at [[Development:Blocks/Appendix_B| Appendix B]]).&lt;br /&gt;
&lt;br /&gt;
The guide is written as an interactive course which aims to develop a configurable, multi-purpose block that displays arbitrary HTML. It&#039;s targeted mainly at people with little experience with Moodle or programming in general and aims to show how easy it is to create new blocks for Moodle. A certain small amount of PHP programming knowledge is still required, though. &lt;br /&gt;
&lt;br /&gt;
Experienced developers and those who just want a &#039;&#039;&#039;reference&#039;&#039;&#039; text should refer to [[Development:Blocks/Appendix_A| Appendix A]] because the main guide has a rather low concentration of pure information in the text.&lt;br /&gt;
&lt;br /&gt;
== Basic Concepts ==&lt;br /&gt;
&lt;br /&gt;
Through this guide, we will be following the creation of an &amp;quot;HTML&amp;quot; block from scratch in order to demonstrate most of the block features at our disposal. Our block will be named &amp;quot;SimpleHTML&amp;quot;. This does not constrain us regarding the name of the actual directory on the server where the files for our block will be stored, but for consistency we will follow the practice of using the lowercased form &amp;quot;simplehtml&amp;quot; in any case where such a name is required. &lt;br /&gt;
&lt;br /&gt;
Whenever we refer to a file or directory name which contains &amp;quot;simplehtml&amp;quot;, it&#039;s important to remember that &#039;&#039;only&#039;&#039; the &amp;quot;simplehtml&amp;quot; part is up to us to change; the rest is standardized and essential for Moodle to work correctly.&lt;br /&gt;
&lt;br /&gt;
Whenever a file&#039;s path is mentioned in this guide, it will always start with a slash. This refers to the Moodle home directory; all files and directories will be referred to with respect to that directory.&lt;br /&gt;
&lt;br /&gt;
== Ready, Set, Go! ==&lt;br /&gt;
&lt;br /&gt;
To define a &amp;quot;block&amp;quot; in Moodle, in the most basic case we need to provide just one source code file. We start by creating the directory &#039;&#039;/blocks/simplehtml/&#039;&#039; and creating a file named &#039;&#039;/blocks/simplehtml/&#039;&#039;&#039;&#039;&#039;block_simplehtml.php&#039;&#039;&#039; which will hold our code. We then begin coding the block:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
class block_simplehtml extends block_base {&lt;br /&gt;
  function init() {&lt;br /&gt;
    $this-&amp;gt;title   = get_string(&#039;simplehtml&#039;, &#039;block_simplehtml&#039;);&lt;br /&gt;
    $this-&amp;gt;version = 2004111200;&lt;br /&gt;
  }&lt;br /&gt;
  // The PHP tag and the curly bracket for the class definition &lt;br /&gt;
  // will only be closed after there is another function added in the next section.&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first line is our block class definition; it must be named exactly in the manner shown. Again, only the &amp;quot;simplehtml&amp;quot; part can (and indeed must) change; everything else is standardized.&lt;br /&gt;
&lt;br /&gt;
Our class is then given a small method: [[Development:Blocks/Appendix_A#init.28.29| init()]]. This is essential for all blocks, and its purpose is to set the two class member variables listed inside it. But what do these values actually mean? Here&#039;s a more detailed description.&lt;br /&gt;
&lt;br /&gt;
[[Development:Blocks/Appendix_A#.24this-.3Etitle| $this-&amp;gt;title]] is the title displayed in the header of our block. We can set it to whatever we like; in this case it&#039;s set to read the actual title from a language file we are presumably distributing together with the block. I &#039;ll skip ahead a bit here and say that if you want your block to display &#039;&#039;&#039;no&#039;&#039;&#039; title at all, then you should set this to any descriptive value you want (but &#039;&#039;&#039;not&#039;&#039;&#039; make it an empty string). We will later see [[Development:Blocks#Eye_Candy| how to disable the title&#039;s display]].&lt;br /&gt;
&lt;br /&gt;
[[Development:Blocks/Appendix_A#.24this-.3Eversion| $this-&amp;gt;version]] is the version of our block. This actually would only make a difference if your block wanted to keep its own data in special tables in the database (i.e. for very complex blocks). In that case the version number is used exactly as it&#039;s used in activities; an upgrade script uses it to incrementally upgrade an &amp;quot;old&amp;quot; version of the block&#039;s data to the latest. We will outline this process further ahead, since blocks tend to be relatively simple and not hold their own private data. &lt;br /&gt;
&lt;br /&gt;
In our example, this is certainly the case so we just set [[Development:Blocks/Appendix_A#.24this-.3Eversion| $this-&amp;gt;version]] to &#039;&#039;&#039;YYYYMMDD00&#039;&#039;&#039; and forget about it.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;UPDATING:&#039;&#039;&#039;&amp;lt;br /&amp;gt; &lt;br /&gt;
Prior to version 1.5, the basic structure of each block class was slightly different. Refer to [[Development:Blocks/Appendix_B| Appendix B]] for more information on the changes that old blocks have to make to conform to the new standard.&lt;br /&gt;
&lt;br /&gt;
== I Just Hear Static ==&lt;br /&gt;
In order to get our block to actually display something on screen, we need to add one more method to our class (before the final closing brace in our file). The new code is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;  &lt;br /&gt;
  function get_content() {&lt;br /&gt;
    if ($this-&amp;gt;content !== NULL) {&lt;br /&gt;
      return $this-&amp;gt;content;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    $this-&amp;gt;content         =  new stdClass;&lt;br /&gt;
    $this-&amp;gt;content-&amp;gt;text   = &#039;The content of our SimpleHTML block!&#039;;&lt;br /&gt;
    $this-&amp;gt;content-&amp;gt;footer = &#039;Footer here...&#039;;&lt;br /&gt;
 &lt;br /&gt;
    return $this-&amp;gt;content;&lt;br /&gt;
  }&lt;br /&gt;
}   // Here&#039;s the closing curly bracket for the class definition&lt;br /&gt;
    // and here&#039;s the closing PHP tag from the section above.&lt;br /&gt;
?&amp;gt;  &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It can&#039;t get any simpler than that, can it? Let&#039;s dissect this method to see what&#039;s going on...&lt;br /&gt;
&lt;br /&gt;
First of all, there is a check that returns the current value of [[Development:Blocks/Appendix_A#.24this-.3Econtent| $this-&amp;gt;content]] if it&#039;s not NULL; otherwise we proceed with &amp;quot;computing&amp;quot; it. Since the computation is potentially a time-consuming operation and it &#039;&#039;&#039;will&#039;&#039;&#039; be called several times for each block (Moodle works that way internally), we take a precaution and include this time-saver.&lt;br /&gt;
Supposing the content had not been computed before (it was NULL), we then define it from scratch. The code speaks for itself there, so there isn&#039;t much to say. Just keep in mind that we can use HTML both in the text &#039;&#039;&#039;and&#039;&#039;&#039; in the footer, if we want to.&lt;br /&gt;
&lt;br /&gt;
At this point our block should be capable of being automatically installed in Moodle and added to courses; visit your administration page to install it (Click &amp;quot;Notifications&amp;quot; under the Site Administration Block) and after seeing it in action come back to continue our tutorial.&lt;br /&gt;
&lt;br /&gt;
== Configure That Out ==&lt;br /&gt;
&lt;br /&gt;
The current version of our block doesn&#039;t really do much; it just displays a fixed message, which is not very useful. What we &#039;d really like to do is allow the teachers to customize what goes into the block. This, in block-speak, is called &amp;quot;instance configuration&amp;quot;. So let&#039;s give our block some instance configuration...&lt;br /&gt;
First of all, we need to tell Moodle that we want it to provide instance-specific configuration amenities to our block. That&#039;s as simple as adding one more method to our block class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function instance_allow_config() {&lt;br /&gt;
  return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This small change is enough to make Moodle display an &amp;quot;Edit...&amp;quot; icon in our block&#039;s header when we turn editing mode on in any course. However, if you try to click on that icon you will be presented with a notice that complains about the block&#039;s configuration not being implemented correctly. Try it, it&#039;s harmless.&lt;br /&gt;
Moodle&#039;s complaints do make sense. We told it that we want to have configuration, but we didn&#039;t say &#039;&#039;what&#039;&#039; kind of configuration we want, or how it should be displayed. To do that, we need to create one more file: &amp;lt;span class=&amp;quot;filename&amp;quot;&amp;gt;/blocks/simplehtml/&#039;&#039;&#039;config_instance.html&#039;&#039;&#039;&amp;lt;/span&amp;gt; (which has to be named exactly like that). For the moment, copy paste the following into it and save:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;table cellpadding=&amp;quot;9&amp;quot; cellspacing=&amp;quot;0&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;tr valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;td align=&amp;quot;right&amp;quot;&amp;gt;&lt;br /&gt;
       &amp;lt;?php print_string(&#039;configcontent&#039;, &#039;block_simplehtml&#039;); ?&amp;gt;:&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
    &amp;lt;td&amp;gt;&lt;br /&gt;
       &amp;lt;?php print_textarea(true, 10, 50, 0, 0, &#039;text&#039;, $this-&amp;gt;config-&amp;gt;text); ?&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
  &amp;lt;tr&amp;gt;&lt;br /&gt;
    &amp;lt;td colspan=&amp;quot;2&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;&amp;lt;?php print_string(&#039;savechanges&#039;) ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;?php use_html_editor(); ?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It isn&#039;t difficult to see that the above code just provides us with a wysiwyg-editor-enabled textarea to write our block&#039;s desired content in and a submit button to save. But... what&#039;s $this-&amp;gt;config-&amp;gt;text? Well...&lt;br /&gt;
Moodle goes a long way to make things easier for block developers. Did you notice that the textarea is actually named &amp;quot;text&amp;quot;? When the submit button is pressed, Moodle saves each and every field it can find in our &#039;&#039;&#039;config_instance.html&#039;&#039;&#039; file as instance configuration data. &lt;br /&gt;
&lt;br /&gt;
We can then access that data as &#039;&#039;&#039;$this-&amp;gt;config-&amp;gt;&#039;&#039;variablename&#039;&#039;&#039;&#039;&#039;, where &#039;&#039;variablename&#039;&#039; is the actual name we used for our field; in this case, &amp;quot;text&amp;quot;. So in essence, the above form just pre-populates the textarea with the current content of the block (as indeed it should) and then allows us to change it.&lt;br /&gt;
&lt;br /&gt;
You also might be surprised by the presence of a submit button and the absence of any &amp;lt;form&amp;gt; element at the same time. But the truth is, we don&#039;t need to worry about that at all; Moodle goes a really long way to make things easier for developers! We just print the configuration options we want, in any format we want; include a submit button, and Moodle will handle all the rest itself. The instance configuration variables are automatically at our disposal to access from any of the class methods &#039;&#039;except&#039;&#039; [[Development:Blocks/Appendix_A#init.28.29| init()]].&lt;br /&gt;
&lt;br /&gt;
In the event where the default behavior is not satisfactory, we can still override it. However, this requires advanced modifications to our block class and will not be covered here; refer to [[Development:Blocks/Appendix_A| Appendix A]] for more details.&lt;br /&gt;
Having now the ability to refer to this instance configuration data through [[Development:Blocks/Appendix_A#.24this-.3Econfig| $this-&amp;gt;config]], the final twist is to tell our block to actually &#039;&#039;display&#039;&#039; what is saved in its configuration data. To do that, find this snippet in &#039;&#039;/blocks/simplehtml/block_simplehtml.php&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
 $this-&amp;gt;content = new stdClass;&lt;br /&gt;
 $this-&amp;gt;content-&amp;gt;text   = &#039;The content of our SimpleHTML block!&#039;;&lt;br /&gt;
 $this-&amp;gt;content-&amp;gt;footer = &#039;Footer here...&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
 $this-&amp;gt;content = new stdClass;&lt;br /&gt;
 $this-&amp;gt;content-&amp;gt;text   = $this-&amp;gt;config-&amp;gt;text;&lt;br /&gt;
 $this-&amp;gt;content-&amp;gt;footer = &#039;Footer here...&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Oh, and since the footer isn&#039;t really exciting at this point, we remove it from our block because it doesn&#039;t contribute anything. We could just as easily have decided to make the footer configurable in the above way, too. So for our latest code, the snippet becomes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
 $this-&amp;gt;content = new stdClass;&lt;br /&gt;
 $this-&amp;gt;content-&amp;gt;text   = $this-&amp;gt;config-&amp;gt;text;&lt;br /&gt;
 $this-&amp;gt;content-&amp;gt;footer = &#039;&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After this discussion, our block is ready for prime time! Indeed, if you now visit any course with a SimpleHTML block, you will see that modifying its contents is now a snap.&lt;br /&gt;
&lt;br /&gt;
[[#top|Back to top of page]]&lt;br /&gt;
&lt;br /&gt;
== The Specialists ==&lt;br /&gt;
&lt;br /&gt;
Implementing instance configuration for the block&#039;s contents was good enough to whet our appetite, but who wants to stop there? Why not customize the block&#039;s title, too?&lt;br /&gt;
&lt;br /&gt;
Why not, indeed. Well, our first attempt to achieve this is natural enough: let&#039;s add another field to &amp;lt;span class=&amp;quot;filename&amp;quot;&amp;gt;/blocks/simplehtml/config_instance.html&amp;lt;/span&amp;gt;. Here goes:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;tr valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;td align=&amp;quot;right&amp;quot;&amp;gt;&amp;lt;p&amp;gt;&lt;br /&gt;
    &amp;lt;?php print_string(&#039;configtitle&#039;, &#039;block_simplehtml&#039;); ?&amp;gt;:&amp;lt;/p&amp;gt;&lt;br /&gt;
  &amp;lt;/td&amp;gt;&lt;br /&gt;
  &amp;lt;td&amp;gt;&lt;br /&gt;
    &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;title&amp;quot; size=&amp;quot;30&amp;quot; value=&amp;quot;&amp;lt;?php echo $this-&amp;gt;config-&amp;gt;title; ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
  &amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We save the edited file, go to a course, edit the title of the block and... nothing happens! The instance configuration is saved correctly, all right (editing it once more proves that) but it&#039;s not being displayed. All we get is just the simple &amp;quot;SimpleHTML&amp;quot; title.&lt;br /&gt;
&lt;br /&gt;
That&#039;s not too weird, if we think back a bit. Do you remember that [[Development:Blocks/Appendix_A#init.28.29|init()]] method, where we set [[Development:Blocks/Appendix_A#.24this-.3Etitle|$this-&amp;gt;title]]? We didn&#039;t actually change its value from then, and [[Development:Blocks/Appendix_A#.24this-.3Etitle|$this-&amp;gt;title]] is definitely not the same as &#039;&#039;&#039;$this-&amp;gt;config-&amp;gt;title&#039;&#039;&#039; (to Moodle, at least). What we need is a way to update [[Development:Blocks/Appendix_A#.24this-.3Etitle|$this-&amp;gt;title]] with the value in the instance configuration. But as we said a bit earlier, we can use [[Development:Blocks/Appendix_A#.24this-.3Econfig| $this-&amp;gt;config]] in all methods &#039;&#039;except&#039;&#039; [[Development:Blocks/Appendix_A#init.28.29|init()]]! So what can we do?&lt;br /&gt;
&lt;br /&gt;
Let&#039;s pull out another ace from our sleeve, and add this small method to our block class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function specialization() {&lt;br /&gt;
  if(!empty($this-&amp;gt;config-&amp;gt;title)){&lt;br /&gt;
    $this-&amp;gt;title = $this-&amp;gt;config-&amp;gt;title;&lt;br /&gt;
  }else{&lt;br /&gt;
    $this-&amp;gt;config-&amp;gt;title = &#039;Some title ...&#039;;&lt;br /&gt;
  }&lt;br /&gt;
  if(empty($this-&amp;gt;config-&amp;gt;text)){&lt;br /&gt;
    $this-&amp;gt;config-&amp;gt;text = &#039;Some text ...&#039;;&lt;br /&gt;
  }    &lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Aha, here&#039;s what we wanted to do all along! But what&#039;s going on with the [[Development:Blocks/Appendix_A#specialization.28.29| specialization()]] method?&lt;br /&gt;
&lt;br /&gt;
This &amp;quot;magic&amp;quot; method has actually a very nice property: it&#039;s &#039;&#039;guaranteed&#039;&#039; to be automatically called by Moodle as soon as our instance configuration is loaded and available (that is, immediately after [[Development:Blocks/Appendix_A#init.28.29|init()]] is called). That means before the block&#039;s content is computed for the first time, and indeed before &#039;&#039;anything&#039;&#039; else is done with the block. Thus, providing a [[Development:Blocks/Appendix_A#specialization.28.29| specialization()]] method is the natural choice for any configuration data that needs to be acted upon &amp;quot;as soon as possible&amp;quot;, as in this case.&lt;br /&gt;
&lt;br /&gt;
== Now You See Me, Now You Don&#039;t ==&lt;br /&gt;
&lt;br /&gt;
Now would be a good time to mention another nifty technique that can be used in blocks, and which comes in handy quite often. Specifically, it may be the case that our block will have something interesting to display some of the time; but in some other cases, it won&#039;t have anything useful to say. (An example here would be the &amp;quot;Recent Activity&amp;quot; block, in the case where no recent activity in fact exists. &lt;br /&gt;
&lt;br /&gt;
However in that case the block chooses to explicitly inform you of the lack of said activity, which is arguably useful). It would be nice, then, to be able to have our block &amp;quot;disappear&amp;quot; if it&#039;s not needed to display it.&lt;br /&gt;
&lt;br /&gt;
This is indeed possible, and the way to do it is to make sure that after the [[Development:Blocks/Appendix_A#get_content.28.29| get_content()]] method is called, the block is completely void of content. Specifically, &amp;quot;void of content&amp;quot; means that both $this-&amp;gt;content-&amp;gt;text and $this-&amp;gt;content-&amp;gt;footer are each equal to the empty string (&amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;). Moodle performs this check by calling the block&#039;s [[Development:Blocks/Appendix_A#is_empty.28.29| is_empty()]] method, and if the block is indeed empty then it is not displayed at all.&lt;br /&gt;
&lt;br /&gt;
Note that the exact value of the block&#039;s title and the presence or absence of a [[Development:Blocks/Appendix_A#hide_header.28.29| hide_header()]] method do &#039;&#039;not&#039;&#039; affect this behavior. A block is considered empty if it has no content, irrespective of anything else.&lt;br /&gt;
&lt;br /&gt;
== We Are Legion ==&lt;br /&gt;
&lt;br /&gt;
Right now our block is fully configurable, both in title and content. It&#039;s so versatile, in fact, that we could make pretty much anything out of it. It would be really nice to be able to add multiple blocks of this type to a single course. And, as you might have guessed, doing that is as simple as adding another small method to our block class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function instance_allow_multiple() {&lt;br /&gt;
  return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This tells Moodle that it should allow any number of instances of the SimpleHTML block in any course. After saving the changes to our file, Moodle immediately allows us to add multiple copies of the block without further ado!&lt;br /&gt;
&lt;br /&gt;
There are a couple more of interesting points to note here. First of all, even if a block itself allows multiple instances in the same page, the administrator still has the option of disallowing such behavior. This setting can be set separately for each block from the Administration / Configuration / Blocks page.&lt;br /&gt;
&lt;br /&gt;
And finally, a nice detail is that as soon as we defined an [[Development:Blocks/Appendix_A#instance_allow_multiple.28.29| instance_allow_multiple()]] method, the method [[Development:Blocks/Appendix_A#instance_allow_config.28.29| instance_allow_config()]] that was already defined became obsolete. &lt;br /&gt;
&lt;br /&gt;
Moodle assumes that if a block allows multiple instances of itself, those instances will want to be configured (what is the point of same multiple instances in the same page if they are identical?) and thus automatically provides an &amp;quot;Edit&amp;quot; icon. So, we can also remove the whole [[Development:Blocks/Appendix_A#instance_allow_config.28.29| instance_allow_config()]] method now without harm. We had only needed it when multiple instances of the block were not allowed.&lt;br /&gt;
&lt;br /&gt;
[[#top|Back to top of page]]&lt;br /&gt;
&lt;br /&gt;
== The Effects of Globalization ==&lt;br /&gt;
&lt;br /&gt;
Configuring each block instance with its own personal data is cool enough, but sometimes administrators need some way to &amp;quot;touch&amp;quot; all instances of a specific block at the same time. In the case of our SimpleHTML block, a few settings that would make sense to apply to all instances aren&#039;t that hard to come up with. &lt;br /&gt;
&lt;br /&gt;
For example, we might want to limit the contents of each block to only so many characters, or we might have a setting that filters HTML out of the block&#039;s contents, only allowing pure text in. Granted, such a feature wouldn&#039;t win us any awards for naming our block &amp;quot;SimpleHTML&amp;quot; but some tormented administrator somewhere might actually find it useful.&lt;br /&gt;
&lt;br /&gt;
This kind of configuration is called &amp;quot;global configuration&amp;quot; and applies only to a specific block type (all instances of that block type are affected, however). Implementing such configuration for our block is quite similar to implementing the instance configuration. We will now see how to implement the second example, having a setting that only allows text and not HTML in the block&#039;s contents.&lt;br /&gt;
First of all, we need to tell Moodle that we want our block to provide global configuration by, what a surprise, adding a small method to our block class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt; &lt;br /&gt;
function has_config() {&lt;br /&gt;
  return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, we need to create a HTML file that actually prints out the configuration screen. In our case, we &#039;ll just print out a checkbox saying &amp;quot;Do not allow HTML in the content&amp;quot; and a &amp;quot;submit&amp;quot; button. Let&#039;s create the file &amp;lt;span class=&amp;quot;filename&amp;quot;&amp;gt;/blocks/simplehtml/config_global.html&amp;lt;/span&amp;gt; which again must be named just so, and copy paste the following into it:&lt;br /&gt;
&lt;br /&gt;
[[Development_talk:Blocks|TODO: New settings.php method]] &lt;br /&gt;
: Just to note that general documentation about admin settings is at [[Development:Admin_settings#Individual_settings]]. In the absence of documentation, you can look at blocks/course_list, blocks/online_users and blocks/rss_client. They all use a settings.php file.--[[User:Tim Hunt|Tim Hunt]] 19:38, 28 January 2009 (CST)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;text-align: center;&amp;quot;&amp;gt;&lt;br /&gt;
 &amp;lt;input type=&amp;quot;hidden&amp;quot; name=&amp;quot;block_simplehtml_strict&amp;quot; value=&amp;quot;0&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;input type=&amp;quot;checkbox&amp;quot; name=&amp;quot;block_simplehtml_strict&amp;quot; value=&amp;quot;1&amp;quot;&lt;br /&gt;
   &amp;lt;?php if(!empty($CFG-&amp;gt;block_simplehtml_strict)) &lt;br /&gt;
             echo &#039;checked=&amp;quot;checked&amp;quot;&#039;; ?&amp;gt; /&amp;gt;&lt;br /&gt;
   &amp;lt;?php print_string(&#039;donotallowhtml&#039;, &#039;block_simplehtml&#039;); ?&amp;gt;&lt;br /&gt;
 &amp;lt;p&amp;gt;&lt;br /&gt;
 &amp;lt;input type=&amp;quot;submit&amp;quot; value=&amp;quot;&amp;lt;?php print_string(&#039;savechanges&#039;); ?&amp;gt;&amp;quot; /&amp;gt;&lt;br /&gt;
 &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
True to our block&#039;s name, this looks simple enough. What it does is that it displays a checkbox named &amp;quot;block_simplehtml_strict&amp;quot; and if the Moodle configuration variable with the same name (i.e., $CFG-&amp;gt;block_simplehtml_strict) is set and not empty (that means it&#039;s not equal to an empty string, to zero, or to boolean FALSE) it displays the box as pre-checked (reflecting the current status). &lt;br /&gt;
&lt;br /&gt;
Why does it check the configuration setting with the same name? Because the default implementation of the global configuration saving code takes all the variables we have in our form and saves them as Moodle configuration options with the same name. Thus, it&#039;s good practice to use a descriptive name and also one that won&#039;t possibly conflict with the name of another setting. &lt;br /&gt;
&lt;br /&gt;
&amp;quot;block_simplehtml_strict&amp;quot; clearly satisfies both requirements.&lt;br /&gt;
&lt;br /&gt;
The astute reader may have noticed that we actually have &#039;&#039;two&#039;&#039; input fields named &amp;quot;block_simplehtml_strict&amp;quot; in our configuration file. One is hidden and its value is always 0; the other is the checkbox and its value is 1. What gives? Why have them both there?&lt;br /&gt;
&lt;br /&gt;
Actually, this is a small trick we use to make our job as simple as possible. HTML forms work this way: if a checkbox in a form is not checked, its name does not appear at all in the variables passed to PHP when the form is submitted. That effectively means that, when we uncheck the box and click submit, the variable is not passed to PHP at all. Thus, PHP does not know to update its value to &amp;quot;0&amp;quot;, and our &amp;quot;strict&amp;quot; setting cannot be turned off at all once we turn it on for the first time. Not the behavior we want, surely.&lt;br /&gt;
&lt;br /&gt;
However, when PHP handles received variables from a form, the variables are processed in the order in which they appear in the form. If a variable comes up having the same name with an already-processed variable, the new value overwrites the old one. Taking advantage of this, our logic runs as follows: the variable &amp;quot;block_simplehtml_strict&amp;quot; is first unconditionally set to &amp;quot;0&amp;quot;. Then, &#039;&#039;if&#039;&#039; the box is checked, it is set to &amp;quot;1&amp;quot;, overwriting the previous value as discussed. The net result is that our configuration setting behaves as it should.&lt;br /&gt;
&lt;br /&gt;
To round our bag of tricks up, notice that the use of &#039;&#039;if(!empty($CFG-&amp;gt;block_simplehtml_strict))&#039;&#039; in the test for &amp;quot;should the box be checked by default?&amp;quot; is quite deliberate. The first time this script runs, the variable &#039;&#039;&#039;$CFG-&amp;gt;block_simplehtml_strict&#039;&#039;&#039; will not exist at all. After it&#039;s set for the first time, its value can be either &amp;quot;0&amp;quot; or &amp;quot;1&amp;quot;. Given that both &amp;quot;not set&amp;quot; and the string &amp;quot;0&amp;quot; evaluate as empty while the sting &amp;quot;1&amp;quot; does not, we manage to avoid any warnings from PHP regarding the variable not being set at all, &#039;&#039;and&#039;&#039; have a nice human-readable representation for its two possible values (&amp;quot;0&amp;quot; and &amp;quot;1&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
=== config_save() ===&lt;br /&gt;
&lt;br /&gt;
Now that we have managed to cram a respectable amount of tricks into a few lines of HTML, we might as well discuss the alternative in case that tricks are not enough for a specific configuration setup we have in mind. Saving the data is done in the method [[Development:Blocks/Appendix_A#config_save.28.29| config_save()]], the default implementation of which is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt; &lt;br /&gt;
function config_save($data) {&lt;br /&gt;
  // Default behavior: save all variables as $CFG properties&lt;br /&gt;
  foreach ($data as $name =&amp;gt; $value) {&lt;br /&gt;
    set_config($name, $value);&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;
As can be clearly seen, Moodle passes this method an associative array $data which contains all the variables coming in from our configuration screen. If we wanted to do the job without the &amp;quot;hidden variable with the same name&amp;quot; trick we used above, one way to do it would be by overriding this method with the following:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function config_save($data) {&lt;br /&gt;
  if(isset($data[&#039;block_simplehtml_strict&#039;])) {&lt;br /&gt;
    set_config(&#039;block_simplehtml_strict&#039;, &#039;1&#039;);&lt;br /&gt;
  }else {&lt;br /&gt;
    set_config(&#039;block_simplehtml_strict&#039;, &#039;0&#039;);&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;
Quite straightfoward: if the variable &amp;quot;block_simplehtml_strict&amp;quot; is passed to us, then it can only mean that the user has checked it, so set the configuration variable with the same name to &amp;quot;1&amp;quot;. Otherwise, set it to &amp;quot;0&amp;quot;. Of course, this version would need to be updated if we add more configuration options because it doesn&#039;t respond to them as the default implementation does. Still, it&#039;s useful to know how we can override the default implementation if it does not fit our needs (for example, we might not want to save the variable as part of the Moodle configuration but do something else with it).&lt;br /&gt;
&lt;br /&gt;
So, we are now at the point where we know if the block should allow HTML tags in its content or not. How do we get the block to actually respect that setting?&lt;br /&gt;
&lt;br /&gt;
We could decide to do one of two things: either have the block &amp;quot;clean&amp;quot; HTML out from the input before saving it in the instance configuration and then display it as-is (the &amp;quot;eager&amp;quot; approach); or have it save the data &amp;quot;as is&amp;quot; and then clean it up each time just before displaying it (the &amp;quot;lazy&amp;quot; approach). The eager approach involves doing work once when saving the configuration; the lazy approach means doing work each time the block is displayed and thus it promises to be worse performance-wise. We shall hence go with the eager approach.&lt;br /&gt;
&lt;br /&gt;
[[#top|Back to top of page]]&lt;br /&gt;
&lt;br /&gt;
=== instance_config_save() ===&lt;br /&gt;
&lt;br /&gt;
Much as we did just before with overriding [[Development:Blocks/Appendix_A#config_save.28.29| config_save()]], what is needed here is overriding the method [[Development:Blocks/Appendix_A#instance_config_save.28.29| instance_config_save()]] which handles the instance configuration. The default implementation is as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function instance_config_save($data) {&lt;br /&gt;
  $data = stripslashes_recursive($data);&lt;br /&gt;
  $this-&amp;gt;config = $data;&lt;br /&gt;
  return set_field(&#039;block_instance&#039;, &lt;br /&gt;
                   &#039;configdata&#039;,&lt;br /&gt;
                    base64_encode(serialize($data)),&lt;br /&gt;
                   &#039;id&#039;, &lt;br /&gt;
                   $this-&amp;gt;instance-&amp;gt;id);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This may look intimidating at first (what&#039;s all this stripslashes_recursive() and base64_encode() and serialize() stuff?) but do not despair; we won&#039;t have to touch any of it. We will only add some extra validation code in the beginning and then instruct Moodle to additionally call this default implementation to do the actual storing of the data. Specifically, we will add a method to our class which goes like this:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function instance_config_save($data) {&lt;br /&gt;
  // Clean the data if we have to&lt;br /&gt;
  global $CFG;&lt;br /&gt;
  if(!empty($CFG-&amp;gt;block_simplehtml_strict)) {&lt;br /&gt;
    $data-&amp;gt;text = strip_tags($data-&amp;gt;text);&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
  // And now forward to the default implementation defined in the parent class&lt;br /&gt;
  return parent::instance_config_save($data);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
At last! Now the administrator has absolute power of life and death over what type of content is allowed in our &amp;quot;SimpleHTML&amp;quot; block! Absolute? Well... not exactly. In fact, if we think about it for a while, it will become apparent that if at some point in time HTML is allowed and some blocks have saved their content with HTML included, and afterwards the administrator changes the setting to &amp;quot;off&amp;quot;, this will only prevent subsequent content changes from including HTML. Blocks which already had HTML in their content would continue to display it!&lt;br /&gt;
&lt;br /&gt;
Following that train of thought, the next stop is realizing that we wouldn&#039;t have this problem if we had chosen the lazy approach a while back, because in that case we would &amp;quot;sanitize&amp;quot; each block&#039;s content just before it was displayed. &lt;br /&gt;
&lt;br /&gt;
The only thing we can do with the eager approach is strip all the tags from the content of all SimpleHTML instances as soon as the admin setting is changed to &amp;quot;HTML off&amp;quot;; but even then, turning the setting back to &amp;quot;HTML on&amp;quot; won&#039;t bring back the tags we stripped away. On the other hand, the lazy approach might be slower, but it&#039;s more versatile; we can choose whether to strip or keep the HTML before displaying the content, and we won&#039;t lose it at all if the admin toggles the setting off and on again. Isn&#039;t the life of a developer simple and wonderful?&lt;br /&gt;
&lt;br /&gt;
=== Exercise === &lt;br /&gt;
We will let this part of the tutorial come to a close with the obligatory exercise for the reader: &lt;br /&gt;
In order to have the SimpleHTML block work &amp;quot;correctly&amp;quot;, find out how to strengthen the eager approach to strip out all tags from the existing configuration of all instances of our block, &#039;&#039;&#039;or&#039;&#039;&#039; go back and implement the lazy approach instead. &lt;br /&gt;
(Hint: Do that in the [[Development:Blocks/Appendix_A#get_content.28.29| get_content()]] method.)&lt;br /&gt;
&lt;br /&gt;
=== UPDATING: === &lt;br /&gt;
Prior to version 1.5, the file &#039;&#039;config_global.html&#039;&#039; was named simply &#039;&#039;config.html&#039;&#039;. Also, the methods [[Blocks_Howto#method_config_save| config_save]] and [[Blocks_Howto#method_config_print| config_print]] were named &#039;&#039;&#039;handle_config&#039;&#039;&#039; and &#039;&#039;&#039;print_config&#039;&#039;&#039; respectively. Upgrading a block to work with Moodle 1.5 involves updating these aspects; refer to [[Blocks_Howto#appendix_b| Appendix B]] for more information.&lt;br /&gt;
&lt;br /&gt;
== Eye Candy ==&lt;br /&gt;
&lt;br /&gt;
Our block is just about complete functionally, so now let&#039;s take a look at some of the tricks we can use to make its behavior customized in a few more useful ways.&lt;br /&gt;
&lt;br /&gt;
First of all, there are a couple of ways we can adjust the visual aspects of our block. For starters, it might be useful to create a block that doesn&#039;t display a header (title) at all. You can see this effect in action in the Course Description block that comes with Moodle. This behavior is achieved by, you guessed it, adding one more method to our block class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function hide_header() {&lt;br /&gt;
  return true;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One more note here: we cannot just set an empty title inside the block&#039;s [[Development:Blocks/Appendix_A#init.28.29| init()]] method; it&#039;s necessary for each block to have a unique, non-empty title after [[Development:Blocks/Appendix_A#init.28.29| init()]] is called so that Moodle can use those titles to differentiate between all of the installed blocks.&lt;br /&gt;
&lt;br /&gt;
Another adjustment we might want to do is instruct our block to take up a certain amount of width on screen. Moodle handles this as a two-part process: first, it queries each block about its preferred width and takes the maximum number as the desired value. Then, the page that&#039;s being displayed can choose to use this value or, more probably, bring it within some specific range of values if it isn&#039;t already. That means that the width setting is a best-effort settlement; your block can &#039;&#039;request&#039;&#039; a certain width and Moodle will &#039;&#039;try&#039;&#039; to provide it, but there&#039;s no guarantee whatsoever about the end result. As a concrete example, all standard Moodle course formats will deliver any requested width between 180 and 210 pixels, inclusive.&lt;br /&gt;
&lt;br /&gt;
To instruct Moodle about our block&#039;s preferred width, we add one more method to the block class:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function preferred_width() {&lt;br /&gt;
  // The preferred value is in pixels&lt;br /&gt;
  return 200;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
This will make our block (and all the other blocks displayed at the same side of the page) a bit wider than standard.&lt;br /&gt;
&lt;br /&gt;
Finally, we can also affect some properties of the actual HTML that will be used to print our block. Each block is fully contained within a &amp;amp;lt;table&amp;amp;gt; element, inside which all the HTML for that block is printed. We can instruct Moodle to add HTML attributes with specific values to that container. This would be done to either a) directly affect the end result (if we say, assign bgcolor=&amp;quot;black&amp;quot;), or b) give us freedom to customize the end result using CSS (this is in fact done by default as we&#039;ll see below).&lt;br /&gt;
&lt;br /&gt;
The default behavior of this feature in our case will assign to our block&#039;s container the class HTML attribute with the value &amp;quot;sideblock block_simplehtml&amp;quot; (the prefix &amp;quot;block_&amp;quot; followed by the name of our block, lowercased). We can then use that class to make CSS selectors in our theme to alter this block&#039;s visual style (for example, &amp;quot;.sideblock.block_simplehtml { border: 1px black solid}&amp;quot;).&lt;br /&gt;
&lt;br /&gt;
To change the default behavior, we will need to define a method which returns an associative array of attribute names and values. For example, the version&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function html_attributes() {&lt;br /&gt;
  return array(&lt;br /&gt;
    &#039;class&#039;       =&amp;gt; &#039;sideblock block_&#039;. $this-&amp;gt;name(),&lt;br /&gt;
    &#039;onmouseover&#039; =&amp;gt; &amp;quot;alert(&#039;Mouseover on our block!&#039;);&amp;quot;&lt;br /&gt;
  );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will result in a mouseover event being added to our block using JavaScript, just as if we had written the onmouseover=&amp;quot;alert(...)&amp;quot; part ourselves in HTML. Note that we actually duplicate the part which sets the class attribute (we want to keep that, and since we override the default behavior it&#039;s our responsibility to emulate it if required). &lt;br /&gt;
&lt;br /&gt;
And the final elegant touch is that we don&#039;t set the class to the hard-coded value &amp;quot;block_simplehtml&amp;quot; but instead use the [[Development:Blocks/Appendix_A#name.28.29| name()]] method to make it dynamically match our block&#039;s name.&lt;br /&gt;
&lt;br /&gt;
===and some other useful examples too:===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function html_attributes() {&lt;br /&gt;
    // Default case: an id with the instance and a class with our name in it&lt;br /&gt;
    return array(&#039;id&#039; =&amp;gt; &#039;inst&#039;.$this-&amp;gt;instance-&amp;gt;id, &#039;class&#039; =&amp;gt; &#039;block_&#039;. $this-&amp;gt;name());&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This method should return an associative array of HTML attributes that will be given to your block&#039;s container element when Moodle constructs the output HTML. No sanitization will be performed in these elements at all.&lt;br /&gt;
&lt;br /&gt;
If you intend to override this method, you should return the default attributes as well as those you add yourself. The recommended way to do this is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function html_attributes() {&lt;br /&gt;
    $attrs = parent::html_attributes();&lt;br /&gt;
    // Add your own attributes here, e.g.&lt;br /&gt;
    // $attrs[&#039;width&#039;] = &#039;50%&#039;;&lt;br /&gt;
    return $attrs;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Authorized Personnel Only ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s not difficult to imagine a block which is very useful in some circumstances but it simply cannot be made meaningful in others. An example of this would be the &amp;quot;Social Activities&amp;quot; block which is indeed useful in a course with the social format, but doesn&#039;t do anything useful in a course with the weeks format. There should be some way of allowing the use of such blocks only where they are indeed meaningful, and not letting them confuse users if they are not.&lt;br /&gt;
&lt;br /&gt;
Moodle allows us to declare which course formats each block is allowed to be displayed in, and enforces these restrictions as set by the block developers at all times. The information is given to Moodle as a standard associative array, with each key corresponding to a page format and defining a boolean value (true/false) that declares whether the block should be allowed to appear in that page format.&lt;br /&gt;
&lt;br /&gt;
Notice the deliberate use of the term &#039;&#039;page&#039;&#039; instead of &#039;&#039;course&#039;&#039; in the above paragraph. This is because in Moodle 1.5 and onwards, blocks can be displayed in any page that supports them. The best example of such pages are the course pages, but we are not restricted to them. For instance, the quiz view page (the first one we see when we click on the name of the quiz) also supports blocks.&lt;br /&gt;
&lt;br /&gt;
The format names we can use for the pages derive from the name of the script which is actually used to display that page. For example, when we are looking at a course, the script is &amp;lt;span class=&amp;quot;filename&amp;quot;&amp;gt;/course/view.php&amp;lt;/span&amp;gt; (this is evident from the browser&#039;s address line). Thus, the format name of that page is &#039;&#039;&#039;course-view&#039;&#039;&#039;. It follows easily that the format name for a quiz view page is &#039;&#039;&#039;mod-quiz-view&#039;&#039;&#039;. This rule of thumb does have a few exceptions, however:&lt;br /&gt;
&lt;br /&gt;
# The format name for the front page of Moodle is &#039;&#039;&#039;site-index&#039;&#039;&#039;.&lt;br /&gt;
# The format name for courses is actually not just &#039;&#039;&#039;course-view&#039;&#039;&#039;&amp;lt;nowiki&amp;gt;; it is &amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;course-view-weeks&#039;&#039;&#039;, &#039;&#039;&#039;course-view-topics&#039;&#039;&#039;, etc.&lt;br /&gt;
# Even though there is no such page, the format name &#039;&#039;&#039;all&#039;&#039;&#039; can be used as a catch-all option.&lt;br /&gt;
&lt;br /&gt;
We can include as many format names as we want in our definition of the applicable formats. Each format can be allowed or disallowed, and there are also three more rules that help resolve the question &amp;quot;is this block allowed into this page or not?&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
# Prefixes of a format name will match that format name; for example, &#039;&#039;&#039;mod&#039;&#039;&#039; will match all the activity modules. &#039;&#039;&#039;course-view&#039;&#039;&#039; will match any course, regardless of the course format. And finally, &#039;&#039;&#039;site&#039;&#039;&#039; will also match the front page (remember that its full format name is &#039;&#039;&#039;site-index&#039;&#039;&#039;).&lt;br /&gt;
# The more specialized a format name that matches our page is, the higher precedence it has when deciding if the block will be allowed. For example, &#039;&#039;&#039;mod&#039;&#039;&#039;, &#039;&#039;&#039;mod-quiz&#039;&#039;&#039; and &#039;&#039;&#039;mod-quiz-view&#039;&#039;&#039; all match the quiz view page. But if all three are present, &#039;&#039;&#039;mod-quiz-view&#039;&#039;&#039; will take precedence over the other two because it is a better match.&lt;br /&gt;
# The character &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039; can be used in place of any word. For example, &#039;&#039;&#039;mod&#039;&#039;&#039; and &#039;&#039;&#039;mod-*&#039;&#039;&#039; are equivalent. At the time of this document&#039;s writing, there is no actual reason to utilize this &amp;quot;wildcard matching&amp;quot; feature, but it exists for future usage.&lt;br /&gt;
# The order that the format names appear does not make any difference.&lt;br /&gt;
All of the above are enough to make the situation sound complex, so let&#039;s look at some specific examples. First of all, to have our block appear &#039;&#039;&#039;only&#039;&#039;&#039; in the site front page, we would use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt; &lt;br /&gt;
function applicable_formats() {&lt;br /&gt;
  return array(&#039;site&#039; =&amp;gt; true);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
Since &#039;&#039;&#039;all&#039;&#039;&#039; is missing, the block is disallowed from appearing in &#039;&#039;any&#039;&#039; course format; but then &#039;&#039;&#039;site&#039;&#039;&#039; is set to TRUE, so it&#039;s explicitly allowed to appear in the site front page (remember that &#039;&#039;&#039;site&#039;&#039;&#039; matches &#039;&#039;&#039;site-index&#039;&#039;&#039; because it&#039;s a prefix).&lt;br /&gt;
&lt;br /&gt;
For another example, if we wanted to allow the block to appear in all course formats &#039;&#039;except&#039;&#039; social, and also to &#039;&#039;not&#039;&#039; be allowed anywhere but in courses, we would use:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt; &lt;br /&gt;
function applicable_formats() {&lt;br /&gt;
  return array(&lt;br /&gt;
           &#039;course-view&#039; =&amp;gt; true, &lt;br /&gt;
    &#039;course-view-social&#039; =&amp;gt; false);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This time, we first allow the block to appear in all courses and then we explicitly disallow the social format.&lt;br /&gt;
For our final, most complicated example, suppose that a block can be displayed in the site front page, in courses (but not social courses) and also when we are viewing any activity module, &#039;&#039;except&#039;&#039; quiz. This would be:&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
function applicable_formats() {&lt;br /&gt;
  return array(&lt;br /&gt;
           &#039;site-index&#039; =&amp;gt; true,&lt;br /&gt;
          &#039;course-view&#039; =&amp;gt; true, &lt;br /&gt;
   &#039;course-view-social&#039; =&amp;gt; false,&lt;br /&gt;
                  &#039;mod&#039; =&amp;gt; true, &lt;br /&gt;
             &#039;mod-quiz&#039; =&amp;gt; false&lt;br /&gt;
  );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It is not difficult to realize that the above accomplishes the objective if we remember that there is a &amp;quot;best match&amp;quot; policy to determine the end result.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;UPDATING:&#039;&#039;&#039; &amp;lt;br /&amp;gt;&lt;br /&gt;
Prior to version 1.5, blocks were only allowed in courses (and in Moodle 1.4, in the site front page). Also, the keywords used to describe the valid course formats at the time were slightly different and had to be changed in order to allow for a more open architecture. Refer to [[Development:Blocks/Appendix_B| Appendix B]] for more information on the changes that old blocks have to make to conform to the new standard.&lt;br /&gt;
&lt;br /&gt;
== Lists and Icons ==&lt;br /&gt;
&lt;br /&gt;
In this final part of the guide we will briefly discuss an additional capability of Moodle&#039;s block system, namely the ability to very easily create blocks that display a list of choices to the user. This list is displayed with one item per line, and an optional image (icon) next to the item. An example of such a &#039;&#039;list block&#039;&#039; is the standard Moodle &amp;quot;admin&amp;quot; block, which illustrates all the points discussed in this section.&lt;br /&gt;
&lt;br /&gt;
As we have seen so far, blocks use two properties of [[Development:Blocks/Appendix_A#.24this-.3Econtent| $this-&amp;gt;content]]: &amp;quot;text&amp;quot; and &amp;quot;footer&amp;quot;. The text is displayed as-is as the block content, and the footer is displayed below the content in a smaller font size. List blocks use $this-&amp;gt;content-&amp;gt;footer in the exact same way, but they ignore $this-&amp;gt;content-&amp;gt;text.&lt;br /&gt;
&lt;br /&gt;
Instead, Moodle expects such blocks to set two other properties when the [[Development:Blocks/Appendix_A#get_content.28.29| get_content()]] method is called: $this-&amp;gt;content-&amp;gt;items and $this-&amp;gt;content-&amp;gt;icons. $this-&amp;gt;content-&amp;gt;items should be a numerically indexed array containing elements that represent the HTML for each item in the list that is going to be displayed. Usually these items will be HTML anchor tags which provide links to some page. $this-&amp;gt;content-&amp;gt;icons should also be a numerically indexed array, with exactly as many items as $this-&amp;gt;content-&amp;gt;items has. Each of these items should be a fully qualified HTML &amp;lt;img&amp;gt; tag, with &amp;quot;src&amp;quot;, &amp;quot;height&amp;quot;, &amp;quot;width&amp;quot; and &amp;quot;alt&amp;quot; attributes. Obviously, it makes sense to keep the images small and of a uniform size.&lt;br /&gt;
&lt;br /&gt;
In order to tell Moodle that we want to have a list block instead of the standard text block, we need to make a small change to our block class declaration. Instead of extending class &#039;&#039;&#039;block_base&#039;&#039;&#039;, our block will extend class &#039;&#039;&#039;block_list&#039;&#039;&#039;. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt; &lt;br /&gt;
 class block_my_menu extends block_list {&lt;br /&gt;
     // The init() method does not need to change at all&lt;br /&gt;
 }&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In addition to making this change, we must of course also modify the [[Development:Blocks/Appendix_A#get_content.28.29| get_content()]] method to construct the [[Development:Blocks/Appendix_A#.24this-.3Econtent| $this-&amp;gt;content]] variable as discussed above:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt; &lt;br /&gt;
function get_content() {&lt;br /&gt;
  if ($this-&amp;gt;content !== null) {&lt;br /&gt;
    return $this-&amp;gt;content;&lt;br /&gt;
  }&lt;br /&gt;
 &lt;br /&gt;
  $this-&amp;gt;content         = new stdClass;&lt;br /&gt;
  $this-&amp;gt;content-&amp;gt;items  = array();&lt;br /&gt;
  $this-&amp;gt;content-&amp;gt;icons  = array();&lt;br /&gt;
  $this-&amp;gt;content-&amp;gt;footer = &#039;Footer here...&#039;;&lt;br /&gt;
 &lt;br /&gt;
  $this-&amp;gt;content-&amp;gt;items[] = &#039;&amp;lt;a href=&amp;quot;some_file.php&amp;quot;&amp;gt;Menu Option 1&amp;lt;/a&amp;gt;&#039;;&lt;br /&gt;
  $this-&amp;gt;content-&amp;gt;icons[] = &#039;&amp;lt;img src=&amp;quot;images/icons/1.gif&amp;quot; class=&amp;quot;icon&amp;quot; alt=&amp;quot;&amp;quot; /&amp;gt;&#039;;&lt;br /&gt;
 &lt;br /&gt;
  // Add more list items here&lt;br /&gt;
 &lt;br /&gt;
  return $this-&amp;gt;content;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To summarize, if we want to create a list block instead of a text block, we just need to change the block class declaration and the [[Development:Blocks/Appendix_A#get_content.28.29| get_content()]] method. Adding the mandatory [[Development:Blocks/Appendix_A#init.28.29| init()]] method as discussed earlier will then give us our first list block in no time!&lt;br /&gt;
&lt;br /&gt;
[[#top|Back to top of page]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
[http://dev.moodle.org/mod/resource/view.php?id=48 Unit 7 of the Introduction to Moodle Programming course] is a follow up to this course. (But you should follow the forum discussions of that course closely as there are still some bugs and inconsistencies.)&lt;br /&gt;
&lt;br /&gt;
== Appendices ==&lt;br /&gt;
&lt;br /&gt;
The appendices have been moved to separate pages:&lt;br /&gt;
&lt;br /&gt;
* Appendix A: [[Development:Blocks/Appendix A|&#039;&#039;block_base&#039;&#039; Reference]] &lt;br /&gt;
* Appendix B: [[Development:Blocks/Appendix B|Differences in the Blocks API for Moodle Versions prior to 1.5]]&lt;br /&gt;
* Appendix C: [[Development:Blocks/Appendix C|Creating Database Tables for Blocks (prior to 1.7)]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Blocks]]&lt;br /&gt;
[[Category:Tutorial]]&lt;br /&gt;
&lt;br /&gt;
[[es:Desarrollo de bloques]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:XMLDB_introduction&amp;diff=63094</id>
		<title>Development:XMLDB introduction</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:XMLDB_introduction&amp;diff=63094"/>
		<updated>2009-09-16T12:19:51Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: spelling mistake&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Development:XMLDB Documentation|XMLDB Documentation]] &amp;gt; Introduction&lt;br /&gt;
----&lt;br /&gt;
__NOTOC__&lt;br /&gt;
One of the main upcoming features in Moodle 1.7 will be its ability to work with some more [[wikipedia:RDBMS|RDBMS]] ([[wikipedia:MSSQL|MSSQL]] and [[wikipedia:Oracle database|Oracle]]) while maintaining everything working properly with both [[MySQL]] and [[PostgreSQL]]. As Moodle core uses [http://adodb.sourceforge.net/ ADOdb] internally, this possibility has been present since the beginning and, with the current maturity of the project (5 years old baby!), this can be a good moment to sort all this out.&lt;br /&gt;
&lt;br /&gt;
Initially, all our tests and preliminary work was to inspect how [http://adodb.sourceforge.net/ ADOdb] was doing its work, and how we could mix together all those 4 RDBMS, whose SQL dialects, although pretty similar, have some differences and idiosyncrasies that force us to do some important changes to our current database code (formerly &#039;&#039;&#039;datalib.php&#039;&#039;&#039;) and how it&#039;s used by the rest of Moodle.&lt;br /&gt;
&lt;br /&gt;
All the changes to be performed, which primary objective is to enable Moodle to work with more RDBMS, must be fulfilled by following these non-functional requirements: &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Provide one layer (new) for DB creation/upgrade&#039;&#039;&#039; ([[wikipedia:Data_Definition_Language|DDL]]): With this, developers will create their structures in one neutral form, independent of the exact implementation to be used by each RDBMS.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Provide one layer (existing) for DB handling&#039;&#039;&#039; ([[wikipedia:Data_Manipulation_Language|DML]]): With this, developers will request/store information also in one neutral form, independent of the RDBMS being used.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Easy migration path from previous versions&#039;&#039;&#039;: The current installation/upgrade system will work until, at least, Moodle 2.0, allowing 3rd party developers to migrate to the new system.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Simple, usable and effective&#039;&#039;&#039;: Until now, the way to upgrade Moodle has been really cool and it has worked pretty fine since the beginning. However, it has forced developers to maintain at least two installation and two upgrade scripts for each module/plugin. The new alternative will have only one file to install and one file to upgrade (per module/plugin too), reducing the possibility of mistakes drastically.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Conditional code usage must be minimised&#039;&#039;&#039;: Database libraries must accept 99% of potential SQL sentences, building/transforming them as necessary to work properly under any RDBMS. The number of places using custom (per DB) code should be minimum.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Well documented&#039;&#039;&#039;: All the functions defined, both at DML and DDL level must be well documented, helping the developer to find and use the correct one in each situation.&lt;br /&gt;
&lt;br /&gt;
== The Stack ==&lt;br /&gt;
&lt;br /&gt;
The next stack shows how Moodle 1.7 code will interact with the underlying RDBMS. It will help us understand a bit more what we are trying to do and will explain some of the points related in the Roadmap (below in this page).&lt;br /&gt;
&lt;br /&gt;
[[Image:MoodleDBStack.png|center]]&lt;br /&gt;
&lt;br /&gt;
Moodle code will use two &#039;&#039;languages&#039;&#039; to perform its DB actions:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;XMLDB neutral description files&#039;&#039;&#039;: To create, modify and delete database objects (DDL: create/alter/drop tables, fields, indexes, constraints...). It consists of a collection of validated, standard, XML files. They will be used to define all the DB objects. New for 1.7.&lt;br /&gt;
* &#039;&#039;&#039;Moodle SQL neutral statements&#039;&#039;&#039;: To add, modify, delete and select database information (DML: insert/update/delete/select records). To modify for 1.7.&lt;br /&gt;
&lt;br /&gt;
Please note the &#039;&#039;&#039;neutral&#039;&#039;&#039; keyword used in the expressions above. It means that both &#039;&#039;&#039;languages&#039;&#039;&#039; will be 100% the same, independent of the underlying RDBMS being used. And this must be particularly true for the XMLDB part.&lt;br /&gt;
&lt;br /&gt;
Obviously it&#039;s possible that in the SQL part we found some specialised queries (using complex joins, regular expressions...) that will force us to do some &#039;&#039;&#039;Exceptions&#039;&#039;&#039;. Well, they can exist (in fact, they exist), but we always must try to provide an alternate path to minimise them using neutral statements and standard libraries.&lt;br /&gt;
&lt;br /&gt;
Each one of the &#039;&#039;&#039;languages&#039;&#039;&#039; above will use its own library to do the work:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Moodle DDL Library&#039;&#039;&#039; ([[Development:DDL functions|ddllib.php]]): Where all the functions needed to handle DB objects will exist. This library is new for 1.7 and will provide developers with a high level of abstraction. As input it will accept some well defined objects and actions and it will execute the proper commands for the RDBMS being used.&lt;br /&gt;
* &#039;&#039;&#039;Moodle DML Library&#039;&#039;&#039; ([[Development:DML functions|dmllib.php]]): Where all the functions needed to handle DB contents will exist. This library is new for 1.7, although its contents are, basically, functions currently present in &#039;&#039;&#039;datalib.php&#039;&#039;&#039; (moved from there). All those DML functions will offer cross-db support for insert/update/delete/select statements using a common behaviour.&lt;br /&gt;
&lt;br /&gt;
Also note that &#039;&#039;&#039;datalib.php&#039;&#039;&#039; is still present in the schema above. It will contain all the functions that haven&#039;t been moved to the new &#039;&#039;&#039;ddllib.php&#039;&#039;&#039; and &#039;&#039;&#039;dmllib.php&#039;&#039;&#039; libraries. Only some common functions will remain there, and these will disappear (it&#039;s considered a legacy library) in upcoming &#039;&#039;&#039;Moodle&#039;&#039;&#039; releases (after 1.7) by moving all those functions to their proper library (course/lib.php, user/lib.php....). &lt;br /&gt;
&lt;br /&gt;
Both of these libraries (plus the small &#039;&#039;&#039;Exceptions&#039;&#039;&#039; bar) will perform all their actions using the &#039;&#039;&#039;ADOdb Database Abstraction Library for PHP&#039;&#039;&#039; that will receive all the requests from them, communicate with the DB (&#039;&#039;&#039;MySQL&#039;&#039;&#039;, &#039;&#039;&#039;PostgreSQL&#039;&#039;&#039;, &#039;&#039;&#039;Oracle&#039;&#039;&#039; or &#039;&#039;&#039;SQL*Server&#039;&#039;&#039;), retrieve results and forward them back to originator library.&lt;br /&gt;
&lt;br /&gt;
== The process ==&lt;br /&gt;
&lt;br /&gt;
This section points to the main areas of information about the &#039;&#039;&#039;process of design and implementation&#039;&#039;&#039; of the new XMLDB layer:&lt;br /&gt;
&lt;br /&gt;
* [[XMLDB Roadmap|Roadmap]]: Where the whole process is defined. It has been split into small chunks to be performed and tested easily. Also, such documents should be used to track what&#039;s done and what&#039;s pending, while using easy nomenclature.&lt;br /&gt;
&lt;br /&gt;
* [[XMLDB Problems|Problems]]: A comprehensive list of issues that need to be determined/solved prior to incorporating them into the [[XMLDB Roadmap|roadmap]].&lt;br /&gt;
&lt;br /&gt;
== The documentation ==&lt;br /&gt;
&lt;br /&gt;
This section points to the &#039;&#039;&#039;main documentation index&#039;&#039;&#039; about the implemented XMLDB:&lt;br /&gt;
&lt;br /&gt;
* [[Development:XMLDB Documentation|Documentation]]: Where you&#039;ll find quick links to different parts of the XMLDB documentation.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
=== XMLDB related ===&lt;br /&gt;
&lt;br /&gt;
* [[Development:XMLDB preliminary links|XMLDB preliminary links]] - A collection of links about general info, searched and analysed at the initial stages of the project&lt;br /&gt;
* [[Development:XMLDB preliminary notes|XMLDB preliminary notes]] - A collection of notes collected in the early stages of this project, pointing both to some changes required and some problems to solve.&lt;br /&gt;
&lt;br /&gt;
=== Database related ===&lt;br /&gt;
&lt;br /&gt;
* [[Development:DDL functions|DDL functions]] - Documentation for all the Data Definition Language (DDL) functions available inside Moodle.&lt;br /&gt;
* [[Development:DML functions|DML functions]] - Documentation for all the Data Manipulation Language (DML) functions available inside Moodle.&lt;br /&gt;
&lt;br /&gt;
[[Category:XMLDB]]&lt;br /&gt;
&lt;br /&gt;
[[zh:开发:XML数据库计划]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:SSH_key&amp;diff=62154</id>
		<title>Development:SSH key</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:SSH_key&amp;diff=62154"/>
		<updated>2009-08-27T12:41:05Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==What is a SSH key?==&lt;br /&gt;
&lt;br /&gt;
SSH keys are used for secure connections across a network.  They come in pairs, so you have a public key and a private key.&lt;br /&gt;
&lt;br /&gt;
The standard ssh2 file format (see&lt;br /&gt;
http://www.openssh.org/txt/draft-ietf-secsh-publickeyfile-02.txt)&lt;br /&gt;
looks like this:&lt;br /&gt;
&lt;br /&gt;
 ---- BEGIN SSH2 PUBLIC KEY ----&lt;br /&gt;
 Comment: &amp;quot;jtbell@Jon-Bells-Computer&amp;quot;&lt;br /&gt;
 AAAAB3NzaC1kc3MAAACBAPNgmidbM2rhYjUXunpnlXjHWfV+vc8/5YKrn8Y5P0Y6KwmG2G&lt;br /&gt;
 GMgNBon3LX3iJlBhtuU3FCBj3G1Kdt5vUhQHhUmHVrOasi47vawTrv7ZJCfiaSGwRsiBHt&lt;br /&gt;
 Jta5CAp7t0EnzX2q6BvPbFBBHNLyy6uNVpL2jOR06Pkx/vaqyScvAAAAFQDHvwmjWYwK9g&lt;br /&gt;
 K6Sp+pSvI7bwEUtwAAAIANMJDotMpfj89N+7+FJylSS+uFEQSS61PxENl/Mcj1jUREjJg2&lt;br /&gt;
 eNsJdAB9Ev99hWYS+7lFRtTJ2eh4Y9gpGe7BX3e2YGHOqp8cWCVCIKaMzwk9To+xnfThWq&lt;br /&gt;
 IfHT8I6CJxp/5ez02m6F2k/5iukvOwbGms6EAZK1DTBhDOHjEQwQAAAIAlz2/qBWkaMP+s&lt;br /&gt;
 W8FLmGKM+cCw5+asOaJGTwrFVuwJkDMvdEWxmG92A2dxuUske0d/AkN6zJp7HD0wlfesRM&lt;br /&gt;
 3+c+Res5qun9lFcdM4i03VoV5mXd+T7laS8yku6vZgvZZFnPvr2LOUnc7XThGFwMaQpFEW&lt;br /&gt;
 U8cvQbttO6QrT2CD2w==&lt;br /&gt;
 ---- END SSH2 PUBLIC KEY ----&lt;br /&gt;
&lt;br /&gt;
However, Moodle uses OpenSSH on its server and this key will not work with the OpenSSH server in this format; OpenSSH requires the key to be in OpenSSH format. Here is an example of a DSA public key in OpenSSH format (usually they are all in one line):&lt;br /&gt;
&lt;br /&gt;
 ssh-dss AAAAB3NzaC1kc3MAAACBAJ3hB5SAF6mBXPlZlRoJEZi0KSIN+NU2iGiaXZXi9CDrgVxTp6/&lt;br /&gt;
 sc56UcYCp4qjfrZ2G3+6PWbxYso4P4YyUC+61RU5KPy4EcTJske3O+aNvec/20cW7PT3TvH1+sxwGry&lt;br /&gt;
 mD50kTiXDgo5nXdqFvibgM61WW2DGTKlEUsZys0njRAAAAFQDs7ukaTGJlZdeznwFUAttTH9LrwwAAA&lt;br /&gt;
 IAMm4sLCdvvBx9WPkvWDX0OIXSteCYckiQxesOfPvz26FfYxuTG/2dljDlalC+kYG05C1NEcmZWSNES&lt;br /&gt;
 GBGfccSYSfI3Y5ahSVUhOC2LMO3JNjVyYUnOM/iyhzrnRfQoWO9GFMaugq0jBMlhZA4UO26yJqJ+BtX&lt;br /&gt;
 IyItaEEJdc/ghIwAAAIBFeCZynstlbBjP648+mDKIvzNSS+JYr5klGxS3q8A56NPcYhDMxGn7h1DKbb&lt;br /&gt;
 2AV4pO6y+6hDrWo3UT4dLVuzK01trwp PYp6JXTSZZ12ZaXNPz7sX9/z6pzMqhX4UEfjVsLcuF+ZS6a&lt;br /&gt;
 QCPO0ZZEa1z+EEIZSD/ykLQsDwPxGjPBqw== someone@somewhere.com&lt;br /&gt;
&lt;br /&gt;
In addition to OpenSSH and Standard SSH formats there are a variety of proprietary formats as well as SSH1 and SSH2 differences to account for, which can make this confusing. &lt;br /&gt;
&lt;br /&gt;
In the example above you will note that the key starts with &amp;quot;ssh-dss&amp;quot;. This is because this key was generated using DSA as opposed to RSA. A number of vendors in the SSH arena have argued, as per the PuTTY documentation that can be found at http://the.earth.li/~sgtatham/putty/0.55/htmldoc/Chapter8.html#S8.2.10 that users should employ RSA encryption because&lt;br /&gt;
&lt;br /&gt;
 DSA has an intrinsic weakness which makes it very easy to create a signature&lt;br /&gt;
 which contains enough information to give away the private key! This would &lt;br /&gt;
 allow an attacker to pretend to be you for any number of future sessions. &lt;br /&gt;
&lt;br /&gt;
An SSH2 public key in OpenSSH format will start with &amp;quot;ssh-rsa&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The idea behind all of this is that once you have keys on the remote server and your local host,  access will be simpler since the server will only grant access to someone who has the matching private key.&lt;br /&gt;
&lt;br /&gt;
==Why do I need a SSH key?==&lt;br /&gt;
&lt;br /&gt;
Our CVS server uses OpenSSH, so if you are a Moodle developer and you want to make your logins easier (by avoiding typing in your password all the time) then you will need to submit public key in Openssh format via the &amp;quot;Update my developer information&amp;quot; tab at http://moodle.org/cvs.&lt;br /&gt;
&lt;br /&gt;
==How do I create a SSH key pair?==&lt;br /&gt;
&lt;br /&gt;
===Platform Independent===&lt;br /&gt;
&lt;br /&gt;
Visit http://www.sshkeygen.com and simply follow the directions there.&lt;br /&gt;
&lt;br /&gt;
===Eclipse===&lt;br /&gt;
&lt;br /&gt;
If you plan to use Eclipse for development, please refer to the Eclipse document https://docs.moodle.org/en/Eclipse as Eclipse now has a plugin that allows you to manage all ssh key matters from within Eclipse.&lt;br /&gt;
&lt;br /&gt;
===Unix/Linux===&lt;br /&gt;
&lt;br /&gt;
You can use ssh-keygen at your system prompt.  Please consult the man page on your system for the options available to you.&lt;br /&gt;
&lt;br /&gt;
# Run:  &#039;&#039;&#039;ssh-keygen -t (rsa or dsa)&#039;&#039;&#039;. This will not include a passphrase. *&lt;br /&gt;
# Use of rsa or dsa above will result in rsa or dsa replacing each XXX below.&lt;br /&gt;
# Look in your ~/.ssh directory (or wherever you saved the output).  You&#039;ll find &#039;&#039;&#039;id_XXX&#039;&#039;&#039; (private) and &#039;&#039;&#039;id_XXX.pub&#039;&#039;&#039; (public).&lt;br /&gt;
# Cut and paste the contents of &#039;&#039;&#039;id_XXX.pub&#039;&#039;&#039; into your developer profile on http://moodle.org/cvs&lt;br /&gt;
# Put the private key wherever you will be calling CVS from (in your .ssh directory, for example).  Make sure it&#039;s secure!&lt;br /&gt;
&lt;br /&gt;
* This section initially recommended using &#039;&#039;ssh-keygen -d&#039;&#039; but it is unclear what the source of this -d option might be.&lt;br /&gt;
&lt;br /&gt;
===Windows===&lt;br /&gt;
Use puttygen and follow the instructions [http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter8.html here]. Make sure you choose the RSA2 key format and that when you copy the key data into the textbox on the site, that you have all of the characters on one line. If you have opened the key with word pad, it will have line breaks in it which will stop it from working.&lt;br /&gt;
&lt;br /&gt;
The box should look like this:&lt;br /&gt;
&lt;br /&gt;
 ssh-rsa&lt;br /&gt;
 AAAAWfg&amp;amp;jkf4D34H5@4svf..... (single very long line continues beyond edge of textbox)&lt;br /&gt;
&lt;br /&gt;
===Mac OS X===&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:XHTML&amp;diff=62106</id>
		<title>Development:XHTML</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:XHTML&amp;diff=62106"/>
		<updated>2009-08-26T10:19:54Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==XHTML Strict 1.0==&lt;br /&gt;
&lt;br /&gt;
Moodle output must be compliant with XHTML Strict 1.0. This means it must be:&lt;br /&gt;
&lt;br /&gt;
===Well-formed XML===&lt;br /&gt;
&lt;br /&gt;
In a well-formed XML document, every opening tag has a matching close tag; tags are properly nested, attributes are properly quoted, and the file contains no syntax errors. See [http://www.w3.org/TR/xml/#sec-well-formed the XML specification for a formal definition].&lt;br /&gt;
&lt;br /&gt;
While developing, you should have the option Administration ► Server ► Debugging ► XML strict headers turned on. With this option on, your web browser will refuse to display any page that is not well-formed. This makes such problems easy to find and fix.&lt;br /&gt;
&lt;br /&gt;
===Valid XHTML Strict===&lt;br /&gt;
&lt;br /&gt;
This means that the XML of your page follows the particular rules from the [http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict XHTML-1.0-Strict DTD]. &amp;lt;nowiki&amp;gt;For example, the first tag in the file must be &amp;lt;html&amp;gt;, a &amp;lt;form&amp;gt; tag must have an action=&amp;quot;&amp;quot; attribute, an &amp;lt;li&amp;gt; can only appear inside an &amp;lt;ol&amp;gt; or &amp;lt;ul&amp;gt;, you cannot use &amp;lt;frame&amp;gt; tags, and so on.&amp;lt;/nowiki&amp;gt; and so on.&lt;br /&gt;
&lt;br /&gt;
You can check whether the HTML you output is valid by using a HTML validator, for example the [https://addons.mozilla.org/en-US/firefox/addon/249 Html Validator] add-on for Firefox.&lt;br /&gt;
&lt;br /&gt;
===Semantic markup===&lt;br /&gt;
&lt;br /&gt;
That is, HTML tags should be used only to mark up the appropriate types of content. For example:&lt;br /&gt;
* tables should not be used for page layout, just to display tabular information,&lt;br /&gt;
* if something is a heading, it should be marked up using &amp;lt;h&#039;&#039;n&#039;&#039;&amp;gt; tags, for an appropriate &#039;&#039;n&#039;&#039;,&lt;br /&gt;
* &amp;lt;nowiki&amp;gt;if something is a list, it should marked up using &amp;lt;ol&amp;gt;, &amp;lt;ul&amp;gt; or &amp;lt;dl&amp;gt;,&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
* see [[Semantic HTML]] for further details&lt;br /&gt;
&lt;br /&gt;
==Styling==&lt;br /&gt;
&lt;br /&gt;
How the HTML is laid out should be controlled by CSS in whichever theme is currently selected.&lt;br /&gt;
&lt;br /&gt;
* Ensure that the HTML contains enough id=&amp;quot;...&amp;quot; and class=&amp;quot;...&amp;quot; attributes so that theme designers can easily control how &lt;br /&gt;
* Never embed inline styles in the HTML (that is, do not use the style=&amp;quot;...&amp;quot; attribute).&lt;br /&gt;
* As you change core Moodle code, you must update the standard theme so that Moodle looks OK out of the box.&lt;br /&gt;
* If you need to make basic style definitions for a module (or some other sorts of plugin), put them in a file called styles.php in that module. This will be included into every theme.&lt;br /&gt;
&lt;br /&gt;
== Moodle API ==&lt;br /&gt;
&lt;br /&gt;
* Use the functions in lib/weblib to do as much as possible (print_header(), print_box() etc)&lt;br /&gt;
* This API will change a lot in Moodle 2.0.  See:  [[Development:Navigation_2.0]]&lt;br /&gt;
&lt;br /&gt;
== See also: ==&lt;br /&gt;
&lt;br /&gt;
* [http://developer.apple.com/internet/webcontent/bestwebdev.html Web Page Development: Best Practices] by the Safari development team at Apple.&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/502/en/index.php?title=Development:Coding&amp;diff=62075</id>
		<title>Development:Coding</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/502/en/index.php?title=Development:Coding&amp;diff=62075"/>
		<updated>2009-08-25T21:50:49Z</updated>

		<summary type="html">&lt;p&gt;Josepuib: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is the top-level page describing Moodle&#039;s coding guidelines.  It&#039;s the place to start if you want to know how to write code for Moodle.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;WARNING: Under construction RIGHT NOW!&amp;lt;/p&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Moodle architecture==&lt;br /&gt;
&lt;br /&gt;
Moodle tries to run on the widest possible range of platforms, for the widest possible number of people, while remaining easy to install, use, upgrade and integrate with other systems.&lt;br /&gt;
&lt;br /&gt;
For more about this, see: [[Moodle architecture]].&lt;br /&gt;
&lt;br /&gt;
==Plugins== &lt;br /&gt;
&lt;br /&gt;
Moodle has a general philosophy of modularity.  There are over 25 different types of plugins, however many of these plugin types work the same way.&lt;br /&gt;
&lt;br /&gt;
For more about the structure of plugins, see [[Development:Plugins|Moodle plugins]].&lt;br /&gt;
&lt;br /&gt;
==Coding style==&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly so when many developers are involved. A standard style helps to ensure that the code is easier to read and understand, which helps overall quality. &lt;br /&gt;
&lt;br /&gt;
Writing your code in this way is an important step to having your code accepted by the Moodle community.&lt;br /&gt;
&lt;br /&gt;
Our [[Development:Coding_style|Moodle coding style]] document explains this standard.&lt;br /&gt;
&lt;br /&gt;
==Security==&lt;br /&gt;
&lt;br /&gt;
Security is about protecting the interests and data of all our users.  Moodle may not be banking software, but it is still protecting a lot of sensitive and important data such as private discussions and grades from outside eyes (or student hackers!) as well as protecting our users from spammers and other internet predators.&lt;br /&gt;
&lt;br /&gt;
It&#039;s also a script running on people&#039;s servers, so Moodle needs to be a responsible Internet citizen and not introduce vulnerabilities that could allow crackers to gain unlawful access to the server it runs on. &lt;br /&gt;
&lt;br /&gt;
Any single script (in Moodle core or a third party module) can introduce a vulnerability to thousands of sites, so it&#039;s important that all developers strictly follow our [[Development:Security|Moodle security guidelines]].&lt;br /&gt;
&lt;br /&gt;
==XHTML==&lt;br /&gt;
&lt;br /&gt;
It&#039;s important that Moodle produces strict, well-formed XHTML code, compliant with all common accessibility guidelines (such as W3C WAG).&lt;br /&gt;
&lt;br /&gt;
This helps consistency across browsers in a nicely-degrading way (especially those using non-visual or mobile browsers), as well as improving life for theme designers.&lt;br /&gt;
&lt;br /&gt;
Full information is here:  [[Development:XHTML|Moodle XHTML]]&lt;br /&gt;
&lt;br /&gt;
==JavaScript==&lt;br /&gt;
&lt;br /&gt;
In general, everything in Moodle should work with JavaScript turned off in your browser.  If you do have JavaScript enabled it should only improve usability (not add features).&lt;br /&gt;
&lt;br /&gt;
This is important for accessibility, and in line with the principles of unobtrusive JavaScript and progressive enhancement. &lt;br /&gt;
&lt;br /&gt;
See the [[Development:JavaScript guidelines|Moodle JavaScript guidelines]] for more information.&lt;br /&gt;
&lt;br /&gt;
==Internationalisation==&lt;br /&gt;
&lt;br /&gt;
Moodle works in over 81 languages because we pay great attention to keeping the language strings and locale information separate from the code, in language packs.&lt;br /&gt;
&lt;br /&gt;
The default language for all code and documentation, however, is English (AU).&lt;br /&gt;
&lt;br /&gt;
Full details:  [[Development:Internationalisation|Moodle Internationalisation]]&lt;br /&gt;
&lt;br /&gt;
==Accessibility==&lt;br /&gt;
&lt;br /&gt;
Moodle should work well for the widest possible range of people.&lt;br /&gt;
&lt;br /&gt;
See: [[Development:Accessibility|Moodle Accessibility]]&lt;br /&gt;
&lt;br /&gt;
==Usability==&lt;br /&gt;
&lt;br /&gt;
See: [[Development:Moodle_User_Interface_Guidelines|Moodle User Interface Guidelines]]  (being produced summer 2009)&lt;br /&gt;
* Implementing user interfaces: [[Development:Interface_guidelines| Interface Guidelines]]&lt;br /&gt;
&lt;br /&gt;
==Database==&lt;br /&gt;
&lt;br /&gt;
Moodle has a powerful database abstraction layer that we wrote ourselves, called [[Development:XMLDB_Documentation|XMLDB]].  This lets the same Moodle code work on MySQL, PostgreSQL, Oracle and MSSQL.&lt;br /&gt;
&lt;br /&gt;
We have tools and API for [[Development:DDL functions|defining and modifying tables]] as well as [[Development:DML functions|methods for getting data in and out]] of the database.&lt;br /&gt;
&lt;br /&gt;
Overview: [[Development:Database|Moodle Database]] guidelines&lt;br /&gt;
&lt;br /&gt;
==Events==&lt;br /&gt;
&lt;br /&gt;
Moodle allows inter-module communication via &#039;&#039;&#039;events&#039;&#039;&#039;.  Modules can &#039;&#039;&#039;trigger&#039;&#039;&#039; specific events and other modules can choose to &#039;&#039;&#039;handle&#039;&#039;&#039; those events.&lt;br /&gt;
&lt;br /&gt;
Full information:  [[Development:Events_API|Moodle Events API]]&lt;br /&gt;
&lt;br /&gt;
==Unit tests==&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Unit_testing Unit testing] is not simply a technique but a philosophy of software development.&lt;br /&gt;
&lt;br /&gt;
The idea is to create automatable tests for each bit of functionality that you are developing (at the same time you are developing it).  This not only helps everyone later test that the software works, but helps the development itself, because it forces you to work in a modular way with very clearly defined structures and goals.&lt;br /&gt;
&lt;br /&gt;
Moodle uses a library called simpletest (not very extensively yet though!) that makes writing unit tests fairly simple.  Our unit testing is currently not deep but we want to improve this.&lt;br /&gt;
&lt;br /&gt;
Full information here:  [[Development:Unit_tests|Moodle Unit Tests]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://doku.clausvb.de/php_coding_standard.htm General PHP coding standards]&lt;br /&gt;
* [http://pear.php.net/manual/en/standards.php PEAR coding standards]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|Coding]]&lt;br /&gt;
&lt;br /&gt;
[[es:Manual de Estilo de Código]]&lt;br /&gt;
[[ja:コーディング]]&lt;br /&gt;
[[zh:代码指南]]&lt;br /&gt;
[[pl:Kodowanie]]&lt;br /&gt;
[[pt:manual_de_codigo]]&lt;br /&gt;
[[fr:Développement:Directives_de_codage]]&lt;/div&gt;</summary>
		<author><name>Josepuib</name></author>
	</entry>
</feed>