<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hccrle</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hccrle"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/Special:Contributions/Hccrle"/>
	<updated>2026-04-10T16:53:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Upgrading_to_Moodle_1.9&amp;diff=26671</id>
		<title>Upgrading to Moodle 1.9</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Upgrading_to_Moodle_1.9&amp;diff=26671"/>
		<updated>2008-10-09T13:31:17Z</updated>

		<summary type="html">&lt;p&gt;Hccrle: /* Upgrading more than one version */ correct grammar&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.9}}&lt;br /&gt;
==Before upgrading, please...==&lt;br /&gt;
&lt;br /&gt;
* Check that your site meets all system requirements for 1.9 in &#039;&#039;Administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;&lt;br /&gt;
* Do a full database backup!&lt;br /&gt;
* Remember to purge PHP cache if using any PHP accelerator&lt;br /&gt;
* Read [[Upgrading to Moodle 1.8]] if you are upgrading to 1.9 from 1.6 or 1.7&lt;br /&gt;
* Read [[Upgrading to Moodle 1.7]] if you are upgrading from 1.6&lt;br /&gt;
&lt;br /&gt;
===Notes===&lt;br /&gt;
* If upgrading from 1.6 or later, you must have converted your site to Unicode&lt;br /&gt;
* If upgrading from earlier than 1.6, we recommend upgrading to 1.6 first, then 1.8 -&amp;gt; 1.9&lt;br /&gt;
* We recommend PHP 5.2 or later, but you must have at least PHP 4.3.0&lt;br /&gt;
&lt;br /&gt;
==Now upgrade==&lt;br /&gt;
&lt;br /&gt;
Once you have satisfied the requirements for Moodle 1.9, follow the instructions on the [[Upgrading|upgrading]] page.&lt;br /&gt;
&lt;br /&gt;
==Upgrading more than one version==&lt;br /&gt;
&lt;br /&gt;
In general, it is recommended to upgrade via each version of Moodle, for example 1.7 -&amp;gt; 1.8 -&amp;gt; 1.9. An exception to this is when upgrading from 1.5 or 1.6, when it is recommended that 1.7 be skipped, in other words upgrade 1.5 -&amp;gt; 1.6 -&amp;gt; 1.8 -&amp;gt; 1.9. (The main reason for this recommendation is that the default roles settings obtained when upgrading to 1.7 are not ideal for 1.8 onwards.)&lt;br /&gt;
&lt;br /&gt;
==Front page activities==&lt;br /&gt;
&lt;br /&gt;
To enable logged-in users to participate in front page activities, such as viewing the site news, the default front page role should be set to student in &#039;&#039;Administration &amp;gt; Front Page &amp;gt; [[Front Page settings]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Gradebook ==&lt;br /&gt;
&lt;br /&gt;
=== What improvements in the gradebook justify upgrading from 1.8 to 1.9? ===&lt;br /&gt;
*Faster execution, more noticeable with large sites&lt;br /&gt;
*More scalable&lt;br /&gt;
*More control over the display of grades, to teachers and students&lt;br /&gt;
*More [[Category aggregation|aggregation options]]&lt;br /&gt;
*A simple, [[Development:Grades#API_for_communication_with_modules.2Fblocks|public API]] that can be used by any module to support grading&lt;br /&gt;
*Possibility to write [[Development:Gradebook_Report_Tutorial|custom grade reports]]&lt;br /&gt;
*A [[Development:Grades#History_tables|&amp;quot;Grade change history&amp;quot; record]]&lt;br /&gt;
&lt;br /&gt;
=== Why is the new gradebook so complicated? ===&lt;br /&gt;
Added power and control requires more options. It is mostly the number of options and settings that gives the impression of complexity. Here are some of the main reasons for the changes made in the gradebook for 1.9:&lt;br /&gt;
&lt;br /&gt;
*Previous gradebook did not scale well: it became very slow and unmanageable in large organisations with many students, activities and grades&lt;br /&gt;
*Grades were generated and stored by each module without much consistency&lt;br /&gt;
*Difficulty in producing new types of reports&lt;br /&gt;
*No [[Outcomes]]&lt;br /&gt;
&lt;br /&gt;
=== Is the gradebook in 1.9 faster than in 1.8? ===&lt;br /&gt;
According to [http://moodle.org/mod/forum/discuss.php?d=91034&amp;amp;parent=410224 one early report], yes. There are other more thorough benchmark tests being conducted, and we will publish the results when they are made public.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Release Notes]]&lt;br /&gt;
*[[:Category:Moodle 1.9]]&lt;br /&gt;
*[[Question Engine Changes in Moodle 1.9]] (includes some important documentation on question engine upgrade for those who make extensive use of the question bank and quiz module)&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=75088 Automatic update of language package while updating in 1.9]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=89825 Change in Moodle 1.8 and 1.9 : admin tree icons are now themeable - some themes need to be upgraded]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=92027 Migration 1.8 to 1.9]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Mise à jour à Moodle 1.9]]&lt;br /&gt;
[[ja:Moodle1.9へのアップグレード]]&lt;/div&gt;</summary>
		<author><name>Hccrle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=XMLDB_introduction&amp;diff=6272</id>
		<title>XMLDB introduction</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=XMLDB_introduction&amp;diff=6272"/>
		<updated>2007-08-29T10:53:08Z</updated>

		<summary type="html">&lt;p&gt;Hccrle: /* The process */ grammar corrections&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[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 be filled following the next 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 part developers to migrate along the time 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, but 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 in an high degree.&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 underlying RDBMS. It will help us to 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 in 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, independently  of the underlying RDBMS being used. And this must be particularly true for the XMLDB part. Point.&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; ([[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 an 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; ([[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; continues 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 this situation 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 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 chuncks to be performed and tested easily. Also, such documents should be used to track what&#039;s done and what&#039;s pending following some easy nomenclature.&lt;br /&gt;
&lt;br /&gt;
* [[XMLDB Problems|Problems]]: A comprensive 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;
* [[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;
* [[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;
* [[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;
* [[DDL functions|DDL functions]] - Documentation for all the Data Definition Language (DDL) functions available inside Moodle.&lt;br /&gt;
* [[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>Hccrle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=XMLDB_introduction&amp;diff=6271</id>
		<title>XMLDB introduction</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=XMLDB_introduction&amp;diff=6271"/>
		<updated>2007-08-28T11:22:46Z</updated>

		<summary type="html">&lt;p&gt;Hccrle: /* The Stack */ correct grammar: this libraries -&amp;gt; these libraries, request -&amp;gt; requests&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[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 be filled following the next 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 part developers to migrate along the time 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, but 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 in an high degree.&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 underlying RDBMS. It will help us to 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 in 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, independently  of the underlying RDBMS being used. And this must be particularly true for the XMLDB part. Point.&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; ([[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 an 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; ([[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; continues 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 this situation 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 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 splitted in small chuncks to be performed and tested easily. Also, such documents should be used to track what&#039;s done and what&#039;s pending following some easy nomenclature.&lt;br /&gt;
&lt;br /&gt;
* [[XMLDB Problems|Problems]]: A comprensive list of issues that need to be determined/solved prior to incorporate them to 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;
* [[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;
* [[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;
* [[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;
* [[DDL functions|DDL functions]] - Documentation for all the Data Definition Language (DDL) functions available inside Moodle.&lt;br /&gt;
* [[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>Hccrle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Output_functions&amp;diff=3414</id>
		<title>Output functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Output_functions&amp;diff=3414"/>
		<updated>2007-07-18T10:27:35Z</updated>

		<summary type="html">&lt;p&gt;Hccrle: /* print_textarea() */  correct grammar (tense agreement)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page tries to explain a bit how dynamic data should be sent from Moodle to the browser in an organised and standard way. Obviously it&#039;s possible to have your own output methods but, thinking that you are going to share your code (yep, this is an OpenSource project!) and in the collaborative way we try to build and maintain the system every day, it would be really better to follow the basic guidelines explained below.&lt;br /&gt;
&lt;br /&gt;
By using them you will be helping to have better, more secure and readable code. Spend some minutes trying to understand them, please!&lt;br /&gt;
&lt;br /&gt;
Of course, these functions can be discussed, modified and new functions can arrive if there are some good reasons for it. Just discuss it in the [http://moodle.org/mod/forum/view.php?id=55 General developer forum] at [http://moodle.org moodle.org].&lt;br /&gt;
&lt;br /&gt;
For each of the functions below we&#039;ll try to explain when they should be used, explaining the most important parameters supported and their meaning. Let&#039;s review them!&lt;br /&gt;
&lt;br /&gt;
=== p() and s() ===&lt;br /&gt;
&lt;br /&gt;
 function s($var, $strip=false)&lt;br /&gt;
 function p($var, $strip=false)&lt;br /&gt;
&lt;br /&gt;
These functions share the same code so they will be explained together. The only difference is that s() returns the string while p() prints it directly.&lt;br /&gt;
&lt;br /&gt;
These functions should be used to:&lt;br /&gt;
&lt;br /&gt;
* print all the &#039;&#039;&#039;values of form fields&#039;&#039;&#039; like &amp;lt;nowiki&amp;gt;&amp;lt;input&amp;gt;&amp;lt;/nowiki&amp;gt; or &amp;lt;nowiki&amp;gt;&amp;lt;textarea&amp;gt;&amp;lt;/nowiki&amp;gt; tags.&lt;br /&gt;
* to &#039;&#039;&#039;show plain (non html) text&#039;&#039;&#039; that has been introduced by the user (search string, quiz responses...).&lt;br /&gt;
* in general, all the &#039;&#039;&#039;dynamic data, not being html&#039;&#039;&#039;, that doesn&#039;t need to be cleaned nor processed by filters&lt;br /&gt;
&lt;br /&gt;
It is important not to use these functions for strings that contain html markup.&lt;br /&gt;
&lt;br /&gt;
The functions replace certain characters that would have special meaning in html ( &amp;lt;, &amp;gt;, &amp;quot;, &#039;, and &amp;amp;) by html entities so that they are displayed as intended. Note that even though the value of form fields printed with p() will have these characters converted to html entities, the submitted values will contain the original characters again.&lt;br /&gt;
&lt;br /&gt;
The key parameter for this function is:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;strip&#039;&#039;&#039;: it decides if we want to strip slashes from the string or no. By default it&#039;s &#039;false&#039; so no strip will be performed. We should set such parameter to &#039;true&#039; only when data to be processed isn&#039;t coming from database but from http requests (forms, links...).&lt;br /&gt;
&lt;br /&gt;
=== format_text() ===&lt;br /&gt;
&lt;br /&gt;
 function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL ) &lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* print &#039;&#039;&#039;any html/plain/markdown/moodle text&#039;&#039;&#039;, needing any of the features below. Mainly used for long strings like posts, answers, glossary items...&lt;br /&gt;
&lt;br /&gt;
Note that this function is really &#039;&#039;&#039;heavy&#039;&#039;&#039; because it supports &#039;&#039;&#039;cleaning&#039;&#039;&#039; of dangerous contents, delegates processing to enabled &#039;&#039;&#039;filter&#039;&#039;&#039;s, supports different &#039;&#039;&#039;formats&#039;&#039;&#039; of text (HTML, PLAIN, MARKDOWN, MOODLE) and performs a lot of &#039;&#039;&#039;automatic conversions&#039;&#039;&#039; like adding smilies, build links. Also, it includes a strong &#039;&#039;&#039;cache mechanism&#039;&#039;&#039; (DB based) that will alleviate the server from a lot of work processing the same texts time and again.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;format&#039;&#039;&#039;: To tell the function about how the data has been entered. It defaults to FORMAT_MOODLE that is a cool format to process plain text because it features automatic link conversion, smilies and good conversion to html output. Other formats are FORMAT_HTML, FORMAT_PLAIN, FORMAT_MARKDOWN. See [[Formatting options]].&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;options&#039;&#039;&#039;: Here we can specify how we want the process to be performed. You only need to define them if they are different from the default value assumed. Main options are:&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;noclean&#039;&#039;&#039;: To decide if we want to skip the clean of text, &#039;&#039;&#039;un-protecting us&#039;&#039;&#039; from attacks and other security flaws (defaults to false, so protection is enabled. You &#039;&#039;&#039;shouldn&#039;t set it to true ever&#039;&#039;&#039; unless you are 200% sure that only controlled users can edit it (mainly admins). &#039;&#039;&#039;Never use it for general text places&#039;&#039;&#039; (posts...) or you will be, sooner or later, attacked! Note that this option is ignored for FORMAT_PLAIN, the text is never cleaned.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;filter&#039;&#039;&#039;: To decide if you want to allow filters to process the text (defaults to true). This is ignored by FORMAT_PLAIN for which filters are never applied.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;smiley&#039;&#039;&#039;: To decide if we want automatic conversion of smilies to images (defaults to true). This is ignored by FORMAT_PLAIN for which smileys are never converted.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;para&#039;&#039;&#039;: To decide if you want every paragraph automatically enclosed between html paragraph tags (&amp;lt;nowiki&amp;gt;&amp;lt;p&amp;gt;...&amp;lt;/p&amp;gt;&amp;lt;/nowiki&amp;gt;) (defaults to true). This option only applies to FORMAT_MOODLE.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;newlines&#039;&#039;&#039;: To decide if linefeeds in text should be converted to html newlines (&amp;lt;nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/nowiki&amp;gt;) (defaults to true). This option only applies to FORMAT_MOODLE.&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help filters to know how they should work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
&lt;br /&gt;
=== format_string() ===&lt;br /&gt;
&lt;br /&gt;
 function format_string ($string, $striplinks = false, $courseid=NULL )&lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* print &#039;&#039;&#039;short strings (non html) that need filter processing&#039;&#039;&#039; (activity titles, post subjects, glossary concepts...).&lt;br /&gt;
&lt;br /&gt;
Please note that this function is basically one stripped version of the full format_text() function detailed above and &#039;&#039;&#039;it doesn&#039;t offer any of its options or protections&#039;&#039;&#039;. It simply filters the strings and returns the result, so we must ensure that text being processed has been properly cleaned at input time, using the proper xxx_param() functions.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;striplinks&#039;&#039;&#039;: To decide if, after the text has been processed by filters, we must delete any link from the result text. Used when we want to show the text inside menus, page titles... (defaults to false).&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help filters to know how they should work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
&lt;br /&gt;
=== print_textarea() ===&lt;br /&gt;
&lt;br /&gt;
 function print_textarea($usehtmleditor, $rows, $cols, $width, &lt;br /&gt;
                        $height, $name, $value=&amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, $courseid=0, $return=false)&lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* display &amp;lt;nowiki&amp;gt;&amp;lt;textarea&amp;gt;&amp;lt;/nowiki&amp;gt; fields when we want to allow users (based in their preferences and browser capabilities) &#039;&#039;&#039;to use the visual HTML editor&#039;&#039;&#039; instead of one standard &#039;plain&#039; area.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;usehtmleditor&#039;&#039;&#039;: to decide if the HTML editor must be showed. The value of this parameter must be calculated by the can_use_html_editor() function.&lt;br /&gt;
* &#039;&#039;&#039;rows, cols&#039;&#039;&#039;: to be applied it the standard textarea is showed.&lt;br /&gt;
* &#039;&#039;&#039;width, height&#039;&#039;&#039;: to be applied if the HTML editor is used.&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039;: the name of the field that will contain the text once the form is submitted.&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039;: the initial value of the textarea.&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help the editor to know where it is work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
* &#039;&#039;&#039;return&#039;&#039;&#039;: to decide if the generated html code must be returned to the caller (true) or printed directly (false). Defaults to false.&lt;br /&gt;
&lt;br /&gt;
[[Category:Output functions]]&lt;/div&gt;</summary>
		<author><name>Hccrle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Output_functions&amp;diff=3413</id>
		<title>Output functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Output_functions&amp;diff=3413"/>
		<updated>2007-07-17T18:12:56Z</updated>

		<summary type="html">&lt;p&gt;Hccrle: /* format_string() */ corrected grammatical errors&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page tries to explain a bit how dynamic data should be sent from Moodle to the browser in an organised and standard way. Obviously it&#039;s possible to have your own output methods but, thinking that you are going to share your code (yep, this is an OpenSource project!) and in the collaborative way we try to build and maintain the system every day, it would be really better to follow the basic guidelines explained below.&lt;br /&gt;
&lt;br /&gt;
By using them you will be helping to have better, more secure and readable code. Spend some minutes trying to understand them, please!&lt;br /&gt;
&lt;br /&gt;
Of course, these functions can be discussed, modified and new functions can arrive if there are some good reasons for it. Just discuss it in the [http://moodle.org/mod/forum/view.php?id=55 General developer forum] at [http://moodle.org moodle.org].&lt;br /&gt;
&lt;br /&gt;
For each of the functions below we&#039;ll try to explain when they should be used, explaining the most important parameters supported and their meaning. Let&#039;s review them!&lt;br /&gt;
&lt;br /&gt;
=== p() and s() ===&lt;br /&gt;
&lt;br /&gt;
 function s($var, $strip=false)&lt;br /&gt;
 function p($var, $strip=false)&lt;br /&gt;
&lt;br /&gt;
These functions share the same code so they will be explained together. The only difference is that s() returns the string while p() prints it directly.&lt;br /&gt;
&lt;br /&gt;
These functions should be used to:&lt;br /&gt;
&lt;br /&gt;
* print all the &#039;&#039;&#039;values of form fields&#039;&#039;&#039; like &amp;lt;nowiki&amp;gt;&amp;lt;input&amp;gt;&amp;lt;/nowiki&amp;gt; or &amp;lt;nowiki&amp;gt;&amp;lt;textarea&amp;gt;&amp;lt;/nowiki&amp;gt; tags.&lt;br /&gt;
* to &#039;&#039;&#039;show plain (non html) text&#039;&#039;&#039; that has been introduced by the user (search string, quiz responses...).&lt;br /&gt;
* in general, all the &#039;&#039;&#039;dynamic data, not being html&#039;&#039;&#039;, that doesn&#039;t need to be cleaned nor processed by filters&lt;br /&gt;
&lt;br /&gt;
It is important not to use these functions for strings that contain html markup.&lt;br /&gt;
&lt;br /&gt;
The functions replace certain characters that would have special meaning in html ( &amp;lt;, &amp;gt;, &amp;quot;, &#039;, and &amp;amp;) by html entities so that they are displayed as intended. Note that even though the value of form fields printed with p() will have these characters converted to html entities, the submitted values will contain the original characters again.&lt;br /&gt;
&lt;br /&gt;
The key parameter for this function is:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;strip&#039;&#039;&#039;: it decides if we want to strip slashes from the string or no. By default it&#039;s &#039;false&#039; so no strip will be performed. We should set such parameter to &#039;true&#039; only when data to be processed isn&#039;t coming from database but from http requests (forms, links...).&lt;br /&gt;
&lt;br /&gt;
=== format_text() ===&lt;br /&gt;
&lt;br /&gt;
 function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL ) &lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* print &#039;&#039;&#039;any html/plain/markdown/moodle text&#039;&#039;&#039;, needing any of the features below. Mainly used for long strings like posts, answers, glossary items...&lt;br /&gt;
&lt;br /&gt;
Note that this function is really &#039;&#039;&#039;heavy&#039;&#039;&#039; because it supports &#039;&#039;&#039;cleaning&#039;&#039;&#039; of dangerous contents, delegates processing to enabled &#039;&#039;&#039;filter&#039;&#039;&#039;s, supports different &#039;&#039;&#039;formats&#039;&#039;&#039; of text (HTML, PLAIN, MARKDOWN, MOODLE) and performs a lot of &#039;&#039;&#039;automatic conversions&#039;&#039;&#039; like adding smilies, build links. Also, it includes a strong &#039;&#039;&#039;cache mechanism&#039;&#039;&#039; (DB based) that will alleviate the server from a lot of work processing the same texts time and again.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;format&#039;&#039;&#039;: To tell the function about how the data has been entered. It defaults to FORMAT_MOODLE that is a cool format to process plain text because it features automatic link conversion, smilies and good conversion to html output. Other formats are FORMAT_HTML, FORMAT_PLAIN, FORMAT_MARKDOWN. See [[Formatting options]].&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;options&#039;&#039;&#039;: Here we can specify how we want the process to be performed. You only need to define them if they are different from the default value assumed. Main options are:&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;noclean&#039;&#039;&#039;: To decide if we want to skip the clean of text, &#039;&#039;&#039;un-protecting us&#039;&#039;&#039; from attacks and other security flaws (defaults to false, so protection is enabled. You &#039;&#039;&#039;shouldn&#039;t set it to true ever&#039;&#039;&#039; unless you are 200% sure that only controlled users can edit it (mainly admins). &#039;&#039;&#039;Never use it for general text places&#039;&#039;&#039; (posts...) or you will be, sooner or later, attacked! Note that this option is ignored for FORMAT_PLAIN, the text is never cleaned.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;filter&#039;&#039;&#039;: To decide if you want to allow filters to process the text (defaults to true). This is ignored by FORMAT_PLAIN for which filters are never applied.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;smiley&#039;&#039;&#039;: To decide if we want automatic conversion of smilies to images (defaults to true). This is ignored by FORMAT_PLAIN for which smileys are never converted.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;para&#039;&#039;&#039;: To decide if you want every paragraph automatically enclosed between html paragraph tags (&amp;lt;nowiki&amp;gt;&amp;lt;p&amp;gt;...&amp;lt;/p&amp;gt;&amp;lt;/nowiki&amp;gt;) (defaults to true). This option only applies to FORMAT_MOODLE.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;newlines&#039;&#039;&#039;: To decide if linefeeds in text should be converted to html newlines (&amp;lt;nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/nowiki&amp;gt;) (defaults to true). This option only applies to FORMAT_MOODLE.&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help filters to know how they should work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
&lt;br /&gt;
=== format_string() ===&lt;br /&gt;
&lt;br /&gt;
 function format_string ($string, $striplinks = false, $courseid=NULL )&lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* print &#039;&#039;&#039;short strings (non html) that need filter processing&#039;&#039;&#039; (activity titles, post subjects, glossary concepts...).&lt;br /&gt;
&lt;br /&gt;
Please note that this function is basically one stripped version of the full format_text() function detailed above and &#039;&#039;&#039;it doesn&#039;t offer any of its options or protections&#039;&#039;&#039;. It simply filters the strings and returns the result, so we must ensure that text being processed has been properly cleaned at input time, using the proper xxx_param() functions.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;striplinks&#039;&#039;&#039;: To decide if, after the text has been processed by filters, we must delete any link from the result text. Used when we want to show the text inside menus, page titles... (defaults to false).&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help filters to know how they should work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
&lt;br /&gt;
=== print_textarea() ===&lt;br /&gt;
&lt;br /&gt;
 function print_textarea($usehtmleditor, $rows, $cols, $width, &lt;br /&gt;
                        $height, $name, $value=&amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, $courseid=0, $return=false)&lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* display &amp;lt;nowiki&amp;gt;&amp;lt;textarea&amp;gt;&amp;lt;/nowiki&amp;gt; fields when we want to allow users (based in their preferences and browser capabilities) &#039;&#039;&#039;to use the visual HTML editor&#039;&#039;&#039; instead of one standard &#039;plain&#039; area.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;usehtmleditor&#039;&#039;&#039;: to decide if the HTML editor must be showed. The value of this parameter must be calculated by the can_use_html_editor() function.&lt;br /&gt;
* &#039;&#039;&#039;rows, cols&#039;&#039;&#039;: to be applied it the standard textarea is showed.&lt;br /&gt;
* &#039;&#039;&#039;width, height&#039;&#039;&#039;: to be applied if the HTML editor is used.&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039;: the name of the field that will contain the text once the form was submitted.&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039;: the initial value of the textarea.&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help the editor to know where it is work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
* &#039;&#039;&#039;return&#039;&#039;&#039;: to decide if the generated html code must be returned to the caller (true) or printed directly (false). Defaults to false.&lt;br /&gt;
&lt;br /&gt;
[[Category:Output functions]]&lt;/div&gt;</summary>
		<author><name>Hccrle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Output_functions&amp;diff=3412</id>
		<title>Output functions</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Output_functions&amp;diff=3412"/>
		<updated>2007-07-17T18:06:38Z</updated>

		<summary type="html">&lt;p&gt;Hccrle: /* format_text() */  removed double negative (never -&amp;gt; ever)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page tries to explain a bit how dynamic data should be sent from Moodle to the browser in an organised and standard way. Obviously it&#039;s possible to have your own output methods but, thinking that you are going to share your code (yep, this is an OpenSource project!) and in the collaborative way we try to build and maintain the system every day, it would be really better to follow the basic guidelines explained below.&lt;br /&gt;
&lt;br /&gt;
By using them you will be helping to have better, more secure and readable code. Spend some minutes trying to understand them, please!&lt;br /&gt;
&lt;br /&gt;
Of course, these functions can be discussed, modified and new functions can arrive if there are some good reasons for it. Just discuss it in the [http://moodle.org/mod/forum/view.php?id=55 General developer forum] at [http://moodle.org moodle.org].&lt;br /&gt;
&lt;br /&gt;
For each of the functions below we&#039;ll try to explain when they should be used, explaining the most important parameters supported and their meaning. Let&#039;s review them!&lt;br /&gt;
&lt;br /&gt;
=== p() and s() ===&lt;br /&gt;
&lt;br /&gt;
 function s($var, $strip=false)&lt;br /&gt;
 function p($var, $strip=false)&lt;br /&gt;
&lt;br /&gt;
These functions share the same code so they will be explained together. The only difference is that s() returns the string while p() prints it directly.&lt;br /&gt;
&lt;br /&gt;
These functions should be used to:&lt;br /&gt;
&lt;br /&gt;
* print all the &#039;&#039;&#039;values of form fields&#039;&#039;&#039; like &amp;lt;nowiki&amp;gt;&amp;lt;input&amp;gt;&amp;lt;/nowiki&amp;gt; or &amp;lt;nowiki&amp;gt;&amp;lt;textarea&amp;gt;&amp;lt;/nowiki&amp;gt; tags.&lt;br /&gt;
* to &#039;&#039;&#039;show plain (non html) text&#039;&#039;&#039; that has been introduced by the user (search string, quiz responses...).&lt;br /&gt;
* in general, all the &#039;&#039;&#039;dynamic data, not being html&#039;&#039;&#039;, that doesn&#039;t need to be cleaned nor processed by filters&lt;br /&gt;
&lt;br /&gt;
It is important not to use these functions for strings that contain html markup.&lt;br /&gt;
&lt;br /&gt;
The functions replace certain characters that would have special meaning in html ( &amp;lt;, &amp;gt;, &amp;quot;, &#039;, and &amp;amp;) by html entities so that they are displayed as intended. Note that even though the value of form fields printed with p() will have these characters converted to html entities, the submitted values will contain the original characters again.&lt;br /&gt;
&lt;br /&gt;
The key parameter for this function is:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;strip&#039;&#039;&#039;: it decides if we want to strip slashes from the string or no. By default it&#039;s &#039;false&#039; so no strip will be performed. We should set such parameter to &#039;true&#039; only when data to be processed isn&#039;t coming from database but from http requests (forms, links...).&lt;br /&gt;
&lt;br /&gt;
=== format_text() ===&lt;br /&gt;
&lt;br /&gt;
 function format_text($text, $format=FORMAT_MOODLE, $options=NULL, $courseid=NULL ) &lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* print &#039;&#039;&#039;any html/plain/markdown/moodle text&#039;&#039;&#039;, needing any of the features below. Mainly used for long strings like posts, answers, glossary items...&lt;br /&gt;
&lt;br /&gt;
Note that this function is really &#039;&#039;&#039;heavy&#039;&#039;&#039; because it supports &#039;&#039;&#039;cleaning&#039;&#039;&#039; of dangerous contents, delegates processing to enabled &#039;&#039;&#039;filter&#039;&#039;&#039;s, supports different &#039;&#039;&#039;formats&#039;&#039;&#039; of text (HTML, PLAIN, MARKDOWN, MOODLE) and performs a lot of &#039;&#039;&#039;automatic conversions&#039;&#039;&#039; like adding smilies, build links. Also, it includes a strong &#039;&#039;&#039;cache mechanism&#039;&#039;&#039; (DB based) that will alleviate the server from a lot of work processing the same texts time and again.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;format&#039;&#039;&#039;: To tell the function about how the data has been entered. It defaults to FORMAT_MOODLE that is a cool format to process plain text because it features automatic link conversion, smilies and good conversion to html output. Other formats are FORMAT_HTML, FORMAT_PLAIN, FORMAT_MARKDOWN. See [[Formatting options]].&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;options&#039;&#039;&#039;: Here we can specify how we want the process to be performed. You only need to define them if they are different from the default value assumed. Main options are:&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;noclean&#039;&#039;&#039;: To decide if we want to skip the clean of text, &#039;&#039;&#039;un-protecting us&#039;&#039;&#039; from attacks and other security flaws (defaults to false, so protection is enabled. You &#039;&#039;&#039;shouldn&#039;t set it to true ever&#039;&#039;&#039; unless you are 200% sure that only controlled users can edit it (mainly admins). &#039;&#039;&#039;Never use it for general text places&#039;&#039;&#039; (posts...) or you will be, sooner or later, attacked! Note that this option is ignored for FORMAT_PLAIN, the text is never cleaned.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;filter&#039;&#039;&#039;: To decide if you want to allow filters to process the text (defaults to true). This is ignored by FORMAT_PLAIN for which filters are never applied.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;smiley&#039;&#039;&#039;: To decide if we want automatic conversion of smilies to images (defaults to true). This is ignored by FORMAT_PLAIN for which smileys are never converted.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;para&#039;&#039;&#039;: To decide if you want every paragraph automatically enclosed between html paragraph tags (&amp;lt;nowiki&amp;gt;&amp;lt;p&amp;gt;...&amp;lt;/p&amp;gt;&amp;lt;/nowiki&amp;gt;) (defaults to true). This option only applies to FORMAT_MOODLE.&lt;br /&gt;
**&#039;&#039;&#039;options-&amp;gt;newlines&#039;&#039;&#039;: To decide if linefeeds in text should be converted to html newlines (&amp;lt;nowiki&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;/nowiki&amp;gt;) (defaults to true). This option only applies to FORMAT_MOODLE.&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help filters to know how they should work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
&lt;br /&gt;
=== format_string() ===&lt;br /&gt;
&lt;br /&gt;
 function format_string ($string, $striplinks = false, $courseid=NULL )&lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* print &#039;&#039;&#039;short strings (non html) that need filter processing&#039;&#039;&#039; (activity titles, post subjects, glossary concepts...).&lt;br /&gt;
&lt;br /&gt;
Please note that this function is basically one stripped version of the full format_text() function detailed above and &#039;&#039;&#039;it doesn&#039;t offer any of it options nor protections&#039;&#039;&#039;. It simply filters the strings and return the result, so we must ensure that text being processed has been properly cleaned at input time, using the proper xxx_param() functions.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;striplinks&#039;&#039;&#039;: To decide if, after the text has been processed by filters, we must delete any link from the result test. Used when we want to show the text inside menus, page titles... (defaults to false).&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help filters to know how they should work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
&lt;br /&gt;
=== print_textarea() ===&lt;br /&gt;
&lt;br /&gt;
 function print_textarea($usehtmleditor, $rows, $cols, $width, &lt;br /&gt;
                        $height, $name, $value=&amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, $courseid=0, $return=false)&lt;br /&gt;
&lt;br /&gt;
This function should be used to:&lt;br /&gt;
&lt;br /&gt;
* display &amp;lt;nowiki&amp;gt;&amp;lt;textarea&amp;gt;&amp;lt;/nowiki&amp;gt; fields when we want to allow users (based in their preferences and browser capabilities) &#039;&#039;&#039;to use the visual HTML editor&#039;&#039;&#039; instead of one standard &#039;plain&#039; area.&lt;br /&gt;
&lt;br /&gt;
Some interesting parameters for this function are:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;usehtmleditor&#039;&#039;&#039;: to decide if the HTML editor must be showed. The value of this parameter must be calculated by the can_use_html_editor() function.&lt;br /&gt;
* &#039;&#039;&#039;rows, cols&#039;&#039;&#039;: to be applied it the standard textarea is showed.&lt;br /&gt;
* &#039;&#039;&#039;width, height&#039;&#039;&#039;: to be applied if the HTML editor is used.&lt;br /&gt;
* &#039;&#039;&#039;name&#039;&#039;&#039;: the name of the field that will contain the text once the form was submitted.&lt;br /&gt;
* &#039;&#039;&#039;value&#039;&#039;&#039;: the initial value of the textarea.&lt;br /&gt;
* &#039;&#039;&#039;courseid&#039;&#039;&#039;: This parameter should be passed always to help the editor to know where it is work. This parameter will become less and less important Moodle was 100% of the current course using some session or global variable (it&#039;s one work in progress just now) but, for now, it&#039;s recommended to set it always in the function call.&lt;br /&gt;
* &#039;&#039;&#039;return&#039;&#039;&#039;: to decide if the generated html code must be returned to the caller (true) or printed directly (false). Defaults to false.&lt;br /&gt;
&lt;br /&gt;
[[Category:Output functions]]&lt;/div&gt;</summary>
		<author><name>Hccrle</name></author>
	</entry>
</feed>