$sql="SELECT *, COUNT(*) AS TOTAL_VERS, SUM(hits) AS TOTAL_VISITS FROM ".$tbl_wiki."WHERE ".$groupfilter.$condition_session."";
$allpages=Database::query($sql);
while ($row=Database::fetch_array($allpages)) {
$total_versions = $row['TOTAL_VERS'];
$total_visits = $row['TOTAL_VISITS'];
$total_visits = intval($row['TOTAL_VISITS']);
}
$sql="SELECT * FROM ".$tbl_wiki."WHERE ".$groupfilter.$condition_session."";
@ -537,14 +556,35 @@ if ($_GET['action']=='statistics' && (api_is_allowed_to_edit(false,true) || api_
}
//check only last version of all pages (current page)
$sql =' SELECT *, COUNT(*) AS TOTAL_PAGES, SUM(hits) AS TOTAL_VISITS_LV FROM '.$tbl_wiki.' s1
WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
$sql='SELECT * FROM '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';
$allpages=Database::query($sql);
@ -706,6 +746,7 @@ else{
//Creation date of the oldest wiki page and version
$first_wiki_date='0000-00-00 00:00:00';
$sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.$condition_session.' ORDER BY dtime ASC LIMIT 1';
//Average score of all wiki pages. (If a page has not scored zero rated)
$media_score =0;
$sql="SELECT *, SUM(score) AS TOTAL_SCORE FROM ".$tbl_wiki." WHERE ".$groupfilter.$condition_session." GROUP BY reflink ";//group by because mark in all versions, then always is ok. Do not use "count" because using "group by", would give a wrong value
$allpages=Database::query($sql);
while ($row=Database::fetch_array($allpages)) {
@ -733,7 +776,8 @@ if (!empty($total_pages)) {
}
//Average user progress in his pages
$media_progress=0;
$sql='SELECT *, SUM(progress) AS TOTAL_PROGRESS FROM '.$tbl_wiki.' s1 WHERE s1.c_id = '.$course_id.' AND id=(SELECT MAX(s2.id) FROM '.$tbl_wiki.' s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND '.$groupfilter.' AND session_id='.$session_id.')';//As the value is only the latest version I can not use group by
$allpages=Database::query($sql);
@ -756,16 +800,33 @@ while ($row=Database::fetch_array($allpages)) {
//Total of different IP addresses that have participated in the wiki
$total_ip=0;
$sql='SELECT * FROM '.$tbl_wiki.' WHERE '.$groupfilter.$condition_session.' GROUP BY user_ip';