<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/38/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Libertymoodle</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/38/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Libertymoodle"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/Special:Contributions/Libertymoodle"/>
	<updated>2026-05-15T22:10:42Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Header_and_footer&amp;diff=137134</id>
		<title>Header and footer</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Header_and_footer&amp;diff=137134"/>
		<updated>2020-07-27T08:46:49Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* &amp;#039;Get the mobile app&amp;#039; rewording link */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Site appearance}}&lt;br /&gt;
You can easily add links and other information to the top and bottom, and header and footer of your Moodle site.&lt;br /&gt;
&lt;br /&gt;
== Customising the header==&lt;br /&gt;
*The administrator can add links, metatags, CSS or Java Script to the header section of your page via &#039;&#039;Site administration &amp;gt; Appearance &amp;gt; Additional HTML&#039;&#039; &lt;br /&gt;
*You can  specify HTML or CSS or JavaScript that you want added to every page without altering the Moodle code files. &lt;br /&gt;
* Add your HTML/CSS to the&#039; Within HEAD&#039; box&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:headerbox.png|thumb|400px|Adding HTML]]&lt;br /&gt;
| [[File:headerlink.png|thumb|400px|The resulting text]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Dropdown menus===&lt;br /&gt;
Although not strictly in the &#039;header&#039; section, custom dropdown menus may be added to the top of your site via &#039;&#039;Site administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; Theme settings&#039;&#039;  and adding your links to the Custom menu box, using the examples given to help you.&lt;br /&gt;
&lt;br /&gt;
[[File:custommenu.png|thumb|center|500px|Example of a site with custom dropdown menus]]&lt;br /&gt;
&lt;br /&gt;
==Customising the footer==&lt;br /&gt;
&lt;br /&gt;
*As with header options in the section above, the administrator can add links, CSS or Java Script to the footer section of your page via &#039;&#039;Site administration &amp;gt; Appearance &amp;gt; Additional HTML&#039;&#039; &lt;br /&gt;
*This  might be useful for adding Google Analytics, for example.&lt;br /&gt;
* Add your HTML/CSS to the &#039;Before BODY is closed&#039; box.&lt;br /&gt;
&lt;br /&gt;
===Footer link to Moodle docs===&lt;br /&gt;
&lt;br /&gt;
*Moodle Docs is an abbreviation for &#039;&#039;Moodle documentation&#039;&#039;.&lt;br /&gt;
*By default, managers, teachers and non-editing teachers (and any other users with the capability [[Capabilities/moodle/site:doclinks|moodle/site:doclinks]]) have &amp;quot;Moodle Docs for this page&amp;quot; links at the bottom of each page in Moodle for accessing context-specific documentation.&lt;br /&gt;
&lt;br /&gt;
[[File:MoodleDocsforthispageScreenshot.png|thumb|center|400px|&#039;Moodle Docs for this page&#039; link]]&lt;br /&gt;
&lt;br /&gt;
*An administrator can change Moodle Docs settings in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Appearance &amp;gt; Moodle Docs&#039;&#039;. The link can be made to open in a new window; the docs language may be forced, and the docs link may be removed by removing the link from the Moodle docs document root field.&lt;br /&gt;
*If you have your own custom documentation online or wish to link to other documentation online, you can change the link in this Moodle docs document root field.&lt;br /&gt;
*You can download the Moodle Docs files for several branches and languages of Moodle Docs from [http://wimski.org/docs/ http://wimski.org/docs/]. These files can be hosted in a local intranet and this may be useful for places that have strict internet policies that prevent Moodle users from reaching [https://docs.moodle.org/en/Main_page The Moodle Docs site].&lt;br /&gt;
&lt;br /&gt;
==&#039;Get the mobile app&#039; link==&lt;br /&gt;
&lt;br /&gt;
In Moodle 3.4 onwards, the link &#039;Get the mobile app&#039; in the footer encourages users to make use of the [[Moodle Mobile]] app. &lt;br /&gt;
&lt;br /&gt;
By default, the link is https://download.moodle.org/mobile however the setting &#039;App download page&#039; (in &#039;Mobile appearance&#039; in the Site administration) can be changed e.g. for sites using a branded mobile app.&lt;br /&gt;
&lt;br /&gt;
To prevent the &#039;Get the mobile app&#039; link being displayed in the footer, simply remove the URL from the &#039;App download page&#039; setting so that the field is blank and then save changes.&lt;br /&gt;
&lt;br /&gt;
If mobile services are not enabled for the site, then the &#039;Get the mobile app&#039; link is not displayed.&lt;br /&gt;
&lt;br /&gt;
==Theme settings options==&lt;br /&gt;
Some themes allow you to add custom CSS and footer text via their settings pages The standard &#039;Clean&#039; and &#039;More&#039; themes offer this option, via &#039;&#039;Site administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; Clean/More&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:morefootnotebox.png|thumb|400px|Adding content to the footer in the More settings page]]&lt;br /&gt;
| [[File:morefootnote.png|thumb|400px|The resulting text]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Customising the &#039;main body&#039; section==&lt;br /&gt;
*As with header and footer options, you can add code and script to the main body of the page.&lt;br /&gt;
*This might be useful for adding a banner image, a text heading or an alert message for example.&lt;br /&gt;
* Add your content to the &#039;When BODY is opened&#039; box.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Theme settings]] for details of how to set up custom menu items&lt;br /&gt;
* [http://wimski.org/docs/ http://wimski.org/docs/] for downloading offline Moodle Docs pages.&lt;br /&gt;
&lt;br /&gt;
[[de:Kopf- und Fußzeile]]&lt;br /&gt;
[[es:Encabezado y pie de página]]&lt;br /&gt;
[[fr:Entête et pied de page]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Automated_course_backup&amp;diff=136862</id>
		<title>Automated course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Automated_course_backup&amp;diff=136862"/>
		<updated>2020-04-15T15:32:54Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Setting an automated course backup schedule - add Windows path */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Backup}}&lt;br /&gt;
==Automating course backups==&lt;br /&gt;
&lt;br /&gt;
Automated course backups runs the same functions as individual [[Course backup|course backups]]. It&#039;s a good idea to schedule backups for when your server isn&#039;t usually busy. Running the backup tool over all the courses can be processor-intensive, so you shouldn&#039;t run it when there are a lot of students trying to access the server. You should always alert users with an announcement on the first page that if they log on during the backup hours they may notice a decrease in performance.  &lt;br /&gt;
&lt;br /&gt;
In order to make scheduled backups, you have to set up CRON to run periodically. Please refer to the [[Cron|cron instructions]].&lt;br /&gt;
&lt;br /&gt;
==Setting an automated course backup schedule==&lt;br /&gt;
&lt;br /&gt;
/To set the backup schedule:&lt;br /&gt;
#Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Courses &amp;gt; Backups &amp;gt; Automated backup setup&#039;&#039;.&lt;br /&gt;
#Set backup_auto_active to enabled.&lt;br /&gt;
#Select the days of the week to run the backup.&lt;br /&gt;
#Set the execution time for the backup process. For most servers, early morning will be the best time.  Keep in mind the time zone your server is using.&lt;br /&gt;
#Set the &amp;quot;Save to...&amp;quot; path. If you can, choose a backup path on another machine or on a different drive than the one Moodle is on. You don’t want to lose your backups at the same time you lose your Moodle site if the drive fails. If you leave the field blank, then backup zip files will be saved in the backup folder of each course files folder. On a Linux server the path might look like: &#039;&#039;&#039;/home/(your user or domain)/public_html/archive/&#039;&#039;&#039; or if it&#039;s below the publicly accessible folders: &#039;&#039;&#039;/home/(your user or domain)/archive/&#039;&#039;&#039;. On Windows the path might look like: &#039;&#039;&#039;D:\Archive\&#039;&#039;&#039;.&lt;br /&gt;
If the path is not recognized a red X is shown after saving, otherwise a green check.&lt;br /&gt;
#Set all other options appropriately. &lt;br /&gt;
#Click the &amp;quot;Save changes&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tip&#039;&#039;&#039;: To save disk space, you can choose to delete backups older than a specified number of days. If so, you should also specify a minimum number of backups to be kept. (The settings &#039;Delete backups older than&#039; and &#039;Minimum number of backups kept&#039; are new in Moodle 3.0 onwards.)&lt;br /&gt;
&lt;br /&gt;
Once you&#039;ve set up your backup schedule, Moodle will automatically create archives of all the courses on the server at the time you specified. Once the backup is complete, Moodle will send you an email describing the status of the backup.&lt;br /&gt;
&lt;br /&gt;
==Backups report==&lt;br /&gt;
&lt;br /&gt;
A last execution log of scheduled course backups can be found in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Reports &amp;gt; Backups&#039;&#039;. It displays a list of all course backups made, the time taken to create them, their status (see below), and the next scheduled automated backup execution time.&lt;br /&gt;
&lt;br /&gt;
Clicking the &#039;View logs&#039; icon next to the course name (1 in screenshot below) will display a detailed backup log for a particular course, including date, hour and minute when each step of the backup was performed (2). This log is useful for troubleshooting backup errors.&lt;br /&gt;
&lt;br /&gt;
[[File:backuplogs.png|thumb|500px|center|]]&lt;br /&gt;
&lt;br /&gt;
===Backup status===&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;OK&#039;&#039;&#039; - The course backup was successfully completed.&lt;br /&gt;
*&#039;&#039;&#039;Skipped&#039;&#039;&#039; - The course was skipped (not backed up) because the course was unavailable to students and had not been changed in the last 31 days. This is not an error, but a feature designed to save process time.&lt;br /&gt;
*&#039;&#039;&#039;Unfinished&#039;&#039;&#039; - The backup was not finished. This might have happened because the job to execute backups ran out of time or resources (e.g., the cron running the backups ran out of time before finishing all the courses waiting). The unfinished jobs should be completed when the next scheduled backups are repeated. &lt;br /&gt;
*&#039;&#039;&#039;Error&#039;&#039;&#039; - There were errors in the backup process for the course, so a backup was not completed. For additional details about the error (1) check the backup log for the affected course (i.e. click the &#039;View logs&#039; icon next to the course name) or (2) back up the course manually with debugging turned on to see what error message is displayed.&lt;br /&gt;
&lt;br /&gt;
==Course versus site backups==&lt;br /&gt;
&lt;br /&gt;
*Automated course backups are more expensive in terms of time and CPU usage. The recovery time to have your site running again is longer. &lt;br /&gt;
*Course backups are useful for obtaining &amp;quot;fresh&amp;quot; copies of courses to be re-used or distributed individually, however they should never be used as a primary backup system (unless your hosting doesn&#039;t allow the preferred [[Site backup|site backups]]). &lt;br /&gt;
&lt;br /&gt;
==Capabilities==&lt;br /&gt;
&lt;br /&gt;
Both the [[Capabilities/moodle/backup:downloadfile|download course backup files capability]] and the [[Capabilities/moodle/restore:userinfo|restore user data from a course backup capability]] are required to be able to download automated course backups. There is also a [[Capabilities/moodle/restore:viewautomatedfilearea|restore courses from the automated backup storage capability]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Report]]&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Ikastaroen_segurtasun-kopia_automatikoa]]&lt;br /&gt;
[[fr:Sauvegarde (administrateurs)#Rapports Sauvegardes]]&lt;br /&gt;
[[ja:自動コースバックアップ]]&lt;br /&gt;
[[de:Automatische Kurssicherung]]&lt;br /&gt;
[[es:Respaldo de curso automatizado]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=136762</id>
		<title>Configurable reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=136762"/>
		<updated>2020-03-17T15:55:33Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Filters Issue */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox plugin&lt;br /&gt;
|type = Block&lt;br /&gt;
|entry = https://moodle.org/plugins/view.php?plugin=block_configurable_reports&lt;br /&gt;
|tracker = http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
|discussion = https://moodle.org/mod/forum/view.php?id=7979&lt;br /&gt;
|maintainer = [[User:Juan Leyva|Juan Leyva]], [[User:Sara Arjona Téllez|Sara Arjona Téllez]]&lt;br /&gt;
|float = right&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
# Download the Configurable Reports installation file and unzip it to the &#039;&#039;&#039;\blocks&#039;&#039;&#039; directory in your Moodle folder.&lt;br /&gt;
# Be sure that the final name of the directory is: configurable_reports, the full path in your Moodle installation will be blocks/configurable_reports&lt;br /&gt;
# Login to Moodle as Administrator and click Notifications under Site Administration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information see [[Installing contributed modules or plugins]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This block is a Moodle custom reports builder. It its also connected to a [https://github.com/jleyva/moodle-configurable_reports_repository public repository of sample reports] (only plugin version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
It is designed in a modular way to allow developers to create new plugins in less than an hour.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can create custom reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Anyone with block, managereports or manageownreports permissions at SITE level or COURSE level.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What type of reports can I create?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Courses reports, with information regarding courses.&lt;br /&gt;
&lt;br /&gt;
- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.&lt;br /&gt;
&lt;br /&gt;
- Users reports, with information regarding users and their activity in a course.&lt;br /&gt;
&lt;br /&gt;
- Timeline reports, this is a special type of report that displays a timeline. A course or user report can be embedded in this timeline showing data depending on the start and end time of the current row.&lt;br /&gt;
&lt;br /&gt;
- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as [https://moodle.org/plugins/view.php?plugin=report_customsql Tim Hunt&#039;s Custom SQL queries] plugin.&lt;br /&gt;
&lt;br /&gt;
Note for developers: You can create your own type of reports.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can view the reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When you create a report you can select which users can view it.&lt;br /&gt;
&lt;br /&gt;
The reports are displayed in a block in the course or site frontpage.&lt;br /&gt;
&lt;br /&gt;
== Creating a report ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a very simple process.  &lt;br /&gt;
&lt;br /&gt;
If you are going to create a report for a course, you have to add the block in the course and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
On the other hand, for site reports, add the block in the frontpage and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
You must enter a name, an optional description, and you have to choose the type of report, pagination and exports formats.&lt;br /&gt;
&lt;br /&gt;
Depending on the report choosen, there will be more or less tabs. These are the tabs for the courses and users report:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Columns&#039;&#039;&#039;: Here you can choose the differents columns of your report depending on the type of report. (Course Name, User firstname, etc..)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Conditions&#039;&#039;&#039;: Here you can define the conditions (i.e, only courses from this category, only users from Spain, etc.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ordering&#039;&#039;&#039;: Here you can choose how to order the report using fields and directions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filters&#039;&#039;&#039;: Here you can choose which filters will be displayed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Template&#039;&#039;&#039;: You can modify the report&#039;s layout by creating a template.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Permissions&#039;&#039;&#039;: Here you can choose who can view a report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Calculations&#039;&#039;&#039;: Here you can add calculations for columns, i.e: average of number of users enrolled in courses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plots&#039;&#039;&#039;: Here you can add graphs to your report based on the report columns and values.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;View report&#039;&#039;&#039;: Self explanatory&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a users&#039; report ===&lt;br /&gt;
&lt;br /&gt;
Requirements: &#039;&#039;Users from Spain, but not from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user&#039;s city must be displayed. A pie plot showing the users&#039; cities is required. A calculation table showing the total forum post views is required. The report must be ordered by users&#039; lastname.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how easy it is!&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Enter a name, a description and choose &amp;quot;Users report&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you will be redirected to the first Tab named &amp;quot;Columns&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Columns&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here you can define the report table properties, width, align, cell padding, cell spacing, etc.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User profile field&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Choose the field &amp;quot;firstname&amp;quot; and enter a name for the column in the text field. You can leave the rest of elements blank.&lt;br /&gt;
&lt;br /&gt;
Repeat the process above for the lastname and city fields.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose a module from the list, in this example, a forum.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Adding Conditions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Conditions Tab.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, the Operator &amp;quot;=&amp;quot;, and enter the value &amp;quot;ES&amp;quot; (this is the international code for Spain as Moodle stores it).&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;city&amp;quot;, the Operator &amp;quot;&amp;lt;&amp;gt;&amp;quot;, and enter the value &amp;quot;Madrid&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;Users in current report course&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These are the main conditions of the reports. Note that at the bottom there is a text box called condition, with this text:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;c2 and c1 and c3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Here you can define a logic condition, in this case, we don&#039;t need to edit this condition but you can create complex expressions like:&lt;br /&gt;
&lt;br /&gt;
 (c1 and c2) or (c4 and c3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Ordering&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Ordering Tab.&lt;br /&gt;
&lt;br /&gt;
Add a ordering named &amp;quot;User field ordering&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Lastname&amp;quot; and the ordering &amp;quot;ASC&amp;quot; (Ascending).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Filters Tab.&lt;br /&gt;
&lt;br /&gt;
Add a filter named &amp;quot;User field filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose city.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Permissions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Permissions Tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;User field Value&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, and enter the value &amp;quot;ES&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Here you can add more permissions and a logic condition to be achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Calculations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Calculations tab.&lt;br /&gt;
&lt;br /&gt;
Choose Sum.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Plots&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Plots tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;Pie&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the colum &amp;quot;City&amp;quot; as Name and Value.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville, etc. and test the report.&lt;br /&gt;
&lt;br /&gt;
You can download the report in different formats (ods and xls), remember to check these options in the report page.&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#Users_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a SQL Report ===&lt;br /&gt;
&lt;br /&gt;
You can find a lot of SQL Reports here: [[ad-hoc contributed reports]]&lt;br /&gt;
&lt;br /&gt;
Since this block supports Tim Hunt&#039;s CustomSQL Queries Reports, you can use any query.&lt;br /&gt;
&lt;br /&gt;
Remember to add a &amp;quot;Time filter&amp;quot; if you are going to use reports with time tokens.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&lt;br /&gt;
&lt;br /&gt;
Enter a name, description, choose &amp;quot;SQL&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you redirect to the first Tab named &amp;quot;Custom SQL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add this query (&#039;&#039;Courses activity&#039;&#039;):&lt;br /&gt;
&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;
==== Adding a calculation ====&lt;br /&gt;
# Go to Calculations Tab&lt;br /&gt;
# Add a Sum calculation, choose the hits column&lt;br /&gt;
&lt;br /&gt;
==== Adding a Plot ====&lt;br /&gt;
# Go to Plot&lt;br /&gt;
# Add a Pie graph, choosing coursename as Name and hits as value&lt;br /&gt;
&lt;br /&gt;
So, here you have a report with a Graph and calculations based on a SQL Query.&lt;br /&gt;
&lt;br /&gt;
Note: Bar charts are currently not displaying on systems using PHP 7: https://github.com/jleyva/moodle-block_configurablereports/issues/101&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filters add a control to the report that allows the user to select a subset of data when the report runs.  Filters require two steps:&lt;br /&gt;
&lt;br /&gt;
# Select the filter you want to use on the &amp;quot;Filters&amp;quot; tab&lt;br /&gt;
# Add SQL code to make the filter affect the output.&lt;br /&gt;
&lt;br /&gt;
These are the filters that can be used to constrain your report:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%FILTER_CATEGORIES:&lt;br /&gt;
%%FILTER_COURSEMODULEID:&lt;br /&gt;
%%FILTER_COURSEMODULEFIELDS:&lt;br /&gt;
%%FILTER_COURSEMODULE:&lt;br /&gt;
%%FILTER_COURSES:&lt;br /&gt;
%%FILTER_COURSEENROLLEDSTUDENTS:&lt;br /&gt;
%%FILTER_USERS:&lt;br /&gt;
%%FILTER_ROLE:&lt;br /&gt;
%%FILTER_SEARCHTEXT:&lt;br /&gt;
%%FILTER_SEMESTER:&lt;br /&gt;
%%FILTER_STARTTIME:&lt;br /&gt;
%%FILTER_ENDTIME:&lt;br /&gt;
%%FILTER_SUBCATEGORIES:&lt;br /&gt;
%%FILTER_COURSEUSER:&lt;br /&gt;
%%FILTER_SYSTEMUSER:&lt;br /&gt;
%%FILTER_YEARHEBREW:&lt;br /&gt;
%%FILTER_YEARNUMERIC:&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Using Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When using a filter you need at least one static WHERE condition, followed by one or more filters. For example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
WHERE 1&lt;br /&gt;
%%FILTER_COURSES:c.id%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can technically add multiple filters, but once a user applies one filter to a report all filters for report are applied. So it can be a little tricky to have multiple filters on the same report. For example if you add a course and date filter to a report, then if you just want to filter by course you have to make sure your date filters are set to date range that covers all courses.&lt;br /&gt;
&lt;br /&gt;
Many of the filters are hard coded to be drop down menus which are sorted by database id number instead of alphabetically. This can be problematic if you have a large number of users, courses, or categories. However, you can use one search text filter per report, which can be used to work around the issue in some cases.&lt;br /&gt;
&lt;br /&gt;
Many filters require a logical operator to specify how the filter works. For example&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%FILTER_STARTTIME:l.TIME:&amp;gt;%% %%FILTER_ENDTIME:l.TIME:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a Course filter; it&#039;s very easy.&lt;br /&gt;
# Go to filters, choose Courses&lt;br /&gt;
# Edit the Custom SQL query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &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;
Note that we are adding a token called: %%FILTER_COURSES:l.courseid%% &lt;br /&gt;
&lt;br /&gt;
Go to View report, and you will see a Courses Filter, choose a Course and click on Add, here you have a report filtered.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also add a Starttime and endtime filter&lt;br /&gt;
&lt;br /&gt;
# Go to filters, choose Start / End date filter&lt;br /&gt;
# Go to Custom SQL tab, this is the new query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &lt;br /&gt;
%%FILTER_STARTTIME:l.time:&amp;gt;%% %%FILTER_ENDTIME:l.time:&amp;lt;%% &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;
&lt;br /&gt;
If you want to filter text (for example, lastname)&lt;br /&gt;
&lt;br /&gt;
# Go to filters, choose Search Text filter&lt;br /&gt;
# Go to Custom SQL tab and type your query. Here is an example for querying the user table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname&lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_SEARCHTEXT:u.lastname:~%%&lt;br /&gt;
ORDER BY u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace WHERE 1=1 with your WHERE criteria. If you do not have any where criteria and do not specify WHERE 1=1, you will receive a SQL error.&lt;br /&gt;
&lt;br /&gt;
One more example (for filtering a group of courses by category)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, c.fullname as Course,c.id as CourseID&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;
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
%%FILTER_CATEGORIES:c.category%% &lt;br /&gt;
GROUP BY l.course&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to View report, now you can filter by time also.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filter Issue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
CONTRIB-4414 describes an issue where if you use the date filtering function and specify the end date as, for example: 6/11/13, Configurable Reports only searches for end dates up until 6/11/13 12:00 AM. The afternoon data for 6/11/13 is not included, so data for 6/11/13 2:30 PM will be excluded.&lt;br /&gt;
&lt;br /&gt;
The workaround to include the entire end date for the full 24 hour period is to change:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
%%FILTER_ENDTIME:table.field:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
to:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
%%FILTER_ENDTIME:table.field-86399:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== SQL variables ====&lt;br /&gt;
&lt;br /&gt;
If you place one of these strings in your SQL queries, it will be replaced by the appropriate value (current course id, current user id, Moodle www root (url), etc.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%CATEGORYID%%&lt;br /&gt;
%%COURSEID%%&lt;br /&gt;
%%CURRENTUSER%%&lt;br /&gt;
%%DEBUG%%&lt;br /&gt;
%%FILTER_VAR%%&lt;br /&gt;
%%STARTTIME%%&#039;,&#039;%%ENDTIME%%&lt;br /&gt;
%%USERID%%&lt;br /&gt;
%%WWWROOT%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#SQL_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a timeline report ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This report assumes that you have created at least one user or course report&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a course report or user report can be embedded.&lt;br /&gt;
&lt;br /&gt;
In this example we are going to create a report showing the user logins to the site during the last month (day per day).&lt;br /&gt;
&lt;br /&gt;
Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)&lt;br /&gt;
&lt;br /&gt;
Select the statistic (User logins)&lt;br /&gt;
&lt;br /&gt;
Create a Timeline report, in the Timeline tab you can select the dates or days of the report (in this case, the last 30 days) and the interval of time for every row.&lt;br /&gt;
&lt;br /&gt;
Add three &amp;quot;Other report column&amp;quot; columns, selecting all the previous user report columns.&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all, you can create a new type of plot (line graph). This graph is suitable for data depending on time.&lt;br /&gt;
&lt;br /&gt;
== Advanced options ==&lt;br /&gt;
&lt;br /&gt;
=== Export and import of reports ===&lt;br /&gt;
&lt;br /&gt;
Embedded reports exporting is not working because the reports include references to another reports. A workaround is edit the imported report for changing the references in the &amp;quot;Other report field&amp;quot; column.&lt;br /&gt;
&lt;br /&gt;
Reports that uses the user module outline column can&#039;t be exported either&lt;br /&gt;
&lt;br /&gt;
=== Use the same report in different courses ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
In order to use the same report in different courses you have to check the &amp;quot;Global report&amp;quot; option where creating a new report. This report will be then displayed in all the courses where the configurable report block is displayed and the block instance settings are set to &amp;quot;Display global reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to display global reports in a certain block instance you can always edit the instance settings for selecting &amp;quot;No&amp;quot; in the &amp;quot;Display global reports&amp;quot; block setting.&lt;br /&gt;
&lt;br /&gt;
Notice that these types of reports inherit the context of the course where is displayed, so any condition related to course inside the report is calculated using the course where the report is being viewed&lt;br /&gt;
&lt;br /&gt;
=== Reports can run on a different DB then the current (production) DB ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
This functionality is for using a copy of the same moodle database, not for queries to other database sources.&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings&lt;br /&gt;
&lt;br /&gt;
=== DataTables for the report table ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to enable this functionality&lt;br /&gt;
&lt;br /&gt;
=== CodeMirror.js for highlighting SQL query code ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to disable this functionality&lt;br /&gt;
&lt;br /&gt;
=== Using GITHUB as a repository to distribute and manage sharable SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to point to your own repository&lt;br /&gt;
&lt;br /&gt;
=== Cron SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
=== Settings to control security of SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to change the security level&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
You can customize the report output using a template.&lt;br /&gt;
&lt;br /&gt;
Just enable the Template option in the same name tab.&lt;br /&gt;
&lt;br /&gt;
This is an example html code for displaying a list of users:&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;p align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;##reportname##&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;60%&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Record:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;img src=&amp;quot;http://yourmoodle.com/user/pix.php/[[id]]/f1.jpg&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;h2&amp;gt;[[Firstname]] [[Lastname]]&amp;lt;/h2&amp;gt;&lt;br /&gt;
City: [[City]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Footer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
##graphs## &lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
##exportoptions##&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Embedded reports ===&lt;br /&gt;
&lt;br /&gt;
An embedded report consists in a report&#039;s set of columns that are embedded in another report.&lt;br /&gt;
&lt;br /&gt;
You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type of report&lt;br /&gt;
! Reports that can be embedded&lt;br /&gt;
|-&lt;br /&gt;
| Courses&lt;br /&gt;
| Users&lt;br /&gt;
|-&lt;br /&gt;
| Categories&lt;br /&gt;
| Courses&lt;br /&gt;
|-&lt;br /&gt;
| Timeline&lt;br /&gt;
| Users, courses&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.&lt;br /&gt;
&lt;br /&gt;
To embed a report just add a &amp;quot;Other report&amp;quot; column, a list of your reports will be showed.&lt;br /&gt;
&lt;br /&gt;
Inside a course report you can embed a user report and the other way.&lt;br /&gt;
&lt;br /&gt;
==== Timeline reports ====&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a courses report or users report can be embedded.&lt;br /&gt;
&lt;br /&gt;
Timeline reports should be used when your user or course report includes statistics (course stats or user stats columns). I.e: you can create a report showing the number of user logins to the site during a week or month.&lt;br /&gt;
&lt;br /&gt;
== Reports repository ==&lt;br /&gt;
&lt;br /&gt;
Configurable Reports is connected to two different repositories:&lt;br /&gt;
&lt;br /&gt;
* https://github.com/jleyva/moodle-configurable_reports_repository A repository of any type of reports (users, courses, sql, etc...)&lt;br /&gt;
* https://github.com/jleyva/moodle-custom_sql_report_queries A repository of just SQL queries to be used in the SQL repor type&lt;br /&gt;
&lt;br /&gt;
You can use your custom repository following this instructions:&lt;br /&gt;
&lt;br /&gt;
* First, you need a github account (free)&lt;br /&gt;
&lt;br /&gt;
* Fork any of the previous repositorys, using the GITHUB fork tool&lt;br /&gt;
&lt;br /&gt;
* Using GIT, clone the repository to your computer in order to add your custom reports (some GIT knowledge is needed)&lt;br /&gt;
&lt;br /&gt;
* Go to Administration / Plugins / Blocks / Configurable reports and change the settings for pointing to your repository (github account + / + repository name&lt;br /&gt;
&lt;br /&gt;
* If you want to contribute to the official repository, use the Pull request Github feature (So I can easily add your reports)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Developers documentation ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s very easy to create new report types, components and plugins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Report&#039;&#039;&#039;: A report plugin is a folder located at /report. &lt;br /&gt;
This folder contains a .class.php file with the child - class of the report_base.&lt;br /&gt;
&lt;br /&gt;
You only need to modify a few methods to add a new report type.&lt;br /&gt;
Please, take a look at any of the current reports. The SQL report is an example of a non-typical report, &lt;br /&gt;
meanwhile the users and courses reports are standard reports.&lt;br /&gt;
&lt;br /&gt;
The best way to create a report is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Component&#039;&#039;&#039;: A component is part of a report, a component may be used by more than one report.&lt;br /&gt;
The main Component is the component Columns, that is used to add the columns of a report.&lt;br /&gt;
&lt;br /&gt;
Others components are filters, permissions, plot, calculations..&lt;br /&gt;
&lt;br /&gt;
The best way to create a component is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plugin&#039;&#039;&#039;: A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc.)&lt;br /&gt;
A plugin usually works for a unique report, but there are plugins that work for more than one report.&lt;br /&gt;
The best way to create a plugin is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
== How to request a new feature ==&lt;br /&gt;
&lt;br /&gt;
* Go to the Plugin Tracker http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
* Check in the open issues if your feature have been already requested http://tracker.moodle.org/secure/IssueNavigator.jspa?reset=true&amp;amp;jqlQuery=project+%3D+CONTRIB+AND+component+%3D+%22Block%3A+Configurable+report%22+AND+status+%3D+Open+ORDER+BY+priority+DESC&amp;amp;mode=hide&lt;br /&gt;
* If not, create a New issue (Component: Non-core contributed modules Issue type: New feature) (You have to register yourself in the tracker)&lt;br /&gt;
* Select the component Block: Configurable Reports and your Moodle version&lt;br /&gt;
* Explain in the Description field your needs&lt;br /&gt;
* If you have funding, you can contact me using the forum or the moodle internal messaging system, since I work for a Moodle Partner I can work on your request.&lt;br /&gt;
* Vote and Watch the issue you have created&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
Juan Leyva [http://moodle.org/user/view.php?id=49568&amp;amp;course=1 Moodle profile]&lt;br /&gt;
&lt;br /&gt;
[http://twitter.com/jleyvadelgado Follow me in Twitter]&lt;br /&gt;
&lt;br /&gt;
== Screenshots ==&lt;br /&gt;
&lt;br /&gt;
=== Users report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_user_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SQL report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_sql_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* CONTRIB-2386&lt;br /&gt;
* [https://tracker.moodle.org/issues/?jql=project%20%3D%20CONTRIB%20AND%20component%20%3D%20%22Block%3A%20Configurable%20report%22 Block: Configurable reports] Tracker component&lt;br /&gt;
* [http://moodle.org/plugins/view.php?plugin=block_configurable_reports Modules &amp;amp; Plugins] database entry&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=159820 Help forum]&lt;br /&gt;
* [[ad-hoc_contributed_reports|contributed reports]] (in plain SQL)&lt;br /&gt;
* [https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]&lt;br /&gt;
* [https://www.youtube.com/watch?v=lF6CuY2Qiw0 Configurable Reports as a Learning Analytics Tool] - iMoot 2015 presentation by Elizabeth Dalton&lt;br /&gt;
* [http://opensourceelearning.blogspot.co.za/2015/08/moodle-configurable-reports-plugin-all.html All Variables and Filters] - Lists the Variables and Filters you can use in a report&lt;br /&gt;
&lt;br /&gt;
[[Category:Report]]&lt;br /&gt;
[[Category:Contributed_code]]&lt;br /&gt;
&lt;br /&gt;
[[es:blocks/configurable_reports/]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=136761</id>
		<title>Configurable reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=136761"/>
		<updated>2020-03-17T15:53:35Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Filter issue */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox plugin&lt;br /&gt;
|type = Block&lt;br /&gt;
|entry = https://moodle.org/plugins/view.php?plugin=block_configurable_reports&lt;br /&gt;
|tracker = http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
|discussion = https://moodle.org/mod/forum/view.php?id=7979&lt;br /&gt;
|maintainer = [[User:Juan Leyva|Juan Leyva]], [[User:Sara Arjona Téllez|Sara Arjona Téllez]]&lt;br /&gt;
|float = right&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
# Download the Configurable Reports installation file and unzip it to the &#039;&#039;&#039;\blocks&#039;&#039;&#039; directory in your Moodle folder.&lt;br /&gt;
# Be sure that the final name of the directory is: configurable_reports, the full path in your Moodle installation will be blocks/configurable_reports&lt;br /&gt;
# Login to Moodle as Administrator and click Notifications under Site Administration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information see [[Installing contributed modules or plugins]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This block is a Moodle custom reports builder. It its also connected to a [https://github.com/jleyva/moodle-configurable_reports_repository public repository of sample reports] (only plugin version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
It is designed in a modular way to allow developers to create new plugins in less than an hour.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can create custom reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Anyone with block, managereports or manageownreports permissions at SITE level or COURSE level.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What type of reports can I create?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Courses reports, with information regarding courses.&lt;br /&gt;
&lt;br /&gt;
- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.&lt;br /&gt;
&lt;br /&gt;
- Users reports, with information regarding users and their activity in a course.&lt;br /&gt;
&lt;br /&gt;
- Timeline reports, this is a special type of report that displays a timeline. A course or user report can be embedded in this timeline showing data depending on the start and end time of the current row.&lt;br /&gt;
&lt;br /&gt;
- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as [https://moodle.org/plugins/view.php?plugin=report_customsql Tim Hunt&#039;s Custom SQL queries] plugin.&lt;br /&gt;
&lt;br /&gt;
Note for developers: You can create your own type of reports.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can view the reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When you create a report you can select which users can view it.&lt;br /&gt;
&lt;br /&gt;
The reports are displayed in a block in the course or site frontpage.&lt;br /&gt;
&lt;br /&gt;
== Creating a report ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a very simple process.  &lt;br /&gt;
&lt;br /&gt;
If you are going to create a report for a course, you have to add the block in the course and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
On the other hand, for site reports, add the block in the frontpage and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
You must enter a name, an optional description, and you have to choose the type of report, pagination and exports formats.&lt;br /&gt;
&lt;br /&gt;
Depending on the report choosen, there will be more or less tabs. These are the tabs for the courses and users report:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Columns&#039;&#039;&#039;: Here you can choose the differents columns of your report depending on the type of report. (Course Name, User firstname, etc..)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Conditions&#039;&#039;&#039;: Here you can define the conditions (i.e, only courses from this category, only users from Spain, etc.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ordering&#039;&#039;&#039;: Here you can choose how to order the report using fields and directions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filters&#039;&#039;&#039;: Here you can choose which filters will be displayed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Template&#039;&#039;&#039;: You can modify the report&#039;s layout by creating a template.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Permissions&#039;&#039;&#039;: Here you can choose who can view a report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Calculations&#039;&#039;&#039;: Here you can add calculations for columns, i.e: average of number of users enrolled in courses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plots&#039;&#039;&#039;: Here you can add graphs to your report based on the report columns and values.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;View report&#039;&#039;&#039;: Self explanatory&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a users&#039; report ===&lt;br /&gt;
&lt;br /&gt;
Requirements: &#039;&#039;Users from Spain, but not from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user&#039;s city must be displayed. A pie plot showing the users&#039; cities is required. A calculation table showing the total forum post views is required. The report must be ordered by users&#039; lastname.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how easy it is!&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Enter a name, a description and choose &amp;quot;Users report&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you will be redirected to the first Tab named &amp;quot;Columns&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Columns&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here you can define the report table properties, width, align, cell padding, cell spacing, etc.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User profile field&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Choose the field &amp;quot;firstname&amp;quot; and enter a name for the column in the text field. You can leave the rest of elements blank.&lt;br /&gt;
&lt;br /&gt;
Repeat the process above for the lastname and city fields.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose a module from the list, in this example, a forum.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Adding Conditions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Conditions Tab.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, the Operator &amp;quot;=&amp;quot;, and enter the value &amp;quot;ES&amp;quot; (this is the international code for Spain as Moodle stores it).&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;city&amp;quot;, the Operator &amp;quot;&amp;lt;&amp;gt;&amp;quot;, and enter the value &amp;quot;Madrid&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;Users in current report course&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These are the main conditions of the reports. Note that at the bottom there is a text box called condition, with this text:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;c2 and c1 and c3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Here you can define a logic condition, in this case, we don&#039;t need to edit this condition but you can create complex expressions like:&lt;br /&gt;
&lt;br /&gt;
 (c1 and c2) or (c4 and c3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Ordering&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Ordering Tab.&lt;br /&gt;
&lt;br /&gt;
Add a ordering named &amp;quot;User field ordering&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Lastname&amp;quot; and the ordering &amp;quot;ASC&amp;quot; (Ascending).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Filters Tab.&lt;br /&gt;
&lt;br /&gt;
Add a filter named &amp;quot;User field filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose city.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Permissions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Permissions Tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;User field Value&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, and enter the value &amp;quot;ES&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Here you can add more permissions and a logic condition to be achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Calculations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Calculations tab.&lt;br /&gt;
&lt;br /&gt;
Choose Sum.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Plots&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Plots tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;Pie&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the colum &amp;quot;City&amp;quot; as Name and Value.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville, etc. and test the report.&lt;br /&gt;
&lt;br /&gt;
You can download the report in different formats (ods and xls), remember to check these options in the report page.&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#Users_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a SQL Report ===&lt;br /&gt;
&lt;br /&gt;
You can find a lot of SQL Reports here: [[ad-hoc contributed reports]]&lt;br /&gt;
&lt;br /&gt;
Since this block supports Tim Hunt&#039;s CustomSQL Queries Reports, you can use any query.&lt;br /&gt;
&lt;br /&gt;
Remember to add a &amp;quot;Time filter&amp;quot; if you are going to use reports with time tokens.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&lt;br /&gt;
&lt;br /&gt;
Enter a name, description, choose &amp;quot;SQL&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you redirect to the first Tab named &amp;quot;Custom SQL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add this query (&#039;&#039;Courses activity&#039;&#039;):&lt;br /&gt;
&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;
==== Adding a calculation ====&lt;br /&gt;
# Go to Calculations Tab&lt;br /&gt;
# Add a Sum calculation, choose the hits column&lt;br /&gt;
&lt;br /&gt;
==== Adding a Plot ====&lt;br /&gt;
# Go to Plot&lt;br /&gt;
# Add a Pie graph, choosing coursename as Name and hits as value&lt;br /&gt;
&lt;br /&gt;
So, here you have a report with a Graph and calculations based on a SQL Query.&lt;br /&gt;
&lt;br /&gt;
Note: Bar charts are currently not displaying on systems using PHP 7: https://github.com/jleyva/moodle-block_configurablereports/issues/101&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filters add a control to the report that allows the user to select a subset of data when the report runs.  Filters require two steps:&lt;br /&gt;
&lt;br /&gt;
# Select the filter you want to use on the &amp;quot;Filters&amp;quot; tab&lt;br /&gt;
# Add SQL code to make the filter affect the output.&lt;br /&gt;
&lt;br /&gt;
These are the filters that can be used to constrain your report:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%FILTER_CATEGORIES:&lt;br /&gt;
%%FILTER_COURSEMODULEID:&lt;br /&gt;
%%FILTER_COURSEMODULEFIELDS:&lt;br /&gt;
%%FILTER_COURSEMODULE:&lt;br /&gt;
%%FILTER_COURSES:&lt;br /&gt;
%%FILTER_COURSEENROLLEDSTUDENTS:&lt;br /&gt;
%%FILTER_USERS:&lt;br /&gt;
%%FILTER_ROLE:&lt;br /&gt;
%%FILTER_SEARCHTEXT:&lt;br /&gt;
%%FILTER_SEMESTER:&lt;br /&gt;
%%FILTER_STARTTIME:&lt;br /&gt;
%%FILTER_ENDTIME:&lt;br /&gt;
%%FILTER_SUBCATEGORIES:&lt;br /&gt;
%%FILTER_COURSEUSER:&lt;br /&gt;
%%FILTER_SYSTEMUSER:&lt;br /&gt;
%%FILTER_YEARHEBREW:&lt;br /&gt;
%%FILTER_YEARNUMERIC:&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Using Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When using a filter you need at least one static WHERE condition, followed by one or more filters. For example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
WHERE 1&lt;br /&gt;
%%FILTER_COURSES:c.id%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can technically add multiple filters, but once a user applies one filter to a report all filters for report are applied. So it can be a little tricky to have multiple filters on the same report. For example if you add a course and date filter to a report, then if you just want to filter by course you have to make sure your date filters are set to date range that covers all courses.&lt;br /&gt;
&lt;br /&gt;
Many of the filters are hard coded to be drop down menus which are sorted by database id number instead of alphabetically. This can be problematic if you have a large number of users, courses, or categories. However, you can use one search text filter per report, which can be used to work around the issue in some cases.&lt;br /&gt;
&lt;br /&gt;
Many filters require a logical operator to specify how the filter works. For example&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%FILTER_STARTTIME:l.TIME:&amp;gt;%% %%FILTER_ENDTIME:l.TIME:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a Course filter; it&#039;s very easy.&lt;br /&gt;
# Go to filters, choose Courses&lt;br /&gt;
# Edit the Custom SQL query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &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;
Note that we are adding a token called: %%FILTER_COURSES:l.courseid%% &lt;br /&gt;
&lt;br /&gt;
Go to View report, and you will see a Courses Filter, choose a Course and click on Add, here you have a report filtered.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also add a Starttime and endtime filter&lt;br /&gt;
&lt;br /&gt;
# Go to filters, choose Start / End date filter&lt;br /&gt;
# Go to Custom SQL tab, this is the new query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &lt;br /&gt;
%%FILTER_STARTTIME:l.time:&amp;gt;%% %%FILTER_ENDTIME:l.time:&amp;lt;%% &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;
&lt;br /&gt;
If you want to filter text (for example, lastname)&lt;br /&gt;
&lt;br /&gt;
# Go to filters, choose Search Text filter&lt;br /&gt;
# Go to Custom SQL tab and type your query. Here is an example for querying the user table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname&lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_SEARCHTEXT:u.lastname:~%%&lt;br /&gt;
ORDER BY u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace WHERE 1=1 with your WHERE criteria. If you do not have any where criteria and do not specify WHERE 1=1, you will receive a SQL error.&lt;br /&gt;
&lt;br /&gt;
One more example (for filtering a group of courses by category)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, c.fullname as Course,c.id as CourseID&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;
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
%%FILTER_CATEGORIES:c.category%% &lt;br /&gt;
GROUP BY l.course&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to View report, now you can filter by time also.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filter Issue&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
CONTRIB-4414 describes an issue where if you use the date filtering function and specify the end date as, for example, 6/11/13, Configurable Reports only searches for end dates up until 6/11/13 12:00 AM. The afternoon data for 6/11/13 is not included, so data for 6/11/13 2:30 PM will be excluded.&lt;br /&gt;
&lt;br /&gt;
The workaround to include the entire end date for the full 24 hour period is to change:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
%%FILTER_ENDTIME:table.field:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
to:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
%%FILTER_ENDTIME:table.field-86399:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== SQL variables ====&lt;br /&gt;
&lt;br /&gt;
If you place one of these strings in your SQL queries, it will be replaced by the appropriate value (current course id, current user id, Moodle www root (url), etc.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%CATEGORYID%%&lt;br /&gt;
%%COURSEID%%&lt;br /&gt;
%%CURRENTUSER%%&lt;br /&gt;
%%DEBUG%%&lt;br /&gt;
%%FILTER_VAR%%&lt;br /&gt;
%%STARTTIME%%&#039;,&#039;%%ENDTIME%%&lt;br /&gt;
%%USERID%%&lt;br /&gt;
%%WWWROOT%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#SQL_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a timeline report ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This report assumes that you have created at least one user or course report&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a course report or user report can be embedded.&lt;br /&gt;
&lt;br /&gt;
In this example we are going to create a report showing the user logins to the site during the last month (day per day).&lt;br /&gt;
&lt;br /&gt;
Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)&lt;br /&gt;
&lt;br /&gt;
Select the statistic (User logins)&lt;br /&gt;
&lt;br /&gt;
Create a Timeline report, in the Timeline tab you can select the dates or days of the report (in this case, the last 30 days) and the interval of time for every row.&lt;br /&gt;
&lt;br /&gt;
Add three &amp;quot;Other report column&amp;quot; columns, selecting all the previous user report columns.&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all, you can create a new type of plot (line graph). This graph is suitable for data depending on time.&lt;br /&gt;
&lt;br /&gt;
== Advanced options ==&lt;br /&gt;
&lt;br /&gt;
=== Export and import of reports ===&lt;br /&gt;
&lt;br /&gt;
Embedded reports exporting is not working because the reports include references to another reports. A workaround is edit the imported report for changing the references in the &amp;quot;Other report field&amp;quot; column.&lt;br /&gt;
&lt;br /&gt;
Reports that uses the user module outline column can&#039;t be exported either&lt;br /&gt;
&lt;br /&gt;
=== Use the same report in different courses ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
In order to use the same report in different courses you have to check the &amp;quot;Global report&amp;quot; option where creating a new report. This report will be then displayed in all the courses where the configurable report block is displayed and the block instance settings are set to &amp;quot;Display global reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to display global reports in a certain block instance you can always edit the instance settings for selecting &amp;quot;No&amp;quot; in the &amp;quot;Display global reports&amp;quot; block setting.&lt;br /&gt;
&lt;br /&gt;
Notice that these types of reports inherit the context of the course where is displayed, so any condition related to course inside the report is calculated using the course where the report is being viewed&lt;br /&gt;
&lt;br /&gt;
=== Reports can run on a different DB then the current (production) DB ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
This functionality is for using a copy of the same moodle database, not for queries to other database sources.&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings&lt;br /&gt;
&lt;br /&gt;
=== DataTables for the report table ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to enable this functionality&lt;br /&gt;
&lt;br /&gt;
=== CodeMirror.js for highlighting SQL query code ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to disable this functionality&lt;br /&gt;
&lt;br /&gt;
=== Using GITHUB as a repository to distribute and manage sharable SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to point to your own repository&lt;br /&gt;
&lt;br /&gt;
=== Cron SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
=== Settings to control security of SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to change the security level&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
You can customize the report output using a template.&lt;br /&gt;
&lt;br /&gt;
Just enable the Template option in the same name tab.&lt;br /&gt;
&lt;br /&gt;
This is an example html code for displaying a list of users:&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;p align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;##reportname##&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;60%&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Record:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;img src=&amp;quot;http://yourmoodle.com/user/pix.php/[[id]]/f1.jpg&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;h2&amp;gt;[[Firstname]] [[Lastname]]&amp;lt;/h2&amp;gt;&lt;br /&gt;
City: [[City]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Footer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
##graphs## &lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
##exportoptions##&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Embedded reports ===&lt;br /&gt;
&lt;br /&gt;
An embedded report consists in a report&#039;s set of columns that are embedded in another report.&lt;br /&gt;
&lt;br /&gt;
You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type of report&lt;br /&gt;
! Reports that can be embedded&lt;br /&gt;
|-&lt;br /&gt;
| Courses&lt;br /&gt;
| Users&lt;br /&gt;
|-&lt;br /&gt;
| Categories&lt;br /&gt;
| Courses&lt;br /&gt;
|-&lt;br /&gt;
| Timeline&lt;br /&gt;
| Users, courses&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.&lt;br /&gt;
&lt;br /&gt;
To embed a report just add a &amp;quot;Other report&amp;quot; column, a list of your reports will be showed.&lt;br /&gt;
&lt;br /&gt;
Inside a course report you can embed a user report and the other way.&lt;br /&gt;
&lt;br /&gt;
==== Timeline reports ====&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a courses report or users report can be embedded.&lt;br /&gt;
&lt;br /&gt;
Timeline reports should be used when your user or course report includes statistics (course stats or user stats columns). I.e: you can create a report showing the number of user logins to the site during a week or month.&lt;br /&gt;
&lt;br /&gt;
== Reports repository ==&lt;br /&gt;
&lt;br /&gt;
Configurable Reports is connected to two different repositories:&lt;br /&gt;
&lt;br /&gt;
* https://github.com/jleyva/moodle-configurable_reports_repository A repository of any type of reports (users, courses, sql, etc...)&lt;br /&gt;
* https://github.com/jleyva/moodle-custom_sql_report_queries A repository of just SQL queries to be used in the SQL repor type&lt;br /&gt;
&lt;br /&gt;
You can use your custom repository following this instructions:&lt;br /&gt;
&lt;br /&gt;
* First, you need a github account (free)&lt;br /&gt;
&lt;br /&gt;
* Fork any of the previous repositorys, using the GITHUB fork tool&lt;br /&gt;
&lt;br /&gt;
* Using GIT, clone the repository to your computer in order to add your custom reports (some GIT knowledge is needed)&lt;br /&gt;
&lt;br /&gt;
* Go to Administration / Plugins / Blocks / Configurable reports and change the settings for pointing to your repository (github account + / + repository name&lt;br /&gt;
&lt;br /&gt;
* If you want to contribute to the official repository, use the Pull request Github feature (So I can easily add your reports)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Developers documentation ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s very easy to create new report types, components and plugins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Report&#039;&#039;&#039;: A report plugin is a folder located at /report. &lt;br /&gt;
This folder contains a .class.php file with the child - class of the report_base.&lt;br /&gt;
&lt;br /&gt;
You only need to modify a few methods to add a new report type.&lt;br /&gt;
Please, take a look at any of the current reports. The SQL report is an example of a non-typical report, &lt;br /&gt;
meanwhile the users and courses reports are standard reports.&lt;br /&gt;
&lt;br /&gt;
The best way to create a report is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Component&#039;&#039;&#039;: A component is part of a report, a component may be used by more than one report.&lt;br /&gt;
The main Component is the component Columns, that is used to add the columns of a report.&lt;br /&gt;
&lt;br /&gt;
Others components are filters, permissions, plot, calculations..&lt;br /&gt;
&lt;br /&gt;
The best way to create a component is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plugin&#039;&#039;&#039;: A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc.)&lt;br /&gt;
A plugin usually works for a unique report, but there are plugins that work for more than one report.&lt;br /&gt;
The best way to create a plugin is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
== How to request a new feature ==&lt;br /&gt;
&lt;br /&gt;
* Go to the Plugin Tracker http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
* Check in the open issues if your feature have been already requested http://tracker.moodle.org/secure/IssueNavigator.jspa?reset=true&amp;amp;jqlQuery=project+%3D+CONTRIB+AND+component+%3D+%22Block%3A+Configurable+report%22+AND+status+%3D+Open+ORDER+BY+priority+DESC&amp;amp;mode=hide&lt;br /&gt;
* If not, create a New issue (Component: Non-core contributed modules Issue type: New feature) (You have to register yourself in the tracker)&lt;br /&gt;
* Select the component Block: Configurable Reports and your Moodle version&lt;br /&gt;
* Explain in the Description field your needs&lt;br /&gt;
* If you have funding, you can contact me using the forum or the moodle internal messaging system, since I work for a Moodle Partner I can work on your request.&lt;br /&gt;
* Vote and Watch the issue you have created&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
Juan Leyva [http://moodle.org/user/view.php?id=49568&amp;amp;course=1 Moodle profile]&lt;br /&gt;
&lt;br /&gt;
[http://twitter.com/jleyvadelgado Follow me in Twitter]&lt;br /&gt;
&lt;br /&gt;
== Screenshots ==&lt;br /&gt;
&lt;br /&gt;
=== Users report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_user_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SQL report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_sql_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* CONTRIB-2386&lt;br /&gt;
* [https://tracker.moodle.org/issues/?jql=project%20%3D%20CONTRIB%20AND%20component%20%3D%20%22Block%3A%20Configurable%20report%22 Block: Configurable reports] Tracker component&lt;br /&gt;
* [http://moodle.org/plugins/view.php?plugin=block_configurable_reports Modules &amp;amp; Plugins] database entry&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=159820 Help forum]&lt;br /&gt;
* [[ad-hoc_contributed_reports|contributed reports]] (in plain SQL)&lt;br /&gt;
* [https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]&lt;br /&gt;
* [https://www.youtube.com/watch?v=lF6CuY2Qiw0 Configurable Reports as a Learning Analytics Tool] - iMoot 2015 presentation by Elizabeth Dalton&lt;br /&gt;
* [http://opensourceelearning.blogspot.co.za/2015/08/moodle-configurable-reports-plugin-all.html All Variables and Filters] - Lists the Variables and Filters you can use in a report&lt;br /&gt;
&lt;br /&gt;
[[Category:Report]]&lt;br /&gt;
[[Category:Contributed_code]]&lt;br /&gt;
&lt;br /&gt;
[[es:blocks/configurable_reports/]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Configurable_reports&amp;diff=136760</id>
		<title>Talk:Configurable reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Configurable_reports&amp;diff=136760"/>
		<updated>2020-03-17T15:34:48Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Templates - variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Templates ===&lt;br /&gt;
The Templates section lists several &amp;quot;variables&amp;quot; such as:&lt;br /&gt;
* ##exportoptions##&lt;br /&gt;
* ##reportname##&lt;br /&gt;
* ##graphs##&lt;br /&gt;
&lt;br /&gt;
Please document what these are. How can they be used in reports?&lt;br /&gt;
&lt;br /&gt;
Please include a definitive list of these items.&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Configurable_reports&amp;diff=136759</id>
		<title>Talk:Configurable reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Configurable_reports&amp;diff=136759"/>
		<updated>2020-03-17T15:34:27Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Templates - variables */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== Templates ===&lt;br /&gt;
The Templates section lists several &amp;quot;variables&amp;quot; such as &lt;br /&gt;
* ##exportoptions##&lt;br /&gt;
* ##reportname##&lt;br /&gt;
* ##graphs##&lt;br /&gt;
&lt;br /&gt;
Please document what these are. How can they be used in reports?&lt;br /&gt;
&lt;br /&gt;
Please include a definitive list of these items.&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136752</id>
		<title>Course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136752"/>
		<updated>2020-03-12T12:45:51Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Example : clarify courseid param */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Backup}}&lt;br /&gt;
A course can be saved with some or all of its parts by using the course backup.  Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site.  A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.  &lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/eNe6kRv2ndI| desc = Course backup: Moodle 3.7}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Backing up a course==&lt;br /&gt;
&lt;br /&gt;
To backup a course&lt;br /&gt;
&lt;br /&gt;
# Go into the course.&lt;br /&gt;
# Click the Backup link either in the gear menu or the Administration block (depending upon the theme).&lt;br /&gt;
# Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.&lt;br /&gt;
# Schema settings  - Select/deselect specific items to include in backup, then click the Next button.&lt;br /&gt;
# If desired, select specific types of activity to be backed up by clicking the link &#039;Show type options&#039; &lt;br /&gt;
# Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the &#039;Perform backup&#039; button&lt;br /&gt;
# Complete - Click the Continue button&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
[[File:backupgroups.png|thumb|Backup settings]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore2.png|thumb|Back up screen with option to select activity types]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form &#039;&#039;backup-moodle2-course-coursename-date-hour.mbz&#039;&#039;, ending in &#039;&#039;-nu.mbz&#039;&#039; when backed up with no users and &#039;&#039;-an.mbz&#039;&#039;  with anonymized names.&lt;br /&gt;
&lt;br /&gt;
Tip: If you are satisfied with the default settings and don&#039;t wish to go through all the backup screens, you can simply click &#039;Jump to final step&#039; to perform the backup.&lt;br /&gt;
&lt;br /&gt;
==Anonymizing user information==&lt;br /&gt;
&lt;br /&gt;
Anonymize user information is a backup feature which &amp;quot;protects user identities&amp;quot; by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example  &amp;quot;Max Manager&amp;quot; might become  &amp;quot;anonfirstname4 anonlastname4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Asynchronous course backups==&lt;br /&gt;
&lt;br /&gt;
With large courses it is helpful to be able to continue working while the course is backing up in the background. This can be done if the administrator checks the box &#039;Enable asynchronous backups&#039; from &#039;&#039;Site Administration / Advanced features&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Backup via CLI for administrators==&lt;br /&gt;
&lt;br /&gt;
Site administrators can backup selected courses using a CLI script.&lt;br /&gt;
&lt;br /&gt;
===Options===&lt;br /&gt;
* --courseid=INTEGER (Course ID for backup.)&lt;br /&gt;
* --courseshortname=STRING (Course shortname for backup.)&lt;br /&gt;
* --destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)&lt;br /&gt;
* -h, --help (Print out this help.)&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server. From the command line CD to the Moodle &#039;&#039;\admin\cli&#039;&#039; folder and run this command:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
php backup.php --courseid=25 --destination=\\moodledata\backup&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &#039;--courseid&#039; is the id of the course that you want to backup.&lt;br /&gt;
&lt;br /&gt;
The .mbz backup file for courseid=25 will be stored in the &#039;&#039;backup&#039;&#039; subfolder in the &#039;&#039;Moodledata&#039;&#039; ($CFG-&amp;gt;dataroot) folder.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
* Lose content after a restore in Moodle 2.0 ?  Do you see topic headings that say &amp;quot;Orphaned activities&amp;quot;?   Solution: Go to course settings and increase the number of topic sections and things will return to normal.&lt;br /&gt;
&lt;br /&gt;
==Creative uses==&lt;br /&gt;
The backup and restore processes can offer the teacher and administrators many creative solutions.&lt;br /&gt;
*Duplicating courses or specific activities in one course to another course (similar to Import)&lt;br /&gt;
*Updating a production Moodle site course, with material from a localhost site course&lt;br /&gt;
*Transferring a course to a new Moodle site.&lt;br /&gt;
*In earlier versions of Moodle, a way of rolling a course forward without past student activity&lt;br /&gt;
*Creating a blank activity, save just that activity and then restore it to the course or another course one or more times. &lt;br /&gt;
&lt;br /&gt;
==General backup defaults==&lt;br /&gt;
&lt;br /&gt;
Default settings for course backups can be set by a site administrator in &#039;General backup defaults&#039; in the Site administration.&lt;br /&gt;
&lt;br /&gt;
Selected settings may be locked, so that they cannot be changed when creating a course backup.&lt;br /&gt;
&lt;br /&gt;
By selecting a time in the &amp;quot;Keep logs for..&amp;quot;  dropdown, it is possible to specify how long backup  logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.&lt;br /&gt;
&lt;br /&gt;
==Course backup stops above 90%, not showing any errors==&lt;br /&gt;
This has been reported to be caused by:&lt;br /&gt;
* a [[Course_formats#Contributed_Course_Formats|non-standard course_format]]. Try replacing the course format.&lt;br /&gt;
* not enough server RAM. Adding more RAM to your server is usually the first [[Performance_recommendations|performance recomendation]].&lt;br /&gt;
&lt;br /&gt;
==Course backup capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/backup:anonymise|Anonymise user data on backup]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupsection|Backup sections]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]&lt;br /&gt;
*[[Capabilities/moodle/backup:configure|Configure backup options]]&lt;br /&gt;
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]&lt;br /&gt;
*[[Capabilities/moodle/backup:userinfo|Backup user data]]&lt;br /&gt;
&lt;br /&gt;
==Error: Trying to restore user &#039;admin&#039; from backup file will cause conflict ==&lt;br /&gt;
* Before proceeding, it would be advisable to have a second admin account &#039;&#039;just in case something goes wrong&#039;&#039;.&lt;br /&gt;
* Check that the admin accounts on each server have &#039;&#039;&#039;different&#039;&#039;&#039; unique usernames and email addresses and then try again to backup up the course with user data and restore it. &lt;br /&gt;
** If you can not make a new backup and you must use an existing &#039;conflicting&#039; backup file, you will have to change the new site&#039;s main admin account with extreme care to remember the new main admin&#039;s password and email.&lt;br /&gt;
* Note that the admin account from the imported file may loose the password and become unusable; &lt;br /&gt;
* You are advised to update/reset the &#039;imported&#039; main &#039;admin&#039;s account&#039;s password before logging out, as this will most likely be the main &#039;admin&#039; account for the site, and you would get into serious problems if this account stops working.&lt;br /&gt;
* If something goes terribly wrong, you can use the second admin account to fix the main admin account. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Course restore]]&lt;br /&gt;
*[[Backup of user data]]&lt;br /&gt;
*[[Activity backup]]&lt;br /&gt;
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI&lt;br /&gt;
&lt;br /&gt;
[[Category:Course]]&lt;br /&gt;
&lt;br /&gt;
[[de:Kurssicherung]]&lt;br /&gt;
[[es:Respaldo del curso]]&lt;br /&gt;
[[eu:Ikastaroaren_Segurtasun-kopia]]&lt;br /&gt;
[[fr:Sauvegarde de cours]]&lt;br /&gt;
[[ja:コースバックアップ]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136751</id>
		<title>Course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136751"/>
		<updated>2020-03-12T12:32:49Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Example : typo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Backup}}&lt;br /&gt;
A course can be saved with some or all of its parts by using the course backup.  Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site.  A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.  &lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/eNe6kRv2ndI| desc = Course backup: Moodle 3.7}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Backing up a course==&lt;br /&gt;
&lt;br /&gt;
To backup a course&lt;br /&gt;
&lt;br /&gt;
# Go into the course.&lt;br /&gt;
# Click the Backup link either in the gear menu or the Administration block (depending upon the theme).&lt;br /&gt;
# Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.&lt;br /&gt;
# Schema settings  - Select/deselect specific items to include in backup, then click the Next button.&lt;br /&gt;
# If desired, select specific types of activity to be backed up by clicking the link &#039;Show type options&#039; &lt;br /&gt;
# Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the &#039;Perform backup&#039; button&lt;br /&gt;
# Complete - Click the Continue button&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
[[File:backupgroups.png|thumb|Backup settings]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore2.png|thumb|Back up screen with option to select activity types]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form &#039;&#039;backup-moodle2-course-coursename-date-hour.mbz&#039;&#039;, ending in &#039;&#039;-nu.mbz&#039;&#039; when backed up with no users and &#039;&#039;-an.mbz&#039;&#039;  with anonymized names.&lt;br /&gt;
&lt;br /&gt;
Tip: If you are satisfied with the default settings and don&#039;t wish to go through all the backup screens, you can simply click &#039;Jump to final step&#039; to perform the backup.&lt;br /&gt;
&lt;br /&gt;
==Anonymizing user information==&lt;br /&gt;
&lt;br /&gt;
Anonymize user information is a backup feature which &amp;quot;protects user identities&amp;quot; by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example  &amp;quot;Max Manager&amp;quot; might become  &amp;quot;anonfirstname4 anonlastname4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Asynchronous course backups==&lt;br /&gt;
&lt;br /&gt;
With large courses it is helpful to be able to continue working while the course is backing up in the background. This can be done if the administrator checks the box &#039;Enable asynchronous backups&#039; from &#039;&#039;Site Administration / Advanced features&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Backup via CLI for administrators==&lt;br /&gt;
&lt;br /&gt;
Site administrators can backup selected courses using a CLI script.&lt;br /&gt;
&lt;br /&gt;
===Options===&lt;br /&gt;
* --courseid=INTEGER (Course ID for backup.)&lt;br /&gt;
* --courseshortname=STRING (Course shortname for backup.)&lt;br /&gt;
* --destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)&lt;br /&gt;
* -h, --help (Print out this help.)&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server. From the command line CD to the Moodle &#039;&#039;\admin\cli&#039;&#039; folder and run this command:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
php backup.php --courseid=25 --destination=\\moodledata\backup&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The .mbz backup file for courseid=25 will be stored in the &#039;&#039;backup&#039;&#039; subfolder in the &#039;&#039;Moodledata&#039;&#039; ($CFG-&amp;gt;dataroot) folder.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
* Lose content after a restore in Moodle 2.0 ?  Do you see topic headings that say &amp;quot;Orphaned activities&amp;quot;?   Solution: Go to course settings and increase the number of topic sections and things will return to normal.&lt;br /&gt;
&lt;br /&gt;
==Creative uses==&lt;br /&gt;
The backup and restore processes can offer the teacher and administrators many creative solutions.&lt;br /&gt;
*Duplicating courses or specific activities in one course to another course (similar to Import)&lt;br /&gt;
*Updating a production Moodle site course, with material from a localhost site course&lt;br /&gt;
*Transferring a course to a new Moodle site.&lt;br /&gt;
*In earlier versions of Moodle, a way of rolling a course forward without past student activity&lt;br /&gt;
*Creating a blank activity, save just that activity and then restore it to the course or another course one or more times. &lt;br /&gt;
&lt;br /&gt;
==General backup defaults==&lt;br /&gt;
&lt;br /&gt;
Default settings for course backups can be set by a site administrator in &#039;General backup defaults&#039; in the Site administration.&lt;br /&gt;
&lt;br /&gt;
Selected settings may be locked, so that they cannot be changed when creating a course backup.&lt;br /&gt;
&lt;br /&gt;
By selecting a time in the &amp;quot;Keep logs for..&amp;quot;  dropdown, it is possible to specify how long backup  logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.&lt;br /&gt;
&lt;br /&gt;
==Course backup stops above 90%, not showing any errors==&lt;br /&gt;
This has been reported to be caused by:&lt;br /&gt;
* a [[Course_formats#Contributed_Course_Formats|non-standard course_format]]. Try replacing the course format.&lt;br /&gt;
* not enough server RAM. Adding more RAM to your server is usually the first [[Performance_recommendations|performance recomendation]].&lt;br /&gt;
&lt;br /&gt;
==Course backup capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/backup:anonymise|Anonymise user data on backup]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupsection|Backup sections]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]&lt;br /&gt;
*[[Capabilities/moodle/backup:configure|Configure backup options]]&lt;br /&gt;
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]&lt;br /&gt;
*[[Capabilities/moodle/backup:userinfo|Backup user data]]&lt;br /&gt;
&lt;br /&gt;
==Error: Trying to restore user &#039;admin&#039; from backup file will cause conflict ==&lt;br /&gt;
* Before proceeding, it would be advisable to have a second admin account &#039;&#039;just in case something goes wrong&#039;&#039;.&lt;br /&gt;
* Check that the admin accounts on each server have &#039;&#039;&#039;different&#039;&#039;&#039; unique usernames and email addresses and then try again to backup up the course with user data and restore it. &lt;br /&gt;
** If you can not make a new backup and you must use an existing &#039;conflicting&#039; backup file, you will have to change the new site&#039;s main admin account with extreme care to remember the new main admin&#039;s password and email.&lt;br /&gt;
* Note that the admin account from the imported file may loose the password and become unusable; &lt;br /&gt;
* You are advised to update/reset the &#039;imported&#039; main &#039;admin&#039;s account&#039;s password before logging out, as this will most likely be the main &#039;admin&#039; account for the site, and you would get into serious problems if this account stops working.&lt;br /&gt;
* If something goes terribly wrong, you can use the second admin account to fix the main admin account. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Course restore]]&lt;br /&gt;
*[[Backup of user data]]&lt;br /&gt;
*[[Activity backup]]&lt;br /&gt;
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI&lt;br /&gt;
&lt;br /&gt;
[[Category:Course]]&lt;br /&gt;
&lt;br /&gt;
[[de:Kurssicherung]]&lt;br /&gt;
[[es:Respaldo del curso]]&lt;br /&gt;
[[eu:Ikastaroaren_Segurtasun-kopia]]&lt;br /&gt;
[[fr:Sauvegarde de cours]]&lt;br /&gt;
[[ja:コースバックアップ]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136750</id>
		<title>Course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136750"/>
		<updated>2020-03-12T11:40:37Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Example - typo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Backup}}&lt;br /&gt;
A course can be saved with some or all of its parts by using the course backup.  Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site.  A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.  &lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/eNe6kRv2ndI| desc = Course backup: Moodle 3.7}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Backing up a course==&lt;br /&gt;
&lt;br /&gt;
To backup a course&lt;br /&gt;
&lt;br /&gt;
# Go into the course.&lt;br /&gt;
# Click the Backup link either in the gear menu or the Administration block (depending upon the theme).&lt;br /&gt;
# Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.&lt;br /&gt;
# Schema settings  - Select/deselect specific items to include in backup, then click the Next button.&lt;br /&gt;
# If desired, select specific types of activity to be backed up by clicking the link &#039;Show type options&#039; &lt;br /&gt;
# Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the &#039;Perform backup&#039; button&lt;br /&gt;
# Complete - Click the Continue button&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
[[File:backupgroups.png|thumb|Backup settings]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore2.png|thumb|Back up screen with option to select activity types]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form &#039;&#039;backup-moodle2-course-coursename-date-hour.mbz&#039;&#039;, ending in &#039;&#039;-nu.mbz&#039;&#039; when backed up with no users and &#039;&#039;-an.mbz&#039;&#039;  with anonymized names.&lt;br /&gt;
&lt;br /&gt;
Tip: If you are satisfied with the default settings and don&#039;t wish to go through all the backup screens, you can simply click &#039;Jump to final step&#039; to perform the backup.&lt;br /&gt;
&lt;br /&gt;
==Anonymizing user information==&lt;br /&gt;
&lt;br /&gt;
Anonymize user information is a backup feature which &amp;quot;protects user identities&amp;quot; by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example  &amp;quot;Max Manager&amp;quot; might become  &amp;quot;anonfirstname4 anonlastname4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Asynchronous course backups==&lt;br /&gt;
&lt;br /&gt;
With large courses it is helpful to be able to continue working while the course is backing up in the background. This can be done if the administrator checks the box &#039;Enable asynchronous backups&#039; from &#039;&#039;Site Administration / Advanced features&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Backup via CLI for administrators==&lt;br /&gt;
&lt;br /&gt;
Site administrators can backup selected courses using a CLI script.&lt;br /&gt;
&lt;br /&gt;
===Options===&lt;br /&gt;
* --courseid=INTEGER (Course ID for backup.)&lt;br /&gt;
* --courseshortname=STRING (Course shortname for backup.)&lt;br /&gt;
* --destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)&lt;br /&gt;
* -h, --help (Print out this help.)&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server. CD to the Moodle &#039;&#039;\admin\cli&#039;&#039; folder and run this command:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
php backup.php --courseid=25 --destination=\\moodledata\backup&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The .mbz backup file for courseid=25 will be stored in the &#039;&#039;backup&#039;&#039; subfolder in the &#039;&#039;Moodledata&#039;&#039; ($CFG-&amp;gt;dataroot) folder.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
* Lose content after a restore in Moodle 2.0 ?  Do you see topic headings that say &amp;quot;Orphaned activities&amp;quot;?   Solution: Go to course settings and increase the number of topic sections and things will return to normal.&lt;br /&gt;
&lt;br /&gt;
==Creative uses==&lt;br /&gt;
The backup and restore processes can offer the teacher and administrators many creative solutions.&lt;br /&gt;
*Duplicating courses or specific activities in one course to another course (similar to Import)&lt;br /&gt;
*Updating a production Moodle site course, with material from a localhost site course&lt;br /&gt;
*Transferring a course to a new Moodle site.&lt;br /&gt;
*In earlier versions of Moodle, a way of rolling a course forward without past student activity&lt;br /&gt;
*Creating a blank activity, save just that activity and then restore it to the course or another course one or more times. &lt;br /&gt;
&lt;br /&gt;
==General backup defaults==&lt;br /&gt;
&lt;br /&gt;
Default settings for course backups can be set by a site administrator in &#039;General backup defaults&#039; in the Site administration.&lt;br /&gt;
&lt;br /&gt;
Selected settings may be locked, so that they cannot be changed when creating a course backup.&lt;br /&gt;
&lt;br /&gt;
By selecting a time in the &amp;quot;Keep logs for..&amp;quot;  dropdown, it is possible to specify how long backup  logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.&lt;br /&gt;
&lt;br /&gt;
==Course backup stops above 90%, not showing any errors==&lt;br /&gt;
This has been reported to be caused by:&lt;br /&gt;
* a [[Course_formats#Contributed_Course_Formats|non-standard course_format]]. Try replacing the course format.&lt;br /&gt;
* not enough server RAM. Adding more RAM to your server is usually the first [[Performance_recommendations|performance recomendation]].&lt;br /&gt;
&lt;br /&gt;
==Course backup capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/backup:anonymise|Anonymise user data on backup]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupsection|Backup sections]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]&lt;br /&gt;
*[[Capabilities/moodle/backup:configure|Configure backup options]]&lt;br /&gt;
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]&lt;br /&gt;
*[[Capabilities/moodle/backup:userinfo|Backup user data]]&lt;br /&gt;
&lt;br /&gt;
==Error: Trying to restore user &#039;admin&#039; from backup file will cause conflict ==&lt;br /&gt;
* Before proceeding, it would be advisable to have a second admin account &#039;&#039;just in case something goes wrong&#039;&#039;.&lt;br /&gt;
* Check that the admin accounts on each server have &#039;&#039;&#039;different&#039;&#039;&#039; unique usernames and email addresses and then try again to backup up the course with user data and restore it. &lt;br /&gt;
** If you can not make a new backup and you must use an existing &#039;conflicting&#039; backup file, you will have to change the new site&#039;s main admin account with extreme care to remember the new main admin&#039;s password and email.&lt;br /&gt;
* Note that the admin account from the imported file may loose the password and become unusable; &lt;br /&gt;
* You are advised to update/reset the &#039;imported&#039; main &#039;admin&#039;s account&#039;s password before logging out, as this will most likely be the main &#039;admin&#039; account for the site, and you would get into serious problems if this account stops working.&lt;br /&gt;
* If something goes terribly wrong, you can use the second admin account to fix the main admin account. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Course restore]]&lt;br /&gt;
*[[Backup of user data]]&lt;br /&gt;
*[[Activity backup]]&lt;br /&gt;
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI&lt;br /&gt;
&lt;br /&gt;
[[Category:Course]]&lt;br /&gt;
&lt;br /&gt;
[[de:Kurssicherung]]&lt;br /&gt;
[[es:Respaldo del curso]]&lt;br /&gt;
[[eu:Ikastaroaren_Segurtasun-kopia]]&lt;br /&gt;
[[fr:Sauvegarde de cours]]&lt;br /&gt;
[[ja:コースバックアップ]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136749</id>
		<title>Course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136749"/>
		<updated>2020-03-12T11:38:30Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Example pth fix*/&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Backup}}&lt;br /&gt;
A course can be saved with some or all of its parts by using the course backup.  Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site.  A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.  &lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/eNe6kRv2ndI| desc = Course backup: Moodle 3.7}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Backing up a course==&lt;br /&gt;
&lt;br /&gt;
To backup a course&lt;br /&gt;
&lt;br /&gt;
# Go into the course.&lt;br /&gt;
# Click the Backup link either in the gear menu or the Administration block (depending upon the theme).&lt;br /&gt;
# Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.&lt;br /&gt;
# Schema settings  - Select/deselect specific items to include in backup, then click the Next button.&lt;br /&gt;
# If desired, select specific types of activity to be backed up by clicking the link &#039;Show type options&#039; &lt;br /&gt;
# Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the &#039;Perform backup&#039; button&lt;br /&gt;
# Complete - Click the Continue button&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
[[File:backupgroups.png|thumb|Backup settings]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore2.png|thumb|Back up screen with option to select activity types]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form &#039;&#039;backup-moodle2-course-coursename-date-hour.mbz&#039;&#039;, ending in &#039;&#039;-nu.mbz&#039;&#039; when backed up with no users and &#039;&#039;-an.mbz&#039;&#039;  with anonymized names.&lt;br /&gt;
&lt;br /&gt;
Tip: If you are satisfied with the default settings and don&#039;t wish to go through all the backup screens, you can simply click &#039;Jump to final step&#039; to perform the backup.&lt;br /&gt;
&lt;br /&gt;
==Anonymizing user information==&lt;br /&gt;
&lt;br /&gt;
Anonymize user information is a backup feature which &amp;quot;protects user identities&amp;quot; by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example  &amp;quot;Max Manager&amp;quot; might become  &amp;quot;anonfirstname4 anonlastname4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Asynchronous course backups==&lt;br /&gt;
&lt;br /&gt;
With large courses it is helpful to be able to continue working while the course is backing up in the background. This can be done if the administrator checks the box &#039;Enable asynchronous backups&#039; from &#039;&#039;Site Administration / Advanced features&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Backup via CLI for administrators==&lt;br /&gt;
&lt;br /&gt;
Site administrators can backup selected courses using a CLI script.&lt;br /&gt;
&lt;br /&gt;
===Options===&lt;br /&gt;
* --courseid=INTEGER (Course ID for backup.)&lt;br /&gt;
* --courseshortname=STRING (Course shortname for backup.)&lt;br /&gt;
* --destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)&lt;br /&gt;
* -h, --help (Print out this help.)&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server:&lt;br /&gt;
&lt;br /&gt;
CD to the Moodle &#039;&#039;\admin\cli&#039;&#039; folder and run this command:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
php backup.php --courseid=25 --destination=\\moodledata\backup&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The .mbz backup file for courseid=25 will be stored in the &#039;&#039;backup&#039;&#039; subfolder in the &#039;&#039;Moodledata&#039;&#039; ($CFG-&amp;gt;dataroot) folder.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
* Lose content after a restore in Moodle 2.0 ?  Do you see topic headings that say &amp;quot;Orphaned activities&amp;quot;?   Solution: Go to course settings and increase the number of topic sections and things will return to normal.&lt;br /&gt;
&lt;br /&gt;
==Creative uses==&lt;br /&gt;
The backup and restore processes can offer the teacher and administrators many creative solutions.&lt;br /&gt;
*Duplicating courses or specific activities in one course to another course (similar to Import)&lt;br /&gt;
*Updating a production Moodle site course, with material from a localhost site course&lt;br /&gt;
*Transferring a course to a new Moodle site.&lt;br /&gt;
*In earlier versions of Moodle, a way of rolling a course forward without past student activity&lt;br /&gt;
*Creating a blank activity, save just that activity and then restore it to the course or another course one or more times. &lt;br /&gt;
&lt;br /&gt;
==General backup defaults==&lt;br /&gt;
&lt;br /&gt;
Default settings for course backups can be set by a site administrator in &#039;General backup defaults&#039; in the Site administration.&lt;br /&gt;
&lt;br /&gt;
Selected settings may be locked, so that they cannot be changed when creating a course backup.&lt;br /&gt;
&lt;br /&gt;
By selecting a time in the &amp;quot;Keep logs for..&amp;quot;  dropdown, it is possible to specify how long backup  logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.&lt;br /&gt;
&lt;br /&gt;
==Course backup stops above 90%, not showing any errors==&lt;br /&gt;
This has been reported to be caused by:&lt;br /&gt;
* a [[Course_formats#Contributed_Course_Formats|non-standard course_format]]. Try replacing the course format.&lt;br /&gt;
* not enough server RAM. Adding more RAM to your server is usually the first [[Performance_recommendations|performance recomendation]].&lt;br /&gt;
&lt;br /&gt;
==Course backup capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/backup:anonymise|Anonymise user data on backup]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupsection|Backup sections]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]&lt;br /&gt;
*[[Capabilities/moodle/backup:configure|Configure backup options]]&lt;br /&gt;
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]&lt;br /&gt;
*[[Capabilities/moodle/backup:userinfo|Backup user data]]&lt;br /&gt;
&lt;br /&gt;
==Error: Trying to restore user &#039;admin&#039; from backup file will cause conflict ==&lt;br /&gt;
* Before proceeding, it would be advisable to have a second admin account &#039;&#039;just in case something goes wrong&#039;&#039;.&lt;br /&gt;
* Check that the admin accounts on each server have &#039;&#039;&#039;different&#039;&#039;&#039; unique usernames and email addresses and then try again to backup up the course with user data and restore it. &lt;br /&gt;
** If you can not make a new backup and you must use an existing &#039;conflicting&#039; backup file, you will have to change the new site&#039;s main admin account with extreme care to remember the new main admin&#039;s password and email.&lt;br /&gt;
* Note that the admin account from the imported file may loose the password and become unusable; &lt;br /&gt;
* You are advised to update/reset the &#039;imported&#039; main &#039;admin&#039;s account&#039;s password before logging out, as this will most likely be the main &#039;admin&#039; account for the site, and you would get into serious problems if this account stops working.&lt;br /&gt;
* If something goes terribly wrong, you can use the second admin account to fix the main admin account. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Course restore]]&lt;br /&gt;
*[[Backup of user data]]&lt;br /&gt;
*[[Activity backup]]&lt;br /&gt;
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI&lt;br /&gt;
&lt;br /&gt;
[[Category:Course]]&lt;br /&gt;
&lt;br /&gt;
[[de:Kurssicherung]]&lt;br /&gt;
[[es:Respaldo del curso]]&lt;br /&gt;
[[eu:Ikastaroaren_Segurtasun-kopia]]&lt;br /&gt;
[[fr:Sauvegarde de cours]]&lt;br /&gt;
[[ja:コースバックアップ]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136748</id>
		<title>Course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136748"/>
		<updated>2020-03-12T11:34:42Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Example formatting code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Backup}}&lt;br /&gt;
A course can be saved with some or all of its parts by using the course backup.  Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site.  A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.  &lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/eNe6kRv2ndI| desc = Course backup: Moodle 3.7}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Backing up a course==&lt;br /&gt;
&lt;br /&gt;
To backup a course&lt;br /&gt;
&lt;br /&gt;
# Go into the course.&lt;br /&gt;
# Click the Backup link either in the gear menu or the Administration block (depending upon the theme).&lt;br /&gt;
# Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.&lt;br /&gt;
# Schema settings  - Select/deselect specific items to include in backup, then click the Next button.&lt;br /&gt;
# If desired, select specific types of activity to be backed up by clicking the link &#039;Show type options&#039; &lt;br /&gt;
# Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the &#039;Perform backup&#039; button&lt;br /&gt;
# Complete - Click the Continue button&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
[[File:backupgroups.png|thumb|Backup settings]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore2.png|thumb|Back up screen with option to select activity types]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form &#039;&#039;backup-moodle2-course-coursename-date-hour.mbz&#039;&#039;, ending in &#039;&#039;-nu.mbz&#039;&#039; when backed up with no users and &#039;&#039;-an.mbz&#039;&#039;  with anonymized names.&lt;br /&gt;
&lt;br /&gt;
Tip: If you are satisfied with the default settings and don&#039;t wish to go through all the backup screens, you can simply click &#039;Jump to final step&#039; to perform the backup.&lt;br /&gt;
&lt;br /&gt;
==Anonymizing user information==&lt;br /&gt;
&lt;br /&gt;
Anonymize user information is a backup feature which &amp;quot;protects user identities&amp;quot; by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example  &amp;quot;Max Manager&amp;quot; might become  &amp;quot;anonfirstname4 anonlastname4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Asynchronous course backups==&lt;br /&gt;
&lt;br /&gt;
With large courses it is helpful to be able to continue working while the course is backing up in the background. This can be done if the administrator checks the box &#039;Enable asynchronous backups&#039; from &#039;&#039;Site Administration / Advanced features&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Backup via CLI for administrators==&lt;br /&gt;
&lt;br /&gt;
Site administrators can backup selected courses using a CLI script.&lt;br /&gt;
&lt;br /&gt;
===Options===&lt;br /&gt;
* --courseid=INTEGER (Course ID for backup.)&lt;br /&gt;
* --courseshortname=STRING (Course shortname for backup.)&lt;br /&gt;
* --destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)&lt;br /&gt;
* -h, --help (Print out this help.)&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server:&lt;br /&gt;
&lt;br /&gt;
CD to the Moodle &#039;&#039;\admin\cli&#039;&#039; folder and run this command:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
php backup.php --courseid=25 --destination=\\moodledata\backup&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The .mbz backup file for courseid=25 will be stored in the &#039;&#039;backup&#039;&#039; subfolder in the &#039;&#039;Moodledata&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
* Lose content after a restore in Moodle 2.0 ?  Do you see topic headings that say &amp;quot;Orphaned activities&amp;quot;?   Solution: Go to course settings and increase the number of topic sections and things will return to normal.&lt;br /&gt;
&lt;br /&gt;
==Creative uses==&lt;br /&gt;
The backup and restore processes can offer the teacher and administrators many creative solutions.&lt;br /&gt;
*Duplicating courses or specific activities in one course to another course (similar to Import)&lt;br /&gt;
*Updating a production Moodle site course, with material from a localhost site course&lt;br /&gt;
*Transferring a course to a new Moodle site.&lt;br /&gt;
*In earlier versions of Moodle, a way of rolling a course forward without past student activity&lt;br /&gt;
*Creating a blank activity, save just that activity and then restore it to the course or another course one or more times. &lt;br /&gt;
&lt;br /&gt;
==General backup defaults==&lt;br /&gt;
&lt;br /&gt;
Default settings for course backups can be set by a site administrator in &#039;General backup defaults&#039; in the Site administration.&lt;br /&gt;
&lt;br /&gt;
Selected settings may be locked, so that they cannot be changed when creating a course backup.&lt;br /&gt;
&lt;br /&gt;
By selecting a time in the &amp;quot;Keep logs for..&amp;quot;  dropdown, it is possible to specify how long backup  logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.&lt;br /&gt;
&lt;br /&gt;
==Course backup stops above 90%, not showing any errors==&lt;br /&gt;
This has been reported to be caused by:&lt;br /&gt;
* a [[Course_formats#Contributed_Course_Formats|non-standard course_format]]. Try replacing the course format.&lt;br /&gt;
* not enough server RAM. Adding more RAM to your server is usually the first [[Performance_recommendations|performance recomendation]].&lt;br /&gt;
&lt;br /&gt;
==Course backup capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/backup:anonymise|Anonymise user data on backup]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupsection|Backup sections]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]&lt;br /&gt;
*[[Capabilities/moodle/backup:configure|Configure backup options]]&lt;br /&gt;
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]&lt;br /&gt;
*[[Capabilities/moodle/backup:userinfo|Backup user data]]&lt;br /&gt;
&lt;br /&gt;
==Error: Trying to restore user &#039;admin&#039; from backup file will cause conflict ==&lt;br /&gt;
* Before proceeding, it would be advisable to have a second admin account &#039;&#039;just in case something goes wrong&#039;&#039;.&lt;br /&gt;
* Check that the admin accounts on each server have &#039;&#039;&#039;different&#039;&#039;&#039; unique usernames and email addresses and then try again to backup up the course with user data and restore it. &lt;br /&gt;
** If you can not make a new backup and you must use an existing &#039;conflicting&#039; backup file, you will have to change the new site&#039;s main admin account with extreme care to remember the new main admin&#039;s password and email.&lt;br /&gt;
* Note that the admin account from the imported file may loose the password and become unusable; &lt;br /&gt;
* You are advised to update/reset the &#039;imported&#039; main &#039;admin&#039;s account&#039;s password before logging out, as this will most likely be the main &#039;admin&#039; account for the site, and you would get into serious problems if this account stops working.&lt;br /&gt;
* If something goes terribly wrong, you can use the second admin account to fix the main admin account. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Course restore]]&lt;br /&gt;
*[[Backup of user data]]&lt;br /&gt;
*[[Activity backup]]&lt;br /&gt;
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI&lt;br /&gt;
&lt;br /&gt;
[[Category:Course]]&lt;br /&gt;
&lt;br /&gt;
[[de:Kurssicherung]]&lt;br /&gt;
[[es:Respaldo del curso]]&lt;br /&gt;
[[eu:Ikastaroaren_Segurtasun-kopia]]&lt;br /&gt;
[[fr:Sauvegarde de cours]]&lt;br /&gt;
[[ja:コースバックアップ]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136747</id>
		<title>Course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Course_backup&amp;diff=136747"/>
		<updated>2020-03-12T11:33:29Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Example: add Windows CLI info with DESTINATION being the Moodledata folder */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Backup}}&lt;br /&gt;
A course can be saved with some or all of its parts by using the course backup.  Typically, the site administrator will set a schedule of [[Automated course backup|automated course backups]] for the whole site.  A teacher can create a backup or download an existing backup for safe keeping, or for use on another Moodle site.  &lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/eNe6kRv2ndI| desc = Course backup: Moodle 3.7}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Backing up a course==&lt;br /&gt;
&lt;br /&gt;
To backup a course&lt;br /&gt;
&lt;br /&gt;
# Go into the course.&lt;br /&gt;
# Click the Backup link either in the gear menu or the Administration block (depending upon the theme).&lt;br /&gt;
# Initial settings - Select activities, blocks, filters and other items as required then click the Next button. Users with appropriate permissions, such as administrators and managers, can choose whether to [[Backup of user data|include users]], anonymize user information, or include user role assignments, groups, groupings, user files, comments, user completion details, course logs and grade history in the backup.&lt;br /&gt;
# Schema settings  - Select/deselect specific items to include in backup, then click the Next button.&lt;br /&gt;
# If desired, select specific types of activity to be backed up by clicking the link &#039;Show type options&#039; &lt;br /&gt;
# Confirmation and review - Check that everything is as required, using the Previous button if necessary, otherwise click the &#039;Perform backup&#039; button&lt;br /&gt;
# Complete - Click the Continue button&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
[[File:backupgroups.png|thumb|Backup settings]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore1.png|thumb|Back up screen with option to select all or none]]&lt;br /&gt;
|&lt;br /&gt;
|[[File:26backuprestore2.png|thumb|Back up screen with option to select activity types]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
A backup file (with distinctive .mbz extension to avoid confusion with .zip files) is then saved in the course backup area. Backup file names are of the form &#039;&#039;backup-moodle2-course-coursename-date-hour.mbz&#039;&#039;, ending in &#039;&#039;-nu.mbz&#039;&#039; when backed up with no users and &#039;&#039;-an.mbz&#039;&#039;  with anonymized names.&lt;br /&gt;
&lt;br /&gt;
Tip: If you are satisfied with the default settings and don&#039;t wish to go through all the backup screens, you can simply click &#039;Jump to final step&#039; to perform the backup.&lt;br /&gt;
&lt;br /&gt;
==Anonymizing user information==&lt;br /&gt;
&lt;br /&gt;
Anonymize user information is a backup feature which &amp;quot;protects user identities&amp;quot; by making each user anonymous. If this box is checked in the backup initial settings, Moodle will substitute aliases for real names, substituting @doesntexist.com email addresses and so forth. For example  &amp;quot;Max Manager&amp;quot; might become  &amp;quot;anonfirstname4 anonlastname4&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Asynchronous course backups==&lt;br /&gt;
&lt;br /&gt;
With large courses it is helpful to be able to continue working while the course is backing up in the background. This can be done if the administrator checks the box &#039;Enable asynchronous backups&#039; from &#039;&#039;Site Administration / Advanced features&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Backup via CLI for administrators==&lt;br /&gt;
&lt;br /&gt;
Site administrators can backup selected courses using a CLI script.&lt;br /&gt;
&lt;br /&gt;
===Options===&lt;br /&gt;
* --courseid=INTEGER (Course ID for backup.)&lt;br /&gt;
* --courseshortname=STRING (Course shortname for backup.)&lt;br /&gt;
* --destination=STRING (Path where to store backup file. If not set the backup will be stored within the course backup file area.)&lt;br /&gt;
* -h, --help (Print out this help.)&lt;br /&gt;
&lt;br /&gt;
===Example===&lt;br /&gt;
\$sudo -u www-data /usr/bin/php admin/cli/backup.php --courseid=2 --destination=/moodle/backup/&lt;br /&gt;
&lt;br /&gt;
On Windows you will use cmd.exe to run the /admin/cli/backup.php script. If you have your Moodledata folder setup on a separate data server you can specify a UNC path to your backup folder on that data server:&lt;br /&gt;
&lt;br /&gt;
CD to the Moodle &#039;&#039;\admin\cli&#039;&#039; folder and run this command:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
php backup.php --courseid=25 --destination=\\moodledata\backup&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The .mbz backup file for courseid=25 will be stored in the &#039;&#039;backup&#039;&#039; subfolder in the &#039;&#039;Moodledata&#039;&#039; folder.&lt;br /&gt;
&lt;br /&gt;
==Tips and tricks==&lt;br /&gt;
* Lose content after a restore in Moodle 2.0 ?  Do you see topic headings that say &amp;quot;Orphaned activities&amp;quot;?   Solution: Go to course settings and increase the number of topic sections and things will return to normal.&lt;br /&gt;
&lt;br /&gt;
==Creative uses==&lt;br /&gt;
The backup and restore processes can offer the teacher and administrators many creative solutions.&lt;br /&gt;
*Duplicating courses or specific activities in one course to another course (similar to Import)&lt;br /&gt;
*Updating a production Moodle site course, with material from a localhost site course&lt;br /&gt;
*Transferring a course to a new Moodle site.&lt;br /&gt;
*In earlier versions of Moodle, a way of rolling a course forward without past student activity&lt;br /&gt;
*Creating a blank activity, save just that activity and then restore it to the course or another course one or more times. &lt;br /&gt;
&lt;br /&gt;
==General backup defaults==&lt;br /&gt;
&lt;br /&gt;
Default settings for course backups can be set by a site administrator in &#039;General backup defaults&#039; in the Site administration.&lt;br /&gt;
&lt;br /&gt;
Selected settings may be locked, so that they cannot be changed when creating a course backup.&lt;br /&gt;
&lt;br /&gt;
By selecting a time in the &amp;quot;Keep logs for..&amp;quot;  dropdown, it is possible to specify how long backup  logs information is kept before being deleted. As this information may be very large, it is recommended the length of time chosen be quite short.&lt;br /&gt;
&lt;br /&gt;
==Course backup stops above 90%, not showing any errors==&lt;br /&gt;
This has been reported to be caused by:&lt;br /&gt;
* a [[Course_formats#Contributed_Course_Formats|non-standard course_format]]. Try replacing the course format.&lt;br /&gt;
* not enough server RAM. Adding more RAM to your server is usually the first [[Performance_recommendations|performance recomendation]].&lt;br /&gt;
&lt;br /&gt;
==Course backup capabilities==&lt;br /&gt;
&lt;br /&gt;
*[[Capabilities/moodle/backup:anonymise|Anonymise user data on backup]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupcourse|Backup courses]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backupsection|Backup sections]]&lt;br /&gt;
*[[Capabilities/moodle/backup:backuptargetimport|Backup for import]]&lt;br /&gt;
*[[Capabilities/moodle/backup:configure|Configure backup options]]&lt;br /&gt;
*[[Capabilities/moodle/backup:downloadfile|Download files from backup areas]]&lt;br /&gt;
*[[Capabilities/moodle/backup:userinfo|Backup user data]]&lt;br /&gt;
&lt;br /&gt;
==Error: Trying to restore user &#039;admin&#039; from backup file will cause conflict ==&lt;br /&gt;
* Before proceeding, it would be advisable to have a second admin account &#039;&#039;just in case something goes wrong&#039;&#039;.&lt;br /&gt;
* Check that the admin accounts on each server have &#039;&#039;&#039;different&#039;&#039;&#039; unique usernames and email addresses and then try again to backup up the course with user data and restore it. &lt;br /&gt;
** If you can not make a new backup and you must use an existing &#039;conflicting&#039; backup file, you will have to change the new site&#039;s main admin account with extreme care to remember the new main admin&#039;s password and email.&lt;br /&gt;
* Note that the admin account from the imported file may loose the password and become unusable; &lt;br /&gt;
* You are advised to update/reset the &#039;imported&#039; main &#039;admin&#039;s account&#039;s password before logging out, as this will most likely be the main &#039;admin&#039; account for the site, and you would get into serious problems if this account stops working.&lt;br /&gt;
* If something goes terribly wrong, you can use the second admin account to fix the main admin account. &lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Course restore]]&lt;br /&gt;
*[[Backup of user data]]&lt;br /&gt;
*[[Activity backup]]&lt;br /&gt;
* Administrators can use [http://moosh-online.com/commands/#course-restore MOOSH] to bulk backup and restore courses from CLI&lt;br /&gt;
&lt;br /&gt;
[[Category:Course]]&lt;br /&gt;
&lt;br /&gt;
[[de:Kurssicherung]]&lt;br /&gt;
[[es:Respaldo del curso]]&lt;br /&gt;
[[eu:Ikastaroaren_Segurtasun-kopia]]&lt;br /&gt;
[[fr:Sauvegarde de cours]]&lt;br /&gt;
[[ja:コースバックアップ]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Capabilities/mod/feedback:view&amp;diff=135996</id>
		<title>Talk:Capabilities/mod/feedback:view</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Capabilities/mod/feedback:view&amp;diff=135996"/>
		<updated>2019-11-21T17:09:02Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Explanation required */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;What does &amp;quot;allows a user to view a feedback activity&amp;quot; mean? Can a user with this capability just open a feedback form or can they see all the feedback responses submitted by students?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 17:08, 21 November 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=ad-hoc_contributed_reports&amp;diff=135964</id>
		<title>ad-hoc contributed reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=ad-hoc_contributed_reports&amp;diff=135964"/>
		<updated>2019-11-19T14:29:08Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Quiz Module Reports - Questions which are tagged within a course/quiz */&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;
=== Enrolment count in each Course ===&lt;br /&gt;
&lt;br /&gt;
Shows the total number of enroled users of all roles in each course. Sorted by course name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.fullname, COUNT(ue.id) AS Enroled&lt;br /&gt;
FROM prefix_course AS c &lt;br /&gt;
JOIN prefix_enrol AS en ON en.courseid = c.id&lt;br /&gt;
JOIN prefix_user_enrolments AS ue ON ue.enrolid = en.id&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
ORDER BY c.fullname&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;
==== Users loggedin within the last 7 days ====&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
    l.* FROM mdl_logstore_standard_log l&lt;br /&gt;
WHERE&lt;br /&gt;
   l.eventname = &#039;\\core\\event\\user_loggedin&#039;&lt;br /&gt;
   AND FROM_UNIXTIME(l.timecreated, &#039;%Y-%m-%d&#039;) &amp;gt;= DATE_SUB(NOW(), INTERVAL 7 DAY)&lt;br /&gt;
&lt;br /&gt;
SELECT l.eventname FROM mdl_logstore_standard_log l&lt;br /&gt;
GROUP BY l.eventname&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;
===List Students with enrollment and completion dates in current course===&lt;br /&gt;
This is meant to be a &amp;quot;global&amp;quot; report in Configurable Reports containing the following:&lt;br /&gt;
firstname, lastname, idnumber, institution, department, email, student enrolment date, student completion date&lt;br /&gt;
Note: for PGSQL, use to_timestamp() instead of FROM_UNIXTIME()&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
u.firstname&lt;br /&gt;
, u.lastname&lt;br /&gt;
, u.idnumber&lt;br /&gt;
, u.institution&lt;br /&gt;
, u.department&lt;br /&gt;
, u.email&lt;br /&gt;
, FROM_UNIXTIME(cc.timeenrolled)&lt;br /&gt;
, FROM_UNIXTIME(cc.timecompleted)&lt;br /&gt;
&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;
JOIN prefix_course_completions AS cc ON cc.course = c.id AND cc.userid = u.id&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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 (in the U.S., Canada and the Americas) is changing the default English to United States 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;
NOTE: UPDATE commands require the ability to alter the database directly via tools like Adminer or PHPMyAdmin or other db tools.&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;
To do this for only users who have a particular country set, use this as an example:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
UPDATE prefix_user SET lang = &#039;en_us&#039; WHERE country = &#039;US&#039; AND lang = &#039;en&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== List of users with Authentication ===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
Sometimes you need to do mass changes of authentication methods. A common case is changing default manual to LDAP. &lt;br /&gt;
&lt;br /&gt;
This will show you the Authentication setting for all users:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT username, auth from prefix_user &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: UPDATE commands require the ability to alter the database directly via tools like Adminer or PHPMyAdmin or other db tools. &lt;br /&gt;
&lt;br /&gt;
This code will change the setting from &#039;manual&#039; to &#039;ldap&#039; for all users except for the first two accounts which are Guest and Admin. (WARNING: it is bad practice to change your admin account from manual to an external method as failure of that external method will lock you out of Moodle as admin.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
UPDATE prefix_user SET auth = &#039;ldap&#039; WHERE auth = &#039;manual&#039; AND id &amp;gt; 2&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;
=== User&#039;s accumulative time spent in course ===&lt;br /&gt;
A sum up of the time delta between logstore_standard_log user&#039;s records, considering the a 2 hour session limit.&lt;br /&gt;
&lt;br /&gt;
Uses: current user&#039;s id %%USERID%% and current course&#039;s id %%COURSEID%%  &lt;br /&gt;
&lt;br /&gt;
And also using a date filter (which can be ignored)  &lt;br /&gt;
&lt;br /&gt;
The extra &amp;quot;User&amp;quot; field is used as a dummy field for the Line chart Series field, in which I use X=id, Series=Type, Y=delta.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
l.id, &lt;br /&gt;
l.timecreated, &lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(l.timecreated),&#039;%d-%m-%Y&#039;) AS dTime,&lt;br /&gt;
@prevtime := (SELECT max(timecreated) FROM mdl_logstore_standard_log &lt;br /&gt;
		WHERE userid = %%USERID%% and id &amp;lt; l.id ORDER BY id ASC LIMIT 1) AS prev_time,&lt;br /&gt;
IF (l.timecreated - @prevtime &amp;lt; 7200, @delta := @delta + (l.timecreated-@prevtime),0) AS sumtime,&lt;br /&gt;
l.timecreated-@prevtime AS delta,&lt;br /&gt;
&amp;quot;User&amp;quot; as type&lt;br /&gt;
&lt;br /&gt;
FROM prefix_logstore_standard_log as l, &lt;br /&gt;
(SELECT @delta := 0) AS s_init &lt;br /&gt;
# Change UserID&lt;br /&gt;
WHERE l.userid = %%USERID%% AND l.courseid = %%COURSEID%%&lt;br /&gt;
%%FILTER_STARTTIME:l.timecreated:&amp;gt;%% %%FILTER_ENDTIME:l.timecreated:&amp;lt;%% &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Low-Participation Student Report ===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College / Moodle HQ&lt;br /&gt;
&lt;br /&gt;
This report returns a list of students who are enrolled in courses filtered by a short-name text marker (in this case &amp;quot;OL-&amp;quot;) in the specified category, but have very low participation in the course during the specified time period (fewer than 2 &amp;quot;Edits&amp;quot; to Activity Modules, indicating few active contributions to the course). The number of &amp;quot;Edits&amp;quot; is provided for each student for the time period specified.&lt;br /&gt;
&lt;br /&gt;
An &amp;quot;Edit&amp;quot; is defined as course activity other than viewing content. Click the &amp;quot;Logs&amp;quot; link to review the student activity. The Logs offer the option to review &amp;quot;View&amp;quot; activity as well as &amp;quot;Edit&amp;quot; activity.&lt;br /&gt;
&lt;br /&gt;
Only &amp;quot;visible&amp;quot; courses are included in this report. The report may be downloaded as an Excel spreadsheet.&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to set up Filters: &amp;quot;Start / End date filter&amp;quot; and &amp;quot;Filter categories&amp;quot; on the Filters tab in Configurable reports.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.lastname AS Last, u.firstname AS First, u.idnumber AS IDnumber, u.email AS email, c.shortname AS CourseID,  count(l.id) AS Edits, CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;https://learn.granite.edu/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=-view&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;
&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; %%FILTER_STARTTIME:l.TIME:&amp;gt;%% %%FILTER_ENDTIME:l.TIME:&amp;lt;%%&lt;br /&gt;
&lt;br /&gt;
WHERE ra.roleid =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
AND c.visible=1&lt;br /&gt;
# This prefix filter allows the exclusion of non-online courses at the original institution. Alter this to fit your institution, or remove it.&lt;br /&gt;
AND c.shortname LIKE &#039;%OL-%&#039;&lt;br /&gt;
%%FILTER_CATEGORIES:c.category%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY u.idnumber&lt;br /&gt;
&lt;br /&gt;
HAVING Edits &amp;lt; 2&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Messages of All Users in a Specific Course ===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
NOTE: This query will probably not work at all in 3.5 now due to the changes in the structure of the Messages database. - RT&lt;br /&gt;
&lt;br /&gt;
This query shows the personal messages between users in a specific course, given the course id number. Properly speaking, personal messages pertain only to users and are not part of courses, but by filtering enrollments for roles in a course, you can show this. &lt;br /&gt;
&lt;br /&gt;
This report as is shows only the messages between Teachers and Students, as the WHERE statement contains and AND ((...))) section that restrict this report to ONLY messages between Teachers (role id = 3) and Students (role id =5). Remove that part of the statement if you wish to see _all_ messages between all users, e.g. teachers to teachers, student to student. &lt;br /&gt;
&lt;br /&gt;
Also, if you have created custom roles, you can replace the default id numbers with custom ones to further enhance the report.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
u.username AS &#039;From&#039;,&lt;br /&gt;
CONCAT(u.firstname ,&#039; &#039;,u.lastname) AS &#039;From Name&#039;,&lt;br /&gt;
u2.username AS &#039;To&#039;,&lt;br /&gt;
CONCAT(u2.firstname ,&#039; &#039;,u2.lastname) AS &#039;To Name&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(me.timecreated), &#039;%Y-%m-%d %H:%i&#039;) AS &#039;When&#039;,&lt;br /&gt;
me.subject AS &#039;Subject&#039;, &lt;br /&gt;
me.smallmessage AS &#039;Message&#039;&lt;br /&gt;
FROM prefix_message me&lt;br /&gt;
JOIN prefix_role_assignments AS ra ON ra.userid = me.useridfrom AND ra.roleid IN (3,4,5)  &lt;br /&gt;
JOIN prefix_role_assignments AS ra2 ON ra2.userid = me.useridto AND ra2.roleid IN (3,4,5)  &lt;br /&gt;
JOIN prefix_context AS ctx ON ra.contextid = ctx.id AND ra2.contextid = ctx.id&lt;br /&gt;
JOIN prefix_course AS c ON c.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_user u ON u.id = me.useridfrom&lt;br /&gt;
JOIN prefix_user u2 ON u2.id = me.useridto&lt;br /&gt;
WHERE c.id=## &lt;br /&gt;
AND ((ra.roleid = 3 AND ra2.roleid = 5) OR (ra.roleid = 5 AND ra2.roleid = 3)) &lt;br /&gt;
ORDER BY me.useridfrom, me.useridto, me.timecreated&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;
===Distinct user logins per month===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
The following will show you the months of the current calendar year with the total number of distinct, unique user logins per month. Change the year in the WHERE clause to the year you need.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
 COUNT(DISTINCT l.userid) AS &#039;DistinctUserLogins&#039;, &lt;br /&gt;
 DATE_FORMAT(FROM_UNIXTIME(l.timecreated), &#039;%M&#039;) AS &#039;Month&#039;&lt;br /&gt;
FROM prefix_logstore_standard_log l&lt;br /&gt;
WHERE l.action = &#039;loggedin&#039; AND YEAR(FROM_UNIXTIME(l.timecreated)) = &#039;2017&#039; &lt;br /&gt;
GROUP BY MONTH(FROM_UNIXTIME(l.timecreated))&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(l.courseid) 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 mdl_logstore_standard_log AS l&lt;br /&gt;
  JOIN mdl_course AS c ON c.id = l.courseid&lt;br /&gt;
WHERE l.courseid &amp;gt; 0&lt;br /&gt;
      AND FROM_UNIXTIME(l.timecreated) &amp;gt;= DATE_SUB(NOW(), INTERVAL 1 DAY)&lt;br /&gt;
      AND c.fullname LIKE &#039;%תשעו%&#039;&lt;br /&gt;
GROUP BY l.courseid&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, Granite State College&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;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This report can take a long time to run. While it can be run in Configurable Reports on demand, it may be more appropriate to implement it in the Ad Hoc Queries plugin as a scheduled report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This version uses legacy (pre-2.7) logs. See below for post-2.7 Standard Logs version.&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;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Post-2.7 log version:&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;
, FROM_UNIXTIME(c.startdate) AS Course_Start_Date&lt;br /&gt;
&lt;br /&gt;
, c.visible AS Visible&lt;br /&gt;
&lt;br /&gt;
,  COUNT(DISTINCT l.id) AS Edits&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF((l.timecreated-c.startdate)&amp;lt;0,l.id,NULL)) AS &#039;Before Term&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=0,l.id,NULL)) AS &#039;Week 1&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=1,l.id,NULL)) AS &#039;Week 2&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=2,l.id,NULL)) AS &#039;Week 3&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=3,l.id,NULL)) AS &#039;Week 4&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=4,l.id,NULL)) AS &#039;Week 5&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=5,l.id,NULL)) AS &#039;Week 6&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=6,l.id,NULL)) AS &#039;Week 7&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=7,l.id,NULL)) AS &#039;Week 8&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=8,l.id,NULL)) AS &#039;Week 9&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=9,l.id,NULL)) AS &#039;Week 10&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=10,l.id,NULL)) AS &#039;Week 11&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=11,l.id,NULL)) AS &#039;Week 12&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))&amp;gt;=12,l.id,NULL)) AS &#039;After Term&#039;&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;
LEFT JOIN prefix_role_assignments AS ra ON u.id = ra.userid&lt;br /&gt;
LEFT JOIN prefix_context AS ctx ON ra.contextid = ctx.id&lt;br /&gt;
LEFT JOIN prefix_course AS c ON c.id = ctx.instanceid&lt;br /&gt;
LEFT JOIN prefix_course_categories as cc ON c.category = cc.id&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_logstore_standard_log AS l ON l.userid = u.id AND l.courseid = c.id  AND l.crud IN (&#039;c&#039;,&#039;u&#039;)&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 &#039;%OL-%&#039;&lt;br /&gt;
AND cc.idnumber LIKE &#039;%current%&#039;&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 RIGHT(c.shortname,2), c.shortname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Weekly Student Online Participation===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Displays participation of students in the current course by week, including pre-term and post-term edits. An edit is defined as a change to the course, such as a discussion post, the submission of an assignment, or the completion of a quiz, as well as alterations to course content such as database entries (if permitted).&lt;br /&gt;
&lt;br /&gt;
Links to three other reports are also provided:&lt;br /&gt;
&lt;br /&gt;
* Logs: complete log entries for the student in the course, organized by date&lt;br /&gt;
* Activity Outline: the &amp;quot;Outline Report&amp;quot; from the User Activity Reports, summarizing the student&#039;s activity in the course, organized by course content&lt;br /&gt;
* Consolidated Activity Report: the &amp;quot;Complete Report&amp;quot; from the User Activity Reports, detailing the student&#039;s activity in the course, organized by course content (includes text of forum posts)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This should be defined as a &amp;quot;Global&amp;quot; report (visible from within all courses). At our institution, 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. We pull advisor names into student user profiles as part of our configuration. These lines are present in the code below, but are commented out, as they are very specific to your Moodle configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This version of the report uses legacy (pre-2.7) logs. See below for a post-2.7 Standard Logs version.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
u.lastname AS &#039;Last Name&#039;&lt;br /&gt;
, u.firstname AS &#039;First Name&#039;&lt;br /&gt;
,  COUNT(l.id) AS &#039;Edits&#039;&lt;br /&gt;
&lt;br /&gt;
, SUM(IF((l.time-c.startdate)/7&amp;lt;0,1,0)) AS &#039;Before Term&#039;&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=0,1,0)) AS &#039;Week 1&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=1,1,0)) AS &#039;Week 2&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=2,1,0)) AS &#039;Week 3&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=3,1,0)) AS &#039;Week 4&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=4,1,0)) AS &#039;Week 5&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=5,1,0)) AS &#039;Week 6&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=6,1,0)) AS &#039;Week 7&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=7,1,0)) AS &#039;Week 8&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=8,1,0)) AS &#039;Week 9&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=9,1,0)) AS &#039;Week 10&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=10,1,0)) AS &#039;Week 11&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=11,1,0)) AS &#039;Week 12&#039;&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))&amp;gt;=15,1,0)) AS &#039;After Term&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&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 &#039;Logs&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/report/outline/user.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;amp;course=&#039;,c.id,&#039;&amp;amp;mode=outline&amp;quot;&amp;gt;&#039;,&#039;Outline&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Activity Outline&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/report/outline/user.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;amp;course=&#039;,c.id,&#039;&amp;amp;mode=complete&amp;quot;&amp;gt;&#039;,&#039;Activity&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Consolidated Activity&#039;&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 =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY u.idnumber&lt;br /&gt;
&lt;br /&gt;
ORDER BY u.lastname, u.firstname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Post-2.7 (Standard Logs) version&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
u.lastname AS &#039;Last Name&#039;&lt;br /&gt;
, u.firstname AS &#039;First Name&#039;&lt;br /&gt;
,  COUNT(l.id) AS &#039;Edits&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF((l.timecreated-c.startdate)&amp;lt;0,l.id,NULL)) AS &#039;Before Term&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=0,l.id,NULL)) AS &#039;Week 1&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=1,l.id,NULL)) AS &#039;Week 2&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=2,l.id,NULL)) AS &#039;Week 3&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=3,l.id,NULL)) AS &#039;Week 4&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=4,l.id,NULL)) AS &#039;Week 5&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=5,l.id,NULL)) AS &#039;Week 6&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=6,l.id,NULL)) AS &#039;Week 7&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=7,l.id,NULL)) AS &#039;Week 8&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=8,l.id,NULL)) AS &#039;Week 9&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=9,l.id,NULL)) AS &#039;Week 10&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=10,l.id,NULL)) AS &#039;Week 11&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=11,l.id,NULL)) AS &#039;Week 12&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))&amp;gt;=12,l.id,NULL)) AS &#039;After Term&#039;&lt;br /&gt;
&lt;br /&gt;
# Our institution stores academic advisor names and emails in custom profile fields&lt;br /&gt;
#, CONCAT(&#039;&amp;lt;a href=&amp;quot;mailto:&#039;,uce.data,&#039;&amp;quot;&amp;gt;&#039;,uid.data, &#039;&amp;lt;/a&amp;gt;&#039;)  AS &#039;Academic Advisor&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&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 &#039;Logs&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/report/outline/user.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;amp;course=&#039;,c.id,&#039;&amp;amp;mode=outline&amp;quot;&amp;gt;&#039;,&#039;Outline&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Activity Outline&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/report/outline/user.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;amp;course=&#039;,c.id,&#039;&amp;amp;mode=complete&amp;quot;&amp;gt;&#039;,&#039;Activity&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Consolidated Activity&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/user.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;amp;course=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,&#039;Posts&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Posts&#039;&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;
# student academic coach - you can include custom profile field data with these methods&lt;br /&gt;
# LEFT JOIN prefix_user_info_data as uid ON u.id = uid.userid AND uid.fieldid = &#039;2&#039;&lt;br /&gt;
# student academic coach email&lt;br /&gt;
# LEFT JOIN prefix_user_info_data as uce on u.id = uce.userid AND uce.fieldid = &#039;6&#039;&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_logstore_standard_log AS l ON l.userid = u.id AND l.courseid = c.id  AND l.crud IN (&#039;c&#039;,&#039;u&#039;)&lt;br /&gt;
&lt;br /&gt;
WHERE ra.roleid =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY u.idnumber&lt;br /&gt;
&lt;br /&gt;
ORDER BY u.lastname, u.firstname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===My Weekly Online Participation===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Displays participation of the &#039;&#039;&#039;current user&#039;&#039;&#039; in the &#039;&#039;&#039;current course&#039;&#039;&#039; by week, including pre-term and post-term submissions/edits. A submission/edit is defined as a change to the course, such as a discussion post, the submission of an assignment, or the completion of a quiz, as well as alterations to course content such as database entries or new course activities or resources (if permitted).&lt;br /&gt;
&lt;br /&gt;
This report uses Standard Logs (post 2.7).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
l.component AS &#039;activity&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF((l.timecreated-c.startdate)&amp;lt;0,l.id,NULL)) AS &#039;Before Term&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=0,l.id,NULL)) AS &#039;Week 1&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=1,l.id,NULL)) AS &#039;Week 2&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=2,l.id,NULL)) AS &#039;Week 3&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=3,l.id,NULL)) AS &#039;Week 4&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=4,l.id,NULL)) AS &#039;Week 5&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=5,l.id,NULL)) AS &#039;Week 6&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=6,l.id,NULL)) AS &#039;Week 7&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=7,l.id,NULL)) AS &#039;Week 8&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=8,l.id,NULL)) AS &#039;Week 9&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=9,l.id,NULL)) AS &#039;Week 10&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=10,l.id,NULL)) AS &#039;Week 11&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))=11,l.id,NULL)) AS &#039;Week 12&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(FLOOR((l.timecreated - c.startdate)/(60*60*24*7))&amp;gt;=12,l.id,NULL)) AS &#039;After Term&#039;&lt;br /&gt;
&lt;br /&gt;
,  COUNT(l.id) AS &#039;Total&#039;&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_logstore_standard_log AS l ON l.userid = u.id AND l.courseid = c.id  AND l.crud IN (&#039;c&#039;,&#039;u&#039;)&lt;br /&gt;
&lt;br /&gt;
WHERE 1&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
AND u.id = %%USERID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY l.component&lt;br /&gt;
&lt;br /&gt;
ORDER BY l.component&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Faculty/Student Interactions===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Returns a count of instructor and other-student responses to student activity for the specified time period. This report can help indicate whether students&#039; comments are being responded to, as well as summarizing post activity by students during the specified time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This version of the report uses legacy (pre-2.7) logs. See below for the post-2.7 Standard Logs version.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This should be defined as a &amp;quot;Global&amp;quot; report (visible from within all courses). &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This report can take a long time to run. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
# Identify student&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/message/index.php?id=&#039; , allstu.id , &#039;&amp;quot;&amp;gt;&#039; , allstu.firstname , &#039; &#039; , allstu.lastname , &#039;&amp;lt;/a&amp;gt;&#039; ) AS &#039;Student - click to send message&#039;&lt;br /&gt;
&lt;br /&gt;
, IF((COUNT(DISTINCT IF(fps.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fps.id,NULL) )&amp;gt;0) OR (COUNT(DISTINCT IF(asb.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asb.id,NULL))&amp;gt;0) OR  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id AND mfs.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Student Participated This week&#039;&lt;br /&gt;
&lt;br /&gt;
, IF((COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) )&amp;gt;0) OR (COUNT(DISTINCT IF(asg.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asg.id,NULL))&amp;gt;0) OR (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id  AND mts.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Student Contacted This week&#039;&lt;br /&gt;
&lt;br /&gt;
## Only posts within last 7 days&lt;br /&gt;
&lt;br /&gt;
# Count posts by student&lt;br /&gt;
, COUNT(DISTINCT IF(fps.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fps.id,NULL)) AS &#039;Forum Stu Posts - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# Count replies to student posts by instructors&lt;br /&gt;
, COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) ) AS &#039;Forum Instr Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# using link back to student posts on replies, get unique student IDs responded&lt;br /&gt;
, COUNT(DISTINCT IF(fpsr.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpsr.id,NULL)) - COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) ) AS &#039;Forum Stu Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# all replies&lt;br /&gt;
, COUNT(DISTINCT IF(fpsr.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpsr.id,NULL)) AS &#039;Forum All Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# add in count of graded assignments - 7 days&lt;br /&gt;
, COUNT(DISTINCT IF(asb.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asb.id,NULL)) AS &#039;Assign Submit - 7 days&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(asg.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asg.id,NULL)) AS &#039;Assign Grades - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# Messages between students and instructors - 7 days&lt;br /&gt;
,  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id AND mfs.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))) AS &#039;Msg Stu to Instr - 7 days&#039;&lt;br /&gt;
, (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id  AND mts.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))) AS &#039;Msg Instr to Stu - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
## All posts in course so far&lt;br /&gt;
# Count posts by student&lt;br /&gt;
, COUNT(DISTINCT fps.id) AS &#039;Forum Stu Posts - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# Count replies to student posts by instructors&lt;br /&gt;
, COUNT(DISTINCT fpi.id) AS &#039;Forum Instr Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# using link back to student posts on replies, get unique student IDs responded&lt;br /&gt;
, COUNT(DISTINCT fpsr.id) - COUNT(DISTINCT fpi.id) AS &#039;Forum Stu Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# all replies&lt;br /&gt;
, COUNT(DISTINCT fpsr.id) AS &#039;Forum All Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# add in count of graded assignments - whole course&lt;br /&gt;
, COUNT(DISTINCT asb.id) AS &#039;Assign Submit - to date&#039;&lt;br /&gt;
, COUNT(DISTINCT asg.id) AS &#039;Assign Grades - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# Messages between students and instructors - to date&lt;br /&gt;
,  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id ) AS &#039;Msg Stu to Instr - to date&#039;&lt;br /&gt;
, (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id) AS &#039;Msg Instr to Stu - to date&#039;&lt;br /&gt;
&lt;br /&gt;
## JOINS&lt;br /&gt;
&lt;br /&gt;
# Start by getting all the students in the course&lt;br /&gt;
FROM prefix_user AS allstu &lt;br /&gt;
JOIN prefix_role_assignments AS ras ON allstu.id = ras.userid AND ras.roleid = 5&lt;br /&gt;
JOIN prefix_context AS ctx  ON ras.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;
# Now we get the forums and forum discussions from this course only&lt;br /&gt;
LEFT JOIN prefix_forum AS frm ON frm.course = c.id AND c.id = %%COURSEID%%&lt;br /&gt;
LEFT JOIN prefix_forum_discussions AS fd ON fd.course = %%COURSEID%% AND fd.forum = frm.id&lt;br /&gt;
&lt;br /&gt;
# These are forum discussion posts just by students within specified time&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fps ON fps.userid = allstu.id AND fps.discussion = fd.id&lt;br /&gt;
&lt;br /&gt;
# Separately, we connect the instructors of the courses&lt;br /&gt;
# We can use the context we have already gotten for the students&lt;br /&gt;
LEFT JOIN prefix_role_assignments AS rai ON rai.contextid = ctx.id&lt;br /&gt;
LEFT JOIN prefix_user AS instr ON instr.id = rai.userid AND rai.roleid =3&lt;br /&gt;
&lt;br /&gt;
# Now we will connect to posts by instructors that are replies to student posts&lt;br /&gt;
# This is a left join, because we don&#039;t want to eliminate any students from the list&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpi ON fpi.discussion = fd.id AND fpi.userid = instr.id AND fpi.parent = fps.id&lt;br /&gt;
&lt;br /&gt;
# To get identities of only those students who were replied to:&lt;br /&gt;
# Connect from instr replies back up to parent posts by students again&lt;br /&gt;
# This has to be a LEFT JOIN, we know these posts exist but don&#039;t eliminate non-responded students&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpir ON fpir.id = fpi.parent&lt;br /&gt;
&lt;br /&gt;
# We also want to know if students are replying to one another&lt;br /&gt;
# These are posts that are replies to student posts&lt;br /&gt;
# Again, a left join&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpsr ON fpsr.discussion = fd.id AND fpsr.parent = fps.id&lt;br /&gt;
&lt;br /&gt;
# get the activity modules&lt;br /&gt;
LEFT JOIN prefix_course_modules AS cm ON c.id = cm.course&lt;br /&gt;
&lt;br /&gt;
# get the assignments&lt;br /&gt;
LEFT JOIN prefix_assign AS a ON  cm.instance = a.id&lt;br /&gt;
 LEFT JOIN prefix_assign_submission AS asb ON a.id = asb.assignment AND asb.userid=allstu.id &lt;br /&gt;
LEFT JOIN prefix_assign_grades AS asg ON asg.assignment = a.id AND asg.userid = allstu.id AND asg.assignment = asb.assignment &lt;br /&gt;
&lt;br /&gt;
# We care about messages that involve both the instructor and students of this course&lt;br /&gt;
# messages from instructor to students:&lt;br /&gt;
# LEFT JOIN prefix_message AS mts ON mts.useridfrom = instr.id AND mts.useridto = allstu.id&lt;br /&gt;
# LEFT JOIN prefix_message AS mfs ON mfs.useridfrom = instr.id AND mfs.useridto = allstu.id&lt;br /&gt;
&lt;br /&gt;
WHERE  &lt;br /&gt;
c.id = %%COURSEID%% &lt;br /&gt;
&lt;br /&gt;
# GROUP BY c.shortname , allstu.id&lt;br /&gt;
GROUP BY allstu.id&lt;br /&gt;
&lt;br /&gt;
ORDER BY allstu.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Post-2.7 Standard Logs version&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
# Identify student&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/message/index.php?id=&#039; , allstu.id , &#039;&amp;quot;&amp;gt;&#039; , allstu.firstname , &#039; &#039; , allstu.lastname , &#039;&amp;lt;/a&amp;gt;&#039; ) AS &#039;Student - click to send message&#039;&lt;br /&gt;
&lt;br /&gt;
, IF((COUNT(DISTINCT IF(fps.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fps.id,NULL) )&amp;gt;0) OR (COUNT(DISTINCT IF(asb.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asb.id,NULL))&amp;gt;0) OR  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id AND mfs.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Student Participated This week&#039;&lt;br /&gt;
&lt;br /&gt;
, IF((COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) )&amp;gt;0) OR (COUNT(DISTINCT IF(asg.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asg.id,NULL))&amp;gt;0) OR (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id  AND mts.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Student Contacted This week&#039;&lt;br /&gt;
&lt;br /&gt;
## Only posts within last 7 days&lt;br /&gt;
&lt;br /&gt;
# Count posts by student&lt;br /&gt;
, COUNT(DISTINCT IF(fps.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fps.id,NULL)) AS &#039;Forum Stu Posts - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# Count replies to student posts by instructors&lt;br /&gt;
, COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) ) AS &#039;Forum Instr Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# using link back to student posts on replies, get unique student IDs responded&lt;br /&gt;
, COUNT(DISTINCT IF(fpsr.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpsr.id,NULL)) - COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) ) AS &#039;Forum Stu Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# all replies&lt;br /&gt;
, COUNT(DISTINCT IF(fpsr.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpsr.id,NULL)) AS &#039;Forum All Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# add in count of graded assignments - 7 days&lt;br /&gt;
, COUNT(DISTINCT IF(asb.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asb.id,NULL)) AS &#039;Assign Submit - 7 days&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(asg.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asg.id,NULL)) AS &#039;Assign Grades - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# Messages between students and instructors - 7 days&lt;br /&gt;
,  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id AND mfs.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))) AS &#039;Msg Stu to Instr - 7 days&#039;&lt;br /&gt;
, (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id  AND mts.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))) AS &#039;Msg Instr to Stu - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
## All posts in course so far&lt;br /&gt;
# Count posts by student&lt;br /&gt;
, COUNT(DISTINCT fps.id) AS &#039;Forum Stu Posts - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# Count replies to student posts by instructors&lt;br /&gt;
, COUNT(DISTINCT fpi.id) AS &#039;Forum Instr Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# using link back to student posts on replies, get unique student IDs responded&lt;br /&gt;
, COUNT(DISTINCT fpsr.id) - COUNT(DISTINCT fpi.id) AS &#039;Forum Stu Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# all replies&lt;br /&gt;
, COUNT(DISTINCT fpsr.id) AS &#039;Forum All Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# add in count of graded assignments - whole course&lt;br /&gt;
, COUNT(DISTINCT asb.id) AS &#039;Assign Submit - to date&#039;&lt;br /&gt;
, COUNT(DISTINCT asg.id) AS &#039;Assign Grades - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# Messages between students and instructors - to date&lt;br /&gt;
,  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id ) AS &#039;Msg Stu to Instr - to date&#039;&lt;br /&gt;
, (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id) AS &#039;Msg Instr to Stu - to date&#039;&lt;br /&gt;
&lt;br /&gt;
## JOINS&lt;br /&gt;
&lt;br /&gt;
# Start by getting all the students in the course&lt;br /&gt;
FROM prefix_user AS allstu &lt;br /&gt;
JOIN prefix_role_assignments AS ras ON allstu.id = ras.userid AND ras.roleid = 5&lt;br /&gt;
JOIN prefix_context AS ctx  ON ras.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;
# Now we get the forums and forum discussions from this course only&lt;br /&gt;
JOIN prefix_forum AS frm ON frm.course = c.id AND c.id = %%COURSEID%%&lt;br /&gt;
JOIN prefix_forum_discussions AS fd ON fd.course = %%COURSEID%% AND fd.forum = frm.id&lt;br /&gt;
&lt;br /&gt;
# These are forum discussion posts just by students within specified time&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fps ON fps.userid = allstu.id AND fps.discussion = fd.id&lt;br /&gt;
&lt;br /&gt;
# Separately, we connect the instructors of the courses&lt;br /&gt;
# We can use the context we have already gotten for the students&lt;br /&gt;
JOIN prefix_role_assignments AS rai ON rai.contextid = ctx.id&lt;br /&gt;
JOIN prefix_user AS instr ON instr.id = rai.userid AND rai.roleid =3&lt;br /&gt;
&lt;br /&gt;
# Now we will connect to posts by instructors that are replies to student posts&lt;br /&gt;
# This is a left join, because we don&#039;t want to eliminate any students from the list&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpi ON fpi.discussion = fd.id AND fpi.userid = instr.id AND fpi.parent = fps.id&lt;br /&gt;
&lt;br /&gt;
# To get identities of only those students who were replied to:&lt;br /&gt;
# Connect from instr replies back up to parent posts by students again&lt;br /&gt;
# This has to be a LEFT JOIN, we know these posts exist but don&#039;t eliminate non-responded students&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpir ON fpir.id = fpi.parent&lt;br /&gt;
&lt;br /&gt;
# We also want to know if students are replying to one another&lt;br /&gt;
# These are posts that are replies to student posts&lt;br /&gt;
# Again, a left join&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpsr ON fpsr.discussion = fd.id AND fpsr.parent = fps.id&lt;br /&gt;
&lt;br /&gt;
# get the activity modules&lt;br /&gt;
JOIN prefix_course_modules AS cm ON c.id = cm.course&lt;br /&gt;
&lt;br /&gt;
# get the assignments&lt;br /&gt;
 JOIN prefix_assign AS a ON  cm.instance = a.id&lt;br /&gt;
 LEFT JOIN prefix_assign_submission AS asb ON a.id = asb.assignment AND asb.userid=allstu.id &lt;br /&gt;
LEFT JOIN prefix_assign_grades AS asg ON asg.assignment = a.id AND asg.userid = allstu.id AND asg.assignment = asb.assignment &lt;br /&gt;
&lt;br /&gt;
WHERE  &lt;br /&gt;
c.id = %%COURSEID%% &lt;br /&gt;
&lt;br /&gt;
# GROUP BY c.shortname , allstu.id&lt;br /&gt;
GROUP BY allstu.id&lt;br /&gt;
&lt;br /&gt;
ORDER BY allstu.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Student Resource Usage===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Displays usage by students of all activities and resources in the current course by activity. Only activities and sections which are visible in the course are included. This version requires the new &amp;quot;Standard Logs&amp;quot; from Moodle 2.7+.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This should be defined as a &amp;quot;Global&amp;quot; report (visible from within all courses). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
cs.section AS &#039;Week&#039;&lt;br /&gt;
, cs.name AS &#039;Section Name&#039;&lt;br /&gt;
, m.name AS &#039;item type&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&lt;br /&gt;
COALESCE(a.name, &#039;&#039;), &lt;br /&gt;
COALESCE(b.name,&#039;&#039;), &lt;br /&gt;
COALESCE(cert.name,&#039;&#039;), &lt;br /&gt;
COALESCE(chat.name,&#039;&#039;), &lt;br /&gt;
COALESCE(choice.name,&#039;&#039;), &lt;br /&gt;
COALESCE(data.name,&#039;&#039;), &lt;br /&gt;
COALESCE(feedback.name,&#039;&#039;), &lt;br /&gt;
COALESCE(folder.name,&#039;&#039;), &lt;br /&gt;
COALESCE(forum.name,&#039;&#039;), &lt;br /&gt;
COALESCE(glossary.name,&#039;&#039;), &lt;br /&gt;
COALESCE(imscp.name,&#039;&#039;), &lt;br /&gt;
COALESCE(lesson.name,&#039;&#039;), &lt;br /&gt;
COALESCE(p.name,&#039;&#039;),&lt;br /&gt;
COALESCE(questionnaire.name,&#039;&#039;), &lt;br /&gt;
COALESCE(quiz.name,&#039;&#039;), &lt;br /&gt;
COALESCE(cr.name,&#039;&#039;), &lt;br /&gt;
COALESCE(scorm.name,&#039;&#039;), &lt;br /&gt;
COALESCE(survey.name,&#039;&#039;), &lt;br /&gt;
COALESCE(url.name,&#039;&#039;), &lt;br /&gt;
COALESCE(wiki.name,&#039;&#039;), &lt;br /&gt;
COALESCE(workshop.name,&#039;&#039;), &lt;br /&gt;
COALESCE(kalvidassign.name,&#039;&#039;), &lt;br /&gt;
COALESCE(attendance.name,&#039;&#039;), &lt;br /&gt;
COALESCE(checklist.name,&#039;&#039;), &lt;br /&gt;
COALESCE(flashcard.name,&#039;&#039;), &lt;br /&gt;
COALESCE(lti.name,&#039;&#039;), &lt;br /&gt;
COALESCE(oublog.name,&#039;&#039;), &lt;br /&gt;
COALESCE(ouwiki.name,&#039;&#039;), &lt;br /&gt;
COALESCE(subpage.name,&#039;&#039;), &lt;br /&gt;
COALESCE(journal.name,&#039;&#039;), &lt;br /&gt;
COALESCE(lightboxgallery.name,&#039;&#039;), &lt;br /&gt;
COALESCE(elluminate.name,&#039;&#039;), &lt;br /&gt;
COALESCE(adaptivequiz.name,&#039;&#039;), &lt;br /&gt;
COALESCE(hotpot.name,&#039;&#039;), &lt;br /&gt;
COALESCE(wiziq.name,&#039;&#039;), &lt;br /&gt;
COALESCE(turnitintooltwo.name,&#039;&#039;), &lt;br /&gt;
COALESCE(kvr.name,&#039;&#039;)&lt;br /&gt;
) AS &#039;item name&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(l.crud IN (&#039;r&#039;),1,0)) AS &#039;total views&#039;&lt;br /&gt;
, SUM(IF(l.crud IN (&#039;c&#039;,&#039;u&#039;),1,0)) AS &#039;total submissions&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(l.crud IN (&#039;r&#039;),u.id,NULL)) AS &#039;count of students who viewed&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(l.crud IN (&#039;c&#039;,&#039;u&#039;),u.id,NULL)) AS &#039;count of students who submitted&#039;&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;
JOIN prefix_course_sections AS cs ON cs.course = c.id AND cs.section &amp;lt;= 14 #AND cs.section &amp;gt; 0&lt;br /&gt;
LEFT JOIN prefix_course_modules AS cm ON cm.course = c.id AND cm.section = cs.id&lt;br /&gt;
JOIN prefix_modules AS m ON m.id = cm.module AND m.name NOT LIKE &#039;label&#039;&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_assign AS a ON a.id = cm.instance AND m.name = &#039;assign&#039;&lt;br /&gt;
LEFT JOIN prefix_book AS b ON b.id = cm.instance AND m.name = &#039;book&#039;&lt;br /&gt;
LEFT JOIN prefix_certificate AS cert ON cert.id = cm.instance AND m.name = &#039;certificate&#039;&lt;br /&gt;
LEFT JOIN prefix_chat AS chat ON chat.id = cm.instance AND m.name = &#039;chat&#039;&lt;br /&gt;
LEFT JOIN prefix_choice AS choice ON choice.id = cm.instance AND m.name = &#039;choice&#039;&lt;br /&gt;
LEFT JOIN prefix_data AS data ON data.id = cm.instance AND m.name = &#039;data&#039;&lt;br /&gt;
LEFT JOIN prefix_feedback AS feedback ON feedback.id = cm.instance AND m.name = &#039;feedback&#039;&lt;br /&gt;
LEFT JOIN prefix_folder AS folder ON folder.id = cm.instance AND m.name = &#039;folder&#039;&lt;br /&gt;
LEFT JOIN prefix_forum AS forum ON forum.id = cm.instance AND m.name = &#039;forum&#039;&lt;br /&gt;
LEFT JOIN prefix_glossary AS glossary ON glossary.id = cm.instance AND m.name = &#039;glossary&#039;&lt;br /&gt;
LEFT JOIN prefix_imscp AS imscp ON imscp.id = cm.instance AND m.name = &#039;imscp&#039;&lt;br /&gt;
LEFT JOIN prefix_lesson AS lesson ON lesson.id = cm.instance AND m.name = &#039;lesson&#039;&lt;br /&gt;
LEFT JOIN prefix_page AS p ON p.id = cm.instance AND m.name = &#039;page&#039;&lt;br /&gt;
LEFT JOIN prefix_questionnaire AS questionnaire ON questionnaire.id = cm.instance AND m.name = &#039;questionnaire&#039;&lt;br /&gt;
LEFT JOIN prefix_quiz AS quiz ON quiz.id = cm.instance AND m.name = &#039;quiz&#039;&lt;br /&gt;
LEFT JOIN prefix_resource AS cr ON cr.id = cm.instance AND m.name = &#039;resource&#039;&lt;br /&gt;
LEFT JOIN prefix_scorm AS scorm ON scorm.id = cm.instance AND m.name = &#039;scorm&#039;&lt;br /&gt;
LEFT JOIN prefix_survey AS survey ON survey.id = cm.instance AND m.name = &#039;survey&#039;&lt;br /&gt;
LEFT JOIN prefix_url AS url ON url.id = cm.instance AND m.name = &#039;url&#039;&lt;br /&gt;
LEFT JOIN prefix_wiki AS wiki ON wiki.id = cm.instance AND m.name = &#039;wiki&#039;&lt;br /&gt;
LEFT JOIN prefix_workshop AS workshop ON workshop.id = cm.instance AND m.name = &#039;workshop&#039;&lt;br /&gt;
LEFT JOIN prefix_kalvidassign AS kalvidassign ON kalvidassign.id = cm.instance AND m.name = &#039;kalvidassign&#039;&lt;br /&gt;
LEFT JOIN prefix_kalvidres AS kvr ON kvr.id = cm.instance AND m.name = &#039;kalvidres&#039;&lt;br /&gt;
LEFT JOIN prefix_attendance AS attendance ON attendance.id = cm.instance AND m.name = &#039;attendance&#039;&lt;br /&gt;
LEFT JOIN prefix_checklist AS checklist ON checklist.id = cm.instance AND m.name = &#039;checklist&#039;&lt;br /&gt;
LEFT JOIN prefix_flashcard AS flashcard ON flashcard.id = cm.instance AND m.name = &#039;flashcard&#039;&lt;br /&gt;
LEFT JOIN prefix_lti AS lti ON lti.id = cm.instance AND m.name = &#039;lti&#039;&lt;br /&gt;
LEFT JOIN prefix_oublog AS oublog ON oublog.id = cm.instance AND m.name = &#039;oublog&#039;&lt;br /&gt;
LEFT JOIN prefix_ouwiki AS ouwiki ON ouwiki.id = cm.instance AND m.name = &#039;ouwiki&#039;&lt;br /&gt;
LEFT JOIN prefix_subpage AS subpage ON subpage.id = cm.instance AND m.name = &#039;subpage&#039;&lt;br /&gt;
LEFT JOIN prefix_journal AS journal ON journal.id = cm.instance AND m.name = &#039;journal&#039;&lt;br /&gt;
LEFT JOIN prefix_lightboxgallery AS lightboxgallery ON lightboxgallery.id = cm.instance AND m.name = &#039;lightboxgallery&#039;&lt;br /&gt;
LEFT JOIN prefix_elluminate AS elluminate ON elluminate.id = cm.instance AND m.name = &#039;elluminate&#039;&lt;br /&gt;
LEFT JOIN prefix_adaptivequiz AS adaptivequiz ON adaptivequiz.id = cm.instance AND m.name = &#039;adaptivequiz&#039;&lt;br /&gt;
LEFT JOIN prefix_hotpot AS hotpot ON hotpot.id = cm.instance AND m.name = &#039;hotpot&#039;&lt;br /&gt;
LEFT JOIN prefix_wiziq AS wiziq ON wiziq.id = cm.instance AND m.name = &#039;wiziq&#039;&lt;br /&gt;
LEFT JOIN prefix_turnitintooltwo AS turnitintooltwo ON turnitintooltwo.id = cm.instance AND m.name = &#039;turnitintooltwo&#039;&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_logstore_standard_log AS l ON l.userid = u.id AND l.courseid = c.id&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
WHERE ra.roleid =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
AND cs.visible = 1&lt;br /&gt;
AND cm.visible = 1&lt;br /&gt;
&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY cm.id&lt;br /&gt;
&lt;br /&gt;
ORDER BY cs.section&lt;br /&gt;
&amp;lt;/code&amp;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_logstore_standard_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME( l.`timecreated` ) BETWEEN  &#039;2018-10-01 00:00:00&#039; AND  &#039;2019-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 prefix_logstore_standard_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`timecreated`) BETWEEN &#039;2017-10-01 00:00:00&#039; AND &#039;2018-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 2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_logstore_standard_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`timecreated`) BETWEEN &#039;2017-10-01 00:00:00&#039; AND &#039;2018-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2017&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_logstore_standard_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`timecreated`) BETWEEN &#039;2018-10-01 00:00:00&#039; AND &#039;2019-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 2018&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_logstore_standard_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`timecreated`) BETWEEN &#039;2018-10-01 00:00:00&#039; AND &#039;2019-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2018&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_logstore_standard_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`timecreated`) BETWEEN &#039;2019-10-01 00:00:00&#039; AND &#039;2020-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 2019&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) &lt;br /&gt;
FROM prefix_logstore_standard_log AS l&lt;br /&gt;
WHERE (FROM_UNIXTIME(l.`timecreated`) BETWEEN &#039;2019-10-01 00:00:00&#039; AND &#039;2020-09-31 00:00:00&#039;)&lt;br /&gt;
AND l.module = m.name&lt;br /&gt;
) AS &amp;quot;Used 2019&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;
===Unique user sessions per day and month + graph===&lt;br /&gt;
The &amp;quot;graph&amp;quot; column is used when displaying a graph (which needs at least three columns to pick from)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(DISTINCT userid) AS &amp;quot;Unique User Logins&amp;quot;&lt;br /&gt;
,DATE_FORMAT(FROM_UNIXTIME(timecreated), &amp;quot;%y /%m / %d&amp;quot;) AS &amp;quot;Year / Month / Day&amp;quot;, &amp;quot;Graph&amp;quot; &lt;br /&gt;
FROM `mdl_logstore_standard_log` &lt;br /&gt;
WHERE action LIKE &#039;loggedin&#039;&lt;br /&gt;
#AND timecreated &amp;gt;  UNIX_TIMESTAMP(&#039;2015-01-01 00:00:00&#039;) # optional start date&lt;br /&gt;
#AND timecreated &amp;lt;= UNIX_TIMESTAMP(&#039;2015-01-31 23:59:00&#039;) # optional end date&lt;br /&gt;
GROUP BY MONTH(FROM_UNIXTIME(timecreated)), DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
ORDER BY MONTH(FROM_UNIXTIME(timecreated)), DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And...&lt;br /&gt;
&lt;br /&gt;
Counting user&#039;s global and unique hits per day + counting individual usage of specific activities and resources (on that day),&lt;br /&gt;
&lt;br /&gt;
And since I am using phpMyAdmin&#039;s &amp;quot;Display Graph&amp;quot; feature (at the bottom of the query&#039;s output page), I have scaled down the &amp;quot;User Hits&amp;quot; by 10 to fit the graph. that&#039;s it.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DATE_FORMAT(FROM_UNIXTIME(timecreated), &amp;quot;%y-%m-%d&amp;quot;) AS &amp;quot;Datez&amp;quot;&lt;br /&gt;
,COUNT(DISTINCT userid) AS &amp;quot;Unique Users&amp;quot;&lt;br /&gt;
,ROUND(COUNT(*)/10) &amp;quot;User Hits (K)&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_quiz&#039;,1,0)) &amp;quot;Quizzes&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_forum&#039; or component=&#039;mod_forumng&#039;,1,0)) &amp;quot;Forums&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_assign&#039;,1,0)) &amp;quot;Assignments&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_oublog&#039;,1,0)) &amp;quot;Blogs&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_resource&#039;,1,0)) &amp;quot;Files (Resource)&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_url&#039;,1,0)) &amp;quot;Links (Resource)&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_page&#039;,1,0)) &amp;quot;Pages (Resource)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM `mdl_logstore_standard_log` &lt;br /&gt;
WHERE 1=1&lt;br /&gt;
AND timecreated &amp;gt;  UNIX_TIMESTAMP(&#039;2015-03-01 00:00:00&#039;) # optional START DATE&lt;br /&gt;
AND timecreated &amp;lt;= UNIX_TIMESTAMP(&#039;2015-05-31 23:59:00&#039;) # optional END DATE&lt;br /&gt;
GROUP BY MONTH(FROM_UNIXTIME(timecreated)), DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
ORDER BY MONTH(FROM_UNIXTIME(timecreated)), DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===System wide, daily unique user hits for the last 7 days===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
  DATE_FORMAT(FROM_UNIXTIME(l.timecreated), &#039;%m%d&#039;) &#039;Day&#039;&lt;br /&gt;
  ,COUNT(DISTINCT l.userid) AS &#039;Distinct Users Hits&#039;&lt;br /&gt;
  ,COUNT( l.userid) AS &#039;Users Hits&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_logstore_standard_log AS l&lt;br /&gt;
WHERE l.courseid &amp;gt; 1&lt;br /&gt;
      AND FROM_UNIXTIME(l.timecreated) &amp;gt;= DATE_SUB(NOW(), INTERVAL 7 DAY)&lt;br /&gt;
GROUP BY DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===User detailed activity in course modules===&lt;br /&gt;
Considering only several modules: url, resource, forum, quiz, questionnaire.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.id, ra.roleid,&lt;br /&gt;
CONCAT(u.lastname, &#039; &#039;, u.firstname) AS &#039;Student&#039;&lt;br /&gt;
,COUNT(l.id) AS &#039;Actions&#039;&lt;br /&gt;
,l.component &amp;quot;Module type&amp;quot;&lt;br /&gt;
,l.objectid &amp;quot;Module ID&amp;quot;&lt;br /&gt;
,CASE &lt;br /&gt;
  WHEN l.component = &#039;mod_url&#039; THEN (SELECT u.name FROM prefix_url AS u WHERE u.id = l.objectid )&lt;br /&gt;
  WHEN l.component = &#039;mod_resource&#039; THEN (SELECT r.name FROM prefix_resource AS r WHERE r.id = l.objectid )&lt;br /&gt;
  WHEN l.component = &#039;mod_forum&#039; THEN (SELECT f.name FROM prefix_forum AS f WHERE f.id = l.objectid )&lt;br /&gt;
  WHEN l.component = &#039;mod_quiz&#039; THEN (SELECT q.name FROM prefix_quiz AS q WHERE q.id = l.objectid )&lt;br /&gt;
  WHEN l.component = &#039;mod_questionnaire&#039; THEN (SELECT q.name FROM prefix_questionnaire AS q WHERE q.id = l.objectid )&lt;br /&gt;
END AS &#039;Module name&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT GROUP_CONCAT(g.name) FROM prefix_groups AS g&lt;br /&gt;
JOIN prefix_groups_members AS m ON g.id = m.groupid WHERE g.courseid = l.courseid AND m.userid = u.id) &amp;quot;user_groups&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT s.name &lt;br /&gt;
  FROM prefix_course_modules AS cm &lt;br /&gt;
  JOIN prefix_course_sections AS s ON s.course = cm.course AND s.id = cm.section &lt;br /&gt;
  WHERE cm.id = l.contextinstanceid) AS &amp;quot;Section name&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_logstore_standard_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 ra.userid = l.userid &lt;br /&gt;
  AND ra.contextid = (SELECT id FROM prefix_context WHERE instanceid = l.courseid AND contextlevel = 50) &lt;br /&gt;
WHERE l.courseid = %%COURSEID%%&lt;br /&gt;
  AND l.component IN (&#039;mod_url&#039;, &#039;mod_resource&#039;, &#039;mod_forum&#039;, &#039;mod_quiz&#039;, &#039;mod_questionnaire&#039;) &lt;br /&gt;
  %%FILTER_STARTTIME:l.timecreated:&amp;gt;%% %%FILTER_ENDTIME:l.timecreated:&amp;lt;%%&lt;br /&gt;
 &lt;br /&gt;
GROUP BY u.id, l.component&lt;br /&gt;
ORDER BY u.lastname, u.firstname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===What teachers and courses considered active?===&lt;br /&gt;
This report display several calculations and parameters that help the Online academic training team find teachers that might need more support getting their courses more supporting of online learning pedagogical methodologies.  &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;,&lt;br /&gt;
			  course.id,&#039;&amp;quot;&amp;gt;&#039;,course.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course &lt;br /&gt;
&lt;br /&gt;
#,course.shortname&lt;br /&gt;
&lt;br /&gt;
,CASE &lt;br /&gt;
  WHEN course.fullname LIKE &#039;%2012%&#039; THEN &#039;2012&#039;&lt;br /&gt;
  WHEN course.fullname LIKE &#039;%2013%&#039; THEN &#039;2013&#039; &lt;br /&gt;
  WHEN course.fullname LIKE &#039;%2014%&#039; THEN &#039;2014&#039;&lt;br /&gt;
  WHEN course.fullname LIKE &#039;%2015%&#039; THEN &#039;2015&#039;&lt;br /&gt;
END AS Year&lt;br /&gt;
&lt;br /&gt;
,CASE &lt;br /&gt;
  WHEN course.fullname LIKE &#039;%semester a%&#039; THEN &#039;Spring semester&#039;&lt;br /&gt;
  WHEN course.fullname LIKE &#039;%semester b%&#039; THEN &#039;Fall semester&#039;&lt;br /&gt;
  WHEN course.fullname LIKE &#039;%semester s%&#039; THEN &#039;Summer semester&#039;&lt;br /&gt;
END AS Semester&lt;br /&gt;
&lt;br /&gt;
,IF(course.startdate&amp;gt;0, DATE_FORMAT(FROM_UNIXTIME(startdate), &#039;%d-%m-%Y&#039;), &#039;no date&#039;) AS &amp;quot;Course Start Date&amp;quot; &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 AND ctx.instanceid = course.id&lt;br /&gt;
) AS Students&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 = 4 AND ctx.instanceid = course.id&lt;br /&gt;
) AS &amp;quot;Assistant teacher&amp;quot;&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 = 3 AND ctx.instanceid = course.id&lt;br /&gt;
) AS Teachers&lt;br /&gt;
&lt;br /&gt;
# Uncomment to use the new Moodle 2.8+ logstore&lt;br /&gt;
#,(SELECT COUNT(*) FROM mdl_logstore_standard_log AS l WHERE l.courseid = course.id) AS Hits&lt;br /&gt;
&lt;br /&gt;
#,(SELECT COUNT(*)&lt;br /&gt;
#FROM mdl_logstore_standard_log AS l&lt;br /&gt;
#JOIN mdl_role_assignments AS ra ON ra.userid= l.userid AND ra.roleid = 5 AND ra.contextid = (SELECT id FROM mdl_context WHERE instanceid = l.courseid AND contextlevel = 50) &lt;br /&gt;
#WHERE l.courseid = course.id ) AS &amp;quot;Student HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#,(SELECT COUNT(*)&lt;br /&gt;
#FROM mdl_logstore_standard_log AS l&lt;br /&gt;
#JOIN mdl_role_assignments AS ra ON ra.userid= l.userid AND ra.roleid = 3 AND ra.contextid = (SELECT id FROM mdl_context WHERE instanceid = l.courseid AND contextlevel = 50) &lt;br /&gt;
#WHERE l.courseid = course.id ) AS &amp;quot;Teacher HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM mdl_log AS l WHERE l.course = course.id) AS Hits&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
JOIN mdl_context AS con ON con.instanceid= l.course AND con.contextlevel=50&lt;br /&gt;
JOIN mdl_role_assignments AS ra ON ra.contextid= con.id AND ra.userid= l.userid AND ra.roleid = 5 &lt;br /&gt;
WHERE l.course = course.id) AS &amp;quot;Students HITs&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
JOIN mdl_context AS con ON con.instanceid= l.course AND con.contextlevel=50&lt;br /&gt;
JOIN mdl_role_assignments AS ra ON ra.contextid= con.id AND ra.userid= l.userid AND ra.roleid = 3 &lt;br /&gt;
WHERE l.course = course.id) AS &amp;quot;Teachers HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT GROUP_CONCAT( CONCAT( u.firstname,  &amp;quot; &amp;quot;, u.lastname ) ) &lt;br /&gt;
FROM prefix_course c&lt;br /&gt;
JOIN prefix_context con ON con.instanceid = c.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 c.id = course.id&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
) AS Teachers&lt;br /&gt;
  &lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm WHERE cm.course = course.id) Modules&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(DISTINCT cm.module) FROM prefix_course_modules cm &lt;br /&gt;
  WHERE cm.course = course.id) UniqueModules&lt;br /&gt;
&lt;br /&gt;
,(SELECT GROUP_CONCAT(DISTINCT m.name) &lt;br /&gt;
  FROM prefix_course_modules cm &lt;br /&gt;
  JOIN mdl_modules as m ON m.id = cm.module&lt;br /&gt;
  WHERE cm.course = course.id) UniqueModuleNames&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM mdl_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN ( &#039;ouwiki&#039;, &#039;wiki&#039;) ) &amp;quot;Num Wikis&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM mdl_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN ( &#039;oublog&#039;) ) &amp;quot;Num Blogs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM mdl_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN ( &#039;forum&#039;, &#039;forumng&#039;) ) &amp;quot;Num Forums&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN (&#039;resource&#039;, &#039;folder&#039;, &#039;url&#039;, &#039;tab&#039;, &#039;file&#039;, &#039;book&#039;, &#039;page&#039;) ) Resources&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN (&#039;forum&#039;, &#039;forumng&#039;, &#039;oublog&#039;, &#039;page&#039;, &#039;file&#039;, &#039;url&#039;, &#039;wiki&#039; , &#039;ouwiki&#039;) ) &amp;quot;Basic Activities&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN (&#039;advmindmap&#039;, &#039;assign&#039;, &#039;attendance&#039;, &#039;book&#039;, &#039;choice&#039;, &#039;folder&#039;, &#039;tab&#039;, &#039;glossary&#039;, &#039;questionnaire&#039;, &#039;quiz&#039;, &#039;label&#039; ) ) &amp;quot;Avarage Activities&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN (&#039;elluminate&#039;, &#039;game&#039;, &#039;workshop&#039;) ) &amp;quot;Advanced Activities&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS course&lt;br /&gt;
&lt;br /&gt;
#WHERE course.shortname LIKE &#039;%2015%&#039;&lt;br /&gt;
#WHERE 1=1&lt;br /&gt;
#%%FILTER_SEARCHTEXT:course.shortname:~%%&lt;br /&gt;
&lt;br /&gt;
WHERE course.fullname LIKE &#039;%2015%&#039; &lt;br /&gt;
&lt;br /&gt;
HAVING Modules &amp;gt; 2&lt;br /&gt;
ORDER BY UniqueModules DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Weekly attendance report===&lt;br /&gt;
This report display weekly report in format HH:M:SS This MySQL query works together with AttendaceRegister module, and gather Log information from Attendanceregister_log table. &lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, SEC_TO_TIME (SUM(arsess.duration)) AS weekly_online_attendance,  FROM_UNIXTIME (arsess.logout) AS Last_Logout&lt;br /&gt;
FROM prefix_attendanceregister_session AS arsess&lt;br /&gt;
JOIN prefix_user AS u ON arsess.userid = u.id&lt;br /&gt;
&lt;br /&gt;
WHERE (((arsess.logout) BETWEEN UNIX_TIMESTAMP(DATE_SUB(CURDATE(), INTERVAL 7 DAY)) AND UNIX_TIMESTAMP(CURDATE())))&lt;br /&gt;
&lt;br /&gt;
GROUP BY arsess.userid&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===How many distinct users connected to Moodle using the app by month===&lt;br /&gt;
https://moodle.org/mod/forum/discuss.php?d=336086#p1354194 by &lt;br /&gt;
Iñigo Zendegi Urzelai&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
  to_char(to_timestamp(&amp;quot;timecreated&amp;quot;),&#039;YYYY&#039;) as year, &lt;br /&gt;
  to_char(to_timestamp(&amp;quot;timecreated&amp;quot;),&#039;MM&#039;) as month, &lt;br /&gt;
  count(distinct userid) as distinct_users&lt;br /&gt;
&lt;br /&gt;
FROM prefix_logstore_standard_log l&lt;br /&gt;
WHERE l.origin=&#039;ws&#039;&lt;br /&gt;
GROUP BY to_char(to_timestamp(&amp;quot;timecreated&amp;quot;),&#039;YYYY&#039;), to_char(to_timestamp(&amp;quot;timecreated&amp;quot;),&#039;MM&#039;) &lt;br /&gt;
ORDER BY to_char(to_timestamp(&amp;quot;timecreated&amp;quot;),&#039;YYYY&#039;), to_char(to_timestamp(&amp;quot;timecreated&amp;quot;),&#039;MM&#039;);&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.userid) AS Views&lt;br /&gt;
FROM `mdl_logstore_standard_log` l, `mdl_user` u, `mdl_role_assignments` r&lt;br /&gt;
WHERE l.courseid=35&lt;br /&gt;
AND l.userid = u.id&lt;br /&gt;
AND (l.timecreated &amp;gt; UNIX_TIMESTAMP(&#039;2015-01-01 00:00:00&#039;) AND l.timecreated &amp;lt;= UNIX_TIMESTAMP(&#039;2015-01-31 23:59:59&#039;))AND r.contextid= (&lt;br /&gt;
	 SELECT id&lt;br /&gt;
	 FROM mdl_context&lt;br /&gt;
	 WHERE contextlevel=50 AND instanceid=l.courseid&lt;br /&gt;
 )&lt;br /&gt;
AND r.roleid=5&lt;br /&gt;
AND r.userid = u.id&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;
#The following line restricts the courses returned to those having more than 2 modules.  Adjust based on your needs.&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;
=== Least active or probably empty courses===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
It is difficult to know sometimes when a course is actually empty or was never really in use. Other than the simple case where the course was created and never touched again, in which case the course timecreated and timemodified will be the same, many courses created as shells for teachers or other users may be used once or a few times and have few or no test users enrollments in them. This query helps you see the range of such courses, showing you how many days if any it was used after initial creation, and how many user are enrolled. It denotes a course never ever modified by &amp;quot;-1&amp;quot; instead of &amp;quot;0&amp;quot; so you can sort those to the top. By default it limits this to courses used within 60 days of creation, and to courses with 3 or less enrollments (for example, teacher and assistant and test student account only.) You can easily adjust these numbers. The query includes a link to the course as well. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
c.fullname,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;,CHAR(63),&#039;id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.shortname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;CourseLink&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(c.timecreated), &#039;%Y-%m-%d %H:%i&#039;) AS &#039;Timecreated&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(c.timemodified), &#039;%Y-%m-%d %H:%i&#039;) AS &#039;Timemodified&#039;,&lt;br /&gt;
CASE&lt;br /&gt;
 WHEN c.timecreated = c.timemodified THEN &#039;-1&#039;&lt;br /&gt;
 ELSE DATEDIFF(FROM_UNIXTIME(c.timemodified),FROM_UNIXTIME(c.timecreated))&lt;br /&gt;
END AS &#039;DateDifference&#039;,&lt;br /&gt;
COUNT(ue.id) AS Enroled&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_enrol AS en ON en.courseid = c.id&lt;br /&gt;
LEFT JOIN prefix_user_enrolments AS ue ON ue.enrolid = en.id&lt;br /&gt;
WHERE DATEDIFF(FROM_UNIXTIME(c.timemodified),FROM_UNIXTIME(c.timecreated) ) &amp;lt; 60&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
HAVING COUNT(ue.id) &amp;lt;= 3&lt;br /&gt;
ORDER BY c.fullname&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
===Users enrolled in a course with groups but not assigned a group ===&lt;br /&gt;
&lt;br /&gt;
Displays by course all enrolled users that have not been assigned a group in courses that have groups. NOTE: This needs to be optimized.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DISTINCT&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;
JOIN prefix_groups AS g ON g.courseid = course.id&lt;br /&gt;
&lt;br /&gt;
WHERE ue.enrolid NOT IN (select userid from prefix_groups_members WHERE g.id=groupid)&lt;br /&gt;
&lt;br /&gt;
ORDER BY Course, Lastname&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
Note: if you are using Configurable Reports block and want to perform this query on the current course you are in, then you can use a WHERE clause like this:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
WHERE c.id = %%COURSEID%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Group Export===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
Note: if you are using Configurable Reports block and want to perform this query on the current course you are in, then you can use a WHERE clause like this:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
WHERE c.id = %%COURSEID%%&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;
===All users enrolled in a course without a role===&lt;br /&gt;
Identifies All users that are enrolled in a course but are not assigned a role.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
user.firstname AS Firstname,&lt;br /&gt;
user.lastname AS Lastname,&lt;br /&gt;
user.idnumber Employee_ID,&lt;br /&gt;
course.fullname AS Course&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 user ON user.id = ue.userid&lt;br /&gt;
&lt;br /&gt;
WHERE user.id NOT IN (&lt;br /&gt;
SELECT u.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_role AS r ON r.id = ra.roleid&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE c.id=course.id&lt;br /&gt;
)&lt;br /&gt;
ORDER BY Course, Lastname, Firstname&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List course resources accumulative file size and count===&lt;br /&gt;
This is the main (first) report, which has a link (alias) to a second report (the following on this page) which list each file in the course.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.id &amp;quot;CourseID&amp;quot;, context.id &amp;quot;ContextID&amp;quot;&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 &amp;quot;Course Name&amp;quot;&lt;br /&gt;
, COUNT(*) &amp;quot;Course Files&amp;quot; , ROUND( SUM( f.filesize ) /1048576 ) AS file_size_MB&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/blocks/configurable_reports/viewreport.php?alias=coursefiles&amp;amp;courseid=1&amp;amp;filter_courses=&#039;, c.id, &#039;&amp;quot;&amp;gt;List files&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;List Files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_files AS f&lt;br /&gt;
JOIN mdl_context AS context ON context.id = f.contextid&lt;br /&gt;
JOIN mdl_course AS c ON c.id = (&lt;br /&gt;
  SELECT instanceid&lt;br /&gt;
  FROM mdl_context&lt;br /&gt;
  WHERE id = SUBSTRING_INDEX( SUBSTRING_INDEX( context.path, &#039;/&#039; , -2 ) , &#039;/&#039;, 1 ) )&lt;br /&gt;
WHERE filesize &amp;gt;0&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this report, you will have to define &amp;quot;alias&amp;quot; report property to &amp;quot;coursefiles&amp;quot; for it to be able to be called from the above report.&lt;br /&gt;
And also setup (add) a FILTER_COURSES filter. &lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
id ,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/pluginfile.php/&#039;, contextid, &#039;/&#039;, component, &#039;/&#039;, filearea, &#039;/&#039;, itemid, &#039;/&#039;, filename, &#039;&amp;quot;&amp;gt;&#039;, filename,&#039;&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;File&amp;quot;&lt;br /&gt;
,filesize, mimetype ,author, license, timecreated, component, filearea, filepath&lt;br /&gt;
&lt;br /&gt;
FROM mdl_files AS f&lt;br /&gt;
WHERE filesize &amp;gt;0&lt;br /&gt;
            AND f.contextid&lt;br /&gt;
            IN (   SELECT id&lt;br /&gt;
                     FROM mdl_context&lt;br /&gt;
                    WHERE path &lt;br /&gt;
                     LIKE (   SELECT CONCAT(&#039;%/&#039;,id,&#039;/%&#039;)&lt;br /&gt;
                                  AS contextquery&lt;br /&gt;
                                FROM mdl_context&lt;br /&gt;
                               WHERE 1=1&lt;br /&gt;
			        %%FILTER_COURSES:instanceid%%&lt;br /&gt;
                                 AND contextlevel = 50&lt;br /&gt;
                           )&lt;br /&gt;
                )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Which courses has redundant topics===&lt;br /&gt;
This report list several &amp;quot;active topics&amp;quot; calculations, per course. which should give an administrator some indications for which topics/sections/weeks are filled with resources and activities and which ones are empty and not used (usually, at the end of the course).&lt;br /&gt;
&lt;br /&gt;
The following, second SQL query, could be used to &amp;quot;trim&amp;quot; down those redundant course topics/sections/weeks by updating the course format&#039;s numsection (Number of sections) setting. (It&#039;s a per course format setting!)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT id, format,&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 value  FROM  `mdl_course_format_options` WHERE  `courseid` = c.id AND `format` = c.format AND `name` = &#039;numsections&#039; ) AS &amp;quot;numsections&amp;quot;&lt;br /&gt;
,(SELECT COUNT(*) FROM  `mdl_course_sections` WHERE  `course` = c.id AND `sequence` !=  &#039;&#039; ) AS &amp;quot;Non empty sections count&amp;quot;&lt;br /&gt;
,(SELECT COUNT(*) FROM  `mdl_course_sections` WHERE  `course` = c.id ) AS &amp;quot;Total section count&amp;quot;&lt;br /&gt;
,(SELECT COUNT(*) FROM  `mdl_course_sections` WHERE  `course` = c.id AND sequence IS NOT NULL) AS &amp;quot;Non NULL sections count&amp;quot;&lt;br /&gt;
,(SELECT COUNT(*) FROM  `mdl_course_sections` WHERE  `course` = c.id AND name != &#039;&#039;) AS &amp;quot;Non empty section Name count&amp;quot;&lt;br /&gt;
 ,(SELECT COUNT(*) FROM mdl_course_modules cm WHERE cm.course = c.id) &amp;quot;Modules count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_course AS c&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following SQL REPLACE query is used for &amp;quot;fixing&amp;quot; (updating) the &amp;quot;numsections&amp;quot; of a specific course format &amp;quot;onetopics&amp;quot; (you can always change it, or discard it to use this SQL REPLACE on all course formats) &lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
REPLACE INTO `mdl_course_format_options` (`id`, `courseid`, `format`, `sectionid`, `name`, `value`) &lt;br /&gt;
SELECT NULL, c.id, &#039;onetopic&#039;, &#039;0&#039;, &#039;numsections&#039;, (SELECT COUNT(*) FROM `mdl_course_sections` WHERE `course` = c.id AND name != &#039;&#039;)&lt;br /&gt;
FROM `mdl_course` c where format = &#039;onetopic&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Hidden Courses with Students Enrolled===&lt;br /&gt;
Contributed by Eric Strom&lt;br /&gt;
&lt;br /&gt;
This query identifies courses with student enrollment that are currently hidden from students. Includes the defined course start date, count of students and instructors, and a clickable email link of instructor (first found record if more than one).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.visible AS Visible, &lt;br /&gt;
DATE(FROM_UNIXTIME(c.startdate)) AS StartDate, &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;,CHAR(63),&#039;id=&#039;,&lt;br /&gt;
c.id,&#039;&amp;quot;&amp;gt;&#039;,c.idnumber,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course_ID,&lt;br /&gt;
&lt;br /&gt;
(SELECT COUNT( ra.userid ) 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( ra.userid ) 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 Instructors,&lt;br /&gt;
&lt;br /&gt;
(SELECT DISTINCT concat(&#039;&amp;lt;a href=&amp;quot;mailto:&#039;,u.email,&#039;&amp;quot;&amp;gt;&#039;,u.email,&#039;&amp;lt;/a&amp;gt;&#039;)&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 &#039;Instructor_Email&#039;, &lt;br /&gt;
&lt;br /&gt;
now() AS Report_Timestamp&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c &lt;br /&gt;
WHERE c.visible = 0 AND (SELECT COUNT( ra.userid ) FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid = 5 AND ctx.instanceid = c.id) &amp;gt; 0&lt;br /&gt;
ORDER BY StartDate, Instructor_Email, Course_ID&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Course Design Reports==&lt;br /&gt;
&lt;br /&gt;
These are reports which summarize course design aspects, such as activity and resource modules per section, types of activities used, etc.&lt;br /&gt;
&lt;br /&gt;
===Course Content/Week===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
This report assumes that the first 14 sections in a course, not including the &amp;quot;0&amp;quot; or &amp;quot;Welcome&amp;quot; section, correspond to weeks (with &amp;quot;Subsections&amp;quot; given numbers much higher in the sequence). Of those sections, each is checked to count the number of:&lt;br /&gt;
&lt;br /&gt;
    Forums&lt;br /&gt;
    Graded Activities (may include Forums)&lt;br /&gt;
    Resources (not including a Label)&lt;br /&gt;
&lt;br /&gt;
Totals of each of these types of content elements per section are provided.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Only visible resources and activities are counted.&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: this is a &amp;quot;Global&amp;quot; report. Run it within a course to see a summary of the contents of that course.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
 &lt;br /&gt;
cs.section AS &#039;Week&#039;&lt;br /&gt;
, cs.name AS &#039;Section Name&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF((gi.id IS NULL) AND (m.name NOT LIKE &#039;label&#039;),cm.id,NULL)) AS &#039;Ungraded Resources&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(m.name LIKE &#039;forum&#039;, cm.id, NULL)) AS &#039;Forums&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(gi.id, cm.id, NULL)) AS &#039;Graded Activities&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_course_sections AS cs ON cs.course = c.id AND cs.section &amp;lt;= 14 AND cs.section &amp;gt; 0&lt;br /&gt;
LEFT JOIN prefix_course_modules AS cm ON cm.course = c.id AND cm.section = cs.id &lt;br /&gt;
JOIN prefix_modules AS m ON m.id = cm.module&lt;br /&gt;
LEFT JOIN prefix_grade_items AS gi ON gi.courseid = c.id AND gi.itemmodule = m.name AND gi.iteminstance = cm.instance&lt;br /&gt;
&lt;br /&gt;
WHERE &lt;br /&gt;
cs.visible = 1&lt;br /&gt;
AND cm.visible = 1&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY cs.section&lt;br /&gt;
ORDER BY cs.section&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Assignments and Weights===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Returns a list of grade book categories for the current course, grade book weightings, the first type of assignment included in the category, a count of different assignment types for each category, and a count of assignments for each category.&lt;br /&gt;
&lt;br /&gt;
Categories with weights of 0 are not included in this report.&lt;br /&gt;
&lt;br /&gt;
Only visible activities are included in this report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This is designed to be a &amp;quot;Global&amp;quot; report in Configurable Reports.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
&lt;br /&gt;
IF(gc.parent IS NOT NULL, gc.fullname, &#039;None&#039;) AS &#039;Grade Book Category&#039;&lt;br /&gt;
, IF(gc.parent IS NOT NULL, ROUND(gic.aggregationcoef, 2), ROUND(SUM(DISTINCT gi.aggregationcoef), 2)+ROUND(SUM(DISTINCT mgi.aggregationcoef), 2)) AS &#039;Category weight&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT_WS(&#039;, &#039;,GROUP_CONCAT(DISTINCT gi.itemmodule SEPARATOR &#039;, &#039;), IF(mgi.id, &#039;manual&#039;,NULL)) AS &#039;Activity Types&#039;&lt;br /&gt;
, COUNT(DISTINCT gi.itemmodule) + IF(mgi.id,1,0) AS &#039;Different Activity Types&#039;&lt;br /&gt;
, CONCAT_WS(&#039;&amp;lt;br&amp;gt;&#039;, GROUP_CONCAT(DISTINCT gi.itemname ORDER BY gi.itemname SEPARATOR &#039;&amp;lt;br&amp;gt;&#039;), GROUP_CONCAT(DISTINCT mgi.itemname ORDER BY mgi.itemname SEPARATOR &#039;&amp;lt;br&amp;gt;&#039;)) AS &#039;Activity Names&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(gi.id, cm.id, NULL)) + COUNT(DISTINCT mgi.id) AS &#039;Activity Count&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
&lt;br /&gt;
#get grade categories&lt;br /&gt;
LEFT JOIN prefix_grade_categories AS gc ON gc.courseid = c.id &lt;br /&gt;
# back from categories to grade items to get aggregations and weights&lt;br /&gt;
JOIN prefix_grade_items AS gic ON gic.courseid = c.id AND gic.itemtype = &#039;category&#039; AND gic.aggregationcoef != 0 AND (LOCATE(gic.iteminstance, gc.path) OR (gc.parent IS NULL))&lt;br /&gt;
&lt;br /&gt;
# attach activities to course&lt;br /&gt;
JOIN prefix_course_modules AS cm ON cm.course = c.id &lt;br /&gt;
# attach grade items to activities&lt;br /&gt;
LEFT JOIN prefix_grade_items AS gi ON gi.courseid = c.id AND gi.iteminstance = cm.instance AND gi.itemtype = &#039;mod&#039; AND gi.categoryid = gc.id AND gi.hidden != 1&lt;br /&gt;
&lt;br /&gt;
# attach manual grade items to course-- they don&#039;t have modules&lt;br /&gt;
LEFT JOIN prefix_grade_items AS mgi ON mgi.courseid = c.id and mgi.itemtype = &#039;manual&#039; AND mgi.categoryid = gc.id&lt;br /&gt;
&lt;br /&gt;
WHERE &lt;br /&gt;
cm.visible = 1&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY gc.id&lt;br /&gt;
ORDER BY gc.id&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pre-Term Course Review===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Provides an overview of the readiness of ONLINE, HYBRID, and BLENDED courses in the Staging category and all subcategories. Links to each course are provided. Other details:&lt;br /&gt;
&lt;br /&gt;
#   &amp;quot;Required blocks&amp;quot; include Instructor Block (mooprofile), Activities, and the Research block.&lt;br /&gt;
#    &amp;quot;Instructor Details&amp;quot; block is not the &amp;quot;Instructor&amp;quot; block (mooprofile) automatically provided by the system. It is an optional block that can be edited by the instructor. If not edited to remove boilerplate text, it should be hidden.&lt;br /&gt;
#    All courses should be in the &amp;quot;Collapsed Topics&amp;quot; format with the &amp;quot;Weeks&amp;quot; structure.&lt;br /&gt;
#    &amp;quot;Weeks defined in course settings&amp;quot; is taken from our SIS when the course shells are created, but can be edited by faculty. &amp;quot;# of weeks named and visible&amp;quot; should usually match or exceed this value.&lt;br /&gt;
#    We recommend that each week contain at least one forum, at least one graded activity, and at least one ungraded resource.&lt;br /&gt;
#    &amp;quot;Syllabus updated&amp;quot; date is for the first attached file found with the text &amp;quot;syllabus&amp;quot; in the name. The &amp;quot;Days ago&amp;quot; calculation is included for convenience.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: At our institution, we construct categories each term, and insert a text string &amp;quot;staging&amp;quot; in the Category ID for pre-term courses during the preparation or &amp;quot;staging&amp;quot; phase of course development. We remove this text string (and change it to &amp;quot;production&amp;quot;) when courses go live at the start of the new term.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;,CHAR(63),&#039;id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.shortname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
&lt;br /&gt;
#,RIGHT(c.idnumber,2) AS Type # Specific to GSC &amp;quot;Instructional Method&amp;quot; storage&lt;br /&gt;
&lt;br /&gt;
#, substring_index(substr(c.shortname FROM locate(&#039;.&#039;,c.shortname)+1),&#039;-&#039;,1) AS Section # Specific to GSC&lt;br /&gt;
 &lt;br /&gt;
,(SELECT CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/user/view.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;quot;&amp;gt;&#039;,u.lastname,&#039;, &#039;, u.firstname,&#039;&amp;lt;/a&amp;gt;&#039;)&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 &#039;Instructor&#039; &lt;br /&gt;
&lt;br /&gt;
,(SELECT IF((u2.description IS NULL) OR (u2.description LIKE &#039;&#039;),&#039;NO&#039;, &#039;YES&#039;)&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 u2 ON u2.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS &#039;Profile Has Bio&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT IF(u3.picture &amp;gt; 0,&#039;YES&#039;,&#039;NO&#039;)&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 u3 ON u3.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS &#039;Profile Has Picture&#039;&lt;br /&gt;
&lt;br /&gt;
, IF(((bpi.visible IS NULL) OR (bpi.visible !=0)) AND ((bpm.visible IS NULL) OR (bpm.visible !=0)) AND ((bpa.visible IS NULL) OR (bpa.visible !=0)) AND ((bpr.visible IS NULL) OR (bpr.visible !=0)),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Required blocks visible&#039;&lt;br /&gt;
#, IF((bpm.visible IS NULL) OR (bpm.visible !=0),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Messages block visible&#039;&lt;br /&gt;
#, IF((bpa.visible IS NULL) OR (bpa.visible !=0),&#039;YES&#039;,&#039;NO&#039;) AS &#039;activities block visible&#039;&lt;br /&gt;
#, IF((bpr.visible IS NULL) OR (bpr.visible !=0),&#039;YES&#039;,&#039;NO&#039;) AS &#039;research block visible&#039;&lt;br /&gt;
&lt;br /&gt;
#, IF(SUM(IF(bi.configdata LIKE &#039;Tzo4OiJzdGRDbGFzcyI6Mzp7czo1OiJ0aXRsZSI7czoxODoiSW5zdHJ1Y3RvciBEZXRhaWxzI%&#039;,1,0)) AND (bip.visible !=0),&#039;YES&#039;,&#039;&#039;) AS &#039;Instructor Details Block visible&#039; # This is a hack based on UUencoded string data from the title of HTML &amp;quot;Instructor Details&amp;quot; block&lt;br /&gt;
&lt;br /&gt;
#, IF(bi.configdata LIKE &#039;%ZGl0IHRoaXMgYmxvY2s%&#039;,&#039;NO&#039;,&#039;&#039;) AS &#039;Instructor Details Block Updated&#039; # HTML block has string &#039;dit this block&#039;&lt;br /&gt;
&lt;br /&gt;
#, IF(COUNT(bi.id) -  SUM(IF(bi.configdata LIKE &#039;Tzo4OiJzdGRDbGFzcyI6Mzp7czo1OiJ0aXRsZSI7czoxODoiSW5zdHJ1Y3RvciBEZXRhaWxzI%&#039;,1,0)),&#039;YES&#039;,&#039;&#039;) AS &#039;possible extra instructor blocks&#039; #looking for any HTML block with &amp;quot;instructor&amp;quot; in the title&lt;br /&gt;
&lt;br /&gt;
, IF(c.format=&#039;topcoll&#039;,&#039;YES&#039;, c.format) AS &#039;Collapsed Topics course format&#039; # change this if you want to test for a different format&lt;br /&gt;
, IF(cfo.value = 2, &#039;YES&#039;,&#039;NO&#039;) AS &#039;weeks structure&#039;&lt;br /&gt;
&lt;br /&gt;
, cfw.value AS &#039;weeks defined in course settings&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(((cs.name IS NOT NULL) AND (cs.visible = 1) AND (cs.section != &#039;0&#039;) AND (cs.sequence IS NOT NULL)),cs.id,NULL)) AS &#039;# of weeks named &amp;amp; visible (includes orphans)&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(m.name LIKE &#039;forum&#039;, cm.id, NULL)) AS &#039;Forums&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(m.name LIKE &#039;forum&#039; ,cs.id , NULL)) AS &#039;Weeks with Forum&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(gi.id, cm.id, NULL)) AS &#039;Activities&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(gi.id, cs.id, NULL)) AS &#039;Weeks with Activities&#039;&lt;br /&gt;
, COUNT(DISTINCT mgi.id) AS &#039;Manual Grade Items&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF((gi.id IS NULL) AND (m.name NOT IN (&#039;forum&#039;,&#039;label&#039;)),cm.id,NULL)) AS &#039;Resources&#039;&lt;br /&gt;
, COUNT(DISTINCT IF((gi.id IS NULL) AND (m.name NOT IN (&#039;forum&#039;,&#039;label&#039;)), cs.id, NULL)) AS &#039;Weeks with Resources&#039;&lt;br /&gt;
&lt;br /&gt;
# Here are some other things you could check for per course&lt;br /&gt;
#,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id 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 JOIN prefix_modules AS m ON cm.module = m.id WHERE cm.course = c.id AND m.name LIKE &#039;%quiz%&#039;) AS Quizzes&lt;br /&gt;
 &lt;br /&gt;
#,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id WHERE cm.course = c.id AND m.name LIKE &#039;%assign%&#039;) AS Assignments&lt;br /&gt;
&lt;br /&gt;
#,(SELECT COUNT(prefix_resource.id) FROM prefix_resource JOIN prefix_course ON prefix_course.id = prefix_resource.course WHERE c.id = prefix_resource.course) AS Files&lt;br /&gt;
&lt;br /&gt;
#,(SELECT COUNT(prefix_url.id) FROM prefix_url JOIN prefix_course ON prefix_course.id = prefix_url.course WHERE c.id = prefix_url.course) AS Links&lt;br /&gt;
&lt;br /&gt;
,(SELECT FROM_UNIXTIME(MAX(prefix_resource.timemodified))&lt;br /&gt;
FROM prefix_resource&lt;br /&gt;
JOIN prefix_course ON prefix_course.id = prefix_resource.course WHERE c.id = prefix_resource.course AND prefix_resource.name LIKE &#039;%syllabus%&#039;) AS SyllabusDate&lt;br /&gt;
&lt;br /&gt;
,(SELECT TO_DAYS(NOW())-TO_DAYS(FROM_UNIXTIME(MAX(prefix_resource.timemodified)))&lt;br /&gt;
FROM prefix_resource&lt;br /&gt;
JOIN prefix_course ON prefix_course.id = prefix_resource.course WHERE c.id = prefix_resource.course AND prefix_resource.name LIKE &#039;%syllabus%&#039;) AS DaysAgo&lt;br /&gt;
&lt;br /&gt;
, IF(COUNT(DISTINCT IF(f.type LIKE &#039;news&#039;, f.id,NULL)),&#039;YES&#039;,&#039;NO&#039; ) AS &#039;Announcement Forum Visible&#039;&lt;br /&gt;
&lt;br /&gt;
, IF(COUNT(DISTINCT IF(f.type LIKE &#039;news&#039;, fd.id,NULL)),&#039;YES&#039;,&#039;NO&#039; ) AS &#039;Announcement posted&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
LEFT JOIN prefix_course_categories as cc ON c.category = cc.id&lt;br /&gt;
LEFT JOIN prefix_context AS ctxx ON c.id = ctxx.instanceid &lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bpi ON bpi.contextid = ctxx.id AND bpi.blockinstanceid = &#039;43692&#039; # mooprofile&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bpm ON bpm.contextid = ctxx.id AND bpm.blockinstanceid = &#039;43962&#039; # messages&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bpa ON bpa.contextid = ctxx.id AND bpa.blockinstanceid = &#039;43963&#039; # activities&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bpr ON bpr.contextid = ctxx.id AND bpr.blockinstanceid = &#039;38368&#039; # html research help&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_course_sections AS cs ON cs.course = c.id AND cs.visible = 1 AND cs.sequence IS NOT NULL&lt;br /&gt;
LEFT JOIN prefix_course_modules AS cm ON cm.course = c.id AND cm.section = cs.id &lt;br /&gt;
LEFT JOIN prefix_modules AS m ON m.id = cm.module&lt;br /&gt;
LEFT JOIN prefix_grade_items AS gi ON gi.courseid = c.id AND gi.itemmodule = m.name AND gi.iteminstance = cm.instance&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_forum AS f ON f.course = c.id AND cm.instance = f.id AND cm.visible = 1&lt;br /&gt;
LEFT JOIN prefix_forum_discussions AS fd ON fd.forum = f.id&lt;br /&gt;
&lt;br /&gt;
# attach manual grade items to course-- they don&#039;t have modules&lt;br /&gt;
LEFT JOIN prefix_grade_items AS mgi ON mgi.courseid = c.id and mgi.itemtype = &#039;manual&#039;&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_course_format_options AS cfo ON cfo.courseid = c.id AND cfo.name = &#039;layoutstructure&#039;&lt;br /&gt;
LEFT JOIN prefix_course_format_options AS cfw ON cfw.courseid = c.id AND cfw.name = &#039;numsections&#039;&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_block_instances AS bi ON bi.parentcontextid = ctxx.id AND bi.blockname = &#039;html&#039; AND (bi.configdata LIKE &#039;%SW5zdHJ1Y3Rvc%&#039; or bi.configdata LIKE &#039;%bnN0cnVjdG9y%&#039;)&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bip ON bip.blockinstanceid = bi.id&lt;br /&gt;
&lt;br /&gt;
WHERE RIGHT(c.idnumber,2) IN (&#039;OL&#039;, &#039;BL&#039;, &#039;HY&#039;) &lt;br /&gt;
# AND substring(cc.path,2,2) IN (&#039;26&#039;) # Staging&lt;br /&gt;
#AND substring(cc.path,2,3) IN (&#039;158&#039;) # UG&lt;br /&gt;
AND cc.idnumber LIKE &#039;%staging%&#039;&lt;br /&gt;
AND ctxx.contextlevel = 50&lt;br /&gt;
&lt;br /&gt;
GROUP BY c.shortname&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;
===Course Syllabus===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College / Moodle HQ&lt;br /&gt;
&lt;br /&gt;
This report requires ELIS. It runs from within a course and constructs a course syllabus based on content in the course and in the ELIS entries related to the course (Class Instance, Course Description, and Program). It is a proof-of-concept of an automated syllabus production tool. Fields such as &amp;quot;Course Policies&amp;quot; and &amp;quot;Teaching Philosophy&amp;quot; are added to the Class Instance records, and instructors enter them there. The Instructor Bio is pulled from the User Profile of all users with the Teacher role in the course.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
c.fullname AS &#039;fullname&#039;&lt;br /&gt;
, ec.idnumber AS &#039;elis-id&#039;&lt;br /&gt;
, DATE_FORMAT(FROM_UNIXTIME(ec.startdate), &#039;%b %e, %Y&#039;) AS &#039;start&#039;&lt;br /&gt;
, DATE_FORMAT(FROM_UNIXTIME(ec.enddate), &#039;%b %e, %Y&#039;) AS &#039;end&#039;&lt;br /&gt;
, ecd.name AS &#039;longname&#039;&lt;br /&gt;
, ecd.code AS &#039;coursecode&#039;&lt;br /&gt;
, ecd.credits AS &#039;coursecredits&#039;&lt;br /&gt;
, ecd.syllabus AS &#039;description&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;learning-outcomes&#039;&lt;br /&gt;
WHERE ctxecd.id = eft.contextid) AS &#039;outcomes&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/user/view.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;quot;&amp;gt;&#039;,u.firstname,&#039; &#039;, u.lastname,&#039;&amp;lt;/a&amp;gt; &#039;, u.email)&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 &#039;Instructor&#039; &lt;br /&gt;
&lt;br /&gt;
, (SELECT  efc.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_char AS efc&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = efc.fieldid AND ef.shortname = &#039;term-code&#039;&lt;br /&gt;
WHERE ctxci.id = efc.contextid) AS &#039;termcode&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;prerequisites&#039;&lt;br /&gt;
WHERE ctxecd.id = eft.contextid) AS &#039;prerequisites&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;textbooks&#039;&lt;br /&gt;
WHERE ctxci.id = eft.contextid) AS &#039;textbooks&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;other-class-materials&#039;&lt;br /&gt;
WHERE ctxci.id = eft.contextid) AS &#039;other-class-materials&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;course-policies&#039;&lt;br /&gt;
WHERE ctxci.id = eft.contextid) AS &#039;course-policies&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;teaching-philosophy&#039;&lt;br /&gt;
WHERE ctxci.id = eft.contextid) AS &#039;teaching-philosophy&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;course-methods&#039;&lt;br /&gt;
WHERE ctxci.id = eft.contextid) AS &#039;course-methods&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT u2.description&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 u2 ON u2.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS &#039;Bio&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT&lt;br /&gt;
&lt;br /&gt;
GROUP_CONCAT(DISTINCT CONCAT(&lt;br /&gt;
&lt;br /&gt;
&#039;&amp;lt;tr&amp;gt;&amp;lt;td style=&amp;quot;border: solid #000 .5px&amp;quot;&amp;gt;&#039;,IF(gc.parent IS NOT NULL, gc.fullname, &#039;None&#039;)&lt;br /&gt;
, &#039; &amp;lt;/td&amp;gt;&amp;lt;td style=&amp;quot;border: solid #000 .5px&amp;quot;&amp;gt; &#039;&lt;br /&gt;
,IF(gc.parent IS NOT NULL, ROUND(gic.aggregationcoef, 2), ROUND( gi.aggregationcoef, 2)+ROUND(mgi.aggregationcoef, 2))&lt;br /&gt;
&lt;br /&gt;
) SEPARATOR &#039;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&#039;)&lt;br /&gt;
#get grade categories&lt;br /&gt;
FROM prefix_grade_categories AS gc &lt;br /&gt;
# back from categories to grade items to get aggregations and weights&lt;br /&gt;
LEFT JOIN prefix_grade_items AS gic ON gic.courseid = gc.courseid AND gic.itemtype = &#039;category&#039; AND gic.aggregationcoef != 0 AND (LOCATE(gic.iteminstance, gc.path) OR (gc.parent IS NULL))&lt;br /&gt;
# attach grade items to activities&lt;br /&gt;
LEFT JOIN prefix_grade_items AS gi ON gi.courseid = gc.courseid  AND gi.itemtype = &#039;mod&#039; AND gi.categoryid = gc.id AND gi.hidden != 1&lt;br /&gt;
# attach manual grade items to course-- they don&#039;t have modules&lt;br /&gt;
LEFT JOIN prefix_grade_items AS mgi ON mgi.courseid = gc.courseid and mgi.itemtype = &#039;manual&#039; AND mgi.categoryid = gc.id&lt;br /&gt;
WHERE gc.courseid = c.id  ) AS &#039;grade categories&#039;&lt;br /&gt;
&lt;br /&gt;
, &#039;&amp;lt;table width = &amp;quot;50%&amp;quot; &amp;gt;&#039; AS &#039;table start&#039;&lt;br /&gt;
, &#039;&amp;lt;table width = &amp;quot;100%&amp;quot; &amp;gt;&#039; AS &#039;table start 2&#039;&lt;br /&gt;
, &#039;&amp;lt;/table&amp;gt;&#039; AS &#039;table end&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;activities-schedule&#039;&lt;br /&gt;
WHERE ctxci.id = eft.contextid) AS &#039;activities&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;schedule&#039;&lt;br /&gt;
WHERE ctxci.id = eft.contextid) AS &#039;schedule&#039;&lt;br /&gt;
&lt;br /&gt;
, (SELECT  eft.data&lt;br /&gt;
FROM prefix_local_eliscore_fld_data_text AS eft&lt;br /&gt;
JOIN prefix_local_eliscore_field AS ef ON ef.id = eft.fieldid AND ef.shortname = &#039;grading-scale&#039;&lt;br /&gt;
WHERE ctxepm.id = eft.contextid) AS &#039;gradescale&#039;&lt;br /&gt;
&lt;br /&gt;
FROM&lt;br /&gt;
prefix_course AS c &lt;br /&gt;
&lt;br /&gt;
# connect moodle course to ELIS class instance&lt;br /&gt;
LEFT JOIN prefix_local_elisprogram_cls_mdl AS ecm ON ecm.moodlecourseid = c.id&lt;br /&gt;
LEFT JOIN prefix_local_elisprogram_cls AS ec ON ec.id = ecm.classid&lt;br /&gt;
# class instance context&lt;br /&gt;
LEFT JOIN prefix_context AS ctxci ON ctxci.instanceid = ec.id AND ctxci.contextlevel = &#039;14&#039;&lt;br /&gt;
&lt;br /&gt;
# connect ELIS class instance to ELIS course description&lt;br /&gt;
LEFT JOIN prefix_local_elisprogram_crs AS ecd ON ecd.id = ec.courseid&lt;br /&gt;
# course description context&lt;br /&gt;
LEFT JOIN prefix_context AS ctxecd ON ctxecd.instanceid = ecd.id AND ctxecd.contextlevel = &#039;13&#039;&lt;br /&gt;
&lt;br /&gt;
#connect ELIS program to ELIS Course Description&lt;br /&gt;
LEFT JOIN prefix_local_elisprogram_pgm_crs AS epc ON epc.courseid = ecd.id&lt;br /&gt;
LEFT JOIN prefix_local_elisprogram_pgm AS epm ON epm.id = epc.curriculumid&lt;br /&gt;
# course program context&lt;br /&gt;
LEFT JOIN prefix_context AS ctxepm ON ctxepm.instanceid = epm.id AND ctxepm.contextlevel = &#039;11&#039;&lt;br /&gt;
&lt;br /&gt;
WHERE&lt;br /&gt;
&lt;br /&gt;
c.id = %%COURSEID%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Course Activities Helper===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
This report provides a list of the graded activities in a course.&lt;br /&gt;
* &#039;&#039;&#039;Note&#039;&#039;&#039;: Only graded activities are displayed.&lt;br /&gt;
* &#039;&#039;&#039;Note&#039;&#039;&#039;: This is a &amp;quot;Global&amp;quot; report. Run it within a course to see a summary of the contents of that course.&lt;br /&gt;
* &#039;&#039;&#039;Note&#039;&#039;&#039;: This report assumes that course sections each last one week.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
# 303 Course Activities Helper&lt;br /&gt;
&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
gi.itemmodule AS &#039;activity type&#039;&lt;br /&gt;
# cs.section AS &#039;section number&#039;&lt;br /&gt;
&lt;br /&gt;
# Calculation assumes each section lasts one week&lt;br /&gt;
, CONCAT(DATE_FORMAT(FROM_UNIXTIME(c.startdate + (7*24*60*60* (cs.section-1))), &#039;%b %e, %Y&#039;),&#039; - &amp;lt;br&amp;gt;&#039;,DATE_FORMAT(FROM_UNIXTIME(c.startdate + (7*24*60*60* (cs.section))), &#039;%b %e, %Y&#039;)) AS &#039;Date&#039;&lt;br /&gt;
&lt;br /&gt;
, gi.itemname AS &#039;activity name&#039;&lt;br /&gt;
&lt;br /&gt;
#, (SELECT asg.intro FROM prefix_assign AS asg WHERE asg.id = cm.instance) AS &#039;intro&#039;&lt;br /&gt;
&lt;br /&gt;
#, (SELECT f.intro FROM prefix_forum AS f WHERE f.id = cm.instance) AS &#039;f intro&#039;&lt;br /&gt;
&lt;br /&gt;
, CASE gi.itemmodule &lt;br /&gt;
WHEN &#039;assign&#039; THEN (SELECT asg.intro FROM prefix_assign AS asg WHERE asg.id = gi.iteminstance) &lt;br /&gt;
WHEN &#039;forum&#039; THEN (SELECT f.intro FROM prefix_forum AS f WHERE f.id = gi.iteminstance) &lt;br /&gt;
WHEN &#039;quiz&#039; THEN (SELECT q.intro FROM prefix_quiz AS q WHERE q.id = gi.iteminstance) &lt;br /&gt;
END AS &#039;test case&#039;&lt;br /&gt;
&lt;br /&gt;
#, (SELECT GROUP_CONCAT(CONCAT(&#039; - &#039;,gi.itemname) SEPARATOR &#039;&amp;lt;BR&amp;gt;&#039;) FROM  prefix_grade_items AS gi  JOIN prefix_course_modules AS cm ON  gi.iteminstance = cm.instance WHERE gi.gradetype = 1 AND gi.hidden != 1 AND gi.courseid = c.id AND cm.course = c.id AND cm.section = cs.id ) AS &#039;activities&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
FROM&lt;br /&gt;
prefix_course AS c &lt;br /&gt;
&lt;br /&gt;
#get grade sections&lt;br /&gt;
LEFT JOIN prefix_course_sections AS cs ON cs.course = c.id  AND cs.section &amp;gt; 0 AND cs.section &amp;lt;=14&lt;br /&gt;
LEFT JOIN prefix_course_modules AS cm ON cm.course = c.id AND cm.section = cs.id&lt;br /&gt;
&lt;br /&gt;
#LEFT JOIN prefix_assign AS asg ON asg.id = cm.instance&lt;br /&gt;
&lt;br /&gt;
JOIN prefix_grade_items AS gi  ON  gi.iteminstance = cm.instance AND gi.gradetype = 1 AND gi.hidden != 1 AND gi.courseid = c.id AND cm.course = c.id AND cm.section = cs.id&lt;br /&gt;
&lt;br /&gt;
WHERE&lt;br /&gt;
c.id = %%COURSEID%%&lt;br /&gt;
AND cs.visible = 1&lt;br /&gt;
&lt;br /&gt;
ORDER BY gi.itemmodule, cs.section&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;, &lt;br /&gt;
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,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 &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,gg.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;
FROM_UNIXTIME(gg.timemodified) AS Time&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
And:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
u.firstname + &#039; &#039; + u.lastname AS &#039;Display Name&#039;, &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
with:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
CONCAT(u.firstname,&#039; &#039;,u.lastname) AS &#039;Display Name&#039;, &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 AND gi.itemtype = &#039;course&#039;&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
A very simple report with a 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 &lt;br /&gt;
  u.username, &lt;br /&gt;
  c.shortname,  &lt;br /&gt;
 DATE_FORMAT(FROM_UNIXTIME(p.timecompleted),&#039;%Y-%m-%d&#039;) 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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
&lt;br /&gt;
===Extra Credit Items by Name Only===&lt;br /&gt;
Contributed by Eric Strom&lt;br /&gt;
&lt;br /&gt;
This query identifies grade items in visible courses with student enrollment that have &amp;quot;extra credit&amp;quot; in the name of the item but set as extra credit in the grade settings. Includes the defined course start date, count of students and instructors, and a clickable email link of instructor (first found record if more than one).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DATE(FROM_UNIXTIME(c.startdate)) AS StartDate, &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/grade/edit/tree/index.php&#039;,CHAR(63),&#039;id=&#039;,&lt;br /&gt;
c.id,&#039;&amp;quot;&amp;gt;&#039;,c.idnumber,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course_ID, gi.itemname AS Item_Name&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT( ra.userid ) 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( ra.userid ) 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 Instructors&lt;br /&gt;
&lt;br /&gt;
,(SELECT DISTINCT concat(&#039;&amp;lt;a href=&amp;quot;mailto:&#039;,u.email,&#039;&amp;quot;&amp;gt;&#039;,u.email,&#039;&amp;lt;/a&amp;gt;&#039;)&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 &#039;Instructor_Email&#039;&lt;br /&gt;
&lt;br /&gt;
,now() AS Report_Timestamp&lt;br /&gt;
&lt;br /&gt;
FROM prefix_grade_items AS gi&lt;br /&gt;
JOIN prefix_course AS c ON gi.courseid = c.id&lt;br /&gt;
&lt;br /&gt;
WHERE gi.itemname LIKE &#039;%extra credit%&#039; &lt;br /&gt;
	AND gi.gradetype = &#039;1&#039; &lt;br /&gt;
	AND gi.hidden = &#039;0&#039; &lt;br /&gt;
	AND gi.aggregationcoef = &#039;0&#039; &lt;br /&gt;
	AND c.visible = 1&lt;br /&gt;
	AND (SELECT COUNT( ra.userid ) FROM prefix_role_assignments AS ra JOIN prefix_context AS ctx ON ra.contextid = ctx.id WHERE ra.roleid = 5 AND ctx.instanceid = c.id) &amp;gt; 0&lt;br /&gt;
&lt;br /&gt;
GROUP BY Course_ID, gi.id&lt;br /&gt;
ORDER BY StartDate, Course_ID&lt;br /&gt;
 &lt;br /&gt;
%%FILTER_SEARCHTEXT:Course_ID:~%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Site Wide Number of Courses Completed by User===&lt;br /&gt;
Contributed by Ken St. John&lt;br /&gt;
&lt;br /&gt;
Simple report that shows the number of completed courses for all users site wide&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.lastname, u.firstname,&lt;br /&gt;
COUNT(p.timecompleted) AS TotalCompletions&lt;br /&gt;
FROM prefix_course_completions AS p&lt;br /&gt;
JOIN prefix_user AS u ON p.userid = u.id&lt;br /&gt;
GROUP BY p.userid&lt;br /&gt;
ORDER BY u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Activity Module Reports==&lt;br /&gt;
&lt;br /&gt;
=== User activity completions with dates===&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
This report shows the users completion status of activities across all courses. It is intended to be uses with Configurable Reports filters for user, start and end times, and also to be able to search the Module names. &lt;br /&gt;
&lt;br /&gt;
Note: The CASE statement with module numbers may differ on different systems, depending on the number give to the module when the site was created or the module added to the site. These are common default numbers, but you should check your id numbers for them in the course_modules table and adjust as required. You can also add other, third-party plugins too if you wish. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
u.username As &#039;User&#039;,&lt;br /&gt;
c.shortname AS &#039;Course&#039;,&lt;br /&gt;
m.name AS Activitytype, &lt;br /&gt;
CASE &lt;br /&gt;
    WHEN cm.module = 1 THEN (SELECT a1.name FROM prefix_assign a1            WHERE a1.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 2 THEN (SELECT a2.name FROM prefix_assignment a2    WHERE a2.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 3 THEN (SELECT a3.name FROM prefix_book a3               WHERE a3.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 4 THEN (SELECT a4.name FROM prefix_chat a4                WHERE a4.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 5 THEN (SELECT a5.name FROM prefix_choice a5            WHERE a5.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 6 THEN (SELECT a6.name FROM prefix_data a6                WHERE a6.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 7 THEN (SELECT a7.name FROM prefix_feedback a7        WHERE a7.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 8 THEN (SELECT a8.name FROM prefix_folder a8              WHERE a8.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 9 THEN (SELECT a9.name FROM prefix_forum a9              WHERE a9.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 10 THEN (SELECT a10.name FROM prefix_glossary a10         WHERE a10.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 11 THEN (SELECT a11.name FROM prefix_imscp  a11           WHERE a11.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 12 THEN (SELECT a12.name FROM prefix_label a12              WHERE a12.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 13 THEN (SELECT a13.name FROM prefix_lesson a13            WHERE a13.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 14 THEN (SELECT a14.name FROM prefix_lti a14                    WHERE a14.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 15 THEN (SELECT a15.name FROM prefix_page a15               WHERE a15.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 16 THEN (SELECT a16.name FROM prefix_quiz  a16               WHERE a16.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 17 THEN (SELECT a17.name FROM prefix_resource a17         WHERE a17.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 18 THEN (SELECT a18.name FROM prefix_scorm a18             WHERE a18.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 19 THEN (SELECT a19.name FROM prefix_survey a19             WHERE a19.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 20 THEN (SELECT a20.name FROM prefix_url a20                      WHERE a20.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 21 THEN (SELECT a21.name FROM prefix_wiki a21                    WHERE a21.id = cm.instance)&lt;br /&gt;
    WHEN cm.module = 22 THEN (SELECT a22.name FROM prefix_workshop a22           WHERE a22.id = cm.instance)&lt;br /&gt;
END AS Actvityname,&lt;br /&gt;
# cm.section AS Coursesection,&lt;br /&gt;
CASE&lt;br /&gt;
    WHEN cm.completion = 0 THEN &#039;0 None&#039;&lt;br /&gt;
    WHEN cm.completion = 1 THEN &#039;1 Self&#039;&lt;br /&gt;
    WHEN cm.completion = 2 THEN &#039;2 Auto&#039;&lt;br /&gt;
END AS Activtycompletiontype, &lt;br /&gt;
CASE&lt;br /&gt;
   WHEN cmc.completionstate = 0 THEN &#039;In Progress&#039;&lt;br /&gt;
   WHEN cmc.completionstate = 1 THEN &#039;Completed&#039;&lt;br /&gt;
   WHEN cmc.completionstate = 2 THEN &#039;Completed with Pass&#039;&lt;br /&gt;
   WHEN cmc.completionstate = 3 THEN &#039;Completed with Fail&#039;&lt;br /&gt;
   ELSE &#039;Unknown&#039;&lt;br /&gt;
END AS &#039;Progress&#039;, &lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(cmc.timemodified), &#039;%Y-%m-%d %H:%i&#039;) AS &#039;When&#039;&lt;br /&gt;
FROM prefix_course_modules_completion cmc &lt;br /&gt;
JOIN prefix_user u ON cmc.userid = u.id&lt;br /&gt;
JOIN prefix_course_modules cm ON cmc.coursemoduleid = cm.id&lt;br /&gt;
JOIN prefix_course c ON cm.course = c.id&lt;br /&gt;
JOIN prefix_modules m ON cm.module = m.id&lt;br /&gt;
# skip the predefined admin and guest user&lt;br /&gt;
WHERE u.id &amp;gt; 2&lt;br /&gt;
# config reports filters&lt;br /&gt;
%%FILTER_USERS:u.username%%&lt;br /&gt;
%%FILTER_SEARCHTEXT:m.name:~%%&lt;br /&gt;
%%FILTER_STARTTIME:cmc.timemodified:&amp;gt;%% %%FILTER_ENDTIME:cmc.timemodified:&amp;lt;%%&lt;br /&gt;
&lt;br /&gt;
ORDER BY u.username&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&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;
===SCORM Usage by Course Start Date===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College &lt;br /&gt;
&lt;br /&gt;
Report of number of inclusions of SCORM activities in courses, filtered by course start date.&lt;br /&gt;
&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;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;,CHAR(63),&#039;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;
&lt;br /&gt;
, cc.name AS &#039;Category&#039;&lt;br /&gt;
, scm.name AS &#039;Sample Activity Name&#039;&lt;br /&gt;
, FROM_UNIXTIME(c.startdate) AS &#039;Course Start Date&#039;&lt;br /&gt;
, COUNT(DISTINCT cm.id) AS &#039;Resources Used&#039;&lt;br /&gt;
#, FROM_UNIXTIME(cm.added) AS &#039;resource added&#039;&lt;br /&gt;
&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 AND m.name LIKE &#039;SCO%&#039;&lt;br /&gt;
&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
JOIN prefix_scorm AS scm ON scm.id = cm.instance&lt;br /&gt;
&lt;br /&gt;
WHERE&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
%%FILTER_STARTTIME:c.startdate:&amp;gt;%%&lt;br /&gt;
%%FILTER_ENDTIME:c.startdate:&amp;lt;%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY c.shortname, m.name&lt;br /&gt;
ORDER BY c.startdate, c.shortname &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== LTI (External Tool) Usage by Course Start Date===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College &lt;br /&gt;
&lt;br /&gt;
Report of number of inclusions of  LTI (External Tool) Usage activities in courses, filtered by course start date.&lt;br /&gt;
&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;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;,CHAR(63),&#039;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;
&lt;br /&gt;
, cc.name AS &#039;Category&#039;&lt;br /&gt;
, lti.name AS &#039;Sample Activity Name&#039;&lt;br /&gt;
, FROM_UNIXTIME(c.startdate) AS &#039;Course Start Date&#039;&lt;br /&gt;
, COUNT(DISTINCT cm.id) AS &#039;Resources Used&#039;&lt;br /&gt;
#, FROM_UNIXTIME(cm.added) AS &#039;resource added&#039;&lt;br /&gt;
&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 AND m.name LIKE &#039;lti&#039;&lt;br /&gt;
&lt;br /&gt;
JOIN prefix_course AS c ON c.id = cm.course&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
JOIN prefix_lti AS lti ON lti.id = cm.instance&lt;br /&gt;
WHERE&lt;br /&gt;
1&lt;br /&gt;
&lt;br /&gt;
%%FILTER_STARTTIME:c.startdate:&amp;gt;%%&lt;br /&gt;
%%FILTER_ENDTIME:c.startdate:&amp;lt;%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY c.shortname, m.name&lt;br /&gt;
ORDER BY c.startdate, c.shortname &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;
&lt;br /&gt;
=== All Simple Certificates Earned in the Site===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
Basic report of all certificates earned with the Simple Certificate plugin module in the whole site, sorted by most recent first. (Note: this uses the MySQL [http://www.mysqltutorial.org/mysql-date_format/ DATE_FORMAT] function.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
CONCAT (u.firstname, &#039; &#039;,u.lastname) As &#039;User&#039;,&lt;br /&gt;
c.fullname AS &#039;Course&#039;,&lt;br /&gt;
sc.name AS &#039;Certificate&#039;,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME(sci.timecreated), &#039;%Y-%m-%d&#039; ) As &#039;Date Awarded&#039;&lt;br /&gt;
# sci.code &#039;CertificateId&#039;&lt;br /&gt;
FROM prefix_simplecertificate_issues sci&lt;br /&gt;
JOIN prefix_user u ON sci.userid = u.id&lt;br /&gt;
JOIN prefix_simplecertificate sc ON sci.certificateid = sc.id&lt;br /&gt;
JOIN prefix_course AS c ON sc.course = c.id&lt;br /&gt;
ORDER BY sci.timecreated DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to limit this to the most recent ones, you can add a condition to limit it to a certain number of days past. For example, adding this WHERE clause (above the ORDER BY) will show only those earned in the last 30 days:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
WHERE DATEDIFF(NOW(),FROM_UNIXTIME(sci.timecreated) ) &amp;lt; 30&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This query is for the deprecated old Assignment module from Moodle 2.2, not the new Assignments module. Please update this query if you are the author or it will be removed as the 2.2 Assignment module is no longer supported since release 2.7.&lt;br /&gt;
&#039;&#039;&#039; See: [https://docs.moodle.org/dev/Moodle_2.7_release_notes#Assignment]&lt;br /&gt;
&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;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This query is for the deprecated old Assignment module from Moodle 2.2, not the new Assignments module. Please update this query if you are the author or it will be removed as the 2.2 Assignment module is no longer supported since release 2.7.&lt;br /&gt;
&#039;&#039;&#039; See: [https://docs.moodle.org/dev/Moodle_2.7_release_notes#Assignment]&lt;br /&gt;
&lt;br /&gt;
&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;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: This query is for the deprecated old Assignment module from Moodle 2.2, not the new Assignments module. Please update this query if you are the author or it will be removed as the 2.2 Assignment module is no longer supported since release 2.7.&lt;br /&gt;
&#039;&#039;&#039; See: [https://docs.moodle.org/dev/Moodle_2.7_release_notes#Assignment]&lt;br /&gt;
&lt;br /&gt;
&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;
===Rubrics without zero values in criteria===&lt;br /&gt;
Contributed by Eric Strom&lt;br /&gt;
&lt;br /&gt;
Rubric calculations in Moodle can fail to align with instructors expectations if they lack a zero value for each criterion used in the assessment. From documentation at https://docs.moodle.org/32/en/Rubrics#Grade_calculation:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;For example, when the teacher in the previous example chose both levels with 1 point, the plain sum would be 2 points. But that is actually the lowest possible score so it maps to the grade 0 in Moodle.&lt;br /&gt;
TIP: To avoid confusion from this sort of thing, we recommend including a level with 0 points in every rubric criterion.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This report identifies rubrics having criteria without a zero value level and the courses they live in. This also refines to only assignments with active rubrics that are visible to students in the course. Links to the each rubric id is the direct link to edit the rubric. Fix by adding a zero level for each criteria that is missing it. In general, the grading changes that result will be in the students&#039; favor.&lt;br /&gt;
&lt;br /&gt;
Includes search filter of course idnumber.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT cat.name AS Department, concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;,CHAR(63),&#039;id=&#039;,&lt;br /&gt;
c.id,&#039;&amp;quot;&amp;gt;&#039;,c.idnumber,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course_ID, &lt;br /&gt;
c.fullname AS Course_Name, &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/grade/grading/form/rubric/edit.php&#039;,CHAR(63),&#039;areaid=&#039;,gd.areaid,&#039;&amp;quot;&amp;gt;&#039;,gd.areaid,&#039;&amp;lt;/a&amp;gt;&#039;) AS Rubric&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_course_categories AS cat &lt;br /&gt;
ON cat.id = c.category&lt;br /&gt;
JOIN prefix_course_modules AS cm &lt;br /&gt;
ON c.id=cm.course&lt;br /&gt;
JOIN prefix_context AS ctx &lt;br /&gt;
ON cm.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_grading_areas AS garea &lt;br /&gt;
ON ctx.id = garea.contextid&lt;br /&gt;
JOIN prefix_grading_definitions AS gd &lt;br /&gt;
ON garea.id = gd.areaid&lt;br /&gt;
JOIN prefix_gradingform_rubric_criteria AS crit &lt;br /&gt;
ON gd.id = crit.definitionid&lt;br /&gt;
JOIN prefix_gradingform_rubric_levels AS levels &lt;br /&gt;
ON levels.criterionid = crit.id&lt;br /&gt;
WHERE cm.visible=&#039;1&#039; AND garea.activemethod = &#039;rubric&#039; AND (crit.id NOT IN&lt;br /&gt;
(SELECT crit.id&lt;br /&gt;
FROM prefix_gradingform_rubric_criteria AS crit&lt;br /&gt;
JOIN prefix_gradingform_rubric_levels AS levels &lt;br /&gt;
ON levels.criterionid = crit.id WHERE levels.score = &#039;0&#039;))&lt;br /&gt;
&lt;br /&gt;
GROUP BY Rubric&lt;br /&gt;
ORDER BY Course_ID, Rubric&lt;br /&gt;
&lt;br /&gt;
%%FILTER_SEARCHTEXT:c.idnumber:~%%&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;
==Feedback Module Reports==&lt;br /&gt;
===List the answers to all the Feedback activities within the current course, submitted by the current user===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT /* crs.fullname as &amp;quot;Course name&amp;quot;, f.name AS &amp;quot;Journal name&amp;quot;, CONCAT(u.firstname,&#039; &#039;,UPPER(u.lastname)) as &amp;quot;Participant&amp;quot;, */ /* include these fields if you want to check the composition of the recordset */&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(c.timemodified),&#039;%W %e %M, %Y&#039;) as &amp;quot;Answer Date&amp;quot;,&lt;br /&gt;
CASE i.typ WHEN &#039;label&#039; THEN i.presentation ELSE i.name END as &amp;quot;Topic&amp;quot;,  /* usually labels are used as section titles, so you&#039;d want them present in the recordset */&lt;br /&gt;
v.value as &amp;quot;My Answer&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_feedback AS f&lt;br /&gt;
INNER JOIN prefix_course as crs on crs.id=f.course %%FILTER_COURSES:f.course%% &lt;br /&gt;
INNER JOIN prefix_feedback_item AS i ON f.id=i.feedback&lt;br /&gt;
INNER JOIN prefix_feedback_completed AS c on f.id=c.feedback %%FILTER_COURSEUSER:c.userid%% &lt;br /&gt;
LEFT JOIN prefix_feedback_value AS v on v.completed=c.id AND v.item=i.id&lt;br /&gt;
INNER JOIN prefix_user AS u on c.userid=u.id&lt;br /&gt;
&lt;br /&gt;
WHERE c.id = %%COURSEID%% AND u.id = %%USERID%%  AND c.anonymous_response = 1  /* This clause limits the recordset to the current course and the current user and includes/ excludes the anonymous responses as needed */&lt;br /&gt;
&lt;br /&gt;
ORDER BY f.id, c.timemodified, i.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Show all Feedbacks from all courses for all users including showing names of anonymous users===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
Shows all Feedbacks in all Courses with all multi-choice questions and answers of all users including showing the username of anonymous users. Also shows tryly anonymous users on the front page as &#039;Not-logged-in&#039; users. This is a rough report, not a pretty report, and is limited to multiple-choice type questions, but is shows the answer number and the list of possible answers in raw form. I post it here as a basis for further reports, and also as away to get the identities of anonymous users if needed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
c.shortname AS Course, &lt;br /&gt;
f.name AS Feedback,&lt;br /&gt;
# i.id AS Itemid,&lt;br /&gt;
i.name AS Itemname,&lt;br /&gt;
i.label AS Itemlabel,&lt;br /&gt;
CASE &lt;br /&gt;
 WHEN f.anonymous = 1 AND u.id != 0 THEN CONCAT(u.username, &#039; :ANON&#039;)&lt;br /&gt;
 WHEN fc.userid = 0 THEN &#039;Not-logged-in&#039;&lt;br /&gt;
 ELSE u.username&lt;br /&gt;
END AS &#039;User&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(fc.timemodified),&#039;%Y-%m-%d %H:%i&#039;) AS &amp;quot;Completed&amp;quot;,&lt;br /&gt;
v.value AS &amp;quot;Choice&amp;quot;,&lt;br /&gt;
CASE &lt;br /&gt;
 WHEN i.typ = &#039;multichoice&#039; THEN&lt;br /&gt;
     IF (  SUBSTRING(i.presentation,1,6)=&#039;d&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&#039;,&lt;br /&gt;
	       SUBSTRING(i.presentation,7),&lt;br /&gt;
		   i.presentation)&lt;br /&gt;
 ELSE i.presentation&lt;br /&gt;
END AS &amp;quot;Answers&amp;quot;,&lt;br /&gt;
i.typ,&lt;br /&gt;
i.dependitem,&lt;br /&gt;
i.dependvalue&lt;br /&gt;
&lt;br /&gt;
FROM prefix_feedback f&lt;br /&gt;
JOIN prefix_course c ON c.id=f.course &lt;br /&gt;
JOIN prefix_feedback_item AS i ON f.id=i.feedback&lt;br /&gt;
JOIN prefix_feedback_completed fc ON f.id=fc.feedback&lt;br /&gt;
LEFT JOIN prefix_feedback_value v ON v.completed=fc.id AND v.item=i.id&lt;br /&gt;
LEFT JOIN prefix_user AS u ON fc.userid=u.id&lt;br /&gt;
WHERE i.typ != &#039;pagebreak&#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;
===Delete all the automated backup files===&lt;br /&gt;
Prepare bash cli script to delete all the automated backup files on the file system. (clean up some disk space)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT CONCAT( &#039;rm -f /var/moodledatanew/filedir/&#039;, SUBSTRING( contenthash, 1, 2 ) , &#039;/&#039;, SUBSTRING( contenthash, 3, 2 ) , &#039;/&#039;, contenthash ) &lt;br /&gt;
FROM `mdl_files` &lt;br /&gt;
WHERE `filename` LIKE &#039;%mbz%&#039;&lt;br /&gt;
AND filearea = &#039;automated&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find out how much disk space is used by all automated backup files:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT SUM(filesize)/(1024*1024*1024) FROM `mdl_files` WHERE  `filename` LIKE &#039;%mbz%&#039; AND filearea =  &#039;automated&#039;&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 = %%COURSEID%% &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;
&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;
&lt;br /&gt;
(Number of forums that have been posted by teacher/Google translator)&lt;br /&gt;
&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;
&lt;br /&gt;
(We wanted to know what the teacher&#039;s actions are in the forums of each course, so this report was made. /Google translator)&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;
&lt;br /&gt;
===List all the Posts in all the Forums that got high rating===&lt;br /&gt;
We setup a scale that let teachers and students Rate forum post with &amp;quot;Important, interesting, valuable, not rated&amp;quot; scale&lt;br /&gt;
And then add a link to the following report at the begining of the course &amp;quot;Link to all interesting posts&amp;quot;&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/view.php?f=&#039;,f.id,&#039;&amp;quot;&amp;gt;&#039;,f.name,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Forum name,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/discuss.php?d=&#039;,fd.id,&#039;#p&#039;,fp.id,&#039;&amp;quot;&amp;gt;&#039;,fp.subject,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Post link&#039;,&lt;br /&gt;
SUM(r.rating) AS &#039;Rating&#039;&lt;br /&gt;
FROM mdl_rating AS r&lt;br /&gt;
  JOIN mdl_forum_posts AS fp ON fp.id = r.itemid&lt;br /&gt;
  JOIN mdl_forum_discussions AS fd ON fd.id = fp.discussion&lt;br /&gt;
  JOIN mdl_forum AS f ON f.id = fd.forum&lt;br /&gt;
WHERE r.component = &#039;mod_forum&#039; AND r.ratingarea = &#039;post&#039; AND f.course = %%COURSEID%%&lt;br /&gt;
GROUP BY r.itemid&lt;br /&gt;
ORDER BY SUM(r.rating) DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List all the Posts in all Discussions of a single Forum===&lt;br /&gt;
This report is used to help export all the student&#039;s posts and discussions of a single forum, by passing the context module id as a parameter to the report using &amp;quot;&amp;amp;filter_var=cmid&amp;quot;&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/view.php?f=&#039;, f.id, &#039;&amp;quot;&amp;gt;&#039;, f.name, &#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Forum name&#039;,&lt;br /&gt;
fd.name AS &#039;Discussion&#039;, &lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/forum/discuss.php?d=&#039;, fd.id, &#039;#p&#039;, fp.id, &#039;&amp;quot;&amp;gt;&#039;, fp.subject, &#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Post (link)&#039;,&lt;br /&gt;
fp.message&lt;br /&gt;
&lt;br /&gt;
FROM mdl_forum_posts AS fp &lt;br /&gt;
  JOIN mdl_forum_discussions AS fd ON fd.id = fp.discussion&lt;br /&gt;
  JOIN mdl_forum AS f ON f.id = fd.forum&lt;br /&gt;
  JOIN mdl_course_modules AS cm ON cm.module = 9 AND cm.instance = f.id&lt;br /&gt;
WHERE cm.id = %%FILTER_VAR%%&lt;br /&gt;
ORDER BY f.id, fd.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;
Note: this query does not work in Moodle 2.8+. There is no mdl_quiz.questions field. It will need to be rewritten to use the usage/contextid organization.&lt;br /&gt;
&lt;br /&gt;
Here is a version for Moodle 3.x&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT cm.id &#039;cmid&#039;, quiz.id &#039;quiz id&#039;&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/quiz/edit.php?cmid=&#039;, &lt;br /&gt;
	   cm.id, &#039;&amp;quot;&amp;gt;&#039;, quiz.name, &#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;edit quiz&#039;&lt;br /&gt;
,q.id &#039;qid&#039;, q.name &#039;question name&#039;&lt;br /&gt;
FROM mdl_quiz AS quiz&lt;br /&gt;
JOIN mdl_course_modules cm ON cm.instance = quiz.id AND cm.module = 33 # 33=quiz mdl_modules&lt;br /&gt;
JOIN mdl_quiz_slots qs ON qs.quizid = quiz.id &lt;br /&gt;
JOIN mdl_question AS q ON q.id = qs.questionid&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;
===Quiz activity research===&lt;br /&gt;
This report was made to extract student full activity in quizzes for an academic research about adapting instructional design teaching methods in online learning. The students do not use the Quiz module as a standard quiz but more as Study booklets or mini courses with embedded questions and hints to assist students evaluate their progress (Similar to what you expect to find in a SCORM activity)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
cm.course &amp;quot;course_id&amp;quot;, cm.id &amp;quot;moduel_id&amp;quot;, q.id &amp;quot;quiz_id&amp;quot;, q.name &amp;quot;quiz_name&amp;quot;,&lt;br /&gt;
 &lt;br /&gt;
CASE q.grademethod&lt;br /&gt;
      WHEN 1 THEN &amp;quot;GRADEHIGHEST&amp;quot;&lt;br /&gt;
      WHEN 2 THEN &amp;quot;GRADEAVERAGE&amp;quot;&lt;br /&gt;
      WHEN 3 THEN &amp;quot;ATTEMPTFIRST&amp;quot;&lt;br /&gt;
      WHEN 4 THEN &amp;quot;ATTEMPTLAST&amp;quot;&lt;br /&gt;
END &amp;quot;grade method&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
, q.attempts &amp;quot;quiz_attempts_allowed&amp;quot;, cm.groupmode &amp;quot;group_mode&amp;quot;&lt;br /&gt;
, qa.id &amp;quot;attempt_id&amp;quot;, qa.state &amp;quot;attempt_state&amp;quot;, qa.sumgrades &amp;quot;attempt_grade&amp;quot;, qg.grade &amp;quot;user_final_grade&amp;quot;, q.grade &amp;quot;quiz_max_grade&amp;quot;&lt;br /&gt;
,(SELECT GROUP_CONCAT(g.name) FROM mdl_groups AS g&lt;br /&gt;
JOIN mdl_groups_members AS m ON g.id = m.groupid WHERE g.courseid = q.course AND m.userid = u.id) &amp;quot;user_groups&amp;quot;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(qa.timestart), &#039;%d-%m-%Y %h:%k&#039;) &amp;quot;attempt_start&amp;quot;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(qa.timefinish), &#039;%d-%m-%Y %h:%k&#039;) &amp;quot;attempt_finish&amp;quot;,&lt;br /&gt;
u.id &amp;quot;user_id&amp;quot;, u.firstname, u.lastname,&lt;br /&gt;
question.id &amp;quot;question_id&amp;quot;, question.name &amp;quot;question_name&amp;quot;,&lt;br /&gt;
qas.state &amp;quot;question_step_state&amp;quot;,qas.fraction &amp;quot;question_grade&amp;quot;, qh.hint, question.qtype &amp;quot;question_type&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_quiz as q&lt;br /&gt;
JOIN mdl_course_modules as cm ON cm.instance = q.id and cm.module = 14 &lt;br /&gt;
JOIN mdl_quiz_attempts qa ON q.id = qa.quiz&lt;br /&gt;
LEFT JOIN mdl_quiz_grades as qg ON qg.quiz = q.id and qg.userid = qa.userid&lt;br /&gt;
JOIN mdl_user as u ON u.id = qa.userid&lt;br /&gt;
JOIN mdl_question_usages as qu ON qu.id = qa.uniqueid&lt;br /&gt;
JOIN mdl_question_attempts as qatt ON qatt.questionusageid = qu.id&lt;br /&gt;
JOIN mdl_question as question ON question.id = qatt.questionid&lt;br /&gt;
JOIN mdl_question_attempt_steps as qas ON qas.questionattemptid = qatt.id&lt;br /&gt;
LEFT JOIN mdl_question_hints as qh ON qh.questionid = q.id&lt;br /&gt;
#WHERE q.id = &amp;quot;SOME QUIZ ID&amp;quot;&lt;br /&gt;
WHERE cm.course = &amp;quot;SOME COURSE ID&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Quiz Usage in Courses by Date===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
This report lists the courses containing quizzes with the course start date between the two values, and provides a summary of the types of questions in the quizzes in each course and whether question randomization and answer randomization functions were used.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Multiple Choice&amp;quot; questions include true/false and matching question types.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Short Answer&amp;quot; are questions that accept a single phrase.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Other&amp;quot; questions include fixed numerical, calculated, essay, and various drag and drop types.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Min Quiz Age&amp;quot; and &amp;quot;Max Quiz Age&amp;quot; provide data about the last modified date for the quizzes in the course, compared to the course start date. The values are expressed in units of days. A negative value indicates that a quiz was edited after the start of the course. A value greater than 90 days indicates that the quiz may have been used in an earlier term (cohort) without modification.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: In Configurable Reports, the Date Filter is not applied until the &amp;quot;Apply&amp;quot; button is clicked.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
c.shortname AS &#039;Course&#039;&lt;br /&gt;
#, u.lastname AS &#039;Instructor&#039;&lt;br /&gt;
, COUNT(DISTINCT q.id) AS &#039;Quizzes&#039;&lt;br /&gt;
, COUNT(DISTINCT qu.id) AS &#039;Questions&#039;&lt;br /&gt;
, SUM(IF (qu.qtype = &#039;multichoice&#039;, 1, 0 )) + SUM(IF (qu.qtype = &#039;truefalse&#039;, 1, 0 )) + SUM(IF (qu.qtype = &#039;match&#039;, 1, 0 ))  AS &#039;multichoice&#039;&lt;br /&gt;
&lt;br /&gt;
, SUM(IF (qu.qtype = &#039;shortanswer&#039;, 1, 0 )) AS &#039;shortanswer&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT( qu.id) - SUM(IF (qu.qtype = &#039;multichoice&#039;, 1, 0 )) - SUM(IF (qu.qtype = &#039;truefalse&#039;, 1, 0 )) - SUM(IF (qu.qtype = &#039;match&#039;, 1, 0 )) - SUM(IF (qu.qtype = &#039;shortanswer&#039;, 1, 0 )) AS &#039;Other&#039;&lt;br /&gt;
&lt;br /&gt;
, (SUM(IF (qu.qtype = &#039;multichoice&#039;, 1, 0 )) + SUM(IF (qu.qtype = &#039;truefalse&#039;, 1, 0 )) + SUM(IF (qu.qtype = &#039;match&#039;, 1, 0 )))/COUNT( qu.id) AS &#039;Percent MC&#039;&lt;br /&gt;
&lt;br /&gt;
#, SUM(IF (qu.qtype = &#039;numerical&#039;, 1, 0 )) AS &#039;numerical&#039;&lt;br /&gt;
#, SUM(IF (qu.qtype LIKE &#039;calc%&#039;, 1, 0 )) AS &#039;calculated&#039;&lt;br /&gt;
#, SUM(IF (qu.qtype = &#039;random&#039;, 1, 0 )) AS &#039;random&#039;&lt;br /&gt;
#, SUM(IF (qu.qtype = &#039;shortanswer&#039;, 1, 0 )) AS &#039;shortanswer&#039;&lt;br /&gt;
#, SUM(IF (qu.qtype = &#039;essay&#039;, 1, 0 )) AS &#039;essay&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
, IF(q.shufflequestions &amp;gt; 0,&#039;Yes&#039;,&#039;No&#039;) AS &#039;Randomized Questions&#039;&lt;br /&gt;
, IF(q.shuffleanswers &amp;gt; 0,&#039;Yes&#039;,&#039;No&#039;) AS &#039;Randomized Answers&#039;&lt;br /&gt;
 &lt;br /&gt;
#, FROM_UNIXTIME(c.startdate) AS &#039;Course Start Date&#039;&lt;br /&gt;
#, FROM_UNIXTIME(MIN(q.timemodified)) AS &#039;Last Modified&#039;&lt;br /&gt;
&lt;br /&gt;
#, DATEDIFF(FROM_UNIXTIME(c.startdate),FROM_UNIXTIME(MIN(q.timemodified))) AS &#039;Quiz age&#039;&lt;br /&gt;
&lt;br /&gt;
, MIN(DATEDIFF(FROM_UNIXTIME(c.startdate),FROM_UNIXTIME(q.timemodified))) AS &#039;Min Quiz Age&#039; &lt;br /&gt;
, MAX(DATEDIFF(FROM_UNIXTIME(c.startdate),FROM_UNIXTIME(q.timemodified))) AS &#039;Max Quiz Age&#039; &lt;br /&gt;
&lt;br /&gt;
#, SUM(IF (DATEDIFF(FROM_UNIXTIME(c.startdate),FROM_UNIXTIME(q.timemodified)) &amp;lt; 90, 1,0)) AS &#039;new quizzes&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_quiz AS q&lt;br /&gt;
JOIN prefix_course AS c on c.id = q.course&lt;br /&gt;
JOIN prefix_quiz_question_instances AS qqi ON qqi.quiz = q.id&lt;br /&gt;
LEFT JOIN prefix_question AS qu ON qu.id = qqi.question&lt;br /&gt;
&lt;br /&gt;
WHERE&lt;br /&gt;
1&lt;br /&gt;
%%FILTER_STARTTIME:c.startdate:&amp;gt;%% %%FILTER_ENDTIME:c.startdate:&amp;lt;%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
&lt;br /&gt;
ORDER BY c.shortname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Student responses (answers) to quiz questions===&lt;br /&gt;
(Contributed by Juan F with help from Tim hunt and fellow Moodlers on the forums)&lt;br /&gt;
A report that targets a specific quiz for all of our Biology courses, a summary of all questions and how many students get them right/wrong.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
    concat( u.firstname, &amp;quot; &amp;quot;, u.lastname ) AS &amp;quot;Student Name&amp;quot;,&lt;br /&gt;
    u.id,&lt;br /&gt;
    quiza.userid,&lt;br /&gt;
    q.course,&lt;br /&gt;
    q.name,&lt;br /&gt;
    quiza.attempt,&lt;br /&gt;
    qa.slot,&lt;br /&gt;
    que.questiontext AS &#039;Question&#039;,&lt;br /&gt;
    qa.rightanswer AS &#039;Correct Answer&#039;,&lt;br /&gt;
    qa.responsesummary AS &#039;Student Answer&#039;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_quiz_attempts quiza&lt;br /&gt;
JOIN mdl_quiz q ON q.id=quiza.quiz&lt;br /&gt;
JOIN mdl_question_usages qu ON qu.id = quiza.uniqueid&lt;br /&gt;
JOIN mdl_question_attempts qa ON qa.questionusageid = qu.id&lt;br /&gt;
JOIN mdl_question que ON que.id = qa.questionid&lt;br /&gt;
JOIN mdl_user u ON u.id = quiza.userid&lt;br /&gt;
&lt;br /&gt;
WHERE q.name = &amp;quot;BIO 208 Post Test Assessment&amp;quot;&lt;br /&gt;
AND q.course = &amp;quot;17926&amp;quot;&lt;br /&gt;
&lt;br /&gt;
ORDER BY quiza.userid, quiza.attempt, qa.slot&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Questions which are tagged within a course/quiz===&lt;br /&gt;
Calculates subgrades for tags in the each of the quizzes in a course. &lt;br /&gt;
Contributed by Daniel Thies in https://moodle.org/mod/forum/discuss.php?d=324314#p1346542&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
    quiz.name AS quiz,&lt;br /&gt;
    t.rawname AS tag,&lt;br /&gt;
    CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/quiz/review.php?attempt=&#039;,&lt;br /&gt;
            MAX(quiza.id),&#039;&amp;quot;&amp;gt;&#039;,u.firstname,&#039; &#039;,u.lastname,&#039;&amp;lt;/a&amp;gt;&#039;) AS student,&lt;br /&gt;
    CAST(SUM(qas.fraction) as decimal(12,1)) AS correct,&lt;br /&gt;
    CAST(SUM(qa.maxmark) as decimal(12,1)) AS maximum,&lt;br /&gt;
    CAST(SUM(qas.fraction)/SUM(qa.maxmark)*100 as decimal(4,2)) AS score&lt;br /&gt;
FROM prefix_quiz_attempts quiza&lt;br /&gt;
JOIN prefix_user u ON quiza.userid = u.id&lt;br /&gt;
JOIN prefix_question_usages qu ON qu.id = quiza.uniqueid&lt;br /&gt;
JOIN prefix_question_attempts qa ON qa.questionusageid = qu.id&lt;br /&gt;
JOIN prefix_quiz quiz ON quiz.id = quiza.quiz&lt;br /&gt;
JOIN prefix_tag_instance ti ON qa.questionid = ti.itemid&lt;br /&gt;
JOIN prefix_tag t ON t.id = ti.tagid&lt;br /&gt;
JOIN (SELECT MAX(fraction) AS fraction, questionattemptid&lt;br /&gt;
        FROM prefix_question_attempt_steps&lt;br /&gt;
        GROUP BY questionattemptid) qas ON qas.questionattemptid = qa.id &lt;br /&gt;
WHERE quiz.course = %%COURSEID%%&lt;br /&gt;
GROUP BY quiza.userid,&lt;br /&gt;
    quiza.quiz,&lt;br /&gt;
    quiz.name,&lt;br /&gt;
    u.firstname,&lt;br /&gt;
    u.lastname,&lt;br /&gt;
    ti.tagid,&lt;br /&gt;
    t.rawname&lt;br /&gt;
ORDER BY quiza.quiz, t.rawname, u.lastname, u.firstname, score&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;
===Lists SCORM status for all enrolled users by Course name===&lt;br /&gt;
This report will list the SCORM status for all users enrolled in the course. It is ordered first by Course name, then student&#039;s last name, then student&#039;s first name, then attempt number. This can be limited to individual courses by adding to the where clause the course id to report on.  &lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
u.firstname AS First,&lt;br /&gt;
u.lastname AS Last, &lt;br /&gt;
u.idnumber AS Employee_ID,  &lt;br /&gt;
u.city AS City,&lt;br /&gt;
uid.data AS State,&lt;br /&gt;
u.country AS Country,&lt;br /&gt;
g.name AS Group_name,&lt;br /&gt;
c.fullname AS Course, &lt;br /&gt;
st.attempt AS Attempt,&lt;br /&gt;
st.value AS Status,&lt;br /&gt;
FROM_UNIXTIME(st.timemodified,&amp;quot;%m-%d-%Y&amp;quot;) AS Date &lt;br /&gt;
&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_user_info_data AS uid ON uid.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;
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;
&lt;br /&gt;
WHERE st.element=&#039;cmi.core.lesson_status&#039; AND m.userid=u.id&lt;br /&gt;
&lt;br /&gt;
UNION&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
user2.firstname AS First,&lt;br /&gt;
user2.lastname AS Last,&lt;br /&gt;
user2. idnumber AS Employee_ID,&lt;br /&gt;
user2.city AS City,&lt;br /&gt;
uid.data AS State,&lt;br /&gt;
user2.country AS Country,&lt;br /&gt;
g.name AS Group_name,&lt;br /&gt;
c.fullname AS Course,&lt;br /&gt;
&amp;quot;-&amp;quot; AS Attempt,&lt;br /&gt;
&amp;quot;not_started&amp;quot; AS Status,&lt;br /&gt;
&amp;quot;-&amp;quot; AS Date&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;
JOIN prefix_user_info_data AS uid ON uid.userid = user2.id &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_scorm AS sc ON sc.course=c.id&lt;br /&gt;
Left Join prefix_scorm_scoes_track AS st on st.scormid=sc.id AND st.userid=user2.id&lt;br /&gt;
&lt;br /&gt;
WHERE  st.timemodified IS NULL AND m.userid=user2.id&lt;br /&gt;
&lt;br /&gt;
ORDER BY  Course, Last, First, Attempt&lt;br /&gt;
&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
=== Manage badges (System &amp;amp; Course) ===&lt;br /&gt;
&lt;br /&gt;
List system wide badges, course and system level badges + a link to relevant &amp;quot;manage badges&amp;quot; page.&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 &#039;System&#039;&lt;br /&gt;
  WHEN b.type = 2 THEN &#039;Course&#039;&lt;br /&gt;
END AS Level&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/badges/index.php?type=&#039;, b.type, &#039;&amp;amp;id=&#039;,&lt;br /&gt;
			  c.id, &#039;&amp;quot;&amp;gt;Manage badges in: &#039;, c.fullname, &#039;&amp;lt;/a&amp;gt;&#039;) AS Manage &lt;br /&gt;
FROM prefix_badge AS b&lt;br /&gt;
JOIN prefix_course AS c ON c.id = b.courseid&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&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;
===Cohorts with Courses===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
List of all cohorts with name, id, visibility, and which courses they are enrolled in.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
# h.id,&lt;br /&gt;
# e.customint1,&lt;br /&gt;
h.name AS Cohort,&lt;br /&gt;
h.idnumber AS Cohortid,&lt;br /&gt;
CASE &lt;br /&gt;
 WHEN h.visible = 1 THEN &#039;Yes&#039;&lt;br /&gt;
 ELSE &#039;-&#039;&lt;br /&gt;
END AS Cohortvisible,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;, CHAR(63),&#039;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_cohort h&lt;br /&gt;
JOIN prefix_enrol e ON h.id = e.customint1&lt;br /&gt;
JOIN prefix_course c ON c.id = e.courseid %%FILTER_COURSES:e.courseid%% &lt;br /&gt;
WHERE e.enrol = &#039;cohort&#039; AND e.roleid = 5&lt;br /&gt;
&amp;lt;/code&amp;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;
===Course Aggregation Report===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
If you are considering upgrading from Moodle 2.6 to 2.8 or later, your grades may be changed. This report can help quantify and identify the courses at risk of changes.&lt;br /&gt;
&lt;br /&gt;
In particular, be on the lookout for any courses with the following combinations of parameters, which are known to cause changes in calculations:&lt;br /&gt;
&lt;br /&gt;
# mean of grades set with aggregate with subcategory.&lt;br /&gt;
# Simple weighted mean of grades with aggregate with sub category and drop the lowest&lt;br /&gt;
# Sum of grades drop the lowest&lt;br /&gt;
&lt;br /&gt;
Also review:&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-48618&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-48634&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-49257&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-50089&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-50062&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
&lt;br /&gt;
COUNT(c.shortname) AS &#039;Count of Courses&#039;&lt;br /&gt;
&lt;br /&gt;
# If you want to display all the courses for each aggregation type, uncomment the next line and change GROUP BY settings&lt;br /&gt;
#, c.shortname AS &#039;course name&#039;&lt;br /&gt;
&lt;br /&gt;
# If you need to display grade categories for each aggregation type, uncomment the next line and change GROUP BY settings&lt;br /&gt;
#, gc.fullname AS &#039;grade category name&#039;&lt;br /&gt;
&lt;br /&gt;
, gc.aggregation AS &#039;aggregation method&#039;&lt;br /&gt;
&lt;br /&gt;
#These aggregation text strings appear to be hard-coded. I couldn&#039;t find a table for them. If you have aggregation types I haven&#039;t included here, they&#039;ll be blank in your report results.&lt;br /&gt;
, CASE gc.aggregation&lt;br /&gt;
  WHEN 0 THEN &#039;Mean of Grades&#039;&lt;br /&gt;
  WHEN 2 THEN &#039;Median of Grades&#039;&lt;br /&gt;
  WHEN 6 THEN &#039;Highest Grade&#039;&lt;br /&gt;
  WHEN 8 THEN &#039;Mode of Grades&#039;&lt;br /&gt;
  WHEN 10 THEN &#039;Weighted Mean of Grades&#039;&lt;br /&gt;
  WHEN 11 THEN &#039;Simple Weighted Mean of Grades&#039;&lt;br /&gt;
  WHEN 12 THEN &#039;Mean of Grades (with extra credits)&#039;&lt;br /&gt;
  WHEN 13 THEN &#039;Sum of Grades&#039;&lt;br /&gt;
END AS &#039;aggregation name&#039;&lt;br /&gt;
&lt;br /&gt;
# Note that gc.aggregatesubcats column is eliminated in 2.8 and later per MDL-47503, so comment that line on updated systems or you&#039;ll get an error&lt;br /&gt;
, gc.keephigh AS &#039;keep high&#039;&lt;br /&gt;
, gc.droplow AS &#039;dr0p low&#039;&lt;br /&gt;
, gc.aggregateonlygraded AS &#039;Aggregate only graded&#039;&lt;br /&gt;
, gc.aggregateoutcomes AS &#039;aggregate outcomes&#039;&lt;br /&gt;
, gc.aggregatesubcats AS &#039;aggregate subcategories&#039;&lt;br /&gt;
&lt;br /&gt;
# If you are displaying data about individual courses, you may want to know how old they are&lt;br /&gt;
#, FROM_UNIXTIME(c.startdate) AS &#039;course start date&#039;&lt;br /&gt;
&lt;br /&gt;
# If you are trying to use this report to check to see if final grades have changed after an upgrade, you might want these data items, but calculations can still change later when the courses are actually viewed. Also, you&#039;ll need to uncomment the necessary JOINs below&lt;br /&gt;
#, gi.itemname AS &#039;grade item&#039;&lt;br /&gt;
#, gg.finalgrade AS &#039;final grade&#039;&lt;br /&gt;
&lt;br /&gt;
FROM&lt;br /&gt;
&lt;br /&gt;
prefix_course AS c&lt;br /&gt;
JOIN prefix_grade_categories AS gc ON gc.courseid = c.id&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
&lt;br /&gt;
#LEFT JOIN prefix_grade_items AS gi ON gi.courseid = c.id #AND gi.categoryid=gc.id&lt;br /&gt;
#LEFT JOIN prefix_grade_grades AS gg ON gg.itemid = gi.id AND gg.userid = u.id&lt;br /&gt;
&lt;br /&gt;
WHERE&lt;br /&gt;
1&lt;br /&gt;
#AND gc.aggregation = 13 #only the dreaded Sum of Grades aggregations&lt;br /&gt;
#AND gc.depth = 1 # if for some reason you only want course aggregations, not subcategories&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GROUP BY gc.aggregation, gc.keephigh, gc.droplow, gc.aggregateonlygraded, gc.aggregateoutcomes, gc.aggregatesubcats&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Running Cron jobs (task_scheduled) ===&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT classname&lt;br /&gt;
  ,DATE_FORMAT(FROM_UNIXTIME(lastruntime), &#039;%H:%i [%d]&#039;) AS &#039;last&#039;&lt;br /&gt;
  ,DATE_FORMAT(now(), &#039;%H:%i&#039;) AS &#039;now&#039;&lt;br /&gt;
  ,DATE_FORMAT(FROM_UNIXTIME(nextruntime), &#039;%H:%i [%d]&#039;) AS &#039;next&#039;&lt;br /&gt;
  ,DATE_FORMAT(FROM_UNIXTIME(UNIX_TIMESTAMP()-nextruntime), &#039;%i&#039;) AS &#039;next in min&#039;&lt;br /&gt;
FROM mdl_task_scheduled&lt;br /&gt;
WHERE now() &amp;gt; FROM_UNIXTIME(nextruntime)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== All Meta courses with Parent and Child course relationships ===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
This shows the list of courses with Meta course link enrollments in them (&#039;Parent course&#039;), and the courses which are connected to them to provide enrollments (&#039;Child courses&#039;).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
c.fullname AS &#039;Parent course name&#039;,&lt;br /&gt;
c.shortname AS &#039;Parent course shortname&#039;,&lt;br /&gt;
en.courseid AS &#039;Parent course id&#039;,&lt;br /&gt;
(SELECT fullname FROM prefix_course WHERE prefix_course.id = en.customint1) As &#039;Child course name&#039;,&lt;br /&gt;
(SELECT shortname FROM prefix_course WHERE prefix_course.id = en.customint1) As &#039;Child course shortname&#039;,&lt;br /&gt;
en.customint1 AS &#039;Child course id&#039;&lt;br /&gt;
FROM prefix_enrol en&lt;br /&gt;
JOIN prefix_course c ON c.id = en.courseid&lt;br /&gt;
WHERE en.enrol = &#039;meta&#039;&lt;br /&gt;
ORDER BY c.fullname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Learning Analytics Reports ==&lt;br /&gt;
(Moodle v. 3.4 and later)&lt;br /&gt;
&lt;br /&gt;
=== Learning Analytics Model Summary ===&lt;br /&gt;
This report provides a list of the learning analytics models on your site, whether enabled or not, and several details about them.&lt;br /&gt;
&lt;br /&gt;
(Note: this report was created on a system using PostgreSQL. Some changes may be needed for other forms of SQL.)&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
am.id AS &amp;quot;model id&amp;quot;,	 &lt;br /&gt;
split_part(am.target,&#039;\&#039;,5) AS &amp;quot;target&amp;quot;,&lt;br /&gt;
CASE WHEN am.enabled=1 THEN &#039;YES&#039; ELSE &#039;NO&#039; END AS &amp;quot;enabled&amp;quot;,	 &lt;br /&gt;
CASE WHEN am.trained=1 THEN &#039;YES&#039; ELSE &#039;NO&#039; END AS &amp;quot;trained&amp;quot;,&lt;br /&gt;
am.name,	 &lt;br /&gt;
/* indicators,*/&lt;br /&gt;
char_length(am.indicators) - char_length(REPLACE(am.indicators,&#039;,&#039;,&#039;&#039;))+1 AS &amp;quot;indicator count&amp;quot;,&lt;br /&gt;
split_part(am.timesplitting,&#039;\&#039;,5) AS &amp;quot;interval&amp;quot;,&lt;br /&gt;
/*&lt;br /&gt;
to_timestamp(am.version) AS &amp;quot;version&amp;quot;,	 &lt;br /&gt;
to_timestamp(am.timecreated) AS &amp;quot;time created&amp;quot;,	 &lt;br /&gt;
to_timestamp(am.timemodified) AS &amp;quot;time modified&amp;quot;,	&lt;br /&gt;
*/&lt;br /&gt;
COUNT(DISTINCT ap.contextid) AS &amp;quot;contexts&amp;quot;,&lt;br /&gt;
COUNT(ap.sampleid) AS &amp;quot;samples&amp;quot;,&lt;br /&gt;
/* AVG(ap.prediction) AS &amp;quot;avg prediction&amp;quot;, */&lt;br /&gt;
ROUND(ap.prediction,1) AS &amp;quot;prediction&amp;quot;,		   &lt;br /&gt;
ROUND(AVG(aml.score),3) AS &amp;quot;model accuracy (avg)&amp;quot;,&lt;br /&gt;
apa.actionname AS &amp;quot;action&amp;quot;,&lt;br /&gt;
COUNT(apa.id) AS &amp;quot;number actions taken&amp;quot;&lt;br /&gt;
		   &lt;br /&gt;
FROM prefix_analytics_models AS am&lt;br /&gt;
JOIN prefix_analytics_predictions AS ap ON am.id = ap.modelid&lt;br /&gt;
LEFT JOIN prefix_analytics_models_log AS aml ON aml.modelid = am.id&lt;br /&gt;
LEFT JOIN prefix_analytics_prediction_actions AS apa ON apa.predictionid = ap.id&lt;br /&gt;
GROUP BY am.id, ap.prediction, apa.actionname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Analytics Indicator Calculations ===&lt;br /&gt;
Pulls calculations from the &amp;quot;analytics_indicator_calc&amp;quot; table consisting of all calculations made for each indicator for each sample within each context for every model. In most cases you will want to limit this per context or sample, or at least group by context and sample.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
id,	 &lt;br /&gt;
to_timestamp(starttime) AS &amp;quot;start time&amp;quot;,	 &lt;br /&gt;
to_timestamp(endtime) AS &amp;quot;end time&amp;quot;,	 &lt;br /&gt;
contextid,	 &lt;br /&gt;
sampleorigin,	 &lt;br /&gt;
sampleid,	 &lt;br /&gt;
/*indicator, */&lt;br /&gt;
split_part(indicator,&#039;\&#039;,2) AS &amp;quot;module&amp;quot;,&lt;br /&gt;
split_part(indicator,&#039;\&#039;,5) AS &amp;quot;indicator type&amp;quot;,&lt;br /&gt;
value,	 &lt;br /&gt;
to_timestamp(timecreated) AS &amp;quot;time created&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_indicator_calc&lt;br /&gt;
WHERE id = 1&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Analytics Models ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_models&amp;quot; table consisting of one row per model. See the &amp;quot;Learning Analytics Model Summary&amp;quot; report, above, for an expanded report that JOINs model data from different tables to provide a more comprehensive view.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
id,	 &lt;br /&gt;
enabled,	 &lt;br /&gt;
trained, &lt;br /&gt;
name,	 &lt;br /&gt;
split_part(target,&#039;\&#039;,5) AS &amp;quot;target&amp;quot;,&lt;br /&gt;
/* indicators,*/&lt;br /&gt;
char_length(indicators) - char_length(REPLACE(indicators,&#039;,&#039;,&#039;&#039;))+1 AS &amp;quot;indicator count&amp;quot;,&lt;br /&gt;
split_part(timesplitting,&#039;\&#039;,5) AS &amp;quot;interval&amp;quot;,&lt;br /&gt;
predictionsprocessor, &lt;br /&gt;
to_timestamp(version) AS &amp;quot;version&amp;quot;,	 &lt;br /&gt;
to_timestamp(timecreated) AS &amp;quot;time created&amp;quot;,	 &lt;br /&gt;
to_timestamp(timemodified) AS &amp;quot;time modified&amp;quot;,	 &lt;br /&gt;
usermodified&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_models&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Analytics Models Log ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_models_log&amp;quot; table consisting of evaluation calculations per model. If model evaluations have not been manually executed on the system from the command line, there will be no contents in this table.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
id,	 &lt;br /&gt;
modelid,	 &lt;br /&gt;
to_timestamp(version) AS &amp;quot;version&amp;quot;,	 &lt;br /&gt;
evaluationmode,	 &lt;br /&gt;
split_part(target,&#039;\&#039;,5) AS &amp;quot;target&amp;quot;,	 &lt;br /&gt;
/* indicators,*/&lt;br /&gt;
char_length(indicators) - char_length(REPLACE(indicators,&#039;,&#039;,&#039;&#039;))+1 AS &amp;quot;indicator count&amp;quot;,&lt;br /&gt;
split_part(timesplitting,&#039;\&#039;,5) AS &amp;quot;interval&amp;quot;,	 &lt;br /&gt;
score,	 &lt;br /&gt;
info,	 &lt;br /&gt;
dir,	 &lt;br /&gt;
to_timestamp(timecreated) AS &amp;quot;time created&amp;quot;,	 &lt;br /&gt;
usermodified&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_models_log&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Analytics Predictions ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_predictions&amp;quot; table consisting of one row per prediction per model. Counts the number of indicators calculated for each prediction, but does not list them. If a model has not yet been trained, the system cannot make predictions and this table will not include rows for that model ID. See the &amp;quot;Learning Analytics Model Summary&amp;quot; report, above, for an expanded report that JOINs model data from different tables to provide a more comprehensive view.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
id,	 &lt;br /&gt;
modelid,	 &lt;br /&gt;
contextid,	 &lt;br /&gt;
sampleid,	 &lt;br /&gt;
rangeindex,	 &lt;br /&gt;
prediction,	 &lt;br /&gt;
predictionscore,	 &lt;br /&gt;
char_length(calculations) - char_length(REPLACE(calculations,&#039;,&#039;,&#039;&#039;))+1 AS &amp;quot;indicators calculated&amp;quot;,&lt;br /&gt;
to_timestamp(timecreated) AS &amp;quot;time created&amp;quot;,	 &lt;br /&gt;
to_timestamp(timestart) AS &amp;quot;time start&amp;quot;,	 &lt;br /&gt;
to_timestamp(timeend) AS &amp;quot;time end&amp;quot;&lt;br /&gt;
&lt;br /&gt;
from prefix_analytics_predictions&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Analytics Prediction Actions ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_prediction_actions&amp;quot; table consisting of one row per action taken per prediction (e.g. a teacher viewing the outline report for a student at risk). If the model has not yet made predictions, there can be no prediction actions. See the &amp;quot;Learning Analytics Model Summary&amp;quot; report, above, for an expanded report that JOINs model data from different tables to provide a more comprehensive view.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
id,	 &lt;br /&gt;
predictionid,	 &lt;br /&gt;
userid,	 &lt;br /&gt;
actionname,	 &lt;br /&gt;
to_timestamp(timecreated) AS &amp;quot;time created&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_prediction_actions&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Analytics Predictions with All Indicators ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_predictions&amp;quot; table consisting of one row per prediction per model. Lists the indicators calculated for each prediction. If a model has not yet been trained, the system cannot make predictions and this table will not include rows for that model ID.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
id AS &amp;quot;Prediction ID&amp;quot;,	 &lt;br /&gt;
modelid AS &amp;quot;Model ID&amp;quot;,	 &lt;br /&gt;
contextid AS &amp;quot;Context ID&amp;quot;,	 &lt;br /&gt;
sampleid AS &amp;quot;Sample ID&amp;quot;,	 &lt;br /&gt;
rangeindex AS &amp;quot;Analysis Interval&amp;quot;,	 &lt;br /&gt;
prediction AS &amp;quot;Prediction value&amp;quot;,	 &lt;br /&gt;
predictionscore,	 &lt;br /&gt;
calculations,&lt;br /&gt;
char_length(calculations) - char_length(REPLACE(calculations,&#039;,&#039;,&#039;&#039;))+1 AS &amp;quot;indicators calculated&amp;quot;,&lt;br /&gt;
to_timestamp(timecreated) AS &amp;quot;time created&amp;quot;,	 &lt;br /&gt;
to_timestamp(timestart) AS &amp;quot;time start&amp;quot;,	 &lt;br /&gt;
to_timestamp(timeend) AS &amp;quot;time end&amp;quot;&lt;br /&gt;
&lt;br /&gt;
from prefix_analytics_predictions&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Analytics Predict Samples ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_predict_samples&amp;quot; table consisting of one row per analysis interval per model, with a count of the samples used for each prediction. Sample details are not included here, but the report can be modified to list samples by IDs if needed by parsing the contents of the sampleids field. For example, this counts the number of student enrolments for which the system has generated predictions for a given model and analysis interval.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
id,	 &lt;br /&gt;
modelid,	 &lt;br /&gt;
analysableid,	 &lt;br /&gt;
split_part(timesplitting,&#039;\&#039;,5) AS &amp;quot;interval&amp;quot;,	 &lt;br /&gt;
rangeindex,	 &lt;br /&gt;
/* sampleids, */	 &lt;br /&gt;
char_length(sampleids) - char_length(REPLACE(sampleids,&#039;,&#039;,&#039;&#039;))+1 AS &amp;quot;samples used&amp;quot;,&lt;br /&gt;
to_timestamp(timecreated) AS &amp;quot;time created&amp;quot;,	 &lt;br /&gt;
to_timestamp(timemodified) AS &amp;quot;time modified&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_predict_samples&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Analytics Train Samples ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_train_samples&amp;quot; table consisting of one row per analysis interval per model, with a count of the samples used for each training calculation. &lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
id,	 &lt;br /&gt;
modelid,	 &lt;br /&gt;
analysableid,	 &lt;br /&gt;
split_part(timesplitting,&#039;\&#039;,5) AS &amp;quot;interval&amp;quot;,&lt;br /&gt;
/* sampleids,	*/&lt;br /&gt;
char_length(sampleids) - char_length(REPLACE(sampleids,&#039;,&#039;,&#039;&#039;))+1 AS &amp;quot;samples used&amp;quot;,&lt;br /&gt;
to_timestamp(timecreated) AS &amp;quot;time created&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_train_samples&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Analytics Used Analysables ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_used_analysables&amp;quot; table consisting of one row per context per model, noting whether the analysable was used to train the model or to make a prediction. This data is used to control the training and prediction processes.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
id,	 &lt;br /&gt;
modelid,	 &lt;br /&gt;
action,	 &lt;br /&gt;
analysableid,	 &lt;br /&gt;
to_timestamp(firstanalysis) AS &amp;quot;first analysis&amp;quot;,	 &lt;br /&gt;
to_timestamp(timeanalysed) AS &amp;quot;time analysed&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_used_analysables&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Analytics Used Files ===&lt;br /&gt;
Pulls data from the &amp;quot;analytics_used_files&amp;quot; table consisting of one row per file per model, noting whether the file was used to train the model or to make a prediction. This data is used to control the training and prediction processes.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
&lt;br /&gt;
id,	 &lt;br /&gt;
modelid,	 &lt;br /&gt;
fileid,	 &lt;br /&gt;
action,	 &lt;br /&gt;
TO_TIMESTAMP(time) AS Time&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_used_files&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Average Cognitive Depth and Social Breadth===&lt;br /&gt;
&lt;br /&gt;
Here is a simple SQL snippet to calculate average cognitive depth and social breadth indicators for all students in the system. This one ignores  indicator values of 0, as they are nulls as defined in this model.&lt;br /&gt;
Contributed by Elizabeth Dalton, Moodle HQ&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
&lt;br /&gt;
i.contextid,&lt;br /&gt;
i.sampleid,&lt;br /&gt;
&lt;br /&gt;
TRUNC(AVG(CASE&lt;br /&gt;
WHEN i.indicator LIKE &#039;%cognitive%&#039; THEN i.value &lt;br /&gt;
ELSE &#039;0&#039;&lt;br /&gt;
END),2) AS &amp;quot;Average Cognitive Depth&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
TRUNC(AVG(CASE&lt;br /&gt;
WHEN i.indicator LIKE &#039;%social%&#039; THEN i.value &lt;br /&gt;
ELSE &#039;0&#039;&lt;br /&gt;
END),2) AS &amp;quot;Average Social Breadth&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_analytics_indicator_calc as i&lt;br /&gt;
WHERE&lt;br /&gt;
i.value != 0&lt;br /&gt;
GROUP BY i.contextid, i.sampleid&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful sub queries ==&lt;br /&gt;
&lt;br /&gt;
IN this section please put any short one purpose sub queries that show how common procedures often useful as part of larger queries.&lt;br /&gt;
&lt;br /&gt;
=== All teachers in the course ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This snippet shows how to get teachers from a course. The contextevel for course objects is 50. And the default Teacher role is role id 3.&lt;br /&gt;
&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;
=== Get custom User profile fields for a user ===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
This snippet of code shows how to connect a user with their custom profile field data. This will list all users with all custom profile fields and data. Custom profile fields have two tables, one for the definition of the profile field (user_info_field) and its settings, and a separate table to hold the data entered by users (user_info_data). &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, uif.name, uid.data&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 &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you want to limit it to one of those fields, you can restrict it by shortname of the custom profile field, so:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, uif.name, uid.data&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;shortname1&#039;)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will show you only the data from the custom profile field with the shortname &#039;shortname1&#039;.&lt;br /&gt;
&lt;br /&gt;
If you want to do this with two or more custom profile fields, you will need to have a JOIN and table alias for each with a restriction for each profile field shortname. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, d1.data AS &#039;Profile One&#039;, d2.data As &#039;Profile Two&#039;&lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
JOIN prefix_user_info_data d1 ON d1.userid = u.id&lt;br /&gt;
JOIN prefix_user_info_field f1 ON d1.fieldid = f1.id AND f1.shortname = &#039;shortname1&#039;&lt;br /&gt;
JOIN prefix_user_info_data d2 ON d2.userid = u.id&lt;br /&gt;
JOIN prefix_user_info_field f2 ON d2.fieldid = f2.id AND f2.shortname = &#039;shortname2&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== NOTE: Alternate Method ====&lt;br /&gt;
&lt;br /&gt;
If you have more than a couple of fields you need to use, then this query may time out or not return data due to too many joins. The limit seems to be around 10 custom profile fields. &lt;br /&gt;
&lt;br /&gt;
Instead you should use an alternate method which uses Subselects for each of the profile fields. Details and sample code are in this forum discussion: https://moodle.org/mod/forum/discuss.php?d=355502#p1434854. A sample of the style is:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username&lt;br /&gt;
&lt;br /&gt;
,(SELECT d1.data FROM prefix_user_info_data d1&lt;br /&gt;
 JOIN prefix_user_info_field f1 ON d1.fieldid = f1.id AND f1.shortname = &#039;shortname1&#039;&lt;br /&gt;
 WHERE d1.userid = u.id&lt;br /&gt;
) AS thefirstfield&lt;br /&gt;
&lt;br /&gt;
,(SELECT d1.data FROM prefix_user_info_data d1&lt;br /&gt;
 JOIN prefix_user_info_field f1 ON d1.fieldid = f1.id AND f1.shortname = &#039;shortname2&#039;&lt;br /&gt;
 WHERE d1.userid = u.id&lt;br /&gt;
) AS thesecondfield&lt;br /&gt;
&lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== How to use Configurable Reports Date Time Filters===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
In the Configurable Reports block, you can set the Time and Date filter to allow you to pick your report Start date/time and End date/time interactively. This will work on any column in a table that is a timestamp.&lt;br /&gt;
&lt;br /&gt;
Here is a simple example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.username, &lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(u.firstaccess),&#039;%Y-%m-%d %H:%i&#039;) AS &#039;FirstAccess&#039;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(u.lastaccess),&#039;%Y-%m-%d %H:%i&#039;) AS &#039;LastAccess&#039;   &lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_STARTTIME:u.firstaccess:&amp;gt;%% &lt;br /&gt;
%%FILTER_ENDTIME:u.lastaccess:&amp;lt;%% &lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
1) You will need to replace name of the table and column for the filter to use the time and date column you need for your query. In the example above, it filters on the firstaccess and lastaccess columns in the user table. If you were doing a report on course completion, you might put the timecompleted column, and so forth.&lt;br /&gt;
&lt;br /&gt;
2) You MUST then add the Start / End date filter on the Filters tab of the Report. If you don&#039;t, the report will still run, probably, but the filter will be ignored.&lt;br /&gt;
&lt;br /&gt;
Note: the WHERE 1=1 statement is a peculiarity of the filters in Config reports: if you don&#039;t have a WHERE statement in your query already, then you must add this dummy WHERE to keep the statement valid. If you already have a WHERE statement in your code, simply add the %%FILTER%% placeholders after it (and before any GROUP or ORDER BY statements.)&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]&lt;br /&gt;
* [https://moodleschema.zoola.io/index.html Moodle DB schema explorer] - searching and filtering tables, fields and external key connections between tables.&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributed code]]&lt;br /&gt;
&lt;br /&gt;
[[es:Reportes específicos hechos por usuarios]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=134998</id>
		<title>Configurable reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=134998"/>
		<updated>2019-08-07T07:35:30Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Maintainer list */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox plugin&lt;br /&gt;
|type = Block&lt;br /&gt;
|entry = https://moodle.org/plugins/view.php?plugin=block_configurable_reports&lt;br /&gt;
|tracker = http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
|discussion = https://moodle.org/mod/forum/view.php?id=7979&lt;br /&gt;
|maintainer = [[User:Juan Leyva|Juan Leyva]], [[User:Sara Arjona Téllez|Sara Arjona Téllez]]&lt;br /&gt;
|float = right&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
# Download the Configurable Reports installation file and unzip it to the &#039;&#039;&#039;\blocks&#039;&#039;&#039; directory in your Moodle folder.&lt;br /&gt;
# Be sure that the final name of the directory is: configurable_reports, the full path in your Moodle installation will be blocks/configurable_reports&lt;br /&gt;
# Login to Moodle as Administrator and click Notifications under Site Administration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information see [[Installing contributed modules or plugins]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This block is a Moodle custom reports builder. It its also connected to a [https://github.com/jleyva/moodle-configurable_reports_repository public repository of sample reports] (only plugin version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
It is designed in a modular way to allow developers to create new plugins in less than an hour.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can create custom reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Anyone with block, managereports or manageownreports permissions at SITE level or COURSE level.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What type of reports can I create?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Courses reports, with information regarding courses.&lt;br /&gt;
&lt;br /&gt;
- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.&lt;br /&gt;
&lt;br /&gt;
- Users reports, with information regarding users and their activity in a course.&lt;br /&gt;
&lt;br /&gt;
- Timeline reports, this is a special type of report that displays a timeline. A course or user report can be embedded in this timeline showing data depending on the start and end time of the current row.&lt;br /&gt;
&lt;br /&gt;
- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as [https://moodle.org/plugins/view.php?plugin=report_customsql Tim Hunt&#039;s Custom SQL queries] plugin.&lt;br /&gt;
&lt;br /&gt;
Note for developers: You can create your own type of reports.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can view the reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When you create a report you can select which users can view it.&lt;br /&gt;
&lt;br /&gt;
The reports are displayed in a block in the course or site frontpage.&lt;br /&gt;
&lt;br /&gt;
== Creating a report ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a very simple process.  &lt;br /&gt;
&lt;br /&gt;
If you are going to create a report for a course, you have to add the block in the course and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
On the other hand, for site reports, add the block in the frontpage and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
You must enter a name, an optional description, and you have to choose the type of report, pagination and exports formats.&lt;br /&gt;
&lt;br /&gt;
Depending on the report choosen, there will be more or less tabs. These are the tabs for the courses and users report:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Columns&#039;&#039;&#039;: Here you can choose the differents columns of your report depending on the type of report. (Course Name, User firstname, etc..)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Conditions&#039;&#039;&#039;: Here you can define the conditions (i.e, only courses from this category, only users from Spain, etc.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ordering&#039;&#039;&#039;: Here you can choose how to order the report using fields and directions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filters&#039;&#039;&#039;: Here you can choose which filters will be displayed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Template&#039;&#039;&#039;: You can modify the report&#039;s layout by creating a template.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Permissions&#039;&#039;&#039;: Here you can choose who can view a report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Calculations&#039;&#039;&#039;: Here you can add calculations for columns, i.e: average of number of users enrolled in courses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plots&#039;&#039;&#039;: Here you can add graphs to your report based on the report columns and values.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;View report&#039;&#039;&#039;: Self explanatory&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a users&#039; report ===&lt;br /&gt;
&lt;br /&gt;
Requirements: &#039;&#039;Users from Spain, but not from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user&#039;s city must be displayed. A pie plot showing the users&#039; cities is required. A calculation table showing the total forum post views is required. The report must be ordered by users&#039; lastname.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how easy it is!&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Enter a name, a description and choose &amp;quot;Users report&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you will be redirected to the first Tab named &amp;quot;Columns&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Columns&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here you can define the report table properties, width, align, cell padding, cell spacing, etc.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User profile field&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Choose the field &amp;quot;firstname&amp;quot; and enter a name for the column in the text field. You can leave the rest of elements blank.&lt;br /&gt;
&lt;br /&gt;
Repeat the process above for the lastname and city fields.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose a module from the list, in this example, a forum.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Adding Conditions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Conditions Tab.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, the Operator &amp;quot;=&amp;quot;, and enter the value &amp;quot;ES&amp;quot; (this is the international code for Spain as Moodle stores it).&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;city&amp;quot;, the Operator &amp;quot;&amp;lt;&amp;gt;&amp;quot;, and enter the value &amp;quot;Madrid&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;Users in current report course&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These are the main conditions of the reports. Note that at the bottom there is a text box called condition, with this text:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;c2 and c1 and c3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Here you can define a logic condition, in this case, we don&#039;t need to edit this condition but you can create complex expressions like:&lt;br /&gt;
&lt;br /&gt;
 (c1 and c2) or (c4 and c3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Ordering&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Ordering Tab.&lt;br /&gt;
&lt;br /&gt;
Add a ordering named &amp;quot;User field ordering&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Lastname&amp;quot; and the ordering &amp;quot;ASC&amp;quot; (Ascending).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Filters Tab.&lt;br /&gt;
&lt;br /&gt;
Add a filter named &amp;quot;User field filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose city.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Permissions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Permissions Tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;User field Value&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, and enter the value &amp;quot;ES&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Here you can add more permissions and a logic condition to be achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Calculations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Calculations tab.&lt;br /&gt;
&lt;br /&gt;
Choose Sum.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Plots&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Plots tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;Pie&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the colum &amp;quot;City&amp;quot; as Name and Value.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville, etc. and test the report.&lt;br /&gt;
&lt;br /&gt;
You can download the report in different formats (ods and xls), remember to check these options in the report page.&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#Users_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a SQL Report ===&lt;br /&gt;
&lt;br /&gt;
You can find a lot of SQL Reports here: [[ad-hoc contributed reports]]&lt;br /&gt;
&lt;br /&gt;
Since this block supports Tim Hunt&#039;s CustomSQL Queries Reports, you can use any query.&lt;br /&gt;
&lt;br /&gt;
Remember to add a &amp;quot;Time filter&amp;quot; if you are going to use reports with time tokens.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&lt;br /&gt;
&lt;br /&gt;
Enter a name, description, choose &amp;quot;SQL&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you redirect to the first Tab named &amp;quot;Custom SQL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add this query (&#039;&#039;Courses activity&#039;&#039;):&lt;br /&gt;
&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;
==== Adding a calculation ====&lt;br /&gt;
# Go to Calculations Tab&lt;br /&gt;
# Add a Sum calculation, choose the hits column&lt;br /&gt;
&lt;br /&gt;
==== Adding a Plot ====&lt;br /&gt;
# Go to Plot&lt;br /&gt;
# Add a Pie graph, choosing coursename as Name and hits as value&lt;br /&gt;
&lt;br /&gt;
So, here you have a report with a Graph and calculations based on a SQL Query.&lt;br /&gt;
&lt;br /&gt;
Note: Bar charts are currently not displaying on systems using PHP 7: https://github.com/jleyva/moodle-block_configurablereports/issues/101&lt;br /&gt;
&lt;br /&gt;
==== Filters ====&lt;br /&gt;
&lt;br /&gt;
Filters add a control to the report that allows the user to select a subset of data when the report runs.  Filters require two steps:&lt;br /&gt;
&lt;br /&gt;
# Select the filter you want to use on the &amp;quot;Filters&amp;quot; tab&lt;br /&gt;
# Add SQL code to make the filter affect the output.&lt;br /&gt;
&lt;br /&gt;
These are the filters that can be used to constrain your report:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%FILTER_CATEGORIES:&lt;br /&gt;
%%FILTER_COURSEMODULEID:&lt;br /&gt;
%%FILTER_COURSEMODULEFIELDS:&lt;br /&gt;
%%FILTER_COURSEMODULE:&lt;br /&gt;
%%FILTER_COURSES:&lt;br /&gt;
%%FILTER_COURSEENROLLEDSTUDENTS:&lt;br /&gt;
%%FILTER_USERS:&lt;br /&gt;
%%FILTER_ROLE:&lt;br /&gt;
%%FILTER_SEARCHTEXT:&lt;br /&gt;
%%FILTER_SEMESTER:&lt;br /&gt;
%%FILTER_STARTTIME:&lt;br /&gt;
%%FILTER_ENDTIME:&lt;br /&gt;
%%FILTER_SUBCATEGORIES:&lt;br /&gt;
%%FILTER_COURSEUSER:&lt;br /&gt;
%%FILTER_SYSTEMUSER:&lt;br /&gt;
%%FILTER_YEARHEBREW:&lt;br /&gt;
%%FILTER_YEARNUMERIC:&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Using Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When using a filter you need at least one static WHERE condition, followed by one or more filters. For example&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
WHERE 1&lt;br /&gt;
%%FILTER_COURSES:c.id%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can technically add multiple filters, but once a user applies one filter to a report all filters for report are applied. So it can be a little tricky to have multiple filters on the same report. For example if you add a course and date filter to a report, then if you just want to filter by course you have to make sure your date filters are set to date range that covers all courses.&lt;br /&gt;
&lt;br /&gt;
Many of the filters are hard coded to be drop down menus which are sorted by database id number instead of alphabetically. This can be problematic if you have a large number of users, courses, or categories. However, you can use one search text filter per report, which can be used to work around the issue in some cases.&lt;br /&gt;
&lt;br /&gt;
Many filters require a logical operator to specify how the filter works. For example&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%FILTER_STARTTIME:l.TIME:&amp;gt;%% %%FILTER_ENDTIME:l.TIME:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can add a Course filter; it&#039;s very easy.&lt;br /&gt;
# Go to filters, choose Courses&lt;br /&gt;
# Edit the Custom SQL query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &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;
Note that we are adding a token called: %%FILTER_COURSES:l.courseid%% &lt;br /&gt;
&lt;br /&gt;
Go to View report, and you will see a Courses Filter, choose a Course and click on Add, here you have a report filtered.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also add a Starttime and endtime filter&lt;br /&gt;
&lt;br /&gt;
# Go to filters, choose Start / End date filter&lt;br /&gt;
# Go to Custom SQL tab, this is the new query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &lt;br /&gt;
%%FILTER_STARTTIME:l.time:&amp;gt;%% %%FILTER_ENDTIME:l.time:&amp;lt;%% &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;
&lt;br /&gt;
If you want to filter text (for example, lastname)&lt;br /&gt;
&lt;br /&gt;
# Go to filters, choose Search Text filter&lt;br /&gt;
# Go to Custom SQL tab and type your query. Here is an example for querying the user table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname&lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_SEARCHTEXT:u.lastname:~%%&lt;br /&gt;
ORDER BY u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace WHERE 1=1 with your WHERE criteria. If you do not have any where criteria and do not specify WHERE 1=1, you will receive a SQL error.&lt;br /&gt;
&lt;br /&gt;
One more example (for filtering a group of courses by category)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, c.fullname as Course,c.id as CourseID&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;
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
%%FILTER_CATEGORIES:c.category%% &lt;br /&gt;
GROUP BY l.course&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Go to View report, now you can filter by time also&lt;br /&gt;
&lt;br /&gt;
==== SQL variables ====&lt;br /&gt;
&lt;br /&gt;
If you place one of these strings in your SQL queries, it will be replaced by the appropriate value (current course id, current user id, Moodle www root (url), etc.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
%%CATEGORYID%%&lt;br /&gt;
%%COURSEID%%&lt;br /&gt;
%%CURRENTUSER%%&lt;br /&gt;
%%DEBUG%%&lt;br /&gt;
%%FILTER_VAR%%&lt;br /&gt;
%%STARTTIME%%&#039;,&#039;%%ENDTIME%%&lt;br /&gt;
%%USERID%%&lt;br /&gt;
%%WWWROOT%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#SQL_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a timeline report ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This report assumes that you have created at least one user or course report&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a course report or user report can be embedded.&lt;br /&gt;
&lt;br /&gt;
In this example we are going to create a report showing the user logins to the site during the last month (day per day).&lt;br /&gt;
&lt;br /&gt;
Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)&lt;br /&gt;
&lt;br /&gt;
Select the statistic (User logins)&lt;br /&gt;
&lt;br /&gt;
Create a Timeline report, in the Timeline tab you can select the dates or days of the report (in this case, the last 30 days) and the interval of time for every row.&lt;br /&gt;
&lt;br /&gt;
Add three &amp;quot;Other report column&amp;quot; columns, selecting all the previous user report columns.&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all, you can create a new type of plot (line graph). This graph is suitable for data depending on time.&lt;br /&gt;
&lt;br /&gt;
== Advanced options ==&lt;br /&gt;
&lt;br /&gt;
=== Export and import of reports ===&lt;br /&gt;
&lt;br /&gt;
Embedded reports exporting is not working because the reports include references to another reports. A workaround is edit the imported report for changing the references in the &amp;quot;Other report field&amp;quot; column.&lt;br /&gt;
&lt;br /&gt;
Reports that uses the user module outline column can&#039;t be exported either&lt;br /&gt;
&lt;br /&gt;
=== Use the same report in different courses ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
In order to use the same report in different courses you have to check the &amp;quot;Global report&amp;quot; option where creating a new report. This report will be then displayed in all the courses where the configurable report block is displayed and the block instance settings are set to &amp;quot;Display global reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to display global reports in a certain block instance you can always edit the instance settings for selecting &amp;quot;No&amp;quot; in the &amp;quot;Display global reports&amp;quot; block setting.&lt;br /&gt;
&lt;br /&gt;
Notice that these types of reports inherit the context of the course where is displayed, so any condition related to course inside the report is calculated using the course where the report is being viewed&lt;br /&gt;
&lt;br /&gt;
=== Reports can run on a different DB then the current (production) DB ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
This functionality is for using a copy of the same moodle database, not for queries to other database sources.&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings&lt;br /&gt;
&lt;br /&gt;
=== DataTables for the report table ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to enable this functionality&lt;br /&gt;
&lt;br /&gt;
=== CodeMirror.js for highlighting SQL query code ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to disable this functionality&lt;br /&gt;
&lt;br /&gt;
=== Using GITHUB as a repository to distribute and manage sharable SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to point to your own repository&lt;br /&gt;
&lt;br /&gt;
=== Cron SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
=== Settings to control security of SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to change the security level&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
You can customize the report output using a template.&lt;br /&gt;
&lt;br /&gt;
Just enable the Template option in the same name tab.&lt;br /&gt;
&lt;br /&gt;
This is an example html code for displaying a list of users:&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;p align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;##reportname##&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;60%&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Record:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;img src=&amp;quot;http://yourmoodle.com/user/pix.php/[[id]]/f1.jpg&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;h2&amp;gt;[[Firstname]] [[Lastname]]&amp;lt;/h2&amp;gt;&lt;br /&gt;
City: [[City]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Footer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
##graphs## &lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
##exportoptions##&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Embedded reports ===&lt;br /&gt;
&lt;br /&gt;
An embedded report consists in a report&#039;s set of columns that are embedded in another report.&lt;br /&gt;
&lt;br /&gt;
You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type of report&lt;br /&gt;
! Reports that can be embedded&lt;br /&gt;
|-&lt;br /&gt;
| Courses&lt;br /&gt;
| Users&lt;br /&gt;
|-&lt;br /&gt;
| Categories&lt;br /&gt;
| Courses&lt;br /&gt;
|-&lt;br /&gt;
| Timeline&lt;br /&gt;
| Users, courses&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.&lt;br /&gt;
&lt;br /&gt;
To embed a report just add a &amp;quot;Other report&amp;quot; column, a list of your reports will be showed.&lt;br /&gt;
&lt;br /&gt;
Inside a course report you can embed a user report and the other way.&lt;br /&gt;
&lt;br /&gt;
==== Timeline reports ====&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a courses report or users report can be embedded.&lt;br /&gt;
&lt;br /&gt;
Timeline reports should be used when your user or course report includes statistics (course stats or user stats columns). I.e: you can create a report showing the number of user logins to the site during a week or month.&lt;br /&gt;
&lt;br /&gt;
== Reports repository ==&lt;br /&gt;
&lt;br /&gt;
Configurable Reports is connected to two different repositories:&lt;br /&gt;
&lt;br /&gt;
* https://github.com/jleyva/moodle-configurable_reports_repository A repository of any type of reports (users, courses, sql, etc...)&lt;br /&gt;
* https://github.com/jleyva/moodle-custom_sql_report_queries A repository of just SQL queries to be used in the SQL repor type&lt;br /&gt;
&lt;br /&gt;
You can use your custom repository following this instructions:&lt;br /&gt;
&lt;br /&gt;
* First, you need a github account (free)&lt;br /&gt;
&lt;br /&gt;
* Fork any of the previous repositorys, using the GITHUB fork tool&lt;br /&gt;
&lt;br /&gt;
* Using GIT, clone the repository to your computer in order to add your custom reports (some GIT knowledge is needed)&lt;br /&gt;
&lt;br /&gt;
* Go to Administration / Plugins / Blocks / Configurable reports and change the settings for pointing to your repository (github account + / + repository name&lt;br /&gt;
&lt;br /&gt;
* If you want to contribute to the official repository, use the Pull request Github feature (So I can easily add your reports)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Developers documentation ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s very easy to create new report types, components and plugins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Report&#039;&#039;&#039;: A report plugin is a folder located at /report. &lt;br /&gt;
This folder contains a .class.php file with the child - class of the report_base.&lt;br /&gt;
&lt;br /&gt;
You only need to modify a few methods to add a new report type.&lt;br /&gt;
Please, take a look at any of the current reports. The SQL report is an example of a non-typical report, &lt;br /&gt;
meanwhile the users and courses reports are standard reports.&lt;br /&gt;
&lt;br /&gt;
The best way to create a report is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Component&#039;&#039;&#039;: A component is part of a report, a component may be used by more than one report.&lt;br /&gt;
The main Component is the component Columns, that is used to add the columns of a report.&lt;br /&gt;
&lt;br /&gt;
Others components are filters, permissions, plot, calculations..&lt;br /&gt;
&lt;br /&gt;
The best way to create a component is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plugin&#039;&#039;&#039;: A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc.)&lt;br /&gt;
A plugin usually works for a unique report, but there are plugins that work for more than one report.&lt;br /&gt;
The best way to create a plugin is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
== How to request a new feature ==&lt;br /&gt;
&lt;br /&gt;
* Go to the Plugin Tracker http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
* Check in the open issues if your feature have been already requested http://tracker.moodle.org/secure/IssueNavigator.jspa?reset=true&amp;amp;jqlQuery=project+%3D+CONTRIB+AND+component+%3D+%22Block%3A+Configurable+report%22+AND+status+%3D+Open+ORDER+BY+priority+DESC&amp;amp;mode=hide&lt;br /&gt;
* If not, create a New issue (Component: Non-core contributed modules Issue type: New feature) (You have to register yourself in the tracker)&lt;br /&gt;
* Select the component Block: Configurable Reports and your Moodle version&lt;br /&gt;
* Explain in the Description field your needs&lt;br /&gt;
* If you have funding, you can contact me using the forum or the moodle internal messaging system, since I work for a Moodle Partner I can work on your request.&lt;br /&gt;
* Vote and Watch the issue you have created&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
Juan Leyva [http://moodle.org/user/view.php?id=49568&amp;amp;course=1 Moodle profile]&lt;br /&gt;
&lt;br /&gt;
[http://twitter.com/jleyvadelgado Follow me in Twitter]&lt;br /&gt;
&lt;br /&gt;
== Screenshots ==&lt;br /&gt;
&lt;br /&gt;
=== Users report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_user_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SQL report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_sql_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
* CONTRIB-2386&lt;br /&gt;
* [https://tracker.moodle.org/issues/?jql=project%20%3D%20CONTRIB%20AND%20component%20%3D%20%22Block%3A%20Configurable%20report%22 Block: Configurable reports] Tracker component&lt;br /&gt;
* [http://moodle.org/plugins/view.php?plugin=block_configurable_reports Modules &amp;amp; Plugins] database entry&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=159820 Help forum]&lt;br /&gt;
* [[ad-hoc_contributed_reports|contributed reports]] (in plain SQL)&lt;br /&gt;
* [https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]&lt;br /&gt;
* [https://www.youtube.com/watch?v=lF6CuY2Qiw0 Configurable Reports as a Learning Analytics Tool] - iMoot 2015 presentation by Elizabeth Dalton&lt;br /&gt;
* [http://opensourceelearning.blogspot.co.za/2015/08/moodle-configurable-reports-plugin-all.html All Variables and Filters] - Lists the Variables and Filters you can use in a report&lt;br /&gt;
&lt;br /&gt;
[[Category:Report]]&lt;br /&gt;
[[Category:Contributed_code]]&lt;br /&gt;
&lt;br /&gt;
[[es:blocks/configurable_reports/]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Redis_cache_store&amp;diff=134005</id>
		<title>Redis cache store</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Redis_cache_store&amp;diff=134005"/>
		<updated>2019-05-22T09:26:04Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Performance}}&lt;br /&gt;
The Redis cache store is one of the best options to handle session and application cache as it supports: data guarantee, locking, key awareness. (and also can be used for [[Session_handling#Redis_session_driver|user&#039;s sessions caching]] in the config.php file)&lt;br /&gt;
&lt;br /&gt;
Before Redis is available as a cache store, you will need to install [[Redis]] service (daemon) on your Moodle server, locally in case of a single Moodle app node architecture or externally if you are using a cluster of Moodle nodes. only then, you can configure Redis as an application or session level cache store.&lt;br /&gt;
&lt;br /&gt;
If you are configuring a cluster of Moodle servers/nodes, the [[Redis]] service (daemon) should be installed on an external server and all Moodle nodes (servers/instances) should point to that external Redis. so all user&#039;s data is available when the user is using (connected to) any of the Moodle nodes, in case the user&#039;s connection is not persistent (sticky) to a specific node for the entire Moodle session. An external Redis (NoSQL) service can be installed on the main SQL server alongside the MySQL/MariaDB service, just make sure you have enough memory allocated on that server for both services. &lt;br /&gt;
&lt;br /&gt;
A good practice is to give the [[Redis]] cache store prefix a proper short name and not leave it empty, as later on, it might conflict with user&#039;s session Redis cache you might choose to use, or other Moodle instances that will be installed on the same server. for example &amp;quot;my-school-name_cs_&amp;quot;, where you replace &amp;quot;my-school-name&amp;quot; with your short school name. (and if you are also using a user&#039;s session store on the config.php file, you might like to prefix it with &amp;quot;my-school-name_us_&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
When using a cluster setup with several Moodle instances on each node that belong to different Schools/Institutes/clients, make sure that you use the same Prefix for all Moodle instances that are on different nodes and are of the same School/Institute/Client.&lt;br /&gt;
&lt;br /&gt;
==Installing Redis server==&lt;br /&gt;
* [https://www.linode.com/docs/databases/redis/install-and-configure-redis-on-centos-7 install and configure redis on centos 7]&lt;br /&gt;
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04 install and configure redis on Ubuntu 18.04]&lt;br /&gt;
* [[Session_handling#Redis_session_driver]] and [https://www.digitalocean.com/community/tutorials/how-to-set-up-a-redis-server-as-a-session-handler-for-php-on-ubuntu-14-04 How to Set Up a Redis Server as a Session Handler for PHP]&lt;br /&gt;
==Installing Redis php driver==&lt;br /&gt;
* For CentOS, you can use either [https://rpms.remirepo.net/ Remi] or [https://ius.io/ IUS] repositories, and install the [https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/repoview/php71u-pecl-redis.html php71u-pecl-redis] driver.&lt;br /&gt;
* [https://gist.github.com/hollodotme/418e9b7c6ebc358e7fda Redis php-fpm 7 driver on Ubuntu 14.04]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [https://gist.github.com/kabel/10023961 Monitor Redis stats (a php one page app)]&lt;br /&gt;
* MDL-48468 : Add a Redis cache store to Moodle core&lt;br /&gt;
&lt;br /&gt;
[[de:Redis Cache]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Caching&amp;diff=133982</id>
		<title>Talk:Caching</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Caching&amp;diff=133982"/>
		<updated>2019-05-21T16:18:03Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Retire Memcache / Memcached */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When editing cache mappings most of a Primary store and a Final store setting.  These setting really need to be defined as to their purpose.&lt;br /&gt;
&lt;br /&gt;
=== Redis Cache Store Instance ===&lt;br /&gt;
The &#039;&#039;&#039;Section 6 Adding cache store instances&#039;&#039;&#039; section of this doc has these four options:&lt;br /&gt;
&lt;br /&gt;
    6.1 File cache&lt;br /&gt;
    6.2 Memcache&lt;br /&gt;
    6.3 Memcached&lt;br /&gt;
    6.4 MongoDB&lt;br /&gt;
&lt;br /&gt;
What about Redis? Can a &amp;quot;Redis cache store instance&amp;quot; be used here too? If so, please expand the article to explain this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Memcache / Memcached ===&lt;br /&gt;
As of May 2019 various documents indicate that Memcache and Memcached are old technologies that aren&#039;t fully compatible with PHP 7 anymore. Examples:&lt;br /&gt;
* MDL-55602 says &amp;quot;memcache is not PHP7 compatible&amp;quot;.&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=355932#p1435923 Re: memcached problem]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=371013#p1496352 Re: Memcahed and moodle 3.5]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=366556 Upgrading 3.1.5 to 3.4.1]&lt;br /&gt;
&lt;br /&gt;
Should this Memcache / Memcached section be removed from this documentation, or at least updated to indicate the modern alternatives that should be used instead?&lt;br /&gt;
&lt;br /&gt;
Linked Tracker issue: MDL-65542&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 11:23, 21 May 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Caching&amp;diff=133594</id>
		<title>Talk:Caching</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Caching&amp;diff=133594"/>
		<updated>2019-04-23T14:33:04Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Addd a Redis Cache Store Instance&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When editing cache mappings most of a Primary store and a Final store setting.  These setting really need to be defined as to their purpose.&lt;br /&gt;
&lt;br /&gt;
=== Redis Cache Store Instance ===&lt;br /&gt;
The &#039;&#039;&#039;Section 6 Adding cache store instances&#039;&#039;&#039; section of this doc has these four options:&lt;br /&gt;
&lt;br /&gt;
    6.1 File cache&lt;br /&gt;
    6.2 Memcache&lt;br /&gt;
    6.3 Memcached&lt;br /&gt;
    6.4 MongoDB&lt;br /&gt;
&lt;br /&gt;
What about Redis? Can a &amp;quot;Redis cache store instance&amp;quot; be used here too? If so, please expand the article to explain this.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 14:31, 23 April 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Caching&amp;diff=133593</id>
		<title>Talk:Caching</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Caching&amp;diff=133593"/>
		<updated>2019-04-23T14:32:01Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Addd a Redis Cache Store Instance&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;When editing cache mappings most of a Primary store and a Final store setting.  These setting really need to be defined as to their purpose.&lt;br /&gt;
&lt;br /&gt;
=== Redis Cache Store Instance ===&lt;br /&gt;
The &#039;&#039;&#039;Section 6 Adding cache store instances&#039;&#039;&#039; section of this doc has these options:&lt;br /&gt;
&lt;br /&gt;
    6.1 File cache&lt;br /&gt;
    6.2 Memcache&lt;br /&gt;
    6.3 Memcached&lt;br /&gt;
    6.4 MongoDB&lt;br /&gt;
&lt;br /&gt;
What about Redis? Can a &amp;quot;Redis cache store instance&amp;quot; be used here too? If so, please expand the article to explain this.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 14:31, 23 April 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=No_login&amp;diff=133338</id>
		<title>No login</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=No_login&amp;diff=133338"/>
		<updated>2019-03-15T06:56:18Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also - https link */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Authentication}}&lt;br /&gt;
An administrator may &amp;quot;turn off&amp;quot; or suspend a user&#039;s account by selecting &amp;quot;No Login&amp;quot; in the &amp;quot;Choose an authentication method setting&amp;quot; in the user&#039;s profile, or by ticking the &#039;Suspended account&#039; checkbox.&lt;br /&gt;
&lt;br /&gt;
[[File:newnologin.png]]&lt;br /&gt;
&lt;br /&gt;
Different users have to have unique email addresses in their profile, even when email is not enabled.  When the &amp;quot;No Login&amp;quot; setting is used, the account email may not be re-used to create another account.  This essentially is a way to bar a particular user account from using Moodle for the duration that the account is assigned to this authentication type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=173432 What is the difference between suspending and soft-deleting a user?]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=341147 Suspended vs Authentication: No login?]&lt;br /&gt;
&lt;br /&gt;
[[fr:Pas de connexion]]&lt;br /&gt;
[[de:Kein_Login]]&lt;br /&gt;
[[es:Sin ingreso]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=No_login&amp;diff=133337</id>
		<title>No login</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=No_login&amp;diff=133337"/>
		<updated>2019-03-15T06:55:27Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Authentication}}&lt;br /&gt;
An administrator may &amp;quot;turn off&amp;quot; or suspend a user&#039;s account by selecting &amp;quot;No Login&amp;quot; in the &amp;quot;Choose an authentication method setting&amp;quot; in the user&#039;s profile, or by ticking the &#039;Suspended account&#039; checkbox.&lt;br /&gt;
&lt;br /&gt;
[[File:newnologin.png]]&lt;br /&gt;
&lt;br /&gt;
Different users have to have unique email addresses in their profile, even when email is not enabled.  When the &amp;quot;No Login&amp;quot; setting is used, the account email may not be re-used to create another account.  This essentially is a way to bar a particular user account from using Moodle for the duration that the account is assigned to this authentication type.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=173432 What is the difference between suspending and soft-deleting a user?]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=341147 Suspended vs Authentication: No login?]&lt;br /&gt;
&lt;br /&gt;
[[fr:Pas de connexion]]&lt;br /&gt;
[[de:Kein_Login]]&lt;br /&gt;
[[es:Sin ingreso]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Installing_plugins&amp;diff=133326</id>
		<title>Installing plugins</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Installing_plugins&amp;diff=133326"/>
		<updated>2019-03-11T15:05:12Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Undo revision 133325 by Libertymoodle (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
==Why install additional plugins?==&lt;br /&gt;
&lt;br /&gt;
Plugins enable you to add additional features and functionality to Moodle, such as new activities, new quiz question types, new reports, integrations with other systems and many more. &lt;br /&gt;
&lt;br /&gt;
Note: Certain hosting solutions, such as [https://moodle.com/cloud/ MoodleCloud], prevent plugins being installed from within Moodle.&lt;br /&gt;
&lt;br /&gt;
==Choosing the best plugins for your site==&lt;br /&gt;
&lt;br /&gt;
Note: It is recommended that you proceed with caution and always try installing these plugins in a local experimental server before installing them in a production server.&lt;br /&gt;
&lt;br /&gt;
* Moodle has a [https://moodle.org/plugins/report/index.php?report=favourites&amp;amp;p=0&amp;amp;l=50&amp;amp;s=favourited&amp;amp;d=DESC list of the most favourite plugins], which might be worth considering for adding to your site :)&lt;br /&gt;
* You can find the plugins with the largest number of downloads in the last three months at [https://moodle.org/plugins/stats.php https://moodle.org/plugins/stats.php]. These are the plugins most likely to be most useful for most sites. It would probably be a good idea to consider them first.&lt;br /&gt;
* You can test and try more than 50 of the most popular Moodle plugins at [http://plugins.moodlebites.com plugins.moodlebites.com]&lt;br /&gt;
* See the [https://moodle.org/mod/forum/discuss.php?d=325804 list of (year 2015) favorite plugins] by Gavin Henrick&lt;br /&gt;
* Moodle has a list of plugins that have received the [https://moodle.org/plugins/browse.php?list=award&amp;amp;id=1 Reviewers&#039; choice award]. These are given by the plugins guardians and reviewers for particularly useful, well coded or otherwise interesting plugins. &lt;br /&gt;
* If your Moodle site needs assessment beyond the sixteen [https://docs.moodle.org/38/en/Question_types#Standard_question_types standard question types included in Moodle core], see the many (49 in 2017) available [https://docs.moodle.org/38/en/Third-party_question_types third party question types].&lt;br /&gt;
* Special cases:&lt;br /&gt;
** All plugins with &#039;&#039;mobile&#039;&#039; in their name, are related to [https://docs.moodle.org/38/en/Moodle_Mobile mobile devices].&lt;br /&gt;
&lt;br /&gt;
===Elementary school teaching===&lt;br /&gt;
You might consider some plugins for [[Gamification|gamification]], such as the [https://moodle.org/plugins/mod_quizgame Quizventure].&lt;br /&gt;
&lt;br /&gt;
===Plugins for K-12 teaching===&lt;br /&gt;
For [https://en.wikipedia.org/wiki/K%E2%80%9312 K-12] teaching and learning environments, please consider installing the plugins that are included in the [https://moodle.com/cloud/school/?utm_source=Sendy&amp;amp;utm_medium=Email&amp;amp;utm_campaign=Newsletter_July2016 Moodle for School at MoodleCloud]: &lt;br /&gt;
* [https://moodle.org/plugins/mod_attendance Attendance]&lt;br /&gt;
* [http://bigbluebutton.org/ BigBlueButton]&lt;br /&gt;
* [https://moodle.org/plugins/mod_checklist Checklist]&lt;br /&gt;
* [https://moodle.org/plugins/atto_chemistry Chemistry editor]&lt;br /&gt;
* [https://moodle.org/plugins/mod_choicegroup Group choice]&lt;br /&gt;
* [https://moodle.org/plugins/block_xp Level up!]&lt;br /&gt;
* [https://moodle.org/plugins/mod_quizgame Quizventure]&lt;br /&gt;
* [https://moodle.org/plugins/tinymce_wordcount Word count]&lt;br /&gt;
&lt;br /&gt;
===Plugins for University teaching===&lt;br /&gt;
For universities, there is a [https://docs.moodle.org/38/en/Tertiary_education#Moodle_plugins_by.2Ffor_Universities list of plugins by/for Universities], and a [https://docs.moodle.org/38/en/Tertiary_education#Discipline-specific_plugins link to discipline-specific plugins], which might be worth considering.&lt;br /&gt;
&lt;br /&gt;
== Considerations for production sites (skip if you&#039;re just moodling) ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VERY IMPORTANT&#039;&#039;&#039; Warning: Please be aware that some plugins have not been reviewed, and the quality and/or suitability for your Moodle site has not been checked. Please be careful. It may not do what you expect, it may have serious security issues or it may even not work at all. This is however improving over time with the evolving new plugins directory system.&lt;br /&gt;
&lt;br /&gt;
* If you have a large site for production purposes consider if you &#039;&#039;&#039;really&#039;&#039;&#039; need the plugin? More functionality means more things to support, more things to (potentially) go wrong and more things to worry about at upgrade time. &lt;br /&gt;
* Is the plugin supported and maintained? If something goes wrong can you get support? Will bugs be fixed?&lt;br /&gt;
* If the plugin does not work in a future version of Moodle, what will you do about it?&lt;br /&gt;
* Beware of &#039;&#039;patches&#039;&#039; ([https://moodle.org/plugins/browse.php?list=category&amp;amp;id=38 Moodle Plugins Directory Other category]) ! If a plugin modifies or replaces core files then be very careful. It can only be guaranteed to work with the exact build (version) of Moodle it was created for and is highly unlikely to survive a Moodle upgrade.&lt;br /&gt;
* Look at [https://moodle.org/mod/forum/discuss.php?d=340821#p1373707 this] and [https://moodle.org/mod/forum/discuss.php?d=346296 also this] forum threads of users worried about installing a plugin.&lt;br /&gt;
&lt;br /&gt;
==Installing a plugin==&lt;br /&gt;
&lt;br /&gt;
To install a plugin, its source code must be put (deployed) into the appropriate location inside the Moodle installation directory and the main administration page &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Notifications&#039;&#039; must be visited. There are three ways how the plugin code can be deployed into Moodle.&lt;br /&gt;
&lt;br /&gt;
Plugin code may be deployed from within Moodle, either directly from the Moodle plugins directory or by uploading a ZIP file. The web server process has to have write access to the plugin type folder where the new plugin is to be installed in order to use either of these methods.&lt;br /&gt;
&lt;br /&gt;
Alternatively, a plugin may be deployed manually at the server.&lt;br /&gt;
&lt;br /&gt;
===Installing directly from the Moodle plugins directory===&lt;br /&gt;
&lt;br /&gt;
# Login as an admin and go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Install plugins&#039;&#039;. (If you can&#039;t find this location, then plugin installation is prevented on your site.)&lt;br /&gt;
# Click the button &#039;Install plugins from Moodle plugins directory&#039;.&lt;br /&gt;
# Search for a plugin with an Install button, click the Install button then click Continue.&lt;br /&gt;
# Confirm the installation request&lt;br /&gt;
# Check the plugin validation report&lt;br /&gt;
&lt;br /&gt;
===Installing via uploaded ZIP file===&lt;br /&gt;
&lt;br /&gt;
# Go to the [https://moodle.org/plugins Moodle plugins directory], select your current Moodle version, then choose a plugin with a Download button and download the ZIP file.&lt;br /&gt;
# Login to your Moodle site as an admin and go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Install plugins&#039;&#039;.&lt;br /&gt;
# Upload the ZIP file. You should only be prompted to add extra details (in the Show more section) if your plugin is not automatically detected.&lt;br /&gt;
# If your target directory is not writeable, you will see a warning message.&lt;br /&gt;
# Check the plugin validation report&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:plugin1.png|thumb|Install plugins]]&lt;br /&gt;
| [[File:add-on package validation.png|thumb|Plugin package validation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Installing manually at the server===&lt;br /&gt;
&lt;br /&gt;
If you can&#039;t deploy the plugin code via the administration web interface, you have to copy it to the server file system manually (e.g. if the web server process does not have write access to the Moodle installation tree to do this for you).&lt;br /&gt;
&lt;br /&gt;
First, establish the correct place in the Moodle code tree for the plugin type. Common locations are:&lt;br /&gt;
&lt;br /&gt;
* /path/to/moodle/theme/ - themes&lt;br /&gt;
* /path/to/moodle/mod/ - activity modules and resources&lt;br /&gt;
* /path/to/moodle/blocks/ - sidebar blocks&lt;br /&gt;
* /path/to/moodle/question/type/ - question types&lt;br /&gt;
* /path/to/moodle/course/format/ - course formats&lt;br /&gt;
* /path/to/moodle/admin/report/ - admin reports&lt;br /&gt;
&lt;br /&gt;
See [[:dev:Plugins]] for the full list of all plugin types and their locations within the Moodle tree.&lt;br /&gt;
&lt;br /&gt;
# Go to the [https://moodle.org/plugins Moodle plugins directory]; select your current Moodle version, then choose a plugin with a Download button and download the ZIP file.&lt;br /&gt;
# Upload or copy it to your Moodle server.&lt;br /&gt;
# Unzip it in the right place for the plugin type (or follow the plugin instructions). &lt;br /&gt;
# In your Moodle site (as admin) go to &#039;&#039;Site administration &amp;gt; Notifications&#039;&#039; (you should, for most plugin types, get a message saying the plugin is installed).&lt;br /&gt;
&lt;br /&gt;
Note: The plugin may contain language files.  They&#039;ll be found by your Moodle automatically. These language strings can be customized using the standard &#039;&#039;Site administration &amp;gt; Language&#039;&#039; editing interface. If you get a &amp;quot;Database error&amp;quot; when you try to edit your language files, there is a strong chance that the language files included within the downloaded ZIP file of this plugin have a coding problem. If you delete the &#039;&#039;plugin_name/lang/other_language_different_to_English/&#039;&#039; folder with the new language strings and the database error disappears, this is indeed the case. Please notify the plugin maintainer, so that it can be fixed in future releases.&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
&lt;br /&gt;
===Errors===&lt;br /&gt;
&lt;br /&gt;
If you obtain an error, please [[Debugging|turn debugging on]] to obtain additional information about the cause of the error.&lt;br /&gt;
&lt;br /&gt;
;Database error while doing a language customization : May not be related to the [[Language_customisation#Database_error|Language customization]], but rather a problem with a recently installed plugin.&lt;br /&gt;
&lt;br /&gt;
;tool_installaddon/err_curl_exec - cURL error 60 : This suggests problems with the validation of the SSL certificate of the remote (moodle.org) site. This is also a known problem in Moodle Windows 7 servers running the Moodle package for Windows. See [[SSL certificate for moodle.org]] for more info and possible solutions.&lt;br /&gt;
&lt;br /&gt;
===A file permissions error has occurred===&lt;br /&gt;
&lt;br /&gt;
On certain 3.0.x versions, when installing plugins via the administration interface, the Moodle uses the configuration settings &amp;lt;tt&amp;gt;$CFG-&amp;gt;directorypermissions&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;$CFG-&amp;gt;filepermissions&amp;lt;/tt&amp;gt;. If these are not defined explicitly in your config.php, the default value is set automatically to 777 (rwxrwxrwx) for directories and 666 (rw-rw-rw-) for files (see lib/setup.php).&lt;br /&gt;
&lt;br /&gt;
If this default behaviour does not fit your needs and hosting environment, you may wish to specify more strict setting such as&lt;br /&gt;
&lt;br /&gt;
 $CFG-&amp;gt;directorypermissions = 02750;&lt;br /&gt;
&lt;br /&gt;
A common error after installing plugins is that when you create an instance of the module and then save and display it, it reports the error, &amp;quot;A file permissions error has occurred. Please check the permissions on the script and the directory it is in and try again.&amp;quot; If you get this, the file permissions of the package are mostl likely set to 711 preventing them from running correctly. With your preferred FTP client or via your web hosts control panel, set the file permissions of all the files and directories in the installed module, e.g. /moodle/mod/[myplugin]/ to 755 and then see if you can successfully view the module instance.&lt;br /&gt;
&lt;br /&gt;
===Default exception handler: Error writing to database Debug: Duplicate entry &#039;en_us-...===&lt;br /&gt;
* These errors are usually caused by a third party plugin. &lt;br /&gt;
* To find the involved plugin, go to [http://lang.moodle.org http://lang.moodle.org] and use the AMOS tool to find all the strings with the given string identifier.&lt;br /&gt;
* Remove the suspected plugin and check if the error has disappeared. If so, please contact the plugin maintainer and report this issue.&lt;br /&gt;
* Please see [https://moodle.org/mod/forum/discuss.php?d=219504 this forum thread] for known causes and fixes.&lt;br /&gt;
&lt;br /&gt;
===When installing manually===&lt;br /&gt;
&lt;br /&gt;
* Check the file permissions. The web server needs to be able to read the plugin files. If the the rest of Moodle works then try to make the plugin permissions and ownership match. &lt;br /&gt;
* Did you &#039;&#039;&#039;definitely&#039;&#039;&#039; unzip or install the plugin in the correct place?&lt;br /&gt;
* Because Moodle scans plugin folders for new plugins you cannot have any other files or folders there. Make sure you deleted the zip file and don&#039;t try to rename (for example) an old version of the plugin to some other name - it will break.&lt;br /&gt;
* Make sure the directory name for the plugin is correct. All the names &#039;&#039;&#039;have&#039;&#039;&#039; to match. If you change the name, then it won&#039;t work.&lt;br /&gt;
&lt;br /&gt;
===Obtaining help===&lt;br /&gt;
&lt;br /&gt;
Ask in a forum in [http://moodle.org/course/view.php?id=5 Moodle in English]. Make sure you describe your system (including versions of MySQL, PHP etc.), what you tried and what happened. Copy and paste error messages exactly. Provide the link to the version of the plugin you downloaded (some have very similar names).&lt;br /&gt;
&lt;br /&gt;
==Uninstalling a plugin==&lt;br /&gt;
&lt;br /&gt;
To uninstall a plugin&lt;br /&gt;
# Go to &#039;&#039;Administration&amp;gt; Site Administration &amp;gt; Plugins &amp;gt; Plugins overview&#039;&#039; and click the Uninstall link opposite the plugin you wish to remove&lt;br /&gt;
# Use a file manager to remove/delete the actual plugin directory as instructed, otherwise Moodle will reinstall it next time you access the site administration&lt;br /&gt;
&lt;br /&gt;
==Plugins overview==&lt;br /&gt;
&lt;br /&gt;
[[File:plugins overview.png|thumb|center|400px|Plugins overview highlighting available check button]]&lt;br /&gt;
&lt;br /&gt;
The Plugins overview page in &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Plugins &amp;gt; Plugins overview&#039;&#039; lists all installed plugins, together with the version number,release, availability (enabled or disabled) and settings link (if applicable).&lt;br /&gt;
&lt;br /&gt;
A &#039;Check for available updates&#039; button enables admins to quickly check for any updates available for plugins installed on the site (from the [http://moodle.org/plugins plugins directory]). Any updates available are highlighted, with further information and a download link in the notes column opposite the plugin.&lt;br /&gt;
&lt;br /&gt;
===Plugin updating from within Moodle===&lt;br /&gt;
&lt;br /&gt;
An administrator can enable updates deployment in  &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Server &amp;gt; Update notifications&#039;&#039;. Then when updates are available, &#039;Install this update&#039; buttons are shown on the Plugins overview page. See [[Automatic updates deployment]] for more details.&lt;br /&gt;
&lt;br /&gt;
==Preventing installing plugins from within Moodle==&lt;br /&gt;
&lt;br /&gt;
If required, installing and updating from within Moodle can be prevented by copying the following lines of code from config-dist.php and pasting them in config.php.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// Use the following flag to completely disable the installation of plugins&lt;br /&gt;
// (new plugins, available updates and missing dependencies) and related&lt;br /&gt;
// features (such as cancelling the plugin installation or upgrade) via the&lt;br /&gt;
// server administration web interface.&lt;br /&gt;
$CFG-&amp;gt;disableupdateautodeploy = true;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=325804 list of (year 2015) favorite plugins] by Gavin Henrick&lt;br /&gt;
* [[Notifications]] for further details of update notifications&lt;br /&gt;
* [[Plugin Review Criteria]]&lt;br /&gt;
* [[Plugins FAQ]]&lt;br /&gt;
* Moodle in English [http://moodle.org/mod/forum/view.php?id=44 General plugins forum]&lt;br /&gt;
* [[Installing Moodle from Git repository#Installing a contributed extension from its Git repository|Installing a contributed extension from its Git repository]]&lt;br /&gt;
&lt;br /&gt;
For developers:&lt;br /&gt;
&lt;br /&gt;
*[[:dev:Category:Plugins|Plugins developer documentation]]&lt;br /&gt;
*[[:dev:Plugin validation]]&lt;br /&gt;
*[[:dev:On-click add-on installation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributed code]]&lt;br /&gt;
&lt;br /&gt;
[[de:Plugins installieren]]&lt;br /&gt;
[[es:Instalar complementos]]&lt;br /&gt;
[[fr:Installation de plugins]]&lt;br /&gt;
[[it:Installare plugin]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Installing_plugins&amp;diff=133325</id>
		<title>Installing plugins</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Installing_plugins&amp;diff=133325"/>
		<updated>2019-03-11T15:03:51Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Installing directly from the Moodle plugins directory - disable instructions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
==Why install additional plugins?==&lt;br /&gt;
&lt;br /&gt;
Plugins enable you to add additional features and functionality to Moodle, such as new activities, new quiz question types, new reports, integrations with other systems and many more. &lt;br /&gt;
&lt;br /&gt;
Note: Certain hosting solutions, such as [https://moodle.com/cloud/ MoodleCloud], prevent plugins being installed from within Moodle.&lt;br /&gt;
&lt;br /&gt;
==Choosing the best plugins for your site==&lt;br /&gt;
&lt;br /&gt;
Note: It is recommended that you proceed with caution and always try installing these plugins in a local experimental server before installing them in a production server.&lt;br /&gt;
&lt;br /&gt;
* Moodle has a [https://moodle.org/plugins/report/index.php?report=favourites&amp;amp;p=0&amp;amp;l=50&amp;amp;s=favourited&amp;amp;d=DESC list of the most favourite plugins], which might be worth considering for adding to your site :)&lt;br /&gt;
* You can find the plugins with the largest number of downloads in the last three months at [https://moodle.org/plugins/stats.php https://moodle.org/plugins/stats.php]. These are the plugins most likely to be most useful for most sites. It would probably be a good idea to consider them first.&lt;br /&gt;
* You can test and try more than 50 of the most popular Moodle plugins at [http://plugins.moodlebites.com plugins.moodlebites.com]&lt;br /&gt;
* See the [https://moodle.org/mod/forum/discuss.php?d=325804 list of (year 2015) favorite plugins] by Gavin Henrick&lt;br /&gt;
* Moodle has a list of plugins that have received the [https://moodle.org/plugins/browse.php?list=award&amp;amp;id=1 Reviewers&#039; choice award]. These are given by the plugins guardians and reviewers for particularly useful, well coded or otherwise interesting plugins. &lt;br /&gt;
* If your Moodle site needs assessment beyond the sixteen [https://docs.moodle.org/38/en/Question_types#Standard_question_types standard question types included in Moodle core], see the many (49 in 2017) available [https://docs.moodle.org/38/en/Third-party_question_types third party question types].&lt;br /&gt;
* Special cases:&lt;br /&gt;
** All plugins with &#039;&#039;mobile&#039;&#039; in their name, are related to [https://docs.moodle.org/38/en/Moodle_Mobile mobile devices].&lt;br /&gt;
&lt;br /&gt;
===Elementary school teaching===&lt;br /&gt;
You might consider some plugins for [[Gamification|gamification]], such as the [https://moodle.org/plugins/mod_quizgame Quizventure].&lt;br /&gt;
&lt;br /&gt;
===Plugins for K-12 teaching===&lt;br /&gt;
For [https://en.wikipedia.org/wiki/K%E2%80%9312 K-12] teaching and learning environments, please consider installing the plugins that are included in the [https://moodle.com/cloud/school/?utm_source=Sendy&amp;amp;utm_medium=Email&amp;amp;utm_campaign=Newsletter_July2016 Moodle for School at MoodleCloud]: &lt;br /&gt;
* [https://moodle.org/plugins/mod_attendance Attendance]&lt;br /&gt;
* [http://bigbluebutton.org/ BigBlueButton]&lt;br /&gt;
* [https://moodle.org/plugins/mod_checklist Checklist]&lt;br /&gt;
* [https://moodle.org/plugins/atto_chemistry Chemistry editor]&lt;br /&gt;
* [https://moodle.org/plugins/mod_choicegroup Group choice]&lt;br /&gt;
* [https://moodle.org/plugins/block_xp Level up!]&lt;br /&gt;
* [https://moodle.org/plugins/mod_quizgame Quizventure]&lt;br /&gt;
* [https://moodle.org/plugins/tinymce_wordcount Word count]&lt;br /&gt;
&lt;br /&gt;
===Plugins for University teaching===&lt;br /&gt;
For universities, there is a [https://docs.moodle.org/38/en/Tertiary_education#Moodle_plugins_by.2Ffor_Universities list of plugins by/for Universities], and a [https://docs.moodle.org/38/en/Tertiary_education#Discipline-specific_plugins link to discipline-specific plugins], which might be worth considering.&lt;br /&gt;
&lt;br /&gt;
== Considerations for production sites (skip if you&#039;re just moodling) ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;VERY IMPORTANT&#039;&#039;&#039; Warning: Please be aware that some plugins have not been reviewed, and the quality and/or suitability for your Moodle site has not been checked. Please be careful. It may not do what you expect, it may have serious security issues or it may even not work at all. This is however improving over time with the evolving new plugins directory system.&lt;br /&gt;
&lt;br /&gt;
* If you have a large site for production purposes consider if you &#039;&#039;&#039;really&#039;&#039;&#039; need the plugin? More functionality means more things to support, more things to (potentially) go wrong and more things to worry about at upgrade time. &lt;br /&gt;
* Is the plugin supported and maintained? If something goes wrong can you get support? Will bugs be fixed?&lt;br /&gt;
* If the plugin does not work in a future version of Moodle, what will you do about it?&lt;br /&gt;
* Beware of &#039;&#039;patches&#039;&#039; ([https://moodle.org/plugins/browse.php?list=category&amp;amp;id=38 Moodle Plugins Directory Other category]) ! If a plugin modifies or replaces core files then be very careful. It can only be guaranteed to work with the exact build (version) of Moodle it was created for and is highly unlikely to survive a Moodle upgrade.&lt;br /&gt;
* Look at [https://moodle.org/mod/forum/discuss.php?d=340821#p1373707 this] and [https://moodle.org/mod/forum/discuss.php?d=346296 also this] forum threads of users worried about installing a plugin.&lt;br /&gt;
&lt;br /&gt;
==Installing a plugin==&lt;br /&gt;
&lt;br /&gt;
To install a plugin, its source code must be put (deployed) into the appropriate location inside the Moodle installation directory and the main administration page &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Notifications&#039;&#039; must be visited. There are three ways how the plugin code can be deployed into Moodle.&lt;br /&gt;
&lt;br /&gt;
Plugin code may be deployed from within Moodle, either directly from the Moodle plugins directory or by uploading a ZIP file. The web server process has to have write access to the plugin type folder where the new plugin is to be installed in order to use either of these methods.&lt;br /&gt;
&lt;br /&gt;
Alternatively, a plugin may be deployed manually at the server.&lt;br /&gt;
&lt;br /&gt;
===Installing directly from the Moodle plugins directory===&lt;br /&gt;
&lt;br /&gt;
# Login as an admin and go to &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Install plugins&#039;&#039;. (If you can&#039;t find this location, then plugin installation is prevented on your site. Refer to [https://docs.moodle.org/38/en/Automatic_updates_deployment#Disabling_updates_deployment Disabling_updates_deployment] for details on how to enable it.)&lt;br /&gt;
# Click the button &#039;Install plugins from Moodle plugins directory&#039;.&lt;br /&gt;
# Search for a plugin with an Install button, click the Install button then click Continue.&lt;br /&gt;
# Confirm the installation request&lt;br /&gt;
# Check the plugin validation report&lt;br /&gt;
&lt;br /&gt;
===Installing via uploaded ZIP file===&lt;br /&gt;
&lt;br /&gt;
# Go to the [https://moodle.org/plugins Moodle plugins directory], select your current Moodle version, then choose a plugin with a Download button and download the ZIP file.&lt;br /&gt;
# Login to your Moodle site as an admin and go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Install plugins&#039;&#039;.&lt;br /&gt;
# Upload the ZIP file. You should only be prompted to add extra details (in the Show more section) if your plugin is not automatically detected.&lt;br /&gt;
# If your target directory is not writeable, you will see a warning message.&lt;br /&gt;
# Check the plugin validation report&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:plugin1.png|thumb|Install plugins]]&lt;br /&gt;
| [[File:add-on package validation.png|thumb|Plugin package validation]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Installing manually at the server===&lt;br /&gt;
&lt;br /&gt;
If you can&#039;t deploy the plugin code via the administration web interface, you have to copy it to the server file system manually (e.g. if the web server process does not have write access to the Moodle installation tree to do this for you).&lt;br /&gt;
&lt;br /&gt;
First, establish the correct place in the Moodle code tree for the plugin type. Common locations are:&lt;br /&gt;
&lt;br /&gt;
* /path/to/moodle/theme/ - themes&lt;br /&gt;
* /path/to/moodle/mod/ - activity modules and resources&lt;br /&gt;
* /path/to/moodle/blocks/ - sidebar blocks&lt;br /&gt;
* /path/to/moodle/question/type/ - question types&lt;br /&gt;
* /path/to/moodle/course/format/ - course formats&lt;br /&gt;
* /path/to/moodle/admin/report/ - admin reports&lt;br /&gt;
&lt;br /&gt;
See [[:dev:Plugins]] for the full list of all plugin types and their locations within the Moodle tree.&lt;br /&gt;
&lt;br /&gt;
# Go to the [https://moodle.org/plugins Moodle plugins directory]; select your current Moodle version, then choose a plugin with a Download button and download the ZIP file.&lt;br /&gt;
# Upload or copy it to your Moodle server.&lt;br /&gt;
# Unzip it in the right place for the plugin type (or follow the plugin instructions). &lt;br /&gt;
# In your Moodle site (as admin) go to &#039;&#039;Site administration &amp;gt; Notifications&#039;&#039; (you should, for most plugin types, get a message saying the plugin is installed).&lt;br /&gt;
&lt;br /&gt;
Note: The plugin may contain language files.  They&#039;ll be found by your Moodle automatically. These language strings can be customized using the standard &#039;&#039;Site administration &amp;gt; Language&#039;&#039; editing interface. If you get a &amp;quot;Database error&amp;quot; when you try to edit your language files, there is a strong chance that the language files included within the downloaded ZIP file of this plugin have a coding problem. If you delete the &#039;&#039;plugin_name/lang/other_language_different_to_English/&#039;&#039; folder with the new language strings and the database error disappears, this is indeed the case. Please notify the plugin maintainer, so that it can be fixed in future releases.&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
&lt;br /&gt;
===Errors===&lt;br /&gt;
&lt;br /&gt;
If you obtain an error, please [[Debugging|turn debugging on]] to obtain additional information about the cause of the error.&lt;br /&gt;
&lt;br /&gt;
;Database error while doing a language customization : May not be related to the [[Language_customisation#Database_error|Language customization]], but rather a problem with a recently installed plugin.&lt;br /&gt;
&lt;br /&gt;
;tool_installaddon/err_curl_exec - cURL error 60 : This suggests problems with the validation of the SSL certificate of the remote (moodle.org) site. This is also a known problem in Moodle Windows 7 servers running the Moodle package for Windows. See [[SSL certificate for moodle.org]] for more info and possible solutions.&lt;br /&gt;
&lt;br /&gt;
===A file permissions error has occurred===&lt;br /&gt;
&lt;br /&gt;
On certain 3.0.x versions, when installing plugins via the administration interface, the Moodle uses the configuration settings &amp;lt;tt&amp;gt;$CFG-&amp;gt;directorypermissions&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;$CFG-&amp;gt;filepermissions&amp;lt;/tt&amp;gt;. If these are not defined explicitly in your config.php, the default value is set automatically to 777 (rwxrwxrwx) for directories and 666 (rw-rw-rw-) for files (see lib/setup.php).&lt;br /&gt;
&lt;br /&gt;
If this default behaviour does not fit your needs and hosting environment, you may wish to specify more strict setting such as&lt;br /&gt;
&lt;br /&gt;
 $CFG-&amp;gt;directorypermissions = 02750;&lt;br /&gt;
&lt;br /&gt;
A common error after installing plugins is that when you create an instance of the module and then save and display it, it reports the error, &amp;quot;A file permissions error has occurred. Please check the permissions on the script and the directory it is in and try again.&amp;quot; If you get this, the file permissions of the package are mostl likely set to 711 preventing them from running correctly. With your preferred FTP client or via your web hosts control panel, set the file permissions of all the files and directories in the installed module, e.g. /moodle/mod/[myplugin]/ to 755 and then see if you can successfully view the module instance.&lt;br /&gt;
&lt;br /&gt;
===Default exception handler: Error writing to database Debug: Duplicate entry &#039;en_us-...===&lt;br /&gt;
* These errors are usually caused by a third party plugin. &lt;br /&gt;
* To find the involved plugin, go to [http://lang.moodle.org http://lang.moodle.org] and use the AMOS tool to find all the strings with the given string identifier.&lt;br /&gt;
* Remove the suspected plugin and check if the error has disappeared. If so, please contact the plugin maintainer and report this issue.&lt;br /&gt;
* Please see [https://moodle.org/mod/forum/discuss.php?d=219504 this forum thread] for known causes and fixes.&lt;br /&gt;
&lt;br /&gt;
===When installing manually===&lt;br /&gt;
&lt;br /&gt;
* Check the file permissions. The web server needs to be able to read the plugin files. If the the rest of Moodle works then try to make the plugin permissions and ownership match. &lt;br /&gt;
* Did you &#039;&#039;&#039;definitely&#039;&#039;&#039; unzip or install the plugin in the correct place?&lt;br /&gt;
* Because Moodle scans plugin folders for new plugins you cannot have any other files or folders there. Make sure you deleted the zip file and don&#039;t try to rename (for example) an old version of the plugin to some other name - it will break.&lt;br /&gt;
* Make sure the directory name for the plugin is correct. All the names &#039;&#039;&#039;have&#039;&#039;&#039; to match. If you change the name, then it won&#039;t work.&lt;br /&gt;
&lt;br /&gt;
===Obtaining help===&lt;br /&gt;
&lt;br /&gt;
Ask in a forum in [http://moodle.org/course/view.php?id=5 Moodle in English]. Make sure you describe your system (including versions of MySQL, PHP etc.), what you tried and what happened. Copy and paste error messages exactly. Provide the link to the version of the plugin you downloaded (some have very similar names).&lt;br /&gt;
&lt;br /&gt;
==Uninstalling a plugin==&lt;br /&gt;
&lt;br /&gt;
To uninstall a plugin&lt;br /&gt;
# Go to &#039;&#039;Administration&amp;gt; Site Administration &amp;gt; Plugins &amp;gt; Plugins overview&#039;&#039; and click the Uninstall link opposite the plugin you wish to remove&lt;br /&gt;
# Use a file manager to remove/delete the actual plugin directory as instructed, otherwise Moodle will reinstall it next time you access the site administration&lt;br /&gt;
&lt;br /&gt;
==Plugins overview==&lt;br /&gt;
&lt;br /&gt;
[[File:plugins overview.png|thumb|center|400px|Plugins overview highlighting available check button]]&lt;br /&gt;
&lt;br /&gt;
The Plugins overview page in &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Plugins &amp;gt; Plugins overview&#039;&#039; lists all installed plugins, together with the version number,release, availability (enabled or disabled) and settings link (if applicable).&lt;br /&gt;
&lt;br /&gt;
A &#039;Check for available updates&#039; button enables admins to quickly check for any updates available for plugins installed on the site (from the [http://moodle.org/plugins plugins directory]). Any updates available are highlighted, with further information and a download link in the notes column opposite the plugin.&lt;br /&gt;
&lt;br /&gt;
===Plugin updating from within Moodle===&lt;br /&gt;
&lt;br /&gt;
An administrator can enable updates deployment in  &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Server &amp;gt; Update notifications&#039;&#039;. Then when updates are available, &#039;Install this update&#039; buttons are shown on the Plugins overview page. See [[Automatic updates deployment]] for more details.&lt;br /&gt;
&lt;br /&gt;
==Preventing installing plugins from within Moodle==&lt;br /&gt;
&lt;br /&gt;
If required, installing and updating from within Moodle can be prevented by copying the following lines of code from config-dist.php and pasting them in config.php.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
// Use the following flag to completely disable the installation of plugins&lt;br /&gt;
// (new plugins, available updates and missing dependencies) and related&lt;br /&gt;
// features (such as cancelling the plugin installation or upgrade) via the&lt;br /&gt;
// server administration web interface.&lt;br /&gt;
$CFG-&amp;gt;disableupdateautodeploy = true;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=325804 list of (year 2015) favorite plugins] by Gavin Henrick&lt;br /&gt;
* [[Notifications]] for further details of update notifications&lt;br /&gt;
* [[Plugin Review Criteria]]&lt;br /&gt;
* [[Plugins FAQ]]&lt;br /&gt;
* Moodle in English [http://moodle.org/mod/forum/view.php?id=44 General plugins forum]&lt;br /&gt;
* [[Installing Moodle from Git repository#Installing a contributed extension from its Git repository|Installing a contributed extension from its Git repository]]&lt;br /&gt;
&lt;br /&gt;
For developers:&lt;br /&gt;
&lt;br /&gt;
*[[:dev:Category:Plugins|Plugins developer documentation]]&lt;br /&gt;
*[[:dev:Plugin validation]]&lt;br /&gt;
*[[:dev:On-click add-on installation]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributed code]]&lt;br /&gt;
&lt;br /&gt;
[[de:Plugins installieren]]&lt;br /&gt;
[[es:Instalar complementos]]&lt;br /&gt;
[[fr:Installation de plugins]]&lt;br /&gt;
[[it:Installare plugin]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Capabilities/mod/quiz:manage&amp;diff=133324</id>
		<title>Talk:Capabilities/mod/quiz:manage</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Capabilities/mod/quiz:manage&amp;diff=133324"/>
		<updated>2019-03-11T11:17:25Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Request for clarity */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The one line explanation on this page says: &amp;quot;This allows a user to manage quizzes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
What does that mean? When managing quizzes what can you do and what can&#039;t you do? &lt;br /&gt;
&lt;br /&gt;
Can someone expand this doc to answer that and clarify the meaning of &amp;quot;This allows a user to manage quizzes&amp;quot;. I&#039;m not sure what that means.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 11:16, 11 March 2019 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Moodle_migration&amp;diff=132846</id>
		<title>Moodle migration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Moodle_migration&amp;diff=132846"/>
		<updated>2018-12-19T09:56:06Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Formatting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
There may be times when you need to move your Moodle site from one server to another. For example, moving a Moodle site from shared hosting service&#039;s server to a dedicated server.&lt;br /&gt;
&lt;br /&gt;
==Recommended method==&lt;br /&gt;
&lt;br /&gt;
This involves moving a whole site from one server to another. If you are changing the domain/IP address to the new server you need to do these steps:&lt;br /&gt;
&lt;br /&gt;
===Turn on maintenance mode===&lt;br /&gt;
&lt;br /&gt;
Place your current Moodle site into [[Maintenance mode]] via &#039;&#039;Site Administration &amp;gt; Server &amp;gt; Maintenance Mode&#039;&#039; to prevent any further additions to the Moodle database. Don&#039;t let administrators login during the migration as they are not affected by the maintenance mode setting.&lt;br /&gt;
&lt;br /&gt;
===Backup the Moodle database on the old sever===&lt;br /&gt;
&lt;br /&gt;
The right way to back up your database depends on which database system you are using. The instructions below are one way to back up a MySQL database. Another option would be to use a tool like phpMyAdmin to manually make a backup. The documentation for your database will give more options. There are many ways to do such backups. Here is an outline of a little script you can run from command line on Unix to backup the database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /my/backup/directory&lt;br /&gt;
mv moodle-database.sql.gz moodle-database-old.sql.gz&lt;br /&gt;
mysqldump -h example.com -u myusername -p&#039;mypassword&#039; -C -Q -e --create-options mydatabasename &amp;gt; moodle-database.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
If you only write &amp;quot;-p&amp;quot; without your password, you will be prompted for it.&lt;br /&gt;
&lt;br /&gt;
=== Restore the database backup to the new server ===&lt;br /&gt;
&lt;br /&gt;
Copy the database back up files to the new server and restore into the new database server.&lt;br /&gt;
&lt;br /&gt;
Once you have created the new database on the new server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;mysql -p new_database &amp;lt; moodle-database.sql&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For other databases, follow their instructions for restoring a backup. &lt;br /&gt;
&lt;br /&gt;
===Copy moodledata from the old server to the new server===&lt;br /&gt;
&lt;br /&gt;
Copy the contents of your data directory (check for the value in &amp;lt;code&amp;gt;$CFG-&amp;gt;dataroot&amp;lt;/code&amp;gt;) to the new server. This can be a lot of data, so consider using a good data copying tool like [https://rsync.samba.org/ rsync]. If using an FTP client, the transfer of the &amp;lt;code&amp;gt;filedir&amp;lt;/code&amp;gt; folder must be in &#039;&#039;&#039;BINARY&#039;&#039;&#039; mode or the files will get corrupted in the process.&lt;br /&gt;
&lt;br /&gt;
NB: It is not necessary to copy the contents of these directories:&lt;br /&gt;
* /moodledata/cache&lt;br /&gt;
* /moodledata/localcache&lt;br /&gt;
* /moodledata/sessions&lt;br /&gt;
* /moodledata/temp&lt;br /&gt;
* /moodledata/trashdir &lt;br /&gt;
Omitting these files will reduce transfer time substantially.&lt;br /&gt;
&lt;br /&gt;
Check the file permissions of the copied files. The web server needs read and write access.&lt;br /&gt;
&lt;br /&gt;
===Copy the Moodle code from the old server to the new server===&lt;br /&gt;
&lt;br /&gt;
You will need to copy the Moodle code itself to the new server (this is the Moodle folder found in your webroot folder e.g. /var/www or public_html). &lt;br /&gt;
&lt;br /&gt;
Check the file permissions of the copied files. The web server needs read access.&lt;br /&gt;
&lt;br /&gt;
===Update config.php with the URL of the new server===&lt;br /&gt;
&lt;br /&gt;
If the migration will move Moodle to a new URL, then update $CFG-&amp;gt;wwwroot in config.php to point to the new location.&lt;br /&gt;
&lt;br /&gt;
Also check the other properties there. Is the path $CFG-&amp;gt;moodledata still correct? Do the database connection settings need to be changed?&lt;br /&gt;
&lt;br /&gt;
===Test the copied site===&lt;br /&gt;
&lt;br /&gt;
You should now be able to log into the new site as admin, and verify that most things are working.&lt;br /&gt;
&lt;br /&gt;
===Update links containing wwwroot in the database===&lt;br /&gt;
&lt;br /&gt;
The one thing we have not fixed is any internal links stored in the database. To fix these use the [[Search and replace tool]] by going to {wwwroot}/admin/tool/replace/index.php.&lt;br /&gt;
&lt;br /&gt;
Enter the url for your old server (&amp;lt;nowiki&amp;gt;http://oldserver.com/&amp;lt;/nowiki&amp;gt;) and new server (&amp;lt;nowiki&amp;gt;http://newserver.com/&amp;lt;/nowiki&amp;gt;) and it will fix any links stored in the database.&lt;br /&gt;
&lt;br /&gt;
===Take the site out of maintenance mode===&lt;br /&gt;
&lt;br /&gt;
Test the migration some more, then when you are satisfied, remember to take the site out of maintenance mode.&lt;br /&gt;
&lt;br /&gt;
==Quick and hacky method==&lt;br /&gt;
&lt;br /&gt;
If you have shell access on both servers, here is a quick command-line based method.&lt;br /&gt;
&lt;br /&gt;
*Set up a new empty database on the &#039;&#039;&#039;new&#039;&#039;&#039; server.&lt;br /&gt;
*Place your existing Moodle site into maintenance mode.&lt;br /&gt;
*Login to shell on the &#039;&#039;&#039;old&#039;&#039;&#039; existing server.&lt;br /&gt;
*Use rsync to copy &#039;&#039;&#039;moodledata&#039;&#039;&#039; and &#039;&#039;&#039;public_html&#039;&#039;&#039; or &#039;&#039;&#039;moodle&#039;&#039;&#039; folders (or whatever directory your Moodle install is in) to the new server - execute (replacing caps with your details; SOURCE = the directory you want to copy) for each directory:&lt;br /&gt;
::&amp;lt;code&amp;gt;rsync -av -e ssh SOURCE/ USERNAME@NEW_SERVER.COM:/PATH/TO/DESTINATION/&amp;lt;/code&amp;gt;&lt;br /&gt;
*Dump existing database and move and import into database on new server by executing:&lt;br /&gt;
::&amp;lt;code&amp;gt;mysqldump --allow-keywords --opt -uMySQL_USERNAME -pPASSWORD DATABASE | ssh USER@DOMAIN &amp;quot;mysql -uMySQL_USERNAME -pPASSWORD DATABASE&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
*Replace any links in the database that contin the full site URL:&lt;br /&gt;
::&amp;lt;code&amp;gt;#sed -e &#039;s/oldserver.com/newserver.com/g&#039; oldmysqldump.sql &amp;gt; newmysqldump.sql&amp;lt;/code&amp;gt;&lt;br /&gt;
*On the &#039;&#039;&#039;new server&#039;&#039;&#039;, update &#039;&#039;&#039;config.php&#039;&#039;&#039; with relevant details where applicable (e.g. database name and user details, the wwwroot and the dataroot).&lt;br /&gt;
*Check ownership and permissions are correct on both moodle code and moodledata directories.&lt;br /&gt;
*Make sure everything is working.&lt;br /&gt;
&lt;br /&gt;
Takes about 15 minutes for a small site.  However, transferring several Gigabytes of data for a larger site can take hours depending on your network connection and hard drive read/write speed.&lt;br /&gt;
&lt;br /&gt;
When you are happy all has gone well, set up redirects/make DNS changes if required, take new site out of maintenance mode and &amp;quot;switch off&amp;quot; old site. &lt;br /&gt;
&lt;br /&gt;
*If you are switching the ip address from the old server to the new one, you will need to turn off the old server before firing up the new one to avoid ip addressing conflicts and confusion!&lt;br /&gt;
&lt;br /&gt;
==Other considerations==&lt;br /&gt;
&lt;br /&gt;
===Upgrade Moodle at the same time?===&lt;br /&gt;
&lt;br /&gt;
While doing the work of migrating Moodle, you might want to [[Upgrading | upgrade Moodle]] to the latest version at the same time. On the other hand, if you do that, and something breaks, you won&#039;t be sure which change caused the problem, so the more cautious approach is to change one thing at a time, and test in between to verify that all is well.&lt;br /&gt;
&lt;br /&gt;
===DNS &amp;amp; masquerading changes===&lt;br /&gt;
&lt;br /&gt;
You may have had to change the DNS entries for the new Moodle site. If you have done so, it will take some time for the changes to replicate, so be patient. If your server is located behind a firewall, you may also have to change your firewall rules to allow access to the new server. See the [[Masquerading | masquerading docs]].&lt;br /&gt;
&lt;br /&gt;
===Internal and external access===&lt;br /&gt;
&lt;br /&gt;
If you have a set up where your Moodle site can be accessed via a network and via the internet, ensure you check that the new site can be accessed internally and externally.&lt;br /&gt;
&lt;br /&gt;
===reCAPTCHA===&lt;br /&gt;
If you migrate to a new domain and have setup [[Email-based_self-registration]], you need to create new API-Keys at google. You will find the explanation and links to google  in [[Email-based_self-registration]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Site backup]]&lt;br /&gt;
* [[Site restore]]&lt;br /&gt;
* [[Backup and restore FAQ]]&lt;br /&gt;
&lt;br /&gt;
==Any questions?==&lt;br /&gt;
&lt;br /&gt;
Please post in the [http://moodle.org/mod/forum/view.php?id=28 Installing and upgrading help forum] on moodle.org&lt;br /&gt;
&lt;br /&gt;
[[es:Migración de Moodle]]&lt;br /&gt;
[[fr:Migration de Moodle]]&lt;br /&gt;
[[ja:Moodle移行]]&lt;br /&gt;
[[de:Moodle-Migration]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Moodle_migration&amp;diff=132845</id>
		<title>Moodle migration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Moodle_migration&amp;diff=132845"/>
		<updated>2018-12-19T09:50:06Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Formatting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
There may be times when you need to move your Moodle site from one server to another. For example, moving a Moodle site from shared hosting service&#039;s server to a dedicated server.&lt;br /&gt;
&lt;br /&gt;
==Recommended method==&lt;br /&gt;
&lt;br /&gt;
This involves moving a whole site from one server to another. If you are changing the domain/IP address to the new server you need to do these steps:&lt;br /&gt;
&lt;br /&gt;
===Turn on maintenance mode===&lt;br /&gt;
&lt;br /&gt;
Place your current Moodle site into [[Maintenance mode]] via &#039;&#039;Site Administration &amp;gt; Server &amp;gt; Maintenance Mode&#039;&#039; to prevent any further additions to the Moodle database. Don&#039;t let administrators login during the migration as they are not affected by the maintenance mode setting.&lt;br /&gt;
&lt;br /&gt;
===Backup the Moodle database on the old sever===&lt;br /&gt;
&lt;br /&gt;
The right way to back up your database depends on which database system you are using. The instructions below are one way to back up a MySQL database. Another option would be to use a tool like phpMyAdmin to manually make a backup. The documentation for your database will give more options. There are many ways to do such backups. Here is an outline of a little script you can run from command line on Unix to backup the database:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd /my/backup/directory&lt;br /&gt;
mv moodle-database.sql.gz moodle-database-old.sql.gz&lt;br /&gt;
mysqldump -h example.com -u myusername -p&#039;mypassword&#039; -C -Q -e --create-options mydatabasename &amp;gt; moodle-database.sql&lt;br /&gt;
&amp;lt;/pre&amp;gt; &lt;br /&gt;
If you only write &amp;quot;-p&amp;quot; without your password, you will be prompted for it.&lt;br /&gt;
&lt;br /&gt;
=== Restore the database backup to the new server ===&lt;br /&gt;
&lt;br /&gt;
Copy the database back up files to the new server and restore into the new database server.&lt;br /&gt;
&lt;br /&gt;
Once you have created the new database on the new server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;mysql -p new_database &amp;lt; moodle-database.sql&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For other databases, follow their instructions for restoring a backup. &lt;br /&gt;
&lt;br /&gt;
===Copy moodledata from the old server to the new server===&lt;br /&gt;
&lt;br /&gt;
Copy the contents of your data directory (check for the value in &amp;lt;code&amp;gt;$CFG-&amp;gt;dataroot&amp;lt;/code&amp;gt;) to the new server. This can be a lot of data, so consider using a good data copying tool like [https://rsync.samba.org/ rsync]. If using an FTP client, the transfer of the &amp;lt;code&amp;gt;filedir&amp;lt;/code&amp;gt; folder must be in &#039;&#039;&#039;BINARY&#039;&#039;&#039; mode or the files will get corrupted in the process.&lt;br /&gt;
&lt;br /&gt;
NB: It is not necessary to copy the contents of these directories:&lt;br /&gt;
* /moodledata/cache,&lt;br /&gt;
* /moodledata/localcache,&lt;br /&gt;
* /moodledata/sessions,&lt;br /&gt;
* /moodledata/temp, or&lt;br /&gt;
* /moodledata/trashdir &lt;br /&gt;
Omitting these files will reduce transfer time substantially.&lt;br /&gt;
&lt;br /&gt;
Check the file permissions of the copied files. The web server needs read and write access.&lt;br /&gt;
&lt;br /&gt;
===Copy the Moodle code from the old server to the new server===&lt;br /&gt;
&lt;br /&gt;
You will need to copy the Moodle code itself to the new server (this is the Moodle folder found in your webroot folder e.g. /var/www or public_html). &lt;br /&gt;
&lt;br /&gt;
Check the file permissions of the copied files. The web server needs read access.&lt;br /&gt;
&lt;br /&gt;
===Update config.php with the URL of the new server===&lt;br /&gt;
&lt;br /&gt;
If the migration will move Moodle to a new URL, then update $CFG-&amp;gt;wwwroot in config.php to point to the new location.&lt;br /&gt;
&lt;br /&gt;
Also check the other properties there. Is the path $CFG-&amp;gt;moodledata still correct? Do the database connection settings need to be changed?&lt;br /&gt;
&lt;br /&gt;
===Test the copied site===&lt;br /&gt;
&lt;br /&gt;
You should now be able to log into the new site as admin, and verify that most things are working.&lt;br /&gt;
&lt;br /&gt;
===Update links containing wwwroot in the database===&lt;br /&gt;
&lt;br /&gt;
The one thing we have not fixed is any internal links stored in the database. To fix these use the [[Search and replace tool]] by going to {wwwroot}/admin/tool/replace/index.php.&lt;br /&gt;
&lt;br /&gt;
Enter the url for your old server (&amp;lt;nowiki&amp;gt;http://oldserver.com/&amp;lt;/nowiki&amp;gt;) and new server (&amp;lt;nowiki&amp;gt;http://newserver.com/&amp;lt;/nowiki&amp;gt;) and it will fix any links stored in the database.&lt;br /&gt;
&lt;br /&gt;
===Take the site out of maintenance mode===&lt;br /&gt;
&lt;br /&gt;
Test the migration some more, then when you are satisfied, remember to take the site out of maintenance mode.&lt;br /&gt;
&lt;br /&gt;
==Quick and hacky method==&lt;br /&gt;
&lt;br /&gt;
If you have shell access on both servers, here is a quick command-line based method.&lt;br /&gt;
&lt;br /&gt;
*Set up a new empty database on the &#039;&#039;&#039;new&#039;&#039;&#039; server.&lt;br /&gt;
*Place your existing Moodle site into maintenance mode.&lt;br /&gt;
*Login to shell on the &#039;&#039;&#039;old&#039;&#039;&#039; existing server.&lt;br /&gt;
*Use rsync to copy &#039;&#039;&#039;moodledata&#039;&#039;&#039; and &#039;&#039;&#039;public_html&#039;&#039;&#039; or &#039;&#039;&#039;moodle&#039;&#039;&#039; folders (or whatever directory your Moodle install is in) to the new server - execute (replacing caps with your details; SOURCE = the directory you want to copy) for each directory:&lt;br /&gt;
::&amp;lt;code&amp;gt;rsync -av -e ssh SOURCE/ USERNAME@NEW_SERVER.COM:/PATH/TO/DESTINATION/&amp;lt;/code&amp;gt;&lt;br /&gt;
*Dump existing database and move and import into database on new server by executing:&lt;br /&gt;
::&amp;lt;code&amp;gt;mysqldump --allow-keywords --opt -uMySQL_USERNAME -pPASSWORD DATABASE | ssh USER@DOMAIN &amp;quot;mysql -uMySQL_USERNAME -pPASSWORD DATABASE&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
*Replace any links in the database that contin the full site URL:&lt;br /&gt;
::&amp;lt;code&amp;gt;#sed -e &#039;s/oldserver.com/newserver.com/g&#039; oldmysqldump.sql &amp;gt; newmysqldump.sql&amp;lt;/code&amp;gt;&lt;br /&gt;
*On the &#039;&#039;&#039;new server&#039;&#039;&#039;, update &#039;&#039;&#039;config.php&#039;&#039;&#039; with relevant details where applicable (e.g. database name and user details, the wwwroot and the dataroot).&lt;br /&gt;
*Check ownership and permissions are correct on both moodle code and moodledata directories.&lt;br /&gt;
*Make sure everything is working.&lt;br /&gt;
&lt;br /&gt;
Takes about 15 minutes for a small site.  However, transferring several Gigabytes of data for a larger site can take hours depending on your network connection and hard drive read/write speed.&lt;br /&gt;
&lt;br /&gt;
When you are happy all has gone well, set up redirects/make DNS changes if required, take new site out of maintenance mode and &amp;quot;switch off&amp;quot; old site. &lt;br /&gt;
&lt;br /&gt;
*If you are switching the ip address from the old server to the new one, you will need to turn off the old server before firing up the new one to avoid ip addressing conflicts and confusion!&lt;br /&gt;
&lt;br /&gt;
==Other considerations==&lt;br /&gt;
&lt;br /&gt;
===Upgrade Moodle at the same time?===&lt;br /&gt;
&lt;br /&gt;
While doing the work of migrating Moodle, you might want to [[Upgrading | upgrade Moodle]] to the latest version at the same time. On the other hand, if you do that, and something breaks, you won&#039;t be sure which change caused the problem, so the more cautious approach is to change one thing at a time, and test in between to verify that all is well.&lt;br /&gt;
&lt;br /&gt;
===DNS &amp;amp; masquerading changes===&lt;br /&gt;
&lt;br /&gt;
You may have had to change the DNS entries for the new Moodle site. If you have done so, it will take some time for the changes to replicate, so be patient. If your server is located behind a firewall, you may also have to change your firewall rules to allow access to the new server. See the [[Masquerading | masquerading docs]].&lt;br /&gt;
&lt;br /&gt;
===Internal and external access===&lt;br /&gt;
&lt;br /&gt;
If you have a set up where your Moodle site can be accessed via a network and via the internet, ensure you check that the new site can be accessed internally and externally.&lt;br /&gt;
&lt;br /&gt;
===reCAPTCHA===&lt;br /&gt;
If you migrate to a new domain and have setup [[Email-based_self-registration]], you need to create new API-Keys at google. You will find the explanation and links to google  in [[Email-based_self-registration]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Site backup]]&lt;br /&gt;
* [[Site restore]]&lt;br /&gt;
* [[Backup and restore FAQ]]&lt;br /&gt;
&lt;br /&gt;
==Any questions?==&lt;br /&gt;
&lt;br /&gt;
Please post in the [http://moodle.org/mod/forum/view.php?id=28 Installing and upgrading help forum] on moodle.org&lt;br /&gt;
&lt;br /&gt;
[[es:Migración de Moodle]]&lt;br /&gt;
[[fr:Migration de Moodle]]&lt;br /&gt;
[[ja:Moodle移行]]&lt;br /&gt;
[[de:Moodle-Migration]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Search_and_replace_tool&amp;diff=132130</id>
		<title>Search and replace tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Search_and_replace_tool&amp;diff=132130"/>
		<updated>2018-11-01T13:16:31Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Update warning */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Admin tools}}&lt;br /&gt;
Admins can search and replace text e.g. URLs in their Moodle database using the search and replace tool at &amp;lt;nowiki&amp;gt;http://yourmoodlesite.org/admin/tool/replace/index.php&amp;lt;/nowiki&amp;gt; (replacing yourmoodlesite.org with the address of your Moodle site). This is useful when a [[Moodle migration|Moodle site is moved from one server to another]] or when the URL changes.&lt;br /&gt;
&lt;br /&gt;
Alternatively, a command line script can be used to search and replace text. See [[Administration via command line]] for details.&lt;br /&gt;
&lt;br /&gt;
{{Warning|A database and site backup should be created before performing a search and replace.}}&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Tracker issue MDL-35099 Convert hidden search/replace script into a proper core admin tool&lt;br /&gt;
&lt;br /&gt;
[[es:Herramienta para buscar y remplazar]]&lt;br /&gt;
[[fr: Recherche et remplacement]]&lt;br /&gt;
[[de:Datenbank-Suche]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Search_and_replace_tool&amp;diff=132125</id>
		<title>Talk:Search and replace tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Search_and_replace_tool&amp;diff=132125"/>
		<updated>2018-10-31T11:50:55Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Need to improve &amp;quot;Shorten result if necessary&amp;quot; */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;In recent versions of Moodle this Search and Replace tool has an additional checkbox called &amp;quot;Shorten result if necessary&amp;quot;, so this screenshot is out of date. &lt;br /&gt;
&lt;br /&gt;
What is this &amp;quot;Shorten result if necessary&amp;quot; checkbox? What does &amp;quot;Shorten result if necessary&amp;quot; mean? &lt;br /&gt;
&lt;br /&gt;
And what are &amp;quot;the risks of this operation&amp;quot;? Those risks should be listed here. Not everybody is able to read PHP code to try and work out the risks themselves.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 13:01, 16 September 2014 (WST)&lt;br /&gt;
&lt;br /&gt;
:Thanks Luis, I have removed the out-of-date screenshot. --[[User:Helen Foster|Helen Foster]] ([[User talk:Helen Foster|talk]]) 16:14, 25 August 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
:: What does &amp;quot;Shorten result if necessary&amp;quot; do? Can somebody add an explanation to this topic? --[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 11:50, 31 October 2018 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=HTTPS_conversion_tool&amp;diff=132107</id>
		<title>HTTPS conversion tool</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=HTTPS_conversion_tool&amp;diff=132107"/>
		<updated>2018-10-29T10:19:27Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Add Help argument */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security}}&lt;br /&gt;
[[File:HTTPStool.png|thumb|left|HTTPS conversion tool]]The HTTPS conversion tool in Moodle 3.4 onwards will convert any embedded HTTP content (not links) on your site to HTTPS in order for it to display correctly on your HTTPS site. It is accessed from the HTTP security screen of Site administration, or by typing directly &#039;&#039;YOURMOODLESITE.com&#039;&#039;/admin/tool/httpsreplace/index.php (where YOURMOODLESITE.com is the name of your site).&lt;br /&gt;
&lt;br /&gt;
Before performing the conversion, content will be scanned to find any URLs which may not work after conversion i.e. any domains which do not appear to support HTTPS content. After switching to HTTPS, the content included from these sites will no longer display within Moodle for users with secure modern browsers. These problematic domains will be converted, but obviously won&#039;t work once the conversion is complete, hence they are reported for audit prior to the conversion process. &lt;br /&gt;
&lt;br /&gt;
There is also a CLI conversion tool. To list domains that need conversion:&lt;br /&gt;
&lt;br /&gt;
 php admin/tool/httpsreplace/cli/url_replace.php -l&lt;br /&gt;
&lt;br /&gt;
To perform the conversion:&lt;br /&gt;
&lt;br /&gt;
 php admin/tool/httpsreplace/cli/url_replace.php -r --confirm&lt;br /&gt;
&lt;br /&gt;
To view Help:&lt;br /&gt;
&lt;br /&gt;
 php admin/tool/httpsreplace/cli/url_replace.php -h&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* MDL-46269&lt;br /&gt;
&lt;br /&gt;
[[es:Herramienta para conversión a HTTPS]]&lt;br /&gt;
[[de:HTTPS Konvertierung]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Custom_SQL_queries_report&amp;diff=127064</id>
		<title>Custom SQL queries report</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Custom_SQL_queries_report&amp;diff=127064"/>
		<updated>2017-03-09T09:31:32Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* typo fix */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Sitewide reports}}&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 plugins]] documentation.&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;
===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;
===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;
==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;
===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;
===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;
PostgreSQL version of the Monthly Usage by Role query:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
extract(month from to_timestamp(prefix_stats_user_monthly.timeend)) AS calendar_month,&lt;br /&gt;
extract(year from to_timestamp(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 extract(month from to_timestamp(prefix_stats_user_monthly.timeend)),&lt;br /&gt;
extract(year from to_timestamp(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;
extract(year from to_timestamp(prefix_stats_user_monthly.timeend)), extract(month from to_timestamp(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;
===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;
* [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;
* [http://moodle.org/mod/data/view.php?d=13&amp;amp;rid=2884 Modules and plugins database entry]&lt;br /&gt;
* [[Configurable_reports|Configurable reports]] block&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributed_code]]&lt;br /&gt;
&lt;br /&gt;
[[es:Reportes de consultas personalizadas SQL]]&lt;br /&gt;
[[fr:admin/report/customsql/index]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Moodle_migration&amp;diff=123027</id>
		<title>Talk:Moodle migration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Moodle_migration&amp;diff=123027"/>
		<updated>2016-04-25T09:51:36Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Add info for load balanced Moodle sites */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Moodle on Multiple Servers ==&lt;br /&gt;
This article is written with the assumption that Moodle will be hosted on a single server. But what about large Moodle installations that are hosted on multiple &amp;quot;load balanced&amp;quot; servers? These sites may share the Moodledata folder using e.g. NAS storage. The database may also be hosted on a different database server. Is the migration process any different for these multi-server sites? If so, what needs to be done differently when migrating these sites? Example: how should caching be configured on these multi-server environments?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 17:51, 25 April 2016 (AWST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=122913</id>
		<title>Configurable reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=122913"/>
		<updated>2016-04-14T10:46:05Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox plugin&lt;br /&gt;
|type = Block&lt;br /&gt;
|entry = https://moodle.org/plugins/view.php?plugin=block_configurable_reports&lt;br /&gt;
|tracker = http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
|discussion = https://moodle.org/mod/forum/view.php?id=7979&lt;br /&gt;
|maintainer = [[User:Juan Leyva|Juan Leyva]]&lt;br /&gt;
|float = right&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
# Download the Configurable Reports installation file and unzip it to the &#039;&#039;&#039;\blocks&#039;&#039;&#039; directory in your Moodle folder.&lt;br /&gt;
# Be sure that the final name of the directory is: configurable_reports, the full path in your Moodle installation will be blocks/configurable_reports&lt;br /&gt;
# Login to Moodle as Administrator and click Notifications under Site Administration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information see [[Installing contributed modules or plugins]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This block is a Moodle custom reports builder. It its also connected to a [https://github.com/jleyva/moodle-configurable_reports_repository public repository of sample reports] (only plugin version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
It is designed in a modular way to allow developers to create new plugins in less than an hour.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can create custom reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Anyone with block, managereports or manageownreports permissions at SITE level or COURSE level.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What type of reports can I create?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Courses reports, with information regarding courses.&lt;br /&gt;
&lt;br /&gt;
- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.&lt;br /&gt;
&lt;br /&gt;
- Users reports, with information regarding users and their activity in a course.&lt;br /&gt;
&lt;br /&gt;
- Timeline reports, this is a special type of report that displays a timeline. A course or user report can be embedded in this timeline showing data depending on the start and end time of the current row.&lt;br /&gt;
&lt;br /&gt;
- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as [https://moodle.org/plugins/view.php?plugin=report_customsql Tim Hunt&#039;s Custom SQL queries] plugin.&lt;br /&gt;
&lt;br /&gt;
Note for developers: You can create your own type of reports.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can view the reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When you create a report you can select which users can view it.&lt;br /&gt;
&lt;br /&gt;
The reports are displayed in a block in the course or site frontpage.&lt;br /&gt;
&lt;br /&gt;
== Creating a report ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a very simple process.  &lt;br /&gt;
&lt;br /&gt;
If you are going to create a report for a course, you have to add the block in the course and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
On the other hand, for site reports, add the block in the frontpage and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
You must enter a name, an optional description, and you have to choose the type of report, pagination and exports formats.&lt;br /&gt;
&lt;br /&gt;
Depending on the report choosen, there will be more or less tabs. These are the tabs for the courses and users report:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Columns&#039;&#039;&#039;: Here you can choose the differents columns of your report depending on the type of report. (Course Name, User firstname, etc..)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Conditions&#039;&#039;&#039;: Here you can define the conditions (i.e, only courses from this category, only users from Spain, etc.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ordering&#039;&#039;&#039;: Here you can choose how to order the report using fields and directions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filters&#039;&#039;&#039;: Here you can choose which filters will be displayed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Template&#039;&#039;&#039;: You can modify the report&#039;s layout by creating a template.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Permissions&#039;&#039;&#039;: Here you can choose who can view a report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Calculations&#039;&#039;&#039;: Here you can add calculations for columns, i.e: average of number of users enrolled in courses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plots&#039;&#039;&#039;: Here you can add graphs to your report based on the report columns and values.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;View report&#039;&#039;&#039;: Self explanatory&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a users&#039; report ===&lt;br /&gt;
&lt;br /&gt;
Requirements: &#039;&#039;Users from Spain, but not from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user&#039;s city must be displayed. A pie plot showing the users&#039; cities is required. A calculation table showing the total forum post views is required. The report must be ordered by users&#039; lastname.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how easy it is!&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Enter a name, a description and choose &amp;quot;Users report&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you will be redirected to the first Tab named &amp;quot;Columns&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Columns&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here you can define the report table properties, width, align, cell padding, cell spacing, etc.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User profile field&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Choose the field &amp;quot;firstname&amp;quot; and enter a name for the column in the text field. You can leave the rest of elements blank.&lt;br /&gt;
&lt;br /&gt;
Repeat the process above for the lastname and city fields.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose a module from the list, in this example, a forum.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Adding Conditions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Conditions Tab.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, the Operator &amp;quot;=&amp;quot;, and enter the value &amp;quot;ES&amp;quot; (this is the international code for Spain as Moodle stores it).&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;city&amp;quot;, the Operator &amp;quot;&amp;lt;&amp;gt;&amp;quot;, and enter the value &amp;quot;Madrid&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;Users in current report course&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These are the main conditions of the reports. Note that at the bottom there is a text box called condition, with this text:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;c2 and c1 and c3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Here you can define a logic condition, in this case, we don&#039;t need to edit this condition but you can create complex expressions like:&lt;br /&gt;
&lt;br /&gt;
 (c1 and c2) or (c4 and c3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Ordering&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Ordering Tab.&lt;br /&gt;
&lt;br /&gt;
Add a ordering named &amp;quot;User field ordering&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Lastname&amp;quot; and the ordering &amp;quot;ASC&amp;quot; (Ascending).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Filters Tab.&lt;br /&gt;
&lt;br /&gt;
Add a filter named &amp;quot;User field filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose city.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Permissions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Permissions Tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;User field Value&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, and enter the value &amp;quot;ES&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Here you can add more permissions and a logic condition to be achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Calculations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Calculations tab.&lt;br /&gt;
&lt;br /&gt;
Choose Sum.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Plots&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Plots tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;Pie&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the colum &amp;quot;City&amp;quot; as Name and Value.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville, etc. and test the report.&lt;br /&gt;
&lt;br /&gt;
You can download the report in different formats (ods and xls), remember to check these options in the report page.&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#Users_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a SQL Report ===&lt;br /&gt;
&lt;br /&gt;
You can find a lot of SQL Reports here: [[ad-hoc contributed reports]]&lt;br /&gt;
&lt;br /&gt;
Since this block supports Tim Hunt&#039;s CustomSQL Queries Reports, you can use any query.&lt;br /&gt;
&lt;br /&gt;
Remember to add a &amp;quot;Time filter&amp;quot; if you are going to use reports with time tokens.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&lt;br /&gt;
&lt;br /&gt;
Enter a name, description, choose &amp;quot;SQL&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you redirect to the first Tab named &amp;quot;Custom SQL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add this query (&#039;&#039;Courses activity&#039;&#039;):&lt;br /&gt;
&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;
Go to Calculations Tab&lt;br /&gt;
&lt;br /&gt;
Add a Sum calculation, choose the hits column&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go to Plot&lt;br /&gt;
&lt;br /&gt;
Add a Pie graph, choosing coursename as Name and hits as value&lt;br /&gt;
&lt;br /&gt;
So, here you have a report with a Graph and calculations based on a SQL Query.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can add a Course filter, it&#039;s very easy:&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Courses&lt;br /&gt;
&lt;br /&gt;
Edit the Custom SQL query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &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;
Note that we are adding a token called: %%FILTER_COURSES:l.courseid%% &lt;br /&gt;
&lt;br /&gt;
Go to View report, and you will see a Courses Filter, choose a Course and click on Add, here you have a report filtered.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also add a Starttime and endtime filter&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Start / End date filter&lt;br /&gt;
&lt;br /&gt;
Go to Custom SQL tab, this is the new query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &lt;br /&gt;
%%FILTER_STARTTIME:l.time:&amp;gt;%% %%FILTER_ENDTIME:l.time:&amp;lt;%% &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;
&lt;br /&gt;
If you want to filter text (for example, lastname)&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Search Text filter&lt;br /&gt;
&lt;br /&gt;
Go to Custom SQL tab and type your query. Here is an example for querying the user table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname&lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_SEARCHTEXT:u.lastname:~%%&lt;br /&gt;
ORDER BY u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace WHERE 1=1 with your WHERE criteria. If you do not have any where criteria and do not specify WHERE 1=1, you will receive a SQL error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One more example (for filtering a group of courses by category)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, c.fullname as Course,c.id as CourseID&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;
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
%%FILTER_CATEGORIES:c.category%% &lt;br /&gt;
GROUP BY l.course&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Go to View report, now you can filter by time also&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SQL variables&#039;&#039;&#039;&lt;br /&gt;
If you place this strings in your SQL queries, it will be replaced by the appropriate value (current course id, current user id, Moodle www root (url))&lt;br /&gt;
&lt;br /&gt;
* %%COURSEID%% &lt;br /&gt;
* %%USERID%%&lt;br /&gt;
* %%WWWROOT%%&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#SQL_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a timeline report ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This report assumes that you have created at least one user or course report&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a course report or user report can be embedded.&lt;br /&gt;
&lt;br /&gt;
In this example we are going to create a report showing the user logins to the site during the last month (day per day).&lt;br /&gt;
&lt;br /&gt;
Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)&lt;br /&gt;
&lt;br /&gt;
Select the statistic (User logins)&lt;br /&gt;
&lt;br /&gt;
Create a Timeline report, in the Timeline tab you can select the dates or days of the report (in this case, the last 30 days) and the interval of time for every row.&lt;br /&gt;
&lt;br /&gt;
Add three &amp;quot;Other report column&amp;quot; columns, selecting all the previous user report columns.&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all, you can create a new type of plot (line graph). This graph is suitable for data depending on time.&lt;br /&gt;
&lt;br /&gt;
== Advanced options ==&lt;br /&gt;
&lt;br /&gt;
=== Export and import of reports ===&lt;br /&gt;
&lt;br /&gt;
Embedded reports exporting is not working because the reports include references to another reports. A workaround is edit the imported report for changing the references in the &amp;quot;Other report field&amp;quot; column.&lt;br /&gt;
&lt;br /&gt;
Reports that uses the user module outline column can&#039;t be exported either&lt;br /&gt;
&lt;br /&gt;
=== Use the same report in different courses ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
In order to use the same report in different courses you have to check the &amp;quot;Global report&amp;quot; option where creating a new report. This report will be then displayed in all the courses where the configurable report block is displayed and the block instance settings are set to &amp;quot;Display global reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to display global reports in a certain block instance you can always edit the instance settings for selecting &amp;quot;No&amp;quot; in the &amp;quot;Display global reports&amp;quot; block setting.&lt;br /&gt;
&lt;br /&gt;
Notice that these types of reports inherit the context of the course where is displayed, so any condition related to course inside the report is calculated using the course where the report is being viewed&lt;br /&gt;
&lt;br /&gt;
=== Reports can run on a different DB then the current (production) DB ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings&lt;br /&gt;
&lt;br /&gt;
=== DataTables for the report table ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to enable this functionality&lt;br /&gt;
&lt;br /&gt;
=== CodeMirror.js for highlighting SQL query code ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to disable this functionality&lt;br /&gt;
&lt;br /&gt;
=== Using GITHUB as a repository to distribute and manage sharable SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to point to your own repository&lt;br /&gt;
&lt;br /&gt;
=== Cron SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
=== Settings to control security of SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to change the security level&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
You can customize the report output using a template.&lt;br /&gt;
&lt;br /&gt;
Just enable the Template option in the same name tab.&lt;br /&gt;
&lt;br /&gt;
This is an example html code for displaying a list of users:&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;p align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;##reportname##&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;60%&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Record:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;img src=&amp;quot;http://yourmoodle.com/user/pix.php/[[id]]/f1.jpg&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;h2&amp;gt;[[Firstname]] [[Lastname]]&amp;lt;/h2&amp;gt;&lt;br /&gt;
City: [[City]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Footer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
##graphs## &lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
##exportoptions##&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Embedded reports ===&lt;br /&gt;
&lt;br /&gt;
An embedded report consists in a report&#039;s set of columns that are embedded in another report.&lt;br /&gt;
&lt;br /&gt;
You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type of report&lt;br /&gt;
! Reports that can be embedded&lt;br /&gt;
|-&lt;br /&gt;
| Courses&lt;br /&gt;
| Users&lt;br /&gt;
|-&lt;br /&gt;
| Categories&lt;br /&gt;
| Courses&lt;br /&gt;
|-&lt;br /&gt;
| Timeline&lt;br /&gt;
| Users, courses&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.&lt;br /&gt;
&lt;br /&gt;
To embed a report just add a &amp;quot;Other report&amp;quot; column, a list of your reports will be showed.&lt;br /&gt;
&lt;br /&gt;
Inside a course report you can embed a user report and the other way.&lt;br /&gt;
&lt;br /&gt;
==== Timeline reports ====&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a courses report or users report can be embedded.&lt;br /&gt;
&lt;br /&gt;
Timeline reports should be used when your user or course report includes statistics (course stats or user stats columns). I.e: you can create a report showing the number of user logins to the site during a week or month.&lt;br /&gt;
&lt;br /&gt;
== Reports repository ==&lt;br /&gt;
&lt;br /&gt;
Configurable Reports is connected to two different repositories:&lt;br /&gt;
&lt;br /&gt;
* https://github.com/jleyva/moodle-configurable_reports_repository A repository of any type of reports (users, courses, sql, etc...)&lt;br /&gt;
* https://github.com/jleyva/moodle-custom_sql_report_queries A repository of just SQL queries to be used in the SQL repor type&lt;br /&gt;
&lt;br /&gt;
You can use your custom repository following this instructions:&lt;br /&gt;
&lt;br /&gt;
* First, you need a github account (free)&lt;br /&gt;
&lt;br /&gt;
* Fork any of the previous repositorys, using the GITHUB fork tool&lt;br /&gt;
&lt;br /&gt;
* Using GIT, clone the repository to your computer in order to add your custom reports (some GIT knowledge is needed)&lt;br /&gt;
&lt;br /&gt;
* Go to Administration / Plugins / Blocks / Configurable reports and change the settings for pointing to your repository (github account + / + repository name&lt;br /&gt;
&lt;br /&gt;
* If you want to contribute to the official repository, use the Pull request Github feature (So I can easily add your reports)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Developers documentation ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s very easy to create new report types, components and plugins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Report&#039;&#039;&#039;: A report plugin is a folder located at /report. &lt;br /&gt;
This folder contains a .class.php file with the child - class of the report_base.&lt;br /&gt;
&lt;br /&gt;
You only need to modify a few methods to add a new report type.&lt;br /&gt;
Please, take a look at any of the current reports. The SQL report is an example of a non-typical report, &lt;br /&gt;
meanwhile the users and courses reports are standard reports.&lt;br /&gt;
&lt;br /&gt;
The best way to create a report is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Component&#039;&#039;&#039;: A component is part of a report, a component may be used by more than one report.&lt;br /&gt;
The main Component is the component Columns, that is used to add the columns of a report.&lt;br /&gt;
&lt;br /&gt;
Others components are filters, permissions, plot, calculations..&lt;br /&gt;
&lt;br /&gt;
The best way to create a component is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plugin&#039;&#039;&#039;: A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc.)&lt;br /&gt;
A plugin usually works for a unique report, but there are plugins that work for more than one report.&lt;br /&gt;
The best way to create a plugin is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
== How to request a new feature ==&lt;br /&gt;
&lt;br /&gt;
* Go to the Plugin Tracker http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
* Check in the open issues if your feature have been already requested http://tracker.moodle.org/secure/IssueNavigator.jspa?reset=true&amp;amp;jqlQuery=project+%3D+CONTRIB+AND+component+%3D+%22Block%3A+Configurable+report%22+AND+status+%3D+Open+ORDER+BY+priority+DESC&amp;amp;mode=hide&lt;br /&gt;
* If not, create a New issue (Component: Non-core contributed modules Issue type: New feature) (You have to register yourself in the tracker)&lt;br /&gt;
* Select the component Block: Configurable Reports and your Moodle version&lt;br /&gt;
* Explain in the Description field your needs&lt;br /&gt;
* If you have funding, you can contact me using the forum or the moodle internal messaging system, since I work for a Moodle Partner I can work on your request.&lt;br /&gt;
* Vote and Watch the issue you have created&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
Juan Leyva [http://moodle.org/user/view.php?id=49568&amp;amp;course=1 Moodle profile]&lt;br /&gt;
&lt;br /&gt;
[http://twitter.com/jleyvadelgado Follow me in Twitter]&lt;br /&gt;
&lt;br /&gt;
== Screenshots ==&lt;br /&gt;
&lt;br /&gt;
=== Users report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_user_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SQL report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_sql_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
CONTRIB-2386&lt;br /&gt;
&lt;br /&gt;
[http://tracker.moodle.org/browse/CONTRIB/component/10753 Block: Configurable reports] Tracker component&lt;br /&gt;
&lt;br /&gt;
[http://moodle.org/plugins/view.php?plugin=block_configurable_reports Modules &amp;amp; Plugins] database entry&lt;br /&gt;
&lt;br /&gt;
[http://moodle.org/mod/forum/discuss.php?d=159820 Help forum]&lt;br /&gt;
&lt;br /&gt;
[[ad-hoc_contributed_reports|contributed reports]] (in plain SQL)&lt;br /&gt;
&lt;br /&gt;
[https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=lF6CuY2Qiw0 Configurable Reports as a Learning Analytics Tool] - iMoot 2015 presentation by Elizabeth Dalton&lt;br /&gt;
&lt;br /&gt;
[http://opensourceelearning.blogspot.co.za/2015/08/moodle-configurable-reports-plugin-all.html All Variables and Filters] - Lists the Variables and Filters you can use in a report&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:blocks/configurable_reports/]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=122912</id>
		<title>Configurable reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=122912"/>
		<updated>2016-04-14T10:27:46Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Added See Also link */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox plugin&lt;br /&gt;
|type = Block&lt;br /&gt;
|entry = https://moodle.org/plugins/view.php?plugin=block_configurable_reports&lt;br /&gt;
|tracker = http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
|discussion = https://moodle.org/mod/forum/view.php?id=7979&lt;br /&gt;
|maintainer = [[User:Juan Leyva|Juan Leyva]]&lt;br /&gt;
|float = right&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
# Download the Configurable Reports installation file and unzip it to the &#039;&#039;&#039;\blocks&#039;&#039;&#039; directory in your Moodle folder.&lt;br /&gt;
# Be sure that the final name of the directory is: configurable_reports, the full path in your Moodle installation will be blocks/configurable_reports&lt;br /&gt;
# Login to Moodle as Administrator and click Notifications under Site Administration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information see [[Installing contributed modules or plugins]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This block is a Moodle custom reports builder. It its also connected to a [https://github.com/jleyva/moodle-configurable_reports_repository public repository of sample reports] (only plugin version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
It is designed in a modular way to allow developers to create new plugins in less than an hour.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can create custom reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Anyone with block, managereports or manageownreports permissions at SITE level or COURSE level.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What type of reports can I create?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Courses reports, with information regarding courses.&lt;br /&gt;
&lt;br /&gt;
- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.&lt;br /&gt;
&lt;br /&gt;
- Users reports, with information regarding users and their activity in a course.&lt;br /&gt;
&lt;br /&gt;
- Timeline reports, this is a special type of report that displays a timeline. A course or user report can be embedded in this timeline showing data depending on the start and end time of the current row.&lt;br /&gt;
&lt;br /&gt;
- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as [https://moodle.org/plugins/view.php?plugin=report_customsql Tim Hunt&#039;s Custom SQL queries] plugin.&lt;br /&gt;
&lt;br /&gt;
Note for developers: You can create your own type of reports.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can view the reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When you create a report you can select which users can view it.&lt;br /&gt;
&lt;br /&gt;
The reports are displayed in a block in the course or site frontpage.&lt;br /&gt;
&lt;br /&gt;
== Creating a report ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a very simple process.  &lt;br /&gt;
&lt;br /&gt;
If you are going to create a report for a course, you have to add the block in the course and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
On the other hand, for site reports, add the block in the frontpage and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
You must enter a name, an optional description, and you have to choose the type of report, pagination and exports formats.&lt;br /&gt;
&lt;br /&gt;
Depending on the report choosen, there will be more or less tabs. These are the tabs for the courses and users report:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Columns&#039;&#039;&#039;: Here you can choose the differents columns of your report depending on the type of report. (Course Name, User firstname, etc..)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Conditions&#039;&#039;&#039;: Here you can define the conditions (i.e, only courses from this category, only users from Spain, etc.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ordering&#039;&#039;&#039;: Here you can choose how to order the report using fields and directions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filters&#039;&#039;&#039;: Here you can choose which filters will be displayed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Template&#039;&#039;&#039;: You can modify the report&#039;s layout by creating a template.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Permissions&#039;&#039;&#039;: Here you can choose who can view a report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Calculations&#039;&#039;&#039;: Here you can add calculations for columns, i.e: average of number of users enrolled in courses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plots&#039;&#039;&#039;: Here you can add graphs to your report based on the report columns and values.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;View report&#039;&#039;&#039;: Self explanatory&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a users&#039; report ===&lt;br /&gt;
&lt;br /&gt;
Requirements: &#039;&#039;Users from Spain, but not from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user&#039;s city must be displayed. A pie plot showing the users&#039; cities is required. A calculation table showing the total forum post views is required. The report must be ordered by users&#039; lastname.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how easy it is!&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Enter a name, a description and choose &amp;quot;Users report&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you will be redirected to the first Tab named &amp;quot;Columns&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Columns&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here you can define the report table properties, width, align, cell padding, cell spacing, etc.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User profile field&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Choose the field &amp;quot;firstname&amp;quot; and enter a name for the column in the text field. You can leave the rest of elements blank.&lt;br /&gt;
&lt;br /&gt;
Repeat the process above for the lastname and city fields.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose a module from the list, in this example, a forum.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Adding Conditions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Conditions Tab.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, the Operator &amp;quot;=&amp;quot;, and enter the value &amp;quot;ES&amp;quot; (this is the international code for Spain as Moodle stores it).&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;city&amp;quot;, the Operator &amp;quot;&amp;lt;&amp;gt;&amp;quot;, and enter the value &amp;quot;Madrid&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;Users in current report course&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These are the main conditions of the reports. Note that at the bottom there is a text box called condition, with this text:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;c2 and c1 and c3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Here you can define a logic condition, in this case, we don&#039;t need to edit this condition but you can create complex expressions like:&lt;br /&gt;
&lt;br /&gt;
 (c1 and c2) or (c4 and c3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Ordering&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Ordering Tab.&lt;br /&gt;
&lt;br /&gt;
Add a ordering named &amp;quot;User field ordering&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Lastname&amp;quot; and the ordering &amp;quot;ASC&amp;quot; (Ascending).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Filters Tab.&lt;br /&gt;
&lt;br /&gt;
Add a filter named &amp;quot;User field filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose city.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Permissions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Permissions Tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;User field Value&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, and enter the value &amp;quot;ES&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Here you can add more permissions and a logic condition to be achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Calculations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Calculations tab.&lt;br /&gt;
&lt;br /&gt;
Choose Sum.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Plots&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Plots tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;Pie&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the colum &amp;quot;City&amp;quot; as Name and Value.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville, etc. and test the report.&lt;br /&gt;
&lt;br /&gt;
You can download the report in different formats (ods and xls), remember to check these options in the report page.&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#Users_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a SQL Report ===&lt;br /&gt;
&lt;br /&gt;
You can find a lot of SQL Reports here: [[ad-hoc contributed reports]]&lt;br /&gt;
&lt;br /&gt;
Since this block supports Tim Hunt&#039;s CustomSQL Queries Reports, you can use any query.&lt;br /&gt;
&lt;br /&gt;
Remember to add a &amp;quot;Time filter&amp;quot; if you are going to use reports with time tokens.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&lt;br /&gt;
&lt;br /&gt;
Enter a name, description, choose &amp;quot;SQL&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you redirect to the first Tab named &amp;quot;Custom SQL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add this query (&#039;&#039;Courses activity&#039;&#039;):&lt;br /&gt;
&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;
Go to Calculations Tab&lt;br /&gt;
&lt;br /&gt;
Add a Sum calculation, choose the hits column&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go to Plot&lt;br /&gt;
&lt;br /&gt;
Add a Pie graph, choosing coursename as Name and hits as value&lt;br /&gt;
&lt;br /&gt;
So, here you have a report with a Graph and calculations based on a SQL Query.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can add a Course filter, it&#039;s very easy:&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Courses&lt;br /&gt;
&lt;br /&gt;
Edit the Custom SQL query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &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;
Note that we are adding a token called: %%FILTER_COURSES:l.courseid%% &lt;br /&gt;
&lt;br /&gt;
Go to View report, and you will see a Courses Filter, choose a Course and click on Add, here you have a report filtered.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also add a Starttime and endtime filter&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Start / End date filter&lt;br /&gt;
&lt;br /&gt;
Go to Custom SQL tab, this is the new query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &lt;br /&gt;
%%FILTER_STARTTIME:l.time:&amp;gt;%% %%FILTER_ENDTIME:l.time:&amp;lt;%% &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;
&lt;br /&gt;
If you want to filter text (for example, lastname)&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Search Text filter&lt;br /&gt;
&lt;br /&gt;
Go to Custom SQL tab and type your query. Here is an example for querying the user table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname&lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_SEARCHTEXT:u.lastname:~%%&lt;br /&gt;
ORDER BY u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace WHERE 1=1 with your WHERE criteria. If you do not have any where criteria and do not specify WHERE 1=1, you will receive a SQL error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One more example (for filtering a group of courses by category)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, c.fullname as Course,c.id as CourseID&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;
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
%%FILTER_CATEGORIES:c.category%% &lt;br /&gt;
GROUP BY l.course&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Go to View report, now you can filter by time also&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SQL variables&#039;&#039;&#039;&lt;br /&gt;
If you place this strings in your SQL queries, it will be replaced by the appropriate value (current course id, current user id, Moodle www root (url))&lt;br /&gt;
&lt;br /&gt;
* %%COURSEID%% &lt;br /&gt;
* %%USERID%%&lt;br /&gt;
* %%WWWROOT%%&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#SQL_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a timeline report ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This report assumes that you have created at least one user or course report&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a course report or user report can be embedded.&lt;br /&gt;
&lt;br /&gt;
In this example we are going to create a report showing the user logins to the site during the last month (day per day).&lt;br /&gt;
&lt;br /&gt;
Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)&lt;br /&gt;
&lt;br /&gt;
Select the statistic (User logins)&lt;br /&gt;
&lt;br /&gt;
Create a Timeline report, in the Timeline tab you can select the dates or days of the report (in this case, the last 30 days) and the interval of time for every row.&lt;br /&gt;
&lt;br /&gt;
Add three &amp;quot;Other report column&amp;quot; columns, selecting all the previous user report columns.&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all, you can create a new type of plot (line graph). This graph is suitable for data depending on time.&lt;br /&gt;
&lt;br /&gt;
== Advanced options ==&lt;br /&gt;
&lt;br /&gt;
=== Export and import of reports ===&lt;br /&gt;
&lt;br /&gt;
Embedded reports exporting is not working because the reports include references to another reports. A workaround is edit the imported report for changing the references in the &amp;quot;Other report field&amp;quot; column.&lt;br /&gt;
&lt;br /&gt;
Reports that uses the user module outline column can&#039;t be exported either&lt;br /&gt;
&lt;br /&gt;
=== Use the same report in different courses ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
In order to use the same report in different courses you have to check the &amp;quot;Global report&amp;quot; option where creating a new report. This report will be then displayed in all the courses where the configurable report block is displayed and the block instance settings are set to &amp;quot;Display global reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to display global reports in a certain block instance you can always edit the instance settings for selecting &amp;quot;No&amp;quot; in the &amp;quot;Display global reports&amp;quot; block setting.&lt;br /&gt;
&lt;br /&gt;
Notice that these types of reports inherit the context of the course where is displayed, so any condition related to course inside the report is calculated using the course where the report is being viewed&lt;br /&gt;
&lt;br /&gt;
=== Reports can run on a different DB then the current (production) DB ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings&lt;br /&gt;
&lt;br /&gt;
=== DataTables for the report table ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to enable this functionality&lt;br /&gt;
&lt;br /&gt;
=== CodeMirror.js for highlighting SQL query code ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to disable this functionality&lt;br /&gt;
&lt;br /&gt;
=== Using GITHUB as a repository to distribute and manage sharable SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to point to your own repository&lt;br /&gt;
&lt;br /&gt;
=== Cron SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
=== Settings to control security of SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to change the security level&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
You can customize the report output using a template.&lt;br /&gt;
&lt;br /&gt;
Just enable the Template option in the same name tab.&lt;br /&gt;
&lt;br /&gt;
This is an example html code for displaying a list of users:&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;p align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;##reportname##&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;60%&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Record:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;img src=&amp;quot;http://yourmoodle.com/user/pix.php/[[id]]/f1.jpg&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;h2&amp;gt;[[Firstname]] [[Lastname]]&amp;lt;/h2&amp;gt;&lt;br /&gt;
City: [[City]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Footer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
##graphs## &lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
##exportoptions##&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Embedded reports ===&lt;br /&gt;
&lt;br /&gt;
An embedded report consists in a report&#039;s set of columns that are embedded in another report.&lt;br /&gt;
&lt;br /&gt;
You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type of report&lt;br /&gt;
! Reports that can be embedded&lt;br /&gt;
|-&lt;br /&gt;
| Courses&lt;br /&gt;
| Users&lt;br /&gt;
|-&lt;br /&gt;
| Categories&lt;br /&gt;
| Courses&lt;br /&gt;
|-&lt;br /&gt;
| Timeline&lt;br /&gt;
| Users, courses&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.&lt;br /&gt;
&lt;br /&gt;
To embed a report just add a &amp;quot;Other report&amp;quot; column, a list of your reports will be showed.&lt;br /&gt;
&lt;br /&gt;
Inside a course report you can embed a user report and the other way.&lt;br /&gt;
&lt;br /&gt;
==== Timeline reports ====&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a courses report or users report can be embedded.&lt;br /&gt;
&lt;br /&gt;
Timeline reports should be used when your user or course report includes statistics (course stats or user stats columns). I.e: you can create a report showing the number of user logins to the site during a week or month.&lt;br /&gt;
&lt;br /&gt;
== Reports repository ==&lt;br /&gt;
&lt;br /&gt;
Configurable Reports is connected to two different repositories:&lt;br /&gt;
&lt;br /&gt;
* https://github.com/jleyva/moodle-configurable_reports_repository A repository of any type of reports (users, courses, sql, etc...)&lt;br /&gt;
* https://github.com/jleyva/moodle-custom_sql_report_queries A repository of just SQL queries to be used in the SQL repor type&lt;br /&gt;
&lt;br /&gt;
You can use your custom repository following this instructions:&lt;br /&gt;
&lt;br /&gt;
* First, you need a github account (free)&lt;br /&gt;
&lt;br /&gt;
* Fork any of the previous repositorys, using the GITHUB fork tool&lt;br /&gt;
&lt;br /&gt;
* Using GIT, clone the repository to your computer in order to add your custom reports (some GIT knowledge is needed)&lt;br /&gt;
&lt;br /&gt;
* Go to Administration / Plugins / Blocks / Configurable reports and change the settings for pointing to your repository (github account + / + repository name&lt;br /&gt;
&lt;br /&gt;
* If you want to contribute to the official repository, use the Pull request Github feature (So I can easily add your reports)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Developers documentation ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s very easy to create new report types, components and plugins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Report&#039;&#039;&#039;: A report plugin is a folder located at /report. &lt;br /&gt;
This folder contains a .class.php file with the child - class of the report_base.&lt;br /&gt;
&lt;br /&gt;
You only need to modify a few methods to add a new report type.&lt;br /&gt;
Please, take a look at any of the current reports. The SQL report is an example of a non-typical report, &lt;br /&gt;
meanwhile the users and courses reports are standard reports.&lt;br /&gt;
&lt;br /&gt;
The best way to create a report is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Component&#039;&#039;&#039;: A component is part of a report, a component may be used by more than one report.&lt;br /&gt;
The main Component is the component Columns, that is used to add the columns of a report.&lt;br /&gt;
&lt;br /&gt;
Others components are filters, permissions, plot, calculations..&lt;br /&gt;
&lt;br /&gt;
The best way to create a component is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plugin&#039;&#039;&#039;: A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc.)&lt;br /&gt;
A plugin usually works for a unique report, but there are plugins that work for more than one report.&lt;br /&gt;
The best way to create a plugin is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
== How to request a new feature ==&lt;br /&gt;
&lt;br /&gt;
* Go to the Plugin Tracker http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
* Check in the open issues if your feature have been already requested http://tracker.moodle.org/secure/IssueNavigator.jspa?reset=true&amp;amp;jqlQuery=project+%3D+CONTRIB+AND+component+%3D+%22Block%3A+Configurable+report%22+AND+status+%3D+Open+ORDER+BY+priority+DESC&amp;amp;mode=hide&lt;br /&gt;
* If not, create a New issue (Component: Non-core contributed modules Issue type: New feature) (You have to register yourself in the tracker)&lt;br /&gt;
* Select the component Block: Configurable Reports and your Moodle version&lt;br /&gt;
* Explain in the Description field your needs&lt;br /&gt;
* If you have funding, you can contact me using the forum or the moodle internal messaging system, since I work for a Moodle Partner I can work on your request.&lt;br /&gt;
* Vote and Watch the issue you have created&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
Juan Leyva [http://moodle.org/user/view.php?id=49568&amp;amp;course=1 Moodle profile]&lt;br /&gt;
&lt;br /&gt;
[http://twitter.com/jleyvadelgado Follow me in Twitter]&lt;br /&gt;
&lt;br /&gt;
== Screenshots ==&lt;br /&gt;
&lt;br /&gt;
=== Users report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_user_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SQL report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_sql_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
CONTRIB-2386&lt;br /&gt;
&lt;br /&gt;
[http://tracker.moodle.org/browse/CONTRIB/component/10753 Block: Configurable reports] Tracker component&lt;br /&gt;
&lt;br /&gt;
[http://moodle.org/plugins/view.php?plugin=block_configurable_reports Modules &amp;amp; Plugins] database entry&lt;br /&gt;
&lt;br /&gt;
[http://moodle.org/mod/forum/discuss.php?d=159820 Help forum]&lt;br /&gt;
&lt;br /&gt;
[[ad-hoc_contributed_reports|contributed reports]] (in plain SQL)&lt;br /&gt;
&lt;br /&gt;
[https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]&lt;br /&gt;
&lt;br /&gt;
[https://www.youtube.com/watch?v=lF6CuY2Qiw0 Configurable Reports as a Learning Analytics Tool] - iMoot 2015 presentation by Elizabeth Dalton&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:blocks/configurable_reports/]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=119248</id>
		<title>Configurable reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Configurable_reports&amp;diff=119248"/>
		<updated>2015-07-08T10:52:21Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See Also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Infobox plugin&lt;br /&gt;
|type = Block&lt;br /&gt;
|entry = https://moodle.org/plugins/view.php?plugin=block_configurable_reports&lt;br /&gt;
|tracker = http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
|discussion = https://moodle.org/mod/forum/view.php?id=7979&lt;br /&gt;
|maintainer = [[User:Juan Leyva|Juan Leyva]]&lt;br /&gt;
|float = right&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
# Download the Configurable Reports installation file and unzip it to the &#039;&#039;&#039;\blocks&#039;&#039;&#039; directory in your Moodle folder.&lt;br /&gt;
# Be sure that the final name of the directory is: configurable_reports, the full path in your Moodle installation will be blocks/configurable_reports&lt;br /&gt;
# Login to Moodle as Administrator and click Notifications under Site Administration.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information see [[Installing contributed modules or plugins]]&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This block is a Moodle custom reports builder. It its also connected to a [https://github.com/jleyva/moodle-configurable_reports_repository public repository of sample reports] (only plugin version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
It is designed in a modular way to allow developers to create new plugins in less than an hour.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can create custom reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Anyone with block, managereports or manageownreports permissions at SITE level or COURSE level.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;What type of reports can I create?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Courses reports, with information regarding courses.&lt;br /&gt;
&lt;br /&gt;
- Categories reports, with information regarding categories. A courses report can be embedded in this type of report.&lt;br /&gt;
&lt;br /&gt;
- Users reports, with information regarding users and their activity in a course.&lt;br /&gt;
&lt;br /&gt;
- Timeline reports, this is a special type of report that displays a timeline. A course or user report can be embedded in this timeline showing data depending on the start and end time of the current row.&lt;br /&gt;
&lt;br /&gt;
- Custom SQL Reports, custom SQL queries. This block can use the same SQL queries as [https://moodle.org/plugins/view.php?plugin=report_customsql Tim Hunt&#039;s Custom SQL queries] plugin.&lt;br /&gt;
&lt;br /&gt;
Note for developers: You can create your own type of reports.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Who can view the reports?&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
When you create a report you can select which users can view it.&lt;br /&gt;
&lt;br /&gt;
The reports are displayed in a block in the course or site frontpage.&lt;br /&gt;
&lt;br /&gt;
== Creating a report ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a very simple process.  &lt;br /&gt;
&lt;br /&gt;
If you are going to create a report for a course, you have to add the block in the course and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
On the other hand, for site reports, add the block in the frontpage and click in the &amp;quot;Manage reports&amp;quot; link.&lt;br /&gt;
&lt;br /&gt;
You must enter a name, an optional description, and you have to choose the type of report, pagination and exports formats.&lt;br /&gt;
&lt;br /&gt;
Depending on the report choosen, there will be more or less tabs. These are the tabs for the courses and users report:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Columns&#039;&#039;&#039;: Here you can choose the differents columns of your report depending on the type of report. (Course Name, User firstname, etc..)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Conditions&#039;&#039;&#039;: Here you can define the conditions (i.e, only courses from this category, only users from Spain, etc.)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Ordering&#039;&#039;&#039;: Here you can choose how to order the report using fields and directions.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Filters&#039;&#039;&#039;: Here you can choose which filters will be displayed.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Template&#039;&#039;&#039;: You can modify the report&#039;s layout by creating a template.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Permissions&#039;&#039;&#039;: Here you can choose who can view a report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Calculations&#039;&#039;&#039;: Here you can add calculations for columns, i.e: average of number of users enrolled in courses&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plots&#039;&#039;&#039;: Here you can add graphs to your report based on the report columns and values.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;View report&#039;&#039;&#039;: Self explanatory&lt;br /&gt;
&lt;br /&gt;
== Tutorial ==&lt;br /&gt;
&lt;br /&gt;
=== Creating a users&#039; report ===&lt;br /&gt;
&lt;br /&gt;
Requirements: &#039;&#039;Users from Spain, but not from Madrid, in this course. This report can be viewed only by users from Spain. A filter based on the user&#039;s city must be displayed. A pie plot showing the users&#039; cities is required. A calculation table showing the total forum post views is required. The report must be ordered by users&#039; lastname.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Let&#039;s see how easy it is!&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Enter a name, a description and choose &amp;quot;Users report&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you will be redirected to the first Tab named &amp;quot;Columns&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Columns&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Here you can define the report table properties, width, align, cell padding, cell spacing, etc.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User profile field&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Choose the field &amp;quot;firstname&amp;quot; and enter a name for the column in the text field. You can leave the rest of elements blank.&lt;br /&gt;
&lt;br /&gt;
Repeat the process above for the lastname and city fields.&lt;br /&gt;
&lt;br /&gt;
Add a Column called &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose a module from the list, in this example, a forum.&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&#039;&#039;&#039;Adding Conditions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Conditions Tab.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, the Operator &amp;quot;=&amp;quot;, and enter the value &amp;quot;ES&amp;quot; (this is the international code for Spain as Moodle stores it).&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;User field Condition&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;city&amp;quot;, the Operator &amp;quot;&amp;lt;&amp;gt;&amp;quot;, and enter the value &amp;quot;Madrid&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Add a Condition named &amp;quot;Users in current report course&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
These are the main conditions of the reports. Note that at the bottom there is a text box called condition, with this text:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;c2 and c1 and c3&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Here you can define a logic condition, in this case, we don&#039;t need to edit this condition but you can create complex expressions like:&lt;br /&gt;
&lt;br /&gt;
 (c1 and c2) or (c4 and c3)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Ordering&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Ordering Tab.&lt;br /&gt;
&lt;br /&gt;
Add a ordering named &amp;quot;User field ordering&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Lastname&amp;quot; and the ordering &amp;quot;ASC&amp;quot; (Ascending).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Filters&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Filters Tab.&lt;br /&gt;
&lt;br /&gt;
Add a filter named &amp;quot;User field filter&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose city.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Permissions&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Permissions Tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;User field Value&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;Country&amp;quot;, and enter the value &amp;quot;ES&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Here you can add more permissions and a logic condition to be achieved.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Calculations&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Calculations tab.&lt;br /&gt;
&lt;br /&gt;
Choose Sum.&lt;br /&gt;
&lt;br /&gt;
Choose the column &amp;quot;User module actions&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Adding Plots&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Click on the Plots tab.&lt;br /&gt;
&lt;br /&gt;
Choose &amp;quot;Pie&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Choose the colum &amp;quot;City&amp;quot; as Name and Value.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally, add a few users in Moodle with the country Spain, and different cities, Madrid, Barcelona, Seville, etc. and test the report.&lt;br /&gt;
&lt;br /&gt;
You can download the report in different formats (ods and xls), remember to check these options in the report page.&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#Users_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a SQL Report ===&lt;br /&gt;
&lt;br /&gt;
You can find a lot of SQL Reports here: [[ad-hoc contributed reports]]&lt;br /&gt;
&lt;br /&gt;
Since this block supports Tim Hunt&#039;s CustomSQL Queries Reports, you can use any query.&lt;br /&gt;
&lt;br /&gt;
Remember to add a &amp;quot;Time filter&amp;quot; if you are going to use reports with time tokens.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First of all, install the block.&lt;br /&gt;
&lt;br /&gt;
Go to the course where the report will be created.&lt;br /&gt;
&lt;br /&gt;
Add an instance of the Custom Reports block.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Manage reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Click on &amp;quot;Add report&lt;br /&gt;
&lt;br /&gt;
Enter a name, description, choose &amp;quot;SQL&amp;quot; as Type of Report&lt;br /&gt;
&lt;br /&gt;
The report will be saved and you redirect to the first Tab named &amp;quot;Custom SQL&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Add this query (&#039;&#039;Courses activity&#039;&#039;):&lt;br /&gt;
&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;
Go to Calculations Tab&lt;br /&gt;
&lt;br /&gt;
Add a Sum calculation, choose the hits column&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Go to Plot&lt;br /&gt;
&lt;br /&gt;
Add a Pie graph, choosing coursename as Name and hits as value&lt;br /&gt;
&lt;br /&gt;
So, here you have a report with a Graph and calculations based on a SQL Query.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can add a Course filter, it&#039;s very easy:&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Courses&lt;br /&gt;
&lt;br /&gt;
Edit the Custom SQL query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &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;
Note that we are adding a token called: %%FILTER_COURSES:l.courseid%% &lt;br /&gt;
&lt;br /&gt;
Go to View report, and you will see a Courses Filter, choose a Course and click on Add, here you have a report filtered.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You can also add a Starttime and endtime filter&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Start / End date filter&lt;br /&gt;
&lt;br /&gt;
Go to Custom SQL tab, this is the new query:&lt;br /&gt;
&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;
%%FILTER_COURSES:l.course%% &lt;br /&gt;
%%FILTER_STARTTIME:l.time:&amp;gt;%% %%FILTER_ENDTIME:l.time:&amp;lt;%% &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;
&lt;br /&gt;
If you want to filter text (for example, lastname)&lt;br /&gt;
&lt;br /&gt;
Go to filters, choose Search Text filter&lt;br /&gt;
&lt;br /&gt;
Go to Custom SQL tab and type your query. Here is an example for querying the user table:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT u.firstname, u.lastname&lt;br /&gt;
FROM prefix_user u&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_SEARCHTEXT:u.lastname:~%%&lt;br /&gt;
ORDER BY u.lastname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace WHERE 1=1 with your WHERE criteria. If you do not have any where criteria and do not specify WHERE 1=1, you will receive a SQL error.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
One more example (for filtering a group of courses by category)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(l.id) hits, c.fullname as Course,c.id as CourseID&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;
FROM prefix_log l INNER JOIN prefix_course c ON l.course = c.id&lt;br /&gt;
%%FILTER_CATEGORIES:c.category%% &lt;br /&gt;
GROUP BY l.course&lt;br /&gt;
ORDER BY hits DESC&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
Go to View report, now you can filter by time also&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;SQL variables&#039;&#039;&#039;&lt;br /&gt;
If you place this strings in your SQL queries, it will be replaced by the appropriate value (current course id, current user id, Moodle www root (url))&lt;br /&gt;
&lt;br /&gt;
* %%COURSEID%% &lt;br /&gt;
* %%USERID%%&lt;br /&gt;
* %%WWWROOT%%&lt;br /&gt;
&lt;br /&gt;
[[blocks/configurable_reports/#SQL_report | See screenshot]]&lt;br /&gt;
&lt;br /&gt;
=== Creating a timeline report ===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;This report assumes that you have created at least one user or course report&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a course report or user report can be embedded.&lt;br /&gt;
&lt;br /&gt;
In this example we are going to create a report showing the user logins to the site during the last month (day per day).&lt;br /&gt;
&lt;br /&gt;
Create a User report (see tutorial above) with three columns (firstname, lastname and user statistics)&lt;br /&gt;
&lt;br /&gt;
Select the statistic (User logins)&lt;br /&gt;
&lt;br /&gt;
Create a Timeline report, in the Timeline tab you can select the dates or days of the report (in this case, the last 30 days) and the interval of time for every row.&lt;br /&gt;
&lt;br /&gt;
Add three &amp;quot;Other report column&amp;quot; columns, selecting all the previous user report columns.&lt;br /&gt;
&lt;br /&gt;
And that&#039;s all, you can create a new type of plot (line graph). This graph is suitable for data depending on time.&lt;br /&gt;
&lt;br /&gt;
== Advanced options ==&lt;br /&gt;
&lt;br /&gt;
=== Export and import of reports ===&lt;br /&gt;
&lt;br /&gt;
Embedded reports exporting is not working because the reports include references to another reports. A workaround is edit the imported report for changing the references in the &amp;quot;Other report field&amp;quot; column.&lt;br /&gt;
&lt;br /&gt;
Reports that uses the user module outline column can&#039;t be exported either&lt;br /&gt;
&lt;br /&gt;
=== Use the same report in different courses ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
In order to use the same report in different courses you have to check the &amp;quot;Global report&amp;quot; option where creating a new report. This report will be then displayed in all the courses where the configurable report block is displayed and the block instance settings are set to &amp;quot;Display global reports&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t want to display global reports in a certain block instance you can always edit the instance settings for selecting &amp;quot;No&amp;quot; in the &amp;quot;Display global reports&amp;quot; block setting.&lt;br /&gt;
&lt;br /&gt;
Notice that these types of reports inherit the context of the course where is displayed, so any condition related to course inside the report is calculated using the course where the report is being viewed&lt;br /&gt;
&lt;br /&gt;
=== Reports can run on a different DB then the current (production) DB ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings&lt;br /&gt;
&lt;br /&gt;
=== DataTables for the report table ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to enable this functionality&lt;br /&gt;
&lt;br /&gt;
=== CodeMirror.js for highlighting SQL query code ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to disable this functionality&lt;br /&gt;
&lt;br /&gt;
=== Using GITHUB as a repository to distribute and manage sharable SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to point to your own repository&lt;br /&gt;
&lt;br /&gt;
=== Cron SQL queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
=== Settings to control security of SQL Queries ===&lt;br /&gt;
&lt;br /&gt;
(Available only in Configurable Report version 2.3 and above)&lt;br /&gt;
&lt;br /&gt;
Go to Admin -&amp;gt; Plugins -&amp;gt; Blocks -&amp;gt; Configurable Report settings to change the security level&lt;br /&gt;
&lt;br /&gt;
=== Templates ===&lt;br /&gt;
&lt;br /&gt;
You can customize the report output using a template.&lt;br /&gt;
&lt;br /&gt;
Just enable the Template option in the same name tab.&lt;br /&gt;
&lt;br /&gt;
This is an example html code for displaying a list of users:&lt;br /&gt;
&lt;br /&gt;
Header:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;p align=&amp;quot;center&amp;quot;&amp;gt;&amp;lt;b&amp;gt;##reportname##&amp;lt;/b&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;60%&amp;quot; align=&amp;quot;center&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Record:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;table width=&amp;quot;100%&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;img src=&amp;quot;http://yourmoodle.com/user/pix.php/[[id]]/f1.jpg&amp;quot;&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td&amp;gt;&amp;lt;h2&amp;gt;[[Firstname]] [[Lastname]]&amp;lt;/h2&amp;gt;&lt;br /&gt;
City: [[City]]&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Footer:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code html4strict&amp;gt;&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;td valign=&amp;quot;top&amp;quot;&amp;gt;&lt;br /&gt;
##graphs## &lt;br /&gt;
&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
##exportoptions##&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Embedded reports ===&lt;br /&gt;
&lt;br /&gt;
An embedded report consists in a report&#039;s set of columns that are embedded in another report.&lt;br /&gt;
&lt;br /&gt;
You can embed a user report into a course report, in this case, the resulting rows will be expanded duplicating each row for each user.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Type of report&lt;br /&gt;
! Reports that can be embedded&lt;br /&gt;
|-&lt;br /&gt;
| Courses&lt;br /&gt;
| Users&lt;br /&gt;
|-&lt;br /&gt;
| Categories&lt;br /&gt;
| Courses&lt;br /&gt;
|-&lt;br /&gt;
| Timeline&lt;br /&gt;
| Users, courses&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Imagine you have a courses report, you can embed a user report, every row of the course report will be cloned for each user.&lt;br /&gt;
&lt;br /&gt;
To embed a report just add a &amp;quot;Other report&amp;quot; column, a list of your reports will be showed.&lt;br /&gt;
&lt;br /&gt;
Inside a course report you can embed a user report and the other way.&lt;br /&gt;
&lt;br /&gt;
==== Timeline reports ====&lt;br /&gt;
&lt;br /&gt;
Timeline reports are a special type of reports. A timeline report displays a timeline in which a courses report or users report can be embedded.&lt;br /&gt;
&lt;br /&gt;
Timeline reports should be used when your user or course report includes statistics (course stats or user stats columns). I.e: you can create a report showing the number of user logins to the site during a week or month.&lt;br /&gt;
&lt;br /&gt;
== Reports repository ==&lt;br /&gt;
&lt;br /&gt;
Configurable Reports is connected to two different repositories:&lt;br /&gt;
&lt;br /&gt;
* https://github.com/jleyva/moodle-configurable_reports_repository A repository of any type of reports (users, courses, sql, etc...)&lt;br /&gt;
* https://github.com/jleyva/moodle-custom_sql_report_queries A repository of just SQL queries to be used in the SQL repor type&lt;br /&gt;
&lt;br /&gt;
You can use your custom repository following this instructions:&lt;br /&gt;
&lt;br /&gt;
* First, you need a github account (free)&lt;br /&gt;
&lt;br /&gt;
* Fork any of the previous repositorys, using the GITHUB fork tool&lt;br /&gt;
&lt;br /&gt;
* Using GIT, clone the repository to your computer in order to add your custom reports (some GIT knowledge is needed)&lt;br /&gt;
&lt;br /&gt;
* Go to Administration / Plugins / Blocks / Configurable reports and change the settings for pointing to your repository (github account + / + repository name&lt;br /&gt;
&lt;br /&gt;
* If you want to contribute to the official repository, use the Pull request Github feature (So I can easily add your reports)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Developers documentation ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s very easy to create new report types, components and plugins.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Report&#039;&#039;&#039;: A report plugin is a folder located at /report. &lt;br /&gt;
This folder contains a .class.php file with the child - class of the report_base.&lt;br /&gt;
&lt;br /&gt;
You only need to modify a few methods to add a new report type.&lt;br /&gt;
Please, take a look at any of the current reports. The SQL report is an example of a non-typical report, &lt;br /&gt;
meanwhile the users and courses reports are standard reports.&lt;br /&gt;
&lt;br /&gt;
The best way to create a report is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Component&#039;&#039;&#039;: A component is part of a report, a component may be used by more than one report.&lt;br /&gt;
The main Component is the component Columns, that is used to add the columns of a report.&lt;br /&gt;
&lt;br /&gt;
Others components are filters, permissions, plot, calculations..&lt;br /&gt;
&lt;br /&gt;
The best way to create a component is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Plugin&#039;&#039;&#039;: A plugin is a component module. The component column has a few of plugins (coursefield, userfield, etc.)&lt;br /&gt;
A plugin usually works for a unique report, but there are plugins that work for more than one report.&lt;br /&gt;
The best way to create a plugin is to duplicate an existing one.&lt;br /&gt;
&lt;br /&gt;
== How to request a new feature ==&lt;br /&gt;
&lt;br /&gt;
* Go to the Plugin Tracker http://tracker.moodle.org/browse/CONTRIB/component/10753&lt;br /&gt;
* Check in the open issues if your feature have been already requested http://tracker.moodle.org/secure/IssueNavigator.jspa?reset=true&amp;amp;jqlQuery=project+%3D+CONTRIB+AND+component+%3D+%22Block%3A+Configurable+report%22+AND+status+%3D+Open+ORDER+BY+priority+DESC&amp;amp;mode=hide&lt;br /&gt;
* If not, create a New issue (Component: Non-core contributed modules Issue type: New feature) (You have to register yourself in the tracker)&lt;br /&gt;
* Select the component Block: Configurable Reports and your Moodle version&lt;br /&gt;
* Explain in the Description field your needs&lt;br /&gt;
* If you have funding, you can contact me using the forum or the moodle internal messaging system, since I work for a Moodle Partner I can work on your request.&lt;br /&gt;
* Vote and Watch the issue you have created&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
Juan Leyva [http://moodle.org/user/view.php?id=49568&amp;amp;course=1 Moodle profile]&lt;br /&gt;
&lt;br /&gt;
[http://twitter.com/jleyvadelgado Follow me in Twitter]&lt;br /&gt;
&lt;br /&gt;
== Screenshots ==&lt;br /&gt;
&lt;br /&gt;
=== Users report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_user_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== SQL report ===&lt;br /&gt;
[[Image:block_custom_reports_sample_sql_report.png|600px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
CONTRIB-2386&lt;br /&gt;
&lt;br /&gt;
[http://tracker.moodle.org/browse/CONTRIB/component/10753 Block: Configurable reports] Tracker component&lt;br /&gt;
&lt;br /&gt;
[http://moodle.org/plugins/view.php?plugin=block_configurable_reports Modules &amp;amp; Plugins] database entry&lt;br /&gt;
&lt;br /&gt;
[http://moodle.org/mod/forum/discuss.php?d=159820 Help forum]&lt;br /&gt;
&lt;br /&gt;
[[ad-hoc_contributed_reports|contributed reports]] (in plain SQL)&lt;br /&gt;
&lt;br /&gt;
[https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:blocks/configurable_reports/]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=ad-hoc_contributed_reports&amp;diff=119247</id>
		<title>ad-hoc contributed reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=ad-hoc_contributed_reports&amp;diff=119247"/>
		<updated>2015-07-08T10:18:33Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: See also&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;
=== Enrolment count in each Course ===&lt;br /&gt;
&lt;br /&gt;
Shows the total number of enroled users of all roles in each course. Sorted by course name.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.fullname, COUNT(ue.id) AS Enroled&lt;br /&gt;
FROM prefix_course AS c &lt;br /&gt;
JOIN prefix_enrol AS en ON en.courseid = c.id&lt;br /&gt;
JOIN prefix_user_enrolments AS ue ON ue.enrolid = en.id&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
ORDER BY c.fullname&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;
=== List of users with Authentication ===&lt;br /&gt;
&lt;br /&gt;
Sometimes you need to do mass changes of authentication methods. A common case is changing default manual to LDAP. &lt;br /&gt;
&lt;br /&gt;
This will show you the Authentication setting for all users:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT username, auth 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;manual&#039; to &#039;ldap&#039; for all users except for the first two accounts which are Guest and Admin. (WARNING: it is bad practice to change you admin account from manual to an external method as failure of that external method will lock you out of Moodle as admin.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
UPDATE prefix_user SET auth = &#039;ldap&#039; WHERE auth = &#039;manual&#039; AND id &amp;gt; 2&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, Granite State College&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;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This report can take a long time to run. While it can be run in Configurable Reports on demand, it may be more appropriate to implement it in the Ad Hoc Queries plugin as a scheduled report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This report uses legacy (pre-2.7) logs. A conversion to the new log system is in the works.&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;
===Weekly Student Online Participation===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Displays participation of students in the current course by week, including pre-term and post-term edits. An edit is defined as a change to the course, such as a discussion post, the submission of an assignment, or the completion of a quiz, as well as alterations to course content such as database entries (if permitted).&lt;br /&gt;
&lt;br /&gt;
Links to three other reports are also provided:&lt;br /&gt;
&lt;br /&gt;
* Logs: complete log entries for the student in the course, organized by date&lt;br /&gt;
* Activity Outline: the &amp;quot;Outline Report&amp;quot; from the User Activity Reports, summarizing the student&#039;s activity in the course, organized by course content&lt;br /&gt;
* Consolidated Activity Report: the &amp;quot;Complete Report&amp;quot; from the User Activity Reports, detailing the student&#039;s activity in the course, organized by course content (includes text of forum posts)&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This should be defined as a &amp;quot;Global&amp;quot; report (visible from within all courses). At our institution, 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. We pull advisor names into student user profiles as part of our configuration. These lines are present in the code below, but are commented out, as they are very specific to your Moodle configuration.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This report uses legacy (pre-2.7) logs. A conversion to the new log system is in the works.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
u.lastname AS &#039;Last Name&#039;&lt;br /&gt;
, u.firstname AS &#039;First Name&#039;&lt;br /&gt;
,  COUNT(l.id) AS &#039;Edits&#039;&lt;br /&gt;
&lt;br /&gt;
, SUM(IF((l.time-c.startdate)/7&amp;lt;0,1,0)) AS &#039;Before Term&#039;&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=0,1,0)) AS &#039;Week 1&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=1,1,0)) AS &#039;Week 2&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=2,1,0)) AS &#039;Week 3&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=3,1,0)) AS &#039;Week 4&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=4,1,0)) AS &#039;Week 5&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=5,1,0)) AS &#039;Week 6&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=6,1,0)) AS &#039;Week 7&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=7,1,0)) AS &#039;Week 8&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=8,1,0)) AS &#039;Week 9&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=9,1,0)) AS &#039;Week 10&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=10,1,0)) AS &#039;Week 11&#039;&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))=11,1,0)) AS &#039;Week 12&#039;&lt;br /&gt;
&lt;br /&gt;
, SUM(IF(FLOOR((l.time - c.startdate)/(60*60*24*7))&amp;gt;=15,1,0)) AS &#039;After Term&#039;&lt;br /&gt;
&lt;br /&gt;
#, CONCAT(&#039;&amp;lt;a href=&amp;quot;mailto:&#039;,uce.data,&#039;&amp;quot;&amp;gt;&#039;,uid.data, &#039;&amp;lt;/a&amp;gt;&#039;)  AS &#039;Academic Advisor&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&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 &#039;Logs&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/report/outline/user.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;amp;course=&#039;,c.id,&#039;&amp;amp;mode=outline&amp;quot;&amp;gt;&#039;,&#039;Outline&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Activity Outline&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/report/outline/user.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;amp;course=&#039;,c.id,&#039;&amp;amp;mode=complete&amp;quot;&amp;gt;&#039;,&#039;Activity&#039;,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Consolidated Activity&#039;&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;
# student academic coach&lt;br /&gt;
# LEFT JOIN prefix_user_info_data as uid ON u.id = uid.userid AND uid.fieldid = &#039;2&#039;&lt;br /&gt;
# student academic coach email&lt;br /&gt;
# LEFT JOIN prefix_user_info_data as uce on u.id = uce.userid AND uce.fieldid = &#039;6&#039;&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 =5&lt;br /&gt;
AND ctx.instanceid = c.id&lt;br /&gt;
&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY u.idnumber&lt;br /&gt;
&lt;br /&gt;
ORDER BY u.lastname, u.firstname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Faculty/Student Interactions===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Returns a count of instructor and other-student responses to student activity for the specified time period. This report can help indicate whether students&#039; comments are being responded to, as well as summarizing post activity by students during the specified time.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This report uses legacy (pre-2.7) logs. A conversion to the new log system is in the works.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This should be defined as a &amp;quot;Global&amp;quot; report (visible from within all courses). &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This report can take a long time to run. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
# Identify student&lt;br /&gt;
CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/message/index.php?id=&#039; , allstu.id , &#039;&amp;quot;&amp;gt;&#039; , allstu.firstname , &#039; &#039; , allstu.lastname , &#039;&amp;lt;/a&amp;gt;&#039; ) AS &#039;Student - click to send message&#039;&lt;br /&gt;
&lt;br /&gt;
, IF((COUNT(DISTINCT IF(fps.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fps.id,NULL) )&amp;gt;0) OR (COUNT(DISTINCT IF(asb.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asb.id,NULL))&amp;gt;0) OR  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id AND mfs.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Student Participated This week&#039;&lt;br /&gt;
&lt;br /&gt;
, IF((COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) )&amp;gt;0) OR (COUNT(DISTINCT IF(asg.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asg.id,NULL))&amp;gt;0) OR (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id  AND mts.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Student Contacted This week&#039;&lt;br /&gt;
&lt;br /&gt;
## Only posts within last 7 days&lt;br /&gt;
&lt;br /&gt;
# Count posts by student&lt;br /&gt;
, COUNT(DISTINCT IF(fps.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fps.id,NULL)) AS &#039;Forum Stu Posts - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# Count replies to student posts by instructors&lt;br /&gt;
, COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) ) AS &#039;Forum Instr Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# using link back to student posts on replies, get unique student IDs responded&lt;br /&gt;
, COUNT(DISTINCT IF(fpsr.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpsr.id,NULL)) - COUNT(DISTINCT IF(fpi.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpi.id,NULL) ) AS &#039;Forum Stu Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# all replies&lt;br /&gt;
, COUNT(DISTINCT IF(fpsr.created &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),fpsr.id,NULL)) AS &#039;Forum All Replies - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# add in count of graded assignments - 7 days&lt;br /&gt;
, COUNT(DISTINCT IF(asb.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asb.id,NULL)) AS &#039;Assign Submit - 7 days&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(asg.timemodified &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60)),asg.id,NULL)) AS &#039;Assign Grades - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
# Messages between students and instructors - 7 days&lt;br /&gt;
,  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id AND mfs.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))) AS &#039;Msg Stu to Instr - 7 days&#039;&lt;br /&gt;
, (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id  AND mts.timecreated &amp;gt; (UNIX_TIMESTAMP()  - (7*24*60*60))) AS &#039;Msg Instr to Stu - 7 days&#039;&lt;br /&gt;
&lt;br /&gt;
## All posts in course so far&lt;br /&gt;
# Count posts by student&lt;br /&gt;
, COUNT(DISTINCT fps.id) AS &#039;Forum Stu Posts - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# Count replies to student posts by instructors&lt;br /&gt;
, COUNT(DISTINCT fpi.id) AS &#039;Forum Instr Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# using link back to student posts on replies, get unique student IDs responded&lt;br /&gt;
, COUNT(DISTINCT fpsr.id) - COUNT(DISTINCT fpi.id) AS &#039;Forum Stu Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# all replies&lt;br /&gt;
, COUNT(DISTINCT fpsr.id) AS &#039;Forum All Replies - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# add in count of graded assignments - whole course&lt;br /&gt;
, COUNT(DISTINCT asb.id) AS &#039;Assign Submit - to date&#039;&lt;br /&gt;
, COUNT(DISTINCT asg.id) AS &#039;Assign Grades - to date&#039;&lt;br /&gt;
&lt;br /&gt;
# Messages between students and instructors - to date&lt;br /&gt;
,  (SELECT COUNT(DISTINCT mfs.id) FROM prefix_message AS mfs WHERE mfs.useridfrom = allstu.id AND mfs.useridto = instr.id ) AS &#039;Msg Stu to Instr - to date&#039;&lt;br /&gt;
, (SELECT COUNT(DISTINCT mts.id) FROM prefix_message AS mts WHERE mts.useridfrom = instr.id AND mts.useridto = allstu.id) AS &#039;Msg Instr to Stu - to date&#039;&lt;br /&gt;
&lt;br /&gt;
## JOINS&lt;br /&gt;
&lt;br /&gt;
# Start by getting all the students in the course&lt;br /&gt;
FROM prefix_user AS allstu &lt;br /&gt;
JOIN prefix_role_assignments AS ras ON allstu.id = ras.userid AND ras.roleid = 5&lt;br /&gt;
JOIN prefix_context AS ctx  ON ras.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;
# Now we get the forums and forum discussions from this course only&lt;br /&gt;
LEFT JOIN prefix_forum AS frm ON frm.course = c.id AND c.id = %%COURSEID%%&lt;br /&gt;
LEFT JOIN prefix_forum_discussions AS fd ON fd.course = %%COURSEID%% AND fd.forum = frm.id&lt;br /&gt;
&lt;br /&gt;
# These are forum discussion posts just by students within specified time&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fps ON fps.userid = allstu.id AND fps.discussion = fd.id&lt;br /&gt;
&lt;br /&gt;
# Separately, we connect the instructors of the courses&lt;br /&gt;
# We can use the context we have already gotten for the students&lt;br /&gt;
LEFT JOIN prefix_role_assignments AS rai ON rai.contextid = ctx.id&lt;br /&gt;
LEFT JOIN prefix_user AS instr ON instr.id = rai.userid AND rai.roleid =3&lt;br /&gt;
&lt;br /&gt;
# Now we will connect to posts by instructors that are replies to student posts&lt;br /&gt;
# This is a left join, because we don&#039;t want to eliminate any students from the list&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpi ON fpi.discussion = fd.id AND fpi.userid = instr.id AND fpi.parent = fps.id&lt;br /&gt;
&lt;br /&gt;
# To get identities of only those students who were replied to:&lt;br /&gt;
# Connect from instr replies back up to parent posts by students again&lt;br /&gt;
# This has to be a LEFT JOIN, we know these posts exist but don&#039;t eliminate non-responded students&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpir ON fpir.id = fpi.parent&lt;br /&gt;
&lt;br /&gt;
# We also want to know if students are replying to one another&lt;br /&gt;
# These are posts that are replies to student posts&lt;br /&gt;
# Again, a left join&lt;br /&gt;
LEFT JOIN prefix_forum_posts AS fpsr ON fpsr.discussion = fd.id AND fpsr.parent = fps.id&lt;br /&gt;
&lt;br /&gt;
# get the activity modules&lt;br /&gt;
LEFT JOIN prefix_course_modules AS cm ON c.id = cm.course&lt;br /&gt;
&lt;br /&gt;
# get the assignments&lt;br /&gt;
LEFT JOIN prefix_assign AS a ON  cm.instance = a.id&lt;br /&gt;
 LEFT JOIN prefix_assign_submission AS asb ON a.id = asb.assignment AND asb.userid=allstu.id &lt;br /&gt;
LEFT JOIN prefix_assign_grades AS asg ON asg.assignment = a.id AND asg.userid = allstu.id AND asg.assignment = asb.assignment &lt;br /&gt;
&lt;br /&gt;
# We care about messages that involve both the instructor and students of this course&lt;br /&gt;
# messages from instructor to students:&lt;br /&gt;
# LEFT JOIN prefix_message AS mts ON mts.useridfrom = instr.id AND mts.useridto = allstu.id&lt;br /&gt;
# LEFT JOIN prefix_message AS mfs ON mfs.useridfrom = instr.id AND mfs.useridto = allstu.id&lt;br /&gt;
&lt;br /&gt;
WHERE  &lt;br /&gt;
c.id = %%COURSEID%% &lt;br /&gt;
&lt;br /&gt;
# GROUP BY c.shortname , allstu.id&lt;br /&gt;
GROUP BY allstu.id&lt;br /&gt;
&lt;br /&gt;
ORDER BY allstu.lastname&lt;br /&gt;
&amp;lt;/code&amp;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;
===Unique user sessions per day and month + graph===&lt;br /&gt;
The &amp;quot;graph&amp;quot; column is used when displaying a graph (which needs at least three columns to pick from)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT COUNT(DISTINCT userid) AS &amp;quot;Unique User Logins&amp;quot;&lt;br /&gt;
,DATE_FORMAT(FROM_UNIXTIME(timecreated), &amp;quot;%y /%m / %d&amp;quot;) AS &amp;quot;Year / Month / Day&amp;quot;, &amp;quot;Graph&amp;quot; &lt;br /&gt;
FROM `mdl_logstore_standard_log` &lt;br /&gt;
WHERE action LIKE &#039;loggedin&#039;&lt;br /&gt;
#AND timecreated &amp;gt;  UNIX_TIMESTAMP(&#039;2015-01-01 00:00:00&#039;) # optional start date&lt;br /&gt;
#AND timecreated &amp;lt;= UNIX_TIMESTAMP(&#039;2015-01-31 23:59:00&#039;) # optional end date&lt;br /&gt;
GROUP BY MONTH(FROM_UNIXTIME(timecreated)), DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
ORDER BY MONTH(FROM_UNIXTIME(timecreated)), DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And...&lt;br /&gt;
&lt;br /&gt;
Counting user&#039;s global and unique hits per day + counting individual usage of specific activities and resources (on that day),&lt;br /&gt;
&lt;br /&gt;
And since I am using phpMyAdmin&#039;s &amp;quot;Display Graph&amp;quot; feature (at the bottom of the query&#039;s output page), I have scaled down the &amp;quot;User Hits&amp;quot; by 10 to fit the graph. that&#039;s it.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DATE_FORMAT(FROM_UNIXTIME(timecreated), &amp;quot;%y-%m-%d&amp;quot;) AS &amp;quot;Datez&amp;quot;&lt;br /&gt;
,COUNT(DISTINCT userid) AS &amp;quot;Unique Users&amp;quot;&lt;br /&gt;
,ROUND(COUNT(*)/10) &amp;quot;User Hits (K)&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_quiz&#039;,1,0)) &amp;quot;Quizzes&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_forum&#039; or component=&#039;mod_forumng&#039;,1,0)) &amp;quot;Forums&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_assign&#039;,1,0)) &amp;quot;Assignments&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_oublog&#039;,1,0)) &amp;quot;Blogs&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_resource&#039;,1,0)) &amp;quot;Files (Resource)&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_url&#039;,1,0)) &amp;quot;Links (Resource)&amp;quot;&lt;br /&gt;
,SUM(IF(component=&#039;mod_page&#039;,1,0)) &amp;quot;Pages (Resource)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM `mdl_logstore_standard_log` &lt;br /&gt;
WHERE 1=1&lt;br /&gt;
AND timecreated &amp;gt;  UNIX_TIMESTAMP(&#039;2015-03-01 00:00:00&#039;) # optional START DATE&lt;br /&gt;
AND timecreated &amp;lt;= UNIX_TIMESTAMP(&#039;2015-05-31 23:59:00&#039;) # optional END DATE&lt;br /&gt;
GROUP BY MONTH(FROM_UNIXTIME(timecreated)), DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
ORDER BY MONTH(FROM_UNIXTIME(timecreated)), DAY(FROM_UNIXTIME(timecreated))&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===What teachers and courses considered active?===&lt;br /&gt;
This report display several calculations and parameters that help the Online academic training team find teachers that might need more support getting their courses more supporting of online learning pedagogical methodologies.  &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;,&lt;br /&gt;
			  course.id,&#039;&amp;quot;&amp;gt;&#039;,course.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course &lt;br /&gt;
&lt;br /&gt;
#,course.shortname&lt;br /&gt;
&lt;br /&gt;
,CASE &lt;br /&gt;
  WHEN course.fullname LIKE &#039;%2012%&#039; THEN &#039;2012&#039;&lt;br /&gt;
  WHEN course.fullname LIKE &#039;%2013%&#039; THEN &#039;2013&#039; &lt;br /&gt;
  WHEN course.fullname LIKE &#039;%2014%&#039; THEN &#039;2014&#039;&lt;br /&gt;
  WHEN course.fullname LIKE &#039;%2015%&#039; THEN &#039;2015&#039;&lt;br /&gt;
END AS Year&lt;br /&gt;
&lt;br /&gt;
,CASE &lt;br /&gt;
  WHEN course.fullname LIKE &#039;%semester a%&#039; THEN &#039;Spring semester&#039;&lt;br /&gt;
  WHEN course.fullname LIKE &#039;%semester b%&#039; THEN &#039;Fall semester&#039;&lt;br /&gt;
  WHEN course.fullname LIKE &#039;%semester s%&#039; THEN &#039;Summer semester&#039;&lt;br /&gt;
END AS Semester&lt;br /&gt;
&lt;br /&gt;
,IF(course.startdate&amp;gt;0, DATE_FORMAT(FROM_UNIXTIME(startdate), &#039;%d-%m-%Y&#039;), &#039;no date&#039;) AS &amp;quot;Course Start Date&amp;quot; &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 AND ctx.instanceid = course.id&lt;br /&gt;
) AS Students&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 = 4 AND ctx.instanceid = course.id&lt;br /&gt;
) AS &amp;quot;Assistant teacher&amp;quot;&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 = 3 AND ctx.instanceid = course.id&lt;br /&gt;
) AS Teachers&lt;br /&gt;
&lt;br /&gt;
# Uncomment to use the new Moodle 2.8+ logstore&lt;br /&gt;
#,(SELECT COUNT(*) FROM mdl_logstore_standard_log AS l WHERE l.courseid = course.id) AS Hits&lt;br /&gt;
&lt;br /&gt;
#,(SELECT COUNT(*)&lt;br /&gt;
#FROM mdl_logstore_standard_log AS l&lt;br /&gt;
#JOIN mdl_role_assignments AS ra ON ra.contextid= l.contextid AND ra.userid= l.userid AND ra.roleid = 5 &lt;br /&gt;
#WHERE l.courseid = course.id ) AS &amp;quot;Student HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
#,(SELECT COUNT(*)&lt;br /&gt;
#FROM mdl_logstore_standard_log AS l&lt;br /&gt;
#JOIN mdl_role_assignments AS ra ON ra.contextid= l.contextid AND ra.userid= l.userid AND ra.roleid = 3 &lt;br /&gt;
#WHERE l.courseid = course.id ) AS &amp;quot;Teacher HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM mdl_log AS l WHERE l.course = course.id) AS Hits&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
JOIN mdl_context AS con ON con.instanceid= l.course AND con.contextlevel=50&lt;br /&gt;
JOIN mdl_role_assignments AS ra ON ra.contextid= con.id AND ra.userid= l.userid AND ra.roleid = 5 &lt;br /&gt;
WHERE l.course = course.id) AS &amp;quot;Students HITs&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
,(SELECT COUNT(*)&lt;br /&gt;
FROM mdl_log AS l&lt;br /&gt;
JOIN mdl_context AS con ON con.instanceid= l.course AND con.contextlevel=50&lt;br /&gt;
JOIN mdl_role_assignments AS ra ON ra.contextid= con.id AND ra.userid= l.userid AND ra.roleid = 3 &lt;br /&gt;
WHERE l.course = course.id) AS &amp;quot;Teachers HITs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT GROUP_CONCAT( CONCAT( u.firstname,  &amp;quot; &amp;quot;, u.lastname ) ) &lt;br /&gt;
FROM prefix_course c&lt;br /&gt;
JOIN prefix_context con ON con.instanceid = c.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 c.id = course.id&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
) AS Teachers&lt;br /&gt;
  &lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm WHERE cm.course = course.id) Modules&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(DISTINCT cm.module) FROM prefix_course_modules cm &lt;br /&gt;
  WHERE cm.course = course.id) UniqueModules&lt;br /&gt;
&lt;br /&gt;
,(SELECT GROUP_CONCAT(DISTINCT m.name) &lt;br /&gt;
  FROM prefix_course_modules cm &lt;br /&gt;
  JOIN mdl_modules as m ON m.id = cm.module&lt;br /&gt;
  WHERE cm.course = course.id) UniqueModuleNames&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM mdl_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN ( &#039;ouwiki&#039;, &#039;wiki&#039;) ) &amp;quot;Num Wikis&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM mdl_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN ( &#039;oublog&#039;) ) &amp;quot;Num Blogs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM mdl_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN ( &#039;forum&#039;, &#039;forumng&#039;) ) &amp;quot;Num Forums&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN (&#039;resource&#039;, &#039;folder&#039;, &#039;url&#039;, &#039;tab&#039;, &#039;file&#039;, &#039;book&#039;, &#039;page&#039;) ) Resources&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN (&#039;forum&#039;, &#039;forumng&#039;, &#039;oublog&#039;, &#039;page&#039;, &#039;file&#039;, &#039;url&#039;, &#039;wiki&#039; , &#039;ouwiki&#039;) ) &amp;quot;Basic Activities&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN (&#039;advmindmap&#039;, &#039;assign&#039;, &#039;attendance&#039;, &#039;book&#039;, &#039;choice&#039;, &#039;folder&#039;, &#039;tab&#039;, &#039;glossary&#039;, &#039;questionnaire&#039;, &#039;quiz&#039;, &#039;label&#039; ) ) &amp;quot;Avarage Activities&amp;quot;&lt;br /&gt;
&lt;br /&gt;
,(SELECT COUNT(*) FROM prefix_course_modules cm JOIN mdl_modules as m ON m.id = cm.module &lt;br /&gt;
  WHERE cm.course = course.id AND m.name IN (&#039;elluminate&#039;, &#039;game&#039;, &#039;workshop&#039;) ) &amp;quot;Advanced Activities&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS course&lt;br /&gt;
&lt;br /&gt;
#WHERE course.shortname LIKE &#039;%2015%&#039;&lt;br /&gt;
#WHERE 1=1&lt;br /&gt;
#%%FILTER_SEARCHTEXT:course.shortname:~%%&lt;br /&gt;
&lt;br /&gt;
WHERE course.fullname LIKE &#039;%2015%&#039; &lt;br /&gt;
&lt;br /&gt;
HAVING Modules &amp;gt; 2&lt;br /&gt;
ORDER BY UniqueModules DESC&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.userid) AS Views&lt;br /&gt;
FROM `mdl_logstore_standard_log` l, `mdl_user` u, `mdl_role_assignments` r&lt;br /&gt;
WHERE l.courseid=35&lt;br /&gt;
AND l.userid = u.id&lt;br /&gt;
AND (l.timecreated &amp;gt; UNIX_TIMESTAMP(&#039;2015-01-01 00:00:00&#039;) AND l.timecreated &amp;lt;= UNIX_TIMESTAMP(&#039;2015-01-31 23:59:59&#039;))AND r.contextid= (&lt;br /&gt;
	 SELECT id&lt;br /&gt;
	 FROM mdl_context&lt;br /&gt;
	 WHERE contextlevel=50 AND instanceid=l.courseid&lt;br /&gt;
 )&lt;br /&gt;
AND r.roleid=5&lt;br /&gt;
AND r.userid = u.id&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;
===Users enrolled in a course with groups but not assigned a group ===&lt;br /&gt;
&lt;br /&gt;
Displays by course all enrolled users that have not been assigned a group in courses that have groups. NOTE: This needs to be optimized.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DISTINCT&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;
JOIN prefix_groups AS g ON g.courseid = course.id&lt;br /&gt;
&lt;br /&gt;
WHERE ue.enrolid NOT IN (select userid from prefix_groups_members WHERE g.id=groupid)&lt;br /&gt;
&lt;br /&gt;
ORDER BY Course, Lastname&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;
===All users enrolled in a course without a role===&lt;br /&gt;
Identifies All users that are enrolled in a course but are not assigned a role.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
user.firstname AS Firstname,&lt;br /&gt;
user.lastname AS Lastname,&lt;br /&gt;
user.idnumber Employee_ID,&lt;br /&gt;
course.fullname AS Course&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 user ON user.id = ue.userid&lt;br /&gt;
&lt;br /&gt;
WHERE user.id NOT IN (&lt;br /&gt;
SELECT u.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_role AS r ON r.id = ra.roleid&lt;br /&gt;
JOIN prefix_user AS u ON u.id = ra.userid&lt;br /&gt;
WHERE c.id=course.id&lt;br /&gt;
)&lt;br /&gt;
ORDER BY Course, Lastname, Firstname&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List course resources accumulative file size and count===&lt;br /&gt;
This is the main (first) report, which has a link (alias) to a second report (the following on this page) which list each file in the course.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT c.id &amp;quot;CourseID&amp;quot;, context.id &amp;quot;ContextID&amp;quot;&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 &amp;quot;Course Name&amp;quot;&lt;br /&gt;
, COUNT(*) &amp;quot;Course Files&amp;quot; , ROUND( SUM( f.filesize ) /1048576 ) AS file_size_MB&lt;br /&gt;
,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/blocks/configurable_reports/viewreport.php?alias=coursefiles&amp;amp;courseid=1&amp;amp;filter_courses=&#039;, c.id, &#039;&amp;quot;&amp;gt;List files&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;List Files&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_files AS f&lt;br /&gt;
JOIN mdl_context AS context ON context.id = f.contextid&lt;br /&gt;
JOIN mdl_course AS c ON c.id = (&lt;br /&gt;
  SELECT instanceid&lt;br /&gt;
  FROM mdl_context&lt;br /&gt;
  WHERE id = SUBSTRING_INDEX( SUBSTRING_INDEX( context.path, &#039;/&#039; , -2 ) , &#039;/&#039;, 1 ) )&lt;br /&gt;
WHERE filesize &amp;gt;0&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With this report, you will have to define &amp;quot;alias&amp;quot; report property to &amp;quot;coursefiles&amp;quot; for it to be able to be called from the above report.&lt;br /&gt;
And also setup (add) a FILTER_COURSES filter. &lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
id ,CONCAT(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/pluginfile.php/&#039;, contextid, &#039;/&#039;, component, &#039;/&#039;, filearea, &#039;/&#039;, itemid, &#039;/&#039;, filename, &#039;&amp;quot;&amp;gt;&#039;, filename,&#039;&amp;lt;/a&amp;gt;&#039;) AS &amp;quot;File&amp;quot;&lt;br /&gt;
,filesize, mimetype ,author, license, timecreated, component, filearea, filepath&lt;br /&gt;
&lt;br /&gt;
FROM mdl_files AS f&lt;br /&gt;
WHERE filesize &amp;gt;0&lt;br /&gt;
            AND f.contextid&lt;br /&gt;
            IN (   SELECT id&lt;br /&gt;
                     FROM mdl_context&lt;br /&gt;
                    WHERE path &lt;br /&gt;
                     LIKE (   SELECT CONCAT(&#039;%/&#039;,id,&#039;/%&#039;)&lt;br /&gt;
                                  AS contextquery&lt;br /&gt;
                                FROM mdl_context&lt;br /&gt;
                               WHERE 1=1&lt;br /&gt;
			        %%FILTER_COURSES:instanceid%%&lt;br /&gt;
                                 AND contextlevel = 50&lt;br /&gt;
                           )&lt;br /&gt;
                )&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Which courses has redundant topics===&lt;br /&gt;
This report list several &amp;quot;active topics&amp;quot; calculations, per course. which should give an administrator some indications for which topics/sections/weeks are filled with resources and activities and which ones are empty and not used (usually, at the end of the course).&lt;br /&gt;
&lt;br /&gt;
The following, second SQL query, could be used to &amp;quot;trim&amp;quot; down those redundant course topics/sections/weeks by updating the course format&#039;s numsection (Number of sections) setting. (It&#039;s a per course format setting!)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT id, format,&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 value  FROM  `mdl_course_format_options` WHERE  `courseid` = c.id AND `format` = c.format AND `name` = &#039;numsections&#039; ) AS &amp;quot;numsections&amp;quot;&lt;br /&gt;
,(SELECT COUNT(*) FROM  `mdl_course_sections` WHERE  `course` = c.id AND `sequence` !=  &#039;&#039; ) AS &amp;quot;Non empty sections count&amp;quot;&lt;br /&gt;
,(SELECT COUNT(*) FROM  `mdl_course_sections` WHERE  `course` = c.id ) AS &amp;quot;Total section count&amp;quot;&lt;br /&gt;
,(SELECT COUNT(*) FROM  `mdl_course_sections` WHERE  `course` = c.id AND sequence IS NOT NULL) AS &amp;quot;Non NULL sections count&amp;quot;&lt;br /&gt;
,(SELECT COUNT(*) FROM  `mdl_course_sections` WHERE  `course` = c.id AND name != &#039;&#039;) AS &amp;quot;Non empty section Name count&amp;quot;&lt;br /&gt;
 ,(SELECT COUNT(*) FROM mdl_course_modules cm WHERE cm.course = c.id) &amp;quot;Modules count&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_course AS c&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The following SQL REPLACE query is used for &amp;quot;fixing&amp;quot; (updating) the &amp;quot;numsections&amp;quot; of a specific course format &amp;quot;onetopics&amp;quot; (you can always change it, or discard it to use this SQL REPLACE on all course formats) &lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
REPLACE INTO `mdl_course_format_options` (`id`, `courseid`, `format`, `sectionid`, `name`, `value`) &lt;br /&gt;
SELECT NULL, c.id, &#039;onetopic&#039;, &#039;0&#039;, &#039;numsections&#039;, (SELECT COUNT(*) FROM `mdl_course_sections` WHERE `course` = c.id AND name != &#039;&#039;)&lt;br /&gt;
FROM `mdl_course` c where format = &#039;onetopic&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Course Design Reports==&lt;br /&gt;
&lt;br /&gt;
These are reports which summarize course design aspects, such as activity and resource modules per section, types of activities used, etc.&lt;br /&gt;
&lt;br /&gt;
===Course Content/Week===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
This report assumes that the first 14 sections in a course, not including the &amp;quot;0&amp;quot; or &amp;quot;Welcome&amp;quot; section, correspond to weeks (with &amp;quot;Subsections&amp;quot; given numbers much higher in the sequence). Of those sections, each is checked to count the number of:&lt;br /&gt;
&lt;br /&gt;
    Forums&lt;br /&gt;
    Graded Activities (may include Forums)&lt;br /&gt;
    Resources (not including a Label)&lt;br /&gt;
&lt;br /&gt;
Totals of each of these types of content elements per section are provided.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: Only visible resources and activities are counted.&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: this is a &amp;quot;Global&amp;quot; report.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
 &lt;br /&gt;
cs.section AS &#039;Week&#039;&lt;br /&gt;
, cs.name AS &#039;Section Name&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF((gi.id IS NULL) AND (m.name NOT LIKE &#039;label&#039;),cm.id,NULL)) AS &#039;Ungraded Resources&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(m.name LIKE &#039;forum&#039;, cm.id, NULL)) AS &#039;Forums&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(gi.id, cm.id, NULL)) AS &#039;Graded Activities&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_course_sections AS cs ON cs.course = c.id AND cs.section &amp;lt;= 14 AND cs.section &amp;gt; 0&lt;br /&gt;
LEFT JOIN prefix_course_modules AS cm ON cm.course = c.id AND cm.section = cs.id &lt;br /&gt;
JOIN prefix_modules AS m ON m.id = cm.module&lt;br /&gt;
LEFT JOIN prefix_grade_items AS gi ON gi.courseid = c.id AND gi.itemmodule = m.name AND gi.iteminstance = cm.instance&lt;br /&gt;
&lt;br /&gt;
WHERE &lt;br /&gt;
cs.visible = 1&lt;br /&gt;
AND cm.visible = 1&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY cs.section&lt;br /&gt;
ORDER BY cs.section&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Assignments and Weights===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Returns a list of grade book categories for the current course, grade book weightings, the first type of assignment included in the category, a count of different assignment types for each category, and a count of assignments for each category.&lt;br /&gt;
&lt;br /&gt;
Categories with weights of 0 are not included in this report.&lt;br /&gt;
&lt;br /&gt;
Only visible activities are included in this report.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: This is designed to be a &amp;quot;Global&amp;quot; report in Configurable Reports.&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
&lt;br /&gt;
IF(gc.parent IS NOT NULL, gc.fullname, &#039;None&#039;) AS &#039;Grade Book Category&#039;&lt;br /&gt;
, IF(gc.parent IS NOT NULL, ROUND(gic.aggregationcoef, 2), ROUND(SUM(DISTINCT gi.aggregationcoef), 2)+ROUND(SUM(DISTINCT mgi.aggregationcoef), 2)) AS &#039;Category weight&#039;&lt;br /&gt;
&lt;br /&gt;
, CONCAT_WS(&#039;, &#039;,GROUP_CONCAT(DISTINCT gi.itemmodule SEPARATOR &#039;, &#039;), IF(mgi.id, &#039;manual&#039;,NULL)) AS &#039;Activity Types&#039;&lt;br /&gt;
, COUNT(DISTINCT gi.itemmodule) + IF(mgi.id,1,0) AS &#039;Different Activity Types&#039;&lt;br /&gt;
, CONCAT_WS(&#039;&amp;lt;br&amp;gt;&#039;, GROUP_CONCAT(DISTINCT gi.itemname ORDER BY gi.itemname SEPARATOR &#039;&amp;lt;br&amp;gt;&#039;), GROUP_CONCAT(DISTINCT mgi.itemname ORDER BY mgi.itemname SEPARATOR &#039;&amp;lt;br&amp;gt;&#039;)) AS &#039;Activity Names&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(gi.id, cm.id, NULL)) + COUNT(DISTINCT mgi.id) AS &#039;Activity Count&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
&lt;br /&gt;
#get grade categories&lt;br /&gt;
LEFT JOIN prefix_grade_categories AS gc ON gc.courseid = c.id &lt;br /&gt;
# back from categories to grade items to get aggregations and weights&lt;br /&gt;
JOIN prefix_grade_items AS gic ON gic.courseid = c.id AND gic.itemtype = &#039;category&#039; AND gic.aggregationcoef != 0 AND (LOCATE(gic.iteminstance, gc.path) OR (gc.parent IS NULL))&lt;br /&gt;
&lt;br /&gt;
# attach activities to course&lt;br /&gt;
JOIN prefix_course_modules AS cm ON cm.course = c.id &lt;br /&gt;
# attach grade items to activities&lt;br /&gt;
LEFT JOIN prefix_grade_items AS gi ON gi.courseid = c.id AND gi.iteminstance = cm.instance AND gi.itemtype = &#039;mod&#039; AND gi.categoryid = gc.id AND gi.hidden != 1&lt;br /&gt;
&lt;br /&gt;
# attach manual grade items to course-- they don&#039;t have modules&lt;br /&gt;
LEFT JOIN prefix_grade_items AS mgi ON mgi.courseid = c.id and mgi.itemtype = &#039;manual&#039; AND mgi.categoryid = gc.id&lt;br /&gt;
&lt;br /&gt;
WHERE &lt;br /&gt;
cm.visible = 1&lt;br /&gt;
AND c.id = %%COURSEID%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY gc.id&lt;br /&gt;
ORDER BY gc.id&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Pre-Term Course Review===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
Provides an overview of the readiness of ONLINE, HYBRID, and BLENDED courses in the Staging category and all subcategories. Links to each course are provided. Other details:&lt;br /&gt;
&lt;br /&gt;
#   &amp;quot;Required blocks&amp;quot; include Instructor Block (mooprofile), Activities, and the Research block.&lt;br /&gt;
#    &amp;quot;Instructor Details&amp;quot; block is not the &amp;quot;Instructor&amp;quot; block (mooprofile) automatically provided by the system. It is an optional block that can be edited by the instructor. If not edited to remove boilerplate text, it should be hidden.&lt;br /&gt;
#    All courses should be in the &amp;quot;Collapsed Topics&amp;quot; format with the &amp;quot;Weeks&amp;quot; structure.&lt;br /&gt;
#    &amp;quot;Weeks defined in course settings&amp;quot; is taken from our SIS when the course shells are created, but can be edited by faculty. &amp;quot;# of weeks named and visible&amp;quot; should usually match or exceed this value.&lt;br /&gt;
#    We recommend that each week contain at least one forum, at least one graded activity, and at least one ungraded resource.&lt;br /&gt;
#    &amp;quot;Syllabus updated&amp;quot; date is for the first attached file found with the text &amp;quot;syllabus&amp;quot; in the name. The &amp;quot;Days ago&amp;quot; calculation is included for convenience.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: At our institution, we construct categories each term, and insert a text string &amp;quot;staging&amp;quot; in the Category ID for pre-term courses during the preparation or &amp;quot;staging&amp;quot; phase of course development. We remove this text string (and change it to &amp;quot;production&amp;quot;) when courses go live at the start of the new term.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;,CHAR(63),&#039;id=&#039;,c.id,&#039;&amp;quot;&amp;gt;&#039;,c.shortname,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course&lt;br /&gt;
&lt;br /&gt;
#,RIGHT(c.idnumber,2) AS Type # Specific to GSC &amp;quot;Instructional Method&amp;quot; storage&lt;br /&gt;
&lt;br /&gt;
#, substring_index(substr(c.shortname FROM locate(&#039;.&#039;,c.shortname)+1),&#039;-&#039;,1) AS Section # Specific to GSC&lt;br /&gt;
 &lt;br /&gt;
,(SELECT CONCAT(&#039;&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;%%WWWROOT%%/user/view.php&#039;,CHAR(63),&#039;id=&#039;,u.id,&#039;&amp;quot;&amp;gt;&#039;,u.lastname,&#039;, &#039;, u.firstname,&#039;&amp;lt;/a&amp;gt;&#039;)&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 &#039;Instructor&#039; &lt;br /&gt;
&lt;br /&gt;
,(SELECT IF((u2.description IS NULL) OR (u2.description LIKE &#039;&#039;),&#039;NO&#039;, &#039;YES&#039;)&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 u2 ON u2.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS &#039;Profile Has Bio&#039;&lt;br /&gt;
&lt;br /&gt;
,(SELECT IF(u3.picture &amp;gt; 0,&#039;YES&#039;,&#039;NO&#039;)&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 u3 ON u3.id = ra.userid&lt;br /&gt;
WHERE ra.roleid = 3 AND ctx.instanceid = c.id LIMIT 1) AS &#039;Profile Has Picture&#039;&lt;br /&gt;
&lt;br /&gt;
, IF(((bpi.visible IS NULL) OR (bpi.visible !=0)) AND ((bpm.visible IS NULL) OR (bpm.visible !=0)) AND ((bpa.visible IS NULL) OR (bpa.visible !=0)) AND ((bpr.visible IS NULL) OR (bpr.visible !=0)),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Required blocks visible&#039;&lt;br /&gt;
#, IF((bpm.visible IS NULL) OR (bpm.visible !=0),&#039;YES&#039;,&#039;NO&#039;) AS &#039;Messages block visible&#039;&lt;br /&gt;
#, IF((bpa.visible IS NULL) OR (bpa.visible !=0),&#039;YES&#039;,&#039;NO&#039;) AS &#039;activities block visible&#039;&lt;br /&gt;
#, IF((bpr.visible IS NULL) OR (bpr.visible !=0),&#039;YES&#039;,&#039;NO&#039;) AS &#039;research block visible&#039;&lt;br /&gt;
&lt;br /&gt;
#, IF(SUM(IF(bi.configdata LIKE &#039;Tzo4OiJzdGRDbGFzcyI6Mzp7czo1OiJ0aXRsZSI7czoxODoiSW5zdHJ1Y3RvciBEZXRhaWxzI%&#039;,1,0)) AND (bip.visible !=0),&#039;YES&#039;,&#039;&#039;) AS &#039;Instructor Details Block visible&#039; # This is a hack based on UUencoded string data from the title of HTML &amp;quot;Instructor Details&amp;quot; block&lt;br /&gt;
&lt;br /&gt;
#, IF(bi.configdata LIKE &#039;%ZGl0IHRoaXMgYmxvY2s%&#039;,&#039;NO&#039;,&#039;&#039;) AS &#039;Instructor Details Block Updated&#039; # HTML block has string &#039;dit this block&#039;&lt;br /&gt;
&lt;br /&gt;
#, IF(COUNT(bi.id) -  SUM(IF(bi.configdata LIKE &#039;Tzo4OiJzdGRDbGFzcyI6Mzp7czo1OiJ0aXRsZSI7czoxODoiSW5zdHJ1Y3RvciBEZXRhaWxzI%&#039;,1,0)),&#039;YES&#039;,&#039;&#039;) AS &#039;possible extra instructor blocks&#039; #looking for any HTML block with &amp;quot;instructor&amp;quot; in the title&lt;br /&gt;
&lt;br /&gt;
, IF(c.format=&#039;topcoll&#039;,&#039;YES&#039;, c.format) AS &#039;Collapsed Topics course format&#039; # change this if you want to test for a different format&lt;br /&gt;
, IF(cfo.value = 2, &#039;YES&#039;,&#039;NO&#039;) AS &#039;weeks structure&#039;&lt;br /&gt;
&lt;br /&gt;
, cfw.value AS &#039;weeks defined in course settings&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(((cs.name IS NOT NULL) AND (cs.visible = 1) AND (cs.section != &#039;0&#039;) AND (cs.sequence IS NOT NULL)),cs.id,NULL)) AS &#039;# of weeks named &amp;amp; visible (includes orphans)&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(m.name LIKE &#039;forum&#039;, cm.id, NULL)) AS &#039;Forums&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(m.name LIKE &#039;forum&#039; ,cs.id , NULL)) AS &#039;Weeks with Forum&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF(gi.id, cm.id, NULL)) AS &#039;Activities&#039;&lt;br /&gt;
, COUNT(DISTINCT IF(gi.id, cs.id, NULL)) AS &#039;Weeks with Activities&#039;&lt;br /&gt;
, COUNT(DISTINCT mgi.id) AS &#039;Manual Grade Items&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT(DISTINCT IF((gi.id IS NULL) AND (m.name NOT IN (&#039;forum&#039;,&#039;label&#039;)),cm.id,NULL)) AS &#039;Resources&#039;&lt;br /&gt;
, COUNT(DISTINCT IF((gi.id IS NULL) AND (m.name NOT IN (&#039;forum&#039;,&#039;label&#039;)), cs.id, NULL)) AS &#039;Weeks with Resources&#039;&lt;br /&gt;
&lt;br /&gt;
# Here are some other things you could check for per course&lt;br /&gt;
#,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id 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 JOIN prefix_modules AS m ON cm.module = m.id WHERE cm.course = c.id AND m.name LIKE &#039;%quiz%&#039;) AS Quizzes&lt;br /&gt;
 &lt;br /&gt;
#,(SELECT count( m.name ) AS count FROM prefix_course_modules AS cm JOIN prefix_modules AS m ON cm.module = m.id WHERE cm.course = c.id AND m.name LIKE &#039;%assign%&#039;) AS Assignments&lt;br /&gt;
&lt;br /&gt;
#,(SELECT COUNT(prefix_resource.id) FROM prefix_resource JOIN prefix_course ON prefix_course.id = prefix_resource.course WHERE c.id = prefix_resource.course) AS Files&lt;br /&gt;
&lt;br /&gt;
#,(SELECT COUNT(prefix_url.id) FROM prefix_url JOIN prefix_course ON prefix_course.id = prefix_url.course WHERE c.id = prefix_url.course) AS Links&lt;br /&gt;
&lt;br /&gt;
,(SELECT FROM_UNIXTIME(MAX(prefix_resource.timemodified))&lt;br /&gt;
FROM prefix_resource&lt;br /&gt;
JOIN prefix_course ON prefix_course.id = prefix_resource.course WHERE c.id = prefix_resource.course AND prefix_resource.name LIKE &#039;%syllabus%&#039;) AS SyllabusDate&lt;br /&gt;
&lt;br /&gt;
,(SELECT TO_DAYS(NOW())-TO_DAYS(FROM_UNIXTIME(MAX(prefix_resource.timemodified)))&lt;br /&gt;
FROM prefix_resource&lt;br /&gt;
JOIN prefix_course ON prefix_course.id = prefix_resource.course WHERE c.id = prefix_resource.course AND prefix_resource.name LIKE &#039;%syllabus%&#039;) AS DaysAgo&lt;br /&gt;
&lt;br /&gt;
, IF(COUNT(DISTINCT IF(f.type LIKE &#039;news&#039;, f.id,NULL)),&#039;YES&#039;,&#039;NO&#039; ) AS &#039;Announcement Forum Visible&#039;&lt;br /&gt;
&lt;br /&gt;
, IF(COUNT(DISTINCT IF(f.type LIKE &#039;news&#039;, fd.id,NULL)),&#039;YES&#039;,&#039;NO&#039; ) AS &#039;Announcement posted&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
LEFT JOIN prefix_course_categories as cc ON c.category = cc.id&lt;br /&gt;
LEFT JOIN prefix_context AS ctxx ON c.id = ctxx.instanceid &lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bpi ON bpi.contextid = ctxx.id AND bpi.blockinstanceid = &#039;43692&#039; # mooprofile&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bpm ON bpm.contextid = ctxx.id AND bpm.blockinstanceid = &#039;43962&#039; # messages&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bpa ON bpa.contextid = ctxx.id AND bpa.blockinstanceid = &#039;43963&#039; # activities&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bpr ON bpr.contextid = ctxx.id AND bpr.blockinstanceid = &#039;38368&#039; # html research help&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_course_sections AS cs ON cs.course = c.id AND cs.visible = 1 AND cs.sequence IS NOT NULL&lt;br /&gt;
LEFT JOIN prefix_course_modules AS cm ON cm.course = c.id AND cm.section = cs.id &lt;br /&gt;
LEFT JOIN prefix_modules AS m ON m.id = cm.module&lt;br /&gt;
LEFT JOIN prefix_grade_items AS gi ON gi.courseid = c.id AND gi.itemmodule = m.name AND gi.iteminstance = cm.instance&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_forum AS f ON f.course = c.id AND cm.instance = f.id AND cm.visible = 1&lt;br /&gt;
LEFT JOIN prefix_forum_discussions AS fd ON fd.forum = f.id&lt;br /&gt;
&lt;br /&gt;
# attach manual grade items to course-- they don&#039;t have modules&lt;br /&gt;
LEFT JOIN prefix_grade_items AS mgi ON mgi.courseid = c.id and mgi.itemtype = &#039;manual&#039;&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_course_format_options AS cfo ON cfo.courseid = c.id AND cfo.name = &#039;layoutstructure&#039;&lt;br /&gt;
LEFT JOIN prefix_course_format_options AS cfw ON cfw.courseid = c.id AND cfw.name = &#039;numsections&#039;&lt;br /&gt;
&lt;br /&gt;
LEFT JOIN prefix_block_instances AS bi ON bi.parentcontextid = ctxx.id AND bi.blockname = &#039;html&#039; AND (bi.configdata LIKE &#039;%SW5zdHJ1Y3Rvc%&#039; or bi.configdata LIKE &#039;%bnN0cnVjdG9y%&#039;)&lt;br /&gt;
LEFT JOIN prefix_block_positions AS bip ON bip.blockinstanceid = bi.id&lt;br /&gt;
&lt;br /&gt;
WHERE RIGHT(c.idnumber,2) IN (&#039;OL&#039;, &#039;BL&#039;, &#039;HY&#039;) &lt;br /&gt;
# AND substring(cc.path,2,2) IN (&#039;26&#039;) # Staging&lt;br /&gt;
#AND substring(cc.path,2,3) IN (&#039;158&#039;) # UG&lt;br /&gt;
AND cc.idnumber LIKE &#039;%staging%&#039;&lt;br /&gt;
AND ctxx.contextlevel = 50&lt;br /&gt;
&lt;br /&gt;
GROUP BY c.shortname&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;
===Rubrics without zero values in criteria===&lt;br /&gt;
Contributed by Eric Strom&lt;br /&gt;
&lt;br /&gt;
Rubric calculations in Moodle can fail to align with instructors expectations if they lack a zero value for each criterion used in the assessment. From documentation at https://docs.moodle.org/38/en/Rubrics#Grade_calculation:&lt;br /&gt;
&lt;br /&gt;
&amp;quot;For example, when the teacher in the previous example chose both levels with 1 point, the plain sum would be 2 points. But that is actually the lowest possible score so it maps to the grade 0 in Moodle.&lt;br /&gt;
TIP: To avoid confusion from this sort of thing, we recommend including a level with 0 points in every rubric criterion.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This report identifies rubrics having criteria without a zero value level and the courses they live in. This also refines to only assignments with active rubrics that are visible to students in the course. Links to the each rubric id is the direct link to edit the rubric. Fix by adding a zero level for each criteria that is missing it. In general, the grading changes that result will be in the students&#039; favor.&lt;br /&gt;
&lt;br /&gt;
Includes search filter of course idnumber.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT cat.name AS Department, concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/course/view.php&#039;,CHAR(63),&#039;id=&#039;,&lt;br /&gt;
c.id,&#039;&amp;quot;&amp;gt;&#039;,c.idnumber,&#039;&amp;lt;/a&amp;gt;&#039;) AS Course_ID, &lt;br /&gt;
c.fullname AS Course_Name, &lt;br /&gt;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/grade/grading/form/rubric/edit.php&#039;,CHAR(63),&#039;areaid=&#039;,gd.areaid,&#039;&amp;quot;&amp;gt;&#039;,gd.areaid,&#039;&amp;lt;/a&amp;gt;&#039;) AS Rubric&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
JOIN prefix_course_categories AS cat &lt;br /&gt;
ON cat.id = c.category&lt;br /&gt;
JOIN prefix_course_modules AS cm &lt;br /&gt;
ON c.id=cm.course&lt;br /&gt;
JOIN prefix_context AS ctx &lt;br /&gt;
ON cm.id = ctx.instanceid&lt;br /&gt;
JOIN prefix_grading_areas AS garea &lt;br /&gt;
ON ctx.id = garea.contextid&lt;br /&gt;
JOIN prefix_grading_definitions AS gd &lt;br /&gt;
ON garea.id = gd.areaid&lt;br /&gt;
JOIN prefix_gradingform_rubric_criteria AS crit &lt;br /&gt;
ON gd.id = crit.definitionid&lt;br /&gt;
JOIN prefix_gradingform_rubric_levels AS levels &lt;br /&gt;
ON levels.criterionid = crit.id&lt;br /&gt;
WHERE cm.visible=&#039;1&#039; AND garea.activemethod = &#039;rubric&#039; AND (crit.id NOT IN&lt;br /&gt;
(SELECT crit.id&lt;br /&gt;
FROM prefix_gradingform_rubric_criteria AS crit&lt;br /&gt;
JOIN prefix_gradingform_rubric_levels AS levels &lt;br /&gt;
ON levels.criterionid = crit.id WHERE levels.score = &#039;0&#039;))&lt;br /&gt;
&lt;br /&gt;
GROUP BY Rubric&lt;br /&gt;
ORDER BY Course_ID, Rubric&lt;br /&gt;
&lt;br /&gt;
%%FILTER_SEARCHTEXT:c.idnumber:~%%&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;
===Delete all the automated backup files===&lt;br /&gt;
Prepare bash cli script to delete all the automated backup files on the file system. (clean up some disk space)&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT CONCAT( &#039;rm -f /var/moodledatanew/filedir/&#039;, SUBSTRING( contenthash, 1, 2 ) , &#039;/&#039;, SUBSTRING( contenthash, 3, 2 ) , &#039;/&#039;, contenthash ) &lt;br /&gt;
FROM `mdl_files` &lt;br /&gt;
WHERE `filename` LIKE &#039;%mbz%&#039;&lt;br /&gt;
AND filearea = &#039;automated&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Find out how much disk space is used by all automated backup files:&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT SUM(filesize)/(1024*1024*1024) FROM `mdl_files` WHERE  `filename` LIKE &#039;%mbz%&#039; AND filearea =  &#039;automated&#039;&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;
&lt;br /&gt;
===Quiz activity research===&lt;br /&gt;
This report was made to extract student full activity in quizzes for an academic research about adapting instructional design teaching methods in online learning. The students do not use the Quiz module as a standard quiz but more as Study booklets or mini courses with embedded questions and hints to assist students evaluate their progress (Similar to what you expect to find in a SCORM activity)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
cm.course &amp;quot;course_id&amp;quot;, cm.id &amp;quot;moduel_id&amp;quot;, q.id &amp;quot;quiz_id&amp;quot;, q.name &amp;quot;quiz_name&amp;quot;,&lt;br /&gt;
 &lt;br /&gt;
CASE q.grademethod&lt;br /&gt;
      WHEN 1 THEN &amp;quot;GRADEHIGHEST&amp;quot;&lt;br /&gt;
      WHEN 2 THEN &amp;quot;GRADEAVERAGE&amp;quot;&lt;br /&gt;
      WHEN 3 THEN &amp;quot;ATTEMPTFIRST&amp;quot;&lt;br /&gt;
      WHEN 4 THEN &amp;quot;ATTEMPTLAST&amp;quot;&lt;br /&gt;
END &amp;quot;grade method&amp;quot;&lt;br /&gt;
   &lt;br /&gt;
, q.attempts &amp;quot;quiz_attempts_allowed&amp;quot;, cm.groupmode &amp;quot;group_mode&amp;quot;&lt;br /&gt;
, qa.id &amp;quot;attempt_id&amp;quot;, qa.state &amp;quot;attempt_state&amp;quot;, qa.sumgrades &amp;quot;attempt_grade&amp;quot;, qg.grade &amp;quot;user_final_grade&amp;quot;, q.grade &amp;quot;quiz_max_grade&amp;quot;&lt;br /&gt;
,(SELECT GROUP_CONCAT(g.name) FROM mdl_groups AS g&lt;br /&gt;
JOIN mdl_groups_members AS m ON g.id = m.groupid WHERE g.courseid = q.course AND m.userid = u.id) &amp;quot;user_groups&amp;quot;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(qa.timestart), &#039;%d-%m-%Y %h:%k&#039;) &amp;quot;attempt_start&amp;quot;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(qa.timefinish), &#039;%d-%m-%Y %h:%k&#039;) &amp;quot;attempt_finish&amp;quot;,&lt;br /&gt;
u.id &amp;quot;user_id&amp;quot;, u.firstname, u.lastname,&lt;br /&gt;
question.id &amp;quot;question_id&amp;quot;, question.name &amp;quot;question_name&amp;quot;,&lt;br /&gt;
qas.state &amp;quot;question_step_state&amp;quot;,qas.fraction &amp;quot;question_grade&amp;quot;, qh.hint, question.qtype &amp;quot;question_type&amp;quot;&lt;br /&gt;
&lt;br /&gt;
FROM mdl_quiz as q&lt;br /&gt;
JOIN mdl_course_modules as cm ON cm.instance = q.id and cm.module = 14 &lt;br /&gt;
JOIN mdl_quiz_attempts qa ON q.id = qa.quiz&lt;br /&gt;
LEFT JOIN mdl_quiz_grades as qg ON qg.quiz = q.id and qg.userid = qa.userid&lt;br /&gt;
JOIN mdl_user as u ON u.id = qa.userid&lt;br /&gt;
JOIN mdl_question_usages as qu ON qu.id = qa.uniqueid&lt;br /&gt;
JOIN mdl_question_attempts as qatt ON qatt.questionusageid = qu.id&lt;br /&gt;
JOIN mdl_question as question ON question.id = qatt.questionid&lt;br /&gt;
JOIN mdl_question_attempt_steps as qas ON qas.questionattemptid = qatt.id&lt;br /&gt;
LEFT JOIN mdl_question_hints as qh ON qh.questionid = q.id&lt;br /&gt;
#WHERE q.id = &amp;quot;SOME QUIZ ID&amp;quot;&lt;br /&gt;
WHERE cm.course = &amp;quot;SOME COURSE ID&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Quiz Usage in Courses by Date===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
This report lists the courses containing quizzes with the course start date between the two values, and provides a summary of the types of questions in the quizzes in each course and whether question randomization and answer randomization functions were used.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Multiple Choice&amp;quot; questions include true/false and matching question types.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Short Answer&amp;quot; are questions that accept a single phrase.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Other&amp;quot; questions include fixed numerical, calculated, essay, and various drag and drop types.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Min Quiz Age&amp;quot; and &amp;quot;Max Quiz Age&amp;quot; provide data about the last modified date for the quizzes in the course, compared to the course start date. The values are expressed in units of days. A negative value indicates that a quiz was edited after the start of the course. A value greater than 90 days indicates that the quiz may have been used in an earlier term (cohort) without modification.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: In Configurable Reports, the Date Filter is not applied until the &amp;quot;Apply&amp;quot; button is clicked.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
&lt;br /&gt;
c.shortname AS &#039;Course&#039;&lt;br /&gt;
#, u.lastname AS &#039;Instructor&#039;&lt;br /&gt;
, COUNT(DISTINCT q.id) AS &#039;Quizzes&#039;&lt;br /&gt;
, COUNT(DISTINCT qu.id) AS &#039;Questions&#039;&lt;br /&gt;
, SUM(IF (qu.qtype = &#039;multichoice&#039;, 1, 0 )) + SUM(IF (qu.qtype = &#039;truefalse&#039;, 1, 0 )) + SUM(IF (qu.qtype = &#039;match&#039;, 1, 0 ))  AS &#039;multichoice&#039;&lt;br /&gt;
&lt;br /&gt;
, SUM(IF (qu.qtype = &#039;shortanswer&#039;, 1, 0 )) AS &#039;shortanswer&#039;&lt;br /&gt;
&lt;br /&gt;
, COUNT( qu.id) - SUM(IF (qu.qtype = &#039;multichoice&#039;, 1, 0 )) - SUM(IF (qu.qtype = &#039;truefalse&#039;, 1, 0 )) - SUM(IF (qu.qtype = &#039;match&#039;, 1, 0 )) - SUM(IF (qu.qtype = &#039;shortanswer&#039;, 1, 0 )) AS &#039;Other&#039;&lt;br /&gt;
&lt;br /&gt;
, (SUM(IF (qu.qtype = &#039;multichoice&#039;, 1, 0 )) + SUM(IF (qu.qtype = &#039;truefalse&#039;, 1, 0 )) + SUM(IF (qu.qtype = &#039;match&#039;, 1, 0 )))/COUNT( qu.id) AS &#039;Percent MC&#039;&lt;br /&gt;
&lt;br /&gt;
#, SUM(IF (qu.qtype = &#039;numerical&#039;, 1, 0 )) AS &#039;numerical&#039;&lt;br /&gt;
#, SUM(IF (qu.qtype LIKE &#039;calc%&#039;, 1, 0 )) AS &#039;calculated&#039;&lt;br /&gt;
#, SUM(IF (qu.qtype = &#039;random&#039;, 1, 0 )) AS &#039;random&#039;&lt;br /&gt;
#, SUM(IF (qu.qtype = &#039;shortanswer&#039;, 1, 0 )) AS &#039;shortanswer&#039;&lt;br /&gt;
#, SUM(IF (qu.qtype = &#039;essay&#039;, 1, 0 )) AS &#039;essay&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
, IF(q.shufflequestions &amp;gt; 0,&#039;Yes&#039;,&#039;No&#039;) AS &#039;Randomized Questions&#039;&lt;br /&gt;
, IF(q.shuffleanswers &amp;gt; 0,&#039;Yes&#039;,&#039;No&#039;) AS &#039;Randomized Answers&#039;&lt;br /&gt;
 &lt;br /&gt;
#, FROM_UNIXTIME(c.startdate) AS &#039;Course Start Date&#039;&lt;br /&gt;
#, FROM_UNIXTIME(MIN(q.timemodified)) AS &#039;Last Modified&#039;&lt;br /&gt;
&lt;br /&gt;
#, DATEDIFF(FROM_UNIXTIME(c.startdate),FROM_UNIXTIME(MIN(q.timemodified))) AS &#039;Quiz age&#039;&lt;br /&gt;
&lt;br /&gt;
, MIN(DATEDIFF(FROM_UNIXTIME(c.startdate),FROM_UNIXTIME(q.timemodified))) AS &#039;Min Quiz Age&#039; &lt;br /&gt;
, MAX(DATEDIFF(FROM_UNIXTIME(c.startdate),FROM_UNIXTIME(q.timemodified))) AS &#039;Max Quiz Age&#039; &lt;br /&gt;
&lt;br /&gt;
#, SUM(IF (DATEDIFF(FROM_UNIXTIME(c.startdate),FROM_UNIXTIME(q.timemodified)) &amp;lt; 90, 1,0)) AS &#039;new quizzes&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_quiz AS q&lt;br /&gt;
JOIN prefix_course AS c on c.id = q.course&lt;br /&gt;
JOIN prefix_quiz_question_instances AS qqi ON qqi.quiz = q.id&lt;br /&gt;
LEFT JOIN prefix_question AS qu ON qu.id = qqi.question&lt;br /&gt;
&lt;br /&gt;
WHERE&lt;br /&gt;
1&lt;br /&gt;
%%FILTER_STARTTIME:c.startdate:&amp;gt;%% %%FILTER_ENDTIME:c.startdate:&amp;lt;%%&lt;br /&gt;
&lt;br /&gt;
GROUP BY c.id&lt;br /&gt;
&lt;br /&gt;
ORDER BY c.shortname&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;
===Course Aggregation Report===&lt;br /&gt;
Contributed by Elizabeth Dalton, Granite State College&lt;br /&gt;
&lt;br /&gt;
If you are considering upgrading from Moodle 2.6 to 2.8 or later, your grades may be changed. This report can help quantify and identify the courses at risk of changes.&lt;br /&gt;
&lt;br /&gt;
In particular, be on the lookout for any courses with the following combinations of parameters, which are known to cause changes in calculations:&lt;br /&gt;
&lt;br /&gt;
# mean of grades set with aggregate with subcategory.&lt;br /&gt;
# Simple weighted mean of grades with aggregate with sub category and drop the lowest&lt;br /&gt;
# Sum of grades drop the lowest&lt;br /&gt;
&lt;br /&gt;
Also review:&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-48618&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-48634&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-49257&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-50089&lt;br /&gt;
https://tracker.moodle.org/browse/MDL-50062&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
&lt;br /&gt;
COUNT(c.shortname) AS &#039;Count of Courses&#039;&lt;br /&gt;
&lt;br /&gt;
# If you want to display all the courses for each aggregation type, uncomment the next line and change GROUP BY settings&lt;br /&gt;
#, c.shortname AS &#039;course name&#039;&lt;br /&gt;
&lt;br /&gt;
# If you need to display grade categories for each aggregation type, uncomment the next line and change GROUP BY settings&lt;br /&gt;
#, gc.fullname AS &#039;grade category name&#039;&lt;br /&gt;
&lt;br /&gt;
, gc.aggregation AS &#039;aggregation method&#039;&lt;br /&gt;
&lt;br /&gt;
#These aggregation text strings appear to be hard-coded. I couldn&#039;t find a table for them. If you have aggregation types I haven&#039;t included here, they&#039;ll be blank in your report results.&lt;br /&gt;
, CASE gc.aggregation&lt;br /&gt;
  WHEN 0 THEN &#039;Mean of Grades&#039;&lt;br /&gt;
  WHEN 2 THEN &#039;Median of Grades&#039;&lt;br /&gt;
  WHEN 6 THEN &#039;Highest Grade&#039;&lt;br /&gt;
  WHEN 8 THEN &#039;Mode of Grades&#039;&lt;br /&gt;
  WHEN 10 THEN &#039;Weighted Mean of Grades&#039;&lt;br /&gt;
  WHEN 11 THEN &#039;Simple Weighted Mean of Grades&#039;&lt;br /&gt;
  WHEN 12 THEN &#039;Mean of Grades (with extra credits)&#039;&lt;br /&gt;
  WHEN 13 THEN &#039;Sum of Grades&#039;&lt;br /&gt;
END AS &#039;aggregation name&#039;&lt;br /&gt;
&lt;br /&gt;
# Note that gc.aggregatesubcats column is eliminated in 2.8 and later per MDL-47503, so comment that line on updated systems or you&#039;ll get an error&lt;br /&gt;
, gc.keephigh AS &#039;keep high&#039;&lt;br /&gt;
, gc.droplow AS &#039;dr0p low&#039;&lt;br /&gt;
, gc.aggregateonlygraded AS &#039;Aggregate only graded&#039;&lt;br /&gt;
, gc.aggregateoutcomes AS &#039;aggregate outcomes&#039;&lt;br /&gt;
, gc.aggregatesubcats AS &#039;aggregate subcategories&#039;&lt;br /&gt;
&lt;br /&gt;
# If you are displaying data about individual courses, you may want to know how old they are&lt;br /&gt;
#, FROM_UNIXTIME(c.startdate) AS &#039;course start date&#039;&lt;br /&gt;
&lt;br /&gt;
# If you are trying to use this report to check to see if final grades have changed after an upgrade, you might want these data items, but calculations can still change later when the courses are actually viewed. Also, you&#039;ll need to uncomment the necessary JOINs below&lt;br /&gt;
#, gi.itemname AS &#039;grade item&#039;&lt;br /&gt;
#, gg.finalgrade AS &#039;final grade&#039;&lt;br /&gt;
&lt;br /&gt;
FROM&lt;br /&gt;
&lt;br /&gt;
prefix_course AS c&lt;br /&gt;
JOIN prefix_grade_categories AS gc ON gc.courseid = c.id&lt;br /&gt;
JOIN prefix_course_categories AS cc ON cc.id = c.category&lt;br /&gt;
&lt;br /&gt;
#LEFT JOIN prefix_grade_items AS gi ON gi.courseid = c.id #AND gi.categoryid=gc.id&lt;br /&gt;
#LEFT JOIN prefix_grade_grades AS gg ON gg.itemid = gi.id AND gg.userid = u.id&lt;br /&gt;
&lt;br /&gt;
WHERE&lt;br /&gt;
1&lt;br /&gt;
#AND gc.aggregation = 13 #only the dreaded Sum of Grades aggregations&lt;br /&gt;
#AND gc.depth = 1 # if for some reason you only want course aggregations, not subcategories&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
GROUP BY gc.aggregation, gc.keephigh, gc.droplow, gc.aggregateonlygraded, gc.aggregateoutcomes, gc.aggregatesubcats&lt;br /&gt;
&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;
==See also==&lt;br /&gt;
[https://github.com/jleyva/moodle-configurable_reports_repository Configurable Reports Repository on GitHub]&lt;br /&gt;
&lt;br /&gt;
[[Category:Contributed code]]&lt;br /&gt;
&lt;br /&gt;
[[es:Reportes específicos hechos por usuarios]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118616</id>
		<title>Talk:Logging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118616"/>
		<updated>2015-05-21T12:20:59Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Legacy logging&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;
:: Do current versions of Moodle core still write any data to the legacy log?&lt;br /&gt;
:: --[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 20:20, 21 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;br /&gt;
&lt;br /&gt;
:: Thanks Marina. If you disable writing to the legacy log will the data that would have been written to the legacy log if it were still enabled be written to the standard log instead? Or will that &amp;quot;legacy log data&amp;quot; not be written to any log at all?&lt;br /&gt;
:: --[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 17:37, 21 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
Can you migrate the data in the legacy logs to the new standard log? If so, is there a documented migration process?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 19:05, 21 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
If you have a need to keep all your logging data indefinately, or for a very long time, does it make better to use an external database for logging? If so, is there any documentation describing how to do this log data migration from the Moodle database to the external logging database?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 19:05, 21 May 2015 (AWST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118615</id>
		<title>Talk:Logging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118615"/>
		<updated>2015-05-21T12:16:14Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: More logging questions&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;br /&gt;
&lt;br /&gt;
:: Thanks Marina. If you disable writing to the legacy log will the data that would have been written to the legacy log if it were still enabled be written to the standard log instead? Or will that &amp;quot;legacy log data&amp;quot; not be written to any log at all?&lt;br /&gt;
:: --[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 17:37, 21 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
:: Do current versions of Moodle core still write any data to the legacy log?&lt;br /&gt;
:: --[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 20:16, 21 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
Can you migrate the data in the legacy logs to the new standard log? If so, is there a documented migration process?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 19:05, 21 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
If you have a need to keep all your logging data indefinately, or for a very long time, does it make better to use an external database for logging? If so, is there any documentation describing how to do this log data migration from the Moodle database to the external logging database?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 19:05, 21 May 2015 (AWST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118614</id>
		<title>Talk:Logging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118614"/>
		<updated>2015-05-21T11:05:21Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Logging FAQs */&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;br /&gt;
&lt;br /&gt;
:: Thanks Marina. If you disable writing to the legacy log will the data that would have been written to the legacy log if it were still enabled be written to the standard log instead? Or will that &amp;quot;legacy log data&amp;quot; not be written to any log at all?&lt;br /&gt;
:: --[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 17:37, 21 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
Can you migrate the data in the legacy logs to the new standard log? If so, is there a documented migration process?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 19:05, 21 May 2015 (AWST)&lt;br /&gt;
&lt;br /&gt;
If you have a need to keep all your logging data indefinately, or for a very long time, does it make better to use an external database for logging? If so, is there any documentation describing how to do this log data migration from the Moodle database to the external logging database?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 19:05, 21 May 2015 (AWST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118612</id>
		<title>Talk:Logging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118612"/>
		<updated>2015-05-21T09:37:26Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Legacy logging */&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;br /&gt;
&lt;br /&gt;
:: Thanks Marina. If you disable writing to the legacy log will the data that would have been written to the legacy log if it were still enabled be written to the standard log instead? Or will that &amp;quot;legacy log data&amp;quot; not be written to any log at all?&lt;br /&gt;
:: --[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 17:37, 21 May 2015 (AWST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118601</id>
		<title>Talk:Logging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118601"/>
		<updated>2015-05-20T07:52:25Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Legacy logging */&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;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118600</id>
		<title>Talk:Logging</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Logging&amp;diff=118600"/>
		<updated>2015-05-20T07:50:01Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Need clarity on Standard logging and Legacy logging */&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; 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 standard log that is not stored in the legacy 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:50, 20 May 2015 (AWST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Using_slash_arguments&amp;diff=117692</id>
		<title>Using slash arguments</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Using_slash_arguments&amp;diff=117692"/>
		<updated>2015-03-25T11:28:47Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: SCORM FAQ link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Environment}}&lt;br /&gt;
It is recommended that the use of slash arguments is enabled. In future it will be required. &lt;br /&gt;
&lt;br /&gt;
For further information, see&lt;br /&gt;
&lt;br /&gt;
* [[Internet Information Services#Slasharguments|IIS server configuration]]&lt;br /&gt;
* [[Apache#Slasharguments|Apache slasharguments configuration]]&lt;br /&gt;
* [[Nginx#Slasharguments|Nginx slasharguments configuration]]&lt;br /&gt;
* [[SCORM_FAQ#slash_arguments_warning_when_I_add.2Fupdate_SCORM_objects_in_my_course|SCORM FAQ: slash arguments warning when I add/update SCORM objects in my course]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Using_slash_arguments&amp;diff=117691</id>
		<title>Using slash arguments</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Using_slash_arguments&amp;diff=117691"/>
		<updated>2015-03-25T11:27:07Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Added SCORM_FAQ slash_arguments link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Environment}}&lt;br /&gt;
It is recommended that the use of slash arguments is enabled. In future it will be required. &lt;br /&gt;
&lt;br /&gt;
For further information, see&lt;br /&gt;
&lt;br /&gt;
* [[Internet Information Services#Slasharguments|IIS server configuration]]&lt;br /&gt;
* [[Apache#Slasharguments|Apache slasharguments configuration]]&lt;br /&gt;
* [[Nginx#Slasharguments|Nginx slasharguments configuration]]&lt;br /&gt;
* [[SCORM_FAQ#slash_arguments_warning_when_I_add.2Fupdate_SCORM_objects_in_my_course|SCORM FAQ slash arguments warning when I add/update SCORM objects in my course]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Internet_Information_Services&amp;diff=117288</id>
		<title>Internet Information Services</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Internet_Information_Services&amp;diff=117288"/>
		<updated>2015-03-03T13:36:20Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Debugging problems */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}[[Internet Information Services]] (&#039;&#039;&#039;IIS&#039;&#039;&#039;) is the web server software bundled with Windows Server, as well as certain client versions of Windows. Please note Apache web server has much better community support and there are usually fewer problems when running Moodle on Apache. Windows OS is not suitable for large installations because PHP is limited to 32bit even in 64bit Windows, please consider using Linux or other unix-like operating systems instead.&lt;br /&gt;
&lt;br /&gt;
==IIS installation steps (Windows 7)==&lt;br /&gt;
&lt;br /&gt;
# Go to Control panel, click on Programs and Turn Windows features on or off&lt;br /&gt;
# Tick &amp;quot;Internet Information Services&amp;quot; and &amp;quot;Internet Information Services / Application Development Features / CGI&amp;quot;&lt;br /&gt;
# Install [http://www.microsoft.com/web/downloads/platform.aspx Microsoft Web Platform Installer]&lt;br /&gt;
&lt;br /&gt;
==PHP installation steps==&lt;br /&gt;
&lt;br /&gt;
It is strongly recommended to use only the official MS Platform installer, it automatically installs all necessary components and facilitates easy configuration with PHP manager. Manual installation attempts often fail or may not allow Moodle to function properly. Unfortunately MS does not usually distribute up-to-date version of PHP, you may need to download them manually.&lt;br /&gt;
&lt;br /&gt;
# Install [http://www.microsoft.com/web/downloads/platform.aspx Miscrosoft Web Platform Installer]&lt;br /&gt;
# Install latest PHP 5.5.x using Web Platform Installer&lt;br /&gt;
# Install URL Rewrite 2.0 using Web Platform Installer&lt;br /&gt;
&lt;br /&gt;
Optionally you may install the required components manually:&lt;br /&gt;
# Download [http://phpmanager.codeplex.com PHP manager for IIS] and install it&lt;br /&gt;
# Download latest PHP 5.5.x VC11 x86 Non Thread Safe from [http://windows.php.net/download/ http://windows.php.net/download/]&lt;br /&gt;
# Extract the Zip file to a directory such as C:\PHP\&lt;br /&gt;
# Install the Visual C++ Redistributable for Visual Studio 2012 [http://www.microsoft.com/en-us/download/details.aspx?id=30679] - on 64bit Windows install both x86 and x64&lt;br /&gt;
# Open the Internet Information Service (IIS) Manager - right click on This computer and select Manage&lt;br /&gt;
# Click on PHP Manager icon&lt;br /&gt;
# Register new PHP version - select C:\PHP\php-cgi.exe&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning: PHP needs to be configured via FastCGI in IIS, older CGI interface is known to have problems with some file names.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==PHP configuration steps==&lt;br /&gt;
&lt;br /&gt;
# Set PHP configuration to values recommended by PHP Manager&lt;br /&gt;
# Enable required extensions in the PHP manager: php_intl.dll, php_pgsql.dll&lt;br /&gt;
# Enable [[OPcache]] extension&lt;br /&gt;
# Set your timezone in PHP.ini&lt;br /&gt;
# Set appropriate memory limits in PHP.ini&lt;br /&gt;
&lt;br /&gt;
==IIS configuration steps==&lt;br /&gt;
&lt;br /&gt;
# Setup URL rewriting described below&lt;br /&gt;
# Configure IIS to show detailed error pages.&lt;br /&gt;
# Set very long CGI timeout - 1 hour or better more.&lt;br /&gt;
# In IIS Manager add Moodle dirroot directory as a new virtual directory or set it as site directory&lt;br /&gt;
&lt;br /&gt;
===Slasharguments===&lt;br /&gt;
&lt;br /&gt;
IIS 7 should support relative path arguments by default, if it does not work try enabling following in your php.ini&lt;br /&gt;
&lt;br /&gt;
 cgi.fix_pathinfo = 1&lt;br /&gt;
&lt;br /&gt;
===URL rewriting===&lt;br /&gt;
If you can not modify registry as described below you may try manual configuration of rewrite rules, the PHP installation via &#039;&#039;Microsoft Web Platform Installer&#039;&#039; installs necessary &#039;&#039;URL Rewrite 2.0&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
[[File:Rewrite_rule_-_Internet_Information_Services_(IIS)_Manager.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add following rewrite rule to enable support for unicode file names in Moodle and to work around internal file length limitation breaking YUI file serving:&lt;br /&gt;
&lt;br /&gt;
* Matches the Pattern - Regular Expressions - &amp;lt;code&amp;gt;^([^\?]+?\.php)(\/.+)$&amp;lt;/code&amp;gt;&lt;br /&gt;
* Action - Rewrite - &amp;lt;code&amp;gt;{R:1}\?file={R:2}&amp;lt;/code&amp;gt;&lt;br /&gt;
* Append query string - enabled&lt;br /&gt;
* Stop processing of subsequent rules - enabled&lt;br /&gt;
&lt;br /&gt;
===Optional UTF-8 file name fix===&lt;br /&gt;
&lt;br /&gt;
By default IIS is unable to handle unicode characters in files uploaded into Moodle. This may result in not working Javascript on Moodle site (impossible to expand navigation, etc.) or broken CSS styles.&lt;br /&gt;
&lt;br /&gt;
See [http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/configuring-the-fastcgi-extension-for-iis-60#utf8servervars Using UTF-8 Encoding for Server Variables] and [http://support.microsoft.com/kb/2277918/ How to get UTF-8 Encoding support in IIS 7.5 in Windows 7 and Windows Server 2008 R2 with the KB 2277918 hotfix].&lt;br /&gt;
&lt;br /&gt;
Execute:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
reg add HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\w3svc\Parameters /v FastCGIUtf8ServerVariables /t REG_MULTI_SZ /d REQUEST_URI\0PATH_INFO&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CGI timeouts===&lt;br /&gt;
&lt;br /&gt;
By default IIS is configured to stop execution of any PHP script after 5 minutes of activity, this interferes with long running Moodle scripts such as upgrade or cron. The timeout should be increased to at least one hour.&lt;br /&gt;
&lt;br /&gt;
==Directory permissions==&lt;br /&gt;
&lt;br /&gt;
The default IIS account is &#039;&#039;IIS_IUSRS&#039;&#039;, make sure it has appropriate access right to Moodle dirroot (read only) and dataroot (read/write) directories.&lt;br /&gt;
&lt;br /&gt;
==Debugging problems==&lt;br /&gt;
&lt;br /&gt;
By default, IIS uses custom error pages that intentionally hide error details on production sites:&lt;br /&gt;
[[Image:scratch1_77F5DD11.jpg|frame|center|IIS default error message]]&lt;br /&gt;
&lt;br /&gt;
But when you&#039;re diagnosing problems in Moodle that&#039;s not very useful. You can temporarily disable these default error messages in IIS so that you see a specific Moodle error message. To achieve that set the &amp;quot;existingResponse&amp;quot; setting for Custom Error Pages in IIS to “PassThrough” for your Moodle site. The result will be that Moodle displays a more specific message about the error when a problem occurs:&lt;br /&gt;
[[Image:scratch2_243263F6.jpg|frame|center|Useful error message]]&lt;br /&gt;
The generic IIS &amp;quot;404&amp;quot; error message which normally does not reveal any details about the problem will no longer be displayed.&lt;br /&gt;
&lt;br /&gt;
The debugging option in &#039;&#039;Settings&amp;gt;Site administration&amp;gt;Development&amp;gt;Debugging&#039;&#039; should also be enabled so that you see the debug messages.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Installing MSSQL for PHP]]&lt;br /&gt;
* [http://www.iis.net  The Official Microsoft IIS Site]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Internet_Information_Services Wikipedia article on IIS]&lt;br /&gt;
* [http://php.iis.net/ PHP installer for IIS]&lt;br /&gt;
* [http://blogs.iis.net/kehand/archive/2009/08/09/php-and-custom-error-pages.aspx Kern Handa&#039;s blog post about IIS error messages]&lt;br /&gt;
&lt;br /&gt;
[[ja:IIS]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Internet_Information_Services&amp;diff=117287</id>
		<title>Internet Information Services</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Internet_Information_Services&amp;diff=117287"/>
		<updated>2015-03-03T13:34:44Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}[[Internet Information Services]] (&#039;&#039;&#039;IIS&#039;&#039;&#039;) is the web server software bundled with Windows Server, as well as certain client versions of Windows. Please note Apache web server has much better community support and there are usually fewer problems when running Moodle on Apache. Windows OS is not suitable for large installations because PHP is limited to 32bit even in 64bit Windows, please consider using Linux or other unix-like operating systems instead.&lt;br /&gt;
&lt;br /&gt;
==IIS installation steps (Windows 7)==&lt;br /&gt;
&lt;br /&gt;
# Go to Control panel, click on Programs and Turn Windows features on or off&lt;br /&gt;
# Tick &amp;quot;Internet Information Services&amp;quot; and &amp;quot;Internet Information Services / Application Development Features / CGI&amp;quot;&lt;br /&gt;
# Install [http://www.microsoft.com/web/downloads/platform.aspx Microsoft Web Platform Installer]&lt;br /&gt;
&lt;br /&gt;
==PHP installation steps==&lt;br /&gt;
&lt;br /&gt;
It is strongly recommended to use only the official MS Platform installer, it automatically installs all necessary components and facilitates easy configuration with PHP manager. Manual installation attempts often fail or may not allow Moodle to function properly. Unfortunately MS does not usually distribute up-to-date version of PHP, you may need to download them manually.&lt;br /&gt;
&lt;br /&gt;
# Install [http://www.microsoft.com/web/downloads/platform.aspx Miscrosoft Web Platform Installer]&lt;br /&gt;
# Install latest PHP 5.5.x using Web Platform Installer&lt;br /&gt;
# Install URL Rewrite 2.0 using Web Platform Installer&lt;br /&gt;
&lt;br /&gt;
Optionally you may install the required components manually:&lt;br /&gt;
# Download [http://phpmanager.codeplex.com PHP manager for IIS] and install it&lt;br /&gt;
# Download latest PHP 5.5.x VC11 x86 Non Thread Safe from [http://windows.php.net/download/ http://windows.php.net/download/]&lt;br /&gt;
# Extract the Zip file to a directory such as C:\PHP\&lt;br /&gt;
# Install the Visual C++ Redistributable for Visual Studio 2012 [http://www.microsoft.com/en-us/download/details.aspx?id=30679] - on 64bit Windows install both x86 and x64&lt;br /&gt;
# Open the Internet Information Service (IIS) Manager - right click on This computer and select Manage&lt;br /&gt;
# Click on PHP Manager icon&lt;br /&gt;
# Register new PHP version - select C:\PHP\php-cgi.exe&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning: PHP needs to be configured via FastCGI in IIS, older CGI interface is known to have problems with some file names.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==PHP configuration steps==&lt;br /&gt;
&lt;br /&gt;
# Set PHP configuration to values recommended by PHP Manager&lt;br /&gt;
# Enable required extensions in the PHP manager: php_intl.dll, php_pgsql.dll&lt;br /&gt;
# Enable [[OPcache]] extension&lt;br /&gt;
# Set your timezone in PHP.ini&lt;br /&gt;
# Set appropriate memory limits in PHP.ini&lt;br /&gt;
&lt;br /&gt;
==IIS configuration steps==&lt;br /&gt;
&lt;br /&gt;
# Setup URL rewriting described below&lt;br /&gt;
# Configure IIS to show detailed error pages.&lt;br /&gt;
# Set very long CGI timeout - 1 hour or better more.&lt;br /&gt;
# In IIS Manager add Moodle dirroot directory as a new virtual directory or set it as site directory&lt;br /&gt;
&lt;br /&gt;
===Slasharguments===&lt;br /&gt;
&lt;br /&gt;
IIS 7 should support relative path arguments by default, if it does not work try enabling following in your php.ini&lt;br /&gt;
&lt;br /&gt;
 cgi.fix_pathinfo = 1&lt;br /&gt;
&lt;br /&gt;
===URL rewriting===&lt;br /&gt;
If you can not modify registry as described below you may try manual configuration of rewrite rules, the PHP installation via &#039;&#039;Microsoft Web Platform Installer&#039;&#039; installs necessary &#039;&#039;URL Rewrite 2.0&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
[[File:Rewrite_rule_-_Internet_Information_Services_(IIS)_Manager.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add following rewrite rule to enable support for unicode file names in Moodle and to work around internal file length limitation breaking YUI file serving:&lt;br /&gt;
&lt;br /&gt;
* Matches the Pattern - Regular Expressions - &amp;lt;code&amp;gt;^([^\?]+?\.php)(\/.+)$&amp;lt;/code&amp;gt;&lt;br /&gt;
* Action - Rewrite - &amp;lt;code&amp;gt;{R:1}\?file={R:2}&amp;lt;/code&amp;gt;&lt;br /&gt;
* Append query string - enabled&lt;br /&gt;
* Stop processing of subsequent rules - enabled&lt;br /&gt;
&lt;br /&gt;
===Optional UTF-8 file name fix===&lt;br /&gt;
&lt;br /&gt;
By default IIS is unable to handle unicode characters in files uploaded into Moodle. This may result in not working Javascript on Moodle site (impossible to expand navigation, etc.) or broken CSS styles.&lt;br /&gt;
&lt;br /&gt;
See [http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/configuring-the-fastcgi-extension-for-iis-60#utf8servervars Using UTF-8 Encoding for Server Variables] and [http://support.microsoft.com/kb/2277918/ How to get UTF-8 Encoding support in IIS 7.5 in Windows 7 and Windows Server 2008 R2 with the KB 2277918 hotfix].&lt;br /&gt;
&lt;br /&gt;
Execute:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
reg add HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\w3svc\Parameters /v FastCGIUtf8ServerVariables /t REG_MULTI_SZ /d REQUEST_URI\0PATH_INFO&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CGI timeouts===&lt;br /&gt;
&lt;br /&gt;
By default IIS is configured to stop execution of any PHP script after 5 minutes of activity, this interferes with long running Moodle scripts such as upgrade or cron. The timeout should be increased to at least one hour.&lt;br /&gt;
&lt;br /&gt;
==Directory permissions==&lt;br /&gt;
&lt;br /&gt;
The default IIS account is &#039;&#039;IIS_IUSRS&#039;&#039;, make sure it has appropriate access right to Moodle dirroot (read only) and dataroot (read/write) directories.&lt;br /&gt;
&lt;br /&gt;
==Debugging problems==&lt;br /&gt;
&lt;br /&gt;
By default, IIS uses custom error pages that intentionally hide error details on production sites:&lt;br /&gt;
[[Image:scratch1_77F5DD11.jpg|frame|center|IIS default error message]]&lt;br /&gt;
&lt;br /&gt;
When diagnosing problems in Moodle that&#039;s not very useful, so you can temporarily disable these default error messages in IIS so that you see a specific Moodle error message. To achieve that set the &amp;quot;existingResponse&amp;quot; setting for Custom Error Pages in IIS to “PassThrough” for your Moodle site. The result will be that Moodle displays a more specific message about the error when a problem occurs:&lt;br /&gt;
[[Image:scratch2_243263F6.jpg|frame|center|Useful error message]]&lt;br /&gt;
The generic IIS &amp;quot;404&amp;quot; error message which normally does not reveal any details about the problem will no longer be displayed.&lt;br /&gt;
&lt;br /&gt;
The debugging option in &#039;&#039;Settings&amp;gt;Site administration&amp;gt;Development&amp;gt;Debugging&#039;&#039; should also be enabled so that you see the debug messages.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Installing MSSQL for PHP]]&lt;br /&gt;
* [http://www.iis.net  The Official Microsoft IIS Site]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Internet_Information_Services Wikipedia article on IIS]&lt;br /&gt;
* [http://php.iis.net/ PHP installer for IIS]&lt;br /&gt;
* [http://blogs.iis.net/kehand/archive/2009/08/09/php-and-custom-error-pages.aspx Kern Handa&#039;s blog post about IIS error messages]&lt;br /&gt;
&lt;br /&gt;
[[ja:IIS]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Internet_Information_Services&amp;diff=117286</id>
		<title>Internet Information Services</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Internet_Information_Services&amp;diff=117286"/>
		<updated>2015-03-03T13:33:10Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: IIS debugging setup&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}[[Internet Information Services]] (&#039;&#039;&#039;IIS&#039;&#039;&#039;) is the web server software bundled with Windows Server, as well as certain client versions of Windows. Please note Apache web server has much better community support and there are usually fewer problems when running Moodle on Apache. Windows OS is not suitable for large installations because PHP is limited to 32bit even in 64bit Windows, please consider using Linux or other unix-like operating systems instead.&lt;br /&gt;
&lt;br /&gt;
==IIS installation steps (Windows 7)==&lt;br /&gt;
&lt;br /&gt;
# Go to Control panel, click on Programs and Turn Windows features on or off&lt;br /&gt;
# Tick &amp;quot;Internet Information Services&amp;quot; and &amp;quot;Internet Information Services / Application Development Features / CGI&amp;quot;&lt;br /&gt;
# Install [http://www.microsoft.com/web/downloads/platform.aspx Microsoft Web Platform Installer]&lt;br /&gt;
&lt;br /&gt;
==PHP installation steps==&lt;br /&gt;
&lt;br /&gt;
It is strongly recommended to use only the official MS Platform installer, it automatically installs all necessary components and facilitates easy configuration with PHP manager. Manual installation attempts often fail or may not allow Moodle to function properly. Unfortunately MS does not usually distribute up-to-date version of PHP, you may need to download them manually.&lt;br /&gt;
&lt;br /&gt;
# Install [http://www.microsoft.com/web/downloads/platform.aspx Miscrosoft Web Platform Installer]&lt;br /&gt;
# Install latest PHP 5.5.x using Web Platform Installer&lt;br /&gt;
# Install URL Rewrite 2.0 using Web Platform Installer&lt;br /&gt;
&lt;br /&gt;
Optionally you may install the required components manually:&lt;br /&gt;
# Download [http://phpmanager.codeplex.com PHP manager for IIS] and install it&lt;br /&gt;
# Download latest PHP 5.5.x VC11 x86 Non Thread Safe from [http://windows.php.net/download/ http://windows.php.net/download/]&lt;br /&gt;
# Extract the Zip file to a directory such as C:\PHP\&lt;br /&gt;
# Install the Visual C++ Redistributable for Visual Studio 2012 [http://www.microsoft.com/en-us/download/details.aspx?id=30679] - on 64bit Windows install both x86 and x64&lt;br /&gt;
# Open the Internet Information Service (IIS) Manager - right click on This computer and select Manage&lt;br /&gt;
# Click on PHP Manager icon&lt;br /&gt;
# Register new PHP version - select C:\PHP\php-cgi.exe&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning: PHP needs to be configured via FastCGI in IIS, older CGI interface is known to have problems with some file names.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==PHP configuration steps==&lt;br /&gt;
&lt;br /&gt;
# Set PHP configuration to values recommended by PHP Manager&lt;br /&gt;
# Enable required extensions in the PHP manager: php_intl.dll, php_pgsql.dll&lt;br /&gt;
# Enable [[OPcache]] extension&lt;br /&gt;
# Set your timezone in PHP.ini&lt;br /&gt;
# Set appropriate memory limits in PHP.ini&lt;br /&gt;
&lt;br /&gt;
==IIS configuration steps==&lt;br /&gt;
&lt;br /&gt;
# Setup URL rewriting described below&lt;br /&gt;
# Configure IIS to show detailed error pages.&lt;br /&gt;
# Set very long CGI timeout - 1 hour or better more.&lt;br /&gt;
# In IIS Manager add Moodle dirroot directory as a new virtual directory or set it as site directory&lt;br /&gt;
&lt;br /&gt;
===Slasharguments===&lt;br /&gt;
&lt;br /&gt;
IIS 7 should support relative path arguments by default, if it does not work try enabling following in your php.ini&lt;br /&gt;
&lt;br /&gt;
 cgi.fix_pathinfo = 1&lt;br /&gt;
&lt;br /&gt;
===URL rewriting===&lt;br /&gt;
If you can not modify registry as described below you may try manual configuration of rewrite rules, the PHP installation via &#039;&#039;Microsoft Web Platform Installer&#039;&#039; installs necessary &#039;&#039;URL Rewrite 2.0&#039;&#039; module.&lt;br /&gt;
&lt;br /&gt;
[[File:Rewrite_rule_-_Internet_Information_Services_(IIS)_Manager.png|thumb]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Add following rewrite rule to enable support for unicode file names in Moodle and to work around internal file length limitation breaking YUI file serving:&lt;br /&gt;
&lt;br /&gt;
* Matches the Pattern - Regular Expressions - &amp;lt;code&amp;gt;^([^\?]+?\.php)(\/.+)$&amp;lt;/code&amp;gt;&lt;br /&gt;
* Action - Rewrite - &amp;lt;code&amp;gt;{R:1}\?file={R:2}&amp;lt;/code&amp;gt;&lt;br /&gt;
* Append query string - enabled&lt;br /&gt;
* Stop processing of subsequent rules - enabled&lt;br /&gt;
&lt;br /&gt;
===Optional UTF-8 file name fix===&lt;br /&gt;
&lt;br /&gt;
By default IIS is unable to handle unicode characters in files uploaded into Moodle. This may result in not working Javascript on Moodle site (impossible to expand navigation, etc.) or broken CSS styles.&lt;br /&gt;
&lt;br /&gt;
See [http://www.iis.net/learn/application-frameworks/install-and-configure-php-on-iis/configuring-the-fastcgi-extension-for-iis-60#utf8servervars Using UTF-8 Encoding for Server Variables] and [http://support.microsoft.com/kb/2277918/ How to get UTF-8 Encoding support in IIS 7.5 in Windows 7 and Windows Server 2008 R2 with the KB 2277918 hotfix].&lt;br /&gt;
&lt;br /&gt;
Execute:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
reg add HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\w3svc\Parameters /v FastCGIUtf8ServerVariables /t REG_MULTI_SZ /d REQUEST_URI\0PATH_INFO&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CGI timeouts===&lt;br /&gt;
&lt;br /&gt;
By default IIS is configured to stop execution of any PHP script after 5 minutes of activity, this interferes with long running Moodle scripts such as upgrade or cron. The timeout should be increased to at least one hour.&lt;br /&gt;
&lt;br /&gt;
==Directory permissions==&lt;br /&gt;
&lt;br /&gt;
The default IIS account is &#039;&#039;IIS_IUSRS&#039;&#039;, make sure it has appropriate access right to Moodle dirroot (read only) and dataroot (read/write) directories.&lt;br /&gt;
&lt;br /&gt;
==Debugging problems==&lt;br /&gt;
&lt;br /&gt;
By default, IIS uses custom error pages that intentionally hide error details on production sites:&lt;br /&gt;
[[Image:scratch1_77F5DD11.jpg|frame|center|IIS default error message]]&lt;br /&gt;
&lt;br /&gt;
When diagnosing problems in Moodle that&#039;s not very useful, so you can temporarily disable these default error messages in IIS so that you see a specific Moodle error message. To achieve that set the &amp;quot;existingResponse&amp;quot; setting for Custom Error Pages in IIS to “PassThrough” for your Moodle site. The result will be that Moodle displays a more specific message about the error when a problem occurs:&lt;br /&gt;
[[Image:scratch2_243263F6.jpg|frame|center|Useful error message]]&lt;br /&gt;
The generic IIS &amp;quot;404&amp;quot; error message which normally does not reveal any details about the problem will no longer be displayed.&lt;br /&gt;
&lt;br /&gt;
The debugging option in &#039;&#039;Settings&amp;gt;Site administration&amp;gt;Development&amp;gt;Debugging&#039;&#039; should also be enabled so that you see the debug messages.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Installing MSSQL for PHP]]&lt;br /&gt;
* [http://www.iis.net  The Official Microsoft IIS Site]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Internet_Information_Services Wikipedia article on IIS]&lt;br /&gt;
* [http://php.iis.net/ PHP installer for IIS]&lt;br /&gt;
* [http://blogs.iis.net/kehand/archive/2009/08/09/php-and-custom-error-pages.aspx blog post about IIS error messages]&lt;br /&gt;
&lt;br /&gt;
[[ja:IIS]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=File:scratch1_77F5DD11.jpg&amp;diff=117285</id>
		<title>File:scratch1 77F5DD11.jpg</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=File:scratch1_77F5DD11.jpg&amp;diff=117285"/>
		<updated>2015-03-03T13:26:08Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Default IIS 404 error message, without and specific details of the problem.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Default IIS 404 error message, without and specific details of the problem.&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=File:scratch2_243263F6.jpg&amp;diff=117284</id>
		<title>File:scratch2 243263F6.jpg</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=File:scratch2_243263F6.jpg&amp;diff=117284"/>
		<updated>2015-03-03T13:24:39Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Useful Moodle error message&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Useful Moodle error message&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Question_bank&amp;diff=115255</id>
		<title>Talk:Question bank</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Question_bank&amp;diff=115255"/>
		<updated>2014-10-17T09:08:15Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* =Clarify functionality */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Clarify functionality===&lt;br /&gt;
What is the purpose of the &amp;quot;Also show old questions&amp;quot; checkbox on the Question Bank page (/question/edit.php?cmid=...)?&lt;br /&gt;
&lt;br /&gt;
What is an &amp;quot;old question&amp;quot;?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 17:06, 17 October 2014 (WST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/38/en/index.php?title=Talk:Question_bank&amp;diff=115254</id>
		<title>Talk:Question bank</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/38/en/index.php?title=Talk:Question_bank&amp;diff=115254"/>
		<updated>2014-10-17T09:06:52Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: What is &amp;quot;Also show old questions&amp;quot; checkbox?&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;===Clarify functionality==&lt;br /&gt;
What is the purpose of the &amp;quot;Also show old questions&amp;quot; checkbox on the Question Bank page (/question/edit.php?cmid=...)?&lt;br /&gt;
&lt;br /&gt;
What is an &amp;quot;old question&amp;quot;?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 17:06, 17 October 2014 (WST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
</feed>