<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/36/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Theforce</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/36/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Theforce"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/Special:Contributions/Theforce"/>
	<updated>2026-04-15T05:48:56Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/36/en/index.php?title=Development:CVS_for_developers&amp;diff=37602</id>
		<title>Development:CVS for developers</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/index.php?title=Development:CVS_for_developers&amp;diff=37602"/>
		<updated>2008-06-13T04:57:05Z</updated>

		<summary type="html">&lt;p&gt;Theforce: /* Merging fixes */ -- note re: db schema added&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;CVS&#039;&#039;&#039; is the Concurrent Versioning System, a commonly-used way of managing source code for large software projects. CVS keeps all versions of all files so that nothing is ever lost, and usage by different people is tracked. It also provides ways to merge code if two or more people are working on the same file. All code and all versions are stored on a central server (in the case of Moodle, at cvs.moodle.org). The [http://cvsbook.red-bean.com/cvsbook.html CVS book] holds more information about CVS than you need.&lt;br /&gt;
&lt;br /&gt;
If you just want to download Moodle using CVS to run a site, then you probably don&#039;t need this page - please see [[CVS for Administrators]] instead.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Joining the project as a developer==&lt;br /&gt;
&lt;br /&gt;
So, you&#039;ve been offered CVS write access to help us develop and maintain Moodle!  Welcome aboard!&lt;br /&gt;
&lt;br /&gt;
To be able to write changes into [http://cvs.moodle.org/ Moodle&#039;s CVS archive], you first need to have an account on the server.  Only trusted developers get these accounts.  To request access, go to the &amp;quot;Apply for CVS Access&amp;quot; tab on the CVS page on Moodle.org (http://moodle.org/cvs).  Tell us what modules you&#039;d like to access (e.g. a language module), and why.  You&#039;ll receive notification in a day or so.&lt;br /&gt;
&lt;br /&gt;
With that done, you should have all the permissions you need, so you just need to set up your machine and download the current source code so you can start working on it. &lt;br /&gt;
&lt;br /&gt;
For the examples on this page, let&#039;s assume your username is &#039;&#039;&#039;myusername&#039;&#039;&#039; and your password is &#039;&#039;&#039;mypassword&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==CVS modules==&lt;br /&gt;
&lt;br /&gt;
Within CVS, the word &amp;quot;modules&amp;quot; refers to separate collections of code. In Moodle we have the following modules within our repository:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;moodle&#039;&#039;&#039; - the main Moodle source code&lt;br /&gt;
* &#039;&#039;&#039;lang&#039;&#039;&#039; - all the language packs&lt;br /&gt;
* &#039;&#039;&#039;[[Development:contrib|contrib]]&#039;&#039;&#039; - user contributions and other assorted code in development&lt;br /&gt;
* &#039;&#039;&#039;mysql&#039;&#039;&#039; - a customised phpMyAdmin to plug into Moodle for database admin&lt;br /&gt;
* &#039;&#039;&#039;windows-cron&#039;&#039;&#039; - a small package that makes cron possible on Windows systems&lt;br /&gt;
* &#039;&#039;&#039;docs&#039;&#039;&#039; - various extra user-contributed documentation&lt;br /&gt;
&lt;br /&gt;
Most people are working on the existing features in the moodle module, but many are also contributing new ideas in the contrib modules. Once code reaches a certain level of maturity in the contrib area, it can be migrated over into the main moodle tree.&lt;br /&gt;
&lt;br /&gt;
==Basic CVS commands==&lt;br /&gt;
&lt;br /&gt;
===CVS on Unix===&lt;br /&gt;
&lt;br /&gt;
Moodle CVS uses ssh as a transport layer for security, so you will have to set a CVS_RSH environment variable in your Unix shell. It&#039;s best to put these commands in your .bashrc or .cshrc so you don&#039;t have to type it all the time:&lt;br /&gt;
        setenv CVS_RSH ssh (for csh, tcsh etc)&lt;br /&gt;
        export CVS_RSH=ssh (for sh, bash etc)&lt;br /&gt;
&lt;br /&gt;
Next, you can check out the latest development version of Moodle using this (all one line). NOTE: Don&#039;t try to do run this first CVS command over an existing moodle installation: start fresh with a new directory!:&lt;br /&gt;
        cvs -z3 -d:ext:myusername@cvs.moodle.org:/cvsroot/moodle co moodle&lt;br /&gt;
&lt;br /&gt;
The command is similar for other CVS modules:&lt;br /&gt;
        cvs -z3 -d:ext:myusername@cvs.moodle.org:/cvsroot/moodle co contrib&lt;br /&gt;
&lt;br /&gt;
If you want to checkout a single plugin (attendance block as an example here) from contrib into the current directory, you can use:&lt;br /&gt;
        cvs -z3 -d:ext:myusername@cvs.moodle.org:/cvsroot/moodle co -d attendance contrib/plugins/blocks/attendance&lt;br /&gt;
&lt;br /&gt;
Note that you will be prompted for mypassword for each command unless you set up authorized keys.  Read [[Development:SSH_key|SSH Keys]] for more details on how to set those up.&lt;br /&gt;
&lt;br /&gt;
Now, you should have a new &#039;moodle&#039; directory. You can rename it and move it around if you like. Go into it:&lt;br /&gt;
        cd moodle&lt;br /&gt;
&lt;br /&gt;
All the latest Moodle files should be in there. You can now change files in your copy. To compare your files and directories against the main CVS copy on the server use cvs diff, e.g.:&lt;br /&gt;
        cvs diff -c config-dist.php&lt;br /&gt;
        cvs diff -c lang&lt;br /&gt;
&lt;br /&gt;
To fetch the latest updates from the server use:&lt;br /&gt;
        cvs update -dP&lt;br /&gt;
&lt;br /&gt;
To copy your new files back to the server you would do something like:&lt;br /&gt;
        cd lang/ca&lt;br /&gt;
        cvs commit&lt;br /&gt;
&lt;br /&gt;
You will be prompted to add some comments (depends on your default text editor).   Please write a meaningful, descriptive comment and &#039;&#039;&#039;always include the name of any tracker issues that talk about the issue you are fixing&#039;&#039;&#039; (eg &#039;&#039;&#039;MDL-XXXX&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
After that your changes will be sent to the CVS server and stored in the repository. Done!&lt;br /&gt;
&lt;br /&gt;
To save more time you can put default arguments into a file called .cvsrc in your home directory. For example, mine contains:&lt;br /&gt;
        diff -c&lt;br /&gt;
        update -dP&lt;br /&gt;
&lt;br /&gt;
Try &#039;cvs help&#039; for more details ...&lt;br /&gt;
&lt;br /&gt;
===CVS on Mac OSX===&lt;br /&gt;
&lt;br /&gt;
You can follow the same instructions as for Unix (above) in a terminal window. However, the cvs command is not installed by default in an OSX. You first need to install the XCode Tools. You should find this on your original installation disk. Failing that it can be downloaded (a fairly hefty download) from the Apple developer web site ([http://developer.apple.com]).&lt;br /&gt;
&lt;br /&gt;
===CVS on Windows===&lt;br /&gt;
&lt;br /&gt;
First, you need to download a completely fresh copy of Moodle using your developer account.&lt;br /&gt;
&lt;br /&gt;
1. Get TortoiseCVS from tortoisecvs.org and install it, then reboot. (Tortoise is not currently supported on vista but [http://www.syntevo.com/smartcvs/index.html SmartCVS] works well).&lt;br /&gt;
&lt;br /&gt;
2. Find or create a new folder somewhere where you want Moodle to be downloaded to.&lt;br /&gt;
&lt;br /&gt;
3. Right-mouse-click that folder and choose &amp;quot;CVS Checkout&amp;quot; from the menu. You should see a dialog box.&lt;br /&gt;
&lt;br /&gt;
4. Copy this text into the CVSROOT field (using your own username!):&lt;br /&gt;
&lt;br /&gt;
           :ext:myusername@cvs.moodle.org:/cvsroot/moodle&lt;br /&gt;
&lt;br /&gt;
5. Under the &amp;quot;Module&amp;quot; field, type &amp;quot;moodle&amp;quot; to get the latest development version of Moodle, &amp;quot;contrib&amp;quot; to get the contributions directory, or &amp;quot;mysql&amp;quot; to get the MySQL Admin module.&lt;br /&gt;
&lt;br /&gt;
6. Press the button: &amp;quot;OK&amp;quot; and everything should be downloaded.&lt;br /&gt;
&lt;br /&gt;
A dialog box should show all the files being downloaded, and after a while you should have a complete copy of Moodle. After this first checkout, you can fetch the latest updated files from the CVS server:&lt;br /&gt;
&lt;br /&gt;
# Right-mouse-click on your Moodle folder (or any file) and select &amp;quot;CVS Update&amp;quot;.&lt;br /&gt;
# Sit back and watch the logs scroll by. Take note of conflicts that may occur if your local code has changes that conflict with the incoming versions - you will need to edit these files and resolve the conflicts manually.&lt;br /&gt;
&lt;br /&gt;
After modifying files (you will notice their icons change from green to red!), you can commit them back to the CVS server like this:&lt;br /&gt;
&lt;br /&gt;
# Right-mouse-click on your Moodle folder (or any file) and select &amp;quot;CVS Commit...&amp;quot;.&lt;br /&gt;
# In the dialog box, type a clear description of the changes you are committing.  &#039;&#039;&#039;Always include the name of any tracker issues related to what you are fixing&#039;&#039;&#039; (eg &#039;&#039;&#039;MDL-XXXX&#039;&#039;&#039;).&lt;br /&gt;
# Click &amp;quot;OK&amp;quot;. Your changes will be sent to the server.&lt;br /&gt;
# If you create a folder, BE CAREFUL about using the &amp;quot;CVS Add&amp;quot; option as it will add the folder to CVS without requiring a commit. Once added, the folder cannot be removed from CVS even though it will be pruned so long as it is empty.&lt;br /&gt;
&lt;br /&gt;
Please note that as of April 15 2008, TortoiseCVS 1.10.6 might not work really well with Windows Vista. You could report bugs to TortoiseCVS site (hosted by SourceForge) or google &amp;quot;TortoiseCVS vista&amp;quot; for more details.&lt;br /&gt;
&lt;br /&gt;
==CVS commit messages==&lt;br /&gt;
&lt;br /&gt;
Every commit you make to CVS should have a commit message containing&lt;br /&gt;
* a tracker issue id like MDL-12345 (if necessary, create an issue before committing, the only exception is for very minor typos.)&lt;br /&gt;
* A brief description of the problem you are fixing. (If you are feeling lazy, you may be able to get away with copying and pasting the issue summary from the tracker.)&lt;br /&gt;
* If it is not immediately obvious, a brief summary of why this change fixes the problem. If a longer description is necessary,  you may also want to add more information to the tracker issue, or Moodle Docs, but the code changes + commit message should provide enough clues to how the fix works on their own.&lt;br /&gt;
&lt;br /&gt;
==Working with branches==&lt;br /&gt;
&lt;br /&gt;
This diagram shows how the main moodle module branches into different versions over time.&lt;br /&gt;
&lt;br /&gt;
[[Image:Cvstree.png|CVS tree]]&lt;br /&gt;
&lt;br /&gt;
To see all the current tags and branches that are available, use this command on any old file (such as index.php in the top moodle directory):&lt;br /&gt;
    cvs status -v index.php&lt;br /&gt;
&lt;br /&gt;
Some tagging guidelines:&lt;br /&gt;
* Tag and branch names should always be all upper-case.&lt;br /&gt;
* Tags and branches should ALWAYS be applied to the entire module (all of Moodle). Don&#039;t tag individual files or directories.&lt;br /&gt;
* We don&#039;t allow renaming of tags because people may be relying on them, so get them right the first time!&lt;br /&gt;
&lt;br /&gt;
===Trunk development===&lt;br /&gt;
&lt;br /&gt;
The Trunk of CVS is the main development version of Moodle. In CVS it is also known as the HEAD, or default branch.&lt;br /&gt;
&lt;br /&gt;
Moodle developers try to keep this stable as possible, but as it usually contains new code it probably has bugs and small instabilities.&lt;br /&gt;
&lt;br /&gt;
Every now and then we decide the product has enough features to make a release. At this time, the trunk is tagged with a MOODLE_XX_BETA tag (in case we ever want to roll back to that point) and a new branch is formed for the release, called MOODLE_XX_STABLE.&lt;br /&gt;
&lt;br /&gt;
A Beta package is also released at this point - it&#039;s for testers who don&#039;t use CVS but want to test the latest features and report bugs.&lt;br /&gt;
&lt;br /&gt;
===Stable branches for each release===&lt;br /&gt;
&lt;br /&gt;
As soon as the stable branch MOODLE_XX_STABLE is created, development efforts will fork into two streams for a while. Some people may continue working on new features in the trunk for the next release, but most developers should be concentrating on using the current STABLE branch and fixing bugs that are found in it.&lt;br /&gt;
&lt;br /&gt;
You can switch your local copy of Moodle to the STABLE version using the following command in Unix from the root directory:&lt;br /&gt;
    cvs update -dP -r MOODLE_XX_STABLE&lt;br /&gt;
&lt;br /&gt;
After that, all the commands described above will apply to that stable version. To return to the trunk version just issue:&lt;br /&gt;
    cvs update -dPA&lt;br /&gt;
&lt;br /&gt;
On Windows clients you should have a menu from which you can choose the branch.&lt;br /&gt;
&lt;br /&gt;
Once the new STABLE branch really stabilises, a release can be declared. Packages are created for distribution and the branch will be tagged (by Martin Dougiamas) with a tag named: MOODLE_XXX&lt;br /&gt;
&lt;br /&gt;
===Merging fixes===&lt;br /&gt;
&lt;br /&gt;
All bug fixes in any STABLE branch should be merged back into the trunk so that they become available in future versions of Moodle. A floating tag called MOODLE_XX_MERGED needs to be maintained to keep track of the last merge. The procedure for such a merge is as follows (I&#039;m using CVS on the Unix command line but the steps are the same for any CVS client):&lt;br /&gt;
&lt;br /&gt;
[[Image:Merging.png|thumb|right|300px|This diagram summarises the process]]&lt;br /&gt;
1. I highly recommend keeping one checked out copy of each stable branch and the trunk/head version locally to make it easier to jump between them.  Set them all up as virtual web sites on your development machine.  I use directories like /moodle/18, /moodle/19 /moodle/dev etc.&lt;br /&gt;
&lt;br /&gt;
2. Update to the latest stable version (I&#039;ll use XX in the example but it could be 18, 19 etc) for the relevant files, and do a cvs diff just to double-check exactly what you are checking in.  Note you only need to update the files/directories you are working in, but sometimes it help to update everything anyway just to do a final check on the functionality using the web.&lt;br /&gt;
&lt;br /&gt;
          cd /moodle/XX/user&lt;br /&gt;
          cvs update -dPA&lt;br /&gt;
          cvs diff -c file1.php file2.php&lt;br /&gt;
&lt;br /&gt;
3. If all looks OK, check in the fix to the stable branch.  Make sure that the commit message contains the bug tracker ID (eg MDL-1111) and a decent description of your thoughts on the fix.  If you don&#039;t specify a message in the command line, you&#039;ll be put into an editor to type one.&lt;br /&gt;
&lt;br /&gt;
          cvs commit -m &amp;quot;MDL-1234 Corrected a small typo in the user name field&amp;quot; file1.php file2.php&lt;br /&gt;
&lt;br /&gt;
4. Go to the very latest trunk version and make sure it&#039;s up-to-date.&lt;br /&gt;
          &lt;br /&gt;
          cd /moodle/dev/user&lt;br /&gt;
          cvs update -dPA&lt;br /&gt;
&lt;br /&gt;
5. Merge everything into your local copy of the trunk from your stable branch since the last merge.  You can use the same sequence of (4) and (5) to merge the changes into other stable branches too (to backport the fix to the previous stable versions).&lt;br /&gt;
&lt;br /&gt;
          cvs update -kk -j MOODLE_XX_MERGED -j MOODLE_XX_STABLE file1.php file2.php&lt;br /&gt;
&lt;br /&gt;
6. Carefully watch the update logs for conflicts, and fix every file that you see with a conflict.  Afterwards, it may help to just run a diff to make sure the result is what you expected:&lt;br /&gt;
&lt;br /&gt;
          cvs diff -c file1.php file2.php&lt;br /&gt;
&lt;br /&gt;
7. Check your merged local copy back into CVS trunk version&lt;br /&gt;
&lt;br /&gt;
          cvs commit -m &amp;quot;MDL-1234 Corrected a small typo in the user name field, merged from XX&amp;quot; file1.php file2.php&lt;br /&gt;
&lt;br /&gt;
8. Go back to your branch version&lt;br /&gt;
&lt;br /&gt;
          cd /moodle/XX/user&lt;br /&gt;
&lt;br /&gt;
9. Update the floating merge tag for the affected files (so that it matches MOODLE_XX_STABLE) so that this process can be repeated next time&lt;br /&gt;
&lt;br /&gt;
          cvs tag -RF MOODLE_XX_MERGED file1.php file2.php&lt;br /&gt;
&lt;br /&gt;
Finally, the values for $version in all the Moodle version.php files within the stable branch should not be updated at all if possible (except the last digit if absolutely necessary). The reason is that someone updating from a very stable version to the next very stable version could miss database upgrades that happened on the trunk.&lt;br /&gt;
&lt;br /&gt;
In other words, if you have changes to the database schema to commit to a stable branch, please check with Martin Dougiamas, or one of the other core Moodle developers.&lt;br /&gt;
&lt;br /&gt;
===Merging fixes with TortoiseCVS===&lt;br /&gt;
Situation: we did a fix on MOODLE_19_STABLE. We modified one file for this fix. This fix needs to be done on Moodle 1.8 and trunk(HEAD). All following CVS instructions will be applied on the file that we changed.&lt;br /&gt;
 &lt;br /&gt;
1. Update to the latest stable versions (HEAD included)&lt;br /&gt;
&lt;br /&gt;
          Right click on the moodle folder&lt;br /&gt;
          CVS update&lt;br /&gt;
          OK&lt;br /&gt;
&lt;br /&gt;
2. On your MOODLE19 branch: commit your fix &lt;br /&gt;
&lt;br /&gt;
          Right Click on the file&lt;br /&gt;
          CVS commit&lt;br /&gt;
          Enter a description: &amp;quot;MDL-XXXX bug fix description&amp;quot;&lt;br /&gt;
          OK&lt;br /&gt;
&lt;br /&gt;
3. On your HEAD repository: merge the changes&lt;br /&gt;
&lt;br /&gt;
          Right Click on the file&lt;br /&gt;
          CVS&amp;gt;&lt;br /&gt;
          Merge...&lt;br /&gt;
          Start: MOODLE_19_MERGED&lt;br /&gt;
          End  : MOODLE_19_STABLE&lt;br /&gt;
          OK&lt;br /&gt;
&lt;br /&gt;
4. If the resulting file have some conflicts, TortoiseCVS displays a red square on the file icon. Edit the file with your text editor and resolve the conflicts.&lt;br /&gt;
&lt;br /&gt;
5. Run a diff to make sure the result is what you expected&lt;br /&gt;
&lt;br /&gt;
          Right Click on the file&lt;br /&gt;
          CVS Diff&lt;br /&gt;
          OK&lt;br /&gt;
&lt;br /&gt;
6. Commit the fix&lt;br /&gt;
&lt;br /&gt;
          Right Click on the file&lt;br /&gt;
          CVS commit&lt;br /&gt;
          Enter a description: &amp;quot;MDL-XXXX bug fix description, merged from 19&amp;quot;&lt;br /&gt;
          OK&lt;br /&gt;
&lt;br /&gt;
We&#039;ve commit MOODLE_19_STABLE and trunk. It&#039;s now time to backport the change on MOODLE_18_STABLE.&lt;br /&gt;
On your MOODLE18 branch: reproduce step 3 to 6.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
7. On your MOODLE19 branch: update the floating merge tag for the affected file&lt;br /&gt;
&lt;br /&gt;
          Right Click on the file&lt;br /&gt;
          CVS&amp;gt;&lt;br /&gt;
          Tag...&lt;br /&gt;
          Tag: MOODLE_19_MERGED&lt;br /&gt;
          Select &#039;Move existing tag&#039;&lt;br /&gt;
          OK&lt;br /&gt;
&lt;br /&gt;
On your MOODLE18 branch: reproduce step 7 (with Tag: MOODLE_18_MERGED).&lt;br /&gt;
&lt;br /&gt;
===Feature branches for large changes===&lt;br /&gt;
&lt;br /&gt;
Occasionally, there may be a very large feature that needs to be checked in so several people can work on it, but it is too unstable to be included in the main development trunk.&lt;br /&gt;
&lt;br /&gt;
In these cases a short-term branch can be created to work on the feature, and then merged back into the main trunk as soon as possible. An example called MOODLE_19_WIDGET branch can be seen in the above diagram.&lt;br /&gt;
&lt;br /&gt;
If you need to do this for your new WIDGET feature, follow these steps:&lt;br /&gt;
&lt;br /&gt;
1. Discuss with other developers to make sure it&#039;s necessary!&lt;br /&gt;
&lt;br /&gt;
2. Make a new tag on the trunk (for all of moodle) called MOODLE_XX_WIDGET_PRE&lt;br /&gt;
&lt;br /&gt;
          cvs tag -R MOODLE_XX_WIDGET_PRE&lt;br /&gt;
&lt;br /&gt;
3. Create your branch called MOODLE_XX_WIDGET&lt;br /&gt;
&lt;br /&gt;
          cvs tag -Rb MOODLE_XX_WIDGET&lt;br /&gt;
&lt;br /&gt;
4. Work in that branch until the feature is reasonably stable. Commit as necessary.&lt;br /&gt;
&lt;br /&gt;
          cvs commit&lt;br /&gt;
&lt;br /&gt;
5. When ready, merge the whole branch into the trunk, fix conflicts, commit it to the trunk and then abandon the branch.&lt;br /&gt;
&lt;br /&gt;
          cvs update -dPA&lt;br /&gt;
          cvs update -kk -j MOODLE_XX_WIDGET&lt;br /&gt;
          cvs commit&lt;br /&gt;
&lt;br /&gt;
Good luck, be careful and have fun!&lt;br /&gt;
&lt;br /&gt;
==Who on earth is ...==&lt;br /&gt;
&lt;br /&gt;
Some of the people committing to the Moodle codebase have non-boring account names on the CVS server. If you are ever looking at a CVS commit, and wondering &amp;quot;who on earth is this purpleblob person?&amp;quot; This information is now available at: [http://moodle.org/mod/cvsadmin/view.php?cid=1 Moodle developers with write access].&lt;br /&gt;
&lt;br /&gt;
==Tips and Hints==&lt;br /&gt;
* [http://moodle.org/mod/cvsadmin/ Change your password or SSH key] (click on &amp;quot;Update my developer information&amp;quot;)&lt;br /&gt;
* [[Tracking Moodle CVS with git]]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=34472 Merging Custom Moodle Code With Stable Releases]&lt;br /&gt;
* [[Unmerged files]]: To see if you&#039;ve forgotten to merge any file.&lt;br /&gt;
* [http://ximbiot.com/cvs/manual/ CVS Manual]&lt;br /&gt;
* [[Development:contrib|Introduction to the &#039;&#039;&#039;contrib&#039;&#039;&#039; area of CVS]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://tracker.moodle.org/browse/MDLSITE-193 &amp;quot;All developers should switch to using the cvs.moodle.org alias&amp;quot;]&lt;br /&gt;
* [[CVS for Administrators]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer|CVS for developers]]&lt;br /&gt;
[[Category:Developer tools]]&lt;br /&gt;
&lt;br /&gt;
[[es:CVS para desarrolladores]]&lt;br /&gt;
[[fr:CVS pour développeurs]]&lt;br /&gt;
[[pt:CVS_para_programadores]]&lt;/div&gt;</summary>
		<author><name>Theforce</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/36/en/index.php?title=AuthMoodle&amp;diff=37009</id>
		<title>AuthMoodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/index.php?title=AuthMoodle&amp;diff=37009"/>
		<updated>2008-06-04T02:56:58Z</updated>

		<summary type="html">&lt;p&gt;Theforce: added link to MediawikiSSO&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=AuthMoodle.php=&lt;br /&gt;
&lt;br /&gt;
(See also [[MediawikiSSO]])&lt;br /&gt;
&lt;br /&gt;
* an extension of mediawiki&#039;s AuthPlugin class so that moodle users can sign in to a mediawiki with the same login/pw&lt;br /&gt;
* used in this https://docs.moodle.org mediawiki production site&lt;br /&gt;
* download from http://moodle.org/file.php/5/moddata/forum/366/196104/AuthMoodle.php&lt;br /&gt;
* first posted by Martin Dougiamas in april 2006 in http://moodle.org/mod/forum/post.php?reply=196104 as an attachment&lt;br /&gt;
&lt;br /&gt;
quoting Martin&#039;s instructions based on the root folder of the wikimedia installation:&lt;br /&gt;
&lt;br /&gt;
 Save it in extensions/AuthMoodle.php.&lt;br /&gt;
 Then you just put this in LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;pre&amp;gt;&lt;br /&gt;
 require_once( &#039;extensions/AuthMoodle.php&#039; );&lt;br /&gt;
 $wgAuth = new AuthMoodle();&lt;br /&gt;
 $wgAuth-&amp;gt;setAuthMoodleTablePrefix(&#039;&#039;);&lt;br /&gt;
 $wgAuth-&amp;gt;setAuthMoodleDBServer(&#039;yoursite.org&#039;);&lt;br /&gt;
 $wgAuth-&amp;gt;setAuthMoodleDBName(&#039;yourdb&#039;);&lt;br /&gt;
 $wgAuth-&amp;gt;setAuthMoodleUser(&#039;yourdbuser&#039;);&lt;br /&gt;
 $wgAuth-&amp;gt;setAuthMoodlePassword(&#039;yourdbpass&#039;);&lt;br /&gt;
 &amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Bugs with AuthMoodle in mediawiki 1.7==&lt;br /&gt;
* preferences are no longer sticky (they pretend to save but don&#039;t really save)&amp;lt;br&amp;gt;&#039;&#039;&#039;fix:&#039;&#039;&#039; disable this &#039;&#039;&#039;if&#039;&#039;&#039; in includes/SpecialPreferences.php around line 290:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;/*&#039;&#039;&#039;&lt;br /&gt;
 if (!$wgAuth-&amp;gt;updateExternalDB($wgUser)) {&lt;br /&gt;
     $this-&amp;gt;mainPrefsForm( wfMsg( &#039;externaldberror&#039; ) );&lt;br /&gt;
     return;&lt;br /&gt;
 }&lt;br /&gt;
 &#039;&#039;&#039;*/&#039;&#039;&#039; &lt;br /&gt;
* if the moodle database prefix is different from the mediawiki database prefix must match (or be blank)&amp;lt;br&amp;gt;&#039;&#039;&#039;fix:&#039;&#039;&#039; edit the function tableName in includes/Database.php around line 1310 and 1313:&lt;br /&gt;
&lt;br /&gt;
 function tableName( $name ) {&lt;br /&gt;
    global $wgSharedDB&#039;&#039;&#039;, $wgAuth&#039;&#039;&#039;;&lt;br /&gt;
    # Skip quoted literals&lt;br /&gt;
    if ( $name{0} != &#039;`&#039; ) {&lt;br /&gt;
        if ( $this-&amp;gt;mTablePrefix !== &#039;&#039; &amp;amp;&amp;amp;  strpos( &#039;.&#039;, $name ) === false &lt;br /&gt;
             &#039;&#039;&#039;&amp;amp;&amp;amp; strpos ($name, $wgAuth-&amp;gt;mAuthMoodleTablePrefix) === false&#039;&#039;&#039; ) {&lt;br /&gt;
&lt;br /&gt;
* for mediawiki 1.7, I had to change line 33 to &#039;&#039;&#039;includes/&#039;&#039;&#039;AuthPlugin.php and comment out line 223-226 (refers to a non-existent function)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* bugtracker conversation leading to creation of AuthMoodle http://moodle.org/bugs/bug.php?op=show&amp;amp;bugid=4666&lt;br /&gt;
* usage info: [[MoodleDocs:Authentication]]&lt;br /&gt;
* based probably on http://svn.wikimedia.org/svnroot/mediawiki/trunk/extensions/auth/&lt;br /&gt;
&lt;br /&gt;
[[Category:MoodleDocs]]&lt;br /&gt;
[[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Theforce</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/36/en/index.php?title=User:Luke_Hudson&amp;diff=34729</id>
		<title>User:Luke Hudson</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/index.php?title=User:Luke_Hudson&amp;diff=34729"/>
		<updated>2008-04-10T04:57:04Z</updated>

		<summary type="html">&lt;p&gt;Theforce: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I&#039;m one of the developers in the eLearning team at Catalyst IT.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve been working on Moodle development for nearly two years now, working on a large variety of tasks.&lt;br /&gt;
&lt;br /&gt;
I was born in 1977 in London, but moved to New Zealand about twenty years ago.&lt;br /&gt;
&lt;br /&gt;
I speak French reasonably fluently, as a second language, and I&#039;ve learned some German and New Zealand Sign Language.&lt;/div&gt;</summary>
		<author><name>Theforce</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/36/en/index.php?title=NTLM_authentication&amp;diff=32399</id>
		<title>NTLM authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/index.php?title=NTLM_authentication&amp;diff=32399"/>
		<updated>2008-02-19T01:02:37Z</updated>

		<summary type="html">&lt;p&gt;Theforce: /* Assumptions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.9}}This document describes how to set up NTLM/Integrated Authentication in Moodle. &lt;br /&gt;
&lt;br /&gt;
This is integrated into Moodle 1.9 onwards.&lt;br /&gt;
&lt;br /&gt;
For earlier versions, it uses a modified version of LDAP Authentication.&lt;br /&gt;
The NTLM Authentication module is available in the Modules and Plugins database here:&lt;br /&gt;
http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=314&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Assumptions==&lt;br /&gt;
&lt;br /&gt;
#You are running MS Active Directory for Authentication.&lt;br /&gt;
#The Server hosting your website is a member of the Active Directory Domain that your users are also members of.&lt;br /&gt;
#You are able to define people inside your Network (and authenticated to the Domain) from an IP range or IP range of computers.&lt;br /&gt;
#You have &amp;quot;some&amp;quot; basic knowledge of php and are able to configure the index.php with the range of internal IP addresses.&lt;br /&gt;
#You are familar with or have read the LDAP authentication documentation.&lt;br /&gt;
#The Active Directory domain credentials of your users are returned as &#039;&#039;&#039;DOMAINNAME\username&#039;&#039;&#039; from your authentication service. If you are using the Winbind service from the Samba project, this can be untrue, depending on your Winbind configuration settings.&lt;br /&gt;
&lt;br /&gt;
If you can not modify your settings to satisfy this last assumption, then you will need to remove or comment out the line that reads:&lt;br /&gt;
    $username = substr(strrchr($username, &#039;\\&#039;), 1); //strip domain info&lt;br /&gt;
and add the relevant lines of code to extract the username part from the domain user credentials and store it in $username.&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.9==&lt;br /&gt;
&lt;br /&gt;
No installation needed. See the Auth/LDAP settings for the NTLM config options. You only have to&lt;br /&gt;
&lt;br /&gt;
*Set the subnet mask&lt;br /&gt;
*On IIS: turn on Integrated Authentication&lt;br /&gt;
*On Apache - use one of the 3 methods outlined below&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.6/1.7==&lt;br /&gt;
#Copy the folder AUTH/NTLM into the AUTH folder of your moodle installation.&lt;br /&gt;
#Configure the IP/Subnet Mask in the Config screen.&lt;br /&gt;
[https://docs.moodle.org/en/NTLM_authentication#Configuring IP/Subnet Mask see below for more help]&lt;br /&gt;
If the IP/Subnet Mask does not give enough complexity for your network, Modify the auth/ntlm/index.php file - for instructions on doing this, view the comments in the file.&lt;br /&gt;
#Turn Integrated Authentication ON and Anonymous Authentication OFF for the moodle\auth\ntlm\oncampuslogin.php file. [https://docs.moodle.org/en/NTLM_authentication#How_to_Turn_Integrated_Authentication_on see below for more detailed instructions]&lt;br /&gt;
#Visit the admin page of your moodle installation - you should see notification that the NTLM_AUTH module has been installed.&lt;br /&gt;
#go to the configuration &amp;gt; variables page, find the dbsessions setting (in 1.8 on admin page server \ sessions page), and set it to &amp;quot;YES&amp;quot; then save the page.&lt;br /&gt;
#go to the Authentication admin page and select auth_ntlmtitle as your authentication method Note: - this doesn&#039;t display full text as I haven&#039;t created a language file for this module - you will also see auth_ntlmdescription instead of a proper description - you don&#039;t need to worry about this, as you will be the only one who ever sees this.&lt;br /&gt;
#Configure this page with your normal LDAP settings. NOTE: the Alternate Login URL at the bottom of this page (or on the main authentication page in 1.8 - and needs to be set manually to the oncampus url)has been set to the NTLM page. - if you wish uninstall this auth module, you must reset this variable on the new authentication type page. eg - if you wish to revert back to manual authentication, then change to manual, and then make sure you delete the alternate login url at the bottom of the page.&lt;br /&gt;
#(OPTIONAL) modify the offcampuslogin page to give errors when students try to prefix their usercode with your domain.&lt;br /&gt;
around line 216 find this code, uncomment all the lines and replace the letters &#039;DOM&#039; with your domain:&lt;br /&gt;
&lt;br /&gt;
    if (empty($errormsg)) {&lt;br /&gt;
        if (strstr(strtolower($frm-&amp;gt;username), &amp;quot;DOM\\&amp;quot;) &amp;lt;&amp;gt; false) { //NAD - DOM messages.&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;) . &amp;quot; DOM\\ is not required!&amp;quot;;&lt;br /&gt;
        } else if (strpos($frm-&amp;gt;username, &amp;quot;@&amp;quot;) &amp;lt;&amp;gt; false) {&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;) . &amp;quot; enter your username - not your e-mail address.&amp;quot;;&lt;br /&gt;
        } else {&lt;br /&gt;
            $errormsg = get_string(&amp;quot;invalidlogin&amp;quot;);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
==Installation on 1.5==&lt;br /&gt;
&lt;br /&gt;
See the README in the auth/ntml package.&lt;br /&gt;
&lt;br /&gt;
==How to Turn Integrated Authentication on==&lt;br /&gt;
The File ntlmsso_magic.php (1.9 or above) or oncampuslogin.php (1.8 or below) MUST have NTLM/Integrated Authentication enabled at the server or the page will not work.&lt;br /&gt;
===IIS Configuration===&lt;br /&gt;
Open up IIS, and find the auth/ldap/ntlmsso_magic.php (1.9 or above) or auth/ntlm/oncampuslogin.php (1.8 or below) file, &lt;br /&gt;
#right click on the file, choose properties&lt;br /&gt;
#under the &amp;quot;file security&amp;quot; tab, click on the Authentication and Access control &amp;quot;edit&amp;quot; button&lt;br /&gt;
#untick &amp;quot;Enable Anonymous Access&amp;quot; and tick &amp;quot;Integrated Windows Authentication&amp;quot;&lt;br /&gt;
===APACHE Configuration===&lt;br /&gt;
There are currently 3 possible methods for this:&lt;br /&gt;
&lt;br /&gt;
====Using the NTLM part of Samba (Linux)====&lt;br /&gt;
&lt;br /&gt;
* Get the plugin here: http://samba.org/ftp/unpacked/lorikeet/mod_auth_ntlm_winbind/ and follow the instructions inside the README file. You&#039;ll need to install the Apache development packages in addition to the core C develpment packages.&lt;br /&gt;
* Once you have compiled it, put it inside Apache&#039;s modules subdirectory (this location depends on a number of factors, like compiling Apache yourself, using different Linux distributions packages, an so on), and load and enable the module in Apache&#039;s configuration. For example, if your Apache modules are under &amp;lt;code&amp;gt;/usr/lib/apache2/modules&amp;lt;/code&amp;gt;, you&#039;ll need something like this in your Apache configuration file (usually called &amp;lt;code&amp;gt;apache2.conf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;http2.conf&amp;lt;/code&amp;gt;):&lt;br /&gt;
&lt;br /&gt;
   &amp;lt;IfModule !mod_auth_ntlm_winbind.c&amp;gt;&lt;br /&gt;
       LoadModule auth_ntlm_winbind_module /usr/lib/apache2/modules/mod_auth_ntlm_winbind.so&lt;br /&gt;
   &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Install the Samba &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; daemon package. This packages relies on Samba&#039;s configuration file to get some important settings (like the Windows domain name, uid and gid range mappings, and so on). In addition to that, you&#039;ll need to make your Linux/Unix machine part of the domain. Otherwise winbind won&#039;t be able to pull user and groups informationi from the domain controllers. You should read the Samba documentation to perform this step, but the most important part is having something like the following lines in your &amp;lt;code&amp;gt;smb.conf&amp;lt;/code&amp;gt; file (in addition to what you already have there):&lt;br /&gt;
&lt;br /&gt;
  workgroup = DOMAINNAME&lt;br /&gt;
  password server = *&lt;br /&gt;
  security = domain&lt;br /&gt;
  encrypt passwords = true&lt;br /&gt;
  idmap uid = 10000-20000&lt;br /&gt;
  idmap gid = 10000-20000&lt;br /&gt;
&lt;br /&gt;
: and executing the command (as root):&lt;br /&gt;
&lt;br /&gt;
  # net join DOMAINNAME -U Administrator&lt;br /&gt;
&lt;br /&gt;
: where &#039;&#039;&#039;DOMAINNAME&#039;&#039;&#039; is the NetBIOS windows domain name, and &#039;&#039;&#039;Administrator&#039;&#039;&#039; an account with enough privileges to add new machines to the domain.&amp;lt;br/&amp;gt; You&#039;ll need to type this account&#039;s password for the command to succeed.&lt;br /&gt;
&lt;br /&gt;
: Also, make sure you have disabled &amp;quot;Microsoft Network Server: digitally sign communications (always)&amp;quot; in your Domain Controllers Security Policy, unless you are using a version of Samba that can sign SMB packets.&lt;br /&gt;
&lt;br /&gt;
* Restart the &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; service to apply the changes and test that it&#039;s running ok by executing:&lt;br /&gt;
&lt;br /&gt;
  $ wbinfo -u&lt;br /&gt;
&lt;br /&gt;
: You should get the full list of Windows domain users. If you use &#039;&#039;&#039;&amp;lt;code&amp;gt;-g&amp;lt;/code&amp;gt;&#039;&#039;&#039; instead, you&#039;ll get the domain groups list.&lt;br /&gt;
&lt;br /&gt;
* Check that your &amp;lt;code&amp;gt;winbind&amp;lt;/code&amp;gt; package installed the authentication helper command &amp;lt;code&amp;gt;ntlm_auth&amp;lt;/code&amp;gt;, as we&#039;ll need it later. We&#039;ll assume the helper is located at &amp;lt;code&amp;gt;/usr/bin/ntlm_auth&amp;lt;/code&amp;gt;. If yours is at a different location, make sure you adjust the path in the example below.&lt;br /&gt;
&lt;br /&gt;
* Add something like this to your Apache configuration file (usually called &amp;lt;code&amp;gt;apache2.conf&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;http2.conf&amp;lt;/code&amp;gt;). We&#039;ll assume that your Moodle &amp;lt;code&amp;gt;$CFG-&amp;gt;dirroot&amp;lt;/code&amp;gt; directory is located at &amp;lt;code&amp;gt;/var/www/moodle&amp;lt;/code&amp;gt; in the example:&lt;br /&gt;
: &#039;&#039;&#039;For 1.9 or above use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;/var/www/moodle/auth/ldap/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
            NTLMAuth on&lt;br /&gt;
            AuthType NTLM&lt;br /&gt;
            AuthName &amp;quot;Moodle NTLM Authentication&amp;quot;&lt;br /&gt;
            NTLMAuthHelper &amp;quot;/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp&amp;quot;&lt;br /&gt;
            NTLMBasicAuthoritative on&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
: &#039;&#039;&#039;For 1.8 or below use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;/var/www/moodle/auth/ntlm/&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
            NTLMAuth on&lt;br /&gt;
            AuthType NTLM&lt;br /&gt;
            AuthName &amp;quot;Moodle NTLM Authentication&amp;quot;&lt;br /&gt;
            NTLMAuthHelper &amp;quot;/usr/bin/ntlm_auth --helper-protocol=squid-2.5-ntlmssp&amp;quot;&lt;br /&gt;
            NTLMBasicAuthoritative on&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
* Check the permissions of the Winbind pipe directory (Ubuntu places it under &amp;lt;code&amp;gt;/var/run/samba/winbindd_privileged&amp;lt;/code&amp;gt;, yours may be placed at a different location). Apache will need to be able to enter that directory, so we need to make sure it has the right permissions. So have a look at the permissions of that directory and note the name of the group assigned to it. The following example is from a Ubuntu 7.10 machine:&lt;br /&gt;
&lt;br /&gt;
  $ ls -ald /var/run/samba/winbindd_privileged&lt;br /&gt;
  drwxr-x--- 2 root winbindd_priv 60 2007-11-17 16:18 /var/run/samba/winbindd_privileged/&lt;br /&gt;
&lt;br /&gt;
:so we see the group is &amp;lt;code&amp;gt;winbindd_priv&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* Instead of modifying the directory permissions (which could break other services that use winbind) we are goint to make the Apache user (&amp;lt;code&amp;gt;www-data&amp;lt;/code&amp;gt; in our example, but could be &amp;lt;code&amp;gt;httpd&amp;lt;/code&amp;gt;, or &amp;lt;code&amp;gt;nobody&amp;lt;/code&amp;gt;, etc.) is part of the appropiate group. Execute the following as root:&lt;br /&gt;
&lt;br /&gt;
  # adduser www-data winbindd_priv&lt;br /&gt;
&lt;br /&gt;
: &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt; is available in Debian and Ubuntu at least. If your distribution doesn&#039;t have &amp;lt;code&amp;gt;adduser&amp;lt;/code&amp;gt;, you can edit &amp;lt;code&amp;gt;/etc/group&amp;lt;/code&amp;gt; manually to achive the same effect.&lt;br /&gt;
&lt;br /&gt;
* Restart the Apache service to apply the changes. Have a look at Apache&#039;s error log to see that everything is ok.&lt;br /&gt;
&lt;br /&gt;
* Couple of gotchas - in Fedora Core, keep alive is turned OFF by default in the httpd.conf - see this bug for further info: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=188138&amp;lt;br /&amp;gt;&lt;br /&gt;
* Email Dan if you get this working - I&#039;m keen to hear how people go using the samba winbind option!&lt;br /&gt;
::-- Hi Dan! I made it work using Ubuntu 7.04. That&#039;s what I&#039;ve used to update the documentation. [[User:Iñaki Arenaza|Iñaki Arenaza]] 10:43, 30 September 2007 (CDT)&lt;br /&gt;
&lt;br /&gt;
====Using the NTLM Auth Module for Apache====&lt;br /&gt;
#get the Module from: http://modntlm.sourceforge.net/&lt;br /&gt;
#use something like this in your httpd.conf: http://moodle.org/mod/forum/discuss.php?d=45887#211074&lt;br /&gt;
&lt;br /&gt;
====Using the mod_auth_sspi Module for Apache 2 on Windows====&lt;br /&gt;
NOTE: This setup is currently being used in a live production environment, and is therefore suitable for such use provided it is correctly configured and tested.&lt;br /&gt;
&lt;br /&gt;
This is the recommended method for Apache 2 on Windows, however it will &#039;&#039;&#039;not&#039;&#039;&#039; work on Linux/UNIX systems.&lt;br /&gt;
It provides better stability and higher performance than other NTLM modules.&lt;br /&gt;
&lt;br /&gt;
* Download the mod_auth_sspi Module from: http://sourceforge.net/projects/mod-auth-sspi/. At the moment of writing this (2007.09.30), the current version is mod_auth_sspi 1.0.4, which has two different ZIP files to download:&lt;br /&gt;
&lt;br /&gt;
::* mod_auth_sspi-1.0.4-2.0.58.zip :   Use this file if you are using Apache 2.0.x.&lt;br /&gt;
::* mod_auth_sspi-1.0.4-2.2.2.zip :   Use this file if you are using Apache 2.2.x.&lt;br /&gt;
&lt;br /&gt;
* Unzip the right file and copy mod_auth_sspi.so (it&#039;s inside &#039;&#039;&#039;bin&#039;&#039;&#039; subdirectory) to your Apache modules directory.&lt;br /&gt;
* Edit your Apache 2 configuration file (httpd.conf) to load the module.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;IfModule !mod_auth_sspi.c&amp;gt;&lt;br /&gt;
        LoadModule sspi_auth_module modules/mod_auth_sspi.so&lt;br /&gt;
    &amp;lt;/IfModule&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Choose one of the two methods below&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Method 1&#039;&#039;&#039;: This method is recommended for servers that will host a single Moodle instance. Configure NTLM from the main configuration file, add the following to httpd.conf (substitute &amp;quot;C:\moodle&amp;quot; with the path to your Moodle installation e.g. &amp;quot;C:\my-moodle&amp;quot;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.9 or above use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;C:\moodle\auth\ldap&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
            AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
            AuthType SSPI&lt;br /&gt;
            SSPIAuth On&lt;br /&gt;
            SSPIOfferBasic Off&lt;br /&gt;
            SSPIAuthoritative On&lt;br /&gt;
            SSPIDomain mycollege.ac.uk&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
:: &#039;&#039;&#039;For 1.8 or below use&#039;&#039;&#039;:&lt;br /&gt;
    &amp;lt;Directory &amp;quot;C:\moodle\auth\ntlm&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
            AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
            AuthType SSPI&lt;br /&gt;
            SSPIAuth On&lt;br /&gt;
            SSPIOfferBasic Off&lt;br /&gt;
            SSPIAuthoritative On&lt;br /&gt;
            SSPIDomain mycollege.ac.uk&lt;br /&gt;
            require valid-user&lt;br /&gt;
        &amp;lt;/Files&amp;gt;&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
: &#039;&#039;&#039;Method 2&#039;&#039;&#039;: The alternative method is to use a .htaccess file&lt;br /&gt;
:This method is recommended for servers that will host multiple Moodle instances. It allows additional Moodle instances to be configured without restarting apache, and also makes the solution a little more portable. We need to add a directive to the main httpd.conf to allow configuration of authentication within .htaccess files.&lt;br /&gt;
    &amp;lt;Directory C:\moodle&amp;gt;&lt;br /&gt;
        AllowOverride AuthConfig&lt;br /&gt;
    &amp;lt;/Directory&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.9 or above&#039;&#039;&#039;:&lt;br /&gt;
:::Create a new text file named &#039;.htaccess&#039; in the directory &#039;C:\moodle\moodle\auth\ldap&#039; and add the following directives:&lt;br /&gt;
    &amp;lt;Files ntlmsso_magic.php&amp;gt;&lt;br /&gt;
        AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
        AuthType SSPI&lt;br /&gt;
        SSPIAuth On&lt;br /&gt;
        SSPIOfferBasic Off&lt;br /&gt;
        SSPIAuthoritative On&lt;br /&gt;
        SSPIDomain mycollege.ac.uk&lt;br /&gt;
        require valid-user&lt;br /&gt;
    &amp;lt;/Files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:: &#039;&#039;&#039;For 1.8 or below&#039;&#039;&#039;:&lt;br /&gt;
:::Create a new text file named &#039;.htaccess&#039; in the directory &#039;C:\moodle\moodle\auth\ntlm&#039; and add the following directives:&lt;br /&gt;
    &amp;lt;Files oncampuslogin.php&amp;gt;&lt;br /&gt;
        AuthName &amp;quot;Moodle at My College&amp;quot;&lt;br /&gt;
        AuthType SSPI&lt;br /&gt;
        SSPIAuth On&lt;br /&gt;
        SSPIOfferBasic Off&lt;br /&gt;
        SSPIAuthoritative On&lt;br /&gt;
        SSPIDomain mycollege.ac.uk&lt;br /&gt;
        require valid-user&lt;br /&gt;
    &amp;lt;/Files&amp;gt;&lt;br /&gt;
&lt;br /&gt;
:This enables the Moodle folder to be moved to any apache webserver that is configured to allow authentication configuration through .htaccess&lt;br /&gt;
&lt;br /&gt;
For further help and discussion: http://moodle.org/mod/forum/discuss.php?d=56565&lt;br /&gt;
&lt;br /&gt;
==Configuring IP/Subnet Mask==&lt;br /&gt;
Subnet masks are based on binary patterns so need a bit of knowledge to understand. The best way to find out what IP/Subnet masks to use is to ask your Network Admin. &lt;br /&gt;
* &#039;&#039;&#039;(pre-1.9 only)&#039;&#039;&#039; Once you have configured your IP/Subnet masks, you can use the check_ip.php page to test if you have set these ranges up correctly.&lt;br /&gt;
* The new way of specifiying subnets is even easier/more flexible than before 1.9. Just type them one after the other, separated by commas. You can use several syntaxes:&lt;br /&gt;
** Type the network-number/prefix-length combination. E.g. 192.168.1.0/24&lt;br /&gt;
** Type the network &#039;prefix&#039;, ending in a period character. E.g. 192.168.1.&lt;br /&gt;
** Type the network address range (&#039;&#039;&#039;this only works for the last address octect&#039;&#039;&#039;). E.g. 192.168.1.1-254&lt;br /&gt;
:All the three examples refer to the same subnetwork.&lt;br /&gt;
* So assuming you need to specify the following subnetworks:&lt;br /&gt;
** 10.1.0/255.255.0.0&lt;br /&gt;
** 10.2.0.0/255.255.0.0&lt;br /&gt;
** 172.16.0.0/255.255.0.0&lt;br /&gt;
** 192.168.100.0/255.255.255.240&lt;br /&gt;
:You can type:&lt;br /&gt;
  10.1.0.0/16, 10.2.0.0/16, 172.16.0.0/16, 192.168.100.0/28&lt;br /&gt;
: or:&lt;br /&gt;
  10.1.0.0/16, 10.2.0.0/16, 172.16.0.0/16, 192.168.100.240-255&lt;br /&gt;
:or even:&lt;br /&gt;
  10.1., 10.2., 172.16., 192.168.100.0/28&lt;br /&gt;
:(the last one cannot be expressed as a network &#039;prefix&#039; as the netmask does not fall in an octect boundary).&lt;br /&gt;
&lt;br /&gt;
==Notes/Tips==&lt;br /&gt;
# (pre-1.9 only) When using IIS, dbsessions is required to be set to &amp;quot;YES&amp;quot; because when Integrated authentication is turned on for the oncampuslogin.php page, and dbsessions is set to &amp;quot;NO&amp;quot; then the server impersonates the user to write the session in the moodledata\sessions folder. The recommended fix is to set dbsessions to &amp;quot;YES&amp;quot; so that sessions are stored in the db. The non-recommended alternative method is to allow domain users write access to the sessions directory.&lt;br /&gt;
# (pre-1.9 only) If you forget to change the internal IP addresses in index.php to your own, you can just use the offcampuslogin url to login using your admin account. eg: http://yoursite.com/moodle/auth/ntlm/offcampuslogin.php&lt;br /&gt;
#If you are using Firefox, you will need to follow these steps:&lt;br /&gt;
:*Load Firefox and type about:config in the address box. The configuration settings page should be displayed.&lt;br /&gt;
:*In the Filter box, type the word &amp;quot;ntlm&amp;quot; to filter the NTLM strings. You should see three settings displayed.&lt;br /&gt;
:*Double-click on &amp;quot;network.automatic-ntlm-auth.trusted-uris&amp;quot;.&lt;br /&gt;
:*In the box, enter the full URL of your Moodle server. For example &amp;lt;pre&amp;gt;http://moodle.mydomain.com&amp;lt;/pre&amp;gt;&lt;br /&gt;
:*Close Firefox and restart.&lt;br /&gt;
&lt;br /&gt;
==Specific File information== &lt;br /&gt;
(mainly for developers)&lt;br /&gt;
#auth\ntlm\index.php&amp;lt;br /&amp;gt;This is the page used for the Alternate Login URL setting on the config page for the NTLM plugin.&amp;lt;br&amp;gt;The index.php file handles which login page to use based on the IP address of the user.&amp;lt;br&amp;gt;if inside your network, they should be directed to the oncampuslogin.php screen.&amp;lt;br&amp;gt;if outside your network, they should be directed to the offcampuslogin.php screen.&amp;lt;br&amp;gt;you will need to modify the if statements in this file to match the IP ranges inside your network.&lt;br /&gt;
#auth\ntlm\index_form.html&amp;lt;br /&amp;gt;this is a copy of the file login\index_form.php.&amp;lt;br /&amp;gt; The only change in this file from the standard one is that the form action=&amp;quot;index.php&amp;quot; is changed to form action=&amp;quot;offcampuslogin.php&amp;quot; this is because anyone who is displayed the form will be an offcampus user.&lt;br /&gt;
#auth\ntlm\offcampuslogin.php&amp;lt;br /&amp;gt;this is a copy of the file moodle\login\index.php with a couple of minor modifications.&amp;lt;br /&amp;gt;the modifications to this file involve the setting of a variable ($onoroffcampus = &amp;quot;offcampus&amp;quot;;) this is used by the auth plugin to define which page is being used for authentication. the other modification is for displaying extra error messages to the user. - with all the authentication methods we have students are constantly confused about how to enter their credentials if you use NTLM authentication elsewhere at your site you will be aware of the users having to enter the domain\username when authenticating. - this code block sits around line 215 in the file.&lt;br /&gt;
#auth\ntlm\oncampuslogin.php&amp;lt;br /&amp;gt;this is a copy of the file login\index.php&amp;lt;br /&amp;gt;This file has been modified to get the details of the authenticated user via NTLM.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=42 Using Moodle: User authentication] forum&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=45887 NTLM Authentication] forum discussion&lt;br /&gt;
*[http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=314 Download the NTLM Authentication Module]&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=80104 Merging AD NTLM SSO into auth/ldap] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Authentification NTLM]]&lt;/div&gt;</summary>
		<author><name>Theforce</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/36/en/index.php?title=Capabilities/mod/scorm:savetrack&amp;diff=29912</id>
		<title>Capabilities/mod/scorm:savetrack</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/index.php?title=Capabilities/mod/scorm:savetrack&amp;diff=29912"/>
		<updated>2007-12-06T23:11:58Z</updated>

		<summary type="html">&lt;p&gt;Theforce: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;*This allows a user to save SCORM/AICC tracks -- in other words, for their scores, etc. to be recorded in Moodle.&lt;br /&gt;
&lt;br /&gt;
[[Category:Capabilities|SCORM]]&lt;br /&gt;
[[Category:SCORM]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Gaitasunak/mod/scorm:savetrack]]&lt;/div&gt;</summary>
		<author><name>Theforce</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/36/en/index.php?title=Import_course_data&amp;diff=27104</id>
		<title>Import course data</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/index.php?title=Import_course_data&amp;diff=27104"/>
		<updated>2007-09-20T03:04:02Z</updated>

		<summary type="html">&lt;p&gt;Theforce: note re: userdata&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Course admin}}&lt;br /&gt;
&lt;br /&gt;
Course data may be imported from any other course for which the teacher has editing rights.&lt;br /&gt;
However, using the Import Course Data feature, will not import user data, such as forum posts and discussions;  it will only import the structure of such activities.&lt;br /&gt;
&lt;br /&gt;
1.  Select the Import option from the Administration side-block.  &lt;br /&gt;
&lt;br /&gt;
2.  Next, select the course you wish to import from and click the &#039;&#039;Use this course&#039;&#039; button.&lt;br /&gt;
&lt;br /&gt;
3.  You will be presented with a check box list from which you can select the type of activities or resources you wish to import. &lt;br /&gt;
&lt;br /&gt;
4.  Finally, click &#039;&#039;Continue&#039;&#039; when done to import that data. &lt;br /&gt;
&lt;br /&gt;
NB: Selecting forums, for example, will import all forums from that course. Currently you cannot import individual items within a module type.&lt;br /&gt;
&lt;br /&gt;
Groups can also be imported as a batch from a file.&lt;br /&gt;
&lt;br /&gt;
Backups, especially in 1.6, offer other creative ways to bring in course material from other courses. See [[Course_backup]] or the backup link on the index.&lt;br /&gt;
&lt;br /&gt;
[[Image:Import.jpg]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Teacher]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Importation]]&lt;/div&gt;</summary>
		<author><name>Theforce</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/36/en/index.php?title=Enrolment/OSCommerce&amp;diff=19748</id>
		<title>Enrolment/OSCommerce</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/index.php?title=Enrolment/OSCommerce&amp;diff=19748"/>
		<updated>2007-01-29T22:55:33Z</updated>

		<summary type="html">&lt;p&gt;Theforce: added trivial description of work status&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Work-in-progress for the OSCommerce enrolment plugin. See http://moodle.org/mod/forum/discuss.php?d=60259&lt;br /&gt;
&lt;br /&gt;
So far, I&#039;m using the Catalyst specific OSCommerce branch, which has some modifications to suit the enrolment plugin for Moodle.  Most of the modifications either streamline the purchase process, or disable areas of OSCommerce which are not used in this setup.&lt;br /&gt;
&lt;br /&gt;
The enrolment plugin has been upgraded to suit Moodle 1.7, but needs some checking to see if anything has been missed in the changes from Moodle 1.5 (custom branch, however; closer to 1.6) to 1.7.&lt;br /&gt;
&lt;br /&gt;
More information will be added soon.&lt;/div&gt;</summary>
		<author><name>Theforce</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/36/en/index.php?title=Development:Unit_tests&amp;diff=14735</id>
		<title>Development:Unit tests</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/36/en/index.php?title=Development:Unit_tests&amp;diff=14735"/>
		<updated>2006-08-23T05:30:58Z</updated>

		<summary type="html">&lt;p&gt;Theforce: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The purpose of unit testing is to test the individual parts of the program (functions, and methods of classes) to make sure that each individually does the right thing. Once unit testing has given you the confidence that each part works, then you should use other forms of testing to ensure that the different parts work together properly.&lt;br /&gt;
&lt;br /&gt;
The unit testing framework is based on the [http://www.lastcraft.com/simple_test.php SimpleTest] framework. It was incorporated into Moodle by Nick Freear and Tim Hunt from [http://www.open.ac.uk/ The Open University].&lt;br /&gt;
&lt;br /&gt;
== Running the unit tests in Moodle ==&lt;br /&gt;
&lt;br /&gt;
=== Running the basic tests ===&lt;br /&gt;
&lt;br /&gt;
# Log in with an admin account. &lt;br /&gt;
# Go to the admin screen.&lt;br /&gt;
# Click on the &#039;&#039;&#039;Reports&#039;&#039;&#039; link near the bottom of the page.&lt;br /&gt;
# Click on the &#039;&#039;&#039;Run the unit tests&#039;&#039;&#039; link.&lt;br /&gt;
# Wait for the tests to run.&lt;br /&gt;
&lt;br /&gt;
=== Options for running the tests ===&lt;br /&gt;
&lt;br /&gt;
At the bottom of the tests page, there is form that lets you adjust the options used when running the tests.&lt;br /&gt;
&lt;br /&gt;
==== Show passes as well as fails ====&lt;br /&gt;
&lt;br /&gt;
Normally, only details of the tests that have failed are printed. Turning on this options shows details of all the passes too.&lt;br /&gt;
&lt;br /&gt;
==== Show the search for test files ====&lt;br /&gt;
&lt;br /&gt;
The tests to run are found automatically be searching the codebase for files whose names match &#039;&#039;&#039;test*.php&#039;&#039;&#039; in directories called &#039;&#039;&#039;simpletest&#039;&#039;&#039;. Turning on this option will print a list of the folders searched and the test files found. This is sometimes useful for debugging.&lt;br /&gt;
&lt;br /&gt;
This option is particularly useful when one of your test files has a syntax error. When this happens, you sometimes just get a blank page with no error message. Turning on the show search option lets you see which test file it was that gave the error. If necessary, you can enable this option manually by adding &amp;quot;showsearch=1&amp;quot; to the end of the URL.&lt;br /&gt;
&lt;br /&gt;
==== Run a thorough test (may be slow) ====&lt;br /&gt;
&lt;br /&gt;
If you turn on this option, then as well as looking for files called &#039;&#039;&#039;test*.php&#039;&#039;&#039;, the search also looks for files called &#039;&#039;&#039;slowtest*.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
To be useful, the full test run should find most bugs, but not take too long to complete. So if you have very, very detailed tests of an area of the code, it may be better to select a subset for everday testing, and only use the more detailed tests when a bug is reported, or you are doing new development in that area of the code.&lt;br /&gt;
&lt;br /&gt;
This option is most useful when combined with the next option.&lt;br /&gt;
&lt;br /&gt;
==== Only run tests in ====&lt;br /&gt;
&lt;br /&gt;
Normally, tests from all parts of the codebase are run. However, when you are just doing development of one part of the code, that is a waste of time. You can type the name of a folder (for example &#039;&#039;&#039;mod/quiz&#039;&#039;&#039;) or a particular test file (for example &#039;&#039;&#039;lib/simpletest/testdatalib.php&#039;&#039;&#039;) and then only those tests will be run.&lt;br /&gt;
&lt;br /&gt;
[[Image:RunOnlyTheseTests.png|right]] Instead of typing a path into this box, there is an easier way. Whenever a pass or fail is displayed, the name of the test file is printed. Each section of the path name is a link to run only the tests in that folder or file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Writing new tests ==&lt;br /&gt;
&lt;br /&gt;
As an example, suppose we wanted to start writing tests for the functions in the file &#039;question/editlib.php&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Where to put the tests ===&lt;br /&gt;
&lt;br /&gt;
If you have read the first half of this page and were paying attention, you can probably work out that you should create a folder called &#039;&#039;&#039;question/testeditlib&#039;&#039;&#039;, and create a file in there called something like &#039;&#039;&#039;testeditlib.php&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The skeleton of this file should look like:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;?php&lt;br /&gt;
/**&lt;br /&gt;
 * Unit tests for (some of) question/editlib.php.&lt;br /&gt;
 *&lt;br /&gt;
 * @copyright &amp;amp;copy; 2006 The Open University&lt;br /&gt;
 * @author T.J.Hunt@open.ac.uk&lt;br /&gt;
 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License&lt;br /&gt;
 * @package question&lt;br /&gt;
 */&lt;br /&gt;
&lt;br /&gt;
/** */&lt;br /&gt;
require_once(dirname(__FILE__) . &#039;/../../config.php&#039;);&lt;br /&gt;
&lt;br /&gt;
global $CFG;&lt;br /&gt;
require_once($CFG-&amp;gt;libdir . &#039;/simpletestlib.php&#039;); // Include the test libraries&lt;br /&gt;
require_once($CFG-&amp;gt;dirroot . &#039;/question/editlib.php&#039;); // Include the code to test&lt;br /&gt;
&lt;br /&gt;
/** This class contains the test cases for the functions in editlib.php. */&lt;br /&gt;
class question_editlib_test extends UnitTestCase {&lt;br /&gt;
    function test_get_default_question_category() {&lt;br /&gt;
        // Do the test here/&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
?&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That is, you have a class called something_test, and in that class you have lots of methods called test_something. Normally, you have one test method for each function you want to test, and you may as well called the test method &#039;&#039;&#039;test_name_of_function_being_tested&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Inside a test function ===&lt;br /&gt;
&lt;br /&gt;
The inside of a test function tyically looks like this: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;function test_get_default_question_category() {&lt;br /&gt;
    // Set things up in preparation for the test.&lt;br /&gt;
&lt;br /&gt;
    // Call the function you want to test.&lt;br /&gt;
&lt;br /&gt;
    // Check that the result is what you expected.&lt;br /&gt;
}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
=== Test data ===&lt;br /&gt;
&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
=== setUp and tearDown methods ===&lt;br /&gt;
&lt;br /&gt;
If all your test cases relate to the same area of code, and so need the same set of test data, then you can create a method called &amp;lt;code&amp;gt;setUp()&amp;lt;/code&amp;gt; that sets up the test data. If present, this method will be called before each test method. You can write a matching &amp;lt;code&amp;gt;tearDown()&amp;lt;/code&amp;gt; method if there is any clean-up that needs to be done after each test case has run.&lt;br /&gt;
&lt;br /&gt;
If you have some test test cases the need one sort of setup, and some other test cases that need a different setup, consider splitting your tests into two separate classes, each with its own &amp;lt;code&amp;gt;setUp()&amp;lt;/code&amp;gt; method.&lt;br /&gt;
&lt;br /&gt;
=== Further information ===&lt;br /&gt;
&lt;br /&gt;
The simpletest documentation is at: http://simpletest.sourceforge.net/.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Changes to your existing code to make it work with unit testing ==&lt;br /&gt;
&lt;br /&gt;
When code is being tested, it gets included from inside one of the simpletest library function. If the code is expecting to be run directly (for example, if it is a view.php or index.php function), you are likely to get errors becuase that expectation is no longer true.&lt;br /&gt;
&lt;br /&gt;
=== Include paths ===&lt;br /&gt;
&lt;br /&gt;
Includes like&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;require_once(&#039;../../config.php&#039;); // Won&#039;t work.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
won&#039;t work. Instead, the more robust option is &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;require_once(dirname(__FILE__) . &#039;/../../config.php&#039;); // Do this.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Access to global variables ===&lt;br /&gt;
&lt;br /&gt;
Because your code was included from within a function, you can&#039;t access access global variables until you have done a global statement.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;require_once(dirname(__FILE__) . &#039;/../../config.php&#039;);&lt;br /&gt;
require_once($CFG-&amp;gt;libdir . &#039;/moodlelib.php&#039;); // Won&#039;t work.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;require_once(dirname(__FILE__) . &#039;/../../config.php&#039;);&lt;br /&gt;
&lt;br /&gt;
global $CFG; // You need this.&lt;br /&gt;
require_once($CFG-&amp;gt;libdir . &#039;/moodlelib.php&#039;); // Will work now.&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== More about unit testing in general ==&lt;br /&gt;
&lt;br /&gt;
The best book I know about unit testing is &#039;&#039;&#039;Pragmatic Unit Testing in Java with JUnit&#039;&#039; by Andrew Hunt (no relation) and David Thomas. I know, this book is not called Pragmatic Unit Testing in PHP with SimpleTest. However, it is an excellent book - short, to the point, and very practical. Most of what it says is not specific to Java and JUnit and it is obvious how to apply it in our testing setup.&lt;br /&gt;
&lt;br /&gt;
[[Category:Developer]]&lt;/div&gt;</summary>
		<author><name>Theforce</name></author>
	</entry>
</feed>