<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/400/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Libertymoodle</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/400/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Libertymoodle"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/Special:Contributions/Libertymoodle"/>
	<updated>2026-04-17T21:00:43Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Automated_course_backup&amp;diff=145073</id>
		<title>Talk:Automated course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Automated_course_backup&amp;diff=145073"/>
		<updated>2023-10-06T12:43:04Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Explain backup file retention settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Explain backup file retention settings  ==&lt;br /&gt;
&lt;br /&gt;
The following automated backup settings are rather confusing:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;Maximum number of backups kept backup | backup_auto_max_kept&#039;&#039;&lt;br /&gt;
* &#039;&#039;Delete backups older than backup | backup_auto_delete_days&#039;&#039;&lt;br /&gt;
* &#039;&#039;Minimum number of backups kept backup | backup_auto_min_kept&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
Please explain what each of these settings do - and, more importantly, how they should be used together. Give practical examples of what will happen when you use different combinations of these settings.&lt;br /&gt;
&lt;br /&gt;
For example, what happens if you specify these settings?&lt;br /&gt;
* backup_auto_max_kept = 10&lt;br /&gt;
* backup_auto_delete_days = 2&lt;br /&gt;
* backup_auto_min_kept = 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How many .mbz file will actually be retained after the number of days specified in backup_auto_max_kept days (10 in my example above)?&lt;br /&gt;
Will the number of .mbz files specified in backup_auto_min_kept be retained forever? Does that mean that Moodle will always keep the number of backups specified in backup_auto_min_kept in the backup destination?&lt;br /&gt;
&lt;br /&gt;
If you set &amp;quot;Delete backups older than&amp;quot; to NEVER, how does it affect the &amp;quot;Maximum number of backups kept&amp;quot; and &amp;quot;Minimum number of backups kept&amp;quot; settings?&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 12:32, 6 October 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Automated_course_backup&amp;diff=145072</id>
		<title>Talk:Automated course backup</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Automated_course_backup&amp;diff=145072"/>
		<updated>2023-10-06T12:34:08Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Explain backup file retention settings */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Explain backup file retention settings  ==&lt;br /&gt;
&lt;br /&gt;
The following automated backup settings are rather confusing:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;Maximum number of backups kept backup | backup_auto_max_kept&#039;&#039;&lt;br /&gt;
* &#039;&#039;Delete backups older than backup | backup_auto_delete_days&#039;&#039;&lt;br /&gt;
* &#039;&#039;Minimum number of backups kept backup | backup_auto_min_kept&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
Please explain what each of these settings do - and, more importantly, how they should be used together. Give practical examples of what will happen when you use different combinations of these settings.&lt;br /&gt;
&lt;br /&gt;
For example, what happens if you specify these settings?&lt;br /&gt;
* backup_auto_max_kept = 10&lt;br /&gt;
* backup_auto_delete_days = 2&lt;br /&gt;
* backup_auto_min_kept = 1&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
How many .mbz file will actually be retained after the number of days specified in backup_auto_max_kept days (10 in my example above)?&lt;br /&gt;
Will the number of .mbz files specified in backup_auto_min_kept be retained forever? Does that mean that Moodle will always keep the number of backups specified in backup_auto_min_kept in the backup destination?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 12:34, 6 October 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=error/moodle/invaliduser&amp;diff=145070</id>
		<title>error/moodle/invaliduser</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=error/moodle/invaliduser&amp;diff=145070"/>
		<updated>2023-09-28T14:19:03Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This error can occur when Moodle tries to access a user in the Moodle database that does not exist. This can happen when you try to view your student profile in Moodle by manually entering the URL in the address bar of your browser. Example if you type http://yourschool.com/user/profile.php?id=12345 into your browser and the 12345 id does not correspond to the id of your Moodle profile you will get this error.&lt;br /&gt;
&lt;br /&gt;
You should always avoid typing a url directly in the address bar of your browser when you are navigating through your Moodle site. Always use the navigation that is part of Moodle to get around the site.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Error]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:error/moodle/invaliduser]]&lt;br /&gt;
[[fr:error/moodle/invaliduser]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=error/moodle/invaliduser&amp;diff=145069</id>
		<title>error/moodle/invaliduser</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=error/moodle/invaliduser&amp;diff=145069"/>
		<updated>2023-09-28T14:18:09Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This error can occur when Moodle tries to access a user in the Moodle database that does not exist. This can happen when you try to view your student profile in Moodle by manually entering the URL in the address bar of your browser. Example if you type http://yourschool.com/user/profile.php?id=12345 into your browser and the 12345 id does not correspond to the id of your Moodle profile you will get this error.&lt;br /&gt;
&lt;br /&gt;
You should always avoid typing a url directly in the address bar of your browser when you are navigating through your Moodle site. Always use the navigation that is part of Moodle to get around the site.&lt;br /&gt;
[[Category:Error]]&lt;br /&gt;
[[https://docs.moodle.org/es/error/moodle/invaliduser]]&lt;br /&gt;
[[https://docs.moodle.org/fr/error/moodle/invaliduser]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=error/moodle/invaliduser&amp;diff=145068</id>
		<title>error/moodle/invaliduser</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=error/moodle/invaliduser&amp;diff=145068"/>
		<updated>2023-09-28T14:08:56Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Added error description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
[[Category:Error]]&lt;br /&gt;
[[https://docs.moodle.org/es/error/moodle/invaliduser]]&lt;br /&gt;
This error can occur when Moodle tries to access a user in the Moodle database that does not exist. This can happen when you try to view your student profile in Moodle by manually entering the URL in the address bar of your browser. Example if you type &amp;lt;nowiki&amp;gt;http://yourschool.com/user/profile.php?id=12345&amp;lt;/nowiki&amp;gt; into your browser and the 12345 id does not correspond to the id of your Moodle profile you will get this error.&lt;br /&gt;
&lt;br /&gt;
You should always avoid typing a url directly in the address bar of your browser when you are navigating through your Moodle site. Always use the navigation that is part of Moodle to get around the site.&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Report_builder&amp;diff=145017</id>
		<title>Talk:Report builder</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Report_builder&amp;diff=145017"/>
		<updated>2023-06-14T07:23:41Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Report Builder - add custom sql queries explanation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page should explain that the Report Builder does NOT have an interface for creating reports using custom sql queries.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 07:23, 14 June 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Installation_Guide_for_Installing_on_Amazon_EC2&amp;diff=145016</id>
		<title>Talk:Installation Guide for Installing on Amazon EC2</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Installation_Guide_for_Installing_on_Amazon_EC2&amp;diff=145016"/>
		<updated>2023-06-12T13:25:33Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Add Set up MYSQL heading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Set up MYSQL ==&lt;br /&gt;
&lt;br /&gt;
Under &amp;quot;Set up MYSQL&amp;quot; &amp;quot;Make additional security-related changes to mysql&amp;quot;, there is a command to remove anonymous access:&lt;br /&gt;
 &lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user = ;       &lt;br /&gt;
&lt;br /&gt;
This returns a syntax error for me. However:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user = &amp;amp;#39; &amp;amp;#39; ;&lt;br /&gt;
&lt;br /&gt;
I believe those quotes should be there, and think the problem is caused when attempting to type the apostrophy directly into Moodle WYSIWYG editor, which translates into an empty space. If you use the double apostrophy directly in the MySQL commandline editor instead of leaving it blank, then it appears to work. I think this is the correct syntax.&lt;br /&gt;
&lt;br /&gt;
== How to get the Moodle code ==&lt;br /&gt;
&lt;br /&gt;
How do you get the Moodle code into this solution? Do you manually ftp it into /var/www/html/ ?&lt;br /&gt;
&lt;br /&gt;
And what about non-core Moodle plugins? How do you get them uploaded?&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 13:13, 12 June 2023 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Moodledata ==&lt;br /&gt;
&lt;br /&gt;
This article leaves out some critical components:&lt;br /&gt;
&lt;br /&gt;
* Where do you create the Moodledata folder and how do you create it?&lt;br /&gt;
* How do you setup the caching layers for e.g. Redis?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 13:23, 12 June 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Installation_Guide_for_Installing_on_Amazon_EC2&amp;diff=145015</id>
		<title>Talk:Installation Guide for Installing on Amazon EC2</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Installation_Guide_for_Installing_on_Amazon_EC2&amp;diff=145015"/>
		<updated>2023-06-12T13:23:52Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Moodledata */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Under &amp;quot;Set up MYSQL&amp;quot; &amp;quot;Make additional security-related changes to mysql&amp;quot;, there is a command to remove anonymous access:&lt;br /&gt;
 &lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user = ;       &lt;br /&gt;
&lt;br /&gt;
This returns a syntax error for me. However:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user = &amp;amp;#39; &amp;amp;#39; ;&lt;br /&gt;
&lt;br /&gt;
I believe those quotes should be there, and think the problem is caused when attempting to type the apostrophy directly into Moodle WYSIWYG editor, which translates into an empty space. If you use the double apostrophy directly in the MySQL commandline editor instead of leaving it blank, then it appears to work. I think this is the correct syntax.&lt;br /&gt;
&lt;br /&gt;
== How to get the Moodle code ==&lt;br /&gt;
&lt;br /&gt;
How do you get the Moodle code into this solution? Do you manually ftp it into /var/www/html/ ?&lt;br /&gt;
&lt;br /&gt;
And what about non-core Moodle plugins? How do you get them uploaded?&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 13:13, 12 June 2023 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Moodledata ==&lt;br /&gt;
&lt;br /&gt;
This article leaves out some critical components:&lt;br /&gt;
&lt;br /&gt;
* Where do you create the Moodledata folder and how do you create it?&lt;br /&gt;
* How do you setup the caching layers for e.g. Redis?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 13:23, 12 June 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Installation_Guide_for_Installing_on_Amazon_EC2&amp;diff=145014</id>
		<title>Talk:Installation Guide for Installing on Amazon EC2</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Installation_Guide_for_Installing_on_Amazon_EC2&amp;diff=145014"/>
		<updated>2023-06-12T13:14:30Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* How to get the Moodle code  */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Under &amp;quot;Set up MYSQL&amp;quot; &amp;quot;Make additional security-related changes to mysql&amp;quot;, there is a command to remove anonymous access:&lt;br /&gt;
 &lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user = ;       &lt;br /&gt;
&lt;br /&gt;
This returns a syntax error for me. However:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user = &amp;amp;#39; &amp;amp;#39; ;&lt;br /&gt;
&lt;br /&gt;
I believe those quotes should be there, and think the problem is caused when attempting to type the apostrophy directly into Moodle WYSIWYG editor, which translates into an empty space. If you use the double apostrophy directly in the MySQL commandline editor instead of leaving it blank, then it appears to work. I think this is the correct syntax.&lt;br /&gt;
&lt;br /&gt;
== How to get the Moodle code ==&lt;br /&gt;
&lt;br /&gt;
How do you get the Moodle code into this solution? Do you manually ftp it into /var/www/html/ ?&lt;br /&gt;
&lt;br /&gt;
And what about non-core Moodle plugins? How do you get them uploaded?&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 13:13, 12 June 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Installation_Guide_for_Installing_on_Amazon_EC2&amp;diff=145013</id>
		<title>Talk:Installation Guide for Installing on Amazon EC2</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Installation_Guide_for_Installing_on_Amazon_EC2&amp;diff=145013"/>
		<updated>2023-06-12T13:13:27Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* How to get the Moodle code */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Under &amp;quot;Set up MYSQL&amp;quot; &amp;quot;Make additional security-related changes to mysql&amp;quot;, there is a command to remove anonymous access:&lt;br /&gt;
 &lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user = ;       &lt;br /&gt;
&lt;br /&gt;
This returns a syntax error for me. However:&lt;br /&gt;
&lt;br /&gt;
mysql&amp;gt; DELETE FROM mysql.user WHERE user = &amp;amp;#39; &amp;amp;#39; ;&lt;br /&gt;
&lt;br /&gt;
I believe those quotes should be there, and think the problem is caused when attempting to type the apostrophy directly into Moodle WYSIWYG editor, which translates into an empty space. If you use the double apostrophy directly in the MySQL commandline editor instead of leaving it blank, then it appears to work. I think this is the correct syntax.&lt;br /&gt;
&lt;br /&gt;
== How to get the Moodle code ==&lt;br /&gt;
&lt;br /&gt;
How do you get the Moodle code into this solution? Do you manually ftp it into /var/www/html/ ?&lt;br /&gt;
&lt;br /&gt;
And what about non-core Moodle plugins? How do you get them uploaded?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 13:13, 12 June 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Event_monitoring&amp;diff=145006</id>
		<title>Talk:Event monitoring</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Event_monitoring&amp;diff=145006"/>
		<updated>2023-05-10T08:00:11Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Event monitoring - describe performance issues */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Enabling event monitoring==&lt;br /&gt;
&lt;br /&gt;
This section says that &amp;quot;Event monitoring is disabled by default because of performance issues.&amp;quot; Please describe what these performance issues are. And, since enabling Event monitoring can cause performance issues, please explain what these issues are.&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 08:00, 10 May 2023 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Authenticated_user_role&amp;diff=144982</id>
		<title>Authenticated user role</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Authenticated_user_role&amp;diff=144982"/>
		<updated>2023-03-17T09:42:22Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Add See Also section */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Standard roles}}&lt;br /&gt;
When a user logs in, they are automatically assigned the role of authenticated user. A user will have additional roles as well as the authenticated user role according to where they are in Moodle, such as student in a course.&lt;br /&gt;
&lt;br /&gt;
By default, authenticated users have permission to edit their own profile, send messages, blog and do other things outside of courses.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
* Using Moodle [https://moodle.org/mod/forum/discuss.php?d=325032 The difference between &amp;quot;Authenticated User&amp;quot; and &amp;quot;Student&amp;quot; roles]&lt;br /&gt;
&lt;br /&gt;
[[eu:Autentifikatutako_erabiltzailea]]&lt;br /&gt;
[[fr:Utilisateur authentifié]]&lt;br /&gt;
[[ja:認証ユーザ]]&lt;br /&gt;
[[de:Authentifizierter-Nutzer-Rolle]]&lt;br /&gt;
[[es:Rol de usuario autenticado]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=User_profiles&amp;diff=144952</id>
		<title>User profiles</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=User_profiles&amp;diff=144952"/>
		<updated>2023-01-11T13:09:14Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also: add Elearning World link */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Site appearance}}&lt;br /&gt;
==User profiles==&lt;br /&gt;
Every user has a profile page which may be reached from the user menu top right and then clicking Profile. This page contains links to further pages allowing the user to [[Edit profile |edit their profile information]] and preferences, view their forum/blog posts, and check any reports they have access to.&lt;br /&gt;
&lt;br /&gt;
The Privacy and policies section provides links for contacting the Privacy officer, requesting data export and account deletion (new in 3.6), along with a data retention summary page (new in 3.6) (unless disabled by the administrator).&lt;br /&gt;
[[File:36NewProfilePage.png|thumb|center|600px|Example of a user&#039;s Profile page. Click to view full size.]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If mobile access is enabled, a link to download the [[Moodle Mobile app]] is visible on the profile. (See screenshot above.)&lt;br /&gt;
==Viewing others&#039;s profiles==&lt;br /&gt;
Users with permission to view the profiles of other users can view them by clicking on their name. If they click on the name of a user within a course, the course profile will be displayed and the full profile may be viewed (if allowed) by clicking the link &amp;quot;Full profile&amp;quot; in the Miscellaneous section:&lt;br /&gt;
&lt;br /&gt;
[[File:fullprofilelink.png]]&lt;br /&gt;
&lt;br /&gt;
Note: All users are allowed to view the full profile of users listed as course contacts in the course description.&lt;br /&gt;
&lt;br /&gt;
See [[View profile]] for more information on how the profile information is displayed and [[Edit profile]] for information on updating profiles.&lt;br /&gt;
==Site administration settings==&lt;br /&gt;
===Site policies===&lt;br /&gt;
An administrator can force users to login for profiles and select which roles are visible in user profiles (by default teacher, non-editing teacher and student) in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Security &amp;gt; Site policies&#039;&#039;.&lt;br /&gt;
===Default profile page===&lt;br /&gt;
An administrator or manager (or any other user with the capability [[Capabilities/moodle/user:managesyspages|moodle/user:managesyspages]]) can add additional blocks onto the default profile page for all users from &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Appearance &amp;gt; Default profile page&#039;&#039;. Blocks can be added to the left, right or middle of the page.&lt;br /&gt;
&lt;br /&gt;
Note that this does NOT allow you to remove the following blocks, or to change the layout/order of these blocks:&lt;br /&gt;
* User details&lt;br /&gt;
* Privacy and policies&lt;br /&gt;
* Course Details&lt;br /&gt;
* Miscellaneous&lt;br /&gt;
* Reports&lt;br /&gt;
* Login activity&lt;br /&gt;
* Mobile app (only displays if &#039;&#039;[[Mobile_web_services]]&#039;&#039; are configured)&lt;br /&gt;
These are all ‘fake’ blocks and cannot be removed through the normal blocks administration interface.&lt;br /&gt;
&lt;br /&gt;
Clicking the button &#039;Reset profile for all users&#039; will then apply these settings to the profile pages of everyone on the site.&lt;br /&gt;
==Preventing users from customizing their profile page==&lt;br /&gt;
By default, users can customize their public profile page and add blocks. To prevent this&lt;br /&gt;
# Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;&lt;br /&gt;
# Edit the authenticated user role and untick the capability [[Capabilities/moodle/user:manageownblocks|moodle/user:manageownblocks]]&lt;br /&gt;
==User profile capabilities==&lt;br /&gt;
System:&lt;br /&gt;
*[[Capabilities/moodle/user:editownprofile|Edit own user profile]]&lt;br /&gt;
*[[Capabilities/moodle/user:manageownblocks|Manage blocks on own public user profile]]&lt;br /&gt;
*[[Capabilities/moodle/user:managesyspages|Configure default page layout for public user profiles]]&lt;br /&gt;
*[[Capabilities/moodle/user:update|Update user profiles]]&lt;br /&gt;
Users:&lt;br /&gt;
*[[Capabilities/moodle/user:editprofile|Edit user profile]]&lt;br /&gt;
*[[Capabilities/moodle/user:manageblocks|Manage blocks on user profile of other users]]&lt;br /&gt;
*[[Capabilities/moodle/user:viewalldetails|View user full information]]&lt;br /&gt;
Course:&lt;br /&gt;
*[[Capabilities/moodle/user:viewdetails|View user profiles]]&lt;br /&gt;
==See also==&lt;br /&gt;
*[[View profile]]&lt;br /&gt;
*[[Activity report]]&lt;br /&gt;
*[[User profile fields]]&lt;br /&gt;
*[[Site policies]]&lt;br /&gt;
*[[Update profile]]&lt;br /&gt;
*[https://www.elearningworld.org/moodle-lms-show-hide-profile-sections-and-fields/ Show/Hide Profile Sections and Fields - ElearningWorld.org]&lt;br /&gt;
[[de:Nutzerprofil]]&lt;br /&gt;
[[es:Perfiles de usuario]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:RedHat_Linux_installation&amp;diff=144900</id>
		<title>Talk:RedHat Linux installation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:RedHat_Linux_installation&amp;diff=144900"/>
		<updated>2022-11-22T07:02:37Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Download */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a great article, but please add a full explanation and description for using Redis for the session and/or file caching layers.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 10:09, 22 November 2021 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup Moodle ==&lt;br /&gt;
=== Download ===&lt;br /&gt;
This Download section starts with this instruction:&lt;br /&gt;
&lt;br /&gt;
* Download your favourite version of Moodle from moodle.org (.zip archive is easiest)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But where do you download it to? Please specify.&amp;lt;br /&amp;gt;&lt;br /&gt;
Or does RedHat automatically download files to a specific default directory? If so, what&#039;s that directory?&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you run the &amp;quot;cp moodle_111.zip /usr/moodle&amp;quot; command, where does RedHat know where to find the &amp;quot;moodle_111.zip&amp;quot; file that is mentioned in the command?&amp;lt;br /&amp;gt;&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 06:38, 22 November 2022 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:RedHat_Linux_installation&amp;diff=144899</id>
		<title>Talk:RedHat Linux installation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:RedHat_Linux_installation&amp;diff=144899"/>
		<updated>2022-11-22T06:46:37Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* RedHat Linux installation - Download */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a great article, but please add a full explanation and description for using Redis for the session and/or file caching layers.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 10:09, 22 November 2021 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup Moodle ==&lt;br /&gt;
=== Download ===&lt;br /&gt;
This Download section starts with this instruction:&lt;br /&gt;
&lt;br /&gt;
* Download your favourite version of Moodle from moodle.org (.zip archive is easiest)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But where do you download it to? Please specify.&amp;lt;br /&amp;gt;&lt;br /&gt;
Does RedHat automatically download files to a specific default directory? If so, what&#039;s that directory?&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When you run the &amp;quot;cp moodle_111.zip /usr/moodle&amp;quot; command, where does RedHat know where to find the &amp;quot;moodle_111.zip&amp;quot; file that is mentioned in the command?&amp;lt;br /&amp;gt;&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 06:38, 22 November 2022 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:RedHat_Linux_installation&amp;diff=144898</id>
		<title>Talk:RedHat Linux installation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:RedHat_Linux_installation&amp;diff=144898"/>
		<updated>2022-11-22T06:39:13Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* RedHat Linux installation - clarify the Setup Moodle Download section */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a great article, but please add a full explanation and description for using Redis for the session and/or file caching layers.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 10:09, 22 November 2021 (UTC)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Setup Moodle ==&lt;br /&gt;
=== Download ===&lt;br /&gt;
This Download section starts with this instruction:&lt;br /&gt;
&lt;br /&gt;
* Download your favourite version of Moodle from moodle.org (.zip archive is easiest)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But where do you download it to? Please specify.&amp;lt;br /&amp;gt;&lt;br /&gt;
Does RedHat automatically download files to a specific default directory? If so, what&#039;s that directory?&amp;lt;br /&amp;gt;&lt;br /&gt;
When you run the &amp;quot;cp moodle_111.zip /usr/moodle&amp;quot; command, where does RedHat know where to find the &amp;quot;moodle_111.zip&amp;quot; file that is mentioned in the command?&amp;lt;br /&amp;gt;&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 06:38, 22 November 2022 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=144748</id>
		<title>Security report on default user role</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=144748"/>
		<updated>2022-10-26T06:02:45Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Default user role is incorrectly defined TYPO */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security overview report}}&lt;br /&gt;
==Default role for all users==&lt;br /&gt;
In general the default role for all users should be set to authenticated user. Normally all permissions for the role of authenticated user should be left as default. &lt;br /&gt;
==Default user role is incorrectly defined==&lt;br /&gt;
If the security overview report shows the default role for all users with status &#039;Critical&#039; and states that &#039;The default user role &amp;quot;Authenticated user&amp;quot; is incorrectly defined!&#039; it means that one or more risky capabilities are allowed for the role.&lt;br /&gt;
&lt;br /&gt;
This could also refer to a bug in Moodle. Check the &#039;&#039;tool/dataprivacy:requestdeleteforotheruser&#039;&#039; capablity in the Authenticated User role. This setting now defaults to &amp;quot;Not Set&amp;quot;. If the Authenticated User role on your site has this capability set to the default &amp;quot;Not Set&amp;quot; and you have not changed any of the other permissions on this role then no further action is required. See the MDL-67852: &#039;&#039;&#039;Security overview report shows critical warning for &amp;quot;Default role for all users&amp;quot; with default requestdelete config&#039;&#039;&#039; Tracker issue and the following Using Moodle Forum discussions:&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=387143 Security overview]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=403379 Security checks and Default role for all users]&lt;br /&gt;
==Reviewing authenticated user role permissions==&lt;br /&gt;
The permissions for the role of authenticated user can be reviewed as follows:&lt;br /&gt;
# Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;&lt;br /&gt;
# In the role column, click the link &#039;Authenticated user&#039;&lt;br /&gt;
# Browse the permissions column&lt;br /&gt;
If there is no reason for changing permissions from default, then the role can be reset by clicking the Reset button at the top of the page.&lt;br /&gt;
&lt;br /&gt;
[[File:ResetRoleButton.jpg]]&lt;br /&gt;
&lt;br /&gt;
After resetting the authenticated user role, the security overview report will show the default role for all users with status OK.&lt;br /&gt;
==See also==&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=7301 Security and Privacy forum]&lt;br /&gt;
* Using Moodle [https://moodle.org/mod/forum/discuss.php?d=387143 Security overview] discussion&lt;br /&gt;
[[es:Reporte de seguridad sobre rol del usuario por defecto]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=144745</id>
		<title>Security report on default user role</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=144745"/>
		<updated>2022-10-24T11:25:07Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Default user role is incorrectly defined - clarify actions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security overview report}}&lt;br /&gt;
==Default role for all users==&lt;br /&gt;
In general the default role for all users should be set to authenticated user. Normally all permissions for the role of authenticated user should be left as default. &lt;br /&gt;
==Default user role is incorrectly defined==&lt;br /&gt;
If the security overview report shows the default role for all users with status &#039;Critical&#039; and states that &#039;The default user role &amp;quot;Authenticated user&amp;quot; is incorrectly defined!&#039; it means that one or more risky capabilities are allowed for the role.&lt;br /&gt;
&lt;br /&gt;
This could also refer to a bug in Moodle. Check the &#039;&#039;tool/dataprivacy:requestdeleteforotheruser&#039;&#039; capablity in the Authenticated User role. This setting now defaults to &amp;quot;Not Set&amp;quot;. If the Authenticated User role on your site has this capability set to the default &amp;quot;Not Set&amp;quot; and you have not changed any of the other permissions on this role then no further action is required. See the MDL-67852: &#039;&#039;&#039;Security overview report shows critical warning for &amp;quot;Default role for all users&amp;quot; with default requestdelete config&#039;&#039;&#039; Tracker issue and the following Using Moodle Forum discussions:&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=387143 &amp;lt;nowiki&amp;gt;Security overview]&amp;lt;/nowiki&amp;gt;]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=403379 Security checks and Default role for all users]&lt;br /&gt;
==Reviewing authenticated user role permissions==&lt;br /&gt;
The permissions for the role of authenticated user can be reviewed as follows:&lt;br /&gt;
# Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;&lt;br /&gt;
# In the role column, click the link &#039;Authenticated user&#039;&lt;br /&gt;
# Browse the permissions column&lt;br /&gt;
If there is no reason for changing permissions from default, then the role can be reset by clicking the Reset button at the top of the page.&lt;br /&gt;
&lt;br /&gt;
[[File:ResetRoleButton.jpg]]&lt;br /&gt;
&lt;br /&gt;
After resetting the authenticated user role, the security overview report will show the default role for all users with status OK.&lt;br /&gt;
==See also==&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=7301 Security and Privacy forum]&lt;br /&gt;
* Using Moodle [https://moodle.org/mod/forum/discuss.php?d=387143 Security overview] discussion&lt;br /&gt;
[[es:Reporte de seguridad sobre rol del usuario por defecto]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=144744</id>
		<title>Security report on default user role</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=144744"/>
		<updated>2022-10-24T11:17:46Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Default user role is incorrectly defined - add Tracker issue and forum links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security overview report}}&lt;br /&gt;
==Default role for all users==&lt;br /&gt;
In general the default role for all users should be set to authenticated user. Normally all permissions for the role of authenticated user should be left as default. &lt;br /&gt;
==Default user role is incorrectly defined==&lt;br /&gt;
If the security overview report shows the default role for all users with status &#039;Critical&#039; and states that &#039;The default user role &amp;quot;Authenticated user&amp;quot; is incorrectly defined!&#039; it means that one or more risky capabilities are allowed for the role.&lt;br /&gt;
&lt;br /&gt;
This could also refer to a bug in Moodle. Check the &#039;&#039;tool/dataprivacy:requestdeleteforotheruser&#039;&#039; capablity in the Authenticated User role. This setting now defaults to &amp;quot;Not Set&amp;quot;. If the Authenticated User role on your site has this capability set to the default &amp;quot;Not Set&amp;quot; then no further action is required. See the MDL-67852: &#039;&#039;&#039;Security overview report shows critical warning for &amp;quot;Default role for all users&amp;quot; with default requestdelete config&#039;&#039;&#039; Tracker issue and the following Using Moodle Forum discussions:&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=387143 &amp;lt;nowiki&amp;gt;Security overview]&amp;lt;/nowiki&amp;gt;]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=403379 Security checks and Default role for all users]&lt;br /&gt;
==Reviewing authenticated user role permissions==&lt;br /&gt;
The permissions for the role of authenticated user can be reviewed as follows:&lt;br /&gt;
# Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;&lt;br /&gt;
# In the role column, click the link &#039;Authenticated user&#039;&lt;br /&gt;
# Browse the permissions column&lt;br /&gt;
If there is no reason for changing permissions from default, then the role can be reset by clicking the Reset button at the top of the page.&lt;br /&gt;
&lt;br /&gt;
[[File:ResetRoleButton.jpg]]&lt;br /&gt;
&lt;br /&gt;
After resetting the authenticated user role, the security overview report will show the default role for all users with status OK.&lt;br /&gt;
==See also==&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=7301 Security and Privacy forum]&lt;br /&gt;
* Using Moodle [https://moodle.org/mod/forum/discuss.php?d=387143 Security overview] discussion&lt;br /&gt;
[[es:Reporte de seguridad sobre rol del usuario por defecto]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=144743</id>
		<title>Security report on default user role</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=144743"/>
		<updated>2022-10-24T11:15:19Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Default user role is incorrectly defined - add Tracker issue and forum links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security overview report}}&lt;br /&gt;
==Default role for all users==&lt;br /&gt;
In general the default role for all users should be set to authenticated user. Normally all permissions for the role of authenticated user should be left as default. &lt;br /&gt;
==Default user role is incorrectly defined==&lt;br /&gt;
If the security overview report shows the default role for all users with status &#039;Critical&#039; and states that &#039;The default user role &amp;quot;Authenticated user&amp;quot; is incorrectly defined!&#039; it means that one or more risky capabilities are allowed for the role.&lt;br /&gt;
&lt;br /&gt;
This could also refer to a bug in Moodle. Check the &#039;&#039;tool/dataprivacy:requestdeleteforotheruser&#039;&#039; capablity in the Authenticated User role. This setting now defaults to &amp;quot;Not Set&amp;quot;. If the Authenticated User role on your site has this capability set to the default &amp;quot;Not Set&amp;quot; then no further action is required. See the &#039;&#039;&#039;MDL-67852: Security overview report shows critical warning for &amp;quot;Default role for all users&amp;quot; with default requestdelete config&#039;&#039;&#039; Tracker issue and the following Using Moodle Forum discussions:&lt;br /&gt;
&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=387143 &amp;lt;nowiki&amp;gt;Security overview]&amp;lt;/nowiki&amp;gt;]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=403379 Security checks and Default role for all users]&lt;br /&gt;
&lt;br /&gt;
==Reviewing authenticated user role permissions==&lt;br /&gt;
The permissions for the role of authenticated user can be reviewed as follows:&lt;br /&gt;
# Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;&lt;br /&gt;
# In the role column, click the link &#039;Authenticated user&#039;&lt;br /&gt;
# Browse the permissions column&lt;br /&gt;
If there is no reason for changing permissions from default, then the role can be reset by clicking the Reset button at the top of the page.&lt;br /&gt;
&lt;br /&gt;
[[File:ResetRoleButton.jpg]]&lt;br /&gt;
&lt;br /&gt;
After resetting the authenticated user role, the security overview report will show the default role for all users with status OK.&lt;br /&gt;
==See also==&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=7301 Security and Privacy forum]&lt;br /&gt;
* Using Moodle [https://moodle.org/mod/forum/discuss.php?d=387143 Security overview] discussion&lt;br /&gt;
[[es:Reporte de seguridad sobre rol del usuario por defecto]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Caching&amp;diff=144179</id>
		<title>Caching</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Caching&amp;diff=144179"/>
		<updated>2022-09-09T13:02:34Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* More information - More Info section link */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Performance}}&lt;br /&gt;
A cache is a collection of processed data that is kept on hand and re-used to avoid costly repeated database queries.&lt;br /&gt;
&lt;br /&gt;
Moodle 2.4 saw the implementation of MUC, the Moodle Universal Cache. This new system allows certain functions of Moodle (e.g. string fetching) to take advantage of different installed cache services (e.g. files, ram, memcached).&lt;br /&gt;
&lt;br /&gt;
In future versions of Moodle, we will continue expanding the number of Moodle functions that use MUC, which will continue improving performance, but you can already start using it to improve your site.&lt;br /&gt;
&lt;br /&gt;
==General approach to performance testing==&lt;br /&gt;
&lt;br /&gt;
Here is the general strategy you should be taking:&lt;br /&gt;
&lt;br /&gt;
# Build a test environment that is as close to your real production instance as possible (e.g. hardware, software, networking, etc.)&lt;br /&gt;
# Make sure to remove as many uncontrolled variables as you can from this environment (e.g. other services)&lt;br /&gt;
# Use a tool to place a realistic but simulated and repeatable load upon your server. (e.g. jmeter or selenium).&lt;br /&gt;
# Decide on a way to measure the performance of the server by capturing data (ram, load, time taken, etc.)&lt;br /&gt;
# Run your load and measure a baseline performance result.&lt;br /&gt;
# Change one variable at a time and re-run the load to see if performance gets better or worse.  Repeat as necessary.&lt;br /&gt;
# When you discover settings that result in consistent performance improvement, apply to your production site.&lt;br /&gt;
&lt;br /&gt;
==Cache configuration in Moodle==&lt;br /&gt;
&lt;br /&gt;
Since Moodle 2.4, Moodle has provided a caching plugin framework to give administrators the ability to control where Moodle stores cached data. For most Moodle sites, the default configuration should be sufficient, and it is not necessary to change the configuration. For larger Moodle sites with multiple servers, administrators may wish to use memcached, mongodb or other systems to store cache data. The cache plugin screen provides administrators with the ability to configure what cache data is stored where.&amp;lt;br /&amp;gt;&lt;br /&gt;
Caching in Moodle is controlled by what is known as the Moodle Universal Cache. Commonly referred to as MUC.&lt;br /&gt;
&lt;br /&gt;
This document explains briefly what MUC is before proceeding into detail about the concepts and configuration options it offers.&lt;br /&gt;
&lt;br /&gt;
==The basic cache concepts in Moodle==&lt;br /&gt;
Caching in Moodle isn&#039;t as complex as it first appears. A little background knowledge will go a long way in understanding how cache configuration works.&lt;br /&gt;
&lt;br /&gt;
===Cache types===&lt;br /&gt;
Let&#039;s start with cache types (sometimes referred to as mode). There are three basic types of caches in Moodle.&lt;br /&gt;
&lt;br /&gt;
The first is the application cache. This is by far the most commonly used cache type in code. All users share its information, and its data persists between requests. Information stored here is usually cached for one of two reasons, either it is required information for the majority of requests and saves us one or more database interactions, or it is information that is accessed less frequently but is resource intensive to generate.&amp;lt;br /&amp;gt;&lt;br /&gt;
By default, this information is stored in an organised structure within your Moodle data directory.&lt;br /&gt;
&lt;br /&gt;
The second cache type is the session cache. This is just like the PHP session that you will already be familiar with; it uses the PHP session by default. You may be wondering why we have this cache type at all, but the answer is simple. MUC provides a managed means of storing and removing information that is required between requests. It offers developers a framework to use rather than having to re-invent the wheel and ensures that we have access to a controlled means of managing the cache as required.&amp;lt;br /&amp;gt;&lt;br /&gt;
It is important to note that this isn&#039;t a frequently used cache type as, by default, session cache data is stored in the PHP session, and the PHP session is stored in the database. Uses of the session cache type are limited to small datasets as we don&#039;t want to bloat sessions and thus put a strain on the database.&lt;br /&gt;
&lt;br /&gt;
The third and final type is the request cache. Data stored in this cache type only persists for the lifetime of the request. If you&#039;re a PHP developer, think of it like a managed static variable.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is by far the least used of the three cache types. Uses are often limited to information that will be accessed several times within the same request, usually by more than an area of code.&lt;br /&gt;
Cached information is stored in memory by default.&lt;br /&gt;
&lt;br /&gt;
==== Cache types and multiple-server systems ====&lt;br /&gt;
&lt;br /&gt;
If you have a system with multiple front-end web servers, the application cache must be shared between the servers. In other words, you cannot use fast local storage for the application cache but must use shared storage or some other form of shared cache such as a shared memcached.&lt;br /&gt;
&lt;br /&gt;
The same applies to session cache unless you use a &#039;sticky sessions&#039; mechanism to ensure that users always access the same front-end server within a session.&lt;br /&gt;
&lt;br /&gt;
===Cache backends===&lt;br /&gt;
Cache backends are where data actually gets stored. These include things like the file system, PHP session, Memcached, and memory.&amp;lt;br /&amp;gt;&lt;br /&gt;
By default, just file system, PHP session, and memory are used within Moodle.&amp;lt;br /&amp;gt;&lt;br /&gt;
We don&#039;t require that a site has access to any other systems such a Memcached. Instead, that is something you are responsible for installing and configuring yourself.&amp;lt;br /&amp;gt;&lt;br /&gt;
When cache backends are mentioned, think of systems outside of Moodle that can store data. The MongoDB server, the Memcached server and similar &amp;quot;server&amp;quot; applications.&lt;br /&gt;
&lt;br /&gt;
===Cache stores===&lt;br /&gt;
&lt;br /&gt;
Cache stores are a plugin type within Moodle. They facilitate connecting Moodle to the cache backends discussed above. The standard Moodle has the three defaults mentioned above as well as Memcached, MongoDB, [[APC user cache (APCu)]] and [[Redis cache store|Redis]].&lt;br /&gt;
&lt;br /&gt;
You can find other cache store plugins in the [https://moodle.org/plugins/browse.php?list=category&amp;amp;id=48 plugins database].&lt;br /&gt;
&lt;br /&gt;
The code for these is located within cache/stores in your Moodle directory root.&lt;br /&gt;
&lt;br /&gt;
Within Moodle, you can configure as many cache stores as your architecture requires. If you have several Memcached servers, for instance, you can create a cache store instance for each. By default, Moodle contains three cache store instances that get used when you&#039;ve made no other configuration.&lt;br /&gt;
* A file store instance is created, which gets used for all application caches. It stores its data in your moodledata directory.&lt;br /&gt;
* A session store instance is created, which gets used for all session caches. It stores its data in the PHP session, which, by default, is stored in your database.&lt;br /&gt;
* A static memory store instance is created, which gets used for all request cache types. Data exists in memory for just the lifetime of a request.&lt;br /&gt;
&lt;br /&gt;
===Caches: what happens in code===&lt;br /&gt;
Caches are created in code and are used by the developer to store data they see a need to cache.&amp;lt;br /&amp;gt;&lt;br /&gt;
Let&#039;s keep this section nice and short because perhaps you are not a developer. There is one very important point you must know about.&amp;lt;br /&amp;gt;&lt;br /&gt;
The developer does not get any say in where the data gets cached. They must specify the following information when creating a cache to use.&lt;br /&gt;
# The type of cache they require.&lt;br /&gt;
# The area of code this cache will belong to (the API, if you will).&lt;br /&gt;
# The cache&#039;s name, something they make up to describe in one word what the cache stores.&lt;br /&gt;
&lt;br /&gt;
There are several optional requirements and settings they can specify as well, but don&#039;t worry about that at this point.&amp;lt;br /&amp;gt;&lt;br /&gt;
The important point is that they can&#039;t choose which cache backend to use; they can only choose the type of cache they want from the three detailed above.&lt;br /&gt;
&lt;br /&gt;
===How it ties together===&lt;br /&gt;
&lt;br /&gt;
This is best described in relation to roles played in an organisation.&lt;br /&gt;
&lt;br /&gt;
# The system administrator installs the cache backends you wish to use. Memcached, XCache, APC and so on.&amp;lt;br /&amp;gt;Moodle doesn&#039;t know about these; they are outside of Moodle&#039;s scope and purely the responsibility of your system administrator.&lt;br /&gt;
# The Moodle administrator creates a cache store instance in Moodle for each backend the site will make use of.&amp;lt;br /&amp;gt;There can be one or more cache store instances for each backend. Some backends like Memcached have settings to create separated spaces within one backend.&lt;br /&gt;
# The developer has created caches in code and is using them to store data.&amp;lt;br /&amp;gt;He doesn&#039;t know anything about how you will use your caches; he just creates a &amp;quot;cache&amp;quot; and tells Moodle what type it is best for.&lt;br /&gt;
# The Moodle administrator creates a mapping between a cache store instance and a cache.&amp;lt;br /&amp;gt;That mapping tells Moodle to use the backend you specify to store the data the developer wants cached.&lt;br /&gt;
&lt;br /&gt;
In addition to that, you can take things further still.&lt;br /&gt;
* You can map many caches to a single cache store instance.&lt;br /&gt;
* You can map multiple cache store instances to a single cache with priority (primary ... final)&lt;br /&gt;
* You can map a cache store instance to be the default store used for all caches of a specific type that don&#039;t otherwise have specific mappings.&lt;br /&gt;
&lt;br /&gt;
If this is the first time you are reading about the Moodle Universal Cache, this probably sounds pretty complex but don&#039;t worry; it will be discussed in better detail as we work through how to configure the caching in Moodle.&lt;br /&gt;
&lt;br /&gt;
==Advanced concepts==&lt;br /&gt;
These concepts are things that most sites will not need to know or concern themselves about.&lt;br /&gt;
&lt;br /&gt;
You should only start looking here if you are looking to maximise performance on large sites running over clustered services with shared cache backends or on multi-site architecture again where information is being shared between sites.&lt;br /&gt;
&lt;br /&gt;
===Locking===&lt;br /&gt;
&lt;br /&gt;
The idea of locking is nothing new; it is the process of controlling access to avoid concurrency issues.&lt;br /&gt;
&lt;br /&gt;
MUC has a second type of plugin; a cache lock plugin used when caches require it. To date, no caches have required it. A cache by nature is volatile, and any information that is absolutely mission-critical should be a more permanent data store, likely the database.&lt;br /&gt;
&lt;br /&gt;
Nonetheless, there is a locking system that cache definitions can require within their options, and that will be applied when interacting with a cache store instance.&lt;br /&gt;
&lt;br /&gt;
===Sharing===&lt;br /&gt;
&lt;br /&gt;
Every bit of data that gets stored within a cache has a calculated unique key associated with it.&amp;lt;br /&amp;gt;&lt;br /&gt;
By default, part of that key is the site identifier making any content stored in the cache specific to the site that stored it. For most sites, this is exactly what you want.&amp;lt;br /&amp;gt;&lt;br /&gt;
However, it&#039;s beneficial to allow multiple sites or somehow linked sites to share cached data in some situations.&amp;lt;br /&amp;gt;&lt;br /&gt;
Of course, not all caches can be shared, however some certainly can and by sharing, you can further reduce load and increase performance by maximising resource use.&lt;br /&gt;
&lt;br /&gt;
This is an advanced feature; if you choose to configure sharing, please do so carefully.&lt;br /&gt;
&lt;br /&gt;
To make use of sharing, you need to first configure identical cache store instances in the sites you want to share information, and then on each site, set the sharing for the cache to the same value.&lt;br /&gt;
&lt;br /&gt;
; Sites with the same site ID: This is the default, it allows for sites with the same site ID to share cached information. It is the most restrictive but is going to work for all caches. All other options carry an element of risk in that you have to ensure the cache&#039;s information is applicable to all sites that will be accessing it.&lt;br /&gt;
; Sites running the same version: All sites accessing the backend that have the same Moodle version can share the information this cache has stored in the cache store.&lt;br /&gt;
; Custom key: For this, you manually enter a key to use for sharing. You must then enter the exact same key into the other sites you want to share information.&lt;br /&gt;
; Everyone: The cached data is accessible to all other sites accessing the data. This option puts the ball entirely in the Moodle administrators court.&lt;br /&gt;
&lt;br /&gt;
For example, if you had several Moodle sites all the same version running on a server with APC installed you could decide to map the language cache to the APC store and configure sharing for all sites running the same version.&amp;lt;br /&amp;gt;&lt;br /&gt;
The language cache for sites on the same version is safe to share in many situations, it is used on practically every page, and APC is extremely fast. These three points may result in a nice wee performance boost for your sites.&amp;lt;br /&amp;gt;&lt;br /&gt;
It is important to consider with the language cache that by sharing it between sites any language customisations will also be shared.&lt;br /&gt;
&lt;br /&gt;
==The cache configuration screen==&lt;br /&gt;
&lt;br /&gt;
The cache configuration screen is your one stop shop for configuring caching in Moodle.&amp;lt;br /&amp;gt;&lt;br /&gt;
It gives you an overview of how caching is currently configured for your site and it provides links to all of the actions you can perform to configure caching to your specific needs.&lt;br /&gt;
&lt;br /&gt;
===Accessing the cache configuration screen===&lt;br /&gt;
&lt;br /&gt;
[[Image:cacheadmin29.png|thumb|200px|The cache configuration screen]]&lt;br /&gt;
&lt;br /&gt;
The cache configuration screen can only be accessed by users with the &#039;&#039;moodle/site:config&#039;&#039; capability. By default this is only admins.&amp;lt;br /&amp;gt;&lt;br /&gt;
Once logged in the configuration screen can be found in  &#039;&#039;&#039;Site Administration &amp;gt; Plugins &amp;gt; Caching &amp;gt; Configuration&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===Installed cache stores===&lt;br /&gt;
&lt;br /&gt;
[[Image:ist29.png|thumb|500px|Installed cache stores screenshot]]&lt;br /&gt;
&lt;br /&gt;
This is showing you a list of cache store plugins that you have installed.&amp;lt;br /&amp;gt;&lt;br /&gt;
For each plugin you can quickly see whether it is ready to be used (any PHP requirements have been met), how many store instances already exist on this site, the cache types that this store can be used for, what features it supports (advanced) and any actions you can perform relating to this store.&lt;br /&gt;
&lt;br /&gt;
Often the only action available is to create a new store instance.&amp;lt;br /&amp;gt;&lt;br /&gt;
Most stores support having multiple instances, however not all as you will see that that the session cache and static request cache do not. For those two stores, it does not make sense to have multiple instances.&lt;br /&gt;
&lt;br /&gt;
===Configured store instances===&lt;br /&gt;
&lt;br /&gt;
[[Image:csi29.png|thumb|500px|Configured store instances screenshot]]&lt;br /&gt;
&lt;br /&gt;
Here you get a list of the cache store instances on this site.&lt;br /&gt;
&lt;br /&gt;
; &#039;&#039;&#039;Store name&#039;&#039;&#039;: The name given to this cache store instance when it is created so that you can recognise it. It can be anything you want and is only used so that you can identify the store instance.&lt;br /&gt;
; &#039;&#039;&#039;Plugin&#039;&#039;&#039;: The cache store plugin of which this is an instance of.&lt;br /&gt;
; &#039;&#039;&#039;Ready &#039;&#039;&#039;: A tick gets shown when all PHP requirements have been met as well as any connection or set-up requirements have been verified.&lt;br /&gt;
; &#039;&#039;&#039;Store mappings&#039;&#039;&#039;: The number of caches this store instance has been mapped to explicitly. Does not include any uses through default mappings (discussed below).&lt;br /&gt;
; &#039;&#039;&#039;Modes&#039;&#039;&#039;: The modes that this cache store instance can serve.&lt;br /&gt;
; &#039;&#039;&#039;Supports&#039;&#039;&#039;: The features supported by this cache store instance.&lt;br /&gt;
; &#039;&#039;&#039;Locking &#039;&#039;&#039;: Locking is a mechanism that restricts access to cached data to one process at a time to prevent the data from being overwritten. The locking method determines how the lock is acquired and checked.&lt;br /&gt;
; &#039;&#039;&#039;Actions&#039;&#039;&#039;: Any actions that can be performed against this cache store instance.&lt;br /&gt;
&lt;br /&gt;
===Known cache definitions===&lt;br /&gt;
&lt;br /&gt;
[[Image:caching-27-04-known-cache-definitions.png|thumb|500px|Known cache definitions screenshot]]&lt;br /&gt;
&lt;br /&gt;
The idea of a cache definition hasn&#039;t been discussed here yet. It is something controlled by the developer. When they create a cache they can do so in two ways, the first is by creating a cache definition. This is essentially telling Moodle about the cache they&#039;ve created. The second way is to create an Ad hoc cache. Developers are always encouraged to use the first method. Only caches with a definition can be mapped and further configured by the admin. Ad hoc caches will make use of default settings only.&amp;lt;br /&amp;gt;&lt;br /&gt;
Typically Ad hoc caches are only permitted in situations where the cache is small and configuring it beyond defaults would provide no benefit to administrators. Really it&#039;s like saying you the administrator doesn&#039;t need to concern yourself with it.&lt;br /&gt;
&lt;br /&gt;
For each cache shown here you get the following information:&lt;br /&gt;
&lt;br /&gt;
; &#039;&#039;&#039;Definition&#039;&#039;&#039; : A concise description of this cache.&lt;br /&gt;
; &#039;&#039;&#039;Mode&#039;&#039;&#039;: The cache type this cache is designed for.&lt;br /&gt;
; &#039;&#039;&#039;Component &#039;&#039;&#039;: The code component the cache is associated with.&lt;br /&gt;
; &#039;&#039;&#039;Area&#039;&#039;&#039;: The area of code this cache is serving within the component.&lt;br /&gt;
; &#039;&#039;&#039;Store mappings&#039;&#039;&#039;: The store or stores that will be used for this cache.&lt;br /&gt;
; &#039;&#039;&#039;Sharing&#039;&#039;&#039;: How is sharing configured for this site.&lt;br /&gt;
; &#039;&#039;&#039;Actions&#039;&#039;&#039;: Any actions that can be performed on the cache. Typically you can edit the cache store instance mappings, edit sharing, and purge the cache.&lt;br /&gt;
&lt;br /&gt;
You&#039;ll also find at the bottom of this table a link title &amp;quot;Rescan definitions&amp;quot;. Clicking this link will cause Moodle to go off an check all core components, and installed plugins looking for changes in the cache definitions.&amp;lt;br /&amp;gt;&lt;br /&gt;
This happens by default during an upgrade, and if a new cache definition is encountered. However, should you find yourself looking for a cache that isn&#039;t there this may be worth a try.&amp;lt;br /&amp;gt;&lt;br /&gt;
It is also handy for developers as it allows them to quickly apply changes when working with caches. It is useful when tweaking cache definitions to find what works best.&lt;br /&gt;
&lt;br /&gt;
Information on specific cache definitions can be found on the [[Cache definitions]] page.&lt;br /&gt;
&lt;br /&gt;
===Summary of cache lock instances===&lt;br /&gt;
&lt;br /&gt;
[[Image:caching-27-05-summary-of-cache-lock-instances.png|thumb|500px|Summary of cache lock instances screenshot]]&lt;br /&gt;
&lt;br /&gt;
As mentioned above cache locking is an advanced concept in MUC.&amp;lt;br /&amp;gt;&lt;br /&gt;
The table here shows information on the configured locking mechanisms available to MUC. By default, just a single locking mechanism is available, file locking.&lt;br /&gt;
At present, there are no caches that make use of this and as such I won&#039;t discuss it further here.&lt;br /&gt;
&lt;br /&gt;
===Stores used when no mapping is present===&lt;br /&gt;
&lt;br /&gt;
[[Image:caching-27-06-stores-used-when-no-mapping-is-present.png|thumb|500px|Mapping of default stores screenshot]]&lt;br /&gt;
&lt;br /&gt;
This table quickly shows which cache store instances are going to be used for cache types if there are no specific mappings in place.&amp;lt;br /&amp;gt;&lt;br /&gt;
To simplify that, this shows the default cache stores for each type.&lt;br /&gt;
&lt;br /&gt;
At the bottom, you will notice there is a link &amp;quot;Edit mappings&amp;quot; that takes you to a page where you can configure this.&lt;br /&gt;
&lt;br /&gt;
==Adding cache store instances==&lt;br /&gt;
&lt;br /&gt;
The default configuration is going to work for all sites, however, you may be able to improve the performance of your sites by making use of various caching backends and techniques. The first thing you will want to do is add cache store instances configured to connect to/use the cache backends you&#039;ve set up.&lt;br /&gt;
&lt;br /&gt;
===File cache===&lt;br /&gt;
&lt;br /&gt;
[[Image:caching-27-07-add-file-cache-store.png|thumb|300px|Adding a file cache store screenshot]]&lt;br /&gt;
&lt;br /&gt;
When on the cache configuration screen within the &#039;&#039;Installed cache stores&#039;&#039; table, you should see the File cache plugin, click &#039;&#039;`Add instance`&#039;&#039; to start the process of adding a file cache store instance.&lt;br /&gt;
&lt;br /&gt;
When creating a file cache there is in fact only one required param, the store name. The store name is used to identify the file store instance in the configuration interface and must be unique to the site.&lt;br /&gt;
It can be anything you want, but we would advice making it something that describes your intended use of the file store.&lt;br /&gt;
&lt;br /&gt;
The following properties can also be specified, customising where the file cache will be located, and how it operates.&lt;br /&gt;
&lt;br /&gt;
; &#039;&#039;&#039;Cache path&#039;&#039;&#039;: Allows you to specify a directory to use when storing cache data on the file system. Of course the user the web server is running as must have read/write access to this directory. By default (blank) the Moodledata directory will be used.&lt;br /&gt;
; &#039;&#039;&#039;Auto create directory&#039;&#039;&#039;: If enabled when the cache is initialised if the specified directory does not exist Moodle will create it. If this is specified and the directory does not exist the cache will be deemed not ready and will not be used.&lt;br /&gt;
; &#039;&#039;&#039;Single directory store&#039;&#039;&#039;: By default, the file store will create a subdirectory structure to store data in. The first 3 characters of the data key will be used as a directory. This is useful in avoiding file system limits it the file system has a maximum number of files per directory. By enabling this option the file cache will not use subdirectories for storage of data. This leads to a flat structure but one that is more likely to hit file system limits. Use with care.&lt;br /&gt;
; &#039;&#039;&#039;Prescan directory&#039;&#039;&#039;: One of the features the file cache provides is to prescan the storage directory when the cache is first used. This leads to faster checks of files at the expense of an in-depth read.&lt;br /&gt;
&lt;br /&gt;
The file cache store is the default store used for application caches and by default, the moodledata directory gets used for the cache.&lt;br /&gt;
File access can be a taxing resource in times of increased load and the following are some ideas about configuring alternative file stores in order to improve performance.&lt;br /&gt;
&lt;br /&gt;
First up is there a faster file system available for use on your server.&amp;lt;br /&amp;gt;&lt;br /&gt;
Perhaps you have an SSD installed but are not using it for your moodledata directory because space is a premium.&amp;lt;br /&amp;gt;&lt;br /&gt;
You should consider creating a directory or small partition on your SSD and creating a file store to use that instead of your Moodle data directory.&lt;br /&gt;
&lt;br /&gt;
Next, you&#039;ve not got a faster drive available for use, but you do have plenty of free space.&amp;lt;br /&amp;gt;&lt;br /&gt;
Something that may be worth giving a shot would be to create a small partition on the drive you&#039;ve got installed that uses a performance orientated file system.&amp;lt;br /&amp;gt;&lt;br /&gt;
Many Linux installations these days, for example, use EXT4, a nice file system but one that has overheads due to the likes of journalling.&amp;lt;br /&amp;gt;&lt;br /&gt;
Creating a partition and using a file system that has been optimised for performance may give you that little boost you are looking for. Remember caches are designed to be volatile and choosing a file system for a cache is a different decision to choosing a file system for your server.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, if you&#039;re ready to go to lengths and have an abundance of memory on your server you could consider creating a ramdisk/tmpfs and pointing a file store at that.&lt;br /&gt;
Purely based in memory, it is volatile exactly like the cache is, and file system performance just isn&#039;t going to get much better than this.&amp;lt;br /&amp;gt;&lt;br /&gt;
Of course, you will be limited in space and you are essentially taking that resource away from your server.&lt;br /&gt;
&lt;br /&gt;
Please remember with all of these ideas that they are just ideas.&amp;lt;br /&amp;gt;&lt;br /&gt;
Whatever you choose - test, test, test, be sure of the decision you make.&lt;br /&gt;
&lt;br /&gt;
===Memcached===&lt;br /&gt;
&lt;br /&gt;
[[Image:caching-27-09-add-memcached-store.png|thumb|300px|Add Memcached store screenshot]]&lt;br /&gt;
&lt;br /&gt;
You must first have a [https://docs.moodle.org/400/en/Performance_recommendations#MemCached Memcached server] you can access and have the [https://docs.moodle.org/400/en/Performance_recommendations#MemCached Memcached PHP extension] installed and enabled on your server.&lt;br /&gt;
&lt;br /&gt;
There are two required parameters in configuring a Memcached store.&lt;br /&gt;
&lt;br /&gt;
; &#039;&#039;&#039;Store name&#039;&#039;&#039;: It is used to identify the store instance in the configuration interface and must be unique to the site.&lt;br /&gt;
; &#039;&#039;&#039;Servers&#039;&#039;&#039;: The servers you wish this cache store use. See below for details.&lt;br /&gt;
&lt;br /&gt;
Servers should be added one per line and each line can contain 1 to 3 properties separated by colons.&lt;br /&gt;
# The URL or IP address of the server (required)&lt;br /&gt;
# The port the server is listening on (optional)&lt;br /&gt;
# The weight to give this server (optional)&lt;br /&gt;
&lt;br /&gt;
For example, if you had two Memcached instances running on your server, one configured for the default port, and one configured for 11212 you would use the following:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
127.0.0.1&lt;br /&gt;
127.0.0.1:11212&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There are also several optional parameters you can set when creating a Memcached store.&lt;br /&gt;
&lt;br /&gt;
; &#039;&#039;&#039;Use compression&#039;&#039;&#039;: Defaults to true, but can be disabled if you wish.&lt;br /&gt;
; &#039;&#039;&#039;Use serialiser&#039;&#039;&#039;: Allows you to select which serialiser gets used when communicating with the Memcached server. By default the Memcached extension and PHP only provide one serialised, however, there is a couple of others available for installation if you go looking for them. One, for example, is the igbinary found at https://github.com/igbinary/igbinary.&lt;br /&gt;
; &#039;&#039;&#039;Prefix key&#039;&#039;&#039;: Allows you to set some characters that will be prefixed to all keys before interacting with the server.&lt;br /&gt;
; &#039;&#039;&#039;Hash method&#039;&#039;&#039;: The hash method provided by the Memcached extension is used by default here. However, you can select to use an alternative if you wish. http://www.php.net/manual/en/memcached.constants.php provides little information on the options available. Please note if you wish to you can also override the default hash function PHP uses within your php.ini.&lt;br /&gt;
; &#039;&#039;&#039;Buffer writes &#039;&#039;&#039;: Disabled by default, and for good reason. Turning on buffered writes will minimise interaction with the Memcached server by buffering io operations. The downside to this is that there is a good chance multiple requests will end up generating the data on a system with any concurrency because no one had pushed it to the Memcached server when they first requested it. Enabling this can be advantageous for caches that are only accessed in capability-controlled areas, for example, where multiple interactions take a toll on network resources. But that is definitely on the extreme tweaking end of the scale.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important implementation notes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* The Memcached extension does not provide a means of deleting a set or entries. Either a single entry is deleted, or all entries are deleted.&lt;br /&gt;
Because of this, it is important to note that when you purge a Memcached store within Moodle it deletes ALL entries in the Memcached server. Not just those relating to Moodle.&amp;lt;br /&amp;gt;&lt;br /&gt;
For that reason, it is highly recommended to use dedicated Memcached servers and to &#039;&#039;&#039;NOT&#039;&#039;&#039; configure any other software to use the same servers. Doing so may lead to performance depreciation and adverse effects.&lt;br /&gt;
* Likewise if you want to use Memcached for caching and for sessions in Moodle it is essential to use two Memcached servers. One for sessions, and one for caching. Otherwise, a cache purge in Moodle will purge your sessions!&lt;br /&gt;
&lt;br /&gt;
===MongoDB===&lt;br /&gt;
&lt;br /&gt;
[[Image:caching-27-10-add-mongodb-store.png|thumb|300px|Add MongoDB store screenshot]]&lt;br /&gt;
&lt;br /&gt;
MongoDB is an open source document orientated NoSQL database. Check out their website www.mongodb.org for more information.&lt;br /&gt;
&lt;br /&gt;
; &#039;&#039;&#039;Store name&#039;&#039;&#039;: Used to identify the store instance in the configuration interface and must be unique to the site.&lt;br /&gt;
; &#039;&#039;&#039;Server &#039;&#039;&#039;: This is the connection string for the server you want to use. Multiple servers can be specified using a comma-separated list.&lt;br /&gt;
; &#039;&#039;&#039;Database &#039;&#039;&#039;: The name of the database to make use of.&lt;br /&gt;
; &#039;&#039;&#039;Username&#039;&#039;&#039;: The username to use when making a connection.&lt;br /&gt;
; &#039;&#039;&#039;Password &#039;&#039;&#039;: The password of the user being used for the connection.&lt;br /&gt;
; &#039;&#039;&#039;Replica set &#039;&#039;&#039;: The name of the replica set to connect to. If this is given the master will be determined by using the ismaster database command on the seeds, so the driver may end up connecting to a server that was not even listed.&lt;br /&gt;
; &#039;&#039;&#039;Use&#039;&#039;&#039;: If enabled the usesafe option will be used during insert, get, and remove operations. If you&#039;ve specified a replica set this will be forced on anyway.&lt;br /&gt;
; &#039;&#039;&#039;Use safe value&#039;&#039;&#039;: You can choose to provide a specific value for use safe. This will determine the number of servers that operations must be completed on before they are deemed to have been completed.&lt;br /&gt;
; &#039;&#039;&#039;Use extended keys&#039;&#039;&#039;: If enabled full key sets will be used when working with the plugin. This isn&#039;t used internally yet but would allow you to easily search and investigate the MongoDB plugin manually if you so choose. Turning this on will add a small overhead so should only be done if you require it.&lt;br /&gt;
&lt;br /&gt;
==Mapping a cache to a store instance==&lt;br /&gt;
&lt;br /&gt;
[[Image:caching-27-11-store-mapping.png|thumb|300px|Cache definition store mapping screenshot]]&lt;br /&gt;
&lt;br /&gt;
Mapping a store instance to a cache tells Moodle to use that store instance when the cache is interacted with. This allows the Moodle administrator to control where information gets stored and, most importantly, optimise your site&#039;s performance by making the most of the resources available to your site.&lt;br /&gt;
&lt;br /&gt;
To set a mapping first browse to the cache configuration screen.&amp;lt;br /&amp;gt;&lt;br /&gt;
Proceed to find the &#039;&#039;Known cache definitions&#039;&#039; table and within it find the cache you&#039;d like to map.&lt;br /&gt;
In the actions column select the link for &#039;&#039;&#039;Edit mappings&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
The screen you are presented allows you to map one or more cache store instances to be used by this cache.&amp;lt;br /&amp;gt;&lt;br /&gt;
You are presented with several drop-downs that allow you to map one or more cached. All mapped caches get interacted with. The &amp;quot;Primary&amp;quot; store is the store that will be used first when interacting with the cache.&lt;br /&gt;
The &amp;quot;Final&amp;quot; mapped store will be the last cache store interacted with.&amp;lt;br /&amp;gt;&lt;br /&gt;
How this interaction occurs is documented below.&lt;br /&gt;
&lt;br /&gt;
If no stores are mapped for the cache then the default stores are used. Have a look at the section below for information on changing the default stores.&lt;br /&gt;
&lt;br /&gt;
If a single store instance is mapped to the cache the following occurs:&lt;br /&gt;
; &#039;&#039;Getting data from the cache&#039;&#039;: Moodle asks the cache to get the data. The cache attempts to get it from the store. If the store has it, it gives it to the cache, and the cache gives it to Moodle so that it can use the data. If the store doesn&#039;t have it, then fail is returned and Moodle will have to generate the data and will most likely then send it to the cache.&lt;br /&gt;
; &#039;&#039;Storing data in the cache&#039;&#039;: Moodle will ask the cache to store some data, and the cache will give it to the cache store.&lt;br /&gt;
&lt;br /&gt;
If multiple store instances are mapped to the cache the following occurs:&lt;br /&gt;
; &#039;&#039;Getting data from a store&#039;&#039;: Moodle asks the cache to get the data. The cache attempts to get it from the first store. If the first store has it then it returns the data to the cache and the cache returns it to Moodle. If the first store doesn&#039;t have the data then it attempts to get the data from the second store. If the second store has it is returns it to the first store that then stores it itself before returning it to the cache. If it doesn&#039;t then the next store is used. This continues until either the data is found or there are no more stores to check.&lt;br /&gt;
; &#039;&#039;Storing data in the cache&#039;&#039;: Moodle will ask the cache to store some data, the cache will give it to every mapped cache store for storage.&lt;br /&gt;
&lt;br /&gt;
The main advantage of assigning multiple stores is that you can introduce cache redundancy. Of course, this introduces an overhead so it should only be used when actually required.&lt;br /&gt;
The following is an example of when mapping multiple stores can provide an advantage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Scenario:&lt;br /&gt;
You have a web server that has a Moodle site as well as other sites.&lt;br /&gt;
You also have a Memcached server that is used by several sites including Moodle.&lt;br /&gt;
&lt;br /&gt;
Memcached has a limited size cache, that when full and requested to store more information frees space by dropping the least used cache entries.&lt;br /&gt;
&lt;br /&gt;
You want to use Memcached for your Moodle site because it is fast, however, you are aware that it may introduce more cache misses because it is a heavily used Memcached server.&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
To get around this you map two stores to caches you wish to use Memcached.&lt;br /&gt;
You make Memcached the primary store, and you make the default file store the final cache store.&lt;br /&gt;
&lt;br /&gt;
Explanation:&lt;br /&gt;
By doing this you&#039;ve created redundancy; when something is requested, Moodle first tries to get it from Memcached (the fastest store) and if it is not there it proceeds to check the file cache.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Just a couple more points of interest:&lt;br /&gt;
&lt;br /&gt;
* Mapping multiple caches will introduce overhead, the more caches mapped the more overhead.&lt;br /&gt;
* Consider the cache stores you are mapping to, if data remains there once set then there is no point mapping any further stores after it. This technique is primarily valuable in situations where data is not guaranteed to remain after being set.&lt;br /&gt;
* Always test your configuration. Enable the display of performance information and then watch which stores get used when interacting with Moodle in such a way as to trigger the cache.&lt;br /&gt;
&lt;br /&gt;
==Setting the stores that get used when no mapping is present==&lt;br /&gt;
&lt;br /&gt;
[[Image:caching-27-12-default-store-mapping.png|thumb|300px|Setting which stores get used when no mapping is present screenshot]]&lt;br /&gt;
&lt;br /&gt;
This is really setting the default stores that get used for a cache type when there is not a specific mapping that has been made for it.&lt;br /&gt;
&lt;br /&gt;
To set a mapping first browse to the cache configuration screen.&amp;lt;br /&amp;gt;&lt;br /&gt;
Proceed to find the &#039;&#039;Stores used when no mapping is present&#039;&#039; table.&amp;lt;br /&amp;gt;&lt;br /&gt;
After the table you will find a link &#039;&#039;&#039;Edit mappings&#039;&#039;&#039;, click this.&lt;br /&gt;
&lt;br /&gt;
On the screen you are presented with you can select one store for each cache type to use when a cache of the corresponding type gets initialised and there is not an explicit mapping for it.&lt;br /&gt;
&lt;br /&gt;
Note that on this interface the drop downs only contain store instances that are suitable for mapping to the type.&lt;br /&gt;
Not all instances will necessarily be shown. If you have a store instance you don&#039;t see then it is not suitable for &#039;&#039;&#039;ALL&#039;&#039;&#039; the cache definitions that exist.&amp;lt;br /&amp;gt;&lt;br /&gt;
You will not be able to make that store instance the default, you will instead need to map it explicitly to each cache you want/can use it for.&lt;br /&gt;
&lt;br /&gt;
==Configuring caching for your site==&lt;br /&gt;
&lt;br /&gt;
This is where it really gets tricky, and unfortunately, there is no step-by-step guide to this.&lt;br /&gt;
&lt;br /&gt;
How caching can be best configured for a site comes down entirely to the site in question and the resources available to it.&lt;br /&gt;
&lt;br /&gt;
What can be offered are some tips and tricks to get you thinking about things and to perhaps introduce ideas that will help you along the way.&lt;br /&gt;
&lt;br /&gt;
If you are reading this document and you&#039;ve learnt a thing or two about configuring caching on your site share your learnings by adding to the points here.&lt;br /&gt;
&lt;br /&gt;
* Plan it. It&#039;s a complex thing. Understand your site, understand your system, and really think how users will be using it all.&lt;br /&gt;
* If you&#039;ve got a small site the gains aren&#039;t likely to be significant, if you&#039;ve got a large site getting this right can lead to a substantial boost in performance.&lt;br /&gt;
* When looking at cache backends really research the advantages and disadvantages of each. Keep your site in mind when thinking about them. Depending upon your site you may find that no one cache backend is going to meet the entire needs of your site and that you will benefit from having a couple of backends at your disposal.&lt;br /&gt;
* Things aren&#039;t usually as simple as installing a cache backend and then using it. Pay attention to configuration and try to optimise it for your system. Test it separately and have an understanding of its performance before telling Moodle about it. The cache allows you to shift load off the database and reduce page request processing.&amp;lt;br /&amp;gt;If for instance you have Memcached installed but your connection has not been optimised for it you may well find yourself in a losing situation before you even tell Moodle about the Memcached server.&lt;br /&gt;
* When considering your default store instances keep in mind that they must operate with data sets of varying sizes and frequency. For a large site really your best bet is to look at each cache definition and map it to a store that is best suited for the data it includes and the frequency of access.&amp;lt;br /&amp;gt;Cache definitions have been documented [[Cache definitions]].&lt;br /&gt;
* Again when mapping store instances to caches really think about the cache you are mapping and make a decision based upon what you understand of your site and what you know about the cache.&amp;lt;br /&amp;gt;Cache definitions have been documented [[Cache definitions]].&lt;br /&gt;
* Test your configuration. If you can stress test it even better! If you turn on performance information Moodle will also print cache access information at the bottom of the screen. You can use this to visually check the cache is being used as you expect, and it will give you an indication of where misses etc. are occurring.&lt;br /&gt;
* Keep an eye on your backend. Moodle doesn&#039;t provide a means of monitoring a cache backend and that is certainly something you should keep an eye on. Memcached for instance drops least used data when full to make room for new entries. APC, on the other hand, stops accepting data when full. Both will impact your performance if full and you&#039;re going to encounter misses. However APC when full is horrible, but it is much faster.&lt;br /&gt;
&lt;br /&gt;
===More on performance testing===&lt;br /&gt;
&lt;br /&gt;
Two links that might be useful to anyone considering testing performance on their own servers:&lt;br /&gt;
&lt;br /&gt;
* [http://www.iteachwithmoodle.com/2012/10/12/moodle-performance-testing-how-much-more-horsepower-do-each-new-versions-of-moodle-require/ Moodle performance testing: how much more horsepower do each new versions of Moodle require?]&lt;br /&gt;
* [http://www.iteachwithmoodle.com/2012/10/11/how-to-stress-test-your-moodle-server-using-loadstorm/ How to load test your Moodle server using Loadstorm]&lt;br /&gt;
&lt;br /&gt;
===Performance advice for load-balanced web servers===&lt;br /&gt;
&lt;br /&gt;
# In Moodle 2.4 onwards with load-balanced web servers, don&#039;t use the default caching option that stores the data in moodledata on a shared network drive.   Use memcached instead.   See Tim Hunt&#039;s article on http://tjhunt.blogspot.de/2013/05/performance-testing-moodle.html&lt;br /&gt;
# In Moodle 2.6 onwards make sure you set $CFG-&amp;gt;localcachedir to some local directory in config.php (for each node).  This will speed up some of the disk caching that happens outside of MUC, such as themes, javascript, libraries etc.&lt;br /&gt;
&lt;br /&gt;
==Troubleshooting==&lt;br /&gt;
&lt;br /&gt;
Have you encountered a problem, or found yourself in a conundrum? Perhaps the answer is in this section. If not when you find an answer, how about you share it here.&lt;br /&gt;
&lt;br /&gt;
==More information==&lt;br /&gt;
* [[Cache definitions]] Information on the cache definitions found within Moodle.&lt;br /&gt;
* [[:dev:Cache API|Cache API]] Details of the Cache API.&lt;br /&gt;
* [[:dev:Cache API - Quick reference|Cache API - Quick reference]] A short, code focused page of on the Cache API.&lt;br /&gt;
* [[:dev:The Moodle Universal Cache (MUC)|The Moodle Universal Cache (MUC)]] The original cache specification.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Cache related forum discussions that may help in understanding MUC:&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=217195 MUC is here, now what?] &lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=226123 Status of MUC?]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=222250 Putting cachedir on local disks in cluster]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=232122 moodle cachestore_file]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=378416#p1526130 Why using a not-completely-shared application cache will fail]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=240971#p1117097 Some Cache / MUC questions]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Other:&lt;br /&gt;
* [http://jfilip.ca/2013/08/20/moodle-2-4-5-vs-2-5-1-performance-and-muc-apc-cache-store/ Moodle 2.4.5 vs. 2.5.1 performance and MUC APC cache store] blog post by Justin Filip&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[MUC FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[de:Caching]]&lt;br /&gt;
[[es:Cacheando]]&lt;br /&gt;
[[fr:Mettre en cache]]&lt;br /&gt;
[[ja:キャッシング]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:error/local_hub/cannotregisternotavailablesite&amp;diff=144102</id>
		<title>Talk:error/local hub/cannotregisternotavailablesite</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:error/local_hub/cannotregisternotavailablesite&amp;diff=144102"/>
		<updated>2022-08-23T17:55:18Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Typo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This topic says: &amp;quot;To register to a hub your Moodle site needs to be accessible by the hub so the two can communicate bi-directionally.&amp;quot; What does this really mean? How does the hub connect to a Moodle site? What protocol does it use to do the connection? (http? https? Something else?)&lt;br /&gt;
&lt;br /&gt;
What proxy and/or firewall rules need to be created to give &amp;quot;the hub&amp;quot; access to the Moodle site?&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 20:49, 18 September 2014 (WST)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Site_registration&amp;diff=144099</id>
		<title>Site registration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Site_registration&amp;diff=144099"/>
		<updated>2022-08-23T09:41:07Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Enable Content (remove __NOTOC__) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Managing a Moodle site}}&lt;br /&gt;
[[File:Boost-Moodle-Registrations.jpg]]&lt;br /&gt;
==Why register my site?==&lt;br /&gt;
Registering your site gives us a better picture of how Moodle is used worldwide and helps us make decisions about new features and plugins.&lt;br /&gt;
==4 reasons to register==&lt;br /&gt;
# Stay up to date by email whenever there are new releases of Moodle or security alerts. &lt;br /&gt;
# Be part of the [https://stats.moodle.org/ statistics of the worldwide community]. &lt;br /&gt;
# List your site on our [https://stats.moodle.org/sites/ list of registered sites in your country]. (But if you want to keep it private, that&#039;s fine too!)&lt;br /&gt;
# Make use of the messaging server https://messages.moodle.net/ for [[Moodle app notifications]].&lt;br /&gt;
==How about security?==&lt;br /&gt;
We don&#039;t share your information with anyone. We don&#039;t go into your site. We use the aggregated anonymous data to publish the statistics of the worldwide community and use the other data to help us in our decision making around new features and plugins.&lt;br /&gt;
==How do I register?==&lt;br /&gt;
Register your site by logging in as an administrator and going to &#039;&#039;Site administration / Registration&#039;&#039;. If you&#039;re not the admin, ask them nicely to check!&lt;br /&gt;
==I don’t want my details public==&lt;br /&gt;
Your registration is private to us unless you choose to make it public.&lt;br /&gt;
==Do I have to register? What happens if I don’t?==&lt;br /&gt;
Registration is optional, but we wouldn&#039;t want you to miss out on any important security issues or upgrades and put your site at risk. The more people who register, the better a picture we get of how Moodle is used and which aspects we can improve. So registering is a win-win for you as well as for us.&lt;br /&gt;
&lt;br /&gt;
However, if you only want to use Moodle for testing things out then you don&#039;t need to put your site online and you don&#039;t need to register it.&lt;br /&gt;
==I can’t register my site!==&lt;br /&gt;
Only sites which are online can be registered. If your site is online and you have problems registering, please use the [https://moodle.com/contact/support/?selection=community#form Moodle.com contact form].&lt;br /&gt;
&lt;br /&gt;
If you encounter a problem updating your registration, please try un-registering then re-registering your site. To un-register your site, click the ‘Unregister’ link at the bottom of the Registration page.&lt;br /&gt;
&lt;br /&gt;
Note that it can take a while before your site is listed so please be patient.&lt;br /&gt;
==See also==&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=362833 Annoying restored test Moodle] forum discussion about a test site and registration&lt;br /&gt;
* MDLSITE-6267 Registration regularly fails with invalid token not found on a 3.9 site&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
[[de:Moodle-Site registrieren]]&lt;br /&gt;
[[es:Registro del sitio]]&lt;br /&gt;
[[it:Registrazione del sito]]&lt;br /&gt;
[[ja: サイト登録]]&lt;br /&gt;
[[fr:Enregistrement du site]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Site_registration&amp;diff=144098</id>
		<title>Site registration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Site_registration&amp;diff=144098"/>
		<updated>2022-08-23T08:10:41Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also : add MDLSITE-6267 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Managing a Moodle site}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
[[File:Boost-Moodle-Registrations.jpg]]&lt;br /&gt;
==Why register my site?==&lt;br /&gt;
Registering your site gives us a better picture of how Moodle is used worldwide and helps us make decisions about new features and plugins.&lt;br /&gt;
==4 reasons to register==&lt;br /&gt;
# Stay up to date by email whenever there are new releases of Moodle or security alerts. &lt;br /&gt;
# Be part of the [https://stats.moodle.org/ statistics of the worldwide community]. &lt;br /&gt;
# List your site on our [https://stats.moodle.org/sites/ list of registered sites in your country]. (But if you want to keep it private, that&#039;s fine too!)&lt;br /&gt;
# Make use of the messaging server https://messages.moodle.net/ for [[Moodle app notifications]].&lt;br /&gt;
==How about security?==&lt;br /&gt;
We don&#039;t share your information with anyone. We don&#039;t go into your site. We use the aggregated anonymous data to publish the statistics of the worldwide community and use the other data to help us in our decision making around new features and plugins.&lt;br /&gt;
==How do I register?==&lt;br /&gt;
Register your site by logging in as an administrator and going to &#039;&#039;Site administration / Registration&#039;&#039;. If you&#039;re not the admin, ask them nicely to check!&lt;br /&gt;
==I don’t want my details public==&lt;br /&gt;
Your registration is private to us unless you choose to make it public.&lt;br /&gt;
==Do I have to register? What happens if I don’t?==&lt;br /&gt;
Registration is optional, but we wouldn&#039;t want you to miss out on any important security issues or upgrades and put your site at risk. The more people who register, the better a picture we get of how Moodle is used and which aspects we can improve. So registering is a win-win for you as well as for us.&lt;br /&gt;
&lt;br /&gt;
However, if you only want to use Moodle for testing things out then you don&#039;t need to put your site online and you don&#039;t need to register it.&lt;br /&gt;
==I can’t register my site!==&lt;br /&gt;
Only sites which are online can be registered. If your site is online and you have problems registering, please use the [https://moodle.com/contact/support/?selection=community#form Moodle.com contact form].&lt;br /&gt;
&lt;br /&gt;
If you encounter a problem updating your registration, please try un-registering then re-registering your site. To un-register your site, click the ‘Unregister’ link at the bottom of the Registration page.&lt;br /&gt;
&lt;br /&gt;
Note that it can take a while before your site is listed so please be patient.&lt;br /&gt;
==See also==&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=362833 Annoying restored test Moodle] forum discussion about a test site and registration&lt;br /&gt;
* MDLSITE-6267 Registration regularly fails with invalid token not found on a 3.9 site&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
[[de:Moodle-Site registrieren]]&lt;br /&gt;
[[es:Registro del sitio]]&lt;br /&gt;
[[it:Registrazione del sito]]&lt;br /&gt;
[[ja: サイト登録]]&lt;br /&gt;
[[fr:Enregistrement du site]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Site_registration&amp;diff=144097</id>
		<title>Site registration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Site_registration&amp;diff=144097"/>
		<updated>2022-08-23T08:05:11Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also: add MDLSITE-6267 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Managing a Moodle site}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
[[File:Boost-Moodle-Registrations.jpg]]&lt;br /&gt;
==Why register my site?==&lt;br /&gt;
Registering your site gives us a better picture of how Moodle is used worldwide and helps us make decisions about new features and plugins.&lt;br /&gt;
==4 reasons to register==&lt;br /&gt;
# Stay up to date by email whenever there are new releases of Moodle or security alerts. &lt;br /&gt;
# Be part of the [https://stats.moodle.org/ statistics of the worldwide community]. &lt;br /&gt;
# List your site on our [https://stats.moodle.org/sites/ list of registered sites in your country]. (But if you want to keep it private, that&#039;s fine too!)&lt;br /&gt;
# Make use of the messaging server https://messages.moodle.net/ for [[Moodle app notifications]].&lt;br /&gt;
==How about security?==&lt;br /&gt;
We don&#039;t share your information with anyone. We don&#039;t go into your site. We use the aggregated anonymous data to publish the statistics of the worldwide community and use the other data to help us in our decision making around new features and plugins.&lt;br /&gt;
==How do I register?==&lt;br /&gt;
Register your site by logging in as an administrator and going to &#039;&#039;Site administration / Registration&#039;&#039;. If you&#039;re not the admin, ask them nicely to check!&lt;br /&gt;
==I don’t want my details public==&lt;br /&gt;
Your registration is private to us unless you choose to make it public.&lt;br /&gt;
==Do I have to register? What happens if I don’t?==&lt;br /&gt;
Registration is optional, but we wouldn&#039;t want you to miss out on any important security issues or upgrades and put your site at risk. The more people who register, the better a picture we get of how Moodle is used and which aspects we can improve. So registering is a win-win for you as well as for us.&lt;br /&gt;
&lt;br /&gt;
However, if you only want to use Moodle for testing things out then you don&#039;t need to put your site online and you don&#039;t need to register it.&lt;br /&gt;
==I can’t register my site!==&lt;br /&gt;
Only sites which are online can be registered. If your site is online and you have problems registering, please use the [https://moodle.com/contact/support/?selection=community#form Moodle.com contact form].&lt;br /&gt;
&lt;br /&gt;
If you encounter a problem updating your registration, please try un-registering then re-registering your site. To un-register your site, click the ‘Unregister’ link at the bottom of the Registration page.&lt;br /&gt;
&lt;br /&gt;
Note that it can take a while before your site is listed so please be patient.&lt;br /&gt;
==See also==&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=362833 Annoying restored test Moodle] forum discussion about a test site and registration&lt;br /&gt;
* [https://tracker.moodle.org/browse/MDLSITE-6267 MDLSITE-6267] Registration regularly fails with invalid token not found on a 3.9 site&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
[[de:Moodle-Site registrieren]]&lt;br /&gt;
[[es:Registro del sitio]]&lt;br /&gt;
[[it:Registrazione del sito]]&lt;br /&gt;
[[ja: サイト登録]]&lt;br /&gt;
[[fr:Enregistrement du site]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Site_registration&amp;diff=144096</id>
		<title>Site registration</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Site_registration&amp;diff=144096"/>
		<updated>2022-08-23T08:00:36Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also : add MDLSITE-6267 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Managing a Moodle site}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
[[File:Boost-Moodle-Registrations.jpg]]&lt;br /&gt;
==Why register my site?==&lt;br /&gt;
Registering your site gives us a better picture of how Moodle is used worldwide and helps us make decisions about new features and plugins.&lt;br /&gt;
==4 reasons to register==&lt;br /&gt;
# Stay up to date by email whenever there are new releases of Moodle or security alerts. &lt;br /&gt;
# Be part of the [https://stats.moodle.org/ statistics of the worldwide community]. &lt;br /&gt;
# List your site on our [https://stats.moodle.org/sites/ list of registered sites in your country]. (But if you want to keep it private, that&#039;s fine too!)&lt;br /&gt;
# Make use of the messaging server https://messages.moodle.net/ for [[Moodle app notifications]].&lt;br /&gt;
==How about security?==&lt;br /&gt;
We don&#039;t share your information with anyone. We don&#039;t go into your site. We use the aggregated anonymous data to publish the statistics of the worldwide community and use the other data to help us in our decision making around new features and plugins.&lt;br /&gt;
==How do I register?==&lt;br /&gt;
Register your site by logging in as an administrator and going to &#039;&#039;Site administration / Registration&#039;&#039;. If you&#039;re not the admin, ask them nicely to check!&lt;br /&gt;
==I don’t want my details public==&lt;br /&gt;
Your registration is private to us unless you choose to make it public.&lt;br /&gt;
==Do I have to register? What happens if I don’t?==&lt;br /&gt;
Registration is optional, but we wouldn&#039;t want you to miss out on any important security issues or upgrades and put your site at risk. The more people who register, the better a picture we get of how Moodle is used and which aspects we can improve. So registering is a win-win for you as well as for us.&lt;br /&gt;
&lt;br /&gt;
However, if you only want to use Moodle for testing things out then you don&#039;t need to put your site online and you don&#039;t need to register it.&lt;br /&gt;
==I can’t register my site!==&lt;br /&gt;
Only sites which are online can be registered. If your site is online and you have problems registering, please use the [https://moodle.com/contact/support/?selection=community#form Moodle.com contact form].&lt;br /&gt;
&lt;br /&gt;
If you encounter a problem updating your registration, please try un-registering then re-registering your site. To un-register your site, click the ‘Unregister’ link at the bottom of the Registration page.&lt;br /&gt;
&lt;br /&gt;
Note that it can take a while before your site is listed so please be patient.&lt;br /&gt;
==See also==&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=362833 Annoying restored test Moodle] forum discussion about a test site and registration&lt;br /&gt;
* [https://tracker.moodle.org/browse/MDLSITE-6267?focusedCommentId=883291&amp;amp;page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel MDLSITE-6267] Registration regularly fails with invalid token not found on a 3.9 site&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
[[de:Moodle-Site registrieren]]&lt;br /&gt;
[[es:Registro del sitio]]&lt;br /&gt;
[[it:Registrazione del sito]]&lt;br /&gt;
[[ja: サイト登録]]&lt;br /&gt;
[[fr:Enregistrement du site]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:RedHat_Linux_installation&amp;diff=142560</id>
		<title>Talk:RedHat Linux installation</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:RedHat_Linux_installation&amp;diff=142560"/>
		<updated>2021-11-22T10:09:34Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Created page with &amp;quot;This is a great article, but please add a full explanation and description for using Redis for the session and/or file caching layers. --~~~~&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This is a great article, but please add a full explanation and description for using Redis for the session and/or file caching layers.&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 10:09, 22 November 2021 (UTC)&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Context&amp;diff=141571</id>
		<title>Context</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Context&amp;diff=141571"/>
		<updated>2021-08-25T06:07:02Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* Add forum link to See also section */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Main page}}&lt;br /&gt;
A context is a space in Moodle where [[Roles_and_capabilities|roles]] can be assigned. For example, a Moodle site is one context and that contains a number of other contexts within it. A category is a context, within a site context, that contains courses and sub-categories that have a context of their own. &lt;br /&gt;
&lt;br /&gt;
A [[Courses|course]] may hold, within its own context, an activity, or a [[Question bank]]&#039;s question category, which are also contexts. A context might contain other contexts and Roles can be assigned to each context. &lt;br /&gt;
&lt;br /&gt;
There is a hierarchy of contexts which helps locate and define a specific space. A course can have many contexts in its space. These might include lesson, assignment, forum and quiz modules and blocks. &lt;br /&gt;
&lt;br /&gt;
Generally speaking, this hierarchy allows a lower context to receive information from a higher context. Thus a student in the context of Course A, will initially be considered a student in a Quiz context that is located in Course A. Or when a theme has been set for the Biology course categories, that is passed on to Biology 101. &lt;br /&gt;
==Roles and contexts==&lt;br /&gt;
A context is combined with role permissions to define a User&#039;s [[Roles and capabilities|capabilities]] on any page in Moodle. Typically contexts have their own organization structure which allow a User&#039;s role to be passed along to the context &amp;quot;below&amp;quot; but not to the one above it.[[Image:context.png|right|thumb|150px|Each context can have a different role assigned to a User]]&lt;br /&gt;
It is possible to assign a user different permissions based upon a specific context. For example, a user might be given the role of &amp;quot;student&amp;quot; for a course but be given a teacher&#039;s role in the context of one specific forum. Or a user can be a teacher of one course and a student in another course. &lt;br /&gt;
&lt;br /&gt;
Many Moodle contexts have a place to grant exceptions to specific roles within that context. Those exceptions are non-transferable from that context. That is, an exception can be applied to the next context downward, but cannot applied sideways nor upward from that context.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Graphic showing contexts within contexts ==&lt;br /&gt;
The image below shows a few contexts and their relationships. The &amp;quot;System&amp;quot; or Moodle site is the overall context. The user is defined initially in this context. &lt;br /&gt;
*The System context has 2 contexts under it, with other context under them&lt;br /&gt;
**The Front page context has&lt;br /&gt;
*** An activity module context and&lt;br /&gt;
*** A block context within it&lt;br /&gt;
**The Course Category context has&lt;br /&gt;
***A Course context within it. The course context has&lt;br /&gt;
**** An activity module context and&lt;br /&gt;
****A block context within it&lt;br /&gt;
[[Image:Moodle-contexts-1.8.png]]&lt;br /&gt;
&lt;br /&gt;
(Source: [[Development:Roles#Context]])&lt;br /&gt;
==Another graphic of hierarchy==&lt;br /&gt;
[[File:Hierarchycategories.png|thumb|center|Showing the Site &amp;gt; Category &amp;gt; Course contexts but not activities]]&lt;br /&gt;
== See also ==&lt;br /&gt;
* [[Roles FAQ]]&lt;br /&gt;
*[[Course_categories|Course categories context]]&lt;br /&gt;
*[https://moodle.org/mod/forum/discuss.php?d=138539#p690741 Explanation of the constants for the context levels] forum discussion&lt;br /&gt;
[[es:Contexto]]&lt;br /&gt;
[[fr:Contextes]]&lt;br /&gt;
[[ja:コンテクスト]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Redis_cache_store&amp;diff=140773</id>
		<title>Talk:Redis cache store</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Redis_cache_store&amp;diff=140773"/>
		<updated>2021-07-13T09:14:33Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Redis cashe store: &amp;quot;Request&amp;quot; cache section explanation required&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;quot;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, &#039;&#039;&#039;in case the user&#039;s connection is not persistent (sticky) to a specific node for the entire Moodle session&#039;&#039;&#039;.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This bit is not really correct, unless you meant only session cache:&lt;br /&gt;
in case the user&#039;s connection is not persistent (sticky) to a specific node for the entire Moodle session&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the &amp;quot;Configuring Redis in Moodle&amp;quot; section it says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;quot;Under &amp;quot;Stores used when no mapping is present&amp;quot; click Edit mappings&amp;quot;. Set &amp;quot;Redis1&amp;quot; (or the name used earlier) for the &amp;quot;Application&amp;quot; and &amp;quot;Session&amp;quot; caches.&amp;quot;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But what about the &#039;&#039;&#039;&amp;quot;Request&amp;quot; cache&#039;&#039;&#039; section. Something needs to be said about the &amp;quot;Request&amp;quot; cache . What do you specify for the &amp;quot;Request&amp;quot; cache? If nothing is required then this wiki should say so and offer an explanation why.&lt;br /&gt;
(I don&#039;t know so I can&#039;t write it.) If it is optional then this wiki should say so.&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 09:08, 13 July 2021 (UTC)&lt;br /&gt;
&lt;br /&gt;
----&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Talk:Redis_cache_store&amp;diff=140772</id>
		<title>Talk:Redis cache store</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Talk:Redis_cache_store&amp;diff=140772"/>
		<updated>2021-07-13T09:08:59Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: Redis cashe store: &amp;quot;Request&amp;quot; cache section explanation required&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;quot;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, &#039;&#039;&#039;in case the user&#039;s connection is not persistent (sticky) to a specific node for the entire Moodle session&#039;&#039;&#039;.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
This bit is not really correct, unless you meant only session cache:&lt;br /&gt;
in case the user&#039;s connection is not persistent (sticky) to a specific node for the entire Moodle session&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
In the &amp;quot;Configuring Redis in Moodle&amp;quot; section it says:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
&amp;quot;Under &amp;quot;Stores used when no mapping is present&amp;quot; click Edit mappings&amp;quot;. Set &amp;quot;Redis1&amp;quot; (or the name used earlier) for the &amp;quot;Application&amp;quot; and &amp;quot;Session&amp;quot; caches.&amp;quot;&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
But what about the &#039;&#039;&#039;&amp;quot;Request&amp;quot; cache&#039;&#039;&#039; section. Something needs to be said about the &amp;quot;Request&amp;quot; cache . What do you specify for the &amp;quot;Request&amp;quot; cache? If nothing is required then this wiki should say so and offer an explanation why.&lt;br /&gt;
(I don&#039;t know so I can&#039;t write it.)&lt;br /&gt;
&lt;br /&gt;
--[[User:Luis de Vasconcelos|Luis de Vasconcelos]] ([[User talk:Luis de Vasconcelos|talk]]) 09:08, 13 July 2021 (UTC)&lt;br /&gt;
&lt;br /&gt;
----&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=138388</id>
		<title>Security report on default user role</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Security_report_on_default_user_role&amp;diff=138388"/>
		<updated>2020-09-04T05:46:35Z</updated>

		<summary type="html">&lt;p&gt;Libertymoodle: /* See also new link */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security overview report}}&lt;br /&gt;
==Default role for all users==&lt;br /&gt;
&lt;br /&gt;
In general the default role for all users should be set to authenticated user. Normally all permissions for the role of authenticated user should be left as default. &lt;br /&gt;
&lt;br /&gt;
==Default user role is incorrectly defined==&lt;br /&gt;
&lt;br /&gt;
If the security overview report shows the default role for all users with status &#039;Critical&#039; and states that &#039;The default user role &amp;quot;Authenticated user&amp;quot; is incorrectly defined!&#039; it means that one or more risky capabilities are allowed for the role.&lt;br /&gt;
&lt;br /&gt;
==Reviewing authenticated user role permissions==&lt;br /&gt;
&lt;br /&gt;
The permissions for the role of authenticated user can be reviewed as follows:&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;&lt;br /&gt;
# In the role column, click the link &#039;Authenticated user&#039;&lt;br /&gt;
# Browse the permissions column&lt;br /&gt;
&lt;br /&gt;
If there is no reason for changing permissions from default, then the role can be reset by clicking the Reset button at the top of the page.&lt;br /&gt;
&lt;br /&gt;
[[File:ResetRoleButton.jpg]]&lt;br /&gt;
&lt;br /&gt;
After resetting the authenticated user role, the security overview report will show the default role for all users with status OK.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=7301 Security and Privacy forum]&lt;br /&gt;
* Using Moodle [https://moodle.org/mod/forum/discuss.php?d=387143 Security overview] discussion&lt;br /&gt;
&lt;br /&gt;
[[es:Reporte de seguridad sobre rol del usuario por defecto]]&lt;/div&gt;</summary>
		<author><name>Libertymoodle</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Header_and_footer&amp;diff=137746</id>
		<title>Header and footer</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Header_and_footer&amp;diff=137746"/>
		<updated>2020-07-27T08:44:44Z</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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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/400/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>
</feed>