<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="sv">
	<id>https://docs.moodle.org/4x/sv/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Howardsmiller</id>
	<title>MoodleDocs - Användarbidrag [sv]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/4x/sv/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Howardsmiller"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/Special:Bidrag/Howardsmiller"/>
	<updated>2026-04-09T06:53:29Z</updated>
	<subtitle>Användarbidrag</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=ad-hoc_contributed_reports&amp;diff=138607</id>
		<title>ad-hoc contributed reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=ad-hoc_contributed_reports&amp;diff=138607"/>
		<updated>2020-10-01T13:05:40Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Enrolled users who have never accessed a given course (simpler version) */&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;
===Enrolled users who have never accessed a given course (simpler version)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT username, firstname, lastname, idnumber&lt;br /&gt;
FROM prefix_user_enrolments ue&lt;br /&gt;
JOIN prefix_enrol en ON ue.enrolid = en.id&lt;br /&gt;
JOIN prefix_user uu ON uu.id = ue.userid &lt;br /&gt;
WHERE en.courseid = 123456&lt;br /&gt;
AND NOT EXISTS (&lt;br /&gt;
    SELECT * FROM prefix_user_lastaccess la&lt;br /&gt;
    WHERE la.userid = ue.userid&lt;br /&gt;
    AND la.courseid = en.courseid&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Replace 123456 near the middle with your courseid)&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;
Compatibility: MySQL and PostgreSQL&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DISTINCT mrc.capability &lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;1&#039; AND rc.contextid = &#039;1&#039;) AS Manager&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;2&#039; AND rc.contextid = &#039;1&#039;) AS Course_Creator&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;3&#039; AND rc.contextid = &#039;1&#039;) AS Teacher&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;4&#039; AND rc.contextid = &#039;1&#039;) AS Assistant_Teacher&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;5&#039; AND rc.contextid = &#039;1&#039;) AS Student&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;6&#039; AND rc.contextid = &#039;1&#039;) AS Guest&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;7&#039; AND rc.contextid = &#039;1&#039;) AS Authenticated&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;8&#039; AND rc.contextid = &#039;1&#039;) AS Auth_front&lt;br /&gt;
FROM prefix_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;
Returns all assignments submitted by those with the student role that have the status of &#039;submitted&#039;, 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;
&lt;br /&gt;
&#039;&#039;&#039;This query is updated for use with Moodle 2.2 or later.  Contributed by Carly J. Born, Carleton College&#039;&#039;&#039;&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;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/assign/view.php?id=&#039;, &lt;br /&gt;
cm.id, &lt;br /&gt;
&#039;&amp;amp;rownum=0&amp;amp;action=grader&amp;amp;userid=&#039;, &lt;br /&gt;
u.id,&lt;br /&gt;
&#039;&amp;quot;&amp;gt;Grade&amp;lt;/a&amp;gt;&#039;) &lt;br /&gt;
AS &amp;quot;Assignment link&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
FROM prefix_assign_submission sub&lt;br /&gt;
JOIN prefix_assign a ON a.id = sub.assignment&lt;br /&gt;
JOIN prefix_user u ON u.id = sub.userid&lt;br /&gt;
JOIN prefix_course c ON c.id = a.course AND c.id = %%COURSEID%%&lt;br /&gt;
JOIN prefix_course_modules cm ON c.id = cm.course &lt;br /&gt;
JOIN prefix_context cxt ON c.id=cxt.instanceid AND cxt.contextlevel=50&lt;br /&gt;
JOIN prefix_role_assignments ra ON cxt.id = ra.contextid AND ra.roleid=5 AND ra.userid=u.id&lt;br /&gt;
 &lt;br /&gt;
WHERE cm.instance = a.id AND cm.module = 22 AND sub.status=&#039;submitted&#039;&lt;br /&gt;
 &lt;br /&gt;
ORDER BY c.fullname, a.name, u.lastname&lt;br /&gt;
&amp;lt;/code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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;
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;
&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 truly 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;
&lt;br /&gt;
=== All Private Files 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;
Lists all files by all users in the Private Files repository, with the file path location and name in the moodledata/filedir directory structure, and time created.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
u.username, &lt;br /&gt;
f.filename, &lt;br /&gt;
CONCAT(&#039;/&#039;, LEFT(f.contenthash,2), &#039;/&#039;, MID(f.contenthash,3,2), &#039;/&#039;, f.contenthash) AS &amp;quot;Filedir_Location&amp;quot;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(f.timecreated),&#039;%Y-%m-%d %H:%i&#039;) AS &amp;quot;Created&amp;quot;&lt;br /&gt;
FROM prefix_files f &lt;br /&gt;
JOIN prefix_user u ON u.id = f.userid&lt;br /&gt;
WHERE f.component = &#039;user&#039; &lt;br /&gt;
AND f.filearea = &#039;private&#039; &lt;br /&gt;
AND f.filesize &amp;gt; 0 &lt;br /&gt;
ORDER BY u.username, f.filename&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;
==Competencies==&lt;br /&gt;
&lt;br /&gt;
===List of competencies from a framework and the courses including them===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
f.shortname AS &#039;Framework&#039;,&lt;br /&gt;
comp.shortname AS &#039;Competency&#039;, &lt;br /&gt;
cccomp.courseid AS &#039;Course id&#039;, &lt;br /&gt;
c.fullname AS &#039;Course name&#039;,&lt;br /&gt;
c.shortname AS &#039;Course code&#039;&lt;br /&gt;
FROM &lt;br /&gt;
prefix_competency_coursecomp AS cccomp &lt;br /&gt;
INNER JOIN prefix_competency AS comp ON cccomp.competencyid = comp.id&lt;br /&gt;
INNER JOIN prefix_course AS c ON cccomp.courseid = c.id&lt;br /&gt;
INNER JOIN prefix_competency_framework AS f ON comp.competencyframeworkid = f.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Count the courses using each competency from frameworks===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
Unfortunately, there is not a filter by competency framework.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
f.shortname AS framework,&lt;br /&gt;
comp.shortname AS &#039;Competency&#039;,&lt;br /&gt;
COUNT(cccomp.competencyid) AS &#039;nb course&#039;&lt;br /&gt;
FROM prefix_competency AS comp&lt;br /&gt;
INNER JOIN prefix_competency_framework AS f ON comp.competencyframeworkid = f.id&lt;br /&gt;
LEFT JOIN prefix_competency_coursecomp AS cccomp ON cccomp.competencyid = comp.id&lt;br /&gt;
GROUP BY comp.id, comp.shortname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Scale details with ids ===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
Competency import and export files include scales with id numbers. However, the management page in Grades &amp;gt; Scales does not have the scale id, nor other useful details that scales store about themselves, like who made them and when, and what context they pertain to. This simple query shows you that information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
s.id AS Scaleid,&lt;br /&gt;
s.name AS Scale_Name,&lt;br /&gt;
s.scale AS Scale,&lt;br /&gt;
CASE  &lt;br /&gt;
  WHEN s.courseid = 0 THEN &#039;System&#039;&lt;br /&gt;
  ELSE (SELECT shortname FROM prefix_course WHERE id = s.courseid)&lt;br /&gt;
END AS Context,&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN s.userid = 0 THEN &#039;System&#039;&lt;br /&gt;
  ELSE (SELECT username FROM prefix_user WHERE id = s.userid)&lt;br /&gt;
END AS User,&lt;br /&gt;
s.description,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME(s.timemodified), &#039;%Y-%m-%d %H:%i&#039; ) AS &#039;Modified&#039;&lt;br /&gt;
FROM prefix_scale s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syllabus==&lt;br /&gt;
&lt;br /&gt;
Our school simply asks teachers to drop a file (resource) on their course page&lt;br /&gt;
and rename this resource (not the file) starting with &amp;quot;syllabus&amp;quot; (case insensitive)&lt;br /&gt;
&lt;br /&gt;
===Count the number of resources whose name starts by &amp;quot;Syllabus&amp;quot;===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
Select &lt;br /&gt;
r.name As &#039;Resource name&#039;,&lt;br /&gt;
cc.name AS &#039;Category&#039;,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a href=&amp;quot;%%WWWROOT%%/pluginfile.php/&#039;, ct.id, &#039;/mod_resource/content/1/&#039;, f.filename, &#039;&amp;quot;&amp;gt;&#039;,f.filename,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Clickable filename&#039;,&lt;br /&gt;
&lt;br /&gt;
c.fullname AS &#039;Course name&#039;,&lt;br /&gt;
c.shortname AS &#039;Course shortname&#039;,&lt;br /&gt;
&lt;br /&gt;
# the date filters are connected to this &amp;quot;last modif&amp;quot; field&lt;br /&gt;
# userful to check if the syllabus has been updated this year&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(f.timemodified), &#039;%e %b %Y&#039;) AS &#039;last modif&#039;, &lt;br /&gt;
&lt;br /&gt;
# tell if the file is visible by the students or hidden&lt;br /&gt;
IF(cm.visible=0,&amp;quot;masqué&amp;quot;,&amp;quot;visible&amp;quot;) AS &#039;Visibility&#039;,&lt;br /&gt;
&lt;br /&gt;
# next line tries to give the real path (local path) if you want to create a zip file using an external script)&lt;br /&gt;
# notice that the path is in the column &amp;quot;contenthash&amp;quot; and NOT in the column pathhash&lt;br /&gt;
# if the contenthash starts with 9af3... then the file is stored in moodledata/filedir/9a/f3/contenthash&lt;br /&gt;
# I try to get the path to moodledata from the value of the geoip variable in the mdl_config table... maybe a bad idea&lt;br /&gt;
CONCAT(&#039;&amp;quot;&#039;,(Select left(value, length(value)-25) from prefix_config where name =&amp;quot;geoip2file&amp;quot;),&#039;/filedir/&#039;, left(f.contenthash,2), &amp;quot;/&amp;quot;,substring(f.contenthash,3,2),&#039;/&#039;, f.contenthash, &#039;&amp;quot;&#039;) AS &#039;link&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
INNER JOIN prefix_course_modules AS cm ON cm.instance = r.id&lt;br /&gt;
INNER JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
INNER JOIN prefix_context AS ct ON ct.instanceid = cm.id&lt;br /&gt;
JOIN prefix_course_categories cc ON c.category = cc.id&lt;br /&gt;
INNER JOIN prefix_files AS f ON f.contextid = ct.id AND f.mimetype IS NOT NULL AND f.component = &#039;mod_resource&#039;&lt;br /&gt;
WHERE LOWER( r.name) LIKE &#039;syllabus%&#039;&lt;br /&gt;
%%FILTER_STARTTIME:f.timemodified:&amp;gt;%% %%FILTER_ENDTIME:f.timemodified:&amp;lt;%%&lt;br /&gt;
%%FILTER_SUBCATEGORIES:cc.path%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List files which have been tagged &amp;quot;Syllabus&amp;quot;===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
Select &lt;br /&gt;
t.rawname AS &#039;rawtag&#039;,&lt;br /&gt;
c.shortname AS &#039;Cours shortname&#039;,&lt;br /&gt;
c.fullname AS &#039;Course name&#039;,&lt;br /&gt;
r.name As &#039;Resource name&#039;,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a href=&amp;quot;%%WWWROOT%%/pluginfile.php/&#039;, ti.contextid, &#039;/mod_resource/content/1/&#039;, f.filename, &#039;&amp;quot;&amp;gt;cliquez ici&amp;lt;/a&amp;gt;&#039;) AS &#039;link&#039;,&lt;br /&gt;
ti.contextid AS &#039;Instance for link&#039;,&lt;br /&gt;
f.id AS &#039;file id&#039; &lt;br /&gt;
FROM prefix_tag_instance AS ti&lt;br /&gt;
INNER JOIN prefix_tag AS t ON ti.tagid = t.id&lt;br /&gt;
INNER JOIN prefix_course_modules AS cm ON ti.itemid = cm.id&lt;br /&gt;
INNER JOIN prefix_course AS c ON cm.course = c.id&lt;br /&gt;
INNER JOIN prefix_resource AS r ON r.id = cm.instance&lt;br /&gt;
INNER JOIN prefix_files AS f ON f.contextid = ti.contextid AND f.mimetype IS NOT NULL&lt;br /&gt;
WHERE t.rawname = &#039;Syllabus&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List of courses WITHOUT a resource with a name starting by &amp;quot;syllabus&amp;quot;===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select c.id, c.shortname,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a 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 &#039;Course link&#039;&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
LEFT JOIN (&lt;br /&gt;
  Select r.course &lt;br /&gt;
  from prefix_resource AS r&lt;br /&gt;
  WHERE LOWER( r.name) LIKE &#039;syllabus%&#039;&lt;br /&gt;
  GROUP BY r.course) AS r ON r.course = c.id&lt;br /&gt;
INNER JOIN prefix_course_categories cc ON c.category = cc.id&lt;br /&gt;
WHERE r.course IS NULL &lt;br /&gt;
%%FILTER_SUBCATEGORIES:cc.path%%&lt;br /&gt;
%%FILTER_STARTTIME:c.startdate:&amp;gt;%% %%FILTER_ENDTIME:c.enddate:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List of courses have MULTIPLE resource with a name like &amp;quot;Syllabus%&amp;quot;===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
r.course,&lt;br /&gt;
c.shortname,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;, r.id, &#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Course link&#039;&lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
INNER JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories cc ON c.category = cc.id&lt;br /&gt;
WHERE LOWER( r.name) LIKE &#039;syllabus%&#039;&lt;br /&gt;
GROUP BY r.course HAVING count(r.course)&amp;gt;1&lt;br /&gt;
%%FILTER_SUBCATEGORIES:cc.path%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Chat==&lt;br /&gt;
&lt;br /&gt;
===List the chats===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
This report gives the list of all chats with the name of the course and various ids needed for further queries.&lt;br /&gt;
&lt;br /&gt;
The column &amp;quot;participants&amp;quot; is intended to work with an (optional) secondary report. If you don&#039;t need it , you can erase it.&lt;br /&gt;
It produces a direct link to another (optional) report which will give you the current participants list to this chat.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
c.shortname,&lt;br /&gt;
c.fullname,&lt;br /&gt;
ch.course, &lt;br /&gt;
ch.id,&lt;br /&gt;
# if you intend to use a secondary report to see the participants of a specific chat&lt;br /&gt;
# create the secondary report, check the id of the report in the url, and change the 21 in next line to your participant report&#039;s id&lt;br /&gt;
CONCAT(&#039;&amp;lt;a href=&amp;quot;%%WWWROOT%%/blocks/configurable_reports/viewreport.php?id=21&amp;amp;filter_courses=&#039;, ch.id,&#039;&amp;quot;&amp;gt;Chat participants&amp;lt;/a&amp;gt;&#039;) AS &#039;Course link&#039;,&lt;br /&gt;
ch.chattime&lt;br /&gt;
&lt;br /&gt;
FROM&lt;br /&gt;
prefix_chat ch&lt;br /&gt;
INNER JOIN prefix_course c ON c.id = ch.course&lt;br /&gt;
&lt;br /&gt;
ORDER BY ch.chattime, c.fullname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===Participants to a chat (optional secondary report)===&lt;br /&gt;
This version of the participant list is intended to work with a link given in the previous report.&lt;br /&gt;
* User opens the report listing all the chats on the platform&lt;br /&gt;
* user clicks on the link from the column &amp;quot;chat participant&amp;quot; &lt;br /&gt;
* which open this report with a filter on the chatid&lt;br /&gt;
&#039;&#039;(careful, we are tweaking the coursefilter to carry instead the chatid: the displayed &amp;quot;course filter&amp;quot; will not work! but we need it)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
c.id AS courseid,&lt;br /&gt;
chu.chatid,&lt;br /&gt;
chu.userid AS &#039;chat user userid&#039;,&lt;br /&gt;
c.fullname,&lt;br /&gt;
u.username,&lt;br /&gt;
u.firstname,&lt;br /&gt;
u.lastname,&lt;br /&gt;
u.email&lt;br /&gt;
                                &lt;br /&gt;
FROM&lt;br /&gt;
prefix_user u &lt;br /&gt;
LEFT JOIN prefix_chat_users chu ON chu.userid = u.id&lt;br /&gt;
INNER JOIN prefix_course c ON c.id = chu.course&lt;br /&gt;
&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_COURSES:chu.chatid%%&lt;br /&gt;
# you can also filter by course&lt;br /&gt;
# but don&#039;t put comment line between where and filter&lt;br /&gt;
# %%FILTER_COURSES:chu.course%%&lt;br /&gt;
&lt;br /&gt;
                                &lt;br /&gt;
ORDER BY c.fullname&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List current participants to chat===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
c.id AS courseid,&lt;br /&gt;
chu.chatid,&lt;br /&gt;
chu.userid AS &#039;chat user userid&#039;,&lt;br /&gt;
c.fullname,&lt;br /&gt;
u.username,&lt;br /&gt;
u.firstname,&lt;br /&gt;
u.lastname,&lt;br /&gt;
u.email&lt;br /&gt;
                                &lt;br /&gt;
FROM&lt;br /&gt;
prefix_user u &lt;br /&gt;
LEFT JOIN prefix_chat_users chu ON chu.userid = u.id&lt;br /&gt;
INNER JOIN prefix_course c ON c.id = chu.course&lt;br /&gt;
&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_COURSES:chu.course%%&lt;br /&gt;
                                &lt;br /&gt;
ORDER BY c.fullname&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>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=ad-hoc_contributed_reports&amp;diff=138606</id>
		<title>ad-hoc contributed reports</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=ad-hoc_contributed_reports&amp;diff=138606"/>
		<updated>2020-10-01T13:05:14Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Enrolled users,which did not login into the Course, even once (Moodle 2) */&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;
===Enrolled users who have never accessed a given course (simpler version)===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SELECT username, firstname, lastname, idnumber&lt;br /&gt;
FROM prefix_user_enrolments ue&lt;br /&gt;
JOIN prefix_enrol en ON ue.enrolid = en.id&lt;br /&gt;
JOIN prefix_user uu ON uu.id = ue.userid &lt;br /&gt;
WHERE en.courseid = 123456&lt;br /&gt;
AND NOT EXISTS (&lt;br /&gt;
    SELECT * FROM prefix_user_lastaccess la&lt;br /&gt;
    WHERE la.userid = ue.userid&lt;br /&gt;
    AND la.courseid = en.courseid&lt;br /&gt;
)&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(Replace 123456 near the middle with your courseid)&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;
Compatibility: MySQL and PostgreSQL&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT DISTINCT mrc.capability &lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;1&#039; AND rc.contextid = &#039;1&#039;) AS Manager&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;2&#039; AND rc.contextid = &#039;1&#039;) AS Course_Creator&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;3&#039; AND rc.contextid = &#039;1&#039;) AS Teacher&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;4&#039; AND rc.contextid = &#039;1&#039;) AS Assistant_Teacher&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;5&#039; AND rc.contextid = &#039;1&#039;) AS Student&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;6&#039; AND rc.contextid = &#039;1&#039;) AS Guest&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;7&#039; AND rc.contextid = &#039;1&#039;) AS Authenticated&lt;br /&gt;
,(SELECT &#039;X&#039; FROM prefix_role_capabilities AS rc WHERE rc.capability = mrc.capability AND rc.roleid = &#039;8&#039; AND rc.contextid = &#039;1&#039;) AS Auth_front&lt;br /&gt;
FROM prefix_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;
Returns all assignments submitted by those with the student role that have the status of &#039;submitted&#039;, 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;
&lt;br /&gt;
&#039;&#039;&#039;This query is updated for use with Moodle 2.2 or later.  Contributed by Carly J. Born, Carleton College&#039;&#039;&#039;&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;
concat(&#039;&amp;lt;a target=&amp;quot;_new&amp;quot; href=&amp;quot;%%WWWROOT%%/mod/assign/view.php?id=&#039;, &lt;br /&gt;
cm.id, &lt;br /&gt;
&#039;&amp;amp;rownum=0&amp;amp;action=grader&amp;amp;userid=&#039;, &lt;br /&gt;
u.id,&lt;br /&gt;
&#039;&amp;quot;&amp;gt;Grade&amp;lt;/a&amp;gt;&#039;) &lt;br /&gt;
AS &amp;quot;Assignment link&amp;quot;&lt;br /&gt;
 &lt;br /&gt;
FROM prefix_assign_submission sub&lt;br /&gt;
JOIN prefix_assign a ON a.id = sub.assignment&lt;br /&gt;
JOIN prefix_user u ON u.id = sub.userid&lt;br /&gt;
JOIN prefix_course c ON c.id = a.course AND c.id = %%COURSEID%%&lt;br /&gt;
JOIN prefix_course_modules cm ON c.id = cm.course &lt;br /&gt;
JOIN prefix_context cxt ON c.id=cxt.instanceid AND cxt.contextlevel=50&lt;br /&gt;
JOIN prefix_role_assignments ra ON cxt.id = ra.contextid AND ra.roleid=5 AND ra.userid=u.id&lt;br /&gt;
 &lt;br /&gt;
WHERE cm.instance = a.id AND cm.module = 22 AND sub.status=&#039;submitted&#039;&lt;br /&gt;
 &lt;br /&gt;
ORDER BY c.fullname, a.name, u.lastname&lt;br /&gt;
&amp;lt;/code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
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;
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;
&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 truly 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;
&lt;br /&gt;
=== All Private Files 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;
Lists all files by all users in the Private Files repository, with the file path location and name in the moodledata/filedir directory structure, and time created.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
u.username, &lt;br /&gt;
f.filename, &lt;br /&gt;
CONCAT(&#039;/&#039;, LEFT(f.contenthash,2), &#039;/&#039;, MID(f.contenthash,3,2), &#039;/&#039;, f.contenthash) AS &amp;quot;Filedir_Location&amp;quot;,&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(f.timecreated),&#039;%Y-%m-%d %H:%i&#039;) AS &amp;quot;Created&amp;quot;&lt;br /&gt;
FROM prefix_files f &lt;br /&gt;
JOIN prefix_user u ON u.id = f.userid&lt;br /&gt;
WHERE f.component = &#039;user&#039; &lt;br /&gt;
AND f.filearea = &#039;private&#039; &lt;br /&gt;
AND f.filesize &amp;gt; 0 &lt;br /&gt;
ORDER BY u.username, f.filename&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;
==Competencies==&lt;br /&gt;
&lt;br /&gt;
===List of competencies from a framework and the courses including them===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT &lt;br /&gt;
f.shortname AS &#039;Framework&#039;,&lt;br /&gt;
comp.shortname AS &#039;Competency&#039;, &lt;br /&gt;
cccomp.courseid AS &#039;Course id&#039;, &lt;br /&gt;
c.fullname AS &#039;Course name&#039;,&lt;br /&gt;
c.shortname AS &#039;Course code&#039;&lt;br /&gt;
FROM &lt;br /&gt;
prefix_competency_coursecomp AS cccomp &lt;br /&gt;
INNER JOIN prefix_competency AS comp ON cccomp.competencyid = comp.id&lt;br /&gt;
INNER JOIN prefix_course AS c ON cccomp.courseid = c.id&lt;br /&gt;
INNER JOIN prefix_competency_framework AS f ON comp.competencyframeworkid = f.id&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Count the courses using each competency from frameworks===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
Unfortunately, there is not a filter by competency framework.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
f.shortname AS framework,&lt;br /&gt;
comp.shortname AS &#039;Competency&#039;,&lt;br /&gt;
COUNT(cccomp.competencyid) AS &#039;nb course&#039;&lt;br /&gt;
FROM prefix_competency AS comp&lt;br /&gt;
INNER JOIN prefix_competency_framework AS f ON comp.competencyframeworkid = f.id&lt;br /&gt;
LEFT JOIN prefix_competency_coursecomp AS cccomp ON cccomp.competencyid = comp.id&lt;br /&gt;
GROUP BY comp.id, comp.shortname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Scale details with ids ===&lt;br /&gt;
&lt;br /&gt;
Contributed by: [https://moodle.org/user/profile.php?id=88992 Randy Thornton]&lt;br /&gt;
&lt;br /&gt;
Competency import and export files include scales with id numbers. However, the management page in Grades &amp;gt; Scales does not have the scale id, nor other useful details that scales store about themselves, like who made them and when, and what context they pertain to. This simple query shows you that information.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
s.id AS Scaleid,&lt;br /&gt;
s.name AS Scale_Name,&lt;br /&gt;
s.scale AS Scale,&lt;br /&gt;
CASE  &lt;br /&gt;
  WHEN s.courseid = 0 THEN &#039;System&#039;&lt;br /&gt;
  ELSE (SELECT shortname FROM prefix_course WHERE id = s.courseid)&lt;br /&gt;
END AS Context,&lt;br /&gt;
CASE &lt;br /&gt;
  WHEN s.userid = 0 THEN &#039;System&#039;&lt;br /&gt;
  ELSE (SELECT username FROM prefix_user WHERE id = s.userid)&lt;br /&gt;
END AS User,&lt;br /&gt;
s.description,&lt;br /&gt;
DATE_FORMAT( FROM_UNIXTIME(s.timemodified), &#039;%Y-%m-%d %H:%i&#039; ) AS &#039;Modified&#039;&lt;br /&gt;
FROM prefix_scale s&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Syllabus==&lt;br /&gt;
&lt;br /&gt;
Our school simply asks teachers to drop a file (resource) on their course page&lt;br /&gt;
and rename this resource (not the file) starting with &amp;quot;syllabus&amp;quot; (case insensitive)&lt;br /&gt;
&lt;br /&gt;
===Count the number of resources whose name starts by &amp;quot;Syllabus&amp;quot;===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
Select &lt;br /&gt;
r.name As &#039;Resource name&#039;,&lt;br /&gt;
cc.name AS &#039;Category&#039;,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a href=&amp;quot;%%WWWROOT%%/pluginfile.php/&#039;, ct.id, &#039;/mod_resource/content/1/&#039;, f.filename, &#039;&amp;quot;&amp;gt;&#039;,f.filename,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Clickable filename&#039;,&lt;br /&gt;
&lt;br /&gt;
c.fullname AS &#039;Course name&#039;,&lt;br /&gt;
c.shortname AS &#039;Course shortname&#039;,&lt;br /&gt;
&lt;br /&gt;
# the date filters are connected to this &amp;quot;last modif&amp;quot; field&lt;br /&gt;
# userful to check if the syllabus has been updated this year&lt;br /&gt;
DATE_FORMAT(FROM_UNIXTIME(f.timemodified), &#039;%e %b %Y&#039;) AS &#039;last modif&#039;, &lt;br /&gt;
&lt;br /&gt;
# tell if the file is visible by the students or hidden&lt;br /&gt;
IF(cm.visible=0,&amp;quot;masqué&amp;quot;,&amp;quot;visible&amp;quot;) AS &#039;Visibility&#039;,&lt;br /&gt;
&lt;br /&gt;
# next line tries to give the real path (local path) if you want to create a zip file using an external script)&lt;br /&gt;
# notice that the path is in the column &amp;quot;contenthash&amp;quot; and NOT in the column pathhash&lt;br /&gt;
# if the contenthash starts with 9af3... then the file is stored in moodledata/filedir/9a/f3/contenthash&lt;br /&gt;
# I try to get the path to moodledata from the value of the geoip variable in the mdl_config table... maybe a bad idea&lt;br /&gt;
CONCAT(&#039;&amp;quot;&#039;,(Select left(value, length(value)-25) from prefix_config where name =&amp;quot;geoip2file&amp;quot;),&#039;/filedir/&#039;, left(f.contenthash,2), &amp;quot;/&amp;quot;,substring(f.contenthash,3,2),&#039;/&#039;, f.contenthash, &#039;&amp;quot;&#039;) AS &#039;link&#039;&lt;br /&gt;
&lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
INNER JOIN prefix_course_modules AS cm ON cm.instance = r.id&lt;br /&gt;
INNER JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
INNER JOIN prefix_context AS ct ON ct.instanceid = cm.id&lt;br /&gt;
JOIN prefix_course_categories cc ON c.category = cc.id&lt;br /&gt;
INNER JOIN prefix_files AS f ON f.contextid = ct.id AND f.mimetype IS NOT NULL AND f.component = &#039;mod_resource&#039;&lt;br /&gt;
WHERE LOWER( r.name) LIKE &#039;syllabus%&#039;&lt;br /&gt;
%%FILTER_STARTTIME:f.timemodified:&amp;gt;%% %%FILTER_ENDTIME:f.timemodified:&amp;lt;%%&lt;br /&gt;
%%FILTER_SUBCATEGORIES:cc.path%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List files which have been tagged &amp;quot;Syllabus&amp;quot;===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
Select &lt;br /&gt;
t.rawname AS &#039;rawtag&#039;,&lt;br /&gt;
c.shortname AS &#039;Cours shortname&#039;,&lt;br /&gt;
c.fullname AS &#039;Course name&#039;,&lt;br /&gt;
r.name As &#039;Resource name&#039;,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a href=&amp;quot;%%WWWROOT%%/pluginfile.php/&#039;, ti.contextid, &#039;/mod_resource/content/1/&#039;, f.filename, &#039;&amp;quot;&amp;gt;cliquez ici&amp;lt;/a&amp;gt;&#039;) AS &#039;link&#039;,&lt;br /&gt;
ti.contextid AS &#039;Instance for link&#039;,&lt;br /&gt;
f.id AS &#039;file id&#039; &lt;br /&gt;
FROM prefix_tag_instance AS ti&lt;br /&gt;
INNER JOIN prefix_tag AS t ON ti.tagid = t.id&lt;br /&gt;
INNER JOIN prefix_course_modules AS cm ON ti.itemid = cm.id&lt;br /&gt;
INNER JOIN prefix_course AS c ON cm.course = c.id&lt;br /&gt;
INNER JOIN prefix_resource AS r ON r.id = cm.instance&lt;br /&gt;
INNER JOIN prefix_files AS f ON f.contextid = ti.contextid AND f.mimetype IS NOT NULL&lt;br /&gt;
WHERE t.rawname = &#039;Syllabus&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List of courses WITHOUT a resource with a name starting by &amp;quot;syllabus&amp;quot;===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select c.id, c.shortname,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a 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 &#039;Course link&#039;&lt;br /&gt;
FROM prefix_course AS c&lt;br /&gt;
LEFT JOIN (&lt;br /&gt;
  Select r.course &lt;br /&gt;
  from prefix_resource AS r&lt;br /&gt;
  WHERE LOWER( r.name) LIKE &#039;syllabus%&#039;&lt;br /&gt;
  GROUP BY r.course) AS r ON r.course = c.id&lt;br /&gt;
INNER JOIN prefix_course_categories cc ON c.category = cc.id&lt;br /&gt;
WHERE r.course IS NULL &lt;br /&gt;
%%FILTER_SUBCATEGORIES:cc.path%%&lt;br /&gt;
%%FILTER_STARTTIME:c.startdate:&amp;gt;%% %%FILTER_ENDTIME:c.enddate:&amp;lt;%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List of courses have MULTIPLE resource with a name like &amp;quot;Syllabus%&amp;quot;===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
r.course,&lt;br /&gt;
c.shortname,&lt;br /&gt;
CONCAT(&#039;&amp;lt;a href=&amp;quot;%%WWWROOT%%/course/view.php?id=&#039;, r.id, &#039;&amp;quot;&amp;gt;&#039;,c.fullname,&#039;&amp;lt;/a&amp;gt;&#039;) AS &#039;Course link&#039;&lt;br /&gt;
FROM prefix_resource AS r&lt;br /&gt;
INNER JOIN prefix_course AS c ON c.id = r.course&lt;br /&gt;
JOIN prefix_course_categories cc ON c.category = cc.id&lt;br /&gt;
WHERE LOWER( r.name) LIKE &#039;syllabus%&#039;&lt;br /&gt;
GROUP BY r.course HAVING count(r.course)&amp;gt;1&lt;br /&gt;
%%FILTER_SUBCATEGORIES:cc.path%%&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Chat==&lt;br /&gt;
&lt;br /&gt;
===List the chats===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
This report gives the list of all chats with the name of the course and various ids needed for further queries.&lt;br /&gt;
&lt;br /&gt;
The column &amp;quot;participants&amp;quot; is intended to work with an (optional) secondary report. If you don&#039;t need it , you can erase it.&lt;br /&gt;
It produces a direct link to another (optional) report which will give you the current participants list to this chat.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
select &lt;br /&gt;
c.shortname,&lt;br /&gt;
c.fullname,&lt;br /&gt;
ch.course, &lt;br /&gt;
ch.id,&lt;br /&gt;
# if you intend to use a secondary report to see the participants of a specific chat&lt;br /&gt;
# create the secondary report, check the id of the report in the url, and change the 21 in next line to your participant report&#039;s id&lt;br /&gt;
CONCAT(&#039;&amp;lt;a href=&amp;quot;%%WWWROOT%%/blocks/configurable_reports/viewreport.php?id=21&amp;amp;filter_courses=&#039;, ch.id,&#039;&amp;quot;&amp;gt;Chat participants&amp;lt;/a&amp;gt;&#039;) AS &#039;Course link&#039;,&lt;br /&gt;
ch.chattime&lt;br /&gt;
&lt;br /&gt;
FROM&lt;br /&gt;
prefix_chat ch&lt;br /&gt;
INNER JOIN prefix_course c ON c.id = ch.course&lt;br /&gt;
&lt;br /&gt;
ORDER BY ch.chattime, c.fullname&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
===Participants to a chat (optional secondary report)===&lt;br /&gt;
This version of the participant list is intended to work with a link given in the previous report.&lt;br /&gt;
* User opens the report listing all the chats on the platform&lt;br /&gt;
* user clicks on the link from the column &amp;quot;chat participant&amp;quot; &lt;br /&gt;
* which open this report with a filter on the chatid&lt;br /&gt;
&#039;&#039;(careful, we are tweaking the coursefilter to carry instead the chatid: the displayed &amp;quot;course filter&amp;quot; will not work! but we need it)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SELECT&lt;br /&gt;
c.id AS courseid,&lt;br /&gt;
chu.chatid,&lt;br /&gt;
chu.userid AS &#039;chat user userid&#039;,&lt;br /&gt;
c.fullname,&lt;br /&gt;
u.username,&lt;br /&gt;
u.firstname,&lt;br /&gt;
u.lastname,&lt;br /&gt;
u.email&lt;br /&gt;
                                &lt;br /&gt;
FROM&lt;br /&gt;
prefix_user u &lt;br /&gt;
LEFT JOIN prefix_chat_users chu ON chu.userid = u.id&lt;br /&gt;
INNER JOIN prefix_course c ON c.id = chu.course&lt;br /&gt;
&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_COURSES:chu.chatid%%&lt;br /&gt;
# you can also filter by course&lt;br /&gt;
# but don&#039;t put comment line between where and filter&lt;br /&gt;
# %%FILTER_COURSES:chu.course%%&lt;br /&gt;
&lt;br /&gt;
                                &lt;br /&gt;
ORDER BY c.fullname&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===List current participants to chat===&lt;br /&gt;
Contributed by [https://moodle.org/user/profile.php?id=2049965 François Parlant]&lt;br /&gt;
&amp;lt;code sql&amp;gt;&lt;br /&gt;
SELECT&lt;br /&gt;
c.id AS courseid,&lt;br /&gt;
chu.chatid,&lt;br /&gt;
chu.userid AS &#039;chat user userid&#039;,&lt;br /&gt;
c.fullname,&lt;br /&gt;
u.username,&lt;br /&gt;
u.firstname,&lt;br /&gt;
u.lastname,&lt;br /&gt;
u.email&lt;br /&gt;
                                &lt;br /&gt;
FROM&lt;br /&gt;
prefix_user u &lt;br /&gt;
LEFT JOIN prefix_chat_users chu ON chu.userid = u.id&lt;br /&gt;
INNER JOIN prefix_course c ON c.id = chu.course&lt;br /&gt;
&lt;br /&gt;
WHERE 1=1&lt;br /&gt;
%%FILTER_COURSES:chu.course%%&lt;br /&gt;
                                &lt;br /&gt;
ORDER BY c.fullname&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>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Git_for_Administrators&amp;diff=138192</id>
		<title>Git for Administrators</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Git_for_Administrators&amp;diff=138192"/>
		<updated>2020-08-23T13:17:10Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Moodle branch names */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
This page describes how to maintain a copy of Moodle on your production server which can easily be upgraded using Git. If you have customisations of Moodle core code, you are advised to follow the instructions in the [[:dev:Git for developers|Git for developers guide]].&lt;br /&gt;
&lt;br /&gt;
To get the most of Git it is worth making the effort to understand its basic concepts - see the section below. It can be a bit of a steep learning curve, especially if you are used to CVS or Subversion. &lt;br /&gt;
&lt;br /&gt;
== Getting hold of Git (Windows, OSX, Linux and others) ==&lt;br /&gt;
&lt;br /&gt;
Support for Git was, up until recently, mostly confined to Linux but builds are now available for most popular operating systems:&lt;br /&gt;
&lt;br /&gt;
* List of downloads from Git site - http://git-scm.com/download&lt;br /&gt;
&lt;br /&gt;
Once you have downloaded and installed your OS relevant git installation, the git commands in this document should work with your operating system.&lt;br /&gt;
&lt;br /&gt;
== Moodle branch names ==&lt;br /&gt;
&lt;br /&gt;
Major Moodle versions each have their own branch in Git. For example, MOODLE_38_STABLE (3.8), MOODLE_39_STABLE (3.9). Development is generally done on branch &#039;master&#039;. The entire lifetime of that version will stay on that branch. Each release is designated by adding a Git &#039;tag&#039;, for example v3.9.0-beta, v3.9.0-rc1, v3.9.0.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: Even though the branch name has &#039;STABLE&#039; in it, it does not mean that the code on that branch is actually stable. Soon after the branch is made it will contain &#039;beta&#039; and &#039;release candidate&#039; versions of the new Moodle version. It&#039;s important to check that the current state of the branch meets your needs. Generally, the easiest way is to examine the current contents of version.php - substitute the branch in this url, https://github.com/moodle/moodle/blob/MOODLE_39_STABLE/version.php&lt;br /&gt;
&lt;br /&gt;
Do not use alpha, beta, release-candidates or code from the master branch for production sites. It could have significant bugs.&lt;br /&gt;
&lt;br /&gt;
== Obtaining the code from Git ==&lt;br /&gt;
&lt;br /&gt;
The command line version of Git is discussed here. Graphical clients are little more than wrappers around the command line version, so you should be able to deduce the correct parameters quite easily. &lt;br /&gt;
&lt;br /&gt;
You can find the official Moodle git repository at git://git.moodle.org/moodle.git (with an official clone at git://github.com/moodle/moodle.git). To initialize your local checkout, use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/webroot&lt;br /&gt;
$ git clone git://git.moodle.org/moodle.git                       (1)&lt;br /&gt;
$ cd moodle&lt;br /&gt;
$ git branch -a                                                   (2)&lt;br /&gt;
$ git branch --track MOODLE_39_STABLE origin/MOODLE_39_STABLE     (3)&lt;br /&gt;
$ git checkout MOODLE_39_STABLE                                   (4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The command (1) initializes the new local repository as a clone of the &#039;upstream&#039; (i.e. the remote server based) moodle.git repository. The upstream repository is called &#039;origin&#039; by default. It creates a new directory named &#039;&#039;moodle&#039;&#039;, where it downloads all the files. This operation can take a while as it is actually getting the entire history of all Moodle versions&lt;br /&gt;
* The command (2) lists all available branches.&lt;br /&gt;
* Use the command (3) to create a new local branch called MOODLE_39_STABLE and set it to track the remote branch MOODLE_39_STABLE from the upstream repository.&lt;br /&gt;
* The command (4) actually switches to the newly created local branch. &lt;br /&gt;
==Git Connection Refused Error==&lt;br /&gt;
*If connection refused, use: $ git clone https://github.com/moodle/moodle.git&lt;br /&gt;
&#039;&#039;fatal: unable to connect to git.moodle.org:&lt;br /&gt;
git.moodle.org[0: 34.210.133.53]: errno=Connection refused&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Note that Git has a huge number of options for each command and it&#039;s actually possible to do the above process with a single command (left as an exercise!!).&lt;br /&gt;
&lt;br /&gt;
==Git from behind a firewall==&lt;br /&gt;
&lt;br /&gt;
Git uses a read-only protocol that may be blocked by your firewall (port 9418). If this is a problem, you can use Github&#039;s http version &amp;lt;nowiki&amp;gt;https://github.com/moodle/moodle.git&amp;lt;/nowiki&amp;gt;. It&#039;s a bit slower, so use the Git protocol if you can.&lt;br /&gt;
&lt;br /&gt;
== Updating your installation ==&lt;br /&gt;
&lt;br /&gt;
The Moodle development team performs integration and testing of fixed bugs every Monday and Tuesday. On Wednesday you can install all patches by updating your code. Check the [http://git.moodle.org/gw?p=moodle.git;a=summary shortlog] to see if the official repository has been already updated or not.&lt;br /&gt;
&lt;br /&gt;
To update your code to the latest version (on the MOODLE_39_STABLE branch) &#039;&#039;&#039;all&#039;&#039;&#039; you have to do is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ git pull&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If this is a production site you should still consider the [[Upgrade]] instructions (e.g. take backups).&lt;br /&gt;
&lt;br /&gt;
== Installing a contributed extension from its Git repository ==&lt;br /&gt;
&lt;br /&gt;
This is one way to handle adding plugins from other Git repositories into your Moodle repository. Another way is to use Git Submodules. However, at the time of writing, this is one of Git&#039;s rougher features and should be regarded as an advanced option. &lt;br /&gt;
&lt;br /&gt;
For example, let us say we want to install the [[Certificate module]] from its Git repository into our Moodle {{Version}}.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ cd mod                                                          (1)&lt;br /&gt;
$ git clone https://github.com/markn86/moodle-mod_certificate.git certificate     (2)&lt;br /&gt;
$ cd certificate&lt;br /&gt;
$ git checkout -b MOODLE_39_STABLE origin/MOODLE_39_STABLE        (3)&lt;br /&gt;
$ git branch -d master                                            (4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The command (1) changes the current directory into the &#039;&#039;mod&#039;&#039; folder of your local Moodle clone. The command (2) creates a new subdirectory &#039;&#039;certificate&#039;&#039; and makes a local clone of vanilla Certificate repository. The command (3) creates a new local branch that will track the remote branch with a Certificate version for Moodle {{Version}}. The command (4) deletes the &#039;&#039;master&#039;&#039; that was created automatically by git-clone in (2) as we do not want it in this production checkout.&lt;br /&gt;
&lt;br /&gt;
Note: you should check first the compatibility of a module with your Moodle branch by asking directly to the Maintainer before cloning the repo or - if you want to guess it - by issuing the command below before running the command (3), in order to verify what is available among the branches:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git branch -a&lt;br /&gt;
* master&lt;br /&gt;
  remotes/origin/HEAD -&amp;gt; origin/master&lt;br /&gt;
  remotes/origin/MOODLE_20_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_21_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_22_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_23_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_24_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_25_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_26_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_27_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_28_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_29_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_30_STABLE&lt;br /&gt;
 remotes/origin/MOODLE_31_STABLE&lt;br /&gt;
  remotes/origin/master&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will avoid an error message when you issue the command (3) against a nonexistent branch, e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
§ git checkout -b MOODLE_31_STABLE origin/MOODLE_31_STABLE&lt;br /&gt;
fatal: git checkout: updating paths is incompatible with switching branches.&lt;br /&gt;
Did you intend to checkout &#039;origin/MOODLE_31_STABLE&#039; which can not be resolved as commit?&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Note: To fix above error, use: &amp;quot;git fetch origin MOODLE_31_STABLE:LOCAL_MOODLE_31_STABLE&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now it is wise to add the new directory mod/certificate/ to the list of ignored files of the main Moodle clone, otherwise a status of the main clone will keep reminding you that the new code has not been checked in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ echo /mod/certificate/ &amp;gt;&amp;gt; .git/info/exclude&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To update your Moodle installation now, you must visit both Git repositories and pull changes from upstream.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ git pull&lt;br /&gt;
$ cd mod/certificate&lt;br /&gt;
$ git pull&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Writing a shell script with these lines in the root of Moodle installation is a very good idea. Otherwise it is easy to forget what Git repositories are there within the main Moodle repository.&lt;br /&gt;
&lt;br /&gt;
== Installing and maintaining contributed extensions using Git submodules ==&lt;br /&gt;
&lt;br /&gt;
As it was said in the previous section, this is for advanced users only.&lt;br /&gt;
Therefore it is necessary, that you have some experience with Git and its commands.&lt;br /&gt;
A step-by-step explanation will be provided, but in order to follow these steps it is helpful to understand, what these commands do.&lt;br /&gt;
&lt;br /&gt;
Advanced options and commands can be found at [[https://git-scm.com/book/en/v2/Git-Tools-Submodules|the Git book]].&lt;br /&gt;
If you have any questions about Git submodules, please visit the site above first.&lt;br /&gt;
&lt;br /&gt;
=== Installing a new extension into an existing Moodle ===&lt;br /&gt;
&lt;br /&gt;
As an example we use the [[Certificate module]] from the previous section.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git submodule add https://github.com/markn86/moodle-mod_certificate.git mod/certificate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, that Git is reporting two new files in the repository:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch MOODLE_29_STABLE&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	new file:   .gitmodules&lt;br /&gt;
#	new file:   mod/certificate&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file &#039;&#039;&#039;.gitmodules&#039;&#039;&#039; contains the local path and url of all your submodules.&lt;br /&gt;
It has to be committed, if you intend to clone the repository later (see the page [[Moodle development environment with Git submodules]]).&lt;br /&gt;
Before commiting, make sure to check the configuration of the plugin&#039;s Git repository, since the automatically generated settings may be not sufficient.&lt;br /&gt;
For future updates it is helpful, to track the remote branch, which corresponds to the Moodle version of your repository.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd mod/certificate&lt;br /&gt;
$ git branch -avv&lt;br /&gt;
* master                          345f5b1 [origin/master] Replaced deprecated function&lt;br /&gt;
  remotes/origin/HEAD             -&amp;gt; origin/master&lt;br /&gt;
  remotes/origin/MOODLE_20_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_21_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_22_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_23_STABLE fe047de Check that the function exists rather than relying on the Moodle version&lt;br /&gt;
  remotes/origin/MOODLE_24_STABLE 1051f7d CONTRIB-4892 Fixed the email to others functionality&lt;br /&gt;
  remotes/origin/MOODLE_25_STABLE cdb221a CONTRIB-4946: Removed character from language file breaking AMOS&lt;br /&gt;
  remotes/origin/MOODLE_26_STABLE 696802a Increased version&lt;br /&gt;
  remotes/origin/MOODLE_27_STABLE d3c0379 Increased version&lt;br /&gt;
  remotes/origin/MOODLE_28_STABLE fa8df83 Increased version&lt;br /&gt;
  remotes/origin/MOODLE_29_STABLE 3f03740 Replaced deprecated function&lt;br /&gt;
  remotes/origin/master           345f5b1 Replaced deprecated function&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git created the branch &#039;&#039;&#039;master&#039;&#039;&#039; which tracks &#039;&#039;&#039;origin/master&#039;&#039;&#039; automatically, because the remote repository has checked out &#039;&#039;&#039;master&#039;&#039;&#039;.&lt;br /&gt;
Therefore, create a new branch, which tracks the appropriate remote branch.&lt;br /&gt;
Of course, this is only possible, if the remote repository offers those branches. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git checkout -b MOODLE_29_STABLE origin/MOODLE_29_STABLE&lt;br /&gt;
Branch MOODLE_29_STABLE set up to track remote branch MOODLE_29_STABLE from origin.&lt;br /&gt;
Switched to a new branch &#039;MOODLE_29_STABLE&#039;&lt;br /&gt;
$ git branch -D master&lt;br /&gt;
Deleted branch master (was 345f5b1).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It is not necessary to delete the &#039;&#039;&#039;master&#039;&#039;&#039; branch, but it&#039;s useless to keep it.&lt;br /&gt;
In fact, these settings don&#039;t need to be touched afterwards.&lt;br /&gt;
&lt;br /&gt;
The final step is to commit the changes to the main repository.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git commit -a -m &amp;quot;New extension mod_certificate installed&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has to be ensured, that the commit includes only the changes for the new Git submodule (since &#039;&#039;&#039;-a&#039;&#039;&#039; commits all non-staged changes).&lt;br /&gt;
&lt;br /&gt;
=== Maintaining Git submodules ===&lt;br /&gt;
&lt;br /&gt;
Maintaining a set of submodules is extremely easy.&lt;br /&gt;
Consider a Moodle repository with several submodules installed.&lt;br /&gt;
Keep in mind, that the extension &#039;&#039;&#039;mod_mylittleextension&#039;&#039;&#039; is a fake plugin, created for a test scenario in this example.&lt;br /&gt;
It is not an official Moodle module. For updating all your submodules at once, type in:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git submodule foreach git pull&lt;br /&gt;
Entering &#039;block/coursefeedback&#039;&lt;br /&gt;
Already up-to-date.&lt;br /&gt;
Entering &#039;mod/certificate&#039;&lt;br /&gt;
Already up-to-date.&lt;br /&gt;
Entering &#039;mod/mylittleextension&#039;&lt;br /&gt;
remote: Counting objects: 6, done.&lt;br /&gt;
remote: Compressing objects: 100% (4/4), done.&lt;br /&gt;
remote: Total 4 (delta 0), reused 0 (delta 0)&lt;br /&gt;
Unpacking objects: 100% (4/4), done.&lt;br /&gt;
From /local/repositories/mle&lt;br /&gt;
   89d9eae..64c122d  master     -&amp;gt; origin/master&lt;br /&gt;
Updating 89d9eae..64c122d&lt;br /&gt;
Fast-forward&lt;br /&gt;
 index.html  |    9 +++++++++&lt;br /&gt;
 version.php |    6 +++---&lt;br /&gt;
 2 files changed, 12 insertions(+), 3 deletions(-)&lt;br /&gt;
 create mode 100644 index.html&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch MOODLE_29_STABLE&lt;br /&gt;
# Changes not staged for commit:&lt;br /&gt;
#   (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)&lt;br /&gt;
#   (use &amp;quot;git checkout -- &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   mod/mylittleextension (new commits)&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The command &#039;&#039;&#039;git submodule foreach [another command]&#039;&#039;&#039; walks through all submodule repositiories and executes what is specified by &#039;&#039;&#039;[another command]&#039;&#039;&#039;.&lt;br /&gt;
In this case it is &#039;&#039;&#039;git pull&#039;&#039;&#039;.&lt;br /&gt;
Therefore the module mylittleextension was updated and the main repository isn&#039;t clean anymore until changes are committed:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git commit -a -m &amp;quot;Plugin updates&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maintaining plugins with Git submodules has also another application than simplifying the update process.&lt;br /&gt;
In a greater scale it can be used to maintain a Moodle project, where multiple developers need to have an exact copy of your moodle without organizing external plugins manually.&lt;br /&gt;
You can read more about this topic at the page [[Moodle development environment with Git submodules]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation using Git]]&lt;br /&gt;
* [[Git for Mac]]&lt;br /&gt;
* [[:dev:Moodle versions]]&lt;br /&gt;
* For fixing a Tracker Issue (MDL) / Forking Moodle / CONTRIButing code [[:dev:User:Sam_Hemelryk/My_Moodle_Git_workflow|User:Sam_Hemelryk/My_Moodle_Git_workflow]]&lt;br /&gt;
* [[Moodle_Production_Server_with_GIT|Case study Git + Moodle from Technical University Berlin]]&lt;br /&gt;
&lt;br /&gt;
; Moodle forum discussions&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=255175 Github and Moodle deployment for production]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=168094 GIT help needed]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=231046 Clear git guide for Admins (not developers)]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=393756 Best way to use Git]&lt;br /&gt;
&lt;br /&gt;
; External resources &lt;br /&gt;
* [http://thamblings.blogspot.com.au/2013/07/upgrading-moodle-from-git.html Deploying Moodle from git - Blog post from a production experience]&lt;br /&gt;
* [http://gitref.org/ Git Reference]&lt;br /&gt;
* [http://progit.org/book/ Pro Git book]&lt;br /&gt;
&lt;br /&gt;
[[ja:管理者用Git]]&lt;br /&gt;
[[fr:Git_pour_administrateurs]]&lt;br /&gt;
[[es:Git para Administradores]]&lt;br /&gt;
[[en:Git für Administratoren]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Git_for_Administrators&amp;diff=138191</id>
		<title>Git for Administrators</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Git_for_Administrators&amp;diff=138191"/>
		<updated>2020-08-23T09:03:36Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Moodle branch names */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
This page describes how to maintain a copy of Moodle on your production server which can easily be upgraded using Git. If you have customisations of Moodle core code, you are advised to follow the instructions in the [[:dev:Git for developers|Git for developers guide]].&lt;br /&gt;
&lt;br /&gt;
To get the most of Git it is worth making the effort to understand its basic concepts - see the section below. It can be a bit of a steep learning curve, especially if you are used to CVS or Subversion. &lt;br /&gt;
&lt;br /&gt;
== Getting hold of Git (Windows, OSX, Linux and others) ==&lt;br /&gt;
&lt;br /&gt;
Support for Git was, up until recently, mostly confined to Linux but builds are now available for most popular operating systems:&lt;br /&gt;
&lt;br /&gt;
* List of downloads from Git site - http://git-scm.com/download&lt;br /&gt;
&lt;br /&gt;
Once you have downloaded and installed your OS relevant git installation, the git commands in this document should work with your operating system.&lt;br /&gt;
&lt;br /&gt;
== Moodle branch names ==&lt;br /&gt;
&lt;br /&gt;
Major Moodle versions each have their own branch in Git. For example, MOODLE_38_STABLE (3.8), MOODLE_39_STABLE (3.9). Development is generally done on branch &#039;master&#039;. The entire lifetime of that version will stay on that branch. Each release is designated by adding a Git &#039;tag&#039;, for example v3.9.0-beta, v3.9.0-rc1, v3.9.0.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: Even though the branch name has &#039;STABLE&#039; in it, it does not mean that the code on that branch is actually stable. Soon after the branch is made it will contain &#039;beta&#039; and &#039;release candidate&#039; versions of the new Moodle version. It&#039;s important to check that the current state of the branch meets your needs. Generally, the easiest way is to examine the current contents of version.php.&lt;br /&gt;
&lt;br /&gt;
Do not use alpha, beta, release-candidates or code from the master branch for production sites. It could have significant bugs.&lt;br /&gt;
&lt;br /&gt;
== Obtaining the code from Git ==&lt;br /&gt;
&lt;br /&gt;
The command line version of Git is discussed here. Graphical clients are little more than wrappers around the command line version, so you should be able to deduce the correct parameters quite easily. &lt;br /&gt;
&lt;br /&gt;
You can find the official Moodle git repository at git://git.moodle.org/moodle.git (with an official clone at git://github.com/moodle/moodle.git). To initialize your local checkout, use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/webroot&lt;br /&gt;
$ git clone git://git.moodle.org/moodle.git                       (1)&lt;br /&gt;
$ cd moodle&lt;br /&gt;
$ git branch -a                                                   (2)&lt;br /&gt;
$ git branch --track MOODLE_39_STABLE origin/MOODLE_39_STABLE     (3)&lt;br /&gt;
$ git checkout MOODLE_39_STABLE                                   (4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The command (1) initializes the new local repository as a clone of the &#039;upstream&#039; (i.e. the remote server based) moodle.git repository. The upstream repository is called &#039;origin&#039; by default. It creates a new directory named &#039;&#039;moodle&#039;&#039;, where it downloads all the files. This operation can take a while as it is actually getting the entire history of all Moodle versions&lt;br /&gt;
* The command (2) lists all available branches.&lt;br /&gt;
* Use the command (3) to create a new local branch called MOODLE_39_STABLE and set it to track the remote branch MOODLE_39_STABLE from the upstream repository.&lt;br /&gt;
* The command (4) actually switches to the newly created local branch. &lt;br /&gt;
==Git Connection Refused Error==&lt;br /&gt;
*If connection refused, use: $ git clone https://github.com/moodle/moodle.git&lt;br /&gt;
&#039;&#039;fatal: unable to connect to git.moodle.org:&lt;br /&gt;
git.moodle.org[0: 34.210.133.53]: errno=Connection refused&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Note that Git has a huge number of options for each command and it&#039;s actually possible to do the above process with a single command (left as an exercise!!).&lt;br /&gt;
&lt;br /&gt;
==Git from behind a firewall==&lt;br /&gt;
&lt;br /&gt;
Git uses a read-only protocol that may be blocked by your firewall (port 9418). If this is a problem, you can use Github&#039;s http version &amp;lt;nowiki&amp;gt;https://github.com/moodle/moodle.git&amp;lt;/nowiki&amp;gt;. It&#039;s a bit slower, so use the Git protocol if you can.&lt;br /&gt;
&lt;br /&gt;
== Updating your installation ==&lt;br /&gt;
&lt;br /&gt;
The Moodle development team performs integration and testing of fixed bugs every Monday and Tuesday. On Wednesday you can install all patches by updating your code. Check the [http://git.moodle.org/gw?p=moodle.git;a=summary shortlog] to see if the official repository has been already updated or not.&lt;br /&gt;
&lt;br /&gt;
To update your code to the latest version (on the MOODLE_39_STABLE branch) &#039;&#039;&#039;all&#039;&#039;&#039; you have to do is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ git pull&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If this is a production site you should still consider the [[Upgrade]] instructions (e.g. take backups).&lt;br /&gt;
&lt;br /&gt;
== Installing a contributed extension from its Git repository ==&lt;br /&gt;
&lt;br /&gt;
This is one way to handle adding plugins from other Git repositories into your Moodle repository. Another way is to use Git Submodules. However, at the time of writing, this is one of Git&#039;s rougher features and should be regarded as an advanced option. &lt;br /&gt;
&lt;br /&gt;
For example, let us say we want to install the [[Certificate module]] from its Git repository into our Moodle {{Version}}.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ cd mod                                                          (1)&lt;br /&gt;
$ git clone https://github.com/markn86/moodle-mod_certificate.git certificate     (2)&lt;br /&gt;
$ cd certificate&lt;br /&gt;
$ git checkout -b MOODLE_39_STABLE origin/MOODLE_39_STABLE        (3)&lt;br /&gt;
$ git branch -d master                                            (4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The command (1) changes the current directory into the &#039;&#039;mod&#039;&#039; folder of your local Moodle clone. The command (2) creates a new subdirectory &#039;&#039;certificate&#039;&#039; and makes a local clone of vanilla Certificate repository. The command (3) creates a new local branch that will track the remote branch with a Certificate version for Moodle {{Version}}. The command (4) deletes the &#039;&#039;master&#039;&#039; that was created automatically by git-clone in (2) as we do not want it in this production checkout.&lt;br /&gt;
&lt;br /&gt;
Note: you should check first the compatibility of a module with your Moodle branch by asking directly to the Maintainer before cloning the repo or - if you want to guess it - by issuing the command below before running the command (3), in order to verify what is available among the branches:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git branch -a&lt;br /&gt;
* master&lt;br /&gt;
  remotes/origin/HEAD -&amp;gt; origin/master&lt;br /&gt;
  remotes/origin/MOODLE_20_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_21_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_22_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_23_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_24_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_25_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_26_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_27_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_28_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_29_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_30_STABLE&lt;br /&gt;
 remotes/origin/MOODLE_31_STABLE&lt;br /&gt;
  remotes/origin/master&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will avoid an error message when you issue the command (3) against a nonexistent branch, e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
§ git checkout -b MOODLE_31_STABLE origin/MOODLE_31_STABLE&lt;br /&gt;
fatal: git checkout: updating paths is incompatible with switching branches.&lt;br /&gt;
Did you intend to checkout &#039;origin/MOODLE_31_STABLE&#039; which can not be resolved as commit?&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Note: To fix above error, use: &amp;quot;git fetch origin MOODLE_31_STABLE:LOCAL_MOODLE_31_STABLE&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now it is wise to add the new directory mod/certificate/ to the list of ignored files of the main Moodle clone, otherwise a status of the main clone will keep reminding you that the new code has not been checked in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ echo /mod/certificate/ &amp;gt;&amp;gt; .git/info/exclude&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To update your Moodle installation now, you must visit both Git repositories and pull changes from upstream.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ git pull&lt;br /&gt;
$ cd mod/certificate&lt;br /&gt;
$ git pull&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Writing a shell script with these lines in the root of Moodle installation is a very good idea. Otherwise it is easy to forget what Git repositories are there within the main Moodle repository.&lt;br /&gt;
&lt;br /&gt;
== Installing and maintaining contributed extensions using Git submodules ==&lt;br /&gt;
&lt;br /&gt;
As it was said in the previous section, this is for advanced users only.&lt;br /&gt;
Therefore it is necessary, that you have some experience with Git and its commands.&lt;br /&gt;
A step-by-step explanation will be provided, but in order to follow these steps it is helpful to understand, what these commands do.&lt;br /&gt;
&lt;br /&gt;
Advanced options and commands can be found at [[https://git-scm.com/book/en/v2/Git-Tools-Submodules|the Git book]].&lt;br /&gt;
If you have any questions about Git submodules, please visit the site above first.&lt;br /&gt;
&lt;br /&gt;
=== Installing a new extension into an existing Moodle ===&lt;br /&gt;
&lt;br /&gt;
As an example we use the [[Certificate module]] from the previous section.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git submodule add https://github.com/markn86/moodle-mod_certificate.git mod/certificate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, that Git is reporting two new files in the repository:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch MOODLE_29_STABLE&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	new file:   .gitmodules&lt;br /&gt;
#	new file:   mod/certificate&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file &#039;&#039;&#039;.gitmodules&#039;&#039;&#039; contains the local path and url of all your submodules.&lt;br /&gt;
It has to be committed, if you intend to clone the repository later (see the page [[Moodle development environment with Git submodules]]).&lt;br /&gt;
Before commiting, make sure to check the configuration of the plugin&#039;s Git repository, since the automatically generated settings may be not sufficient.&lt;br /&gt;
For future updates it is helpful, to track the remote branch, which corresponds to the Moodle version of your repository.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd mod/certificate&lt;br /&gt;
$ git branch -avv&lt;br /&gt;
* master                          345f5b1 [origin/master] Replaced deprecated function&lt;br /&gt;
  remotes/origin/HEAD             -&amp;gt; origin/master&lt;br /&gt;
  remotes/origin/MOODLE_20_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_21_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_22_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_23_STABLE fe047de Check that the function exists rather than relying on the Moodle version&lt;br /&gt;
  remotes/origin/MOODLE_24_STABLE 1051f7d CONTRIB-4892 Fixed the email to others functionality&lt;br /&gt;
  remotes/origin/MOODLE_25_STABLE cdb221a CONTRIB-4946: Removed character from language file breaking AMOS&lt;br /&gt;
  remotes/origin/MOODLE_26_STABLE 696802a Increased version&lt;br /&gt;
  remotes/origin/MOODLE_27_STABLE d3c0379 Increased version&lt;br /&gt;
  remotes/origin/MOODLE_28_STABLE fa8df83 Increased version&lt;br /&gt;
  remotes/origin/MOODLE_29_STABLE 3f03740 Replaced deprecated function&lt;br /&gt;
  remotes/origin/master           345f5b1 Replaced deprecated function&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git created the branch &#039;&#039;&#039;master&#039;&#039;&#039; which tracks &#039;&#039;&#039;origin/master&#039;&#039;&#039; automatically, because the remote repository has checked out &#039;&#039;&#039;master&#039;&#039;&#039;.&lt;br /&gt;
Therefore, create a new branch, which tracks the appropriate remote branch.&lt;br /&gt;
Of course, this is only possible, if the remote repository offers those branches. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git checkout -b MOODLE_29_STABLE origin/MOODLE_29_STABLE&lt;br /&gt;
Branch MOODLE_29_STABLE set up to track remote branch MOODLE_29_STABLE from origin.&lt;br /&gt;
Switched to a new branch &#039;MOODLE_29_STABLE&#039;&lt;br /&gt;
$ git branch -D master&lt;br /&gt;
Deleted branch master (was 345f5b1).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It is not necessary to delete the &#039;&#039;&#039;master&#039;&#039;&#039; branch, but it&#039;s useless to keep it.&lt;br /&gt;
In fact, these settings don&#039;t need to be touched afterwards.&lt;br /&gt;
&lt;br /&gt;
The final step is to commit the changes to the main repository.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git commit -a -m &amp;quot;New extension mod_certificate installed&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has to be ensured, that the commit includes only the changes for the new Git submodule (since &#039;&#039;&#039;-a&#039;&#039;&#039; commits all non-staged changes).&lt;br /&gt;
&lt;br /&gt;
=== Maintaining Git submodules ===&lt;br /&gt;
&lt;br /&gt;
Maintaining a set of submodules is extremely easy.&lt;br /&gt;
Consider a Moodle repository with several submodules installed.&lt;br /&gt;
Keep in mind, that the extension &#039;&#039;&#039;mod_mylittleextension&#039;&#039;&#039; is a fake plugin, created for a test scenario in this example.&lt;br /&gt;
It is not an official Moodle module. For updating all your submodules at once, type in:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git submodule foreach git pull&lt;br /&gt;
Entering &#039;block/coursefeedback&#039;&lt;br /&gt;
Already up-to-date.&lt;br /&gt;
Entering &#039;mod/certificate&#039;&lt;br /&gt;
Already up-to-date.&lt;br /&gt;
Entering &#039;mod/mylittleextension&#039;&lt;br /&gt;
remote: Counting objects: 6, done.&lt;br /&gt;
remote: Compressing objects: 100% (4/4), done.&lt;br /&gt;
remote: Total 4 (delta 0), reused 0 (delta 0)&lt;br /&gt;
Unpacking objects: 100% (4/4), done.&lt;br /&gt;
From /local/repositories/mle&lt;br /&gt;
   89d9eae..64c122d  master     -&amp;gt; origin/master&lt;br /&gt;
Updating 89d9eae..64c122d&lt;br /&gt;
Fast-forward&lt;br /&gt;
 index.html  |    9 +++++++++&lt;br /&gt;
 version.php |    6 +++---&lt;br /&gt;
 2 files changed, 12 insertions(+), 3 deletions(-)&lt;br /&gt;
 create mode 100644 index.html&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch MOODLE_29_STABLE&lt;br /&gt;
# Changes not staged for commit:&lt;br /&gt;
#   (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)&lt;br /&gt;
#   (use &amp;quot;git checkout -- &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   mod/mylittleextension (new commits)&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The command &#039;&#039;&#039;git submodule foreach [another command]&#039;&#039;&#039; walks through all submodule repositiories and executes what is specified by &#039;&#039;&#039;[another command]&#039;&#039;&#039;.&lt;br /&gt;
In this case it is &#039;&#039;&#039;git pull&#039;&#039;&#039;.&lt;br /&gt;
Therefore the module mylittleextension was updated and the main repository isn&#039;t clean anymore until changes are committed:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git commit -a -m &amp;quot;Plugin updates&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maintaining plugins with Git submodules has also another application than simplifying the update process.&lt;br /&gt;
In a greater scale it can be used to maintain a Moodle project, where multiple developers need to have an exact copy of your moodle without organizing external plugins manually.&lt;br /&gt;
You can read more about this topic at the page [[Moodle development environment with Git submodules]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation using Git]]&lt;br /&gt;
* [[Git for Mac]]&lt;br /&gt;
* [[:dev:Moodle versions]]&lt;br /&gt;
* For fixing a Tracker Issue (MDL) / Forking Moodle / CONTRIButing code [[:dev:User:Sam_Hemelryk/My_Moodle_Git_workflow|User:Sam_Hemelryk/My_Moodle_Git_workflow]]&lt;br /&gt;
* [[Moodle_Production_Server_with_GIT|Case study Git + Moodle from Technical University Berlin]]&lt;br /&gt;
&lt;br /&gt;
; Moodle forum discussions&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=255175 Github and Moodle deployment for production]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=168094 GIT help needed]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=231046 Clear git guide for Admins (not developers)]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=393756 Best way to use Git]&lt;br /&gt;
&lt;br /&gt;
; External resources &lt;br /&gt;
* [http://thamblings.blogspot.com.au/2013/07/upgrading-moodle-from-git.html Deploying Moodle from git - Blog post from a production experience]&lt;br /&gt;
* [http://gitref.org/ Git Reference]&lt;br /&gt;
* [http://progit.org/book/ Pro Git book]&lt;br /&gt;
&lt;br /&gt;
[[ja:管理者用Git]]&lt;br /&gt;
[[fr:Git_pour_administrateurs]]&lt;br /&gt;
[[es:Git para Administradores]]&lt;br /&gt;
[[en:Git für Administratoren]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Git_for_Administrators&amp;diff=138190</id>
		<title>Git for Administrators</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Git_for_Administrators&amp;diff=138190"/>
		<updated>2020-08-23T08:07:01Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Getting hold of Git (Windows, OSX, Linux and others) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
This page describes how to maintain a copy of Moodle on your production server which can easily be upgraded using Git. If you have customisations of Moodle core code, you are advised to follow the instructions in the [[:dev:Git for developers|Git for developers guide]].&lt;br /&gt;
&lt;br /&gt;
To get the most of Git it is worth making the effort to understand its basic concepts - see the section below. It can be a bit of a steep learning curve, especially if you are used to CVS or Subversion. &lt;br /&gt;
&lt;br /&gt;
== Getting hold of Git (Windows, OSX, Linux and others) ==&lt;br /&gt;
&lt;br /&gt;
Support for Git was, up until recently, mostly confined to Linux but builds are now available for most popular operating systems:&lt;br /&gt;
&lt;br /&gt;
* List of downloads from Git site - http://git-scm.com/download&lt;br /&gt;
&lt;br /&gt;
Once you have downloaded and installed your OS relevant git installation, the git commands in this document should work with your operating system.&lt;br /&gt;
&lt;br /&gt;
== Moodle branch names ==&lt;br /&gt;
&lt;br /&gt;
Major Moodle versions each have their own branch in Git. For example, MOODLE_38_STABLE (3.8), MOODLE_39_STABLE (3.9). Development is generally done on branch &#039;master&#039;. The entire lifetime of that version will stay on that branch. Each release is designated by adding a Git &#039;tag&#039;, for example v3.9.0-beta, v3.9.0-rc1, v3.9.0.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: Even though the branch name has &#039;STABLE&#039; in it, it does not mean that the code on that branch is actually stable. Soon after the branch is made it will contain &#039;beta&#039; and &#039;release candidate&#039; versions of the new Moodle version. It&#039;s important to check that the current state of the branch meets your needs. Generally, the easiest way is to examine the current contents of version.php.&lt;br /&gt;
&lt;br /&gt;
== Obtaining the code from Git ==&lt;br /&gt;
&lt;br /&gt;
The command line version of Git is discussed here. Graphical clients are little more than wrappers around the command line version, so you should be able to deduce the correct parameters quite easily. &lt;br /&gt;
&lt;br /&gt;
You can find the official Moodle git repository at git://git.moodle.org/moodle.git (with an official clone at git://github.com/moodle/moodle.git). To initialize your local checkout, use&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/webroot&lt;br /&gt;
$ git clone git://git.moodle.org/moodle.git                       (1)&lt;br /&gt;
$ cd moodle&lt;br /&gt;
$ git branch -a                                                   (2)&lt;br /&gt;
$ git branch --track MOODLE_39_STABLE origin/MOODLE_39_STABLE     (3)&lt;br /&gt;
$ git checkout MOODLE_39_STABLE                                   (4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* The command (1) initializes the new local repository as a clone of the &#039;upstream&#039; (i.e. the remote server based) moodle.git repository. The upstream repository is called &#039;origin&#039; by default. It creates a new directory named &#039;&#039;moodle&#039;&#039;, where it downloads all the files. This operation can take a while as it is actually getting the entire history of all Moodle versions&lt;br /&gt;
* The command (2) lists all available branches.&lt;br /&gt;
* Use the command (3) to create a new local branch called MOODLE_39_STABLE and set it to track the remote branch MOODLE_39_STABLE from the upstream repository.&lt;br /&gt;
* The command (4) actually switches to the newly created local branch. &lt;br /&gt;
==Git Connection Refused Error==&lt;br /&gt;
*If connection refused, use: $ git clone https://github.com/moodle/moodle.git&lt;br /&gt;
&#039;&#039;fatal: unable to connect to git.moodle.org:&lt;br /&gt;
git.moodle.org[0: 34.210.133.53]: errno=Connection refused&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Note that Git has a huge number of options for each command and it&#039;s actually possible to do the above process with a single command (left as an exercise!!).&lt;br /&gt;
&lt;br /&gt;
==Git from behind a firewall==&lt;br /&gt;
&lt;br /&gt;
Git uses a read-only protocol that may be blocked by your firewall (port 9418). If this is a problem, you can use Github&#039;s http version &amp;lt;nowiki&amp;gt;https://github.com/moodle/moodle.git&amp;lt;/nowiki&amp;gt;. It&#039;s a bit slower, so use the Git protocol if you can.&lt;br /&gt;
&lt;br /&gt;
== Updating your installation ==&lt;br /&gt;
&lt;br /&gt;
The Moodle development team performs integration and testing of fixed bugs every Monday and Tuesday. On Wednesday you can install all patches by updating your code. Check the [http://git.moodle.org/gw?p=moodle.git;a=summary shortlog] to see if the official repository has been already updated or not.&lt;br /&gt;
&lt;br /&gt;
To update your code to the latest version (on the MOODLE_39_STABLE branch) &#039;&#039;&#039;all&#039;&#039;&#039; you have to do is:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ git pull&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If this is a production site you should still consider the [[Upgrade]] instructions (e.g. take backups).&lt;br /&gt;
&lt;br /&gt;
== Installing a contributed extension from its Git repository ==&lt;br /&gt;
&lt;br /&gt;
This is one way to handle adding plugins from other Git repositories into your Moodle repository. Another way is to use Git Submodules. However, at the time of writing, this is one of Git&#039;s rougher features and should be regarded as an advanced option. &lt;br /&gt;
&lt;br /&gt;
For example, let us say we want to install the [[Certificate module]] from its Git repository into our Moodle {{Version}}.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ cd mod                                                          (1)&lt;br /&gt;
$ git clone https://github.com/markn86/moodle-mod_certificate.git certificate     (2)&lt;br /&gt;
$ cd certificate&lt;br /&gt;
$ git checkout -b MOODLE_39_STABLE origin/MOODLE_39_STABLE        (3)&lt;br /&gt;
$ git branch -d master                                            (4)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The command (1) changes the current directory into the &#039;&#039;mod&#039;&#039; folder of your local Moodle clone. The command (2) creates a new subdirectory &#039;&#039;certificate&#039;&#039; and makes a local clone of vanilla Certificate repository. The command (3) creates a new local branch that will track the remote branch with a Certificate version for Moodle {{Version}}. The command (4) deletes the &#039;&#039;master&#039;&#039; that was created automatically by git-clone in (2) as we do not want it in this production checkout.&lt;br /&gt;
&lt;br /&gt;
Note: you should check first the compatibility of a module with your Moodle branch by asking directly to the Maintainer before cloning the repo or - if you want to guess it - by issuing the command below before running the command (3), in order to verify what is available among the branches:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git branch -a&lt;br /&gt;
* master&lt;br /&gt;
  remotes/origin/HEAD -&amp;gt; origin/master&lt;br /&gt;
  remotes/origin/MOODLE_20_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_21_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_22_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_23_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_24_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_25_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_26_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_27_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_28_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_29_STABLE&lt;br /&gt;
  remotes/origin/MOODLE_30_STABLE&lt;br /&gt;
 remotes/origin/MOODLE_31_STABLE&lt;br /&gt;
  remotes/origin/master&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
This will avoid an error message when you issue the command (3) against a nonexistent branch, e.g.:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
§ git checkout -b MOODLE_31_STABLE origin/MOODLE_31_STABLE&lt;br /&gt;
fatal: git checkout: updating paths is incompatible with switching branches.&lt;br /&gt;
Did you intend to checkout &#039;origin/MOODLE_31_STABLE&#039; which can not be resolved as commit?&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 Note: To fix above error, use: &amp;quot;git fetch origin MOODLE_31_STABLE:LOCAL_MOODLE_31_STABLE&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Now it is wise to add the new directory mod/certificate/ to the list of ignored files of the main Moodle clone, otherwise a status of the main clone will keep reminding you that the new code has not been checked in.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ echo /mod/certificate/ &amp;gt;&amp;gt; .git/info/exclude&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
To update your Moodle installation now, you must visit both Git repositories and pull changes from upstream.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle/&lt;br /&gt;
$ git pull&lt;br /&gt;
$ cd mod/certificate&lt;br /&gt;
$ git pull&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Writing a shell script with these lines in the root of Moodle installation is a very good idea. Otherwise it is easy to forget what Git repositories are there within the main Moodle repository.&lt;br /&gt;
&lt;br /&gt;
== Installing and maintaining contributed extensions using Git submodules ==&lt;br /&gt;
&lt;br /&gt;
As it was said in the previous section, this is for advanced users only.&lt;br /&gt;
Therefore it is necessary, that you have some experience with Git and its commands.&lt;br /&gt;
A step-by-step explanation will be provided, but in order to follow these steps it is helpful to understand, what these commands do.&lt;br /&gt;
&lt;br /&gt;
Advanced options and commands can be found at [[https://git-scm.com/book/en/v2/Git-Tools-Submodules|the Git book]].&lt;br /&gt;
If you have any questions about Git submodules, please visit the site above first.&lt;br /&gt;
&lt;br /&gt;
=== Installing a new extension into an existing Moodle ===&lt;br /&gt;
&lt;br /&gt;
As an example we use the [[Certificate module]] from the previous section.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git submodule add https://github.com/markn86/moodle-mod_certificate.git mod/certificate&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, that Git is reporting two new files in the repository:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch MOODLE_29_STABLE&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	new file:   .gitmodules&lt;br /&gt;
#	new file:   mod/certificate&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The file &#039;&#039;&#039;.gitmodules&#039;&#039;&#039; contains the local path and url of all your submodules.&lt;br /&gt;
It has to be committed, if you intend to clone the repository later (see the page [[Moodle development environment with Git submodules]]).&lt;br /&gt;
Before commiting, make sure to check the configuration of the plugin&#039;s Git repository, since the automatically generated settings may be not sufficient.&lt;br /&gt;
For future updates it is helpful, to track the remote branch, which corresponds to the Moodle version of your repository.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd mod/certificate&lt;br /&gt;
$ git branch -avv&lt;br /&gt;
* master                          345f5b1 [origin/master] Replaced deprecated function&lt;br /&gt;
  remotes/origin/HEAD             -&amp;gt; origin/master&lt;br /&gt;
  remotes/origin/MOODLE_20_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_21_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_22_STABLE 1aa1040 Added option to print &#039;grade category&#039; grade&lt;br /&gt;
  remotes/origin/MOODLE_23_STABLE fe047de Check that the function exists rather than relying on the Moodle version&lt;br /&gt;
  remotes/origin/MOODLE_24_STABLE 1051f7d CONTRIB-4892 Fixed the email to others functionality&lt;br /&gt;
  remotes/origin/MOODLE_25_STABLE cdb221a CONTRIB-4946: Removed character from language file breaking AMOS&lt;br /&gt;
  remotes/origin/MOODLE_26_STABLE 696802a Increased version&lt;br /&gt;
  remotes/origin/MOODLE_27_STABLE d3c0379 Increased version&lt;br /&gt;
  remotes/origin/MOODLE_28_STABLE fa8df83 Increased version&lt;br /&gt;
  remotes/origin/MOODLE_29_STABLE 3f03740 Replaced deprecated function&lt;br /&gt;
  remotes/origin/master           345f5b1 Replaced deprecated function&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git created the branch &#039;&#039;&#039;master&#039;&#039;&#039; which tracks &#039;&#039;&#039;origin/master&#039;&#039;&#039; automatically, because the remote repository has checked out &#039;&#039;&#039;master&#039;&#039;&#039;.&lt;br /&gt;
Therefore, create a new branch, which tracks the appropriate remote branch.&lt;br /&gt;
Of course, this is only possible, if the remote repository offers those branches. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git checkout -b MOODLE_29_STABLE origin/MOODLE_29_STABLE&lt;br /&gt;
Branch MOODLE_29_STABLE set up to track remote branch MOODLE_29_STABLE from origin.&lt;br /&gt;
Switched to a new branch &#039;MOODLE_29_STABLE&#039;&lt;br /&gt;
$ git branch -D master&lt;br /&gt;
Deleted branch master (was 345f5b1).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
It is not necessary to delete the &#039;&#039;&#039;master&#039;&#039;&#039; branch, but it&#039;s useless to keep it.&lt;br /&gt;
In fact, these settings don&#039;t need to be touched afterwards.&lt;br /&gt;
&lt;br /&gt;
The final step is to commit the changes to the main repository.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git commit -a -m &amp;quot;New extension mod_certificate installed&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It has to be ensured, that the commit includes only the changes for the new Git submodule (since &#039;&#039;&#039;-a&#039;&#039;&#039; commits all non-staged changes).&lt;br /&gt;
&lt;br /&gt;
=== Maintaining Git submodules ===&lt;br /&gt;
&lt;br /&gt;
Maintaining a set of submodules is extremely easy.&lt;br /&gt;
Consider a Moodle repository with several submodules installed.&lt;br /&gt;
Keep in mind, that the extension &#039;&#039;&#039;mod_mylittleextension&#039;&#039;&#039; is a fake plugin, created for a test scenario in this example.&lt;br /&gt;
It is not an official Moodle module. For updating all your submodules at once, type in:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd /path/to/your/moodle&lt;br /&gt;
$ git submodule foreach git pull&lt;br /&gt;
Entering &#039;block/coursefeedback&#039;&lt;br /&gt;
Already up-to-date.&lt;br /&gt;
Entering &#039;mod/certificate&#039;&lt;br /&gt;
Already up-to-date.&lt;br /&gt;
Entering &#039;mod/mylittleextension&#039;&lt;br /&gt;
remote: Counting objects: 6, done.&lt;br /&gt;
remote: Compressing objects: 100% (4/4), done.&lt;br /&gt;
remote: Total 4 (delta 0), reused 0 (delta 0)&lt;br /&gt;
Unpacking objects: 100% (4/4), done.&lt;br /&gt;
From /local/repositories/mle&lt;br /&gt;
   89d9eae..64c122d  master     -&amp;gt; origin/master&lt;br /&gt;
Updating 89d9eae..64c122d&lt;br /&gt;
Fast-forward&lt;br /&gt;
 index.html  |    9 +++++++++&lt;br /&gt;
 version.php |    6 +++---&lt;br /&gt;
 2 files changed, 12 insertions(+), 3 deletions(-)&lt;br /&gt;
 create mode 100644 index.html&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch MOODLE_29_STABLE&lt;br /&gt;
# Changes not staged for commit:&lt;br /&gt;
#   (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)&lt;br /&gt;
#   (use &amp;quot;git checkout -- &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   mod/mylittleextension (new commits)&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The command &#039;&#039;&#039;git submodule foreach [another command]&#039;&#039;&#039; walks through all submodule repositiories and executes what is specified by &#039;&#039;&#039;[another command]&#039;&#039;&#039;.&lt;br /&gt;
In this case it is &#039;&#039;&#039;git pull&#039;&#039;&#039;.&lt;br /&gt;
Therefore the module mylittleextension was updated and the main repository isn&#039;t clean anymore until changes are committed:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git commit -a -m &amp;quot;Plugin updates&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Maintaining plugins with Git submodules has also another application than simplifying the update process.&lt;br /&gt;
In a greater scale it can be used to maintain a Moodle project, where multiple developers need to have an exact copy of your moodle without organizing external plugins manually.&lt;br /&gt;
You can read more about this topic at the page [[Moodle development environment with Git submodules]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation using Git]]&lt;br /&gt;
* [[Git for Mac]]&lt;br /&gt;
* [[:dev:Moodle versions]]&lt;br /&gt;
* For fixing a Tracker Issue (MDL) / Forking Moodle / CONTRIButing code [[:dev:User:Sam_Hemelryk/My_Moodle_Git_workflow|User:Sam_Hemelryk/My_Moodle_Git_workflow]]&lt;br /&gt;
* [[Moodle_Production_Server_with_GIT|Case study Git + Moodle from Technical University Berlin]]&lt;br /&gt;
&lt;br /&gt;
; Moodle forum discussions&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=255175 Github and Moodle deployment for production]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=168094 GIT help needed]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=231046 Clear git guide for Admins (not developers)]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=393756 Best way to use Git]&lt;br /&gt;
&lt;br /&gt;
; External resources &lt;br /&gt;
* [http://thamblings.blogspot.com.au/2013/07/upgrading-moodle-from-git.html Deploying Moodle from git - Blog post from a production experience]&lt;br /&gt;
* [http://gitref.org/ Git Reference]&lt;br /&gt;
* [http://progit.org/book/ Pro Git book]&lt;br /&gt;
&lt;br /&gt;
[[ja:管理者用Git]]&lt;br /&gt;
[[fr:Git_pour_administrateurs]]&lt;br /&gt;
[[es:Git para Administradores]]&lt;br /&gt;
[[en:Git für Administratoren]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=137021</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=137021"/>
		<updated>2020-05-17T13:21:05Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers.&lt;br /&gt;
&lt;br /&gt;
If you want to avoid installing Moodle yourself completely, consider https://moodlecloud.com/&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending on the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution to cloud VMs or other hosted solutions. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirements] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone -b MOODLE_{{Version3}}_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
chown -R root /path/to/moodle&lt;br /&gt;
chmod -R 0755 /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
On test/dev sites you &#039;&#039;may&#039;&#039; want to make the files writeable in order to use the built in plugin installer. This is discouraged for live sites (at least, revert to more secure settings if you do).&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]] (recommended)&lt;br /&gt;
* [[MariaDB]] (recommended)&lt;br /&gt;
* [[MySQL]]&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (not recommended)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web-based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block (Classic theme) or the Site administration button in the navigation bar (Boost). Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Email &amp;gt; Outgoing mail configuration&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). You can also set a norepy email on this page.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Server &amp;gt; Support contact&#039;&#039;. Set your support contact email. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underlying OS):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
[Date] &lt;br /&gt;
; Defines the default timezone used by the date functions &lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039; : From Site administration &amp;gt; Server &amp;gt; Test outgoing mail configuration, use the  link to send yourself a test email. Don&#039;t be tempted to skip this step.&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory? If you don&#039;t fully understand how file ownership and permissions work on your operating system it would be time very well spent to find out.&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=401983 Another one for cPanel using videos]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=136985</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=136985"/>
		<updated>2020-05-11T12:14:14Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers.&lt;br /&gt;
&lt;br /&gt;
If you want to avoid installing Moodle yourself completely, consider https://moodlecloud.com/&lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending on the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution to cloud VMs or other hosted solutions. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirements] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone -b MOODLE_{{Version3}}_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
chown -R root /path/to/moodle&lt;br /&gt;
chmod -R 0755 /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
On test/dev sites you &#039;&#039;may&#039;&#039; want to make the files writeable in order to use the built in plugin installer. This is discouraged for live sites (at least, revert to more secure settings if you do).&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]] (recommended)&lt;br /&gt;
* [[MariaDB]] (recommended)&lt;br /&gt;
* [[MySQL]]&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (not recommended)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web-based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block (Classic theme) or the Site administration button in the navigation bar (Boost). Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Email &amp;gt; Outgoing mail configuration&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). You can also set a norepy email on this page.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Server &amp;gt; Support contact&#039;&#039;. Set your support contact email. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underlying OS):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
[Date] &lt;br /&gt;
; Defines the default timezone used by the date functions &lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039; : From Site administration &amp;gt; Server &amp;gt; Test outgoing mail configuration, use the  link to send yourself a test email. Don&#039;t be tempted to skip this step.&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory? If you don&#039;t fully understand how file ownership and permissions work on your operating system it would be time very well spent to find out.&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=136984</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=136984"/>
		<updated>2020-05-11T12:13:12Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Set up your server */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending on the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution to cloud VMs or other hosted solutions. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirements] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone -b MOODLE_{{Version3}}_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
chown -R root /path/to/moodle&lt;br /&gt;
chmod -R 0755 /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
On test/dev sites you &#039;&#039;may&#039;&#039; want to make the files writeable in order to use the built in plugin installer. This is discouraged for live sites (at least, revert to more secure settings if you do).&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]] (recommended)&lt;br /&gt;
* [[MariaDB]] (recommended)&lt;br /&gt;
* [[MySQL]]&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (not recommended)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web-based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block (Classic theme) or the Site administration button in the navigation bar (Boost). Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Email &amp;gt; Outgoing mail configuration&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). You can also set a norepy email on this page.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Server &amp;gt; Support contact&#039;&#039;. Set your support contact email. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underlying OS):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
[Date] &lt;br /&gt;
; Defines the default timezone used by the date functions &lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039; : From Site administration &amp;gt; Server &amp;gt; Test outgoing mail configuration, use the  link to send yourself a test email. Don&#039;t be tempted to skip this step.&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory? If you don&#039;t fully understand how file ownership and permissions work on your operating system it would be time very well spent to find out.&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=136983</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=136983"/>
		<updated>2020-05-11T12:09:34Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: Removing a lot of &amp;quot;advanced&amp;quot; fluff from the installation page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirements] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone -b MOODLE_{{Version3}}_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
chown -R root /path/to/moodle&lt;br /&gt;
chmod -R 0755 /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
On test/dev sites you &#039;&#039;may&#039;&#039; want to make the files writeable in order to use the built in plugin installer. This is discouraged for live sites (at least, revert to more secure settings if you do).&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]] (recommended)&lt;br /&gt;
* [[MariaDB]] (recommended)&lt;br /&gt;
* [[MySQL]]&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (not recommended)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web-based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block (Classic theme) or the Site administration button in the navigation bar (Boost). Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Email &amp;gt; Outgoing mail configuration&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). You can also set a norepy email on this page.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Server &amp;gt; Support contact&#039;&#039;. Set your support contact email. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underlying OS):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
[Date] &lt;br /&gt;
; Defines the default timezone used by the date functions &lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039; : From Site administration &amp;gt; Server &amp;gt; Test outgoing mail configuration, use the  link to send yourself a test email. Don&#039;t be tempted to skip this step.&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory? If you don&#039;t fully understand how file ownership and permissions work on your operating system it would be time very well spent to find out.&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=136971</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=136971"/>
		<updated>2020-05-06T16:20:40Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: ACL is too much information here.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirements] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone -b MOODLE_{{Version3}}_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other options you might consider:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;--depth=1&#039;&#039;  for shallow cloning (only) latest revision (be advised! If you are a developer, you will not be able to easily make git updates and modification later on when this feature is used) &lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;--single-branch&#039;&#039;  to limit cloning to a single branch, this fetches the Moodle {{Version}} Stable branch (latest weekly build). For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
# chmod -R 0755 /path/to/moodle&lt;br /&gt;
# find /path/to/moodle -type f -exec chmod 0644 {} \;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
The third command finds all the regular files and executes the chmod command 0644 on them. &lt;br /&gt;
&lt;br /&gt;
If you want to use the built-in plugin installer you need to make the directory writable by web server user. It is strongly recommended to use ACL when your server supports it, for example if your Apache server uses account www-data: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The effect of the previous command is to allow the Apache user account (www-data in this case) to access and change files within the moodle site. Many people would consider this a brave move for a new site admin to implement. In a new moodle you can safely leave this out. A default Ubuntu install does not have the +a option for the chmod command anyway. The +a attribute is an ACL (Access Control List) facility which allows you to set per user access for individual files. For example, OSX has this by default.&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]] (recommended)&lt;br /&gt;
* [[MariaDB]] (recommended)&lt;br /&gt;
* [[MySQL]]&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (not recommended)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web-based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block (Classic theme) or the Site administration button in the navigation bar (Boost). Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Email &amp;gt; Outgoing mail configuration&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). You can also set a norepy email on this page.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Server &amp;gt; Support contact&#039;&#039;. Set your support contact email. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underlying OS):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
[Date] &lt;br /&gt;
; Defines the default timezone used by the date functions &lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039; : From Site administration &amp;gt; Server &amp;gt; Test outgoing mail configuration, use the  link to send yourself a test email. Don&#039;t be tempted to skip this step.&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory? If you don&#039;t fully understand how file ownership and permissions work on your operating system it would be time very well spent to find out.&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136744</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136744"/>
		<updated>2020-03-11T09:36:20Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Install the new Moodle software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}	&lt;br /&gt;
&#039;&#039;This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Check the requirements==&lt;br /&gt;
&lt;br /&gt;
Before upgrading, check that your server meets all requirements for {{Version}} in &#039;&#039;Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for both [{{Release notes}}#Server_requirements server] and [{{Release notes}}#Client_requirements client] software requirements.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* You can only upgrade to Moodle {{Version}} from Moodle 3.2 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/32/en/Upgrading_to_Moodle_3.2 upgrade to 3.2] as a first step.&lt;br /&gt;
&lt;br /&gt;
==Before upgrading==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Consider setting the [[Upgrade key|upgrade key]] for your site.&lt;br /&gt;
&lt;br /&gt;
== Backup important data ==&lt;br /&gt;
&lt;br /&gt;
There are three areas that should be backed up before any upgrade:&lt;br /&gt;
#Moodle software (For example, everything in server/htdocs/moodle)&lt;br /&gt;
#Moodle uploaded files (For example, server/moodledata)&lt;br /&gt;
#Moodle database (For example, your Postgres or MySQL database dump)&lt;br /&gt;
&lt;br /&gt;
See [[Site backup]] for more specific information.&lt;br /&gt;
&lt;br /&gt;
== Check for plugin updates ==&lt;br /&gt;
&lt;br /&gt;
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.&lt;br /&gt;
&lt;br /&gt;
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).&lt;br /&gt;
&lt;br /&gt;
The upgrade of the plugin will then happen as part of the Moodle upgrade process.&lt;br /&gt;
&lt;br /&gt;
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.&lt;br /&gt;
&lt;br /&gt;
==Put your site into maintenance mode==&lt;br /&gt;
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.&lt;br /&gt;
&lt;br /&gt;
== Install the new Moodle software ==&lt;br /&gt;
You can fetch the current version of the software at&lt;br /&gt;
&lt;br /&gt;
wget http://sourceforge.net/projects/moodle/files/Moodle/stable38/moodle-latest-38.tgz&lt;br /&gt;
&lt;br /&gt;
=== Standard install package ===&lt;br /&gt;
&lt;br /&gt;
# Move your old Moodle software program files to another location. &#039;&#039;Do NOT copy new files over the old files.&#039;&#039;&lt;br /&gt;
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.&lt;br /&gt;
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. &lt;br /&gt;
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)&lt;br /&gt;
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it.  Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder.  If you are moving your installation to a new server or new location on your server, then you will need to follow the [[Migration]] documents.&lt;br /&gt;
&lt;br /&gt;
====Linux====&lt;br /&gt;
 mv moodle moodle.backup&lt;br /&gt;
 tar xvzf moodle-latest-{{Version}}.tgz&lt;br /&gt;
&lt;br /&gt;
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (&#039;&#039;&#039;check that custom plugins are the correct version for your new Moodle first&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 cp moodle.backup/config.php moodle&lt;br /&gt;
 cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme&lt;br /&gt;
 cp -pr moodle.backup/mod/mymod moodle/mod/mymod&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make moodle/config.php (and the rest of the source code) readable by your www server. For maximum security the files should not be writeable by your server. This is especially important on a &#039;production&#039; server open to the public internet. &lt;br /&gt;
&lt;br /&gt;
 chown -R root:root moodle (Linux debian - or even create a user especially for moodle. &#039;&#039;&#039;Don&#039;t&#039;&#039;&#039; use the web server user, e.g. www-data)&lt;br /&gt;
 chmod -R 755 moodle&lt;br /&gt;
&lt;br /&gt;
If you use cron, take care that cron.php is executeable and uses the correct php command: &lt;br /&gt;
 chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)&lt;br /&gt;
 copy the first line from cron.php (if it looks like &#039;#!/usr/local/bin/php&#039; or &#039;#!/usr/local/bin/php5.3&#039;, no need to copy &#039;&amp;lt;?php&#039;) &lt;br /&gt;
if necessary.  However, for a simple upgrade, there should be no need to change anything with cron.&lt;br /&gt;
&lt;br /&gt;
=== Using Git ===&lt;br /&gt;
&lt;br /&gt;
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.&lt;br /&gt;
&lt;br /&gt;
===Command line upgrade===&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
== Finishing the upgrade ==&lt;br /&gt;
&lt;br /&gt;
The last step is to trigger the upgrade processes within Moodle. &lt;br /&gt;
&lt;br /&gt;
If you put your site into Maintenance mode earlier; take it out now!&lt;br /&gt;
&lt;br /&gt;
To do this just go to &#039;&#039;Site administration &amp;gt; Notifications&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can&#039;t do itself (very rare) then you will see messages telling you what you need to do.&lt;br /&gt;
&lt;br /&gt;
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!&lt;br /&gt;
&lt;br /&gt;
Note: If you are running multiple servers then you should purge all caches manually (via &#039;&#039;Site administration &amp;gt; Development &amp;gt; Purge all caches&#039;&#039;) after completing the upgrade on all servers.&lt;br /&gt;
&lt;br /&gt;
===Fatal error: Maximum execution time of 30 seconds exceeded...===&lt;br /&gt;
&lt;br /&gt;
If your server uses a main language other than English, you may encounter a &#039;Fatal error: Maximum execution time of 30 seconds exceeded&#039; when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a successful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.&lt;br /&gt;
&lt;br /&gt;
==After upgrading==&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you in Moodle {{Version}}==&lt;br /&gt;
&lt;br /&gt;
===Course overview improvements===&lt;br /&gt;
&lt;br /&gt;
New course overview settings enable an admin to &lt;br /&gt;
&lt;br /&gt;
* reduce the currently available layouts (Card, List and Summary)&lt;br /&gt;
* specify which filter options are available, including providing a custom filter which uses course custom field values&lt;br /&gt;
&lt;br /&gt;
===Course request changes===&lt;br /&gt;
&lt;br /&gt;
The capabilities moodle/course:request and moodle/site:approvecourse may now be applied in the category context.&lt;br /&gt;
&lt;br /&gt;
===Removed functionality===&lt;br /&gt;
&lt;br /&gt;
* The Community finder block and course-sharing functionality have been removed as part of the preparations for the new MoodleNet open social media platform.&lt;br /&gt;
* The People block has been removed because there is a Participants link in the navigation drawer (Boost theme) and in the navigation block (Classic theme).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Please add more items here...&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20upgrade_notes upgrade_notes-labelled issues] and [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20ui_change%20 ui_change-labelled issues]. &lt;br /&gt;
&lt;br /&gt;
===New capabilities in Moodle {{Version}}===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Forum&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* forumreport/summary:view&lt;br /&gt;
* forumreport/summary:viewall&lt;br /&gt;
* mod/forum:exportforum&lt;br /&gt;
* mod/forum:grade&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;H5P&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* atto/h5p:addembed&lt;br /&gt;
* moodle/h5p:deploy&lt;br /&gt;
* moodle/h5p:setdisplayoptions&lt;br /&gt;
* moodle/h5p:updatelibraries&lt;br /&gt;
&lt;br /&gt;
=== Moodle 3.2, 3.3, 3.4, 3.5, 3.6 and 3.7 improvements ===&lt;br /&gt;
&lt;br /&gt;
Depending on which version you are upgrading from, please see the section &#039;Possible issues that may affect you&#039; in the documentation&lt;br /&gt;
&lt;br /&gt;
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]&lt;br /&gt;
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]&lt;br /&gt;
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]&lt;br /&gt;
* [https://docs.moodle.org/35/en/Upgrading Upgrading to Moodle 3.5]&lt;br /&gt;
* [https://docs.moodle.org/36/en/Upgrading Upgrading to Moodle 3.6]&lt;br /&gt;
* [https://docs.moodle.org/37/en/Upgrading Upgrading to Moodle 3.7]&lt;br /&gt;
&lt;br /&gt;
==Any questions about the process?==&lt;br /&gt;
&lt;br /&gt;
Please post in the [https://moodle.org/mod/forum/view.php?id=28 Installing and upgrading help forum] on moodle.org.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=393570 Problem accessing dropdown such as personal profile since 3.8 (20191118) update] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[es:Actualización de moodle]]&lt;br /&gt;
[[fr:Mise à jour]]&lt;br /&gt;
[[ja:Moodleをアップグレードする]]&lt;br /&gt;
[[de:Aktualisierung von Moodle]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136743</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136743"/>
		<updated>2020-03-11T09:34:49Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: Undo revision 136720 by Howardsmiller (talk)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}	&lt;br /&gt;
&#039;&#039;This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Check the requirements==&lt;br /&gt;
&lt;br /&gt;
Before upgrading, check that your server meets all requirements for {{Version}} in &#039;&#039;Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for both [{{Release notes}}#Server_requirements server] and [{{Release notes}}#Client_requirements client] software requirements.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* You can only upgrade to Moodle {{Version}} from Moodle 3.2 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/32/en/Upgrading_to_Moodle_3.2 upgrade to 3.2] as a first step.&lt;br /&gt;
&lt;br /&gt;
==Before upgrading==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Consider setting the [[Upgrade key|upgrade key]] for your site.&lt;br /&gt;
&lt;br /&gt;
== Backup important data ==&lt;br /&gt;
&lt;br /&gt;
There are three areas that should be backed up before any upgrade:&lt;br /&gt;
#Moodle software (For example, everything in server/htdocs/moodle)&lt;br /&gt;
#Moodle uploaded files (For example, server/moodledata)&lt;br /&gt;
#Moodle database (For example, your Postgres or MySQL database dump)&lt;br /&gt;
&lt;br /&gt;
See [[Site backup]] for more specific information.&lt;br /&gt;
&lt;br /&gt;
== Check for plugin updates ==&lt;br /&gt;
&lt;br /&gt;
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.&lt;br /&gt;
&lt;br /&gt;
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).&lt;br /&gt;
&lt;br /&gt;
The upgrade of the plugin will then happen as part of the Moodle upgrade process.&lt;br /&gt;
&lt;br /&gt;
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.&lt;br /&gt;
&lt;br /&gt;
==Put your site into maintenance mode==&lt;br /&gt;
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.&lt;br /&gt;
&lt;br /&gt;
== Install the new Moodle software ==&lt;br /&gt;
You can fetch the current version of the software at&lt;br /&gt;
&lt;br /&gt;
wget https://download.moodle.org/download.php/stable38/moodle-3.8.2.zip&lt;br /&gt;
&lt;br /&gt;
=== Standard install package ===&lt;br /&gt;
&lt;br /&gt;
# Move your old Moodle software program files to another location. &#039;&#039;Do NOT copy new files over the old files.&#039;&#039;&lt;br /&gt;
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.&lt;br /&gt;
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. &lt;br /&gt;
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)&lt;br /&gt;
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it.  Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder.  If you are moving your installation to a new server or new location on your server, then you will need to follow the [[Migration]] documents.&lt;br /&gt;
&lt;br /&gt;
====Linux====&lt;br /&gt;
 mv moodle moodle.backup&lt;br /&gt;
 tar xvzf moodle-latest-{{Version}}.tgz&lt;br /&gt;
&lt;br /&gt;
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (&#039;&#039;&#039;check that custom plugins are the correct version for your new Moodle first&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 cp moodle.backup/config.php moodle&lt;br /&gt;
 cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme&lt;br /&gt;
 cp -pr moodle.backup/mod/mymod moodle/mod/mymod&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make moodle/config.php (and the rest of the source code) readable by your www server. For maximum security the files should not be writeable by your server. This is especially important on a &#039;production&#039; server open to the public internet. &lt;br /&gt;
&lt;br /&gt;
 chown -R root:root moodle (Linux debian - or even create a user especially for moodle. &#039;&#039;&#039;Don&#039;t&#039;&#039;&#039; use the web server user, e.g. www-data)&lt;br /&gt;
 chmod -R 755 moodle&lt;br /&gt;
&lt;br /&gt;
If you use cron, take care that cron.php is executeable and uses the correct php command: &lt;br /&gt;
 chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)&lt;br /&gt;
 copy the first line from cron.php (if it looks like &#039;#!/usr/local/bin/php&#039; or &#039;#!/usr/local/bin/php5.3&#039;, no need to copy &#039;&amp;lt;?php&#039;) &lt;br /&gt;
if necessary.  However, for a simple upgrade, there should be no need to change anything with cron.&lt;br /&gt;
&lt;br /&gt;
=== Using Git ===&lt;br /&gt;
&lt;br /&gt;
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.&lt;br /&gt;
&lt;br /&gt;
===Command line upgrade===&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
== Finishing the upgrade ==&lt;br /&gt;
&lt;br /&gt;
The last step is to trigger the upgrade processes within Moodle. &lt;br /&gt;
&lt;br /&gt;
If you put your site into Maintenance mode earlier; take it out now!&lt;br /&gt;
&lt;br /&gt;
To do this just go to &#039;&#039;Site administration &amp;gt; Notifications&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can&#039;t do itself (very rare) then you will see messages telling you what you need to do.&lt;br /&gt;
&lt;br /&gt;
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!&lt;br /&gt;
&lt;br /&gt;
Note: If you are running multiple servers then you should purge all caches manually (via &#039;&#039;Site administration &amp;gt; Development &amp;gt; Purge all caches&#039;&#039;) after completing the upgrade on all servers.&lt;br /&gt;
&lt;br /&gt;
===Fatal error: Maximum execution time of 30 seconds exceeded...===&lt;br /&gt;
&lt;br /&gt;
If your server uses a main language other than English, you may encounter a &#039;Fatal error: Maximum execution time of 30 seconds exceeded&#039; when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a successful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.&lt;br /&gt;
&lt;br /&gt;
==After upgrading==&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you in Moodle {{Version}}==&lt;br /&gt;
&lt;br /&gt;
===Course overview improvements===&lt;br /&gt;
&lt;br /&gt;
New course overview settings enable an admin to &lt;br /&gt;
&lt;br /&gt;
* reduce the currently available layouts (Card, List and Summary)&lt;br /&gt;
* specify which filter options are available, including providing a custom filter which uses course custom field values&lt;br /&gt;
&lt;br /&gt;
===Course request changes===&lt;br /&gt;
&lt;br /&gt;
The capabilities moodle/course:request and moodle/site:approvecourse may now be applied in the category context.&lt;br /&gt;
&lt;br /&gt;
===Removed functionality===&lt;br /&gt;
&lt;br /&gt;
* The Community finder block and course-sharing functionality have been removed as part of the preparations for the new MoodleNet open social media platform.&lt;br /&gt;
* The People block has been removed because there is a Participants link in the navigation drawer (Boost theme) and in the navigation block (Classic theme).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Please add more items here...&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20upgrade_notes upgrade_notes-labelled issues] and [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20ui_change%20 ui_change-labelled issues]. &lt;br /&gt;
&lt;br /&gt;
===New capabilities in Moodle {{Version}}===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Forum&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* forumreport/summary:view&lt;br /&gt;
* forumreport/summary:viewall&lt;br /&gt;
* mod/forum:exportforum&lt;br /&gt;
* mod/forum:grade&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;H5P&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* atto/h5p:addembed&lt;br /&gt;
* moodle/h5p:deploy&lt;br /&gt;
* moodle/h5p:setdisplayoptions&lt;br /&gt;
* moodle/h5p:updatelibraries&lt;br /&gt;
&lt;br /&gt;
=== Moodle 3.2, 3.3, 3.4, 3.5, 3.6 and 3.7 improvements ===&lt;br /&gt;
&lt;br /&gt;
Depending on which version you are upgrading from, please see the section &#039;Possible issues that may affect you&#039; in the documentation&lt;br /&gt;
&lt;br /&gt;
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]&lt;br /&gt;
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]&lt;br /&gt;
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]&lt;br /&gt;
* [https://docs.moodle.org/35/en/Upgrading Upgrading to Moodle 3.5]&lt;br /&gt;
* [https://docs.moodle.org/36/en/Upgrading Upgrading to Moodle 3.6]&lt;br /&gt;
* [https://docs.moodle.org/37/en/Upgrading Upgrading to Moodle 3.7]&lt;br /&gt;
&lt;br /&gt;
==Any questions about the process?==&lt;br /&gt;
&lt;br /&gt;
Please post in the [https://moodle.org/mod/forum/view.php?id=28 Installing and upgrading help forum] on moodle.org.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=393570 Problem accessing dropdown such as personal profile since 3.8 (20191118) update] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[es:Actualización de moodle]]&lt;br /&gt;
[[fr:Mise à jour]]&lt;br /&gt;
[[ja:Moodleをアップグレードする]]&lt;br /&gt;
[[de:Aktualisierung von Moodle]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136720</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136720"/>
		<updated>2020-03-10T12:43:20Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Install the new Moodle software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}	&lt;br /&gt;
&#039;&#039;This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Check the requirements==&lt;br /&gt;
&lt;br /&gt;
Before upgrading, check that your server meets all requirements for {{Version}} in &#039;&#039;Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for both [{{Release notes}}#Server_requirements server] and [{{Release notes}}#Client_requirements client] software requirements.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* You can only upgrade to Moodle {{Version}} from Moodle 3.2 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/32/en/Upgrading_to_Moodle_3.2 upgrade to 3.2] as a first step.&lt;br /&gt;
&lt;br /&gt;
==Before upgrading==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Consider setting the [[Upgrade key|upgrade key]] for your site.&lt;br /&gt;
&lt;br /&gt;
== Backup important data ==&lt;br /&gt;
&lt;br /&gt;
There are three areas that should be backed up before any upgrade:&lt;br /&gt;
#Moodle software (For example, everything in server/htdocs/moodle)&lt;br /&gt;
#Moodle uploaded files (For example, server/moodledata)&lt;br /&gt;
#Moodle database (For example, your Postgres or MySQL database dump)&lt;br /&gt;
&lt;br /&gt;
See [[Site backup]] for more specific information.&lt;br /&gt;
&lt;br /&gt;
== Check for plugin updates ==&lt;br /&gt;
&lt;br /&gt;
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.&lt;br /&gt;
&lt;br /&gt;
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).&lt;br /&gt;
&lt;br /&gt;
The upgrade of the plugin will then happen as part of the Moodle upgrade process.&lt;br /&gt;
&lt;br /&gt;
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.&lt;br /&gt;
&lt;br /&gt;
==Put your site into maintenance mode==&lt;br /&gt;
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.&lt;br /&gt;
&lt;br /&gt;
== Install the new Moodle software ==&lt;br /&gt;
You can fetch the current, stable version of the software at&lt;br /&gt;
&lt;br /&gt;
wget https://download.moodle.org/download.php/stable38/moodle-3.8.2.zip&lt;br /&gt;
&lt;br /&gt;
...or the latest weekly build here...&lt;br /&gt;
&lt;br /&gt;
wget https://github.com/moodle/moodle/archive/MOODLE_38_STABLE.zip&lt;br /&gt;
&lt;br /&gt;
=== Standard install package ===&lt;br /&gt;
&lt;br /&gt;
# Move your old Moodle software program files to another location. &#039;&#039;Do NOT copy new files over the old files.&#039;&#039;&lt;br /&gt;
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.&lt;br /&gt;
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. &lt;br /&gt;
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)&lt;br /&gt;
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it.  Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder.  If you are moving your installation to a new server or new location on your server, then you will need to follow the [[Migration]] documents.&lt;br /&gt;
&lt;br /&gt;
====Linux====&lt;br /&gt;
 mv moodle moodle.backup&lt;br /&gt;
 tar xvzf moodle-latest-{{Version}}.tgz&lt;br /&gt;
&lt;br /&gt;
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (&#039;&#039;&#039;check that custom plugins are the correct version for your new Moodle first&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 cp moodle.backup/config.php moodle&lt;br /&gt;
 cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme&lt;br /&gt;
 cp -pr moodle.backup/mod/mymod moodle/mod/mymod&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make moodle/config.php (and the rest of the source code) readable by your www server. For maximum security the files should not be writeable by your server. This is especially important on a &#039;production&#039; server open to the public internet. &lt;br /&gt;
&lt;br /&gt;
 chown -R root:root moodle (Linux debian - or even create a user especially for moodle. &#039;&#039;&#039;Don&#039;t&#039;&#039;&#039; use the web server user, e.g. www-data)&lt;br /&gt;
 chmod -R 755 moodle&lt;br /&gt;
&lt;br /&gt;
If you use cron, take care that cron.php is executeable and uses the correct php command: &lt;br /&gt;
 chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)&lt;br /&gt;
 copy the first line from cron.php (if it looks like &#039;#!/usr/local/bin/php&#039; or &#039;#!/usr/local/bin/php5.3&#039;, no need to copy &#039;&amp;lt;?php&#039;) &lt;br /&gt;
if necessary.  However, for a simple upgrade, there should be no need to change anything with cron.&lt;br /&gt;
&lt;br /&gt;
=== Using Git ===&lt;br /&gt;
&lt;br /&gt;
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.&lt;br /&gt;
&lt;br /&gt;
===Command line upgrade===&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
== Finishing the upgrade ==&lt;br /&gt;
&lt;br /&gt;
The last step is to trigger the upgrade processes within Moodle. &lt;br /&gt;
&lt;br /&gt;
If you put your site into Maintenance mode earlier; take it out now!&lt;br /&gt;
&lt;br /&gt;
To do this just go to &#039;&#039;Site administration &amp;gt; Notifications&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can&#039;t do itself (very rare) then you will see messages telling you what you need to do.&lt;br /&gt;
&lt;br /&gt;
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!&lt;br /&gt;
&lt;br /&gt;
Note: If you are running multiple servers then you should purge all caches manually (via &#039;&#039;Site administration &amp;gt; Development &amp;gt; Purge all caches&#039;&#039;) after completing the upgrade on all servers.&lt;br /&gt;
&lt;br /&gt;
===Fatal error: Maximum execution time of 30 seconds exceeded...===&lt;br /&gt;
&lt;br /&gt;
If your server uses a main language other than English, you may encounter a &#039;Fatal error: Maximum execution time of 30 seconds exceeded&#039; when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a successful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.&lt;br /&gt;
&lt;br /&gt;
==After upgrading==&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you in Moodle {{Version}}==&lt;br /&gt;
&lt;br /&gt;
===Course overview improvements===&lt;br /&gt;
&lt;br /&gt;
New course overview settings enable an admin to &lt;br /&gt;
&lt;br /&gt;
* reduce the currently available layouts (Card, List and Summary)&lt;br /&gt;
* specify which filter options are available, including providing a custom filter which uses course custom field values&lt;br /&gt;
&lt;br /&gt;
===Course request changes===&lt;br /&gt;
&lt;br /&gt;
The capabilities moodle/course:request and moodle/site:approvecourse may now be applied in the category context.&lt;br /&gt;
&lt;br /&gt;
===Removed functionality===&lt;br /&gt;
&lt;br /&gt;
* The Community finder block and course-sharing functionality have been removed as part of the preparations for the new MoodleNet open social media platform.&lt;br /&gt;
* The People block has been removed because there is a Participants link in the navigation drawer (Boost theme) and in the navigation block (Classic theme).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Please add more items here...&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20upgrade_notes upgrade_notes-labelled issues] and [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20ui_change%20 ui_change-labelled issues]. &lt;br /&gt;
&lt;br /&gt;
===New capabilities in Moodle {{Version}}===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Forum&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* forumreport/summary:view&lt;br /&gt;
* forumreport/summary:viewall&lt;br /&gt;
* mod/forum:exportforum&lt;br /&gt;
* mod/forum:grade&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;H5P&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* atto/h5p:addembed&lt;br /&gt;
* moodle/h5p:deploy&lt;br /&gt;
* moodle/h5p:setdisplayoptions&lt;br /&gt;
* moodle/h5p:updatelibraries&lt;br /&gt;
&lt;br /&gt;
=== Moodle 3.2, 3.3, 3.4, 3.5, 3.6 and 3.7 improvements ===&lt;br /&gt;
&lt;br /&gt;
Depending on which version you are upgrading from, please see the section &#039;Possible issues that may affect you&#039; in the documentation&lt;br /&gt;
&lt;br /&gt;
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]&lt;br /&gt;
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]&lt;br /&gt;
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]&lt;br /&gt;
* [https://docs.moodle.org/35/en/Upgrading Upgrading to Moodle 3.5]&lt;br /&gt;
* [https://docs.moodle.org/36/en/Upgrading Upgrading to Moodle 3.6]&lt;br /&gt;
* [https://docs.moodle.org/37/en/Upgrading Upgrading to Moodle 3.7]&lt;br /&gt;
&lt;br /&gt;
==Any questions about the process?==&lt;br /&gt;
&lt;br /&gt;
Please post in the [https://moodle.org/mod/forum/view.php?id=28 Installing and upgrading help forum] on moodle.org.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=393570 Problem accessing dropdown such as personal profile since 3.8 (20191118) update] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[es:Actualización de moodle]]&lt;br /&gt;
[[fr:Mise à jour]]&lt;br /&gt;
[[ja:Moodleをアップグレードする]]&lt;br /&gt;
[[de:Aktualisierung von Moodle]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136719</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136719"/>
		<updated>2020-03-10T12:41:24Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Install the new Moodle software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}	&lt;br /&gt;
&#039;&#039;This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Check the requirements==&lt;br /&gt;
&lt;br /&gt;
Before upgrading, check that your server meets all requirements for {{Version}} in &#039;&#039;Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for both [{{Release notes}}#Server_requirements server] and [{{Release notes}}#Client_requirements client] software requirements.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* You can only upgrade to Moodle {{Version}} from Moodle 3.2 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/32/en/Upgrading_to_Moodle_3.2 upgrade to 3.2] as a first step.&lt;br /&gt;
&lt;br /&gt;
==Before upgrading==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Consider setting the [[Upgrade key|upgrade key]] for your site.&lt;br /&gt;
&lt;br /&gt;
== Backup important data ==&lt;br /&gt;
&lt;br /&gt;
There are three areas that should be backed up before any upgrade:&lt;br /&gt;
#Moodle software (For example, everything in server/htdocs/moodle)&lt;br /&gt;
#Moodle uploaded files (For example, server/moodledata)&lt;br /&gt;
#Moodle database (For example, your Postgres or MySQL database dump)&lt;br /&gt;
&lt;br /&gt;
See [[Site backup]] for more specific information.&lt;br /&gt;
&lt;br /&gt;
== Check for plugin updates ==&lt;br /&gt;
&lt;br /&gt;
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.&lt;br /&gt;
&lt;br /&gt;
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).&lt;br /&gt;
&lt;br /&gt;
The upgrade of the plugin will then happen as part of the Moodle upgrade process.&lt;br /&gt;
&lt;br /&gt;
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.&lt;br /&gt;
&lt;br /&gt;
==Put your site into maintenance mode==&lt;br /&gt;
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.&lt;br /&gt;
&lt;br /&gt;
== Install the new Moodle software ==&lt;br /&gt;
You can fetch the current version of the software at&lt;br /&gt;
&lt;br /&gt;
wget https://download.moodle.org/download.php/stable38/moodle-3.8.2.zip&lt;br /&gt;
&lt;br /&gt;
=== Standard install package ===&lt;br /&gt;
&lt;br /&gt;
# Move your old Moodle software program files to another location. &#039;&#039;Do NOT copy new files over the old files.&#039;&#039;&lt;br /&gt;
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.&lt;br /&gt;
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. &lt;br /&gt;
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)&lt;br /&gt;
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it.  Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder.  If you are moving your installation to a new server or new location on your server, then you will need to follow the [[Migration]] documents.&lt;br /&gt;
&lt;br /&gt;
====Linux====&lt;br /&gt;
 mv moodle moodle.backup&lt;br /&gt;
 tar xvzf moodle-latest-{{Version}}.tgz&lt;br /&gt;
&lt;br /&gt;
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (&#039;&#039;&#039;check that custom plugins are the correct version for your new Moodle first&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 cp moodle.backup/config.php moodle&lt;br /&gt;
 cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme&lt;br /&gt;
 cp -pr moodle.backup/mod/mymod moodle/mod/mymod&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make moodle/config.php (and the rest of the source code) readable by your www server. For maximum security the files should not be writeable by your server. This is especially important on a &#039;production&#039; server open to the public internet. &lt;br /&gt;
&lt;br /&gt;
 chown -R root:root moodle (Linux debian - or even create a user especially for moodle. &#039;&#039;&#039;Don&#039;t&#039;&#039;&#039; use the web server user, e.g. www-data)&lt;br /&gt;
 chmod -R 755 moodle&lt;br /&gt;
&lt;br /&gt;
If you use cron, take care that cron.php is executeable and uses the correct php command: &lt;br /&gt;
 chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)&lt;br /&gt;
 copy the first line from cron.php (if it looks like &#039;#!/usr/local/bin/php&#039; or &#039;#!/usr/local/bin/php5.3&#039;, no need to copy &#039;&amp;lt;?php&#039;) &lt;br /&gt;
if necessary.  However, for a simple upgrade, there should be no need to change anything with cron.&lt;br /&gt;
&lt;br /&gt;
=== Using Git ===&lt;br /&gt;
&lt;br /&gt;
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.&lt;br /&gt;
&lt;br /&gt;
===Command line upgrade===&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
== Finishing the upgrade ==&lt;br /&gt;
&lt;br /&gt;
The last step is to trigger the upgrade processes within Moodle. &lt;br /&gt;
&lt;br /&gt;
If you put your site into Maintenance mode earlier; take it out now!&lt;br /&gt;
&lt;br /&gt;
To do this just go to &#039;&#039;Site administration &amp;gt; Notifications&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can&#039;t do itself (very rare) then you will see messages telling you what you need to do.&lt;br /&gt;
&lt;br /&gt;
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!&lt;br /&gt;
&lt;br /&gt;
Note: If you are running multiple servers then you should purge all caches manually (via &#039;&#039;Site administration &amp;gt; Development &amp;gt; Purge all caches&#039;&#039;) after completing the upgrade on all servers.&lt;br /&gt;
&lt;br /&gt;
===Fatal error: Maximum execution time of 30 seconds exceeded...===&lt;br /&gt;
&lt;br /&gt;
If your server uses a main language other than English, you may encounter a &#039;Fatal error: Maximum execution time of 30 seconds exceeded&#039; when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a successful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.&lt;br /&gt;
&lt;br /&gt;
==After upgrading==&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you in Moodle {{Version}}==&lt;br /&gt;
&lt;br /&gt;
===Course overview improvements===&lt;br /&gt;
&lt;br /&gt;
New course overview settings enable an admin to &lt;br /&gt;
&lt;br /&gt;
* reduce the currently available layouts (Card, List and Summary)&lt;br /&gt;
* specify which filter options are available, including providing a custom filter which uses course custom field values&lt;br /&gt;
&lt;br /&gt;
===Course request changes===&lt;br /&gt;
&lt;br /&gt;
The capabilities moodle/course:request and moodle/site:approvecourse may now be applied in the category context.&lt;br /&gt;
&lt;br /&gt;
===Removed functionality===&lt;br /&gt;
&lt;br /&gt;
* The Community finder block and course-sharing functionality have been removed as part of the preparations for the new MoodleNet open social media platform.&lt;br /&gt;
* The People block has been removed because there is a Participants link in the navigation drawer (Boost theme) and in the navigation block (Classic theme).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Please add more items here...&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20upgrade_notes upgrade_notes-labelled issues] and [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20ui_change%20 ui_change-labelled issues]. &lt;br /&gt;
&lt;br /&gt;
===New capabilities in Moodle {{Version}}===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Forum&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* forumreport/summary:view&lt;br /&gt;
* forumreport/summary:viewall&lt;br /&gt;
* mod/forum:exportforum&lt;br /&gt;
* mod/forum:grade&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;H5P&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* atto/h5p:addembed&lt;br /&gt;
* moodle/h5p:deploy&lt;br /&gt;
* moodle/h5p:setdisplayoptions&lt;br /&gt;
* moodle/h5p:updatelibraries&lt;br /&gt;
&lt;br /&gt;
=== Moodle 3.2, 3.3, 3.4, 3.5, 3.6 and 3.7 improvements ===&lt;br /&gt;
&lt;br /&gt;
Depending on which version you are upgrading from, please see the section &#039;Possible issues that may affect you&#039; in the documentation&lt;br /&gt;
&lt;br /&gt;
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]&lt;br /&gt;
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]&lt;br /&gt;
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]&lt;br /&gt;
* [https://docs.moodle.org/35/en/Upgrading Upgrading to Moodle 3.5]&lt;br /&gt;
* [https://docs.moodle.org/36/en/Upgrading Upgrading to Moodle 3.6]&lt;br /&gt;
* [https://docs.moodle.org/37/en/Upgrading Upgrading to Moodle 3.7]&lt;br /&gt;
&lt;br /&gt;
==Any questions about the process?==&lt;br /&gt;
&lt;br /&gt;
Please post in the [https://moodle.org/mod/forum/view.php?id=28 Installing and upgrading help forum] on moodle.org.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=393570 Problem accessing dropdown such as personal profile since 3.8 (20191118) update] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[es:Actualización de moodle]]&lt;br /&gt;
[[fr:Mise à jour]]&lt;br /&gt;
[[ja:Moodleをアップグレードする]]&lt;br /&gt;
[[de:Aktualisierung von Moodle]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136716</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=136716"/>
		<updated>2020-03-10T12:15:47Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Install the new Moodle software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}	&lt;br /&gt;
&#039;&#039;This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Check the requirements==&lt;br /&gt;
&lt;br /&gt;
Before upgrading, check that your server meets all requirements for {{Version}} in &#039;&#039;Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for both [{{Release notes}}#Server_requirements server] and [{{Release notes}}#Client_requirements client] software requirements.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* You can only upgrade to Moodle {{Version}} from Moodle 3.2 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/32/en/Upgrading_to_Moodle_3.2 upgrade to 3.2] as a first step.&lt;br /&gt;
&lt;br /&gt;
==Before upgrading==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Consider setting the [[Upgrade key|upgrade key]] for your site.&lt;br /&gt;
&lt;br /&gt;
== Backup important data ==&lt;br /&gt;
&lt;br /&gt;
There are three areas that should be backed up before any upgrade:&lt;br /&gt;
#Moodle software (For example, everything in server/htdocs/moodle)&lt;br /&gt;
#Moodle uploaded files (For example, server/moodledata)&lt;br /&gt;
#Moodle database (For example, your Postgres or MySQL database dump)&lt;br /&gt;
&lt;br /&gt;
See [[Site backup]] for more specific information.&lt;br /&gt;
&lt;br /&gt;
== Check for plugin updates ==&lt;br /&gt;
&lt;br /&gt;
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.&lt;br /&gt;
&lt;br /&gt;
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).&lt;br /&gt;
&lt;br /&gt;
The upgrade of the plugin will then happen as part of the Moodle upgrade process.&lt;br /&gt;
&lt;br /&gt;
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.&lt;br /&gt;
&lt;br /&gt;
==Put your site into maintenance mode==&lt;br /&gt;
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.&lt;br /&gt;
&lt;br /&gt;
== Install the new Moodle software ==&lt;br /&gt;
You can fetch the current version of the software at&lt;br /&gt;
&lt;br /&gt;
https://download.moodle.org/releases/latest/&lt;br /&gt;
&lt;br /&gt;
=== Standard install package ===&lt;br /&gt;
&lt;br /&gt;
# Move your old Moodle software program files to another location. &#039;&#039;Do NOT copy new files over the old files.&#039;&#039;&lt;br /&gt;
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.&lt;br /&gt;
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. &lt;br /&gt;
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)&lt;br /&gt;
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it.  Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder.  If you are moving your installation to a new server or new location on your server, then you will need to follow the [[Migration]] documents.&lt;br /&gt;
&lt;br /&gt;
====Linux====&lt;br /&gt;
 mv moodle moodle.backup&lt;br /&gt;
 tar xvzf moodle-latest-{{Version}}.tgz&lt;br /&gt;
&lt;br /&gt;
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (&#039;&#039;&#039;check that custom plugins are the correct version for your new Moodle first&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 cp moodle.backup/config.php moodle&lt;br /&gt;
 cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme&lt;br /&gt;
 cp -pr moodle.backup/mod/mymod moodle/mod/mymod&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make moodle/config.php (and the rest of the source code) readable by your www server. For maximum security the files should not be writeable by your server. This is especially important on a &#039;production&#039; server open to the public internet. &lt;br /&gt;
&lt;br /&gt;
 chown -R root:root moodle (Linux debian - or even create a user especially for moodle. &#039;&#039;&#039;Don&#039;t&#039;&#039;&#039; use the web server user, e.g. www-data)&lt;br /&gt;
 chmod -R 755 moodle&lt;br /&gt;
&lt;br /&gt;
If you use cron, take care that cron.php is executeable and uses the correct php command: &lt;br /&gt;
 chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)&lt;br /&gt;
 copy the first line from cron.php (if it looks like &#039;#!/usr/local/bin/php&#039; or &#039;#!/usr/local/bin/php5.3&#039;, no need to copy &#039;&amp;lt;?php&#039;) &lt;br /&gt;
if necessary.  However, for a simple upgrade, there should be no need to change anything with cron.&lt;br /&gt;
&lt;br /&gt;
=== Using Git ===&lt;br /&gt;
&lt;br /&gt;
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.&lt;br /&gt;
&lt;br /&gt;
===Command line upgrade===&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
== Finishing the upgrade ==&lt;br /&gt;
&lt;br /&gt;
The last step is to trigger the upgrade processes within Moodle. &lt;br /&gt;
&lt;br /&gt;
If you put your site into Maintenance mode earlier; take it out now!&lt;br /&gt;
&lt;br /&gt;
To do this just go to &#039;&#039;Site administration &amp;gt; Notifications&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can&#039;t do itself (very rare) then you will see messages telling you what you need to do.&lt;br /&gt;
&lt;br /&gt;
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!&lt;br /&gt;
&lt;br /&gt;
Note: If you are running multiple servers then you should purge all caches manually (via &#039;&#039;Site administration &amp;gt; Development &amp;gt; Purge all caches&#039;&#039;) after completing the upgrade on all servers.&lt;br /&gt;
&lt;br /&gt;
===Fatal error: Maximum execution time of 30 seconds exceeded...===&lt;br /&gt;
&lt;br /&gt;
If your server uses a main language other than English, you may encounter a &#039;Fatal error: Maximum execution time of 30 seconds exceeded&#039; when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a successful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.&lt;br /&gt;
&lt;br /&gt;
==After upgrading==&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you in Moodle {{Version}}==&lt;br /&gt;
&lt;br /&gt;
===Course overview improvements===&lt;br /&gt;
&lt;br /&gt;
New course overview settings enable an admin to &lt;br /&gt;
&lt;br /&gt;
* reduce the currently available layouts (Card, List and Summary)&lt;br /&gt;
* specify which filter options are available, including providing a custom filter which uses course custom field values&lt;br /&gt;
&lt;br /&gt;
===Course request changes===&lt;br /&gt;
&lt;br /&gt;
The capabilities moodle/course:request and moodle/site:approvecourse may now be applied in the category context.&lt;br /&gt;
&lt;br /&gt;
===Removed functionality===&lt;br /&gt;
&lt;br /&gt;
* The Community finder block and course-sharing functionality have been removed as part of the preparations for the new MoodleNet open social media platform.&lt;br /&gt;
* The People block has been removed because there is a Participants link in the navigation drawer (Boost theme) and in the navigation block (Classic theme).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Please add more items here...&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20upgrade_notes upgrade_notes-labelled issues] and [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.8%22)%20AND%20labels%20%3D%20ui_change%20 ui_change-labelled issues]. &lt;br /&gt;
&lt;br /&gt;
===New capabilities in Moodle {{Version}}===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Forum&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* forumreport/summary:view&lt;br /&gt;
* forumreport/summary:viewall&lt;br /&gt;
* mod/forum:exportforum&lt;br /&gt;
* mod/forum:grade&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;H5P&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* atto/h5p:addembed&lt;br /&gt;
* moodle/h5p:deploy&lt;br /&gt;
* moodle/h5p:setdisplayoptions&lt;br /&gt;
* moodle/h5p:updatelibraries&lt;br /&gt;
&lt;br /&gt;
=== Moodle 3.2, 3.3, 3.4, 3.5, 3.6 and 3.7 improvements ===&lt;br /&gt;
&lt;br /&gt;
Depending on which version you are upgrading from, please see the section &#039;Possible issues that may affect you&#039; in the documentation&lt;br /&gt;
&lt;br /&gt;
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]&lt;br /&gt;
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]&lt;br /&gt;
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]&lt;br /&gt;
* [https://docs.moodle.org/35/en/Upgrading Upgrading to Moodle 3.5]&lt;br /&gt;
* [https://docs.moodle.org/36/en/Upgrading Upgrading to Moodle 3.6]&lt;br /&gt;
* [https://docs.moodle.org/37/en/Upgrading Upgrading to Moodle 3.7]&lt;br /&gt;
&lt;br /&gt;
==Any questions about the process?==&lt;br /&gt;
&lt;br /&gt;
Please post in the [https://moodle.org/mod/forum/view.php?id=28 Installing and upgrading help forum] on moodle.org.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=393570 Problem accessing dropdown such as personal profile since 3.8 (20191118) update] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[es:Actualización de moodle]]&lt;br /&gt;
[[fr:Mise à jour]]&lt;br /&gt;
[[ja:Moodleをアップグレードする]]&lt;br /&gt;
[[de:Aktualisierung von Moodle]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Guest_access&amp;diff=136615</id>
		<title>Guest access</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Guest_access&amp;diff=136615"/>
		<updated>2020-02-06T09:35:59Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: It&amp;#039;s not a plugin. It&amp;#039;s core functionality&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Enrolment}}&lt;br /&gt;
The Guest access facility allows users with the [[Guest_role |Guest role]] to view the contents of a course. This  might be used, for example, if a Moodle site serves as a website where certain courses contain publicly available information, or else with a commercial Moodle site where courses with guest access can  offers a &amp;quot;taster&amp;quot; of the kind of courses which may be purchased. (Note that the guest cannot participate in any activities; they can only view content.)&lt;br /&gt;
&lt;br /&gt;
==Course settings for guest access==&lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/9X8dVVRw52w | desc = How to allow guests into courses}}&lt;br /&gt;
# With the [[Boost theme]], from the navigation drawer on the left,  click &#039;Participants&#039;, and then from the gear menu on the right, click &#039;Enrolment method&amp;gt; Guest access&#039;. With other themes, click &#039;&#039;Administration &amp;gt; Course administration &amp;gt; Users &amp;gt; Enrolment methods&#039;&#039; and then Guest access. &lt;br /&gt;
#Enable guest access by clicking on the &amp;quot;eye&amp;quot; icon or by choosing it in the &#039;Add method&#039; dropdown menu.&lt;br /&gt;
# If you wish to set a password, then click the configure icon and type in your password here.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Admin settings for guest access==&lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/KA9VdsqPhoM | desc = How to allow guests onto your Moodle site}}&lt;br /&gt;
&lt;br /&gt;
*In &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Manage enrol plugins&#039;&#039;,ensure Guest access is enabled (has its eye open.) This enables Guest access.&lt;br /&gt;
* In &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage authentication&#039;&#039; set the Guest login button to Show if you want the button on the Front page. &lt;br /&gt;
* Also Guest accounts can be logged - check the &#039;&#039;Administration&amp;gt; Site administration &amp;gt; Plugins &amp;gt; Logging &amp;gt; Log guest access&#039;&#039; setting&lt;br /&gt;
* A site policy for guests may be set in &#039;&#039;Site administration &amp;gt; Security &amp;gt; Site policies&#039;&#039;. Guests then have to agree to the site policy before accessing a course with guest access.&lt;br /&gt;
&lt;br /&gt;
===Default settings for guest access===&lt;br /&gt;
*Clicking on &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Enrolments &amp;gt; Guest access&#039;&#039; brings up the screen where admin can set defaults for guest access in courses.&lt;br /&gt;
**Clicking the &#039;Advanced&#039; button next to &#039;Allow guest access&#039; will hide this setting in a course and will instead display a &#039;Show more&#039; link to click on to access the setting.&lt;br /&gt;
** Guest access can be turned on by default in all new courses and you can also:&lt;br /&gt;
**require each course with guest access to have a password for guests. (Note: this can confuse teachers who are not aware of the requirement.)&lt;br /&gt;
**use or ignore your Moodle&#039;s standard password policy for guest access passwords&lt;br /&gt;
**offer if needed the first letter of the password as a hint.&lt;br /&gt;
&lt;br /&gt;
===Auto-login guests===&lt;br /&gt;
*In &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; User policies&#039;&#039;, you can tick the box so that visitors are automatically logged in as guests when accessing a course with guest access (i.e. they don&#039;t have to click the &amp;quot;login as guest button&amp;quot;.&lt;br /&gt;
*In &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Authentication &amp;gt; Manage Authentication&#039;&#039;, you must have &amp;quot;Guest login button&amp;quot; set to &amp;quot;Show&amp;quot;.&lt;br /&gt;
*In &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Security &amp;gt; Site policies&#039;&#039; you can check &amp;quot;Open to Google&amp;quot; setting so that the Google search robot will be allowed to enter your site as a Guest. In addition, people coming in to your site via a Google search will automatically be logged in as a Guest.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Guest role]]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=347107#p1400235 Re: Guest access to course sections!] forum post&lt;br /&gt;
*Tracker discussion &#039;Auto-login guests not working&#039; MDLSITE-4903&lt;br /&gt;
[[de:Gastzugang zum Kurs]]&lt;br /&gt;
&lt;br /&gt;
[[es:Acceso de invitados]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Performance_recommendations&amp;diff=135615</id>
		<title>Performance recommendations</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Performance_recommendations&amp;diff=135615"/>
		<updated>2019-09-30T08:10:31Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* PHP performance */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Performance}}&lt;br /&gt;
Moodle can be made to perform very well, at small usage levels or scaling up to many thousands of users. The factors involved in performance are basically the same as for any PHP-based database-driven system. When trying to optimize your server, try to focus on the factor which will make the most difference to the user. For example, if you have relatively more users browsing than accessing the database, look to improve the webserver performance.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Obtain a baseline benchmark==&lt;br /&gt;
&lt;br /&gt;
Before attempting any optimization, you should obtain a baseline benchmark of the component of the system you are trying to improve. For Linux try [http://lbs.sourceforge.net/ LBS] and for Windows use the Performance Monitor. Once you have quantitative data about how your system is performing currently, you&#039;ll be able to determine if the change you have made has had any real impact.&lt;br /&gt;
&lt;br /&gt;
The overall aim of adjustments to improve performance is to use RAM (cacheing) and to reduce disk-based activity. It is especially important to try to eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM. &lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;optimization order preference&#039;&#039;&#039; is usually: primary storage (more RAM), secondary storage (faster hard disks/improved hard disk configuration), processor (more and faster).&lt;br /&gt;
&lt;br /&gt;
It can be interesting to install and use the [https://moodle.org/plugins/report_benchmark Benchmark plugin] in order to find the bottlenecks of your system that specifically affect Moodle.&lt;br /&gt;
&lt;br /&gt;
==Scalability==&lt;br /&gt;
&lt;br /&gt;
Moodle&#039;s design (with clear separation of application layers) allows for strongly scalable setups. (Please check the list of [[Large installations|large Moodle installations]].)&lt;br /&gt;
&lt;br /&gt;
Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.&lt;br /&gt;
&lt;br /&gt;
It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore and cache areas (see [[Caching]]), but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster), but this is not an easy task and you should seek expert support, e.g. from a Moodle Partner.&lt;br /&gt;
&lt;br /&gt;
On very large, load-balanced, systems the performance of the shared components become critical. It&#039;s important that your shared file areas are properly tuned and that you use an effective cache (Redis is highly recommended). A good understanding of these areas of system administration should be considered a minimum requirement. &lt;br /&gt;
&lt;br /&gt;
===Server cluster===&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=57202 Moodle clustering]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=44470 Software load balancing]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=49986 TCP load balancing]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=88214 Installation for 3000 simultaneous users]&lt;br /&gt;
&lt;br /&gt;
==Hardware configuration==&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: The fastest and most effective change that you can make to improve performance is to &#039;&#039;&#039;increase the amount of RAM on your web server&#039;&#039;&#039; - get as much as possible (e.g. 4GB or more). Increasing primary memory will reduce the need for processes to swap to disk and will enable your server to handle more users.&lt;br /&gt;
* Better performance is gained by obtaining the best &#039;&#039;&#039;processor capability&#039;&#039;&#039; you can, i.e. dual or dual core processors. A modern BIOS should allow you to enable hyperthreading, but check if this makes a difference to the overall performance of the processors by using a [http://en.wikipedia.org/wiki/Super_PI CPU benchmarking tool].&lt;br /&gt;
* If you can afford them, use &#039;&#039;&#039;SCSI hard disks&#039;&#039;&#039; instead of SATA drives. SATA drives will increase your system&#039;s CPU utilization, whereas SCSI drives have their own integrated processors and come into their own when you have multiple drives. If you must have SATA drives, check that your motherboard and the drives themselves support NCQ (Native Command Queuing).&lt;br /&gt;
* Purchase hard disks with a &#039;&#039;&#039;low seek time&#039;&#039;&#039;. This will improve the overall speed of your system, especially when accessing Moodle&#039;s reports.&lt;br /&gt;
* Size your &#039;&#039;&#039;swap file&#039;&#039;&#039; correctly. The general advice is to set it to 4 x physical RAM.&lt;br /&gt;
* Use a &#039;&#039;&#039;RAID disk system&#039;&#039;&#039;. Although there are many different RAID configurations you can create, the following generally works best:&lt;br /&gt;
** install a hardware RAID controller (if you can)&lt;br /&gt;
** the operating system and swap drive on one set of disks configured as RAID-1.&lt;br /&gt;
** Moodle, Web server and Database server on another set of disks configured as RAID-5.&lt;br /&gt;
* If your &#039;moodledata&#039; area is going to be on relatively slow storage (e.g. NFS mount on to a NAS device) you will  have performance issues with the default cache configuration (which writes to this storage). See the page on [[Caching]] and choose an alternative. Redis is recommended. Using [https://en.wikipedia.org/wiki/GlusterFS GlusterFS] / [https://en.wikipedia.org/wiki/OCFS2 OCFS2] / [https://en.wikipedia.org/wiki/GFS2 GFS2] on a [https://en.wikipedia.org/wiki/Storage_Area_Network SAN] device and [https://en.wikipedia.org/wiki/Fibre_Channel Fiber Channel] could improve performance (See more info on the Moodle [https://moodle.org/mod/forum/discuss.php?d=214680#p1123124 forum thread], [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 NFS performance tuing] )&lt;br /&gt;
* Use &#039;&#039;&#039;gigabit ethernet&#039;&#039;&#039; for improved latency and throughput. This is especially important when you have your webserver and database server separated out on different hosts.&lt;br /&gt;
* Check the settings on your &#039;&#039;&#039;network card&#039;&#039;&#039;. You may get an improvement in performance by increasing the use of buffers and transmit/receive descriptors (balance this with processor and memory overheads) and off-loading TCP checksum calculation onto the card instead of the OS.&lt;br /&gt;
*  Read this [http://moodle.org/mod/forum/discuss.php?d=68579 Case Study] on a server stress test with 300 users.  &lt;br /&gt;
* See this [http://elearning.sgu.ac.jp/doc/PT/ accompanying report] on network traffic and server loads.&lt;br /&gt;
* Also see this SFSU presentation at Educause (using VMWare): [http://www.educause.edu/Resources/AnOpenSourceLMSforaMissionCrit/162843]&lt;br /&gt;
&lt;br /&gt;
==Operating System==&lt;br /&gt;
* You can use [http://en.wikipedia.org/wiki/Linux Linux](recommended), Unix-based, Windows or Mac OS X for the server &#039;&#039;&#039;operating system&#039;&#039;&#039;. *nix operating systems generally require less memory than Mac OS X or Windows servers for doing the same task as the server is configured with just a shell interface. Additionally Linux does not have licensing fees attached, but can have a big learning curve if you&#039;re used to another operating system. If you have a large number of processors running SMP, you may also want to consider using a highly tuned OS such as [http://en.wikipedia.org/wiki/Solaris_Operating_Environment Solaris].&lt;br /&gt;
* Check your own OS and &#039;&#039;&#039;vendor specific instructions&#039;&#039;&#039; for optimization steps.&lt;br /&gt;
** For Linux look at the [http://linuxperf.sourceforge.net/ Linux Performance Team] site. &lt;br /&gt;
** For Linux investigate the hdparm command, e.g. hdparm -m16 -d1 can be used to enable read/write on multiple sectors and DMA. Mount disks with the [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 &amp;quot;async&amp;quot; and &amp;quot;noatime&amp;quot;] options.&lt;br /&gt;
** For Windows set the sever to be optimized for network applications (Control Panel, Network Connections, LAN connection, Properties, File &amp;amp; Printer Sharing for Microsoft Networks, Properties, Optimization). You can also search the [http://technet.microsoft.com/ Microsoft TechNet site] for optimization documents.&lt;br /&gt;
&lt;br /&gt;
==Web server performance==&lt;br /&gt;
&lt;br /&gt;
Installing [http://www.mozilla.com/en-US/ Firefox] and the [https://addons.mozilla.org/en-US/firefox/addon/1843 firebug] extension will allow you to watch the time it takes for each page component to load. Also, the [https://addons.mozilla.org/en-US/firefox/addon/5369 Yslow] extension will evaluate your page against Yahoo&#039;s [http://www.skrenta.com/2007/05/14_rules_for_fast_web_pages_by_1.html 14 rules], full text [http://developer.yahoo.com/performance/rules.html Best Practices for Speeding Up Your Web Site], &amp;lt;strike&amp;gt;([http://video.yahoo.com/video/play?vid=1040890 video])&amp;lt;/strike&amp;gt; for fast loading websites.&lt;br /&gt;
&lt;br /&gt;
===PHP performance===&lt;br /&gt;
* PHP contains a built-in accelerator. Make sure it is enabled. &lt;br /&gt;
* Improvements in read/write performance can be improved by putting the cached PHP pages on a [[TMPFS]] filesystem - but remember that you&#039;ll lose the cache contents when there is a power failure or the server is rebooted.&lt;br /&gt;
* Performance of PHP is better when installed as an &#039;&#039;&#039;Apache/IIS6 ISAPI module&#039;&#039;&#039; (rather than a CGI). IIS 7.0/7.5 (Windows Server 2008/R2) users should choose a FastCGI installation for best performance.&lt;br /&gt;
* Also check the &#039;&#039;&#039;memory_limit&#039;&#039;&#039; in php.ini. The default value for the memory_limit directive is 128M. On some sites, it may need to be larger - especially for some backup operations. &lt;br /&gt;
* Also see [[PHP_settings_by_Moodle_version]]&lt;br /&gt;
* Use [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html PHP-FPM] (with apache).&lt;br /&gt;
&lt;br /&gt;
===Install HowTo===&lt;br /&gt;
==== APC ====&lt;br /&gt;
* [http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html APC on CentOS 5.x (linux)]&lt;br /&gt;
* [http://fplanque.com/dev/linux/install-apc-php-cache-debian-lenny APC on Debian (linux)]&lt;br /&gt;
==== eAccelerator ====&lt;br /&gt;
* [http://noveckg.blogspot.com/2010/02/installing-eaccelerator-cache-for-php.html Installing eAccelerator on CentOS 5.x (linux)]&lt;br /&gt;
* [https://docs.moodle.org/en/Installing_eAccelerator_In_Ubuntu_Server/ Installing eAccelerator on Ubuntu Server (linux)]&lt;br /&gt;
==== MemCached ====&lt;br /&gt;
Memcached server (daemon)&lt;br /&gt;
* [https://www.tecmint.com/install-memcached-on-centos-7/ Installing Memcached on CentOS 7.x (linux)] (as of php 7.x, only memcached is available)&lt;br /&gt;
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-memcached-on-centos-7 How To Install and Secure Memcached on CentOS 7]&lt;br /&gt;
* [https://wiki.zimbra.com/wiki/Blocking_Memcached_Attack#Iptables_rules_for_Redhat_based_servers Iptables rules for Redhat based servers]&lt;br /&gt;
Memcached PHP 7.1 extension &lt;br /&gt;
* [https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/repoview/php71u-pecl-memcached.html php71u-pecl-memcached] from IUS CentOS 7.x repository.&lt;br /&gt;
&lt;br /&gt;
===Apache performance===&lt;br /&gt;
* If you are using Apache on a Windows server, use the build from [http://www.apachelounge.com Apache Lounge] which is reported to have [http://moodle.org/mod/forum/discuss.php?d=93358 performance and stability improvements] compared to the official Apache download. Note that this is an unofficial build, so may not keep up with official releases.&lt;br /&gt;
* Set the &#039;&#039;&#039;MaxRequestWorkers&#039;&#039;&#039; directive correctly (&#039;&#039;&#039;MaxClients&#039;&#039;&#039; before Apache 2.4). Use this formula to help (which uses 80% of available memory to leave room for spare):&lt;br /&gt;
 MaxRequestWorkers = Total available memory * 80% / Max memory usage of apache process&lt;br /&gt;
:Memory usage of apache process is usually 10MB but Moodle can easily use up to 100MB per process, so a general rule of thumb is to divide your available memory in megabytes by 100 to get a conservative setting for MaxClients. You are quite likely to find yourself lowering the MaxRequestWorkers from its default of 150 on a Moodle server. To get a more accurate estimate read the value from the shell command:&lt;br /&gt;
 #ps -ylC httpd --sort:rss&lt;br /&gt;
&lt;br /&gt;
:If you need to increase the value of &#039;&#039;&#039;MaxRequestWorkers&#039;&#039;&#039; beyond 256, you will also need to set the &#039;&#039;&#039;ServerLimit&#039;&#039;&#039; directive. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Warning&#039;&#039;&#039;: Do not be tempted to set the value of MaxRequestWorkers higher than your available memory as your server will consume more RAM than available and start to swap to disk. &lt;br /&gt;
* Consider reducing the &#039;&#039;&#039;number of modules&#039;&#039;&#039; that Apache loads in the httpd.conf file to the minumum necessary to reduce the memory needed. &lt;br /&gt;
* Use the &#039;&#039;&#039;latest version of Apache&#039;&#039;&#039; - Apache 2 has an improved memory model which reduces memory usage further.&lt;br /&gt;
* For Unix/Linux systems, consider lowering &#039;&#039;&#039;MaxConnectionsPerChild&#039;&#039;&#039; (&#039;&#039;&#039;MaxRequestsPerChild&#039;&#039;&#039; before Apache 2.4) in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits). &lt;br /&gt;
* For a heavily loaded server, consider setting &#039;&#039;&#039;KeepAlive Off&#039;&#039;&#039; (do this only if your Moodle pages do not contain links to resources or uploaded images) or lowering the &#039;&#039;&#039;KeepAliveTimeout&#039;&#039;&#039; to between 2 and 5. The default is 15 (seconds) - the higher the value the more server processes will be kept waiting for possibly idle connections. A more accurate value for KeepAliveTimeout is obtained by observing how long it takes your users to download a page. After altering any of the KeepAlive variables, monitor your CPU utilization as there may be an additional overhead in initiating more worker processes/threads.&lt;br /&gt;
* As an alternative to using KeepAlive Off, consider setting-up a &#039;&#039;&#039;Reverse Proxy server&#039;&#039;&#039; infront of the Moodle server to cache HTML files with images. You can then return Apache to using keep-alives on the Moodle server.&lt;br /&gt;
* If you do not use a .htaccess file, set the &#039;&#039;&#039;AllowOverride&#039;&#039;&#039; variable to AllowOverride None to prevent .htaccess lookups.&lt;br /&gt;
* Set &#039;&#039;&#039;DirectoryIndex&#039;&#039;&#039; correctly so as to avoid content-negotiation. Here&#039;s an example from a production server:&lt;br /&gt;
 DirectoryIndex index.php index.html index.htm&lt;br /&gt;
* Unless you are doing development work on the server, set &#039;&#039;&#039;ExtendedStatus Off&#039;&#039;&#039; and disable mod_info as well as mod_status.&lt;br /&gt;
* Leave &#039;&#039;&#039;HostnameLookups Off&#039;&#039;&#039; (as default) to reduce DNS latency.&lt;br /&gt;
* Consider reducing the value of &#039;&#039;&#039;TimeOut&#039;&#039;&#039; to between 30 to 60 (seconds). &lt;br /&gt;
* For the &#039;&#039;&#039;Options directive&#039;&#039;&#039;, avoid Options Multiviews as this performs a directory scan. To reduce disk I/O further use&lt;br /&gt;
 Options -Indexes FollowSymLinks&lt;br /&gt;
&lt;br /&gt;
* Compression reduces response times by reducing the size of the HTTP response&lt;br /&gt;
# Install and enable mod_deflate - refer to documentation or man pages&lt;br /&gt;
# Add this code to the virtual server config file within the &amp;lt;directory&amp;gt; section for the root directory (or within the .htaccess file if AllowOverrides is On):&lt;br /&gt;
 &amp;lt;ifModule mod_deflate.c&amp;gt;&lt;br /&gt;
   AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/javascript text/css application/javascript&lt;br /&gt;
 &amp;lt;/ifmodule&amp;gt;&lt;br /&gt;
* Use Apache [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html event] [http://httpd.apache.org/docs/current/mpm.html MPM] (and not the default Prefork or Worker)&lt;br /&gt;
&lt;br /&gt;
===IIS performance===&lt;br /&gt;
All alter this location in the registry:&lt;br /&gt;
 HKLM\SYSTEM\CurrentControlSet\Services\Inetinfo\Parameters\&lt;br /&gt;
* The equivalent to KeepAliveTimeout is &#039;&#039;&#039;ListenBackLog&#039;&#039;&#039; (IIS - registry location is HKLM\ SYSTEM\ CurrentControlSet\ Services\ Inetinfo\ Parameters). Set this to between 2 to 5.&lt;br /&gt;
*Change the &#039;&#039;&#039;MemCacheSize&#039;&#039;&#039; value to adjust the amount of memory (Mb) that IIS will use for its file cache (50% of available memory by default).&lt;br /&gt;
*Change the &#039;&#039;&#039;MaxCachedFileSize&#039;&#039;&#039; to adjust the maximum size of a file cached in the file cache in bytes. Default is 262,144 (256K).&lt;br /&gt;
*Create a new DWORD called &#039;&#039;&#039;ObjectCacheTTL&#039;&#039;&#039; to change the length of time (in milliseconds) that objects in the cache are held in memory. Default is 30,000 milliseconds (30 seconds).&lt;br /&gt;
&lt;br /&gt;
===Lighttpd, NginX and Cherokee performance===&lt;br /&gt;
You can increase server performance by using a &#039;&#039;&#039;light-weight&#039;&#039;&#039; webserver like [http://www.lighttpd.net/ lighttpd],  [http://nginx.net/ nginx] or [http://www.cherokee-project.com/ cherokee] in combination with PHP in FastCGI-mode. Lighttpd was originally created as a proof-of-concept[http://www.lighttpd.net/story] to address the [http://www.kegel.com/c10k.html C10k problem] and while primarily recommended for memory-limited servers, its design origins and asynchronous-IO model make it a suitable and proven[http://blog.lighttpd.net/articles/2006/12/28/lighttpd-powers-5-alexa-top-250-sites] alternative HTTP server for high-load websites and web apps, including Moodle. See the [[lighttpd | MoodleDocs Lighttpd page]] for additional information, configuration example and links.&lt;br /&gt;
&lt;br /&gt;
Alternatively, both [http://www.lighttpd.net/ lighttpd] and [http://nginx.net/ nginx] are capable of performing as a load-balancer and/or reverse-proxy to alleviate load on back-end servers[http://www.linuxjournal.com/article/10108], providing benefit without requiring an actual software change on existing servers.&lt;br /&gt;
&lt;br /&gt;
Do note that these are likely to be the least tested server environments of all particularly if you are using advanced features such as web services and/or Moodle Networking. They are probably best considered for heavily used Moodle sites with relatively simple configurations.&lt;br /&gt;
&lt;br /&gt;
===X-Sendfile===&lt;br /&gt;
&lt;br /&gt;
X-Sendfile modules improve performance when sending large files from Moodle. It is recommended to configure your web server and Moodle to use this feature of available.&lt;br /&gt;
&lt;br /&gt;
Configure web server:&lt;br /&gt;
* Apache - https://tn123.org/mod_xsendfile/&lt;br /&gt;
* Lighttpd - http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file&lt;br /&gt;
* Nginx - http://wiki.nginx.org/XSendfile&lt;br /&gt;
&lt;br /&gt;
Enable support in config.php (see config-dist.php):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-Sendfile&#039;;           // Apache {@see https://tn123.org/mod_xsendfile/}&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-LIGHTTPD-send-file&#039;; // Lighttpd {@see http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file}&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-Accel-Redirect&#039;;     // Nginx {@see http://wiki.nginx.org/XSendfile}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure file location prefixes if your server implementation requires it:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//     $CFG-&amp;gt;xsendfilealiases = array(&lt;br /&gt;
//         &#039;/dataroot/&#039; =&amp;gt; $CFG-&amp;gt;dataroot,&lt;br /&gt;
//         &#039;/cachedir/&#039; =&amp;gt; &#039;/var/www/moodle/cache&#039;,    // for custom $CFG-&amp;gt;cachedir locations&lt;br /&gt;
//         &#039;/localcachedir/&#039; =&amp;gt; &#039;/var/local/cache&#039;,    // for custom $CFG-&amp;gt;localcachedir locations&lt;br /&gt;
//         &#039;/tempdir/&#039;  =&amp;gt; &#039;/var/www/moodle/temp&#039;,     // for custom $CFG-&amp;gt;tempdir locations&lt;br /&gt;
//         &#039;/filedir&#039;   =&amp;gt; &#039;/var/www/moodle/filedir&#039;,  // for custom $CFG-&amp;gt;filedir locations&lt;br /&gt;
//     );&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database performance==&lt;br /&gt;
&lt;br /&gt;
===MySQL performance===&lt;br /&gt;
&lt;br /&gt;
The following are MySQL specific settings which can be adjusted for better performance in your my.cnf (my.ini in Windows). The file contains a list of settings and their values. To see the current values use these commands&lt;br /&gt;
 SHOW STATUS;&lt;br /&gt;
 SHOW VARIABLES; &lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: You must make backups of your database before attempting to change any MySQL server configuration. After any change to the my.cnf, restart mysqld.&lt;br /&gt;
&lt;br /&gt;
If you are able, the [http://mysqltuner.com/ MySQLTuner] tool can be run against your MySQL server and will calculate appropriate configuration values for most of the following settings based on your current load, status and variables automatically.&lt;br /&gt;
&lt;br /&gt;
* Enable the &#039;&#039;&#039;query cache&#039;&#039;&#039; with &lt;br /&gt;
 query_cache_type = 1. &lt;br /&gt;
For most Moodle installs, set the following:&lt;br /&gt;
 query_cache_size = 36M &lt;br /&gt;
 query_cache_min_res_unit = 2K. &lt;br /&gt;
The query cache will improve performance if you are doing few updates on the database. &lt;br /&gt;
* Set the &#039;&#039;&#039;table cache&#039;&#039;&#039; correctly. For Moodle 1.6 set &lt;br /&gt;
 table_cache = 256 #(table_open_cache in MySQL &amp;gt; 5.1.2)&lt;br /&gt;
(min), and for Moodle 1.7 set &lt;br /&gt;
 table_cache = 512 #(table_open_cache in MySQL &amp;gt; 5.1.2)&lt;br /&gt;
(min). The table cache is used by all threads (connections), so monitor the value of opened_tables to further adjust - if opened_tables &amp;gt; 3 * table_cache(table_open_cache in MySQL &amp;gt; 5.1.2) then increase table_cache upto your OS limit. Note also that the figure for table_cache will also change depending on the number of modules and plugins you have installed. Find the number for your server by executing the mysql statement below. Look at the number returned and set table_cache to this value.&lt;br /&gt;
 mysql&amp;gt;SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema=&#039;yourmoodledbname&#039;;&lt;br /&gt;
* Set the &#039;&#039;&#039;thread cache&#039;&#039;&#039; correctly. Adjust the value so that your thread cache utilization is as close to 100% as possible by this formula:&lt;br /&gt;
 thread cache utilization (%) = (threads_created / connections) * 100&lt;br /&gt;
* The &#039;&#039;&#039;key buffer&#039;&#039;&#039; can improve the access speed to Moodle&#039;s SELECT queries. The correct size depends on the size of the index files (.myi) and in Moodle 1.6 or later (without any additional modules and plugins), the recommendation for this value is key_buffer_size = 32M. Ideally you want the database to be reading once from the disk for every 100 requests so monitor that the value is suitable for your install by adjusting the value of key_buffer_size so that the following formulas are true:&lt;br /&gt;
 key_read / key_read_requests &amp;lt; 0.01&lt;br /&gt;
 key_write / key_write_requests &amp;lt;= 1.0&lt;br /&gt;
* Set the &#039;&#039;&#039;maximum number of connections&#039;&#039;&#039; so that your users will not see a &amp;quot;Too many connections&amp;quot; message. Be careful that this may have an impact on the total memory used. MySQL connections usually last for milliseconds, so it is unusual even for a heavily loaded server for this value to be over 200.&lt;br /&gt;
* Manage &#039;&#039;&#039;high burst activity&#039;&#039;&#039;. If your Moodle install uses a lot of quizzes and you are experiencing performance problems (check by monitoring the value of threads_connected - it should not be rising) consider increasing the value of back_log.&lt;br /&gt;
* &#039;&#039;&#039;Optimize your tables weekly and after upgrading Moodle&#039;&#039;&#039;. It is good practice to also optimize your tables after performing a large data deletion exercise, e.g. at the end of your semester or academic year. This will ensure that index files are up to date. Backup your database first and then use:&lt;br /&gt;
 mysql&amp;gt;CHECK TABLE mdl_tablename;&lt;br /&gt;
 mysql&amp;gt;OPTIMIZE TABLE mdl_tablename;&lt;br /&gt;
:The common tables in Moodle to check are mdl_course_sections, mdl_forum_posts, mdl_log and mdl_sessions (if using dbsessions). Any errors need to be corrected using REPAIR TABLE (see the [http://dev.mysql.com/doc/refman/5.0/en/repair-table.html MySQL manual] and this [http://moodle.org/mod/forum/discuss.php?d=58208#p279638 forum script]).&lt;br /&gt;
* &#039;&#039;&#039;Maintain the key distribution&#039;&#039;&#039;. Every month or so it is a good idea to stop the mysql server and run these myisamchk commands.&lt;br /&gt;
 #myisamchk -a -S /pathtomysql/data/moodledir/*.MYI&lt;br /&gt;
:&#039;&#039;&#039;Warning&#039;&#039;&#039;: You must stop the mysql database process (mysqld) before running any myisamchk command. If you do not, you risk data loss.&lt;br /&gt;
* Reduce the number of &#039;&#039;&#039;temporary tables saved to disk&#039;&#039;&#039;. Check this with the created_tmp_disk_tables value. If this is relatively large (&amp;gt;5%) increase tmp_table_size until you see a reduction. Note that this will have an impact on RAM usage.&lt;br /&gt;
&lt;br /&gt;
===PostgreSQL performance===&lt;br /&gt;
&lt;br /&gt;
There are some good papers around on tuning PostgreSQL (like [http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server this one]), and Moodle&#039;s case does not seem to be different to the general case.&lt;br /&gt;
&lt;br /&gt;
The first thing to recognise is that if you really need to worry about tuning you should be using a separate machine for the database server. If you are not using a separate machine then the answers to many performance questions are substantially muddied by the memory requirements of the rest of the application.&lt;br /&gt;
&lt;br /&gt;
You should probably &#039;&#039;&#039;enable autovacuum&#039;&#039;&#039;, unless you know what you are doing. Many e-learning sites have predictable periods of low use, so disabling autovacuum and running a specific vacuum at those times can be a good option. Or perhaps leave autovacuum running but do a full vacuum weekly in a quiet period.&lt;br /&gt;
&lt;br /&gt;
Set &#039;&#039;&#039;shared_buffers&#039;&#039;&#039; to something reasonable. For versions up to 8.1 my testing has shown that peak performance is almost always obtained with buffers &amp;lt; 10000, so if you are using such a version, and have more than 512M of RAM just set shared_buffers to 10,000 (8MB).&lt;br /&gt;
&lt;br /&gt;
The buffer management had a big overhaul in 8.2 and &amp;quot;reasonable&amp;quot; is now a much larger number. I have not conducted performance tests with 8.2, but the recommendations from others are generally that you should now scale shared_buffers much more with memory and may continue to reap benefits even up to values like 100,000 (80MB). Consider using 1-2% of system RAM.&lt;br /&gt;
&lt;br /&gt;
PostgreSQL will also assume that the operating system is caching its files, so setting &#039;&#039;&#039;effective_cache_size&#039;&#039;&#039; to a reasonable value is also a good idea. A reasonable value will usually be (total RAM - RAM in use by programs). If you are running Linux and leave the system running for a day or two you can look at &#039;free&#039; and under the &#039;cached&#039; column you will see what it currently is. Consider taking that number (which is kB) and dividing it by 10 (i.e. allow 20% for other programs cache needs and then divide by 8 to get pages). If you are not using a dedicated database server you will need to decrease that value to account for usage by other programs.&lt;br /&gt;
&lt;br /&gt;
Some other useful parameters that can have positive effects, and the values I would typically set them to on a machine with 4G RAM, are:&lt;br /&gt;
&lt;br /&gt;
 work_mem = 10240&lt;br /&gt;
&lt;br /&gt;
That&#039;s 10M of RAM to use instead of on-disk sorting and so forth. That can give a big speed increase, but it is per connection and 200 connections * 10M is 2G, so it can theoretically chew up a lot of RAM.&lt;br /&gt;
&lt;br /&gt;
 maintenance_work_mem = 163840&lt;br /&gt;
&lt;br /&gt;
That&#039;s 160M of RAM which will be used by (e.g.) VACUUM, index rebuild, cluster and so forth. This should only be used periodically and should be freed when those processes exit, so I believe it is well worth while.&lt;br /&gt;
&lt;br /&gt;
 wal_buffers = 64&lt;br /&gt;
&lt;br /&gt;
These buffers are used for the write-ahead log, and there have been a number of reports on the PostgreSQL mailing lists of improvement from this level of increase.&lt;br /&gt;
&lt;br /&gt;
This is a little out of date now (version 8.0) but still worth a read: http://www.powerpostgresql.com/Docs&lt;br /&gt;
&lt;br /&gt;
And there is lots of good stuff here as well: http://www.varlena.com/GeneralBits/Tidbits/index.php&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Based on Andrew McMillan&#039;s post at [http://moodle.org/mod/forum/discuss.php?d=68558 Tuning PostgreSQL] forum thread.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Splitting &#039;&#039;&#039;mdl_log&#039;&#039;&#039; to several tables and using a VIEW with UNION to read them as one. (See Tim Hunt [https://moodle.org/mod/forum/discuss.php?d=243531#p1104165 explanation] on the Moodle forums)&lt;br /&gt;
&lt;br /&gt;
===Other database performance links===&lt;br /&gt;
* Consider using a &#039;&#039;&#039;distributed cacheing system&#039;&#039;&#039; like [http://en.wikipedia.org/wiki/Memcached memcached] but note that memcached does not have any security features so it should be used behind a firewall.&lt;br /&gt;
* Consider using PostgreSQL. See [[Arguments in favour of PostgreSQL]] and [http://moodle.org/mod/forum/discuss.php?d=49195 how to migrate from MySQL to PostgreSQL] (forum discussion).&lt;br /&gt;
* [http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html General advice on tuning MySQL parameters] (advice from the MySQL manual)&lt;br /&gt;
* [http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/ InnoDB performance optimization] taken from the [http://www.mysqlperformanceblog.com/ MySQL performance blog] site.&lt;br /&gt;
&lt;br /&gt;
==Performance of different Moodle modules==&lt;br /&gt;
&lt;br /&gt;
Moodle&#039;s activity modules, filters, and other plugins can be activated/deactivated. If necessary, you may wish to deactivate some features (such as chat) if not required - but this isn&#039;t necessary. Some notes on the performance of certain modules:&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;Chat&#039;&#039;&#039; module is [http://moodle.org/mod/forum/discuss.php?d=37979&amp;amp;parent=175079 said] to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use &#039;&#039;Streamed&#039;&#039; updates, or, if you&#039;re using a Unix-based webserver, by running the chat in daemon mode. When using the Chat module use the configuration settings to tune for your expected load. Pay particular attention to the &#039;&#039;chat_old_ping&#039;&#039; and &#039;&#039;chat_refresh&#039;&#039; parameters as these can have greatest impact on server load.&lt;br /&gt;
* The Moodle &#039;&#039;&#039;Cron&#039;&#039;&#039; task is triggered by calling the script &#039;&#039;cron.php&#039;&#039;. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. &#039;&#039;php -f /path/to/moodle/directory/admin/cli/cron.php&#039;&#039;) efficiency can be much improved.&lt;br /&gt;
* The &#039;&#039;&#039;Recent activities&#039;&#039;&#039; block is consuming too many resources if you have huge number of records &amp;lt;code&amp;gt;mdl_log&amp;lt;/code&amp;gt;. This is being tested to optimize the SQL query.&lt;br /&gt;
* The &#039;&#039;&#039;Quiz&#039;&#039;&#039; module is known to stretch database performance. However, it has been getting better in recent versions, and we don&#039;t know of any good, up-to-date performance measurements. (Here is a [http://moodle.org/mod/forum/discuss.php?d=68579 case study from 2007 with 300 quiz users].). The following suggestions were described by [https://moodle.org/user/view.php?id=94615&amp;amp;course=5 Al Rachels] in [https://moodle.org/mod/forum/discuss.php?d=347126 this forum thread]:&lt;br /&gt;
** make sure both Moodle, and the operating system, are installed on a [https://en.wikipedia.org/wiki/Solid-state_drive solid state drive]&lt;br /&gt;
** upgrade to and use [https://docs.moodle.org/dev/Moodle_and_PHP7 PHP 7]&lt;br /&gt;
** run MySQLTuner and implement its recommendations&lt;br /&gt;
&lt;br /&gt;
See [[Performance settings]] for more information on performance-related Moodle settings.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*Using Moodle: [http://moodle.org/mod/forum/view.php?f=94 Hardware and Performance] forum&lt;br /&gt;
*[http://opensourceelearning.blogspot.be/2012/10/why-your-moodle-site-is-slow-five.html Why Your Moodle Site is Slow: Five Simple Settings] blog post from Jonathan Moore &lt;br /&gt;
*I teach with Moodle perfomance testing: http://www.iteachwithmoodle.com/2012/11/17/moodle-2-4-beta-performance-test-comparison-with-moodle-2-3/&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.2 performance and MUC APC cahe store]&lt;br /&gt;
*[http://jfilip.ca/2013/09/25/moodle-performance-testing-2-4-6-vs-2-5-2-vs-2-6dev/ Moodle performance testing 2.4.6 vs 2.5.2 vs 2.6dev]&lt;br /&gt;
*[http://jfilip.ca/2013/09/24/moodle-performance-analysis-revisted-now-with-mariadb/ Moodle performance analysis revisited (now with MariaDB)]&lt;br /&gt;
*[http://tjhunt.blogspot.ca/2013/05/performance-testing-moodle.html Tim Hunt&#039;s blog (May 2, 2013) on performance testing Moodle]&lt;br /&gt;
*[http://newrelic.com/ New Relic, Application Performance Monitoring]&lt;br /&gt;
*[http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html Performance enhacements for Apache and PHP (Apache Event MPM and PHP-FPM)]&lt;br /&gt;
*[https://scholarlms.net/performance-recommendations/ Performance recommendations]&lt;br /&gt;
&lt;br /&gt;
There have been a lot of discussions on moodle.org about performance, here are some of the more interesting and (potentially) useful ones:&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=83057 Performance woes!]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=57028 Performance perspectives - a little script]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=88927 Comments on planned server hardware]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=102978#p461624 Moodle performance in a pil by Martin Langhoff]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=240391#unread Advice on optimising php/db code in moodle2+]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=243531 Moodle 2.5 performance testing at the OU]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=273602 100 active users limit with 4vCPU]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=336603#p1356423 Performance Tip ... shared...]&lt;br /&gt;
&lt;br /&gt;
[[es:Recomendaciones sobre desempeño]]&lt;br /&gt;
[[fr:Performance]]&lt;br /&gt;
[[ja:パフォーマンス]]&lt;br /&gt;
[[de:Geschwindigkeitsempfehlungen]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Performance_recommendations&amp;diff=135614</id>
		<title>Performance recommendations</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Performance_recommendations&amp;diff=135614"/>
		<updated>2019-09-30T08:08:28Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Hardware configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Performance}}&lt;br /&gt;
Moodle can be made to perform very well, at small usage levels or scaling up to many thousands of users. The factors involved in performance are basically the same as for any PHP-based database-driven system. When trying to optimize your server, try to focus on the factor which will make the most difference to the user. For example, if you have relatively more users browsing than accessing the database, look to improve the webserver performance.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Obtain a baseline benchmark==&lt;br /&gt;
&lt;br /&gt;
Before attempting any optimization, you should obtain a baseline benchmark of the component of the system you are trying to improve. For Linux try [http://lbs.sourceforge.net/ LBS] and for Windows use the Performance Monitor. Once you have quantitative data about how your system is performing currently, you&#039;ll be able to determine if the change you have made has had any real impact.&lt;br /&gt;
&lt;br /&gt;
The overall aim of adjustments to improve performance is to use RAM (cacheing) and to reduce disk-based activity. It is especially important to try to eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM. &lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;optimization order preference&#039;&#039;&#039; is usually: primary storage (more RAM), secondary storage (faster hard disks/improved hard disk configuration), processor (more and faster).&lt;br /&gt;
&lt;br /&gt;
It can be interesting to install and use the [https://moodle.org/plugins/report_benchmark Benchmark plugin] in order to find the bottlenecks of your system that specifically affect Moodle.&lt;br /&gt;
&lt;br /&gt;
==Scalability==&lt;br /&gt;
&lt;br /&gt;
Moodle&#039;s design (with clear separation of application layers) allows for strongly scalable setups. (Please check the list of [[Large installations|large Moodle installations]].)&lt;br /&gt;
&lt;br /&gt;
Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.&lt;br /&gt;
&lt;br /&gt;
It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore and cache areas (see [[Caching]]), but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster), but this is not an easy task and you should seek expert support, e.g. from a Moodle Partner.&lt;br /&gt;
&lt;br /&gt;
On very large, load-balanced, systems the performance of the shared components become critical. It&#039;s important that your shared file areas are properly tuned and that you use an effective cache (Redis is highly recommended). A good understanding of these areas of system administration should be considered a minimum requirement. &lt;br /&gt;
&lt;br /&gt;
===Server cluster===&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=57202 Moodle clustering]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=44470 Software load balancing]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=49986 TCP load balancing]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=88214 Installation for 3000 simultaneous users]&lt;br /&gt;
&lt;br /&gt;
==Hardware configuration==&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: The fastest and most effective change that you can make to improve performance is to &#039;&#039;&#039;increase the amount of RAM on your web server&#039;&#039;&#039; - get as much as possible (e.g. 4GB or more). Increasing primary memory will reduce the need for processes to swap to disk and will enable your server to handle more users.&lt;br /&gt;
* Better performance is gained by obtaining the best &#039;&#039;&#039;processor capability&#039;&#039;&#039; you can, i.e. dual or dual core processors. A modern BIOS should allow you to enable hyperthreading, but check if this makes a difference to the overall performance of the processors by using a [http://en.wikipedia.org/wiki/Super_PI CPU benchmarking tool].&lt;br /&gt;
* If you can afford them, use &#039;&#039;&#039;SCSI hard disks&#039;&#039;&#039; instead of SATA drives. SATA drives will increase your system&#039;s CPU utilization, whereas SCSI drives have their own integrated processors and come into their own when you have multiple drives. If you must have SATA drives, check that your motherboard and the drives themselves support NCQ (Native Command Queuing).&lt;br /&gt;
* Purchase hard disks with a &#039;&#039;&#039;low seek time&#039;&#039;&#039;. This will improve the overall speed of your system, especially when accessing Moodle&#039;s reports.&lt;br /&gt;
* Size your &#039;&#039;&#039;swap file&#039;&#039;&#039; correctly. The general advice is to set it to 4 x physical RAM.&lt;br /&gt;
* Use a &#039;&#039;&#039;RAID disk system&#039;&#039;&#039;. Although there are many different RAID configurations you can create, the following generally works best:&lt;br /&gt;
** install a hardware RAID controller (if you can)&lt;br /&gt;
** the operating system and swap drive on one set of disks configured as RAID-1.&lt;br /&gt;
** Moodle, Web server and Database server on another set of disks configured as RAID-5.&lt;br /&gt;
* If your &#039;moodledata&#039; area is going to be on relatively slow storage (e.g. NFS mount on to a NAS device) you will  have performance issues with the default cache configuration (which writes to this storage). See the page on [[Caching]] and choose an alternative. Redis is recommended. Using [https://en.wikipedia.org/wiki/GlusterFS GlusterFS] / [https://en.wikipedia.org/wiki/OCFS2 OCFS2] / [https://en.wikipedia.org/wiki/GFS2 GFS2] on a [https://en.wikipedia.org/wiki/Storage_Area_Network SAN] device and [https://en.wikipedia.org/wiki/Fibre_Channel Fiber Channel] could improve performance (See more info on the Moodle [https://moodle.org/mod/forum/discuss.php?d=214680#p1123124 forum thread], [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 NFS performance tuing] )&lt;br /&gt;
* Use &#039;&#039;&#039;gigabit ethernet&#039;&#039;&#039; for improved latency and throughput. This is especially important when you have your webserver and database server separated out on different hosts.&lt;br /&gt;
* Check the settings on your &#039;&#039;&#039;network card&#039;&#039;&#039;. You may get an improvement in performance by increasing the use of buffers and transmit/receive descriptors (balance this with processor and memory overheads) and off-loading TCP checksum calculation onto the card instead of the OS.&lt;br /&gt;
*  Read this [http://moodle.org/mod/forum/discuss.php?d=68579 Case Study] on a server stress test with 300 users.  &lt;br /&gt;
* See this [http://elearning.sgu.ac.jp/doc/PT/ accompanying report] on network traffic and server loads.&lt;br /&gt;
* Also see this SFSU presentation at Educause (using VMWare): [http://www.educause.edu/Resources/AnOpenSourceLMSforaMissionCrit/162843]&lt;br /&gt;
&lt;br /&gt;
==Operating System==&lt;br /&gt;
* You can use [http://en.wikipedia.org/wiki/Linux Linux](recommended), Unix-based, Windows or Mac OS X for the server &#039;&#039;&#039;operating system&#039;&#039;&#039;. *nix operating systems generally require less memory than Mac OS X or Windows servers for doing the same task as the server is configured with just a shell interface. Additionally Linux does not have licensing fees attached, but can have a big learning curve if you&#039;re used to another operating system. If you have a large number of processors running SMP, you may also want to consider using a highly tuned OS such as [http://en.wikipedia.org/wiki/Solaris_Operating_Environment Solaris].&lt;br /&gt;
* Check your own OS and &#039;&#039;&#039;vendor specific instructions&#039;&#039;&#039; for optimization steps.&lt;br /&gt;
** For Linux look at the [http://linuxperf.sourceforge.net/ Linux Performance Team] site. &lt;br /&gt;
** For Linux investigate the hdparm command, e.g. hdparm -m16 -d1 can be used to enable read/write on multiple sectors and DMA. Mount disks with the [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 &amp;quot;async&amp;quot; and &amp;quot;noatime&amp;quot;] options.&lt;br /&gt;
** For Windows set the sever to be optimized for network applications (Control Panel, Network Connections, LAN connection, Properties, File &amp;amp; Printer Sharing for Microsoft Networks, Properties, Optimization). You can also search the [http://technet.microsoft.com/ Microsoft TechNet site] for optimization documents.&lt;br /&gt;
&lt;br /&gt;
==Web server performance==&lt;br /&gt;
&lt;br /&gt;
Installing [http://www.mozilla.com/en-US/ Firefox] and the [https://addons.mozilla.org/en-US/firefox/addon/1843 firebug] extension will allow you to watch the time it takes for each page component to load. Also, the [https://addons.mozilla.org/en-US/firefox/addon/5369 Yslow] extension will evaluate your page against Yahoo&#039;s [http://www.skrenta.com/2007/05/14_rules_for_fast_web_pages_by_1.html 14 rules], full text [http://developer.yahoo.com/performance/rules.html Best Practices for Speeding Up Your Web Site], &amp;lt;strike&amp;gt;([http://video.yahoo.com/video/play?vid=1040890 video])&amp;lt;/strike&amp;gt; for fast loading websites.&lt;br /&gt;
&lt;br /&gt;
===PHP performance===&lt;br /&gt;
* You are strongly recommended to use a &#039;&#039;&#039;PHP accelerator&#039;&#039;&#039; to ease CPU load, such as [http://pecl.php.net/apc APC], [http://www.php-accelerator.co.uk/ PHPA], [http://trac.lighttpd.net/xcache/ Xcache], [http://sourceforge.net/projects/wincache WinCache] or [http://eaccelerator.net/ eAccelerator]. (Take care to choose a PHP accelerator that is known to work well with your version of PHP and note that Turck MMCache is [http://turckmmcache.exeprod.com/TheManifestoEnglish no longer maintained] and can cause failures with PHP 5). PHP 5.5 (and newer) includes OpCache and is fully supported and recommended by Moodle&lt;br /&gt;
* Improvements in read/write performance can be improved by putting the cached PHP pages on a [[TMPFS]] filesystem - but remember that you&#039;ll lose the cache contents when there is a power failure or the server is rebooted.&lt;br /&gt;
* Performance of PHP is better when installed as an &#039;&#039;&#039;Apache/IIS6 ISAPI module&#039;&#039;&#039; (rather than a CGI). IIS 7.0/7.5 (Windows Server 2008/R2) users should choose a FastCGI installation for best performance.&lt;br /&gt;
* Also check the &#039;&#039;&#039;memory_limit&#039;&#039;&#039; in php.ini, reduce it to 16M for Moodle version earlier than 1.7 ([http://moodle.org/mod/forum/discuss.php?d=39656 See this forum discussion]). For Moodle 1.7 or later, it is recommended that the value of memory_limit should be 40M. As of [http://www.php.net/ChangeLog-5.php PHP 5.2.1] the default value for the memory_limit directive is 128M.&lt;br /&gt;
* Also see [[PHP_settings_by_Moodle_version]]&lt;br /&gt;
* Use [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html PHP-FPM] (with apache).&lt;br /&gt;
&lt;br /&gt;
===Install HowTo===&lt;br /&gt;
==== APC ====&lt;br /&gt;
* [http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html APC on CentOS 5.x (linux)]&lt;br /&gt;
* [http://fplanque.com/dev/linux/install-apc-php-cache-debian-lenny APC on Debian (linux)]&lt;br /&gt;
==== eAccelerator ====&lt;br /&gt;
* [http://noveckg.blogspot.com/2010/02/installing-eaccelerator-cache-for-php.html Installing eAccelerator on CentOS 5.x (linux)]&lt;br /&gt;
* [https://docs.moodle.org/en/Installing_eAccelerator_In_Ubuntu_Server/ Installing eAccelerator on Ubuntu Server (linux)]&lt;br /&gt;
==== MemCached ====&lt;br /&gt;
Memcached server (daemon)&lt;br /&gt;
* [https://www.tecmint.com/install-memcached-on-centos-7/ Installing Memcached on CentOS 7.x (linux)] (as of php 7.x, only memcached is available)&lt;br /&gt;
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-memcached-on-centos-7 How To Install and Secure Memcached on CentOS 7]&lt;br /&gt;
* [https://wiki.zimbra.com/wiki/Blocking_Memcached_Attack#Iptables_rules_for_Redhat_based_servers Iptables rules for Redhat based servers]&lt;br /&gt;
Memcached PHP 7.1 extension &lt;br /&gt;
* [https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/repoview/php71u-pecl-memcached.html php71u-pecl-memcached] from IUS CentOS 7.x repository.&lt;br /&gt;
&lt;br /&gt;
===Apache performance===&lt;br /&gt;
* If you are using Apache on a Windows server, use the build from [http://www.apachelounge.com Apache Lounge] which is reported to have [http://moodle.org/mod/forum/discuss.php?d=93358 performance and stability improvements] compared to the official Apache download. Note that this is an unofficial build, so may not keep up with official releases.&lt;br /&gt;
* Set the &#039;&#039;&#039;MaxRequestWorkers&#039;&#039;&#039; directive correctly (&#039;&#039;&#039;MaxClients&#039;&#039;&#039; before Apache 2.4). Use this formula to help (which uses 80% of available memory to leave room for spare):&lt;br /&gt;
 MaxRequestWorkers = Total available memory * 80% / Max memory usage of apache process&lt;br /&gt;
:Memory usage of apache process is usually 10MB but Moodle can easily use up to 100MB per process, so a general rule of thumb is to divide your available memory in megabytes by 100 to get a conservative setting for MaxClients. You are quite likely to find yourself lowering the MaxRequestWorkers from its default of 150 on a Moodle server. To get a more accurate estimate read the value from the shell command:&lt;br /&gt;
 #ps -ylC httpd --sort:rss&lt;br /&gt;
&lt;br /&gt;
:If you need to increase the value of &#039;&#039;&#039;MaxRequestWorkers&#039;&#039;&#039; beyond 256, you will also need to set the &#039;&#039;&#039;ServerLimit&#039;&#039;&#039; directive. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Warning&#039;&#039;&#039;: Do not be tempted to set the value of MaxRequestWorkers higher than your available memory as your server will consume more RAM than available and start to swap to disk. &lt;br /&gt;
* Consider reducing the &#039;&#039;&#039;number of modules&#039;&#039;&#039; that Apache loads in the httpd.conf file to the minumum necessary to reduce the memory needed. &lt;br /&gt;
* Use the &#039;&#039;&#039;latest version of Apache&#039;&#039;&#039; - Apache 2 has an improved memory model which reduces memory usage further.&lt;br /&gt;
* For Unix/Linux systems, consider lowering &#039;&#039;&#039;MaxConnectionsPerChild&#039;&#039;&#039; (&#039;&#039;&#039;MaxRequestsPerChild&#039;&#039;&#039; before Apache 2.4) in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits). &lt;br /&gt;
* For a heavily loaded server, consider setting &#039;&#039;&#039;KeepAlive Off&#039;&#039;&#039; (do this only if your Moodle pages do not contain links to resources or uploaded images) or lowering the &#039;&#039;&#039;KeepAliveTimeout&#039;&#039;&#039; to between 2 and 5. The default is 15 (seconds) - the higher the value the more server processes will be kept waiting for possibly idle connections. A more accurate value for KeepAliveTimeout is obtained by observing how long it takes your users to download a page. After altering any of the KeepAlive variables, monitor your CPU utilization as there may be an additional overhead in initiating more worker processes/threads.&lt;br /&gt;
* As an alternative to using KeepAlive Off, consider setting-up a &#039;&#039;&#039;Reverse Proxy server&#039;&#039;&#039; infront of the Moodle server to cache HTML files with images. You can then return Apache to using keep-alives on the Moodle server.&lt;br /&gt;
* If you do not use a .htaccess file, set the &#039;&#039;&#039;AllowOverride&#039;&#039;&#039; variable to AllowOverride None to prevent .htaccess lookups.&lt;br /&gt;
* Set &#039;&#039;&#039;DirectoryIndex&#039;&#039;&#039; correctly so as to avoid content-negotiation. Here&#039;s an example from a production server:&lt;br /&gt;
 DirectoryIndex index.php index.html index.htm&lt;br /&gt;
* Unless you are doing development work on the server, set &#039;&#039;&#039;ExtendedStatus Off&#039;&#039;&#039; and disable mod_info as well as mod_status.&lt;br /&gt;
* Leave &#039;&#039;&#039;HostnameLookups Off&#039;&#039;&#039; (as default) to reduce DNS latency.&lt;br /&gt;
* Consider reducing the value of &#039;&#039;&#039;TimeOut&#039;&#039;&#039; to between 30 to 60 (seconds). &lt;br /&gt;
* For the &#039;&#039;&#039;Options directive&#039;&#039;&#039;, avoid Options Multiviews as this performs a directory scan. To reduce disk I/O further use&lt;br /&gt;
 Options -Indexes FollowSymLinks&lt;br /&gt;
&lt;br /&gt;
* Compression reduces response times by reducing the size of the HTTP response&lt;br /&gt;
# Install and enable mod_deflate - refer to documentation or man pages&lt;br /&gt;
# Add this code to the virtual server config file within the &amp;lt;directory&amp;gt; section for the root directory (or within the .htaccess file if AllowOverrides is On):&lt;br /&gt;
 &amp;lt;ifModule mod_deflate.c&amp;gt;&lt;br /&gt;
   AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/javascript text/css application/javascript&lt;br /&gt;
 &amp;lt;/ifmodule&amp;gt;&lt;br /&gt;
* Use Apache [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html event] [http://httpd.apache.org/docs/current/mpm.html MPM] (and not the default Prefork or Worker)&lt;br /&gt;
&lt;br /&gt;
===IIS performance===&lt;br /&gt;
All alter this location in the registry:&lt;br /&gt;
 HKLM\SYSTEM\CurrentControlSet\Services\Inetinfo\Parameters\&lt;br /&gt;
* The equivalent to KeepAliveTimeout is &#039;&#039;&#039;ListenBackLog&#039;&#039;&#039; (IIS - registry location is HKLM\ SYSTEM\ CurrentControlSet\ Services\ Inetinfo\ Parameters). Set this to between 2 to 5.&lt;br /&gt;
*Change the &#039;&#039;&#039;MemCacheSize&#039;&#039;&#039; value to adjust the amount of memory (Mb) that IIS will use for its file cache (50% of available memory by default).&lt;br /&gt;
*Change the &#039;&#039;&#039;MaxCachedFileSize&#039;&#039;&#039; to adjust the maximum size of a file cached in the file cache in bytes. Default is 262,144 (256K).&lt;br /&gt;
*Create a new DWORD called &#039;&#039;&#039;ObjectCacheTTL&#039;&#039;&#039; to change the length of time (in milliseconds) that objects in the cache are held in memory. Default is 30,000 milliseconds (30 seconds).&lt;br /&gt;
&lt;br /&gt;
===Lighttpd, NginX and Cherokee performance===&lt;br /&gt;
You can increase server performance by using a &#039;&#039;&#039;light-weight&#039;&#039;&#039; webserver like [http://www.lighttpd.net/ lighttpd],  [http://nginx.net/ nginx] or [http://www.cherokee-project.com/ cherokee] in combination with PHP in FastCGI-mode. Lighttpd was originally created as a proof-of-concept[http://www.lighttpd.net/story] to address the [http://www.kegel.com/c10k.html C10k problem] and while primarily recommended for memory-limited servers, its design origins and asynchronous-IO model make it a suitable and proven[http://blog.lighttpd.net/articles/2006/12/28/lighttpd-powers-5-alexa-top-250-sites] alternative HTTP server for high-load websites and web apps, including Moodle. See the [[lighttpd | MoodleDocs Lighttpd page]] for additional information, configuration example and links.&lt;br /&gt;
&lt;br /&gt;
Alternatively, both [http://www.lighttpd.net/ lighttpd] and [http://nginx.net/ nginx] are capable of performing as a load-balancer and/or reverse-proxy to alleviate load on back-end servers[http://www.linuxjournal.com/article/10108], providing benefit without requiring an actual software change on existing servers.&lt;br /&gt;
&lt;br /&gt;
Do note that these are likely to be the least tested server environments of all particularly if you are using advanced features such as web services and/or Moodle Networking. They are probably best considered for heavily used Moodle sites with relatively simple configurations.&lt;br /&gt;
&lt;br /&gt;
===X-Sendfile===&lt;br /&gt;
&lt;br /&gt;
X-Sendfile modules improve performance when sending large files from Moodle. It is recommended to configure your web server and Moodle to use this feature of available.&lt;br /&gt;
&lt;br /&gt;
Configure web server:&lt;br /&gt;
* Apache - https://tn123.org/mod_xsendfile/&lt;br /&gt;
* Lighttpd - http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file&lt;br /&gt;
* Nginx - http://wiki.nginx.org/XSendfile&lt;br /&gt;
&lt;br /&gt;
Enable support in config.php (see config-dist.php):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-Sendfile&#039;;           // Apache {@see https://tn123.org/mod_xsendfile/}&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-LIGHTTPD-send-file&#039;; // Lighttpd {@see http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file}&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-Accel-Redirect&#039;;     // Nginx {@see http://wiki.nginx.org/XSendfile}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure file location prefixes if your server implementation requires it:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//     $CFG-&amp;gt;xsendfilealiases = array(&lt;br /&gt;
//         &#039;/dataroot/&#039; =&amp;gt; $CFG-&amp;gt;dataroot,&lt;br /&gt;
//         &#039;/cachedir/&#039; =&amp;gt; &#039;/var/www/moodle/cache&#039;,    // for custom $CFG-&amp;gt;cachedir locations&lt;br /&gt;
//         &#039;/localcachedir/&#039; =&amp;gt; &#039;/var/local/cache&#039;,    // for custom $CFG-&amp;gt;localcachedir locations&lt;br /&gt;
//         &#039;/tempdir/&#039;  =&amp;gt; &#039;/var/www/moodle/temp&#039;,     // for custom $CFG-&amp;gt;tempdir locations&lt;br /&gt;
//         &#039;/filedir&#039;   =&amp;gt; &#039;/var/www/moodle/filedir&#039;,  // for custom $CFG-&amp;gt;filedir locations&lt;br /&gt;
//     );&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database performance==&lt;br /&gt;
&lt;br /&gt;
===MySQL performance===&lt;br /&gt;
&lt;br /&gt;
The following are MySQL specific settings which can be adjusted for better performance in your my.cnf (my.ini in Windows). The file contains a list of settings and their values. To see the current values use these commands&lt;br /&gt;
 SHOW STATUS;&lt;br /&gt;
 SHOW VARIABLES; &lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: You must make backups of your database before attempting to change any MySQL server configuration. After any change to the my.cnf, restart mysqld.&lt;br /&gt;
&lt;br /&gt;
If you are able, the [http://mysqltuner.com/ MySQLTuner] tool can be run against your MySQL server and will calculate appropriate configuration values for most of the following settings based on your current load, status and variables automatically.&lt;br /&gt;
&lt;br /&gt;
* Enable the &#039;&#039;&#039;query cache&#039;&#039;&#039; with &lt;br /&gt;
 query_cache_type = 1. &lt;br /&gt;
For most Moodle installs, set the following:&lt;br /&gt;
 query_cache_size = 36M &lt;br /&gt;
 query_cache_min_res_unit = 2K. &lt;br /&gt;
The query cache will improve performance if you are doing few updates on the database. &lt;br /&gt;
* Set the &#039;&#039;&#039;table cache&#039;&#039;&#039; correctly. For Moodle 1.6 set &lt;br /&gt;
 table_cache = 256 #(table_open_cache in MySQL &amp;gt; 5.1.2)&lt;br /&gt;
(min), and for Moodle 1.7 set &lt;br /&gt;
 table_cache = 512 #(table_open_cache in MySQL &amp;gt; 5.1.2)&lt;br /&gt;
(min). The table cache is used by all threads (connections), so monitor the value of opened_tables to further adjust - if opened_tables &amp;gt; 3 * table_cache(table_open_cache in MySQL &amp;gt; 5.1.2) then increase table_cache upto your OS limit. Note also that the figure for table_cache will also change depending on the number of modules and plugins you have installed. Find the number for your server by executing the mysql statement below. Look at the number returned and set table_cache to this value.&lt;br /&gt;
 mysql&amp;gt;SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema=&#039;yourmoodledbname&#039;;&lt;br /&gt;
* Set the &#039;&#039;&#039;thread cache&#039;&#039;&#039; correctly. Adjust the value so that your thread cache utilization is as close to 100% as possible by this formula:&lt;br /&gt;
 thread cache utilization (%) = (threads_created / connections) * 100&lt;br /&gt;
* The &#039;&#039;&#039;key buffer&#039;&#039;&#039; can improve the access speed to Moodle&#039;s SELECT queries. The correct size depends on the size of the index files (.myi) and in Moodle 1.6 or later (without any additional modules and plugins), the recommendation for this value is key_buffer_size = 32M. Ideally you want the database to be reading once from the disk for every 100 requests so monitor that the value is suitable for your install by adjusting the value of key_buffer_size so that the following formulas are true:&lt;br /&gt;
 key_read / key_read_requests &amp;lt; 0.01&lt;br /&gt;
 key_write / key_write_requests &amp;lt;= 1.0&lt;br /&gt;
* Set the &#039;&#039;&#039;maximum number of connections&#039;&#039;&#039; so that your users will not see a &amp;quot;Too many connections&amp;quot; message. Be careful that this may have an impact on the total memory used. MySQL connections usually last for milliseconds, so it is unusual even for a heavily loaded server for this value to be over 200.&lt;br /&gt;
* Manage &#039;&#039;&#039;high burst activity&#039;&#039;&#039;. If your Moodle install uses a lot of quizzes and you are experiencing performance problems (check by monitoring the value of threads_connected - it should not be rising) consider increasing the value of back_log.&lt;br /&gt;
* &#039;&#039;&#039;Optimize your tables weekly and after upgrading Moodle&#039;&#039;&#039;. It is good practice to also optimize your tables after performing a large data deletion exercise, e.g. at the end of your semester or academic year. This will ensure that index files are up to date. Backup your database first and then use:&lt;br /&gt;
 mysql&amp;gt;CHECK TABLE mdl_tablename;&lt;br /&gt;
 mysql&amp;gt;OPTIMIZE TABLE mdl_tablename;&lt;br /&gt;
:The common tables in Moodle to check are mdl_course_sections, mdl_forum_posts, mdl_log and mdl_sessions (if using dbsessions). Any errors need to be corrected using REPAIR TABLE (see the [http://dev.mysql.com/doc/refman/5.0/en/repair-table.html MySQL manual] and this [http://moodle.org/mod/forum/discuss.php?d=58208#p279638 forum script]).&lt;br /&gt;
* &#039;&#039;&#039;Maintain the key distribution&#039;&#039;&#039;. Every month or so it is a good idea to stop the mysql server and run these myisamchk commands.&lt;br /&gt;
 #myisamchk -a -S /pathtomysql/data/moodledir/*.MYI&lt;br /&gt;
:&#039;&#039;&#039;Warning&#039;&#039;&#039;: You must stop the mysql database process (mysqld) before running any myisamchk command. If you do not, you risk data loss.&lt;br /&gt;
* Reduce the number of &#039;&#039;&#039;temporary tables saved to disk&#039;&#039;&#039;. Check this with the created_tmp_disk_tables value. If this is relatively large (&amp;gt;5%) increase tmp_table_size until you see a reduction. Note that this will have an impact on RAM usage.&lt;br /&gt;
&lt;br /&gt;
===PostgreSQL performance===&lt;br /&gt;
&lt;br /&gt;
There are some good papers around on tuning PostgreSQL (like [http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server this one]), and Moodle&#039;s case does not seem to be different to the general case.&lt;br /&gt;
&lt;br /&gt;
The first thing to recognise is that if you really need to worry about tuning you should be using a separate machine for the database server. If you are not using a separate machine then the answers to many performance questions are substantially muddied by the memory requirements of the rest of the application.&lt;br /&gt;
&lt;br /&gt;
You should probably &#039;&#039;&#039;enable autovacuum&#039;&#039;&#039;, unless you know what you are doing. Many e-learning sites have predictable periods of low use, so disabling autovacuum and running a specific vacuum at those times can be a good option. Or perhaps leave autovacuum running but do a full vacuum weekly in a quiet period.&lt;br /&gt;
&lt;br /&gt;
Set &#039;&#039;&#039;shared_buffers&#039;&#039;&#039; to something reasonable. For versions up to 8.1 my testing has shown that peak performance is almost always obtained with buffers &amp;lt; 10000, so if you are using such a version, and have more than 512M of RAM just set shared_buffers to 10,000 (8MB).&lt;br /&gt;
&lt;br /&gt;
The buffer management had a big overhaul in 8.2 and &amp;quot;reasonable&amp;quot; is now a much larger number. I have not conducted performance tests with 8.2, but the recommendations from others are generally that you should now scale shared_buffers much more with memory and may continue to reap benefits even up to values like 100,000 (80MB). Consider using 1-2% of system RAM.&lt;br /&gt;
&lt;br /&gt;
PostgreSQL will also assume that the operating system is caching its files, so setting &#039;&#039;&#039;effective_cache_size&#039;&#039;&#039; to a reasonable value is also a good idea. A reasonable value will usually be (total RAM - RAM in use by programs). If you are running Linux and leave the system running for a day or two you can look at &#039;free&#039; and under the &#039;cached&#039; column you will see what it currently is. Consider taking that number (which is kB) and dividing it by 10 (i.e. allow 20% for other programs cache needs and then divide by 8 to get pages). If you are not using a dedicated database server you will need to decrease that value to account for usage by other programs.&lt;br /&gt;
&lt;br /&gt;
Some other useful parameters that can have positive effects, and the values I would typically set them to on a machine with 4G RAM, are:&lt;br /&gt;
&lt;br /&gt;
 work_mem = 10240&lt;br /&gt;
&lt;br /&gt;
That&#039;s 10M of RAM to use instead of on-disk sorting and so forth. That can give a big speed increase, but it is per connection and 200 connections * 10M is 2G, so it can theoretically chew up a lot of RAM.&lt;br /&gt;
&lt;br /&gt;
 maintenance_work_mem = 163840&lt;br /&gt;
&lt;br /&gt;
That&#039;s 160M of RAM which will be used by (e.g.) VACUUM, index rebuild, cluster and so forth. This should only be used periodically and should be freed when those processes exit, so I believe it is well worth while.&lt;br /&gt;
&lt;br /&gt;
 wal_buffers = 64&lt;br /&gt;
&lt;br /&gt;
These buffers are used for the write-ahead log, and there have been a number of reports on the PostgreSQL mailing lists of improvement from this level of increase.&lt;br /&gt;
&lt;br /&gt;
This is a little out of date now (version 8.0) but still worth a read: http://www.powerpostgresql.com/Docs&lt;br /&gt;
&lt;br /&gt;
And there is lots of good stuff here as well: http://www.varlena.com/GeneralBits/Tidbits/index.php&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Based on Andrew McMillan&#039;s post at [http://moodle.org/mod/forum/discuss.php?d=68558 Tuning PostgreSQL] forum thread.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Splitting &#039;&#039;&#039;mdl_log&#039;&#039;&#039; to several tables and using a VIEW with UNION to read them as one. (See Tim Hunt [https://moodle.org/mod/forum/discuss.php?d=243531#p1104165 explanation] on the Moodle forums)&lt;br /&gt;
&lt;br /&gt;
===Other database performance links===&lt;br /&gt;
* Consider using a &#039;&#039;&#039;distributed cacheing system&#039;&#039;&#039; like [http://en.wikipedia.org/wiki/Memcached memcached] but note that memcached does not have any security features so it should be used behind a firewall.&lt;br /&gt;
* Consider using PostgreSQL. See [[Arguments in favour of PostgreSQL]] and [http://moodle.org/mod/forum/discuss.php?d=49195 how to migrate from MySQL to PostgreSQL] (forum discussion).&lt;br /&gt;
* [http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html General advice on tuning MySQL parameters] (advice from the MySQL manual)&lt;br /&gt;
* [http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/ InnoDB performance optimization] taken from the [http://www.mysqlperformanceblog.com/ MySQL performance blog] site.&lt;br /&gt;
&lt;br /&gt;
==Performance of different Moodle modules==&lt;br /&gt;
&lt;br /&gt;
Moodle&#039;s activity modules, filters, and other plugins can be activated/deactivated. If necessary, you may wish to deactivate some features (such as chat) if not required - but this isn&#039;t necessary. Some notes on the performance of certain modules:&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;Chat&#039;&#039;&#039; module is [http://moodle.org/mod/forum/discuss.php?d=37979&amp;amp;parent=175079 said] to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use &#039;&#039;Streamed&#039;&#039; updates, or, if you&#039;re using a Unix-based webserver, by running the chat in daemon mode. When using the Chat module use the configuration settings to tune for your expected load. Pay particular attention to the &#039;&#039;chat_old_ping&#039;&#039; and &#039;&#039;chat_refresh&#039;&#039; parameters as these can have greatest impact on server load.&lt;br /&gt;
* The Moodle &#039;&#039;&#039;Cron&#039;&#039;&#039; task is triggered by calling the script &#039;&#039;cron.php&#039;&#039;. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. &#039;&#039;php -f /path/to/moodle/directory/admin/cli/cron.php&#039;&#039;) efficiency can be much improved.&lt;br /&gt;
* The &#039;&#039;&#039;Recent activities&#039;&#039;&#039; block is consuming too many resources if you have huge number of records &amp;lt;code&amp;gt;mdl_log&amp;lt;/code&amp;gt;. This is being tested to optimize the SQL query.&lt;br /&gt;
* The &#039;&#039;&#039;Quiz&#039;&#039;&#039; module is known to stretch database performance. However, it has been getting better in recent versions, and we don&#039;t know of any good, up-to-date performance measurements. (Here is a [http://moodle.org/mod/forum/discuss.php?d=68579 case study from 2007 with 300 quiz users].). The following suggestions were described by [https://moodle.org/user/view.php?id=94615&amp;amp;course=5 Al Rachels] in [https://moodle.org/mod/forum/discuss.php?d=347126 this forum thread]:&lt;br /&gt;
** make sure both Moodle, and the operating system, are installed on a [https://en.wikipedia.org/wiki/Solid-state_drive solid state drive]&lt;br /&gt;
** upgrade to and use [https://docs.moodle.org/dev/Moodle_and_PHP7 PHP 7]&lt;br /&gt;
** run MySQLTuner and implement its recommendations&lt;br /&gt;
&lt;br /&gt;
See [[Performance settings]] for more information on performance-related Moodle settings.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*Using Moodle: [http://moodle.org/mod/forum/view.php?f=94 Hardware and Performance] forum&lt;br /&gt;
*[http://opensourceelearning.blogspot.be/2012/10/why-your-moodle-site-is-slow-five.html Why Your Moodle Site is Slow: Five Simple Settings] blog post from Jonathan Moore &lt;br /&gt;
*I teach with Moodle perfomance testing: http://www.iteachwithmoodle.com/2012/11/17/moodle-2-4-beta-performance-test-comparison-with-moodle-2-3/&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.2 performance and MUC APC cahe store]&lt;br /&gt;
*[http://jfilip.ca/2013/09/25/moodle-performance-testing-2-4-6-vs-2-5-2-vs-2-6dev/ Moodle performance testing 2.4.6 vs 2.5.2 vs 2.6dev]&lt;br /&gt;
*[http://jfilip.ca/2013/09/24/moodle-performance-analysis-revisted-now-with-mariadb/ Moodle performance analysis revisited (now with MariaDB)]&lt;br /&gt;
*[http://tjhunt.blogspot.ca/2013/05/performance-testing-moodle.html Tim Hunt&#039;s blog (May 2, 2013) on performance testing Moodle]&lt;br /&gt;
*[http://newrelic.com/ New Relic, Application Performance Monitoring]&lt;br /&gt;
*[http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html Performance enhacements for Apache and PHP (Apache Event MPM and PHP-FPM)]&lt;br /&gt;
*[https://scholarlms.net/performance-recommendations/ Performance recommendations]&lt;br /&gt;
&lt;br /&gt;
There have been a lot of discussions on moodle.org about performance, here are some of the more interesting and (potentially) useful ones:&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=83057 Performance woes!]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=57028 Performance perspectives - a little script]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=88927 Comments on planned server hardware]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=102978#p461624 Moodle performance in a pil by Martin Langhoff]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=240391#unread Advice on optimising php/db code in moodle2+]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=243531 Moodle 2.5 performance testing at the OU]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=273602 100 active users limit with 4vCPU]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=336603#p1356423 Performance Tip ... shared...]&lt;br /&gt;
&lt;br /&gt;
[[es:Recomendaciones sobre desempeño]]&lt;br /&gt;
[[fr:Performance]]&lt;br /&gt;
[[ja:パフォーマンス]]&lt;br /&gt;
[[de:Geschwindigkeitsempfehlungen]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Performance_recommendations&amp;diff=135613</id>
		<title>Performance recommendations</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Performance_recommendations&amp;diff=135613"/>
		<updated>2019-09-30T08:07:09Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Scalability */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Performance}}&lt;br /&gt;
Moodle can be made to perform very well, at small usage levels or scaling up to many thousands of users. The factors involved in performance are basically the same as for any PHP-based database-driven system. When trying to optimize your server, try to focus on the factor which will make the most difference to the user. For example, if you have relatively more users browsing than accessing the database, look to improve the webserver performance.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Obtain a baseline benchmark==&lt;br /&gt;
&lt;br /&gt;
Before attempting any optimization, you should obtain a baseline benchmark of the component of the system you are trying to improve. For Linux try [http://lbs.sourceforge.net/ LBS] and for Windows use the Performance Monitor. Once you have quantitative data about how your system is performing currently, you&#039;ll be able to determine if the change you have made has had any real impact.&lt;br /&gt;
&lt;br /&gt;
The overall aim of adjustments to improve performance is to use RAM (cacheing) and to reduce disk-based activity. It is especially important to try to eliminate swap file usage as much as you can. If your system starts swapping, this is a sign that you need more RAM. &lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;optimization order preference&#039;&#039;&#039; is usually: primary storage (more RAM), secondary storage (faster hard disks/improved hard disk configuration), processor (more and faster).&lt;br /&gt;
&lt;br /&gt;
It can be interesting to install and use the [https://moodle.org/plugins/report_benchmark Benchmark plugin] in order to find the bottlenecks of your system that specifically affect Moodle.&lt;br /&gt;
&lt;br /&gt;
==Scalability==&lt;br /&gt;
&lt;br /&gt;
Moodle&#039;s design (with clear separation of application layers) allows for strongly scalable setups. (Please check the list of [[Large installations|large Moodle installations]].)&lt;br /&gt;
&lt;br /&gt;
Large sites usually separate the web server and database onto separate servers, although for smaller installations this is typically not necessary.&lt;br /&gt;
&lt;br /&gt;
It is possible to load-balance a Moodle installation, for example by using more than one webserver. The separate webservers should query the same database and refer to the same filestore and cache areas (see [[Caching]]), but otherwise the separation of the application layers is complete enough to make this kind of clustering feasible. Similarly, the database could be a cluster of servers (e.g. a MySQL cluster), but this is not an easy task and you should seek expert support, e.g. from a Moodle Partner.&lt;br /&gt;
&lt;br /&gt;
On very large, load-balanced, systems the performance of the shared components become critical. It&#039;s important that your shared file areas are properly tuned and that you use an effective cache (Redis is highly recommended). A good understanding of these areas of system administration should be considered a minimum requirement. &lt;br /&gt;
&lt;br /&gt;
===Server cluster===&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=57202 Moodle clustering]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=44470 Software load balancing]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=49986 TCP load balancing]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=88214 Installation for 3000 simultaneous users]&lt;br /&gt;
&lt;br /&gt;
==Hardware configuration==&lt;br /&gt;
&#039;&#039;&#039;Note&#039;&#039;&#039;: The fastest and most effective change that you can make to improve performance is to &#039;&#039;&#039;increase the amount of RAM on your web server&#039;&#039;&#039; - get as much as possible (e.g. 4GB or more). Increasing primary memory will reduce the need for processes to swap to disk and will enable your server to handle more users.&lt;br /&gt;
* Better performance is gained by obtaining the best &#039;&#039;&#039;processor capability&#039;&#039;&#039; you can, i.e. dual or dual core processors. A modern BIOS should allow you to enable hyperthreading, but check if this makes a difference to the overall performance of the processors by using a [http://en.wikipedia.org/wiki/Super_PI CPU benchmarking tool].&lt;br /&gt;
* If you can afford them, use &#039;&#039;&#039;SCSI hard disks&#039;&#039;&#039; instead of SATA drives. SATA drives will increase your system&#039;s CPU utilization, whereas SCSI drives have their own integrated processors and come into their own when you have multiple drives. If you must have SATA drives, check that your motherboard and the drives themselves support NCQ (Native Command Queuing).&lt;br /&gt;
* Purchase hard disks with a &#039;&#039;&#039;low seek time&#039;&#039;&#039;. This will improve the overall speed of your system, especially when accessing Moodle&#039;s reports.&lt;br /&gt;
* Size your &#039;&#039;&#039;swap file&#039;&#039;&#039; correctly. The general advice is to set it to 4 x physical RAM.&lt;br /&gt;
* Use a &#039;&#039;&#039;RAID disk system&#039;&#039;&#039;. Although there are many different RAID configurations you can create, the following generally works best:&lt;br /&gt;
** install a hardware RAID controller (if you can)&lt;br /&gt;
** the operating system and swap drive on one set of disks configured as RAID-1.&lt;br /&gt;
** Moodle, Web server and Database server on another set of disks configured as RAID-5.&lt;br /&gt;
* If your &#039;moodledata&#039; area is going to be on relatively slow storage (e.g. NFS mount on to a NAS device) you will probably have performance issues with the default cache configuration (which writes to this storage). See the page on [[Caching]] and consider an alternative. Using [https://en.wikipedia.org/wiki/GlusterFS GlusterFS] / [https://en.wikipedia.org/wiki/OCFS2 OCFS2] / [https://en.wikipedia.org/wiki/GFS2 GFS2] on a [https://en.wikipedia.org/wiki/Storage_Area_Network SAN] device and [https://en.wikipedia.org/wiki/Fibre_Channel Fiber Channel] could improve performance (See more info on the Moodle [https://moodle.org/mod/forum/discuss.php?d=214680#p1123124 forum thread], [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 NFS performance tuing] )&lt;br /&gt;
* Use &#039;&#039;&#039;gigabit ethernet&#039;&#039;&#039; for improved latency and throughput. This is especially important when you have your webserver and database server separated out on different hosts.&lt;br /&gt;
* Check the settings on your &#039;&#039;&#039;network card&#039;&#039;&#039;. You may get an improvement in performance by increasing the use of buffers and transmit/receive descriptors (balance this with processor and memory overheads) and off-loading TCP checksum calculation onto the card instead of the OS.&lt;br /&gt;
*  Read this [http://moodle.org/mod/forum/discuss.php?d=68579 Case Study] on a server stress test with 300 users.  &lt;br /&gt;
* See this [http://elearning.sgu.ac.jp/doc/PT/ accompanying report] on network traffic and server loads.&lt;br /&gt;
* Also see this SFSU presentation at Educause (using VMWare): [http://www.educause.edu/Resources/AnOpenSourceLMSforaMissionCrit/162843]&lt;br /&gt;
&lt;br /&gt;
==Operating System==&lt;br /&gt;
* You can use [http://en.wikipedia.org/wiki/Linux Linux](recommended), Unix-based, Windows or Mac OS X for the server &#039;&#039;&#039;operating system&#039;&#039;&#039;. *nix operating systems generally require less memory than Mac OS X or Windows servers for doing the same task as the server is configured with just a shell interface. Additionally Linux does not have licensing fees attached, but can have a big learning curve if you&#039;re used to another operating system. If you have a large number of processors running SMP, you may also want to consider using a highly tuned OS such as [http://en.wikipedia.org/wiki/Solaris_Operating_Environment Solaris].&lt;br /&gt;
* Check your own OS and &#039;&#039;&#039;vendor specific instructions&#039;&#039;&#039; for optimization steps.&lt;br /&gt;
** For Linux look at the [http://linuxperf.sourceforge.net/ Linux Performance Team] site. &lt;br /&gt;
** For Linux investigate the hdparm command, e.g. hdparm -m16 -d1 can be used to enable read/write on multiple sectors and DMA. Mount disks with the [https://moodle.org/mod/forum/discuss.php?d=310501#p1242382 &amp;quot;async&amp;quot; and &amp;quot;noatime&amp;quot;] options.&lt;br /&gt;
** For Windows set the sever to be optimized for network applications (Control Panel, Network Connections, LAN connection, Properties, File &amp;amp; Printer Sharing for Microsoft Networks, Properties, Optimization). You can also search the [http://technet.microsoft.com/ Microsoft TechNet site] for optimization documents.&lt;br /&gt;
&lt;br /&gt;
==Web server performance==&lt;br /&gt;
&lt;br /&gt;
Installing [http://www.mozilla.com/en-US/ Firefox] and the [https://addons.mozilla.org/en-US/firefox/addon/1843 firebug] extension will allow you to watch the time it takes for each page component to load. Also, the [https://addons.mozilla.org/en-US/firefox/addon/5369 Yslow] extension will evaluate your page against Yahoo&#039;s [http://www.skrenta.com/2007/05/14_rules_for_fast_web_pages_by_1.html 14 rules], full text [http://developer.yahoo.com/performance/rules.html Best Practices for Speeding Up Your Web Site], &amp;lt;strike&amp;gt;([http://video.yahoo.com/video/play?vid=1040890 video])&amp;lt;/strike&amp;gt; for fast loading websites.&lt;br /&gt;
&lt;br /&gt;
===PHP performance===&lt;br /&gt;
* You are strongly recommended to use a &#039;&#039;&#039;PHP accelerator&#039;&#039;&#039; to ease CPU load, such as [http://pecl.php.net/apc APC], [http://www.php-accelerator.co.uk/ PHPA], [http://trac.lighttpd.net/xcache/ Xcache], [http://sourceforge.net/projects/wincache WinCache] or [http://eaccelerator.net/ eAccelerator]. (Take care to choose a PHP accelerator that is known to work well with your version of PHP and note that Turck MMCache is [http://turckmmcache.exeprod.com/TheManifestoEnglish no longer maintained] and can cause failures with PHP 5). PHP 5.5 (and newer) includes OpCache and is fully supported and recommended by Moodle&lt;br /&gt;
* Improvements in read/write performance can be improved by putting the cached PHP pages on a [[TMPFS]] filesystem - but remember that you&#039;ll lose the cache contents when there is a power failure or the server is rebooted.&lt;br /&gt;
* Performance of PHP is better when installed as an &#039;&#039;&#039;Apache/IIS6 ISAPI module&#039;&#039;&#039; (rather than a CGI). IIS 7.0/7.5 (Windows Server 2008/R2) users should choose a FastCGI installation for best performance.&lt;br /&gt;
* Also check the &#039;&#039;&#039;memory_limit&#039;&#039;&#039; in php.ini, reduce it to 16M for Moodle version earlier than 1.7 ([http://moodle.org/mod/forum/discuss.php?d=39656 See this forum discussion]). For Moodle 1.7 or later, it is recommended that the value of memory_limit should be 40M. As of [http://www.php.net/ChangeLog-5.php PHP 5.2.1] the default value for the memory_limit directive is 128M.&lt;br /&gt;
* Also see [[PHP_settings_by_Moodle_version]]&lt;br /&gt;
* Use [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html PHP-FPM] (with apache).&lt;br /&gt;
&lt;br /&gt;
===Install HowTo===&lt;br /&gt;
==== APC ====&lt;br /&gt;
* [http://2bits.com/articles/installing-php-apc-gnulinux-centos-5.html APC on CentOS 5.x (linux)]&lt;br /&gt;
* [http://fplanque.com/dev/linux/install-apc-php-cache-debian-lenny APC on Debian (linux)]&lt;br /&gt;
==== eAccelerator ====&lt;br /&gt;
* [http://noveckg.blogspot.com/2010/02/installing-eaccelerator-cache-for-php.html Installing eAccelerator on CentOS 5.x (linux)]&lt;br /&gt;
* [https://docs.moodle.org/en/Installing_eAccelerator_In_Ubuntu_Server/ Installing eAccelerator on Ubuntu Server (linux)]&lt;br /&gt;
==== MemCached ====&lt;br /&gt;
Memcached server (daemon)&lt;br /&gt;
* [https://www.tecmint.com/install-memcached-on-centos-7/ Installing Memcached on CentOS 7.x (linux)] (as of php 7.x, only memcached is available)&lt;br /&gt;
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-memcached-on-centos-7 How To Install and Secure Memcached on CentOS 7]&lt;br /&gt;
* [https://wiki.zimbra.com/wiki/Blocking_Memcached_Attack#Iptables_rules_for_Redhat_based_servers Iptables rules for Redhat based servers]&lt;br /&gt;
Memcached PHP 7.1 extension &lt;br /&gt;
* [https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/repoview/php71u-pecl-memcached.html php71u-pecl-memcached] from IUS CentOS 7.x repository.&lt;br /&gt;
&lt;br /&gt;
===Apache performance===&lt;br /&gt;
* If you are using Apache on a Windows server, use the build from [http://www.apachelounge.com Apache Lounge] which is reported to have [http://moodle.org/mod/forum/discuss.php?d=93358 performance and stability improvements] compared to the official Apache download. Note that this is an unofficial build, so may not keep up with official releases.&lt;br /&gt;
* Set the &#039;&#039;&#039;MaxRequestWorkers&#039;&#039;&#039; directive correctly (&#039;&#039;&#039;MaxClients&#039;&#039;&#039; before Apache 2.4). Use this formula to help (which uses 80% of available memory to leave room for spare):&lt;br /&gt;
 MaxRequestWorkers = Total available memory * 80% / Max memory usage of apache process&lt;br /&gt;
:Memory usage of apache process is usually 10MB but Moodle can easily use up to 100MB per process, so a general rule of thumb is to divide your available memory in megabytes by 100 to get a conservative setting for MaxClients. You are quite likely to find yourself lowering the MaxRequestWorkers from its default of 150 on a Moodle server. To get a more accurate estimate read the value from the shell command:&lt;br /&gt;
 #ps -ylC httpd --sort:rss&lt;br /&gt;
&lt;br /&gt;
:If you need to increase the value of &#039;&#039;&#039;MaxRequestWorkers&#039;&#039;&#039; beyond 256, you will also need to set the &#039;&#039;&#039;ServerLimit&#039;&#039;&#039; directive. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Warning&#039;&#039;&#039;: Do not be tempted to set the value of MaxRequestWorkers higher than your available memory as your server will consume more RAM than available and start to swap to disk. &lt;br /&gt;
* Consider reducing the &#039;&#039;&#039;number of modules&#039;&#039;&#039; that Apache loads in the httpd.conf file to the minumum necessary to reduce the memory needed. &lt;br /&gt;
* Use the &#039;&#039;&#039;latest version of Apache&#039;&#039;&#039; - Apache 2 has an improved memory model which reduces memory usage further.&lt;br /&gt;
* For Unix/Linux systems, consider lowering &#039;&#039;&#039;MaxConnectionsPerChild&#039;&#039;&#039; (&#039;&#039;&#039;MaxRequestsPerChild&#039;&#039;&#039; before Apache 2.4) in httpd.conf to as low as 20-30 (if you set it any lower the overhead of forking begins to outweigh the benefits). &lt;br /&gt;
* For a heavily loaded server, consider setting &#039;&#039;&#039;KeepAlive Off&#039;&#039;&#039; (do this only if your Moodle pages do not contain links to resources or uploaded images) or lowering the &#039;&#039;&#039;KeepAliveTimeout&#039;&#039;&#039; to between 2 and 5. The default is 15 (seconds) - the higher the value the more server processes will be kept waiting for possibly idle connections. A more accurate value for KeepAliveTimeout is obtained by observing how long it takes your users to download a page. After altering any of the KeepAlive variables, monitor your CPU utilization as there may be an additional overhead in initiating more worker processes/threads.&lt;br /&gt;
* As an alternative to using KeepAlive Off, consider setting-up a &#039;&#039;&#039;Reverse Proxy server&#039;&#039;&#039; infront of the Moodle server to cache HTML files with images. You can then return Apache to using keep-alives on the Moodle server.&lt;br /&gt;
* If you do not use a .htaccess file, set the &#039;&#039;&#039;AllowOverride&#039;&#039;&#039; variable to AllowOverride None to prevent .htaccess lookups.&lt;br /&gt;
* Set &#039;&#039;&#039;DirectoryIndex&#039;&#039;&#039; correctly so as to avoid content-negotiation. Here&#039;s an example from a production server:&lt;br /&gt;
 DirectoryIndex index.php index.html index.htm&lt;br /&gt;
* Unless you are doing development work on the server, set &#039;&#039;&#039;ExtendedStatus Off&#039;&#039;&#039; and disable mod_info as well as mod_status.&lt;br /&gt;
* Leave &#039;&#039;&#039;HostnameLookups Off&#039;&#039;&#039; (as default) to reduce DNS latency.&lt;br /&gt;
* Consider reducing the value of &#039;&#039;&#039;TimeOut&#039;&#039;&#039; to between 30 to 60 (seconds). &lt;br /&gt;
* For the &#039;&#039;&#039;Options directive&#039;&#039;&#039;, avoid Options Multiviews as this performs a directory scan. To reduce disk I/O further use&lt;br /&gt;
 Options -Indexes FollowSymLinks&lt;br /&gt;
&lt;br /&gt;
* Compression reduces response times by reducing the size of the HTTP response&lt;br /&gt;
# Install and enable mod_deflate - refer to documentation or man pages&lt;br /&gt;
# Add this code to the virtual server config file within the &amp;lt;directory&amp;gt; section for the root directory (or within the .htaccess file if AllowOverrides is On):&lt;br /&gt;
 &amp;lt;ifModule mod_deflate.c&amp;gt;&lt;br /&gt;
   AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/javascript text/css application/javascript&lt;br /&gt;
 &amp;lt;/ifmodule&amp;gt;&lt;br /&gt;
* Use Apache [http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html event] [http://httpd.apache.org/docs/current/mpm.html MPM] (and not the default Prefork or Worker)&lt;br /&gt;
&lt;br /&gt;
===IIS performance===&lt;br /&gt;
All alter this location in the registry:&lt;br /&gt;
 HKLM\SYSTEM\CurrentControlSet\Services\Inetinfo\Parameters\&lt;br /&gt;
* The equivalent to KeepAliveTimeout is &#039;&#039;&#039;ListenBackLog&#039;&#039;&#039; (IIS - registry location is HKLM\ SYSTEM\ CurrentControlSet\ Services\ Inetinfo\ Parameters). Set this to between 2 to 5.&lt;br /&gt;
*Change the &#039;&#039;&#039;MemCacheSize&#039;&#039;&#039; value to adjust the amount of memory (Mb) that IIS will use for its file cache (50% of available memory by default).&lt;br /&gt;
*Change the &#039;&#039;&#039;MaxCachedFileSize&#039;&#039;&#039; to adjust the maximum size of a file cached in the file cache in bytes. Default is 262,144 (256K).&lt;br /&gt;
*Create a new DWORD called &#039;&#039;&#039;ObjectCacheTTL&#039;&#039;&#039; to change the length of time (in milliseconds) that objects in the cache are held in memory. Default is 30,000 milliseconds (30 seconds).&lt;br /&gt;
&lt;br /&gt;
===Lighttpd, NginX and Cherokee performance===&lt;br /&gt;
You can increase server performance by using a &#039;&#039;&#039;light-weight&#039;&#039;&#039; webserver like [http://www.lighttpd.net/ lighttpd],  [http://nginx.net/ nginx] or [http://www.cherokee-project.com/ cherokee] in combination with PHP in FastCGI-mode. Lighttpd was originally created as a proof-of-concept[http://www.lighttpd.net/story] to address the [http://www.kegel.com/c10k.html C10k problem] and while primarily recommended for memory-limited servers, its design origins and asynchronous-IO model make it a suitable and proven[http://blog.lighttpd.net/articles/2006/12/28/lighttpd-powers-5-alexa-top-250-sites] alternative HTTP server for high-load websites and web apps, including Moodle. See the [[lighttpd | MoodleDocs Lighttpd page]] for additional information, configuration example and links.&lt;br /&gt;
&lt;br /&gt;
Alternatively, both [http://www.lighttpd.net/ lighttpd] and [http://nginx.net/ nginx] are capable of performing as a load-balancer and/or reverse-proxy to alleviate load on back-end servers[http://www.linuxjournal.com/article/10108], providing benefit without requiring an actual software change on existing servers.&lt;br /&gt;
&lt;br /&gt;
Do note that these are likely to be the least tested server environments of all particularly if you are using advanced features such as web services and/or Moodle Networking. They are probably best considered for heavily used Moodle sites with relatively simple configurations.&lt;br /&gt;
&lt;br /&gt;
===X-Sendfile===&lt;br /&gt;
&lt;br /&gt;
X-Sendfile modules improve performance when sending large files from Moodle. It is recommended to configure your web server and Moodle to use this feature of available.&lt;br /&gt;
&lt;br /&gt;
Configure web server:&lt;br /&gt;
* Apache - https://tn123.org/mod_xsendfile/&lt;br /&gt;
* Lighttpd - http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file&lt;br /&gt;
* Nginx - http://wiki.nginx.org/XSendfile&lt;br /&gt;
&lt;br /&gt;
Enable support in config.php (see config-dist.php):&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-Sendfile&#039;;           // Apache {@see https://tn123.org/mod_xsendfile/}&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-LIGHTTPD-send-file&#039;; // Lighttpd {@see http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file}&lt;br /&gt;
//     $CFG-&amp;gt;xsendfile = &#039;X-Accel-Redirect&#039;;     // Nginx {@see http://wiki.nginx.org/XSendfile}&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configure file location prefixes if your server implementation requires it:&lt;br /&gt;
&amp;lt;code php&amp;gt;&lt;br /&gt;
//     $CFG-&amp;gt;xsendfilealiases = array(&lt;br /&gt;
//         &#039;/dataroot/&#039; =&amp;gt; $CFG-&amp;gt;dataroot,&lt;br /&gt;
//         &#039;/cachedir/&#039; =&amp;gt; &#039;/var/www/moodle/cache&#039;,    // for custom $CFG-&amp;gt;cachedir locations&lt;br /&gt;
//         &#039;/localcachedir/&#039; =&amp;gt; &#039;/var/local/cache&#039;,    // for custom $CFG-&amp;gt;localcachedir locations&lt;br /&gt;
//         &#039;/tempdir/&#039;  =&amp;gt; &#039;/var/www/moodle/temp&#039;,     // for custom $CFG-&amp;gt;tempdir locations&lt;br /&gt;
//         &#039;/filedir&#039;   =&amp;gt; &#039;/var/www/moodle/filedir&#039;,  // for custom $CFG-&amp;gt;filedir locations&lt;br /&gt;
//     );&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Database performance==&lt;br /&gt;
&lt;br /&gt;
===MySQL performance===&lt;br /&gt;
&lt;br /&gt;
The following are MySQL specific settings which can be adjusted for better performance in your my.cnf (my.ini in Windows). The file contains a list of settings and their values. To see the current values use these commands&lt;br /&gt;
 SHOW STATUS;&lt;br /&gt;
 SHOW VARIABLES; &lt;br /&gt;
&#039;&#039;&#039;Important&#039;&#039;&#039;: You must make backups of your database before attempting to change any MySQL server configuration. After any change to the my.cnf, restart mysqld.&lt;br /&gt;
&lt;br /&gt;
If you are able, the [http://mysqltuner.com/ MySQLTuner] tool can be run against your MySQL server and will calculate appropriate configuration values for most of the following settings based on your current load, status and variables automatically.&lt;br /&gt;
&lt;br /&gt;
* Enable the &#039;&#039;&#039;query cache&#039;&#039;&#039; with &lt;br /&gt;
 query_cache_type = 1. &lt;br /&gt;
For most Moodle installs, set the following:&lt;br /&gt;
 query_cache_size = 36M &lt;br /&gt;
 query_cache_min_res_unit = 2K. &lt;br /&gt;
The query cache will improve performance if you are doing few updates on the database. &lt;br /&gt;
* Set the &#039;&#039;&#039;table cache&#039;&#039;&#039; correctly. For Moodle 1.6 set &lt;br /&gt;
 table_cache = 256 #(table_open_cache in MySQL &amp;gt; 5.1.2)&lt;br /&gt;
(min), and for Moodle 1.7 set &lt;br /&gt;
 table_cache = 512 #(table_open_cache in MySQL &amp;gt; 5.1.2)&lt;br /&gt;
(min). The table cache is used by all threads (connections), so monitor the value of opened_tables to further adjust - if opened_tables &amp;gt; 3 * table_cache(table_open_cache in MySQL &amp;gt; 5.1.2) then increase table_cache upto your OS limit. Note also that the figure for table_cache will also change depending on the number of modules and plugins you have installed. Find the number for your server by executing the mysql statement below. Look at the number returned and set table_cache to this value.&lt;br /&gt;
 mysql&amp;gt;SELECT COUNT(table_name) FROM information_schema.tables WHERE table_schema=&#039;yourmoodledbname&#039;;&lt;br /&gt;
* Set the &#039;&#039;&#039;thread cache&#039;&#039;&#039; correctly. Adjust the value so that your thread cache utilization is as close to 100% as possible by this formula:&lt;br /&gt;
 thread cache utilization (%) = (threads_created / connections) * 100&lt;br /&gt;
* The &#039;&#039;&#039;key buffer&#039;&#039;&#039; can improve the access speed to Moodle&#039;s SELECT queries. The correct size depends on the size of the index files (.myi) and in Moodle 1.6 or later (without any additional modules and plugins), the recommendation for this value is key_buffer_size = 32M. Ideally you want the database to be reading once from the disk for every 100 requests so monitor that the value is suitable for your install by adjusting the value of key_buffer_size so that the following formulas are true:&lt;br /&gt;
 key_read / key_read_requests &amp;lt; 0.01&lt;br /&gt;
 key_write / key_write_requests &amp;lt;= 1.0&lt;br /&gt;
* Set the &#039;&#039;&#039;maximum number of connections&#039;&#039;&#039; so that your users will not see a &amp;quot;Too many connections&amp;quot; message. Be careful that this may have an impact on the total memory used. MySQL connections usually last for milliseconds, so it is unusual even for a heavily loaded server for this value to be over 200.&lt;br /&gt;
* Manage &#039;&#039;&#039;high burst activity&#039;&#039;&#039;. If your Moodle install uses a lot of quizzes and you are experiencing performance problems (check by monitoring the value of threads_connected - it should not be rising) consider increasing the value of back_log.&lt;br /&gt;
* &#039;&#039;&#039;Optimize your tables weekly and after upgrading Moodle&#039;&#039;&#039;. It is good practice to also optimize your tables after performing a large data deletion exercise, e.g. at the end of your semester or academic year. This will ensure that index files are up to date. Backup your database first and then use:&lt;br /&gt;
 mysql&amp;gt;CHECK TABLE mdl_tablename;&lt;br /&gt;
 mysql&amp;gt;OPTIMIZE TABLE mdl_tablename;&lt;br /&gt;
:The common tables in Moodle to check are mdl_course_sections, mdl_forum_posts, mdl_log and mdl_sessions (if using dbsessions). Any errors need to be corrected using REPAIR TABLE (see the [http://dev.mysql.com/doc/refman/5.0/en/repair-table.html MySQL manual] and this [http://moodle.org/mod/forum/discuss.php?d=58208#p279638 forum script]).&lt;br /&gt;
* &#039;&#039;&#039;Maintain the key distribution&#039;&#039;&#039;. Every month or so it is a good idea to stop the mysql server and run these myisamchk commands.&lt;br /&gt;
 #myisamchk -a -S /pathtomysql/data/moodledir/*.MYI&lt;br /&gt;
:&#039;&#039;&#039;Warning&#039;&#039;&#039;: You must stop the mysql database process (mysqld) before running any myisamchk command. If you do not, you risk data loss.&lt;br /&gt;
* Reduce the number of &#039;&#039;&#039;temporary tables saved to disk&#039;&#039;&#039;. Check this with the created_tmp_disk_tables value. If this is relatively large (&amp;gt;5%) increase tmp_table_size until you see a reduction. Note that this will have an impact on RAM usage.&lt;br /&gt;
&lt;br /&gt;
===PostgreSQL performance===&lt;br /&gt;
&lt;br /&gt;
There are some good papers around on tuning PostgreSQL (like [http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server this one]), and Moodle&#039;s case does not seem to be different to the general case.&lt;br /&gt;
&lt;br /&gt;
The first thing to recognise is that if you really need to worry about tuning you should be using a separate machine for the database server. If you are not using a separate machine then the answers to many performance questions are substantially muddied by the memory requirements of the rest of the application.&lt;br /&gt;
&lt;br /&gt;
You should probably &#039;&#039;&#039;enable autovacuum&#039;&#039;&#039;, unless you know what you are doing. Many e-learning sites have predictable periods of low use, so disabling autovacuum and running a specific vacuum at those times can be a good option. Or perhaps leave autovacuum running but do a full vacuum weekly in a quiet period.&lt;br /&gt;
&lt;br /&gt;
Set &#039;&#039;&#039;shared_buffers&#039;&#039;&#039; to something reasonable. For versions up to 8.1 my testing has shown that peak performance is almost always obtained with buffers &amp;lt; 10000, so if you are using such a version, and have more than 512M of RAM just set shared_buffers to 10,000 (8MB).&lt;br /&gt;
&lt;br /&gt;
The buffer management had a big overhaul in 8.2 and &amp;quot;reasonable&amp;quot; is now a much larger number. I have not conducted performance tests with 8.2, but the recommendations from others are generally that you should now scale shared_buffers much more with memory and may continue to reap benefits even up to values like 100,000 (80MB). Consider using 1-2% of system RAM.&lt;br /&gt;
&lt;br /&gt;
PostgreSQL will also assume that the operating system is caching its files, so setting &#039;&#039;&#039;effective_cache_size&#039;&#039;&#039; to a reasonable value is also a good idea. A reasonable value will usually be (total RAM - RAM in use by programs). If you are running Linux and leave the system running for a day or two you can look at &#039;free&#039; and under the &#039;cached&#039; column you will see what it currently is. Consider taking that number (which is kB) and dividing it by 10 (i.e. allow 20% for other programs cache needs and then divide by 8 to get pages). If you are not using a dedicated database server you will need to decrease that value to account for usage by other programs.&lt;br /&gt;
&lt;br /&gt;
Some other useful parameters that can have positive effects, and the values I would typically set them to on a machine with 4G RAM, are:&lt;br /&gt;
&lt;br /&gt;
 work_mem = 10240&lt;br /&gt;
&lt;br /&gt;
That&#039;s 10M of RAM to use instead of on-disk sorting and so forth. That can give a big speed increase, but it is per connection and 200 connections * 10M is 2G, so it can theoretically chew up a lot of RAM.&lt;br /&gt;
&lt;br /&gt;
 maintenance_work_mem = 163840&lt;br /&gt;
&lt;br /&gt;
That&#039;s 160M of RAM which will be used by (e.g.) VACUUM, index rebuild, cluster and so forth. This should only be used periodically and should be freed when those processes exit, so I believe it is well worth while.&lt;br /&gt;
&lt;br /&gt;
 wal_buffers = 64&lt;br /&gt;
&lt;br /&gt;
These buffers are used for the write-ahead log, and there have been a number of reports on the PostgreSQL mailing lists of improvement from this level of increase.&lt;br /&gt;
&lt;br /&gt;
This is a little out of date now (version 8.0) but still worth a read: http://www.powerpostgresql.com/Docs&lt;br /&gt;
&lt;br /&gt;
And there is lots of good stuff here as well: http://www.varlena.com/GeneralBits/Tidbits/index.php&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Based on Andrew McMillan&#039;s post at [http://moodle.org/mod/forum/discuss.php?d=68558 Tuning PostgreSQL] forum thread.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Splitting &#039;&#039;&#039;mdl_log&#039;&#039;&#039; to several tables and using a VIEW with UNION to read them as one. (See Tim Hunt [https://moodle.org/mod/forum/discuss.php?d=243531#p1104165 explanation] on the Moodle forums)&lt;br /&gt;
&lt;br /&gt;
===Other database performance links===&lt;br /&gt;
* Consider using a &#039;&#039;&#039;distributed cacheing system&#039;&#039;&#039; like [http://en.wikipedia.org/wiki/Memcached memcached] but note that memcached does not have any security features so it should be used behind a firewall.&lt;br /&gt;
* Consider using PostgreSQL. See [[Arguments in favour of PostgreSQL]] and [http://moodle.org/mod/forum/discuss.php?d=49195 how to migrate from MySQL to PostgreSQL] (forum discussion).&lt;br /&gt;
* [http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html General advice on tuning MySQL parameters] (advice from the MySQL manual)&lt;br /&gt;
* [http://www.mysqlperformanceblog.com/2007/11/01/innodb-performance-optimization-basics/ InnoDB performance optimization] taken from the [http://www.mysqlperformanceblog.com/ MySQL performance blog] site.&lt;br /&gt;
&lt;br /&gt;
==Performance of different Moodle modules==&lt;br /&gt;
&lt;br /&gt;
Moodle&#039;s activity modules, filters, and other plugins can be activated/deactivated. If necessary, you may wish to deactivate some features (such as chat) if not required - but this isn&#039;t necessary. Some notes on the performance of certain modules:&lt;br /&gt;
&lt;br /&gt;
* The &#039;&#039;&#039;Chat&#039;&#039;&#039; module is [http://moodle.org/mod/forum/discuss.php?d=37979&amp;amp;parent=175079 said] to be a hog in terms of frequent HTTP requests to the main server. This can be reduced by setting the module to use &#039;&#039;Streamed&#039;&#039; updates, or, if you&#039;re using a Unix-based webserver, by running the chat in daemon mode. When using the Chat module use the configuration settings to tune for your expected load. Pay particular attention to the &#039;&#039;chat_old_ping&#039;&#039; and &#039;&#039;chat_refresh&#039;&#039; parameters as these can have greatest impact on server load.&lt;br /&gt;
* The Moodle &#039;&#039;&#039;Cron&#039;&#039;&#039; task is triggered by calling the script &#039;&#039;cron.php&#039;&#039;. If this is called over HTTP (e.g. using wget or curl) it can take a large amount of memory on large installations. If it is called by directly invoking the php command (e.g. &#039;&#039;php -f /path/to/moodle/directory/admin/cli/cron.php&#039;&#039;) efficiency can be much improved.&lt;br /&gt;
* The &#039;&#039;&#039;Recent activities&#039;&#039;&#039; block is consuming too many resources if you have huge number of records &amp;lt;code&amp;gt;mdl_log&amp;lt;/code&amp;gt;. This is being tested to optimize the SQL query.&lt;br /&gt;
* The &#039;&#039;&#039;Quiz&#039;&#039;&#039; module is known to stretch database performance. However, it has been getting better in recent versions, and we don&#039;t know of any good, up-to-date performance measurements. (Here is a [http://moodle.org/mod/forum/discuss.php?d=68579 case study from 2007 with 300 quiz users].). The following suggestions were described by [https://moodle.org/user/view.php?id=94615&amp;amp;course=5 Al Rachels] in [https://moodle.org/mod/forum/discuss.php?d=347126 this forum thread]:&lt;br /&gt;
** make sure both Moodle, and the operating system, are installed on a [https://en.wikipedia.org/wiki/Solid-state_drive solid state drive]&lt;br /&gt;
** upgrade to and use [https://docs.moodle.org/dev/Moodle_and_PHP7 PHP 7]&lt;br /&gt;
** run MySQLTuner and implement its recommendations&lt;br /&gt;
&lt;br /&gt;
See [[Performance settings]] for more information on performance-related Moodle settings.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*Using Moodle: [http://moodle.org/mod/forum/view.php?f=94 Hardware and Performance] forum&lt;br /&gt;
*[http://opensourceelearning.blogspot.be/2012/10/why-your-moodle-site-is-slow-five.html Why Your Moodle Site is Slow: Five Simple Settings] blog post from Jonathan Moore &lt;br /&gt;
*I teach with Moodle perfomance testing: http://www.iteachwithmoodle.com/2012/11/17/moodle-2-4-beta-performance-test-comparison-with-moodle-2-3/&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.2 performance and MUC APC cahe store]&lt;br /&gt;
*[http://jfilip.ca/2013/09/25/moodle-performance-testing-2-4-6-vs-2-5-2-vs-2-6dev/ Moodle performance testing 2.4.6 vs 2.5.2 vs 2.6dev]&lt;br /&gt;
*[http://jfilip.ca/2013/09/24/moodle-performance-analysis-revisted-now-with-mariadb/ Moodle performance analysis revisited (now with MariaDB)]&lt;br /&gt;
*[http://tjhunt.blogspot.ca/2013/05/performance-testing-moodle.html Tim Hunt&#039;s blog (May 2, 2013) on performance testing Moodle]&lt;br /&gt;
*[http://newrelic.com/ New Relic, Application Performance Monitoring]&lt;br /&gt;
*[http://blog.bitnami.com/2014/06/performance-enhacements-for-apache-and.html Performance enhacements for Apache and PHP (Apache Event MPM and PHP-FPM)]&lt;br /&gt;
*[https://scholarlms.net/performance-recommendations/ Performance recommendations]&lt;br /&gt;
&lt;br /&gt;
There have been a lot of discussions on moodle.org about performance, here are some of the more interesting and (potentially) useful ones:&lt;br /&gt;
&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=83057 Performance woes!]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=57028 Performance perspectives - a little script]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=88927 Comments on planned server hardware]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=102978#p461624 Moodle performance in a pil by Martin Langhoff]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=240391#unread Advice on optimising php/db code in moodle2+]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=243531 Moodle 2.5 performance testing at the OU]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=273602 100 active users limit with 4vCPU]&lt;br /&gt;
* [https://moodle.org/mod/forum/discuss.php?d=336603#p1356423 Performance Tip ... shared...]&lt;br /&gt;
&lt;br /&gt;
[[es:Recomendaciones sobre desempeño]]&lt;br /&gt;
[[fr:Performance]]&lt;br /&gt;
[[ja:パフォーマンス]]&lt;br /&gt;
[[de:Geschwindigkeitsempfehlungen]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=File_upload_size&amp;diff=134977</id>
		<title>File upload size</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=File_upload_size&amp;diff=134977"/>
		<updated>2019-08-01T14:27:47Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Restricting the File size - how it works */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
==Upload file size restrictions==&lt;br /&gt;
&lt;br /&gt;
Probably the most frequently asked question on moodle.org is &amp;quot;How do I increase the upload file size limit?&amp;quot; The changes that need be made are the same in all versions of Moodle, just in different OS&#039; they need be made in different places. Upload file sizes are restricted in a number of ways and each one in this list restricts the following ones:&lt;br /&gt;
&lt;br /&gt;
# Server level&lt;br /&gt;
# Moodle site level&lt;br /&gt;
# Course level&lt;br /&gt;
# Activity level&lt;br /&gt;
&lt;br /&gt;
This is a contentious issue, mainly because you might think that it should be set inside the Moodle. Unfortunately, this is not so, these are environment issues that need to be set in the server and PHP folders, Moodle cannot work outside itself. &lt;br /&gt;
&lt;br /&gt;
==Physical access to Server==&lt;br /&gt;
These instructions assume you have full physical and administrative access to your server. If you are using a hosted server then you will probably need to look into other ways to increase your file upload size. &lt;br /&gt;
&lt;br /&gt;
There are positives and negatives to both methods below. If you modify the php.ini file then the changes will effect all php applications on your server. Since PHP5 you can only have one php.ini file on your server. The php.ini method will work with all web servers though. The .htaccess method will only effect the folder and all subfolders that it is placed in, but you must have certain settings enabled in Apache.&lt;br /&gt;
&lt;br /&gt;
==Restricting the File size - how it works==&lt;br /&gt;
The Host may set a limit on the maximum file upload size in the Server environment, which you may override if the Host allows you to. PHP has a setting that it uses to limit the size of the file that it handles in upload. The Host has set that figure in the php.ini based on their particular perceptions and their clientele need. This size appears in Moodle in the &#039;&#039;&#039;Site administration &amp;gt; Security &amp;gt; Site security settings &amp;gt; Maximum uploaded file size&#039;&#039;&#039; drop-down combo box. You can change this at any time to suit your site need. In the Course Settings page, there is also a further restriction that can be made. At no time can the Course setting over-ride the Site setting, nor can the Site setting over-ride the php.ini setting, which cannot over-ride the Server setting. The only exception to this rule is that you can manipulate both the Server and the PHP settings, and how to do that is described below.&lt;br /&gt;
&lt;br /&gt;
==Modifying the php.ini file==&lt;br /&gt;
These instructions show you how to change the file upload size by editing your php.ini file.&lt;br /&gt;
&lt;br /&gt;
For the most part these instructions amount to the following.&lt;br /&gt;
In the file /etc/php5/apache2/php.ini you need to change &amp;quot;post_max_size&amp;quot;, &amp;quot;upload_max_filesize&amp;quot; and &amp;quot;max_execution_time&amp;quot; to values that suit your needs using whatever editor you are used to. &lt;br /&gt;
&lt;br /&gt;
Below are some line by line instructions for various installations of Moodle.&lt;br /&gt;
&lt;br /&gt;
====Ubuntu Linux Instructions====&lt;br /&gt;
&lt;br /&gt;
These instructions assume that you have installed the standard Moodle package, PHP 5 and Apache 2 via apt-get and left it all as a default install. If you have compiled yourself I presume that you will know where your php.ini files are!&lt;br /&gt;
&lt;br /&gt;
You need to edit the following three settings in your php.ini file located at: /etc/php5/apache2/&lt;br /&gt;
Here are a set of instructions to follow line by line.&lt;br /&gt;
&lt;br /&gt;
*Type &amp;quot;sudo nano /etc/php5/apache2/php.ini&amp;quot;&lt;br /&gt;
*Press Ctrl and W and type &amp;quot;post_max_size&amp;quot; &lt;br /&gt;
*Change the value to the number of Mb you want your site to accept as uploads&lt;br /&gt;
*Press Ctrl and W and type &amp;quot;upload_max_filesize&amp;quot; &lt;br /&gt;
*Change the value to the number of Mb you want your site to accept as uploads&lt;br /&gt;
*Press Ctrl and W and type &amp;quot;max_execution_time&amp;quot; &lt;br /&gt;
*Change the value to 600&lt;br /&gt;
*Press Ctrl and O&lt;br /&gt;
*Press Ctrl and X&lt;br /&gt;
*Type sudo apachectl restart&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size NGINX] system administrators should also add &amp;quot;client_max_body_size XXXm;&amp;quot; to the &amp;quot;http&amp;quot; section of their nginx main configuration file. ([https://rtcamp.com/tutorials/php/increase-file-upload-size-limit/#change-in-nginx-config see more info]) if you have SSL, that will require you to set the above for the SSL &#039;&#039;server&#039;&#039; and &#039;&#039;location&#039;&#039; too.&lt;br /&gt;
&lt;br /&gt;
Your new file size limit should now appear in Administration &amp;gt; Security &amp;gt; Site Policies &amp;gt; Maximum uploaded file size&lt;br /&gt;
&lt;br /&gt;
====XAMPP on Mac Instructions====&lt;br /&gt;
&lt;br /&gt;
These are instructions for how to do this for Moodle on a Mac using the [http://download.moodle.org/macosx/ XAMPP sample download package available]. (This is not for a OS X production server.)&lt;br /&gt;
&lt;br /&gt;
* Close down Apache and MySQL if they are running via the XAMPP Control app and close the XAMPP Control app &lt;br /&gt;
* Open Finder and go to Applications&lt;br /&gt;
* Navigate down and open the folder &#039;&#039;XAMPP&#039;&#039; / &#039;&#039;xamppfiles&#039;&#039; / &#039;&#039;etc&#039;&#039;&lt;br /&gt;
* Open the file &#039;&#039;php.ini&#039;&#039; with TextEdit (or another plain text editor)&lt;br /&gt;
* Search for the &#039;&#039;post_max_size&#039;&#039; setting and up this from 128M (the default) to more; 500M is the maximum&lt;br /&gt;
* Do the same for &#039;&#039;upload_max_filesize&#039;&#039; (make the numbers the same)&lt;br /&gt;
* Search for the &#039;&#039;max_execution_time&#039;&#039; setting and up this to 300 (or more if you get timeouts on uploads)&lt;br /&gt;
* Save the php.ini file &lt;br /&gt;
* restart Apache and MySQL as usual&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: You may get a &amp;quot;permission denied&amp;quot; error when saving the php.ini file unless you are logged in with  admin access to your Mac. To work around this, you can set the &#039;&#039;/etc&#039;&#039; directory in which the php.ini file is located to be writable temporarily. For how to do that, see [http://answers.yahoo.com/question/index?qid=20090115235753AA4DtJ0 here] or [http://www.ehow.com/how_2314896_fix-permissions-mac-os-x.html here].&lt;br /&gt;
&lt;br /&gt;
====Windows XP and Server 2003 Instructions====&lt;br /&gt;
&lt;br /&gt;
These instructions presume that you have downloaded the latest PHP 5.3.x Windows zip package and extracted it to C:\PHP. If you have installed PHP to another location then change all references to &amp;quot;C:\PHP&amp;quot; to the location you installed PHP too.&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|[[Image:lightbulb.png]]&lt;br /&gt;
|Download and install any text editor that can save the file in a UTF-8 format, [http://www.crimsoneditor.com Crimson Editor] is one such, NotePad++ is another, use that instead of either Wordpad or Notepad! The issue is that WordPad or Notepad will include hidden characters that may not be compatible with the requirements of PHP.   &lt;br /&gt;
|} &lt;br /&gt;
&lt;br /&gt;
*Open C:\PHP&lt;br /&gt;
*Right Click the &#039;&#039;&#039;php.ini&#039;&#039;&#039; file in this folder and choose &amp;quot;Open with...&amp;quot; selecting your editor of choice. &lt;br /&gt;
*Press Ctrl + F and type &amp;quot;post_max_size&amp;quot; (click Find...&amp;quot;, where needed) &lt;br /&gt;
*Change the value to the number of Mb you want your site to accept as uploads&lt;br /&gt;
*Press Ctrl + F and type &amp;quot;upload_max_filesize&amp;quot; (click Find...&amp;quot;, where needed)&lt;br /&gt;
*Change the value to the number of Mb you want your site to accept as uploads&lt;br /&gt;
*Press Ctrl + F and type &amp;quot;max_execution_time&amp;quot; (click Find...&amp;quot;, where needed)&lt;br /&gt;
*Change the value to 600&lt;br /&gt;
*Press Ctrl and S or the save button. &lt;br /&gt;
*Exit your editor. &lt;br /&gt;
*Restart your webserver to reload PHP with the edited changes. &lt;br /&gt;
**&#039;&#039;&#039;For IIS&#039;&#039;&#039;&lt;br /&gt;
**Open the Start Menu on your server and select &amp;quot;Run&amp;quot;&lt;br /&gt;
**Type &amp;quot;iisreset /RESTART&amp;quot;&lt;br /&gt;
**For &#039;&#039;&#039;Apache 2 and Windows XP&#039;&#039;&#039;&lt;br /&gt;
**Go to Start &amp;gt; All Programs &amp;gt; Apache &amp;gt; Restart&lt;br /&gt;
**&#039;&#039;&#039;For Apache 2 and Windows Server&#039;&#039;&#039;&lt;br /&gt;
**The following command will work as long as you have installed Apache 2 as a service on your Windows Server&lt;br /&gt;
**Open your Start Menu on your server and select &amp;quot;Run&amp;quot;&lt;br /&gt;
**Type &amp;quot;httpd -k restart&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Your new file size limit should now appear in Administration &amp;gt; Security &amp;gt; Site Policies &amp;gt; Maximum uploaded file size&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; These instructions also cover the Xampp Windows installer. Just replace C:\PHP with C:\Moodle\server\php and to restart your Moodle with a normal stop-start.&lt;br /&gt;
&lt;br /&gt;
==Modifying the apache config file==&lt;br /&gt;
====Ubuntu Linux Instructions====&lt;br /&gt;
You may also need to edit the config.php file in the moodle directory:&lt;br /&gt;
*Type &amp;quot;gksudo nautilus&amp;quot; to get root permissions&lt;br /&gt;
*Navigate to /etc/moodle&lt;br /&gt;
*Open apache.conf&lt;br /&gt;
*Go to the &amp;quot;&amp;lt;IfModule mod_php5.c&amp;gt;&amp;quot; section&lt;br /&gt;
*Change &amp;quot;php_value upload_max_filesize = 2M&amp;quot; to a higher value&lt;br /&gt;
*Change &amp;quot;php_value post_max_size = 2M&amp;quot; to a higher value&lt;br /&gt;
*Go to the &amp;quot;&amp;lt;IfModule mod_php4.c&amp;gt;&amp;quot; section&lt;br /&gt;
*Change &amp;quot;php_value upload_max_filesize = 2M&amp;quot; to a higher value&lt;br /&gt;
*Change &amp;quot;php_value post_max_size = 2M&amp;quot; to a higher value&lt;br /&gt;
*Save file&lt;br /&gt;
*Type sudo /etc/init.d/apache2 restart&lt;br /&gt;
&lt;br /&gt;
===Modifying the .htaccess file===&lt;br /&gt;
&lt;br /&gt;
The following instructions will only work on an Apache web server, and also the Apache server must have Overrides allowed. Traditionally, you could only use .htaccess files when PHP was run as a module of Apache, but with Apache 2.2, this appears to no longer be the case. You can now use the .htaccess file in either module or cgi forms. As well, allowing the use of .htaccess files will cause a performance hit on the server, not a desirable outcome either - so check with your Host. &lt;br /&gt;
&lt;br /&gt;
The .htaccess file is a distributed configuration file, that is, it can be used on a per-folder basis to configure each user&#039;s folder and sub-folders. You cannot alter the &amp;quot;AllowOverrides&amp;quot; directive in the Apache configuration file with a .htaccess file, only the Host can set that manually. Usually the Host will place a .htaccess file into your site Root if they do allow you to override the server settings. You can edit it the same as below, and the overrides you set will work. Alternatively, you may create your own .htaccess file in your text editor. It may also be called something else, like .config. If you have any file that starts with a ., you might want to open it in your text editor, just out of curiosity. &lt;br /&gt;
&lt;br /&gt;
Create a file called .htaccess in Moodle&#039;s main directory (where &#039;index.php&#039; is located, not the &#039;moodledata&#039; directory) that contains the following information:&lt;br /&gt;
&lt;br /&gt;
 php_value upload_max_filesize 20971520&lt;br /&gt;
 php_value post_max_size 20971520&lt;br /&gt;
 php_value max_execution_time 600&lt;br /&gt;
&lt;br /&gt;
20971520 is the integer value for 20Mb. You can use the following site to [http://www.onlineconversion.com/computer_base2.htm convert MegaBytes to Bytes].&lt;br /&gt;
&lt;br /&gt;
For a more complete description of how to edit the .htacess file, look at this page, [http://httpd.apache.org/docs/current/howto/htaccess.html Apache Tutorial: .htaccess files]&lt;br /&gt;
&lt;br /&gt;
===Modifying the IIS 7.0/7.5 configuration (Windows Server 2008, Windows Server 2008 R2)===&lt;br /&gt;
First increase activity and request time outs (allows large files to succeed on slow connections)&lt;br /&gt;
 FastCGI Settings &amp;gt; Edit (Right-click on PHP application)&lt;br /&gt;
 Set Process Model &amp;gt; Activity Timeout to &#039;3600&#039; (one hour)&lt;br /&gt;
 Set Process Model &amp;gt; Request Timeout to &#039;3600&#039; (one hour)&lt;br /&gt;
Next set &#039;Maximum allowed content length&#039;&lt;br /&gt;
 Request Filtering &amp;gt; Edit Feature Settings:&lt;br /&gt;
 Set &#039;Maximum allowed content length&#039; to your desired file size (in bytes) e.g. &#039;536870912&#039; for 512MB (default is approximately 28.6MB)&lt;br /&gt;
&lt;br /&gt;
==Hosted Server==&lt;br /&gt;
Things can be a little different with a hosted server for uploaded and downloaded file size.  You are probably going to  to be told to create or change a .htaccess file, or to modify a php.ini file.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|[[Image:lightbulb.png]]&lt;br /&gt;
|It might be a good idea to talk to with your service provider before you attempt anything.  They probably have instructions on &amp;quot;how to&amp;quot; and may have their own limits for uploaded file size. Some hosts measure the file size in gigabytes and others in megabytes.  If you are unhappy with their limits, then check your contract and consider changing your provider to one that has a limit and price that you like.&lt;br /&gt;
|}   &lt;br /&gt;
&lt;br /&gt;
===.htaccess with hosted server===&lt;br /&gt;
The one purpose of an .htaccess file is to override the the current limitations of both the server and the php.ini file.  Your hosted server should inform you where that file needs be placed in your Moodle, but generally in the root is sufficient. They may already have a standard file you can use, if so, use it - but perhaps not.  &lt;br /&gt;
&lt;br /&gt;
To the .htaccess file add the lines:&lt;br /&gt;
  php_value upload_max_filesize 128M&lt;br /&gt;
  php_value post_max_size 128M&lt;br /&gt;
  &lt;br /&gt;
&lt;br /&gt;
This will limit uploads to 128MB, but you can make it any size you agree with your provider. The wording may vary slightly, according to the demands of the server.&lt;br /&gt;
&lt;br /&gt;
===php.ini with hosted server===&lt;br /&gt;
Some servers will not allow you to change the moodle root .htaccess file and tell you to use a php.ini file for php directives.  Here you can use the instruction located in the section above called [[File_upload_size#Modifying_the_php.ini_file|Modifying the php.ini file]].&lt;br /&gt;
&lt;br /&gt;
Find the php.ini file in your moodle subfolder on your hosted server. You might want to copy the file as a backup just in case.  Edit php.ini, find &amp;quot;upload_max_filesize&amp;quot; and post_max_size in the code.  After the = change the number.  Here the max filesize is 20 megabytes.  &lt;br /&gt;
&lt;br /&gt;
 upload_max_filesize = 20M&lt;br /&gt;
 post_max_size = 20M&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|[[Image:lightbulb.png]]&lt;br /&gt;
|Still not changed? Some hosts using cpanel have a php config program under services/software. Use the &amp;quot;Single php.ini&amp;quot; option and make sure you note the location of the php.ini file to modify. This changes the .htaccess file in the same area and thus the server limit for all programs using php.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;nicetable&amp;quot;&lt;br /&gt;
|[[Image:lightbulb.png]]&lt;br /&gt;
|Still not changed? [http://nginx.org/en/docs/http/ngx_http_core_module.html#client_max_body_size NGINX] system administrators should also add client_max_body_size XXXm; to the &amp;quot;http&amp;quot; section of their nginx main configuration file. ([https://rtcamp.com/tutorials/php/increase-file-upload-size-limit/#change-in-nginx-config see more info]) if you have SSL, that will require you to set the above for the SSL &#039;&#039;server&#039;&#039; and &#039;&#039;location&#039;&#039; too.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[Administration_FAQ#How_do_the_limits_on_uploaded_files_work.3F|Administration FAQ Doc page]]&lt;br /&gt;
*[[Site_policies#Maximum_uploaded_file_size|Site Policies Doc page]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=39625 Detailed instructions to increase the maximum allowed size for uploaded files] forum discussion&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=97907 Instructions to increase maximum allowed size on hosted servers] forum discussion&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/discuss.php?d=124441 Help on changing the maximum upload size when installing Moodle via apt-get] forum discussion&lt;br /&gt;
&lt;br /&gt;
[[es:Tamaño de archivo subido]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ|File]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Antivirus_plugins&amp;diff=133419</id>
		<title>Antivirus plugins</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Antivirus_plugins&amp;diff=133419"/>
		<updated>2019-03-27T21:23:36Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security}}&lt;br /&gt;
An administrator can enable and configure virus scanners for use on uploaded files via &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Antivirus plugins &amp;gt; Manage antivirus plugins&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
ClamAV antivirus is available as a standard plugin. It&#039;s likely that more antivirus plugins will be available in future from the [https://moodle.org/plugins/ Moodle plugins directory].&lt;br /&gt;
&lt;br /&gt;
==ClamAV antivirus==&lt;br /&gt;
&lt;br /&gt;
To make use of ClamAV antivirus, ClamAV® should be installed on your server. See http://www.clamav.net for more information.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* RHEL/CentOS and [https://en.wikipedia.org/wiki/Security-Enhanced_Linux SELinux]: https://moodle.org/mod/forum/discuss.php?d=316066&lt;br /&gt;
* RHEL/CentOS and [https://access.redhat.com/blogs/766093/posts/1976243 PrivateTmp]: https://moodle.org/mod/forum/discuss.php?d=364706&lt;br /&gt;
* Offboarding ClamScan from web nodes https://moodle.org/mod/forum/discuss.php?d=382731&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Antibirusa]]&lt;br /&gt;
[[de:Antivirus]]&lt;br /&gt;
[[es:Plugins antivirus]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Antivirus_plugins&amp;diff=133418</id>
		<title>Antivirus plugins</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Antivirus_plugins&amp;diff=133418"/>
		<updated>2019-03-27T21:22:43Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security}}&lt;br /&gt;
An administrator can enable and configure virus scanners for use on uploaded files via &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Antivirus plugins &amp;gt; Manage antivirus plugins&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
ClamAV antivirus is available as a standard plugin. It&#039;s likely that more antivirus plugins will be available in future from the [https://moodle.org/plugins/ Moodle plugins directory].&lt;br /&gt;
&lt;br /&gt;
==ClamAV antivirus==&lt;br /&gt;
&lt;br /&gt;
To make use of ClamAV antivirus, ClamAV® should be installed on your server. See http://www.clamav.net for more information.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* RHEL/CentOS and [https://en.wikipedia.org/wiki/Security-Enhanced_Linux SELinux]: https://moodle.org/mod/forum/discuss.php?d=316066&lt;br /&gt;
* RHEL/CentOS and [https://access.redhat.com/blogs/766093/posts/1976243 PrivateTmp]: https://moodle.org/mod/forum/discuss.php?d=364706&lt;br /&gt;
* Offboarding ClamScan from web notes https://moodle.org/mod/forum/discuss.php?d=382731&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Antibirusa]]&lt;br /&gt;
[[de:Antivirus]]&lt;br /&gt;
[[es:Plugins antivirus]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Antivirus_plugins&amp;diff=133417</id>
		<title>Antivirus plugins</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Antivirus_plugins&amp;diff=133417"/>
		<updated>2019-03-27T21:22:15Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Security}}&lt;br /&gt;
An administrator can enable and configure virus scanners for use on uploaded files via &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Antivirus plugins &amp;gt; Manage antivirus plugins&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
ClamAV antivirus is available as a standard plugin. It&#039;s likely that more antivirus plugins will be available in future from the [https://moodle.org/plugins/ Moodle plugins directory].&lt;br /&gt;
&lt;br /&gt;
==ClamAV antivirus==&lt;br /&gt;
&lt;br /&gt;
To make use of ClamAV antivirus, ClamAV® should be installed on your server. See http://www.clamav.net for more information.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* RHEL/CentOS and [https://en.wikipedia.org/wiki/Security-Enhanced_Linux SELinux]: https://moodle.org/mod/forum/discuss.php?d=316066&lt;br /&gt;
* RHEL/CentOS and [https://access.redhat.com/blogs/766093/posts/1976243 PrivateTmp]: https://moodle.org/mod/forum/discuss.php?d=364706&lt;br /&gt;
* Offboarding ClamScan from web notes [https://moodle.org/mod/forum/discuss.php?d=382731]&lt;br /&gt;
&lt;br /&gt;
[[Category:Site administration]]&lt;br /&gt;
&lt;br /&gt;
[[eu:Antibirusa]]&lt;br /&gt;
[[de:Antivirus]]&lt;br /&gt;
[[es:Plugins antivirus]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=132791</id>
		<title>Upgrading</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Upgrading&amp;diff=132791"/>
		<updated>2018-12-10T14:19:52Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: Bad security advice sorted&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}	&lt;br /&gt;
&#039;&#039;This page explains in detail how to upgrade Moodle. For a summary of the process, see [[Upgrade overview]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Check the requirements==&lt;br /&gt;
&lt;br /&gt;
Before upgrading, check that your server meets all requirements for {{Version}} in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; [[Environment]]&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for both [{{Release notes}}#Server_requirements server] and [{{Release notes}}#Client_requirements client] software requirements.&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* You can only upgrade to Moodle {{Version}} from Moodle 3.1 or later. If upgrading from earlier versions, you must [https://docs.moodle.org/31/en/Upgrading_to_Moodle_3.1 upgrade to 3.1] as a first step.&lt;br /&gt;
&lt;br /&gt;
==Before upgrading==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;We advise that you test the upgrade first on a COPY of your production site, to make sure it works as you expect.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Consider setting the [[Upgrade key|upgrade key]] for your site.&lt;br /&gt;
&lt;br /&gt;
== Backup important data ==&lt;br /&gt;
&lt;br /&gt;
There are three areas that should be backed up before any upgrade:&lt;br /&gt;
#Moodle software (For example, everything in server/htdocs/moodle)&lt;br /&gt;
#Moodle uploaded files (For example, server/moodledata)&lt;br /&gt;
#Moodle database (For example, your Postgres or MySQL database dump)&lt;br /&gt;
&lt;br /&gt;
See [[Site backup]] for more specific information.&lt;br /&gt;
&lt;br /&gt;
== Check for plugin updates ==&lt;br /&gt;
&lt;br /&gt;
If you have [[Automatic updates deployment]] enabled, you will be able to update installed plugins automatically during the upgrade. Just make sure you check for available updates (via the button for it) at the Plugins check screen.&lt;br /&gt;
&lt;br /&gt;
If you are updating plugins manually, it is a good moment now to check in the [http://moodle.org/plugins Moodle Plugins directory] whether there is a {{Version}} version available for any plugins (including themes) that you have previously installed on your site. If so, download the plugin package. In the next step, you will copy it to the appropriate location in your Moodle code (see [[Installing plugins]]).&lt;br /&gt;
&lt;br /&gt;
The upgrade of the plugin will then happen as part of the Moodle upgrade process.&lt;br /&gt;
&lt;br /&gt;
If an out-of-date plugin causes your upgrade to fail, you can usually delete the plugin code rather than uninstalling it from within Moodle so that the data associated with it is not deleted.&lt;br /&gt;
&lt;br /&gt;
==Put your site into maintenance mode==&lt;br /&gt;
Before you begin upgrading your site, you should put it into [[Maintenance_mode | maintenance mode]] to stop any non-admin users from logging in. Then you should wait for any currently running cron processes to complete before proceeding.&lt;br /&gt;
&lt;br /&gt;
== Install the new Moodle software ==&lt;br /&gt;
You can fetch the current version of the software through &lt;br /&gt;
&lt;br /&gt;
wget http://sourceforge.net/projects/moodle/files/Moodle/stable{{Version2}}/moodle-latest-{{Version2}}.tgz&lt;br /&gt;
&lt;br /&gt;
=== Standard install package ===&lt;br /&gt;
&lt;br /&gt;
# Move your old Moodle software program files to another location. &#039;&#039;Do NOT copy new files over the old files.&#039;&#039;&lt;br /&gt;
# Unzip or unpack the upgrade file so that all the new Moodle software program files are in the location the old files used to be in on the server. Moodle will adjust SQL and moodledata if it needs to in the upgrade.&lt;br /&gt;
# Copy your old [[Configuration file|config.php file]] back to the new Moodle directory. &lt;br /&gt;
# As mentioned above, if you had installed any plugins on your site you should add them to the new code tree (Moodle directory structure) now. It is important to check that you get the correct version for your new version of Moodle. Be particularly careful that you do not overwrite any code in the new version of Moodle and that you place the plugin folders in the correct directory (the same directory that they are in in the current installation.)&lt;br /&gt;
# Your moodledata folder should be located separately to your Moodle code folder and, as such, should not need anything done to it.  Moodle 3.0 will throw a warning if it is located in a web accessible folder and the moodledata should never be located in the Moodle code folder.  If you are moving your installation to a new server or new location on your server, then you will need to follow the Migration documents.&lt;br /&gt;
&lt;br /&gt;
====Linux====&lt;br /&gt;
 mv moodle moodle.backup&lt;br /&gt;
 tar xvzf moodle-{{Version}}.tgz&lt;br /&gt;
&lt;br /&gt;
Next, copy across your config.php, any custom plugins, and your .htaccess file if you created one (&#039;&#039;&#039;check that custom plugins are the correct version for your new Moodle first&#039;&#039;&#039;):&lt;br /&gt;
&lt;br /&gt;
 cp moodle.backup/config.php moodle&lt;br /&gt;
 cp -pr moodle.backup/theme/mytheme moodle/theme/mytheme&lt;br /&gt;
 cp -pr moodle.backup/mod/mymod moodle/mod/mymod&lt;br /&gt;
&lt;br /&gt;
Don&#039;t forget to make moodle/config.php (and the rest of the source code) readable by your www server. For maximum security the files should not be writeable by your server. This is especially important on a &#039;production&#039; server open to the public internet. &lt;br /&gt;
&lt;br /&gt;
chown -R root:root moodle (Linux debian - or even create a user especially for moodle. &#039;&#039;&#039;Don&#039;t&#039;&#039;&#039; use the web server user, e.g. www-data)&lt;br /&gt;
chmod -R 755 moodle&lt;br /&gt;
&lt;br /&gt;
If you use cron, take care that cron.php is executeable and uses the correct php command: &lt;br /&gt;
 chmod 740 admin/cli/cron.php (some configurations need chmod 750 or chmod 755)&lt;br /&gt;
 copy the first line from cron.php (if it looks like &#039;#!/usr/local/bin/php&#039; or &#039;#!/usr/local/bin/php5.3&#039;, no need to copy &#039;&amp;lt;?php&#039;) &lt;br /&gt;
if necessary.  However, for a simple upgrade, there should be no need to change anything with cron.&lt;br /&gt;
&lt;br /&gt;
=== Using Git ===&lt;br /&gt;
&lt;br /&gt;
You can use Git for updating or upgrading your Moodle. See [[Git for Administrators]] for details.&lt;br /&gt;
&lt;br /&gt;
===Command line upgrade===&lt;br /&gt;
&lt;br /&gt;
On Linux servers, Moodle {{Version}} supports running the [[CLI|upgrade from the command line]], rather than through a web browser. This is likely to be more reliable, particularly for large sites.&lt;br /&gt;
&lt;br /&gt;
== Finishing the upgrade ==&lt;br /&gt;
&lt;br /&gt;
The last step is to trigger the upgrade processes within Moodle. &lt;br /&gt;
&lt;br /&gt;
If you put your site into Maintenance mode earlier; take it out now!&lt;br /&gt;
&lt;br /&gt;
To do this just go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Notifications&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Moodle will automatically detect the new version and perform all the SQL database or file system upgrades that are necessary. If there is anything it can&#039;t do itself (very rare) then you will see messages telling you what you need to do.&lt;br /&gt;
&lt;br /&gt;
Assuming all goes well (no error messages) then you can start using your new version of Moodle and enjoy the new features!&lt;br /&gt;
&lt;br /&gt;
Note: If you are running multiple servers then you should purge all caches manually (via &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Development &amp;gt; Purge all caches&#039;&#039;) after completing the upgrade on all servers.&lt;br /&gt;
&lt;br /&gt;
===Fatal error: Maximum execution time of 30 seconds exceeded...===&lt;br /&gt;
&lt;br /&gt;
If your server uses a main language other than English, you may encounter a &#039;Fatal error: Maximum execution time of 30 seconds exceeded&#039; when you try to upgrade it. You can increase max_execution_time = 160 on php.ini to allow the scripts enough time to process the language update. Otherwise, you can switch to English as the default language before doing the upgrade and back to your original language after a succcessful upgrade. See the forum discussion at https://moodle.org/mod/forum/discuss.php?d=119598.&lt;br /&gt;
&lt;br /&gt;
==After upgrading==&lt;br /&gt;
&lt;br /&gt;
The config.php file from your installation should work fine but if you take a look at config-dist.php that came with Moodle 3.0 there are more/different options available (e.g. database drivers and settings). It&#039;s a good idea to map your old config.php settings to a new one based on the 3.0 config-dist.php.&lt;br /&gt;
&lt;br /&gt;
===Cron===&lt;br /&gt;
&lt;br /&gt;
Cron has received a major update (MDL-25499) and now has support for both scheduled and ad hoc tasks.&lt;br /&gt;
&lt;br /&gt;
The benefits of these changes are:&lt;br /&gt;
* The schedule for every task can be configured by the admin&lt;br /&gt;
* Tasks can run in parallel&lt;br /&gt;
* Cron processes use locking to prevent the same task running at the same time by different processes&lt;br /&gt;
* Clusters with multiple identical application nodes are supported, you can run cron on all of them&lt;br /&gt;
&lt;br /&gt;
A result of this is that cron can be run much more often, which means (for example) forum posts can be sent out sooner.  To take advantage of the new cron system it is now strongly recommended that administrators increase the frequency that cron is run to at least &#039;&#039;once per minute&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
You also may need to modify any automated scripts you have that are parsing the output from cron. It is no longer possible to simply monitor the output of cron for the string &amp;quot;Cron script completed correctly&amp;quot; (if that is what you were doing). An alternative is to monitor the output for the string &amp;quot;task failed:&amp;quot;. If you detect that a task is failing, [[Cron#Debugging_Scheduled_Tasks|here]] are some tips for debugging the failure. &lt;br /&gt;
&lt;br /&gt;
Before the upgrade, there may have been a cron task that was failing, which was preventing the rest of cron from being executed. A failure in any single task will no longer prevent the rest of the Moodle cron tasks from executing, so you may uncover previously masked bugs. It is a good idea to closely monitor the output from cron after the upgrade.&lt;br /&gt;
&lt;br /&gt;
===Assignments===&lt;br /&gt;
&lt;br /&gt;
The old assignment (2.2) module has been removed from core and has been replaced by a stub to support transparently remapping URLs and restoring course backups from the old module to the new one. &lt;br /&gt;
&lt;br /&gt;
If you are still using the old assignment (2.2) module, after upgrading to Moodle 3.0 all assignment (2.2) activities will be hidden. You need to run the [[Assignment upgrade tool]] to un-hide the activities.&lt;br /&gt;
&lt;br /&gt;
If you really, really need to keep using the old assignment (2.2) module, you should update the code to Moodle 3.0, and then replace the &amp;quot;mod/assignment&amp;quot; folder with the one from https://github.com/moodlehq/moodle-mod_assignment/releases before completing the upgrade.&lt;br /&gt;
&lt;br /&gt;
==Possible issues that may affect you in Moodle {{Version}}==&lt;br /&gt;
&lt;br /&gt;
* Sites using a custom theme or login form must include a new login token field in the login form. See the dev docs [[:dev:Login token|Login token]] for details.&lt;br /&gt;
* To use &#039;Run now&#039; links in [[Scheduled tasks]], you will need to set &#039;Path to PHP CLI&#039; (pathtophp) in Site administration / Server / System paths.&lt;br /&gt;
* Adding another user as a messaging contact now requires approval from the other user. Any contacts that you have that aren&#039;t mutual (ie. both users have added each other as a contact) will be removed from your list of contacts.&lt;br /&gt;
* New setting &#039;Allow site-wide messaging&#039; in Site administration / Advanced features. The setting is disabled by default (for new installs) but enabled for upgraded sites.&lt;br /&gt;
* The timeline tab in the course overview block is now in a separate block [[Timeline block|Timeline]]. There are also more new Dashboard blocks - [[Recently accessed courses block|Recently accessed courses]], [[Recently accessed items block|Recently accessed items]] and [[Starred courses block|Starred courses]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Please add more items...&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
See also the list of [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.6%22)%20AND%20labels%20%3D%20upgrade_notes upgrade_notes-labelled issues] and [https://tracker.moodle.org/issues/?jql=project%20%3D%20mdl%20AND%20resolution%20%3D%20fixed%20AND%20fixVersion%20in%20(%223.6%22)%20AND%20labels%20%3D%20ui_change%20 ui_change-labelled issues]. &lt;br /&gt;
&lt;br /&gt;
=== Moodle 3.1, 3.2, 3.3, 3.4 and 3.5 improvements ===&lt;br /&gt;
&lt;br /&gt;
Depending on which version you are upgrading from, please see the section &#039;Possible issues that may affect you&#039; in the documentation&lt;br /&gt;
&lt;br /&gt;
* [https://docs.moodle.org/31/en/Upgrading Upgrading to Moodle 3.1]&lt;br /&gt;
* [https://docs.moodle.org/32/en/Upgrading Upgrading to Moodle 3.2]&lt;br /&gt;
* [https://docs.moodle.org/33/en/Upgrading Upgrading to Moodle 3.3]&lt;br /&gt;
* [https://docs.moodle.org/34/en/Upgrading Upgrading to Moodle 3.4]&lt;br /&gt;
* [https://docs.moodle.org/35/en/Upgrading Upgrading to Moodle 3.5]&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Installation]]&lt;br /&gt;
* Using Moodle [http://moodle.org/mod/forum/view.php?id=28 Installation help forum] &lt;br /&gt;
* [[dev:Moodle {{Version}} release notes|Moodle {{Version}} release notes]]&lt;br /&gt;
&lt;br /&gt;
[[es:Actualización de moodle]]&lt;br /&gt;
[[fr:Mise à jour]]&lt;br /&gt;
[[ja:Moodleをアップグレードする]]&lt;br /&gt;
[[de:Aktualisierung von Moodle]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Feedback_templates&amp;diff=132096</id>
		<title>Feedback templates</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Feedback_templates&amp;diff=132096"/>
		<updated>2018-10-24T13:34:00Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Save these questions as a new template */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Feedback}}&lt;br /&gt;
Within the Feedback Module you can create and re-use sets of Feedback questions using the Template tool.&lt;br /&gt;
&lt;br /&gt;
The Templates tab provides the following template features:&lt;br /&gt;
&lt;br /&gt;
==Use a template==&lt;br /&gt;
&lt;br /&gt;
Previously saved Templates will be listed in this area and can be selected using the dropdown menu.&lt;br /&gt;
&lt;br /&gt;
After selecting a Template, Moodle will display a preview of the Feedback questions contained within the Template and confirm Are you sure you want to use this template?&lt;br /&gt;
&lt;br /&gt;
You will also be required to select one of two options:&lt;br /&gt;
&lt;br /&gt;
;Delete old items&lt;br /&gt;
:Remove any questions/text types previously added to the Feedback Activity you are viewing before importing items from the selected Template&lt;br /&gt;
&lt;br /&gt;
;Append new items&lt;br /&gt;
:Add items stored within the selected template to the current Feedback activity, to any existing questions/text types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once you have made your selection click Save changes to copy across the Feedback items or press Cancel to exit from the template copy process.&lt;br /&gt;
&lt;br /&gt;
== Save these questions as a new template ==&lt;br /&gt;
&lt;br /&gt;
After creating a new Feedback activity and populating it with questions, you can save it as a Template for re-use by yourself or others.&lt;br /&gt;
&lt;br /&gt;
When saving a new Template enter a descriptive title in the Name field and choose whether you wish to make this Template available for use by others via the Public tickbox . A Public template may be viewed and re-used by users with appropriate access rights such as administrators and teacher/trainers. When a Public template is used as a basis for a new Feedback, the activity settings and questions within it may be edited by the teacher/trainer, however the original Template remains unchanged.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; To create public templates users must have the mod/feedback:createpublictemplate capability at the System/Site level. This will not be the case by default. You would either need to allow this capability in the &#039;Authenticated user&#039; role or create a specific side-wide role for permitted users.&lt;br /&gt;
&lt;br /&gt;
== Delete Template... ==&lt;br /&gt;
&lt;br /&gt;
To remove a Template you have created or have appropriate permissions to edit, from your Moodle site, use the Delete template... link and click the delete icon next to the corresponding template name.&lt;br /&gt;
&lt;br /&gt;
==Export Questions==&lt;br /&gt;
&lt;br /&gt;
The Export Questions tool allows you to save the questions/text types within your Feedback Activity in .xml format. Clicking the Export questions link will prompt you to Save or Open this file.&lt;br /&gt;
&lt;br /&gt;
==Import Questions==&lt;br /&gt;
&lt;br /&gt;
Where you have previously exported and saved questions from a Feedback activity in .xml format, you can reimport them into a new Feedback activity. &lt;br /&gt;
&lt;br /&gt;
The Import questions tool is particularly useful where you need to import questions from a different instance of Moodle and the Template tool is not applicable. &lt;br /&gt;
&lt;br /&gt;
Tip: You can also use the Import/Export ability to combine multiple Imports from multiple templates; also it can be used to avoid creating duplicates when using Append.&lt;br /&gt;
&lt;br /&gt;
After clicking on the Import questions link you will be prompted to select one of the following options:&lt;br /&gt;
&lt;br /&gt;
;Delete old items&lt;br /&gt;
:The current questions and all your user&#039;s responses will be deleted within the current Feedback activity&lt;br /&gt;
&lt;br /&gt;
;Append new items&lt;br /&gt;
:All old questions and the assigned values will be preserved within the current Feedback activity and the imported questions will be added to the existing questions.&lt;br /&gt;
&lt;br /&gt;
Use the Choose a file button to navigate to the course Files area and upload and/or select the relevant .xml file. Once selected use the Import from this file button to import the questions or use Cancel to return to the Templates general tab.&lt;br /&gt;
&lt;br /&gt;
[[de:Feedback-Vorlagen]]&lt;br /&gt;
[[es:Plantillas de retroalimentación]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Feedback_templates&amp;diff=132095</id>
		<title>Feedback templates</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Feedback_templates&amp;diff=132095"/>
		<updated>2018-10-24T13:33:28Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Save these questions as a new template */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Feedback}}&lt;br /&gt;
Within the Feedback Module you can create and re-use sets of Feedback questions using the Template tool.&lt;br /&gt;
&lt;br /&gt;
The Templates tab provides the following template features:&lt;br /&gt;
&lt;br /&gt;
==Use a template==&lt;br /&gt;
&lt;br /&gt;
Previously saved Templates will be listed in this area and can be selected using the dropdown menu.&lt;br /&gt;
&lt;br /&gt;
After selecting a Template, Moodle will display a preview of the Feedback questions contained within the Template and confirm Are you sure you want to use this template?&lt;br /&gt;
&lt;br /&gt;
You will also be required to select one of two options:&lt;br /&gt;
&lt;br /&gt;
;Delete old items&lt;br /&gt;
:Remove any questions/text types previously added to the Feedback Activity you are viewing before importing items from the selected Template&lt;br /&gt;
&lt;br /&gt;
;Append new items&lt;br /&gt;
:Add items stored within the selected template to the current Feedback activity, to any existing questions/text types.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Once you have made your selection click Save changes to copy across the Feedback items or press Cancel to exit from the template copy process.&lt;br /&gt;
&lt;br /&gt;
== Save these questions as a new template ==&lt;br /&gt;
&lt;br /&gt;
After creating a new Feedback activity and populating it with questions, you can save it as a Template for re-use by yourself or others.&lt;br /&gt;
&lt;br /&gt;
When saving a new Template enter a descriptive title in the Name field and choose whether you wish to make this Template available for use by others via the Public tickbox . A Public template may be viewed and re-used by users with appropriate access rights such as administrators and teacher/trainers. When a Public template is used as a basis for a new Feedback, the activity settings and questions within it may be edited by the teacher/trainer, however the original Template remains unchanged.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; To create public templates users must have the mod/feedback:createpublictemplate capability at the System/Site level. This will not be the case by default. You would either need to allow this capability in the &#039;Authenticated user&#039; role or crate a specific side-wide role for permitted users.&lt;br /&gt;
&lt;br /&gt;
== Delete Template... ==&lt;br /&gt;
&lt;br /&gt;
To remove a Template you have created or have appropriate permissions to edit, from your Moodle site, use the Delete template... link and click the delete icon next to the corresponding template name.&lt;br /&gt;
&lt;br /&gt;
==Export Questions==&lt;br /&gt;
&lt;br /&gt;
The Export Questions tool allows you to save the questions/text types within your Feedback Activity in .xml format. Clicking the Export questions link will prompt you to Save or Open this file.&lt;br /&gt;
&lt;br /&gt;
==Import Questions==&lt;br /&gt;
&lt;br /&gt;
Where you have previously exported and saved questions from a Feedback activity in .xml format, you can reimport them into a new Feedback activity. &lt;br /&gt;
&lt;br /&gt;
The Import questions tool is particularly useful where you need to import questions from a different instance of Moodle and the Template tool is not applicable. &lt;br /&gt;
&lt;br /&gt;
Tip: You can also use the Import/Export ability to combine multiple Imports from multiple templates; also it can be used to avoid creating duplicates when using Append.&lt;br /&gt;
&lt;br /&gt;
After clicking on the Import questions link you will be prompted to select one of the following options:&lt;br /&gt;
&lt;br /&gt;
;Delete old items&lt;br /&gt;
:The current questions and all your user&#039;s responses will be deleted within the current Feedback activity&lt;br /&gt;
&lt;br /&gt;
;Append new items&lt;br /&gt;
:All old questions and the assigned values will be preserved within the current Feedback activity and the imported questions will be added to the existing questions.&lt;br /&gt;
&lt;br /&gt;
Use the Choose a file button to navigate to the course Files area and upload and/or select the relevant .xml file. Once selected use the Import from this file button to import the questions or use Cancel to return to the Templates general tab.&lt;br /&gt;
&lt;br /&gt;
[[de:Feedback-Vorlagen]]&lt;br /&gt;
[[es:Plantillas de retroalimentación]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=131730</id>
		<title>Installation quick guide</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=131730"/>
		<updated>2018-08-21T21:01:18Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Getting Moodle */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page is intended for administrators who are experienced with installing web server applications and are in a hurry to get up and running. Otherwise please see [[Installing Moodle]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Basic Requirements==&lt;br /&gt;
&lt;br /&gt;
* You will need a working web server (e.g. [[Apache]]), a database (e.g. [[MySQL]], [[MariaDB]] or [[PostgreSQL]]) and have [[PHP]] configured. See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
* Moodle requires a number of [[PHP]] extensions. However, Moodle checks early in the installation process and you can fix the problem and re-start the install script if any are missing.&lt;br /&gt;
* If you want Moodle to send email (you probably do) you need a working Sendmail (Unix/Linux) on your server or access to an SMTP mail server.&lt;br /&gt;
&lt;br /&gt;
==Getting Moodle==&lt;br /&gt;
&lt;br /&gt;
You have two basic options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads ... OR&lt;br /&gt;
* Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b MOODLE_35_STABLE git://git.moodle.org/moodle.git &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
...this fetches a complete copy of the Moodle repository and then switches to the {{Version}} Stable branch. &lt;br /&gt;
&lt;br /&gt;
See [[Git_for_Administrators|Git for Administrators ]] for details on using Git to install Moodle code.&lt;br /&gt;
&lt;br /&gt;
Note: Only download Moodle from one of the moodle.org sources. Other versions (e.g. control panel based installers, Linux distribution repositories, other &amp;quot;one click&amp;quot; installers) cannot be guaranteed to work properly, be upgradable or be supportable.&lt;br /&gt;
&lt;br /&gt;
==Create a database==&lt;br /&gt;
&lt;br /&gt;
* Using your chosen database server, create a new empty database. The default encoding must be UTF8. For example, using MySQL:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Create a user/password combination with appropriate permissions for the database. For example (MySQL again):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO &#039;moodleuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;yourpassword&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes: It is important to GRANT ON moodle.* as the database name including the &#039;.*&#039; and not just the bare database name. Save this password you use for the Moodle user, since you will need it later in the install.&lt;br /&gt;
&lt;br /&gt;
==Create data directory==&lt;br /&gt;
&lt;br /&gt;
* Create an empty directory to hold Moodle files. It &#039;&#039;&#039;must not&#039;&#039;&#039; be in the area served by the web server and must have permissions so that the web server user can write to it. Other than that it can be located anywhere. Typically, either make it owned by the web server user or give it write permissions for &#039;everyone&#039;. If it is on a shared/NFS drive then read [[Caching]] - Moodle caches to this disk area by default and a slow share will mean terrible performance.&lt;br /&gt;
&lt;br /&gt;
==Install Moodle code==&lt;br /&gt;
&lt;br /&gt;
* If you downloaded the zip or tgz file earlier, then unzip / untar / move / copy the Moodle code (obtained above) so that it will be served by your web server (e.g. on Debian based Linux, move to /var/www/html/moodle)&lt;br /&gt;
* Check the permissions and make sure that the web server does &#039;&#039;&#039;not&#039;&#039;&#039; have permissions to write to any of the files in the Moodle code directories (a very common root cause of sites being hacked).&lt;br /&gt;
* If you need to, configure your web server to serve the Moodle site with your chosen URL.&lt;br /&gt;
&lt;br /&gt;
==Configure Moodle==&lt;br /&gt;
&lt;br /&gt;
* In the Moodle code directory, find the file &#039;&#039;config-dist.php&#039;&#039; and copy it to a new file called &#039;&#039;config.php&#039;&#039; (but read next step, &#039;Install Moodle&#039;, first).&lt;br /&gt;
* Edit config.php with your favourite editor and change the appropriate settings to point to your site, directories and database. &#039;&#039;Note: the Moodle install script will create config.php for you if it does not exist but make sure you (re-)set permissions appropriately afterwards&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Install Moodle==&lt;br /&gt;
&lt;br /&gt;
* Go to the URL for your moodle site in a browser (installation will complete automatically) or run the command line version at (requires cli version of PHP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/php /path/to/moodle/admin/cli/install.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The CLI creates the config.php for you and will not run if you created one in the previous step.&lt;br /&gt;
* After completing the install make sure your file permissions are ok for the Moodle program files (not writeable by web server) and the Moodle data files (writeable by web server).&lt;br /&gt;
&lt;br /&gt;
==Set up cron==&lt;br /&gt;
&lt;br /&gt;
You will need a cron job to run periodically. It is recommended that &#039;&#039;the cron is run every minute&#039;&#039;, as required for asynchronous activity deletion when using the [[Recycle bin|recycle bin]]. A typical Unix cron entry will be as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* * * * *    /usr/bin/php /path/to/moodle/admin/cli/cron.php &amp;gt;/dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your site &#039;&#039;&#039;will not work properly&#039;&#039;&#039; unless cron is running regularly. It is very important you do not skip this step.&lt;br /&gt;
&lt;br /&gt;
See [[Cron]] for details.&lt;br /&gt;
&lt;br /&gt;
==Congratulations!==&lt;br /&gt;
&lt;br /&gt;
You are now ready to use your Moodle site.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, check the [[Installation FAQ]] and visit the [http://moodle.org/mod/forum/view.php?id=28 Installation help forum].&lt;br /&gt;
&lt;br /&gt;
[[Category:Quick guide]]&lt;br /&gt;
&lt;br /&gt;
[[de:Installation in Kürze]]&lt;br /&gt;
[[fr:Installation_rapide]]&lt;br /&gt;
[[es:Inicio_Rápido_de_Instalación]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=131729</id>
		<title>Installation quick guide</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=131729"/>
		<updated>2018-08-21T21:00:41Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: Wrong branch&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page is intended for administrators who are experienced with installing web server applications and are in a hurry to get up and running. Otherwise please see [[Installing Moodle]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Basic Requirements==&lt;br /&gt;
&lt;br /&gt;
* You will need a working web server (e.g. [[Apache]]), a database (e.g. [[MySQL]], [[MariaDB]] or [[PostgreSQL]]) and have [[PHP]] configured. See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
* Moodle requires a number of [[PHP]] extensions. However, Moodle checks early in the installation process and you can fix the problem and re-start the install script if any are missing.&lt;br /&gt;
* If you want Moodle to send email (you probably do) you need a working Sendmail (Unix/Linux) on your server or access to an SMTP mail server.&lt;br /&gt;
&lt;br /&gt;
==Getting Moodle==&lt;br /&gt;
&lt;br /&gt;
You have two basic options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads ... OR&lt;br /&gt;
* Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b MOODLE_35_STABLE git://git.moodle.org/moodle.git &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
...this fetches a complete copy of the Moodle repository and then switches to the {{Version}} Stable branch. &lt;br /&gt;
&lt;br /&gt;
See [[Git_for_Administrators|Git for Administrators ]] for details on using Git to install Moodle code.&lt;br /&gt;
&lt;br /&gt;
Note: Only download Moodle from one of the moodle.org sources. Other versions (e.g. control panel based installers, Linux distribution repositories) cannot be guaranteed to work properly, be upgradable or be supportable.&lt;br /&gt;
&lt;br /&gt;
==Create a database==&lt;br /&gt;
&lt;br /&gt;
* Using your chosen database server, create a new empty database. The default encoding must be UTF8. For example, using MySQL:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Create a user/password combination with appropriate permissions for the database. For example (MySQL again):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO &#039;moodleuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;yourpassword&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes: It is important to GRANT ON moodle.* as the database name including the &#039;.*&#039; and not just the bare database name. Save this password you use for the Moodle user, since you will need it later in the install.&lt;br /&gt;
&lt;br /&gt;
==Create data directory==&lt;br /&gt;
&lt;br /&gt;
* Create an empty directory to hold Moodle files. It &#039;&#039;&#039;must not&#039;&#039;&#039; be in the area served by the web server and must have permissions so that the web server user can write to it. Other than that it can be located anywhere. Typically, either make it owned by the web server user or give it write permissions for &#039;everyone&#039;. If it is on a shared/NFS drive then read [[Caching]] - Moodle caches to this disk area by default and a slow share will mean terrible performance.&lt;br /&gt;
&lt;br /&gt;
==Install Moodle code==&lt;br /&gt;
&lt;br /&gt;
* If you downloaded the zip or tgz file earlier, then unzip / untar / move / copy the Moodle code (obtained above) so that it will be served by your web server (e.g. on Debian based Linux, move to /var/www/html/moodle)&lt;br /&gt;
* Check the permissions and make sure that the web server does &#039;&#039;&#039;not&#039;&#039;&#039; have permissions to write to any of the files in the Moodle code directories (a very common root cause of sites being hacked).&lt;br /&gt;
* If you need to, configure your web server to serve the Moodle site with your chosen URL.&lt;br /&gt;
&lt;br /&gt;
==Configure Moodle==&lt;br /&gt;
&lt;br /&gt;
* In the Moodle code directory, find the file &#039;&#039;config-dist.php&#039;&#039; and copy it to a new file called &#039;&#039;config.php&#039;&#039; (but read next step, &#039;Install Moodle&#039;, first).&lt;br /&gt;
* Edit config.php with your favourite editor and change the appropriate settings to point to your site, directories and database. &#039;&#039;Note: the Moodle install script will create config.php for you if it does not exist but make sure you (re-)set permissions appropriately afterwards&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Install Moodle==&lt;br /&gt;
&lt;br /&gt;
* Go to the URL for your moodle site in a browser (installation will complete automatically) or run the command line version at (requires cli version of PHP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/php /path/to/moodle/admin/cli/install.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The CLI creates the config.php for you and will not run if you created one in the previous step.&lt;br /&gt;
* After completing the install make sure your file permissions are ok for the Moodle program files (not writeable by web server) and the Moodle data files (writeable by web server).&lt;br /&gt;
&lt;br /&gt;
==Set up cron==&lt;br /&gt;
&lt;br /&gt;
You will need a cron job to run periodically. It is recommended that &#039;&#039;the cron is run every minute&#039;&#039;, as required for asynchronous activity deletion when using the [[Recycle bin|recycle bin]]. A typical Unix cron entry will be as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* * * * *    /usr/bin/php /path/to/moodle/admin/cli/cron.php &amp;gt;/dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your site &#039;&#039;&#039;will not work properly&#039;&#039;&#039; unless cron is running regularly. It is very important you do not skip this step.&lt;br /&gt;
&lt;br /&gt;
See [[Cron]] for details.&lt;br /&gt;
&lt;br /&gt;
==Congratulations!==&lt;br /&gt;
&lt;br /&gt;
You are now ready to use your Moodle site.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, check the [[Installation FAQ]] and visit the [http://moodle.org/mod/forum/view.php?id=28 Installation help forum].&lt;br /&gt;
&lt;br /&gt;
[[Category:Quick guide]]&lt;br /&gt;
&lt;br /&gt;
[[de:Installation in Kürze]]&lt;br /&gt;
[[fr:Installation_rapide]]&lt;br /&gt;
[[es:Inicio_Rápido_de_Instalación]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=MySQL_full_unicode_support&amp;diff=131508</id>
		<title>MySQL full unicode support</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=MySQL_full_unicode_support&amp;diff=131508"/>
		<updated>2018-07-17T08:43:49Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* File format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Environment}}&lt;br /&gt;
==UTF-8==&lt;br /&gt;
&lt;br /&gt;
UTF-8 is a character encoding that most websites use. It encodes each of the 1,112,064 valid code points. To store all of this information, four bytes is required. The most popular values are in the three byte region. MySQL by default only uses a three byte encoding and so values in the four byte range (eg. Asian characters and Emojis) can not be stored. Any attempt to enter a text that contains four byte characters will result in a Moodle database error.&lt;br /&gt;
&lt;br /&gt;
MySQL does provide full four byte UTF-8 support, but it requires certain database settings to be configured. From version 3.3 on Moodle uses full UTF-8 for both MySQL and MariaDB by default. Existing databases will still run with partial support, but it is recommended to move over to full support.&lt;br /&gt;
&lt;br /&gt;
Moodle comes with a Command Line Interface (CLI) script for converting to full UTF-8 for MySQL (and MariaDB). Before Moodle versions 3.1.5 and 3.2.2 this conversion tool would only change the Collation to some variant of &#039;utf8_bin&#039;. &#039;utf8_unicode_ci&#039; was the recommended Collation. We now recommend using &#039;utf8mb4_unicode_ci&#039; which supports four byte characters (utf8_unicode_ci only supports three).&lt;br /&gt;
&lt;br /&gt;
This script will attempt to change the database Collation, Character set, default table settings and column definitions.&lt;br /&gt;
&lt;br /&gt;
To summarise:&lt;br /&gt;
&lt;br /&gt;
* Fresh installs of Moodle 3.1.5 and 3.2.2 onwards will use utf8mb4 by default, if the database server is configured appropriately (see below).&lt;br /&gt;
* Sites upgrading to Moodle 3.1.5 or 3.2.2 can use the script to update to utf8mb4. In Moodle 3.3, 3.4 and 3.5 a warning will show that the database isn&#039;t using full UTF-8 support and suggest moving to &#039;utf8mb4_unicode_ci&#039;, but you may choose to keep using &#039;utf8_*&#039;.&lt;br /&gt;
&lt;br /&gt;
===File format===&lt;br /&gt;
&lt;br /&gt;
To allow for large indexes on columns that are a varchar, a combination of settings needs to be set. The file format for the system needs to be using &amp;quot;Barracuda&amp;quot;. This allows for the row format to be set to &amp;quot;Compressed&amp;quot; or &amp;quot;Dynamic&amp;quot;. To enable this setting see the upgrade steps listed below. Moodle will not install if you have large format enabled without the Barracuda file format.&lt;br /&gt;
&lt;br /&gt;
===File per table===&lt;br /&gt;
&lt;br /&gt;
To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
===Large prefix===&lt;br /&gt;
&lt;br /&gt;
This in conjunction with the row format being either &amp;quot;Compressed&amp;quot; or &amp;quot;Dynamic&amp;quot; allows for large varchar indexes above 191 characters.&lt;br /&gt;
To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
==Steps to upgrade==&lt;br /&gt;
&lt;br /&gt;
Most important: Please backup your database before making any changes or running the CLI script.&lt;br /&gt;
&lt;br /&gt;
* Change configuration settings for MySQL (exactly the same for MariaDB). This step is optional. You can run the script and it will try and make these changes itself. If errors occur then try manually changing these settings as listed below.&lt;br /&gt;
** On Linux based systems you will want to alter my.cnf. This may be located in &#039;/etc/mysql/&#039;.&lt;br /&gt;
** Make the following alterations to my.cnf:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[client]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&lt;br /&gt;
[mysqld]&lt;br /&gt;
innodb_file_format = Barracuda&lt;br /&gt;
innodb_file_per_table = 1&lt;br /&gt;
innodb_large_prefix&lt;br /&gt;
&lt;br /&gt;
character-set-server = utf8mb4&lt;br /&gt;
collation-server = utf8mb4_unicode_ci&lt;br /&gt;
skip-character-set-client-handshake&lt;br /&gt;
&lt;br /&gt;
[mysql]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* Restart your MySQL server.&lt;br /&gt;
* Run the CLI script to convert to the new Character set and Collation (requires Moodle 3.1.5, 3.2.2 or newer): &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: On very large sites this may take a long time to run. You should probably establish how long on a test install before taking your live site offline. In some cases you might consider dumping and re-importing your data.&lt;br /&gt;
&lt;br /&gt;
* Adjust the $CFG-&amp;gt;dboptions Array in your &#039;&#039;&#039;config.php&#039;&#039;&#039; to make sure that Moodle uses the right Collation when connecting to the MySQL Server: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dboptions = array(&lt;br /&gt;
  &amp;amp;hellip;&lt;br /&gt;
  &#039;dbcollation&#039; =&amp;gt; &#039;utf8mb4_unicode_ci&#039;,&lt;br /&gt;
  &amp;amp;hellip;&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you only have access to the database command line (or something like phpmyadmin) you can try the following sql commands:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET GLOBAL innodb_file_format = barracuda&lt;br /&gt;
&lt;br /&gt;
SET GLOBAL innodb_file_per_table = 1&lt;br /&gt;
&lt;br /&gt;
SET GLOBAL innodb_large_prefix = &#039;on&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try adding some Emojis (e.g. 😂💩) to your Moodle site to verify that the upgrade was successful.&lt;br /&gt;
&lt;br /&gt;
[[Category:Environment|UTF-8]]&lt;br /&gt;
[[Category:UTF-8]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:MySQL soporte unicode completo]]&lt;br /&gt;
[[fr:Support unicode complet pour MySQL]]&lt;br /&gt;
[[de:MySQL Unicode Unterstützung]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=MySQL_full_unicode_support&amp;diff=131507</id>
		<title>MySQL full unicode support</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=MySQL_full_unicode_support&amp;diff=131507"/>
		<updated>2018-07-17T08:40:31Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* UTF-8 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Environment}}&lt;br /&gt;
==UTF-8==&lt;br /&gt;
&lt;br /&gt;
UTF-8 is a character encoding that most websites use. It encodes each of the 1,112,064 valid code points. To store all of this information, four bytes is required. The most popular values are in the three byte region. MySQL by default only uses a three byte encoding and so values in the four byte range (eg. Asian characters and Emojis) can not be stored. Any attempt to enter a text that contains four byte characters will result in a Moodle database error.&lt;br /&gt;
&lt;br /&gt;
MySQL does provide full four byte UTF-8 support, but it requires certain database settings to be configured. From version 3.3 on Moodle uses full UTF-8 for both MySQL and MariaDB by default. Existing databases will still run with partial support, but it is recommended to move over to full support.&lt;br /&gt;
&lt;br /&gt;
Moodle comes with a Command Line Interface (CLI) script for converting to full UTF-8 for MySQL (and MariaDB). Before Moodle versions 3.1.5 and 3.2.2 this conversion tool would only change the Collation to some variant of &#039;utf8_bin&#039;. &#039;utf8_unicode_ci&#039; was the recommended Collation. We now recommend using &#039;utf8mb4_unicode_ci&#039; which supports four byte characters (utf8_unicode_ci only supports three).&lt;br /&gt;
&lt;br /&gt;
This script will attempt to change the database Collation, Character set, default table settings and column definitions.&lt;br /&gt;
&lt;br /&gt;
To summarise:&lt;br /&gt;
&lt;br /&gt;
* Fresh installs of Moodle 3.1.5 and 3.2.2 onwards will use utf8mb4 by default, if the database server is configured appropriately (see below).&lt;br /&gt;
* Sites upgrading to Moodle 3.1.5 or 3.2.2 can use the script to update to utf8mb4. In Moodle 3.3, 3.4 and 3.5 a warning will show that the database isn&#039;t using full UTF-8 support and suggest moving to &#039;utf8mb4_unicode_ci&#039;, but you may choose to keep using &#039;utf8_*&#039;.&lt;br /&gt;
&lt;br /&gt;
===File format===&lt;br /&gt;
&lt;br /&gt;
To allow for large indexes on columns that are a varchar, a combination of settings needs to be set. The file format for the system needs to be using &amp;quot;Barracuda&amp;quot;. This allows for the row format to be set to &amp;quot;Compressed&amp;quot; or &amp;quot;Dynamic&amp;quot;. To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
===File per table===&lt;br /&gt;
&lt;br /&gt;
To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
===Large prefix===&lt;br /&gt;
&lt;br /&gt;
This in conjunction with the row format being either &amp;quot;Compressed&amp;quot; or &amp;quot;Dynamic&amp;quot; allows for large varchar indexes above 191 characters.&lt;br /&gt;
To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
==Steps to upgrade==&lt;br /&gt;
&lt;br /&gt;
Most important: Please backup your database before making any changes or running the CLI script.&lt;br /&gt;
&lt;br /&gt;
* Change configuration settings for MySQL (exactly the same for MariaDB). This step is optional. You can run the script and it will try and make these changes itself. If errors occur then try manually changing these settings as listed below.&lt;br /&gt;
** On Linux based systems you will want to alter my.cnf. This may be located in &#039;/etc/mysql/&#039;.&lt;br /&gt;
** Make the following alterations to my.cnf:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[client]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&lt;br /&gt;
[mysqld]&lt;br /&gt;
innodb_file_format = Barracuda&lt;br /&gt;
innodb_file_per_table = 1&lt;br /&gt;
innodb_large_prefix&lt;br /&gt;
&lt;br /&gt;
character-set-server = utf8mb4&lt;br /&gt;
collation-server = utf8mb4_unicode_ci&lt;br /&gt;
skip-character-set-client-handshake&lt;br /&gt;
&lt;br /&gt;
[mysql]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* Restart your MySQL server.&lt;br /&gt;
* Run the CLI script to convert to the new Character set and Collation (requires Moodle 3.1.5, 3.2.2 or newer): &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: On very large sites this may take a long time to run. You should probably establish how long on a test install before taking your live site offline. In some cases you might consider dumping and re-importing your data.&lt;br /&gt;
&lt;br /&gt;
* Adjust the $CFG-&amp;gt;dboptions Array in your &#039;&#039;&#039;config.php&#039;&#039;&#039; to make sure that Moodle uses the right Collation when connecting to the MySQL Server: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dboptions = array(&lt;br /&gt;
  &amp;amp;hellip;&lt;br /&gt;
  &#039;dbcollation&#039; =&amp;gt; &#039;utf8mb4_unicode_ci&#039;,&lt;br /&gt;
  &amp;amp;hellip;&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you only have access to the database command line (or something like phpmyadmin) you can try the following sql commands:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET GLOBAL innodb_file_format = barracuda&lt;br /&gt;
&lt;br /&gt;
SET GLOBAL innodb_file_per_table = 1&lt;br /&gt;
&lt;br /&gt;
SET GLOBAL innodb_large_prefix = &#039;on&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try adding some Emojis (e.g. 😂💩) to your Moodle site to verify that the upgrade was successful.&lt;br /&gt;
&lt;br /&gt;
[[Category:Environment|UTF-8]]&lt;br /&gt;
[[Category:UTF-8]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:MySQL soporte unicode completo]]&lt;br /&gt;
[[fr:Support unicode complet pour MySQL]]&lt;br /&gt;
[[de:MySQL Unicode Unterstützung]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Working_with_files&amp;diff=131460</id>
		<title>Working with files</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Working_with_files&amp;diff=131460"/>
		<updated>2018-07-11T13:06:28Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Adding a new file type */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Managing content}}&lt;br /&gt;
==Adding files to your course==&lt;br /&gt;
&lt;br /&gt;
Moodle provides an easy way for a teacher to present materials to their students. These materials may take the form of files such as word-processed documents or slideshow presentations. The materials can be displayed on the page either as individual items or bundled together inside folders. One teacher might for instance wish to share a single research document in pdf format; another might have a folder of sample past examination papers for students to download. Most types of files can be uploaded and accessed through Moodle but the student needs to have the correct software to be able to open them.&lt;br /&gt;
&lt;br /&gt;
To add files to a Moodle course, you must first ensure you have the editing turned on.&lt;br /&gt;
&lt;br /&gt;
===Drag and drop===&lt;br /&gt;
*If you are using a modern browser, you can simply click, hold and drag and drop a file directly onto your course page. You will know if drag and drop is available to you because you will (briefly) see a message at the top of your screen:&lt;br /&gt;
[[File:dragdropmessage.png]]&lt;br /&gt;
&lt;br /&gt;
To drag and drop a folder, you must first compress/zip it using whichever program your computer has.&lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/7WzrJDYK6jA | desc = Dragging and dropping files}}&lt;br /&gt;
&lt;br /&gt;
===Add a resource or activity===&lt;br /&gt;
*Instead of drag and drop, you can click the link &#039;Add an activity or resource&#039; and  select either [[File]] or [[Folder]] from the activity chooser (or choose from the  &#039;Add a resource&#039; drop down menu, if this is present instead.)&lt;br /&gt;
&lt;br /&gt;
{{MediaPlayer | url = https://youtu.be/sym4KWInX3c | desc = Uploading files}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:filefolder23.png|thumb|Selecting a file or folder in the activity chooser]]&lt;br /&gt;
| [[File:Workingwithfiles.png|thumb|The &amp;quot;Add a resource&amp;quot; drop down menu]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
*The screen for uploading and displaying a file (or folder of files) includes an &amp;quot;add&amp;quot; button. Clicking on this button takes you to the [[File picker]] which is the name given to the file storage and access area within Moodle. Find out more about the places you can upload or add files from in the [[File picker]] page.&lt;br /&gt;
*There is also a block (with an arrow) into which you can drag and drop a file straight from your desktop into Moodle.&lt;br /&gt;
&lt;br /&gt;
| [[File:newdraganddrop.png|thumb|Area for dragging and dropping files into]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Unzipping uploaded files==&lt;br /&gt;
If you upload a zipped file, you need to unzip it for your students to see the individual files in Moodle. If you drag and drop the zip file you will be prompted to unzip the files and add them to a folder.&lt;br /&gt;
If you manually upload a zipped file to a folder you need to click on the file and click the Unzip button to extract the files from the zip. Once you click save, the students will be able to see the unzipped files in the folder. &lt;br /&gt;
&lt;br /&gt;
==Viewing uploaded files==&lt;br /&gt;
&lt;br /&gt;
* Once uploaded, files appear as thumbnails in the file manager for easy recognition.&lt;br /&gt;
* Files view can be easily toggled between icons view or a table view with sizes and dates, or a hierarchical list view. &lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:truthumbnailsiconsview.png|thumb|File picker icon view]]&lt;br /&gt;
| [[File:tableview.png|thumb|File picker table view]]&lt;br /&gt;
| [[File:hierarchicallistview.png|thumb|File picker hierarchical list view]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Editing or updating uploaded files==&lt;br /&gt;
&lt;br /&gt;
*Clicking on the  name of an uploaded file opens up a pop up dialogue box which allows file details quickly to be altered.&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:popupdialogue.png|thumb|File info popup dialogue]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Creating an alias/shortcut==&lt;br /&gt;
&lt;br /&gt;
*When an uploaded file - or a file from the Private files, Dropbox, File system or EQUELLA repositories - is re-used elsewhere on Moodle, the teacher has the option to make a copy (a new, unconnected version) or to create a shortcut or &#039;&#039;alias&#039;&#039;. &lt;br /&gt;
*If an alias is created, then when the original file is updated, it will change in all instances of the alias. So a teacher might add course notes to their private files for example, and then add them into a number of courses. When the teacher makes an alteration in the file in their private files, this alteration will be reflected in all instances of the course notes.&lt;br /&gt;
*An alias can be recognised by its thumbnail. See the difference in the screenshot below between the original file (left) and the alias (right):&lt;br /&gt;
*To update a file, go to its original location (for example Private files) and upload your new version &#039;&#039;with the same name&#039;&#039; . You will be prompted to override or rename the file. Choose &amp;quot;override&amp;quot; and this file will replace your original file and the alisas/shortcuts will remain and all be updated to your latest version.&lt;br /&gt;
{|&lt;br /&gt;
| [[File:alias.png|thumb|Creating an alias]]&lt;br /&gt;
| [[File:shortcut1.png|frame]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
===Areas in which aliases cannot be made===&lt;br /&gt;
&lt;br /&gt;
An alias cannot be made in the following areas of Moodle:&lt;br /&gt;
&lt;br /&gt;
* an assignment submission&lt;br /&gt;
* a forum post attachment&lt;br /&gt;
* a workshop submission&lt;br /&gt;
* a quiz essay&lt;br /&gt;
* a database activity file field&lt;br /&gt;
&lt;br /&gt;
This is to prevent cases such as a student uploading an item for assessment and then subsequently changing the original in their private files. When a student uses a file from their private files in one of these instances, they do not see the options to &amp;quot;copy&amp;quot; or &amp;quot;create an alias&amp;quot;. Below is an example of a file added to an assignment:&lt;br /&gt;
&lt;br /&gt;
{|&lt;br /&gt;
| [[File:aliasassignment.png|thumb|Assignment submission with no option to create an alias]]&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Site administration settings==&lt;br /&gt;
&lt;br /&gt;
An administrator can add new file types and view, edit and delete existing file types from &#039;&#039;Site administration &amp;gt; Server &amp;gt; File types&#039;&#039;. This means that, for example, if teachers and students on your site use a lot of files specific to a particular program, such files can now be recognised by Moodle, and, when downloaded, they will open in the correct program, rather than presenting themselves as a generic zip file.&lt;br /&gt;
&lt;br /&gt;
[[File:Filetypes1.png|center|thumb|500px||Some examples from the list]]&lt;br /&gt;
&lt;br /&gt;
===Adding a new file type===&lt;br /&gt;
1. Scroll down to the bottom of the page and click the &amp;quot;Add&amp;quot; button&lt;br /&gt;
&lt;br /&gt;
2. Add the details of your file type, using the example below as a guide. This example will add the .mobi extension (for a Kindle ebook) with the standard document icon.&lt;br /&gt;
&lt;br /&gt;
[[File:newfiletype.png|thumb|center|500px|Adding a new filetype]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE: The mimetype is set for a file when it is added/uploaded in Moodle (not when it is downloaded). If you change the mimetype associated with a file extension it will not make any difference to existing files. Only files uploaded in the future will have the new mimetype.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
3. Click to save the changes and you will see your new file type has been added to the list:&lt;br /&gt;
&lt;br /&gt;
[[File:customfileypesuccess.png|thumb|500px|center|New type in the list]]&lt;br /&gt;
&lt;br /&gt;
===Restricting allowed file types===&lt;br /&gt;
&lt;br /&gt;
* Allowed file types for [[Workshop]] submissions may be restricted&lt;br /&gt;
* It is possible to restrict file types for assignments. See [[Assignment settings]].&lt;br /&gt;
&lt;br /&gt;
===Removing a file type===&lt;br /&gt;
*Clicking the X next to a file type will remove it from the site. You will be prompted to confirm before deletion.&lt;br /&gt;
&lt;br /&gt;
===Editing an existing file type===&lt;br /&gt;
*Clicking the edit icon next to a file type will allow you to change certain details, for example the associated icon and description. If you don&#039;t wish to use the default description, you can specify your own custom description (with multi-language tags if your site supports multi-languages) or you can use an alternative language string from mimetypes.php.&lt;br /&gt;
===Google docs and docx===&lt;br /&gt;
Importing Google docs files as docx.  See https://moodle.org/mod/forum/discuss.php?d=320144&lt;br /&gt;
&lt;br /&gt;
==Alternative to MS PowerPoint and PDF files==&lt;br /&gt;
The [https://moodle.org/plugins/mod_revealjs Presentation] additional plugin displays multimedia HTML5 presentations and slide shows in users&#039; web browsers. A web friendly and more feature rich alternative to MS PowerPoint and PDF. However, presentations must be uploaded to moodledata via FTP and you&#039;ll need to learn some basic HTML to create presentations for it.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*HQ Youtube video tutorial: [http://youtu.be/Wt5Hgv-eouE Dragging and dropping files into Moodle].&lt;br /&gt;
*HQ Youtube video tutorial: [http://youtu.be/7i2roZ_OCyI Uploading files to Moodle].&lt;br /&gt;
*[https://www.youtube.com/watch?v=hvIlEkxJPrU How to zip files on Windows 10] (the first part of the video shows the process for Windows 7&amp;amp;8 as well).&lt;br /&gt;
*[https://www.youtube.com/watch?v=V0wkG6zOpjA How to zip files on Mac].&lt;br /&gt;
*[http://lewiscarr.co.uk/2014/11/moodle-file-sharing-explained/ File sharing explained] blog post by Lewis Carr.&lt;br /&gt;
*How to share a single file with students: [[File resource]].&lt;br /&gt;
*How to share a folder of files with students: [[Folder]].&lt;br /&gt;
*Questions about the file picker: [[File picker FAQ]].&lt;br /&gt;
* [[Restoring file aliases]].&lt;br /&gt;
*[http://www.youtube.com/watch?v=IrOKxYRJvGU How teachers upload files in Moodle 2 video].&lt;br /&gt;
*[https://moodle.org/mod/forum/discuss.php?d=332701#p1340373 Powerpoint alternative..for course presentation ] forum thread.&lt;br /&gt;
&lt;br /&gt;
[[de:Arbeiten mit Dateien und Verzeichnissen]]&lt;br /&gt;
[[es:Trabajando con archivos]]&lt;br /&gt;
[[fr:Utilisation de fichiers]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Roles_FAQ&amp;diff=130249</id>
		<title>Roles FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Roles_FAQ&amp;diff=130249"/>
		<updated>2018-03-08T11:06:45Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* How can I prevent a user from changing their own password? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Roles}}&lt;br /&gt;
==What is the definition of a...==&lt;br /&gt;
&lt;br /&gt;
;Capability&lt;br /&gt;
:A configurable aspect of program behavior. Moodle has 100s of capabilities.   Each capability has a computer friendly name like [[Capabilities/mod/forum:rate|mod/forum:rate]] and a human-friendly name like &amp;quot;Rate posts.&amp;quot;&lt;br /&gt;
;Permission&lt;br /&gt;
:Permissions are paired with each  capability.  There are four possible permission values: &#039;&#039;Allow&#039;&#039;, &#039;&#039;Prevent&#039;&#039;, &#039;&#039;Prohibit&#039;&#039; and &#039;&#039;Not set&#039;&#039;/&#039;&#039;Inherit&#039;&#039;. (It is called not-set when defining roles and inherit when overriding permissions.)&lt;br /&gt;
;Role&lt;br /&gt;
:A named set of permissions that are associated with each capability. For example. the &amp;quot;Teacher&amp;quot; and &amp;quot;Student&amp;quot; roles come with the standard Moodle install.&lt;br /&gt;
;Context&lt;br /&gt;
:A functional area of Moodle. Contexts have a hierarchy.  Examples of contexts include a course, activity module, or resource.&lt;br /&gt;
&lt;br /&gt;
==Why isn&#039;t my role change taking effect?==&lt;br /&gt;
&lt;br /&gt;
Certain capabilities e.g. [[Capabilities/moodle/user:changeownpassword|moodle/user:changeownpassword]] may only be applied in the system context, so giving such permissions by assigning a role in the course context will have no effect.&lt;br /&gt;
&lt;br /&gt;
==Why do some users I know are in my course not appear in &#039;&#039;Participants&#039;&#039;?==&lt;br /&gt;
&lt;br /&gt;
Users assigned roles in a higher context, for example users assigned the role of teacher in the course category are technically not enrolled in the course and so will not appear in the Participants link in the [[Navigation block]] but can be found via &#039;&#039;Course administration &amp;gt; Users &amp;gt; Other users&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==How can I prevent a user from changing their own password?==&lt;br /&gt;
&lt;br /&gt;
==== Using roles ====&lt;br /&gt;
&lt;br /&gt;
To prevent a user from changing their own password, you must make sure they do not have [[Capabilities/moodle/user:changeownpassword|moodle/user:changeownpassword]] = Allow in the System context. The Authenticated user role (which is assigned to users in the System context) has moodle/user:changeownpassword = Allow by default, so you have two choices: &lt;br /&gt;
# Edit Authenticated user, setting moodle/user:changeownpassword = Not set &lt;br /&gt;
# Create a new role CannotChangeOwnPassword with moodle/user:changeownpassword = Prevent and all other permissions Not set. Choose &amp;quot;system&amp;quot; for the context type  and assign the role to selected users in the System context  via &#039;&#039;Administration&amp;gt;Site administration -&amp;gt; Users -&amp;gt; Permissions -&amp;gt; Assign system roles).&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Choice (1) will prevent &#039;&#039;all&#039;&#039; users from changing their passwords (except for the administrator, who can do anything).  To selectively allow selected users (say teachers) to change their passwords, you could create a new role CanChangeOwnPassword with moodle/user:changeownpassword = Allow and all other permissions not set and assign the role to selected users in the System context (Site administration -&amp;gt; Users -&amp;gt; Permissions -&amp;gt; Assign system roles).&lt;br /&gt;
&lt;br /&gt;
Choice (2) allows you to be selective, but if you have a lot of users that you want to prevent (say, all students), you will have to make a lot of role assignments in the System context.  There is currently no convenient way to do this, so you might consider choice (1).&lt;br /&gt;
&lt;br /&gt;
Note that you MUST deal with this permission in the System context.&lt;br /&gt;
&lt;br /&gt;
==== Alternative solution ====&lt;br /&gt;
&lt;br /&gt;
Go to Site administration &amp;gt; Plugins &amp;gt; Manage authentication plugins. Find the &#039;forgottenpasswordurl&#039; setting and point it to a static HTML page on your server (or even a Moodle Page resource on the front page). Explain your password policy on that page. This stops users changing passwords. This applies to ALL users, however, so admins will need to fix any lost passwords for the whole site.&lt;br /&gt;
&lt;br /&gt;
==How can I prevent a user from editing their own profile?==&lt;br /&gt;
&lt;br /&gt;
See [[Roles_FAQ#How can I prevent a user from changing their own password? | How can I prevent a user from changing their own password?]]  The answer to this question is the same if you substitute &#039;&#039;edit their own profile&#039;&#039; for &#039;&#039;change their own password&#039;&#039; and &#039;&#039;[[Capabilities/moodle/user:editownprofile|moodle/user:editownprofile]]&#039;&#039; for &#039;&#039;moodle/user:changeownpassword.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== How can I allow a &amp;quot;test&amp;quot; Student user to see courses that are hidden?==&lt;br /&gt;
&lt;br /&gt;
Having a test user to try out courses before you open them to regular students is useful. But if the course is hidden, then the enroled test student will not be able to see it. The solution to this problem, if you do not wish to make the hidden course visible yet, is to create a &#039;&#039;Student tester rol&#039;&#039;, a clone of the default Student role and then set the ability to see hidden courses to Allow.&lt;br /&gt;
&lt;br /&gt;
* Create a new role in &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles &amp;gt; Add a new role&#039;&#039;, then for &#039;&#039;Use role or archtype&#039;&#039; choose &#039;&#039;ARCHETYPE: Student&#039;&#039; (or Student if you have customized the default Student role already)&lt;br /&gt;
* Give the role a new shortname and fullname as appropriate, e.g. studenttester, Student Tester&lt;br /&gt;
* Change the &#039;View hidden courses&#039; [[Capabilities/moodle/course:viewhiddencourses|course:viewhiddencourses]] capability from Not Set to Allow&lt;br /&gt;
* Click the &#039;Create this role button&#039;&lt;br /&gt;
&lt;br /&gt;
Now enrol your test student in the course using this new role instead of the Student role, and they will be able to see and work in the course as a normal student even when the course is hidden. They will not be able to see other hidden courses in which they are not enroled.&lt;br /&gt;
&lt;br /&gt;
==How do I change the name for &amp;quot;teacher&amp;quot; in the course description?==&lt;br /&gt;
&lt;br /&gt;
Either&lt;br /&gt;
* Edit the role of Teacher via &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039; and rename it. The new name will apply site-wide.&lt;br /&gt;
Or&lt;br /&gt;
* Create a duplicate teacher role with an alternative name and assign users the duplicate teacher role as appropriate in the course context. In &#039;&#039;Site administration &amp;gt; Appearance &amp;gt; Course contact&#039;&#039; select the alternative name for teacher that you wish to be displayed in the course description when courses are listed. For example, copy the standard teacher role and call it Instructor and only show that role as the course contact.&lt;br /&gt;
Or&lt;br /&gt;
* Create a new &amp;quot;dummy&amp;quot; role (no capabilities) with those names and assign them to teachers along with the real roles. select the alternative name for teacher that you wish to be displayed in the course description when courses are listed.  For example, copy the guest role, call it Lead Teacher and make this the course contact.  You may have 5 teachers in the course but only one name will appear as Lead Teacher.   If nobody is assigned the role Lead Teacher, no course contact will show.&lt;br /&gt;
Or&lt;br /&gt;
*Names for different roles in a course may be changed in the [[Course settings|Course administration &amp;gt; edit settings]] &amp;quot;Role renaming&amp;quot; fields.  For example, some courses the teacher wants the title &amp;quot;Professor&amp;quot;, or &amp;quot;Chief&amp;quot; or &amp;quot;Mentor&amp;quot;.  &lt;br /&gt;
Or&lt;br /&gt;
*[[Language customization|Edit the language files]] and change any word you want.&lt;br /&gt;
&lt;br /&gt;
==How do I enable teachers to set role overrides?==&lt;br /&gt;
&lt;br /&gt;
#Access &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;.&lt;br /&gt;
#Edit the teacher role and change the capability [[Capabilities/moodle/role:safeoverride|moodle/role:safeoverride]] to allow.&lt;br /&gt;
#Click the button &amp;quot;Save changes&amp;quot;.&lt;br /&gt;
#Click the tab &amp;quot;Allow role overrides&amp;quot; (in &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;).&lt;br /&gt;
#Check the appropriate box(s) in the teacher row to set which role(s) teachers can override. Most likely it will just be the student role (you don&#039;t want teachers to be able to override admins!), so check the box where the teacher row intersects with the student column.&lt;br /&gt;
#Click the button &amp;quot;Save changes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==How do I enable teachers to assign other teachers in a course?==&lt;br /&gt;
&lt;br /&gt;
This is disabled by default but it can be switched on by modifying the teacher&#039;s role. In &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039; select the &amp;quot;Allow role assignments&amp;quot; tab and tick the checkbox where Teacher and Teacher intersect.&lt;br /&gt;
&lt;br /&gt;
==Why doesn&#039;t &amp;quot;Switch role to..&amp;quot; within a course seem to work properly?==&lt;br /&gt;
&lt;br /&gt;
This feature is intended for teachers so that they can see how their course appears for students. It isn&#039;t a reliable view however, as some features do not display correctly when viewed by a teacher who has switched their role to a student. Certain actions (specifically submitting assignments) are excluded from working with &#039;switch roles&#039; (as the submitted work would not be visible on the grading pages, due to the user not having the &#039;submit&#039; permission when they have not switched roles).For that reason  it is always preferable where possible to have a &amp;quot;test&amp;quot; student log in to use.&lt;br /&gt;
&lt;br /&gt;
==How can I allow a non-editing teacher to &amp;quot;switch role to &amp;quot; a student?==&lt;br /&gt;
&lt;br /&gt;
# In &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039;, edit the non-editing teacher role and set the capability &amp;quot;moodle/role:switchroles&amp;quot; to &amp;quot;allow&amp;quot;. This will then allow them to switch their role to a student or a guest (as defined on the &#039;&#039;Allow role switches&#039;&#039; screen.)&lt;br /&gt;
&lt;br /&gt;
==I accidentally deleted a default role. How do I get it back?==&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039; and click the &#039;Add a new role&#039; button&lt;br /&gt;
# Select the role e.g. Teacher to use&lt;br /&gt;
# Click continue&lt;br /&gt;
# Fill in the short name and custom full name&lt;br /&gt;
# Click the &#039;Create this role&#039; button&lt;br /&gt;
&lt;br /&gt;
==Are there any example roles?==&lt;br /&gt;
&lt;br /&gt;
Yes. See [[Creating_custom_roles#Example_custom_roles| the current list]].&lt;br /&gt;
&lt;br /&gt;
==How do I enable logged-in users to participate in front page activities?==&lt;br /&gt;
&lt;br /&gt;
Either:&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; and edit the &#039;Authenticated user on frontpage&#039; role&lt;br /&gt;
# Allow capabilities for the front page activities&lt;br /&gt;
# Click the &#039;Save changes&#039; button&lt;br /&gt;
&lt;br /&gt;
Or:&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Front Page &amp;gt; Front Page settings&#039;&#039;&lt;br /&gt;
# Set the default front page role to student&lt;br /&gt;
# Click the &#039;Save changes&#039; button&lt;br /&gt;
&lt;br /&gt;
==How can I prevent students from editing their profile?==&lt;br /&gt;
&lt;br /&gt;
If you only want students to be prevented from editing their profile, and not all users, you can create a new role, such as Restricted user as described in the [[Demo teacher role]], with moodle/user:editownprofile set to prevent, and assign it to all students in the system context.&lt;br /&gt;
&lt;br /&gt;
Alternatively, you could change moodle/user:editownprofile to not set for the [[Authenticated user role]], then create a new role for teachers with moodle/user:editownprofile set to allow.&lt;br /&gt;
&lt;br /&gt;
==Why can&#039;t I add teachers or students site wide in Moodle?==&lt;br /&gt;
&lt;br /&gt;
You can, however teachers and students typically work in one or more individual courses. It is unusual for a student to be studying every single course on your Moodle and unusual for a teacher to be teaching every single course. Therefore, the default Moodle does not use these as system wide roles.  The Manager role might be one that makes sense to assign on a system or category context.&lt;br /&gt;
&lt;br /&gt;
To assign a teacher or student site-wide&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039; and edit the role to include the &#039;&#039;system&#039;&#039; context. &lt;br /&gt;
#Then search for and allow the capability [[Capabilities/moodle/course:view|moodle/course:view]]&lt;br /&gt;
#Then assign users to this role via &#039;&#039;Administration&amp;gt;Site administration&amp;gt;Users&amp;gt;Permissions&amp;gt;Assign system roles&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
It might be preferable to create a new role based on the teacher or student and assign this in the System context.  Then assign individuals to that role.&lt;br /&gt;
&lt;br /&gt;
==Why isn&#039;t my custom role listed as an available role for assigning?==&lt;br /&gt;
&lt;br /&gt;
When adding/editing a custom role, be sure to tick one or more context types where the role may be assigned.&lt;br /&gt;
&lt;br /&gt;
[[File:context types where role may be assigned.png]]&lt;br /&gt;
&lt;br /&gt;
==How can I set a role back to default?==&lt;br /&gt;
&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Users &amp;gt; Permissions &amp;gt; Define roles&#039;&#039; and click on the name of the role&lt;br /&gt;
# Click the Reset button&lt;br /&gt;
# Select items for reset as desired&lt;br /&gt;
# Click the continue button.&lt;br /&gt;
&lt;br /&gt;
==Permissions don&#039;t seem to be working correctly. What can I do?==&lt;br /&gt;
&lt;br /&gt;
[[File:reviewing badge permissions.png|thumb|Reviewing role permissions]]It is recommended that permissions for each role are reviewed and set according to the role archetype.&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; and click the edit icon opposite a role&lt;br /&gt;
# Click the &#039;Show advanced&#039; button to reveal the different permission settings&lt;br /&gt;
# Review permissions (filtering for particular permissions as appropriate) and, unless there is a good reason to do otherwise, change permissions so that all are set to the highlighted value&lt;br /&gt;
# Click the &#039;Save changes&#039; button&lt;br /&gt;
# Repeat steps 1 to 4 for each role&lt;br /&gt;
&lt;br /&gt;
==Is there a role that can be safely used for a government inspector/supervisor ?==&lt;br /&gt;
The  [https://github.com/3-bits/moodle-role_sepe SEPE] role is used for a (Spanish) government supervisor who can access all Moodle courses without being able to change anything. It can be used in any other country/ language.&lt;br /&gt;
&lt;br /&gt;
==Any further questions?==&lt;br /&gt;
&lt;br /&gt;
Please visit the [http://moodle.org/mod/forum/view.php?id=6826 Roles and Capabilities forum] on moodle.org.&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[de:Rollen FAQ]]&lt;br /&gt;
[[es:FAQ_roles]]&lt;br /&gt;
[[fr:FAQ des rôles]]&lt;br /&gt;
[[ja:ロールFAQ]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=MySQL_full_unicode_support&amp;diff=129642</id>
		<title>MySQL full unicode support</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=MySQL_full_unicode_support&amp;diff=129642"/>
		<updated>2017-12-11T16:03:55Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Steps to upgrade */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Environment}}&lt;br /&gt;
==UTF-8==&lt;br /&gt;
&lt;br /&gt;
UTF-8 is a character encoding that most websites use. It encodes each of the 1,112,064 valid code points. To store all of this information, four bytes is required. The most popular values are in the three byte region. MySQL by default only uses a three byte encoding and so values in the four byte range (eg. Asian characters and Emojis) can not be stored. Any attempt to enter a text that contains four byte characters will result in a Moodle database error.&lt;br /&gt;
&lt;br /&gt;
MySQL does provide full four byte UTF-8 support, but it requires certain database settings to be configured. From version 3.3 on Moodle uses full UTF-8 for both MySQL and MariaDB by default. Existing databases will still run with partial support, but it is recommended to move over to full support.&lt;br /&gt;
&lt;br /&gt;
Moodle comes with a Command Line Interface (CLI) script for converting to full UTF-8 for MySQL (and MariaDB). Before Moodle versions 3.1.5 and 3.2.2 this conversion tool would only change the Collation to some variant of &#039;utf8_bin&#039;. &#039;utf8_unicode_ci&#039; was the recommended Collation. We now recommend using &#039;utf8mb4_unicode_ci&#039; which supports four byte characters (utf8_unicode_ci only supports three).&lt;br /&gt;
&lt;br /&gt;
This script will attempt to change the database Collation, Character set, default table settings and column definitions.&lt;br /&gt;
&lt;br /&gt;
To summarise:&lt;br /&gt;
&lt;br /&gt;
* Fresh installs of Moodle 3.1.5 and 3.2.2 onwards will use utf8mb4 by default, if the database server is configured appropriately (see below).&lt;br /&gt;
* Sites upgrading to Moodle 3.1.5 or 3.2.2 can use the script to update to utf8mb4. In Moodle 3.3 a warning will show that the database isn&#039;t using full UTF-8 support and suggest moving to &#039;utf8mb4_unicode_ci&#039;, but you may choose to keep using &#039;utf8_*&#039;.&lt;br /&gt;
&lt;br /&gt;
===File format===&lt;br /&gt;
&lt;br /&gt;
To allow for large indexes on columns that are a varchar, a combination of settings needs to be set. The file format for the system needs to be using &amp;quot;Barracuda&amp;quot;. This allows for the row format to be set to &amp;quot;Compressed&amp;quot; or &amp;quot;Dynamic&amp;quot;. To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
===File per table===&lt;br /&gt;
&lt;br /&gt;
To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
===Large prefix===&lt;br /&gt;
&lt;br /&gt;
This in conjunction with the row format being either &amp;quot;Compressed&amp;quot; or &amp;quot;Dynamic&amp;quot; allows for large varchar indexes above 191 characters.&lt;br /&gt;
To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
==Steps to upgrade==&lt;br /&gt;
&lt;br /&gt;
Most important: Please backup your database before making any changes or running the CLI script.&lt;br /&gt;
&lt;br /&gt;
* Change configuration settings for MySQL (exactly the same for MariaDB). This step is optional. You can run the script and it will try and make these changes itself. If errors occur then try manually changing these settings as listed below.&lt;br /&gt;
** On Linux based systems you will want to alter my.cnf. This may be located in &#039;/etc/mysql/&#039;.&lt;br /&gt;
** Make the following alterations to my.cnf:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[client]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&lt;br /&gt;
[mysqld]&lt;br /&gt;
innodb_file_format = Barracuda&lt;br /&gt;
innodb_file_per_table = 1&lt;br /&gt;
innodb_large_prefix&lt;br /&gt;
&lt;br /&gt;
character-set-server = utf8mb4&lt;br /&gt;
collation-server = utf8mb4_unicode_ci&lt;br /&gt;
skip-character-set-client-handshake&lt;br /&gt;
&lt;br /&gt;
[mysql]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* Restart your MySQL server.&lt;br /&gt;
* Run the CLI script to convert to the new Character set and Collation (requires Moodle 3.1.5, 3.2.2 or newer): &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: On very large sites this may take a long time to run. You should probably establish how long on a test install before taking your live site offline. In some cases you might consider dumping and re-importing your data.&lt;br /&gt;
&lt;br /&gt;
* Adjust the $CFG-&amp;gt;dboptions Array in your &#039;&#039;&#039;config.php&#039;&#039;&#039; to make sure that Moodle uses the right Collation when connecting to the MySQL Server: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dboptions = array(&lt;br /&gt;
  &amp;amp;hellip;&lt;br /&gt;
  &#039;dbcollation&#039; =&amp;gt; &#039;utf8mb4_unicode_ci&#039;,&lt;br /&gt;
  &amp;amp;hellip;&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you only have access to the database command line (or something like phpmyadmin) you can try the following sql commands:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET GLOBAL innodb_file_format = barracuda&lt;br /&gt;
&lt;br /&gt;
SET GLOBAL innodb_file_per_table = 1&lt;br /&gt;
&lt;br /&gt;
SET GLOBAL innodb_large_prefix = &#039;on&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try adding some Emojis (e.g. 😂💩) to your Moodle site to verify that the upgrade was successful.&lt;br /&gt;
&lt;br /&gt;
[[Category:Environment|UTF-8]]&lt;br /&gt;
[[Category:UTF-8]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:MySQL soporte unicode completo]]&lt;br /&gt;
[[fr:Support unicode complet pour MySQL]]&lt;br /&gt;
[[de:MySQL Unicode Unterstützung]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=MySQL_full_unicode_support&amp;diff=129641</id>
		<title>MySQL full unicode support</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=MySQL_full_unicode_support&amp;diff=129641"/>
		<updated>2017-12-11T16:00:31Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Steps to upgrade */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Environment}}&lt;br /&gt;
==UTF-8==&lt;br /&gt;
&lt;br /&gt;
UTF-8 is a character encoding that most websites use. It encodes each of the 1,112,064 valid code points. To store all of this information, four bytes is required. The most popular values are in the three byte region. MySQL by default only uses a three byte encoding and so values in the four byte range (eg. Asian characters and Emojis) can not be stored. Any attempt to enter a text that contains four byte characters will result in a Moodle database error.&lt;br /&gt;
&lt;br /&gt;
MySQL does provide full four byte UTF-8 support, but it requires certain database settings to be configured. From version 3.3 on Moodle uses full UTF-8 for both MySQL and MariaDB by default. Existing databases will still run with partial support, but it is recommended to move over to full support.&lt;br /&gt;
&lt;br /&gt;
Moodle comes with a Command Line Interface (CLI) script for converting to full UTF-8 for MySQL (and MariaDB). Before Moodle versions 3.1.5 and 3.2.2 this conversion tool would only change the Collation to some variant of &#039;utf8_bin&#039;. &#039;utf8_unicode_ci&#039; was the recommended Collation. We now recommend using &#039;utf8mb4_unicode_ci&#039; which supports four byte characters (utf8_unicode_ci only supports three).&lt;br /&gt;
&lt;br /&gt;
This script will attempt to change the database Collation, Character set, default table settings and column definitions.&lt;br /&gt;
&lt;br /&gt;
To summarise:&lt;br /&gt;
&lt;br /&gt;
* Fresh installs of Moodle 3.1.5 and 3.2.2 onwards will use utf8mb4 by default, if the database server is configured appropriately (see below).&lt;br /&gt;
* Sites upgrading to Moodle 3.1.5 or 3.2.2 can use the script to update to utf8mb4. In Moodle 3.3 a warning will show that the database isn&#039;t using full UTF-8 support and suggest moving to &#039;utf8mb4_unicode_ci&#039;, but you may choose to keep using &#039;utf8_*&#039;.&lt;br /&gt;
&lt;br /&gt;
===File format===&lt;br /&gt;
&lt;br /&gt;
To allow for large indexes on columns that are a varchar, a combination of settings needs to be set. The file format for the system needs to be using &amp;quot;Barracuda&amp;quot;. This allows for the row format to be set to &amp;quot;Compressed&amp;quot; or &amp;quot;Dynamic&amp;quot;. To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
===File per table===&lt;br /&gt;
&lt;br /&gt;
To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
===Large prefix===&lt;br /&gt;
&lt;br /&gt;
This in conjunction with the row format being either &amp;quot;Compressed&amp;quot; or &amp;quot;Dynamic&amp;quot; allows for large varchar indexes above 191 characters.&lt;br /&gt;
To enable this setting see the upgrade steps listed below.&lt;br /&gt;
&lt;br /&gt;
==Steps to upgrade==&lt;br /&gt;
&lt;br /&gt;
Most important: Please backup your database before making any changes or running the CLI script.&lt;br /&gt;
&lt;br /&gt;
* Change configuration settings for MySQL (exactly the same for MariaDB). This step is optional. You can run the script and it will try and make these changes itself. If errors occur then try manually changing these settings as listed below.&lt;br /&gt;
** On Linux based systems you will want to alter my.cnf. This may be located in &#039;/etc/mysql/&#039;.&lt;br /&gt;
** Make the following alterations to my.cnf:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
[client]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&lt;br /&gt;
[mysqld]&lt;br /&gt;
innodb_file_format = Barracuda&lt;br /&gt;
innodb_file_per_table = 1&lt;br /&gt;
innodb_large_prefix&lt;br /&gt;
&lt;br /&gt;
character-set-server = utf8mb4&lt;br /&gt;
collation-server = utf8mb4_unicode_ci&lt;br /&gt;
skip-character-set-client-handshake&lt;br /&gt;
&lt;br /&gt;
[mysql]&lt;br /&gt;
default-character-set = utf8mb4&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
* Restart your MySQL server.&lt;br /&gt;
* Run the CLI script to convert to the new Character set and Collation (requires Moodle 3.1.5, 3.2.2 or newer): &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ php admin/cli/mysql_collation.php --collation=utf8mb4_unicode_ci&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
NOTE: On very large sites this may take a long time to run. You should probably establish how long on a test install before taking your live site offline. In some cases it may consider dumping and re-importing your data.&lt;br /&gt;
&lt;br /&gt;
* Adjust the $CFG-&amp;gt;dboptions Array in your &#039;&#039;&#039;config.php&#039;&#039;&#039; to make sure that Moodle uses the right Collation when connecting to the MySQL Server: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$CFG-&amp;gt;dboptions = array(&lt;br /&gt;
  &amp;amp;hellip;&lt;br /&gt;
  &#039;dbcollation&#039; =&amp;gt; &#039;utf8mb4_unicode_ci&#039;,&lt;br /&gt;
  &amp;amp;hellip;&lt;br /&gt;
);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you only have access to the database command line (or something like phpmyadmin) you can try the following sql commands:&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
SET GLOBAL innodb_file_format = barracuda&lt;br /&gt;
&lt;br /&gt;
SET GLOBAL innodb_file_per_table = 1&lt;br /&gt;
&lt;br /&gt;
SET GLOBAL innodb_large_prefix = &#039;on&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Try adding some Emojis (e.g. 😂💩) to your Moodle site to verify that the upgrade was successful.&lt;br /&gt;
&lt;br /&gt;
[[Category:Environment|UTF-8]]&lt;br /&gt;
[[Category:UTF-8]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:MySQL soporte unicode completo]]&lt;br /&gt;
[[fr:Support unicode complet pour MySQL]]&lt;br /&gt;
[[de:MySQL Unicode Unterstützung]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=OAuth_2_Google_service&amp;diff=128980</id>
		<title>OAuth 2 Google service</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=OAuth_2_Google_service&amp;diff=128980"/>
		<updated>2017-10-23T10:07:32Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* OAuth 2 Google service setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{OAuth2}}&lt;br /&gt;
==Features requiring the OAuth 2 Google service==&lt;br /&gt;
&lt;br /&gt;
You will need to set up an OAuth 2 Google service in order to use the following features:&lt;br /&gt;
&lt;br /&gt;
* [[Google Drive repository]]&lt;br /&gt;
* [[OAuth 2 authentication]] for enabling users to log in to Moodle with their Google account&lt;br /&gt;
* [[Google Drive converter]] for converting assignment submission files to PDF for teachers to annotate&lt;br /&gt;
&lt;br /&gt;
==OAuth 2 Google service setup==&lt;br /&gt;
&lt;br /&gt;
To set up an OAuth 2 client with Google, first we need to login to the [https://console.developers.google.com/ Google Developers Console] and create a new project.&lt;br /&gt;
&lt;br /&gt;
Create a new project using the menu at the top of the page.&lt;br /&gt;
&lt;br /&gt;
[[File:google-1-create-new.png|none|frame|Create new project]]&lt;br /&gt;
&lt;br /&gt;
Call the new project whatever you like, this name is not shown to users when they are asked to authorise this application.&lt;br /&gt;
&lt;br /&gt;
[[File:google-2-create-new-modal.png|none|frame|Name the project]]&lt;br /&gt;
&lt;br /&gt;
Select &amp;quot;credentials&amp;quot; from the menu on the left.&lt;br /&gt;
&lt;br /&gt;
[[File:google-3-credentials.png|none|frame|Switch to credentials page]]&lt;br /&gt;
&lt;br /&gt;
Setup the consent screen for your application. This is where you provide the public information that is shown to users when they are asked to authorise your application. Setting a product name is the minimum information that is required, but the more information you provide here - the more confidence users will have when granting this authorisation.&lt;br /&gt;
&lt;br /&gt;
[[File:google-4-consent.png|none|frame|Setup consent screen]]&lt;br /&gt;
&lt;br /&gt;
Now you can create some client credentials. Switch to the credentials tab and create a new OAuth client ID. &lt;br /&gt;
&lt;br /&gt;
[[File:google-5-oauth-credentials.png|none|frame|Create an OAuth Client ID]]&lt;br /&gt;
&lt;br /&gt;
Setup the credentials for a Web Application. The most important setting here is to set the callback URL (&amp;quot;Authorized redirect URI&amp;quot;). This must be set to &amp;quot;your moodle site url + /admin/oauth2callback.php&amp;quot;. If your moodle site was accessible at &amp;lt;nowiki&amp;gt;https://lemon.edu/&amp;lt;/nowiki&amp;gt; then this callback URL should be set to &amp;lt;nowiki&amp;gt;https://lemon.edu/admin/oauth2callback.php&amp;lt;/nowiki&amp;gt;. Make sure this box has saved properly.&lt;br /&gt;
&lt;br /&gt;
[[File:google-6-web-application-credentials.png|none|frame|Set the callback URL]]&lt;br /&gt;
&lt;br /&gt;
When you have saved the information on this page, Google will give you the client ID and client secret that you need to enter into Moodle.&lt;br /&gt;
&lt;br /&gt;
[[File:google-7-oauth-details.png|none|frame|Got my secrets!]]&lt;br /&gt;
&lt;br /&gt;
Finally we have to enable the Drive API (if we want to use the google drive repository or file converter plugins).&lt;br /&gt;
&lt;br /&gt;
[[File:google-8-library.png|none|frame|View the Library tab]]&lt;br /&gt;
&lt;br /&gt;
[[File:google-9-select-drive.png|none|frame|Select Drive API]]&lt;br /&gt;
&lt;br /&gt;
[[File:google-10-enable-drive.png|none|frame|Enable the API]]&lt;br /&gt;
&lt;br /&gt;
==App verification==&lt;br /&gt;
&lt;br /&gt;
NOTE: If you are just using this for document conversion you will not need to verify (as it only uses one account). You will, however, need to verify your ownership of your domain (see, [https://support.google.com/webmasters/answer/35179])&lt;br /&gt;
&lt;br /&gt;
The Google Drive repository and Google Drive converter also require the app to be verified by completing the [https://support.google.com/code/contact/oauth_app_verification OAuth Developer Verification Form]. The list of scopes that Moodle requires are: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;openid profile email https://www.googleapis.com/auth/drive&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
See the discussion [https://moodle.org/mod/forum/discuss.php?d=356871 Google Drive Repository and Moodle 3.3.1] for more details.&lt;br /&gt;
&lt;br /&gt;
[[es:Servicio OAuth 2 Google]]&lt;br /&gt;
[[de:OAuth2 Google Service]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=OAuth_2_Google_service&amp;diff=128979</id>
		<title>OAuth 2 Google service</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=OAuth_2_Google_service&amp;diff=128979"/>
		<updated>2017-10-23T10:06:27Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* App verification */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{OAuth2}}&lt;br /&gt;
==Features requiring the OAuth 2 Google service==&lt;br /&gt;
&lt;br /&gt;
You will need to set up an OAuth 2 Google service in order to use the following features:&lt;br /&gt;
&lt;br /&gt;
* [[Google Drive repository]]&lt;br /&gt;
* [[OAuth 2 authentication]] for enabling users to log in to Moodle with their Google account&lt;br /&gt;
* [[Google Drive converter]] for converting assignment submission files to PDF for teachers to annotate&lt;br /&gt;
&lt;br /&gt;
==OAuth 2 Google service setup==&lt;br /&gt;
&lt;br /&gt;
To set up an OAuth 2 client with Google, first we need to login to the [https://console.developers.google.com/ Google Developers Console] and create a new project.&lt;br /&gt;
&lt;br /&gt;
Create a new project using the menu at the top of the page.&lt;br /&gt;
&lt;br /&gt;
[[File:google-1-create-new.png|none|frame|Create new project]]&lt;br /&gt;
&lt;br /&gt;
Call the new project whatever you like, this name is not shown to users when they are asked to authorise this application.&lt;br /&gt;
&lt;br /&gt;
[[File:google-2-create-new-modal.png|none|frame|Name the project]]&lt;br /&gt;
&lt;br /&gt;
Select &amp;quot;credentials&amp;quot; from the menu on the left.&lt;br /&gt;
&lt;br /&gt;
[[File:google-3-credentials.png|none|frame|Switch to credentials page]]&lt;br /&gt;
&lt;br /&gt;
Setup the consent screen for your application. This is where you provide the public information that is shown to users when they are asked to authorise your application. Setting a product name is the minimum information that is required, but the more information you provide here - the more confidence users will have when granting this authorisation.&lt;br /&gt;
&lt;br /&gt;
[[File:google-4-consent.png|none|frame|Setup consent screen]]&lt;br /&gt;
&lt;br /&gt;
Now you can create some client credentials. Switch to the credentials tab and create a new OAuth client ID. &lt;br /&gt;
&lt;br /&gt;
[[File:google-5-oauth-credentials.png|none|frame|Create an OAuth Client ID]]&lt;br /&gt;
&lt;br /&gt;
Setup the credentials for a Web Application. The most important setting here is to set the callback URL. This must be set to &amp;quot;your moodle site url + /admin/oauth2callback.php&amp;quot;. If your moodle site was accessible at &amp;lt;nowiki&amp;gt;https://lemon.edu/&amp;lt;/nowiki&amp;gt; then this callback URL should be set to &amp;lt;nowiki&amp;gt;https://lemon.edu/admin/oauth2callback.php&amp;lt;/nowiki&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:google-6-web-application-credentials.png|none|frame|Set the callback URL]]&lt;br /&gt;
&lt;br /&gt;
When you have saved the information on this page, Google will give you the client ID and client secret that you need to enter into Moodle.&lt;br /&gt;
&lt;br /&gt;
[[File:google-7-oauth-details.png|none|frame|Got my secrets!]]&lt;br /&gt;
&lt;br /&gt;
Finally we have to enable the Drive API (if we want to use the google drive repository or file converter plugins).&lt;br /&gt;
&lt;br /&gt;
[[File:google-8-library.png|none|frame|View the Library tab]]&lt;br /&gt;
&lt;br /&gt;
[[File:google-9-select-drive.png|none|frame|Select Drive API]]&lt;br /&gt;
&lt;br /&gt;
[[File:google-10-enable-drive.png|none|frame|Enable the API]]&lt;br /&gt;
&lt;br /&gt;
==App verification==&lt;br /&gt;
&lt;br /&gt;
NOTE: If you are just using this for document conversion you will not need to verify (as it only uses one account). You will, however, need to verify your ownership of your domain (see, [https://support.google.com/webmasters/answer/35179])&lt;br /&gt;
&lt;br /&gt;
The Google Drive repository and Google Drive converter also require the app to be verified by completing the [https://support.google.com/code/contact/oauth_app_verification OAuth Developer Verification Form]. The list of scopes that Moodle requires are: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;openid profile email https://www.googleapis.com/auth/drive&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
See the discussion [https://moodle.org/mod/forum/discuss.php?d=356871 Google Drive Repository and Moodle 3.3.1] for more details.&lt;br /&gt;
&lt;br /&gt;
[[es:Servicio OAuth 2 Google]]&lt;br /&gt;
[[de:OAuth2 Google Service]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Theme_settings&amp;diff=128946</id>
		<title>Theme settings</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Theme_settings&amp;diff=128946"/>
		<updated>2017-10-11T10:51:47Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Custom menu items */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Themes}}&lt;br /&gt;
== Theme settings ==&lt;br /&gt;
An administrator can change theme settings in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; Theme settings&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
[[File:Themesettings.png]]&lt;br /&gt;
&lt;br /&gt;
===Theme list===&lt;br /&gt;
This lists the themes available for course and user themes. Leave this blank to allow any valid theme to be used. If you want to shorten the theme menu, you may specify a comma-separated list of names, though don&#039;t use spaces (e.g. standard,orangewhite).&lt;br /&gt;
&lt;br /&gt;
You can  preview the available themes in &#039;&#039;Administration &amp;gt; Site Administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; Themes selector.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Theme designer mode===&lt;br /&gt;
Turn this on if you are designing and testing themes as it will stop the themes being cached and enable you to see theme changes quickly. (You can also do this with the Clear theme cache button on the theme selector page.)&lt;br /&gt;
&lt;br /&gt;
===Allow user themes===&lt;br /&gt;
If the option &#039;&#039;allowuserthemes&#039;&#039; is enabled, each user may select their preferred theme on the edit profile page. All Moodle pages will be displayed in the user&#039;s theme, apart from courses where a course theme has been set.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; the user&#039;s theme will not be available in mobile and tablet devices unless the option &#039;&#039;enabledevicedetection&#039;&#039; is unchecked.&lt;br /&gt;
&lt;br /&gt;
===Allow course themes===&lt;br /&gt;
If you enable this, then teachers will be able to set their own course themes. Course themes override all other theme choices (site, user, or session themes).&lt;br /&gt;
&lt;br /&gt;
*If the option &#039;&#039;allowcoursethemes&#039;&#039; is enabled, each editing teacher may select their course theme via the Force theme option on the [[course/edit|Course settings]] page. The course will always be displayed in the theme specified in the course setting, with user and the site themes being overwritten.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; the course theme will not be available in mobile and tablet devices unless the option &#039;&#039;enabledevicedetection&#039;&#039; is unchecked.&lt;br /&gt;
&lt;br /&gt;
===Allow category themes===&lt;br /&gt;
When enabled, themes can be set at the category level. This will affect all child categories and courses unless they have specifically set their own theme. WARNING: Enabling category themes may affect performance, as it will result in a few extra DB queries on each page, so only turn this on if you need it!&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;NOTE:&#039;&#039;&#039; the category theme will not be available in mobile and tablet devices unless the option &#039;&#039;enabledevicedetection&#039;&#039; is unchecked.&lt;br /&gt;
&lt;br /&gt;
===Allow theme changes in the URL===&lt;br /&gt;
&lt;br /&gt;
*If this is checked then the theme may be changed by adding &amp;lt;code&amp;gt;?theme=theme_name&amp;lt;/code&amp;gt; (or &amp;lt;code&amp;gt;&amp;amp;theme=theme_name&amp;lt;/code&amp;gt; if there are other URL parameters) to the URL in the browser. &lt;br /&gt;
&lt;br /&gt;
Theme names used as the URL parameter should be the shortname of the theme, which you can see in &#039;&#039;Site administration &amp;gt; Plugins &amp;gt; Plugins overview&#039;&#039; and scroll down to the Themes section near the bottom. Remove the &amp;quot;theme_&amp;quot; prefix to find the proper shortname. Theme shortnames are usually the same as the main theme name, eg. Clean is &#039;clean&#039;, so your URL parameter for it will be: &amp;lt;code&amp;gt;?theme=clean&amp;lt;/code&amp;gt;. Shortnames are always lower case. Themes with multiple words are usually the same but spaces are replaced by underscores, for example the theme &amp;quot;Formal white&amp;quot; should be entered as &amp;lt;code&amp;gt;?theme=formal_white&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
[[File:themeshortnames.jpg]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tip:&#039;&#039; You can turn this on to aid in troubleshooting problems that may be theme related. This will allow you to switch to a standard or different theme for your own session without affecting other users or the site theme.&lt;br /&gt;
&lt;br /&gt;
===Allow users to hide blocks===&lt;br /&gt;
Allows users to display and hide blocks&lt;br /&gt;
&lt;br /&gt;
===Allow blocks to use the docks===&lt;br /&gt;
*If the theme allows it, then checking this will allow the user to move blocks to the side dock.&lt;br /&gt;
&lt;br /&gt;
===Custom menu items===&lt;br /&gt;
{{Note|The [[Boost theme]] does not support submenus in the custom menu setting.}}&lt;br /&gt;
&lt;br /&gt;
The custommenuitems setting allows you to create a drop down menu that can be displayed by themes that support it. &lt;br /&gt;
&lt;br /&gt;
You are able to create the custom menu by entering custom menu items one per line into the setting. Each item is preceded by a number of hyphens (-), the number of hyphens determines the depth of the item. So items that are &#039;&#039;&#039;NOT&#039;&#039;&#039; preceded by a hyphen appear on the top level of the menu (always visible), items with a single hyphen appear on a drop down menu below the previous top level item, and  items with two hyphens appear on a drop down menu below the previous first level item and so on - &#039;&#039;if the theme allows submenus.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The content of each item is constructed of up to three bits, each separated by a &#039;&#039;&#039;|&#039;&#039;&#039; (Shift + \) character. The bits are &#039;&#039;&#039;label&#039;&#039;&#039; | &#039;&#039;&#039;url&#039;&#039;&#039; | &#039;&#039;&#039;tooltip&#039;&#039;&#039;.&lt;br /&gt;
; label : This is the text that will be shown within the menu item. You must specify a label for every item on the menu.&lt;br /&gt;
; url : This is the URL that the user will be taken to it they click the menu item. This is optional, if not provided then the item will not link anywhere.&lt;br /&gt;
; tooltip : If you provide a URL you can also choose to provide a tooltip for the link that is created with the URL. This is optional and if not set the label is used as the tooltip for the menu item.&lt;br /&gt;
&lt;br /&gt;
The following is an example of how you would create a custom menu:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Moodle community|http://moodle.org&lt;br /&gt;
-Moodle free support|http://moodle.org/support&lt;br /&gt;
-Moodle development|http://moodle.org/development&lt;br /&gt;
--Moodle Tracker|http://tracker.moodle.org&lt;br /&gt;
--Moodle Docs|https://docs.moodle.org&lt;br /&gt;
-Moodle News|http://moodle.org/news&lt;br /&gt;
Moodle company&lt;br /&gt;
-Moodle commercial hosting|http://moodle.com/hosting&lt;br /&gt;
-Moodle commercial support|http://moodle.com/support&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note: The custom menu does not escape characters within the label. If you want to use a special HTML character such as an ampersand you must escape it yourself within the label. e.g. use &amp;amp;amp;amp; instead of &amp;amp;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Multilanguage support ====&lt;br /&gt;
&lt;br /&gt;
You can add a language code (or a comma separated list of codes) as the 4th item of the line. The line will be then printed if and only if the user has currently selected the listed language. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
 English only|http://moodle.com|English only item|en&lt;br /&gt;
 German only|http://moodle.de|Deutsch|de,de_du,de_kids&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Adding other attributes to the HTML ====&lt;br /&gt;
Other attributes, such as &#039;&#039;&#039;target&#039;&#039;&#039; can be added:&lt;br /&gt;
&amp;lt;pre&amp;gt;&amp;lt;nowiki&amp;gt;&lt;br /&gt;
 Moodle Homepage|http://moodle.org&amp;quot; target=&amp;quot;_blank&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;&amp;lt;/pre&amp;gt;&lt;br /&gt;
The first quote closes the href attribute, allowing other attributes to be added. Do not add the closing quotation mark on the final attribute, it is added automatically by Moodle.&lt;br /&gt;
&lt;br /&gt;
===User menu items===&lt;br /&gt;
&lt;br /&gt;
The customusermenuitems setting allows you to add or remove items from the user menu. &lt;br /&gt;
&lt;br /&gt;
Three items, Dashboard, Profile and Log out are automatically created and can not be changed. &lt;br /&gt;
&lt;br /&gt;
Other user menu items can be set in this area by removing them, reordering them, or adding custom ones. There are three default items:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
grades,grades|/grade/report/mygrades.php|grades&lt;br /&gt;
messages,message|/message/index.php|message&lt;br /&gt;
preferences,moodle|/user/preferences.php|preferences&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The format for each is the | &amp;quot;pipe&amp;quot; character delineating three parts:&lt;br /&gt;
&lt;br /&gt;
# a string in &amp;quot;langstringname, componentname&amp;quot; form or as plain text &lt;br /&gt;
# a path to a file to run &lt;br /&gt;
# an icon either as a pix icon or as a path to a file URL&lt;br /&gt;
&lt;br /&gt;
Notes: &lt;br /&gt;
&lt;br /&gt;
1) You can refer to a language string in the users language pack by its string name. For example, in the third line above for the default settings, &amp;quot;preferences&amp;quot; is the name of the language string, and &amp;quot;moodle&amp;quot; is the language file it is located in. See Language customisation for more information. If you put a text here instead of a reference to a language string, that text will always show up and not be language specific.&lt;br /&gt;
&lt;br /&gt;
2) The examples are to php files inside the Moodle site, so &amp;quot;/message/index.php&amp;quot; is the path on the current Moodle instance. You could also put a path or URL here to files outside of Moodle as well.&lt;br /&gt;
&lt;br /&gt;
3) The example defaults of icons point to files in the /pix/t/ directory on the Moodle server. You can use any of the pre-existing icon names there (without a file extension). You can add your images to that directory to expand the icon list, or you can prefix the icon name with ../ if you want to use icons from other pix folders. Alternatively, you can use a URL to point to a file elsewhere. &amp;quot;Icon&amp;quot; files are in both png and svg format. &lt;br /&gt;
&lt;br /&gt;
Tip: If you do not specify an icon, the Moodle will supply the gear icon that is used by &amp;quot;Preferences&amp;quot; next to the entry.&lt;br /&gt;
&lt;br /&gt;
Custom item example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;Help Center|/course/view.php?id=2|check&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will add item called &amp;quot;Help Center&amp;quot; which links to a course on the same site with id=2 which has been set up as a help center for all users, and it will show using the standard check mark icon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:m32-defaultusermenuitems.jpg|center]]&lt;br /&gt;
&lt;br /&gt;
===Enable device detection===&lt;br /&gt;
&lt;br /&gt;
If a tablet or mobile theme is set, AND the user is using a tablet or mobile, theme associated with the device is used, always overriding the course, category or user theme.&lt;br /&gt;
&lt;br /&gt;
If no tablet or mobile theme is set, course, category or user themes will be used.&lt;br /&gt;
&lt;br /&gt;
===Device detection regular expressions===&lt;br /&gt;
This will allow you to customize the theme selector options.   For example, you can add a custom theme for IE6 and another for Windows CE by entering the identifying expressions the browser sends and the &amp;quot;Return value&amp;quot; you want to display as the theme selectors &amp;quot;Device type&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Special themes==&lt;br /&gt;
&lt;br /&gt;
=== Session themes ===&lt;br /&gt;
Moodle offers an additional way to set a theme - the &#039;&#039;&#039;session theme&#039;&#039;&#039;. This is set with the URL and lasts until you log out. When you next login, the site/course/user themes are active again. This option is great for theme testing and works perfectly when you want to enable different themes for different situations.&lt;br /&gt;
&lt;br /&gt;
For example you can offer a special link for PDA users and integrate the session theme &#039;&#039;orangewhitepda&#039;&#039; in that link. Nobody needs to change any settings, you just click on that link. The session theme is called by the URL parameter &amp;lt;code&amp;gt;&amp;amp;theme=orangewhitepda&amp;lt;/code&amp;gt;. The whole URL  without the session theme could look like &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://mymoodlesite.org/course/view.php?id=18&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt; and with the parameter for the PDA theme like &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;&amp;quot;http://mymoodlesite.org/course/view.php?id=18&amp;amp;theme=orangewhitepda&amp;quot;&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
In a standard Moodle installation, session themes are not active. To activate them the administrator must add the parameter &amp;lt;code&amp;gt;$CFG-&amp;gt;allowthemechangeonurl = true;&amp;lt;/code&amp;gt; to the Moodle &#039;&#039;config.php&#039;&#039; file in the Moodle base directory.&lt;br /&gt;
&lt;br /&gt;
=== Page theme ===&lt;br /&gt;
A page theme is for special page-only themes set by code, use &amp;lt;code&amp;gt;$PAGE-&amp;gt;force_theme()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
== Theme hierarchy ==&lt;br /&gt;
Here is the usual order that themes are considered by the Moodle interface.&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;border:1px dashed #ddd&amp;quot;&lt;br /&gt;
|- style=&amp;quot;vertical-align:top;text-align:left&amp;quot;&lt;br /&gt;
!Theme type&lt;br /&gt;
! style=&amp;quot;background:#eee&amp;quot;|Overwrites&lt;br /&gt;
!Display&lt;br /&gt;
! style=&amp;quot;background:#eee&amp;quot;|Setting type&lt;br /&gt;
|- style=&amp;quot;vertical-align:top&amp;quot;&lt;br /&gt;
|Site&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;| - &lt;br /&gt;
|all pages*&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|saved in theme profile&lt;br /&gt;
|- style=&amp;quot;vertical-align:top&amp;quot;&lt;br /&gt;
|User&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|Site theme&lt;br /&gt;
|all pages*&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|saved in user profile&lt;br /&gt;
|- style=&amp;quot;vertical-align:top&amp;quot;&lt;br /&gt;
|Course&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|Site, user and session themes&lt;br /&gt;
|one course&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|saved in course profile&lt;br /&gt;
|- style=&amp;quot;vertical-align:top&amp;quot;&lt;br /&gt;
|Session&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|Site and user themes&lt;br /&gt;
|all pages*&lt;br /&gt;
|style=&amp;quot;background:#eee&amp;quot;|temporary until logout&lt;br /&gt;
|}&lt;br /&gt;
(* except courses with the course theme set)&lt;br /&gt;
&lt;br /&gt;
=== Change default  hierarchy===&lt;br /&gt;
The priority of themes can be set via the /moodle/config.php file. The order defines which theme wins when there are several set at different levels. You can set a variable called $CFG-&amp;gt;themeorder (see config-dist.php for more details). By default it is set to: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$CFG-&amp;gt;themeorder = array(&#039;course&#039;, &#039;category&#039;, &#039;session&#039;, &#039;user&#039;, &#039;site&#039;);&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Particular theme settings==&lt;br /&gt;
&lt;br /&gt;
Logo, tagline, link colour, column width, custom CSS and other settings for a particular theme may be set by an administrator in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Appearance &amp;gt; Themes &amp;gt; Theme name&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
*[http://youtu.be/QfhANg1MAZ0 Moodle Theme Settings Page]  MoodleBites video on YouTube &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[es:Configuración de temas]]&lt;br /&gt;
[[fr:Réglages des thèmes]]&lt;br /&gt;
[[ja:テーマ設定]]&lt;br /&gt;
[[de:Design-Einstellungen]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Course_categories&amp;diff=128623</id>
		<title>Course categories</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Course_categories&amp;diff=128623"/>
		<updated>2017-08-18T09:25:21Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Adding a category */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Courses}}&lt;br /&gt;
Course categories organize courses for all Moodle site participants. The default course category on a new Moodle site is &amp;quot;Miscellaneous&amp;quot; (although this can be renamed) A [[Course creator|Course creator]], [[Administrator|Administrator]] or [[Manager|Manager]] can put all courses in the Miscellaneous category. However, teachers and students will find it easier to find their classes if they are organized in descriptive categories.&lt;br /&gt;
&lt;br /&gt;
The list of courses within a category by default shows the teachers and the summary of each course. If the number of courses within a category exceeds 9 (10 or more), then a short list without teachers and summary is shown.&lt;br /&gt;
&lt;br /&gt;
==Adding a category==&lt;br /&gt;
Most people organize their courses by department and college or by topic. Be sure to test the organizational scheme with a few users before entering a large number of courses, to save time in moving them later.&lt;br /&gt;
&lt;br /&gt;
Adding categories is very simple:&lt;br /&gt;
&lt;br /&gt;
*Go to &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Courses &amp;gt; Add a category&#039;&#039; &lt;br /&gt;
*Complete the details required and click &#039;Create category.&#039;&lt;br /&gt;
*Alternatively, you can go to &#039;&#039;Administration&amp;gt;Site administration&amp;gt;Courses&amp;gt;Manage courses and categories&#039;&#039; and click the link &#039;Create new category&#039;.&lt;br /&gt;
*If you are on the category page (or you only have Manager rights at a Course Category level), click the &#039;Manage courses&#039; button at the top-right of the page and then click the link &#039;Create new category&#039;.&lt;br /&gt;
&lt;br /&gt;
[[File:Addcategory.png]]&lt;br /&gt;
&lt;br /&gt;
If the category is visible, the course category description will be displayed to users when they enter the category, above the list of courses.&lt;br /&gt;
&lt;br /&gt;
==Editing or moving a category==&lt;br /&gt;
*You can edit the details of a course category by clicking the actions icon next to its name in &#039;&#039;Administration&amp;gt;Site administration&amp;gt;Courses&amp;gt;Manage courses and categories.&#039;&#039; and selecting &#039;Edit&#039;.&lt;br /&gt;
*You can move categories up or down by clicking the up/down arrow next to the category you wish to move. You can bulk move categories by checking the box to the left of their name and then by selecting from the dropdown &#039;Move selected categories to&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Editmovecategories.png]]&lt;br /&gt;
&lt;br /&gt;
==Adding sub-categories==&lt;br /&gt;
*Sometimes it might be useful to have a sub-category of a course. For example, you might have a category &amp;quot;Science&amp;quot; and wish to have sub-categories &amp;quot;Biology&amp;quot;, &amp;quot;Chemistry&amp;quot; and &amp;quot;Physics&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
*You can make one category a subcategory of another by checking the box to the left of its name and then by selecting from the drop down menu &#039;Move selected categories to&#039; You can create a new, empty sub-category by clicking the actions icon next to its name in &#039;&#039;Administration&amp;gt;Site administration&amp;gt;Courses&amp;gt;Manage courses and categories.&#039;&#039; and selecting &#039;Create new subcategory.&#039;&lt;br /&gt;
&lt;br /&gt;
==Hiding categories==&lt;br /&gt;
*Categories may be easily hidden or shown via &#039;&#039;Administration&amp;gt;Site administration&amp;gt;Courses&amp;gt;Manage courses and categories&#039;&#039; and clicking the &#039;eye&#039; icon of the category you wish to hide.  Hidden categories are only visible to site administrators or those with the capability to &amp;quot;view hidden courses&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Sorting categories==&lt;br /&gt;
Categories may be sorted by ascending/descending names or ID numbers from &#039;&#039;Administration&amp;gt;Site administration&amp;gt;Courses&amp;gt;Manage courses and categories&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
[[File:categorysort.png|thumb|200px|center|Sorting categories]]&lt;br /&gt;
&lt;br /&gt;
Courses within categories may also be sorted. See [[Adding a new course]]&lt;br /&gt;
&lt;br /&gt;
==Setting category depth==&lt;br /&gt;
&lt;br /&gt;
You can limit the number of categories that are displayed in the front page &#039;List of Categories&#039; or &#039;Combo List&#039; from &#039;&#039;Administration&amp;gt;Site administration&amp;gt;Front page&amp;gt;Front page settings&#039;&#039; Deeper level categories will appear as links and the user can expand them.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Assigning users a role in a course category==&lt;br /&gt;
&lt;br /&gt;
To assign a Manager at the Category level, see [[Manager_role#Assigning_the_role_of_Manager_at_the_Category_level | Assign Manager role at category level]].&lt;br /&gt;
&lt;br /&gt;
To enrol teacher or students roles category wide, see [[Category enrolments]].&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
===Screencasts===&lt;br /&gt;
[http://youtu.be/1N5Vs_OfVlA Course and category management]]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=47954 Course Summary Sometimes Not Appearing]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=102803 Allowing teachers to put courses in categories]&lt;br /&gt;
&lt;br /&gt;
[[fr:Ajouter une catégorie de cours]]&lt;br /&gt;
[[es:Categorías de curso]]&lt;br /&gt;
[[de:Kursbereiche]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=128563</id>
		<title>Installation quick guide</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=128563"/>
		<updated>2017-08-11T09:50:56Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Create data directory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page is intended for administrators who are experienced with installing web server applications and are in a hurry to get up and running. Otherwise please see [[Installing Moodle]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Basic Requirements==&lt;br /&gt;
&lt;br /&gt;
* You will need a working web server (e.g. [[Apache]]), a database (e.g. [[MySQL]], [[MariaDB]] or [[PostgreSQL]]) and have [[PHP]] configured. See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
* Moodle requires a number of [[PHP]] extensions. However, Moodle checks early in the installation process and you can fix the problem and re-start the install script if any are missing.&lt;br /&gt;
* If you want Moodle to send email (you probably do) you need a working Sendmail (Unix/Linux) on your server or access to an SMTP mail server.&lt;br /&gt;
&lt;br /&gt;
==Getting Moodle==&lt;br /&gt;
&lt;br /&gt;
You have two basic options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads ... OR&lt;br /&gt;
* Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b MOODLE_{{Version2}}_STABLE git://git.moodle.org/moodle.git &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
...this fetches a complete copy of the Moodle repository and then switches to the {{Version}} Stable branch. &lt;br /&gt;
&lt;br /&gt;
See [[Git_for_Administrators|Git for Administrators ]] for details on using Git to install Moodle code.&lt;br /&gt;
&lt;br /&gt;
Note: Only download Moodle from one of the moodle.org sources. Other versions (e.g. control panel based installers, Linux distribution repositories) cannot be guaranteed to work properly, be upgradable or be supportable.&lt;br /&gt;
&lt;br /&gt;
==Create a database==&lt;br /&gt;
&lt;br /&gt;
* Using your chosen database server, create a new empty database. The default encoding must be UTF8. For example, using MySQL:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Create a user/password combination with appropriate permissions for the database. For example (MySQL again):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO &#039;moodleuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;yourpassword&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes: It is important to GRANT ON moodle.* as the database name including the &#039;.*&#039; and not just the bare database name. Save this password you use for the Moodle user, since you will need it later in the install.&lt;br /&gt;
&lt;br /&gt;
==Create data directory==&lt;br /&gt;
&lt;br /&gt;
* Create an empty directory to hold Moodle files. It &#039;&#039;&#039;must not&#039;&#039;&#039; be in the area served by the web server and must have permissions so that the web server user can write to it. Other than that it can be located anywhere. Typically, either make it owned by the web server user or give it write permissions for &#039;everyone&#039;. If it is on a shared/NFS drive then read [[Caching]] - Moodle caches to this disk area by default and a slow share will mean terrible performance.&lt;br /&gt;
&lt;br /&gt;
==Install Moodle code==&lt;br /&gt;
&lt;br /&gt;
* If you downloaded the zip or tgz file earlier, then unzip / untar / move / copy the Moodle code (obtained above) so that it will be served by your web server (e.g. on Debian based Linux, move to /var/www/html/moodle)&lt;br /&gt;
* Check the permissions and make sure that the web server does &#039;&#039;&#039;not&#039;&#039;&#039; have permissions to write to any of the files in the Moodle code directories (a very common root cause of sites being hacked).&lt;br /&gt;
* If you need to, configure your web server to serve the Moodle site with your chosen URL.&lt;br /&gt;
&lt;br /&gt;
==Configure Moodle==&lt;br /&gt;
&lt;br /&gt;
* In the Moodle code directory, find the file &#039;&#039;config-dist.php&#039;&#039; and copy it to a new file called &#039;&#039;config.php&#039;&#039; (but read next step, &#039;Install Moodle&#039;, first).&lt;br /&gt;
* Edit config.php with your favourite editor and change the appropriate settings to point to your site, directories and database. &#039;&#039;Note: the Moodle install script will create config.php for you if it does not exist but make sure you (re-)set permissions appropriately afterwards&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Install Moodle==&lt;br /&gt;
&lt;br /&gt;
* Go to the URL for your moodle site in a browser (installation will complete automatically) or run the command line version at (requires cli version of PHP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/php /path/to/moodle/admin/cli/install.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The CLI creates the config.php for you and will not run if you created one in the previous step.&lt;br /&gt;
* After completing the install make sure your file permissions are ok for the Moodle program files (not writeable by web server) and the Moodle data files (writeable by web server).&lt;br /&gt;
&lt;br /&gt;
==Set up cron==&lt;br /&gt;
&lt;br /&gt;
You will need a cron job to run periodically. It is recommended that &#039;&#039;the cron is run every minute&#039;&#039;, as required for asynchronous activity deletion when using the [[Recycle bin|recycle bin]]. A typical Unix cron entry will be as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* * * * *    /usr/bin/php /path/to/moodle/admin/cli/cron.php &amp;gt;/dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your site &#039;&#039;&#039;will not work properly&#039;&#039;&#039; unless cron is running regularly. It is very important you do not skip this step.&lt;br /&gt;
&lt;br /&gt;
See [[Cron]] for details.&lt;br /&gt;
&lt;br /&gt;
==Congratulations!==&lt;br /&gt;
&lt;br /&gt;
You are now ready to use your Moodle site.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, check the [[Installation FAQ]] and visit the [http://moodle.org/mod/forum/view.php?id=28 Installation help forum].&lt;br /&gt;
&lt;br /&gt;
[[Category:Quick guide]]&lt;br /&gt;
&lt;br /&gt;
[[ja:インストールクイックスタート]]&lt;br /&gt;
[[de:Installation in Kürze]]&lt;br /&gt;
[[fr:Installation_rapide]]&lt;br /&gt;
[[es:Inicio_Rápido_de_Instalación]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=128562</id>
		<title>Installation quick guide</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=128562"/>
		<updated>2017-08-11T09:49:08Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Install Moodle code */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page is intended for administrators who are experienced with installing web server applications and are in a hurry to get up and running. Otherwise please see [[Installing Moodle]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Basic Requirements==&lt;br /&gt;
&lt;br /&gt;
* You will need a working web server (e.g. [[Apache]]), a database (e.g. [[MySQL]], [[MariaDB]] or [[PostgreSQL]]) and have [[PHP]] configured. See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
* Moodle requires a number of [[PHP]] extensions. However, Moodle checks early in the installation process and you can fix the problem and re-start the install script if any are missing.&lt;br /&gt;
* If you want Moodle to send email (you probably do) you need a working Sendmail (Unix/Linux) on your server or access to an SMTP mail server.&lt;br /&gt;
&lt;br /&gt;
==Getting Moodle==&lt;br /&gt;
&lt;br /&gt;
You have two basic options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads ... OR&lt;br /&gt;
* Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b MOODLE_{{Version2}}_STABLE git://git.moodle.org/moodle.git &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
...this fetches a complete copy of the Moodle repository and then switches to the {{Version}} Stable branch. &lt;br /&gt;
&lt;br /&gt;
See [[Git_for_Administrators|Git for Administrators ]] for details on using Git to install Moodle code.&lt;br /&gt;
&lt;br /&gt;
Note: Only download Moodle from one of the moodle.org sources. Other versions (e.g. control panel based installers, Linux distribution repositories) cannot be guaranteed to work properly, be upgradable or be supportable.&lt;br /&gt;
&lt;br /&gt;
==Create a database==&lt;br /&gt;
&lt;br /&gt;
* Using your chosen database server, create a new empty database. The default encoding must be UTF8. For example, using MySQL:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Create a user/password combination with appropriate permissions for the database. For example (MySQL again):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO &#039;moodleuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;yourpassword&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes: It is important to GRANT ON moodle.* as the database name including the &#039;.*&#039; and not just the bare database name. Save this password you use for the Moodle user, since you will need it later in the install.&lt;br /&gt;
&lt;br /&gt;
==Create data directory==&lt;br /&gt;
&lt;br /&gt;
* Create an empty directory to hold Moodle files. It &#039;&#039;&#039;must not&#039;&#039;&#039; be in the area served by the web server and must have permissions so that the web server user can write to it. Typically, either make it owned by the web server user or give it write permissions for &#039;everyone&#039;.&lt;br /&gt;
&lt;br /&gt;
==Install Moodle code==&lt;br /&gt;
&lt;br /&gt;
* If you downloaded the zip or tgz file earlier, then unzip / untar / move / copy the Moodle code (obtained above) so that it will be served by your web server (e.g. on Debian based Linux, move to /var/www/html/moodle)&lt;br /&gt;
* Check the permissions and make sure that the web server does &#039;&#039;&#039;not&#039;&#039;&#039; have permissions to write to any of the files in the Moodle code directories (a very common root cause of sites being hacked).&lt;br /&gt;
* If you need to, configure your web server to serve the Moodle site with your chosen URL.&lt;br /&gt;
&lt;br /&gt;
==Configure Moodle==&lt;br /&gt;
&lt;br /&gt;
* In the Moodle code directory, find the file &#039;&#039;config-dist.php&#039;&#039; and copy it to a new file called &#039;&#039;config.php&#039;&#039; (but read next step, &#039;Install Moodle&#039;, first).&lt;br /&gt;
* Edit config.php with your favourite editor and change the appropriate settings to point to your site, directories and database. &#039;&#039;Note: the Moodle install script will create config.php for you if it does not exist but make sure you (re-)set permissions appropriately afterwards&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Install Moodle==&lt;br /&gt;
&lt;br /&gt;
* Go to the URL for your moodle site in a browser (installation will complete automatically) or run the command line version at (requires cli version of PHP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/php /path/to/moodle/admin/cli/install.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The CLI creates the config.php for you and will not run if you created one in the previous step.&lt;br /&gt;
* After completing the install make sure your file permissions are ok for the Moodle program files (not writeable by web server) and the Moodle data files (writeable by web server).&lt;br /&gt;
&lt;br /&gt;
==Set up cron==&lt;br /&gt;
&lt;br /&gt;
You will need a cron job to run periodically. It is recommended that &#039;&#039;the cron is run every minute&#039;&#039;, as required for asynchronous activity deletion when using the [[Recycle bin|recycle bin]]. A typical Unix cron entry will be as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* * * * *    /usr/bin/php /path/to/moodle/admin/cli/cron.php &amp;gt;/dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your site &#039;&#039;&#039;will not work properly&#039;&#039;&#039; unless cron is running regularly. It is very important you do not skip this step.&lt;br /&gt;
&lt;br /&gt;
See [[Cron]] for details.&lt;br /&gt;
&lt;br /&gt;
==Congratulations!==&lt;br /&gt;
&lt;br /&gt;
You are now ready to use your Moodle site.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, check the [[Installation FAQ]] and visit the [http://moodle.org/mod/forum/view.php?id=28 Installation help forum].&lt;br /&gt;
&lt;br /&gt;
[[Category:Quick guide]]&lt;br /&gt;
&lt;br /&gt;
[[ja:インストールクイックスタート]]&lt;br /&gt;
[[de:Installation in Kürze]]&lt;br /&gt;
[[fr:Installation_rapide]]&lt;br /&gt;
[[es:Inicio_Rápido_de_Instalación]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=128561</id>
		<title>Installation quick guide</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installation_quick_guide&amp;diff=128561"/>
		<updated>2017-08-11T09:48:29Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: Pointless message in &amp;quot;advanced&amp;quot; section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page is intended for administrators who are experienced with installing web server applications and are in a hurry to get up and running. Otherwise please see [[Installing Moodle]]&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
==Basic Requirements==&lt;br /&gt;
&lt;br /&gt;
* You will need a working web server (e.g. [[Apache]]), a database (e.g. [[MySQL]], [[MariaDB]] or [[PostgreSQL]]) and have [[PHP]] configured. See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
* Moodle requires a number of [[PHP]] extensions. However, Moodle checks early in the installation process and you can fix the problem and re-start the install script if any are missing.&lt;br /&gt;
* If you want Moodle to send email (you probably do) you need a working Sendmail (Unix/Linux) on your server or access to an SMTP mail server.&lt;br /&gt;
&lt;br /&gt;
==Getting Moodle==&lt;br /&gt;
&lt;br /&gt;
You have two basic options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads ... OR&lt;br /&gt;
* Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
git clone -b MOODLE_{{Version2}}_STABLE git://git.moodle.org/moodle.git &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
...this fetches a complete copy of the Moodle repository and then switches to the {{Version}} Stable branch. &lt;br /&gt;
&lt;br /&gt;
See [[Git_for_Administrators|Git for Administrators ]] for details on using Git to install Moodle code.&lt;br /&gt;
&lt;br /&gt;
Note: Only download Moodle from one of the moodle.org sources. Other versions (e.g. control panel based installers, Linux distribution repositories) cannot be guaranteed to work properly, be upgradable or be supportable.&lt;br /&gt;
&lt;br /&gt;
==Create a database==&lt;br /&gt;
&lt;br /&gt;
* Using your chosen database server, create a new empty database. The default encoding must be UTF8. For example, using MySQL:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CREATE DATABASE moodle DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* Create a user/password combination with appropriate permissions for the database. For example (MySQL again):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mysql&amp;gt; GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,CREATE TEMPORARY TABLES,DROP,INDEX,ALTER ON moodle.* TO &#039;moodleuser&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;yourpassword&#039;;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes: It is important to GRANT ON moodle.* as the database name including the &#039;.*&#039; and not just the bare database name. Save this password you use for the Moodle user, since you will need it later in the install.&lt;br /&gt;
&lt;br /&gt;
==Create data directory==&lt;br /&gt;
&lt;br /&gt;
* Create an empty directory to hold Moodle files. It &#039;&#039;&#039;must not&#039;&#039;&#039; be in the area served by the web server and must have permissions so that the web server user can write to it. Typically, either make it owned by the web server user or give it write permissions for &#039;everyone&#039;.&lt;br /&gt;
&lt;br /&gt;
==Install Moodle code==&lt;br /&gt;
&lt;br /&gt;
* If you downloaded the zip or tgz file earlier, then unzip / untar / move / copy the Moodle code (obtained above) so that it will be served by your web server (e.g. on Debian based Linux, move to /var/www/moodle)&lt;br /&gt;
* Check the permissions and make sure that the web server does &#039;&#039;&#039;not&#039;&#039;&#039; have permissions to write to any of the files in the Moodle code directories (a very common root cause of sites being hacked).&lt;br /&gt;
* If you need to, configure your web server to serve the Moodle site with your chosen URL.&lt;br /&gt;
&lt;br /&gt;
==Configure Moodle==&lt;br /&gt;
&lt;br /&gt;
* In the Moodle code directory, find the file &#039;&#039;config-dist.php&#039;&#039; and copy it to a new file called &#039;&#039;config.php&#039;&#039; (but read next step, &#039;Install Moodle&#039;, first).&lt;br /&gt;
* Edit config.php with your favourite editor and change the appropriate settings to point to your site, directories and database. &#039;&#039;Note: the Moodle install script will create config.php for you if it does not exist but make sure you (re-)set permissions appropriately afterwards&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
==Install Moodle==&lt;br /&gt;
&lt;br /&gt;
* Go to the URL for your moodle site in a browser (installation will complete automatically) or run the command line version at (requires cli version of PHP):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
/usr/bin/php /path/to/moodle/admin/cli/install.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The CLI creates the config.php for you and will not run if you created one in the previous step.&lt;br /&gt;
* After completing the install make sure your file permissions are ok for the Moodle program files (not writeable by web server) and the Moodle data files (writeable by web server).&lt;br /&gt;
&lt;br /&gt;
==Set up cron==&lt;br /&gt;
&lt;br /&gt;
You will need a cron job to run periodically. It is recommended that &#039;&#039;the cron is run every minute&#039;&#039;, as required for asynchronous activity deletion when using the [[Recycle bin|recycle bin]]. A typical Unix cron entry will be as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
* * * * *    /usr/bin/php /path/to/moodle/admin/cli/cron.php &amp;gt;/dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Your site &#039;&#039;&#039;will not work properly&#039;&#039;&#039; unless cron is running regularly. It is very important you do not skip this step.&lt;br /&gt;
&lt;br /&gt;
See [[Cron]] for details.&lt;br /&gt;
&lt;br /&gt;
==Congratulations!==&lt;br /&gt;
&lt;br /&gt;
You are now ready to use your Moodle site.&lt;br /&gt;
&lt;br /&gt;
If you run into problems, check the [[Installation FAQ]] and visit the [http://moodle.org/mod/forum/view.php?id=28 Installation help forum].&lt;br /&gt;
&lt;br /&gt;
[[Category:Quick guide]]&lt;br /&gt;
&lt;br /&gt;
[[ja:インストールクイックスタート]]&lt;br /&gt;
[[de:Installation in Kürze]]&lt;br /&gt;
[[fr:Installation_rapide]]&lt;br /&gt;
[[es:Inicio_Rápido_de_Instalación]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=128560</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=128560"/>
		<updated>2017-08-11T09:40:24Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* If something goes wrong... */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirments] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone --depth=1 -b MOODLE_{{Version2}}_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other options you might consider:&lt;br /&gt;
&#039;&#039;--depth=1&#039;&#039;  for shallow cloning (only) latest revision&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;--single-branch&#039;&#039;  to limit cloning to a single branch, this fetches the Moodle {{Version}} Stable branch (latest weekly build). For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
# chmod -R 0755 /path/to/moodle&lt;br /&gt;
# find /path/to/moodle -type f -exec chmod 0644 {} \;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
The third command finds all the regular files and executes the chmod command 0644 on them. &lt;br /&gt;
&lt;br /&gt;
If you want to use the built-in plugin installer you need to make the directory writable by web server user. It is strongly recommended to use ACL when your server supports it, for example if your Apache server uses account www-data: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The effect of the previous command is to allow the Apache user account (www-data in this case) to access and change files within the moodle site. Many people would consider this a brave move for a new site admin to implement. In a new moodle you can safely leave this out. A default Ubuntu install does not have the +a option for the chmod command anyway. The +a attribute is an ACL (Access Control List) facility which allows you to set per user access for individual files. For example, OSX has this by default.&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]] (recommended)&lt;br /&gt;
* [[MariaDB]] (recommended)&lt;br /&gt;
* [[MySQL]]&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (not recommended)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your server supports ACL it is recommended to set following permissions, for example if your Apache server uses account www-data:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are planning to execute PHP scripts from the command line you should set the same permissions for the current user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo chmod -R +a &amp;quot;`whoami` allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block. Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message Outputs &amp;gt; Email&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). The support contact for your site is also set on this page. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underline OS):&lt;br /&gt;
**: &amp;lt;code ini&amp;gt;[Date]&lt;br /&gt;
; Defines the default timezone used by the date functions&lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039;: [[Add a new user|Create a test user]] with a valid email address and [[message|send them a message]]. Do they receive an email copy of the message? If not, check the settings in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message outputs &amp;gt; Email&#039;&#039;. Don&#039;t be tempted to skip this step (clue: email is used to recover lost passwords, including the administrator password when you forget it!)&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory? If you don&#039;t fully understand how file ownership and permissions work on your operating system it would be time very well spent to find out.&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=128559</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=128559"/>
		<updated>2017-08-11T09:38:19Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Create the (moodledata) data directory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirments] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone --depth=1 -b MOODLE_{{Version2}}_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other options you might consider:&lt;br /&gt;
&#039;&#039;--depth=1&#039;&#039;  for shallow cloning (only) latest revision&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;--single-branch&#039;&#039;  to limit cloning to a single branch, this fetches the Moodle {{Version}} Stable branch (latest weekly build). For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
# chmod -R 0755 /path/to/moodle&lt;br /&gt;
# find /path/to/moodle -type f -exec chmod 0644 {} \;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
The third command finds all the regular files and executes the chmod command 0644 on them. &lt;br /&gt;
&lt;br /&gt;
If you want to use the built-in plugin installer you need to make the directory writable by web server user. It is strongly recommended to use ACL when your server supports it, for example if your Apache server uses account www-data: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The effect of the previous command is to allow the Apache user account (www-data in this case) to access and change files within the moodle site. Many people would consider this a brave move for a new site admin to implement. In a new moodle you can safely leave this out. A default Ubuntu install does not have the +a option for the chmod command anyway. The +a attribute is an ACL (Access Control List) facility which allows you to set per user access for individual files. For example, OSX has this by default.&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]] (recommended)&lt;br /&gt;
* [[MariaDB]] (recommended)&lt;br /&gt;
* [[MySQL]]&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (not recommended)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) redis or memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your server supports ACL it is recommended to set following permissions, for example if your Apache server uses account www-data:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are planning to execute PHP scripts from the command line you should set the same permissions for the current user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo chmod -R +a &amp;quot;`whoami` allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block. Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message Outputs &amp;gt; Email&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). The support contact for your site is also set on this page. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underline OS):&lt;br /&gt;
**: &amp;lt;code ini&amp;gt;[Date]&lt;br /&gt;
; Defines the default timezone used by the date functions&lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039;: [[Add a new user|Create a test user]] with a valid email address and [[message|send them a message]]. Do they receive an email copy of the message? If not, check the settings in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message outputs &amp;gt; Email&#039;&#039;. Don&#039;t be tempted to skip this step (clue: email is used to recover lost passwords, including the administrator password when you forget it!)&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory?&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Cron&amp;diff=127367</id>
		<title>Cron</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Cron&amp;diff=127367"/>
		<updated>2017-04-06T13:55:38Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* The web based Moodle cron command */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
The Moodle &#039;cron&#039; process is a PHP script (part of the standard Moodle installation) that must be run regularly in the background.   The Moodle cron script runs different tasks at differently scheduled intervals.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: Do not skip setting up the cron process on your server for your Moodle. Your site will not work properly without it.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
It is recommended that &#039;&#039;the cron is run every minute&#039;&#039;, as required for asynchronous activity deletion when using the [[Recycle bin|recycle bin]].&lt;br /&gt;
&lt;br /&gt;
The cron program (that runs the Moodle script) is a core part of Unix based systems (including Linux and OSX) being used to run all manner of time-dependent services. On Windows the simplest solution is to create a task in the Windows Task Scheduler and set it to run at regular intervals. On shared hosting, you should find the documentation (or ask support) how cron is configured. &lt;br /&gt;
&lt;br /&gt;
Essentially, the task involves adding a single command to the list of cron activities on your system. On Unix based systems this list is a file called a &#039;crontab&#039; which all users have.  &lt;br /&gt;
&lt;br /&gt;
== General discussion ==&lt;br /&gt;
&lt;br /&gt;
See the later sections for your server type; this section contains some general background information. &lt;br /&gt;
&lt;br /&gt;
There are essentially two steps to implementing cron:&lt;br /&gt;
# identifying the correct command to run&lt;br /&gt;
# finding the right place on your system to put the command&lt;br /&gt;
&lt;br /&gt;
=== Working out the Moodle cron command ===&lt;br /&gt;
&lt;br /&gt;
Moodle has two different ways to deploy cron which use different scripts within the Moodle install. These are as follows...&lt;br /&gt;
# The CLI (command line interpreter) script. This will be at the path &amp;lt;pre&amp;gt;/path/to/moodle/admin/cli/cron.php&amp;lt;/pre&amp;gt; If in doubt, this is the correct script to use. This needs to be run by a &#039;PHP CLI&#039; program on your computer. So the final command may look something like &amp;lt;pre&amp;gt;/usr/bin/php /path/to/moodle/admin/cli/cron.php&amp;lt;/pre&amp;gt; You can (and should) try this on your command line to see if it works. &#039;&#039;&#039;WARNING: Check your command-line PHP version is compatible with your chosen version of Moodle. The command-line PHP program is different to the one running your web site and is not always the same version.&#039;&#039;&#039;&lt;br /&gt;
# If, for some reason, you cannot run the CLI script there is the web based script. Note that this is now deprecated and may be removed in future versions. This needs to be run from a web browser and will be accessed via a web url something like &#039;&#039;&#039;http://your.moodle.site/admin/cron.php&#039;&#039;&#039;. You can find command line based web browser (e.g. wget) so the final command may look like &amp;lt;pre&amp;gt;/usr/bin/wget http://your.moodle.site/admin/cron.php&amp;lt;/pre&amp;gt; This has the advantage that it can be run from *anywhere*. If you can&#039;t get cron to work on your machine it can be run somewhere else.&lt;br /&gt;
&lt;br /&gt;
===The web based Moodle cron command===&lt;br /&gt;
* If you have a choice, do not use the web based cron. It is likely to be removed in a future Moodle version. &lt;br /&gt;
* From Moodle 2.9 onwards, the cron job can no longer be run from web by default. You will get an error message:&lt;br /&gt;
 !!! Sorry, internet access to this page has been disabled by the administrator. !!! &lt;br /&gt;
* You can change this in &#039; Dashboard ► Site administration ► Security ► Site policies &#039; by deselecting &#039;Cron execution via command line only&#039;.&lt;br /&gt;
** You will be warned that &#039;Running the cron from a web browser can expose privileged information to anonymous users. Thus it is recommended to only run the cron from the command line or set a cron password for remote access.&#039;&lt;br /&gt;
** You can then write a &#039;Cron password for remote access&#039;. If this field is left empty, no password is required.&lt;br /&gt;
** This means that the cron.php script cannot be run from a web browser without supplying the password using the following form of URL:&lt;br /&gt;
  http://site.example.com/admin/cron.php?password=opensesame&lt;br /&gt;
&lt;br /&gt;
=== Finding the right place to put the command ===&lt;br /&gt;
&lt;br /&gt;
This really does depend on the system you are using and you should find and read the documentation for your platform or hosting. In most cases getting the Moodle cron to run consists of establishing the correct command (above) and then adding it, and the time to run the command, to some sort of file. This might be either through a specific user interface or by editing the file directly.&lt;br /&gt;
&lt;br /&gt;
If using the CLI version you also need to make sure that the cron process is run as the correct user. This is not an issue with the web version. &lt;br /&gt;
&lt;br /&gt;
Example... installing cron on Ubuntu/Debian Linux. Assuming logged in as root..&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;use the crontab command to open a crontab editor window for the www-data user. This is the user that Apache (the web server) runs as on Debian based systems&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ crontab -u www-data -e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;This will open an editor window. To run the cli cron script every 1 minute, add the line:&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*/1 * * * * /usr/bin/php  /path/to/moodle/admin/cli/cron.php &amp;gt;/dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
NOTE: the final &#039;&#039;&#039;&amp;gt;/dev/null&#039;&#039;&#039; sends all the output to the &#039;bin&#039; and stops you getting an email every 1 minute.&lt;br /&gt;
&lt;br /&gt;
== Setting up cron on your system ==&lt;br /&gt;
 &lt;br /&gt;
Choose the information for your server type:&lt;br /&gt;
&lt;br /&gt;
*[[Cron with Unix or Linux]]- Cron services on various UNIX and Linux flavored operating systems.&lt;br /&gt;
*[[Cron with Windows OS]] - Cron services in Windows&lt;br /&gt;
*&#039;&#039;Apple OSX&#039;&#039; - use the built-in &#039;crontab&#039; service which is exactly the same as [[Cron with Unix or Linux]]. However, you might want to do it the &#039;Apple way&#039; using launchd - see [[Cron with MAC OS X]]&lt;br /&gt;
*[[Cron with web hosting services]]- Cron services in various web hosting examples.&lt;br /&gt;
&lt;br /&gt;
Here are some more instructions for specific hosts (please check that these are up to date):&lt;br /&gt;
&lt;br /&gt;
*[[Cron on 1and1 shared servers]]&lt;br /&gt;
&lt;br /&gt;
== Using third party cron service ==&lt;br /&gt;
 &lt;br /&gt;
Besides using cron hosted on your own server, you may use third party cron service (usually called webcron):&lt;br /&gt;
&lt;br /&gt;
*[https://cron-job.org/ cron-job.org] is a free service. (1Minute cron is possible)&lt;br /&gt;
&lt;br /&gt;
*[https://www.easycron.com EasyCron] - A webcron service provider that eliminates the need of crontab or other task schedulers to set cron job.&lt;br /&gt;
&lt;br /&gt;
=== Cron settings in Moodle ===&lt;br /&gt;
&lt;br /&gt;
An admin can set cron execution via command line only or a cron password for remote access in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Security &amp;gt; Site policies&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===Remote cron===&lt;br /&gt;
Using the &#039;web based&#039; version of cron it is perfectly ok to place the cron process on a different machine to the Moodle server. For example, the cron service on a Unix server can invoke the cron web &#039;page&#039; on a Windows based Moodle server.&lt;br /&gt;
&lt;br /&gt;
==Scheduling tasks==&lt;br /&gt;
An administrator can schedule cron tasks very precisely from Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Scheduled tasks, see [[Scheduled tasks]]&lt;br /&gt;
&lt;br /&gt;
==Running cron for several Moodle servers==&lt;br /&gt;
* Tasks can run in parallel and processes use locking to prevent tasks from running at the same time which allows cron to be triggered from multiple web servers that serve the same Moodle instance.&lt;br /&gt;
&lt;br /&gt;
* If you are running different Moodle instances on the same server, then each Moodle instance needs a cron job. (Even a single Apache web server can run different Moodle instances on different domains by using its virtual hosts capability [https://httpd.apache.org/docs/2.2/vhosts/index.html https://httpd.apache.org/docs/2.2/vhosts/index.html].)&lt;br /&gt;
&lt;br /&gt;
== Debugging Scheduled Tasks ==&lt;br /&gt;
&lt;br /&gt;
Sometimes, a particular cron task may not be working correctly. In Moodle versions before 2.7 - any cron task that was throwing exceptions would prevent the rest of cron from running. The only way to monitor if cron was completing each time, was to add some automated checking of the output of running cron (e.g. searching for the string &amp;quot;Cron completed at &amp;quot;).&lt;br /&gt;
&lt;br /&gt;
In Moodle 2.7 and later, a single failing scheduled task will not prevent the remaining tasks from completing. When any single scheduled task fails, it is marked as a failure, and scheduled to be reattempted. If the task keeps failing, the next scheduled time will be backed off until it is attempted at most once every 24 hours. But checking the [[Scheduled tasks]] admin page, you can see if any task is currently failing (it will have a non-zero fail delay - which is the number of seconds to wait before reattempting a failed task). A simple way to debug a failing task, is to run it immediately using the [[Administration via command line#Scheduled_tasks|cli scheduled task runner]] and monitor the output.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Scheduled tasks]]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Cron Wikipedia article on cron function]&lt;br /&gt;
&lt;br /&gt;
Forum discussions:&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=139263#p609060 How to log the output of a Scheduled Task on Windows] - this discussion explains a nice trick that can be very useful when you are experiencing problems with your Windows Scheduled Task and you need to log the output of the Scheduled Task to a log file.&lt;br /&gt;
*[https://moodle.org/mod/forum/discuss.php?d=324443 Cron Lock] &lt;br /&gt;
&lt;br /&gt;
[[es:Cron]]&lt;br /&gt;
[[fr:Cron]]&lt;br /&gt;
[[ja:Cron]]&lt;br /&gt;
[[de:Cron-Job]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Cron&amp;diff=127366</id>
		<title>Cron</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Cron&amp;diff=127366"/>
		<updated>2017-04-06T13:54:54Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Working out the Moodle cron command */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Installing Moodle}}&lt;br /&gt;
The Moodle &#039;cron&#039; process is a PHP script (part of the standard Moodle installation) that must be run regularly in the background.   The Moodle cron script runs different tasks at differently scheduled intervals.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: Do not skip setting up the cron process on your server for your Moodle. Your site will not work properly without it.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
It is recommended that &#039;&#039;the cron is run every minute&#039;&#039;, as required for asynchronous activity deletion when using the [[Recycle bin|recycle bin]].&lt;br /&gt;
&lt;br /&gt;
The cron program (that runs the Moodle script) is a core part of Unix based systems (including Linux and OSX) being used to run all manner of time-dependent services. On Windows the simplest solution is to create a task in the Windows Task Scheduler and set it to run at regular intervals. On shared hosting, you should find the documentation (or ask support) how cron is configured. &lt;br /&gt;
&lt;br /&gt;
Essentially, the task involves adding a single command to the list of cron activities on your system. On Unix based systems this list is a file called a &#039;crontab&#039; which all users have.  &lt;br /&gt;
&lt;br /&gt;
== General discussion ==&lt;br /&gt;
&lt;br /&gt;
See the later sections for your server type; this section contains some general background information. &lt;br /&gt;
&lt;br /&gt;
There are essentially two steps to implementing cron:&lt;br /&gt;
# identifying the correct command to run&lt;br /&gt;
# finding the right place on your system to put the command&lt;br /&gt;
&lt;br /&gt;
=== Working out the Moodle cron command ===&lt;br /&gt;
&lt;br /&gt;
Moodle has two different ways to deploy cron which use different scripts within the Moodle install. These are as follows...&lt;br /&gt;
# The CLI (command line interpreter) script. This will be at the path &amp;lt;pre&amp;gt;/path/to/moodle/admin/cli/cron.php&amp;lt;/pre&amp;gt; If in doubt, this is the correct script to use. This needs to be run by a &#039;PHP CLI&#039; program on your computer. So the final command may look something like &amp;lt;pre&amp;gt;/usr/bin/php /path/to/moodle/admin/cli/cron.php&amp;lt;/pre&amp;gt; You can (and should) try this on your command line to see if it works. &#039;&#039;&#039;WARNING: Check your command-line PHP version is compatible with your chosen version of Moodle. The command-line PHP program is different to the one running your web site and is not always the same version.&#039;&#039;&#039;&lt;br /&gt;
# If, for some reason, you cannot run the CLI script there is the web based script. Note that this is now deprecated and may be removed in future versions. This needs to be run from a web browser and will be accessed via a web url something like &#039;&#039;&#039;http://your.moodle.site/admin/cron.php&#039;&#039;&#039;. You can find command line based web browser (e.g. wget) so the final command may look like &amp;lt;pre&amp;gt;/usr/bin/wget http://your.moodle.site/admin/cron.php&amp;lt;/pre&amp;gt; This has the advantage that it can be run from *anywhere*. If you can&#039;t get cron to work on your machine it can be run somewhere else.&lt;br /&gt;
&lt;br /&gt;
===The web based Moodle cron command===&lt;br /&gt;
* From Moodle 2.9 onwards, the cron job can no longer be run from web by default. You will get an error message:&lt;br /&gt;
 !!! Sorry, internet access to this page has been disabled by the administrator. !!! &lt;br /&gt;
* You can change this in &#039; Dashboard ► Site administration ► Security ► Site policies &#039; by deselecting &#039;Cron execution via command line only&#039;.&lt;br /&gt;
** You will be warned that &#039;Running the cron from a web browser can expose privileged information to anonymous users. Thus it is recommended to only run the cron from the command line or set a cron password for remote access.&#039;&lt;br /&gt;
** You can then write a &#039;Cron password for remote access&#039;. If this field is left empty, no password is required.&lt;br /&gt;
** This means that the cron.php script cannot be run from a web browser without supplying the password using the following form of URL:&lt;br /&gt;
  http://site.example.com/admin/cron.php?password=opensesame&lt;br /&gt;
&lt;br /&gt;
=== Finding the right place to put the command ===&lt;br /&gt;
&lt;br /&gt;
This really does depend on the system you are using and you should find and read the documentation for your platform or hosting. In most cases getting the Moodle cron to run consists of establishing the correct command (above) and then adding it, and the time to run the command, to some sort of file. This might be either through a specific user interface or by editing the file directly.&lt;br /&gt;
&lt;br /&gt;
If using the CLI version you also need to make sure that the cron process is run as the correct user. This is not an issue with the web version. &lt;br /&gt;
&lt;br /&gt;
Example... installing cron on Ubuntu/Debian Linux. Assuming logged in as root..&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;use the crontab command to open a crontab editor window for the www-data user. This is the user that Apache (the web server) runs as on Debian based systems&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ crontab -u www-data -e&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;This will open an editor window. To run the cli cron script every 1 minute, add the line:&#039;&#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
*/1 * * * * /usr/bin/php  /path/to/moodle/admin/cli/cron.php &amp;gt;/dev/null&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
NOTE: the final &#039;&#039;&#039;&amp;gt;/dev/null&#039;&#039;&#039; sends all the output to the &#039;bin&#039; and stops you getting an email every 1 minute.&lt;br /&gt;
&lt;br /&gt;
== Setting up cron on your system ==&lt;br /&gt;
 &lt;br /&gt;
Choose the information for your server type:&lt;br /&gt;
&lt;br /&gt;
*[[Cron with Unix or Linux]]- Cron services on various UNIX and Linux flavored operating systems.&lt;br /&gt;
*[[Cron with Windows OS]] - Cron services in Windows&lt;br /&gt;
*&#039;&#039;Apple OSX&#039;&#039; - use the built-in &#039;crontab&#039; service which is exactly the same as [[Cron with Unix or Linux]]. However, you might want to do it the &#039;Apple way&#039; using launchd - see [[Cron with MAC OS X]]&lt;br /&gt;
*[[Cron with web hosting services]]- Cron services in various web hosting examples.&lt;br /&gt;
&lt;br /&gt;
Here are some more instructions for specific hosts (please check that these are up to date):&lt;br /&gt;
&lt;br /&gt;
*[[Cron on 1and1 shared servers]]&lt;br /&gt;
&lt;br /&gt;
== Using third party cron service ==&lt;br /&gt;
 &lt;br /&gt;
Besides using cron hosted on your own server, you may use third party cron service (usually called webcron):&lt;br /&gt;
&lt;br /&gt;
*[https://cron-job.org/ cron-job.org] is a free service. (1Minute cron is possible)&lt;br /&gt;
&lt;br /&gt;
*[https://www.easycron.com EasyCron] - A webcron service provider that eliminates the need of crontab or other task schedulers to set cron job.&lt;br /&gt;
&lt;br /&gt;
=== Cron settings in Moodle ===&lt;br /&gt;
&lt;br /&gt;
An admin can set cron execution via command line only or a cron password for remote access in &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Security &amp;gt; Site policies&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===Remote cron===&lt;br /&gt;
Using the &#039;web based&#039; version of cron it is perfectly ok to place the cron process on a different machine to the Moodle server. For example, the cron service on a Unix server can invoke the cron web &#039;page&#039; on a Windows based Moodle server.&lt;br /&gt;
&lt;br /&gt;
==Scheduling tasks==&lt;br /&gt;
An administrator can schedule cron tasks very precisely from Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; Scheduled tasks, see [[Scheduled tasks]]&lt;br /&gt;
&lt;br /&gt;
==Running cron for several Moodle servers==&lt;br /&gt;
* Tasks can run in parallel and processes use locking to prevent tasks from running at the same time which allows cron to be triggered from multiple web servers that serve the same Moodle instance.&lt;br /&gt;
&lt;br /&gt;
* If you are running different Moodle instances on the same server, then each Moodle instance needs a cron job. (Even a single Apache web server can run different Moodle instances on different domains by using its virtual hosts capability [https://httpd.apache.org/docs/2.2/vhosts/index.html https://httpd.apache.org/docs/2.2/vhosts/index.html].)&lt;br /&gt;
&lt;br /&gt;
== Debugging Scheduled Tasks ==&lt;br /&gt;
&lt;br /&gt;
Sometimes, a particular cron task may not be working correctly. In Moodle versions before 2.7 - any cron task that was throwing exceptions would prevent the rest of cron from running. The only way to monitor if cron was completing each time, was to add some automated checking of the output of running cron (e.g. searching for the string &amp;quot;Cron completed at &amp;quot;).&lt;br /&gt;
&lt;br /&gt;
In Moodle 2.7 and later, a single failing scheduled task will not prevent the remaining tasks from completing. When any single scheduled task fails, it is marked as a failure, and scheduled to be reattempted. If the task keeps failing, the next scheduled time will be backed off until it is attempted at most once every 24 hours. But checking the [[Scheduled tasks]] admin page, you can see if any task is currently failing (it will have a non-zero fail delay - which is the number of seconds to wait before reattempting a failed task). A simple way to debug a failing task, is to run it immediately using the [[Administration via command line#Scheduled_tasks|cli scheduled task runner]] and monitor the output.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [[Scheduled tasks]]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Cron Wikipedia article on cron function]&lt;br /&gt;
&lt;br /&gt;
Forum discussions:&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=139263#p609060 How to log the output of a Scheduled Task on Windows] - this discussion explains a nice trick that can be very useful when you are experiencing problems with your Windows Scheduled Task and you need to log the output of the Scheduled Task to a log file.&lt;br /&gt;
*[https://moodle.org/mod/forum/discuss.php?d=324443 Cron Lock] &lt;br /&gt;
&lt;br /&gt;
[[es:Cron]]&lt;br /&gt;
[[fr:Cron]]&lt;br /&gt;
[[ja:Cron]]&lt;br /&gt;
[[de:Cron-Job]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Upload_users&amp;diff=127132</id>
		<title>Upload users</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Upload_users&amp;diff=127132"/>
		<updated>2017-03-16T14:30:36Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Hints */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Accounts}}&lt;br /&gt;
==Uploading users via text file==&lt;br /&gt;
&lt;br /&gt;
There are many options for uploading information (fields associated with a user) with this method: from enrolling users in multiple courses with course specific [[Roles|roles]] to updating user information in the [[User profile]] to deleting users from the site.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tip:&#039;&#039; It is usually not necessary to upload users in bulk with Upload users. To keep maintenance work down you should first explore forms of authentication that do not require manual maintenance, such as [[External database authentication|connecting to existing external databases]] or letting the users create their own accounts ([[Self enrolment]]). See [[Authentication]] for more information.&lt;br /&gt;
&lt;br /&gt;
==File formats for upload users file==&lt;br /&gt;
The upload users file has fields separated by a comma (or other delimiter) ONLY - no space.   The first line contains the valid field names.  The rest of the lines (records) contain information about each user.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tip:&#039;&#039; Avoid special characters in field information like quotes or other commas. Test a file with only one record before a large upload.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Tip:&#039;&#039; You can use a spread sheet program to create the file with the required columns and fields. Then save the file as &amp;quot;CSV (comma delimited)&amp;quot;. These files can be opened with simple text editors (eg, [https://notepad-plus-plus.org/ Notepad++]) for verification. &lt;br /&gt;
&lt;br /&gt;
===Valid upload file for testing===&lt;br /&gt;
Here is an example of a simple valid upload file:&lt;br /&gt;
(Column headers on the first line of the file are only highlighted in bold in this example to distinguish it from the rest of the of the data/user details)&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;username,password,firstname,lastname,email,course1,group1,cohort1&#039;&#039;&#039;&lt;br /&gt;
 jonest,verysecret,Tom,Jones,jonest@someplace.edu,math102,Section 1,year 3&lt;br /&gt;
 reznort,somesecret,Trent,Reznor,reznort@someplace.edu,math102,Section 3,year 4&lt;br /&gt;
&lt;br /&gt;
===Fields that can be included===&lt;br /&gt;
&#039;&#039;Tip:&#039;&#039; We strongly recommend that you test a file that contains fields you proposed to use with one user before attempting a file upload for the first time. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Required fields&#039;&#039;&#039;: &lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;username,firstname,lastname,email&amp;lt;/code&amp;gt;&lt;br /&gt;
:Validity checks are performed for:&lt;br /&gt;
#&amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; can only contain alphabetical &#039;&#039;&#039;lowercase&#039;&#039;&#039; letters , numbers, hypen &#039;-&#039;, underscore &#039;_&#039;, period &#039;.&#039;, or at-sign &#039;@&#039; &lt;br /&gt;
#&amp;lt;code&amp;gt;email&amp;lt;/code&amp;gt; is in the form: &#039;&#039;name@example.com&#039;&#039; .&amp;lt;/p&amp;gt; &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Password field&#039;&#039;&#039;: &amp;quot;password&amp;quot; field is optional if &amp;quot;Create password if needed&amp;quot; setting is chosen (default). &lt;br /&gt;
**If included, values should meet the requirements for the site&#039;s [[Site_policies#Password_policy|Password policy]]. To force password change for a particular user, set the password field to &amp;lt;code&amp;gt;changeme&amp;lt;/code&amp;gt;. &lt;br /&gt;
**If omitted, a password will be generated for each user (during the next Cron job) and welcome e-mails sent out.&lt;br /&gt;
**Note: the text for the welcome e-mail is in the language settings. Please refer to this [https://moodle.org/mod/forum/discuss.php?d=210359&amp;amp;parent=917138 forum thread]for details.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Optional fields&#039;&#039;&#039;: To provide values other than the default include one or more of these&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;institution,department,city,country,lang,auth,timezone,idnumber,icq,phone1,phone2,address,url,description,mailformat,maildisplay,htmleditor,autosubscribe&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
*&#039;&#039;&#039;[[Additional name fields]]&#039;&#039;&#039;&lt;br /&gt;
*Country- use a country TWO LETTER CODE&lt;br /&gt;
* The auth field must be used if the site uses an alternative authentication method, such as LDAP, as otherwise the authentication method will default to manual and users using a different auth method won&#039;t be able to log in.&lt;br /&gt;
*Some fields have a maximum number of characters that are allowed (notably institution should be &#039;&#039;&#039;at most 40 characters&#039;&#039;&#039; long).  See hints below.&lt;br /&gt;
*Maildisplay, htmleditor and autosubscribe can be set from an import screen.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Custom profile field names&#039;&#039;&#039;: (Optional). xxxxx is the real custom user profile field name (i.e. the unique shortname)&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;profile_field_xxxxx&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
: Create the custom fields BEFORE importing. Use the standard header. The &amp;quot;shortname&amp;quot; for your custom field is xxxxx (NB the shortname must be all lowercase, otherwise won&#039;t be recognised). The first record must include &amp;quot;profile_field_xxxxx&amp;quot;.&lt;br /&gt;
 &lt;br /&gt;
:&#039;&#039;&#039;Example&#039;&#039;&#039;: To create a custom field &amp;quot;genre&amp;quot;, you must write a shortname &amp;quot;genre&amp;quot; in the new field, and write &amp;quot;profile_field_genre&amp;quot; in the header of the .csv file.&lt;br /&gt;
&lt;br /&gt;
: For custom profile fields that are a menu, use the corresponding value.&lt;br /&gt;
&lt;br /&gt;
For custom profile fields that are dates, use the ISO standard format YYYY-MM-DD, eg. 2014-06-19 which will then be properly localized in the interfaced.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;&#039;Example&#039;&#039;&#039;: A custom field &#039;Department&#039; with one of three values &#039;HR&#039;, &#039;Marketing&#039; or &#039;Training&#039;. Just insert one of those three words (e.g. &#039;Training&#039;) as the value for that field. &lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Special fields&#039;&#039;&#039;: Used for changing of usernames or deleting of users&lt;br /&gt;
:&amp;lt;p&amp;gt;&amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;suspended&amp;lt;/code&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
 &lt;br /&gt;
*&#039;&#039;&#039;Enrolment fields&#039;&#039;&#039;: (Optional):&lt;br /&gt;
:&amp;lt;code&amp;gt;course1,type1,role1,group1,enrolperiod1,enrolstatus1,course2,type2,role2,group2,enrolperiod2,enrolstatus2&amp;lt;/code&amp;gt; etc.&lt;br /&gt;
&lt;br /&gt;
:* Header fields must have a numeric suffix such that &amp;lt;code&amp;gt;type1&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;role1&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;group1&amp;lt;/code&amp;gt;,&amp;lt;code&amp;gt;enrolperiod1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;enrolstatus1&amp;lt;/code&amp;gt; all apply to &amp;lt;code&amp;gt;course1&amp;lt;/code&amp;gt; for course&amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; to course&amp;lt;code&amp;gt;n&amp;lt;/code&amp;gt;.&lt;br /&gt;
:*&amp;lt;code&amp;gt;course&amp;lt;/code&amp;gt; is the &amp;quot;shortname&amp;quot; of the course, if present the user will be enrolled in that course.&lt;br /&gt;
:* &amp;lt;code&amp;gt;type&amp;lt;/code&amp;gt; sets the role to be used for the enrolment. A value of &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; is default course role, &amp;lt;code&amp;gt;2&amp;lt;/code&amp;gt;  is legacy Teacher role and &amp;lt;code&amp;gt;3&amp;lt;/code&amp;gt; is legacy Non-editing Teacher.&lt;br /&gt;
:* &amp;lt;code&amp;gt;role&amp;lt;/code&amp;gt; may be used to specify roles directly, using either role short name or id (numeric names of roles are not supported).&lt;br /&gt;
:* &amp;lt;code&amp;gt;group&amp;lt;/code&amp;gt; may be used to assign users to groups in course, using name or id (numeric group names are not supported)&lt;br /&gt;
:* &amp;lt;code&amp;gt;enrolperiod&amp;lt;/code&amp;gt; may be used to set the enrolment duration, in days, for each course.&lt;br /&gt;
:* &amp;lt;code&amp;gt;enrolstatus&amp;lt;/code&amp;gt; can suspend users from a course when set to 1 or left blank for enrolled. If a user is previously set as inactive / suspended then a value of 0 will unsuspend them.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Cohort field&#039;&#039;&#039;: (Optional):&lt;br /&gt;
:&amp;lt;code&amp;gt;cohort1&amp;lt;/code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
:Internal cohort id numbers or non-numeric Cohort IDs of existing cohorts must be used; names are not allowed.&lt;br /&gt;
*&#039;&#039;&#039;mnethostid&#039;&#039;&#039; (Optional)&lt;br /&gt;
&lt;br /&gt;
Existing [[MNet]]users can be added to courses, groups or cohorts as below:&lt;br /&gt;
#enrolling to courses: username+mnethostid+course required&lt;br /&gt;
# adding to group: username+mnethostid+course+group required&lt;br /&gt;
#adding to cohort: username+mnethostid+cohort required&lt;br /&gt;
#suspending/reviving accounts: username+mnethostid+suspended required&lt;br /&gt;
All other operations are ignored. You can not add users, delete them or update them (such as change names or email, profile fields, etc.)&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;System role&#039;&#039;&#039; (Optional)&lt;br /&gt;
:&amp;lt;code&amp;gt;sysrole1,sysrole2,sysrole3&amp;lt;/code&amp;gt; etc&lt;br /&gt;
Users may be uploaded to a system role (usually Manager or Course creator)  by entering the shortname of that role. Other roles can only be uploaded if they have already been assigned in the &#039;system&#039; context. See [[Creating custom roles]]. Multiple roles can be assigned using &amp;lt;code&amp;gt;sysrole2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;sysrole3&amp;lt;/code&amp;gt;, etc. fields. Note that the number suffix in no way relates to the number suffixes on the enrolment fields. The numbers must go up in sequence starting at 1.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Unassigning roles&#039;&#039;&#039;&lt;br /&gt;
Users can also be removed from a given system role by entering the shortname of that role prefixed with a minus symbol: &#039;-&#039;. If the user is currently assigned to that role, they are removed from it. If the user is not currently assigned to that system role, the field value is ignored. However, the field value must refer to a system role that does exist on the system, otherwise an error will occur.&lt;br /&gt;
[[File:GlobalRoles1.png|thumb|500px|center|Example of a file for uploading users with global/system roles]]&lt;br /&gt;
&lt;br /&gt;
Commas within  a field must be encoded as &amp;amp;#44 - the script will decode these back to commas.&lt;br /&gt;
&lt;br /&gt;
For Boolean fields, use &amp;lt;code&amp;gt;0&amp;lt;/code&amp;gt; for false and &amp;lt;code&amp;gt;1&amp;lt;/code&amp;gt; for true.&lt;br /&gt;
&lt;br /&gt;
To prevent users from receiving a large number of emails from courses or forced subscription forums use the &#039;&#039;&#039;maildigest&#039;&#039;&#039;.  The options for this field are 0 = No digest, 1 = Complete digest and 2 = Digest with just subjects.&lt;br /&gt;
==Upload user process==&lt;br /&gt;
&lt;br /&gt;
# Create file for uploading&lt;br /&gt;
# Go to &#039;&#039;Site administration &amp;gt; Users &amp;gt; Accounts &amp;gt; Upload users&#039;&#039;&lt;br /&gt;
# Add file to upload&lt;br /&gt;
# Upload users preview - check settings and default user profile settings&lt;br /&gt;
# Upload users preview - click &amp;quot;Upload users&amp;quot;&lt;br /&gt;
# Upload users results - shows list of users, exceptions made in upload and summary of number of users&lt;br /&gt;
# Upload users results - click &amp;quot;Continue&amp;quot;&lt;br /&gt;
# Returns to Upload users screen&lt;br /&gt;
&lt;br /&gt;
==Updating users preview==&lt;br /&gt;
There are various settings to better control the desired upload behaviour. These settings are found on the &amp;quot;Upload users preview&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Warning&#039;&#039;&#039;: errors updating existing accounts can affect your users badly. &#039;&#039;&#039;&#039;&#039;Be careful&#039;&#039;&#039;&#039;&#039; when using the options to update.&lt;br /&gt;
&lt;br /&gt;
====Upload type====&lt;br /&gt;
The Upload type specifies how to handle existing accounts.&lt;br /&gt;
;Add new only, skip existing users : is the default Moodle upload type. It creates a new user account for each new record in the uploaded file. If an existing &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; is found (i.e., the &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; in the uploaded file matches an existing &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt;, that record is &#039;&#039;&#039;skipped&#039;&#039;&#039;. By skipping the existing user account, the data in the existing record is not touched (in contrast to the &amp;quot;Add new and update existing users&amp;quot; option) and a second new user account is &#039;&#039;&#039;not&#039;&#039;&#039; created (in contrast to the &amp;quot;Add all, append number to usernames if needed&amp;quot; option). &lt;br /&gt;
;Add all, append number to usernames if needed : creates a new user account for each record in the uploaded file. If an existing user account is found, a new account will be created with a number appended to the &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt;. For example, if a user account for &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; &#039;jsmith&#039; already exists and a new record in the uploaded file contains a record for &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; &#039;jsmith&#039; an additional user account is created with a 1 &#039;&#039;&#039;appended&#039;&#039;&#039; to the &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; to produce user &#039;jsmith1&#039;. &lt;br /&gt;
;Add  new and update existing users : creates a new user account for each new user in the upload file. If an existing user account with the same &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; is found, the account information is &#039;&#039;&#039;updated&#039;&#039;&#039; by the data in the uploaded file. &lt;br /&gt;
;Update existing users only : ignores any new users found in the upload file and updates the user account if a matching &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; record is found in the uploaded file.&lt;br /&gt;
&lt;br /&gt;
====New user password====&lt;br /&gt;
When creating a new user account Moodle can create a new password (if one is not provided) or require a password in the uploaded file.&lt;br /&gt;
;Create password if needed : creates a default password for the new user account if one is not provided in the uploaded file.&lt;br /&gt;
;Field required in file : requires that a password be provided in the uploaded file in order. If a password is not provided, an error is generated and the user account is not created.&lt;br /&gt;
&lt;br /&gt;
====Existing user details====&lt;br /&gt;
The Existing user details options are only available when the Upload type allows existing user accounts to be updated. It specifies how Moodle should process user detail information for existing users.&lt;br /&gt;
;No changes : ignores user detail data in the uploaded and leaves the existing user account data unchanged.&lt;br /&gt;
;Override with file : overwrites data in the existing user account with the data provided in the uploaded file.&lt;br /&gt;
;Override with file and defaults : overwrites data in the existing user account with data provided in the uploaded file and fills in the default values for existing user details when no data is provided in the uploaded file.&lt;br /&gt;
;Fill in missing from file and defaults : adds data in the existing user account with data provided in the uploaded file if the field is empty (does not already contain data) and fills in the default values for existing user details when no data is provided in the uploaded file.&lt;br /&gt;
&lt;br /&gt;
====Existing user password====&lt;br /&gt;
The Existing user password option specifies how to handle password data for existing user accounts when Existing user details is set to overwrite data.&lt;br /&gt;
;No changes : ignores password field in the uploaded user file and leaves the existing user account password untouched&lt;br /&gt;
;Update : overwrites the existing user account password with the password provided in the uploaded file&lt;br /&gt;
&lt;br /&gt;
====Force password change====&lt;br /&gt;
The Force password change option specifies when to tag a user account so that the next login attempt will require the user to change the user&#039;s password.&lt;br /&gt;
;Users having a weak password : If the user account has a weak password as defined by the stie&#039;s [[Password_policy#Password_policy|Password policy]] then the user will be forced to change the password during the next login attempt. This option is not shown if there the site does not have a [[Password_policy#Password_policy|Password policy]], in other words &amp;lt;code&amp;gt;$CFG-&amp;gt;passwordpolicy&amp;lt;/code&amp;gt; must be set to see this option. &lt;br /&gt;
;None : None of the users in the uploaded file will be forced to change the password during the user&#039;s next login attempt.&lt;br /&gt;
;All : All of the users in the uploaded file will be forced to change the password during the user&#039;s next login attempt.&lt;br /&gt;
&lt;br /&gt;
====Allow renames====&lt;br /&gt;
If the uploaded flie contains the special &amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt; field, it is possible to rename a user from the &amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt; to a new &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt;. The default setting is to &#039;&#039;&#039;not&#039;&#039;&#039; allow renames. Keep in mind that renaming a user will require the user to use the new username when logging in.&lt;br /&gt;
;No : ignores the &amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt; field and leaves the existing user account&#039;s &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; field unchanged.&lt;br /&gt;
;Yes : allows the existing user account&#039;s &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; to be changed by the data provided in the uploaded file&#039;s &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; field. The &amp;lt;code&amp;gt;oldusername&amp;lt;/code&amp;gt; will be searched for and then updated with the data provided in the &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt; column. &lt;br /&gt;
&lt;br /&gt;
====Allow deletes====&lt;br /&gt;
If the uploaded file contains the &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt; special field, it is possible to use the upload file to delete existing user accounts. The default setting is to &#039;&#039;&#039;not&#039;&#039;&#039; allow deletes. Keep in mind that deleting a user account will prevent that user from logging in. As a protection, site administrator user accounts cannot be deleted with this method. &lt;br /&gt;
;No : ignores the &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt; special field in the uploaded file and leaves the existing user account unchanged&lt;br /&gt;
;Yes : allows the existing user account to be deleted when the value of the of the &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt; field is 1. &lt;br /&gt;
&lt;br /&gt;
====Allow suspending and activating of accounts====&lt;br /&gt;
If the uploaded file contains the &amp;lt;code&amp;gt;suspended&amp;lt;/code&amp;gt; special field, it is possible to use the upload file to either suspend or make active (unsuspend) existing user accounts. The default setting is to allow suspending/activating of existing user accounts. Keep in mind that suspending an existing user account will prevent that user from logging in. &lt;br /&gt;
;Yes : allows the existing user account to be suspended when the value of the of the &amp;lt;code&amp;gt;suspended&amp;lt;/code&amp;gt; field is 1. &lt;br /&gt;
;No : ignores the &amp;lt;code&amp;gt;suspended&amp;lt;/code&amp;gt; special field in the uploaded file and leaves the existing user account status unchanged.&lt;br /&gt;
&lt;br /&gt;
====Prevent email address duplicates====&lt;br /&gt;
It is possible, but &#039;&#039;&#039;not&#039;&#039;&#039; recommended to upload users with duplicate email addresses. By default, uploading users with duplicate email addresses is prevented. See MDL-38104 for some discussion. Further, since MDL-41115 added the ability for users to login with their email address it is even more important that duplicate email addresses be avoided.&lt;br /&gt;
&lt;br /&gt;
To allow duplicate email addresses, go to Site administration ► Plugins ► Authentication ► Manage authentication. You can tick &amp;quot;Allow accounts with same email&amp;quot;. Then on the upload users screen you will be allowed to change the &amp;quot;Prevent email address duplicates&amp;quot; setting. However, doing this is not recommended. For more info, see the [[Managing_authentication#Allow_accounts_with_same_email|Managing authentication]] docs page&lt;br /&gt;
;Yes : prevents user accounts from being created from the uploaded if an existing user account already has the same email address as found in the uploaded file&#039;s  &amp;lt;code&amp;gt;email&amp;lt;/code&amp;gt; column.&lt;br /&gt;
;No : allows user accounts to be created if an existing user account already has the same email address found in the uploaded file&#039;s  &amp;lt;code&amp;gt;email&amp;lt;/code&amp;gt; column.&lt;br /&gt;
&lt;br /&gt;
====Standardise usernames====&lt;br /&gt;
Standardise usernames is used by default to convert the username to all lower case and to strip out illegal characters. It is possible to not standardise the usernames; however, doing so is &#039;&#039;&#039;not&#039;&#039;&#039; recommended.&lt;br /&gt;
;Yes : standardises usernames found in the uploaded file before updating existing or creating new user accounts so that the username contains only lowercase letters and numbers.&lt;br /&gt;
;No : skips standardising usernames found in the uploaded file so that the newly created or updated usernames will be exactly as they are in the uploaded file (&#039;&#039;&#039;not recommended&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
For those seeking a more technical explanation, the process for standardising the usernames consists of ensuring the characters are all UTF-8 (fix_utf8) encoded, converting the username to lower case, and then stripping out non-letters/non-number characters (unless &#039;&#039;Site administration &amp;gt; Security &amp;gt; Site policies &amp;gt; Allow extended characters in usernames&#039;&#039; is set on) with something similar to: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;$username = preg_replace(&#039;/[^-\.@_a-z0-9]/&#039;, &#039;&#039;, $username);&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Select for bulk user actions====&lt;br /&gt;
After the uploaded file has finished being processed (all new accounts have been created and existing accounts updated as specified by the previous settings), there is an option to select some of those user accounts to perform additional [[admin/user/user_bulk|bulk user actions]] such as &lt;br /&gt;
*Confirm user accounts created through Email-based self-registration which are not yet confirmed by the user&lt;br /&gt;
*Send a message (requires Messaging to be enabled)&lt;br /&gt;
*Delete user accounts&lt;br /&gt;
*Display a list of users on a page&lt;br /&gt;
*Download user data in text, ODS or Excel file format&lt;br /&gt;
*Force users to change their passwords&lt;br /&gt;
*Add users to a cohort&lt;br /&gt;
&lt;br /&gt;
By default, no users are selected for [[admin/user/user_bulk|bulk user actions]].&lt;br /&gt;
&lt;br /&gt;
;No : No users are selected for [[admin/user/user_bulk|bulk user actions]]&lt;br /&gt;
;New users : Only newly created users are selected for [[admin/user/user_bulk|bulk user actions]]&lt;br /&gt;
;Updated users : Only updated user accounts are selected for [[admin/user/user_bulk|bulk user actions]]&lt;br /&gt;
;All users : All users found (existing updated users and newly created user accounts) in the uploaded file are selected for [[admin/user/user_bulk|bulk user actions]]&lt;br /&gt;
&lt;br /&gt;
===Default values===&lt;br /&gt;
&lt;br /&gt;
You can provide default user values for some fields not included in the uploaded file. Some fields include:&lt;br /&gt;
*Email display&lt;br /&gt;
*Forum auto-subscribe&lt;br /&gt;
*City/town&lt;br /&gt;
*ID number&lt;br /&gt;
*Institution&lt;br /&gt;
*Department&lt;br /&gt;
&lt;br /&gt;
==Upload user results ==&lt;br /&gt;
After accepting the preview settings by clicking on &amp;quot;Upload users&amp;quot;, you should see the the Upload users results screen.&lt;br /&gt;
[[File:Upload users results 2.0.JPG|thumb|center|The results screen; everything went well!]]&lt;br /&gt;
This screen will show you any exceptions or changes that were made to each user in the upload process.   For example if you were updating user information, the updated information will be shown.  Or if a user was not added that record will be highlighted.&lt;br /&gt;
&lt;br /&gt;
The screen will summarize how many users were uploaded or updated, indicate the number of weak passwords and the number of errors.&lt;br /&gt;
&lt;br /&gt;
==Advanced potentials of Upload user==&lt;br /&gt;
===Templates===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Note: This section needs checking and updating if necessary for Moodle 2.0. Please do so and remove this note when finished.&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The default values are processed as templates in which the following codes are allowed:&lt;br /&gt;
&lt;br /&gt;
* %l - will be replaced by the lastname&lt;br /&gt;
* %f - will be replaced by the firstname&lt;br /&gt;
* %u - will be replaced by the username&lt;br /&gt;
* %% - will be replaced by the %&lt;br /&gt;
&lt;br /&gt;
Between the percent sign (%) and any code letter (l, f or u) the following modifiers are allowed:&lt;br /&gt;
&lt;br /&gt;
* (-) minus sign - the information specified by the code letter will be converted to lowercase&lt;br /&gt;
* (+) plus sign - the information specified by the code letter will be converted to UPPERCASE&lt;br /&gt;
* (~) tilde sign - the information specified by the code letter will be converted to Title Case&lt;br /&gt;
* a decimal number - the information specified by the code letter will be truncated to that many characters&lt;br /&gt;
&lt;br /&gt;
For example, if the firstname is John and the lastname is Doe, the following values will be obtained with the specified templates:&lt;br /&gt;
&lt;br /&gt;
* %l%f = DoeJohn&lt;br /&gt;
* %l%1f = DoeJ&lt;br /&gt;
* %-l%+f = doeJOHN&lt;br /&gt;
* %-f_%-l = john_doe&lt;br /&gt;
*&amp;lt;nowiki&amp;gt; http://www.example.com/~%u/&amp;lt;/nowiki&amp;gt; results in  &amp;lt;nowiki&amp;gt;http://www.example.com/~jdoe/&amp;lt;/nowiki&amp;gt; (if the username is jdoe or %-1f%-l)&lt;br /&gt;
&lt;br /&gt;
Template processing is done only on default values, and not on the values retrieved from the CSV file.&lt;br /&gt;
&lt;br /&gt;
In order to create correct Moodle usernames, the username is always converted to lowercase. Moreover, if the &amp;quot;Allow extended characters in usernames&amp;quot; option in the Site policies page is off, characters different to letters, digits, dash (-) and dot (.) are removed. For example if the firstname is John Jr. and the lastname is Doe, the username %-f_%-l will produce john jr._doe when Allow extended characters in usernames is on, and johnjr.doe when off.&lt;br /&gt;
&lt;br /&gt;
When the &amp;quot;New username duplicate handling&amp;quot; setting is set to Append counter, an auto-increment counter will be append to duplicate usernames produced by the template. For example, if the CSV file contains the users named John Doe, Jane Doe and Jenny Doe without explicit usernames, the default username is %-1f%-l and New username duplicate handling is set to Append counter, then the usernames produced will be jdoe, jdoe2 and jdoe3.&lt;br /&gt;
&lt;br /&gt;
===Deleting accounts===&lt;br /&gt;
&lt;br /&gt;
If the &amp;lt;code&amp;gt;deleted&amp;lt;/code&amp;gt; field is present, users with value 1 for it will be deleted. In this case, all the fields may be omitted, except for &amp;lt;code&amp;gt;username&amp;lt;/code&amp;gt;. After uploading the file, be sure to change the &amp;quot;Upload type&amp;quot; to &amp;quot;Update existing users only&amp;quot; and the &amp;quot;Allow deletes&amp;quot; option to &amp;quot;Yes&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039;  A similar field is available for &amp;lt;code&amp;gt;suspended&amp;lt;/code&amp;gt;. This enables a user account to be temporarily disabled rather than completely removed.&lt;br /&gt;
&lt;br /&gt;
Deleting and uploading accounts could be done with a single CSV file. For example, the following file will add the user Tom Jones and delete the user reznort:&lt;br /&gt;
&lt;br /&gt;
 username,firstname,lastname,deleted&lt;br /&gt;
 jonest,Tom,Jones,0&lt;br /&gt;
 reznort,,,1&lt;br /&gt;
&lt;br /&gt;
==Encoding file format==&lt;br /&gt;
On the initial Upload user screen, you may select the file encoding format from a pull down list.  These include UTF-8 (the default), ASCII,  ISO-8859-1 to ISO-8859-11 or any one of over 36 formats.&lt;br /&gt;
&lt;br /&gt;
==Hints==&lt;br /&gt;
&lt;br /&gt;
===Spreadsheet===&lt;br /&gt;
&lt;br /&gt;
If you use a spreadsheet program such as Excel to create your .csv file, check the resulting output in a text editor before you upload it.  It is possible to get trailing commas on each line from an empty field if you have added and deleted columns of information prior to saving the final file. Also check the character encoding. A csv file is a simple text file (ASCII or Unicode) that can be used to upload user accounts.&lt;br /&gt;
&lt;br /&gt;
Excel translates passwords that begin with - (minus) or + (plus) as zero. Even when saving as .csv and saying &amp;quot;Yes&amp;quot; to &amp;quot;Keep this format, and leave out any incompatible features.&amp;quot; Check for this before uploading, as a zero halts the upload process.&lt;br /&gt;
&lt;br /&gt;
If you use a formula in Excel to create fields (for example, the concatenate function to create a user name), then remember to copy the cells with the formula and use special paste with values checked to make them into an acceptable data for a csv file.&lt;br /&gt;
&lt;br /&gt;
The upload will also fail if you have trailing spaces at the end of your data fields. Often, this can not be removed with a simple Find &amp;quot; &amp;quot; and Replace with &amp;quot;&amp;quot;. If information has been copied from web sources than it is possible to include non-breaking spaces which will prevent your upload from being completed correctly. To find these invisible spaces, use the Find and Replace function in Excel. In the find field, hold alt and type 0160. Leave the replace field blank. &lt;br /&gt;
&lt;br /&gt;
===Country===&lt;br /&gt;
The country should be written as a two letter code, in capitals. For example, use BE for Belgium or NL for the Netherlands.  Using &amp;quot;be&amp;quot; or &amp;quot;nl&amp;quot; or &amp;quot;USA&amp;quot; as a country code will result in a database error.&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039;  If you are having trouble working out the two-letter code for a country, you can consult the list of [http://www.iso.org/iso/country_names_and_code_elements country names and code elements] available on the ISO Website. A common error is to use UK for United Kingdom; it should be GB.&lt;br /&gt;
&lt;br /&gt;
===Field size limits===&lt;br /&gt;
Some fields have maximum character lengths, as defined in the database fields.  Typically the file will import to the preview list screen but not finish the process. Turn on debug to see the fields that are too long. The error will be &amp;quot;User not added - error&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The sizes of some common fields, in number of characters, are currently (3.2):&lt;br /&gt;
&lt;br /&gt;
*username - 100 	 &lt;br /&gt;
*password - 255 	 &lt;br /&gt;
*idnumber - 255 	 &lt;br /&gt;
*firstname - 100 	 &lt;br /&gt;
*lastname - 100 	 &lt;br /&gt;
*lastnamephonetic - 255 	 &lt;br /&gt;
*firstnamephonetic - 255 	 &lt;br /&gt;
*middlename - 255 	 &lt;br /&gt;
*alternatename - 255 &lt;br /&gt;
*institution -  255 	 &lt;br /&gt;
*department - 255 	 &lt;br /&gt;
*address - 255 	 &lt;br /&gt;
*city - 120 	 &lt;br /&gt;
*icq -15 	 &lt;br /&gt;
*skype - 50 	 &lt;br /&gt;
*yahoo - 50 	 &lt;br /&gt;
*aim - 50&lt;br /&gt;
*msn - 50 	 &lt;br /&gt;
*phone1 - 20 	 &lt;br /&gt;
*phone2  - 20&lt;br /&gt;
&lt;br /&gt;
===Time zones===&lt;br /&gt;
&lt;br /&gt;
The entry is case sensitive so &amp;lt;code&amp;gt;Europe/London&amp;lt;/code&amp;gt; will work but &amp;lt;code&amp;gt;europe/london&amp;lt;/code&amp;gt; will not. Use the names from the Timezone list found in &#039;&#039;Site administration &amp;gt; Location &amp;gt; Default timezone&#039;&#039; in their proper format.&lt;br /&gt;
&lt;br /&gt;
===All user fields listed here===&lt;br /&gt;
:All the user fields that are valid in an upload file are listed below, except for any custom fields you may have created (for which see below.)&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;pre&amp;gt;firstname,lastname,username,email,password,auth,idnumber,institution,department,city,country,timezone,lang,mailformat,maildisplay,maildigest,htmleditor,autosubscribe,skype,msn,aim,yahoo,icq,phone1,phone2,address,url,description,descriptionformat,oldusername,deleted,suspended,alternatename,lastnamephonetic,firstnamephonetic,middlename&amp;lt;/pre&amp;gt; &lt;br /&gt;
&lt;br /&gt;
TIP: You can copy/paste the above as plain text and save it as a csv file to use as a template header for your upload files.&lt;br /&gt;
&lt;br /&gt;
The courses are listed by number as&amp;lt;pre&amp;gt;course1,course2,course3,course4&amp;lt;/pre&amp;gt; etc.&lt;br /&gt;
&lt;br /&gt;
===Enroll users to Cohorts (system groups)===&lt;br /&gt;
You can enroll users to any Cohort (system level group) by using only the &amp;quot;username&amp;quot; and the &amp;quot;Cohort ID&amp;quot;.&lt;br /&gt;
Here is a sample CSV file:&lt;br /&gt;
&lt;br /&gt;
 &#039;&#039;&#039;username,cohort1&#039;&#039;&#039;&lt;br /&gt;
 teacher1,system-teachers&lt;br /&gt;
 teacher2,system-teachers&lt;br /&gt;
 teacher3,system-teachers&lt;br /&gt;
&lt;br /&gt;
Make sure you set &amp;quot;Upload type&amp;quot; to &amp;quot;Update existing users only&amp;quot; (So you are not asked to add firstname, lastname and email fields too)&lt;br /&gt;
&lt;br /&gt;
===Capabilities===&lt;br /&gt;
&lt;br /&gt;
You may wish to create a limited role to allow some users access to this function. Create a role and assign to the user at the system/site level with the following capabilities allowed&lt;br /&gt;
* moodle/site:uploadusers&lt;br /&gt;
* moodle/role:assign&lt;br /&gt;
* In &#039;Allow role assignments&#039; permit this new role to assign the required roles&lt;br /&gt;
&lt;br /&gt;
In particular, don&#039;t forget the moodle/role:assign capability (even if these users have it in the courses they will be enrolling users in - it won&#039;t work).&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://youtu.be/PFGLZnuu_JI Adding users by using a CSV in Moodle]  MoodleBites video on YouTube&lt;br /&gt;
*[[Flat file]] enrolment&lt;br /&gt;
* [[User profile fields]] for details of how to include data about custom user profile fields in the upload users file&lt;br /&gt;
* [[Upload courses]]&lt;br /&gt;
&lt;br /&gt;
Using Moodle forum discussions:&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=36851 Can I auto enroll from Excel?]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=97903 Uploading users to custom roles]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=181259 User upload option: standardise usernames]&lt;br /&gt;
*[http://moodle.org/mod/forum/discuss.php?d=144569 Matriculacion con flat file csv] - discussion in Spanish&lt;br /&gt;
&lt;br /&gt;
[[fr:Importer des utilisateurs]]&lt;br /&gt;
[[ja:ユーザのアップロード]]&lt;br /&gt;
[[de:Nutzerliste hochladen]]&lt;br /&gt;
[[es:Subir usuarios]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=125737</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=125737"/>
		<updated>2016-10-28T20:40:55Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Create the (moodledata) data directory */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirments] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone --depth=1 -b MOODLE_31_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other options you might consider:&lt;br /&gt;
&#039;&#039;--depth=1&#039;&#039;  for shallow cloning (only) latest revision&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;--single-branch&#039;&#039;  to limit cloning to a single branch, this fetches the Moodle 3.1 Stable branch (latest weekly build). For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
# chmod -R 0755 /path/to/moodle&lt;br /&gt;
# find /path/to/moodle -type f -exec chmod 0644 {} \;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
The third command finds all the regular files and executes the chmod command 0644 on them. &lt;br /&gt;
&lt;br /&gt;
If you want to use the built-in plugin installer you need to make the directory writable by web server user. It is strongly recommended to use ACL when your server supports it, for example if your Apache server uses account www-data: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The effect of the previous command is to allow the Apache user account (www-data in this case) to access and change files within the moodle site. Many people would consider this a brave move for a new site admin to implement. In a new moodle you can safely leave this out. A default Ubuntu install does not have the +a option for the chmod command anyway. The +a attribute is an ACL (Access Control List) facility which allows you to set per user access for individual files. For example, OSX has this by default.&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]]&lt;br /&gt;
* [[MariaDB]] (known issues - see MDL-45233)&lt;br /&gt;
* [[MySQL]] (known issues - see MDL-45233)&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (known issues, not fully supported - see MDL-41310)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the default way Moodle caches data you may have serious performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your server supports ACL it is recommended to set following permissions, for example if your Apache server uses account www-data:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are planning to execute PHP scripts from the command line you should set the same permissions for the current user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo chmod -R +a &amp;quot;`whoami` allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block. Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message Outputs &amp;gt; Email&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). The support contact for your site is also set on this page. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underline OS):&lt;br /&gt;
**: &amp;lt;code ini&amp;gt;[Date]&lt;br /&gt;
; Defines the default timezone used by the date functions&lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039;: [[Add a new user|Create a test user]] with a valid email address and [[message|send them a message]]. Do they receive an email copy of the message? If not, check the settings in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message outputs &amp;gt; Email&#039;&#039;. Don&#039;t be tempted to skip this step (clue: email is used to recover lost passwords, including the administrator password when you forget it!)&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory?&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=125736</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=125736"/>
		<updated>2016-10-28T20:38:17Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Download and copy files into place */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirments] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone --depth=1 -b MOODLE_31_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other options you might consider:&lt;br /&gt;
&#039;&#039;--depth=1&#039;&#039;  for shallow cloning (only) latest revision&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;--single-branch&#039;&#039;  to limit cloning to a single branch, this fetches the Moodle 3.1 Stable branch (latest weekly build). For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can typically place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
# chmod -R 0755 /path/to/moodle&lt;br /&gt;
# find /path/to/moodle -type f -exec chmod 0644 {} \;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
The third command finds all the regular files and executes the chmod command 0644 on them. &lt;br /&gt;
&lt;br /&gt;
If you want to use the built-in plugin installer you need to make the directory writable by web server user. It is strongly recommended to use ACL when your server supports it, for example if your Apache server uses account www-data: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The effect of the previous command is to allow the Apache user account (www-data in this case) to access and change files within the moodle site. Many people would consider this a brave move for a new site admin to implement. In a new moodle you can safely leave this out. A default Ubuntu install does not have the +a option for the chmod command anyway. The +a attribute is an ACL (Access Control List) facility which allows you to set per user access for individual files. For example, OSX has this by default.&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]]&lt;br /&gt;
* [[MariaDB]] (known issues - see MDL-45233)&lt;br /&gt;
* [[MySQL]] (known issues - see MDL-45233)&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (known issues, not fully supported - see MDL-41310)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the way Moodle caches data you may have performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your server supports ACL it is recommended to set following permissions, for example if your Apache server uses account www-data:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are planning to execute PHP scripts from the command line you should set the same permissions for the current user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo chmod -R +a &amp;quot;`whoami` allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block. Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message Outputs &amp;gt; Email&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). The support contact for your site is also set on this page. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underline OS):&lt;br /&gt;
**: &amp;lt;code ini&amp;gt;[Date]&lt;br /&gt;
; Defines the default timezone used by the date functions&lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039;: [[Add a new user|Create a test user]] with a valid email address and [[message|send them a message]]. Do they receive an email copy of the message? If not, check the settings in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message outputs &amp;gt; Email&#039;&#039;. Don&#039;t be tempted to skip this step (clue: email is used to recover lost passwords, including the administrator password when you forget it!)&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory?&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=125735</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=125735"/>
		<updated>2016-10-28T20:36:51Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Download and copy files into place */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirments] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code (including host provided Moodle installers), you are strongly advised to only obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone --depth=1 -b MOODLE_31_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other options you might consider:&lt;br /&gt;
&#039;&#039;--depth=1&#039;&#039;  for shallow cloning (only) latest revision&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;--single-branch&#039;&#039;  to limit cloning to a single branch, this fetches the Moodle 3.1 Stable branch (latest weekly build). For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can either place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
# chmod -R 0755 /path/to/moodle&lt;br /&gt;
# find /path/to/moodle -type f -exec chmod 0644 {} \;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
The third command finds all the regular files and executes the chmod command 0644 on them. &lt;br /&gt;
&lt;br /&gt;
If you want to use the built-in plugin installer you need to make the directory writable by web server user. It is strongly recommended to use ACL when your server supports it, for example if your Apache server uses account www-data: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The effect of the previous command is to allow the Apache user account (www-data in this case) to access and change files within the moodle site. Many people would consider this a brave move for a new site admin to implement. In a new moodle you can safely leave this out. A default Ubuntu install does not have the +a option for the chmod command anyway. The +a attribute is an ACL (Access Control List) facility which allows you to set per user access for individual files. For example, OSX has this by default.&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]]&lt;br /&gt;
* [[MariaDB]] (known issues - see MDL-45233)&lt;br /&gt;
* [[MySQL]] (known issues - see MDL-45233)&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (known issues, not fully supported - see MDL-41310)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the way Moodle caches data you may have performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your server supports ACL it is recommended to set following permissions, for example if your Apache server uses account www-data:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are planning to execute PHP scripts from the command line you should set the same permissions for the current user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo chmod -R +a &amp;quot;`whoami` allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block. Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message Outputs &amp;gt; Email&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). The support contact for your site is also set on this page. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underline OS):&lt;br /&gt;
**: &amp;lt;code ini&amp;gt;[Date]&lt;br /&gt;
; Defines the default timezone used by the date functions&lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039;: [[Add a new user|Create a test user]] with a valid email address and [[message|send them a message]]. Do they receive an email copy of the message? If not, check the settings in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message outputs &amp;gt; Email&#039;&#039;. Don&#039;t be tempted to skip this step (clue: email is used to recover lost passwords, including the administrator password when you forget it!)&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory?&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
	<entry>
		<id>https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=125734</id>
		<title>Installing Moodle</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/4x/sv/index.php?title=Installing_Moodle&amp;diff=125734"/>
		<updated>2016-10-28T20:35:56Z</updated>

		<summary type="html">&lt;p&gt;Howardsmiller: /* Set up your server */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Template:Installing Moodle}}&lt;br /&gt;
&#039;&#039;This page explains how to install Moodle. If you are an expert and/or in a hurry try [[Installation Quickstart]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
If you just want to try Moodle on a standalone machine there are &#039;one-click&#039; installers for Windows (see [[Complete install packages for Windows]]) and for OSX (see [[Complete Install Packages for Mac OS X]]) or [[ install on OS X]]. These are unsuitable for production servers. &lt;br /&gt;
&lt;br /&gt;
== Requirements ==&lt;br /&gt;
&lt;br /&gt;
Moodle is primarily developed in Linux using [[Apache]], [[PostgreSQL]]/[[MySQL]]/[[MariaDB]] and [[PHP]] (sometimes known as the LAMP platform). Typically this is also how Moodle is run, although there are other options as long as the software requirements of the  [{{Release notes}} release] are met.&lt;br /&gt;
&lt;br /&gt;
If you are installing Moodle in a Windows server, note that from php5.5 onwards, you will also need to have  the Visual C++ Redistributable for Visual Studio 2012 installed from:&lt;br /&gt;
http://www.microsoft.com/en-us/download/details.aspx?id=30679 Visual C++] ( x86 or x64)  &lt;br /&gt;
&lt;br /&gt;
The basic requirements for Moodle are as follows:&lt;br /&gt;
&lt;br /&gt;
=== Hardware === &lt;br /&gt;
* Disk space: 200MB for the Moodle code, plus as much as you need to store content. 5GB is probably a realistic minimum. &lt;br /&gt;
* Processor: 1GHz (min), 2GHz dual core or more recommended.&lt;br /&gt;
* Memory: 512MB (min), 1GB or more is recommended. 8GB plus is likely on a large production server&lt;br /&gt;
* Consider separate servers for the web &amp;quot;front ends&amp;quot; and the database. It is much easier to &amp;quot;tune&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All the above requirements will vary depending on specific hardware and software combinations as well as the type of use and load; busy sites may well require additional resources. Further guidance can be found under [[Performance_recommendations|performance recommendations]]. Moodle scales easily by increasing hardware.&lt;br /&gt;
&lt;br /&gt;
For very large sites, you are much better starting with a small pilot and gaining some experience and insight. A &amp;quot;what hardware do I need for 50,000 user?&amp;quot; style post in the forums is highly unlikely to get a useful answer.&lt;br /&gt;
&lt;br /&gt;
=== Software ===&lt;br /&gt;
&lt;br /&gt;
See the [{{Release notes}} release notes] in the dev docs for software requirements.&lt;br /&gt;
&lt;br /&gt;
== Set up your server ==&lt;br /&gt;
&lt;br /&gt;
Depending the use case a Moodle server may be anything from a Desktop PC (e.g. for testing and evaluating) to a rackmounted or  [[Server cluster|clustered]] solution. As mentioned above there are lots of possibilities for installing the basic server software, some links and pointers are at [[Installing AMP]], [[Internet_Information_Services|IIS]], [[Nginx]]. &lt;br /&gt;
&lt;br /&gt;
It will help hugely, regardless of your deployment choices, if time is taken to understand how to configure the different parts of your software stack (HTTP daemon, database,  PHP etc). Do not expect the standard server configuration to be optimal for Moodle. For example, the web server and database servers will almost certainly require tuning to get the best out of Moodle.&lt;br /&gt;
&lt;br /&gt;
If a hosting provider is being used  ensure that all Moodle [{{Release notes}}#Server_requirements requirments] (such as PHP version) are met by the hosting platform before attempting the installation. It will help to become familiar with changing settings within the hosting provider&#039;s platform (e.g. PHP file upload maximums) as the options and tools provided vary.&lt;br /&gt;
&lt;br /&gt;
== Download and copy files into place ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT: While there are now a number of places you can get the Moodle code, you are strongly advised to obtain Moodle from moodle.org. If you run into problems it will be a great deal easier to support you.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You have two options:&lt;br /&gt;
* Download your required version from http://moodle.org/downloads and unzip/unpack...&lt;br /&gt;
* &#039;&#039;&#039;OR&#039;&#039;&#039; Pull the code from the Git repository (recommended for developers and also makes upgrading very simple):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ git clone --depth=1 -b MOODLE_31_STABLE git://git.moodle.org/moodle.git  &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Other options you might consider:&lt;br /&gt;
&#039;&#039;--depth=1&#039;&#039;  for shallow cloning (only) latest revision&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;--single-branch&#039;&#039;  to limit cloning to a single branch, this fetches the Moodle 3.1 Stable branch (latest weekly build). For a fuller discussion see [[Git for Administrators]]. &lt;br /&gt;
&lt;br /&gt;
Either of the above should result in a directory called &#039;&#039;&#039;moodle&#039;&#039;&#039;, containing a number of files and folders. &lt;br /&gt;
&lt;br /&gt;
You can either place the whole folder in your web server documents directory, in which case the site will be located at &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com/moodle&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;, or you can copy all the contents straight into the main web server documents directory, in which case the site will be simply &#039;&#039;&#039;&amp;lt;nowiki&amp;gt;http://yourwebserver.com&amp;lt;/nowiki&amp;gt;&#039;&#039;&#039;. See the documentation for your system and/or web server if you are unsure. &lt;br /&gt;
&lt;br /&gt;
:&#039;&#039;Tip:&#039;&#039; If you are downloading Moodle to your local computer and then uploading it to your hosted web site, if possible upload the compressed file and decompress at the remote end (check your &#039;file manager&#039;). Failing that, watch FTP progress carefully for errors or missed files.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Secure the Moodle files:&#039;&#039;&#039; It is vital that the files are not writeable by the web server user. For example, on Unix/Linux (as root):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
# chmod -R 0755 /path/to/moodle&lt;br /&gt;
# find /path/to/moodle -type f -exec chmod 0644 {} \;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
(files are owned by the administrator/superuser and are only writeable by them - readable by everyone else)&lt;br /&gt;
&lt;br /&gt;
The third command finds all the regular files and executes the chmod command 0644 on them. &lt;br /&gt;
&lt;br /&gt;
If you want to use the built-in plugin installer you need to make the directory writable by web server user. It is strongly recommended to use ACL when your server supports it, for example if your Apache server uses account www-data: &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The effect of the previous command is to allow the Apache user account (www-data in this case) to access and change files within the moodle site. Many people would consider this a brave move for a new site admin to implement. In a new moodle you can safely leave this out. A default Ubuntu install does not have the +a option for the chmod command anyway. The +a attribute is an ACL (Access Control List) facility which allows you to set per user access for individual files. For example, OSX has this by default.&lt;br /&gt;
&lt;br /&gt;
== Create an empty database ==&lt;br /&gt;
&lt;br /&gt;
Next create a new, empty database for your installation. You need to find and make a note of following information for use during the final installation stage:&lt;br /&gt;
* &#039;&#039;&#039;dbhost&#039;&#039;&#039; - the database server hostname. Probably &#039;&#039;localhost&#039;&#039; if the database and web server are the same machine, otherwise the name of the database server&lt;br /&gt;
* &#039;&#039;&#039;dbname&#039;&#039;&#039; - the database name. Whatever you called it, e.g. &#039;&#039;moodle&#039;&#039; &lt;br /&gt;
* &#039;&#039;&#039;dbuser&#039;&#039;&#039; - the username for the database. Whatever you assigned, e.g. &#039;&#039;moodleuser&#039;&#039; - do not use the root/superuser account. Create a proper account with the minimum permissions needed.&lt;br /&gt;
* &#039;&#039;&#039;dbpass&#039;&#039;&#039; - the password for the above user&lt;br /&gt;
&lt;br /&gt;
If your site is hosted you should find a web-based administration page for databases as part of the control panel (or ask your administrator). For everyone else or for detailed instructions, see the page for your chosen database server:&lt;br /&gt;
* [[PostgreSQL]]&lt;br /&gt;
* [[MariaDB]] (known issues - see MDL-45233)&lt;br /&gt;
* [[MySQL]] (known issues - see MDL-45233)&lt;br /&gt;
* [[MSSQL]]&lt;br /&gt;
* [[Oracle]] (known issues, not fully supported - see MDL-41310)&lt;br /&gt;
&lt;br /&gt;
== Create the (&#039;&#039;moodledata&#039;&#039;) data directory  ==&lt;br /&gt;
&lt;br /&gt;
Moodle requires a directory to store all of its files (all your site&#039;s uploaded files, temporary data, cache, session data etc.). The web server needs to be able to write to this directory. On larger systems consider how much free space you are going to use when allocating this directory. &lt;br /&gt;
&lt;br /&gt;
Due to the way Moodle caches data you may have performance issues if you use relatively slow storage (e.g. NFS) for this directory. Read the [[Performance_recommendations]] carefully and consider using (e.g.) memcached for [[Caching]].&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT:&#039;&#039;&#039; This directory must &#039;&#039;&#039;NOT&#039;&#039;&#039; be accessible directly via the web. This would be a serious security hole. Do not try to place it inside your web root or inside your Moodle program files directory. Moodle will not install. It can go anywhere else convenient. &lt;br /&gt;
&lt;br /&gt;
Here is an example (Unix/Linux) of creating the directory and setting the permissions for &#039;&#039;&#039;anyone&#039;&#039;&#039; on the server to write here. This is only appropriate for Moodle servers that are not shared. Discuss this with your server administrator for better permissions that just allow the web server user to access these files.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# mkdir /path/to/moodledata&lt;br /&gt;
# chmod 0777 /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If your server supports ACL it is recommended to set following permissions, for example if your Apache server uses account www-data:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chmod -R +a &amp;quot;www-data allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If you are planning to execute PHP scripts from the command line you should set the same permissions for the current user:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo chmod -R +a &amp;quot;`whoami` allow read,delete,write,append,file_inherit,directory_inherit&amp;quot; /path/to/moodledata&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Securing moodledata in a web directory ====&lt;br /&gt;
&lt;br /&gt;
If you are using a hosted site and you have no option but to place &#039;moodledata&#039; in a web accessible directory. You may be able to secure it by creating an .htaccess file in the &#039;moodledata&#039; directory. This does not work on all systems - see your host/administrator. Create a file called .htaccess containing only the following lines:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
order deny,allow&lt;br /&gt;
deny from all&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Start Moodle install ==&lt;br /&gt;
It&#039;s now time to run the installer to create the database tables and configure your new site. The recommended method is to use the command line installer. If you cannot do this for any reason (e.g. on a Windows server) the web based installer is still available.&lt;br /&gt;
&lt;br /&gt;
=== Command line installer ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s best to run the command line as your system&#039;s web user. You need to know what that is - see your system&#039;s documentation (e.g. Ubuntu/Debian is &#039;www-data&#039;, Centos is &#039;apache&#039;)&lt;br /&gt;
&lt;br /&gt;
* Example of using the command-line  (as root - substitute &#039;www-data&#039; for your web user):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# chown www-data /path/to/moodle&lt;br /&gt;
# cd /path/to/moodle/admin/cli&lt;br /&gt;
# sudo -u www-data /usr/bin/php install.php&lt;br /&gt;
# chown -R root /path/to/moodle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
The chowns allow the script to write a new config.php file. More information about the options can be found using &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# php install.php --help&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will be asked for other settings that have not been discussed on this page - if unsure just accept the defaults. For a full discussion see [[Administration via command line]]&lt;br /&gt;
&lt;br /&gt;
=== Web based installer ===&lt;br /&gt;
&lt;br /&gt;
For ease of use you can install Moodle via the web. We recommend configuring your web server so that the page is not publicly accessible until the installation is complete.&lt;br /&gt;
&lt;br /&gt;
To run the web installer script, just go to your Moodle&#039;s main URL using a web browser.&lt;br /&gt;
&lt;br /&gt;
The installation process will take you through a number of pages. You should be asked to confirm the copyright, see the database tables being created, supply administrator account details and supply the site details. The database creation can take some time - please be patient. You should eventually end up at the Moodle front page with an invitation to create a new course. &lt;br /&gt;
&lt;br /&gt;
It is very likely that you will be asked to download the new config.php file and upload it to your Moodle installation - just follow the on-screen instructions.&lt;br /&gt;
&lt;br /&gt;
==Final configuration==&lt;br /&gt;
&lt;br /&gt;
=== Settings within Moodle ===&lt;br /&gt;
There are a number of options within the Moodle Site Administration screens (accessible from the &#039;Site administration&#039; tab in the &#039;Administration&#039; block. Here are a few of the more important ones that you will probably want to check:&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message Outputs &amp;gt; Email&#039;&#039;: Set your smtp server and authentication if required (so your Moodle site can send emails). The support contact for your site is also set on this page. &lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; System paths&#039;&#039;: Set the paths to du, dot and aspell binaries.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Server &amp;gt; HTTP&#039;&#039;: If you are behind a firewall you may need to set your proxy credentials in the &#039;Web proxy&#039; section.&lt;br /&gt;
* &#039;&#039;Administration &amp;gt; Site administration &amp;gt; Location &amp;gt; Update timezones&#039;&#039;: Run this to make sure your timezone information is up to date. (more info [[Location]])&lt;br /&gt;
** [http://php.net/manual/en/timezones.php Set server&#039;s local timezone] inside &amp;lt;tt&amp;gt;php.ini&amp;lt;/tt&amp;gt; (should probably be inside &amp;lt;tt&amp;gt;/etc/php.ini&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;/etc/php.d/date.ini&amp;lt;/tt&amp;gt;, depending on the underline OS):&lt;br /&gt;
**: &amp;lt;code ini&amp;gt;[Date]&lt;br /&gt;
; Defines the default timezone used by the date functions&lt;br /&gt;
date.timezone = &amp;quot;YOUR LOCAL TIMEZONE&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remaining tasks ===&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Configure Cron&#039;&#039;&#039;: Moodle&#039;s background tasks (e.g. sending out forum emails and performing course backups) are performed by a script which you can set to execute at specific times of the day. This is known as a cron script. Please refer to the [[Cron|Cron instructions]].&lt;br /&gt;
* &#039;&#039;&#039;Set up backups&#039;&#039;&#039;: See [[Site backup]] and [[Automated course backup]].&lt;br /&gt;
* &#039;&#039;&#039;Check mail works&#039;&#039;&#039;: [[Add a new user|Create a test user]] with a valid email address and [[message|send them a message]]. Do they receive an email copy of the message? If not, check the settings in &#039;&#039;Settings &amp;gt; Site administration &amp;gt; Plugins &amp;gt; Message outputs &amp;gt; Email&#039;&#039;. Don&#039;t be tempted to skip this step (clue: email is used to recover lost passwords, including the administrator password when you forget it!)&lt;br /&gt;
* &#039;&#039;&#039;Secure your Moodle site&#039;&#039;&#039;: Read the [[Security recommendations]].&lt;br /&gt;
*&#039;&#039;&#039;Increasing the maximum upload size&#039;&#039;&#039;  See [[Installation FAQ]] Maximum upload file size - how to change it?&lt;br /&gt;
&lt;br /&gt;
=== Installation is complete :) ===&lt;br /&gt;
&lt;br /&gt;
* Create a new course: You can now access Moodle through your web browser (using the same URL as you set during the install process), log in as your admin user and creatse a new course. See  [[Adding a new course|create a new course]].&lt;br /&gt;
&lt;br /&gt;
=== If something goes wrong... ===&lt;br /&gt;
&lt;br /&gt;
Here are some things you should try...&lt;br /&gt;
&lt;br /&gt;
* Check the [[Installation FAQ]]&lt;br /&gt;
* Check your file permissions carefully. Can your web server read (but not write) the Moodle program files? Can your web server read and write your Moodle data directory?&lt;br /&gt;
* Check your database permissions. Have you set up your database user with the correct rights and permissions for your configuration (especially if the web server and database server are different machines)?&lt;br /&gt;
* Create your [[Configuration file]] (config.php) by hand. Copy config-dist.php (in the root of the Moodle program directory) to config.php, edit it and set your database/site options there. Installation will continue from the right place. &lt;br /&gt;
* Once you have a config.php (see previous tip) you can edit it to turn on debugging (in section 8). This may give you extra information to help track down a problem. If you have access, check your web server error log(s).&lt;br /&gt;
* Re-check your php.ini / .htaccess settings. Are they appropriate (e.g. memory_limit), did you edit the correct php.ini / .htaccess file and (if required) did you re-start the web server after making changes?&lt;br /&gt;
* Did you include any non-core (optional) plugins, themes or other code before starting the installation script? If so, remove it and try again (it may be broken or incompatible).&lt;br /&gt;
* Explain your problem in the [http://moodle.org/mod/forum/view.php?id=28 Installation problems forum]. &#039;&#039;&#039;PLEASE&#039;&#039;&#039; list your software versions; explain what you did, what happened and what error messages you saw (if any); explain what you tried. There is no such thing as &#039;nothing&#039;, even a blank page is something!&lt;br /&gt;
&lt;br /&gt;
== Platform specific instructions ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Much of this information is provided by the community. It may not have been checked and may be out of date. Please read in conjunction with the above installation instructions.&lt;br /&gt;
&lt;br /&gt;
* [[Windows installation]]&lt;br /&gt;
** [[Installing Moodle on SmarterASP.NET]]&lt;br /&gt;
* [[Unix or Linux Installation]]&lt;br /&gt;
* [[Mac Installation]]&lt;br /&gt;
* [[Amazon EC2 Cloud Services Installation]]&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* [http://www.slideshare.net/gb2048/my-own-moodle Slideshare presentation by Gareth Barnard on installing a local installation of Moodle] and accompanying [https://drive.google.com/folderview?id=0B17B0rYH2zERU21sQnVweUZCUFk&amp;amp;usp=sharing  help guides]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=182086 New Video Tutorial- How to Install Moodle on Shared Hosting via cPanel (Not Fantastico)]&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=199542 Video Tutorial - Install Moodle on a Virtual Box from scratch] &lt;br /&gt;
&lt;br /&gt;
[[es:Instalaci%C3%B3n_de_moodle]]&lt;br /&gt;
[[de:Installation von Moodle]]&lt;br /&gt;
[[fr:Installation de Moodle]]&lt;br /&gt;
[[ja:Moodleのインストール]]&lt;/div&gt;</summary>
		<author><name>Howardsmiller</name></author>
	</entry>
</feed>