tiki-edit_question_options.php 2.69 KB
Newer Older
1
<?php
changi67's avatar
changi67 committed
2 3 4
/**
 * @package tikiwiki
 */
5
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
changi67's avatar
changi67 committed
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 12

require_once ('tiki-setup.php');
include_once ('lib/quizzes/quizlib.php');
13

14
$auto_query_args = array('sort_mode', 'offset', 'find', 'questionId', 'quizId', 'optionId');
15
$access->check_feature('feature_quizzes');
16 17 18 19

if (!isset($_REQUEST["questionId"])) {
	$smarty->assign('msg', tra("No question indicated"));

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

24 25 26 27 28 29 30 31
$smarty->assign('questionId', $_REQUEST["questionId"]);
$quiz_info = $quizlib->get_quiz_question($_REQUEST["questionId"]);
$smarty->assign('question_info', $quiz_info);
$_REQUEST["quizId"] = $quiz_info["quizId"];
$smarty->assign('quizId', $_REQUEST["quizId"]);

$smarty->assign('individual', 'n');

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

34
$access->check_permission('tiki_p_admin_quizzes');
35

36 37
if (!isset($_REQUEST["optionId"])) {
	$_REQUEST["optionId"] = 0;
38 39
}

40 41 42 43
$smarty->assign('optionId', $_REQUEST["optionId"]);

if ($_REQUEST["optionId"]) {
	$info = $quizlib->get_quiz_question_option($_REQUEST["optionId"]);
44
} else {
45 46 47 48
	$info = array();

	$info["optionText"] = '';
	$info["points"] = '';
49 50
}

51 52 53 54
$smarty->assign('optionText', $info["optionText"]);
$smarty->assign('points', $info["points"]);

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

59
if (isset($_REQUEST["save"])) {
60
	check_ticket('edit-question-options');
61 62 63 64
	$quizlib->replace_question_option($_REQUEST["optionId"], $_REQUEST["optionText"], $_REQUEST["points"], $_REQUEST["questionId"]);

	$smarty->assign('optionText', '');
	$smarty->assign('optionId', 0);
65 66
}

67 68
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'optionText_asc';
69
} else {
70 71
	$sort_mode = $_REQUEST["sort_mode"];
}
72

73 74
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
75
} else {
76
	$offset = $_REQUEST["offset"];
77 78
}

79 80 81 82
$smarty->assign_by_ref('offset', $offset);

if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
83
} else {
84
	$find = '';
85 86
}

87 88 89 90
$smarty->assign('find', $find);

$smarty->assign_by_ref('sort_mode', $sort_mode);
$channels = $quizlib->list_quiz_question_options($_REQUEST["questionId"], $offset, $maxRecords, $sort_mode, $find);
91

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

94
$smarty->assign_by_ref('channels', $channels["data"]);
95

96
ask_ticket('edit-question-options');
97

98 99 100
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');

101
// Display the template
102
$smarty->assign('mid', 'tiki-edit_question_options.tpl');
103
$smarty->display("tiki.tpl");