tiki-quiz_stats.php 3.03 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3
// (c) Copyright 2002-2009 by authors of the Tiki Wiki/CMS/Groupware Project
// 
4 5
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
changi67's avatar
changi67 committed
6
// $Id: /cvsroot/tikiwiki/tiki/tiki-quiz_stats.php,v 1.15 2007-10-12 07:55:31 nyloth Exp $
7
$section = 'quizzes';
8 9
require_once ('tiki-setup.php');
include_once ('lib/quizzes/quizlib.php');
10
$auto_query_args = array('sort_mode', 'offset', 'find');
11
if ($prefs['feature_quizzes'] != 'y') {
changi67's avatar
changi67 committed
12
	$smarty->assign('msg', tra("This feature is disabled") . ": feature_quizzes");
13
	$smarty->display("error.tpl");
14
	die;
15
}
16
if ($tiki_p_view_quiz_stats != 'y') {
17
	$smarty->assign('errortype', 401);
18
	$smarty->assign('msg', tra("You do not have permission to use this feature"));
19
	$smarty->display("error.tpl");
20 21 22 23
	die;
}
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'quizName_asc';
24
} else {
25 26 27 28
	$sort_mode = $_REQUEST["sort_mode"];
}
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
29
} else {
30
	$offset = $_REQUEST["offset"];
31
}
32 33 34
$smarty->assign_by_ref('offset', $offset);
if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
35
} else {
36
	$find = '';
37
}
38 39 40
$smarty->assign('find', $find);
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $quizlib->list_quiz_sum_stats($offset, $maxRecords, $sort_mode, $find);
41 42
$temp_max = count($channels["data"]);
for ($i = 0; $i < $temp_max; $i++) {
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
	if ($userlib->object_has_one_permission($channels["data"][$i]["quizId"], 'quiz')) {
		$channels["data"][$i]["individual"] = 'y';
		if ($userlib->object_has_permission($user, $channels["data"][$i]["quizId"], 'quiz', 'tiki_p_take_quiz')) {
			$channels["data"][$i]["individual_tiki_p_take_quiz"] = 'y';
		} else {
			$channels["data"][$i]["individual_tiki_p_take_quiz"] = 'n';
		}
		if ($userlib->object_has_permission($user, $channels["data"][$i]["quizId"], 'quiz', 'tiki_p_view_quiz_stats')) {
			$channels["data"][$i]["individual_tiki_p_view_quiz_stats"] = 'y';
		} else {
			$channels["data"][$i]["individual_tiki_p_view_quiz_stats"] = 'n';
		}
		if ($userlib->object_has_permission($user, $channels["data"][$i]["quizId"], 'quiz', 'tiki_p_view_user_stats')) {
			$channels["data"][$i]["individual_tiki_p_view_user_stats"] = 'y';
		} else {
			$channels["data"][$i]["individual_tiki_p_view_user_stats"] = 'n';
		}
changi67's avatar
changi67 committed
60
		if ($tiki_p_admin == 'y' || $userlib->object_has_permission($user, $channels["data"][$i]["quizId"], 'quiz', 'tiki_p_admin_quizzes')) {
61 62 63 64 65 66 67 68 69
			$channels["data"][$i]["individual_tiki_p_take_quiz"] = 'y';
			$channels["data"][$i]["individual_tiki_p_view_quiz_stats"] = 'y';
			$channels["data"][$i]["individual_tiki_p_admin_quizzes"] = 'y';
			$channels["data"][$i]["individual_tiki_p_view_user_stats"] = 'y';
		}
	} else {
		$channels["data"][$i]["individual"] = 'n';
	}
}
70
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
71 72
$smarty->assign_by_ref('channels', $channels["data"]);
include_once ('tiki-section_options.php');
73
ask_ticket('quiz-stats');
74
// Display the template
75
$smarty->assign('mid', 'tiki-quiz_stats.tpl');
76
$smarty->display("tiki.tpl");