Commit 94071ab6 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Bug 1737447: Adjust page activity selection for page activity report"

parents c70e1b01 64d60860
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Registered users</h3>
<p>
Sum of all portfolios shared with registered users during the selected time period.
Sum of all portfolios shared with all registered users during the selected time period.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Blocks</h3>
<p>
Sum of all blocks on a page provided that the page was created during the reporting time frame.
Sum of all blocks on a page provided that the page was modified during the reporting time frame.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Collection</h3>
<p>
Title of the collection if the page, which was created during the reporting time frame, is part of one.
Title of the collection if the page, which was modified during the reporting time frame, is part of one.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Comments</h3>
<p>
Sum of all page and artefact comments for a page provided the page was created during the reporting time frame.
Sum of all page and artefact comments for a page provided the page was modified during the reporting time frame.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Created</h3>
<p>
Date when the page was created. Only pages created during the reporting time frame are displayed.
Date when the page was created. Only pages modified during the reporting time frame are displayed.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Last modified</h3>
<p>
Date when the page was last modified provided it was created during the reporting time frame.
Date when the page was last modified during the reporting time frame.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Owner</h3>
<p>
Person, group, or institution that created the page during the reporting time frame.
Person, group, or institution that owns the page modified during the reporting time frame.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Page</h3>
<p>
Title of the the page that was created during the reporting time frame.
Title of the the page that was modified during the reporting time frame.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Last visited</h3>
<p>
Date when a person last visited the page provided it was created during the reporting time frame.
Date when a person last visited the page provided it was modified during the reporting time frame.
</p>
......@@ -2,5 +2,5 @@
<!-- @copyright For copyright information on Mahara, please see the README file distributed with this software. -->
<h3>Visits</h3>
<p>
Sum of all visits on a page provided it was created during the reporting time frame.
Sum of all visits on a page provided it was modified during the reporting time frame.
</p>
......@@ -282,7 +282,7 @@ $string['reportdescpageactivity'] = '<ul>
<li>Number of blocks included in the page</li>
<li>Number of visits to the page</li>
<li>Number of comments on the page</li>
</ul><p>Displayed are pages that were created during the reporting time frame.</p>';
</ul><p>Displayed are pages that were modified during the reporting time frame.</p>';
$string['allothers'] = 'All others';
// Last activities reported on in the "User activity" report
......@@ -327,8 +327,8 @@ $string['reportdescgroups'] = '<ul>
<li>Name</li>
<li>Number of members</li>
<li>Number of pages</li>
<li>Number of shared pages</li>
<li>Number of comments on group pages and artefacts</li>
<li>Number of shared pages</li>
<li>Number of comments on pages and artefacts shared with the group</li>
<li>Number of forums</li>
<li>Number of forum posts</li>
......
......@@ -1252,6 +1252,7 @@ function collaboration_stats_table($limit, $offset, $extra, $institution, $urlli
);
}
else {
$result['pagination'] = null;
return $result;
}
}
......@@ -2207,12 +2208,26 @@ function view_stats_table($limit, $offset, $extra) {
require_once('view.php');
$where = "(v.owner != 0 OR v.owner IS NULL) AND v.type != ? AND v.template != ?";
$values = array('dashboard', View::SITE_TEMPLATE);
if ($start) {
$where .= " AND v.ctime >= DATE(?) AND v.ctime <= DATE(?)";
$values[] = $start;
$values[] = $end;
if (get_config('eventloglevel') == 'all') {
if ($start) {
$where .= " AND e.ctime >= DATE(?) AND e.ctime <= DATE(?)
AND ((e.resourcetype = 'view' AND e.resourceid = v.id)
OR (e.parentresourcetype = 'view' AND e.parentresourceid = v.id))";
$sqlwhere = " v.id IN (SELECT DISTINCT v.id FROM {view} v, {event_log} e WHERE " . $where . ")";
$values[] = $start;
$values[] = $end;
}
$count = count_records_sql("SELECT COUNT(DISTINCT v.id) FROM {view} v, {event_log} e WHERE " . $where, $values);
}
else {
if ($start) {
$where .= " AND v.mtime >= DATE(?) AND v.mtime <= DATE(?)";
$sqlwhere = $where;
$values[] = $start;
$values[] = $end;
}
$count = count_records_sql("SELECT COUNT(*) FROM {view} v WHERE " . $where, $values);
}
$count = count_records_sql("SELECT COUNT(*) FROM {view} v WHERE " . $where, $values);
$pagination = build_pagination(array(
'id' => 'stats_pagination',
......@@ -2246,8 +2261,16 @@ function view_stats_table($limit, $offset, $extra) {
case "collection":
$orderby = " c.name " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.id";
break;
case "comments":
case "owner":
$orderby = " CASE
WHEN v.owner IS NOT NULL
THEN (SELECT CONCAT(firstname, ' ', lastname) FROM {usr} WHERE id = v.owner)
WHEN v.group IS NOT NULL
THEN (SELECT name FROM {group} WHERE id = v.group)
ELSE (SELECT displayname FROM {institution} WHERE name = v.institution)
END " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.id";
break;
case "comments":
case "blocks":
$orderby = " " . $sorttype . " " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.title, v.id";
break;
......@@ -2280,7 +2303,7 @@ function view_stats_table($limit, $offset, $extra) {
FROM {view} v
LEFT JOIN {collection_view} cv ON cv.view = v.id
LEFT JOIN {collection} c ON c.id = cv.collection
WHERE " . $where . "
WHERE " . $sqlwhere . "
ORDER BY " . $orderby;
if (empty($extra['csvdownload'])) {
$viewdata = get_records_sql_assoc($sql, $values, $offset, $limit);
......@@ -2397,15 +2420,28 @@ function institution_view_stats_table($limit, $offset, &$institutiondata, $extra
if ($institutiondata['views'] != 0) {
$start = !empty($extra['start']) ? $extra['start'] : null;
$end = !empty($extra['end']) ? $extra['end'] : date('Y-m-d', strtotime('now'));
$where = 'id IN (' . $institutiondata['viewssql'] . ') AND type != ?';
$where = 'v.id IN (' . $institutiondata['viewssql'] . ') AND v.type != ?';
$values = array_merge($institutiondata['viewssqlparam'], array('dashboard'));
if ($start) {
$where .= " AND ctime >= DATE(?) AND ctime <= DATE(?)";
$values[] = $start;
$values[] = $end;
if (get_config('eventloglevel') == 'all') {
if ($start) {
$where .= " AND e.ctime >= DATE(?) AND e.ctime <= DATE(?)
AND ((e.resourcetype = 'view' AND e.resourceid = v.id)
OR (e.parentresourcetype = 'view' AND e.parentresourceid = v.id))";
$sqlwhere = " v.id IN (SELECT DISTINCT v.id FROM {view} v, {event_log} e WHERE " . $where . ")";
$values[] = $start;
$values[] = $end;
}
$count = count_records_sql("SELECT COUNT(DISTINCT v.id) FROM {view} v, {event_log} e WHERE " . $where, $values);
}
else {
if ($start) {
$where .= " AND v.mtime >= DATE(?) AND v.mtime <= DATE(?)";
$sqlwhere = $where;
$values[] = $start;
$values[] = $end;
}
$count = count_records_sql('SELECT COUNT(*) FROM {view} v WHERE ' . $where, $values);
}
$count = count_records_select('view', $where, $values);
}
else {
$count = 0;
......@@ -2440,8 +2476,19 @@ function institution_view_stats_table($limit, $offset, &$institutiondata, $extra
case "view":
$orderby = " v.title " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.id";
break;
case "comments":
case "collection":
$orderby = " c.name " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.id";
break;
case "owner":
$orderby = " CASE
WHEN v.owner IS NOT NULL
THEN (SELECT CONCAT(firstname, ' ', lastname) FROM {usr} WHERE id = v.owner)
WHEN v.group IS NOT NULL
THEN (SELECT name FROM {group} WHERE id = v.group)
ELSE (SELECT displayname FROM {institution} WHERE name = v.institution)
END " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.id";
break;
case "comments":
case "blocks":
$orderby = " " . $sorttype . " " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.title, v.id";
break;
......@@ -2449,13 +2496,13 @@ function institution_view_stats_table($limit, $offset, &$institutiondata, $extra
$orderby = " v.ctime " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.title, v.id";
break;
case "modified":
$orderby = " m.ctime " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.title, v.id";
$orderby = " v.mtime " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.title, v.id";
break;
case "visited":
$orderby = " a.ctime " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.title, v.id";
$orderby = " v.atime " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.title, v.id";
break;
case "visits":
default:
default:
$orderby = " v.visits " . (!empty($extra['sortdesc']) ? 'ASC' : 'DESC') . ", v.title, v.id";
}
......@@ -2471,8 +2518,12 @@ function institution_view_stats_table($limit, $offset, &$institutiondata, $extra
v.ctime, v.mtime, v.atime,
(SELECT COUNT(*) FROM {block_instance} WHERE view = v.id) AS blocks,
(SELECT COUNT(*) FROM {artefact_comment_comment} WHERE onview = v.id) AS comments
FROM {view} v WHERE " . $where . "
FROM {view} v
LEFT JOIN {collection_view} cv ON cv.view = v.id
LEFT JOIN {collection} c ON c.id = cv.collection
WHERE " . $sqlwhere . "
ORDER BY " . $orderby;
if (!empty($extra['csvdownload'])) {
$viewdata = get_records_sql_assoc($sql, $values);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment