MDL-46987 report_participation: Count duplicate logs as 1

Some of the actions generate more then 1 event.
Example: forum post create generate:
- post_created and
- accessible_uploaded
events which  gets logged at the same time.
Count them as 1 action and not 2, as it is
single action and report should show 1 and not 2
This commit is contained in:
Rajesh Taneja 2014-08-18 16:33:19 +08:00
parent 272fec367f
commit 3bb8c9e356

View File

@ -265,7 +265,7 @@ if (!empty($instanceid) && !empty($roleid)) {
// Get record from sql_internal_reader and merge with records got from legacy log (if needed).
if (!$onlyuselegacyreader) {
$sql = "SELECT ra.userid, $usernamefields, u.idnumber, l.actioncount AS count
$sql = "SELECT ra.userid, $usernamefields, u.idnumber, COUNT(l.actioncount) AS count
FROM (SELECT DISTINCT userid FROM {role_assignments} WHERE contextid $relatedctxsql AND roleid = :roleid ) ra
JOIN {user} u ON u.id = ra.userid
$groupsql
@ -278,7 +278,8 @@ if (!empty($instanceid) && !empty($roleid)) {
AND anonymous = 0
AND contextlevel = :contextlevel
AND (origin = 'web' OR origin = 'ws')
GROUP BY userid) l ON (l.userid = ra.userid)";
GROUP BY userid,timecreated) l ON (l.userid = ra.userid)
GROUP BY ra.userid, $usernamefields, u.idnumber";
$params['edulevel'] = core\event\base::LEVEL_PARTICIPATING;
$params['contextlevel'] = CONTEXT_MODULE;