| 1 | == The following contains how to take statistics from Moodle instances. == |
| 2 | |
| 3 | {{{ |
| 4 | #!sql |
| 5 | SQL |
| 6 | SELECT A.Date,A.UserLogins,B.DistinctUserLogins,C.NoOfActions FROM |
| 7 | (SELECT |
| 8 | COUNT(l.userid) AS 'UserLogins', |
| 9 | DATE_FORMAT(FROM_UNIXTIME(l.timecreated), '%D %M %Y') AS 'Date' |
| 10 | FROM prefix_logstore_standard_log l |
| 11 | WHERE l.action = 'loggedin' AND l.timecreated >= UNIX_TIMESTAMP('2020-03-20') GROUP BY DATE_FORMAT(FROM_UNIXTIME(l.timecreated), '%D %M %Y') )A |
| 12 | JOIN |
| 13 | (SELECT |
| 14 | COUNT(DISTINCT ll.userid) AS 'DistinctUserLogins', |
| 15 | DATE_FORMAT(FROM_UNIXTIME(ll.timecreated), '%D %M %Y') AS 'Date' |
| 16 | FROM prefix_logstore_standard_log ll |
| 17 | WHERE ll.action = 'loggedin' AND ll.timecreated >= UNIX_TIMESTAMP('2020-03-20') GROUP BY DATE_FORMAT(FROM_UNIXTIME(ll.timecreated), '%D %M %Y') )B |
| 18 | USING(Date) |
| 19 | JOIN |
| 20 | ( |
| 21 | SELECT |
| 22 | COUNT(lll.action) AS 'NoOfActions',DATE_FORMAT(FROM_UNIXTIME(lll.timecreated), '%D %M %Y') AS 'Date' |
| 23 | FROM prefix_logstore_standard_log lll |
| 24 | WHERE lll.timecreated >= UNIX_TIMESTAMP('2020-03-20') GROUP BY DATE_FORMAT(FROM_UNIXTIME(lll.timecreated), '%D %M %Y') |
| 25 | )C USING(Date) |
| 26 | }}} |
| 27 | |
| 28 | And the video guide https://youtu.be/w1H9bVvHZok |
| 29 | |
| 30 | '''Credits:''' |
| 31 | |
| 32 | Iroshini Ratnapala, University of Peradeniya |
| 33 | |
| 34 | Buddhika Godakuru, University of Kelaniya |
| 35 | |
| 36 | Hasmi AJM, South Eastern University |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | |