<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/30/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fox</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/30/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fox"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/Special:Contributions/Fox"/>
	<updated>2026-04-09T03:16:58Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Talk:New_features&amp;diff=124611</id>
		<title>Talk:New features</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Talk:New_features&amp;diff=124611"/>
		<updated>2016-05-23T15:24:29Z</updated>

		<summary type="html">&lt;p&gt;Fox: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is protected, so i can&#039;t edit it to add a link to the french version.&lt;br /&gt;
Would you be kind to add it, linking to the (french) page &amp;quot;Nouveautés de Moodle 3.0&amp;quot; (and do the equivalent in documentation for version 2.9 and 3.1).&lt;br /&gt;
Thanks, --[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 21:42, 23 May 2016 (AWST)&lt;br /&gt;
&lt;br /&gt;
==Reply from Mary==&lt;br /&gt;
I&#039;ve done that but there is currently no page for 3.1 - but I&#039;ve made the link in anticipation. --[[User:Mary Cooch|Mary Cooch]] ([[User talk:Mary Cooch|talk]]) 22:27, 23 May 2016 (AWST)&lt;br /&gt;
&lt;br /&gt;
: Thanks Mary. The french page for 3.1 will soon exist ;-) --[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 23:24, 23 May 2016 (AWST)&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Talk:New_features&amp;diff=124606</id>
		<title>Talk:New features</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Talk:New_features&amp;diff=124606"/>
		<updated>2016-05-23T13:42:10Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page is protected, so i can&#039;t edit it to add a link to the french version.&lt;br /&gt;
Would you be kind to add it, linking to the (french) page &amp;quot;Nouveautés de Moodle 3.0&amp;quot; (and do the equivalent in documentation for version 2.9 and 3.1).&lt;br /&gt;
Thanks, --[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 21:42, 23 May 2016 (AWST)&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Logged_in_user_block&amp;diff=122247</id>
		<title>Logged in user block</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Logged_in_user_block&amp;diff=122247"/>
		<updated>2016-02-11T09:23:06Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Blocks}}&lt;br /&gt;
The logged in user block displays certain information about the user who is currently logged in to a Moodle course:&lt;br /&gt;
&lt;br /&gt;
[[File:Loggedinuserexample.png]]&lt;br /&gt;
&lt;br /&gt;
The information which is displayed can be selected by the course teacher by clicking on the &amp;quot;configure&amp;quot; icon of the block. A number of dropdown boxes then appear for the teacher to choose which items will appear:&lt;br /&gt;
&lt;br /&gt;
[[File:Loggedinusersettings.png]]&lt;br /&gt;
&lt;br /&gt;
[[de:Persönliches-Profil-Block]]&lt;br /&gt;
[[es:Bloque de usuario ingresado]]&lt;br /&gt;
[[fr:Bloc Utilisateur connecté]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Moodle_Mobile_additional_features&amp;diff=122231</id>
		<title>Moodle Mobile additional features</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Moodle_Mobile_additional_features&amp;diff=122231"/>
		<updated>2016-02-10T16:05:15Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Mobile}}&lt;br /&gt;
{{Infobox plugin&lt;br /&gt;
|type = Local plugin&lt;br /&gt;
|entry = http://moodle.org/plugins/view.php?plugin=local_mobile&lt;br /&gt;
|tracker = https://tracker.moodle.org/browse/CONTRIB/component/13930&lt;br /&gt;
|discussion = https://moodle.org/mod/forum/view.php?id=7798&lt;br /&gt;
|maintainer = [[User:Juan Leyva|Juan Leyva]]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The Moodle Mobile additional features plugin provides new features and web services for the Moodle Mobile app which are currently only available in the latest Moodle version.&lt;br /&gt;
&lt;br /&gt;
This plugin is officially developed and maintained by Moodle HQ&lt;br /&gt;
&lt;br /&gt;
== How it works ==&lt;br /&gt;
&lt;br /&gt;
Once installed the plugin creates a new service &amp;quot;Moodle Mobile additional features&amp;quot;. The Mobile app checks if this service is enabled. If not, the Mobile app falls backs to the standard core Mobile app service.&lt;br /&gt;
&lt;br /&gt;
Please, open [[Moodle Mobile features]] to check what new features are added to your site depending on your Moodle version.&lt;br /&gt;
&lt;br /&gt;
== Features ==&lt;br /&gt;
&lt;br /&gt;
* Support for sites using SSO authentication methods (Shibboleth and CAS)&lt;br /&gt;
* Support for sites using MNet authentication (Moodle Network authentication)&lt;br /&gt;
* Support for push notifications in Moodle sites prior to version 2.6&lt;br /&gt;
&lt;br /&gt;
=== Enable authentication for sites using SSO methods (like Shibboleth and CAS) ===&lt;br /&gt;
&lt;br /&gt;
VERY IMPORTANT NOTE: You need to disable the &amp;quot;Auto login guest&amp;quot; option &amp;quot;autologinguests&amp;quot;. This setting is not compatible with the SSO via app.&lt;br /&gt;
&lt;br /&gt;
SSO and MNet authentication is not supported in the Windows 8 and Windows Phone 8 apps&lt;br /&gt;
&lt;br /&gt;
Once the plugin is installed, you need to go to Site administration &amp;gt; Plugins &amp;gt; Local plugins &amp;gt; Moodle Mobile additional features&lt;br /&gt;
&lt;br /&gt;
There you can choose the &amp;quot;Type of login&amp;quot;:&lt;br /&gt;
; &#039;&#039;&#039;Via the app&#039;&#039;&#039; : Is the default login, the user must introduce his credentials in the app&lt;br /&gt;
; &#039;&#039;&#039;Via a browser window&#039;&#039;&#039; : A new browser instance is open in the mobile device pointing to the login form in the Moodle site (which may again redirect to external identity providers if required). The user must introduce his credentials there. This is the option that must be selected for sites using SSO methods (or for sites that wants to force the user to authenticate in the site, not in the app)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;mediaplayer&amp;gt;https://www.youtube.com/watch?v=cl8rsyyyg9g&amp;lt;/mediaplayer&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
# Unpack the zip file into the local/ directory. A new directory will be created called local/mobile.&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Notifications&#039;&#039; to complete the plugin installation.&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Web services &amp;gt; Mobile&#039;&#039; and enable web services for mobile devices (Remember to save the changes)&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Web services &amp;gt; External services&#039;&#039;, edit &amp;quot;Moodle Mobile additional features&amp;quot; and check the &amp;quot;Enabled&amp;quot; field, then save changes.&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;, edit the Authenticated user role and allow the capability moodle/webservice:createtoken.&lt;br /&gt;
&lt;br /&gt;
Note: You need to have upgraded the Moodle Mobile app to version 1.4.4.&lt;br /&gt;
&lt;br /&gt;
If you are currently using the Moodle Mobile app, you will need to log out of all your sites in order for the app to detect the new service.&lt;br /&gt;
&lt;br /&gt;
== Admin users, please read ==&lt;br /&gt;
&lt;br /&gt;
This plugin installs a new service in your Moodle installation, the automatic token creation for this type of services is forbidden for admin users. This means that admin users will not be able to use the Mobile app.&lt;br /&gt;
&lt;br /&gt;
This can be solved easily, administrators must create a token manually in Moodle (&#039;&#039;Plugins &amp;gt; Web Services &amp;gt; Manage tokens&#039;&#039;) for the local_mobile service. &#039;&#039;&#039;Note:&#039;&#039;&#039; Be sure to toggle the default &amp;quot;Moodle mobile web services&amp;quot; setting to &amp;quot;Moodle mobile additional features service&amp;quot; before creating the token. &lt;br /&gt;
&lt;br /&gt;
[[de:Moodle Mobile - Zusatzfunktionen]]&lt;br /&gt;
[[es:Características adicionales de Moodle Mobile]]&lt;br /&gt;
[[fr:Fonctionnalités additionnelles de l&#039;app mobile]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Creating_Moodle_Mobile_friendly_courses&amp;diff=122230</id>
		<title>Creating Moodle Mobile friendly courses</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Creating_Moodle_Mobile_friendly_courses&amp;diff=122230"/>
		<updated>2016-02-10T16:02:39Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Mobile}}&lt;br /&gt;
As more and more students access courses from their smartphones, tablets or other mobile devices, it is increasingly important to ensure your courses are mobile-friendly.&lt;br /&gt;
&lt;br /&gt;
Encouraging students to install the [https://download.moodle.org/mobile/ official Moodle mobile app] is one way to improve their learning experience. Below are some suggestions for optimising your course materials for students both using the app and accessing Moodle from mobile devices.&lt;br /&gt;
&lt;br /&gt;
==Use a mobile-friendly theme==&lt;br /&gt;
&lt;br /&gt;
Recent versions of Moodle allow for responsive themes, which adapt to the browser screen size. Make sure your course uses such a theme and check its contents yourself before your students start the course.&lt;br /&gt;
&lt;br /&gt;
==Notifications and messages==&lt;br /&gt;
&lt;br /&gt;
Encourage your students to enable mobile notifications so they are alerted about calendar events, forum posts, messages, assignment submissions and so on. Find out more in [[Mobile app notifications]].&lt;br /&gt;
&lt;br /&gt;
==Provide a &#039;how to&#039; guide to Moodle on the mobile==&lt;br /&gt;
&lt;br /&gt;
Consider offering your students a guide (as a PDF or a page resource) on how to access your course on the app, what they can do and not (yet) do from the app. Read up on the [[Moodle Mobile features]] and what&#039;s [[New for mobile]].&lt;br /&gt;
&lt;br /&gt;
==Setting up your course==&lt;br /&gt;
&lt;br /&gt;
*Topics or weekly course format is best suited to mobile devices.&lt;br /&gt;
*Don&#039;t use orphaned activities or direct links to activities.&lt;br /&gt;
*If you have a mix of students accessing the course on mobile and desktop, consider asking your admin to install the [[Moodle Mobile availability plugin]] which restricts items to desktop or mobile users.&lt;br /&gt;
&lt;br /&gt;
==Course content==&lt;br /&gt;
&lt;br /&gt;
*Labels are initially collapsed, so include a short text introduction of what is inside any label.&lt;br /&gt;
*Use responsive HTML in pages or mini-sites.&lt;br /&gt;
*Try to use a [[Page resource|page resource]] instead of downloadable documents where possible.&lt;br /&gt;
*Avoid uploading many documents or having numerous, text heavy pages. Think more in terms of short &amp;quot;information-bytes&amp;quot;.&lt;br /&gt;
*If you include YouTube videos, provide them also for download and offline viewing in a [[Folder resource|folder]]. Not all video formats are supported so add them in different formats. (MP4 is probably the most widely accepted format.)&lt;br /&gt;
*Note that if you add YouTube video links or map links as URL resources, they will open automatically in the app.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:moodlemobile_short_text_intro.png|thumb|Short text for label]]&lt;br /&gt;
| [[File:moodlemobile_responsive_html.png|thumb|Responsive HTML]]&lt;br /&gt;
| [[File:moodlemobile_youtube_maps_links.png|thumb|Map link]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
=== Things to avoid===&lt;br /&gt;
&lt;br /&gt;
Some activities are not yet supported by the mobile app, so find alternatives.&lt;br /&gt;
&lt;br /&gt;
*Instead  of using an [[IMS content package]], unzip the file and add it as a resource (mini-site)&lt;br /&gt;
&lt;br /&gt;
See [[Moodle Mobile SCORM player]] for things to avoid in SCORM packages.&lt;br /&gt;
&lt;br /&gt;
==Learn more==&lt;br /&gt;
&lt;br /&gt;
* [http://es.slideshare.net/juanleyva/tips-for-creating-moodle-mobile-friendly-courses-sites-moodlemoot-spain-2014 Tips for creating Moodle Mobile friendly courses and sites - MoodleMoot Spain 2014] - Juan Leyva, Mobile app developer,  presented this in 2014. While some features have now been updated, the general principles are still useful. &lt;br /&gt;
* An open course, about &amp;quot;[http://tempus-efa.proj.ac.il/moodle/course/view.php?id=102 Teaching using Mobile - Best practices]&amp;quot;&lt;br /&gt;
&lt;br /&gt;
[[es:Crear sitios amistosos para Moodle Mobile]]&lt;br /&gt;
[[fr:Créer des cours pour appareils mobiles]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Mobile_app_notifications&amp;diff=122229</id>
		<title>Mobile app notifications</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Mobile_app_notifications&amp;diff=122229"/>
		<updated>2016-02-10T16:01:28Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Mobile}}&lt;br /&gt;
&lt;br /&gt;
==For students and teachers==&lt;br /&gt;
[[File:12Notifications.png|thumb|Forum post notification]]&lt;br /&gt;
The Moodle mobile app lets you keep up to date with all that&#039;s happening in your courses and on the site. Every time you open the app, events are synchronised with the main website.&lt;br /&gt;
&lt;br /&gt;
You will receive [[Calendar|Moodle calendar]] event notifications automatically. If you don&#039;t want to get them, you can turn them all off in the app in &#039;&#039;Settings &amp;gt; General,&#039;&#039; or individually in the Calendar events options in the main menu.&lt;br /&gt;
&lt;br /&gt;
You will also receive notifications of messages, forum posts, submitted assignments etc (known as &#039;push notifications&#039;) if your site administrator has enabled these. To receive these notifications you need to enable them for your mobile on the main site, from the user menu top right &amp;gt;&#039;&#039;Preferences&amp;gt;Messaging.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==For administrators==&lt;br /&gt;
&lt;br /&gt;
Push notifications can be enabled by an administrator by connecting their Moodle site to a messaging server such https://messages.moodle.net (available for [[Site registration|registered Moodle sites]] only). An access key can be obtained via &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message outputs &amp;gt; Mobile Notifications&#039;&#039;. (If you have problems requesting the access key, please fill in the [http://goo.gl/forms/WLwkbe8b7c  Airnotifier access key manual request form]. Your site registration will be checked and you will be sent an access key in a few days if everything is correct.)&lt;br /&gt;
&lt;br /&gt;
Users then need to connect at least once with the latest version of the Moodle Mobile app in order to register their phones with the Moodle site.&lt;br /&gt;
&lt;br /&gt;
=== Event Reminders plugin===&lt;br /&gt;
&lt;br /&gt;
Push notifications can also include calendar event notifications, however this requires the [https://moodle.org/plugins/view/local_reminders Event Reminders plugin] to be installed on the Moodle site.&lt;br /&gt;
&lt;br /&gt;
The Event Reminders plugin will automatically send reminders for Moodle calendar events in a timely manner via Moodle message interface. It also allows users to control how they receive messages for each type of event in the Moodle calendar.&lt;br /&gt;
&lt;br /&gt;
=== Installing your own notifications infrastructure ===&lt;br /&gt;
&lt;br /&gt;
If you have a customized version of the Moodle Mobile app, or you want to use your own notifications infrastructure, you will have to install a private [http://airnotifier.github.io AirNotifier] (backend server for notifications).&lt;br /&gt;
&lt;br /&gt;
https://messages.moodle.net uses a slightly modified version of Airnotifier: https://github.com/moodlehq/airnotifier/tree/moodle2. &lt;br /&gt;
&lt;br /&gt;
You will have to add your app certificates - see https://github.com/airnotifier/airnotifier/wiki/Installation for further information.&lt;br /&gt;
&lt;br /&gt;
The Airnotifier message plugin allows you to point to your custom Airnotifier instance using your own access keys.&lt;br /&gt;
&lt;br /&gt;
Remember to install using GIT (repository https://github.com/moodlehq/airnotifier.git branch &#039;&#039;moodle2&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
[[de:Moodle Mobile - Mitteilungen]]&lt;br /&gt;
[[es:Mobile app Notificaciones Push]]&lt;br /&gt;
[[fr:Notifications de l&#039;app mobile]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Moodle_Mobile&amp;diff=122227</id>
		<title>Moodle Mobile</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Moodle_Mobile&amp;diff=122227"/>
		<updated>2016-02-10T15:47:27Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Main page}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
==On the move with Moodle==&lt;br /&gt;
[[File:Mobile orientation.png|thumb|Access your Moodle course on your mobile]]&lt;br /&gt;
Moodle Mobile is the official mobile app for Moodle.&lt;br /&gt;
&lt;br /&gt;
* Browse the content of your courses, even when offline&lt;br /&gt;
* Participate in course activities from your mobile device&lt;br /&gt;
* Receive instant notifications of messages and other events&lt;br /&gt;
* Quickly find and contact other people in your courses&lt;br /&gt;
* Upload images, audio, videos and other files.&lt;br /&gt;
* View your course grades&lt;br /&gt;
&lt;br /&gt;
... and more - see the full list of [[Moodle Mobile features]].&lt;br /&gt;
&lt;br /&gt;
The Moodle Mobile app is available for free from Google Play, Apple Store, and the Windows Phone Store. See [https://download.moodle.org/mobile/ Moodle Mobile downloads] for links. You can also install the app directly from your mobile device by searching for &#039;Moodle Mobile&#039; with author/owner &#039;Moodle Pty Ltd&#039;.&lt;br /&gt;
&lt;br /&gt;
==Using the app==&lt;br /&gt;
*To set up notifications on your app, see [[Mobile app notifications]]&lt;br /&gt;
*For a quick guide to setting up the Moodle mobile app on your site, see [[Moodle Mobile guide for admins]].&lt;br /&gt;
*For ideas to make your Moodle course more mobile friendly, see [[Creating Moodle Mobile friendly courses]].&lt;br /&gt;
&lt;br /&gt;
==Rapid development==&lt;br /&gt;
More features are being added to Moodle Mobile all the time. See [[New for mobile|what&#039;s new in Moodle Mobile]] and the [[:dev:Moodle Mobile release notes|Moodle Mobile release notes]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [[Moodle Mobile FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Mobile]]&lt;br /&gt;
	&lt;br /&gt;
[[fr:App mobile]]&lt;br /&gt;
[[ja:モバイルアプリ]]&lt;br /&gt;
[[de:Mobiles Moodle]]&lt;br /&gt;
[[es:Moodle Mobile]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Moodle_Mobile_features&amp;diff=122226</id>
		<title>Moodle Mobile features</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Moodle_Mobile_features&amp;diff=122226"/>
		<updated>2016-02-10T15:44:59Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Mobile}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
&amp;lt;div class=&amp;quot;contentblock&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:mobile01.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;See your courses at glance&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;Your courses are listed with easy access to contents, participants, grades and notes. A useful filter field lets you find a particular course quickly. If your token expires during a session, you&#039;re prompted to re-enter your password and continue. &amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:02connectwithcourseparticipants.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Connect with course participants&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt; Infinite scrolling improves access to the participant view, with the complete user profile now displayed and available from every page. &amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt; &lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;contentblock&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:10PulltoRefresh.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Pull to refresh&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;Most screens will allow you to pull to refresh, improving the real-time participation experience.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:Mobile orientation.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt; Orientation and resolution support &amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;The app displays in portrait or landscape view, whatever your screen resolution.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;contentblock&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:03coursecontent.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Easily access course content&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;View course activities and and download materials for offline use.  Work through Books and IMS Content packages directly in the app. The downloading status of resources is preserved even when changing sections or pages.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:04ActivityCompletionCheckboxes.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Activity completion&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;Track progress from your device with [[Activity completion]]. Automatic completion is registered, and students can also manually mark a task complete on their mobile.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;contentblock&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:05Grades.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Grades and grading&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt; A Grades link for each course gives fingertip access to the gradebook, and teachers can view assignment submissions on the move.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:06Notes.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Notes&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;Teachers can view site, course and personal notes about their students and add their own notes.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;contentblock&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:07Messages.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Message participants&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;Send and view private messages to colleagues and students from the Messages link in the side tab.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:08Calendar.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Keep up to date with calendar events&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;Site, course and user events can be viewed in the calendar.Calendar events can now be viewed offline and infinite scrolling is available.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&amp;quot;contentblock&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:09PrivateFiles.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;View and upload to your Private files&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;Check the contents of your private files and upload media to them on the go. You&#039;re now allowed up to 50MB storage (depending on your SD card).&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;&lt;br /&gt;
[[File:12Notifications.png|600px]]&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;&lt;br /&gt;
            &amp;lt;h4&amp;gt;Notifications&amp;lt;/h4&amp;gt;&lt;br /&gt;
            &amp;lt;p&amp;gt;Keep up to date with notifications. The app supports both local (calendar events) and push (messages, forum posts, submitted assignments etc) notifications. See [[Mobile app notifications]] for more details. Infinite scrolling is available and local notifications have multi-site support.&amp;lt;/p&amp;gt;&lt;br /&gt;
          &amp;lt;/div&amp;gt;&lt;br /&gt;
        &amp;lt;/div&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
  &amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;			&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;			&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;			&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;			&lt;br /&gt;
[[File: MobileChoice.png|600px]]			&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;			&lt;br /&gt;
            &amp;lt;h4&amp;gt;Make choices&amp;lt;/h4&amp;gt;			&lt;br /&gt;
            &amp;lt;p&amp;gt;The app supports students making and removing choices.&amp;lt;/p&amp;gt;			&lt;br /&gt;
          &amp;lt;/div&amp;gt; 			&lt;br /&gt;
        &amp;lt;/div&amp;gt;			&lt;br /&gt;
      &amp;lt;/li&amp;gt;			&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;			&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;			&lt;br /&gt;
[[File:MobileappChat.png|600px]]			&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;			&lt;br /&gt;
            &amp;lt;h4&amp;gt;Engage in chat, on the move&amp;lt;/h4&amp;gt;			&lt;br /&gt;
            &amp;lt;p&amp;gt;Participate in a course [[Chat activity]].&amp;lt;/p&amp;gt;			&lt;br /&gt;
          &amp;lt;/div&amp;gt;			&lt;br /&gt;
        &amp;lt;/div&amp;gt;			&lt;br /&gt;
      &amp;lt;/li&amp;gt;			&lt;br /&gt;
    &amp;lt;/ul&amp;gt;			&lt;br /&gt;
  &amp;lt;/div&amp;gt;			&lt;br /&gt;
&amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;			&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;			&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;			&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;			&lt;br /&gt;
[[File:MobileSurvey.png|600px]]			&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;			&lt;br /&gt;
            &amp;lt;h4&amp;gt; Feed back to teachers with a survey&amp;lt;/h4&amp;gt;			&lt;br /&gt;
            &amp;lt;p&amp;gt;[[Survey|Surveys]] may now be taken using the app.&amp;lt;/p&amp;gt;			&lt;br /&gt;
          &amp;lt;/div&amp;gt; 			&lt;br /&gt;
        &amp;lt;/div&amp;gt;			&lt;br /&gt;
      &amp;lt;/li&amp;gt;			&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;			&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;			&lt;br /&gt;
[[File: coursesearchmobile.png|600px]]			&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;			&lt;br /&gt;
            &amp;lt;h4&amp;gt;Search the list of courses&amp;lt;/h4&amp;gt;			&lt;br /&gt;
            &amp;lt;p&amp;gt;App users can search courses to find one they wish to take.&amp;lt;/p&amp;gt;			&lt;br /&gt;
          &amp;lt;/div&amp;gt;			&lt;br /&gt;
        &amp;lt;/div&amp;gt;			&lt;br /&gt;
      &amp;lt;/li&amp;gt;			&lt;br /&gt;
    &amp;lt;/ul&amp;gt;			&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;row-fluid&amp;quot;&amp;gt;			&lt;br /&gt;
    &amp;lt;ul class=&amp;quot;thumbnails&amp;quot;&amp;gt;			&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;			&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;			&lt;br /&gt;
[[File:enrolmemobile.png|600px]]			&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;			&lt;br /&gt;
            &amp;lt;h4&amp;gt;Enrol yourself from your smartphone&amp;lt;/h4&amp;gt;			&lt;br /&gt;
            &amp;lt;p&amp;gt;Found a course you like? Enrol immediately via the app.&amp;lt;/p&amp;gt;			&lt;br /&gt;
          &amp;lt;/div&amp;gt; 			&lt;br /&gt;
        &amp;lt;/div&amp;gt;			&lt;br /&gt;
      &amp;lt;/li&amp;gt;			&lt;br /&gt;
      &amp;lt;li class=&amp;quot;span6&amp;quot;&amp;gt;			&lt;br /&gt;
        &amp;lt;div class=&amp;quot;thumbnail&amp;quot;&amp;gt;			&lt;br /&gt;
[[File:scorm syncing.png|600px]]			&lt;br /&gt;
          &amp;lt;div class=&amp;quot;caption&amp;quot;&amp;gt;			&lt;br /&gt;
            &amp;lt;h4&amp;gt;Play SCORM packages on and off-line&amp;lt;/h4&amp;gt;			&lt;br /&gt;
            &amp;lt;p&amp;gt;The [[Moodle Mobile SCORM player]] tracks interactions and synchronises when you&#039;re back online.&amp;lt;/p&amp;gt;			&lt;br /&gt;
          &amp;lt;/div&amp;gt; 			&lt;br /&gt;
        &amp;lt;/div&amp;gt;			&lt;br /&gt;
      &amp;lt;/li&amp;gt;		&lt;br /&gt;
    &amp;lt;/ul&amp;gt;			&lt;br /&gt;
  &amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Features summary====&lt;br /&gt;
&lt;br /&gt;
* Responsive design for phone and tablets&lt;br /&gt;
* Upload a picture into your private file area&lt;br /&gt;
* Record an audio file and upload it into your private file area&lt;br /&gt;
* Record a video and upload it into your private file area&lt;br /&gt;
* Send a private message to a course participant (can be done offline)&lt;br /&gt;
* Take a personal note about a course participant (can be done offline)&lt;br /&gt;
* Add a course participant to your phone contact&lt;br /&gt;
* Call a course participant touching the phone number&lt;br /&gt;
* Locate a course participant address on Google map&lt;br /&gt;
* Download and view some course resources&lt;br /&gt;
* Quick access to your course contents&lt;br /&gt;
* View calendar events&lt;br /&gt;
* Reminder notifications for calendar events&lt;br /&gt;
* Mobile Push notifications&lt;br /&gt;
* Remote layout/style customization (see below)&lt;br /&gt;
* View all your past private messages and notifications&lt;br /&gt;
* Browse and download your private and course files&lt;br /&gt;
* View forum discussions&lt;br /&gt;
* Private messaging between users&lt;br /&gt;
* Calendar integration with warning reminders as local notifications&lt;br /&gt;
* Upload any type of file from your device to your Moodle private files area&lt;br /&gt;
* View the book module and IMS CP&lt;br /&gt;
* View site, course and personal users notes&lt;br /&gt;
* Support for sites using CAS or Shibboleth as auth methods &lt;br /&gt;
* View your activity and course total grades in a course &lt;br /&gt;
* Participate in choices &lt;br /&gt;
* Participate in chats &lt;br /&gt;
* Participate in surveys&lt;br /&gt;
* Access external tools (LTI)&lt;br /&gt;
* Course search&lt;br /&gt;
* Self-enrolment in courses&lt;br /&gt;
* Access courses with guest access enrolment method enabled&lt;br /&gt;
* [[Moodle_Mobile_SCORM_player|SCORM player]]&lt;br /&gt;
&lt;br /&gt;
==Comparison of features in different versions==&lt;br /&gt;
[[File:30_moodlemobile_features.png]]&lt;br /&gt;
&lt;br /&gt;
=== Languages ===&lt;br /&gt;
&lt;br /&gt;
Over 15 languages are currently supported: Arabic, Basque, Catalan, Chinese, Czech, Dutch, English, French, German, Hebrew, Hungarian, Italian, Japanese, Mexican Spanish, Portuguese, Russian, Spanish, Swedish&lt;br /&gt;
&lt;br /&gt;
[[es:Características de Moodle Mobile]]&lt;br /&gt;
[[fr:Fonctionnalités de l&#039;app mobile]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=External_database_enrolment&amp;diff=122223</id>
		<title>External database enrolment</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=External_database_enrolment&amp;diff=122223"/>
		<updated>2016-02-10T09:34:13Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Enrolment}}&lt;br /&gt;
==Using an external database to control enrolments==&lt;br /&gt;
&lt;br /&gt;
You may use a external database (of nearly any kind) to control your enrolments. It is assumed your external database contains a field containing a course ID, a field containing a user ID, and optionally a field containing a role. These are compared against fields that you choose in the local course, user tables, and role tables.&lt;br /&gt;
&lt;br /&gt;
The following are the supported data sources, but note that you will need to have to compiled PHP with the appropriate options or through ODBC.&lt;br /&gt;
&lt;br /&gt;
*access&lt;br /&gt;
*ado&lt;br /&gt;
*mssql&lt;br /&gt;
*borland_ibase&lt;br /&gt;
*csv&lt;br /&gt;
*db2&lt;br /&gt;
*fbsql&lt;br /&gt;
*firebird&lt;br /&gt;
*ibase&lt;br /&gt;
*informix72&lt;br /&gt;
*informix&lt;br /&gt;
*mysql&lt;br /&gt;
*mysqlt&lt;br /&gt;
*oci805&lt;br /&gt;
*oci8&lt;br /&gt;
*oci8po&lt;br /&gt;
*odbc&lt;br /&gt;
*odbc_mssql&lt;br /&gt;
*odbc_oracle&lt;br /&gt;
*oracle&lt;br /&gt;
*postgres64&lt;br /&gt;
*postgres7&lt;br /&gt;
*postgres&lt;br /&gt;
*proxy&lt;br /&gt;
*sqlanywhere&lt;br /&gt;
*sybase&lt;br /&gt;
*vfp&lt;br /&gt;
&lt;br /&gt;
== Enrolment and unenrolment ==&lt;br /&gt;
&lt;br /&gt;
External database enrolment happens at the moment when a user logs into Moodle. The plugin will attempt to automatically enrol the student in all their courses according to the data in the external database and, optionally, create empty courses where they do not already exist. To check if it is working, you can log in as a student and then check that their list of courses is as you would expect. &lt;br /&gt;
&lt;br /&gt;
The process also unenrols users from courses if they are no longer in the database. User records are marked according to their original enrolment method. Therefore the external database plugin can only unenrol users who were enroled by the plugin in the first place.&lt;br /&gt;
&lt;br /&gt;
== Hidden courses ==&lt;br /&gt;
&lt;br /&gt;
Courses that are set to &amp;quot;Course is not available to students&amp;quot; can be ignored for enrolment purposes by setting the &amp;quot;enrol_db_ignorehiddencourse&amp;quot; to &#039;&#039;&#039;yes&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Enrolment and roles ==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;enrol_database | defaultrole&amp;quot; setting in the plugin settings page specifies the role that the user will take when they are added to the course. The default setting will set them to the course default setting (initially &amp;quot;student&amp;quot;). However, you can specify a field in the external table (specified in the &amp;quot;enrol_database | remoterolefield&amp;quot; setting) that contains the short name or id for the user&#039;s role. This could, for example, be used to enrol both students and teachers into courses using a suitably configured database.&lt;br /&gt;
&lt;br /&gt;
== Unenrolment ==&lt;br /&gt;
&lt;br /&gt;
The  External unenrol action (&amp;quot;enrol_database | unenrolaction&amp;quot;) setting in the plugin settings page defines what action should be taken when a user enrolment disappears from external enrolment source. Each setting does the following:&lt;br /&gt;
#&#039;&#039;&#039;&amp;quot;Unenrol user from course&amp;quot;&#039;&#039;&#039; When the user disappears from the external source, the enrolment is completely removed and all the roles removed. This means some user data and settings are purged from course during course unenrolment (that usually include grades, activity attempts, etc.)&lt;br /&gt;
#&#039;&#039;&#039;&amp;quot;Keep user enrolled&amp;quot;&#039;&#039;&#039; When the user disappears from the external source, the enrolment is kept as is, and the user is still able to enter the course and perform activities, access resources, etc. It&#039;s a &amp;quot;do nothing&amp;quot; option.&lt;br /&gt;
#&#039;&#039;&#039;&amp;quot;Disable course enrolment&amp;quot;&#039;&#039;&#039; When the user disappears from the external source, user enrolment is suspended (the user can&#039;t access the course, but user data and settings are kept), and roles are kept as is. You might use this because in some cases the user needs a role with some capability to be visible in UI - such has in gradebook, assignments, etc.&lt;br /&gt;
#&#039;&#039;&#039;&amp;quot;Disable course enrolment and remove roles&amp;quot;&#039;&#039;&#039; When the user disappears from the external source, the enrolment is suspended and roles assigned by enrol instance are removed. Please note that user may &amp;quot;disappear&amp;quot; from gradebook and other areas.&lt;br /&gt;
&lt;br /&gt;
== Creating courses ==&lt;br /&gt;
&lt;br /&gt;
Optionally courses that do not exist in the Moodle site can be created. Switch the &amp;quot;enrol_db_autocreate&amp;quot; option to &amp;quot;yes&amp;quot; in the plugin settings. &lt;br /&gt;
&lt;br /&gt;
You can additionally specify the Category into which the new course will be placed, in the &#039;&#039;&#039;New course category id field&#039;&#039;&#039;. The data in this field must be the id of a currently existing category; it will not create a new category. The id number is number assigned by Moodle in the database when the category is created (e.g. mdl_course_categories.id). &lt;br /&gt;
&lt;br /&gt;
* Do not confuse this &#039;&#039;category id&#039;&#039; with the new custom &#039;&#039;category id number&#039;&#039; field that you can manually assign to a category. (See Trackers http://tracker.moodle.org/browse/MDL-28518 and http://tracker.moodle.org/browse/MDL-31845). &lt;br /&gt;
* Leaving the category id data empty means that a course will be assigned to the default category.&lt;br /&gt;
* If you assign data to categories that do  not exist already in Moodle, the courses will not be created.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default new course category&#039;&#039;&#039; is the category to which courses will be assigned and created in, unless you set up and so indicate in the data field of the &amp;quot;New course category id field.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You may also specify a &#039;&#039;&#039;New course template&#039;&#039;&#039;: a &amp;quot;template&amp;quot; course from which the new course will be copied. The data for this field should be the &#039;&#039;shortname&#039;&#039; of the template course.&lt;br /&gt;
&lt;br /&gt;
== Synchronization script ==&lt;br /&gt;
&lt;br /&gt;
A script is provided that can synchronize all your user enrollments at once - both adding and removing user enrolments (and creating courses if specified). The script is called sync.php and is found in the enrol/database/cli folder.&lt;br /&gt;
&lt;br /&gt;
This script is meant to be called from a system cronjob to sync moodle enrolments with enrolments in the external database. You need to make sure all the users present in the external enrolments are already created in moodle. If you are using external authentication plugins (db, ldap, etc.) you can use the scripts provided by those plugins to synchronize your users before running this script.&lt;br /&gt;
&lt;br /&gt;
Example cron entry&lt;br /&gt;
    # 5 minutes past 4am&lt;br /&gt;
    5 4 * * * /usr/bin/php -c /path/to/php.ini /path/to/moodle/enrol/database/cli/sync.php&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* If you have a large number of enrolments, you may want to raise the memory limits by passing -d memory_limit=256M&lt;br /&gt;
* For debugging &amp;amp; better logging, you are encouraged to use in the command line: -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0&lt;br /&gt;
* This only works for users that already exist in your Moodle site (see comment above)&lt;br /&gt;
&lt;br /&gt;
== Setting up enrolment sync (How to) ==&lt;br /&gt;
&lt;br /&gt;
You will need to perform (as a minimum) the following steps to enable external database enrolment - only a single table is required in the database which contains a record for every user/course combination. If the table is large it is a good idea to make sure appropriate indexes have been created:&lt;br /&gt;
&lt;br /&gt;
* Use an existing database or create a new one. Use an existing table or create a new one with the following minimum fields.&lt;br /&gt;
*# A unique course identifier to match one of the following fields.&lt;br /&gt;
*#* the &amp;quot;idnumber&amp;quot; field in Moodle&#039;s course table (varchar 100), which is manually specified as the &amp;quot;Course ID number&amp;quot; when editing a course&#039;s settings&lt;br /&gt;
*#* the &amp;quot;shortname&amp;quot; field in Moodle&#039;s course table (varchar 255), which is manually specified as the &amp;quot;Course short name&amp;quot; when editing a course&#039;s settings&lt;br /&gt;
*#* the &amp;quot;id&amp;quot; field in Moodle&#039;s course table (int 10), which is based on course creation order&lt;br /&gt;
*# A unique user identifier to match one of the following fields.&lt;br /&gt;
*#* the &amp;quot;idnumber&amp;quot; field in Moodle&#039;s user table (varchar 255), which is manually specified as the &amp;quot;ID number&amp;quot; when editing a user&#039;s profile&lt;br /&gt;
*#* the &amp;quot;username&amp;quot; field in Moodle&#039;s user table (varchar 100), which is manually specified as the &amp;quot;Username&amp;quot; when editing a user&#039;s profile&lt;br /&gt;
*#* the &amp;quot;email&amp;quot; field in Moodle&#039;s user table (varchar 100), which is manually specified as the &amp;quot;Email address&amp;quot; when editing a user&#039;s profile&lt;br /&gt;
*#* the &amp;quot;id&amp;quot; field in Moodle&#039;s user table (int 10), which is based on user creation order&lt;br /&gt;
*# (optional) A unique role identifier to match one of the following fields.&lt;br /&gt;
*#* the &amp;quot;shortname&amp;quot; field in Moodle&#039;s role table (varchar 100), for example editingteacher, coursecreator, student, ...&lt;br /&gt;
*#* the &amp;quot;name&amp;quot; field in Moodle&#039;s role table (varchar 255), for example Teacher, Course creator, Student, ...&lt;br /&gt;
*#* the &amp;quot;id&amp;quot; field in Moodle&#039;s role table (int 10), which is based on initial installation and new role creation order&lt;br /&gt;
* Populate the database table. Each user/course combination to have a record in the table.&lt;br /&gt;
* In Moodle, go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039;, find External Database in the list, enable it (click the closed-eye icon) and click Settings.&lt;br /&gt;
* In the top panel, select the database type (make sure you have the necessary configuration in PHP for that type) and then supply the information to connect to the database.&lt;br /&gt;
* The middle panel creates the mapping between Moodle and the external database. The first three settings are for the local (Moodle) field names and the last three for the remote (external database) settings. They are in the same order.&lt;br /&gt;
** enrol_localcoursefield / enrol_remotecoursefield - in Moodle the name of the field in the course settings the uniquely identifies the course (e.g., idnumber). In the external database the name of the matching field.&lt;br /&gt;
** enrol_localuserfield / enrol_remoteuserfield - in Moodle the name of the field in the user profile that uniquely identified the user (e.g., idnumber). In the external database the name of the matching field.&lt;br /&gt;
** enrol_db_localrolefield / enrol_db_remoterolefield - (optional) in Moodle the name of the field in the role edit page the uniquely identifies the role (e.g., shortname). In the external database the name of the matching field.&lt;br /&gt;
* The Roles panel specifies the role that the user will get in the course if their role is not specified in the external database.&lt;br /&gt;
* A new optional field enrol_database | remoteotheruserfield allows those with the role &amp;quot;Other users&amp;quot; to be added but not to be included as course participants.&lt;br /&gt;
* The final panel enables auto creation of courses.&lt;br /&gt;
* Save changes, and then tick the box to enable external database enrolment.&lt;br /&gt;
&lt;br /&gt;
== Field Mapping Example: ==&lt;br /&gt;
Choose your fields from the Moodle database:&lt;br /&gt;
&lt;br /&gt;
*enrol_localcoursefield:  A course identifier from mdl_course, e.g. &amp;quot;idnumber&amp;quot;&lt;br /&gt;
*enrol_localuserfield: A user identifier from mdl_user, e.g. &amp;quot;idnumber&amp;quot;&lt;br /&gt;
*enrol_localrolefield: (optional) A role identifier from mdl_role, e.g. &amp;quot;shortname&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Create a view in your external database which matches the chosen field values from Moodle:&lt;br /&gt;
&lt;br /&gt;
*enrol_remotecoursefield: A matching course identifier from your external database table, e.g. &amp;quot;course_number&amp;quot;&lt;br /&gt;
*enrol_remoteuserfield: A matching user identifier from your external database table, e.g. &amp;quot;userid&amp;quot;&lt;br /&gt;
*enrol_remoterolefield: (optional) A matching role identifier from your external database table, e.g. &amp;quot;role_name&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Potential gotchas ==&lt;br /&gt;
&lt;br /&gt;
* It almost goes without saying that the integrity of the external database is important. If data is missing from the database then there is a potential for users being unenrolled from some or all of their courses. The unenrollment process will remove them from any group assignments and also poll each module type to give the module the option of removing that user&#039;s data if appropriate (for example, however, forum posts are never deleted). It is therefore prudent that you take the utmost care to ensure that the data in the external database is correct at all times.&lt;br /&gt;
* &#039;&#039;&#039;Minor Security Issue&#039;&#039;&#039; Consider that if the ID number field you use to identify your students is editable by the students (in their profile), then there is a potential for them changing this to the id of another valid student and gaining access to resources that they should not. (However, they will still appear as themselves, they cannot impersonate the other user or otherwise gain access to their resources.) To prevent this and similar issues, you can lock the ID number as well as other fields so the user can not change them. Do this in the &#039;&#039;&#039;Data mapping&#039;&#039;&#039; section of &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; External database&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Errors and diagnostics==&lt;br /&gt;
&lt;br /&gt;
The plugin produces a number of diagnostic messages and/or errors which are recorded to the PHP error log (as defined in the php.ini file). In addition messages about courses that are in the database for the user but that do not exist in the Moodle site will only be produced if debugging is set to ALL or DEVELOPER.&lt;br /&gt;
&lt;br /&gt;
You can get detailed progress information by executing the sync script  with -v parameter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 php /path/to/moodle/enrol/database/cli/sync.php -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=49475 MySQL enrolment plugin doesn&#039;t seem to work] forum discussion&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=74133 Someone explain external database enrolment, please??] forum discussion&lt;br /&gt;
*Example Setup [https://docs.moodle.org/en/Talk:External_database_enrolment#Example_External_Enrollment] Example Database Enrollment Setup&lt;br /&gt;
*[[External database authentication]]&lt;br /&gt;
&lt;br /&gt;
[[es:Inscripción por BasedeDatos externa]]&lt;br /&gt;
[[fr:Inscription par base de données externe]]&lt;br /&gt;
[[de:Einschreibung über externe Datenbank]]&lt;br /&gt;
[[ja:外部データベース登録]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Assign_roles&amp;diff=122222</id>
		<title>Assign roles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Assign_roles&amp;diff=122222"/>
		<updated>2016-02-10T09:13:53Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
==Context and roles==&lt;br /&gt;
&lt;br /&gt;
*In Moodle,  apart from the site administrator, users do not normally have a global, site-wide role. In other words, even though you may be a tutor offline, when you are in Moodle you could have a tutor role in the course you teach in but a student role in another course where you are studying for a diploma. There are a few exceptions but this is generally the case.&lt;br /&gt;
*Because of the way Moodle works,assigning roles is done for a particular context. A site and course are examples of two different contexts. When you create a new role or tweak a pre-existing role via &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;, you are asked in which context(s) you want the role to be assigned:&lt;br /&gt;
[[File:rolecontexttypes.png]]&lt;br /&gt;
&lt;br /&gt;
*Here are some examples of contexts; how to get to the assign roles screen, and when/why you would assign roles here:&lt;br /&gt;
&lt;br /&gt;
===System context===&lt;br /&gt;
*&#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Assign system roles&#039;&#039;&lt;br /&gt;
*Any roles assigned here apply to the whole Moodle site. It makes sense therefore that only roles that need this functionality can be assigned here. The [[Manager]] role and [[Course creator]] role are examples of two such roles. Assigning a teacher or student here would result in their being able to teach/study in every single course on the site, which is not usually desirable. &lt;br /&gt;
*If you really feel your Moodle needs to have teachers or students assigned in the system context, go to the teacher/student role in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039; and check the &amp;quot;system&amp;quot; box. Then search for and allow the capability [[Capabilities/moodle/course:view|moodle/course:view]]&lt;br /&gt;
&lt;br /&gt;
=====Assigning system roles by CSV=====&lt;br /&gt;
&lt;br /&gt;
Where certain custom roles are applied in the system context, it is possible to upload users to that role in bulk by adding the field &#039;&#039;sysrole1&#039;&#039; (etc) to a CSV file.&lt;br /&gt;
&lt;br /&gt;
[[File:GlobalRoles1.png|thumb|500px|center|sysrole column]]&lt;br /&gt;
&lt;br /&gt;
When previewed, there is a column indicating their system role:&lt;br /&gt;
&lt;br /&gt;
[[File:GlobalRoles2.png|thumb|center|500px|Preview screen]]&lt;br /&gt;
&lt;br /&gt;
Once uploaded, the users are present on the &#039;Assign system roles&#039; screen:&lt;br /&gt;
&lt;br /&gt;
[[File:GlobalRoles3.png|thumb|center|500px|Assign system roles screen]]&lt;br /&gt;
&lt;br /&gt;
See [[Upload users]] for information on adding users to roles via CSV.&lt;br /&gt;
&lt;br /&gt;
===Front page context===&lt;br /&gt;
*&#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Front Page&amp;gt;Users&amp;gt;Permissions&amp;gt;Assigned roles&lt;br /&gt;
*Those with a role in the system context do not need to be assigned a role here as well.&lt;br /&gt;
*However you might want to allow a teacher to manage items on the front page; in this instance, you would assign them the role on the Front page.&lt;br /&gt;
&lt;br /&gt;
===Course Category context===&lt;br /&gt;
*See [[Category enrolments]]&lt;br /&gt;
*Users may be enrolled in the category to save enrolling them in each individual course in that category.&lt;br /&gt;
&lt;br /&gt;
===Course context===&lt;br /&gt;
[[File:enrolusers.png|thumb|Enrol users]]&lt;br /&gt;
* Go to &#039;&#039;Administration &amp;gt; Course administration &amp;gt; Enrolled users&#039;&#039;&lt;br /&gt;
* Click the &amp;quot;Enrol users&amp;quot; button and click those users you wish to enrol&lt;br /&gt;
&lt;br /&gt;
The dropdown menu at the top shows roles for which you are allowed to enrol; typically those users with lower roles than you. See [[Enrolled users]] for more details.&lt;br /&gt;
&lt;br /&gt;
===Block context===&lt;br /&gt;
*(Within the block) &#039;&#039;Administration &amp;gt; Assign roles&#039;&#039;&lt;br /&gt;
*You may wish to assign roles to a block if, for instance you want specific people to see the block but for it to be hidden from others&lt;br /&gt;
&lt;br /&gt;
=== Activity Module context===&lt;br /&gt;
*(Within the activity settings) &#039;&#039;Administration &amp;gt; Locally assigned roles&#039;&#039;&lt;br /&gt;
*An example of this is assigning a student the teacher role locally in an individual activity like a forum so they can moderate their classmates&#039; posts while still retaining the student role in the rest of the course.&lt;br /&gt;
&lt;br /&gt;
===User context===&lt;br /&gt;
*The most common use of this is for the Parent role. &lt;br /&gt;
*When the Parent role is created via&#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039; the &amp;quot;user&amp;quot; context box is checked.&lt;br /&gt;
*To assign a parent the role in the context of their child (so they can see their child&#039;s grades etc) click the child&#039;s profile and then go to &#039;&#039;Administration&amp;gt;Roles&amp;gt;Assign roles relative to this user&#039;&#039;&lt;br /&gt;
*See [[Parent role]] for more information.&lt;br /&gt;
&lt;br /&gt;
The assign roles page lists the names of users assigned to each role (unless there are more than 10 users, in which case this is stated).&lt;br /&gt;
&lt;br /&gt;
==Hierarchy==&lt;br /&gt;
&lt;br /&gt;
By assigning a role to a user in a certain context, you grant them the permissions contained in that role for the current context and all lower contexts.&lt;br /&gt;
&lt;br /&gt;
The list of contexts in hierarchical order is as follows:&lt;br /&gt;
&lt;br /&gt;
*System (no parent)&lt;br /&gt;
*Front page (parent = system) - &lt;br /&gt;
*Course category (parent = parent category or system)&lt;br /&gt;
*Course (parent = category or system)&lt;br /&gt;
*Module (parent = course or system) &lt;br /&gt;
*Block (parent = course or system)&lt;br /&gt;
*User (parent = system)&lt;br /&gt;
&lt;br /&gt;
Roles can be inherited.  For example if a user is assigned a Teacher role in a specific course category then the user will have this role in ALL courses within the category. Tip: use the override feature in a specific context for exceptions.&lt;br /&gt;
&lt;br /&gt;
Roles will only work if the role assignment is made in the correct context. Some examples: a Teacher role should be assigned to a user in the course or course category context, a Forum moderator for a particular forum should be assigned in that specific forum.&lt;br /&gt;
&lt;br /&gt;
==Assigning someone the role of Site administrator==&lt;br /&gt;
&lt;br /&gt;
*Site administrators are assigned via a special page: &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Site Administrators&#039;&#039;. Select the name from the right and move it over to the left:&lt;br /&gt;
[[File:managesiteadmins.png]]&lt;br /&gt;
*The original (primary) administrator cannot be deleted.&lt;br /&gt;
&lt;br /&gt;
==Checking a user&#039;s role assignments==&lt;br /&gt;
&lt;br /&gt;
A user&#039;s role assignments can be checked by going to their profile page then in the administration block under the profile settings for the user, clicking &#039;This user&#039;s role assignments&#039;.&lt;br /&gt;
&lt;br /&gt;
==Hidden roles==&lt;br /&gt;
&lt;br /&gt;
If you want to provide users with access to the course, but don&#039;t want them to be visible in the participants list, use the [[Other users]] link in the course administration menu (&#039;&#039;Administration &amp;gt; Course Administration &amp;gt; Users &amp;gt; Other Users&#039;&#039;). Assigning roles here provides course access, and editing rights according to the permissions set for the role assigned without actually enrolling the user in the course. This is similar to the functionality of the &amp;quot;hidden user&amp;quot; check box in previous versions of Moodle.&lt;br /&gt;
&lt;br /&gt;
Note: By default, the only role which can be assigned to other users is the manager role. To enable other roles, such as teacher to be assigned, the capability [[Capabilities/moodle/course:view|moodle/course:view]] should be allowed for the role (see below).&lt;br /&gt;
&lt;br /&gt;
==Enabling teachers to assign the role of teacher==&lt;br /&gt;
&lt;br /&gt;
By default, teachers are only allowed to assign the roles of non-editing teacher, student and guest. To enable teachers to assign the role of teacher:&lt;br /&gt;
&lt;br /&gt;
#Access &#039;&#039;Site Administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Click the tab &amp;quot;Allow role assignments&amp;quot;.&lt;br /&gt;
#Click the checkbox where the teacher row and column intersect.&lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
==Beware of assignments that don&#039;t make sense==&lt;br /&gt;
&lt;br /&gt;
There are many role assignments that do not make sense as the underlying functionality does not exist. Just because you give someone the &amp;quot;right&amp;quot; to do something does not guarantee that the interface or facility actually exists within the context that you have assigned that right. For example, you can assign a user the right to create new categories in the category context. However there is no interface within Moodle to do that (category creation is only available at the system level).&lt;br /&gt;
&lt;br /&gt;
==Multiple assignments==&lt;br /&gt;
&lt;br /&gt;
A significant part of the roles infrastructure is the ability to assign a user into multiple roles (at the same time). The capabilities of each role are merged to produce the effective set of capabilities. For example, a user could be  both a Teacher and Student in the same course. You should be careful to ensure that if you change a user&#039;s role that you remove them from any other roles as required as this will no longer be done automatically.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Creating custom roles]]&lt;br /&gt;
*[[Enrolment]]&lt;br /&gt;
*[[Managing roles]] - for administrators&lt;br /&gt;
*[[Useful things a teacher can do with roles]]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=59900 Discrepancies between Assign Roles lists and Participants list]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=66782 What happens if a user has multiple roles in a course?]&lt;br /&gt;
&lt;br /&gt;
[[Category:Roles]]&lt;br /&gt;
&lt;br /&gt;
[[de:Rollen zuweisen]]&lt;br /&gt;
[[es:Asignar_roles]]&lt;br /&gt;
[[eu:Rolak_esleitu]]&lt;br /&gt;
[[fr:Attribution des rôles]]&lt;br /&gt;
[[ja:ロールの割り当て]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=External_database_authentication&amp;diff=122221</id>
		<title>External database authentication</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=External_database_authentication&amp;diff=122221"/>
		<updated>2016-02-10T08:41:02Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Authentication}}&lt;br /&gt;
Location: &#039;&#039; Site administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; External database&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This method uses an external database table to check whether a given username and password is valid. If the user does not currently exist in Moodle a new account will be created and their information copied from the external database. &lt;br /&gt;
&lt;br /&gt;
== Field mappings ==&lt;br /&gt;
&lt;br /&gt;
This is done by mapping fields at the bottom of the database authentication page. Each data field in the user profile has a text field next to it. Enter the name of the column in the external database that maps to the profile data field.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Update Local&#039;&#039;&#039; - Specifies that the external data will be entered into the local field in question&lt;br /&gt;
* On Creation - specifies that this will only happen on the original login when the account is created for the first time.&lt;br /&gt;
* On Every Login - specifies that changes in the external data will be updated on the local Moodle field in question the next time the user logs in again.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Update External&#039;&#039;&#039; - Specifies just the opposite, meaning changes in the local Moodle field in question will update the corresponding field in the external database&lt;br /&gt;
* Never - Specifies this is disabled&lt;br /&gt;
* On Update - Enables this to happen if a change is made locally (additional configuration is probably required)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Lock Value&#039;&#039;&#039; - Only determines whether the local user can make a change in the Moodle field and does not affect the two settings above.&lt;br /&gt;
* Unlocked - A user can make changes locally in the Moodle field (assumably even if it contradicts the external database the next login would change it again if Update Local is set&lt;br /&gt;
* Locked - A user can never make changes&lt;br /&gt;
* Unlocked if empty - A user can only make changes if the field is not populated already from the external database (this would seem to indicate a user could only enter something into this field once and could not change it after saving)&lt;br /&gt;
&lt;br /&gt;
== Automatic Synchronisation ==&lt;br /&gt;
&lt;br /&gt;
The above method adds new users only when they log in. If you want user accounts to be created in Moodle independent of actual logins, the db authentication plugin offers a script you can run regularly via &#039;cron&#039;. A typical cron entry will be as follows...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
0 * * * *    /usr/bin/php /path/to/moodle/auth/db/cli/sync_users.php &amp;gt;dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This runs every hour (adjust as required). It reads the entire table updating and creating local Moodle users. &lt;br /&gt;
&lt;br /&gt;
If you have custom profile fields on your site, these can be synced with External database authentication.&lt;br /&gt;
&lt;br /&gt;
==Additional Notes==&lt;br /&gt;
&lt;br /&gt;
It is now possible to  use Salted Crypt passwords for the password format with external database authentication from the Password format setting:&lt;br /&gt;
[[File:dbsaltedcrypt.png|thumb|300px|center]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Plain text password matching is now always case sensitive&lt;br /&gt;
* sha1/md5 hash comparisons are now enforced case insensitive (as underlying they are hexadecimal values)&lt;br /&gt;
&lt;br /&gt;
* Some of the things that apply to [[Upload users]] apply to the External database, but not all of the fields in the [[Upload users]] are available for the External Database authentication. The only available fields are the fields listed in the data mapping section of the admin page for the External Database connection.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=45444 Special and characters con tilde (accute accent) when connected to external database] forum discussion&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=75519 HELP!--User Authentication problem] forum discussion&lt;br /&gt;
*[[External database enrolment]]&lt;br /&gt;
*change password in external DB authentication plugin  [https://moodle.org/mod/forum/discuss.php?d=269311#p1162046] &lt;br /&gt;
&lt;br /&gt;
[[de:Externe Datenbank]]&lt;br /&gt;
[[fr:Authentification par base de données externe]]&lt;br /&gt;
[[ja:外部データベース認証]]&lt;br /&gt;
[[es:Autenticación con BasedeDatos externa]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=MoodleDocs:Guidelines_for_contributors&amp;diff=122212</id>
		<title>MoodleDocs:Guidelines for contributors</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=MoodleDocs:Guidelines_for_contributors&amp;diff=122212"/>
		<updated>2016-02-09T09:06:02Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Help}}You are welcome to contribute to Moodle Docs. Find something that can be improved, either in content, grammar or formatting, and fix it! Note: You will need to [[Special:Userlogin|login]] to edit pages.&lt;br /&gt;
&lt;br /&gt;
==Introduction==&lt;br /&gt;
&lt;br /&gt;
* Please note that all contributions are released here under [[License|GNU General Public License]].&lt;br /&gt;
* Every page in Moodle has a link to a corresponding page in Moodle Docs. You can see this on [http://moodle.org moodle.org] and, from an administrator&#039;s perspective, on the [http://demo.moodle.net/ Moodle demo site].&lt;br /&gt;
* You are encouraged to illustrate documentation with screenshots. Please refer to the [[MoodleDocs:Style guide|style guide]] for further information.&lt;br /&gt;
* See [[MoodleDocs:Templates]] for ways of asking for editing help from other contributors.&lt;br /&gt;
&lt;br /&gt;
==Creating new pages==&lt;br /&gt;
&lt;br /&gt;
* You are welcome to create pages for additional documentation about Moodle. Simply type the name of your new page between double brackets &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[New page name]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; on an existing page and follow the link to start editing the new page. Alternatively, you may type in your browser address bar: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;https://docs.moodle.org/en/New_page_name&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; (i.e. replace spaces in the new page name with underscores).&lt;br /&gt;
* Please choose a short name and capitalize the first word only (with a few exceptions, such as the word &#039;&#039;Moodle&#039;&#039;).&lt;br /&gt;
* Please follow the [[MoodleDocs:Style guide|style guide]]. If you categorize new pages it can make it easier for users to find, but the important thing is to put good content into the page. &lt;br /&gt;
* Page titles may be changed in the future by redirecting/moving pages, as part of documentation restructuring.&lt;br /&gt;
&lt;br /&gt;
==Inter-language linking==&lt;br /&gt;
&lt;br /&gt;
* Inter-language links between pages in different languages may be added by typing, for example, &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[es:Corresponding page title in Spanish]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; in the English MoodleDocs, or &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[en:Corresponding page title in English]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; in the [[:es:Portada|Spanish MoodleDocs]], at the bottom of the page, below the category link. Inter-language links will appear automatically in the &amp;quot;In other languages&amp;quot; block.&lt;br /&gt;
&lt;br /&gt;
== Page comments ==&lt;br /&gt;
&lt;br /&gt;
* For comments about a particular page, and/or short discussions, please use the corresponding talk page (click on the page comments tab). Please sign and date your talk page contribution by typing four tildes &amp;lt;nowiki&amp;gt;~~~~&amp;lt;/nowiki&amp;gt;. There&#039;s also a handy button for signing in the toolbar of the editing field: [[Image:Signature Icon.png]]&lt;br /&gt;
&lt;br /&gt;
* For longer discussions about the documentation, please post on moodle.org in the [http://moodle.org/mod/forum/view.php?id=7135 Moodle community sites forum].&lt;br /&gt;
&lt;br /&gt;
* If you find an unsigned comment you can use the Template:Unsigned like so &amp;lt;nowiki&amp;gt;{{Unsigned|Username}}&amp;lt;/nowiki&amp;gt; which will show as &amp;lt;small&amp;gt;(&#039;&#039;The preceding comment was added by&#039;&#039; [[User:Username]])&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Page protection==&lt;br /&gt;
&lt;br /&gt;
* Certain pages, such as the [[Table of Contents]], are protected from editing. Please use the page comments for suggesting additional content or other changes. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Moodle documentation FAQ]]&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=7135 Moodle community sites forum].&lt;br /&gt;
&lt;br /&gt;
[[Category:MoodleDocs|Guidelines for contributors]]&lt;br /&gt;
&lt;br /&gt;
[[ca:MoodleDocs:Recomanacions_als_ajudants]]&lt;br /&gt;
[[de:Hinweise für Moodle Docs Autoren]]&lt;br /&gt;
[[es:MoodleDocs:Normas para colaboradores]]&lt;br /&gt;
[[fr:Contribution à la documentation]]&lt;br /&gt;
[[ja:MoodleDocs:寄稿のガイドライン]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Talk:Logging&amp;diff=118611</id>
		<title>Talk:Logging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Talk:Logging&amp;diff=118611"/>
		<updated>2015-05-21T08:11:59Z</updated>

		<summary type="html">&lt;p&gt;Fox: Thanks Marina&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article says: &amp;quot;A new Moodle site will have Standard logging enabled and Legacy logging disabled. A site which has been upgraded will have both enabled.&amp;quot; &lt;br /&gt;
But is it ok to disable the legacy log on a site which has been upgraded and only use the new standard log? Does Moodle store anything in the legacy log that is not stored in the standard log - especially on a site which has been upgraded? An explanation of this would be useful, especially if disabling the legacy logs will cause some information that is/was logged to the legacy logs to no longer be logged.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 15:52, 20 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
: For what i know, you can disable legacy logs. But if you do so : you won&#039;t be able to look/show/display (existing) legacy logs, and no new legacy logs will be generated. It can be a problem for non standard plugins not well upgraded, still generating legacy logs, but not standard logs. With time, more plugins are upgraded...&lt;br /&gt;
:--[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 19:58, 20 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
Thanks  Séverin - I have added your comments to the page. --[[User:Mary Cooch|Mary Cooch]] ([[User talk:Mary Cooch|talk]]) 22:25, 20 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
: You can disable legacy store plugin completely OR you can only disable writing to legacy log inside the plugin settings. In the second case you will be able to read from the log but no new entries will be added. This is also what will be set automatically during upgrade. [https://docs.moodle.org/27/en/Upgrading#Possible_issues_that_may_affect_you_in_Moodle_2.7 More details]&lt;br /&gt;
: --[[User:Marina Glancy|Marina Glancy]] ([[User talk:Marina Glancy|talk]]) 08:15, 21 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
:: Thanks Marina for your detailed information. If i remember well (but i can be wrong), when i upgraded to 2.7(.1 ?), legacy log where automatically disabled, so not visible. Suppose it has been improved since then.&lt;br /&gt;
::--[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 16:11, 21 May 2015 (AWST)&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Talk:Logging&amp;diff=118602</id>
		<title>Talk:Logging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Talk:Logging&amp;diff=118602"/>
		<updated>2015-05-20T11:58:38Z</updated>

		<summary type="html">&lt;p&gt;Fox: My answer&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This article says: &amp;quot;A new Moodle site will have Standard logging enabled and Legacy logging disabled. A site which has been upgraded will have both enabled.&amp;quot; &lt;br /&gt;
But is it ok to disable the legacy log on a site which has been upgraded and only use the new standard log? Does Moodle store anything in the legacy log that is not stored in the standard log - especially on a site which has been upgraded? An explanation of this would be useful, especially if disabling the legacy logs will cause some information that is/was logged to the legacy logs to no longer be logged.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 15:52, 20 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
: For what i know, you can disable legacy logs. But if you do so : you won&#039;t be able to look/show/display (existing) legacy logs, and no new legacy logs will be generated. It can be a problem for non standard plugins not well upgraded, still generating legacy logs, but not standard logs. With time, more plugins are upgraded...&lt;br /&gt;
:--[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 19:58, 20 May 2015 (AWST)&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=error/tool_uploadcourse/csvfileerror&amp;diff=117672</id>
		<title>error/tool uploadcourse/csvfileerror</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=error/tool_uploadcourse/csvfileerror&amp;diff=117672"/>
		<updated>2015-03-24T15:41:59Z</updated>

		<summary type="html">&lt;p&gt;Fox: Small correction&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This error message appears when a file is uploaded to &#039;&#039;Site administration&amp;gt;Courses&amp;gt;Upload courses&#039;&#039; and the file is either:&lt;br /&gt;
&lt;br /&gt;
*an incorrectly formatted .csv file, in which case, please check [[Upload courses]] &lt;br /&gt;
&lt;br /&gt;
or&lt;br /&gt;
&lt;br /&gt;
* a completely different file such as an .mbz or .tgz file (a Moodle course backup)&lt;br /&gt;
&lt;br /&gt;
{{Note|If you see this errror when uploading an .mbz or tgz file, you should be using [[Course restore]] instead. }}&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Offline_quiz_activity&amp;diff=117377</id>
		<title>Offline quiz activity</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Offline_quiz_activity&amp;diff=117377"/>
		<updated>2015-03-06T13:45:48Z</updated>

		<summary type="html">&lt;p&gt;Fox: Plugin link corrected&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
{{Infobox plugin&lt;br /&gt;
|type = activity&lt;br /&gt;
|entry = https://moodle.org/plugins/view/mod_offlinequiz&lt;br /&gt;
|tracker = https://github.com/academic-moodle-cooperation/moodle-mod_offlinequiz&lt;br /&gt;
|discussion = https://github.com/academic-moodle-cooperation/moodle-mod_offlinequiz&lt;br /&gt;
|maintainer = [[user:AMC Academic Moodle Cooperation|AMC Academic Moodle Cooperation]]&lt;br /&gt;
|float = right&lt;br /&gt;
}}&lt;br /&gt;
[[File:MC Offline quiz module thumbnail.png]]&lt;br /&gt;
The Moodle MC Offline quiz module adds paper-and-pencil multiple-choice quizzes to Moodle. In offline quizzes students mark answers to questions on a sheet of paper (the answer form). The students&#039; answer forms are evaluated and graded automatically by the offline quiz module. &lt;br /&gt;
&lt;br /&gt;
More precisely, a complete offline quiz consists (at least) of the following steps:&lt;br /&gt;
&lt;br /&gt;
* A teacher creates an offline quiz in Moodle and adds multiple-choice questions, all-or-nothing multiple-choice questions or description questions (text) to the quiz. This is very similar to creating online quizzes (standard Moodle quizzes).&lt;br /&gt;
* From the question lists the teacher creates question sheets and answer forms as PDF (DOCX) documents using the module. &lt;br /&gt;
* The question sheets and answer forms are handed out to students for the actual quiz. The students mark the answers they think are correct in the answer form.&lt;br /&gt;
* The teacher scans the filled-in answer forms and uploads the resulting images into the offline quiz. The scanned answer forms are evaluated and graded automatically by the module. &lt;br /&gt;
* If necessary, the teacher corrects errors that might have occurred due to mistakes made by the students or due to bad scan quality. &lt;br /&gt;
&lt;br /&gt;
After results have been created in an offline quiz, students can review their result as usual. If the teacher allows it, students can also see the scanned answer forms and which markings have been recognised as crosses.&lt;br /&gt;
&lt;br /&gt;
The module supports up to six groups which are not related to Moodle course groups. Each group can contain a different set of questions in a different order. Separate question sheets and answer forms are created for the different offline quiz groups.&lt;br /&gt;
&lt;br /&gt;
The module also supports lists of participants which are useful for checking which students actually took part in the exam. Lists of participants are pre-filled with students in Moodle. PDF versions of those lists can be created in the module for easy marking during the exam. The marked lists can be uploaded and evaluated automatically.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&lt;br /&gt;
The offline quiz module is used intensively at different Austrian universities for mass exams. Hundreds of students can be easily examined at the same time (given enough seating space in lecture halls) without the need for expensive e-testing equipment.&lt;br /&gt;
&lt;br /&gt;
==Author==&lt;br /&gt;
Juergen Zimmer, from the [http://www.academic-moodle-cooperation.org Academic Moodle Cooperation] of several Vienna Universities.&lt;br /&gt;
&lt;br /&gt;
==Moodle versions==&lt;br /&gt;
This module is available from [https://moodle.org/plugins/view.php?plugin=mod_offlinequiz the Moodle plugins database] for Moodle 2.6 only.&lt;br /&gt;
&lt;br /&gt;
There seems to be a version for Moodle 2.5 in [https://github.com/academic-moodle-cooperation/moodle-mod_offlinequiz/tree/MOODLE_25_STABLE Github].&lt;br /&gt;
&lt;br /&gt;
There seems to be a version for Moodle 2.2 in [https://github.com/academic-moodle-cooperation/moodle-mod_offlinequiz/blob/5dbf36388eea93f09c3bedfb06dcc77b9e993f8e/README.txt Github].&lt;br /&gt;
&lt;br /&gt;
There will probably be a stable version for Moodle 2.7 by the end of 2014. &lt;br /&gt;
&lt;br /&gt;
==Translations available==&lt;br /&gt;
The Moodle 2.6 version has Mexican Spanish and German language translations made in [https://lang.moodle.org/local/amos/ AMOS].&lt;br /&gt;
&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
Copy the module code directly to the &amp;quot;mod/offlinequiz&amp;quot; directory. Open the messages page in the administration area to automatically start the installation.&lt;br /&gt;
&lt;br /&gt;
The automatic analysis of questionnaires requires the activation of an appropriate cronjob (see README.txt).&lt;br /&gt;
&lt;br /&gt;
==Admin settings==&lt;br /&gt;
&lt;br /&gt;
As an administrator you can set the default values instance-wide on the settings page for administrators in the MC Offline quiz module.&lt;br /&gt;
&lt;br /&gt;
* formula for participant identification (text field)&lt;br /&gt;
* mix questions (checkbox)&lt;br /&gt;
* mix answers (checkbox)&lt;br /&gt;
* logo URL (text field)&lt;br /&gt;
* copyright indication (checkbox)&lt;br /&gt;
* settings for exam inspection (checkbox)&lt;br /&gt;
* decimal places (drop down)&lt;br /&gt;
* paper&#039;s white level (drop down)&lt;br /&gt;
* 1-click inscription (checkbox)&lt;br /&gt;
* role for inscription (drop down)&lt;br /&gt;
* saving days (text field)&lt;br /&gt;
&lt;br /&gt;
==Screenshot of the module==&lt;br /&gt;
[[File:Offline_quiz_screenshot.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Author==&lt;br /&gt;
[https://moodle.org/user/profile.php?id=1765078|  AMC Academic Moodle Cooperation] &lt;br /&gt;
&lt;br /&gt;
This information was copied from http://www.academic-moodle-cooperation.org/en/modules/offline-quiz/ &lt;br /&gt;
&lt;br /&gt;
[[Category:Quiz]]&lt;br /&gt;
[[Category:Questions]]&lt;br /&gt;
&lt;br /&gt;
[[es:mod/offlinequiz/mod]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Talk:ad-hoc_contributed_reports&amp;diff=116241</id>
		<title>Talk:ad-hoc contributed reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Talk:ad-hoc_contributed_reports&amp;diff=116241"/>
		<updated>2014-12-04T13:58:01Z</updated>

		<summary type="html">&lt;p&gt;Fox: Thanks Mary, and reflexion&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Could someone apply my latest changes on 2.7 and 2.6 versions? --[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 17:50, 3 December 2014 (AWST)&lt;br /&gt;
&lt;br /&gt;
==Reply to Séverin==&lt;br /&gt;
I have copied your changes to 2.7 and 2.6 (I think I have got the right bits; let me know if not) However, just to point out that as a rule we only update the latest version and the one before that -- - so normally it would just be 2.8 and 2.7 - but I did 2.6 anyway :) --[[User:Mary Cooch|Mary Cooch]] ([[User talk:Mary Cooch|talk]]) 17:55, 3 December 2014 (AWST)&lt;br /&gt;
&lt;br /&gt;
:Thanks Mary. There was also another change : a new query. I&#039;ve just put it myself in 2.7 and 2.6. I know the general rule, but i feel it&#039;s a problem, because it means that we sometimes let incorrect information, and people can come to some documentation pages in a specific version from a Moodle internal documentation link, a Google search... And they don&#039;t always have the reflex to look at the pages for the most recent version. In fact, if i was using 2.5, i really won&#039;t look for 2.8 version ! --[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 21:58, 4 December 2014 (AWST)&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Debugging&amp;diff=116240</id>
		<title>Debugging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Debugging&amp;diff=116240"/>
		<updated>2014-12-04T09:03:20Z</updated>

		<summary type="html">&lt;p&gt;Fox: Minor typo fixed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Developer tools}}&lt;br /&gt;
Debugging messages can be enabled by an administrator in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Development &amp;gt; Debugging&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Debugging messages are intended to help diagnose problems and/or help Moodle developers. If you have a problem with your Moodle site and ask for help in a Moodle.org forum, a developer may ask you to turn debug messages on, in order to locate the cause of the problem. By default Moodle does not show any error messages at all. If you are having problems (e.g. blank screens or incomplete screens) turning on debugging is usually the first thing to try. &lt;br /&gt;
&lt;br /&gt;
==Debugging settings==&lt;br /&gt;
Here are the settings on the Debugging page:&lt;br /&gt;
&lt;br /&gt;
===Debug messages===&lt;br /&gt;
The default is none, your choices are:&lt;br /&gt;
&lt;br /&gt;
;NONE : Do not show any errors or warnings (Default) &lt;br /&gt;
;ALL : Show all reasonable PHP debug messages&lt;br /&gt;
;MINIMAL : Show only fatal errors&lt;br /&gt;
;NORMAL : Show warnings, errors and notices&lt;br /&gt;
;DEVELOPER : extra Moodle debug messages for developers&lt;br /&gt;
&lt;br /&gt;
There is rarely any advantage in going to Developer level, unless you are a developer, in which case it is strongly recommended.&lt;br /&gt;
&lt;br /&gt;
Once you have got the error message, and copied and pasted it somewhere.  HIGHLY RECOMMENDED to turn Debug back to NONE. Debug messages can give clues to a hacker as to the setup of your site.&lt;br /&gt;
&lt;br /&gt;
===Display debug messages===&lt;br /&gt;
&lt;br /&gt;
There is an option to choose whether to display error messages or simply record them in the server logs.&lt;br /&gt;
&lt;br /&gt;
===Debug email sending===&lt;br /&gt;
&lt;br /&gt;
Determines whether or not to enable verbose debug information during sending of email messages to SMTP server.&lt;br /&gt;
&lt;br /&gt;
===Performance info===&lt;br /&gt;
&lt;br /&gt;
The Performance info option determines whether performance info will be included in the footer of the standard theme (and some other themes). Performance info includes the time for the page to load, the amount of memory used to generate the page, cpu usage, load, and the record cache hit/miss ration.&lt;br /&gt;
&lt;br /&gt;
If you add&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
define(&#039;MDL_PERF&#039;, true);&lt;br /&gt;
define(&#039;MDL_PERFDB&#039;, true);&lt;br /&gt;
define(&#039;MDL_PERFTOLOG&#039;, true);&lt;br /&gt;
define(&#039;MDL_PERFTOFOOT&#039;, true);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
to your config.php file, then it will also count database queries. (This has to be in config.php, because Moodle starts doing DB queries before it loads the config information in the database!&lt;br /&gt;
&lt;br /&gt;
===Show origin of language strings===&lt;br /&gt;
&lt;br /&gt;
Helps with [[:dev:Translation|translation]] and also with [[Language customization]]. Sometimes &amp;lt;code&amp;gt;?strings=1&amp;lt;/code&amp;gt; should be added; other times &amp;lt;code&amp;gt;&amp;amp;strings=1&amp;lt;/code&amp;gt;. See the Wikipedia article [http://en.wikipedia.org/wiki/Query_string Query string] for details.&lt;br /&gt;
&lt;br /&gt;
===Show validator links===&lt;br /&gt;
Be careful, read the warning.&lt;br /&gt;
&lt;br /&gt;
===Show page information===&lt;br /&gt;
To show page information printed in the page footer.&lt;br /&gt;
&lt;br /&gt;
==What to do if you cannot get to the admin screens==&lt;br /&gt;
&lt;br /&gt;
If the error is stopping you even getting to the admin screens to turn on debugging, then you can set the debugging setting manually.&lt;br /&gt;
&lt;br /&gt;
===Try typing the URL directly===&lt;br /&gt;
&lt;br /&gt;
The debug settings are at the URL &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://.../admin/settings.php?section=debugging&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; on your server. Sometimes that URL will work, even though the pages you need to go to get there (for example the site front page) do not. So it is worth trying to enter that URL directly.&lt;br /&gt;
&lt;br /&gt;
===In config.php===&lt;br /&gt;
&lt;br /&gt;
In [[Configuration file|config.php]] you can add the lines:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
@error_reporting(E_ALL | E_STRICT);&lt;br /&gt;
@ini_set(&#039;display_errors&#039;, &#039;1&#039;);&lt;br /&gt;
$CFG-&amp;gt;debug = (E_ALL | E_STRICT); &lt;br /&gt;
$CFG-&amp;gt;debugdisplay = 1;&lt;br /&gt;
&lt;br /&gt;
// You can specify a comma separated list of user ids that always see&lt;br /&gt;
// debug messages, this overrides the debug flag in $CFG-&amp;gt;debug and $CFG-&amp;gt;debugdisplay&lt;br /&gt;
// for these users only.&lt;br /&gt;
$CFG-&amp;gt;debugusers = &#039;2&#039;;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; Add these lines immediately before the line...&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
require_once(dirname(__FILE__) . &#039;/lib/setup.php&#039;);&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember to remove those lines again when you have finished diagnosing your problem.&lt;br /&gt;
&lt;br /&gt;
NOTE: do not try to modify the config database table directly, it will not work because the values are cached in MUC.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Developers can also use [http://xdebug.org/ XDEBUG] (Installed as a module on the Apache server) to further dig into the code, step by step using an [http://xdebug.org/docs/remote XDEBUG client application]. Probably, as part of their favorite IDE. For example: [http://php.netbeans.org/ NetBeans], [http://www.jetbrains.com/phpstorm/ phpStorm] or...&lt;br /&gt;
&lt;br /&gt;
[[es:Depuración]]&lt;br /&gt;
[[fr:Débogage]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Talk:ad-hoc_contributed_reports&amp;diff=116236</id>
		<title>Talk:ad-hoc contributed reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Talk:ad-hoc_contributed_reports&amp;diff=116236"/>
		<updated>2014-12-03T09:50:10Z</updated>

		<summary type="html">&lt;p&gt;Fox: Can someone apply my latest changes on 2.7 and 2.6 version?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;There are some scripts here that are only usable in 1.9 and have 2.x versions working, so I am removing them. ~~ Randy, June 2013&lt;br /&gt;
&lt;br /&gt;
Could someone apply my latest changes on 2.7 and 2.6 versions? --[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 17:50, 3 December 2014 (AWST)&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=ad-hoc_contributed_reports&amp;diff=116220</id>
		<title>ad-hoc contributed reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=ad-hoc_contributed_reports&amp;diff=116220"/>
		<updated>2014-12-02T10:07:59Z</updated>

		<summary type="html">&lt;p&gt;Fox: /* Lists &amp;quot;Totally Opened Courses&amp;quot; (visible, opened to guests, with no password) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Sitewide reports}}&lt;br /&gt;
==User and Role Report==&lt;br /&gt;
&lt;br /&gt;
===Count number of distinct learners and teachers enrolled per category (including all its sub categories)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;SELECT COUNT(DISTINCT lra.userid) AS learners, COUNT(DISTINCT tra.userid) as teachers&lt;br /&gt;
FROM prefix_course AS c #, mdl_course_categories AS cats&lt;br /&gt;
LEFT JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments  AS lra ON lra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_role_assignments  AS tra ON tra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_course_categories AS cats ON c.category = cats.id&lt;br /&gt;
WHERE c.category = cats.id&lt;br /&gt;
AND (&lt;br /&gt;
	cats.path LIKE &#039;%/CATEGORYID/%&#039; #Replace CATEGORYID with the category id you want to count (eg: 80)&lt;br /&gt;
	OR cats.path LIKE &#039;%/CATEGORYID&#039;&lt;br /&gt;
	)&lt;br /&gt;
AND lra.roleid=5&lt;br /&gt;
AND tra.roleid=3&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed ACTIONs for each ROLE (TEACHER, NON-EDITING TEACHER and STUDENT)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT r.name, l.action, COUNT( l.userid ) AS counter&lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
JOIN prefix_context AS context ON context.instanceid = l.course AND context.contextlevel = 50&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON l.userid = ra.userid AND ra.contextid = context.id&lt;br /&gt;
JOIN prefix_role AS r ON ra.roleid = r.id&lt;br /&gt;
WHERE ra.roleid IN ( 3, 4, 5 ) &lt;br /&gt;
GROUP BY roleid, l.action&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Student (user) COUNT in each Course===&lt;br /&gt;
Including (optional) filter by: year (if included in course fullname).&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,course.id,&#039;&amp;quot;&amp;gt;&#039;,course.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/user/index.php?contextid=&#039;,context.id,&#039;&amp;quot;&amp;gt;Show users&amp;lt;/a&amp;gt;&#039;) AS Users&lt;br /&gt;
, COUNT(course.id) AS Students&lt;br /&gt;
FROM prefix_role_assignments AS asg&lt;br /&gt;
JOIN prefix_context AS context ON asg.contextid = context.id AND context.contextlevel = 50&lt;br /&gt;
JOIN prefix_user AS user ON user.id = asg.userid&lt;br /&gt;
JOIN prefix_course AS course ON context.instanceid = course.id&lt;br /&gt;
WHERE asg.roleid = 5 &lt;br /&gt;
# AND course.fullname LIKE &#039;%2013%&#039;&lt;br /&gt;
GROUP BY course.id&lt;br /&gt;
ORDER BY COUNT(course.id) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===LIST of all site USERS by COURSE enrollment (Moodle 2.x)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
user2.firstname AS Firstname,&lt;br /&gt;
user2.lastname AS Lastname,&lt;br /&gt;
user2.email AS Email,&lt;br /&gt;
user2.city AS City,&lt;br /&gt;
course.fullname AS Course&lt;br /&gt;
,(SELECT shortname FROM prefix_role WHERE id=en.roleid) as Role&lt;br /&gt;
,(SELECT name FROM prefix_role WHERE id=en.roleid) as RoleName&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course as course &lt;br /&gt;
JOIN prefix_enrol AS en ON en.courseid = course.id&lt;br /&gt;
JOIN prefix_user_enrolments AS ue ON ue.enrolid = en.id&lt;br /&gt;
JOIN prefix_user AS user2 ON ue.userid = user2.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enrolled users,which did not login into the Course, even once (Moodle 2)===&lt;br /&gt;
Designed forMoodle 2 table structure and uses special plugin filter : %%FILTER_SEARCHTEXT:table.field%%&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
user2.id as ID,&lt;br /&gt;
ul.timeaccess,&lt;br /&gt;
user2.firstname AS Firstname,&lt;br /&gt;
user2.lastname AS Lastname,&lt;br /&gt;
user2.email AS Email,&lt;br /&gt;
user2.city AS City,&lt;br /&gt;
user2.idnumber AS IDNumber,&lt;br /&gt;
user2.phone1 AS Phone,&lt;br /&gt;
user2.institution AS Institution,&lt;br /&gt;
&lt;br /&gt;
IF (user2.lastaccess = 0,&#039;never&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(user2.lastaccess),&#039;%Y-%m-%d&#039;)) AS dLastAccess&lt;br /&gt;
&lt;br /&gt;
,(SELECT DATE_FORMAT(FROM_UNIXTIME(timeaccess),&#039;%Y-%m-%d&#039;) FROM prefix_user_lastaccess WHERE userid=user2.id and courseid=c.id) as CourseLastAccess&lt;br /&gt;
&lt;br /&gt;
,(SELECT r.name&lt;br /&gt;
FROM  prefix_user_enrolments AS uenrol&lt;br /&gt;
JOIN prefix_enrol AS e ON e.id = uenrol.enrolid&lt;br /&gt;
JOIN prefix_role AS r ON e.id = r.id&lt;br /&gt;
WHERE uenrol.userid=user2.id and e.courseid = c.id) AS RoleName&lt;br /&gt;
&lt;br /&gt;
FROM prefix_user_enrolments as ue&lt;br /&gt;
JOIN prefix_enrol as e on e.id = ue.enrolid&lt;br /&gt;
JOIN prefix_course as c ON c.id = e.courseid&lt;br /&gt;
JOIN prefix_user as user2 ON user2 .id = ue.userid&lt;br /&gt;
LEFT JOIN prefix_user_lastaccess as ul on ul.userid = user2.id&lt;br /&gt;
WHERE c.id=16 AND ul.timeaccess IS NULL&lt;br /&gt;
%%FILTER_SEARCHTEXT:user2.firstname%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Role assignments on categories===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/category.php?id=&#039;,cc.id,&#039;&amp;quot;&amp;gt;&#039;,cc.id,&#039;&amp;lt;/a&amp;gt;&#039;) AS id,&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/category.php?id=&#039;,cc.id,&#039;&amp;quot;&amp;gt;&#039;,cc.name,&#039;&amp;lt;/a&amp;gt;&#039;) AS category,&lt;br /&gt;
cc.depth, cc.path, r.name AS role,&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/user/view.php?id=&#039;,usr.id,&#039;&amp;quot;&amp;gt;&#039;,usr.lastname,&#039;&amp;lt;/a&amp;gt;&#039;) AS name,&lt;br /&gt;
usr.firstname, usr.username, usr.email&lt;br /&gt;
FROM prefix_course_categories cc&lt;br /&gt;
INNER JOIN prefix_context cx ON cc.id = cx.instanceid&lt;br /&gt;
AND cx.contextlevel = &#039;40&#039;&lt;br /&gt;
INNER JOIN prefix_role_assignments ra ON cx.id = ra.contextid&lt;br /&gt;
INNER JOIN prefix_role r ON ra.roleid = r.id&lt;br /&gt;
INNER JOIN prefix_user usr ON ra.userid = usr.id&lt;br /&gt;
ORDER BY cc.depth, cc.path, usr.lastname, usr.firstname, r.name, cc.name&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Permissions Overides on Categories===&lt;br /&gt;
(By: [http://moodle.org/mod/forum/discuss.php?d=153059#p712834 Séverin Terrier] )&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT rc.id, ct.instanceid, ccat.name, rc.roleid, rc.capability, rc.permission, &lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( rc.timemodified ) , &#039;%Y-%m-%d&#039; ) AS timemodified, rc.modifierid, ct.instanceid, ct.path, ct.depth&lt;br /&gt;
FROM `prefix_role_capabilities` AS rc&lt;br /&gt;
INNER JOIN `prefix_context` AS ct ON rc.contextid = ct.id&lt;br /&gt;
INNER JOIN `prefix_course_categories` AS ccat ON ccat.id = ct.instanceid&lt;br /&gt;
AND `contextlevel` =40&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Lists &amp;quot;Totally Opened Courses&amp;quot; (visible, opened to guests, with no password)===&lt;br /&gt;
(By: [http://moodle.org/mod/forum/discuss.php?d=153059#p712837 Séverin Terrier] )&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.id,&#039;&amp;lt;/a&amp;gt;&#039;) AS id,&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.shortname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Course&#039;,&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/enrol/instances.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;Méthodes inscription&amp;lt;/a&amp;gt;&#039;) AS &#039;Enrollment plugins&#039;,&lt;br /&gt;
e.sortorder&lt;br /&gt;
FROM prefix_enrol AS e, prefix_course AS c&lt;br /&gt;
WHERE e.enrol=&#039;guest&#039; AND e.status=0 AND e.password=&#039;&#039; AND c.id=e.courseid AND c.visible=1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Lists &amp;quot;loggedin users&amp;quot; from the last 120 days===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT id,username,FROM_UNIXTIME(`lastlogin`) as days &lt;br /&gt;
FROM `prefix_user` &lt;br /&gt;
WHERE DATEDIFF( NOW(),FROM_UNIXTIME(`lastlogin`) ) &amp;lt; 120&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;and user count for that same population:&#039;&#039;&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(id) as Users  FROM `prefix_user` &lt;br /&gt;
WHERE DATEDIFF( NOW(),FROM_UNIXTIME(`lastlogin`) ) &amp;lt; 120&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Lists the users who have only logged into the site once===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT id, username, firstname, lastname, idnumber&lt;br /&gt;
FROM prefix_user&lt;br /&gt;
WHERE prefix_user.deleted = 0&lt;br /&gt;
AND prefix_user.lastlogin = 0 &lt;br /&gt;
AND prefix_user.lastaccess &amp;gt; 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Students in all courses of some institute===&lt;br /&gt;
What is the status (deleted or not) of all Students (roleid = 5) in all courses of some Institute&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.id, c.fullname, u.firstname, u.lastname, u.deleted&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
AND u.institution = &#039;please enter school name here&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full User info (for deleted users)===&lt;br /&gt;
Including extra custom profile fields (from prefix_user_info_data)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT * &lt;br /&gt;
FROM prefix_user as u &lt;br /&gt;
JOIN prefix_user_info_data as uid ON uid.userid = u.id &lt;br /&gt;
JOIN prefix_user_info_field as uif ON (uid.fieldid = uif.id AND uif.shortname = &#039;class&#039;)&lt;br /&gt;
WHERE `deleted` = &amp;quot;1&amp;quot; and `institution`=&amp;quot;your school name&amp;quot; and `department` = &amp;quot;your department&amp;quot; and `data` = &amp;quot;class level and number&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===User&#039;s courses===&lt;br /&gt;
change &amp;quot;u.id = 2&amp;quot; with a new user id&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname, c.id, c.fullname&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE u.id = 2&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List Users with extra info (email) in current course===&lt;br /&gt;
blocks/configurable_reports replaces %%COURSEID%% with course id.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname, u.email&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS context ON context.id = ra.contextid AND context.contextlevel = 50&lt;br /&gt;
JOIN prefix_course AS c ON c.id = context.instanceid AND c.id = %%COURSEID%%&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Special Roles===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT ra.roleid,r.name&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/user.php?id=1&amp;amp;user=&#039;,ra.userid,&#039;&amp;quot;&amp;gt;&#039;,u.firstname ,&#039; &#039;,u.lastname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Username&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_role AS r ON r.id = ra.roleid&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_context AS ctx ON (ctx.id = ra.contextid AND ctx.contextlevel = 50)&lt;br /&gt;
JOIN prefix_course AS c ON ctx.instanceid = c.id&lt;br /&gt;
WHERE ra.roleid &amp;gt; 6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Courses without Teachers===&lt;br /&gt;
Actually, shows the number of Teachers in a course.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id) AS Teachers&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
ORDER BY Teachers ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List of users who have been enrolled for more than 4 weeks===&lt;br /&gt;
For Moodle 2.2 , by  Isuru Madushanka Weerarathna &lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT uenr.userid As User, IF(enr.courseid=uenr.courseid ,&#039;Y&#039;,&#039;N&#039;) As Enrolled, &lt;br /&gt;
IF(DATEDIFF(NOW(), FROM_UNIXTIME(uenr.timecreated))&amp;gt;=28,&#039;Y&#039;,&#039;N&#039;) As EnrolledMoreThan4Weeks&lt;br /&gt;
FROM prefix_enrol As enr, prefix_user_enrolments AS uenr&lt;br /&gt;
WHERE enr.id = uenr.enrolid AND enr.status = uenr.status&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List of users with language===&lt;br /&gt;
&lt;br /&gt;
An issue with systems that do not have their default language set up properly is the need to do a mass change for all users to a localization. A common case is changing default English to American English. &lt;br /&gt;
&lt;br /&gt;
This will show you the language setting for all users:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT username, lang from prefix_user &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will change the setting from &#039;en&#039; to &#039;en_us&#039; for all users:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
UPDATE prefix_user SET lang = &#039;en_us&#039; WHERE lang = &#039;en&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Compare role capability and permissions ===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DISTINCT mrc.capability &lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;1&#039; AND rc.contextid = &#039;1&#039;) AS Manager&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;2&#039; AND rc.contextid = &#039;1&#039;) AS CourseCreator&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;3&#039; AND rc.contextid = &#039;1&#039;) AS Teacher&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;4&#039; AND rc.contextid = &#039;1&#039;) AS AssistantTeacher&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;5&#039; AND rc.contextid = &#039;1&#039;) AS Student&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;6&#039; AND rc.contextid = &#039;1&#039;) AS Guest&lt;br /&gt;
&lt;br /&gt;
FROM `mdl_role_capabilities` AS mrc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Log Activity Reports==&lt;br /&gt;
===Count all Active Users by ROLE in a course category (including all of its sub-categories)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(DISTINCT l.userid) as active&lt;br /&gt;
FROM mdl_course as c&lt;br /&gt;
JOIN mdl_context AS ctx ON  ctx.instanceid=c.id&lt;br /&gt;
JOIN mdl_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN mdl_user_lastaccess as l ON ra.userid = l.userid&lt;br /&gt;
JOIN mdl_course_categories AS cats ON c.category = cats.id&lt;br /&gt;
WHERE c.category=cats.id AND (&lt;br /&gt;
	cats.path LIKE &#039;%/80/%&#039;&lt;br /&gt;
	OR cats.path LIKE &#039;%/80&#039;&lt;br /&gt;
) &lt;br /&gt;
AND ra.roleid=3  AND ctx.contextlevel=50  #ra.roleid= TEACHER 3, NON-EDITING TEACHER 4, STUDENT 5&lt;br /&gt;
AND  l.timeaccess &amp;gt; (unix_timestamp() - ((60*60*24)*NO_OF_DAYS)) #NO_OF_DAYS change to number&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===Detailed &amp;quot;VIEW&amp;quot; ACTION for each ROLE (TEACHER,NONE-EDITING TEACHER and STUDENT)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT l.action, count( l.userid ) as counter , r.name&lt;br /&gt;
FROM `prefix_log` as l&lt;br /&gt;
JOIN `prefix_role_assignments` AS ra on l.userid = ra.userid&lt;br /&gt;
JOIN `prefix_role` AS r ON ra.roleid = r.id&lt;br /&gt;
WHERE (ra.roleid IN (3,4,5)) AND (l.action LIKE &#039;%view%&#039; )&lt;br /&gt;
GROUP BY roleid,l.action&lt;br /&gt;
order by r.name,counter desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Total Activity of Roles:&amp;quot;Teacher&amp;quot; and &amp;quot;None-Editing Teacher&amp;quot; by Dates and by Hours===&lt;br /&gt;
The output columns of this report table can be used as base for a Pivot-Table&lt;br /&gt;
which will show the amount of &#039;&#039;&#039;activity&#039;&#039;&#039; per &#039;&#039;&#039;hour&#039;&#039;&#039; per &#039;&#039;&#039;days&#039;&#039;&#039; in 3D graph view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DATE_FORMAT( FROM_UNIXTIME( l.time ) , &#039;%Y-%m-%d&#039; ) AS grptimed ,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( l.time ) , &#039;%k&#039; ) AS grptimeh  , count( l.userid ) AS counter &lt;br /&gt;
FROM `prefix_log` AS l&lt;br /&gt;
JOIN prefix_user AS u ON u.id = l.userid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON l.userid = ra.userid&lt;br /&gt;
JOIN prefix_role AS r ON r.id = ra.roleid&lt;br /&gt;
WHERE ra.roleid IN (3,4)&lt;br /&gt;
GROUP BY grptimed,grptimeh&lt;br /&gt;
ORDER BY grptimed,grptimeh&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===How many LOGINs per user and user&#039;s Activity===&lt;br /&gt;
+ link username to a user activity graph report&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/user.php?id=1&amp;amp;user=&#039;,u.id,&#039;&amp;amp;mode=alllogs&amp;quot;&amp;gt;&#039;,u.firstname ,&#039; &#039;,u.lastname,&#039;&amp;lt;/a&amp;gt;&#039;) as Username&lt;br /&gt;
,count(*) as logins&lt;br /&gt;
,(SELECT count(*) FROM prefix_log WHERE userid = l.userid GROUP BY userid) as Activity &lt;br /&gt;
FROM prefix_log as l JOIN prefix_user as u ON l.userid = u.id &lt;br /&gt;
WHERE `action` LIKE &#039;%login%&#039; group by userid&lt;br /&gt;
ORDER BY Activity DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Total activity per course, per unique user on the last 24h===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
Select&lt;br /&gt;
     Count(Distinct userid) As countUsers&lt;br /&gt;
   , Count(course) As countVisits&lt;br /&gt;
   , concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
&lt;br /&gt;
 From prefix_log as l&lt;br /&gt;
 JOIN prefix_course as c on c.id = l.course&lt;br /&gt;
 Where course &amp;gt; 0 and FROM_UNIXTIME(time) &amp;gt;= DATE_SUB(NOW(), INTERVAL 1 DAY) and c.fullname LIKE &#039;%תשעג%&#039;&lt;br /&gt;
 Group By course&lt;br /&gt;
ORDER BY countVisits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Weekly Instructor Online Participation===&lt;br /&gt;
Contributed by Elizabeth Dalton&lt;br /&gt;
&lt;br /&gt;
Displays participation of instructors in all courses per week of a term, including pre-term and post-term edits. An edit is defined as a change to the course, such as a discussion post, the grading of an assignment, or the uploading of file attachments, as well as alterations to course content.&lt;br /&gt;
&lt;br /&gt;
* To specify a subject and/or course number, use % as a wildcard, e.g. ARTS% or ARTS501%&lt;br /&gt;
* To match part of a last name, use %, e.g. Smi% will match &amp;quot;Smith&amp;quot;, &amp;quot;Smile&amp;quot;, etc.&lt;br /&gt;
&lt;br /&gt;
At our institution, we include filters on the course name or category to constrain by terms. These are very specific to how course names and categories are constructed at our institution, so I&#039;ve removed those elements from this code. Also, our terms are 12 weeks long. You would want to insert additional &amp;quot;SUM&amp;quot; lines for longer terms, or remove lines for shorter terms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
c.shortname AS CourseID&lt;br /&gt;
, cc.name AS Category&lt;br /&gt;
, CONCAT(u.firstname ,&#039; &#039;,u.lastname) AS Instructor&lt;br /&gt;
&lt;br /&gt;
, (SELECT COUNT( ra2.userid ) AS Users2 FROM prefix_role_assignments AS ra2&lt;br /&gt;
JOIN prefix_context AS ctx2 ON ra2.contextid = ctx2.id&lt;br /&gt;
WHERE ra2.roleid = 5 AND ctx2.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
, c.startdate AS Course_Start_Date&lt;br /&gt;
&lt;br /&gt;
, c.visible AS Visible&lt;br /&gt;
&lt;br /&gt;
,  COUNT(l.id) AS Edits&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time)) - WEEK(FROM_UNIXTIME(c.startdate))&amp;lt;0,1,0)) AS BeforeTerm&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=0,1,0)) AS Week1&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=1,1,0)) AS Week2&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=2,1,0)) AS Week3&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=3,1,0)) AS Week4&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=4,1,0)) AS Week5&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=5,1,0)) AS Week6&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=6,1,0)) AS Week7&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=7,1,0)) AS Week8&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=8,1,0)) AS Week9&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=9,1,0)) AS Week10&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=10,1,0)) AS Week11&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=11,1,0)) AS Week12&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))&amp;gt;=12,1,0)) AS AfterTerm&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/report/log/index.php&#039;,CHAR(63),&#039;chooselog=1&amp;amp;showusers=1&amp;amp;showcourses=0&amp;amp;id=&#039;,c.id,&#039;&amp;amp;user=&#039;,u.id,&#039;&amp;amp;date=0&amp;amp;modid=&amp;amp;modaction=&amp;amp;logformat=showashtml&#039;,&#039;&amp;quot;&amp;gt;&#039;,&#039;Logs&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS Link&lt;br /&gt;
&lt;br /&gt;
FROM prefix_user AS u&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_course_categories as cc ON c.category = cc.id&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_log AS l ON l.userid = u.id AND l.course = c.id  AND l.action NOT LIKE &amp;quot;view%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
WHERE ra.roleid =3&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
AND c.shortname LIKE :course&lt;br /&gt;
AND u.lastname LIKE :last_name&lt;br /&gt;
&lt;br /&gt;
GROUP BY u.idnumber, c.id&lt;br /&gt;
HAVING students &amp;gt; 0&lt;br /&gt;
ORDER BY c.shortname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Module activity (Hits) between dates===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT module, COUNT( * ) &lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME( l.`time` ) BETWEEN  &#039;2012-10-01 00:00:00&#039; AND  &#039;2013-09-31 00:00:00&#039;)&lt;br /&gt;
GROUP BY module&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Module activity (Instances and Hits) for each academic year===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT name&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2010-10-01 00:00:00&#039; AND &#039;2011-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name AND l.action = &#039;add&#039;&lt;br /&gt;
) AS &amp;quot;Added 2010&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2010-10-01 00:00:00&#039; AND &#039;2011-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2010&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2011-10-01 00:00:00&#039; AND &#039;2012-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name AND l.action = &#039;add&#039;&lt;br /&gt;
) AS &amp;quot;Added 2011&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2011-10-01 00:00:00&#039; AND &#039;2012-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2011&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2012-10-01 00:00:00&#039; AND &#039;2013-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name AND l.action = &#039;add&#039;&lt;br /&gt;
) AS &amp;quot;Added 2012&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2012-10-01 00:00:00&#039; AND &#039;2013-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2012&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_modules AS m&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Course Reports==&lt;br /&gt;
===Most Active courses===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, l.course courseId, c.fullname coursename&lt;br /&gt;
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
GROUP BY courseId&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Active courses, advanced===&lt;br /&gt;
Including: Teacher&#039;s name, link to the course, All types of log activities, special YEAR generated field, Activities and Resource count, enrolled Student count&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course &lt;br /&gt;
&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher&lt;br /&gt;
&lt;br /&gt;
,CASE &lt;br /&gt;
  WHEN c.fullname LIKE &#039;%תשע&#039; THEN &#039;תשע&#039;&lt;br /&gt;
  WHEN c.fullname LIKE &#039;%תשעא&#039; THEN &#039;תשעא&#039;&lt;br /&gt;
  WHEN c.fullname LIKE &#039;%תשעב&#039; THEN &#039;תשעב&#039;&lt;br /&gt;
END AS Year&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_course_modules cm WHERE cm.course = l.course) Modules&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
FROM prefix_log l &lt;br /&gt;
INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
HAVING Modules &amp;gt; 2&lt;br /&gt;
ORDER BY Year DESC, hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Count unique teachers with courses that use at least X module (Moodle19)===&lt;br /&gt;
You can remove the outer &amp;quot;SELECT COUNT(*) FROM (...) AS ActiveTeachers&amp;quot; SQL query and get the list of the Teachers and Courses.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(*)&lt;br /&gt;
FROM (SELECT c.id AS CourseID, c.fullname AS Course, ra.roleid AS RoleID, CONCAT(u.firstname, &#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm WHERE cm.course = c.id) AS Modules&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid AND ctx.contextlevel = 50 &lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE  ra.roleid = 3 &lt;br /&gt;
GROUP BY u.id&lt;br /&gt;
HAVING Modules &amp;gt; 5) AS ActiveTeachers&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESOURCE count for each COURSE===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) count, l.course, c.fullname coursename&lt;br /&gt;
FROM prefix_resource l INNER JOIN prefix_course c on l.course = c.id&lt;br /&gt;
GROUP BY course&lt;br /&gt;
ORDER BY count DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Common resource types count for each Category (Moodle19)===&lt;br /&gt;
Including sub-categories in total count.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT mcc.id AS mccid, CONCAT( LPAD( &#039;&#039;, mcc.depth, &#039;.&#039; ) , mcc.name ) AS Category&lt;br /&gt;
,(SELECT COUNT( * ) &lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%&#039;, mccid, &#039;%&#039; ) AND r.TYPE = &#039;file&#039; AND r.reference LIKE &#039;http://%&#039;&lt;br /&gt;
) AS Links&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT( * ) &lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%&#039;, mccid, &#039;%&#039; ) AND r.TYPE = &#039;file&#039; AND r.reference NOT LIKE &#039;http://%&#039;&lt;br /&gt;
) AS Files&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT( * ) &lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%&#039;, mccid, &#039;%&#039; ) AND r.TYPE = &#039;directory&#039; &lt;br /&gt;
) AS Folders&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT( * ) &lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%&#039;, mccid, &#039;%&#039; ) AND r.TYPE = &#039;html&#039; &lt;br /&gt;
) AS Pages&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM stats_log_context_role_course &lt;br /&gt;
WHERE roleid = 5 AND module = &#039;resource&#039; AND category = mcc.id&lt;br /&gt;
) AS Hits&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course_categories AS mcc&lt;br /&gt;
ORDER BY mcc.path&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Where &amp;quot;stats_log_context_role_course&amp;quot; (in the above SQL query) is a VIEW generated by:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
CREATE VIEW stats_log_context_role_course AS&lt;br /&gt;
SELECT l.course, c.category, cc.path, l.module, l.action, ra.userid, ra.roleid&lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
JOIN prefix_context AS context ON context.instanceid = l.course AND context.contextlevel = 50&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.userid = l.userid AND ra.contextid = context.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = l.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Same query but for Moodle2+&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT mcc.id AS mccid, CONCAT( LPAD( &#039;&#039;, mcc.depth, &#039;.&#039; ) , mcc.name ) AS Category,&lt;br /&gt;
mcc.path,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_url AS u&lt;br /&gt;
JOIN prefix_course AS c ON c.id = u.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS URLs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_folder AS f&lt;br /&gt;
JOIN prefix_course AS c ON c.id = f.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS FOLDERs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_page AS p&lt;br /&gt;
JOIN prefix_course AS c ON c.id = p.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS PAGEs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_book AS b&lt;br /&gt;
JOIN prefix_course AS c ON c.id = b.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS BOOKs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_label AS l&lt;br /&gt;
JOIN prefix_course AS c ON c.id = l.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS LABELs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_tab AS t&lt;br /&gt;
JOIN prefix_course AS c ON c.id = t.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS TABs&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course_categories AS mcc&lt;br /&gt;
ORDER BY mcc.path&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed Resource COUNT by Teacher in each course===&lt;br /&gt;
&lt;br /&gt;
Including (optional) filter by: year, semester and course id.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS CourseID&lt;br /&gt;
, c.id&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user AS u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = c.id AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
&lt;br /&gt;
, (CASE &lt;br /&gt;
WHEN c.fullname LIKE &#039;%תשעב%&#039; THEN &#039;2012&#039; &lt;br /&gt;
WHEN c.fullname LIKE &#039;%תשעא%&#039; THEN &#039;2011&#039;&lt;br /&gt;
END ) as Year&lt;br /&gt;
, (CASE &lt;br /&gt;
WHEN c.fullname LIKE &#039;%סמסטר א%&#039; THEN &#039;Semester A&#039; &lt;br /&gt;
WHEN c.fullname LIKE &#039;%סמסטר ב%&#039; THEN &#039;Semester B&#039;&lt;br /&gt;
WHEN c.fullname LIKE &#039;%סמסטר ק%&#039; THEN &#039;Semester C&#039;&lt;br /&gt;
END ) as Semester&lt;br /&gt;
,COUNT(c.id) AS Total&lt;br /&gt;
,(SELECT count(*) FROM prefix_course_modules AS cm WHERE cm.course = c.id AND cm.module= 20) AS TABs&lt;br /&gt;
,(SELECT count(*) FROM prefix_course_modules AS cm WHERE cm.course = c.id AND cm.module= 33) AS BOOKs&lt;br /&gt;
&lt;br /&gt;
FROM `prefix_resource` as r &lt;br /&gt;
JOIN `prefix_course` AS c on c.id = r.course&lt;br /&gt;
#WHERE type= &#039;file&#039; and reference NOT LIKE &#039;http://%&#039; &lt;br /&gt;
&lt;br /&gt;
#WHERE 1=1&lt;br /&gt;
#%%FILTER_YEARS:c.fullname%%&lt;br /&gt;
#AND c.fullname LIKE &#039;%2013%&#039;&lt;br /&gt;
&lt;br /&gt;
GROUP BY course&lt;br /&gt;
ORDER BY COUNT(c.id) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Courses that are defined as using GROUPs===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/group/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,(SELECT count(*) FROM prefix_course_modules cm WHERE cm.course = c.id) Modules&lt;br /&gt;
,(SELECT count(*) FROM prefix_groups g WHERE g.courseid = c.id) Groups&lt;br /&gt;
 FROM `prefix_course` AS c&lt;br /&gt;
WHERE groupmode &amp;gt; 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Courses with Groups===&lt;br /&gt;
&lt;br /&gt;
List of all courses with Groups in them (groupmode &amp;gt; 0). You can also use groupmode=1 to list just Separate type groups or groupmode=2 to list Visible type groups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname, g.name, c.groupmode&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_groups AS g ON c.id = g.courseid&lt;br /&gt;
WHERE c.groupmode &amp;gt; 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Groups in course with member list===&lt;br /&gt;
&lt;br /&gt;
List the groups in a course (replace the # by the course id number) with the members of each group.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname, g.name AS Groupname, u.username&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_groups AS g ON g.courseid = c.id&lt;br /&gt;
JOIN prefix_groups_members AS m ON g.id = m.groupid&lt;br /&gt;
JOIN prefix_user AS u ON m.userid = u.id&lt;br /&gt;
WHERE c.id = #&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Group Export===&lt;br /&gt;
&lt;br /&gt;
There&#039;s a [[Import_groups|group import]] function, but no export. Use this to give you a report with the proper column order and headings to export to a csv file you can then import into another course to replicate the groups. This is a simple version with just the main fields: groupname, description, enrolment key.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT g.name AS groupname, g.description, g.enrolmentkey&lt;br /&gt;
FROM prefix_groups AS g &lt;br /&gt;
JOIN prefix_course as c ON g.courseid = c.id&lt;br /&gt;
WHERE c.id = #&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all Courses in and below a certain category===&lt;br /&gt;
Use this SQL code to retrieve all courses that exist in or under a set category.&lt;br /&gt;
&lt;br /&gt;
$s should be the id of the category you want to know about...&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT prefix_course. * , prefix_course_categories. *&lt;br /&gt;
FROM prefix_course, prefix_course_categories&lt;br /&gt;
WHERE prefix_course.category = prefix_course_categories.id&lt;br /&gt;
AND (&lt;br /&gt;
prefix_course_categories.path LIKE &#039;/$s/%&#039;&lt;br /&gt;
OR prefix_course_categories.path LIKE &#039;/$s&#039;&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all Categories in one level below a certain category===&lt;br /&gt;
Use this PHP code to retrieve a list of all categories below a certain category.&lt;br /&gt;
&lt;br /&gt;
$s should be the id of the top level category you are interested in.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
require_once(&#039;./config.php&#039;);&lt;br /&gt;
&lt;br /&gt;
$parent_id = $s;&lt;br /&gt;
&lt;br /&gt;
$categories= array();&lt;br /&gt;
&lt;br /&gt;
$categories = get_categories($parent_id);&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;ol&amp;gt;&#039;;&lt;br /&gt;
foreach ($categories as $category)&lt;br /&gt;
        {&lt;br /&gt;
        echo &#039;&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;&#039;.$CFG-&amp;gt;wwwroot.&#039;/course/category.php?id=&#039;.$category-&amp;gt;id.&#039;&amp;quot;&amp;gt;&#039;.$category-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#039;;&lt;br /&gt;
        }&lt;br /&gt;
echo &#039;&amp;lt;/ol&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Blog activity per Course (not including VIEW)===&lt;br /&gt;
Filter activity logging to some specific Course Categories!&lt;br /&gt;
+ link course name to actual course (for quick reference)&lt;br /&gt;
(you can change %blog% to %wiki% to filter down all wiki activity or any other module you wish)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,cm.course,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as CourseID&lt;br /&gt;
,m.name ,count(cm.id) as counter &lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS Students&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE `module` LIKE &#039;%blog%&#039; AND course = c.id AND action NOT LIKE &#039;%view%&#039; ) as BlogActivity&lt;br /&gt;
FROM `prefix_course_modules` as cm JOIN prefix_modules as m ON cm.module=m.id JOIN prefix_course as c ON cm.course = c.id &lt;br /&gt;
WHERE m.name LIKE &#039;%blog%&#039; AND c.category IN ( 8,13,15)&lt;br /&gt;
GROUP BY cm.course,cm.module order by counter desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Student&#039;s posts content in all course blogs (oublog)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
b.name &lt;br /&gt;
,op.title&lt;br /&gt;
,op.message&lt;br /&gt;
,( SELECT CONCAT(u.firstname, &#039; &#039;,u.lastname) FROM prefix_user AS u WHERE u.id = oi.userid) AS &amp;quot;Username&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_oublog_posts AS op&lt;br /&gt;
JOIN prefix_oublog_instances AS oi ON oi.id = op.oubloginstancesid &lt;br /&gt;
JOIN prefix_oublog as b ON b.id = oi.oublogid&lt;br /&gt;
JOIN prefix_course AS c ON b.course = c.id&lt;br /&gt;
&lt;br /&gt;
WHERE c.id = %%COURSEID%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All Courses which uploaded a Syllabus file===&lt;br /&gt;
+ under specific Category&lt;br /&gt;
+ show first Teacher in that course&lt;br /&gt;
+ link Course&#039;s fullname to actual course&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
,c.shortname,r.name&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) as Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user as u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) as Teacher&lt;br /&gt;
FROM prefix_resource as r &lt;br /&gt;
JOIN prefix_course as c ON r.course = c.id&lt;br /&gt;
WHERE ( r.name LIKE &#039;%סילבוס%&#039; OR r.name LIKE &#039;%סילאבוס%&#039; OR r.name LIKE &#039;%syllabus%&#039; OR r.name LIKE &#039;%תכנית הקורס%&#039; ) &lt;br /&gt;
AND c.category IN (10,18,26,13,28)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
===Site-wide completed SCORM activities by Course name===&lt;br /&gt;
This report will list all completed attempts for all SCORM activities. It is ordered first by Course name, then student&#039;s last name, then student&#039;s first name, then attempt number. Please note: the FROM_UNIXTIME command is for MySQL.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname First,u.lastname Last,c.fullname Course, st.attempt Attempt,st.value Status,FROM_UNIXTIME(st.timemodified,&amp;quot;%m-%d-%Y&amp;quot;) Date &lt;br /&gt;
FROM prefix_scorm_scoes_track AS st &lt;br /&gt;
JOIN prefix_user AS u ON st.userid=u.id&lt;br /&gt;
JOIN prefix_scorm AS sc ON sc.id=st.scormid&lt;br /&gt;
JOIN prefix_course AS c ON c.id=sc.course&lt;br /&gt;
WHERE st.value=&#039;completed&#039; &lt;br /&gt;
ORDER BY c.fullname, u.lastname,u.firstname, st.attempt&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Module instances + Module HITs by role teacher and student in course==&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
m.name AS &amp;quot;Module name&amp;quot;&lt;br /&gt;
, COUNT(*) AS &amp;quot;Module count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_log AS l &lt;br /&gt;
WHERE l.course = cm.course AND l.module = m.name ) AS &amp;quot;Hits&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
JOIN prefix_context AS con ON con.instanceid= l.course AND con.contextlevel=50&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid= con.id AND ra.userid= l.userid AND ra.roleid = 5 &lt;br /&gt;
WHERE l.course = cm.course AND l.module = m.name) AS &amp;quot;Students HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
JOIN prefix_context AS con ON con.instanceid= l.course AND con.contextlevel=50&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid= con.id AND ra.userid= l.userid AND ra.roleid = 3 &lt;br /&gt;
WHERE l.course = cm.course AND l.module = m.name) AS &amp;quot;Teachers HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_course_modules AS cm&lt;br /&gt;
JOIN mdl_modules AS m on m.id = cm.module&lt;br /&gt;
WHERE cm.course = &#039;%%COURSEID%%&#039;&lt;br /&gt;
GROUP BY cm.module&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Grade and Course Completion Reports==&lt;br /&gt;
===Site-Wide Grade Report with All Items===&lt;br /&gt;
Shows grades for all course items along with course totals for each student. Works with ad-hoc reports or Configurable Reports&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname AS &#039;First&#039; , u.lastname AS &#039;Last&#039;, u.firstname + &#039; &#039; + u.lastname AS &#039;Display Name&#039;, &lt;br /&gt;
c.fullname AS &#039;Course&#039;, &lt;br /&gt;
cc.name AS &#039;Category&#039;,&lt;br /&gt;
&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN gi.itemtype = &#039;course&#039; &lt;br /&gt;
   THEN c.fullname + &#039; Course Total&#039;&lt;br /&gt;
  ELSE gi.itemname&lt;br /&gt;
END AS &#039;Item Name&#039;,&lt;br /&gt;
&lt;br /&gt;
ROUND(gg.finalgrade,2) AS Grade,&lt;br /&gt;
DATEADD(ss,gi.timemodified,&#039;1970-01-01&#039;) AS Time&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_grade_grades AS gg ON gg.userid = u.id&lt;br /&gt;
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid&lt;br /&gt;
JOIN prefix_course_categories as cc ON cc.id = c.category&lt;br /&gt;
&lt;br /&gt;
WHERE  gi.courseid = c.id &lt;br /&gt;
ORDER BY lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
For MySQL users, you&#039;ll need to use the MySQL DATE_ADD function instead of DATEADD. Replace the line&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DATEADD(ss,gi.timemodified,&#039;1970-01-01&#039;) AS Time&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
with&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DATE_ADD(&#039;1970-01-01&#039;, INTERVAL gi.timemodified SECOND) AS Time&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Site-Wide Grade Report with Just Course Totals===&lt;br /&gt;
A second site-wide grade report for all students that just shows course totals. Works with ad-hoc reports or Configurable Reports&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname AS &#039;First&#039; , u.lastname AS &#039;Last&#039;, u.firstname + &#039; &#039; + u.lastname AS &#039;Display Name&#039;, &lt;br /&gt;
cc.name AS &#039;Category&#039;,&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN gi.itemtype = &#039;course&#039; &lt;br /&gt;
   THEN c.fullname + &#039; Course Total&#039;&lt;br /&gt;
  ELSE gi.itemname&lt;br /&gt;
END AS &#039;Item Name&#039;,&lt;br /&gt;
&lt;br /&gt;
ROUND(gg.finalgrade,2) AS Grade,&lt;br /&gt;
DATEADD(ss,gg.timemodified,&#039;1970-01-01&#039;) AS Time&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_grade_grades AS gg ON gg.userid = u.id&lt;br /&gt;
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid&lt;br /&gt;
JOIN prefix_course_categories as cc ON cc.id = c.category&lt;br /&gt;
&lt;br /&gt;
WHERE  gi.courseid = c.id AND gi.itemtype = &#039;course&#039;&lt;br /&gt;
&lt;br /&gt;
ORDER BY lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For MySQL users:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname AS &#039;First&#039; , u.lastname AS &#039;Last&#039;, CONCAT(u.firstname , &#039; &#039; , u.lastname) AS &#039;Display Name&#039;, &lt;br /&gt;
c.fullname AS &#039;Course&#039;, &lt;br /&gt;
cc.name AS &#039;Category&#039;,&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN gi.itemtype = &#039;course&#039; &lt;br /&gt;
   THEN CONCAT(c.fullname, &#039; - Total&#039;)&lt;br /&gt;
  ELSE gi.itemname&lt;br /&gt;
END AS &#039;Item Name&#039;,&lt;br /&gt;
&lt;br /&gt;
ROUND(gg.finalgrade,2) AS Grade,&lt;br /&gt;
FROM_UNIXTIME(gg.timemodified) AS TIME&lt;br /&gt;
 &lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_grade_grades AS gg ON gg.userid = u.id&lt;br /&gt;
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
 &lt;br /&gt;
WHERE  gi.courseid = c.id &lt;br /&gt;
ORDER BY lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Learner report by Learner with grades===&lt;br /&gt;
Which Learners in which course and what are the grades&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname AS &#039;Name&#039; , u.lastname AS &#039;Surname&#039;, c.fullname AS &#039;Course&#039;, cc.name AS &#039;Category&#039;, &lt;br /&gt;
CASE WHEN gi.itemtype = &#039;Course&#039;    &lt;br /&gt;
THEN c.fullname + &#039; Course Total&#039;  &lt;br /&gt;
ELSE gi.itemname &lt;br /&gt;
END AS &#039;Item Name&#039;, ROUND(gg.finalgrade,2) AS Score,ROUND(gg.rawgrademax,2) AS Max, ROUND(gg.finalgrade / gg.rawgrademax * 100 ,2) as Percentage,&lt;br /&gt;
&lt;br /&gt;
if (ROUND(gg.finalgrade / gg.rawgrademax * 100 ,2) &amp;gt; 79,&#039;Yes&#039; , &#039;No&#039;) as Pass&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c &lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid &lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id &lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid &lt;br /&gt;
JOIN prefix_grade_grades AS gg ON gg.userid = u.id &lt;br /&gt;
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid &lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category &lt;br /&gt;
WHERE  gi.courseid = c.id and gi.itemname != &#039;Attendance&#039;&lt;br /&gt;
ORDER BY `Name` ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===User Course Completion===&lt;br /&gt;
&lt;br /&gt;
A very simple report with list of course completion status by username. Completions are noted by date, blank otherwise. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, c.shortname,  &lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(p.timecompleted&lt;br /&gt;
),&#039;%Y-%m-%d&#039;) &lt;br /&gt;
AS completed&lt;br /&gt;
FROM prefix_course_completions AS p&lt;br /&gt;
JOIN prefix_course AS c ON p.course = c.id&lt;br /&gt;
JOIN prefix_user AS u ON p.userid = u.id&lt;br /&gt;
WHERE c.enablecompletion = 1&lt;br /&gt;
ORDER BY u.username&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===User Course Completion with Criteria===&lt;br /&gt;
&lt;br /&gt;
A report with course completions by username, with Aggregation method, Criteria types, and Criteria detail where available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username AS user, &lt;br /&gt;
c.shortname AS course,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(t.timecompleted),&#039;%Y-%m-%d&#039;) AS completed,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN (SELECT a.method FROM prefix_course_completion_aggr_methd AS a  WHERE (a.course = c.id AND a.criteriatype IS NULL) = 1) THEN &amp;quot;Any&amp;quot;&lt;br /&gt;
ELSE &amp;quot;All&amp;quot;&lt;br /&gt;
END AS aggregation,&lt;br /&gt;
CASE &lt;br /&gt;
WHEN p.criteriatype = 1 THEN &amp;quot;Self&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 2 THEN &amp;quot;By Date&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 3 THEN &amp;quot;Unenrol Status&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 4 THEN &amp;quot;Activity&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 5 THEN &amp;quot;Duration&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 6 THEN &amp;quot;Course Grade&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 7 THEN &amp;quot;Approve by Role&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 8 THEN &amp;quot;Previous Course&amp;quot;&lt;br /&gt;
END AS criteriatype,&lt;br /&gt;
CASE &lt;br /&gt;
WHEN p.criteriatype = 1 THEN &amp;quot;*&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 2 THEN DATE_FORMAT(FROM_UNIXTIME(p.timeend),&#039;%Y-%m-%d&#039;)&lt;br /&gt;
WHEN p.criteriatype = 3 THEN t.unenroled&lt;br /&gt;
WHEN p.criteriatype = 4 THEN &lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/&#039;,p.module,&#039;/view.php?id=&#039;,p.moduleinstance,&#039;&amp;quot;&amp;gt;&#039;,p.module,&#039;&amp;lt;/a&amp;gt;&#039;)&lt;br /&gt;
WHEN p.criteriatype = 5 THEN p.enrolperiod&lt;br /&gt;
WHEN p.criteriatype = 6 THEN CONCAT(&#039;Needed: &#039;,ROUND(p.gradepass,2),&#039; Achieved: &#039;,ROUND(t.gradefinal,2)) &lt;br /&gt;
WHEN p.criteriatype = 7 THEN p.role&lt;br /&gt;
WHEN p.criteriatype = 8 THEN (SELECT pc.shortname FROM prefix_course AS pc WHERE pc.id = p.courseinstance)&lt;br /&gt;
END AS criteriadetail &lt;br /&gt;
FROM prefix_course_completion_crit_compl AS t&lt;br /&gt;
JOIN prefix_user AS u ON t.userid = u.id&lt;br /&gt;
JOIN prefix_course AS c ON t.course = c.id&lt;br /&gt;
JOIN prefix_course_completion_criteria AS p ON t.criteriaid = p.id&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Courses with Completion Enabled and their settings===&lt;br /&gt;
&lt;br /&gt;
List of all courses with completion enabled and their Aggregation setting, Criteria types, and Criteria details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT c.shortname AS Course, &lt;br /&gt;
CASE&lt;br /&gt;
WHEN (SELECT a.method FROM prefix_course_completion_aggr_methd AS a  WHERE (a.course = t.course AND a.criteriatype IS NULL)) = 2 THEN &amp;quot;All&amp;quot;&lt;br /&gt;
ELSE &amp;quot;Any&amp;quot;&lt;br /&gt;
END AS Course_Aggregation,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN t.criteriatype = 1 THEN &amp;quot;Self completion&amp;quot;&lt;br /&gt;
WHEN t.criteriatype = 2 THEN &amp;quot;Date done by&amp;quot; &lt;br /&gt;
WHEN t.criteriatype = 3 THEN &amp;quot;Unenrolement&amp;quot; &lt;br /&gt;
WHEN t.criteriatype = 4 THEN &amp;quot;Activity completion&amp;quot;   &lt;br /&gt;
WHEN t.criteriatype = 5 THEN &amp;quot;Duration in days&amp;quot; &lt;br /&gt;
WHEN t.criteriatype = 6 THEN &amp;quot;Final grade&amp;quot;     &lt;br /&gt;
WHEN t.criteriatype = 7 THEN &amp;quot;Approve by role&amp;quot; &lt;br /&gt;
WHEN t.criteriatype = 8 THEN &amp;quot;Previous course&amp;quot;&lt;br /&gt;
END AS Criteria_type,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN t.criteriatype = 1 THEN &amp;quot;On&amp;quot;&lt;br /&gt;
WHEN t.criteriatype = 2 THEN DATE_FORMAT(FROM_UNIXTIME(t.timeend),&#039;%Y-%m-%d&#039;)&lt;br /&gt;
WHEN t.criteriatype = 3 THEN &amp;quot;On&amp;quot;&lt;br /&gt;
WHEN t.criteriatype = 4 THEN&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/&#039;,t.module,&#039;/view.php?id=&#039;,t.moduleinstance,&#039;&amp;quot;&amp;gt;&#039;,t.module,&#039;&amp;lt;/a&amp;gt;&#039;)&lt;br /&gt;
WHEN t.criteriatype = 5 THEN ROUND(t.enrolperiod/86400)&lt;br /&gt;
WHEN t.criteriatype = 6 THEN ROUND(t.gradepass,2)&lt;br /&gt;
WHEN t.criteriatype = 7 THEN (SELECT r.shortname FROM prefix_role AS r WHERE r.id = t.role)&lt;br /&gt;
WHEN t.criteriatype = 8 THEN (SELECT pc.shortname FROM prefix_course AS pc WHERE pc.id = t.courseinstance)&lt;br /&gt;
END AS Criteria_detail&lt;br /&gt;
FROM prefix_course_completion_criteria as t&lt;br /&gt;
JOIN prefix_course AS c ON t.course = c.id&lt;br /&gt;
WHERE c.enablecompletion = 1&lt;br /&gt;
ORDER BY course&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Course Completion Report with custom dates===&lt;br /&gt;
&lt;br /&gt;
List of users who completed multiple or single course/s from a start date to end date chosen by the user. The output gives username, name, course name, completion date and score&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT u.username AS &#039;User Name&#039;,&lt;br /&gt;
CONCAT(u.firstname , &#039; &#039; , u.lastname) AS &#039;Name&#039;,&lt;br /&gt;
c.shortname AS &#039;Course Name&#039;, &lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(p.timecompleted),&#039;%W %e %M, %Y&#039;) AS &#039;Completed Date&#039;,&lt;br /&gt;
ROUND(c4.gradefinal,2) AS &#039;Score&#039;&lt;br /&gt;
FROM prefix_course_completions AS p&lt;br /&gt;
JOIN prefix_course AS c ON p.course = c.id&lt;br /&gt;
JOIN prefix_user AS u ON p.userid = u.id&lt;br /&gt;
JOIN prefix_course_completion_crit_compl AS c4 ON u.id = c4.userid&lt;br /&gt;
WHERE c.enablecompletion = 1  AND (p.timecompleted IS NOT NULL OR p.timecompleted !=&#039;&#039;) &lt;br /&gt;
AND (p.timecompleted&amp;gt;= :start_date AND p.timecompleted&amp;lt;=:end_date)&lt;br /&gt;
GROUP BY u.username&lt;br /&gt;
ORDER BY c.shortname&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Scales used in activities===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT scale.name&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/&#039;,gi.itemmodule,&#039;/view.php?id=&#039;,cm.id,&#039;&amp;quot;&amp;gt;&#039;,gi.itemname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;Module View&amp;quot;&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/modedit.php?up&#039;,&#039;date=&#039;,cm.id,&#039;&amp;quot;&amp;gt;&#039;,gi.itemname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;Module Settings&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_grade_items AS gi&lt;br /&gt;
JOIN prefix_course AS c ON c.id = gi.courseid&lt;br /&gt;
JOIN prefix_course_modules AS cm ON cm.course = gi.courseid AND cm.instance = gi.iteminstance&lt;br /&gt;
JOIN prefix_scale AS scale ON scale.id = gi.scaleid&lt;br /&gt;
WHERE gi.scaleid IS NOT NULL&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Activity Module Reports==&lt;br /&gt;
&lt;br /&gt;
===How many SCORM activities are used in each Course===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT cm.course,c.fullname ,m.name &lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/scorm/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,count(cm.id),&#039;&amp;lt;/a&amp;gt;&#039;) AS Counter&lt;br /&gt;
 &lt;br /&gt;
FROM `prefix_course_modules` as cm &lt;br /&gt;
  JOIN prefix_modules as m ON cm.module=m.id &lt;br /&gt;
  JOIN prefix_course as c ON cm.course = c.id &lt;br /&gt;
WHERE m.name LIKE &#039;%scorm%&#039; &lt;br /&gt;
GROUP BY cm.course,cm.module &lt;br /&gt;
ORDER BY count(cm.id) desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed ACTIONs for each MODULE===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT module,action,count(id) as counter&lt;br /&gt;
FROM prefix_log&lt;br /&gt;
GROUP BY module,action&lt;br /&gt;
ORDER BY module,counter desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Most popular ACTIVITY===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, module&lt;br /&gt;
FROM prefix_log l&lt;br /&gt;
WHERE module != &#039;login&#039; AND module != &#039;course&#039; AND module != &#039;role&#039;&lt;br /&gt;
GROUP BY module&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System wide use of ACTIVITIES and RESOURCES===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT count( cm.id ) AS counter, m.name&lt;br /&gt;
FROM `prefix_course_modules` AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
GROUP BY cm.module&lt;br /&gt;
ORDER BY counter DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===LOG file ACTIONS per MODULE per COURSE (IDs)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select course,module,action,count(action) as summa from prefix_log&lt;br /&gt;
where action &amp;lt;&amp;gt; &#039;new&#039;&lt;br /&gt;
group by course,action,module&lt;br /&gt;
order by course,module,action&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System Wide usage count of various course Activities===&lt;br /&gt;
(Tested and works fine in Moodle 2.x)&lt;br /&gt;
Like: Forum, Wiki, Blog, Assignment, Database,&lt;br /&gt;
#Within specific category&lt;br /&gt;
#Teacher name in course&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher &lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;) AS Wikis&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%blog%&#039;) AS Blogs&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%forum%&#039;) AS Forums&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%data%&#039;) AS Databses&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%assignment%&#039;) AS Assignments&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
WHERE c.category IN ( 18)&lt;br /&gt;
ORDER BY Wikis DESC,Blogs DESC, Forums DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Course wiki usage/activity over the last 6 semesters===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &amp;quot;Courses with Wikis&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;2010&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%Semester A%&#039;) AS &#039;2010 &amp;lt;br/&amp;gt; Semester A&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;2010&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%Semester B%&#039;) AS &#039;2010 &amp;lt;br/&amp;gt; Semester B&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעא&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר א%&#039;) AS &#039;תשעא &amp;lt;br/&amp;gt; סמסטר א&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעא&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר ב%&#039;) AS &#039;תשעא &amp;lt;br/&amp;gt; סמסטר ב&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעב&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר א%&#039;) AS &#039;תשעב &amp;lt;br/&amp;gt; סמסטר א&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעב&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר ב%&#039;) AS &#039;תשעב &amp;lt;br/&amp;gt; סמסטר ב&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעג&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר א%&#039;) AS &#039;תשעג &amp;lt;br/&amp;gt; סמסטר א&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעג&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר ב%&#039;) AS &#039;תשעג &amp;lt;br/&amp;gt; סמסטר ב&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed WIKI activity (per wiki per course)===&lt;br /&gt;
Including Number of Students in course (for reference)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,cm.course,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as CourseID  &lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id ) AS Students&lt;br /&gt;
,m.name&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%updat%&#039; ) as &#039;UPDAT E&#039;&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%annotate%&#039; ) as ANNOTATE&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%comment%&#039; ) as COMMENT&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%add%&#039; ) as &#039;A DD&#039;&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%edit%&#039; ) as EDIT&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action NOT LIKE &#039;%view%&#039; ) as &#039;All (NO View)&#039;&lt;br /&gt;
FROM `prefix_course_modules` as cm &lt;br /&gt;
JOIN prefix_modules as m ON cm.module=m.id &lt;br /&gt;
JOIN prefix_course as c ON cm.course = c.id &lt;br /&gt;
WHERE m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
GROUP BY cm.course,cm.module&lt;br /&gt;
ORDER BY &#039;All (NO View)&#039; DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Wiki usage, system wide===&lt;br /&gt;
(you can filter the output by selecting some specific course categories : &amp;quot;WHERE c.category IN ( 8,13,15)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;) AS Wikis&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039;) AS &#039;WikiActivity&amp;lt;br/&amp;gt;ALL&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039; and l.action LIKE &#039;%add%&#039; ) AS &#039;WikiActivity&amp;lt;br/&amp;gt;ADD&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039; and l.action LIKE &#039;%edit%&#039; ) AS &#039;WikiActivity&amp;lt;br/&amp;gt;EDIT&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039; and l.action LIKE &#039;%annotate%&#039; ) AS &#039;WikiActivity&amp;lt;br/&amp;gt;ANNOTATE&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039; and l.action LIKE &#039;%comments%&#039; ) AS &#039;WikiActivity&amp;lt;br/&amp;gt;Comments&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_ouwiki_pages as ouwp&lt;br /&gt;
JOIN prefix_ouwiki as ouw ON ouw.id = ouwp.subwikiid&lt;br /&gt;
WHERE ouw.course = c.id GROUP BY ouw.course  ) as OUWikiPages&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( DISTINCT nwp.pagename ) FROM prefix_wiki_pages AS nwp&lt;br /&gt;
JOIN prefix_wiki AS nw ON nw.id = nwp.dfwiki WHERE nw.course = c.id ) As NWikiPages&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
WHERE c.category IN ( 8,13,15)&lt;br /&gt;
HAVING Wikis &amp;gt; 0&lt;br /&gt;
ORDER BY &#039;WikiActivity&amp;lt;br/&amp;gt;ALL&#039; DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Aggregated Teacher activity by &amp;quot;WEB2&amp;quot; Modules===&lt;br /&gt;
(Tested and works fine in Moodle 2.x)&lt;br /&gt;
The NV column shows activity without VIEW log activity&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT ra.userid, u.firstname,u.lastname&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%wiki%&#039;) AS Wiki&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%wiki%&#039; AND l.action NOT LIKE &#039;%view%&#039;) AS Wiki_NV&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%forum%&#039;) AS Forum&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%forum%&#039; AND l.action NOT LIKE &#039;%view%&#039;) AS Forum_NV&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%blog%&#039;) AS Blog&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%blog%&#039; AND l.action NOT LIKE &#039;%view%&#039;) AS Blog_NV&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%assignment%&#039;) AS Assignment&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%assignment%&#039; AND l.action NOT LIKE &#039;%view%&#039;) AS Assignment_NV&lt;br /&gt;
FROM prefix_role_assignments AS ra &lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid &lt;br /&gt;
WHERE ra.roleid = 3 &lt;br /&gt;
GROUP BY ra.userid&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all the certificates issued, sort by variables in the custom profile fields===&lt;br /&gt;
Note: The SQL queries look intimidating at first, but isn&#039;t really that difficult to learn. I&#039;ve seen in the forums that users wanted to do &#039;site-wide&#039; groups in 1.9x. This is sort of the idea. It pulls all the certificates issued to all users sorted by the custom profile fields, which in my case is the Units or Depts (i.e. my site wide groups). Why certificates? I&#039;ve explored with both grades and quizzes, the course admins are not really interested in the actual grades but whether the learner received a certificate (i.e. passed the course with x, y, z activities). It also saves me from creating groups and assigning them into the right groups. Even assigning in bulk is not efficient, since I have upward of 25 groups per course and constantly new learners enrolling in courses. The limitation is something to do with the server? as it only pull 5000 rows of data. If anyone figured out how to change this, please let me know. In the meantime, the work around is to pull only a few units/depts at a time to limit the number of rows. This is fine at the moment, since each course admin are only responsible for certain units/depts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME(prefix_certificate_issues.timecreated), &#039;%Y-%m-%d&#039; ) AS Date,&lt;br /&gt;
prefix_certificate_issues.classname AS Topic,&lt;br /&gt;
prefix_certificate.name AS Certificate,&lt;br /&gt;
prefix_certificate_issues.studentname as Name,&lt;br /&gt;
prefix_user_info_data.data AS Units&lt;br /&gt;
&lt;br /&gt;
FROM&lt;br /&gt;
prefix_certificate_issues&lt;br /&gt;
&lt;br /&gt;
INNER JOIN prefix_user_info_data&lt;br /&gt;
on prefix_certificate_issues.userid = prefix_user_info_data.userid&lt;br /&gt;
&lt;br /&gt;
INNER JOIN prefix_certificate&lt;br /&gt;
on prefix_certificate_issues.certificateid = prefix_certificate.id&lt;br /&gt;
&lt;br /&gt;
WHERE prefix_user_info_data.data=&#039;Unit 1&#039;&lt;br /&gt;
OR prefix_user_info_data.data=&#039;Unit 2&#039;&lt;br /&gt;
OR prefix_user_info_data.data=&#039;Unit 3&#039;&lt;br /&gt;
&lt;br /&gt;
ORDER BY Units, Name, Topic ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Counter Blog usage in Courses,system wide===&lt;br /&gt;
What teachers in what courses, uses blogs and how many + student count in that course.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT ( @counter := @counter+1) as counter, &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user AS u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = c.id AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%blog%&#039;) AS Blogs&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c, (SELECT @counter := 0) as s_init&lt;br /&gt;
WHERE c.category IN ( 8,13,15)&lt;br /&gt;
HAVING Blogs &amp;gt; 0&lt;br /&gt;
ORDER BY Blogs DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Elluminate (Blackboard Collaborate) - system wide usage===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT e.name As Session ,er.recordingsize&lt;br /&gt;
,c.fullname As Course&lt;br /&gt;
,u.firstname,u.lastname &lt;br /&gt;
,DATE_FORMAT(FROM_UNIXTIME(e.timestart),&#039;%d-%m-%Y&#039;) AS dTimeStart&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/moodle/mod/elluminate/loadrecording.php?id=&#039;,er.id,&#039;&amp;quot;&amp;gt;Show&amp;lt;/a&amp;gt;&#039;) AS RecordedSession&lt;br /&gt;
&lt;br /&gt;
FROM prefix_elluminate_recordings AS er&lt;br /&gt;
JOIN prefix_elluminate AS e ON e.meetingid = er.meetingid&lt;br /&gt;
JOIN prefix_course as c ON c.id = e.course&lt;br /&gt;
JOIN prefix_user AS u ON u.id = e.creator &lt;br /&gt;
ORDER BY er.recordingsize DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Choice ===&lt;br /&gt;
&lt;br /&gt;
Results of the Choice activity. For all courses, shows course shortname, username, the Choice text, and the answer chosen by the user.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname AS course, u.username, h.name as question, o.text AS answer&lt;br /&gt;
FROM prefix_choice AS h&lt;br /&gt;
JOIN prefix_course AS c ON h.course = c.id&lt;br /&gt;
JOIN prefix_choice_answers AS a ON h.id = a.choiceid&lt;br /&gt;
JOIN prefix_user AS u ON a.userid = u.id&lt;br /&gt;
JOIN prefix_choice_options AS o ON a.optionid = o.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Assignment type usage in courses ===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/assign/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;List assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_assign WHERE c.id = course) AS Assignments&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;file&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
#GROUP BY apc.plugin&lt;br /&gt;
) AS &amp;quot;File Assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;onlinetext&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
) AS &amp;quot;Online Assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;pdf&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
) AS &amp;quot;PDF Assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;offline&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
) AS &amp;quot;Offline Assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;comments&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
) AS &amp;quot;Assignments Comments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_assign AS assign&lt;br /&gt;
JOIN prefix_course AS c ON c.id = assign.course&lt;br /&gt;
GROUP BY c.id &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Assignment Module Reports==&lt;br /&gt;
===All Ungraded Assignments===&lt;br /&gt;
Returns all the submitted assignments that still need grading&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
u.firstname AS &amp;quot;First&amp;quot;,&lt;br /&gt;
u.lastname AS &amp;quot;Last&amp;quot;,&lt;br /&gt;
c.fullname AS &amp;quot;Course&amp;quot;,&lt;br /&gt;
a.name AS &amp;quot;Assignment&amp;quot;&lt;br /&gt;
&lt;br /&gt;
from prefix_assignment_submissions as asb&lt;br /&gt;
join prefix_assignment as a ON a.id = asb.assignment&lt;br /&gt;
join prefix_user as u ON u.id = asb.userid&lt;br /&gt;
join prefix_course as c ON c.id = a.course&lt;br /&gt;
join prefix_course_modules as cm ON c.id = cm.course&lt;br /&gt;
&lt;br /&gt;
where asb.grade &amp;lt; 0 and cm.instance = a.id&lt;br /&gt;
and cm.module = 1&lt;br /&gt;
&lt;br /&gt;
order by c.fullname, a.name, u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All Ungraded Assignments w/ Link===&lt;br /&gt;
Returns all the submitted assignments that still need grading, along with a link that goes directly to the submission to grade it. The links work if you view the report within Moodle.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
u.firstname AS &amp;quot;First&amp;quot;,&lt;br /&gt;
u.lastname AS &amp;quot;Last&amp;quot;,&lt;br /&gt;
c.fullname AS &amp;quot;Course&amp;quot;,&lt;br /&gt;
a.name AS &amp;quot;Assignment&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
&#039;&amp;lt;a href=&amp;quot;http://education.varonis.com/mod/assignment/submissions.php&#039; + char(63) +&lt;br /&gt;
+ &#039;id=&#039; + cast(cm.id as varchar) + &#039;&amp;amp;userid=&#039; + cast(u.id as varchar) &lt;br /&gt;
+ &#039;&amp;amp;mode=single&amp;amp;filter=0&amp;amp;offset=2&amp;quot;&amp;gt;&#039; + a.name + &#039;&amp;lt;/a&amp;gt;&#039;&lt;br /&gt;
AS &amp;quot;Assignmentlink&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
from prefix_assignment_submissions as asb&lt;br /&gt;
join prefix_assignment as a ON a.id = asb.assignment&lt;br /&gt;
join prefix_user as u ON u.id = asb.userid&lt;br /&gt;
join prefix_course as c ON c.id = a.course&lt;br /&gt;
join prefix_course_modules as cm ON c.id = cm.course&lt;br /&gt;
&lt;br /&gt;
where asb.grade &amp;lt; 0 and cm.instance = a.id and cm.module = 1&lt;br /&gt;
&lt;br /&gt;
order by c.fullname, a.name, u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Assignments (and Quizzes) waiting to be graded===&lt;br /&gt;
This report requires a YEAR filter to be added (Available when using the latest block/configurable_reports)&lt;br /&gt;
&lt;br /&gt;
Which you can always remove, to make this query work on earlier versions.&lt;br /&gt;
&lt;br /&gt;
The report includes: &lt;br /&gt;
*number of quizzes&lt;br /&gt;
*unFinished Quiz attempts&lt;br /&gt;
*Finished Quiz attempts&lt;br /&gt;
*number of students&lt;br /&gt;
*number of Assignments&lt;br /&gt;
*number of submitted answers by students &lt;br /&gt;
*number of unchecked assignments (waiting for the Teacher) in a Course.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher &lt;br /&gt;
 &lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/assignment/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;מטלות&amp;lt;/a&amp;gt;&#039;) AS Assignments&lt;br /&gt;
&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/quiz/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;בחנים&amp;lt;/a&amp;gt;&#039;) AS &#039;Quizzes&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_course_modules cm &lt;br /&gt;
JOIN prefix_modules as m ON m.id = cm.module &lt;br /&gt;
WHERE m.name LIKE &#039;quiz&#039; AND cm.course = c.id &lt;br /&gt;
GROUP BY cm.course &lt;br /&gt;
) AS &#039;nQuizzes&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM prefix_quiz_attempts AS qa&lt;br /&gt;
JOIN prefix_quiz AS q ON q.id = qa.quiz&lt;br /&gt;
WHERE q.course = c.id&lt;br /&gt;
AND qa.timefinish = 0&lt;br /&gt;
GROUP BY q.course) AS &#039;unFinished Quiz attempts&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM prefix_quiz_attempts AS qa&lt;br /&gt;
JOIN prefix_quiz AS q ON q.id = qa.quiz&lt;br /&gt;
WHERE q.course = c.id&lt;br /&gt;
AND qa.timefinish &amp;gt; 0&lt;br /&gt;
GROUP BY q.course) AS &#039;finished quiz attempts&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS nStudents&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
,(&lt;br /&gt;
SELECT count(a.id)&lt;br /&gt;
FROM prefix_assignment AS a &lt;br /&gt;
JOIN prefix_course_modules AS cm ON a.course = cm.course &lt;br /&gt;
WHERE cm.instance = a.id AND cm.module = 1 AND a.course = c.id&lt;br /&gt;
) nAssignments&lt;br /&gt;
&lt;br /&gt;
,(&lt;br /&gt;
SELECT count(*)&lt;br /&gt;
FROM prefix_assignment AS a &lt;br /&gt;
WHERE a.course = c.id AND FROM_UNIXTIME(a.timedue) &amp;gt; NOW()&lt;br /&gt;
GROUP BY a.course&lt;br /&gt;
) &#039;Open &amp;lt;br/&amp;gt;Assignments&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(ROUND( (100 / iAssignments ) * iOpenAssignments ) ,&#039;%&#039;) &#039;unFinished &amp;lt;br/&amp;gt;Assignments &amp;lt;br/&amp;gt;(percent)&#039;&lt;br /&gt;
 &lt;br /&gt;
,(&lt;br /&gt;
SELECT count(asb.id)&lt;br /&gt;
FROM prefix_assignment_submissions AS asb&lt;br /&gt;
JOIN prefix_assignment AS a ON a.id = asb.assignment&lt;br /&gt;
JOIN prefix_course_modules AS cm ON a.course = cm.course &lt;br /&gt;
WHERE asb.grade &amp;lt; 0 AND cm.instance = a.id AND cm.module = 1 AND a.course = c.id&lt;br /&gt;
) &#039;unChecked  &amp;lt;br/&amp;gt;Submissions&#039; &lt;br /&gt;
 &lt;br /&gt;
,(&lt;br /&gt;
SELECT count(asb.id)&lt;br /&gt;
FROM prefix_assignment_submissions AS asb&lt;br /&gt;
JOIN prefix_assignment AS a ON a.id = asb.assignment&lt;br /&gt;
JOIN prefix_course_modules AS cm ON a.course = cm.course &lt;br /&gt;
WHERE cm.instance = a.id AND cm.module = 1 AND a.course = c.id&lt;br /&gt;
) &#039;Submitted  &amp;lt;br/&amp;gt;Assignments&#039;&lt;br /&gt;
 &lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
LEFT JOIN (&lt;br /&gt;
SELECT course, count(*) AS iAssignments&lt;br /&gt;
FROM prefix_assignment AS a &lt;br /&gt;
GROUP BY a.course &lt;br /&gt;
) AS tblAssignmentsCount ON tblAssignmentsCount.course = c.id&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN (&lt;br /&gt;
SELECT course, count(*) AS iOpenAssignments&lt;br /&gt;
FROM prefix_assignment AS a &lt;br /&gt;
WHERE FROM_UNIXTIME(a.timedue) &amp;gt; NOW()&lt;br /&gt;
GROUP BY a.course &lt;br /&gt;
) AS tblOpenAssignmentsCount ON tblOpenAssignmentsCount.course = c.id&lt;br /&gt;
&lt;br /&gt;
WHERE 1=1  &lt;br /&gt;
#AND c.fullname LIKE &#039;%תשעג%&#039;&lt;br /&gt;
%%FILTER_YEARS:c.fullname%%&lt;br /&gt;
## You can enable the SEMESTER filter as well, &lt;br /&gt;
## by uncommenting the following line:&lt;br /&gt;
## %%FILTER_SEMESTERS:c.fullname%%&lt;br /&gt;
ORDER BY &#039;Open &amp;lt;br/&amp;gt;Assignments&#039; DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Who is using &amp;quot;Single File Upload&amp;quot; assignment===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
 &lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher &lt;br /&gt;
&lt;br /&gt;
,ass.name as &amp;quot;Assignment Name&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM &lt;br /&gt;
prefix_assignment as ass&lt;br /&gt;
&lt;br /&gt;
JOIN &lt;br /&gt;
prefix_course as c ON c.id = ass.course&lt;br /&gt;
&lt;br /&gt;
WHERE `assignmenttype` LIKE &#039;uploadsingle&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resource Module Reports==&lt;br /&gt;
===List &amp;quot;Recently uploaded files&amp;quot;===&lt;br /&gt;
see what users are uploading&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT FROM_UNIXTIME(time,&#039;%Y %M %D %h:%i:%s&#039;) as time ,ip,userid,url,info  &lt;br /&gt;
FROM `prefix_log` &lt;br /&gt;
WHERE `action` LIKE &#039;upload&#039; &lt;br /&gt;
ORDER BY `prefix_log`.`time`  DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List Courses that loaded a specific file: &amp;quot;X&amp;quot;===&lt;br /&gt;
Did the Teacher (probably) uploaded course&#039;s Syllabus ?&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.id, c.fullname  FROM `prefix_log` as l &lt;br /&gt;
JOIN prefix_course as c ON c.id = l.course &lt;br /&gt;
WHERE `action` LIKE &#039;%upload%&#039; AND ( info LIKE &#039;%Syllabus%&#039; OR info LIKE &#039;%Sylabus%&#039; ) GROUP BY c.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All resources that link to some specific external website===&lt;br /&gt;
+ link to course&lt;br /&gt;
+ who&#039;s the teacher&lt;br /&gt;
+ link to external resource&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,c.shortname,r.name&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/resource/view.php?id=&#039;,r.id,&#039;&amp;quot;&amp;gt;&#039;,r.name,&#039;&amp;lt;/a&amp;gt;&#039;) AS Resource&lt;br /&gt;
FROM prefix_resource AS r &lt;br /&gt;
JOIN prefix_course AS c ON r.course = c.id&lt;br /&gt;
WHERE r.reference LIKE &#039;http://info.oranim.ac.il/home%&#039; &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===&amp;quot;Compose Web Page&amp;quot; RESOURCE count===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT course,prefix_course.fullname, COUNT(*) AS Total&lt;br /&gt;
FROM `prefix_resource`&lt;br /&gt;
JOIN `prefix_course` ON prefix_course.id = prefix_resource.course&lt;br /&gt;
WHERE type=&#039;html&#039;&lt;br /&gt;
GROUP BY course&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Resource count in courses===&lt;br /&gt;
+ (First)Teacher name&lt;br /&gt;
+ Where course is inside some specific Categories&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
COUNT(*) AS count&lt;br /&gt;
,r.course &lt;br /&gt;
,c.shortname shortname&lt;br /&gt;
,c.fullname coursename&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user as u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = r.course AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
FROM prefix_resource r &lt;br /&gt;
JOIN prefix_course c ON r.course = c.id&lt;br /&gt;
WHERE c.category IN (10,13,28,18,26)&lt;br /&gt;
GROUP BY r.course&lt;br /&gt;
ORDER BY COUNT(*) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Forum Module Reports==&lt;br /&gt;
===print all User&#039;s post in course Forums===&lt;br /&gt;
@@COURSEID@@ is a variable the is replace by the current CourseID you are running the sql report from. if you are using the latest block/configurable_reports ! (You can always change it to a fixed course or remove it to display all courses.)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/user.php?course=&#039;,c.id,&#039;&amp;amp;id=&#039;,u.id,&#039;&amp;amp;mode=posts&amp;quot;&amp;gt;&#039;,CONCAT(u.firstname,&#039; &#039;, u.lastname),&#039;&amp;lt;/a&amp;gt;&#039;) As Fullname&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/view.php?f=&#039;,fd.forum,&#039;&amp;quot;&amp;gt;&#039;,f.name,&#039;&amp;lt;/a&amp;gt;&#039;) AS Forum&lt;br /&gt;
,count(*) as Posts&lt;br /&gt;
,(SELECT count(*) FROM prefix_forum_discussions AS ifd JOIN prefix_forum as iforum ON iforum.id = ifd.forum  WHERE ifd.userid = fp.userid AND iforum.id = f.id) AS cAllDiscussion&lt;br /&gt;
&lt;br /&gt;
FROM prefix_forum_posts AS fp &lt;br /&gt;
JOIN prefix_user as u ON u.id = fp.userid &lt;br /&gt;
JOIN prefix_forum_discussions AS fd ON fp.discussion = fd.id &lt;br /&gt;
JOIN prefix_forum AS f ON f.id = fd.forum &lt;br /&gt;
JOIN prefix_course as c ON c.id = fd.course &lt;br /&gt;
WHERE fd.course = &#039;@@COURSEID@@&#039; &lt;br /&gt;
GROUP BY f.id,u.id&lt;br /&gt;
ORDER BY u.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===FORUM use Count per COURSE -- not including NEWS Forum!===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT prefix_course.fullname, prefix_forum.course, count(*) as total FROM prefix_forum&lt;br /&gt;
INNER JOIN prefix_course&lt;br /&gt;
ON prefix_course.id = prefix_forum.course&lt;br /&gt;
WHERE NOT(prefix_forum.type = &#039;news&#039;)&lt;br /&gt;
GROUP BY prefix_forum.course&lt;br /&gt;
ORDER BY total desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===FORUM use Count per COURSE by type -- not including NEWS Forum!===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT prefix_course.fullname, prefix_forum.course, prefix_forum.type, count(*) as total FROM prefix_forum&lt;br /&gt;
INNER JOIN prefix_course&lt;br /&gt;
ON prefix_course.id = prefix_forum.course&lt;br /&gt;
WHERE NOT(prefix_forum.type = &#039;news&#039;)&lt;br /&gt;
GROUP BY prefix_forum.course,prefix_forum.type&lt;br /&gt;
ORDER BY total desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Forum activity - system wide===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.id,&#039;&amp;lt;/a&amp;gt;&#039;) AS CourseID&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user AS u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = c.id AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
,c.fullname as Course&lt;br /&gt;
,f.type&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
, fd.forum, f.name,count(*) AS cPostAndDisc&lt;br /&gt;
,(SELECT count(*) FROM prefix_forum_discussions AS ifd WHERE ifd.forum = f.id) AS cDiscussion&lt;br /&gt;
FROM prefix_forum_posts AS fp&lt;br /&gt;
JOIN prefix_forum_discussions AS fd ON fd.id = fp.discussion&lt;br /&gt;
JOIN prefix_forum AS f ON f.id = fd.forum&lt;br /&gt;
JOIN prefix_course AS c ON c.id = f.course&lt;br /&gt;
WHERE f.type != &#039;news&#039; AND c.fullname LIKE &#039;%2013%&#039;&lt;br /&gt;
## WHERE 1=1 &lt;br /&gt;
## %%FILTER_YEARS:c.fullname%%&lt;br /&gt;
## You can enable the SEMESTER filter as well, &lt;br /&gt;
## by uncommenting the following line:&lt;br /&gt;
## %%FILTER_SEMESTERS:c.fullname%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY fd.forum&lt;br /&gt;
ORDER BY count( * ) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Activity In Forums===&lt;br /&gt;
Trying to figure out how much real activity we have in Forums by aggregating:&lt;br /&gt;
Users in Course, Number of Posts, Number of Discussions, Unique student post, Unique student discussions, Number of Teachers , Number of Students, ratio between unique Student posts and the number of students in the Course...&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.fullname,f.name,f.type &lt;br /&gt;
,(SELECT count(id) FROM prefix_forum_discussions as fd WHERE f.id = fd.forum) as Discussions&lt;br /&gt;
,(SELECT count(distinct fd.userid) FROM prefix_forum_discussions as fd WHERE fd.forum = f.id) as UniqueUsersDiscussions&lt;br /&gt;
,(SELECT count(fp.id) FROM prefix_forum_discussions fd JOIN prefix_forum_posts as fp ON fd.id = fp.discussion WHERE f.id = fd.forum) as Posts&lt;br /&gt;
,(SELECT count(distinct fp.userid) FROM prefix_forum_discussions fd JOIN prefix_forum_posts as fp ON fd.id = fp.discussion WHERE f.id = fd.forum) as UniqueUsersPosts&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Students&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS StudentsCount&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Teachers&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid =3&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS &#039;Teacher&amp;lt;br/&amp;gt;Count&#039;&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid IN (3,5)&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS UserCount&lt;br /&gt;
, (SELECT (UniqueUsersDiscussions / StudentsCount )) as StudentDissUsage&lt;br /&gt;
, (SELECT (UniqueUsersPosts /StudentsCount)) as StudentPostUsage&lt;br /&gt;
FROM prefix_forum as f &lt;br /&gt;
JOIN prefix_course as c ON f.course = c.id&lt;br /&gt;
WHERE `type` != &#039;news&#039;&lt;br /&gt;
ORDER BY StudentPostUsage DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All Forum type:NEWS===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT f.id, f.name&lt;br /&gt;
FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_forum AS f ON cm.instance = f.id&lt;br /&gt;
WHERE m.name = &#039;forum&#039;&lt;br /&gt;
AND f.type = &#039;news&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All new forum NEWS items (discussions) from all my Courses===&lt;br /&gt;
change &amp;quot;userid = 26&amp;quot; and &amp;quot;id = 26&amp;quot; to a new user id&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname,f.name,fd.name,FROM_UNIXTIME(fd.timemodified ,&amp;quot;%d %M %Y &amp;quot;) as Date&lt;br /&gt;
FROM prefix_forum_discussions as fd &lt;br /&gt;
JOIN prefix_forum as f ON f.id = fd.forum &lt;br /&gt;
JOIN prefix_course as c ON c.id = f.course &lt;br /&gt;
JOIN prefix_user_lastaccess as ul ON (c.id = ul.courseid AND ul.userid = 26)&lt;br /&gt;
WHERE fd.timemodified &amp;gt; ul.timeaccess  &lt;br /&gt;
 AND fd.forum IN (SELECT f.id&lt;br /&gt;
 FROM prefix_course_modules AS cm&lt;br /&gt;
 JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
 JOIN prefix_forum AS f ON cm.instance = f.id&lt;br /&gt;
 WHERE m.name = &#039;forum&#039;&lt;br /&gt;
 AND f.type = &#039;news&#039;)&lt;br /&gt;
  AND c.id IN (SELECT c.id&lt;br /&gt;
   FROM prefix_course AS c&lt;br /&gt;
   JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
   JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
   JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
   WHERE u.id = 26) ORDER BY `fd`.`timemodified` DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===News Forum - Discussions COUNT===&lt;br /&gt;
Which is actually... How much instructions students get from their teachers&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname ,&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user AS u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = c.id AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/view.php?f=&#039;,fd.forum,&#039;&amp;quot;&amp;gt;&#039;,count(fd.id),&#039;&amp;lt;/a&amp;gt;&#039;) AS DiscussionsSum&lt;br /&gt;
FROM prefix_forum_discussions AS fd&lt;br /&gt;
INNER JOIN prefix_forum AS f ON f.id = fd.forum&lt;br /&gt;
INNER JOIN prefix_course AS c ON c.id = f.course&lt;br /&gt;
WHERE f.type = &#039;news&#039; AND c.category IN (10,13,28,18,26)&lt;br /&gt;
GROUP BY fd.forum&lt;br /&gt;
ORDER BY count(fd.id) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Cantidad de foros que han sido posteados por profesor===&lt;br /&gt;
Queriamos saber cuales son las acciones del profesor dentro de los foros de cada curso, por ello se hizo este informe.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.shortname,&#039;&amp;lt;/a&amp;gt;&#039;) AS curso,&lt;br /&gt;
CONCAT(u.firstname ,&#039; &#039;,u.lastname) AS Facilitador,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT( m.name ) AS COUNT FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%forum%&#039;) AS foros,&lt;br /&gt;
&lt;br /&gt;
COUNT(*) AS Posts&lt;br /&gt;
&lt;br /&gt;
FROM prefix_forum_posts AS fp &lt;br /&gt;
JOIN prefix_forum_discussions AS fd ON fp.discussion = fd.id &lt;br /&gt;
JOIN prefix_forum AS f ON f.id = fd.forum &lt;br /&gt;
JOIN prefix_course AS c ON c.id = fd.course&lt;br /&gt;
JOIN prefix_user AS u ON u.id = fp.userid &lt;br /&gt;
&lt;br /&gt;
WHERE fp.userid =&lt;br /&gt;
(&lt;br /&gt;
select distinct prefix_user.id&lt;br /&gt;
from prefix_user &lt;br /&gt;
join prefix_role_assignments as ra on ra.userid = prefix_user.id &lt;br /&gt;
where ra.roleid = 3 &lt;br /&gt;
and userid = fp.userid&lt;br /&gt;
limit 1&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
and c.shortname like &#039;%2014-2-1%&#039;&lt;br /&gt;
GROUP BY c.id, u.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quiz Module Reports==&lt;br /&gt;
===Generate a list of instructors and their email addresses for those courses that has &amp;quot;essay questions&amp;quot; in their quizzes===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT qu.id AS quiz_id, qu.course AS course_id, qu.questions,&lt;br /&gt;
                co.fullname AS course_fullname, co.shortname AS course_shortname,&lt;br /&gt;
                qu.name AS quiz_name, FROM_UNIXTIME(qu.timeopen) AS quiz_timeopen, FROM_UNIXTIME(qu.timeclose) AS quiz_timeclose,&lt;br /&gt;
                u.firstname, u.lastname, u.email,&lt;br /&gt;
FROM prefix_quiz qu, prefix_course co, prefix_role re, prefix_context ct, prefix_role_assignments ra, prefix_user u&lt;br /&gt;
WHERE FROM_UNIXTIME(timeopen) &amp;gt; &#039;2008-05-14&#039; AND&lt;br /&gt;
                qu.course = co.id AND&lt;br /&gt;
                co.id = ct.instanceid AND&lt;br /&gt;
                ra.roleid = re.id AND&lt;br /&gt;
                re.name = &#039;Teacher&#039; AND&lt;br /&gt;
                ra.contextid = ct.id AND&lt;br /&gt;
                ra.userid = u.id&lt;br /&gt;
 &lt;br /&gt;
SELECT Count(&#039;x&#039;) As NumOfStudents&lt;br /&gt;
                                FROM prefix_role_assignments a&lt;br /&gt;
                                JOIN prefix_user u ON userid = u.id&lt;br /&gt;
                                WHERE roleid = 5 AND contextid = (SELECT id FROM prefix_context WHERE instanceid = 668 AND contextlevel = 50)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Number of Quizes per Course===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT count(*)&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/quiz/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;Link&amp;lt;/a&amp;gt;&#039;) AS Quizes&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course_modules cm&lt;br /&gt;
JOIN prefix_course c ON c.id = cm.course&lt;br /&gt;
JOIN prefix_modules as m ON m.id = cm.module&lt;br /&gt;
WHERE m.name LIKE &#039;quiz&#039;&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all MultiAnswer (Cloze) Questions===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/quiz/attempt.php?q=&#039;, quiz.id, &#039;&amp;quot;&amp;gt;&#039;, quiz.name, &#039;&amp;lt;/a&amp;gt;&#039;) AS Quiz&lt;br /&gt;
,question.id question_id, question.questiontext &lt;br /&gt;
FROM  prefix_question question&lt;br /&gt;
JOIN prefix_quiz_question_instances qqi ON question.id = qqi.question&lt;br /&gt;
JOIN prefix_quiz quiz ON qqi.quiz = quiz.id&lt;br /&gt;
WHERE  `qtype` LIKE  &#039;multianswer&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List courses with MANUAL grades===&lt;br /&gt;
Which is basically and indication to teachers using Moodle to hold offline grades inside Moodle&#039;s Gradebook,&lt;br /&gt;
So grades could be uploaded into an administrative SIS. Use with Configurable Reports.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT( * )&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/grade/edit/tree/index.php?showadvanced=1&amp;amp;id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
FROM  prefix_grade_items AS gi&lt;br /&gt;
JOIN prefix_course as c ON c.id = gi.courseid&lt;br /&gt;
WHERE  `itemtype` =  &#039;manual&#039;&lt;br /&gt;
GROUP BY courseid&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===List the users that did not took the Quiz===&lt;br /&gt;
Do not forget to change &amp;quot;c.id = 14&amp;quot; and q.name LIKE &#039;%quiz name goes here%&#039;&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
user2.id AS ID,&lt;br /&gt;
ul.timeaccess,&lt;br /&gt;
user2.firstname AS Firstname,&lt;br /&gt;
user2.lastname AS Lastname,&lt;br /&gt;
user2.email AS Email,&lt;br /&gt;
user2.username AS IDNumber,&lt;br /&gt;
user2.institution AS Institution,&lt;br /&gt;
 &lt;br /&gt;
IF (user2.lastaccess = 0,&#039;never&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(user2.lastaccess),&#039;%Y-%m-%d&#039;)) AS dLastAccess&lt;br /&gt;
 &lt;br /&gt;
,(SELECT DATE_FORMAT(FROM_UNIXTIME(timeaccess),&#039;%Y-%m-%d&#039;) FROM prefix_user_lastaccess WHERE userid=user2.id AND courseid=c.id) AS CourseLastAccess&lt;br /&gt;
 &lt;br /&gt;
,(SELECT r.name&lt;br /&gt;
FROM  prefix_user_enrolments AS uenrol&lt;br /&gt;
JOIN prefix_enrol AS e ON e.id = uenrol.enrolid&lt;br /&gt;
JOIN prefix_role AS r ON e.id = r.id&lt;br /&gt;
WHERE uenrol.userid=user2.id AND e.courseid = c.id) AS RoleName&lt;br /&gt;
 &lt;br /&gt;
FROM prefix_user_enrolments AS ue&lt;br /&gt;
JOIN prefix_enrol AS e ON e.id = ue.enrolid&lt;br /&gt;
JOIN prefix_course AS c ON c.id = e.courseid&lt;br /&gt;
JOIN prefix_user AS user2 ON user2 .id = ue.userid&lt;br /&gt;
LEFT JOIN prefix_user_lastaccess AS ul ON ul.userid = user2.id&lt;br /&gt;
WHERE c.id=14 and ue.userid NOT IN (SELECT qa.userid FROM prefix_quiz_attempts AS qa&lt;br /&gt;
JOIN prefix_quiz AS q ON qa.quiz = q.id&lt;br /&gt;
JOIN prefix_course AS c ON q.course = c.id&lt;br /&gt;
WHERE c.id = 14 AND q.name LIKE &#039;%quiz name goes here%&#039;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List Questions in each Quiz===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT quiz.id,quiz.name, q.id, q.name&lt;br /&gt;
FROM mdl_quiz AS quiz&lt;br /&gt;
JOIN mdl_question AS q ON FIND_IN_SET(q.id, quiz.questions)&lt;br /&gt;
WHERE quiz.course = %%COURSEID%%&lt;br /&gt;
ORDER BY quiz.id ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==SCORM Activity Reports==&lt;br /&gt;
&lt;br /&gt;
===Lists All completed SCORM activites by Course name===&lt;br /&gt;
This report will list all completed attempts for all SCORM activities. It is ordered first by Course name, then student&#039;s last name, then student&#039;s first name, then attempt number. Please note: the FROM_UNIXTIME command is for MySQL.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname First,u.lastname Last,c.fullname Course, st.attempt Attempt,st.value Status,FROM_UNIXTIME(st.timemodified,&amp;quot;%m-%d-%Y&amp;quot;) Date &lt;br /&gt;
FROM prefix_scorm_scoes_track AS st &lt;br /&gt;
JOIN prefix_user AS u ON st.userid=u.id&lt;br /&gt;
JOIN prefix_scorm AS sc ON sc.id=st.scormid&lt;br /&gt;
JOIN prefix_course AS c ON c.id=sc.course&lt;br /&gt;
WHERE st.value=&#039;completed&#039; &lt;br /&gt;
ORDER BY c.fullname, u.lastname,u.firstname, st.attempt&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Badges==&lt;br /&gt;
&lt;br /&gt;
=== All badges issued, by User ===&lt;br /&gt;
&lt;br /&gt;
This report will show you all the badges on a site that have been issued, both site and all courses, by the username of each user issued a badge. Includes the type of criteria passed (activity, course completion, manual), date issued, date expires, and a direct link to that issued badge page so you can see all the other details for that badge.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, b.name AS badgename, &lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.courseid IS NOT NULL THEN&lt;br /&gt;
(SELECT c.shortname&lt;br /&gt;
    FROM prefix_course AS c&lt;br /&gt;
    WHERE c.id = b.courseid)&lt;br /&gt;
WHEN b.courseid IS NULL THEN &amp;quot;*&amp;quot;&lt;br /&gt;
END AS Context,&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN t.criteriatype = 1 AND t.method = 1 THEN &amp;quot;Activity Completion (All)&amp;quot;&lt;br /&gt;
  WHEN t.criteriatype = 1 AND t.method = 2 THEN &amp;quot;Activity Completion (Any)&amp;quot;&lt;br /&gt;
  WHEN t.criteriatype = 2 AND t.method = 2 THEN &amp;quot;Manual Award&amp;quot;&lt;br /&gt;
  WHEN t.criteriatype = 4 AND t.method = 1 THEN &amp;quot;Course Completion (All)&amp;quot;&lt;br /&gt;
  WHEN t.criteriatype = 4 AND t.method = 2 THEN &amp;quot;Course Completion (Any)&amp;quot;&lt;br /&gt;
  ELSE CONCAT (&#039;Other: &#039;, t.criteriatype)&lt;br /&gt;
END AS Criteriatype,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( d.dateissued ) , &#039;%Y-%m-%d&#039; ) AS dateissued,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( d.dateexpire ), &#039;%Y-%m-%d&#039; ) AS dateexpires,&lt;br /&gt;
CONCAT (&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/badges/badge.php?hash=&#039;,d.uniquehash,&#039;&amp;quot;&amp;gt;link&amp;lt;/a&amp;gt;&#039;) AS Details&lt;br /&gt;
FROM prefix_badge_issued AS d &lt;br /&gt;
JOIN prefix_badge AS b ON d.badgeid = b.id&lt;br /&gt;
JOIN prefix_user AS u ON d.userid = u.id&lt;br /&gt;
JOIN prefix_badge_criteria AS t on b.id = t.badgeid &lt;br /&gt;
WHERE t.criteriatype &amp;lt;&amp;gt; 0&lt;br /&gt;
ORDER BY u.username&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note: the FROM_UNIXTIME command is for MySQL.&lt;br /&gt;
&lt;br /&gt;
=== All badges available in the system, with Earned count ===&lt;br /&gt;
&lt;br /&gt;
Report of all badges in the system, with badge name and description, context, course shortname if a course badge, whether it is active and available, and a count of how many users have been issued that badge.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT b.id, b.name, b.description,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.type = 1 THEN &amp;quot;System&amp;quot;&lt;br /&gt;
WHEN b.type = 2 THEN &amp;quot;Course&amp;quot;&lt;br /&gt;
END AS Context, &lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.courseid IS NOT NULL THEN &lt;br /&gt;
(SELECT c.shortname &lt;br /&gt;
    FROM prefix_course AS c &lt;br /&gt;
    WHERE c.id = b.courseid)&lt;br /&gt;
WHEN b.courseid IS NULL THEN &amp;quot;*&amp;quot;&lt;br /&gt;
END AS Course, &lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.status = 0 OR b.status = 2 THEN &amp;quot;No&amp;quot;&lt;br /&gt;
WHEN b.status = 1 OR b.status = 3 THEN &amp;quot;Yes&amp;quot;&lt;br /&gt;
WHEN b.status = 4 THEN &amp;quot;x&amp;quot;&lt;br /&gt;
END AS Available,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.status = 0 OR b.status = 1 THEN &amp;quot;0&amp;quot;&lt;br /&gt;
WHEN b.status = 2 OR b.status = 3 OR b.status = 4 THEN &lt;br /&gt;
 (SELECT COUNT(*) &lt;br /&gt;
   FROM prefix_badge_issued AS d&lt;br /&gt;
   WHERE d.badgeid = b.id&lt;br /&gt;
 )&lt;br /&gt;
END AS Earned&lt;br /&gt;
FROM prefix_badge AS b&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Badges Leaderboard ===&lt;br /&gt;
&lt;br /&gt;
A simple list of usernames and how many badges they have earned overall.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, (SELECT COUNT(*) FROM prefix_badge_issued AS d WHERE d.userid = u.id) AS earned&lt;br /&gt;
FROM prefix_user AS u&lt;br /&gt;
ORDER BY earned DESC, u.username ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Administrator Reports==&lt;br /&gt;
&lt;br /&gt;
===Config changes in Export friendly form===&lt;br /&gt;
&lt;br /&gt;
The Administrative report Config changes is very useful but it would be nice to have it in a format that could be easily exported in one listing. Here is code to do that.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( g.timemodified ) , &#039;%Y-%m-%d&#039; ) AS date, &lt;br /&gt;
u.username AS user, &lt;br /&gt;
g.name AS setting, &lt;br /&gt;
CASE &lt;br /&gt;
 WHEN g.plugin IS NULL THEN &amp;quot;core&amp;quot;&lt;br /&gt;
 ELSE g.plugin&lt;br /&gt;
END AS plugin, &lt;br /&gt;
g.value AS new_value, &lt;br /&gt;
g.oldvalue AS original_value&lt;br /&gt;
FROM prefix_config_log  AS g&lt;br /&gt;
JOIN prefix_user AS u ON g.userid = u.id&lt;br /&gt;
ORDER BY date DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Cohorts by user===&lt;br /&gt;
&lt;br /&gt;
How to get a list of all users and which cohorts they belong to.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname, h.idnumber, h.name&lt;br /&gt;
FROM prefix_cohort AS h&lt;br /&gt;
JOIN prefix_cohort_members AS hm ON h.id = hm.cohortid&lt;br /&gt;
JOIN prefix_user AS u ON hm.userid = u.id&lt;br /&gt;
ORDER BY u.firstname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Courses created And Active courses by Year===&lt;br /&gt;
Active courses is counting course that have at least one Hit, And &amp;quot;Active_MoreThan100Hits&amp;quot; counts courses that have at least 100 Hits&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
YEAR( FROM_UNIXTIME( `timecreated` ) ) AS YEAR, COUNT( * ) AS Counter&lt;br /&gt;
&lt;br /&gt;
, (SELECT COUNT( DISTINCT course ) &lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
WHERE YEAR( FROM_UNIXTIME( l.`time` ) ) = YEAR( FROM_UNIXTIME( `timecreated` ) )&lt;br /&gt;
) AS &amp;quot;Active&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM ( &lt;br /&gt;
SELECT COUNT( * ),time &lt;br /&gt;
FROM prefix_log AS l &lt;br /&gt;
GROUP BY course &lt;br /&gt;
HAVING COUNT(*) &amp;gt; 100) AS courses_log&lt;br /&gt;
WHERE YEAR( FROM_UNIXTIME( courses_log.`time` ) ) = YEAR( FROM_UNIXTIME( `timecreated` ) )&lt;br /&gt;
) AS &amp;quot;Active_MoreThan100Hits&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM `prefix_course` &lt;br /&gt;
GROUP BY YEAR( FROM_UNIXTIME( `timecreated` ) ) &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Users created And Active users by Year===&lt;br /&gt;
Active users is counting users that have at least one Hit, And &amp;quot;Active_MoreThan500Hits&amp;quot; counts users that have at least 500 Hits&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
YEAR( FROM_UNIXTIME( `firstaccess` ) ) AS YEAR, COUNT( * ) AS Counter&lt;br /&gt;
&lt;br /&gt;
, (SELECT COUNT( DISTINCT userid ) &lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
WHERE YEAR( FROM_UNIXTIME( l.`time` ) ) = YEAR( FROM_UNIXTIME( `firstaccess` ) )&lt;br /&gt;
) AS &amp;quot;Active&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM ( &lt;br /&gt;
SELECT COUNT( * ),time &lt;br /&gt;
FROM prefix_log AS l &lt;br /&gt;
GROUP BY userid &lt;br /&gt;
HAVING COUNT(*) &amp;gt; 500) AS users_log&lt;br /&gt;
WHERE YEAR( FROM_UNIXTIME( users_log.`time` ) ) = YEAR( FROM_UNIXTIME( `firstaccess` ) )&lt;br /&gt;
) AS &amp;quot;Active_MoreThan500Hits&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM `prefix_user` &lt;br /&gt;
GROUP BY YEAR( FROM_UNIXTIME( `timecreated` ) ) &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful sub queries ==&lt;br /&gt;
&lt;br /&gt;
=== All teachers in the course ===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
,(SELECT GROUP_CONCAT( CONCAT( u.firstname,  &amp;quot; &amp;quot;, u.lastname ) ) &lt;br /&gt;
FROM prefix_course ic&lt;br /&gt;
JOIN prefix_context con ON con.instanceid = ic.id&lt;br /&gt;
JOIN prefix_role_assignments ra ON con.id = ra.contextid AND con.contextlevel = 50&lt;br /&gt;
JOIN prefix_role r ON ra.roleid = r.id&lt;br /&gt;
JOIN prefix_user u ON u.id = ra.userid&lt;br /&gt;
WHERE r.id = 3 AND ic.id = c.id&lt;br /&gt;
GROUP BY ic.id&lt;br /&gt;
) AS TeacherNames&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributed code]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=ad-hoc_contributed_reports&amp;diff=116219</id>
		<title>ad-hoc contributed reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=ad-hoc_contributed_reports&amp;diff=116219"/>
		<updated>2014-12-02T09:57:21Z</updated>

		<summary type="html">&lt;p&gt;Fox: Added &amp;quot;Role assignments on categories&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Sitewide reports}}&lt;br /&gt;
==User and Role Report==&lt;br /&gt;
&lt;br /&gt;
===Count number of distinct learners and teachers enrolled per category (including all its sub categories)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;SELECT COUNT(DISTINCT lra.userid) AS learners, COUNT(DISTINCT tra.userid) as teachers&lt;br /&gt;
FROM prefix_course AS c #, mdl_course_categories AS cats&lt;br /&gt;
LEFT JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments  AS lra ON lra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_role_assignments  AS tra ON tra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_course_categories AS cats ON c.category = cats.id&lt;br /&gt;
WHERE c.category = cats.id&lt;br /&gt;
AND (&lt;br /&gt;
	cats.path LIKE &#039;%/CATEGORYID/%&#039; #Replace CATEGORYID with the category id you want to count (eg: 80)&lt;br /&gt;
	OR cats.path LIKE &#039;%/CATEGORYID&#039;&lt;br /&gt;
	)&lt;br /&gt;
AND lra.roleid=5&lt;br /&gt;
AND tra.roleid=3&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed ACTIONs for each ROLE (TEACHER, NON-EDITING TEACHER and STUDENT)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT r.name, l.action, COUNT( l.userid ) AS counter&lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
JOIN prefix_context AS context ON context.instanceid = l.course AND context.contextlevel = 50&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON l.userid = ra.userid AND ra.contextid = context.id&lt;br /&gt;
JOIN prefix_role AS r ON ra.roleid = r.id&lt;br /&gt;
WHERE ra.roleid IN ( 3, 4, 5 ) &lt;br /&gt;
GROUP BY roleid, l.action&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Student (user) COUNT in each Course===&lt;br /&gt;
Including (optional) filter by: year (if included in course fullname).&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,course.id,&#039;&amp;quot;&amp;gt;&#039;,course.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/user/index.php?contextid=&#039;,context.id,&#039;&amp;quot;&amp;gt;Show users&amp;lt;/a&amp;gt;&#039;) AS Users&lt;br /&gt;
, COUNT(course.id) AS Students&lt;br /&gt;
FROM prefix_role_assignments AS asg&lt;br /&gt;
JOIN prefix_context AS context ON asg.contextid = context.id AND context.contextlevel = 50&lt;br /&gt;
JOIN prefix_user AS user ON user.id = asg.userid&lt;br /&gt;
JOIN prefix_course AS course ON context.instanceid = course.id&lt;br /&gt;
WHERE asg.roleid = 5 &lt;br /&gt;
# AND course.fullname LIKE &#039;%2013%&#039;&lt;br /&gt;
GROUP BY course.id&lt;br /&gt;
ORDER BY COUNT(course.id) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===LIST of all site USERS by COURSE enrollment (Moodle 2.x)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
user2.firstname AS Firstname,&lt;br /&gt;
user2.lastname AS Lastname,&lt;br /&gt;
user2.email AS Email,&lt;br /&gt;
user2.city AS City,&lt;br /&gt;
course.fullname AS Course&lt;br /&gt;
,(SELECT shortname FROM prefix_role WHERE id=en.roleid) as Role&lt;br /&gt;
,(SELECT name FROM prefix_role WHERE id=en.roleid) as RoleName&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course as course &lt;br /&gt;
JOIN prefix_enrol AS en ON en.courseid = course.id&lt;br /&gt;
JOIN prefix_user_enrolments AS ue ON ue.enrolid = en.id&lt;br /&gt;
JOIN prefix_user AS user2 ON ue.userid = user2.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Enrolled users,which did not login into the Course, even once (Moodle 2)===&lt;br /&gt;
Designed forMoodle 2 table structure and uses special plugin filter : %%FILTER_SEARCHTEXT:table.field%%&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
user2.id as ID,&lt;br /&gt;
ul.timeaccess,&lt;br /&gt;
user2.firstname AS Firstname,&lt;br /&gt;
user2.lastname AS Lastname,&lt;br /&gt;
user2.email AS Email,&lt;br /&gt;
user2.city AS City,&lt;br /&gt;
user2.idnumber AS IDNumber,&lt;br /&gt;
user2.phone1 AS Phone,&lt;br /&gt;
user2.institution AS Institution,&lt;br /&gt;
&lt;br /&gt;
IF (user2.lastaccess = 0,&#039;never&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(user2.lastaccess),&#039;%Y-%m-%d&#039;)) AS dLastAccess&lt;br /&gt;
&lt;br /&gt;
,(SELECT DATE_FORMAT(FROM_UNIXTIME(timeaccess),&#039;%Y-%m-%d&#039;) FROM prefix_user_lastaccess WHERE userid=user2.id and courseid=c.id) as CourseLastAccess&lt;br /&gt;
&lt;br /&gt;
,(SELECT r.name&lt;br /&gt;
FROM  prefix_user_enrolments AS uenrol&lt;br /&gt;
JOIN prefix_enrol AS e ON e.id = uenrol.enrolid&lt;br /&gt;
JOIN prefix_role AS r ON e.id = r.id&lt;br /&gt;
WHERE uenrol.userid=user2.id and e.courseid = c.id) AS RoleName&lt;br /&gt;
&lt;br /&gt;
FROM prefix_user_enrolments as ue&lt;br /&gt;
JOIN prefix_enrol as e on e.id = ue.enrolid&lt;br /&gt;
JOIN prefix_course as c ON c.id = e.courseid&lt;br /&gt;
JOIN prefix_user as user2 ON user2 .id = ue.userid&lt;br /&gt;
LEFT JOIN prefix_user_lastaccess as ul on ul.userid = user2.id&lt;br /&gt;
WHERE c.id=16 AND ul.timeaccess IS NULL&lt;br /&gt;
%%FILTER_SEARCHTEXT:user2.firstname%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Role assignments on categories===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/category.php?id=&#039;,cc.id,&#039;&amp;quot;&amp;gt;&#039;,cc.id,&#039;&amp;lt;/a&amp;gt;&#039;) AS id,&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/category.php?id=&#039;,cc.id,&#039;&amp;quot;&amp;gt;&#039;,cc.name,&#039;&amp;lt;/a&amp;gt;&#039;) AS category,&lt;br /&gt;
cc.depth, cc.path, r.name AS role,&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/user/view.php?id=&#039;,usr.id,&#039;&amp;quot;&amp;gt;&#039;,usr.lastname,&#039;&amp;lt;/a&amp;gt;&#039;) AS name,&lt;br /&gt;
usr.firstname, usr.username, usr.email&lt;br /&gt;
FROM prefix_course_categories cc&lt;br /&gt;
INNER JOIN prefix_context cx ON cc.id = cx.instanceid&lt;br /&gt;
AND cx.contextlevel = &#039;40&#039;&lt;br /&gt;
INNER JOIN prefix_role_assignments ra ON cx.id = ra.contextid&lt;br /&gt;
INNER JOIN prefix_role r ON ra.roleid = r.id&lt;br /&gt;
INNER JOIN prefix_user usr ON ra.userid = usr.id&lt;br /&gt;
ORDER BY cc.depth, cc.path, usr.lastname, usr.firstname, r.name, cc.name&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Permissions Overides on Categories===&lt;br /&gt;
(By: [http://moodle.org/mod/forum/discuss.php?d=153059#p712834 Séverin Terrier] )&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT rc.id, ct.instanceid, ccat.name, rc.roleid, rc.capability, rc.permission, &lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( rc.timemodified ) , &#039;%Y-%m-%d&#039; ) AS timemodified, rc.modifierid, ct.instanceid, ct.path, ct.depth&lt;br /&gt;
FROM `prefix_role_capabilities` AS rc&lt;br /&gt;
INNER JOIN `prefix_context` AS ct ON rc.contextid = ct.id&lt;br /&gt;
INNER JOIN `prefix_course_categories` AS ccat ON ccat.id = ct.instanceid&lt;br /&gt;
AND `contextlevel` =40&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Lists &amp;quot;Totally Opened Courses&amp;quot; (visible, opened to guests, with no password)===&lt;br /&gt;
(By: [http://moodle.org/mod/forum/discuss.php?d=153059#p712837 Séverin Terrier] )&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT id , category , fullname , shortname , enrollable&lt;br /&gt;
FROM `prefix_course`&lt;br /&gt;
WHERE `guest` =1&lt;br /&gt;
AND `password` = &amp;quot;&amp;quot;&lt;br /&gt;
AND `visible` =1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Moodle 2.7 you would use:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.id , c.category , c.fullname , c.shortname &lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_enrol AS e ON e.courseid = c.id&lt;br /&gt;
WHERE e.enrol=&#039;guest&#039; AND e.status=1&lt;br /&gt;
AND e.`password` = &#039;&#039;&lt;br /&gt;
AND c.`visible` =1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Lists &amp;quot;loggedin users&amp;quot; from the last 120 days===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT id,username,FROM_UNIXTIME(`lastlogin`) as days &lt;br /&gt;
FROM `prefix_user` &lt;br /&gt;
WHERE DATEDIFF( NOW(),FROM_UNIXTIME(`lastlogin`) ) &amp;lt; 120&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;and user count for that same population:&#039;&#039;&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(id) as Users  FROM `prefix_user` &lt;br /&gt;
WHERE DATEDIFF( NOW(),FROM_UNIXTIME(`lastlogin`) ) &amp;lt; 120&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Lists the users who have only logged into the site once===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT id, username, firstname, lastname, idnumber&lt;br /&gt;
FROM prefix_user&lt;br /&gt;
WHERE prefix_user.deleted = 0&lt;br /&gt;
AND prefix_user.lastlogin = 0 &lt;br /&gt;
AND prefix_user.lastaccess &amp;gt; 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Students in all courses of some institute===&lt;br /&gt;
What is the status (deleted or not) of all Students (roleid = 5) in all courses of some Institute&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.id, c.fullname, u.firstname, u.lastname, u.deleted&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
AND u.institution = &#039;please enter school name here&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Full User info (for deleted users)===&lt;br /&gt;
Including extra custom profile fields (from prefix_user_info_data)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT * &lt;br /&gt;
FROM prefix_user as u &lt;br /&gt;
JOIN prefix_user_info_data as uid ON uid.userid = u.id &lt;br /&gt;
JOIN prefix_user_info_field as uif ON (uid.fieldid = uif.id AND uif.shortname = &#039;class&#039;)&lt;br /&gt;
WHERE `deleted` = &amp;quot;1&amp;quot; and `institution`=&amp;quot;your school name&amp;quot; and `department` = &amp;quot;your department&amp;quot; and `data` = &amp;quot;class level and number&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===User&#039;s courses===&lt;br /&gt;
change &amp;quot;u.id = 2&amp;quot; with a new user id&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname, c.id, c.fullname&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE u.id = 2&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List Users with extra info (email) in current course===&lt;br /&gt;
blocks/configurable_reports replaces %%COURSEID%% with course id.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname, u.email&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS context ON context.id = ra.contextid AND context.contextlevel = 50&lt;br /&gt;
JOIN prefix_course AS c ON c.id = context.instanceid AND c.id = %%COURSEID%%&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Special Roles===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT ra.roleid,r.name&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/user.php?id=1&amp;amp;user=&#039;,ra.userid,&#039;&amp;quot;&amp;gt;&#039;,u.firstname ,&#039; &#039;,u.lastname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Username&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_role AS r ON r.id = ra.roleid&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_context AS ctx ON (ctx.id = ra.contextid AND ctx.contextlevel = 50)&lt;br /&gt;
JOIN prefix_course AS c ON ctx.instanceid = c.id&lt;br /&gt;
WHERE ra.roleid &amp;gt; 6&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Courses without Teachers===&lt;br /&gt;
Actually, shows the number of Teachers in a course.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id) AS Teachers&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
ORDER BY Teachers ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List of users who have been enrolled for more than 4 weeks===&lt;br /&gt;
For Moodle 2.2 , by  Isuru Madushanka Weerarathna &lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT uenr.userid As User, IF(enr.courseid=uenr.courseid ,&#039;Y&#039;,&#039;N&#039;) As Enrolled, &lt;br /&gt;
IF(DATEDIFF(NOW(), FROM_UNIXTIME(uenr.timecreated))&amp;gt;=28,&#039;Y&#039;,&#039;N&#039;) As EnrolledMoreThan4Weeks&lt;br /&gt;
FROM prefix_enrol As enr, prefix_user_enrolments AS uenr&lt;br /&gt;
WHERE enr.id = uenr.enrolid AND enr.status = uenr.status&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List of users with language===&lt;br /&gt;
&lt;br /&gt;
An issue with systems that do not have their default language set up properly is the need to do a mass change for all users to a localization. A common case is changing default English to American English. &lt;br /&gt;
&lt;br /&gt;
This will show you the language setting for all users:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT username, lang from prefix_user &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This code will change the setting from &#039;en&#039; to &#039;en_us&#039; for all users:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
UPDATE prefix_user SET lang = &#039;en_us&#039; WHERE lang = &#039;en&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Compare role capability and permissions ===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DISTINCT mrc.capability &lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;1&#039; AND rc.contextid = &#039;1&#039;) AS Manager&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;2&#039; AND rc.contextid = &#039;1&#039;) AS CourseCreator&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;3&#039; AND rc.contextid = &#039;1&#039;) AS Teacher&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;4&#039; AND rc.contextid = &#039;1&#039;) AS AssistantTeacher&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;5&#039; AND rc.contextid = &#039;1&#039;) AS Student&lt;br /&gt;
,(SELECT rc.permission FROM `mdl_role_capabilities` AS rc WHERE rc.capability = mrc.capability &lt;br /&gt;
  AND rc.roleid = &#039;6&#039; AND rc.contextid = &#039;1&#039;) AS Guest&lt;br /&gt;
&lt;br /&gt;
FROM `mdl_role_capabilities` AS mrc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Log Activity Reports==&lt;br /&gt;
===Count all Active Users by ROLE in a course category (including all of its sub-categories)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(DISTINCT l.userid) as active&lt;br /&gt;
FROM mdl_course as c&lt;br /&gt;
JOIN mdl_context AS ctx ON  ctx.instanceid=c.id&lt;br /&gt;
JOIN mdl_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN mdl_user_lastaccess as l ON ra.userid = l.userid&lt;br /&gt;
JOIN mdl_course_categories AS cats ON c.category = cats.id&lt;br /&gt;
WHERE c.category=cats.id AND (&lt;br /&gt;
	cats.path LIKE &#039;%/80/%&#039;&lt;br /&gt;
	OR cats.path LIKE &#039;%/80&#039;&lt;br /&gt;
) &lt;br /&gt;
AND ra.roleid=3  AND ctx.contextlevel=50  #ra.roleid= TEACHER 3, NON-EDITING TEACHER 4, STUDENT 5&lt;br /&gt;
AND  l.timeaccess &amp;gt; (unix_timestamp() - ((60*60*24)*NO_OF_DAYS)) #NO_OF_DAYS change to number&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===Detailed &amp;quot;VIEW&amp;quot; ACTION for each ROLE (TEACHER,NONE-EDITING TEACHER and STUDENT)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT l.action, count( l.userid ) as counter , r.name&lt;br /&gt;
FROM `prefix_log` as l&lt;br /&gt;
JOIN `prefix_role_assignments` AS ra on l.userid = ra.userid&lt;br /&gt;
JOIN `prefix_role` AS r ON ra.roleid = r.id&lt;br /&gt;
WHERE (ra.roleid IN (3,4,5)) AND (l.action LIKE &#039;%view%&#039; )&lt;br /&gt;
GROUP BY roleid,l.action&lt;br /&gt;
order by r.name,counter desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Total Activity of Roles:&amp;quot;Teacher&amp;quot; and &amp;quot;None-Editing Teacher&amp;quot; by Dates and by Hours===&lt;br /&gt;
The output columns of this report table can be used as base for a Pivot-Table&lt;br /&gt;
which will show the amount of &#039;&#039;&#039;activity&#039;&#039;&#039; per &#039;&#039;&#039;hour&#039;&#039;&#039; per &#039;&#039;&#039;days&#039;&#039;&#039; in 3D graph view.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DATE_FORMAT( FROM_UNIXTIME( l.time ) , &#039;%Y-%m-%d&#039; ) AS grptimed ,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( l.time ) , &#039;%k&#039; ) AS grptimeh  , count( l.userid ) AS counter &lt;br /&gt;
FROM `prefix_log` AS l&lt;br /&gt;
JOIN prefix_user AS u ON u.id = l.userid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON l.userid = ra.userid&lt;br /&gt;
JOIN prefix_role AS r ON r.id = ra.roleid&lt;br /&gt;
WHERE ra.roleid IN (3,4)&lt;br /&gt;
GROUP BY grptimed,grptimeh&lt;br /&gt;
ORDER BY grptimed,grptimeh&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===How many LOGINs per user and user&#039;s Activity===&lt;br /&gt;
+ link username to a user activity graph report&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/user.php?id=1&amp;amp;user=&#039;,u.id,&#039;&amp;amp;mode=alllogs&amp;quot;&amp;gt;&#039;,u.firstname ,&#039; &#039;,u.lastname,&#039;&amp;lt;/a&amp;gt;&#039;) as Username&lt;br /&gt;
,count(*) as logins&lt;br /&gt;
,(SELECT count(*) FROM prefix_log WHERE userid = l.userid GROUP BY userid) as Activity &lt;br /&gt;
FROM prefix_log as l JOIN prefix_user as u ON l.userid = u.id &lt;br /&gt;
WHERE `action` LIKE &#039;%login%&#039; group by userid&lt;br /&gt;
ORDER BY Activity DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Total activity per course, per unique user on the last 24h===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
Select&lt;br /&gt;
     Count(Distinct userid) As countUsers&lt;br /&gt;
   , Count(course) As countVisits&lt;br /&gt;
   , concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
&lt;br /&gt;
 From prefix_log as l&lt;br /&gt;
 JOIN prefix_course as c on c.id = l.course&lt;br /&gt;
 Where course &amp;gt; 0 and FROM_UNIXTIME(time) &amp;gt;= DATE_SUB(NOW(), INTERVAL 1 DAY) and c.fullname LIKE &#039;%תשעג%&#039;&lt;br /&gt;
 Group By course&lt;br /&gt;
ORDER BY countVisits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Weekly Instructor Online Participation===&lt;br /&gt;
Contributed by Elizabeth Dalton&lt;br /&gt;
&lt;br /&gt;
Displays participation of instructors in all courses per week of a term, including pre-term and post-term edits. An edit is defined as a change to the course, such as a discussion post, the grading of an assignment, or the uploading of file attachments, as well as alterations to course content.&lt;br /&gt;
&lt;br /&gt;
* To specify a subject and/or course number, use % as a wildcard, e.g. ARTS% or ARTS501%&lt;br /&gt;
* To match part of a last name, use %, e.g. Smi% will match &amp;quot;Smith&amp;quot;, &amp;quot;Smile&amp;quot;, etc.&lt;br /&gt;
&lt;br /&gt;
At our institution, we include filters on the course name or category to constrain by terms. These are very specific to how course names and categories are constructed at our institution, so I&#039;ve removed those elements from this code. Also, our terms are 12 weeks long. You would want to insert additional &amp;quot;SUM&amp;quot; lines for longer terms, or remove lines for shorter terms.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
c.shortname AS CourseID&lt;br /&gt;
, cc.name AS Category&lt;br /&gt;
, CONCAT(u.firstname ,&#039; &#039;,u.lastname) AS Instructor&lt;br /&gt;
&lt;br /&gt;
, (SELECT COUNT( ra2.userid ) AS Users2 FROM prefix_role_assignments AS ra2&lt;br /&gt;
JOIN prefix_context AS ctx2 ON ra2.contextid = ctx2.id&lt;br /&gt;
WHERE ra2.roleid = 5 AND ctx2.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
, c.startdate AS Course_Start_Date&lt;br /&gt;
&lt;br /&gt;
, c.visible AS Visible&lt;br /&gt;
&lt;br /&gt;
,  COUNT(l.id) AS Edits&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time)) - WEEK(FROM_UNIXTIME(c.startdate))&amp;lt;0,1,0)) AS BeforeTerm&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=0,1,0)) AS Week1&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=1,1,0)) AS Week2&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=2,1,0)) AS Week3&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=3,1,0)) AS Week4&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=4,1,0)) AS Week5&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=5,1,0)) AS Week6&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=6,1,0)) AS Week7&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=7,1,0)) AS Week8&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=8,1,0)) AS Week9&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=9,1,0)) AS Week10&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=10,1,0)) AS Week11&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))=11,1,0)) AS Week12&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(WEEK(FROM_UNIXTIME(l.time))-WEEK(FROM_UNIXTIME(c.startdate))&amp;gt;=12,1,0)) AS AfterTerm&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/report/log/index.php&#039;,CHAR(63),&#039;chooselog=1&amp;amp;showusers=1&amp;amp;showcourses=0&amp;amp;id=&#039;,c.id,&#039;&amp;amp;user=&#039;,u.id,&#039;&amp;amp;date=0&amp;amp;modid=&amp;amp;modaction=&amp;amp;logformat=showashtml&#039;,&#039;&amp;quot;&amp;gt;&#039;,&#039;Logs&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS Link&lt;br /&gt;
&lt;br /&gt;
FROM prefix_user AS u&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_course_categories as cc ON c.category = cc.id&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_log AS l ON l.userid = u.id AND l.course = c.id  AND l.action NOT LIKE &amp;quot;view%&amp;quot;&lt;br /&gt;
&lt;br /&gt;
WHERE ra.roleid =3&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
AND c.shortname LIKE :course&lt;br /&gt;
AND u.lastname LIKE :last_name&lt;br /&gt;
&lt;br /&gt;
GROUP BY u.idnumber, c.id&lt;br /&gt;
HAVING students &amp;gt; 0&lt;br /&gt;
ORDER BY c.shortname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Module activity (Hits) between dates===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT module, COUNT( * ) &lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME( l.`time` ) BETWEEN  &#039;2012-10-01 00:00:00&#039; AND  &#039;2013-09-31 00:00:00&#039;)&lt;br /&gt;
GROUP BY module&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Module activity (Instances and Hits) for each academic year===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT name&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2010-10-01 00:00:00&#039; AND &#039;2011-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name AND l.action = &#039;add&#039;&lt;br /&gt;
) AS &amp;quot;Added 2010&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2010-10-01 00:00:00&#039; AND &#039;2011-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2010&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2011-10-01 00:00:00&#039; AND &#039;2012-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name AND l.action = &#039;add&#039;&lt;br /&gt;
) AS &amp;quot;Added 2011&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2011-10-01 00:00:00&#039; AND &#039;2012-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2011&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2012-10-01 00:00:00&#039; AND &#039;2013-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name AND l.action = &#039;add&#039;&lt;br /&gt;
) AS &amp;quot;Added 2012&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`time`) BETWEEN &#039;2012-10-01 00:00:00&#039; AND &#039;2013-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2012&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_modules AS m&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Course Reports==&lt;br /&gt;
===Most Active courses===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, l.course courseId, c.fullname coursename&lt;br /&gt;
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
GROUP BY courseId&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Active courses, advanced===&lt;br /&gt;
Including: Teacher&#039;s name, link to the course, All types of log activities, special YEAR generated field, Activities and Resource count, enrolled Student count&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course &lt;br /&gt;
&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher&lt;br /&gt;
&lt;br /&gt;
,CASE &lt;br /&gt;
  WHEN c.fullname LIKE &#039;%תשע&#039; THEN &#039;תשע&#039;&lt;br /&gt;
  WHEN c.fullname LIKE &#039;%תשעא&#039; THEN &#039;תשעא&#039;&lt;br /&gt;
  WHEN c.fullname LIKE &#039;%תשעב&#039; THEN &#039;תשעב&#039;&lt;br /&gt;
END AS Year&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_course_modules cm WHERE cm.course = l.course) Modules&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
FROM prefix_log l &lt;br /&gt;
INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
HAVING Modules &amp;gt; 2&lt;br /&gt;
ORDER BY Year DESC, hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Count unique teachers with courses that use at least X module (Moodle19)===&lt;br /&gt;
You can remove the outer &amp;quot;SELECT COUNT(*) FROM (...) AS ActiveTeachers&amp;quot; SQL query and get the list of the Teachers and Courses.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(*)&lt;br /&gt;
FROM (SELECT c.id AS CourseID, c.fullname AS Course, ra.roleid AS RoleID, CONCAT(u.firstname, &#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm WHERE cm.course = c.id) AS Modules&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid AND ctx.contextlevel = 50 &lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE  ra.roleid = 3 &lt;br /&gt;
GROUP BY u.id&lt;br /&gt;
HAVING Modules &amp;gt; 5) AS ActiveTeachers&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===RESOURCE count for each COURSE===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) count, l.course, c.fullname coursename&lt;br /&gt;
FROM prefix_resource l INNER JOIN prefix_course c on l.course = c.id&lt;br /&gt;
GROUP BY course&lt;br /&gt;
ORDER BY count DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Common resource types count for each Category (Moodle19)===&lt;br /&gt;
Including sub-categories in total count.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT mcc.id AS mccid, CONCAT( LPAD( &#039;&#039;, mcc.depth, &#039;.&#039; ) , mcc.name ) AS Category&lt;br /&gt;
,(SELECT COUNT( * ) &lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%&#039;, mccid, &#039;%&#039; ) AND r.TYPE = &#039;file&#039; AND r.reference LIKE &#039;http://%&#039;&lt;br /&gt;
) AS Links&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT( * ) &lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%&#039;, mccid, &#039;%&#039; ) AND r.TYPE = &#039;file&#039; AND r.reference NOT LIKE &#039;http://%&#039;&lt;br /&gt;
) AS Files&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT( * ) &lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%&#039;, mccid, &#039;%&#039; ) AND r.TYPE = &#039;directory&#039; &lt;br /&gt;
) AS Folders&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT( * ) &lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%&#039;, mccid, &#039;%&#039; ) AND r.TYPE = &#039;html&#039; &lt;br /&gt;
) AS Pages&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM stats_log_context_role_course &lt;br /&gt;
WHERE roleid = 5 AND module = &#039;resource&#039; AND category = mcc.id&lt;br /&gt;
) AS Hits&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course_categories AS mcc&lt;br /&gt;
ORDER BY mcc.path&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Where &amp;quot;stats_log_context_role_course&amp;quot; (in the above SQL query) is a VIEW generated by:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
CREATE VIEW stats_log_context_role_course AS&lt;br /&gt;
SELECT l.course, c.category, cc.path, l.module, l.action, ra.userid, ra.roleid&lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
JOIN prefix_context AS context ON context.instanceid = l.course AND context.contextlevel = 50&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.userid = l.userid AND ra.contextid = context.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = l.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Same query but for Moodle2+&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT mcc.id AS mccid, CONCAT( LPAD( &#039;&#039;, mcc.depth, &#039;.&#039; ) , mcc.name ) AS Category,&lt;br /&gt;
mcc.path,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_url AS u&lt;br /&gt;
JOIN prefix_course AS c ON c.id = u.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS URLs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_folder AS f&lt;br /&gt;
JOIN prefix_course AS c ON c.id = f.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS FOLDERs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_page AS p&lt;br /&gt;
JOIN prefix_course AS c ON c.id = p.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS PAGEs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_book AS b&lt;br /&gt;
JOIN prefix_course AS c ON c.id = b.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS BOOKs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_label AS l&lt;br /&gt;
JOIN prefix_course AS c ON c.id = l.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS LABELs,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_tab AS t&lt;br /&gt;
JOIN prefix_course AS c ON c.id = t.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
WHERE cc.path LIKE CONCAT( &#039;%/&#039;, mccid, &#039;%&#039; )&lt;br /&gt;
) AS TABs&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course_categories AS mcc&lt;br /&gt;
ORDER BY mcc.path&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed Resource COUNT by Teacher in each course===&lt;br /&gt;
&lt;br /&gt;
Including (optional) filter by: year, semester and course id.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS CourseID&lt;br /&gt;
, c.id&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user AS u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = c.id AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
&lt;br /&gt;
, (CASE &lt;br /&gt;
WHEN c.fullname LIKE &#039;%תשעב%&#039; THEN &#039;2012&#039; &lt;br /&gt;
WHEN c.fullname LIKE &#039;%תשעא%&#039; THEN &#039;2011&#039;&lt;br /&gt;
END ) as Year&lt;br /&gt;
, (CASE &lt;br /&gt;
WHEN c.fullname LIKE &#039;%סמסטר א%&#039; THEN &#039;Semester A&#039; &lt;br /&gt;
WHEN c.fullname LIKE &#039;%סמסטר ב%&#039; THEN &#039;Semester B&#039;&lt;br /&gt;
WHEN c.fullname LIKE &#039;%סמסטר ק%&#039; THEN &#039;Semester C&#039;&lt;br /&gt;
END ) as Semester&lt;br /&gt;
,COUNT(c.id) AS Total&lt;br /&gt;
,(SELECT count(*) FROM prefix_course_modules AS cm WHERE cm.course = c.id AND cm.module= 20) AS TABs&lt;br /&gt;
,(SELECT count(*) FROM prefix_course_modules AS cm WHERE cm.course = c.id AND cm.module= 33) AS BOOKs&lt;br /&gt;
&lt;br /&gt;
FROM `prefix_resource` as r &lt;br /&gt;
JOIN `prefix_course` AS c on c.id = r.course&lt;br /&gt;
#WHERE type= &#039;file&#039; and reference NOT LIKE &#039;http://%&#039; &lt;br /&gt;
&lt;br /&gt;
#WHERE 1=1&lt;br /&gt;
#%%FILTER_YEARS:c.fullname%%&lt;br /&gt;
#AND c.fullname LIKE &#039;%2013%&#039;&lt;br /&gt;
&lt;br /&gt;
GROUP BY course&lt;br /&gt;
ORDER BY COUNT(c.id) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Courses that are defined as using GROUPs===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/group/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,(SELECT count(*) FROM prefix_course_modules cm WHERE cm.course = c.id) Modules&lt;br /&gt;
,(SELECT count(*) FROM prefix_groups g WHERE g.courseid = c.id) Groups&lt;br /&gt;
 FROM `prefix_course` AS c&lt;br /&gt;
WHERE groupmode &amp;gt; 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Courses with Groups===&lt;br /&gt;
&lt;br /&gt;
List of all courses with Groups in them (groupmode &amp;gt; 0). You can also use groupmode=1 to list just Separate type groups or groupmode=2 to list Visible type groups.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname, g.name, c.groupmode&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_groups AS g ON c.id = g.courseid&lt;br /&gt;
WHERE c.groupmode &amp;gt; 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Groups in course with member list===&lt;br /&gt;
&lt;br /&gt;
List the groups in a course (replace the # by the course id number) with the members of each group.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname, g.name AS Groupname, u.username&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_groups AS g ON g.courseid = c.id&lt;br /&gt;
JOIN prefix_groups_members AS m ON g.id = m.groupid&lt;br /&gt;
JOIN prefix_user AS u ON m.userid = u.id&lt;br /&gt;
WHERE c.id = #&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Group Export===&lt;br /&gt;
&lt;br /&gt;
There&#039;s a [[Import_groups|group import]] function, but no export. Use this to give you a report with the proper column order and headings to export to a csv file you can then import into another course to replicate the groups. This is a simple version with just the main fields: groupname, description, enrolment key.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT g.name AS groupname, g.description, g.enrolmentkey&lt;br /&gt;
FROM prefix_groups AS g &lt;br /&gt;
JOIN prefix_course as c ON g.courseid = c.id&lt;br /&gt;
WHERE c.id = #&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all Courses in and below a certain category===&lt;br /&gt;
Use this SQL code to retrieve all courses that exist in or under a set category.&lt;br /&gt;
&lt;br /&gt;
$s should be the id of the category you want to know about...&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT prefix_course. * , prefix_course_categories. *&lt;br /&gt;
FROM prefix_course, prefix_course_categories&lt;br /&gt;
WHERE prefix_course.category = prefix_course_categories.id&lt;br /&gt;
AND (&lt;br /&gt;
prefix_course_categories.path LIKE &#039;/$s/%&#039;&lt;br /&gt;
OR prefix_course_categories.path LIKE &#039;/$s&#039;&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all Categories in one level below a certain category===&lt;br /&gt;
Use this PHP code to retrieve a list of all categories below a certain category.&lt;br /&gt;
&lt;br /&gt;
$s should be the id of the top level category you are interested in.&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
require_once(&#039;./config.php&#039;);&lt;br /&gt;
&lt;br /&gt;
$parent_id = $s;&lt;br /&gt;
&lt;br /&gt;
$categories= array();&lt;br /&gt;
&lt;br /&gt;
$categories = get_categories($parent_id);&lt;br /&gt;
&lt;br /&gt;
echo &#039;&amp;lt;ol&amp;gt;&#039;;&lt;br /&gt;
foreach ($categories as $category)&lt;br /&gt;
        {&lt;br /&gt;
        echo &#039;&amp;lt;li&amp;gt;&amp;lt;a href=&amp;quot;&#039;.$CFG-&amp;gt;wwwroot.&#039;/course/category.php?id=&#039;.$category-&amp;gt;id.&#039;&amp;quot;&amp;gt;&#039;.$category-&amp;gt;name.&#039;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&#039;;&lt;br /&gt;
        }&lt;br /&gt;
echo &#039;&amp;lt;/ol&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Blog activity per Course (not including VIEW)===&lt;br /&gt;
Filter activity logging to some specific Course Categories!&lt;br /&gt;
+ link course name to actual course (for quick reference)&lt;br /&gt;
(you can change %blog% to %wiki% to filter down all wiki activity or any other module you wish)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,cm.course,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as CourseID&lt;br /&gt;
,m.name ,count(cm.id) as counter &lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS Students&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE `module` LIKE &#039;%blog%&#039; AND course = c.id AND action NOT LIKE &#039;%view%&#039; ) as BlogActivity&lt;br /&gt;
FROM `prefix_course_modules` as cm JOIN prefix_modules as m ON cm.module=m.id JOIN prefix_course as c ON cm.course = c.id &lt;br /&gt;
WHERE m.name LIKE &#039;%blog%&#039; AND c.category IN ( 8,13,15)&lt;br /&gt;
GROUP BY cm.course,cm.module order by counter desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Student&#039;s posts content in all course blogs (oublog)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
b.name &lt;br /&gt;
,op.title&lt;br /&gt;
,op.message&lt;br /&gt;
,( SELECT CONCAT(u.firstname, &#039; &#039;,u.lastname) FROM prefix_user AS u WHERE u.id = oi.userid) AS &amp;quot;Username&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_oublog_posts AS op&lt;br /&gt;
JOIN prefix_oublog_instances AS oi ON oi.id = op.oubloginstancesid &lt;br /&gt;
JOIN prefix_oublog as b ON b.id = oi.oublogid&lt;br /&gt;
JOIN prefix_course AS c ON b.course = c.id&lt;br /&gt;
&lt;br /&gt;
WHERE c.id = %%COURSEID%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All Courses which uploaded a Syllabus file===&lt;br /&gt;
+ under specific Category&lt;br /&gt;
+ show first Teacher in that course&lt;br /&gt;
+ link Course&#039;s fullname to actual course&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
,c.shortname,r.name&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) as Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user as u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) as Teacher&lt;br /&gt;
FROM prefix_resource as r &lt;br /&gt;
JOIN prefix_course as c ON r.course = c.id&lt;br /&gt;
WHERE ( r.name LIKE &#039;%סילבוס%&#039; OR r.name LIKE &#039;%סילאבוס%&#039; OR r.name LIKE &#039;%syllabus%&#039; OR r.name LIKE &#039;%תכנית הקורס%&#039; ) &lt;br /&gt;
AND c.category IN (10,18,26,13,28)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
	&lt;br /&gt;
===Site-wide completed SCORM activities by Course name===&lt;br /&gt;
This report will list all completed attempts for all SCORM activities. It is ordered first by Course name, then student&#039;s last name, then student&#039;s first name, then attempt number. Please note: the FROM_UNIXTIME command is for MySQL.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname First,u.lastname Last,c.fullname Course, st.attempt Attempt,st.value Status,FROM_UNIXTIME(st.timemodified,&amp;quot;%m-%d-%Y&amp;quot;) Date &lt;br /&gt;
FROM prefix_scorm_scoes_track AS st &lt;br /&gt;
JOIN prefix_user AS u ON st.userid=u.id&lt;br /&gt;
JOIN prefix_scorm AS sc ON sc.id=st.scormid&lt;br /&gt;
JOIN prefix_course AS c ON c.id=sc.course&lt;br /&gt;
WHERE st.value=&#039;completed&#039; &lt;br /&gt;
ORDER BY c.fullname, u.lastname,u.firstname, st.attempt&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Module instances + Module HITs by role teacher and student in course==&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
m.name AS &amp;quot;Module name&amp;quot;&lt;br /&gt;
, COUNT(*) AS &amp;quot;Module count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_log AS l &lt;br /&gt;
WHERE l.course = cm.course AND l.module = m.name ) AS &amp;quot;Hits&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
JOIN prefix_context AS con ON con.instanceid= l.course AND con.contextlevel=50&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid= con.id AND ra.userid= l.userid AND ra.roleid = 5 &lt;br /&gt;
WHERE l.course = cm.course AND l.module = m.name) AS &amp;quot;Students HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
JOIN prefix_context AS con ON con.instanceid= l.course AND con.contextlevel=50&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid= con.id AND ra.userid= l.userid AND ra.roleid = 3 &lt;br /&gt;
WHERE l.course = cm.course AND l.module = m.name) AS &amp;quot;Teachers HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_course_modules AS cm&lt;br /&gt;
JOIN mdl_modules AS m on m.id = cm.module&lt;br /&gt;
WHERE cm.course = &#039;%%COURSEID%%&#039;&lt;br /&gt;
GROUP BY cm.module&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Grade and Course Completion Reports==&lt;br /&gt;
===Site-Wide Grade Report with All Items===&lt;br /&gt;
Shows grades for all course items along with course totals for each student. Works with ad-hoc reports or Configurable Reports&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname AS &#039;First&#039; , u.lastname AS &#039;Last&#039;, u.firstname + &#039; &#039; + u.lastname AS &#039;Display Name&#039;, &lt;br /&gt;
c.fullname AS &#039;Course&#039;, &lt;br /&gt;
cc.name AS &#039;Category&#039;,&lt;br /&gt;
&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN gi.itemtype = &#039;course&#039; &lt;br /&gt;
   THEN c.fullname + &#039; Course Total&#039;&lt;br /&gt;
  ELSE gi.itemname&lt;br /&gt;
END AS &#039;Item Name&#039;,&lt;br /&gt;
&lt;br /&gt;
ROUND(gg.finalgrade,2) AS Grade,&lt;br /&gt;
DATEADD(ss,gi.timemodified,&#039;1970-01-01&#039;) AS Time&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_grade_grades AS gg ON gg.userid = u.id&lt;br /&gt;
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid&lt;br /&gt;
JOIN prefix_course_categories as cc ON cc.id = c.category&lt;br /&gt;
&lt;br /&gt;
WHERE  gi.courseid = c.id &lt;br /&gt;
ORDER BY lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
For MySQL users, you&#039;ll need to use the MySQL DATE_ADD function instead of DATEADD. Replace the line&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DATEADD(ss,gi.timemodified,&#039;1970-01-01&#039;) AS Time&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
with&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
DATE_ADD(&#039;1970-01-01&#039;, INTERVAL gi.timemodified SECOND) AS Time&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Site-Wide Grade Report with Just Course Totals===&lt;br /&gt;
A second site-wide grade report for all students that just shows course totals. Works with ad-hoc reports or Configurable Reports&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname AS &#039;First&#039; , u.lastname AS &#039;Last&#039;, u.firstname + &#039; &#039; + u.lastname AS &#039;Display Name&#039;, &lt;br /&gt;
cc.name AS &#039;Category&#039;,&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN gi.itemtype = &#039;course&#039; &lt;br /&gt;
   THEN c.fullname + &#039; Course Total&#039;&lt;br /&gt;
  ELSE gi.itemname&lt;br /&gt;
END AS &#039;Item Name&#039;,&lt;br /&gt;
&lt;br /&gt;
ROUND(gg.finalgrade,2) AS Grade,&lt;br /&gt;
DATEADD(ss,gg.timemodified,&#039;1970-01-01&#039;) AS Time&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_grade_grades AS gg ON gg.userid = u.id&lt;br /&gt;
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid&lt;br /&gt;
JOIN prefix_course_categories as cc ON cc.id = c.category&lt;br /&gt;
&lt;br /&gt;
WHERE  gi.courseid = c.id AND gi.itemtype = &#039;course&#039;&lt;br /&gt;
&lt;br /&gt;
ORDER BY lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For MySQL users:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname AS &#039;First&#039; , u.lastname AS &#039;Last&#039;, CONCAT(u.firstname , &#039; &#039; , u.lastname) AS &#039;Display Name&#039;, &lt;br /&gt;
c.fullname AS &#039;Course&#039;, &lt;br /&gt;
cc.name AS &#039;Category&#039;,&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN gi.itemtype = &#039;course&#039; &lt;br /&gt;
   THEN CONCAT(c.fullname, &#039; - Total&#039;)&lt;br /&gt;
  ELSE gi.itemname&lt;br /&gt;
END AS &#039;Item Name&#039;,&lt;br /&gt;
&lt;br /&gt;
ROUND(gg.finalgrade,2) AS Grade,&lt;br /&gt;
FROM_UNIXTIME(gg.timemodified) AS TIME&lt;br /&gt;
 &lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
JOIN prefix_grade_grades AS gg ON gg.userid = u.id&lt;br /&gt;
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
 &lt;br /&gt;
WHERE  gi.courseid = c.id &lt;br /&gt;
ORDER BY lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Learner report by Learner with grades===&lt;br /&gt;
Which Learners in which course and what are the grades&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname AS &#039;Name&#039; , u.lastname AS &#039;Surname&#039;, c.fullname AS &#039;Course&#039;, cc.name AS &#039;Category&#039;, &lt;br /&gt;
CASE WHEN gi.itemtype = &#039;Course&#039;    &lt;br /&gt;
THEN c.fullname + &#039; Course Total&#039;  &lt;br /&gt;
ELSE gi.itemname &lt;br /&gt;
END AS &#039;Item Name&#039;, ROUND(gg.finalgrade,2) AS Score,ROUND(gg.rawgrademax,2) AS Max, ROUND(gg.finalgrade / gg.rawgrademax * 100 ,2) as Percentage,&lt;br /&gt;
&lt;br /&gt;
if (ROUND(gg.finalgrade / gg.rawgrademax * 100 ,2) &amp;gt; 79,&#039;Yes&#039; , &#039;No&#039;) as Pass&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c &lt;br /&gt;
JOIN prefix_context AS ctx ON c.id = ctx.instanceid &lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id &lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid &lt;br /&gt;
JOIN prefix_grade_grades AS gg ON gg.userid = u.id &lt;br /&gt;
JOIN prefix_grade_items AS gi ON gi.id = gg.itemid &lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category &lt;br /&gt;
WHERE  gi.courseid = c.id and gi.itemname != &#039;Attendance&#039;&lt;br /&gt;
ORDER BY `Name` ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===User Course Completion===&lt;br /&gt;
&lt;br /&gt;
A very simple report with list of course completion status by username. Completions are noted by date, blank otherwise. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, c.shortname,  &lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(p.timecompleted&lt;br /&gt;
),&#039;%Y-%m-%d&#039;) &lt;br /&gt;
AS completed&lt;br /&gt;
FROM prefix_course_completions AS p&lt;br /&gt;
JOIN prefix_course AS c ON p.course = c.id&lt;br /&gt;
JOIN prefix_user AS u ON p.userid = u.id&lt;br /&gt;
WHERE c.enablecompletion = 1&lt;br /&gt;
ORDER BY u.username&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===User Course Completion with Criteria===&lt;br /&gt;
&lt;br /&gt;
A report with course completions by username, with Aggregation method, Criteria types, and Criteria detail where available.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username AS user, &lt;br /&gt;
c.shortname AS course,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(t.timecompleted),&#039;%Y-%m-%d&#039;) AS completed,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN (SELECT a.method FROM prefix_course_completion_aggr_methd AS a  WHERE (a.course = c.id AND a.criteriatype IS NULL) = 1) THEN &amp;quot;Any&amp;quot;&lt;br /&gt;
ELSE &amp;quot;All&amp;quot;&lt;br /&gt;
END AS aggregation,&lt;br /&gt;
CASE &lt;br /&gt;
WHEN p.criteriatype = 1 THEN &amp;quot;Self&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 2 THEN &amp;quot;By Date&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 3 THEN &amp;quot;Unenrol Status&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 4 THEN &amp;quot;Activity&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 5 THEN &amp;quot;Duration&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 6 THEN &amp;quot;Course Grade&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 7 THEN &amp;quot;Approve by Role&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 8 THEN &amp;quot;Previous Course&amp;quot;&lt;br /&gt;
END AS criteriatype,&lt;br /&gt;
CASE &lt;br /&gt;
WHEN p.criteriatype = 1 THEN &amp;quot;*&amp;quot;&lt;br /&gt;
WHEN p.criteriatype = 2 THEN DATE_FORMAT(FROM_UNIXTIME(p.timeend),&#039;%Y-%m-%d&#039;)&lt;br /&gt;
WHEN p.criteriatype = 3 THEN t.unenroled&lt;br /&gt;
WHEN p.criteriatype = 4 THEN &lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/&#039;,p.module,&#039;/view.php?id=&#039;,p.moduleinstance,&#039;&amp;quot;&amp;gt;&#039;,p.module,&#039;&amp;lt;/a&amp;gt;&#039;)&lt;br /&gt;
WHEN p.criteriatype = 5 THEN p.enrolperiod&lt;br /&gt;
WHEN p.criteriatype = 6 THEN CONCAT(&#039;Needed: &#039;,ROUND(p.gradepass,2),&#039; Achieved: &#039;,ROUND(t.gradefinal,2)) &lt;br /&gt;
WHEN p.criteriatype = 7 THEN p.role&lt;br /&gt;
WHEN p.criteriatype = 8 THEN (SELECT pc.shortname FROM prefix_course AS pc WHERE pc.id = p.courseinstance)&lt;br /&gt;
END AS criteriadetail &lt;br /&gt;
FROM prefix_course_completion_crit_compl AS t&lt;br /&gt;
JOIN prefix_user AS u ON t.userid = u.id&lt;br /&gt;
JOIN prefix_course AS c ON t.course = c.id&lt;br /&gt;
JOIN prefix_course_completion_criteria AS p ON t.criteriaid = p.id&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Courses with Completion Enabled and their settings===&lt;br /&gt;
&lt;br /&gt;
List of all courses with completion enabled and their Aggregation setting, Criteria types, and Criteria details.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT c.shortname AS Course, &lt;br /&gt;
CASE&lt;br /&gt;
WHEN (SELECT a.method FROM prefix_course_completion_aggr_methd AS a  WHERE (a.course = t.course AND a.criteriatype IS NULL)) = 2 THEN &amp;quot;All&amp;quot;&lt;br /&gt;
ELSE &amp;quot;Any&amp;quot;&lt;br /&gt;
END AS Course_Aggregation,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN t.criteriatype = 1 THEN &amp;quot;Self completion&amp;quot;&lt;br /&gt;
WHEN t.criteriatype = 2 THEN &amp;quot;Date done by&amp;quot; &lt;br /&gt;
WHEN t.criteriatype = 3 THEN &amp;quot;Unenrolement&amp;quot; &lt;br /&gt;
WHEN t.criteriatype = 4 THEN &amp;quot;Activity completion&amp;quot;   &lt;br /&gt;
WHEN t.criteriatype = 5 THEN &amp;quot;Duration in days&amp;quot; &lt;br /&gt;
WHEN t.criteriatype = 6 THEN &amp;quot;Final grade&amp;quot;     &lt;br /&gt;
WHEN t.criteriatype = 7 THEN &amp;quot;Approve by role&amp;quot; &lt;br /&gt;
WHEN t.criteriatype = 8 THEN &amp;quot;Previous course&amp;quot;&lt;br /&gt;
END AS Criteria_type,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN t.criteriatype = 1 THEN &amp;quot;On&amp;quot;&lt;br /&gt;
WHEN t.criteriatype = 2 THEN DATE_FORMAT(FROM_UNIXTIME(t.timeend),&#039;%Y-%m-%d&#039;)&lt;br /&gt;
WHEN t.criteriatype = 3 THEN &amp;quot;On&amp;quot;&lt;br /&gt;
WHEN t.criteriatype = 4 THEN&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/&#039;,t.module,&#039;/view.php?id=&#039;,t.moduleinstance,&#039;&amp;quot;&amp;gt;&#039;,t.module,&#039;&amp;lt;/a&amp;gt;&#039;)&lt;br /&gt;
WHEN t.criteriatype = 5 THEN ROUND(t.enrolperiod/86400)&lt;br /&gt;
WHEN t.criteriatype = 6 THEN ROUND(t.gradepass,2)&lt;br /&gt;
WHEN t.criteriatype = 7 THEN (SELECT r.shortname FROM prefix_role AS r WHERE r.id = t.role)&lt;br /&gt;
WHEN t.criteriatype = 8 THEN (SELECT pc.shortname FROM prefix_course AS pc WHERE pc.id = t.courseinstance)&lt;br /&gt;
END AS Criteria_detail&lt;br /&gt;
FROM prefix_course_completion_criteria as t&lt;br /&gt;
JOIN prefix_course AS c ON t.course = c.id&lt;br /&gt;
WHERE c.enablecompletion = 1&lt;br /&gt;
ORDER BY course&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Course Completion Report with custom dates===&lt;br /&gt;
&lt;br /&gt;
List of users who completed multiple or single course/s from a start date to end date chosen by the user. The output gives username, name, course name, completion date and score&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT u.username AS &#039;User Name&#039;,&lt;br /&gt;
CONCAT(u.firstname , &#039; &#039; , u.lastname) AS &#039;Name&#039;,&lt;br /&gt;
c.shortname AS &#039;Course Name&#039;, &lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(p.timecompleted),&#039;%W %e %M, %Y&#039;) AS &#039;Completed Date&#039;,&lt;br /&gt;
ROUND(c4.gradefinal,2) AS &#039;Score&#039;&lt;br /&gt;
FROM prefix_course_completions AS p&lt;br /&gt;
JOIN prefix_course AS c ON p.course = c.id&lt;br /&gt;
JOIN prefix_user AS u ON p.userid = u.id&lt;br /&gt;
JOIN prefix_course_completion_crit_compl AS c4 ON u.id = c4.userid&lt;br /&gt;
WHERE c.enablecompletion = 1  AND (p.timecompleted IS NOT NULL OR p.timecompleted !=&#039;&#039;) &lt;br /&gt;
AND (p.timecompleted&amp;gt;= :start_date AND p.timecompleted&amp;lt;=:end_date)&lt;br /&gt;
GROUP BY u.username&lt;br /&gt;
ORDER BY c.shortname&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Scales used in activities===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT scale.name&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/&#039;,gi.itemmodule,&#039;/view.php?id=&#039;,cm.id,&#039;&amp;quot;&amp;gt;&#039;,gi.itemname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;Module View&amp;quot;&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/modedit.php?up&#039;,&#039;date=&#039;,cm.id,&#039;&amp;quot;&amp;gt;&#039;,gi.itemname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;Module Settings&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_grade_items AS gi&lt;br /&gt;
JOIN prefix_course AS c ON c.id = gi.courseid&lt;br /&gt;
JOIN prefix_course_modules AS cm ON cm.course = gi.courseid AND cm.instance = gi.iteminstance&lt;br /&gt;
JOIN prefix_scale AS scale ON scale.id = gi.scaleid&lt;br /&gt;
WHERE gi.scaleid IS NOT NULL&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Activity Module Reports==&lt;br /&gt;
&lt;br /&gt;
===How many SCORM activities are used in each Course===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT cm.course,c.fullname ,m.name &lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/scorm/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,count(cm.id),&#039;&amp;lt;/a&amp;gt;&#039;) AS Counter&lt;br /&gt;
 &lt;br /&gt;
FROM `prefix_course_modules` as cm &lt;br /&gt;
  JOIN prefix_modules as m ON cm.module=m.id &lt;br /&gt;
  JOIN prefix_course as c ON cm.course = c.id &lt;br /&gt;
WHERE m.name LIKE &#039;%scorm%&#039; &lt;br /&gt;
GROUP BY cm.course,cm.module &lt;br /&gt;
ORDER BY count(cm.id) desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed ACTIONs for each MODULE===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT module,action,count(id) as counter&lt;br /&gt;
FROM prefix_log&lt;br /&gt;
GROUP BY module,action&lt;br /&gt;
ORDER BY module,counter desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Most popular ACTIVITY===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, module&lt;br /&gt;
FROM prefix_log l&lt;br /&gt;
WHERE module != &#039;login&#039; AND module != &#039;course&#039; AND module != &#039;role&#039;&lt;br /&gt;
GROUP BY module&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System wide use of ACTIVITIES and RESOURCES===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT count( cm.id ) AS counter, m.name&lt;br /&gt;
FROM `prefix_course_modules` AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
GROUP BY cm.module&lt;br /&gt;
ORDER BY counter DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===LOG file ACTIONS per MODULE per COURSE (IDs)===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select course,module,action,count(action) as summa from prefix_log&lt;br /&gt;
where action &amp;lt;&amp;gt; &#039;new&#039;&lt;br /&gt;
group by course,action,module&lt;br /&gt;
order by course,module,action&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System Wide usage count of various course Activities===&lt;br /&gt;
(Tested and works fine in Moodle 2.x)&lt;br /&gt;
Like: Forum, Wiki, Blog, Assignment, Database,&lt;br /&gt;
#Within specific category&lt;br /&gt;
#Teacher name in course&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher &lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;) AS Wikis&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%blog%&#039;) AS Blogs&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%forum%&#039;) AS Forums&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%data%&#039;) AS Databses&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%assignment%&#039;) AS Assignments&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
WHERE c.category IN ( 18)&lt;br /&gt;
ORDER BY Wikis DESC,Blogs DESC, Forums DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Course wiki usage/activity over the last 6 semesters===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &amp;quot;Courses with Wikis&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;2010&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%Semester A%&#039;) AS &#039;2010 &amp;lt;br/&amp;gt; Semester A&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;2010&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%Semester B%&#039;) AS &#039;2010 &amp;lt;br/&amp;gt; Semester B&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעא&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר א%&#039;) AS &#039;תשעא &amp;lt;br/&amp;gt; סמסטר א&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעא&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר ב%&#039;) AS &#039;תשעא &amp;lt;br/&amp;gt; סמסטר ב&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעב&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר א%&#039;) AS &#039;תשעב &amp;lt;br/&amp;gt; סמסטר א&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעב&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר ב%&#039;) AS &#039;תשעב &amp;lt;br/&amp;gt; סמסטר ב&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעג&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר א%&#039;) AS &#039;תשעג &amp;lt;br/&amp;gt; סמסטר א&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
 and c.fullname LIKE CONCAT(&#039;%&#039;,&#039;תשעג&#039;,&#039;%&#039;) and c.fullname LIKE &#039;%סמסטר ב%&#039;) AS &#039;תשעג &amp;lt;br/&amp;gt; סמסטר ב&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Detailed WIKI activity (per wiki per course)===&lt;br /&gt;
Including Number of Students in course (for reference)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,cm.course,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as CourseID  &lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id ) AS Students&lt;br /&gt;
,m.name&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%updat%&#039; ) as &#039;UPDAT E&#039;&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%annotate%&#039; ) as ANNOTATE&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%comment%&#039; ) as COMMENT&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%add%&#039; ) as &#039;A DD&#039;&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action LIKE &#039;%edit%&#039; ) as EDIT&lt;br /&gt;
, ( SELECT count(id) FROM prefix_log WHERE cmid = cm.id AND action NOT LIKE &#039;%view%&#039; ) as &#039;All (NO View)&#039;&lt;br /&gt;
FROM `prefix_course_modules` as cm &lt;br /&gt;
JOIN prefix_modules as m ON cm.module=m.id &lt;br /&gt;
JOIN prefix_course as c ON cm.course = c.id &lt;br /&gt;
WHERE m.name LIKE &#039;%wiki%&#039;&lt;br /&gt;
GROUP BY cm.course,cm.module&lt;br /&gt;
ORDER BY &#039;All (NO View)&#039; DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Wiki usage, system wide===&lt;br /&gt;
(you can filter the output by selecting some specific course categories : &amp;quot;WHERE c.category IN ( 8,13,15)&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%wiki%&#039;) AS Wikis&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039;) AS &#039;WikiActivity&amp;lt;br/&amp;gt;ALL&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039; and l.action LIKE &#039;%add%&#039; ) AS &#039;WikiActivity&amp;lt;br/&amp;gt;ADD&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039; and l.action LIKE &#039;%edit%&#039; ) AS &#039;WikiActivity&amp;lt;br/&amp;gt;EDIT&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039; and l.action LIKE &#039;%annotate%&#039; ) AS &#039;WikiActivity&amp;lt;br/&amp;gt;ANNOTATE&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.course = c.id AND l.module LIKE &#039;%wiki%&#039; and l.action LIKE &#039;%comments%&#039; ) AS &#039;WikiActivity&amp;lt;br/&amp;gt;Comments&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
,(SELECT count(*) FROM prefix_ouwiki_pages as ouwp&lt;br /&gt;
JOIN prefix_ouwiki as ouw ON ouw.id = ouwp.subwikiid&lt;br /&gt;
WHERE ouw.course = c.id GROUP BY ouw.course  ) as OUWikiPages&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( DISTINCT nwp.pagename ) FROM prefix_wiki_pages AS nwp&lt;br /&gt;
JOIN prefix_wiki AS nw ON nw.id = nwp.dfwiki WHERE nw.course = c.id ) As NWikiPages&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
WHERE c.category IN ( 8,13,15)&lt;br /&gt;
HAVING Wikis &amp;gt; 0&lt;br /&gt;
ORDER BY &#039;WikiActivity&amp;lt;br/&amp;gt;ALL&#039; DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Aggregated Teacher activity by &amp;quot;WEB2&amp;quot; Modules===&lt;br /&gt;
(Tested and works fine in Moodle 2.x)&lt;br /&gt;
The NV column shows activity without VIEW log activity&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT ra.userid, u.firstname,u.lastname&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%wiki%&#039;) AS Wiki&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%wiki%&#039; AND l.action NOT LIKE &#039;%view%&#039;) AS Wiki_NV&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%forum%&#039;) AS Forum&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%forum%&#039; AND l.action NOT LIKE &#039;%view%&#039;) AS Forum_NV&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%blog%&#039;) AS Blog&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%blog%&#039; AND l.action NOT LIKE &#039;%view%&#039;) AS Blog_NV&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%assignment%&#039;) AS Assignment&lt;br /&gt;
,(SELECT count(*) FROM prefix_log as l WHERE l.userid = u.id AND l.module LIKE &#039;%assignment%&#039; AND l.action NOT LIKE &#039;%view%&#039;) AS Assignment_NV&lt;br /&gt;
FROM prefix_role_assignments AS ra &lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid &lt;br /&gt;
WHERE ra.roleid = 3 &lt;br /&gt;
GROUP BY ra.userid&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all the certificates issued, sort by variables in the custom profile fields===&lt;br /&gt;
Note: The SQL queries look intimidating at first, but isn&#039;t really that difficult to learn. I&#039;ve seen in the forums that users wanted to do &#039;site-wide&#039; groups in 1.9x. This is sort of the idea. It pulls all the certificates issued to all users sorted by the custom profile fields, which in my case is the Units or Depts (i.e. my site wide groups). Why certificates? I&#039;ve explored with both grades and quizzes, the course admins are not really interested in the actual grades but whether the learner received a certificate (i.e. passed the course with x, y, z activities). It also saves me from creating groups and assigning them into the right groups. Even assigning in bulk is not efficient, since I have upward of 25 groups per course and constantly new learners enrolling in courses. The limitation is something to do with the server? as it only pull 5000 rows of data. If anyone figured out how to change this, please let me know. In the meantime, the work around is to pull only a few units/depts at a time to limit the number of rows. This is fine at the moment, since each course admin are only responsible for certain units/depts.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME(prefix_certificate_issues.timecreated), &#039;%Y-%m-%d&#039; ) AS Date,&lt;br /&gt;
prefix_certificate_issues.classname AS Topic,&lt;br /&gt;
prefix_certificate.name AS Certificate,&lt;br /&gt;
prefix_certificate_issues.studentname as Name,&lt;br /&gt;
prefix_user_info_data.data AS Units&lt;br /&gt;
&lt;br /&gt;
FROM&lt;br /&gt;
prefix_certificate_issues&lt;br /&gt;
&lt;br /&gt;
INNER JOIN prefix_user_info_data&lt;br /&gt;
on prefix_certificate_issues.userid = prefix_user_info_data.userid&lt;br /&gt;
&lt;br /&gt;
INNER JOIN prefix_certificate&lt;br /&gt;
on prefix_certificate_issues.certificateid = prefix_certificate.id&lt;br /&gt;
&lt;br /&gt;
WHERE prefix_user_info_data.data=&#039;Unit 1&#039;&lt;br /&gt;
OR prefix_user_info_data.data=&#039;Unit 2&#039;&lt;br /&gt;
OR prefix_user_info_data.data=&#039;Unit 3&#039;&lt;br /&gt;
&lt;br /&gt;
ORDER BY Units, Name, Topic ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Counter Blog usage in Courses,system wide===&lt;br /&gt;
What teachers in what courses, uses blogs and how many + student count in that course.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT ( @counter := @counter+1) as counter, &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) as Course&lt;br /&gt;
&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user AS u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = c.id AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
&lt;br /&gt;
,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%blog%&#039;) AS Blogs&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c, (SELECT @counter := 0) as s_init&lt;br /&gt;
WHERE c.category IN ( 8,13,15)&lt;br /&gt;
HAVING Blogs &amp;gt; 0&lt;br /&gt;
ORDER BY Blogs DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Elluminate (Blackboard Collaborate) - system wide usage===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT e.name As Session ,er.recordingsize&lt;br /&gt;
,c.fullname As Course&lt;br /&gt;
,u.firstname,u.lastname &lt;br /&gt;
,DATE_FORMAT(FROM_UNIXTIME(e.timestart),&#039;%d-%m-%Y&#039;) AS dTimeStart&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/moodle/mod/elluminate/loadrecording.php?id=&#039;,er.id,&#039;&amp;quot;&amp;gt;Show&amp;lt;/a&amp;gt;&#039;) AS RecordedSession&lt;br /&gt;
&lt;br /&gt;
FROM prefix_elluminate_recordings AS er&lt;br /&gt;
JOIN prefix_elluminate AS e ON e.meetingid = er.meetingid&lt;br /&gt;
JOIN prefix_course as c ON c.id = e.course&lt;br /&gt;
JOIN prefix_user AS u ON u.id = e.creator &lt;br /&gt;
ORDER BY er.recordingsize DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Choice ===&lt;br /&gt;
&lt;br /&gt;
Results of the Choice activity. For all courses, shows course shortname, username, the Choice text, and the answer chosen by the user.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname AS course, u.username, h.name as question, o.text AS answer&lt;br /&gt;
FROM prefix_choice AS h&lt;br /&gt;
JOIN prefix_course AS c ON h.course = c.id&lt;br /&gt;
JOIN prefix_choice_answers AS a ON h.id = a.choiceid&lt;br /&gt;
JOIN prefix_user AS u ON a.userid = u.id&lt;br /&gt;
JOIN prefix_choice_options AS o ON a.optionid = o.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Assignment type usage in courses ===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/assign/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;List assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_assign WHERE c.id = course) AS Assignments&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;file&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
#GROUP BY apc.plugin&lt;br /&gt;
) AS &amp;quot;File Assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;onlinetext&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
) AS &amp;quot;Online Assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;pdf&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
) AS &amp;quot;PDF Assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;offline&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
) AS &amp;quot;Offline Assignments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_assign_plugin_config AS apc&lt;br /&gt;
JOIN prefix_assign AS iassign ON iassign.id = apc.assignment &lt;br /&gt;
WHERE iassign.course = c.id AND apc.plugin = &#039;comments&#039; AND apc.subtype = &#039;assignsubmission&#039; AND apc.name = &#039;enabled&#039; AND apc.value = &#039;1&#039;&lt;br /&gt;
) AS &amp;quot;Assignments Comments&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_assign AS assign&lt;br /&gt;
JOIN prefix_course AS c ON c.id = assign.course&lt;br /&gt;
GROUP BY c.id &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Assignment Module Reports==&lt;br /&gt;
===All Ungraded Assignments===&lt;br /&gt;
Returns all the submitted assignments that still need grading&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
u.firstname AS &amp;quot;First&amp;quot;,&lt;br /&gt;
u.lastname AS &amp;quot;Last&amp;quot;,&lt;br /&gt;
c.fullname AS &amp;quot;Course&amp;quot;,&lt;br /&gt;
a.name AS &amp;quot;Assignment&amp;quot;&lt;br /&gt;
&lt;br /&gt;
from prefix_assignment_submissions as asb&lt;br /&gt;
join prefix_assignment as a ON a.id = asb.assignment&lt;br /&gt;
join prefix_user as u ON u.id = asb.userid&lt;br /&gt;
join prefix_course as c ON c.id = a.course&lt;br /&gt;
join prefix_course_modules as cm ON c.id = cm.course&lt;br /&gt;
&lt;br /&gt;
where asb.grade &amp;lt; 0 and cm.instance = a.id&lt;br /&gt;
and cm.module = 1&lt;br /&gt;
&lt;br /&gt;
order by c.fullname, a.name, u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All Ungraded Assignments w/ Link===&lt;br /&gt;
Returns all the submitted assignments that still need grading, along with a link that goes directly to the submission to grade it. The links work if you view the report within Moodle.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
u.firstname AS &amp;quot;First&amp;quot;,&lt;br /&gt;
u.lastname AS &amp;quot;Last&amp;quot;,&lt;br /&gt;
c.fullname AS &amp;quot;Course&amp;quot;,&lt;br /&gt;
a.name AS &amp;quot;Assignment&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
&#039;&amp;lt;a href=&amp;quot;http://education.varonis.com/mod/assignment/submissions.php&#039; + char(63) +&lt;br /&gt;
+ &#039;id=&#039; + cast(cm.id as varchar) + &#039;&amp;amp;userid=&#039; + cast(u.id as varchar) &lt;br /&gt;
+ &#039;&amp;amp;mode=single&amp;amp;filter=0&amp;amp;offset=2&amp;quot;&amp;gt;&#039; + a.name + &#039;&amp;lt;/a&amp;gt;&#039;&lt;br /&gt;
AS &amp;quot;Assignmentlink&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
from prefix_assignment_submissions as asb&lt;br /&gt;
join prefix_assignment as a ON a.id = asb.assignment&lt;br /&gt;
join prefix_user as u ON u.id = asb.userid&lt;br /&gt;
join prefix_course as c ON c.id = a.course&lt;br /&gt;
join prefix_course_modules as cm ON c.id = cm.course&lt;br /&gt;
&lt;br /&gt;
where asb.grade &amp;lt; 0 and cm.instance = a.id and cm.module = 1&lt;br /&gt;
&lt;br /&gt;
order by c.fullname, a.name, u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Assignments (and Quizzes) waiting to be graded===&lt;br /&gt;
This report requires a YEAR filter to be added (Available when using the latest block/configurable_reports)&lt;br /&gt;
&lt;br /&gt;
Which you can always remove, to make this query work on earlier versions.&lt;br /&gt;
&lt;br /&gt;
The report includes: &lt;br /&gt;
*number of quizzes&lt;br /&gt;
*unFinished Quiz attempts&lt;br /&gt;
*Finished Quiz attempts&lt;br /&gt;
*number of students&lt;br /&gt;
*number of Assignments&lt;br /&gt;
*number of submitted answers by students &lt;br /&gt;
*number of unchecked assignments (waiting for the Teacher) in a Course.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher &lt;br /&gt;
 &lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/assignment/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;מטלות&amp;lt;/a&amp;gt;&#039;) AS Assignments&lt;br /&gt;
&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/quiz/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;בחנים&amp;lt;/a&amp;gt;&#039;) AS &#039;Quizzes&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_course_modules cm &lt;br /&gt;
JOIN prefix_modules as m ON m.id = cm.module &lt;br /&gt;
WHERE m.name LIKE &#039;quiz&#039; AND cm.course = c.id &lt;br /&gt;
GROUP BY cm.course &lt;br /&gt;
) AS &#039;nQuizzes&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM prefix_quiz_attempts AS qa&lt;br /&gt;
JOIN prefix_quiz AS q ON q.id = qa.quiz&lt;br /&gt;
WHERE q.course = c.id&lt;br /&gt;
AND qa.timefinish = 0&lt;br /&gt;
GROUP BY q.course) AS &#039;unFinished Quiz attempts&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM prefix_quiz_attempts AS qa&lt;br /&gt;
JOIN prefix_quiz AS q ON q.id = qa.quiz&lt;br /&gt;
WHERE q.course = c.id&lt;br /&gt;
AND qa.timefinish &amp;gt; 0&lt;br /&gt;
GROUP BY q.course) AS &#039;finished quiz attempts&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS nStudents&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
,(&lt;br /&gt;
SELECT count(a.id)&lt;br /&gt;
FROM prefix_assignment AS a &lt;br /&gt;
JOIN prefix_course_modules AS cm ON a.course = cm.course &lt;br /&gt;
WHERE cm.instance = a.id AND cm.module = 1 AND a.course = c.id&lt;br /&gt;
) nAssignments&lt;br /&gt;
&lt;br /&gt;
,(&lt;br /&gt;
SELECT count(*)&lt;br /&gt;
FROM prefix_assignment AS a &lt;br /&gt;
WHERE a.course = c.id AND FROM_UNIXTIME(a.timedue) &amp;gt; NOW()&lt;br /&gt;
GROUP BY a.course&lt;br /&gt;
) &#039;Open &amp;lt;br/&amp;gt;Assignments&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(ROUND( (100 / iAssignments ) * iOpenAssignments ) ,&#039;%&#039;) &#039;unFinished &amp;lt;br/&amp;gt;Assignments &amp;lt;br/&amp;gt;(percent)&#039;&lt;br /&gt;
 &lt;br /&gt;
,(&lt;br /&gt;
SELECT count(asb.id)&lt;br /&gt;
FROM prefix_assignment_submissions AS asb&lt;br /&gt;
JOIN prefix_assignment AS a ON a.id = asb.assignment&lt;br /&gt;
JOIN prefix_course_modules AS cm ON a.course = cm.course &lt;br /&gt;
WHERE asb.grade &amp;lt; 0 AND cm.instance = a.id AND cm.module = 1 AND a.course = c.id&lt;br /&gt;
) &#039;unChecked  &amp;lt;br/&amp;gt;Submissions&#039; &lt;br /&gt;
 &lt;br /&gt;
,(&lt;br /&gt;
SELECT count(asb.id)&lt;br /&gt;
FROM prefix_assignment_submissions AS asb&lt;br /&gt;
JOIN prefix_assignment AS a ON a.id = asb.assignment&lt;br /&gt;
JOIN prefix_course_modules AS cm ON a.course = cm.course &lt;br /&gt;
WHERE cm.instance = a.id AND cm.module = 1 AND a.course = c.id&lt;br /&gt;
) &#039;Submitted  &amp;lt;br/&amp;gt;Assignments&#039;&lt;br /&gt;
 &lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
LEFT JOIN (&lt;br /&gt;
SELECT course, count(*) AS iAssignments&lt;br /&gt;
FROM prefix_assignment AS a &lt;br /&gt;
GROUP BY a.course &lt;br /&gt;
) AS tblAssignmentsCount ON tblAssignmentsCount.course = c.id&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN (&lt;br /&gt;
SELECT course, count(*) AS iOpenAssignments&lt;br /&gt;
FROM prefix_assignment AS a &lt;br /&gt;
WHERE FROM_UNIXTIME(a.timedue) &amp;gt; NOW()&lt;br /&gt;
GROUP BY a.course &lt;br /&gt;
) AS tblOpenAssignmentsCount ON tblOpenAssignmentsCount.course = c.id&lt;br /&gt;
&lt;br /&gt;
WHERE 1=1  &lt;br /&gt;
#AND c.fullname LIKE &#039;%תשעג%&#039;&lt;br /&gt;
%%FILTER_YEARS:c.fullname%%&lt;br /&gt;
## You can enable the SEMESTER filter as well, &lt;br /&gt;
## by uncommenting the following line:&lt;br /&gt;
## %%FILTER_SEMESTERS:c.fullname%%&lt;br /&gt;
ORDER BY &#039;Open &amp;lt;br/&amp;gt;Assignments&#039; DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Who is using &amp;quot;Single File Upload&amp;quot; assignment===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
 &lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher &lt;br /&gt;
&lt;br /&gt;
,ass.name as &amp;quot;Assignment Name&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM &lt;br /&gt;
prefix_assignment as ass&lt;br /&gt;
&lt;br /&gt;
JOIN &lt;br /&gt;
prefix_course as c ON c.id = ass.course&lt;br /&gt;
&lt;br /&gt;
WHERE `assignmenttype` LIKE &#039;uploadsingle&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Resource Module Reports==&lt;br /&gt;
===List &amp;quot;Recently uploaded files&amp;quot;===&lt;br /&gt;
see what users are uploading&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT FROM_UNIXTIME(time,&#039;%Y %M %D %h:%i:%s&#039;) as time ,ip,userid,url,info  &lt;br /&gt;
FROM `prefix_log` &lt;br /&gt;
WHERE `action` LIKE &#039;upload&#039; &lt;br /&gt;
ORDER BY `prefix_log`.`time`  DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List Courses that loaded a specific file: &amp;quot;X&amp;quot;===&lt;br /&gt;
Did the Teacher (probably) uploaded course&#039;s Syllabus ?&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.id, c.fullname  FROM `prefix_log` as l &lt;br /&gt;
JOIN prefix_course as c ON c.id = l.course &lt;br /&gt;
WHERE `action` LIKE &#039;%upload%&#039; AND ( info LIKE &#039;%Syllabus%&#039; OR info LIKE &#039;%Sylabus%&#039; ) GROUP BY c.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All resources that link to some specific external website===&lt;br /&gt;
+ link to course&lt;br /&gt;
+ who&#039;s the teacher&lt;br /&gt;
+ link to external resource&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,c.shortname,r.name&lt;br /&gt;
,(SELECT CONCAT(u.firstname,&#039; &#039;, u.lastname) AS Teacher&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS Teacher&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/resource/view.php?id=&#039;,r.id,&#039;&amp;quot;&amp;gt;&#039;,r.name,&#039;&amp;lt;/a&amp;gt;&#039;) AS Resource&lt;br /&gt;
FROM prefix_resource AS r &lt;br /&gt;
JOIN prefix_course AS c ON r.course = c.id&lt;br /&gt;
WHERE r.reference LIKE &#039;http://info.oranim.ac.il/home%&#039; &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===&amp;quot;Compose Web Page&amp;quot; RESOURCE count===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT course,prefix_course.fullname, COUNT(*) AS Total&lt;br /&gt;
FROM `prefix_resource`&lt;br /&gt;
JOIN `prefix_course` ON prefix_course.id = prefix_resource.course&lt;br /&gt;
WHERE type=&#039;html&#039;&lt;br /&gt;
GROUP BY course&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Resource count in courses===&lt;br /&gt;
+ (First)Teacher name&lt;br /&gt;
+ Where course is inside some specific Categories&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
COUNT(*) AS count&lt;br /&gt;
,r.course &lt;br /&gt;
,c.shortname shortname&lt;br /&gt;
,c.fullname coursename&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user as u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = r.course AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
FROM prefix_resource r &lt;br /&gt;
JOIN prefix_course c ON r.course = c.id&lt;br /&gt;
WHERE c.category IN (10,13,28,18,26)&lt;br /&gt;
GROUP BY r.course&lt;br /&gt;
ORDER BY COUNT(*) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Forum Module Reports==&lt;br /&gt;
===print all User&#039;s post in course Forums===&lt;br /&gt;
@@COURSEID@@ is a variable the is replace by the current CourseID you are running the sql report from. if you are using the latest block/configurable_reports ! (You can always change it to a fixed course or remove it to display all courses.)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/user.php?course=&#039;,c.id,&#039;&amp;amp;id=&#039;,u.id,&#039;&amp;amp;mode=posts&amp;quot;&amp;gt;&#039;,CONCAT(u.firstname,&#039; &#039;, u.lastname),&#039;&amp;lt;/a&amp;gt;&#039;) As Fullname&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/view.php?f=&#039;,fd.forum,&#039;&amp;quot;&amp;gt;&#039;,f.name,&#039;&amp;lt;/a&amp;gt;&#039;) AS Forum&lt;br /&gt;
,count(*) as Posts&lt;br /&gt;
,(SELECT count(*) FROM prefix_forum_discussions AS ifd JOIN prefix_forum as iforum ON iforum.id = ifd.forum  WHERE ifd.userid = fp.userid AND iforum.id = f.id) AS cAllDiscussion&lt;br /&gt;
&lt;br /&gt;
FROM prefix_forum_posts AS fp &lt;br /&gt;
JOIN prefix_user as u ON u.id = fp.userid &lt;br /&gt;
JOIN prefix_forum_discussions AS fd ON fp.discussion = fd.id &lt;br /&gt;
JOIN prefix_forum AS f ON f.id = fd.forum &lt;br /&gt;
JOIN prefix_course as c ON c.id = fd.course &lt;br /&gt;
WHERE fd.course = &#039;@@COURSEID@@&#039; &lt;br /&gt;
GROUP BY f.id,u.id&lt;br /&gt;
ORDER BY u.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===FORUM use Count per COURSE -- not including NEWS Forum!===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT prefix_course.fullname, prefix_forum.course, count(*) as total FROM prefix_forum&lt;br /&gt;
INNER JOIN prefix_course&lt;br /&gt;
ON prefix_course.id = prefix_forum.course&lt;br /&gt;
WHERE NOT(prefix_forum.type = &#039;news&#039;)&lt;br /&gt;
GROUP BY prefix_forum.course&lt;br /&gt;
ORDER BY total desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===FORUM use Count per COURSE by type -- not including NEWS Forum!===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT prefix_course.fullname, prefix_forum.course, prefix_forum.type, count(*) as total FROM prefix_forum&lt;br /&gt;
INNER JOIN prefix_course&lt;br /&gt;
ON prefix_course.id = prefix_forum.course&lt;br /&gt;
WHERE NOT(prefix_forum.type = &#039;news&#039;)&lt;br /&gt;
GROUP BY prefix_forum.course,prefix_forum.type&lt;br /&gt;
ORDER BY total desc&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Forum activity - system wide===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.id,&#039;&amp;lt;/a&amp;gt;&#039;) AS CourseID&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user AS u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = c.id AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
,c.fullname as Course&lt;br /&gt;
,f.type&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid = 5 AND ctx.instanceid = c.id) AS Students&lt;br /&gt;
, fd.forum, f.name,count(*) AS cPostAndDisc&lt;br /&gt;
,(SELECT count(*) FROM prefix_forum_discussions AS ifd WHERE ifd.forum = f.id) AS cDiscussion&lt;br /&gt;
FROM prefix_forum_posts AS fp&lt;br /&gt;
JOIN prefix_forum_discussions AS fd ON fd.id = fp.discussion&lt;br /&gt;
JOIN prefix_forum AS f ON f.id = fd.forum&lt;br /&gt;
JOIN prefix_course AS c ON c.id = f.course&lt;br /&gt;
WHERE f.type != &#039;news&#039; AND c.fullname LIKE &#039;%2013%&#039;&lt;br /&gt;
## WHERE 1=1 &lt;br /&gt;
## %%FILTER_YEARS:c.fullname%%&lt;br /&gt;
## You can enable the SEMESTER filter as well, &lt;br /&gt;
## by uncommenting the following line:&lt;br /&gt;
## %%FILTER_SEMESTERS:c.fullname%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY fd.forum&lt;br /&gt;
ORDER BY count( * ) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Activity In Forums===&lt;br /&gt;
Trying to figure out how much real activity we have in Forums by aggregating:&lt;br /&gt;
Users in Course, Number of Posts, Number of Discussions, Unique student post, Unique student discussions, Number of Teachers , Number of Students, ratio between unique Student posts and the number of students in the Course...&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.fullname,f.name,f.type &lt;br /&gt;
,(SELECT count(id) FROM prefix_forum_discussions as fd WHERE f.id = fd.forum) as Discussions&lt;br /&gt;
,(SELECT count(distinct fd.userid) FROM prefix_forum_discussions as fd WHERE fd.forum = f.id) as UniqueUsersDiscussions&lt;br /&gt;
,(SELECT count(fp.id) FROM prefix_forum_discussions fd JOIN prefix_forum_posts as fp ON fd.id = fp.discussion WHERE f.id = fd.forum) as Posts&lt;br /&gt;
,(SELECT count(distinct fp.userid) FROM prefix_forum_discussions fd JOIN prefix_forum_posts as fp ON fd.id = fp.discussion WHERE f.id = fd.forum) as UniqueUsersPosts&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Students&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS StudentsCount&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Teachers&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid =3&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS &#039;Teacher&amp;lt;br/&amp;gt;Count&#039;&lt;br /&gt;
,(SELECT Count( ra.userid ) AS Users&lt;br /&gt;
FROM prefix_role_assignments AS ra&lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
WHERE ra.roleid IN (3,5)&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
) AS UserCount&lt;br /&gt;
, (SELECT (UniqueUsersDiscussions / StudentsCount )) as StudentDissUsage&lt;br /&gt;
, (SELECT (UniqueUsersPosts /StudentsCount)) as StudentPostUsage&lt;br /&gt;
FROM prefix_forum as f &lt;br /&gt;
JOIN prefix_course as c ON f.course = c.id&lt;br /&gt;
WHERE `type` != &#039;news&#039;&lt;br /&gt;
ORDER BY StudentPostUsage DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All Forum type:NEWS===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT f.id, f.name&lt;br /&gt;
FROM prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
JOIN prefix_forum AS f ON cm.instance = f.id&lt;br /&gt;
WHERE m.name = &#039;forum&#039;&lt;br /&gt;
AND f.type = &#039;news&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===All new forum NEWS items (discussions) from all my Courses===&lt;br /&gt;
change &amp;quot;userid = 26&amp;quot; and &amp;quot;id = 26&amp;quot; to a new user id&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname,f.name,fd.name,FROM_UNIXTIME(fd.timemodified ,&amp;quot;%d %M %Y &amp;quot;) as Date&lt;br /&gt;
FROM prefix_forum_discussions as fd &lt;br /&gt;
JOIN prefix_forum as f ON f.id = fd.forum &lt;br /&gt;
JOIN prefix_course as c ON c.id = f.course &lt;br /&gt;
JOIN prefix_user_lastaccess as ul ON (c.id = ul.courseid AND ul.userid = 26)&lt;br /&gt;
WHERE fd.timemodified &amp;gt; ul.timeaccess  &lt;br /&gt;
 AND fd.forum IN (SELECT f.id&lt;br /&gt;
 FROM prefix_course_modules AS cm&lt;br /&gt;
 JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
 JOIN prefix_forum AS f ON cm.instance = f.id&lt;br /&gt;
 WHERE m.name = &#039;forum&#039;&lt;br /&gt;
 AND f.type = &#039;news&#039;)&lt;br /&gt;
  AND c.id IN (SELECT c.id&lt;br /&gt;
   FROM prefix_course AS c&lt;br /&gt;
   JOIN prefix_context AS ctx ON c.id = ctx.instanceid&lt;br /&gt;
   JOIN prefix_role_assignments AS ra ON ra.contextid = ctx.id&lt;br /&gt;
   JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
   WHERE u.id = 26) ORDER BY `fd`.`timemodified` DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===News Forum - Discussions COUNT===&lt;br /&gt;
Which is actually... How much instructions students get from their teachers&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.shortname ,&lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,( SELECT DISTINCT CONCAT(u.firstname,&#039; &#039;,u.lastname)&lt;br /&gt;
  FROM prefix_role_assignments AS ra&lt;br /&gt;
  JOIN prefix_user AS u ON ra.userid = u.id&lt;br /&gt;
  JOIN prefix_context AS ctx ON ctx.id = ra.contextid&lt;br /&gt;
  WHERE ra.roleid = 3 AND ctx.instanceid = c.id AND ctx.contextlevel = 50 LIMIT 1) AS Teacher&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/view.php?f=&#039;,fd.forum,&#039;&amp;quot;&amp;gt;&#039;,count(fd.id),&#039;&amp;lt;/a&amp;gt;&#039;) AS DiscussionsSum&lt;br /&gt;
FROM prefix_forum_discussions AS fd&lt;br /&gt;
INNER JOIN prefix_forum AS f ON f.id = fd.forum&lt;br /&gt;
INNER JOIN prefix_course AS c ON c.id = f.course&lt;br /&gt;
WHERE f.type = &#039;news&#039; AND c.category IN (10,13,28,18,26)&lt;br /&gt;
GROUP BY fd.forum&lt;br /&gt;
ORDER BY count(fd.id) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Cantidad de foros que han sido posteados por profesor===&lt;br /&gt;
Queriamos saber cuales son las acciones del profesor dentro de los foros de cada curso, por ello se hizo este informe.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.shortname,&#039;&amp;lt;/a&amp;gt;&#039;) AS curso,&lt;br /&gt;
CONCAT(u.firstname ,&#039; &#039;,u.lastname) AS Facilitador,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT( m.name ) AS COUNT FROM &lt;br /&gt;
prefix_course_modules AS cm&lt;br /&gt;
JOIN prefix_modules AS m ON cm.module = m.id&lt;br /&gt;
WHERE cm.course = c.id AND m.name LIKE &#039;%forum%&#039;) AS foros,&lt;br /&gt;
&lt;br /&gt;
COUNT(*) AS Posts&lt;br /&gt;
&lt;br /&gt;
FROM prefix_forum_posts AS fp &lt;br /&gt;
JOIN prefix_forum_discussions AS fd ON fp.discussion = fd.id &lt;br /&gt;
JOIN prefix_forum AS f ON f.id = fd.forum &lt;br /&gt;
JOIN prefix_course AS c ON c.id = fd.course&lt;br /&gt;
JOIN prefix_user AS u ON u.id = fp.userid &lt;br /&gt;
&lt;br /&gt;
WHERE fp.userid =&lt;br /&gt;
(&lt;br /&gt;
select distinct prefix_user.id&lt;br /&gt;
from prefix_user &lt;br /&gt;
join prefix_role_assignments as ra on ra.userid = prefix_user.id &lt;br /&gt;
where ra.roleid = 3 &lt;br /&gt;
and userid = fp.userid&lt;br /&gt;
limit 1&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
and c.shortname like &#039;%2014-2-1%&#039;&lt;br /&gt;
GROUP BY c.id, u.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Quiz Module Reports==&lt;br /&gt;
===Generate a list of instructors and their email addresses for those courses that has &amp;quot;essay questions&amp;quot; in their quizzes===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT qu.id AS quiz_id, qu.course AS course_id, qu.questions,&lt;br /&gt;
                co.fullname AS course_fullname, co.shortname AS course_shortname,&lt;br /&gt;
                qu.name AS quiz_name, FROM_UNIXTIME(qu.timeopen) AS quiz_timeopen, FROM_UNIXTIME(qu.timeclose) AS quiz_timeclose,&lt;br /&gt;
                u.firstname, u.lastname, u.email,&lt;br /&gt;
FROM prefix_quiz qu, prefix_course co, prefix_role re, prefix_context ct, prefix_role_assignments ra, prefix_user u&lt;br /&gt;
WHERE FROM_UNIXTIME(timeopen) &amp;gt; &#039;2008-05-14&#039; AND&lt;br /&gt;
                qu.course = co.id AND&lt;br /&gt;
                co.id = ct.instanceid AND&lt;br /&gt;
                ra.roleid = re.id AND&lt;br /&gt;
                re.name = &#039;Teacher&#039; AND&lt;br /&gt;
                ra.contextid = ct.id AND&lt;br /&gt;
                ra.userid = u.id&lt;br /&gt;
 &lt;br /&gt;
SELECT Count(&#039;x&#039;) As NumOfStudents&lt;br /&gt;
                                FROM prefix_role_assignments a&lt;br /&gt;
                                JOIN prefix_user u ON userid = u.id&lt;br /&gt;
                                WHERE roleid = 5 AND contextid = (SELECT id FROM prefix_context WHERE instanceid = 668 AND contextlevel = 50)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Number of Quizes per Course===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT count(*)&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/quiz/index.php?id=&#039;,c.id,&#039;&amp;quot;&amp;gt;Link&amp;lt;/a&amp;gt;&#039;) AS Quizes&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course_modules cm&lt;br /&gt;
JOIN prefix_course c ON c.id = cm.course&lt;br /&gt;
JOIN prefix_modules as m ON m.id = cm.module&lt;br /&gt;
WHERE m.name LIKE &#039;quiz&#039;&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all MultiAnswer (Cloze) Questions===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/quiz/attempt.php?q=&#039;, quiz.id, &#039;&amp;quot;&amp;gt;&#039;, quiz.name, &#039;&amp;lt;/a&amp;gt;&#039;) AS Quiz&lt;br /&gt;
,question.id question_id, question.questiontext &lt;br /&gt;
FROM  prefix_question question&lt;br /&gt;
JOIN prefix_quiz_question_instances qqi ON question.id = qqi.question&lt;br /&gt;
JOIN prefix_quiz quiz ON qqi.quiz = quiz.id&lt;br /&gt;
WHERE  `qtype` LIKE  &#039;multianswer&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List courses with MANUAL grades===&lt;br /&gt;
Which is basically and indication to teachers using Moodle to hold offline grades inside Moodle&#039;s Gradebook,&lt;br /&gt;
So grades could be uploaded into an administrative SIS. Use with Configurable Reports.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT( * )&lt;br /&gt;
,concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/grade/edit/tree/index.php?showadvanced=1&amp;amp;id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
FROM  prefix_grade_items AS gi&lt;br /&gt;
JOIN prefix_course as c ON c.id = gi.courseid&lt;br /&gt;
WHERE  `itemtype` =  &#039;manual&#039;&lt;br /&gt;
GROUP BY courseid&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===List the users that did not took the Quiz===&lt;br /&gt;
Do not forget to change &amp;quot;c.id = 14&amp;quot; and q.name LIKE &#039;%quiz name goes here%&#039;&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
user2.id AS ID,&lt;br /&gt;
ul.timeaccess,&lt;br /&gt;
user2.firstname AS Firstname,&lt;br /&gt;
user2.lastname AS Lastname,&lt;br /&gt;
user2.email AS Email,&lt;br /&gt;
user2.username AS IDNumber,&lt;br /&gt;
user2.institution AS Institution,&lt;br /&gt;
 &lt;br /&gt;
IF (user2.lastaccess = 0,&#039;never&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(user2.lastaccess),&#039;%Y-%m-%d&#039;)) AS dLastAccess&lt;br /&gt;
 &lt;br /&gt;
,(SELECT DATE_FORMAT(FROM_UNIXTIME(timeaccess),&#039;%Y-%m-%d&#039;) FROM prefix_user_lastaccess WHERE userid=user2.id AND courseid=c.id) AS CourseLastAccess&lt;br /&gt;
 &lt;br /&gt;
,(SELECT r.name&lt;br /&gt;
FROM  prefix_user_enrolments AS uenrol&lt;br /&gt;
JOIN prefix_enrol AS e ON e.id = uenrol.enrolid&lt;br /&gt;
JOIN prefix_role AS r ON e.id = r.id&lt;br /&gt;
WHERE uenrol.userid=user2.id AND e.courseid = c.id) AS RoleName&lt;br /&gt;
 &lt;br /&gt;
FROM prefix_user_enrolments AS ue&lt;br /&gt;
JOIN prefix_enrol AS e ON e.id = ue.enrolid&lt;br /&gt;
JOIN prefix_course AS c ON c.id = e.courseid&lt;br /&gt;
JOIN prefix_user AS user2 ON user2 .id = ue.userid&lt;br /&gt;
LEFT JOIN prefix_user_lastaccess AS ul ON ul.userid = user2.id&lt;br /&gt;
WHERE c.id=14 and ue.userid NOT IN (SELECT qa.userid FROM prefix_quiz_attempts AS qa&lt;br /&gt;
JOIN prefix_quiz AS q ON qa.quiz = q.id&lt;br /&gt;
JOIN prefix_course AS c ON q.course = c.id&lt;br /&gt;
WHERE c.id = 14 AND q.name LIKE &#039;%quiz name goes here%&#039;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===List Questions in each Quiz===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT quiz.id,quiz.name, q.id, q.name&lt;br /&gt;
FROM mdl_quiz AS quiz&lt;br /&gt;
JOIN mdl_question AS q ON FIND_IN_SET(q.id, quiz.questions)&lt;br /&gt;
WHERE quiz.course = %%COURSEID%%&lt;br /&gt;
ORDER BY quiz.id ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==SCORM Activity Reports==&lt;br /&gt;
&lt;br /&gt;
===Lists All completed SCORM activites by Course name===&lt;br /&gt;
This report will list all completed attempts for all SCORM activities. It is ordered first by Course name, then student&#039;s last name, then student&#039;s first name, then attempt number. Please note: the FROM_UNIXTIME command is for MySQL.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname First,u.lastname Last,c.fullname Course, st.attempt Attempt,st.value Status,FROM_UNIXTIME(st.timemodified,&amp;quot;%m-%d-%Y&amp;quot;) Date &lt;br /&gt;
FROM prefix_scorm_scoes_track AS st &lt;br /&gt;
JOIN prefix_user AS u ON st.userid=u.id&lt;br /&gt;
JOIN prefix_scorm AS sc ON sc.id=st.scormid&lt;br /&gt;
JOIN prefix_course AS c ON c.id=sc.course&lt;br /&gt;
WHERE st.value=&#039;completed&#039; &lt;br /&gt;
ORDER BY c.fullname, u.lastname,u.firstname, st.attempt&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Badges==&lt;br /&gt;
&lt;br /&gt;
=== All badges issued, by User ===&lt;br /&gt;
&lt;br /&gt;
This report will show you all the badges on a site that have been issued, both site and all courses, by the username of each user issued a badge. Includes the type of criteria passed (activity, course completion, manual), date issued, date expires, and a direct link to that issued badge page so you can see all the other details for that badge.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, b.name AS badgename, &lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.courseid IS NOT NULL THEN&lt;br /&gt;
(SELECT c.shortname&lt;br /&gt;
    FROM prefix_course AS c&lt;br /&gt;
    WHERE c.id = b.courseid)&lt;br /&gt;
WHEN b.courseid IS NULL THEN &amp;quot;*&amp;quot;&lt;br /&gt;
END AS Context,&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN t.criteriatype = 1 AND t.method = 1 THEN &amp;quot;Activity Completion (All)&amp;quot;&lt;br /&gt;
  WHEN t.criteriatype = 1 AND t.method = 2 THEN &amp;quot;Activity Completion (Any)&amp;quot;&lt;br /&gt;
  WHEN t.criteriatype = 2 AND t.method = 2 THEN &amp;quot;Manual Award&amp;quot;&lt;br /&gt;
  WHEN t.criteriatype = 4 AND t.method = 1 THEN &amp;quot;Course Completion (All)&amp;quot;&lt;br /&gt;
  WHEN t.criteriatype = 4 AND t.method = 2 THEN &amp;quot;Course Completion (Any)&amp;quot;&lt;br /&gt;
  ELSE CONCAT (&#039;Other: &#039;, t.criteriatype)&lt;br /&gt;
END AS Criteriatype,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( d.dateissued ) , &#039;%Y-%m-%d&#039; ) AS dateissued,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( d.dateexpire ), &#039;%Y-%m-%d&#039; ) AS dateexpires,&lt;br /&gt;
CONCAT (&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/badges/badge.php?hash=&#039;,d.uniquehash,&#039;&amp;quot;&amp;gt;link&amp;lt;/a&amp;gt;&#039;) AS Details&lt;br /&gt;
FROM prefix_badge_issued AS d &lt;br /&gt;
JOIN prefix_badge AS b ON d.badgeid = b.id&lt;br /&gt;
JOIN prefix_user AS u ON d.userid = u.id&lt;br /&gt;
JOIN prefix_badge_criteria AS t on b.id = t.badgeid &lt;br /&gt;
WHERE t.criteriatype &amp;lt;&amp;gt; 0&lt;br /&gt;
ORDER BY u.username&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Please note: the FROM_UNIXTIME command is for MySQL.&lt;br /&gt;
&lt;br /&gt;
=== All badges available in the system, with Earned count ===&lt;br /&gt;
&lt;br /&gt;
Report of all badges in the system, with badge name and description, context, course shortname if a course badge, whether it is active and available, and a count of how many users have been issued that badge.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT b.id, b.name, b.description,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.type = 1 THEN &amp;quot;System&amp;quot;&lt;br /&gt;
WHEN b.type = 2 THEN &amp;quot;Course&amp;quot;&lt;br /&gt;
END AS Context, &lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.courseid IS NOT NULL THEN &lt;br /&gt;
(SELECT c.shortname &lt;br /&gt;
    FROM prefix_course AS c &lt;br /&gt;
    WHERE c.id = b.courseid)&lt;br /&gt;
WHEN b.courseid IS NULL THEN &amp;quot;*&amp;quot;&lt;br /&gt;
END AS Course, &lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.status = 0 OR b.status = 2 THEN &amp;quot;No&amp;quot;&lt;br /&gt;
WHEN b.status = 1 OR b.status = 3 THEN &amp;quot;Yes&amp;quot;&lt;br /&gt;
WHEN b.status = 4 THEN &amp;quot;x&amp;quot;&lt;br /&gt;
END AS Available,&lt;br /&gt;
CASE&lt;br /&gt;
WHEN b.status = 0 OR b.status = 1 THEN &amp;quot;0&amp;quot;&lt;br /&gt;
WHEN b.status = 2 OR b.status = 3 OR b.status = 4 THEN &lt;br /&gt;
 (SELECT COUNT(*) &lt;br /&gt;
   FROM prefix_badge_issued AS d&lt;br /&gt;
   WHERE d.badgeid = b.id&lt;br /&gt;
 )&lt;br /&gt;
END AS Earned&lt;br /&gt;
FROM prefix_badge AS b&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Badges Leaderboard ===&lt;br /&gt;
&lt;br /&gt;
A simple list of usernames and how many badges they have earned overall.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, (SELECT COUNT(*) FROM prefix_badge_issued AS d WHERE d.userid = u.id) AS earned&lt;br /&gt;
FROM prefix_user AS u&lt;br /&gt;
ORDER BY earned DESC, u.username ASC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Administrator Reports==&lt;br /&gt;
&lt;br /&gt;
===Config changes in Export friendly form===&lt;br /&gt;
&lt;br /&gt;
The Administrative report Config changes is very useful but it would be nice to have it in a format that could be easily exported in one listing. Here is code to do that.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME( g.timemodified ) , &#039;%Y-%m-%d&#039; ) AS date, &lt;br /&gt;
u.username AS user, &lt;br /&gt;
g.name AS setting, &lt;br /&gt;
CASE &lt;br /&gt;
 WHEN g.plugin IS NULL THEN &amp;quot;core&amp;quot;&lt;br /&gt;
 ELSE g.plugin&lt;br /&gt;
END AS plugin, &lt;br /&gt;
g.value AS new_value, &lt;br /&gt;
g.oldvalue AS original_value&lt;br /&gt;
FROM prefix_config_log  AS g&lt;br /&gt;
JOIN prefix_user AS u ON g.userid = u.id&lt;br /&gt;
ORDER BY date DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Cohorts by user===&lt;br /&gt;
&lt;br /&gt;
How to get a list of all users and which cohorts they belong to.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname, h.idnumber, h.name&lt;br /&gt;
FROM prefix_cohort AS h&lt;br /&gt;
JOIN prefix_cohort_members AS hm ON h.id = hm.cohortid&lt;br /&gt;
JOIN prefix_user AS u ON hm.userid = u.id&lt;br /&gt;
ORDER BY u.firstname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Courses created And Active courses by Year===&lt;br /&gt;
Active courses is counting course that have at least one Hit, And &amp;quot;Active_MoreThan100Hits&amp;quot; counts courses that have at least 100 Hits&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
YEAR( FROM_UNIXTIME( `timecreated` ) ) AS YEAR, COUNT( * ) AS Counter&lt;br /&gt;
&lt;br /&gt;
, (SELECT COUNT( DISTINCT course ) &lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
WHERE YEAR( FROM_UNIXTIME( l.`time` ) ) = YEAR( FROM_UNIXTIME( `timecreated` ) )&lt;br /&gt;
) AS &amp;quot;Active&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM ( &lt;br /&gt;
SELECT COUNT( * ),time &lt;br /&gt;
FROM prefix_log AS l &lt;br /&gt;
GROUP BY course &lt;br /&gt;
HAVING COUNT(*) &amp;gt; 100) AS courses_log&lt;br /&gt;
WHERE YEAR( FROM_UNIXTIME( courses_log.`time` ) ) = YEAR( FROM_UNIXTIME( `timecreated` ) )&lt;br /&gt;
) AS &amp;quot;Active_MoreThan100Hits&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM `prefix_course` &lt;br /&gt;
GROUP BY YEAR( FROM_UNIXTIME( `timecreated` ) ) &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Users created And Active users by Year===&lt;br /&gt;
Active users is counting users that have at least one Hit, And &amp;quot;Active_MoreThan500Hits&amp;quot; counts users that have at least 500 Hits&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
YEAR( FROM_UNIXTIME( `firstaccess` ) ) AS YEAR, COUNT( * ) AS Counter&lt;br /&gt;
&lt;br /&gt;
, (SELECT COUNT( DISTINCT userid ) &lt;br /&gt;
FROM prefix_log AS l&lt;br /&gt;
WHERE YEAR( FROM_UNIXTIME( l.`time` ) ) = YEAR( FROM_UNIXTIME( `firstaccess` ) )&lt;br /&gt;
) AS &amp;quot;Active&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM ( &lt;br /&gt;
SELECT COUNT( * ),time &lt;br /&gt;
FROM prefix_log AS l &lt;br /&gt;
GROUP BY userid &lt;br /&gt;
HAVING COUNT(*) &amp;gt; 500) AS users_log&lt;br /&gt;
WHERE YEAR( FROM_UNIXTIME( users_log.`time` ) ) = YEAR( FROM_UNIXTIME( `firstaccess` ) )&lt;br /&gt;
) AS &amp;quot;Active_MoreThan500Hits&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM `prefix_user` &lt;br /&gt;
GROUP BY YEAR( FROM_UNIXTIME( `timecreated` ) ) &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful sub queries ==&lt;br /&gt;
&lt;br /&gt;
=== All teachers in the course ===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
,(SELECT GROUP_CONCAT( CONCAT( u.firstname,  &amp;quot; &amp;quot;, u.lastname ) ) &lt;br /&gt;
FROM prefix_course ic&lt;br /&gt;
JOIN prefix_context con ON con.instanceid = ic.id&lt;br /&gt;
JOIN prefix_role_assignments ra ON con.id = ra.contextid AND con.contextlevel = 50&lt;br /&gt;
JOIN prefix_role r ON ra.roleid = r.id&lt;br /&gt;
JOIN prefix_user u ON u.id = ra.userid&lt;br /&gt;
WHERE r.id = 3 AND ic.id = c.id&lt;br /&gt;
GROUP BY ic.id&lt;br /&gt;
) AS TeacherNames&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributed code]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=You_Might_Be_a_Moodler&amp;diff=116006</id>
		<title>You Might Be a Moodler</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=You_Might_Be_a_Moodler&amp;diff=116006"/>
		<updated>2014-11-17T13:41:37Z</updated>

		<summary type="html">&lt;p&gt;Fox: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In the spirit of Jeff Foxworthy&#039;s &#039;&#039;You Might be a Redneck&#039;&#039; - http://www.jefffoxworthy.com/comedy/jod/index.shtml &lt;br /&gt;
&lt;br /&gt;
*If you have ever turned on a football game and and the orange uniforms of one team caused you to leap up from the sofa and check out moodle.org, you might be a Moodler.&lt;br /&gt;
&lt;br /&gt;
*If you type &amp;quot;moodle.org&amp;quot; in your browser when you intend to type &amp;quot;google.com.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*If you look up recipes in moodle.org.&lt;br /&gt;
&lt;br /&gt;
*If you look up recipes in moodle.org... and [http://moodle.org/mod/forum/discuss.php?d=5395&amp;amp;parent=30227 find them]!&lt;br /&gt;
&lt;br /&gt;
*If you can spell &#039;&#039;&#039;Dougiamas&#039;&#039;&#039; without having to look it up.&lt;br /&gt;
&lt;br /&gt;
*If you can &#039;&#039;pronounce&#039;&#039; &#039;&#039;&#039;Dougiamas&#039;&#039;&#039; without having to look it up.&lt;br /&gt;
&lt;br /&gt;
*If you check the Moodle forums at 8:30 on a Saturday night.&lt;br /&gt;
&lt;br /&gt;
*If you find yourself heading to the bugtracker when the dishwasher is broken.&lt;br /&gt;
&lt;br /&gt;
*If you start seeing double square brackets around words you don&#039;t know the translation of.&lt;br /&gt;
&lt;br /&gt;
*Your spouse wants you to take up golf again because they hate being a &#039;moodle widow(er)&#039; more.&lt;br /&gt;
&lt;br /&gt;
*You describe the color of something as &amp;quot;Moodle&amp;quot; orange.&lt;br /&gt;
&lt;br /&gt;
*If you find yourself logging in to moodle.org during your summer holiday in Italy instead of enjoying the beautiful view or going to the beach. &lt;br /&gt;
&lt;br /&gt;
*You try to figure out how to grade e-mails from your friends&lt;br /&gt;
&lt;br /&gt;
*You find moodle.org is down for some reason and the first thing you want to do is post on moodle.org about it.&lt;br /&gt;
&lt;br /&gt;
*Every verb you use is &#039;to moodle&#039;.&lt;br /&gt;
&lt;br /&gt;
*You go into a Chinese restaurant and ask for a side order of Moodles with your Egg Foo Young.&lt;br /&gt;
&lt;br /&gt;
*You talk about Moodle so much that your non-Moodling, non-native English speaking husband asks if the noodles on the plate in front of him are moodles and when you ask him if that is what he meant to say he replies, &amp;quot;Yes, aren&#039;t they moodles?&amp;quot; (based on a true story)&lt;br /&gt;
&lt;br /&gt;
*You know that the course id for &#039;&#039;&#039;Moodle in English&#039;&#039;&#039; is 5.&lt;br /&gt;
&lt;br /&gt;
*And even if you drive a car, you always drive it in &#039;&#039;&#039;5&#039;&#039;&#039;th gear.&lt;br /&gt;
&lt;br /&gt;
*You throw away all but the orange M&amp;amp;amp;M&#039;s.&lt;br /&gt;
&lt;br /&gt;
*You eat all but the orange M&amp;amp;amp;M&#039;s (and keep it for good &#039;&#039;feng shui&#039;&#039; in your desktop).&lt;br /&gt;
&lt;br /&gt;
*You try to convince your wife and kids that there is a Disney Park in Perth.&lt;br /&gt;
&lt;br /&gt;
*The homepage of your computer is https://moodle.org.&lt;br /&gt;
&lt;br /&gt;
*The homepage of every computer you have ever laid hands on is https://moodle.org.&lt;br /&gt;
&lt;br /&gt;
*You only recently discovered that typing an address in your browser takes you to a page outside Moodle.org&lt;br /&gt;
 &lt;br /&gt;
*You sometimes refer to your third child as &#039;&#039;&#039;1.3&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Your default response to a rerun on TV is to fire up the laptop and check out moodle.org.&lt;br /&gt;
&lt;br /&gt;
*If you put little labels on your TV&#039;s remote control that say... view.php?id=1, view.php?id=2, etc ...&lt;br /&gt;
&lt;br /&gt;
*You have five browser windows open right now, four of which are Moodle sites.&lt;br /&gt;
&lt;br /&gt;
*Reading the moodle.org forums is part of the morning routine:  coffee, newspaper, wake up the children. . .&lt;br /&gt;
&lt;br /&gt;
*You find yourself adding items to a list that only the Moodle clique will understand.&lt;br /&gt;
&lt;br /&gt;
*You tell people to &amp;quot;Keep Moodling&amp;quot; and that they have been &amp;quot;Moodlised&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*If instead of saying &#039;&#039;Have a good day&#039;&#039; you begin greeting folks by saying &#039;&#039;Happy Moodling!&#039;&#039; and even worse when you actually believe that the two statements mean the same thing. {Based on a true story}&lt;br /&gt;
&lt;br /&gt;
*If normal words start being morphed into &#039;&#039;Moodle-isms&#039;&#039;. For example, when someone asks &#039;&#039;How are you?&#039;&#039; you begin to reply with words like Moodle-rrific and Moodle-tastic. Subsequently, you get confused when someone gives you a quizzical look because they do not understand what have just said. {Based on a true story}&lt;br /&gt;
&lt;br /&gt;
*If your students start showing up to the Friday night football games wanting to know when the Moodle chant is going to begin and students begin painting  &#039;&#039;MOODLE&#039;&#039; on their chests! {Based on a true story}&lt;br /&gt;
&lt;br /&gt;
* You are looking forward to Christmas vacation so that you will have time to upgrade Moodle!&lt;br /&gt;
&lt;br /&gt;
* You read something interesting and your first thought is, &amp;quot;I have to post that at moodle.org.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
* You forget that the comment you just ignored from a co-worker won&#039;t be retrievable later in a Recent Activities block.&lt;br /&gt;
&lt;br /&gt;
* When in the supermarket, you prefer to buy orange capsicums (peppers) rather than any other colour.&lt;br /&gt;
&lt;br /&gt;
* If you go to https://moodle.org instead of http://google.com and try some (global) searches there, only realizing after some attempts that you are looking within Moodleland only. {Based on a true story}&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Oohoo_-_Capture_repository&amp;diff=115179</id>
		<title>Oohoo - Capture repository</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Oohoo_-_Capture_repository&amp;diff=115179"/>
		<updated>2014-10-06T09:54:13Z</updated>

		<summary type="html">&lt;p&gt;Fox: Cleaned duplicate information&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Repositories}}&lt;br /&gt;
This repository allows users to record video, sound and take a photo WITHOUT a streaming server. This works as any other Moodle 2.x repository. It must first be enabled. Once enabled, it will show up in the file picker. Simply click on the &amp;quot;Capture&amp;quot; repository and choose if you want to record a sound, a video or have a picture taken from your webcam.&lt;br /&gt;
 &lt;br /&gt;
Once you are done recording, you can edit your video by trimming the beginning and the end.&lt;br /&gt;
&lt;br /&gt;
Note: You must install FFMPEG on your Moodle server inorder for this plugin to work.&lt;br /&gt;
&lt;br /&gt;
==Versions available==&lt;br /&gt;
Available for Moodle 2.3, 2.4, 2.5 and 2.6&lt;br /&gt;
&lt;br /&gt;
==Download==&lt;br /&gt;
From the [https://moodle.org/plugins/view.php?plugin=repository_capture Moodle plugins database]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Theme_settings&amp;diff=113395</id>
		<title>Theme settings</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Theme_settings&amp;diff=113395"/>
		<updated>2014-07-02T13:04:42Z</updated>

		<summary type="html">&lt;p&gt;Fox: /* Adding other attributes to the HTML */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Themes}}&lt;br /&gt;
== Theme settings ==&lt;br /&gt;
An administrator can change theme settings in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; Theme settings&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[File:Themesettings.png]]&lt;br /&gt;
&lt;br /&gt;
===Theme list===&lt;br /&gt;
This lists the themes available for course and user themes. Leave this blank to allow any valid theme to be used. If you want to shorten the theme menu, you may specify a comma-separated list of names, though don&#039;t use spaces (e.g. standard,orangewhite).&lt;br /&gt;
&lt;br /&gt;
You can  preview the available themes in &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; Themes selector.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Theme designer mode===&lt;br /&gt;
Turn this on if you are designing and testing themes as it will stop the themes being cached and enable you to see theme changes quickly. (You can also do this with the Clear theme cache button on the theme selector page.)&lt;br /&gt;
&lt;br /&gt;
===Allow user themes===&lt;br /&gt;
If the option &#039;&#039;allowuserthemes&#039;&#039; is enabled, each user may select their preferred theme on the edit profile page. All Moodle pages will be displayed in the user&#039;s theme, apart from courses where a course theme has been set.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; the user&#039;s theme will not be available in mobile and tablet devices unless the option &#039;&#039;enabledevicedetection&#039;&#039; is unchecked.&lt;br /&gt;
&lt;br /&gt;
===Allow course themes===&lt;br /&gt;
If you enable this, then teachers will be able to set their own course themes. Course themes override all other theme choices (site, user, or session themes).&lt;br /&gt;
&lt;br /&gt;
*If the option &#039;&#039;allowcoursethemes&#039;&#039; is enabled, each editing teacher may select their course theme via the Force theme option on the [[course/edit|Course settings]] page. The course will always be displayed in the theme specified in the course setting, with user and the site themes being overwritten.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; the course theme will not be available in mobile and tablet devices unless the option &#039;&#039;enabledevicedetection&#039;&#039; is unchecked.&lt;br /&gt;
&lt;br /&gt;
===Allow category themes===&lt;br /&gt;
When enabled, themes can be set at the category level. This will affect all child categories and courses unless they have specifically set their own theme. WARNING: Enabling category themes may affect performance, as it will result in a few extra DB queries on each page, so only turn this on if you need it!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; the category theme will not be available in mobile and tablet devices unless the option &#039;&#039;enabledevicedetection&#039;&#039; is unchecked.&lt;br /&gt;
&lt;br /&gt;
===Allow theme changes in the URL===&lt;br /&gt;
*If this is checked then the theme may be changed by adding &amp;lt;code&amp;gt;?theme=theme_name&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;&amp;amp;theme=theme_name&amp;lt;/code&amp;gt; if there are other URL parameters) to the URL in the browser. Theme names should be in lower case with spaces replaced by underscores, for example the theme &amp;quot;Formal white&amp;quot; should be entered as &amp;lt;code&amp;gt;?theme=formal_white&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Allow users to hide blocks===&lt;br /&gt;
Allows users to display and hide blocks&lt;br /&gt;
&lt;br /&gt;
===Allow blocks to use the docks===&lt;br /&gt;
*If the theme allows it, then checking this will allow the user to move blocks to the side dock.&lt;br /&gt;
&lt;br /&gt;
===Custom menu items===&lt;br /&gt;
The custommenuitems setting allows you to create a drop down menu that can be displayed by themes that support it. Currently all themes that are provided with Moodle 2.0 support this custom menu.&lt;br /&gt;
&lt;br /&gt;
You are able to create the custom menu by entering custom menu items one per line into the setting. Each item is preceded by a number of hyphens (-), the number of hyphens determines the depth of the item. So items that are &#039;&#039;&#039;NOT&#039;&#039;&#039; preceded by a hyphen appear on the top level of the menu (always visible), items with a single hyphen appear on a drop down menu below the previous top level item, and  items with two hyphens appear on a drop down menu below the previous first level item and so on.&lt;br /&gt;
&lt;br /&gt;
The content of each item is constructed of up to three bits, each separated by a &#039;&#039;&#039;|&#039;&#039;&#039; (Shift + \) character. The bits are &#039;&#039;&#039;label&#039;&#039;&#039; | &#039;&#039;&#039;url&#039;&#039;&#039; | &#039;&#039;&#039;tooltip&#039;&#039;&#039;.&lt;br /&gt;
; label : This is the text that will be shown within the menu item. You must specify a label for every item on the menu.&lt;br /&gt;
; url : This is the URL that the user will be taken to it they click the menu item. This is optional, if not provided then the item will not link anywhere.&lt;br /&gt;
; tooltip : If you provide a URL you can also choose to provide a tooltip for the link that is created with the URL. This is optional and if not set the label is used as the tooltip for the menu item.&lt;br /&gt;
&lt;br /&gt;
The following is an example of how you would create a custom menu:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Moodle community|http://moodle.org&lt;br /&gt;
-Moodle free support|http://moodle.org/support&lt;br /&gt;
-Moodle development|http://moodle.org/development&lt;br /&gt;
--Moodle Tracker|http://tracker.moodle.org&lt;br /&gt;
--Moodle Docs|https://docs.moodle.org&lt;br /&gt;
-Moodle News|http://moodle.org/news&lt;br /&gt;
Moodle company&lt;br /&gt;
-Moodle commercial hosting|http://moodle.com/hosting&lt;br /&gt;
-Moodle commercial support|http://moodle.com/support&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: The custom menu does not escape characters within the label, if you want to use a special HTML character such as an ampersand you must escape it yourself within the label. e.g. use &amp;amp;amp; instead of &amp;amp;.&lt;br /&gt;
&lt;br /&gt;
For more information on this setting please see the &#039;&#039;Using Moodle&#039;&#039; forum discussion [http://moodle.org/mod/forum/discuss.php?d=149803 Moodle 2.0: Custom menu in core]&lt;br /&gt;
&lt;br /&gt;
==== Multilanguage support ====&lt;br /&gt;
&lt;br /&gt;
You can add a language code (or a comma separated list of codes) as the 4th item of the line. The line will be then printed if and only if the user has currently selected the listed language. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
 English only|http://moodle.com|English only item|en&lt;br /&gt;
 German only|http://moodle.de|Deutsch|de,de_du,de_kids&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding other attributes to the HTML ====&lt;br /&gt;
Other attributes, such as &#039;&#039;&#039;target&#039;&#039;&#039; can be added:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
 Moodle Homepage|http://moodle.org&amp;quot; target=&amp;quot;_blank&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
The first quote closes the href attribute, allowing other attributes to be added. Do not add the closing quotation mark on the final attribute, it is added automatically by Moodle.&lt;br /&gt;
&lt;br /&gt;
===Enable device detection===&lt;br /&gt;
Will detect mobile and tablets that identify themselves via the web browser at the time of login to Moodle.   These work with the theme selector.  When the theme selector has identified a default, mobile and tablet themes, this feature will use that theme.&lt;br /&gt;
&lt;br /&gt;
===Device detection regular expressions===&lt;br /&gt;
This will allow you to customize the theme selector options.   For example, you can add a custom theme for IE6 and another for Windows CE by entering the identifying expressions the browser sends and the &amp;quot;Return value&amp;quot; you want to display as the theme selectors &amp;quot;Device type&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Special themes==&lt;br /&gt;
&lt;br /&gt;
=== Session themes ===&lt;br /&gt;
Moodle offers an additional way to set a theme - the &#039;&#039;&#039;session theme&#039;&#039;&#039;. This is set with the URL and lasts until you log out. When you next login, the site/course/user themes are active again. This option is great for theme testing and works perfectly when you want to enable different themes for different situations.&lt;br /&gt;
&lt;br /&gt;
For example you can offer a special link for PDA users and integrate the session theme &#039;&#039;orangewhitepda&#039;&#039; in that link. Nobody needs to change any settings, you just click on that link. The session theme is called by the URL parameter &amp;lt;code&amp;gt;&amp;amp;theme=orangewhitepda&amp;lt;/code&amp;gt;. The whole URL  without the session theme could look like &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://mymoodlesite.org/course/view.php?id=18&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and with the parameter for the PDA theme like &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;quot;http://mymoodlesite.org/course/view.php?id=18&amp;amp;theme=orangewhitepda&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In a standard Moodle installation, session themes are not active. To activate them the administrator must add the parameter &amp;lt;code&amp;gt;$CFG-&amp;gt;allowthemechangeonurl = true;&amp;lt;/code&amp;gt; to the Moodle &#039;&#039;config.php&#039;&#039; file in the Moodle base directory.&lt;br /&gt;
&lt;br /&gt;
=== Page theme ===&lt;br /&gt;
A page theme is for special page-only themes set by code, use &amp;lt;code&amp;gt;$PAGE-&amp;gt;force_theme()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Theme hierarchy ==&lt;br /&gt;
Here is the usual order that themes are considered by the Moodle interface.&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border:1px dashed #ddd&amp;quot;&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;text-align:left&amp;quot;&lt;br /&gt;
!Theme type&lt;br /&gt;
! style=&amp;quot;background:#eee&amp;quot;|Overwrites&lt;br /&gt;
!Display&lt;br /&gt;
! style=&amp;quot;background:#eee&amp;quot;|Setting type&lt;br /&gt;
|- style=&amp;quot;vertical-align:top&amp;quot;&lt;br /&gt;
|Site&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;| - &lt;br /&gt;
|all pages*&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|saved in theme profile&lt;br /&gt;
|- style=&amp;quot;vertical-align:top&amp;quot;&lt;br /&gt;
|User&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|Site theme&lt;br /&gt;
|all pages*&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|saved in user profile&lt;br /&gt;
|- style=&amp;quot;vertical-align:top&amp;quot;&lt;br /&gt;
|Course&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|Site, user and session themes&lt;br /&gt;
|one course&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|saved in course profile&lt;br /&gt;
|- style=&amp;quot;vertical-align:top&amp;quot;&lt;br /&gt;
|Session&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|Site and user themes&lt;br /&gt;
|all pages*&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|temporary until logout&lt;br /&gt;
|}&lt;br /&gt;
(* except courses with the course theme set)&lt;br /&gt;
&lt;br /&gt;
=== Change default  hierarchy===&lt;br /&gt;
The priority of themes can be set via the /moodle/config.php file. The order defines which theme wins when there are several set at different levels. You can set a variable called $CFG-&amp;gt;themeorder (see config-dist.php for more details). By default it is set to: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$CFG-&amp;gt;themeorder = array(&#039;course&#039;, &#039;category&#039;, &#039;session&#039;, &#039;user&#039;, &#039;site&#039;);&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Particular theme settings==&lt;br /&gt;
&lt;br /&gt;
Logo, tagline, link colour, column width, custom CSS and other settings for a particular theme may be set by an administrator in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; Theme name&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:Configuración de temas]]&lt;br /&gt;
[[fr:Réglages des thèmes]]&lt;br /&gt;
[[ja:テーマ設定]]&lt;br /&gt;
[[de:Design-Einstellungen]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Talk:Moodle.org_configuration&amp;diff=113213</id>
		<title>Talk:Moodle.org configuration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Talk:Moodle.org_configuration&amp;diff=113213"/>
		<updated>2014-06-18T10:03:03Z</updated>

		<summary type="html">&lt;p&gt;Fox: Put in on Dev docs ?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Information on this page is outdated... Would it be possible to have an update, with more details (linux distribution, PHP version...)?--[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 23:15, 16 June 2014 (WST)&lt;br /&gt;
&lt;br /&gt;
I also think this page (and perhaps all moodle.org pages) should be on Dev docs better than on all versions documentation... --[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 18:03, 18 June 2014 (WST)&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Talk:Moodle.org_configuration&amp;diff=113175</id>
		<title>Talk:Moodle.org configuration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Talk:Moodle.org_configuration&amp;diff=113175"/>
		<updated>2014-06-16T15:15:39Z</updated>

		<summary type="html">&lt;p&gt;Fox: Please update the page with actual information&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Information on this page is outdated... Would it be possible to have an update, with more details (linux distribution, PHP version...)?--[[User:Séverin Terrier|Séverin Terrier]] ([[User talk:Séverin Terrier|talk]]) 23:15, 16 June 2014 (WST)&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Unexpected_installation_halts&amp;diff=107701</id>
		<title>Unexpected installation halts</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Unexpected_installation_halts&amp;diff=107701"/>
		<updated>2013-11-12T08:46:59Z</updated>

		<summary type="html">&lt;p&gt;Fox: /* Do not upgrade incrementally */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
Sometimes the installation will hang when setting up tables, where only half the page displayed in the browser and/or other outputs are removed. Examples and causes are:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Truncated MySQL statements==&lt;br /&gt;
 &lt;br /&gt;
 (mysql): SET NAMES &#039;utf8&#039;&lt;br /&gt;
 --------------------------------------------------------------------------------&lt;br /&gt;
 (mysql): SHOW LOCAL VARIABLES LIKE &#039;character_set_database&#039;&lt;br /&gt;
 ...&lt;br /&gt;
 ...&lt;br /&gt;
 (no more statements are displayed)   &lt;br /&gt;
&lt;br /&gt;
==Missing Continue button==&lt;br /&gt;
The “Scroll to continue” link is displayed but no “Continue” button is there. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Note&#039;&#039;&#039;: There is an exception to this when upgrading an existing database and the installation may appear to hang at the roles generation phase. This process can take a very long time - so please be patient.&lt;br /&gt;
&lt;br /&gt;
Below are some solutions you can try to overcome this problem:&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Check for MySQL limits&#039;&#039;&#039;. This is often a MySQL error and not a php error. Check that there is no limit placed on your mysql database, e.g. a &amp;quot;questions&amp;quot; limit. See [http://dev.mysql.com/doc/refman/5.0/en/user-resources.html Limiting Account Resources in the MySQL manual].&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Check your .htaccess files&#039;&#039;&#039;. If the install is on a webhost, adding the following line to the .htaccess file in the Moodle directory has been known to solve the problem.&lt;br /&gt;
 AddType x-mapp-php5 .php&lt;br /&gt;
&lt;br /&gt;
:Try also renaming the .htaccess file so that it is disabled.&lt;br /&gt;
&lt;br /&gt;
==Code customizations==&lt;br /&gt;
You may also want to look and see if you&#039;ve customized any of your code.  Look at the last successful table, and then look at the block, mod, or other code that is referenced by that table.  For example, if your install hangs and continues to say that the forum tables were successful as the last message, look at /mod/forum/ for any custom code.  If you have customized code, backup those files and replace with the correct files.  You can then restart the install by renaming config.php or reinstalling your database from the backup.  If your install is successful, you can make your code changes back into the stock Moodle code.&lt;br /&gt;
&lt;br /&gt;
==Check your memory limit==&lt;br /&gt;
It may also be that the &amp;quot;memory_limit&amp;quot; in your php.ini is set too low. Please check your php.ini file and allocate the recommended amount (see [https://docs.moodle.org/en/Installing_Moodle#Requirements Moodle requirements]). For Moodle version 1.8 and above at least 40MB is  recommended.&lt;br /&gt;
&lt;br /&gt;
==Do not upgrade incrementally==&lt;br /&gt;
To avoid this problem when upgrading, it is recommended to upgrade directly from any previous version to these versions: 1.x -&amp;gt; 1.9.19 -&amp;gt; 2.2.11 -&amp;gt; 2.6.x&lt;br /&gt;
&lt;br /&gt;
A work-around to this problem is to setup a working Moodle system on your local PC or server using the [http://download.moodle.org Moodle Packages]. Once you have a running Moodle, [https://docs.moodle.org/en/Upgrading_Moodle#Backup_important_data backup the database] and import to your webhost. Then backup the Moodle code itself (the &amp;quot;moodle&amp;quot; directory on your PC) and copy this to your webhost using (for example) FTP. Finally, edit the moodle/config.php file for the new settings that have to be changed for the webhost.&lt;br /&gt;
&lt;br /&gt;
Some Moodlers have found the suggestion in http://moodle.org/mod/forum/discuss.php?d=65786#p297433 helpful, for some unknown reason. It claims that it is because the fopen function in the line (now line 426 instead of 406) was not being given a string as the first argument, but that&#039;s not true. It was a string; after the edit it is a string whose first and last characters are single quote marks. The amazing thing is that it works at all after that edit. What&#039;s even more amazing is that it fixes the problem, at least for some users. Go figure.&lt;br /&gt;
&lt;br /&gt;
==Database configuration issues==&lt;br /&gt;
If the installation hangs after entering your database details, it is likely that there is a problem with the details that you have entered for accessing the database. For example, if your MySQL database is running on port 3309 rather than the default 3306, make sure that you set the database URL to &amp;quot;http://localhost:3309&amp;quot; rather than just &amp;quot;http://localhost&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/mod/forum/view.php?id=28 Installation Forum at Moodle.org]&lt;br /&gt;
&lt;br /&gt;
[[ja:予期しないインストールの停止]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=External_database_enrolment&amp;diff=106388</id>
		<title>External database enrolment</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=External_database_enrolment&amp;diff=106388"/>
		<updated>2013-08-21T09:36:04Z</updated>

		<summary type="html">&lt;p&gt;Fox: /* Synchronization Script */ Changed cli script path and name (was 1.9 style). To do in other 2.x docs...&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Enrolment}}&lt;br /&gt;
Location: External database edit settings link in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You may use a external database (of nearly any kind) to control your enrolments. It is assumed your external database contains a field containing a course ID, a field containing a user ID, and optionally a field containing a role. These are compared against fields that you choose in the local course, user tables, and role tables.&lt;br /&gt;
&lt;br /&gt;
The following are the supported data sources, but note that you will need to have to compiled PHP with the appropriate options or through [[ODBC]].&lt;br /&gt;
&lt;br /&gt;
*access&lt;br /&gt;
*ado&lt;br /&gt;
*mssql&lt;br /&gt;
*borland_ibase&lt;br /&gt;
*csv&lt;br /&gt;
*db2&lt;br /&gt;
*fbsql&lt;br /&gt;
*firebird&lt;br /&gt;
*ibase&lt;br /&gt;
*informix72&lt;br /&gt;
*informix&lt;br /&gt;
*mysql&lt;br /&gt;
*mysqlt&lt;br /&gt;
*oci805&lt;br /&gt;
*oci8&lt;br /&gt;
*oci8po&lt;br /&gt;
*odbc&lt;br /&gt;
*odbc_mssql&lt;br /&gt;
*odbc_oracle&lt;br /&gt;
*oracle&lt;br /&gt;
*postgres64&lt;br /&gt;
*postgres7&lt;br /&gt;
*postgres&lt;br /&gt;
*proxy&lt;br /&gt;
*sqlanywhere&lt;br /&gt;
*sybase&lt;br /&gt;
*vfp&lt;br /&gt;
&lt;br /&gt;
== Enrolment &amp;amp; Unenrolment ==&lt;br /&gt;
&lt;br /&gt;
External database enrolment happens at the moment when a user logs into Moodle. The plugin will attempt to automatically enrol the student in all their courses according to the data in the external database and, optionally, create empty courses where they do not already exist. To check if it is working, you can log in as a student and then check that their list of courses is as you would expect. &lt;br /&gt;
&lt;br /&gt;
The process also unenrols users from courses if they are no longer in the database. User records are marked according to their original enrolment method. Therefore the external database plugin can only unenrol users who were enroled by the plugin in the first place.&lt;br /&gt;
&lt;br /&gt;
== Hidden Courses ==&lt;br /&gt;
&lt;br /&gt;
Courses that are set to &amp;quot;Course is not available to students&amp;quot; can be ignored for enrolment purposes by setting the &amp;quot;enrol_db_ignorehiddencourse&amp;quot; to &#039;&#039;&#039;yes&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Enrolment &amp;amp; Roles ==&lt;br /&gt;
&lt;br /&gt;
The &amp;quot;enrol_db_defaultcourseroleid&amp;quot; setting in the plugin settings page specifies the role that the user will take when they are added to the course. The default setting will set them to the course default setting (initially &amp;quot;student&amp;quot;). However, you can specify a field in the external table (specified in the &amp;quot;enrol_db_remoterolefield&amp;quot; setting) that contains the short name for the user&#039;s role. This could, for example, be used to enrol both students and teachers into courses using a suitably configured database. &lt;br /&gt;
&lt;br /&gt;
== Creating Courses ==&lt;br /&gt;
&lt;br /&gt;
Optionally courses that do not exist in the Moodle site can be created. Switch the &amp;quot;enrol_db_autocreate&amp;quot; option to &amp;quot;yes&amp;quot; in the plugin settings. &lt;br /&gt;
&lt;br /&gt;
You can additionally specify the Category into which the new course will be placed, in the &#039;&#039;&#039;New course category id field&#039;&#039;&#039;. The data in this field must be the id of a currently existing category; it will not create a new category. The id number is number assigned by Moodle in the database when the category is created (e.g. mdl_course_categories.id). &lt;br /&gt;
&lt;br /&gt;
* Do not confuse this &#039;&#039;category id&#039;&#039; with the new custom &#039;&#039;category id number&#039;&#039; field that you can manually assign to a category. (See Trackers http://tracker.moodle.org/browse/MDL-28518 and http://tracker.moodle.org/browse/MDL-31845). &lt;br /&gt;
* Leaving the category id data empty means that a course will be assigned to the default category.&lt;br /&gt;
* If you assign data to categories that do  not exist already in Moodle, the courses will not be created.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Default new course category&#039;&#039;&#039; is the category to which courses will be assigned and created in, unless you set up and so indicate in the data field of the &amp;quot;New course category id field.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
You may also specify a &#039;&#039;&#039;New course template&#039;&#039;&#039;: a &amp;quot;template&amp;quot; course from which the new course will be copied. The data for this field should be the &#039;&#039;shortname&#039;&#039; of the template course.&lt;br /&gt;
&lt;br /&gt;
== Synchronization Script ==&lt;br /&gt;
&lt;br /&gt;
A script is provided that can synchronize all your user enrollments at once - both adding and removing user enrolments (and creating courses if specified). The script is called sync.php and is found in the enrol/database/cli folder.&lt;br /&gt;
&lt;br /&gt;
This script is meant to be called from a system cronjob to sync moodle enrolments with enrolments in the external database. You need to make sure all the users present in the external enrolments are already created in moodle. If you are using external authentication plugins (db, ldap, etc.) you can use the scripts provided by those plugins to synchronize your users before running this script.&lt;br /&gt;
&lt;br /&gt;
Example cron entry for Moodle 2.5&lt;br /&gt;
    # 5 minutes past 4am&lt;br /&gt;
    5 4 * * * /usr/bin/php -c /path/to/php.ini /path/to/moodle/enrol/database/cli/sync.php&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* If you have a large number of enrolments, you may want to raise the memory limits by passing -d memory_limit=256M&lt;br /&gt;
* For debugging &amp;amp; better logging, you are encouraged to use in the command line: -d log_errors=1 -d error_reporting=E_ALL -d display_errors=0 -d html_errors=0&lt;br /&gt;
* This only works for users that already exist in your Moodle site (see comment above)&lt;br /&gt;
&lt;br /&gt;
== Setting up enrolment sync (How to) ==&lt;br /&gt;
&lt;br /&gt;
You will need to perform (as a minimum) the following steps to enable external database enrolment - only a single table is required in the database which contains a record for every user/course combination. If the table is large it is a good idea to make sure appropriate indexes have been created:&lt;br /&gt;
&lt;br /&gt;
* Use an existing database or create a new one. Use an existing table or create a new one with the following minimum fields.&lt;br /&gt;
*# A unique course identifier to match one of the following fields.&lt;br /&gt;
*#* the &amp;quot;idnumber&amp;quot; field in Moodle&#039;s course table (varchar 100), which is manually specified as the &amp;quot;Course ID number&amp;quot; when editing a course&#039;s settings&lt;br /&gt;
*#* the &amp;quot;shortname&amp;quot; field in Moodle&#039;s course table (varchar 255), which is manually specified as the &amp;quot;Course short name&amp;quot; when editing a course&#039;s settings&lt;br /&gt;
*#* the &amp;quot;id&amp;quot; field in Moodle&#039;s course table (int 10), which is based on course creation order&lt;br /&gt;
*# A unique user identifier to match one of the following fields.&lt;br /&gt;
*#* the &amp;quot;idnumber&amp;quot; field in Moodle&#039;s user table (varchar 255), which is manually specified as the &amp;quot;ID number&amp;quot; when editing a user&#039;s profile&lt;br /&gt;
*#* the &amp;quot;username&amp;quot; field in Moodle&#039;s user table (varchar 100), which is manually specified as the &amp;quot;Username&amp;quot; when editing a user&#039;s profile&lt;br /&gt;
*#* the &amp;quot;email&amp;quot; field in Moodle&#039;s user table (varchar 100), which is manually specified as the &amp;quot;Email address&amp;quot; when editing a user&#039;s profile&lt;br /&gt;
*#* the &amp;quot;id&amp;quot; field in Moodle&#039;s user table (int 10), which is based on user creation order&lt;br /&gt;
*# (optional) A unique role identifier to match one of the following fields.&lt;br /&gt;
*#* the &amp;quot;shortname&amp;quot; field in Moodle&#039;s role table (varchar 100), for example editingteacher, coursecreator, student, ...&lt;br /&gt;
*#* the &amp;quot;name&amp;quot; field in Moodle&#039;s role table (varchar 255), for example Teacher, Course creator, Student, ...&lt;br /&gt;
*#* the &amp;quot;id&amp;quot; field in Moodle&#039;s role table (int 10), which is based on initial installation and new role creation order&lt;br /&gt;
* Populate the database table. Each user/course combination to have a record in the table.&lt;br /&gt;
* In Moodle, go to Site administration =&amp;gt; Plugins =&amp;gt; Enrolments =&amp;gt; Manage enrol plugins, find External Database in the list, enable it (click the closed-eye icon) and click Settings.&lt;br /&gt;
* In the top panel, select the database type (make sure you have the necessary configuration in PHP for that type) and then supply the information to connect to the database.&lt;br /&gt;
* The middle panel creates the mapping between Moodle and the external database. The first three settings are for the local (Moodle) field names and the last three for the remote (external database) settings. They are in the same order.&lt;br /&gt;
** enrol_localcoursefield / enrol_remotecoursefield - in Moodle the name of the field in the course settings the uniquely identifies the course (e.g., idnumber). In the external database the name of the matching field.&lt;br /&gt;
** enrol_localuserfield / enrol_remoteuserfield - in Moodle the name of the field in the user profile that uniquely identified the user (e.g., idnumber). In the external database the name of the matching field.&lt;br /&gt;
** enrol_db_localrolefield / enrol_db_remoterolefield - (optional) in Moodle the name of the field in the role edit page the uniquely identifies the role (e.g., shortname). In the external database the name of the matching field.&lt;br /&gt;
* The Roles panel specifies the role that the user will get in the course if their role is not specified in the external database.&lt;br /&gt;
* The final panel enables auto creation of courses.&lt;br /&gt;
* Save changes, and then tick the box to enable external database enrolment.&lt;br /&gt;
&lt;br /&gt;
== Database enrolment does not appear in the course enrolment drop down menu. Why? ==&lt;br /&gt;
&lt;br /&gt;
The course enrolment drop down menu only lists [[Enrolment_plugins#Interactive_enrolment|&#039;&#039;&#039;interactive&#039;&#039;&#039; enrolment plugins]]. External database enrolment is not such a plugin, so it doesn&#039;t appear in the list. Similarly, the &amp;quot;Course Enrollable&amp;quot; setting (in the Course Settings) page also only applies to interactive enrolment plugins and has no effect on external database enrollment. &lt;br /&gt;
&lt;br /&gt;
As of this writing, the only interactive enrolment plugins are &#039;&#039;manual&#039;&#039; (also know as &#039;&#039;internal&#039;&#039;), &#039;&#039;paypal&#039;&#039; and &#039;&#039;authorize.net&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
== Field Mapping Example: ==&lt;br /&gt;
Choose your fields from the Moodle database:&lt;br /&gt;
&lt;br /&gt;
*enrol_localcoursefield:  A course identifier from mdl_course, e.g. &amp;quot;idnumber&amp;quot;&lt;br /&gt;
*enrol_localuserfield: A user identifier from mdl_user, e.g. &amp;quot;idnumber&amp;quot;&lt;br /&gt;
*enrol_localrolefield: (optional) A role identifier from mdl_role, e.g. &amp;quot;shortname&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Create a view in your external database which matches the chosen field values from Moodle:&lt;br /&gt;
&lt;br /&gt;
*enrol_remotecoursefield: A matching course identifier from your external database table, e.g. &amp;quot;course_number&amp;quot;&lt;br /&gt;
*enrol_remoteuserfield: A matching user identifier from your external database table, e.g. &amp;quot;userid&amp;quot;&lt;br /&gt;
*enrol_remoterolefield: (optional) A matching role identifier from your external database table, e.g. &amp;quot;role_name&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Potential Gotchas ==&lt;br /&gt;
&lt;br /&gt;
* It almost goes without saying that the integrity of the external database is important. If data is missing from the database then there is a potential for users being unenrolled from some or all of their courses. The unenrollment process will remove them from any group assignments and also poll each module type to give the module the option of removing that user&#039;s data if appropriate (for example, however, forum posts are never deleted). It is therefore prudent that you take the utmost care to ensure that the data in the external bass is correct at all times.&lt;br /&gt;
* &#039;&#039;&#039;Minor Security Issue&#039;&#039;&#039; Consider that if the ID number field you use to identify your students is editable by the students (in their profile), then there is a potential for them changing this to the id of another valid student and gaining access to resources that they should not. (However, they will still appear as themselves, they cannot impersonate the other user or otherwise gain access to their resources.) To prevent this and similar issues, you can lock the ID number as well as other fields so the user can not change them. Do this in the &#039;&#039;&#039;Data mapping&#039;&#039;&#039; section of &#039;&#039;Settings&amp;gt;Site administration&amp;gt;Plugins&amp;gt;Authentication&amp;gt;External database&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Errors and Diagnostics==&lt;br /&gt;
&lt;br /&gt;
The plugin produces a number of diagnostic messages and/or errors which are recorded to the PHP error log (as defined in the php.ini file). In addition messages about courses that are in the database for the user but that do not exist in the Moodle site will only be produced if debugging is set to ALL or DEVELOPER.&lt;br /&gt;
&lt;br /&gt;
You can get detailed progress information by executing the sync script  with -v parameter:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
 php /path/to/moodle/enrol/database/cli/sync.php -v&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=49475 MySQL enrolment plugin doesn&#039;t seem to work] forum discussion&lt;br /&gt;
*Using Moodle [http://moodle.org/mod/forum/discuss.php?d=74133 Someone explain external database enrolment, please??] forum discussion&lt;br /&gt;
*Example Setup [https://docs.moodle.org/en/Talk:External_database_enrolment#Example_External_Enrollment] Example Database Enrollment Setup&lt;br /&gt;
&lt;br /&gt;
[[es:Matriculación Base de Datos Externa]]&lt;br /&gt;
[[fr:Base de données externe]]&lt;br /&gt;
[[de:Einschreibung über externe Datenbank]]&lt;br /&gt;
[[ja:外部データベース登録]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=File_handling&amp;diff=106214</id>
		<title>File handling</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=File_handling&amp;diff=106214"/>
		<updated>2013-07-31T07:33:27Z</updated>

		<summary type="html">&lt;p&gt;Fox: Typo (same problem in other 2.x versions)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Working with files and folders}}&lt;br /&gt;
{{Improve}}&lt;br /&gt;
&lt;br /&gt;
The way files are handled in Moodle 2.0 has changed from earlier versions. Students and teachers will use the [[File picker]] to upload and organize their files in areas called [[Repositories]]. Repositories can be located on the Moodle site or externally. Site administrators can [[Manage repositories|reveal, restrict, add, edit or create repositories]] for the site. &lt;br /&gt;
&lt;br /&gt;
* Previously, if a file was used in different courses, it was duplicated. In Moodle 2.0, files are stored only once, saving disk space.&lt;br /&gt;
* Full support for Unicode file names on all operating systems.&lt;br /&gt;
* Metadata about each file (author, date, license, etc) and what the file is used for are stored in the database.&lt;br /&gt;
* Files are no longer just &amp;quot;uploaded to the course&amp;quot;.  Files are connected to the particular bit of Moodle content that uses them. (For example, a file may belong to a file resource, a forum post or a wiki page). Access to these files is controlled by the same [[Context|contextual]] [[Roles and capabilities|rules]] as as that bit of Moodle, increasing security.&lt;br /&gt;
* File picker has a list (file tree) or icon view &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A video on file handling in Moodle 2.0:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;mediaplayer&amp;gt;http://www.youtube.com/watch?v=2bUwx675Pqo&amp;lt;/mediaplayer&amp;gt;&lt;br /&gt;
== How is Moodle 2.0 better? ==&lt;br /&gt;
*There is no course Files space - good because you don&#039;t have to keep it tidy any more.&lt;br /&gt;
*Access to a file is based on the resource or activity to which it&#039;s connected; from any context you can easily get to a file - good because you can now easily link to files between areas you have editing access to.&lt;br /&gt;
*You can access the File Picker from many more places - good because it helps to avoid tedious and overwhelming front pages.&lt;br /&gt;
*Deleting a link to a file will delete the file - good because your files area won&#039;t become unkempt and unwieldy any longer, and because it will help to keep Moodle&#039;s database small.&lt;br /&gt;
*At the same time you can&#039;t delete a file which is linked elsewhere - good because it is now impossible to break a link.&lt;br /&gt;
&lt;br /&gt;
== Typical Moodle 2.0 workflow ==&lt;br /&gt;
Edit text or activity. Use the file picker to easily select the file from any local or remote repository. The file is then copied to Moodle and stored securely with the text or activity. &lt;br /&gt;
&lt;br /&gt;
Or Edit text or url resource. Use the file picker to select a file from any local or remote repository and select &amp;quot;link&amp;quot;. The file URL is then embedded into the text and when viewed, the media comes directly from the open repository.&lt;br /&gt;
&lt;br /&gt;
The standard Moodle install has  4 default areas (repositories) displayed in file picker for the teacher to select:&lt;br /&gt;
*Server - &lt;br /&gt;
*Recent -&lt;br /&gt;
*Upload -&lt;br /&gt;
*[[Private files]]&lt;br /&gt;
&lt;br /&gt;
The site administrator can expand the above list to include 15 other predefined repository areas.  For example, the teacher may see a file picker link to a Google Docs or UTube repositories where they can find files. As in the previous versions, the teacher can create a folder structure to store the files at the time files are uploaded.&lt;br /&gt;
&lt;br /&gt;
==FAQ==&lt;br /&gt;
Caveat: these are just making a start on these.  Subject to quality, style and accuracy improvements.&lt;br /&gt;
&lt;br /&gt;
===What are ways to make files available to other teachers/designers?===&lt;br /&gt;
In Moodle 2, this is going to require a change of habits. Some of the philosophy is written up in a small essay on course files [[Course_files|here]]&lt;br /&gt;
&lt;br /&gt;
One approach is to use a [[Repositories| repository]].  One of the easiest to set up is a [[File_system_repository_configuration|File System Repository]]  &lt;br /&gt;
&lt;br /&gt;
This needs server access.  One such example:&lt;br /&gt;
&lt;br /&gt;
[[Image:Repository-filesystem-filepicker.png]]&lt;br /&gt;
&lt;br /&gt;
===What are ways to make ONE change in a file and have this reflected across a Moodle site?===&lt;br /&gt;
This also will require a change in thinking.  You cannot just go to the file in the file picker and change it&#039;s name or upload a new file.  This would cause problems if it was linked to elsewhere.&lt;br /&gt;
&lt;br /&gt;
One answer is again to use repositories.  &#039;&#039;&#039;Link&#039;&#039;&#039; to the files in the repository.  Change the files (according to the permissions on the repository) and this is reflected everywhere in the course instantly.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [http://www.youtube.com/watch?v=JtePGeffl3o&amp;amp;feature=player_embedded Video: How teachers can upload files in Moodle 2.0]&lt;br /&gt;
* [[Course files]]&lt;br /&gt;
* [[Development:File API]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=160067 File Manager In Moodle 2.0] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Files]]&lt;br /&gt;
&lt;br /&gt;
[[de:Dateiverwaltung in Moodle 2.0]]&lt;br /&gt;
[[fr:Gestion des fichiers 2.0]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Site_administrators&amp;diff=103063</id>
		<title>Site administrators</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Site_administrators&amp;diff=103063"/>
		<updated>2013-02-08T08:53:50Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Standard roles}}&lt;br /&gt;
Site administrators have permissions to do anything. &lt;br /&gt;
&lt;br /&gt;
Users may be assigned the role of site administrator by another site administrator in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Site administrators&#039;&#039;, but the role itself cannot be edited (or deleted!).&lt;br /&gt;
&lt;br /&gt;
[[File:Managesiteadministrators.png]]&lt;br /&gt;
&lt;br /&gt;
Note: The primary administrator (created when the site was created) cannot be removed from the site administrator role.&lt;br /&gt;
&lt;br /&gt;
[[de:Administrator-Rolle]]&lt;br /&gt;
[[fr:Administrateur]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=User:S%C3%A9verin_Terrier&amp;diff=102678</id>
		<title>User:Séverin Terrier</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=User:S%C3%A9verin_Terrier&amp;diff=102678"/>
		<updated>2013-01-08T10:12:12Z</updated>

		<summary type="html">&lt;p&gt;Fox: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Working in [http://www.ut-capitole.fr Université Toulouse 1 Capitole], i&#039;m administrator of several Moodle sites.&lt;br /&gt;
&lt;br /&gt;
In Moodle community, i :&lt;br /&gt;
* assist [[User:Nicolas Martignoni|Nicolas Martignoni]] for [http://moodle.org/course/view.php?id=20 Moodle en français].&lt;br /&gt;
* try to improve the [[:fr:|french Moodle documentation]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Utilisateur:Séverin Terrier]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Upgrading&amp;diff=102202</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Upgrading&amp;diff=102202"/>
		<updated>2012-11-27T09:36:15Z</updated>

		<summary type="html">&lt;p&gt;Fox: Use 2.4 informations&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}	&lt;br /&gt;
&#039;&#039;This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Check the requirements==&lt;br /&gt;
&lt;br /&gt;
Check that your server meets all requirements for 2.4 in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Note: You can only upgrade to Moodle 2.4 from Moodle 2.2 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/22/en/Upgrading_to_Moodle_2.2 upgrade to 2.2] as a first step.&lt;br /&gt;
&lt;br /&gt;
==Checking database schema - old sites==&lt;br /&gt;
&lt;br /&gt;
If your Moodle site has been upgraded through many prior versions it is possible that there will be some problems with the database schema (compared to a fresh 2.4 installation). This may cause the upgrade to fail. If your site started life prior to Moodle 2.0 it is a very good idea to check and correct the database schema before upgrading. See [[Verify Database Schema]]. You should also run the database integrity checks in the XMLDB editor.&lt;br /&gt;
&lt;br /&gt;
==Contributed plugins==&lt;br /&gt;
&lt;br /&gt;
Any contributed/custom plugins (including themes) that you have previously installed on your site will also need to be replaced with a version suitable for Moodle 2.4 &#039;&#039;before&#039;&#039; upgrading your Moodle installation.&lt;br /&gt;
* Check in the [http://moodle.org/plugins Moodle Plugins directory] for a Moodle 2.4 version of the plugin and copy it to the appropriate location in your Moodle code.&lt;br /&gt;
* The upgrade of the plugin will happen as part of the Moodle upgrade process.&lt;br /&gt;
* If there is not a Moodle 2.4 version of the plugin available, you will need to [[Installing plugins|uninstall the plugin]] before upgrading, otherwise the Moodle upgrade will fail.&lt;br /&gt;
&lt;br /&gt;
==Before you upgrade your site for real==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Backup important data ==&lt;br /&gt;
&lt;br /&gt;
There are three areas that should be backed up before any upgrade:&lt;br /&gt;
#Moodle software (For example, everything in server/htdocs/moodle)&lt;br /&gt;
#Moodle uploaded files (For example, server/moodledata)&lt;br /&gt;
#Moodle database (For example, the SQL or Postgres database)&lt;br /&gt;
&lt;br /&gt;
See [[Site backup]] for more specific information.&lt;br /&gt;
&lt;br /&gt;
==Put your Site into maintenance mode==&lt;br /&gt;
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in.&lt;br /&gt;
&lt;br /&gt;
== Install the new Moodle software ==&lt;br /&gt;
&lt;br /&gt;
=== Standard install package ===&lt;br /&gt;
&lt;br /&gt;
# Move your old Moodle software program files to another location. &#039;&#039;Do NOT copy new files over the old files.&#039;&#039;&lt;br /&gt;
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.&lt;br /&gt;
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. &lt;br /&gt;
# As mentioned above, if you had installed any custom plugins on your site you should add them to the new code. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle. &lt;br /&gt;
&lt;br /&gt;
====Linux====&lt;br /&gt;
 mv moodle moodle.backup&lt;br /&gt;
 tar xvzf moodle-2.4.tgz&lt;br /&gt;
&lt;br /&gt;
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (&#039;&#039;&#039;check that custom plugins are the correct version for your new Moodle first&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 cp moodle.backup/config.php moodle&lt;br /&gt;
 cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme&lt;br /&gt;
 cp -pr moodle.backup/mod/mymod moodle/mod/mymod&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make moodle/config.php (and the rest of the source code) readable by your www server. Ideally the files should not be writeable by your server.&lt;br /&gt;
&lt;br /&gt;
If you use cron, take care that cron.php is executeable and uses the correct php command: &lt;br /&gt;
 chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)&lt;br /&gt;
 copy the first line from cron.php (if it looks like &#039;#!/usr/local/bin/php&#039; or &#039;#!/usr/local/bin/php5.3&#039;, no need to copy &#039;&amp;lt;?php&#039;)&lt;br /&gt;
&lt;br /&gt;
if necessary.&lt;br /&gt;
&lt;br /&gt;
=== Using Git ===&lt;br /&gt;
&lt;br /&gt;
You can use Git for updating or upgrading your Moodle. New sites are recommended to use this rather than CVS since all Moodle development has moved to Git. See [[Git for Administrators]] for details.&lt;br /&gt;
&lt;br /&gt;
===Command line upgrade===&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle 2.4 supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
== Finishing the upgrade ==&lt;br /&gt;
&lt;br /&gt;
The last step is to trigger the upgrade processes within Moodle. &lt;br /&gt;
&lt;br /&gt;
To do this just go to &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Notifications&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can&#039;t do itself (very rare) then you will see messages telling you what you need to do.&lt;br /&gt;
&lt;br /&gt;
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!&lt;br /&gt;
&lt;br /&gt;
==After upgrading==&lt;br /&gt;
&lt;br /&gt;
The config.php file from your 2.2 or 2.3 installation should work fine but if you take a look at config-dist.php that came with Moodle 2.4 there are more/different options available (e.g. database drivers and settings). It&#039;s a good idea to map your old config.php settings to a new one based on the 2.4 config-dist.php.&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you in Moodle 2.4==&lt;br /&gt;
&lt;br /&gt;
=== Two assignment modules ===&lt;br /&gt;
&lt;br /&gt;
A new assignment module was added in Moodle 2.3. The old assignment module is still available (renamed &#039;Assignments 2.2&#039;) and sites which have upgraded from previous versions will have both versions available.&lt;br /&gt;
&lt;br /&gt;
It is recommended that admins upgrade all existing assignments to use the new assignment module as soon as possible, as described in [[Upgrade tool|Assignment upgrade tool]], then disable the old assignment module, to avoid the confusion of having two assignment modules.&lt;br /&gt;
&lt;br /&gt;
===Google registration required for Google Docs and Picasa plugins===&lt;br /&gt;
&lt;br /&gt;
Due to a change in Google&#039;s service, Moodle 2.3 onwards has switched to a more secure and more user-friendly system for communicating with Google called &#039;OAuth 2.0&#039;. As a result, any Google Docs and Picasa plugins (the Google Docs and Picasa repositories and the Google Docs and Picasa portfolios) used previously on the site will be disabled when the site is upgraded.&lt;br /&gt;
&lt;br /&gt;
To re-enable these plugins, an administrator must register their site with Google, as described in [[Google OAuth 2.0 setup]], and obtain a client ID and secret. The client ID and secret can then be used to configure all Google Docs and Picasa plugins.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum] &lt;br /&gt;
* [[dev:Moodle 2.4 release notes|Moodle 2.4 release notes]]&lt;br /&gt;
* [[dev:Upgrade API|Upgrade API]]&lt;br /&gt;
&lt;br /&gt;
[[es:Actualización de moodle]]&lt;br /&gt;
[[fr:Mise à jour]]&lt;br /&gt;
[[ja:Moodleをアップグレードする]]&lt;br /&gt;
[[de:Aktualisierung von Moodle]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Upgrading&amp;diff=102024</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Upgrading&amp;diff=102024"/>
		<updated>2012-11-20T11:09:04Z</updated>

		<summary type="html">&lt;p&gt;Fox: /* Install the new Moodle software */ Typo&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}	&lt;br /&gt;
&#039;&#039;This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Check the requirements==&lt;br /&gt;
&lt;br /&gt;
Check that your server meets all requirements for 2.4 in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Note: You can only upgrade to Moodle 2.4 from Moodle 2.2 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/22/en/Upgrading_to_Moodle_2.2 upgrade to 2.2] as a first step.&lt;br /&gt;
&lt;br /&gt;
==Checking database schema - old sites==&lt;br /&gt;
&lt;br /&gt;
If your Moodle site has been upgraded through many prior versions it is possible that there will be some problems with the database schema (compared to a fresh 2.4 installation). This may cause the upgrade to fail. If your site started life prior to Moodle 2.0 it is a very good idea to check and correct the database schema before upgrading. See [[Verify Database Schema]]. You should also run the database integrity checks in the XMLDB editor.&lt;br /&gt;
&lt;br /&gt;
==Contributed plugins==&lt;br /&gt;
&lt;br /&gt;
Any contributed/custom plugins (including themes) that you have previously installed on your site will also need to be replaced with a version suitable for Moodle 2.4 &#039;&#039;before&#039;&#039; upgrading your Moodle installation.&lt;br /&gt;
* Check in the [http://moodle.org/plugins Moodle Plugins directory] for a Moodle 2.4 version of the plugin and copy it to the appropriate location in your Moodle code.&lt;br /&gt;
* The upgrade of the plugin will happen as part of the Moodle upgrade process.&lt;br /&gt;
* If there is not a Moodle 2.4 version of the plugin available, you will need to [[Installing plugins|uninstall the plugin]] before upgrading, otherwise the Moodle upgrade will fail.&lt;br /&gt;
&lt;br /&gt;
==Before you upgrade your site for real==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Backup important data ==&lt;br /&gt;
&lt;br /&gt;
There are three areas that should be backed up before any upgrade:&lt;br /&gt;
#Moodle software (For example, everything in server/htdocs/moodle)&lt;br /&gt;
#Moodle uploaded files (For example, server/moodledata)&lt;br /&gt;
#Moodle database (For example, the SQL or Postgres database)&lt;br /&gt;
&lt;br /&gt;
See [[Site backup]] for more specific information.&lt;br /&gt;
&lt;br /&gt;
==Put your Site into maintenance mode==&lt;br /&gt;
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in.&lt;br /&gt;
&lt;br /&gt;
== Install the new Moodle software ==&lt;br /&gt;
&lt;br /&gt;
=== Standard install package ===&lt;br /&gt;
&lt;br /&gt;
# Move your old Moodle software program files to another location. &#039;&#039;Do NOT copy new files over the old files.&#039;&#039;&lt;br /&gt;
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.&lt;br /&gt;
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. &lt;br /&gt;
# As mentioned above, if you had installed any custom plugins on your site you should add them to the new code. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle. &lt;br /&gt;
&lt;br /&gt;
====Linux====&lt;br /&gt;
 mv moodle moodle.backup&lt;br /&gt;
 tar xvzf moodle-1.1.tgz&lt;br /&gt;
&lt;br /&gt;
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (&#039;&#039;&#039;check that custom plugins are the correct version for your new Moodle first&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 cp moodle.backup/config.php moodle&lt;br /&gt;
 cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme&lt;br /&gt;
 cp -pr moodle.backup/mod/mymod moodle/mod/mymod&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make moodle/config.php (and the rest of the source code) readable by your www server. Ideally the files should not be writeable by your server.&lt;br /&gt;
&lt;br /&gt;
If you use cron, take care that cron.php is executeable and uses the correct php command: &lt;br /&gt;
 chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)&lt;br /&gt;
 copy the first line from cron.php (if it looks like &#039;#!/usr/local/bin/php&#039; or &#039;#!/usr/local/bin/php5.3&#039;, no need to copy &#039;&amp;lt;?php&#039;)&lt;br /&gt;
&lt;br /&gt;
if necessary.&lt;br /&gt;
&lt;br /&gt;
=== Using Git ===&lt;br /&gt;
&lt;br /&gt;
You can use Git for updating or upgrading your Moodle. New sites are recommended to use this rather than CVS since all Moodle development has moved to Git. See [[Git for Administrators]] for details.&lt;br /&gt;
&lt;br /&gt;
===Command line upgrade===&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle 2.3 supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
== Finishing the upgrade ==&lt;br /&gt;
&lt;br /&gt;
The last step is to trigger the upgrade processes within Moodle. &lt;br /&gt;
&lt;br /&gt;
To do this just go to &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Notifications&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can&#039;t do itself (very rare) then you will see messages telling you what you need to do.&lt;br /&gt;
&lt;br /&gt;
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!&lt;br /&gt;
&lt;br /&gt;
==After upgrading==&lt;br /&gt;
&lt;br /&gt;
The config.php file from your 2.2 installation should work fine but if you take a look at config-dist.php that came with Moodle 2.4 there are more/different options available (e.g. database drivers and settings). It&#039;s a good idea to map your old config.php settings to a new one based on the 2.3 config-dist.php.&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you in Moodle 2.4==&lt;br /&gt;
&lt;br /&gt;
=== Two assignment modules ===&lt;br /&gt;
&lt;br /&gt;
A new assignment module was added in Moodle 2.3. The old assignment module is still available (renamed &#039;Assignments 2.2&#039;) and sites which have upgraded from previous versions will have both versions available.&lt;br /&gt;
&lt;br /&gt;
It is recommended that admins upgrade all existing assignments to use the new assignment module as soon as possible, as described in [[Upgrade tool|Assignment upgrade tool]], then disable the old assignment module, to avoid the confusion of having two assignment modules.&lt;br /&gt;
&lt;br /&gt;
===Google registration required for Google Docs and Picasa plugins===&lt;br /&gt;
&lt;br /&gt;
Due to a change in Google&#039;s service, Moodle 2.3 onwards has switched to a more secure and more user-friendly system for communicating with Google called &#039;OAuth 2.0&#039;. As a result, any Google Docs and Picasa plugins (the Google Docs and Picasa repositories and the Google Docs and Picasa portfolios) used previously on the site will be disabled when the site is upgraded.&lt;br /&gt;
&lt;br /&gt;
To re-enable these plugins, an administrator must register their site with Google, as described in [[Google OAuth 2.0 setup]], and obtain a client ID and secret. The client ID and secret can then be used to configure all Google Docs and Picasa plugins.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum] &lt;br /&gt;
* [[dev:Moodle 2.4 release notes|Moodle 2.4 release notes]]&lt;br /&gt;
* [[dev:Upgrade API|Upgrade API]]&lt;br /&gt;
&lt;br /&gt;
[[es:Actualización de moodle]]&lt;br /&gt;
[[fr:Mise à jour]]&lt;br /&gt;
[[ja:Moodleをアップグレードする]]&lt;br /&gt;
[[de:Aktualisierung von Moodle]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Verify_Database_Schema&amp;diff=98200</id>
		<title>Verify Database Schema</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Verify_Database_Schema&amp;diff=98200"/>
		<updated>2012-06-06T14:05:28Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
If you have been upgrading your Moodle site over several versions, it is possible (likely even) that some differences may have crept in between the database table definitions (the &amp;quot;schema&amp;quot;) in your database and the version you would get creating a new empty site. This happens because of small errors or oversights in the upgrade scripts. Most of these differences are not harmful, but some may cause strange or unexpected errors. For example, if a default value has been added to a field and this was not reflected in an upgrade script code that assumes the presence of the default may fail to work as expected. &lt;br /&gt;
&lt;br /&gt;
The solution is after doing an upgrade (or, if your problem is that the upgrade fails, before) to compare the database schema of the &amp;quot;production&amp;quot; site to that of a newly created site (where no upgrades have been performed) using &#039;&#039;&#039;exactly&#039;&#039;&#039; the same code base. There are a number of ways of doing this, but this article outlines a simple way using the Unix command line.&lt;br /&gt;
&lt;br /&gt;
* Complete the upgrade&lt;br /&gt;
* Generate the database schema from your recently upgraded site using the following command:&lt;br /&gt;
    mysqldump -d -u root -p &#039;&#039;myproductiondb&#039;&#039; &amp;gt;production.schema&lt;br /&gt;
* Copy the code  of your production database to a new (web accessible) location (this is important, it *must* be the same version)&lt;br /&gt;
* Create a new, empty database and moodledata area for the new site as per the [[Installation]] instructions&lt;br /&gt;
* Edit the config.php file to point at the new database and locations, or delete it and use the install script&lt;br /&gt;
* Run the install script to generate the (if applicable) config.php file and the database (admin and site values are not important)&lt;br /&gt;
* Generate the database schema from your new site using the following command:&lt;br /&gt;
    mysqldump -d -u root -p &#039;&#039;mycleandb&#039;&#039; &amp;gt;clean.schema&lt;br /&gt;
* Run the following command to detect the differences&lt;br /&gt;
    diff -u production.schema clean.schema &amp;gt;db.diff&lt;br /&gt;
&lt;br /&gt;
You can now look at &#039;&#039;db.diff&#039;&#039; with your favorite editor to see the differences.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; The above obviously applies to MySQL databases. Other databases are likely to have a similar function to dump only the schema. For example PostgreSQL has the &#039;&#039;&#039;pg_dump&#039;&#039;&#039; command. The remainder of the discussion still applies. &lt;br /&gt;
&lt;br /&gt;
==Interpreting the diff file==&lt;br /&gt;
&lt;br /&gt;
Firstly here&#039;s a (real) example:&lt;br /&gt;
&lt;br /&gt;
     --&lt;br /&gt;
     -- Table structure for table `mdl_backup_config`&lt;br /&gt;
        @@ -129,11 +93,11 @@&lt;br /&gt;
         DROP TABLE IF EXISTS `mdl_backup_config`;&lt;br /&gt;
         CREATE TABLE `mdl_backup_config` (&lt;br /&gt;
    -  `id` int(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
    +  `id` bigint(10) unsigned NOT NULL auto_increment,&lt;br /&gt;
       `name` varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
       `value` varchar(255) NOT NULL default &#039;&#039;,&lt;br /&gt;
        PRIMARY KEY  (`id`),&lt;br /&gt;
    -  UNIQUE KEY `name` (`name`)&lt;br /&gt;
    +  UNIQUE KEY `mdl_backconf_nam_uix` (`name`)&lt;br /&gt;
         ) ENGINE=MyISAM AUTO_INCREMENT=15 DEFAULT CHARSET=utf8 COMMENT=&#039;To store backup configuration variables&#039;;&lt;br /&gt;
&lt;br /&gt;
The file may have lots of blocks of changes. The - lines show lines to be taken out and the + lines the ones to replace them (from the production to the clean). So here, the int has been replaced with a bigint and the key name changed. Both of these, technically, should have been changed at some point by upgrade scripts but have been missed. In this case they are unlikely to affect the operation of Moodle. &lt;br /&gt;
&lt;br /&gt;
===Too many changes to track manually?===&lt;br /&gt;
&lt;br /&gt;
You can also use database management programs to synchronize old and new Moodle databases.&lt;br /&gt;
&lt;br /&gt;
For example [http://wb.mysql.com/ MySQL Workbrench] for MySQL databases.&lt;br /&gt;
&lt;br /&gt;
This is very useful, if You have a lot of changes.&lt;br /&gt;
&lt;br /&gt;
If you can work a Unix/Linux command line the Python script [http://schemasync.org/ Schema Sync] provides a quick and simple way to generate all the commands to update your database.&lt;br /&gt;
&lt;br /&gt;
==Should I worry?==&lt;br /&gt;
&lt;br /&gt;
Changes in field types (as long as they are compatible) and key name changes seem to be the common issues but &#039;&#039;&#039;should&#039;&#039;&#039; not cause problems. Things to look out for would be along the lines of missing fields and changes to default values.&lt;br /&gt;
&lt;br /&gt;
If you are about to upgrade to Moodle 2.0 you should be more concerned. In order for the upgrade to proceed smoothly it is a very good idea to correct these problems.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* The missing indexes report in &#039;&#039;SiteAdmin-&amp;gt;Misc-&amp;gt;XMLDB editor-&amp;gt;Check Indexes&#039;&#039;&lt;br /&gt;
* [http://moodle.org/mod/forum/view.php?id=45 Moodle Databases Forum]&lt;br /&gt;
&lt;br /&gt;
[[de:Datenbank-Schema prüfen]]&lt;br /&gt;
[[fr:Vérification du schéma de la base de données]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Installation&amp;diff=98199</id>
		<title>Installation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Installation&amp;diff=98199"/>
		<updated>2012-06-06T13:15:24Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Main page}}&lt;br /&gt;
&amp;lt;p class=&amp;quot;note&amp;quot;&amp;gt;Note: The following installation pages are currently being updated. Please bear with us while this work is being completed.&amp;lt;/p&amp;gt;&lt;br /&gt;
==Installation==&lt;br /&gt;
&lt;br /&gt;
If you are installing a new Moodle site, start here:&lt;br /&gt;
&lt;br /&gt;
*[[Installation Quickstart]] - for experts and the impatient&lt;br /&gt;
*[[Installing Moodle]] - for everyone else&lt;br /&gt;
*[[Cron]]&lt;br /&gt;
*[[Installing plugins]]&lt;br /&gt;
*[[Installation FAQ]]&lt;br /&gt;
&lt;br /&gt;
==Upgrading==&lt;br /&gt;
&lt;br /&gt;
If you are upgrading your Moodle site, start here:&lt;br /&gt;
&lt;br /&gt;
*[[Upgrading]]&lt;br /&gt;
*[[Upgrading to Moodle 2.3]]&lt;br /&gt;
*[[Git for Administrators|Git guide]]&lt;br /&gt;
*[[CVS for Administrators|CVS guide]]&lt;br /&gt;
*[[Verify Database Schema]]&lt;br /&gt;
*[[Upgrading FAQ]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Moodle migration]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
&lt;br /&gt;
[[de:Installation]]&lt;br /&gt;
[[fr:Installation]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Managing_content&amp;diff=96681</id>
		<title>Managing content</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Managing_content&amp;diff=96681"/>
		<updated>2012-03-27T15:28:44Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Main page}}&lt;br /&gt;
Moodle is &#039;&#039;&#039;not&#039;&#039;&#039; primarily a content management system but it does offer a range of ways to import, export and manage digital content of any kind to enable and support learning. The following links will provide more information:&lt;br /&gt;
&lt;br /&gt;
* [[Working with files]] - how to upload files and folders to Moodle.&lt;br /&gt;
* [[Repositories]] - how to import content into Moodle from external storage sites like [[Flickr repository|Flickr]], [[Youtube_videos_repository|Youtube]], [[Google_Docs_repository|Google docs]] etc.&lt;br /&gt;
* [[Portfolios]] - how to export content from Moodle into external portfolios like [[Mahara portfolio|Mahara]].&lt;br /&gt;
* [[Working with media]] - how best to upload and display images, sound, video and embedded content.&lt;br /&gt;
* [[Filters]] - how to display links,media players, Maths symbols, emoticons and more.&lt;br /&gt;
* [[Licences]] - how to display and choose an appropriate licence for your files.&lt;br /&gt;
* [[Plagiarism prevention]] - how to check students&#039; submitted work is not copied.&lt;br /&gt;
&lt;br /&gt;
[[fr:Gestion du contenu]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Upgrading_to_Moodle_2.2&amp;diff=94062</id>
		<title>Upgrading to Moodle 2.2</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Upgrading_to_Moodle_2.2&amp;diff=94062"/>
		<updated>2011-11-24T09:45:29Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
{{Moodle 2.2}}You can upgrade to Moodle 2.2 from Moodle 2.1, 2.0 or 1.9. If you are upgrading from 1.9, please read the [https://docs.moodle.org/20/en/Upgrading_to_Moodle_2.0 Upgrading to Moodle 2.0] page too. If you are using an earlier version of Moodle, you must upgrade to the latest Moodle 1.9.x first.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==System requirements==&lt;br /&gt;
&lt;br /&gt;
* PHP must be &#039;&#039;&#039;5.3.2&#039;&#039;&#039; or later&lt;br /&gt;
** Required PHP extensions: iconv, curl, ctype, zip, simplexml, spl, pcre, dom, xml, json&lt;br /&gt;
** Required PHP memory_limit at least 40MB (64MB or more recommended if you have a choice)&lt;br /&gt;
* Databases should be one of the following:&lt;br /&gt;
** MySQL 5.0.25 or later  (InnoDB storage engine highly recommended)&lt;br /&gt;
** PostgreSQL 8.3 or later&lt;br /&gt;
** Oracle 10.2 or later&lt;br /&gt;
** MS SQL 2005 or later&lt;br /&gt;
* Any standards-supporting browser from the past few years, for example:&lt;br /&gt;
** Firefox 3 or later &lt;br /&gt;
** Safari 3 or later &lt;br /&gt;
** Google Chrome 4 or later&lt;br /&gt;
** Opera 9 or later&lt;br /&gt;
** MS Internet Explorer 7 or later&lt;br /&gt;
&lt;br /&gt;
Note: The above system requirements are unchanged from Moodle 2.1.&lt;br /&gt;
&lt;br /&gt;
==Before upgrading please... ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE&#039;&#039;&#039;: The upgrade process will irreversibly modify the contents of your database &#039;&#039;&#039;and&#039;&#039;&#039; your moodledata file storage area. If something goes wrong you &#039;&#039;&#039;cannot&#039;&#039;&#039; go back. It is vital that you take good backups of both moodledata and the database in case you have problems with the upgrade. If you are not sure how see [[Site backup]] or ask in the moodle.org forums (explaining what your operating system is).  &lt;br /&gt;
&lt;br /&gt;
* Read the [[:dev:Moodle 2.2 release notes]]&lt;br /&gt;
* Always check your site to make sure it meets all system requirements for 2.2 in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Do a full database backup!&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Do a full moodledata backup&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;Check your backups carefully&#039;&#039;&#039;&lt;br /&gt;
* Remember to purge PHP cache if using any PHP accelerator&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you==&lt;br /&gt;
&lt;br /&gt;
* If you have custom reports, there have been changes that may require (simple) changes to be made to their code.&lt;br /&gt;
* Global search has been removed from core as it was broken.  A new global search is being written for 2.3.&lt;br /&gt;
* Some web service functions have been deprecated.  They still work, but check any web service connections you may have to your Moodle for the future.&lt;br /&gt;
&lt;br /&gt;
==Checking database schema - old sites==&lt;br /&gt;
&lt;br /&gt;
If your Moodle site has been upgraded through many prior versions it is possible that there will be some problems with the database schema (compared to a fresh 2.0 installation). This may cause the upgrade to fail. If your site started life prior to Moodle 2.0 it is a very good idea to check and correct the database schema before upgrading. See [[Verify Database Schema]]. You should also run the database integrity checks in the XMLDB editor, see the &#039;See also&#039; for a link to extra scripts to check for other discrepancies.&lt;br /&gt;
&lt;br /&gt;
==Now upgrade==&lt;br /&gt;
&lt;br /&gt;
Once you have satisfied the requirements for Moodle 2.2, follow the instructions on the [[Upgrading|upgrading]] page.&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle 2.2 supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
==After upgrade==&lt;br /&gt;
&lt;br /&gt;
The config.php file from your 2.0 installation should work fine but if you take a look at config-dist.php that came with Moodle 2.0 there are more/different options available (e.g. database drivers and settings). It&#039;s a good idea to map your old config.php settings to a new one based on the 2.2 config-dist.php.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[dev:Moodle 2.2 release notes]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Mise à jour à Moodle 2.2]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Custom_SQL_queries_report&amp;diff=82587</id>
		<title>Custom SQL queries report</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Custom_SQL_queries_report&amp;diff=82587"/>
		<updated>2011-04-06T08:36:52Z</updated>

		<summary type="html">&lt;p&gt;Fox: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 1.9}}&lt;br /&gt;
Created by The Open University&lt;br /&gt;
&lt;br /&gt;
This admin report plugin allows Administrators to set up arbitrary database queries to act as ad-hoc reports. Reports can be of two types: either run on demand, or scheduled to run automatically. Other users with the right capability can go in and see a list of queries that they have access to. Results can be viewed on-screen or downloaded as CSV.&lt;br /&gt;
&lt;br /&gt;
==Installing this report==&lt;br /&gt;
&lt;br /&gt;
Follow the generic [[Installing contributed modules or plugins]] documentation.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Screen shots==&lt;br /&gt;
&lt;br /&gt;
Here are two example screen shots, showing the two main screens.&lt;br /&gt;
&lt;br /&gt;
[[Image:Custom_report_list.png|thumb|none|600px|The list of available reports]]&lt;br /&gt;
[[Image:Custom_report.png|thumb|none|600px|The results of running one of the reports]]&lt;br /&gt;
&lt;br /&gt;
(Note, these screen shots are in the OU theme, not the standard Moodle theme, and iCMA is OU-jargon for quiz.)&lt;br /&gt;
&lt;br /&gt;
==Interface for normal users==&lt;br /&gt;
&lt;br /&gt;
===List of available queries===&lt;br /&gt;
&lt;br /&gt;
Users with the report/customsql:view capability can access the list of reports in the admin block. Each query is accessible only to a certain people. There are three levels of access:&lt;br /&gt;
* Available to any one who can access the report at all (those with report/customsql:view).&lt;br /&gt;
* Available to people who are able to see other system reports (those with moodle/site:viewreports)&lt;br /&gt;
* Available to administrators only (those with moodle/site:config)&lt;br /&gt;
&lt;br /&gt;
When you go to the list, it will only show the queries you have access to. There is a note beside each query saying when it was last run, and how long it took to generate.&lt;br /&gt;
&lt;br /&gt;
The list shows on-demand and scheduled queries separately.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Running an on-demand query===&lt;br /&gt;
&lt;br /&gt;
To run an on-demand query, click on its name in the list of queries.&lt;br /&gt;
&lt;br /&gt;
The query will be run, and the results will be displayed as a table. Any URLs in the table will automatically be made into hyperlinks.&lt;br /&gt;
&lt;br /&gt;
A description of the query may appear above the table.&lt;br /&gt;
&lt;br /&gt;
The summary of when the query was run and how long it took is shown at the bottom, along with a link to download the CSV file (for example to get the data into Excel) and a link back to the list of all available queries.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Viewing the results of scheduled queries===&lt;br /&gt;
&lt;br /&gt;
Scheduled queries can work in one of two ways. Either each run of the report generates and entire table of reasults, or each run just creates one line of results, and the report builds up a row at a time.&lt;br /&gt;
&lt;br /&gt;
When you click the name in the list of queries, you get taken to a display of the latest results, just like in the on-demand case.&lt;br /&gt;
&lt;br /&gt;
However, if each scheduled run generates a complete report, then at the bottom of a page there will be a list of all the previous runs of the report, so that you can go and see how the report changed over time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Interface for administrators==&lt;br /&gt;
&lt;br /&gt;
Administrators (that is, users with report/customsql:definequeries) see everything that other users see, but with some additions.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Additional controls in the staff interface===&lt;br /&gt;
&lt;br /&gt;
Administrators get shown who each report in the list is available to.&lt;br /&gt;
&lt;br /&gt;
They also get an edit and a delete icon next to each query.&lt;br /&gt;
&lt;br /&gt;
There is an &#039;&#039;&#039;Add new query button&#039;&#039;&#039; at the end of the list of queries.&lt;br /&gt;
&lt;br /&gt;
When viewing a particular query, Administrators get an edit and a delete link underneath the table of results.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Adding or editing a query===&lt;br /&gt;
&lt;br /&gt;
When you click the &#039;&#039;&#039;Add new query button&#039;&#039;&#039;, you get taken to an editing form that lets you define the query.&lt;br /&gt;
&lt;br /&gt;
You must give the query a name.&lt;br /&gt;
&lt;br /&gt;
You can optionally enter a description that is displayed above the results table. You should use this to explain what the results of the query mean.&lt;br /&gt;
&lt;br /&gt;
You must enter the SQL to generate the results you want displayed. This must be an SQL select statement. You must use the prefix prefix_ for table names. It should not be possible to enter any SQL that would alter the contents of the database.&lt;br /&gt;
&lt;br /&gt;
You choose who you want the query to be accessible to.&lt;br /&gt;
&lt;br /&gt;
You choose whether the query should be run on-demand or scheduled weekly or monthly. If the report is scheduled, you can say whether the each run returns one row to be added to a single table, or whether each run generates a separate table.&lt;br /&gt;
&lt;br /&gt;
When you save the new query, the SQL is checked to make sure that it will execute without errors. If you have said that the report will only return a single row, this is also checked.&lt;br /&gt;
After saving the query, if this was a manual query, you are taken to the query results page, so you can see what the results look like. If it was an automatic query or if you cancel the form, you are taken to the list of available queries.&lt;br /&gt;
&lt;br /&gt;
Editing an existing query uses the same form as for adding a new query, but to change the properties of an existing query.&lt;br /&gt;
&lt;br /&gt;
Note that at the OU, weeks start on Saturday. If you don&#039;t like that, there is a fairly obvious constant to hack at the top of locallib.php.&lt;br /&gt;
&lt;br /&gt;
===Deleting a query===&lt;br /&gt;
&lt;br /&gt;
When you click the delete icon or link for a query, you are taken to a confirmation page that shows you SQL of the query you are about to delete. The query is only deleted if you click Yes on the confirmation page.&lt;br /&gt;
&lt;br /&gt;
After deleting a query, you are taken back to the list of queries.&lt;br /&gt;
&lt;br /&gt;
==Share your interesting queries here==&lt;br /&gt;
&lt;br /&gt;
If you come up with any interesting SQL to custom reports, you can share it here.&lt;br /&gt;
&lt;br /&gt;
===Quiz attempts in the last week/month===&lt;br /&gt;
&lt;br /&gt;
Set this up as a scheduled report:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(*)&lt;br /&gt;
FROM prefix_quiz_attempts&lt;br /&gt;
WHERE timefinish &amp;gt; %%STARTTIME%%&lt;br /&gt;
    AND timefinish &amp;lt;= %%ENDTIME%%&lt;br /&gt;
    AND preview = 0&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This &#039;&#039;&#039;must&#039;&#039;&#039; be set up as a &#039;&#039;&#039;Scheduled, on the first day of each week&#039;&#039;&#039; or &#039;&#039;&#039;Scheduled, on the first day of each month&#039;&#039;&#039; report, or it will not work.&lt;br /&gt;
&lt;br /&gt;
===Usage summary===&lt;br /&gt;
&lt;br /&gt;
This report shows roughly the same usage statistics that are sent to moodle.org when you register your site. The ones that are aggregated at http://moodle.org/stats/. (The only difference is that the registration form does not do AND confirmed = 1 for some reason.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
(SELECT COUNT(id) FROM prefix_course) - 1 AS courses,&lt;br /&gt;
(SELECT COUNT(id) FROM prefix_user WHERE deleted = 0 AND confirmed = 1) AS users,&lt;br /&gt;
(SELECT COUNT(DISTINCT ra.userid)&lt;br /&gt;
 FROM prefix_role_capabilities rc&lt;br /&gt;
 JOIN prefix_role_assignments ra ON ra.roleid = rc.roleid&lt;br /&gt;
 WHERE rc.capability IN (&#039;moodle/course:upd&#039; || &#039;ate&#039;, &#039;moodle/site:doanything&#039;)) AS teachers,&lt;br /&gt;
(SELECT COUNT(id) FROM prefix_role_assignments) AS enrolments,&lt;br /&gt;
(SELECT COUNT(id) FROM prefix_forum_posts) AS forum_posts,&lt;br /&gt;
(SELECT COUNT(id) FROM prefix_resource) AS resources,&lt;br /&gt;
(SELECT COUNT(id) FROM prefix_question) AS questions&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are two interesting queries in this blog post [http://tjhunt.blogspot.com/2010/03/when-do-students-submit-their-online.html When do students submit their online tests?].&lt;br /&gt;
&lt;br /&gt;
===Monthly Usage by Role===&lt;br /&gt;
&lt;br /&gt;
This report shows a distinct count of users by their role, accessing your site.  Each instance of user and role is counted once per month, no matter how many courses they access.  We use this to show the total number of students and teachers accessing our site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
month(from_unixtime(`prefix_stats_user_monthly`.`timeend`)) AS calendar_month,&lt;br /&gt;
year(from_unixtime(`prefix_stats_user_monthly`.`timeend`)) AS calendar_year,&lt;br /&gt;
prefix_role.name as user_role,&lt;br /&gt;
COUNT(DISTINCT prefix_stats_user_monthly.userid) AS total_users&lt;br /&gt;
FROM&lt;br /&gt;
prefix_stats_user_monthly&lt;br /&gt;
Inner Join prefix_role_assignments ON prefix_stats_user_monthly.userid = prefix_role_assignments.userid&lt;br /&gt;
Inner Join prefix_context ON prefix_role_assignments.contextid = prefix_context.id&lt;br /&gt;
Inner Join prefix_role ON prefix_role_assignments.roleid = prefix_role.id&lt;br /&gt;
WHERE prefix_context.contextlevel = 50&lt;br /&gt;
AND `prefix_stats_user_monthly`.`stattype` = &#039;activity&#039;&lt;br /&gt;
AND prefix_stats_user_monthly.courseid &amp;lt;&amp;gt;1&lt;br /&gt;
GROUP BY month(from_unixtime(`prefix_stats_user_monthly`.`timeend`)),&lt;br /&gt;
year(from_unixtime(`prefix_stats_user_monthly`.`timeend`)),&lt;br /&gt;
prefix_stats_user_monthly.stattype,&lt;br /&gt;
prefix_role.name&lt;br /&gt;
ORDER BY &lt;br /&gt;
year(from_unixtime(`prefix_stats_user_monthly`.`timeend`)), month(from_unixtime(`prefix_stats_user_monthly`.`timeend`)),&lt;br /&gt;
prefix_role.name&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You must have Statistics turned on to be able to generate any data with this report.&lt;br /&gt;
&lt;br /&gt;
===Show all Quiz results across a site===&lt;br /&gt;
I&#039;m sure someone will be able to improve upon this, but this is a query that will show Quiz results across a site. --[[User:Stuart Mealor|Stuart Mealor]] 22:07, 9 April 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
     prefix_grade_items.itemname,&lt;br /&gt;
     prefix_grade_items.grademax,&lt;br /&gt;
     ROUND(prefix_grade_grades.finalgrade, 0) AS finalgrade,&lt;br /&gt;
     prefix_user.firstname,&lt;br /&gt;
     prefix_user.lastname,&lt;br /&gt;
     prefix_user.username&lt;br /&gt;
FROM&lt;br /&gt;
     prefix_grade_grades&lt;br /&gt;
     INNER JOIN prefix_user ON prefix_grade_grades.userid = prefix_user.id&lt;br /&gt;
     INNER JOIN prefix_grade_items ON prefix_grade_grades.itemid = prefix_grade_items.id&lt;br /&gt;
WHERE (prefix_grade_items.itemname IS NOT NULL)&lt;br /&gt;
AND (prefix_grade_items.itemtype = &#039;mod&#039; OR prefix_grade_items.itemtype = &#039;manual&#039;)&lt;br /&gt;
AND (prefix_grade_items.itemmodule = &#039;quiz&#039; OR prefix_grade_items.itemmodule IS NULL)&lt;br /&gt;
AND (prefix_grade_grades.timemodified IS NOT NULL)&lt;br /&gt;
AND (prefix_grade_grades.finalgrade &amp;gt; 0)&lt;br /&gt;
AND (prefix_user.deleted = 0)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Reports_(administrator)]] for other admin reports&lt;br /&gt;
* [[Installing contributed modules or plugins]]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=136484 Custom SQL queries report] forum announcement&lt;br /&gt;
* list of [[ad-hoc contributed reports]]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=153059 Forum post] with some more useful queries.&lt;br /&gt;
&lt;br /&gt;
[[Category: Administrator]]&lt;br /&gt;
[[Category:Report]]&lt;br /&gt;
[[Category:Contributed_code]]&lt;br /&gt;
&lt;br /&gt;
[[fr:admin/report/customsql/index]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Installations_10000_plus&amp;diff=82380</id>
		<title>Installations 10000 plus</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Installations_10000_plus&amp;diff=82380"/>
		<updated>2011-03-29T14:05:33Z</updated>

		<summary type="html">&lt;p&gt;Fox: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Large Installations}}&lt;br /&gt;
&lt;br /&gt;
Please add your school info here, if you have a Moodle installation catering (or expecting to cater) for 10,000 or more users.&lt;br /&gt;
==Austria==&lt;br /&gt;
* [http://elearning.tuwien.ac.at/ Moodle (TUWEL)] user statistics September 25th 2009 - Vienna University of Technology (TU Vienna)  &lt;br /&gt;
 &lt;br /&gt;
 - 19.250 users (students &amp;amp; teachers)&lt;br /&gt;
 - 13.400 students enrolled in courses&lt;br /&gt;
 - 1.030 teachers enrolled in courses&lt;br /&gt;
 - 5000+ active users per day&lt;br /&gt;
 &lt;br /&gt;
Our mission is „technology for people“. Through our research we „develop scientific excellence“, through our teaching we „enhance comprehensive competence“.&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.uni-graz.at/ moodle @ uni-graz ] Primary moodle server of the Karl Franzens University Graz.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Brazil==&lt;br /&gt;
&lt;br /&gt;
* [http://www.escolatecnica.ufrgs.br Escola Técnica da Universidade Federal do Rio Grande do Sul] - Professional school in Brazil, with 1,200 students. Adopted Moodle in 2004 and has been using it since then.&lt;br /&gt;
&lt;br /&gt;
==Canada==&lt;br /&gt;
&lt;br /&gt;
* [http://www.athabascau.ca/ Athabasca University] - Canada&#039;s leading distance-education and online university: Canada&#039;s Open University, serving about 30,000 students per year. Athabasca has decided to adopt Moodle as a single platform instead of WebCT Vista (i.e. the top of the line version). You can read their [http://www.athabascau.ca/media/index.php?id=132 press release] for more info.&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.mala.bc.ca/ Malaspina University-College] - Malaspina U-C is located on Vancouver Island in British Columbia, Canada. MUC was established in 1969, and has over 10,000 full-time Canadian students, plus 1,000 international students from more than 50 countries. MUC offers graduate and undergraduate degrees, diplomas and certificates, and a 5-level English Language program. MUC offers classroom-student support through Moodle, as well as a range of fully online courses through [http://pr.malaonline.ca/ Malaspina Continuing Education]. MUC switched from WebCT to Moodle in 2006.&lt;br /&gt;
&lt;br /&gt;
* [http://www.usherbrooke.ca/ Université de Sherbrooke] - L&#039;Université de Sherbrooke accueille plus de 37 000 étudiantes et étudiants, provenant de plus de 100 pays, dont quelque 9000 inscrits à l’Université du troisième âge. Plus de 85 % de la population étudiante de l’Université de Sherbrooke provient de l’extérieur de Sherbrooke. L’Université de Sherbrooke emploie 6700 personnes. Elle compte 10 % du corps professoral québécois.&lt;br /&gt;
&lt;br /&gt;
==China==&lt;br /&gt;
&lt;br /&gt;
* [http://english.bit.edu.cn/ Beijing Institute of Technology]&lt;br /&gt;
&lt;br /&gt;
==Czech Republic==&lt;br /&gt;
&lt;br /&gt;
* [https://moodle.czu.cz Czech University of Life Sciences Prague] &lt;br /&gt;
** 35,590 users in 911 courses (14,665 active users in last 15 days) / 18th October 2010&lt;br /&gt;
** Moodle 1.9.5&lt;br /&gt;
** integration with LDAP and Oracle&lt;br /&gt;
** Administration: [http://www.oikt.czu.cz/?r=1686 E-learning Support Centre, Division of IT, CULS Prague]&lt;br /&gt;
&lt;br /&gt;
==France==&lt;br /&gt;
&lt;br /&gt;
* [http://cursus.uhb.fr/ Université de Rennes 2 - Haute Bretagne] - 20,000 to 30,000 users in 1400 courses&lt;br /&gt;
** 8,000 different users connected every month&lt;br /&gt;
** 300 teachers actually involved&lt;br /&gt;
** integration with LDAP and Esup-Portail (based on uPortal) ; &lt;br /&gt;
** authentication via CAS&lt;br /&gt;
&lt;br /&gt;
* [http://cours.univ-tlse1.fr/ Université Toulouse 1 Capitole] - 18,000 users in 800 courses, Moodle 1.9.11+&lt;br /&gt;
** 300 teachers actually involved&lt;br /&gt;
** integration with LDAP and Esup-Portail (based on uPortal)&lt;br /&gt;
** authentication via CAS&lt;br /&gt;
&lt;br /&gt;
==Germany==&lt;br /&gt;
&lt;br /&gt;
* [http://www.isis.tu-berlin.de/ Technische Universität Berlin] - 10,400 Users in 402 courses (updated: 07.June.2007)&lt;br /&gt;
** After a test period, the Information System for Instructors and Students (ISIS) was launched in september 2006. &lt;br /&gt;
&lt;br /&gt;
==India==&lt;br /&gt;
* [http://www.amieindia.net AMIE India] is a website for [http://www.amieindia.net AMIE] students currently (as of September 2007) having 239 courses, 11246 users.&lt;br /&gt;
&lt;br /&gt;
* [http://www.visveswaraya.org/ AMIE] a residential AMIE Institute in Kerala, India, listed in LIMCA Book of Records with 130 All India Ranks, is best ever for AMIE coaching &amp;amp; IIT &amp;amp; NIT higher studies.&lt;br /&gt;
&lt;br /&gt;
==Ireland==&lt;br /&gt;
&lt;br /&gt;
* [http://www.dcu.ie Dublin City University] 18,000 users in 3,600 courses.&lt;br /&gt;
&lt;br /&gt;
==Italy==&lt;br /&gt;
&lt;br /&gt;
* [http://www.aulaweb.unige.it/ AulaWeb - University of Genoa] AulaWeb is an university-wide installation of Moodle, organized in virtual instances, one for each laurea degree. In March 2007, it hosts more than 78 instances used by 10.500 students.&lt;br /&gt;
&lt;br /&gt;
==Jamaica==&lt;br /&gt;
*[http://ourvle.mona.uwi.edu The University of the West Indies] - 23,000+ users in 1600+ courses&lt;br /&gt;
&lt;br /&gt;
==New Zealand==&lt;br /&gt;
&lt;br /&gt;
*[http://campus.openpolytechnic.ac.nz/ The Open Polytechnic of New Zealand] - 35,000+ students, 6,500+ courses, single sign-on for library services using Ezy Proxy, single sign-on for webmail, using SquirrelMail, uses LDAP for interface with Sears Student Management System. Comments by [https://eduforge.org/wiki/wiki/nzvle/wiki?pagename=Comments%20by%20Ken%20Udas%2C%20Director%20of%20eLearning%20at%20the%20Open%20Polytechnic Ken Udas, Director of eLearning at the Open Polytechnic]&lt;br /&gt;
&lt;br /&gt;
==Palestine==&lt;br /&gt;
&lt;br /&gt;
*[http://eclass.alquds.edu Al-Quds University] - 12,000+ users in 900+ courses. Al-Quds University started using moodle in 2004.&lt;br /&gt;
&lt;br /&gt;
== Philippines ==&lt;br /&gt;
&lt;br /&gt;
* [http://eclass.adzu.edu.ph Ateneo de Zamboanga University] - with 10,000+ faculty, staff and students (started using Moodle since 2002)&lt;br /&gt;
&lt;br /&gt;
== Portugal ==&lt;br /&gt;
&lt;br /&gt;
[http://moodle.fct.unl.pt/ Faculdade de Ciências e Tecnologia da Universidade Nova de Lisboa] - 5000+ users in 400+ pages.&lt;br /&gt;
&lt;br /&gt;
==South Africa==&lt;br /&gt;
&lt;br /&gt;
* [http://www.ru.ac.za Rhodes University] in Grahamstown runs an instance of Moodle as its institutional LMS [http://ruconnected.ru.ac.za RUconnected] currently with more than 10 000 registered users, including more than 550 teachers.&lt;br /&gt;
&lt;br /&gt;
== Spain ==&lt;br /&gt;
&lt;br /&gt;
*[http://aulavirtual.uji.es/ Universitat Jaume I]. Official VLE since 2004. 13.600 real users (12.500 students and 1.100 teachers) and 1.300 active courses on February 2009. Moodle 1.9.x.&lt;br /&gt;
&lt;br /&gt;
*[http://www.upc.edu La Universitat Politecnica de Cataluña] on september 2005 started a pilot Moodle installation with 3.000 Students. On september 2006 the migration from the old campus to Moodle will be complete with more than 30.00 students [http://atenea.upc.edu El campus Atenea 4] runs Moodle 1.4.5 y an will be updated to Moodle 1.5.3 in september 2006. [http://www.upc.edu UPC] has developed several applicatons adn bridges between its own informacion systems.&lt;br /&gt;
** Integration with the academic management informatio system &amp;quot;Prisma&amp;quot;.   &lt;br /&gt;
** [http://appserv.lsi.upc.es/palangana/moodle/course/view.php?id=18 Internalmail] (developed also in  UPC) is used for as email internal system.&lt;br /&gt;
** Moodle integration with [http://bibliotecnica.upc.edu the upc library system].&lt;br /&gt;
** Adaptation of Moodle grades to spanish university grading system.&lt;br /&gt;
** And other stuff&lt;br /&gt;
&lt;br /&gt;
*[http://www.urv.cat/ Universitat Rovira i Virgili] using Moodle for three academic years. At present version 1.5.4+ to be updated to 1.6.4+ in short. In march 2007, 22701 users registered and 3500 courses created aprox.&lt;br /&gt;
** Integration with the academic management information system&lt;br /&gt;
** Integration with the corporative LDAP user’s directory&lt;br /&gt;
** Average of 504 courses used regularly (logs at least once a week)&lt;br /&gt;
** Average of 3200 students login at least once a day&lt;br /&gt;
** Average of 7200 students login at least once a week&lt;br /&gt;
** 10500 users (teachers and students) accessed at least once during the last month (data from 26th march 2007)&lt;br /&gt;
&lt;br /&gt;
*[http://www.ulpgc.es/index.php?pagina=campusvirtual&amp;amp;ver=inicio Universidad de Las Palmas de Gran Canaria (ULPGC)] - 24.000 users in aprox. 1800 courses. We started with Moodle 1.4 four years ago as a test pilot project for a small number of courses. Now offered as a basic service for all courses at ULPGC: 55 official EU titles and 5 more offered ONLY through Web. &lt;br /&gt;
** We are using version 1.6.3 with LDAP authentification&lt;br /&gt;
** Custom modules: ULPGCAssignment and ULPGCDialogUe, heavily modified Appointment/Scheduler&lt;br /&gt;
** Custom groupings/scopes for small team activities (e.g. group assignment)&lt;br /&gt;
** Regular-intense usage ranks by 60% of courses/students.&lt;br /&gt;
&lt;br /&gt;
*[http://campusvirtual.ub.edu/ Universitat de Barcelona] - 60.000 users in 7.300 courses. Started in September 2006 as a project, UB Moodle site will be open for all next September.&lt;br /&gt;
&lt;br /&gt;
*[http://campuvirtual.unex.es Universidad de Extremadura] - 15000 users in aprox. 700 courses.&lt;br /&gt;
&lt;br /&gt;
*[http://www.juntadeandalucia.es/educacion/adistancia/semipresencial Andalusia Blended Learning ].VLE of [http://www.juntadeandalucia.es/educacion/permanente Lifelong Learning Service] of &#039;&#039;Junta de Andalucía&#039;&#039;.Actually (2009/2010) 1600 courses and 25000 in aprox. Between them 1500 teachers. It&#039;s expected 35000 users next year.  This VLE is complemented with [http://www.juntadeandalucia.es/educacion/adistancia/avep LifeLong Learning VLE] that offers and open access to educational materials developed for blended learning.&lt;br /&gt;
&lt;br /&gt;
== Sweden ==&lt;br /&gt;
&lt;br /&gt;
[http://lnu.se/?l=en Linnaeus University] - 35.000 students and and 2.000 employees in 2011 - 23.000 Moodle users in 2.000 Moodle courses.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Taiwan==&lt;br /&gt;
&lt;br /&gt;
[http://www.thu.edu.tw/english/enindex.htm Tunghai University]&lt;br /&gt;
*More then 17,000 registed Users&lt;br /&gt;
*16,000 users login in one day( Max. )&lt;br /&gt;
*3,000 courses per semester&lt;br /&gt;
*integration with novell ichan for single sign on&lt;br /&gt;
*integration with school support system&lt;br /&gt;
&lt;br /&gt;
our moodle web site: [http://elearning.thu.edu.tw]&lt;br /&gt;
&lt;br /&gt;
==Trinidad and Tobago==&lt;br /&gt;
&lt;br /&gt;
[http://myelearning.sta.uwi.edu The University of the West Indies]&lt;br /&gt;
St. Augustine Campus&lt;br /&gt;
*More then 22,000 registed Users&lt;br /&gt;
*Over 500 Courses per semester&lt;br /&gt;
*Over 1500 Teachers&lt;br /&gt;
&lt;br /&gt;
Using Moodle since 2006.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==United Kingdom==&lt;br /&gt;
&lt;br /&gt;
*[http://www.open.ac.uk/ The Open University (OU)] - the United Kingdom&#039;s only university dedicated to distance learning. They have around 150,000 undergraduate and more than 30,000 postgraduate students. As of October 2010, the OU&#039;s Moodle database contains over 700,000 users and 7,000 courses.&lt;br /&gt;
&lt;br /&gt;
*[http://openlearn.open.ac.uk/ OpenLearn] The Open University&#039;s open content initiative. Website development began in May 2006 and the site was launched in October 2006, supported by a grant from The William and Flora Hewlett Foundation. By April 2008, 5,400 learning hours of content will be available online. Currenly (early 2007) over 10,000 unique users.&lt;br /&gt;
&lt;br /&gt;
*[http://www.gla.ac.uk/ The University of Glasgow] - A long-established (founded 1451) and high-profile research university in the UK, with 20,000 students (16,000 undergrad, 4,000 postgrad), 6,000 staff, 20,000 unique users of Moodle (as of Jan 2008). Uses LDAP for integration with Novell and a custom MIS system for user authentication. Their site is organised on a one Moodle site per faculty basis to facilitate both appropriate themeing and to simplify balancing across servers.&lt;br /&gt;
&lt;br /&gt;
==United States==&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.cpcc.edu Central Piedmont Community College (CPCC) ] uses moodle for both curriculum and Corporate and Continuing Education. For curriculum it runs in parallel to Blackboard as faculty migrate to moodle over time. There are currently no plans to go moodle only, although many administrators favor this option. The server has 30,000 or so users on it, but the actual number of active users varies widely. It is used for both hybrid and full-online classes. Corporate and Continuing Education runs its own branded instance and uses only moodle for distance education. We have about 80,000 students total, covering the range from GED, adult-ed, curriculum, and other areas serviced by 7 campuses in and around Charlotte, North Carolina. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*[http://ilearn.sfsu.edu San Francisco State University (SFSU) ] uses moodle for more than three years now. We use moodle for our main campus and the College of Extended Learning (CEL). For curriculum, moodle used to run in parallel with Blackboard as faculty migrate to moodle over time (SFSU officially phased out Blackboard, as of 6/30/2007). The servers have total of 89K users (as of 09/05/2007), among these 89K users, 28K are considered as currently active. As for courses, we have total of 57K courses sitting on our database, and among them, around 53K are considered as active. We also have integrated Moodle with our SIMS/R system (see http://www.sfsu.edu/sims/overview.htm). We also have courses that have more than 1,300+ students in one course with lots of quizzes (20+) and quiz attempts. The student population in SFSU covers the range from undergraduate, graduate, and first professional students.&lt;br /&gt;
&lt;br /&gt;
== Venezuela ==&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.unica.edu.ve Cecilio Acosta Catholic University (UNICA)] - with 10,000+ faculty, staff and students (started using Moodle since 2005)&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=admin/environment/php&amp;diff=82361</id>
		<title>admin/environment/php</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=admin/environment/php&amp;diff=82361"/>
		<updated>2011-03-29T07:58:14Z</updated>

		<summary type="html">&lt;p&gt;Fox: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Moodle has different PHP requirements for different versions:&lt;br /&gt;
&lt;br /&gt;
* Moodle 2.1 will require PHP 5.3.2 or later&lt;br /&gt;
* Moodle 2.0 requires PHP 5.2.8 or later. However PHP 5.3.x is recommended&lt;br /&gt;
* Moodle 1.6 to 1.9 requires PHP 4.3.0 or later&lt;br /&gt;
* Moodle 1.0 to 1.5 requires PHP 4.1.0 or later&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* http://www.php.net/downloads.php for the latest downloads&lt;br /&gt;
&lt;br /&gt;
[[Category:Environment|PHP]]&lt;br /&gt;
&lt;br /&gt;
[[eu:admin/environment/php]]&lt;br /&gt;
[[fr:admin/environment/php]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Advanced_features&amp;diff=82325</id>
		<title>Advanced features</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Advanced_features&amp;diff=82325"/>
		<updated>2011-03-28T13:32:08Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}Location: &#039;&#039;Site Administration &amp;gt; Advanced features&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following features in Moodle 2.0 onwards may be enabled/disabled in Advanced features:&lt;br /&gt;
&lt;br /&gt;
* [[Outcomes]]&lt;br /&gt;
* [[Comments 2.0]]&lt;br /&gt;
* [[Tags|Tags functionality]]&lt;br /&gt;
* [[Notes]]&lt;br /&gt;
* [[Portfolios]]&lt;br /&gt;
* [[Web Services]]&lt;br /&gt;
* [[Messaging]]&lt;br /&gt;
* [[Statistics]]&lt;br /&gt;
* [[RSS feeds 2.0|RSS feeds]]&lt;br /&gt;
* [[Blogs]]&lt;br /&gt;
* [[MNet|Networking]]&lt;br /&gt;
* [[Development:Course_completion|Completion tracking]]&lt;br /&gt;
* [[Conditional_activities|Conditional availability]]&lt;br /&gt;
* [[Plagiarism Prevention|Plagiarism plugins]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Funtzio_aurreratuak]]&lt;br /&gt;
[[de:Zusatzoptionen]]&lt;br /&gt;
[[fr:Fonctions avancées]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Category:Environment&amp;diff=82177</id>
		<title>Category:Environment</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Category:Environment&amp;diff=82177"/>
		<updated>2011-03-22T15:36:58Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;An index of Moodle [[Environment|environment]] documentation pages.&lt;br /&gt;
&lt;br /&gt;
[[Category:Administrator]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Catégorie:Environnement]]&lt;br /&gt;
[[ja:Category:動作環境]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=report/security/report_security_check_displayerrors&amp;diff=82069</id>
		<title>report/security/report security check displayerrors</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=report/security/report_security_check_displayerrors&amp;diff=82069"/>
		<updated>2011-03-18T15:26:48Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If PHP is set to display errors, then anyone can enter a faulty URL causing PHP to give up valuable information about directory structures and so on. &lt;br /&gt;
&lt;br /&gt;
(Can someone add instructions on where to turn this off please).&lt;br /&gt;
&lt;br /&gt;
: If you go to &#039;&#039;Administration &amp;gt; Server &amp;gt; Debugging&#039;&#039; and set &amp;quot;Debug messages&amp;quot; to NONE and  &amp;quot;Display debug messages&amp;quot; to NO you should be on the safe side. (If this instruction is correct it should be included in the Security Overview report.) --[[User:Frank Ralf|Frank Ralf]] 11:28, 7 November 2009 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you go to &#039;&#039;&#039;Administration|Reports|Security overview&#039;&#039;&#039;, displaying of PHP errors status is Warning.   &lt;br /&gt;
on your web server, locate php.ini, open it in wordpad and search for &amp;quot;&#039;&#039;&#039;display_errors&#039;&#039;&#039;&amp;quot;.  Ensure that it is set to &amp;quot;&#039;&#039;&#039;display_errors = Off&#039;&#039;&#039;&amp;quot; and then save.  If this is on a hosted webserver (e.g. network solutions), insert &amp;quot;&#039;&#039;&#039;display_errors = Off&#039;&#039;&#039;&amp;quot; into the php.ini or call them for instructions (took 2 minutes) on how to do it.  Very simple to modify. (by &#039;&#039;&#039;opconxps&#039;&#039;&#039; guam)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=7301 Security and Privacy forum]&lt;br /&gt;
* Using [http://moodle.org/mod/forum/discuss.php?d=101761 upgrade to 1.9.2 has PHP setting display_errors message] Moodle forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
&lt;br /&gt;
[[eu:report/security/report_security_check_displayerrors]]&lt;br /&gt;
[[fr:report/security/report security check displayerrors]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=report/security/report_security_check_configrw&amp;diff=82068</id>
		<title>report/security/report security check configrw</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=report/security/report_security_check_configrw&amp;diff=82068"/>
		<updated>2011-03-18T15:21:50Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{stub}}&lt;br /&gt;
&lt;br /&gt;
It&#039;s important that you CHMOD (set permissions) on config.php as read-only. Typically this means setting it to 644, or in some cases 444.&lt;br /&gt;
&lt;br /&gt;
If you cannot do this with your FTP software, try using the File Manager supplied with your webhosting account. Simply navigate to the file you want to alter permissions for, then click on the File Properties link/button and set permissions.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re using a Windows server, simply set the file as Read-Only for Everyone. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=7301 Security and Privacy forum]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=116140 Corrupted php files] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Security]]&lt;br /&gt;
&lt;br /&gt;
[[fr:report/security/report security check configrw]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=File_bank&amp;diff=81992</id>
		<title>File bank</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=File_bank&amp;diff=81992"/>
		<updated>2011-03-16T15:51:35Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
The file bank is the new Moodle 2.0 file repository system. &lt;br /&gt;
&lt;br /&gt;
It can use a feature called the file picker to select existing files from 2 areas (Server and Private files), or a temporary area(Recent files) and an option to upload a new file.   &lt;br /&gt;
&lt;br /&gt;
The file picker has 2 basic views when looking at an area: Icon or List.  The list view is similar to a directory tree, that can collapse directories/folders, or expand directories/folders to show their files still in the tree format.  The icon view shows files and folders as thumbnails icons, the users clicks on the icon to drill down or to select the file.   A breadcrumb indicates the current location in the directory tree.&lt;br /&gt;
&lt;br /&gt;
The upload a file window  has a browse selection feature, plus a field to rename a file, the picking author&#039;s name and the type of license that is stored when the &amp;quot;Upload this file&amp;quot; button is selected.&lt;br /&gt;
&lt;br /&gt;
==Pre Moodle 2.0 description of file system==&lt;br /&gt;
In earlier versions, files were stored via an interface link in the course administration menu called &amp;quot;Files&amp;quot;.  Generally speaking, files and folders in a course, were only available in that course. (Site administrators knew that these files and folders were located in [[Moodledata directory]]).   &lt;br /&gt;
&lt;br /&gt;
In Moodle 2.0, files are stored and accessed via a link with the resource or activity in the course.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[[Course files]] - concept of pre 2.0 and 2.0 system&lt;br /&gt;
*[[File picker]] - used to add resource files.&lt;br /&gt;
*[[HTML editor 2.0]] - Insert group for images and media files&lt;br /&gt;
*[[Repositories]] - different media files&lt;br /&gt;
&lt;br /&gt;
[[Category:Teacher]] [[Category:Files]] [[Category:Moodle 2.0]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Banque de fichiers]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=File_handling&amp;diff=81991</id>
		<title>File handling</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=File_handling&amp;diff=81991"/>
		<updated>2011-03-16T15:45:37Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}The way files are handled in Moodle 2.0 has changed from earlier versions. Students and teachers will use the [[File picker]] to upload and organize their files in areas called [[Repositories]]. Repositories can be located on the Moodle site or externally. Site administrators can [[Manage repositories|reveal, restrict, add, edit or create repositories]] for the site. &lt;br /&gt;
&lt;br /&gt;
* Previously, if a file was used in different courses, it was duplicated. In Moodle 2.0, files are stored only once, saving disk space.&lt;br /&gt;
* Full support for Unicode file names on all operating systems.&lt;br /&gt;
* Metadata about each file (author, date, license, etc) and what the file is used for are stored in the database.&lt;br /&gt;
* Files are no longer just &amp;quot;uploaded to the course&amp;quot;.  Files are connected to the particular bit of Moodle content that uses them. (For example, a file may belong to a file resource, a forum post or a wiki page). Access to these files is controlled by the same [[Context|contextual]] [[Roles and capabilities|rules]] as as that bit of Moodle, increasing security.&lt;br /&gt;
* File picker has a list (file tree) or icon view &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A video on file handling in Moodle 2.0:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;mediaplayer&amp;gt;http://www.youtube.com/watch?v=2bUwx675Pqo&amp;lt;/mediaplayer&amp;gt;&lt;br /&gt;
== Typical Moodle 2.0 workflow ==&lt;br /&gt;
Edit text or activity. Use the file picker to easily select the file from any local or remote repository. The file is then copied to Moodle and stored securely with the text or activity. &lt;br /&gt;
&lt;br /&gt;
Or Edit text or url resource. Use the file picker to select a file from any local or remote repository and select &amp;quot;link&amp;quot;. The file URL is then embedded into the text and when viewed, the media comes directly from the open repository.&lt;br /&gt;
&lt;br /&gt;
The standard Moodle install has  4 default areas (repositories) displayed in file picker for the teacher to select:&lt;br /&gt;
*Server - &lt;br /&gt;
*Recent -&lt;br /&gt;
*Upload -&lt;br /&gt;
*[[Private files]]&lt;br /&gt;
&lt;br /&gt;
The site administrator can expand the above list to include 15 other predefined repository areas.  For example, the teacher may see a file picker link to a Google Docs or UTube repositories where they can find files. As in the previous versions, the teacher can create a folder structure to store the files at the time files are uploaded.&lt;br /&gt;
&lt;br /&gt;
==FAQ==&lt;br /&gt;
Caveat: these are just making a start on these.  Subject to quality, style and accuracy improvements.&lt;br /&gt;
&lt;br /&gt;
===What are ways to make files available to other teachers/designers?===&lt;br /&gt;
In Moodle 2, this is going to require a change of habits. Some of the philosophy is written up in a small essay on course files [[Course_files|here]]&lt;br /&gt;
&lt;br /&gt;
One approach is to use a [[Repositories| repository]].  One of the easiest to set up is a [[File_system_repository_configuration|File System Repository]]  &lt;br /&gt;
&lt;br /&gt;
This needs server access.  One such example:&lt;br /&gt;
&lt;br /&gt;
[[Image:Repository-filesystem-filepicker.png]]&lt;br /&gt;
&lt;br /&gt;
===What are ways to make ONE change in a file and have this reflected across a Moodle site?===&lt;br /&gt;
This also will require a change in thinking.  You cannot just go to the file in the file picker and change it&#039;s name or upload a new file.  This would cause problems if it was linked to elsewhere.&lt;br /&gt;
&lt;br /&gt;
One answer is again to use repositories.  &#039;&#039;&#039;Link&#039;&#039;&#039; to the files in the repository.  Change the files (according to the permissions on the repository) and this is reflected everywhere int he course instantly.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [http://www.youtube.com/watch?v=JtePGeffl3o&amp;amp;feature=player_embedded Video: How teachers can upload files in Moodle 2.0]&lt;br /&gt;
* [[Course files]]&lt;br /&gt;
* [[Development:File API]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=160067 File Manager In Moodle 2.0] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[Category:Files]]&lt;br /&gt;
&lt;br /&gt;
[[de:Dateiverwaltung in Moodle 2.0]]&lt;br /&gt;
[[fr:Gestion des fichiers 2.0]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=File_picker&amp;diff=81990</id>
		<title>File picker</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=File_picker&amp;diff=81990"/>
		<updated>2011-03-16T15:24:51Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}} {{Update}}&lt;br /&gt;
File Picker is the standard interface that most users will use to manage a Moodle 2.0 file repository.  See [[Manage repositories]] &lt;br /&gt;
*Select an area ([[Repositories|a repository)]] to find the file and/or to add a file that can then be selected&lt;br /&gt;
**Server files - files on the site.  What you see here depends on your role in the course.&lt;br /&gt;
**Recent files - files Moodle thinks you have recently added&lt;br /&gt;
**Upload files -  This is where you click to upload files and folders from your computer&lt;br /&gt;
**[[Private files]] - files that belong to the user &lt;br /&gt;
*Use the standard add file- create folder interface &lt;br /&gt;
*Save selected files&lt;br /&gt;
&lt;br /&gt;
[[Image:Files_File-Picker_standard_blank_1.png|thumb|center|Empty file picker, no input area selected ]]&lt;br /&gt;
&lt;br /&gt;
==Standard add file - create folder option==&lt;br /&gt;
When the Resource of a Folder is selected in a course, in file picker, a standard pop-up will ask you for:&lt;br /&gt;
*Add (a file)- selecting this will take you to the add attachment and browse popup.&lt;br /&gt;
*Create a folder&lt;br /&gt;
*Download all files&lt;br /&gt;
[[Image:Files_standard_add_create_folder_with_folder-file_1.png|frame|center|Existing files and a folder ready to be added]]&lt;br /&gt;
&lt;br /&gt;
==Standard browse to add file popup==&lt;br /&gt;
The file picker will present a screen to select a file.  For example, when &amp;quot;Upload file&amp;quot; is selected, but also when you select add an image in the [[HTML editor]], you will see the file picker and the &amp;quot;Upload file&amp;quot; link. The standard add a file popup will ask you:&lt;br /&gt;
*Attachment - Browse.  This is where you find the file&lt;br /&gt;
*Save as - Allows changing the name of the file.  This is optional.  If you do use this, you must include the extension.&lt;br /&gt;
*Author - the default is the current user&lt;br /&gt;
*Choose license - a pull down menu with different licenses to select.&lt;br /&gt;
[[Image:Files standard add file screen 1.png|thumb|center|After a browse to a file on the C: drive]]&lt;br /&gt;
&lt;br /&gt;
== Views in file picker ==&lt;br /&gt;
===View as icons===&lt;br /&gt;
[[Image:Files File picker server files icons 1.png|thumb|center|Server files at demo.moodle.net in icon form, shows breadcrumb]]&lt;br /&gt;
&lt;br /&gt;
===View as list===&lt;br /&gt;
[[Image:Files File picker server files list collapsed 1.png|thumb|center|Server files at demo.moodle.net in list form, folders collapsed]]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
[[File picker FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Files]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Fitxategi-hautatzailea]]&lt;br /&gt;
[[fr:Sélecteur de fichiers]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Development:Stable_branch_support&amp;diff=81216</id>
		<title>Development:Stable branch support</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Development:Stable_branch_support&amp;diff=81216"/>
		<updated>2011-02-10T10:25:44Z</updated>

		<summary type="html">&lt;p&gt;Fox: This page should be updated&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Update}}&lt;br /&gt;
{{Template:Work_in_progress}}&lt;br /&gt;
&lt;br /&gt;
Unfortunately it&#039;s not possible to continue to provide support for older stable branches of Moodle indefinitely due to the amount of work involved. This page describes the process of dropping support for older stable branches.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Dropping support for 1.a.x==&lt;br /&gt;
&lt;br /&gt;
# Decide upon the final release of 1.a.x (taking into account that generally three versions are supported at a given time)&lt;br /&gt;
# Propose a date in MDLSITE-737 for dropping support for 1.a.x 5 months after the final release&lt;br /&gt;
# Announce the final release of 1.a.x in the moodle.org news&lt;br /&gt;
# Document the final release of 1.a.x in the [[:Category:Release_notes|release notes]]&lt;br /&gt;
# Update the Moodle version message in the tracker to read: &amp;quot;There will not be another 1.a.x release, but critical bugs may still be backported to the branch until [&#039;&#039;date 5 months in advance&#039;&#039;].&amp;quot; (both for the [http://tracker.moodle.org/secure/project/ViewProject.jspa?pid=10011 Moodle Project] and the [http://tracker.moodle.org/secure/project/ViewProject.jspa?pid=10033 Non-core contributed modules project]).&lt;br /&gt;
# After 5 months, release 1.a.x+ and archive all 1.a.x versions, closing the stable version in the tracker (also in both projects).&lt;br /&gt;
&lt;br /&gt;
==Dropping support for 1.6.x==&lt;br /&gt;
&lt;br /&gt;
# Proposed date for dropping support for 1.6.x: 31 July 2009&lt;br /&gt;
# Announcement: [http://moodle.org/mod/forum/discuss.php?d=115616 New releases: Moodle 1.9.4, 1.8.8, 1.7.7 and 1.6.9]&lt;br /&gt;
# 1.6.9+ released and 1.6.x versions archived on 31 July 2009. 16_STABLE closed in the tracker.&lt;br /&gt;
&lt;br /&gt;
==Dropping support for 1.7.x==&lt;br /&gt;
&lt;br /&gt;
# Proposed date for dropping support for 1.6.x: 31 October 2009&lt;br /&gt;
# Announcement: [http://moodle.org/mod/forum/discuss.php?d=115616 New releases: Moodle 1.9.4, 1.8.8, 1.7.7 and 1.6.9]&lt;br /&gt;
# 1.7.7+ released and 1.7.x versions archived on 31 October 2009. 17_STABLE closed in the tracker.&lt;br /&gt;
&lt;br /&gt;
==Dropping support for 1.8.x==&lt;br /&gt;
&lt;br /&gt;
See MDLSITE-737 for tentative dates&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* MDLSITE-737 Drop support for 1.6.x and 1.7.x versions in the Tracker&lt;br /&gt;
* [[Updates]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Processes|Stable branch support]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=Converting_your_MySQL_database_to_UTF8&amp;diff=80659</id>
		<title>Converting your MySQL database to UTF8</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=Converting_your_MySQL_database_to_UTF8&amp;diff=80659"/>
		<updated>2011-01-19T15:18:59Z</updated>

		<summary type="html">&lt;p&gt;Fox: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This document describes how to convert your MySQL database from the latin1 charset to UTF8. Moodle requires that your Database is now UTF8 and will not upgrade if your database is not.&lt;br /&gt;
&lt;br /&gt;
For more information about UTF8 have a look at the doc on [[Unicode|unicode]].&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
&lt;br /&gt;
You may see the following error when upgrading your Moodle.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;It is required that you store all your data in Unicode format (UTF-8). New installations must be performed into databases that have their default character set as Unicode. If you are upgrading, you should perform the UTF-8 migration process (see the Admin page).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Moodle requires UTF8 in order to provide better multilingual support and has done since Moodle 1.8. However the UTF8 check during install and upgrade was only been implemented in Moodle 2.0 and you may find you are unable to upgrade because your database was not set up correctly when you first installed Moodle or because you have been running Moodle since before 1.8 and haven&#039;t previously converted your database.&lt;br /&gt;
&lt;br /&gt;
==Converting an empty database==&lt;br /&gt;
If you have created your database schema and are receiving the error during your initial installation your Moodle database will still be empty. You can simply run the below query in your database to resolve the issue.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
alter database mydatabasename charset=utf8;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Converting a database containing tables==&lt;br /&gt;
If you have previously installed Moodle and are now getting the error the following process will allow you to convert your database.&lt;br /&gt;
&lt;br /&gt;
===Linux &amp;amp; Mac===&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
mysqldump -uusername -ppassword -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B dbname &amp;gt; dump.sql&lt;br /&gt;
cp dump.sql dump-fixed.sql&lt;br /&gt;
vim dump-fixed.sql&lt;br /&gt;
:%s/DEFAULT CHARACTER SET latin1/DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci/&lt;br /&gt;
:%s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/&lt;br /&gt;
:wq&lt;br /&gt;
mysql -uusername -ppassword &amp;lt; dump-fixed.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
or alternatively using sed:&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
#  $1-dbusername $2-password $3-dbname&lt;br /&gt;
mysqldump -u$1 -p$2 -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B $3 &amp;gt; dump.sql&lt;br /&gt;
sed &#039;s/DEFAULT CHARACTER SET latin1/DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci/&#039; &amp;lt;dump.sql | sed &#039;s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/&#039; &amp;gt;dump-fixed.sql&lt;br /&gt;
mysql -u$1 -p$2 &amp;lt; dump-fixed.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Explained====&lt;br /&gt;
The following steps will guide you in creating a database dumb, editing the database dump so that the correct charset and collation are used and then restoring the new database.&lt;br /&gt;
&lt;br /&gt;
To start please open a new terminal and move to a temp directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
mysqldump -uusername -ppassword -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database -B dbname &amp;gt; dump.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first step is of course to dump out the database and of course we will use mysqldump for this. We do however need to set several arguments in order to clean up the charsets and provide a dump that is not going to cause you any problems if you are moving this database to a different database server or find yourself having to restore on a reverted system.&lt;br /&gt;
&lt;br /&gt;
; username : The username to access your database.&lt;br /&gt;
; password : The password for the above user.&lt;br /&gt;
; -c : Complete inserts for better compatibility.&lt;br /&gt;
; -e : Extended inserts for better performance.&lt;br /&gt;
; --default-character-set=utf8 : To set the default character set.&lt;br /&gt;
; --single-transaction : To reduce our workload if anything goes wrong.&lt;br /&gt;
; --skip-set-charset : Obviously not wanted or needed as we are changing it anyway.&lt;br /&gt;
; --add-drop-database : Required so we can restore over the top of our existing database.&lt;br /&gt;
; -B : We use this option so that our dump will contain drop table and create table syntax (which we will change the syntax for).&lt;br /&gt;
; dbname : The name of the database to convert.&lt;br /&gt;
&lt;br /&gt;
When you run this command a database dump will be generated into &#039;&#039;&#039;dump.sql&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
cp dump.sql dump-fixed.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Next step is to copy dump.sql to dump-fixed.sql.&lt;br /&gt;
&lt;br /&gt;
We will make the desired changes within dump-fixed.sql and we will keep dump.sql as it is as a backup just in case.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
vim dump-fixed.sql&lt;br /&gt;
:%s/DEFAULT CHARACTER SET latin1/DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci/&lt;br /&gt;
:%s/DEFAULT CHARSET=latin1/DEFAULT CHARSET=utf8/&lt;br /&gt;
:wq&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Now we need to edit the dump and correct the incorrect charsets that have been used. I have chosen to do this with VIM however you can use any search+replace editor or program. ( I choose VIM for this only because every linux user is/should be familiar with it).&lt;br /&gt;
&lt;br /&gt;
First we open the file using VIM, and then run the three commands.&lt;br /&gt;
&lt;br /&gt;
The first command replaces all instances of &#039;&#039;DEFAULT CHARACTER SET latin1&#039;&#039; with &#039;&#039;DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci&#039;&#039;. This is used to fix up the database&#039;s default charset and collation.&lt;br /&gt;
&lt;br /&gt;
The second command replaces all instances of &#039;&#039;DEFAULT CHARSET=latin1&#039;&#039; with &#039;&#039;DEFAULT CHARSET=utf8&#039;&#039;. This converts all tables from using latin1 to using UTF8.&lt;br /&gt;
&lt;br /&gt;
The third command simply saves it and exits.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code bash&amp;gt;&lt;br /&gt;
mysql -uusername -ppassword &amp;lt; dump-fixed.sql&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Now that we&#039;ve made the required changes we simply need to restore the database over top of the existing database. We can do this by running the above command.&lt;br /&gt;
&lt;br /&gt;
===Windows===&lt;br /&gt;
Could someone who is familiar with Windows please convert the above into something that will work on Windows?&lt;br /&gt;
There are likely several additional arguments for mysqldump you will need to specify including setting the file for output using -r to avoid newline issues.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [[Unicode]]&lt;br /&gt;
&lt;br /&gt;
[[Category:UTF-8]]&lt;br /&gt;
[[Category:DB]]&lt;br /&gt;
[[Category:SQL_databases]]&lt;br /&gt;
&lt;br /&gt;
[[fr:Convertir votre base MySQL en UTF-8]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/30/en/index.php?title=AMOS&amp;diff=80445</id>
		<title>AMOS</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/30/en/index.php?title=AMOS&amp;diff=80445"/>
		<updated>2011-01-17T11:04:30Z</updated>

		<summary type="html">&lt;p&gt;Fox: French link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Moodle 2.0}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;AMOS stands for Automated Manipulation Of Strings. AMOS is a central repository of Moodle strings and their history. It tracks the addition of English strings into Moodle code, gathers translations, handles common translation tasks and generates language packages to be deployed on Moodle servers.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The name was chosen in honour of [http://en.wikipedia.org/wiki/John_Amos_Comenius John Amos Comenius], the author of &#039;&#039;Janua linguarum reserata&#039;&#039; (Gate to Languages Unlocked). Sorry Tori ;-)&lt;br /&gt;
&lt;br /&gt;
AMOS is installed at http://lang.moodle.org. If you want to use it, please create an account there. Language pack [[Translation_credits|maintainers]] should then send an email to [mailto:translation@moodle.org translation@moodle.org] (Koen) to get write access for their language.&lt;br /&gt;
&lt;br /&gt;
AMOS provides support for community contributions into the translation. If you want to participate, just create an account at http://lang.moodle.org. There is no need to contact us in this case but you should definitely contact the language maintainer and coordinate your work.&lt;br /&gt;
&lt;br /&gt;
== Basic concepts ==&lt;br /&gt;
&lt;br /&gt;
[[image:amos-screenshot-navigation.png|100px|thumb|right|AMOS tools in the navigation block]]&lt;br /&gt;
AMOS consists of several tools available via the main navigation block - Translator, Stage, Stashes, Contributions and Log.&lt;br /&gt;
&lt;br /&gt;
* User - AMOS is used by languages pack maintainers and by the community members who want to contribute&lt;br /&gt;
* Translator - is a tool that allows you to filter strings you want to work on and translate them&lt;br /&gt;
* Stage - is a temporary working area that holds the strings you have translated during the current session. Maintainers can permanently commit the stage into the strings repository. Contributors can submit the stage for maintainers.&lt;br /&gt;
* Stashes - are snapshots of the stage. Imagine them as ordinary files at your computer where you can save your work. You can submit your stash to the language pack maintainers.&lt;br /&gt;
* Contributions - is a database tracking all submitted contributions and their current status. Records in this database are like issues in Moodle tracker with the translated strings attached.&lt;br /&gt;
* Repository - a database of all Moodle strings and their history running at lang.moodle.org server&lt;br /&gt;
* Log - displays the log of all modifications of Moodle strings.&lt;br /&gt;
&lt;br /&gt;
== Translation workflow ==&lt;br /&gt;
&lt;br /&gt;
The following data flow diagram illustrates how AMOS tools are used during the translation process.&lt;br /&gt;
&lt;br /&gt;
[[image:amos-workflow.png]]&lt;br /&gt;
&lt;br /&gt;
The key AMOS component is the staging area or shortly the stage. It holds translated strings temporarily during your current login session. If you log out, the stage is cleared (though there is a backup - see below). There are several ways how translations can be staged, that is how translated strings can be put into the stage:&lt;br /&gt;
&lt;br /&gt;
* by using AMOS translator&lt;br /&gt;
* by importing strings from an uploaded file&lt;br /&gt;
* by applying a previously created stash&lt;br /&gt;
* by applying a submitted contribution&lt;br /&gt;
&lt;br /&gt;
Language pack maintainers have write access into the AMOS strings repository. Therefore they can commit their stage permanently. Once the stage is committed, staged strings are stored in the AMOS repository. Every hour at xx:45, AMOS generates ZIP packages from the most recent snapshot of the repository. These ZIP packages are published at http://download.moodle.org/langpack/2.0/ for download. Moodle sites can install and update language packages automatically from the &#039;&#039;Site administration &amp;gt; Language &amp;gt; Language packs&#039;&#039; page.&lt;br /&gt;
&lt;br /&gt;
Community members do not have write access into the repository so they can&#039;t commit their stage. Instead, they can submit it to the maintainers. By submitting a stage, a new contribution record is created and language pack maintainers are notified by automatic email message. Maintainers can review the submitted contribution and, if they accept it, commit it on behalf of the contributor.&lt;br /&gt;
&lt;br /&gt;
The stage can be also saved so you can interrupt your work and continue next time you come back to the site. The stage is saved into so called stashing area. Stashing area consists of stashes. A new stash is nothing but a snapshot copy of your current stage. AMOS automatically keeps one stash for you as a backup copy of your most recent stage. A stash can be submitted to the maintainers, too.&lt;br /&gt;
&lt;br /&gt;
== AMOS tools ==&lt;br /&gt;
&lt;br /&gt;
=== Using the translator tool ===&lt;br /&gt;
&lt;br /&gt;
[[image:amos-screenshot-translator.png|300px|thumb|right|AMOS Translator tool]]&lt;br /&gt;
The translator tool page has two main parts. At the top, there is a filter form (1). You use that filter to get the strings you want to translate. When the filter settings are saved (2), a table with the filtered strings is displayed below.&lt;br /&gt;
&lt;br /&gt;
Every row in the table represents a single string. The table has four columns. The first column (3) describes the version (or branch) where the string is used, its identifier and its component. You can see a text like&lt;br /&gt;
&lt;br /&gt;
 2.0 [completiondate,coursereport_completion]&lt;br /&gt;
&lt;br /&gt;
That reads: this string is used in Moodle 2.0, its identifier is &#039;completiondate&#039; and it belongs to &#039;courserepor_completion&#039; component.&lt;br /&gt;
&lt;br /&gt;
The second column (4) contains the English original of the string. Below the text, you can see Google icon. Click that icon to get automatic translation of the string into the language being translated. The next column contains a code of the language that this string is being translated to (for example &amp;quot;cs&amp;quot; for Czech).&lt;br /&gt;
&lt;br /&gt;
Finally the last column contains the translation itself. If it is empty, the string is not translated yet, otherwise it displays the current translation. &#039;&#039;&#039;Click in the cell to turn it into the input editor.&#039;&#039;&#039; Insert the translation and click outside the cell to stage the translation. Note there is no submit button, the text is sent to the stage automatically in the background. You can see that the colour of the cell turned blue. Blue colour signalizes that the translation is currently staged.&lt;br /&gt;
&lt;br /&gt;
You have many options of how to use the strings filter. You can work on a single component or all missing strings at once. You can search for strings containing a given text (either in English or the translated string) etc. You can check for strings in older versions, too but those strings are read-only. They get automatically pulled into AMOS from the CVS repository of 1.x translations.&lt;br /&gt;
&lt;br /&gt;
The &#039;permalink&#039; below the filter&#039;s submit button can be used to keep the current filter settings. For example, you can bookmark a setting use regularly or you can copy the link URL and send it to somebody so they can set their filter just by visiting that URL.&lt;br /&gt;
&lt;br /&gt;
When you finish translating, do not forget to visit the stage page. You probably want either commit it (if you are a lang pack maintainer) or submit it to maintainers so they can review your work and include it into the language pack.&lt;br /&gt;
&lt;br /&gt;
=== Using the stage ===&lt;br /&gt;
&lt;br /&gt;
[[image:amos-screenshot-stage-contrib.png|300px|thumb|right|Strings staged by a contributor]]&lt;br /&gt;
The translated strings are put into a temporary area called &#039;&#039;stage&#039;&#039; immediately after the cursor leaves the editor field. The stage holds your work before it is either committed into the repository (if you are language pack maintainer) or submitted to the maintainers for inclusion or stashed.&lt;br /&gt;
&lt;br /&gt;
The stage is cleared when you logout. You have to explicitly commit or stash the stage so it is saved permanently. If you forget to do it, or there is a problem with the connectivity, your browser crashes or whatever, you can find your most recent snapshot of the stage in autosave stash.&lt;br /&gt;
&lt;br /&gt;
If you are language pack maintainer, you can commit the stage into the repository so your work is registered and the translated strings become part of the official language package. Language packages in ZIP format are generated every hour (at xx:45) and are published at http://download.moodle.org/langpack/2.0/. At the same time, they become available for Moodle sites for automatic update.&lt;br /&gt;
&lt;br /&gt;
=== Importing a file ===&lt;br /&gt;
&lt;br /&gt;
[[image:amos-screenshot-stage-empty.png|300px|thumb|right|Empty stage allows you to import strings from a file]]&lt;br /&gt;
Strings can be translated offline and uploaded back to AMOS. The only supported format at the moment is common PHP format used by Moodle where strings are defined in associative array called $string. For obvious security reasons, AMOS can not actually execute PHP files uploaded by users. Instead, it parses the uploaded file in a similar way as PHP parser, looking for patterns that are considered as valid string definition. That means that not every valid PHP code is valid string definition. AMOS parser requires following conditions are met:&lt;br /&gt;
&lt;br /&gt;
* the filename is valid component name used by Moodle, for example moodle.php, enrol_manual.php or workshop.php&lt;br /&gt;
* the file is valid PHP code without syntax errors - that means is passes the PHP lint check&lt;br /&gt;
* strings are defined as elements of global array $string&lt;br /&gt;
* strings are single quoted constants&lt;br /&gt;
&lt;br /&gt;
Example of a valid file to import into AMOS (filename countries.php, Czech translation)&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;?php&lt;br /&gt;
 &lt;br /&gt;
 $string[&#039;AE&#039;] = &#039;Spojené Arabské emiráty&#039;;&lt;br /&gt;
 $string[&#039;AF&#039;] = &#039;Afghánistán&#039;;&lt;br /&gt;
 $string[&#039;CH&#039;] = &#039;Švýcarsko&#039;;&lt;br /&gt;
 $string[&#039;HU&#039;] = &#039;Maďarsko&#039;;&lt;br /&gt;
 &lt;br /&gt;
 ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
During the import, strings found in the file are added into your stage as if they were translated via web. You can commit them into repository if you have such privilege.&lt;br /&gt;
&lt;br /&gt;
=== Using stashes ===&lt;br /&gt;
&lt;br /&gt;
At any moment, you can save a snapshot of the current stage. We call such snapshot a &#039;&#039;stash&#039;&#039;. Stashed strings are kept forever until you drop them manually (please do not abuse this and keep your stashes reasonable big). The stash can be &#039;&#039;applied&#039;&#039; so that the stashed strings are copied back to the stage.&lt;br /&gt;
&lt;br /&gt;
There is one special stash record for every user called autosave stash. This stash keeps the most recent state of the stage. You may find it useful if you loose the current stage for any reason - your browser crashes, your internet connectivity dies or you accidentally unstage all strings. If that happens, just apply the autosave stash to get your work back. The autosave stash is updated every time you stage a string. So if your stage is empty and your autosave stash is full of strings and you go into the translator first without applying the stash, the autosave will be replaced with the new translated string. We recommend to experiment a bit with this feature first.&lt;br /&gt;
&lt;br /&gt;
=== Using the log tool ===&lt;br /&gt;
&lt;br /&gt;
The Log page allows even anonymous users to search in the history of commits tracked by AMOS. At the top of the page there is a filter that allows you to look for a particular information or report. It is important to realize how the filter actually works. Searching and filtering happens in two steps (this was necessary for performance reasons):&lt;br /&gt;
&lt;br /&gt;
* Firstly, commit records are searched based on the criteria specified in the Commit filter form. If there are more commits found matching the filter settings, only 100 most recent commits are processed.&lt;br /&gt;
* Then, within the commits found, either all string modification records are returned, or you can filter these records, too. Settings in String filter form section are used in that case.&lt;br /&gt;
&lt;br /&gt;
By default, the filter looks for all commits since the last time you logged in and than displays only strings at the currently translated branch modified by those commits.&lt;br /&gt;
&lt;br /&gt;
== Contributing to a language pack ==&lt;br /&gt;
&lt;br /&gt;
AMOS allows community members to help with the translation of Moodle strings. AMOS Contributions page tracks all submitted translations and their current status. Before you start working on a translation, please communicate with the language pack maintainer (to be found on https://docs.moodle.org/en/Translation_credits).&lt;br /&gt;
&lt;br /&gt;
=== Steps for the contributor ===&lt;br /&gt;
&lt;br /&gt;
[[image:amos-screenshot-contribution-new.png|300px|thumb|right|Submitting a contribution form]]&lt;br /&gt;
# Contact the language pack maintainer about your intention to contribute to the language pack&lt;br /&gt;
# Use AMOS translator interface to translate missing strings or amend the current translation&lt;br /&gt;
# Go to the Stage page&lt;br /&gt;
# Click &#039;Submit to maintainers&#039; button&lt;br /&gt;
# At &#039;Submitting a contribution&#039; page, please provide a message for maintainers describing your work and why you would like to see your contribution included. You can cancel the submission at this moment yet. If you are sure, click &#039;Submit to maintainers&#039;.&lt;br /&gt;
# Your stage will submitted into the contributions database. If there were more languages affected by your contribution, the stage will be divided into separate contribution records, one per each language. The language pack maintainers will be notified by email about your new contribution.&lt;br /&gt;
# Language pack maintainers will be able to apply your work into their stage, review it and eventually commit. You will receive automatically generated email when the status of contribution changes (typically when a maintainer starts a review of your work and then when they accept or reject it).&lt;br /&gt;
# Use contribution record comments for further communication with the maintainer about the submitted translation.&lt;br /&gt;
&lt;br /&gt;
=== Steps for the maintainer ===&lt;br /&gt;
&lt;br /&gt;
[[image:amos-screenshot-contribution-details.png|300px|thumb|right|Contribution details page]]&lt;br /&gt;
# When a user submits new contribution, you will receive automatically generated email from AMOS&lt;br /&gt;
# Go to the Contributions page to see a list of all new incoming contributions. Click the link in the table to open the contribution details page&lt;br /&gt;
# Press &#039;Start review&#039; button. That will assign the contribution to yourself, change the status from &#039;New&#039; to &#039;In review&#039;, send automatically generated email to the contributor and will copy the submitted strings into your stage. You should check that your stage is empty before you apply the submitted strings, unless you want to merge several contributions into one commit.&lt;br /&gt;
# Review the submitted strings, eventually edit them. Commit the stage. It is nice to mention the contributor&#039;s name in the commit message and attribute the original authorship to them.&lt;br /&gt;
# Go back to the contribution record and change the status to Accepted or Rejected. Automatically generated email will be sent to the contributor whenever you change the status.&lt;br /&gt;
# Use contribution record comments for further communication with the contributor about the submitted translation.&lt;br /&gt;
# Accepted and Rejected contributions are not shown at the contributions page unless you press &#039;Show resolved contributions&#039; button.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Translation 2.0]] for more information about the process of Moodle 2.x translation&lt;br /&gt;
* [[Development:Languages/AMOS]] for the AMOS internals documentation&lt;br /&gt;
&lt;br /&gt;
[[Category:Language]]&lt;br /&gt;
&lt;br /&gt;
[[fr:AMOS]]&lt;/div&gt;</summary>
		<author><name>Fox</name></author>
	</entry>
</feed>