tiki-edit_question_options.php 3.2 KB
Newer Older
1
<?php
2

3
// $Id: /cvsroot/tikiwiki/tiki/tiki-edit_question_options.php,v 1.17 2007-10-12 07:55:26 nyloth Exp $
4

5
// Copyright (c) 2002-2007, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
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.

9
// Initialization
10 11
require_once ('tiki-setup.php');
include_once ('lib/quizzes/quizlib.php');
12

13 14
$auto_query_args = array('sort_mode', 'offset', 'find', 'questionId', 'quizId', 'optionId');

15
if ($prefs['feature_quizzes'] != 'y') {
16
	$smarty->assign('msg', tra("This feature is disabled").": feature_quizzes");
17

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

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

25
	$smarty->display("error.tpl");
26
	die;
27 28
}

29 30 31 32 33 34 35 36
$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');

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

39
if ($tiki_p_admin_quizzes != 'y') {
40
	$smarty->assign('errortype', 401);
41
	$smarty->assign('msg', tra("You do not have permission to use this feature"));
42

43
	$smarty->display("error.tpl");
44 45
	die;
}
46

47 48
if (!isset($_REQUEST["optionId"])) {
	$_REQUEST["optionId"] = 0;
49 50
}

51 52 53 54
$smarty->assign('optionId', $_REQUEST["optionId"]);

if ($_REQUEST["optionId"]) {
	$info = $quizlib->get_quiz_question_option($_REQUEST["optionId"]);
55
} else {
56 57 58 59
	$info = array();

	$info["optionText"] = '';
	$info["points"] = '';
60 61
}

62 63 64 65
$smarty->assign('optionText', $info["optionText"]);
$smarty->assign('points', $info["points"]);

if (isset($_REQUEST["remove"])) {
mose's avatar
mose committed
66
  $area = 'delquizquestionoptions';
67
  if ($prefs['feature_ticketlib2'] != 'y' or (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"]))) {
mose's avatar
mose committed
68 69 70 71 72
    key_check($area);
		$quizlib->remove_quiz_question_option($_REQUEST["remove"]);
  } else {
    key_get($area);
  }
73 74
}

75
if (isset($_REQUEST["save"])) {
76
	check_ticket('edit-question-options');
77 78 79 80
	$quizlib->replace_question_option($_REQUEST["optionId"], $_REQUEST["optionText"], $_REQUEST["points"], $_REQUEST["questionId"]);

	$smarty->assign('optionText', '');
	$smarty->assign('optionId', 0);
81 82
}

83 84
if (!isset($_REQUEST["sort_mode"])) {
	$sort_mode = 'optionText_asc';
85
} else {
86 87
	$sort_mode = $_REQUEST["sort_mode"];
}
88

89 90
if (!isset($_REQUEST["offset"])) {
	$offset = 0;
91
} else {
92
	$offset = $_REQUEST["offset"];
93 94
}

95 96 97 98
$smarty->assign_by_ref('offset', $offset);

if (isset($_REQUEST["find"])) {
	$find = $_REQUEST["find"];
99
} else {
100
	$find = '';
101 102
}

103 104 105 106
$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);
107

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

110
$smarty->assign_by_ref('channels', $channels["data"]);
111

112
ask_ticket('edit-question-options');
113

114 115 116
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');

117
// Display the template
118
$smarty->assign('mid', 'tiki-edit_question_options.tpl');
119
$smarty->display("tiki.tpl");