//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 c_id = '.$course_id.' ".$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
$sql="SELECT *, SUM(score) AS TOTAL_SCORE FROM ".$tbl_wiki." WHERE c_id = $course_id ".$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)) {
$total_score=$total_score+$row['TOTAL_SCORE'];
@ -992,7 +992,7 @@ echo '<br/>';
}
/////////////////////// Most active users /////////////////////// Juan Carlos Raña Trabado
@ -1511,9 +1510,9 @@ if ($_GET['action']=='links') {
//table
if (api_is_allowed_to_edit(false,true) || api_is_platform_admin()) { //only by professors if page is hidden
$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE s1.c_id = '.$course_id.' AND linksto LIKE '%".Database::escape_string($page)." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";//add blank space after like '%" " %' to identify each word
$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE s1.c_id = $course_id AND linksto LIKE '%".Database::escape_string($page)." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";//add blank space after like '%" " %' to identify each word
} else {
$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE s1.c_id = '.$course_id.' AND visibility=1 AND linksto LIKE '%".Database::escape_string($page)." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = '.$course_id.' AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";//add blank space after like '%" " %' to identify each word
$sql="SELECT * FROM ".$tbl_wiki." s1 WHERE s1.c_id = $course_id AND visibility=1 AND linksto LIKE '%".Database::escape_string($page)." %' AND id=(SELECT MAX(s2.id) FROM ".$tbl_wiki." s2 WHERE s2.c_id = $course_id AND s1.reflink = s2.reflink AND ".$groupfilter.$condition_session.")";//add blank space after like '%" " %' to identify each word
}
$allpages=Database::query($sql);
@ -2088,12 +2087,12 @@ if ($_GET['action']=='history' or $_POST['HistoryDifferences']) {
$sql="SELECT * FROM $tbl_wiki_discuss reviews, $user_table user WHERE reviews.c_id = '.$course_id.' AND reviews.publication_id='".$id."' AND user.user_id='".$firstuserid."' ORDER BY id DESC";
$sql="SELECT * FROM $tbl_wiki_discuss reviews, $user_table user
WHERE reviews.c_id = $course_id AND reviews.publication_id='".$id."' AND user.user_id='".$firstuserid."' ORDER BY id DESC";
$result=Database::query($sql) or die(Database::error());
$sql="SELECT SUM(p_score) as sumWPost FROM $tbl_wiki_discuss WHERE c_id = '.$course_id.' AND publication_id='".$id."' AND NOT p_score='-' ORDER BY id DESC";
$sql="SELECT SUM(p_score) as sumWPost FROM $tbl_wiki_discuss WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-' ORDER BY id DESC";
$result2=Database::query($sql) or die(Database::error());
$row2=Database::fetch_array($result2);
$sql="SELECT * FROM $tbl_wiki_discuss WHERE c_id = '.$course_id.' AND publication_id='".$id."' AND NOT p_score='-'";
$sql="SELECT * FROM $tbl_wiki_discuss WHERE c_id = $course_id AND publication_id='".$id."' AND NOT p_score='-'";
$result3=Database::query($sql) or die(Database::error());
$countWPost_score= Database::num_rows($result3);
@ -2507,9 +2505,10 @@ if ($_GET['action']=='discuss') {
echo ' - '.get_lang('RatingMedia').': '.$avg_WPost_score; // average rating
$sql='UPDATE '.$tbl_wiki.' SET score="'.Database::escape_string($avg_WPost_score).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session; // check if work ok. TODO:
Database::query($sql);
$sql = 'UPDATE '.$tbl_wiki.' SET score="'.Database::escape_string($avg_WPost_score).'"
WHERE c_id = '.$course_id.' AND reflink="'.Database::escape_string($page).'" AND '.$groupfilter.$condition_session;