<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/400/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fmcorz</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/400/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fmcorz"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/Special:Contributions/Fmcorz"/>
	<updated>2026-04-23T01:36:04Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111729</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111729"/>
		<updated>2014-04-11T08:02:39Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Blocks ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * File base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Right-to-left ==&lt;br /&gt;
&lt;br /&gt;
Developers always have to pay attention to RTL languages.&lt;br /&gt;
&lt;br /&gt;
=== Selector ===&lt;br /&gt;
&lt;br /&gt;
Always use the selector &amp;lt;code&amp;gt;.dir-rtl&amp;lt;/code&amp;gt; to define RTL rules. That class is set on the BODY tag, and it should be placed first if you are combining it with another BODY class. When you are using LESS, encapsulate all the rules in &amp;lt;code&amp;gt;.dir-rtl&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl.page-mod-something p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;body.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.page-mod-something.dir-rtl p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl {&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rule placement ===&lt;br /&gt;
&lt;br /&gt;
The RTL rules should be written close to the LTR ones, not in another file. Placing them close to the LTR ones helps (and reminds) the developers to fix both, without the need to search for the existence of RTL rules. If you are using LESS, it is advised to split a huge block into smaller chunks to help locating the corresponding LTR rules.&lt;br /&gt;
&lt;br /&gt;
=== Automatic compliance ===&lt;br /&gt;
&lt;br /&gt;
Whenever possible you should try to avoid writing specific RTL rules. It is more often than one would think possible to have one rule working for both LTR and RTL.&lt;br /&gt;
&lt;br /&gt;
==== Recommended ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin: 0 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== To avoid ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl p {&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What to style ===&lt;br /&gt;
&lt;br /&gt;
RTL rules should only apply to positioning properties, nothing else. And in most cases you will want to revert the LTR rules, to make sure that the rest works as expected.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@wellBackground: #ccc;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@wellBackground: #ccc;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintenance of the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111667</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111667"/>
		<updated>2014-04-09T09:48:51Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Right-to-left */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Blocks ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * File base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Right-to-left ==&lt;br /&gt;
&lt;br /&gt;
Developers always have to pay attention to RTL languages.&lt;br /&gt;
&lt;br /&gt;
=== Selector ===&lt;br /&gt;
&lt;br /&gt;
Always use the selector &amp;lt;code&amp;gt;.dir-rtl&amp;lt;/code&amp;gt; to define RTL rules. That class is set on the BODY tag, and it should be placed first if you are combining it with another BODY class. When you are using LESS, encapsulate all the rules in &amp;lt;code&amp;gt;.dir-rtl&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl.page-mod-something p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;body.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.page-mod-something.dir-rtl p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl {&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rule placement ===&lt;br /&gt;
&lt;br /&gt;
The RTL rules should be written close to the LTR ones, not in another file. Placing them close to the LTR ones helps (and reminds) the developers to fix both, without the need to search for the existence of RTL rules. If you are using LESS, it is advised to split a huge block into smaller chunks to help locating the corresponding LTR rules.&lt;br /&gt;
&lt;br /&gt;
=== Automatic compliance ===&lt;br /&gt;
&lt;br /&gt;
Whenever possible you should try to avoid writing specific RTL rules. It is more often than one would think possible to have one rule working for both LTR and RTL.&lt;br /&gt;
&lt;br /&gt;
==== Recommended ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin: 0 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== To avoid ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl p {&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What to style ===&lt;br /&gt;
&lt;br /&gt;
RTL rules should only apply to positioning properties, nothing else. And in most cases you will want to revert the LTR rules, to make sure that the rest works as expected.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintenance of the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111662</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111662"/>
		<updated>2014-04-09T08:12:45Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Documentation and comments */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Blocks ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * File base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Right-to-left ==&lt;br /&gt;
&lt;br /&gt;
Developers have to always pay attention to RTL languages.&lt;br /&gt;
&lt;br /&gt;
=== Selector ===&lt;br /&gt;
&lt;br /&gt;
Always use the selector &amp;lt;code&amp;gt;.dir-rtl&amp;lt;/code&amp;gt; to define RTL rules. That class is set on the BODY tag, and it should be placed first if you are combining it with another BODY class. When you are using LESS, encapsulate all the rules in &amp;lt;code&amp;gt;.dir-rtl&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl.page-mod-something p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;body.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.page-mod-something.dir-rtl p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl {&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rule placement ===&lt;br /&gt;
&lt;br /&gt;
The RTL rules should be written close to the LTR ones, not in another file. Placing them close to the LTR ones helps (and reminds) the developers to fix both, without the need to search for the existence of RTL rules. If you are using LESS, it is advised to split a huge block into smaller chunks to help locating the corresponding LTR rules.&lt;br /&gt;
&lt;br /&gt;
=== Automatic compliance ===&lt;br /&gt;
&lt;br /&gt;
Whenever possible you should try to avoid writing specific RTL rules. It is more often than one would think possible to have one rule working for both LTR and RTL.&lt;br /&gt;
&lt;br /&gt;
==== Recommended ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin: 0 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== To avoid ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl p {&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What to style ===&lt;br /&gt;
&lt;br /&gt;
RTL rules should only apply to positioning properties, nothing else. And in most cases you will want to revert the LTR rules, to make sure that the rest works as expected.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintenance of the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111661</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111661"/>
		<updated>2014-04-09T08:09:01Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Selector */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Blocks ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Right-to-left ==&lt;br /&gt;
&lt;br /&gt;
Developers have to always pay attention to RTL languages.&lt;br /&gt;
&lt;br /&gt;
=== Selector ===&lt;br /&gt;
&lt;br /&gt;
Always use the selector &amp;lt;code&amp;gt;.dir-rtl&amp;lt;/code&amp;gt; to define RTL rules. That class is set on the BODY tag, and it should be placed first if you are combining it with another BODY class. When you are using LESS, encapsulate all the rules in &amp;lt;code&amp;gt;.dir-rtl&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl.page-mod-something p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;body.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.page-mod-something.dir-rtl p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl {&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rule placement ===&lt;br /&gt;
&lt;br /&gt;
The RTL rules should be written close to the LTR ones, not in another file. Placing them close to the LTR ones helps (and reminds) the developers to fix both, without the need to search for the existence of RTL rules. If you are using LESS, it is advised to split a huge block into smaller chunks to help locating the corresponding LTR rules.&lt;br /&gt;
&lt;br /&gt;
=== Automatic compliance ===&lt;br /&gt;
&lt;br /&gt;
Whenever possible you should try to avoid writing specific RTL rules. It is more often than one would think possible to have one rule working for both LTR and RTL.&lt;br /&gt;
&lt;br /&gt;
==== Recommended ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin: 0 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== To avoid ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl p {&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What to style ===&lt;br /&gt;
&lt;br /&gt;
RTL rules should only apply to positioning properties, nothing else. And in most cases you will want to revert the LTR rules, to make sure that the rest works as expected.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintenance of the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111660</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111660"/>
		<updated>2014-04-09T08:08:31Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* LESS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Blocks ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Right-to-left ==&lt;br /&gt;
&lt;br /&gt;
Developers have to always pay attention to RTL languages.&lt;br /&gt;
&lt;br /&gt;
=== Selector ===&lt;br /&gt;
&lt;br /&gt;
Always use the selector &amp;lt;code css&amp;gt;.dir-rtl&amp;lt;/code&amp;gt; to define RTL rules. That class is set on the BODY tag, and it should be placed first if you are combining it with another BODY class. When you are using LESS, encapsulate all the rules in &amp;lt;code css&amp;gt;.dir-rtl&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl.page-mod-something p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;body.dir-rtl .something&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
.page-mod-something.dir-rtl p&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.dir-rtl {&lt;br /&gt;
    &amp;amp;.page-mod-something {&lt;br /&gt;
        p {&lt;br /&gt;
            padding-left: 0;&lt;br /&gt;
            padding-right: 1em;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl {&lt;br /&gt;
    .something {&lt;br /&gt;
        margin-left: 0;&lt;br /&gt;
        margin-right: 1em;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Rule placement ===&lt;br /&gt;
&lt;br /&gt;
The RTL rules should be written close to the LTR ones, not in another file. Placing them close to the LTR ones helps (and reminds) the developers to fix both, without the need to search for the existence of RTL rules. If you are using LESS, it is advised to split a huge block into smaller chunks to help locating the corresponding LTR rules.&lt;br /&gt;
&lt;br /&gt;
=== Automatic compliance ===&lt;br /&gt;
&lt;br /&gt;
Whenever possible you should try to avoid writing specific RTL rules. It is more often than one would think possible to have one rule working for both LTR and RTL.&lt;br /&gt;
&lt;br /&gt;
==== Recommended ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin: 0 1em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== To avoid ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;p {&lt;br /&gt;
    margin-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl p {&lt;br /&gt;
    margin-right: 1em;&lt;br /&gt;
    margin-left: 0;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== What to style ===&lt;br /&gt;
&lt;br /&gt;
RTL rules should only apply to positioning properties, nothing else. And in most cases you will want to revert the LTR rules, to make sure that the rest works as expected.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-left: 1em;&lt;br /&gt;
}&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    padding-left: 0;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.dir-rtl .something {&lt;br /&gt;
    text-color: red;&lt;br /&gt;
    padding-right: 1em;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintenance of the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111659</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111659"/>
		<updated>2014-04-09T07:45:49Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Block Style */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Blocks ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintenance of the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111658</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111658"/>
		<updated>2014-04-09T07:40:28Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Use constants */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Block Style ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintenance of the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111657</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111657"/>
		<updated>2014-04-09T07:38:28Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Block Style ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintaining the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111656</id>
		<title>User talk:Frédéric Massart</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_talk:Fr%C3%A9d%C3%A9ric_Massart&amp;diff=111656"/>
		<updated>2014-04-09T07:37:26Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: Created page with &amp;quot;== Overview ==  === Scope ===  This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and t...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Overview ==&lt;br /&gt;
&lt;br /&gt;
=== Scope ===&lt;br /&gt;
&lt;br /&gt;
This document describes style guidelines for developers working on or with Moodle code. It talks purely about the mechanics of code layout and the choices we have made for Moodle. &lt;br /&gt;
&lt;br /&gt;
=== Goals ===&lt;br /&gt;
&lt;br /&gt;
Consistent coding style is important in any development project, and particularly 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;
Abstract goals we strive for: &lt;br /&gt;
&lt;br /&gt;
* simplicity&lt;br /&gt;
* readability&lt;br /&gt;
* tool friendliness&lt;br /&gt;
&lt;br /&gt;
== File naming ==&lt;br /&gt;
&lt;br /&gt;
Within plugins, CSS files are normally named &amp;lt;code&amp;gt;styles.css&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In the theme, files can be named according to the theme designer&#039;s wishes but should:&lt;br /&gt;
&lt;br /&gt;
* use lowercase letters only&lt;br /&gt;
* be as short as possible&lt;br /&gt;
* be descriptive&lt;br /&gt;
* be placed in the folder &amp;lt;code&amp;gt;style/&amp;lt;/code&amp;gt; for CSS files, or in &amp;lt;code&amp;gt;less/&amp;lt;/code&amp;gt; for LESS files.&lt;br /&gt;
&lt;br /&gt;
== Block Style ==&lt;br /&gt;
&lt;br /&gt;
* Each selector should be on its own line. If there is a comma in a selector list, follow it with a line break.&lt;br /&gt;
* Property-value pairs should be on their own line, with four spaces of indentation and an ending semicolon.&lt;br /&gt;
* The closing brace should use the same level of indentation as the opening selector.&lt;br /&gt;
* Leave one line between blocks.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@media only screen and (min-width: 768px) {&lt;br /&gt;
    .selector-one,&lt;br /&gt;
    .selector-two {&lt;br /&gt;
        color: #fff;&lt;br /&gt;
        background-color: #000;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_one, .selector_two { color: #fff; background-color: #000; }&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Selectors ==&lt;br /&gt;
&lt;br /&gt;
* Always use lower case and underscores or hyphens. Hyphens are preferred.&lt;br /&gt;
* Names should be made of simple English words.&lt;br /&gt;
* Verbosity is encouraged: names should be as illustrative as is practical to enhance understanding.&lt;br /&gt;
* Use [http://css-tricks.com/semantic-class-names/ semantic names]: names tell what this is instead of what should it look like.&lt;br /&gt;
* Avoid using IDs. They are far more difficult to maintain and override.&lt;br /&gt;
* Do not over-qualify your rules by combining a tagname with a class or ID.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector_name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector-name {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div#selName {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.Color-White {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Properties and values ==&lt;br /&gt;
&lt;br /&gt;
* Should be separated by a colon and a single space, do not minify them.&lt;br /&gt;
* Should be lowercase, except for font names and vendor-specific properties.&lt;br /&gt;
* For color codes, lowercase is preferred and a shorthand whenever possible.&lt;br /&gt;
* For color codes, if you use HSLA or RGBA, always provide a hex fallback.&lt;br /&gt;
* Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values.&lt;br /&gt;
* Do not use &amp;lt;code&amp;gt;!important&amp;lt;/code&amp;gt;. If there is no alternative something is wrong with the CSS you are trying to override.&lt;br /&gt;
* Prefixed vendor-specific properties pairs should appear directly before the generic property they refer to.&lt;br /&gt;
* Indent vendor prefixed declarations so that their values are aligned&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    color: #fff;&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
       -moz-border-radius: 4px;&lt;br /&gt;
            border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
.selector {&lt;br /&gt;
    margin-top: 1px;&lt;br /&gt;
    color: #f90;&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;#selector {&lt;br /&gt;
    color: hsla(0, 0%, 100%, 1);&lt;br /&gt;
    -webkit-border-radius: 4px;&lt;br /&gt;
    -moz-border-radius: 4px;&lt;br /&gt;
    border-radius: 4px;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
#selector {&lt;br /&gt;
    margin-top:1px;&lt;br /&gt;
    color :#ff9900 !important;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Units ==&lt;br /&gt;
&lt;br /&gt;
* Prefer the usage of &#039;&#039;em&#039;&#039; over &#039;&#039;px&#039;&#039;.&lt;br /&gt;
* Do not use the units &#039;&#039;pt&#039;&#039; or &#039;&#039;rem&#039;&#039;. MDL-39934&lt;br /&gt;
* Do not declare the unit when the value is 0.&lt;br /&gt;
&lt;br /&gt;
=== Correct ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0;&lt;br /&gt;
    font-size: 1.25em;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Incorrect ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.something {&lt;br /&gt;
    margin-top: 0px;&lt;br /&gt;
    font-size: 1.25rem;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Documentation and comments ==&lt;br /&gt;
&lt;br /&gt;
Following the general [[Coding style]], comments should start with a capital letter and end with a period.&lt;br /&gt;
&lt;br /&gt;
A block-style comment at the top of the CSS file should explain the purpose of the rules in the file.&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * base.css.&lt;br /&gt;
 * Contains base styles for theme basic.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Block-style comments can also be used to denote a section in a CSS file where all rules pertain to a specific component, view, or functionality:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/**&lt;br /&gt;
 * SCORM Navigation Sidebar.&lt;br /&gt;
 */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use single-line comments to provide more information to other developers about a single rule or small subset of rules:&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
/* Required because YUI resets add a black border to all tables */&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Progressive enhancement ==&lt;br /&gt;
&lt;br /&gt;
* Fallbacks should always be provided. For example, provide a background color fallback to background images and gradients.&lt;br /&gt;
* Use vendor prefixes only when the supported browser in question does not support the unprefixed property.&lt;br /&gt;
* The standard property should come after the vendor-prefixed property.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.selector {&lt;br /&gt;
    background-color: #444; /* Fallback for browsers that don&#039;t support gradients. */&lt;br /&gt;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorStr=&#039;#444&#039;, EndColorStr=&#039;#999&#039;); /* IE6-IE9. */&lt;br /&gt;
    background-image: -webkit-gradient(linear, left top, left bottom, from(#444), to(#999)); /* Safari 4+, Chrome. */&lt;br /&gt;
    background-image: -webkit-linear-gradient(top, #444, #999); /* Chrome 10+, Safari 5.1+, iOS 5+. */&lt;br /&gt;
    background-image: -moz-linear-gradient(top, #444, #999); /* Firefox 3.6. */&lt;br /&gt;
    background-image: -ms-linear-gradient(top, #444, #999); /* IE10. */&lt;br /&gt;
    background-image: -o-linear-gradient(top, #444, #999); /* Opera 11.10+. */&lt;br /&gt;
    background-image: linear-gradient(top, #444, #999); /* W3C Standard. */&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Browser Hacks ==&lt;br /&gt;
&lt;br /&gt;
* Do not use any browser-specific hacks. Moodle provides a more appropriate way to write browser-specific CSS using classes that are added to the body element. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;&lt;br /&gt;
.ie7 .forum-post {&lt;br /&gt;
    min-height: 1px;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* It is not necessary to include hacks for versions of browsers that Moodle core does not provide support for (e.g. IE6 in Moodle 2, except legacy theme).&lt;br /&gt;
&lt;br /&gt;
== Plugins ==&lt;br /&gt;
&lt;br /&gt;
In plugins, the file names can be:&lt;br /&gt;
&lt;br /&gt;
* styles.css (Recommended)&lt;br /&gt;
* styles_&amp;lt;theme name&amp;gt;.css (Not recommended, reserved to 3rd party plugins)&lt;br /&gt;
&lt;br /&gt;
=== Barebones ===&lt;br /&gt;
&lt;br /&gt;
Plugins should define the strict minimum, no text sizes, colours, etc ... those should belong to the theme and not be hardcoded in plugins to allow for easy theming. Of course, this requires Moodle core to provide re-usable classes to style the elements. As Moodle 2.7 has made Bootstrap 2 by default we can start using their classes, but we should make sure that there is a sensible fallback for themes not extending &#039;&#039;bootstrapbase&#039;&#039;, such as &#039;&#039;base&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== LESS ==&lt;br /&gt;
&lt;br /&gt;
[http://lesscss.org/ LESS] works like CSS with some extra features. It should follow the CSS guidelines.&lt;br /&gt;
&lt;br /&gt;
=== Variables ===&lt;br /&gt;
&lt;br /&gt;
* They should use camelCase to follow Bootstrap 2 that is used in core.&lt;br /&gt;
* As for CSS selectors, use semantic names: names tell what this is instead of what should it look like.&lt;br /&gt;
* As Bootstrap 2 does, do not add the word &amp;quot;Color&amp;quot; to variables for _background_ or _border_ and their derivatives.&lt;br /&gt;
* Declaring new variables should be done sparingly, too many variables kill the purpose of using them. If you declare one, try to set its default value from another one.&lt;br /&gt;
* Do not declare more variables than necessary. E.g.: If the background color and border color are likely to always be the same, prefer one variable.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@textColor: red;&lt;br /&gt;
@tableBackground: blue;&lt;br /&gt;
@blockBackground: @wellBackground;&lt;br /&gt;
@calendarGroupEvent: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;@text-color: red;&lt;br /&gt;
@tableBackgrounColor: blue;&lt;br /&gt;
@blockBackground: #ccc;&lt;br /&gt;
@calendarGroupEventBackground: #f90;&lt;br /&gt;
@calendarGroupEventBorder: #f90;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Selectors ===&lt;br /&gt;
&lt;br /&gt;
* Selectors should be encapsulated rather than duplicated.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div {&lt;br /&gt;
    .something {&lt;br /&gt;
        a {&lt;br /&gt;
            color: blue;&lt;br /&gt;
        }&lt;br /&gt;
        color: red;&lt;br /&gt;
    }&lt;br /&gt;
    .something-else a {&lt;br /&gt;
        color: green;&lt;br /&gt;
    }&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;div .something {&lt;br /&gt;
    color: red;&lt;br /&gt;
}&lt;br /&gt;
div .something a {&lt;br /&gt;
    color: blue;&lt;br /&gt;
}&lt;br /&gt;
div .something-else a {&lt;br /&gt;
    color: green;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Values and properties ===&lt;br /&gt;
&lt;br /&gt;
* Colours, font sizes, etc... should never be hardcoded, use a variable instead.&lt;br /&gt;
* Use mixins instead of duplicating values and properties.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: @fontSizeSmall;&lt;br /&gt;
    color: @errorText;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: @errorBackground;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    .error;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code css&amp;gt;.error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&lt;br /&gt;
div .form-error {&lt;br /&gt;
    font-size: 12px;&lt;br /&gt;
    color: red;&lt;br /&gt;
    padding: 1em;&lt;br /&gt;
    background-color: white;&lt;br /&gt;
}&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Javascript ==&lt;br /&gt;
&lt;br /&gt;
=== Use constants ===&lt;br /&gt;
&lt;br /&gt;
Any Javascript code using some CSS to style or target elements should use constants, not directly use the class names or IDs in the code. This greatly helps maintaining the code.&lt;br /&gt;
&lt;br /&gt;
==== Correct ====&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code javascript&amp;gt;var CSS = {&lt;br /&gt;
    GROUP: &#039;some-group&#039;&lt;br /&gt;
}&lt;br /&gt;
var SELECTORS {&lt;br /&gt;
    GROUP: &#039;.&#039; + CSS.GROUP&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Y.Node.create(&#039;&amp;lt;div class=&amp;quot;&#039; + CSS.GROUP + &#039;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;&#039;);&lt;br /&gt;
Y.all(SELECTORS.GROUP);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Incorrect ====&lt;br /&gt;
6&lt;br /&gt;
&amp;lt;code javascript&amp;gt;Y.Node.create(&#039;&amp;lt;div class=&amp;quot;some-group&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&#039;&#039;);&lt;br /&gt;
Y.all(&#039;.some-group&#039;);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Themes Clean and More ==&lt;br /&gt;
&lt;br /&gt;
Clean theme should not contain any CSS or LESS content, it should fully inherit from &#039;&#039;theme_bootstrapbase&#039;&#039;. More can contain a little portion of LESS to ensure that customization is possible, but it should be almost inherit fully from &#039;&#039;theme_bootstrapbase&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[Category:Coding guidelines]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Upload_courses&amp;diff=108137</id>
		<title>Upload courses</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Upload_courses&amp;diff=108137"/>
		<updated>2013-12-02T06:14:42Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Enrolment fields */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Courses}}&lt;br /&gt;
{{New features}}In Moodle 2.6 onwards, an administrator can upload multiple courses via text file in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Courses &amp;gt; Upload courses&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
In addition to creating new courses, this functionality may also be used to update or delete courses, or import content from another course. For information on using this functionality to create course templates, see [[Adding a new course]]&lt;br /&gt;
&lt;br /&gt;
==Upload courses==&lt;br /&gt;
&lt;br /&gt;
To upload one or more courses&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Courses &amp;gt; Upload courses&#039;&#039;&lt;br /&gt;
# Either drag and drop the CSV file or click the &#039;Choose a file&#039; button and select the file in the file picker&lt;br /&gt;
# Select appropriate import options carefully, then click the preview button.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[File:26uploadcourses.png|250px|thumb|Upload courses admin screen]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:uploadcoursesresults.png|250px|thumb|Courses successfully uploaded]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note: It is also possible to use the command-line tool &#039;&#039;admin/tool/uploadcourse/cli/uploadcourse.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When using the web interface, use the &#039;&#039;Preview&#039;&#039; option to see if any errors were detected in the previewed rows. If you proceed with the upload and there were something wrong detected with a course, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
=== Short file example ===&lt;br /&gt;
uploadcourse.csv:&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
shortname,fullname,category,summary,enrolment_1,enrolment_1_role,enrolment_1_enrolperiod,role_student&lt;br /&gt;
courserestored,Course restored,1,a summary,manual,student,1 month,&lt;br /&gt;
courserestored2,Course restored 2,1,a summary,,,,&lt;br /&gt;
courserestored3,Course restored 3,1,a summary,,,,padawan&lt;br /&gt;
courserestored4,Course restored 4,1,&amp;quot;a summary, with comma&amp;quot;,manual,student,1 month,padawan&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Notice there are no spaces between the items.&lt;br /&gt;
&lt;br /&gt;
==Creating the text file==&lt;br /&gt;
&lt;br /&gt;
The text file to upload courses must be a CSV file. It accepts the following columns which are divided in two categories, the course information, and the course actions.&lt;br /&gt;
&lt;br /&gt;
===Course information fields===&lt;br /&gt;
&lt;br /&gt;
Most of those settings are available on the settings page of a course. Please refer to [[Course settings]] for more information.&lt;br /&gt;
&lt;br /&gt;
;shortname&lt;br /&gt;
: The shortname&lt;br /&gt;
;fullname&lt;br /&gt;
: The full name&lt;br /&gt;
;idnumber&lt;br /&gt;
: The ID number&lt;br /&gt;
;category&lt;br /&gt;
: The ID of the category to place the course in. This takes precedence over &#039;&#039;category_idnumber&#039;&#039; and &#039;&#039;category_path&#039;&#039;.&lt;br /&gt;
;category_idnumber&lt;br /&gt;
: The ID number of the category to place the course in. This takes precedence over &#039;&#039;category_path&#039;&#039;.&lt;br /&gt;
;category_path&lt;br /&gt;
: The path of the category to place the course in. If you want to place the course in a category named &amp;quot;Science-Fiction&amp;quot; which is located under the category &amp;quot;Movies&amp;quot;, the value to provide is: &amp;lt;code&amp;gt;Movies &amp;gt; Science-Fiction&amp;lt;/code&amp;gt;. Note that the separator must be &amp;lt;code&amp;gt;[space]&amp;gt;[space]&amp;lt;/code&amp;gt;. Also note that the category MUST exist, it will not be created.&lt;br /&gt;
;visible&lt;br /&gt;
: 1 if the course is visible, 0 if hidden&lt;br /&gt;
;startdate&lt;br /&gt;
: The time at which the course starts. Please note that this value is passed to the PHP function [http://php.net/manual/en/function.strtotime.php strtotime] to generate a timestamp.&lt;br /&gt;
;summary&lt;br /&gt;
: The summary of the course&lt;br /&gt;
;format&lt;br /&gt;
: The course format to use, this must be a valid course format plugin name. E.g. &#039;&#039;weeks&#039;&#039;, &#039;&#039;topics&#039;&#039;.&lt;br /&gt;
;theme&lt;br /&gt;
: The theme to use&lt;br /&gt;
;lang&lt;br /&gt;
: The language to use&lt;br /&gt;
;newsitems&lt;br /&gt;
: The number of news items&lt;br /&gt;
;showgrades&lt;br /&gt;
: 1 to show the gradebook to students, 0 to hide it.&lt;br /&gt;
;showreports&lt;br /&gt;
: 1 to show the activity reports, 0 to hide it.&lt;br /&gt;
;legacyfiles&lt;br /&gt;
: 1 to enable the legacy course files, 0 not to.&lt;br /&gt;
;maxbytes&lt;br /&gt;
: The maximum upload size of the course in bytes. Use 0 for the site limit.&lt;br /&gt;
;groupmode&lt;br /&gt;
: 0 for &#039;&#039;No groups&#039;&#039;, 1 for &#039;&#039;Separate groups&#039;&#039; and 2 for &#039;&#039;Visible groups&#039;&#039;.&lt;br /&gt;
;groupmodeforce&lt;br /&gt;
: 1 to force the group mode, otherwise enter 0.&lt;br /&gt;
;enablecompletion&lt;br /&gt;
: 1 to enable the activity completion, 0 not to.&lt;br /&gt;
&lt;br /&gt;
====Enrolment fields====&lt;br /&gt;
&lt;br /&gt;
Some fields can be constructed to enable and configure enrolment methods. The fields must be named &#039;&#039;enrolment_[number]&#039;&#039; for the enrolment method name, and &#039;&#039;enrolment_[number]_property&#039;&#039; for its properties.&lt;br /&gt;
&lt;br /&gt;
;enrolment_[number]&lt;br /&gt;
: The name of the enrolment method&lt;br /&gt;
;enrolment_[number]_delete&lt;br /&gt;
: 1 to delete this enrolment method from the course, if set to 1 all the other properties will be ignored.&lt;br /&gt;
;enrolment_[number]_disable&lt;br /&gt;
: 1 to disable this enrolment method from the course, if set to 1 all the other properties will be ignored.&lt;br /&gt;
;enrolment_[number]_startdate&lt;br /&gt;
: The enrolment start date. This value is passed to the PHP function strtotime().&lt;br /&gt;
;enrolment_[number]_enddate&lt;br /&gt;
: The enrolment start date. This value is passed to the PHP function strtotime().&lt;br /&gt;
;enrolment_[number]_enrolperiod&lt;br /&gt;
: Number of seconds, or if not a value understood by strtotime() such as &amp;quot;4 days&amp;quot;.&lt;br /&gt;
;enrolment_[number]_role&lt;br /&gt;
: The role short name&lt;br /&gt;
;enrolment_[number]_[property]&lt;br /&gt;
: Where property is understood by the specified enrolment method&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 enrolment_1: manual&lt;br /&gt;
 enrolment_1_role: student&lt;br /&gt;
 enrolment_1_enrolperiod: 1 month&lt;br /&gt;
 &lt;br /&gt;
 enrolment_2: self&lt;br /&gt;
 enrolment_2_startdate: 2013-01-30&lt;br /&gt;
&lt;br /&gt;
====Role renaming====&lt;br /&gt;
&lt;br /&gt;
To rename some roles, using the following pattern:&lt;br /&gt;
&lt;br /&gt;
;role_[shortname]&lt;br /&gt;
: The new name of the role &#039;&#039;[shortname]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 role_student: Apprentice&lt;br /&gt;
 role_teacher: Master&lt;br /&gt;
 role_mycustomrole: Jedi&lt;br /&gt;
&lt;br /&gt;
===Course action fields===&lt;br /&gt;
&lt;br /&gt;
Those settings take precedence over the &#039;&#039;Course process&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
;delete&lt;br /&gt;
: 1 to delete the course &lt;br /&gt;
;rename&lt;br /&gt;
: The shortname to rename the course to&lt;br /&gt;
;backupfile&lt;br /&gt;
: An absolute path to a backup file (.mbz) to import in the course&lt;br /&gt;
;templatecourse&lt;br /&gt;
: The short name of a course to import the content from&lt;br /&gt;
;reset&lt;br /&gt;
: 1 to reset the course&lt;br /&gt;
&lt;br /&gt;
===Mandatory fields===&lt;br /&gt;
&lt;br /&gt;
;shortname&lt;br /&gt;
: This field is mandatory for every operation, with the only exception of creating new courses. See details on the course process parameter &#039;&#039;Shortname template&#039;&#039; for more information.&lt;br /&gt;
;fullname&lt;br /&gt;
: Required when creating a new course.&lt;br /&gt;
;category, category_idnumber, category_path&lt;br /&gt;
: One of these is required when creating a course.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Import options===&lt;br /&gt;
&lt;br /&gt;
To prevent unexpected behaviour, you have to specify what you want the tool to be able to do.&lt;br /&gt;
&lt;br /&gt;
;Upload mode&lt;br /&gt;
: This allows you to specify if courses can be created and/or updated.&lt;br /&gt;
;Update mode&lt;br /&gt;
: If you allow courses to be updated, you also have to tell the tool what to update the courses with.&lt;br /&gt;
;Allow deletes&lt;br /&gt;
: Whether the &#039;&#039;delete&#039;&#039; field is accepted or not&lt;br /&gt;
;Allow renames&lt;br /&gt;
: Whether the &#039;&#039;rename&#039;&#039; field is accepted or not&lt;br /&gt;
;Allow resets&lt;br /&gt;
: Whether the &#039;&#039;reset&#039;&#039; field is accepted or not&lt;br /&gt;
&lt;br /&gt;
===Course process===&lt;br /&gt;
&lt;br /&gt;
This allows you to specify actions to be taken for every course uploaded.&lt;br /&gt;
&lt;br /&gt;
;Shortname template&lt;br /&gt;
: If you are creating courses without a shortname, you can use this field to automatically generate a shortname. This field accepts two placeholders: %i for the ID number, %f for the summary.&lt;br /&gt;
;Restore file&lt;br /&gt;
: A backup file (.mbz) to import in the course after create/update.&lt;br /&gt;
;Restore from course&lt;br /&gt;
: The shortname of a course to import content from after create/update.&lt;br /&gt;
;Reset after upload&lt;br /&gt;
: Whether to reset the course after creating/updating it.&lt;br /&gt;
&lt;br /&gt;
===Default course values===&lt;br /&gt;
&lt;br /&gt;
Those are values that can be set in the web interface for all the fields that are not specified in the CSV file. Note that they are always used when creating a course, but only when specified during update (see &#039;&#039;Update mode&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==Increasing speed==&lt;br /&gt;
&lt;br /&gt;
When importing the content of a backup file, or another course, you are advised to enable the setting &#039;&#039;keeptempdirectoriesonbackup&#039;&#039;. This will considerably speed up the process of the upload if you are importing multiple times from the same source.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Demo screencast: [http://www.youtube.com/watch?v=MzK2jb-9SwE&amp;amp;feature=share&amp;amp;list=SPxcO_MFWQBDe8RRnGjoUDqbcm9PSlIoWn Upload users]&lt;br /&gt;
* [[Upload users]]&lt;br /&gt;
* [http://www.moodleblog.net/2013/11/24/creating-course-templates-in-moodle-2-6/ Creating course templates in Moodle 2.6] blog post by Mary Cooch&lt;br /&gt;
&lt;br /&gt;
[[de:Kurse hochladen]]&lt;br /&gt;
[[es:Subir cursos]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Notes&amp;diff=107991</id>
		<title>Notes</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Notes&amp;diff=107991"/>
		<updated>2013-11-26T03:28:38Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: Styling fix&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{More features}}&lt;br /&gt;
The Notes feature is a way to attach information about a user by another user.  For example, a teacher might attach a note to a specific student about the hobbies and interests that seems to engage that student.  &lt;br /&gt;
&lt;br /&gt;
Users must have the permissions to [[Capabilities/moodle/notes:view|View notes]] and [[Capabilities/moodle/notes:manage|Manage notes]]  in order to use this feature in any context. Thus students might be allowed to view or even manage notes within a course.&lt;br /&gt;
  &lt;br /&gt;
==Accessing Notes==&lt;br /&gt;
&lt;br /&gt;
Users must have the permissions to [[Capabilities/moodle/notes:view|View notes]] and [[Capabilities/moodle/notes:manage|Manage notes]] in order to use this feature in any context. Thus students can be allowed to view or even manage notes within a course.&lt;br /&gt;
&lt;br /&gt;
The Notes page may be accessed via the Navigation block via &#039;&#039;Site pages &amp;gt; Notes&#039;&#039;, &#039;&#039;My Profile &amp;gt; Notes&#039;&#039; and/or &#039;&#039;Courses &amp;gt; Course Name &amp;gt; Participants &amp;gt; &#039;&#039;&#039;Moodle User&#039;&#039;&#039; &amp;gt; Notes&#039;&#039; - depending on your access rights and the context at which the Notes has been set.  &lt;br /&gt;
&lt;br /&gt;
==Note context==&lt;br /&gt;
&lt;br /&gt;
A Note&#039;s [[Context|context]] determines which users can see the note.  You can select from one of the below options when creating or editing a Note.&lt;br /&gt;
&lt;br /&gt;
* Personal - The note will be visible only to you (as the Note author)&lt;br /&gt;
* Course - The note will be visible to other Managers and Teachers in this course (or any users with [[Capabilities/moodle/notes:view|notes:view]] capability in this course)&lt;br /&gt;
* Site - The note will be visible to other Managers and Teachers in all courses (or any users with [[Capabilities/moodle/notes:view|notes:view]] capability in any course) when viewing within a course&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
&lt;br /&gt;
*Notes may be disabled by unticking the &#039;&#039;enablenotes&#039;&#039; checkbox in &#039;&#039;Site administration &amp;gt; [[Advanced features]]&#039;&#039;.&lt;br /&gt;
*An Admin, Manager or Teacher may have used the Notes functionality to create private teaching notes regarding a user and changing this user&#039;s permissions (or their Role type) will give them access to this information&lt;br /&gt;
* Users with this capability set to Allow can edit and delete another user&#039;s Note(s)&lt;br /&gt;
* Users can only view Notes that have been created within the same context to which their Role has been assigned (e.g. Site, Course, Personal/User).&lt;br /&gt;
** Example 1: A Note set to Site Context can be viewed by a Site Administrator at the site level (Site pages&amp;gt; Notes) or by a Teacher when within their own course.&lt;br /&gt;
** Example 2: A Note set to Course Context can only be viewed by a Site Administrator when they are in the course in which it was created&lt;br /&gt;
** Example 3: A Teacher can only view a Course Context Note when viewed within a course both they and the student/user are associated with&lt;br /&gt;
* Notes can be added against any user within the site where the Note author has access rights to view and edit a user&#039;s profile and the ability to [[Capabilities/moodle/notes:view|View notes]] and [[Capabilities/moodle/notes:manage|Manage notes]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Notes FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Notes]]&lt;br /&gt;
&lt;br /&gt;
[[de:Anmerkungen]]&lt;br /&gt;
[[es:Notas]]&lt;br /&gt;
[[eu:Oharrak]]&lt;br /&gt;
[[fr:Annotations]]&lt;br /&gt;
[[ja:ノート]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=admin/tool/uploadcourse/index&amp;diff=107154</id>
		<title>admin/tool/uploadcourse/index</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=admin/tool/uploadcourse/index&amp;diff=107154"/>
		<updated>2013-10-23T07:40:51Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: Removing outdated documentation and linking to new page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Upload courses]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Upload_courses&amp;diff=107153</id>
		<title>Upload courses</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Upload_courses&amp;diff=107153"/>
		<updated>2013-10-23T07:38:22Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Course information fields */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Courses}}&lt;br /&gt;
&lt;br /&gt;
{{New features}}&lt;br /&gt;
An administrator can upload multiple courses using a text file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things you can do when using this tool:not only creating courses, but updating or deleting them. You can also update the course enrolment methods or import the content of another course.&lt;br /&gt;
&lt;br /&gt;
==The text file==&lt;br /&gt;
&lt;br /&gt;
The text file to upload courses must be a CSV file. It accepts the following columns which are divided in two categories, the course information, and the course actions.&lt;br /&gt;
&lt;br /&gt;
===Course information fields===&lt;br /&gt;
&lt;br /&gt;
Most of those settings are available on the settings page of a course, please refer to it for more information.&lt;br /&gt;
&lt;br /&gt;
;shortname&lt;br /&gt;
: The shortname&lt;br /&gt;
;fullname&lt;br /&gt;
: The full name&lt;br /&gt;
;idnumber&lt;br /&gt;
: The ID number&lt;br /&gt;
;category&lt;br /&gt;
: The ID of the category to place the course in. This takes precedence over &#039;&#039;category_idnumber&#039;&#039; and &#039;&#039;category_path&#039;&#039;.&lt;br /&gt;
;category_idnumber&lt;br /&gt;
: The ID number of the category to place the course in. This takes precedence over &#039;&#039;category_path&#039;&#039;.&lt;br /&gt;
;category_path&lt;br /&gt;
: The path of the category to place the course in. If you want to place the course in a category named &amp;quot;Science-Fiction&amp;quot; which is located under the category &amp;quot;Movies&amp;quot;, the value to provide is: &amp;lt;code&amp;gt;Movies &amp;gt; Science-Fiction&amp;lt;/code&amp;gt;. Note that the separator must be &amp;lt;code&amp;gt;[space]&amp;gt;[space]&amp;lt;/code&amp;gt;. Also note that the category MUST exist, it will not be created.&lt;br /&gt;
;visible&lt;br /&gt;
: 1 if the course is visible, 0 if hidden&lt;br /&gt;
;startdate&lt;br /&gt;
: The time at which the course starts. Please note that this value is passed to the PHP function [http://php.net/manual/en/function.strtotime.php strtotime] to generate a timestamp.&lt;br /&gt;
;summary&lt;br /&gt;
: The summary of the course&lt;br /&gt;
;format&lt;br /&gt;
: The course format to use, this must be a valid course format plugin name. E.g. &#039;&#039;weeks&#039;&#039;, &#039;&#039;topics&#039;&#039;.&lt;br /&gt;
;theme&lt;br /&gt;
: The theme to use&lt;br /&gt;
;lang&lt;br /&gt;
: The language to use&lt;br /&gt;
;newsitems&lt;br /&gt;
: The number of news items&lt;br /&gt;
;showgrades&lt;br /&gt;
: 1 to show the gradebook to students, 0 to hide it.&lt;br /&gt;
;showreports&lt;br /&gt;
: 1 to show the activity reports, 0 to hide it.&lt;br /&gt;
;legacyfiles&lt;br /&gt;
: 1 to enable the legacy course files, 0 not to.&lt;br /&gt;
;maxbytes&lt;br /&gt;
: The maximum upload size of the course in bytes. Use 0 for the site limit.&lt;br /&gt;
;groupmode&lt;br /&gt;
: 0 for &#039;&#039;No groups&#039;&#039;, 1 for &#039;&#039;Separate groups&#039;&#039; and 2 for &#039;&#039;Visible groups&#039;&#039;.&lt;br /&gt;
;groupmodeforce&lt;br /&gt;
: 1 to force the group mode, otherwise enter 0.&lt;br /&gt;
;enablecompletion&lt;br /&gt;
: 1 to enable the activity completion, 0 not to.&lt;br /&gt;
&lt;br /&gt;
====Enrolment fields====&lt;br /&gt;
&lt;br /&gt;
Some fields can be constructed to enable and configure enrolment methods. The fields must be named &#039;&#039;enrolment_[number]&#039;&#039; for the enrolment method name, and &#039;&#039;enrolment_[number]_property&#039;&#039; for its properties.&lt;br /&gt;
&lt;br /&gt;
;enrolment_[number]&lt;br /&gt;
: The name of the enrolment method&lt;br /&gt;
;enrolment_[number]_delete&lt;br /&gt;
: 1 to delete this enrolment method from the course, if set to 1 all the other properties will be ignored.&lt;br /&gt;
;enrolment_[number]_disable&lt;br /&gt;
: 1 to disable this enrolment method from the course, if set to 1 all the other properties will be ignored.&lt;br /&gt;
;enrolment_[number]_startdate&lt;br /&gt;
: The enrolment start date. This value is passed to the PHP function strtotime().&lt;br /&gt;
;enrolment_[number]_enddate&lt;br /&gt;
: The enrolment start date. This value is passed to the PHP function strtotime().&lt;br /&gt;
;enrolment_[number]_enrolperiod&lt;br /&gt;
: Number of seconds, or if not a value understood by strtotime() such as &amp;quot;4 days&amp;quot;.&lt;br /&gt;
;enrolment_[number]_role&lt;br /&gt;
: The role short name&lt;br /&gt;
:enrolment_[number]_[property]&lt;br /&gt;
; Where property is understood by the specified enrolment method&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 enrolment_1: manual&lt;br /&gt;
 enrolment_1_role: student&lt;br /&gt;
 enrolment_1_enrolperiod: 1 month&lt;br /&gt;
 &lt;br /&gt;
 enrolment_2: self&lt;br /&gt;
 enrolment_2_startdate: 2013-01-30&lt;br /&gt;
&lt;br /&gt;
====Role renaming====&lt;br /&gt;
&lt;br /&gt;
To rename some roles, using the following pattern:&lt;br /&gt;
&lt;br /&gt;
;role_[shortname]&lt;br /&gt;
: The new name of the role &#039;&#039;[shortname]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 role_student: Apprentice&lt;br /&gt;
 role_teacher: Master&lt;br /&gt;
 role_mycustomrole: Jedi&lt;br /&gt;
&lt;br /&gt;
===Course action fields===&lt;br /&gt;
&lt;br /&gt;
Those settings take precedence over the &#039;&#039;Course process&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
;delete&lt;br /&gt;
: 1 to delete the course &lt;br /&gt;
;rename&lt;br /&gt;
: The shortname to rename the course to&lt;br /&gt;
;backupfile&lt;br /&gt;
: An absolute path to a backup file (.mbz) to import in the course&lt;br /&gt;
;templatecourse&lt;br /&gt;
: The short name of a course to import the content from&lt;br /&gt;
;reset&lt;br /&gt;
: 1 to reset the course&lt;br /&gt;
&lt;br /&gt;
===Mandatory fields===&lt;br /&gt;
&lt;br /&gt;
;shortname&lt;br /&gt;
: This field is mandatory for every operation, with the only exception of creating new courses. See details on the course process parameter &#039;&#039;Shortname template&#039;&#039; for more information.&lt;br /&gt;
;fullname&lt;br /&gt;
: Required when creating a new course.&lt;br /&gt;
;category, category_idnumber, category_path&lt;br /&gt;
: One of these is required when creating a course.&lt;br /&gt;
&lt;br /&gt;
==Uploading the file==&lt;br /&gt;
&lt;br /&gt;
You can upload the file by navigating to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Courses &amp;gt; Upload courses&#039;&#039;. But you can also use the command-line tool &#039;&#039;admin/tool/uploadcourse/cli/uploadcourse.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When using the web interface, use the &#039;&#039;Preview&#039;&#039; option to see if any errors were detected in the previewed rows. If you proceed with the upload and there were something wrong detected with a course, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
===Import options===&lt;br /&gt;
&lt;br /&gt;
To prevent unexpected behaviours, you have to specify what you want the tool to be able to do.&lt;br /&gt;
&lt;br /&gt;
;Upload mode&lt;br /&gt;
: This allows you to specify if courses can be created and/or updated.&lt;br /&gt;
;Update mode&lt;br /&gt;
: If you allow courses to be updated, you also have to tell the tool what to update the courses with.&lt;br /&gt;
;Allow deletes&lt;br /&gt;
: Whether the &#039;&#039;delete&#039;&#039; field is accepted or not&lt;br /&gt;
;Allow renames&lt;br /&gt;
: Whether the &#039;&#039;rename&#039;&#039; field is accepted or not&lt;br /&gt;
;Allow resets&lt;br /&gt;
: Whether the &#039;&#039;reset&#039;&#039; field is accepted or not&lt;br /&gt;
&lt;br /&gt;
===Course process===&lt;br /&gt;
&lt;br /&gt;
This allows you to specify actions to be taken on every single courses uploaded.&lt;br /&gt;
&lt;br /&gt;
;Shortname template&lt;br /&gt;
: If you are creating courses without a shortname, you can use this field to automatically generate a shortname. This field accepts two placeholders: %i for the ID number, %f for the summary.&lt;br /&gt;
;Restore file&lt;br /&gt;
: A backup file (.mbz) to import in the course after create/update.&lt;br /&gt;
;Restore from course&lt;br /&gt;
: The shortname of a course to import content from after create/update.&lt;br /&gt;
;Reset after upload&lt;br /&gt;
: Whether to reset the course after creating/updating it.&lt;br /&gt;
&lt;br /&gt;
===Default course values===&lt;br /&gt;
&lt;br /&gt;
Those are values that can be set in the web interface for all the fields that are not specified in the CSV file. Note that they are always used when creating a course, but only when specified during update (see &#039;&#039;Update mode&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==Increasing speed==&lt;br /&gt;
&lt;br /&gt;
When importing the content of a backup file, or another course, you are adviced to enable the setting &#039;&#039;keeptempdirectoriesonbackup&#039;&#039;. This will considerably speed up the process of the upload if you are importing multiple times from the same source.&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Adding_a_new_course&amp;diff=107152</id>
		<title>Adding a new course</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Adding_a_new_course&amp;diff=107152"/>
		<updated>2013-10-23T07:35:28Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: Removing the note from &amp;quot;Bulk course creation&amp;quot; to prevent outdated information and contain everything in the page Upload courses&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Courses}}&lt;br /&gt;
&lt;br /&gt;
By default a regular teacher can&#039;t add a new course. To add a new course to Moodle you need to have either [[Administrator|Adminstrator]], [[Course creator|Course Creator]] or [[Manager|Manager]] rights.&lt;br /&gt;
&lt;br /&gt;
==Adding a course==&lt;br /&gt;
To add a course:&lt;br /&gt;
*Go to &#039;&#039;Administration&amp;gt;Site Administration&amp;gt;Courses&amp;gt;Manage courses and categories&#039;&#039;&lt;br /&gt;
{|&lt;br /&gt;
|[[File:26addcourse.png|200px|thumb|Link to add a new course]]&lt;br /&gt;
|[[File:26addcourse1.png|200px|thumb|Click New course in the category page on the right]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*Click on the category where you want your course to be. For more information see [[Course categories|Course categories]]&lt;br /&gt;
*Click the &amp;quot;New course&amp;quot; link&lt;br /&gt;
*Enter the [[Course settings|course settings]], then click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
*On the next screen, choose your students/teachers to assign to the course.&lt;br /&gt;
&lt;br /&gt;
==Deleting a course(s)==&lt;br /&gt;
&lt;br /&gt;
A regular teacher can&#039;t delete a course. Administrators and managers (i.e. users with a role for which the capability [[Capabilities/moodle/course:delete|moodle/course:delete]] is allowed) can delete courses. A [[Course creator|Course creator]] can delete courses they have created themselves.&lt;br /&gt;
&lt;br /&gt;
To delete a course (as an administrator or manager):&lt;br /&gt;
*Go to &#039;&#039;Administration&amp;gt;Site Administration&amp;gt;Courses&amp;gt;Manage courses and categories&#039;&#039;&lt;br /&gt;
*Click the course&#039;s category and click the course in the screen on the right.&lt;br /&gt;
*Click the Delete link.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
|[[File:26coursedelete.png|200px|thumb|Deleting a course]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
You can delete multiple courses by: &lt;br /&gt;
*Creating a new (temporary) category. You can name it &amp;quot;To be deleted&amp;quot;.&lt;br /&gt;
*Select and &#039;&#039;&#039;move&#039;&#039;&#039; the &amp;quot;About to be deleted&amp;quot; courses to that category (&amp;quot;To be deleted&amp;quot;).&lt;br /&gt;
*Delete the category (&amp;quot;To be deleted&amp;quot;) and choose &amp;quot;Delete ALL - cannot be undone&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There is no user interface for course creators to delete courses they have created; however they can do so by editing the URL of the course from &amp;lt;nowiki&amp;gt;http://yourmoodlesite.net/course/view.php?id=N&amp;lt;/nowiki&amp;gt; to &amp;lt;nowiki&amp;gt;http://yourmoodlesite.net/course/delete.php?id=N&amp;lt;/nowiki&amp;gt; (replacing &#039;view&#039; with &#039;delete&#039;).&lt;br /&gt;
&lt;br /&gt;
==Course requests==&lt;br /&gt;
&lt;br /&gt;
[[File:Courserequest.png|thumb|Course request screen]]The course request feature can be enabled by an administrator in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Courses &amp;gt; Course request&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
An admin can set the default category for course requests, whether users can select a category when requesting a course, and who can receive notification of course requests (from a list of users with the capability [[Capabilities/moodle/site:approvecourse|moodle/site:approvecourse]]).&lt;br /&gt;
&lt;br /&gt;
A  &#039;Request a new course&#039; button will then appear on the &#039;All courses&#039; page. The All courses page can be accessed via a link in the [[Courses block]].&lt;br /&gt;
&lt;br /&gt;
If course requests are enabled, by default all authenticated users can make course requests. See [[Course requester role]] for details of how to restrict users who can make course requests.&lt;br /&gt;
&lt;br /&gt;
==Bulk course creation==&lt;br /&gt;
{{New features}}&lt;br /&gt;
&lt;br /&gt;
For full detail on how to bulk create courses and use course templates, see [[Upload courses]]&lt;br /&gt;
&lt;br /&gt;
1. Go to &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Courses &amp;gt; Upload courses&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
2. Upload a CSV file either by dragging and dropping or using the button to select from the File picker.&lt;br /&gt;
&lt;br /&gt;
3. Select your import options and click Preview. If the settings are acceptable, click Upload.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=83830 Hide Courses from some users or students] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[de:Kurs anlegen]]&lt;br /&gt;
[[es:Cursos_%28administrador%29]]&lt;br /&gt;
[[eu:Ikastaroak_%28Kudeatzaileak%29]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Upload_courses&amp;diff=107151</id>
		<title>Upload courses</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Upload_courses&amp;diff=107151"/>
		<updated>2013-10-23T07:29:27Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: Added role renaming&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Courses}}&lt;br /&gt;
&lt;br /&gt;
{{New features}}&lt;br /&gt;
An administrator can upload multiple courses using a text file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are many things you can do when using this tool:not only creating courses, but updating or deleting them. You can also update the course enrolment methods or import the content of another course.&lt;br /&gt;
&lt;br /&gt;
==The text file==&lt;br /&gt;
&lt;br /&gt;
The text file to upload courses must be a CSV file. It accepts the following columns which are divided in two categories, the course information, and the course actions.&lt;br /&gt;
&lt;br /&gt;
===Course information fields===&lt;br /&gt;
&lt;br /&gt;
Most of those settings are available on the settings page of a course, please refer to it for more information.&lt;br /&gt;
&lt;br /&gt;
;shortname&lt;br /&gt;
: The shortname&lt;br /&gt;
;fullname&lt;br /&gt;
: The full name&lt;br /&gt;
;idnumber&lt;br /&gt;
: The ID number&lt;br /&gt;
;category&lt;br /&gt;
: The ID of the category to place the course in. This takes precedence over &#039;&#039;category_idnumber&#039;&#039; and &#039;&#039;category_path&#039;&#039;.&lt;br /&gt;
;category_idnumber&lt;br /&gt;
: The ID number of the category to place the course in. This takes precedence over &#039;&#039;category_path&#039;&#039;.&lt;br /&gt;
;category_path&lt;br /&gt;
: The path of the category to place the course in. If you want to place the course in a category named &amp;quot;Science-Fiction&amp;quot; which is located under the category &amp;quot;Movies&amp;quot;, the value to provide is: &amp;lt;code&amp;gt;Movies &amp;gt; Science-Fiction&amp;lt;/code&amp;gt;. Note that the separator must be &amp;lt;code&amp;gt;[space]&amp;gt;[space]&amp;lt;/code&amp;gt;.&lt;br /&gt;
;visible&lt;br /&gt;
: 1 if the course is visible, 0 if hidden&lt;br /&gt;
;startdate&lt;br /&gt;
: The time at which the course starts. Please note that this value is passed to the PHP function [http://php.net/manual/en/function.strtotime.php strtotime] to generate a timestamp.&lt;br /&gt;
;summary&lt;br /&gt;
: The summary of the course&lt;br /&gt;
;format&lt;br /&gt;
: The course format to use, this must be a valid course format plugin name. E.g. &#039;&#039;weeks&#039;&#039;, &#039;&#039;topics&#039;&#039;.&lt;br /&gt;
;theme&lt;br /&gt;
: The theme to use&lt;br /&gt;
;lang&lt;br /&gt;
: The language to use&lt;br /&gt;
;newsitems&lt;br /&gt;
: The number of news items&lt;br /&gt;
;showgrades&lt;br /&gt;
: 1 to show the gradebook to students, 0 to hide it.&lt;br /&gt;
;showreports&lt;br /&gt;
: 1 to show the activity reports, 0 to hide it.&lt;br /&gt;
;legacyfiles&lt;br /&gt;
: 1 to enable the legacy course files, 0 not to.&lt;br /&gt;
;maxbytes&lt;br /&gt;
: The maximum upload size of the course in bytes. Use 0 for the site limit.&lt;br /&gt;
;groupmode&lt;br /&gt;
: 0 for &#039;&#039;No groups&#039;&#039;, 1 for &#039;&#039;Separate groups&#039;&#039; and 2 for &#039;&#039;Visible groups&#039;&#039;.&lt;br /&gt;
;groupmodeforce&lt;br /&gt;
: 1 to force the group mode, otherwise enter 0.&lt;br /&gt;
;enablecompletion&lt;br /&gt;
: 1 to enable the activity completion, 0 not to.&lt;br /&gt;
&lt;br /&gt;
====Enrolment fields====&lt;br /&gt;
&lt;br /&gt;
Some fields can be constructed to enable and configure enrolment methods. The fields must be named &#039;&#039;enrolment_[number]&#039;&#039; for the enrolment method name, and &#039;&#039;enrolment_[number]_property&#039;&#039; for its properties.&lt;br /&gt;
&lt;br /&gt;
;enrolment_[number]&lt;br /&gt;
: The name of the enrolment method&lt;br /&gt;
;enrolment_[number]_delete&lt;br /&gt;
: 1 to delete this enrolment method from the course, if set to 1 all the other properties will be ignored.&lt;br /&gt;
;enrolment_[number]_disable&lt;br /&gt;
: 1 to disable this enrolment method from the course, if set to 1 all the other properties will be ignored.&lt;br /&gt;
;enrolment_[number]_startdate&lt;br /&gt;
: The enrolment start date. This value is passed to the PHP function strtotime().&lt;br /&gt;
;enrolment_[number]_enddate&lt;br /&gt;
: The enrolment start date. This value is passed to the PHP function strtotime().&lt;br /&gt;
;enrolment_[number]_enrolperiod&lt;br /&gt;
: Number of seconds, or if not a value understood by strtotime() such as &amp;quot;4 days&amp;quot;.&lt;br /&gt;
;enrolment_[number]_role&lt;br /&gt;
: The role short name&lt;br /&gt;
:enrolment_[number]_[property]&lt;br /&gt;
; Where property is understood by the specified enrolment method&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 enrolment_1: manual&lt;br /&gt;
 enrolment_1_role: student&lt;br /&gt;
 enrolment_1_enrolperiod: 1 month&lt;br /&gt;
 &lt;br /&gt;
 enrolment_2: self&lt;br /&gt;
 enrolment_2_startdate: 2013-01-30&lt;br /&gt;
&lt;br /&gt;
====Role renaming====&lt;br /&gt;
&lt;br /&gt;
To rename some roles, using the following pattern:&lt;br /&gt;
&lt;br /&gt;
;role_[shortname]&lt;br /&gt;
: The new name of the role &#039;&#039;[shortname]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 role_student: Apprentice&lt;br /&gt;
 role_teacher: Master&lt;br /&gt;
 role_mycustomrole: Jedi&lt;br /&gt;
&lt;br /&gt;
===Course action fields===&lt;br /&gt;
&lt;br /&gt;
Those settings take precedence over the &#039;&#039;Course process&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
;delete&lt;br /&gt;
: 1 to delete the course &lt;br /&gt;
;rename&lt;br /&gt;
: The shortname to rename the course to&lt;br /&gt;
;backupfile&lt;br /&gt;
: An absolute path to a backup file (.mbz) to import in the course&lt;br /&gt;
;templatecourse&lt;br /&gt;
: The short name of a course to import the content from&lt;br /&gt;
;reset&lt;br /&gt;
: 1 to reset the course&lt;br /&gt;
&lt;br /&gt;
===Mandatory fields===&lt;br /&gt;
&lt;br /&gt;
;shortname&lt;br /&gt;
: This field is mandatory for every operation, with the only exception of creating new courses. See details on the course process parameter &#039;&#039;Shortname template&#039;&#039; for more information.&lt;br /&gt;
;fullname&lt;br /&gt;
: Required when creating a new course.&lt;br /&gt;
;category, category_idnumber, category_path&lt;br /&gt;
: One of these is required when creating a course.&lt;br /&gt;
&lt;br /&gt;
==Uploading the file==&lt;br /&gt;
&lt;br /&gt;
You can upload the file by navigating to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Courses &amp;gt; Upload courses&#039;&#039;. But you can also use the command-line tool &#039;&#039;admin/tool/uploadcourse/cli/uploadcourse.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When using the web interface, use the &#039;&#039;Preview&#039;&#039; option to see if any errors were detected in the previewed rows. If you proceed with the upload and there were something wrong detected with a course, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
===Import options===&lt;br /&gt;
&lt;br /&gt;
To prevent unexpected behaviours, you have to specify what you want the tool to be able to do.&lt;br /&gt;
&lt;br /&gt;
;Upload mode&lt;br /&gt;
: This allows you to specify if courses can be created and/or updated.&lt;br /&gt;
;Update mode&lt;br /&gt;
: If you allow courses to be updated, you also have to tell the tool what to update the courses with.&lt;br /&gt;
;Allow deletes&lt;br /&gt;
: Whether the &#039;&#039;delete&#039;&#039; field is accepted or not&lt;br /&gt;
;Allow renames&lt;br /&gt;
: Whether the &#039;&#039;rename&#039;&#039; field is accepted or not&lt;br /&gt;
;Allow resets&lt;br /&gt;
: Whether the &#039;&#039;reset&#039;&#039; field is accepted or not&lt;br /&gt;
&lt;br /&gt;
===Course process===&lt;br /&gt;
&lt;br /&gt;
This allows you to specify actions to be taken on every single courses uploaded.&lt;br /&gt;
&lt;br /&gt;
;Shortname template&lt;br /&gt;
: If you are creating courses without a shortname, you can use this field to automatically generate a shortname. This field accepts two placeholders: %i for the ID number, %f for the summary.&lt;br /&gt;
;Restore file&lt;br /&gt;
: A backup file (.mbz) to import in the course after create/update.&lt;br /&gt;
;Restore from course&lt;br /&gt;
: The shortname of a course to import content from after create/update.&lt;br /&gt;
;Reset after upload&lt;br /&gt;
: Whether to reset the course after creating/updating it.&lt;br /&gt;
&lt;br /&gt;
===Default course values===&lt;br /&gt;
&lt;br /&gt;
Those are values that can be set in the web interface for all the fields that are not specified in the CSV file. Note that they are always used when creating a course, but only when specified during update (see &#039;&#039;Update mode&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==Increasing speed==&lt;br /&gt;
&lt;br /&gt;
When importing the content of a backup file, or another course, you are adviced to enable the setting &#039;&#039;keeptempdirectoriesonbackup&#039;&#039;. This will considerably speed up the process of the upload if you are importing multiple times from the same source.&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Upload_courses&amp;diff=107147</id>
		<title>Upload courses</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Upload_courses&amp;diff=107147"/>
		<updated>2013-10-23T07:18:22Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: Created page with &amp;quot;An administrator can upload multiple courses using a text file.  There are many things can do when using this tool. Not only creating courses, but updating or deleting them, y...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An administrator can upload multiple courses using a text file.&lt;br /&gt;
&lt;br /&gt;
There are many things can do when using this tool. Not only creating courses, but updating or deleting them, you can also update the course enrolment methods or import the content of another course.&lt;br /&gt;
&lt;br /&gt;
==The text file==&lt;br /&gt;
&lt;br /&gt;
The text file to upload courses must be a CSV file. It accepts the following columns which are divided in two categories, the course information, and the course actions.&lt;br /&gt;
&lt;br /&gt;
===Course information fields===&lt;br /&gt;
&lt;br /&gt;
Most of those settings are available on the settings page of a course, please refer to it for more information.&lt;br /&gt;
&lt;br /&gt;
;shortname&lt;br /&gt;
: The shortname&lt;br /&gt;
;fullname&lt;br /&gt;
: The full name&lt;br /&gt;
;idnumber&lt;br /&gt;
: The ID number&lt;br /&gt;
;category&lt;br /&gt;
: The ID of the category to place the course in. This takes precedence over &#039;&#039;category_idnumber&#039;&#039; and &#039;&#039;category_path&#039;&#039;.&lt;br /&gt;
;category_idnumber&lt;br /&gt;
: The ID number of the category to place the course in. This takes precedence over &#039;&#039;category_path&#039;&#039;.&lt;br /&gt;
;category_path&lt;br /&gt;
: The path of the category to place the course in. If you want to place the course in a category named &amp;quot;Science-Fiction&amp;quot; which is located under the category &amp;quot;Movies&amp;quot;, the value to provide is: &amp;lt;code&amp;gt;Movies &amp;gt; Science-Fiction&amp;lt;/code&amp;gt;. Note that the separator must be &amp;lt;code&amp;gt;[space]&amp;gt;[space]&amp;lt;/code&amp;gt;.&lt;br /&gt;
;visible&lt;br /&gt;
: 1 if the course is visible, 0 if hidden&lt;br /&gt;
;startdate&lt;br /&gt;
: The time at which the course starts. Please note that this value is passed to the PHP function [http://php.net/manual/en/function.strtotime.php strtotime] to generate a timestamp.&lt;br /&gt;
;summary&lt;br /&gt;
: The summary of the course&lt;br /&gt;
;format&lt;br /&gt;
: The course format to use, this must be a valid course format plugin name. E.g. &#039;&#039;weeks&#039;&#039;, &#039;&#039;topics&#039;&#039;.&lt;br /&gt;
;theme&lt;br /&gt;
: The theme to use&lt;br /&gt;
;lang&lt;br /&gt;
: The language to use&lt;br /&gt;
;newsitems&lt;br /&gt;
: The number of news items&lt;br /&gt;
;showgrades&lt;br /&gt;
: 1 to show the gradebook to students, 0 to hide it.&lt;br /&gt;
;showreports&lt;br /&gt;
: 1 to show the activity reports, 0 to hide it.&lt;br /&gt;
;legacyfiles&lt;br /&gt;
: 1 to enable the legacy course files, 0 not to.&lt;br /&gt;
;maxbytes&lt;br /&gt;
: The maximum upload size of the course in bytes. Use 0 for the site limit.&lt;br /&gt;
;groupmode&lt;br /&gt;
: 0 for &#039;&#039;No groups&#039;&#039;, 1 for &#039;&#039;Separate groups&#039;&#039; and 2 for &#039;&#039;Visible groups&#039;&#039;.&lt;br /&gt;
;groupmodeforce&lt;br /&gt;
: 1 to force the group mode, otherwise enter 0.&lt;br /&gt;
;enablecompletion&lt;br /&gt;
: 1 to enable the activity completion, 0 not to.&lt;br /&gt;
&lt;br /&gt;
====Enrolment fields====&lt;br /&gt;
&lt;br /&gt;
Some fields can be constructed to enable and configure enrolment methods. The fields must be named &#039;&#039;enrolment_[number]&#039;&#039; for the enrolment method name, and &#039;&#039;enrolment_[number]_property&#039;&#039; for its properties.&lt;br /&gt;
&lt;br /&gt;
;enrolment_[number]&lt;br /&gt;
: The name of the enrolment method&lt;br /&gt;
;enrolment_[number]_delete&lt;br /&gt;
: 1 to delete this enrolment method from the course, if set to 1 all the other properties will be ignored.&lt;br /&gt;
;enrolment_[number]_disable&lt;br /&gt;
: 1 to disable this enrolment method from the course, if set to 1 all the other properties will be ignored.&lt;br /&gt;
;enrolment_[number]_startdate&lt;br /&gt;
: The enrolment start date. This value is passed to the PHP function strtotime().&lt;br /&gt;
;enrolment_[number]_enddate&lt;br /&gt;
: The enrolment start date. This value is passed to the PHP function strtotime().&lt;br /&gt;
;enrolment_[number]_enrolperiod&lt;br /&gt;
: Number of seconds, or if not a value understood by strtotime() such as &amp;quot;4 days&amp;quot;.&lt;br /&gt;
;enrolment_[number]_role&lt;br /&gt;
: The role short name&lt;br /&gt;
:enrolment_[number]_[property]&lt;br /&gt;
; Where property is understood by the specified enrolment method&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Example&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
 enrolment_1: manual&lt;br /&gt;
 enrolment_1_role: student&lt;br /&gt;
 enrolment_1_enrolperiod: 1 month&lt;br /&gt;
 &lt;br /&gt;
 enrolment_2: self&lt;br /&gt;
 enrolment_2_startdate: 2013-01-30&lt;br /&gt;
&lt;br /&gt;
===Course action fields===&lt;br /&gt;
&lt;br /&gt;
Those settings take precedence over the &#039;&#039;Course process&#039;&#039; parameters.&lt;br /&gt;
&lt;br /&gt;
;delete&lt;br /&gt;
: 1 to delete the course &lt;br /&gt;
;rename&lt;br /&gt;
: The shortname to rename the course to&lt;br /&gt;
;backupfile&lt;br /&gt;
: An absolute path to a backup file (.mbz) to import in the course&lt;br /&gt;
;templatecourse&lt;br /&gt;
: The short name of a course to import the content from&lt;br /&gt;
;reset&lt;br /&gt;
: 1 to reset the course&lt;br /&gt;
&lt;br /&gt;
===Mandatory fields===&lt;br /&gt;
&lt;br /&gt;
;shortname&lt;br /&gt;
: This field is mandatory for every operation, with the only exception of creating new courses. See details on the course process parameter &#039;&#039;Shortname template&#039;&#039; for more information.&lt;br /&gt;
;fullname&lt;br /&gt;
: Required when creating a new course.&lt;br /&gt;
;category, category_idnumber, category_path&lt;br /&gt;
: One of these is required when creating a course.&lt;br /&gt;
&lt;br /&gt;
==Uploading the file==&lt;br /&gt;
&lt;br /&gt;
You can upload the file by navigating to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Courses &amp;gt; Upload courses&#039;&#039;. But you can also use the command-line tool &#039;&#039;admin/tool/uploadcourse/cli/uploadcourse.php&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
When using the web interface, use the &#039;&#039;Preview&#039;&#039; option to see if any errors were detected in the previewed rows. If you proceed with the upload and there were something wrong detected with a course, it will be ignored.&lt;br /&gt;
&lt;br /&gt;
===Import options===&lt;br /&gt;
&lt;br /&gt;
To prevent unexpected behaviours, you have to specify what you want the tool to be able to do.&lt;br /&gt;
&lt;br /&gt;
;Upload mode&lt;br /&gt;
: This allows you to specify if courses can be created and/or updated.&lt;br /&gt;
;Update mode&lt;br /&gt;
: If you allow courses to be updated, you also have to tell the tool what to update the courses with.&lt;br /&gt;
;Allow deletes&lt;br /&gt;
: Whether the &#039;&#039;delete&#039;&#039; field is accepted or not&lt;br /&gt;
;Allow renames&lt;br /&gt;
: Whether the &#039;&#039;rename&#039;&#039; field is accepted or not&lt;br /&gt;
;Allow resets&lt;br /&gt;
: Whether the &#039;&#039;reset&#039;&#039; field is accepted or not&lt;br /&gt;
&lt;br /&gt;
===Course process===&lt;br /&gt;
&lt;br /&gt;
This allows you to specify actions to be taken on every single courses uploaded.&lt;br /&gt;
&lt;br /&gt;
;Shortname template&lt;br /&gt;
: If you are creating courses without a shortname, you can use this field to automatically generate a shortname. This field accepts two placeholders: %i for the ID number, %f for the summary.&lt;br /&gt;
;Restore file&lt;br /&gt;
: A backup file (.mbz) to import in the course after create/update.&lt;br /&gt;
;Restore from course&lt;br /&gt;
: The shortname of a course to import content from after create/update.&lt;br /&gt;
;Reset after upload&lt;br /&gt;
: Whether to reset the course after creating/updating it.&lt;br /&gt;
&lt;br /&gt;
===Default course values===&lt;br /&gt;
&lt;br /&gt;
Those are values that can be set in the web interface for all the fields that are not specified in the CSV file. Note that they are always used when creating a course, but only when specified during update (see &#039;&#039;Update mode&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==Increasing speed==&lt;br /&gt;
&lt;br /&gt;
When importing the content of a backup file, or another course, you are adviced to enable the setting &#039;&#039;keeptempdirectoriesonbackup&#039;&#039;. This will considerably speed up the process of the upload if you are importing multiple times from the same source.&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Upload_users&amp;diff=107146</id>
		<title>Upload users</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Upload_users&amp;diff=107146"/>
		<updated>2013-10-23T03:39:13Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Accounts}}&lt;br /&gt;
An administrator can upload multiple user accounts via text file in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Accounts &amp;gt; Upload users&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
There are many robust options for uploading information (fields associated with a user) with this method: from enrolling users in multiple courses with course specific [[Roles|roles]] to updating user information in the [[User profile]] to deleting users from the site.&lt;br /&gt;
&lt;br /&gt;
Rather than uploading the text file, it can simply dragged from the desktop and dropped into the upload area, as demonstrated in the screencast [http://youtu.be/6E-TQXTkZB0 Drag and drop new users into Moodle 2.3] (by Mary Cooch).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tip:&#039;&#039; It is usually not necessary to upload users in bulk with Upload users.  To keep maintenance work down you should first explore forms of authentication that do not require manual maintenance, such as [[External database authentication|connecting to existing external databases]] or letting the users create their own accounts ([[Self enrolment]]). See [[Authentication]] for more information.&lt;br /&gt;
&lt;br /&gt;
[[File:uploadusersnew.png|thumb|center|Initial upload users screen]]&lt;br /&gt;
&lt;br /&gt;
==Upload user process==&lt;br /&gt;
Here is an outline of the process:&lt;br /&gt;
&lt;br /&gt;
# Create file for uploading&lt;br /&gt;
# Go to &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Users &amp;gt; Accounts &amp;gt; Upload users&#039;&#039;&lt;br /&gt;
# Add file to upload&lt;br /&gt;
# Upload users preview - check settings and default user profile settings&lt;br /&gt;
# Upload users preview - click &amp;quot;Upload users&amp;quot;&lt;br /&gt;
# Upload users results - shows list of users, exceptions made in upload and summary of number of users&lt;br /&gt;
# Upload users results - click &amp;quot;Continue&amp;quot;&lt;br /&gt;
# Returns to Upload users screen&lt;br /&gt;
&lt;br /&gt;
==Updating users preview==&lt;br /&gt;
There are settings for the kind of Upload user function you want to perform on the &amp;quot;Upload users preview&amp;quot; page.&lt;br /&gt;
[[File:Upload users preview 2.0.JPG|thumb|center|Upload users preview in Moodle 2.x]]&lt;br /&gt;
&lt;br /&gt;
===Updating existing accounts===&lt;br /&gt;
&lt;br /&gt;
By default Moodle adds new user accounts and skips existing users lines where the &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; matches an existing account. Set &amp;quot;Upload Type&amp;quot; to &#039;&#039;&#039;Add  new and update existing users&#039;&#039;&#039;, and existing user account will be updated.&lt;br /&gt;
*Add all, append number to usernames if needed&lt;br /&gt;
*Add new and update existing users&lt;br /&gt;
*Update existing users only&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: errors updating existing accounts can affect your users badly. Be careful when using the options to update.&lt;br /&gt;
&lt;br /&gt;
===Additional Options===&lt;br /&gt;
&lt;br /&gt;
There are also fields settings to force password change, allow renames, allow deletes, prevent email address duplicates, standardise usernames and select for bulk operations(new users. updated users, all users).&lt;br /&gt;
&lt;br /&gt;
*Standardise usernames - This folds username to lowercase and strips out illegal characters.  This is roughly equivalent to: &lt;br /&gt;
&lt;br /&gt;
  $username = preg_replace(&#039;/[^-\.@_a-z0-9]/&#039;, &#039;&#039;, $username);&lt;br /&gt;
&lt;br /&gt;
===Set default user values===&lt;br /&gt;
&lt;br /&gt;
You may be able to set default user field values, if the fields were not included in the uploaded file on this page.&lt;br /&gt;
&lt;br /&gt;
==Upload user results ==&lt;br /&gt;
After accepting the preview settings by clicking on &amp;quot;Upload users&amp;quot;, you should see the the Upload users results screen.&lt;br /&gt;
[[File:Upload users results 2.0.JPG|thumb|center|The results screen; everything went well!]]&lt;br /&gt;
This screen will show you any exceptions or changes that were made to each user in the upload process.   For example if you were updating user information, the updated information will be shown.  Or if a user was not added that record will be highlighted.&lt;br /&gt;
&lt;br /&gt;
The screen will summarize how many users were uploaded or updated, indicate the number of weak passwords and the number of errors.&lt;br /&gt;
&lt;br /&gt;
==File formats for upload users file==&lt;br /&gt;
The upload users file has fields separated by a comma (or other delimiter) ONLY - no space.   The first line contains the valid field names.  The rest of the lines (records) contain information about each user.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;:Tip:&#039;&#039; Avoid special characters in field information like quotes or other commas. Test a file with only one record before a large upload. Remember there are other ways to authenticate users on you site or enroll users in a course.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;:Tip:&#039;&#039; You can use a spread sheet program to create the file with the required columns and fields. Then save the file as &amp;quot;CSV (comma delimited)&amp;quot;. These files can be opened with simple text editors for verification. &lt;br /&gt;
&lt;br /&gt;
===Valid upload file for testing===&lt;br /&gt;
Here is an example of a simple valid upload file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;username,password,firstname,lastname,email,course1,group1,cohort1&amp;lt;br /&amp;gt;&lt;br /&gt;
jonest,verysecret,Tom,Jones,jonest@someplace.edu,math102,Section 1,year 3&amp;lt;br /&amp;gt;&lt;br /&gt;
reznort,somesecret,Trent,Reznor,reznort@someplace.edu,math102,Section 3,year 4&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Fields that can be included===&lt;br /&gt;
&#039;&#039;:Tip:&#039;&#039; We strongly recommend that you test a file that contains fields you proposed to use with one user before attempting a file upload for the first time.  http://demo.moodle.net might be a good place to see if your test file works.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Required fields&#039;&#039;&#039;: &lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;username,firstname,lastname,email&amp;lt;/code&amp;gt;&lt;br /&gt;
:Validity checks are performed for:&lt;br /&gt;
#&amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; can only contain alphabetical &#039;&#039;&#039;lowercase&#039;&#039;&#039; letters , numbers, hypen &#039;-&#039;, underscore &#039;_&#039;, period &#039;.&#039;, or at-sign &#039;@&#039; &lt;br /&gt;
#&amp;lt;code&amp;gt;email&amp;lt;/code&amp;gt; is in the form: &#039;&#039;name@example.com&#039;&#039; .&amp;lt;/p&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Password field&#039;&#039;&#039;: &amp;quot;password&amp;quot; field is optional if &amp;quot;Create password if needed&amp;quot; setting is chosen (default). &lt;br /&gt;
**If included, values should meet the requirements for the site&#039;s [[Site_policies#Password_policy|Password policy]]. To force password change for a particular user, set the password field to &amp;lt;code&amp;gt;changeme&amp;lt;/code&amp;gt;. &lt;br /&gt;
**If omitted, a password will be generated for each user (during the next Cron job) and welcome e-mails sent out.&lt;br /&gt;
**Note: the text for the welcome e-mail is in the language settings. Please refer to this [https://moodle.org/mod/forum/discuss.php?d=210359&amp;amp;parent=917138 forum thread]for details.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Optional fields&#039;&#039;&#039;: To provide values other than the default include one or more of these&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;institution,department,city,country,lang,auth,timezone,idnumber,icq,phone1,phone2,address,url,description,mailformat,maildisplay,htmleditor,autosubscribe&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
*Country- use a country TWO LETTER CODE&lt;br /&gt;
*Some fields have a maximum number of characters that are allowed (notably institution should be &#039;&#039;&#039;at most 40 characters&#039;&#039;&#039; long).  See hints below.&lt;br /&gt;
*Maildisplay, htmleditor and autosubscribe can be set from an import screen.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Custom profile field names&#039;&#039;&#039;: (Optional). xxxxx is the real custom user profile field name (i.e. the unique shortname)&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;profile_field_xxxxx&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
: Create the custom fields BEFORE importing. Use the standard header. The &amp;quot;shortname&amp;quot; for your custom field is xxxxx (NB the shortname must be all lowercase, otherwise won&#039;t be recognised). The first record must include &amp;quot;profile_field_xxxxx&amp;quot;.&lt;br /&gt;
 &lt;br /&gt;
:&#039;&#039;&#039;Example&#039;&#039;&#039;: To create a custom field &amp;quot;genre&amp;quot;, you must write a shortname &amp;quot;genre&amp;quot; in the new field, and write &amp;quot;profile_field_genre&amp;quot; in the header of the .csv file.&lt;br /&gt;
&lt;br /&gt;
: For custom profile fields that are a menu, use the corresponding value (new in Moodle 2.3 onwards).&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Example&#039;&#039;&#039;: A custom field &#039;Department&#039; with one of three values &#039;HR&#039;, &#039;Marketing&#039; or &#039;Training&#039;. Just insert one of those three words (e.g. &#039;Training&#039;) as the value for that field. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Special fields&#039;&#039;&#039;: Used for changing of usernames or deleting of users&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
*&#039;&#039;&#039;Enrolment fields&#039;&#039;&#039;: (Optional):&lt;br /&gt;
:&amp;lt;code&amp;gt;course1,type1,role1,group1,enrolperiod1,course2,type2,role2,group2,enrolperiod2&amp;lt;/code&amp;gt; etc.&lt;br /&gt;
&lt;br /&gt;
:*&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; is the &amp;quot;shortname&amp;quot; of the course, if present the user will be enrolled in those courses.&lt;br /&gt;
:* &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; refers to the role to be used for associated course enrolment. Value 1 is default course role, 2 is legacy Teacher role and 3 is legacy Non-editing Teacher.&lt;br /&gt;
:* You can use role field instead to specify roles directly - use either role short name or id (numeric names of roles are not supported).&lt;br /&gt;
:* Users may be also assigned to groups in course (group1 in course1, group2 in course2, etc.).&lt;br /&gt;
:* A group is identified by name or id (numeric group names are not supported)&lt;br /&gt;
:* You can set the enrolment duration, in days, for each course (&amp;lt;code&amp;gt;enrolperiod1&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;course1&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;enrolperiod2&amp;lt;/code&amp;gt; for &amp;lt;code&amp;gt;course2&amp;lt;/code&amp;gt;, etc.).&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Cohort field&#039;&#039;&#039;: (Optional):&lt;br /&gt;
:&amp;lt;code&amp;gt;cohort1&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
:Internal cohort id numbers or non-numeric Cohort IDs of existing cohorts must be used; names are not allowed.&lt;br /&gt;
*&#039;&#039;&#039;mnethostid&#039;&#039;&#039; (Optional)&lt;br /&gt;
&lt;br /&gt;
Existing [[MNet]]users can be added to courses, groups or cohorts as below:&lt;br /&gt;
#enrolling to courses: username+mnethostid+course required&lt;br /&gt;
# adding to group: username+mnethostid+course+group required&lt;br /&gt;
#adding to cohort: username+mnethostid+cohort required&lt;br /&gt;
#suspending/reviving accounts: username+mnethostid+suspended required&lt;br /&gt;
All other operations are ignored. You can not add users, delete them or update them (such as change names or email, profile fields, etc.)&lt;br /&gt;
&lt;br /&gt;
Commas within  a field must be encoded as &amp;amp;#44 - the script will decode these back to commas.&lt;br /&gt;
&lt;br /&gt;
For Boolean fields, use &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; for false and &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; for true.&lt;br /&gt;
&lt;br /&gt;
To prevent users from receiving a large number of emails from courses or forced subscription forums use the &#039;&#039;&#039;maildigest&#039;&#039;&#039;.  The options for this field are 0 = No digest, 1 = Complete digest and 2 = Digest with just subjects.&lt;br /&gt;
&lt;br /&gt;
==Advanced potentials of Upload user==&lt;br /&gt;
===Templates===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: This section needs checking and updating if necessary for Moodle 2.0. Please do so and remove this note when finished.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The default values are processed as templates in which the following codes are allowed:&lt;br /&gt;
&lt;br /&gt;
* %l - will be replaced by the lastname&lt;br /&gt;
* %f - will be replaced by the firstname&lt;br /&gt;
* %u - will be replaced by the username&lt;br /&gt;
* %% - will be replaced by the %&lt;br /&gt;
&lt;br /&gt;
Between the percent sign (%) and any code letter (l, f or u) the following modifiers are allowed:&lt;br /&gt;
&lt;br /&gt;
* (-) minus sign - the information specified by the code letter will be converted to lowercase&lt;br /&gt;
* (+) plus sign - the information specified by the code letter will be converted to UPPERCASE&lt;br /&gt;
* (~) tilde sign - the information specified by the code letter will be converted to Title Case&lt;br /&gt;
* a decimal number - the information specified by the code letter will be truncated to that many characters&lt;br /&gt;
&lt;br /&gt;
For example, if the firstname is John and the lastname is Doe, the following values will be obtained with the specified templates:&lt;br /&gt;
&lt;br /&gt;
* %l%f = DoeJohn&lt;br /&gt;
* %l%1f = DoeJ&lt;br /&gt;
* %-l%+f = doeJOHN&lt;br /&gt;
* %-f_%-l = john_doe&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; http://www.example.com/~%u/&amp;lt;/nowiki&amp;gt; results in  &amp;lt;nowiki&amp;gt;http://www.example.com/~jdoe/&amp;lt;/nowiki&amp;gt; (if the username is jdoe or %-1f%-l)&lt;br /&gt;
&lt;br /&gt;
Template processing is done only on default values, and not on the values retrieved from the CSV file.&lt;br /&gt;
&lt;br /&gt;
In order to create correct Moodle usernames, the username is always converted to lowercase. Moreover, if the &amp;quot;Allow extended characters in usernames&amp;quot; option in the Site policies page is off, characters different to letters, digits, dash (-) and dot (.) are removed. For example if the firstname is John Jr. and the lastname is Doe, the username %-f_%-l will produce john jr._doe when Allow extended characters in usernames is on, and johnjr.doe when off.&lt;br /&gt;
&lt;br /&gt;
When the &amp;quot;New username duplicate handling&amp;quot; setting is set to Append counter, an auto-increment counter will be append to duplicate usernames produced by the template. For example, if the CSV file contains the users named John Doe, Jane Doe and Jenny Doe without explicit usernames, the default username is %-1f%-l and New username duplicate handling is set to Append counter, then the usernames produced will be jdoe, jdoe2 and jdoe3.&lt;br /&gt;
&lt;br /&gt;
===Deleting accounts===&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt; field is present, users with value 1 for it will be deleted. In this case, all the fields may be omitted, except for &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt;. After uploading the file, be sure to change the &amp;quot;Upload type&amp;quot; to &amp;quot;Update existing users only&amp;quot; and the &amp;quot;Allow deletes&amp;quot; option to &amp;quot;Yes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039;  A similar field is available for &amp;lt;code&amp;gt;suspended&amp;lt;/code&amp;gt;. This enables a user account to be temporarily disabled rather than completely removed.&lt;br /&gt;
&lt;br /&gt;
Deleting and uploading accounts could be done with a single CSV file. For example, the following file will add the user Tom Jones and delete the user reznort:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;username,firstname,lastname,deleted&amp;lt;br /&amp;gt;&lt;br /&gt;
jonest,Tom,Jones,0&amp;lt;br /&amp;gt;&lt;br /&gt;
reznort,,,1&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Encoding file format==&lt;br /&gt;
On the initial Upload user screen, you may select the file encoding format from a pull down list.  These include UTF-8 (the default), ASCII,  ISO-8859-1 to ISO-8859-11 or any one of over 36 formats.&lt;br /&gt;
&lt;br /&gt;
==Hints==&lt;br /&gt;
&lt;br /&gt;
===Spreadsheet===&lt;br /&gt;
&lt;br /&gt;
If you use a spreadsheet program such as Excel to create your .csv file, check the resulting output in a text editor before you upload it.  It is possible to get trailing commas on each line from an empty field if you have added and deleted columns of information prior to saving the final file. Also check the character encoding. A csv file is a simple text file (ASCII or Unicode) that can be used to upload user accounts.&lt;br /&gt;
&lt;br /&gt;
Excel translates passwords that begin with - (minus) or + (plus) as zero. Even when saving as .csv and saying &amp;quot;Yes&amp;quot; to &amp;quot;Keep this format, and leave out any incompatible features.&amp;quot; Check for this before uploading, as a zero halts the upload process.&lt;br /&gt;
&lt;br /&gt;
If you use a formula in Excel to create fields (for example, the concatenate function to create a user name), then remember to copy the cells with the formula and use special paste with values checked to make them into an acceptable data for a csv file.&lt;br /&gt;
&lt;br /&gt;
The upload will also fail if you have trailing spaces at the end of your data fields. Often, this can not be removed with a simple Find &amp;quot; &amp;quot; and Replace with &amp;quot;&amp;quot;. If information has been copied from web sources than it is possible to include non-breaking spaces which will prevent your upload from being completed correctly. To find these invisible spaces, use the Find and Replace function in Excel. In the find field, hold alt and type 0160. Leave the replace field blank. &lt;br /&gt;
&lt;br /&gt;
===Country===&lt;br /&gt;
The country should be written as a two letter code, in capitals. For example, use BE for Belgium or NL for the Netherlands.  Using &amp;quot;be&amp;quot; or &amp;quot;nl&amp;quot; as a country code will result in a database error.&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039;  If you are having trouble working out the two-letter code for a country, you can consult the list of [http://www.iso.org/iso/country_names_and_code_elements country names and code elements] available on the ISO Website. A common error is to use UK for United Kingdom; it should be GB.&lt;br /&gt;
&lt;br /&gt;
===Field size limits===&lt;br /&gt;
Some fields have maximum character lengths.  Typically the file will import to the preview list screen but not finish the process.  Turn on debug to see the fields that are too long.  Common fields to cause problems are &amp;quot;Institution&amp;quot; which is limited to 40 characters, and &amp;quot;City&amp;quot;, also limited (20 characters).  The error will be &amp;quot;User not added - error&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===All fields listed here===&lt;br /&gt;
:All the fields that are valid are listed below, except for any custom fields you may have created. &lt;br /&gt;
firstname, lastname, username, email, city, country, lang, timezone, mailformat, maildisplay, maildigest, htmleditor, ajax, autosubscribe ,institution, department, idnumber, skype , msn, aim, yahoo, icq, phone1, phone2, address, url, description, descriptionformat, password, auth, oldusername , deleted, suspended, course1, course2, course3, course4&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
*[[Flat file]] enrolment&lt;br /&gt;
* [[User profile fields]] for details of how to include data about custom user profile fields in the upload users file&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=36851 Can I auto enroll from Excel?]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=97903 Uploading users to custom roles]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=181259 User upload option: standardise usernames]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=144569 Matriculacion con flat file csv] - discussion in Spanish&lt;br /&gt;
&lt;br /&gt;
[[fr:Importer des utilisateurs]]&lt;br /&gt;
[[ja:ユーザのアップロード]]&lt;br /&gt;
[[de:Nutzerliste hochladen]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Caching&amp;diff=106371</id>
		<title>Caching</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Caching&amp;diff=106371"/>
		<updated>2013-08-15T09:08:45Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Helper caching (tool_uploadcourse) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Performance}}&lt;br /&gt;
&lt;br /&gt;
A cache is a collection of processed data that is kept on hand and re-used in order to avoid costly repeated database queries.&lt;br /&gt;
&lt;br /&gt;
Moodle 2.4 saw the implementation of MUC, the Moodle Universal Cache.   This new system allows certain functions of Moodle (eg string fetching) take advantage of different installed cache services (eg files, ram, memcached).&lt;br /&gt;
&lt;br /&gt;
In future versions of Moodle we will continue expanding the number of Moodle functions that use MUC, which will continue improving performance, but you can already start using it to improve your site.&lt;br /&gt;
&lt;br /&gt;
==General approach to performance testing==&lt;br /&gt;
&lt;br /&gt;
Here is the general strategy you should be taking:&lt;br /&gt;
&lt;br /&gt;
# Build a test environment that is as close to your real production instance as possible (eg hardware, software, networking, etc)&lt;br /&gt;
# Make sure to remove as many uncontrolled variables as you can from this environment (eg other services)&lt;br /&gt;
# Use a tool to place a realistic, but simulated and repeatable load upon you server. (eg jmeter or selenium).&lt;br /&gt;
# Decide on a way to measure performance of the server by capturing data (ram, load, time taken, etc)&lt;br /&gt;
# Run your load and measure a baseline performance result.&lt;br /&gt;
# Change one variable at a time, and re-run the load to see if performance gets better or worse.  Repeat as necessary.&lt;br /&gt;
# When you discover settings that result in a consistent performance improvement, apply to your production site.&lt;br /&gt;
&lt;br /&gt;
==How to use the caching settings==&lt;br /&gt;
&lt;br /&gt;
Since Moodle 2.4, Moodle has provided a caching plugin framework to give administrators the ability to control where Moodle stores cached data. For most Moodle sites the default configuration should be sufficient and it is not necessary to change the configuration. For larger Moodle sites with multiple servers, administrators may wish to use memcached, mongodb or other systems to store cache data. The cache plugin screen provides administrators with the ability to configure what cache data is stored where. &lt;br /&gt;
&lt;br /&gt;
=== Types of cache ===&lt;br /&gt;
&lt;br /&gt;
Moodle uses three types of cache to store cached data:&lt;br /&gt;
* Request cache - The request cache is available for the duration of every page request. It is not shared between users and is used and cleared on every Moodle request.&lt;br /&gt;
* Session cache - The session cache is available through a users session in Moodle.  It is not shared between users, but persists for a single user throughout their session (i.e. from when they logon til when they log off)&lt;br /&gt;
* Application cache - The application cache is a shared cache which is available for every request. It can be shared between users and the cached data can be kept indefinitely if required.&lt;br /&gt;
&lt;br /&gt;
==== Cache types and multiple-server systems ====&lt;br /&gt;
&lt;br /&gt;
If you have a system with multiple front-end web servers, the application cache must be shared between the servers. In other words, you cannot use fast local storage for the application cache, but must use shared storage or some other form of shared cache such as a shared memcache.&lt;br /&gt;
&lt;br /&gt;
The same applies to session cache, unless you use a &#039;sticky sessions&#039; mechanism to ensure that within a session, users always access the same front-end server.&lt;br /&gt;
&lt;br /&gt;
===Installed cache stores===&lt;br /&gt;
&lt;br /&gt;
This section of the administrator screen displays cache plugins which are installed on the system. It lists what the capabilities of each plugin, what type of cache they provide and provides allows a cache store to be added to the system.&lt;br /&gt;
&lt;br /&gt;
===Configured store instances===&lt;br /&gt;
 &lt;br /&gt;
This section of the administrator screen displays cache stores which have been added to the system. It gives the ability to change the cache configuration and purge the cached data.&lt;br /&gt;
&lt;br /&gt;
===Cache lock instances===&lt;br /&gt;
&lt;br /&gt;
Moodle supports different mechanisms for &#039;locking&#039; access to the various cache stores. At present there is only one option and it is not used, so it can safely be ignored.&lt;br /&gt;
&lt;br /&gt;
===Known cache definitions===&lt;br /&gt;
&lt;br /&gt;
Known cache definitions displays the caches which are in use by Moodle. Each item is an area of Moodle which is using caching. It gives the administrator the ability to configure an individual area of Moodle to use a different cache backend. For example, an administrator of a Moodle cluster may choose to make language string definitions be cached on a dedicated memcached server by using the memcached cache backend.  See the section below for more information about configuring these.&lt;br /&gt;
&lt;br /&gt;
==Cache definition configuration==&lt;br /&gt;
&lt;br /&gt;
Each different cache can be configured independently, allowing admins to &amp;quot;tune&amp;quot; their setup for particular systems.  &lt;br /&gt;
&lt;br /&gt;
By default these caches are all set to use files, which is usually fine on a small one-server system.&lt;br /&gt;
&lt;br /&gt;
On a cluster, however, these defaults can cause problems because shared filesystems are slow, so in these cases we recommend you use a faster shared caching backend like memcached instead.  Note that most of these caches operating under the assumption that they are shared.&lt;br /&gt;
&lt;br /&gt;
In some cases you can choose to use a non-shared cache like the local filesystem however in these instances you be careful to purge caches MANUALLY as part of system administration.&lt;br /&gt;
&lt;br /&gt;
The following reference is intended to help you understand how each caching definition works so you can tune appropriately:&lt;br /&gt;
&lt;br /&gt;
(Note to doc editors, we need contributions below:)&lt;br /&gt;
&lt;br /&gt;
===Language string cache===&lt;br /&gt;
&lt;br /&gt;
* expects shared cache&lt;br /&gt;
* must be purged after any language string change such as editing of local lang packs, updating of lang packs during upgrade, installation or uninstallation of languages&lt;br /&gt;
* starting in 2.6 this will be fully compatible with local node caches&lt;br /&gt;
&lt;br /&gt;
===Database meta information===&lt;br /&gt;
&lt;br /&gt;
* requires shared cache&lt;br /&gt;
* caches need to be invalidated after any DB structure change including creation of temporary tables&lt;br /&gt;
&lt;br /&gt;
===Event invalidation===&lt;br /&gt;
===Question definitions===&lt;br /&gt;
===HTML Purifier - cleaned content===&lt;br /&gt;
&lt;br /&gt;
* expects shared cache&lt;br /&gt;
* must be purged after every upgrade or change of $CFG-&amp;gt;allowobjectembed setting&lt;br /&gt;
* starting in 2.6 this will be fully compatible with local node caches&lt;br /&gt;
&lt;br /&gt;
===Config settings===&lt;br /&gt;
===Course group information===&lt;br /&gt;
===Calendar subscriptions===&lt;br /&gt;
* What is cached:- Record entries from &#039;event_subscriptions&#039; table, representing various calendar subscriptions.&lt;br /&gt;
* When the cache is updated:- When a calendar subscription is updated or deleted.&lt;br /&gt;
* How often it is hit:- Everytime a calendar subscription detail is fetched.&lt;br /&gt;
* When should the cache be purged completely:- This should not be needed.&lt;br /&gt;
&lt;br /&gt;
===YUI Module definitions===&lt;br /&gt;
&lt;br /&gt;
===Plugin types===&lt;br /&gt;
&lt;br /&gt;
* expects shared cache&lt;br /&gt;
* must be purged after every core upgrade or plugin installation, upgrade or uninstallation&lt;br /&gt;
&lt;br /&gt;
===Plugin list 	Application===&lt;br /&gt;
===Plugin info - base===&lt;br /&gt;
===Plugin info - activity modules===&lt;br /&gt;
===Plugin info - blocks===&lt;br /&gt;
===Plugin info - filters===&lt;br /&gt;
===Plugin info - repositories===&lt;br /&gt;
===Plugin info - portfolios===&lt;br /&gt;
===Course categories tree===&lt;br /&gt;
===Course categories lists for particular user===&lt;br /&gt;
===Course categories records===&lt;br /&gt;
===List of course contacts===&lt;br /&gt;
===Repositories instances data===&lt;br /&gt;
&lt;br /&gt;
==Stores used when no mapping is present==&lt;br /&gt;
&lt;br /&gt;
This section displays the default cache stores which should be used by Moodle for each type of Moodle cache. If a mapping for a cache definition does not exist then this default store will be used instead.&lt;br /&gt;
&lt;br /&gt;
==Other performance testing==&lt;br /&gt;
&lt;br /&gt;
Two links that might be useful to anyone considering testing performance on their own servers:&lt;br /&gt;
&lt;br /&gt;
* [http://www.iteachwithmoodle.com/2012/10/12/moodle-performance-testing-how-much-more-horsepower-do-each-new-versions-of-moodle-require/ Moodle performance testing: how much more horsepower do each new versions of Moodle require?]&lt;br /&gt;
* [http://www.iteachwithmoodle.com/2012/10/11/how-to-stress-test-your-moodle-server-using-loadstorm/ How to load test your Moodle server using Loadstorm]&lt;br /&gt;
&lt;br /&gt;
==Performance advise for Moodle 2.5 with load-balanced web servers==&lt;br /&gt;
&lt;br /&gt;
Performance advice: if you are running Moodle 2.4 onwards with load-balanced web servers, don&#039;t use the default caching option that stores the data in moodledata on a shared network drive. Use memcache instead. See Tim Hunt&#039;s article on http://tjhunt.blogspot.de/2013/05/performance-testing-moodle.html. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=217195 MUC is here, now what?] &lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=226123 Status of MUC?]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=222250 Putting cachedir on local disks in cluster]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=232122 moodle cachestore_file]&lt;br /&gt;
&lt;br /&gt;
Developer documentation:&lt;br /&gt;
* [[:dev:The Moodle Universal Cache (MUC)]]&lt;br /&gt;
* [[:dev:Cache API]]&lt;br /&gt;
* [[:dev:Cache API - Quick reference]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[de:Caching]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Caching&amp;diff=106349</id>
		<title>Caching</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Caching&amp;diff=106349"/>
		<updated>2013-08-13T08:09:55Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: /* Repositories instances data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Performance}}&lt;br /&gt;
&lt;br /&gt;
A cache is a collection of processed data that is kept on hand and re-used in order to avoid costly repeated database queries.&lt;br /&gt;
&lt;br /&gt;
Moodle 2.4 saw the implementation of MUC, the Moodle Universal Cache.   This new system allows certain functions of Moodle (eg string fetching) take advantage of different installed cache services (eg files, ram, memcached).&lt;br /&gt;
&lt;br /&gt;
In future versions of Moodle we will continue expanding the number of Moodle functions that use MUC, which will continue improving performance, but you can already start using it to improve your site.&lt;br /&gt;
&lt;br /&gt;
==General approach to performance testing==&lt;br /&gt;
&lt;br /&gt;
Here is the general strategy you should be taking:&lt;br /&gt;
&lt;br /&gt;
# Build a test environment that is as close to your real production instance as possible (eg hardware, software, networking, etc)&lt;br /&gt;
# Make sure to remove as many uncontrolled variables as you can from this environment (eg other services)&lt;br /&gt;
# Use a tool to place a realistic, but simulated and repeatable load upon you server. (eg jmeter or selenium).&lt;br /&gt;
# Decide on a way to measure performance of the server by capturing data (ram, load, time taken, etc)&lt;br /&gt;
# Run your load and measure a baseline performance result.&lt;br /&gt;
# Change one variable at a time, and re-run the load to see if performance gets better or worse.  Repeat as necessary.&lt;br /&gt;
# When you discover settings that result in a consistent performance improvement, apply to your production site.&lt;br /&gt;
&lt;br /&gt;
==How to use the caching settings==&lt;br /&gt;
&lt;br /&gt;
Since Moodle 2.4, Moodle has provided a caching plugin framework to give administrators the ability to control where Moodle stores cached data. For most Moodle sites the default configuration should be sufficient and it is not necessary to change the configuration. For larger Moodle sites with multiple servers, administrators may wish to use memcached, mongodb or other systems to store cache data. The cache plugin screen provides administrators with the ability to configure what cache data is stored where. &lt;br /&gt;
&lt;br /&gt;
=== Types of cache ===&lt;br /&gt;
&lt;br /&gt;
Moodle uses three types of cache to store cached data:&lt;br /&gt;
* Request cache - The request cache is available for the duration of every page request. It is not shared between users and is used and cleared on every Moodle request.&lt;br /&gt;
* Session cache - The session cache is available through a users session in Moodle.  It is not shared between users, but persists for a single user throughout their session (i.e. from when they logon til when they log off)&lt;br /&gt;
* Application cache - The application cache is a shared cache which is available for every request. It can be shared between users and the cached data can be kept indefinitely if required.&lt;br /&gt;
&lt;br /&gt;
==== Cache types and multiple-server systems ====&lt;br /&gt;
&lt;br /&gt;
If you have a system with multiple front-end web servers, the application cache must be shared between the servers. In other words, you cannot use fast local storage for the application cache, but must use shared storage or some other form of shared cache such as a shared memcache.&lt;br /&gt;
&lt;br /&gt;
The same applies to session cache, unless you use a &#039;sticky sessions&#039; mechanism to ensure that within a session, users always access the same front-end server.&lt;br /&gt;
&lt;br /&gt;
===Installed cache stores===&lt;br /&gt;
&lt;br /&gt;
This section of the administrator screen displays cache plugins which are installed on the system. It lists what the capabilities of each plugin, what type of cache they provide and provides allows a cache store to be added to the system.&lt;br /&gt;
&lt;br /&gt;
===Configured store instances===&lt;br /&gt;
 &lt;br /&gt;
This section of the administrator screen displays cache stores which have been added to the system. It gives the ability to change the cache configuration and purge the cached data.&lt;br /&gt;
&lt;br /&gt;
===Cache lock instances===&lt;br /&gt;
&lt;br /&gt;
Moodle supports different mechanisms for &#039;locking&#039; access to the various cache stores. At present there is only one option and it is not used, so it can safely be ignored.&lt;br /&gt;
&lt;br /&gt;
===Known cache definitions===&lt;br /&gt;
&lt;br /&gt;
Known cache definitions displays the caches which are in use by Moodle. Each item is an area of Moodle which is using caching. It gives the administrator the ability to configure an individual area of Moodle to use a different cache backend. For example, an administrator of a Moodle cluster may choose to make language string definitions be cached on a dedicated memcached server by using the memcached cache backend.  See the section below for more information about configuring these.&lt;br /&gt;
&lt;br /&gt;
==Cache definition configuration==&lt;br /&gt;
&lt;br /&gt;
Each different cache can be configured independently, allowing admins to &amp;quot;tune&amp;quot; their setup for particular systems.  &lt;br /&gt;
&lt;br /&gt;
By default these caches are all set to use files, which is usually fine on a small one-server system.&lt;br /&gt;
&lt;br /&gt;
On a cluster, however, these defaults can cause problems because shared filesystems are slow, so in these cases we recommend you use a faster shared caching backend like memcached instead.  Note that most of these caches operating under the assumption that they are shared.&lt;br /&gt;
&lt;br /&gt;
In some cases you can choose to use a non-shared cache like the local filesystem however in these instances you be careful to purge caches MANUALLY as part of system administration.&lt;br /&gt;
&lt;br /&gt;
The following reference is intended to help you understand how each caching definition works so you can tune appropriately:&lt;br /&gt;
&lt;br /&gt;
(Note to doc editors, we need contributions below:)&lt;br /&gt;
&lt;br /&gt;
===Language string cache===&lt;br /&gt;
&lt;br /&gt;
* What is cached:&lt;br /&gt;
* When the cache is updated:&lt;br /&gt;
* How often it is hit:&lt;br /&gt;
* When should the cache be purged completely:&lt;br /&gt;
&lt;br /&gt;
===Database meta information===&lt;br /&gt;
===Event invalidation===&lt;br /&gt;
===Question definitions===&lt;br /&gt;
===HTML Purifier - cleaned content===&lt;br /&gt;
===Config settings===&lt;br /&gt;
===Course group information===&lt;br /&gt;
===Calendar subscriptions===&lt;br /&gt;
===YUI Module definitions===&lt;br /&gt;
===Plugin types===&lt;br /&gt;
===Plugin list 	Application===&lt;br /&gt;
===Plugin info - base===&lt;br /&gt;
===Plugin info - activity modules===&lt;br /&gt;
===Plugin info - blocks===&lt;br /&gt;
===Plugin info - filters===&lt;br /&gt;
===Plugin info - repositories===&lt;br /&gt;
===Plugin info - portfolios===&lt;br /&gt;
===Course categories tree===&lt;br /&gt;
===Course categories lists for particular user===&lt;br /&gt;
===Course categories records===&lt;br /&gt;
===List of course contacts===&lt;br /&gt;
===Repositories instances data===&lt;br /&gt;
&lt;br /&gt;
=== Helper caching (tool_uploadcourse) ===&lt;br /&gt;
&lt;br /&gt;
Cache for the helper of the admin tool to upload courses via CSV.&lt;br /&gt;
&lt;br /&gt;
* What is cached:&lt;br /&gt;
** Categories resolved by ID, path or ID number;&lt;br /&gt;
** Role IDs;&lt;br /&gt;
** Some backup/restore information;&lt;br /&gt;
** Enrolment plugins.&lt;br /&gt;
* When the cache is updated: Every request&lt;br /&gt;
* How often it is hit: Depending on the size of the CSV uploaded&lt;br /&gt;
* When should the cache be purged completely: Never&lt;br /&gt;
&lt;br /&gt;
==Stores used when no mapping is present==&lt;br /&gt;
&lt;br /&gt;
This section displays the default cache stores which should be used by Moodle for each type of Moodle cache. If a mapping for a cache definition does not exist then this default store will be used instead.&lt;br /&gt;
&lt;br /&gt;
==Other performance testing==&lt;br /&gt;
&lt;br /&gt;
Two links that might be useful to anyone considering testing performance on their own servers:&lt;br /&gt;
&lt;br /&gt;
* [http://www.iteachwithmoodle.com/2012/10/12/moodle-performance-testing-how-much-more-horsepower-do-each-new-versions-of-moodle-require/ Moodle performance testing: how much more horsepower do each new versions of Moodle require?]&lt;br /&gt;
* [http://www.iteachwithmoodle.com/2012/10/11/how-to-stress-test-your-moodle-server-using-loadstorm/ How to load test your Moodle server using Loadstorm]&lt;br /&gt;
&lt;br /&gt;
==Performance advise for Moodle 2.5 with load-balanced web servers==&lt;br /&gt;
&lt;br /&gt;
Performance advice: if you are running Moodle 2.4 onwards with load-balanced web servers, don&#039;t use the default caching option that stores the data in moodledata on a shared network drive. Use memcache instead. See Tim Hunt&#039;s article on http://tjhunt.blogspot.de/2013/05/performance-testing-moodle.html. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=217195 MUC is here, now what?] &lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=226123 Status of MUC?]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=222250 Putting cachedir on local disks in cluster]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=232122 moodle cachestore_file]&lt;br /&gt;
&lt;br /&gt;
Developer documentation:&lt;br /&gt;
* [[:dev:The Moodle Universal Cache (MUC)]]&lt;br /&gt;
* [[:dev:Cache API]]&lt;br /&gt;
* [[:dev:Cache API - Quick reference]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[de:Caching]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Using_Chat&amp;diff=100070</id>
		<title>Using Chat</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Using_Chat&amp;diff=100070"/>
		<updated>2012-08-20T03:57:58Z</updated>

		<summary type="html">&lt;p&gt;Fmcorz: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Chat}}&lt;br /&gt;
==Entering the chat==&lt;br /&gt;
[[File:Enterchat.png]]&lt;br /&gt;
&lt;br /&gt;
*As you click the chat link on the course page you see two or three options:&lt;br /&gt;
**Click here to enter the chat now - this takes you to the chat using the chosen site  default chat method - for example Ajax.&lt;br /&gt;
**Use more accessible interface - this gives a simpler chat room without frames and javascript:&lt;br /&gt;
&lt;br /&gt;
[[File:Accessiblechat.png]]&lt;br /&gt;
&lt;br /&gt;
**View past sessions - if this has been enabled and the user is allowed to view past chat sessions, this takes them to a list of past sessions with links to the chat.&lt;br /&gt;
&lt;br /&gt;
==Joining in a chat session==&lt;br /&gt;
*In normal view, the screen is in two parts with the participants on the right, the messages on the left and a box at the bottom into which users type their message and press &amp;quot;Send&amp;quot; to make their contribution:&lt;br /&gt;
&lt;br /&gt;
[[File:Ajaxchat.png]]&lt;br /&gt;
&lt;br /&gt;
*Users can change the appearance of the messages by clicking on &amp;quot;Themes&amp;quot; next to the &amp;quot;Send&amp;quot; button. &#039;&#039;Bubbles&#039;&#039; appears thus:&lt;br /&gt;
&lt;br /&gt;
[[File:Bubbleschat.png]]&lt;br /&gt;
&lt;br /&gt;
The chat module contains some features to make chatting a little nicer.&lt;br /&gt;
&lt;br /&gt;
;Smilies &lt;br /&gt;
:Any smiley faces (emoticons) that you can type elsewhere in Moodle can also be typed in here and they will be displayed correctly.&lt;br /&gt;
&lt;br /&gt;
;Links &lt;br /&gt;
:Internet addresses will be turned into links automatically. &lt;br /&gt;
&lt;br /&gt;
;Emoting &lt;br /&gt;
:You can start a line with &amp;lt;code&amp;gt;/me&amp;lt;/code&amp;gt; to emote. For example, if your name is Kim and you type &amp;lt;code&amp;gt;/me laughs!&amp;lt;/code&amp;gt; then everyone will see &amp;quot;Kim laughs!&amp;quot; &lt;br /&gt;
&lt;br /&gt;
;Beeps &lt;br /&gt;
:You can send a sound to other people by hitting the &amp;quot;beep&amp;quot; link next to their name. A useful shortcut to beep all the people in the chat at once is to type &amp;quot;beep all&amp;quot;. &lt;br /&gt;
&lt;br /&gt;
;HTML &lt;br /&gt;
:If you know some HTML code, you can use it in your text to do things like insert images, play sounds or create different coloured and sized text.&lt;br /&gt;
&lt;br /&gt;
==Chat reports==&lt;br /&gt;
*To view previous chats (if you have permission) click on the &#039;View past chat sessions&#039; link. Teachers can also access past chat sessions from the Chat administration in the Settings block.&lt;br /&gt;
&lt;br /&gt;
[[Image:Pastchatsessions.png]]&lt;br /&gt;
&lt;br /&gt;
*This will bring up a listing of each chat session under the current chat topic.  The listings include the time the chat started and ended, which users participated, and how many messages each user sent.  &lt;br /&gt;
&lt;br /&gt;
*In order for students to see past sessions, the teacher or an administrator must setup the chat to allow everyone to view past chat sessions.  Please refer to the [[Chat settings]] page.&lt;br /&gt;
&lt;br /&gt;
==Exporting chat sessions==&lt;br /&gt;
*Users with the &#039;&#039;mod/chat:exportparticipatedsession&#039;&#039; or the &#039;&#039;mod/chat:exportsession&#039;&#039; permission can export past chat sessions to any portfolio enabled by the administrator:&lt;br /&gt;
&lt;br /&gt;
[[File:Exportchat.png]]&lt;br /&gt;
&lt;br /&gt;
==Why use chat?==&lt;br /&gt;
*Chat has an advantage over a [[Forum]] in that it takes place in Real Time. It is especially beneficial when the group chatting is not able to meet face to face. Examples might be:&lt;br /&gt;
**Regular  meetings of staff on large or split campuses to discuss student or curriculum issues;&lt;br /&gt;
**Regular meetings of students doing online courses to enable them to share experiences with others on the same course but potentially in a different city (or country)&lt;br /&gt;
**A teacher working with his students even though he is out of school&lt;br /&gt;
**A student temporarily unable to attend in person chatting with their tutor to catch up with work. &lt;br /&gt;
**Students out on work experience getting together to discuss their experiences with each other and their tutor&lt;br /&gt;
**Younger children using chat at home in the evenings as a controlled(monitored) introduction to the world of social networking&lt;br /&gt;
&lt;br /&gt;
==Why NOT use chat?==&lt;br /&gt;
*Unless a tutor/moderator is permanently present in the chatroom -or unless the chat is hidden and revealed at certain times, it is difficult to control what is said once a chat has started.&lt;br /&gt;
*Younger students particularly may find it difficult to stay on task and be prone to adding non-useful comments or &amp;quot;beeping&amp;quot; others for the sake of it.&lt;br /&gt;
*In some situations, a forum might be preferred as  it allows for reflection before posting and gives a period of time where the post might be edited.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=734 Chat module forum]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=4792 Positive use of Chat] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[de:Chat nutzen]]&lt;br /&gt;
[[cs:Chatovací zasedání]]&lt;br /&gt;
[[fr:Participer à un chat]]&lt;/div&gt;</summary>
		<author><name>Fmcorz</name></author>
	</entry>
</feed>