tiki-edit_quiz_results.php 2.76 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2015 by authors of the Tiki Wiki CMS Groupware Project
6
//
7 8
// 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
9
// $Id$
10 11

require_once ('tiki-setup.php');
12
$quizlib = TikiLib::lib('quiz');
13

14
$auto_query_args = array('quizId', 'resultId', 'sort_mode', 'offset', 'find');
15
$access->check_feature('feature_quizzes');
16

17 18 19
if (!isset($_REQUEST["quizId"])) {
	$smarty->assign('msg', tra("No quiz indicated"));

20
	$smarty->display("error.tpl");
21
	die;
22 23
}

24
$tikilib->get_perm_object($_REQUEST["quizId"], 'quiz');
25

26
$smarty->assign('individual', 'n');
27
$access->check_permission('tiki_p_admin_quizzes');
28

29 30 31 32 33 34
$smarty->assign('quizId', $_REQUEST["quizId"]);
$quiz_info = $quizlib->get_quiz_result($_REQUEST["quizId"]);
$smarty->assign('quiz_info', $quiz_info);

if (!isset($_REQUEST["resultId"])) {
	$_REQUEST["resultId"] = 0;
35 36
}

37 38 39 40
$smarty->assign('resultId', $_REQUEST["resultId"]);

if ($_REQUEST["resultId"]) {
	$info = $quizlib->get_quiz_result($_REQUEST["resultId"]);
41
} else {
42
	$info = array();
43

44 45 46
	$info["fromPoints"] = 0;
	$info["toPoints"] = 0;
	$info["answer"] = '';
47 48
}

49 50 51 52 53
$smarty->assign('answer', $info["answer"]);
$smarty->assign('fromPoints', $info["fromPoints"]);
$smarty->assign('toPoints', $info["toPoints"]);

if (isset($_REQUEST["remove"])) {
54 55
	$access->check_authenticity();
	$quizlib->remove_quiz_result($_REQUEST["remove"]);
56 57
}

58
if (isset($_REQUEST["save"])) {
59
	check_ticket('edit-quiz-result');
60
	$quizlib->replace_quiz_result(
61 62 63 64 65
		$_REQUEST["resultId"],
		$_REQUEST["quizId"],
		$_REQUEST["fromPoints"],
		$_REQUEST["toPoints"],
		$_REQUEST["answer"]
66
	);
67 68 69 70

	$smarty->assign('answer', '');
	$smarty->assign('resultId', 0);
}
71

72 73
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'fromPoints_asc';
74
} else {
75 76
	$sort_mode = $_REQUEST["sort_mode"];
}
77

78 79
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
80
} else {
81
	$offset = $_REQUEST["offset"];
82 83
}

84 85 86 87
$smarty->assign_by_ref('offset', $offset);

if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
88
} else {
89
	$find = '';
90 91
}

92
$smarty->assign('find', $find);
93

94 95
$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $quizlib->list_quiz_results($_REQUEST["quizId"], $offset, $maxRecords, $sort_mode, $find);
96

97
$smarty->assign_by_ref('cant_pages', $channels["cant"]);
98

99
$smarty->assign_by_ref('channels', $channels["data"]);
100 101

// Fill array with possible number of questions per page
102
$positions = array();
103

104 105
for ($i = 1; $i < 100; $i++)
	$positions[] = $i;
106

107
$smarty->assign('positions', $positions);
108

109
ask_ticket('edit-quiz-result');
110

111 112 113
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');

114
// Display the template
115
$smarty->assign('mid', 'tiki-edit_quiz_results.tpl');
116
$smarty->display("tiki.tpl");