/[pkg-tikiwiki]/branches/feature/external-libs/tiki-edit_quiz_results.php
ViewVC logotype

Contents of /branches/feature/external-libs/tiki-edit_quiz_results.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 96 - (show annotations) (download)
Wed Sep 6 08:36:21 2006 UTC (6 years, 8 months ago) by marcusb-guest
File size: 4118 byte(s)
Clone upstream branch.
1 <?php
2
3 // $Header: /cvsroot/tikiwiki/tiki/tiki-edit_quiz_results.php,v 1.9.2.4 2006/09/03 16:32:32 ohertel Exp $
4
5 // Copyright (c) 2002-2005, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
6 // All Rights Reserved. See copyright.txt for details and a complete list of authors.
7 // Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
8
9 // Initialization
10 require_once ('tiki-setup.php');
11
12 include_once ('lib/quizzes/quizlib.php');
13
14 if ($feature_quizzes != 'y') {
15 $smarty->assign('msg', tra("This feature is disabled").": feature_quizzes");
16
17 $smarty->display("error.tpl");
18 die;
19 }
20
21 if (!isset($_REQUEST["quizId"])) {
22 $smarty->assign('msg', tra("No quiz indicated"));
23
24 $smarty->display("error.tpl");
25 die;
26 }
27
28 $smarty->assign('individual', 'n');
29
30 if ($userlib->object_has_one_permission($_REQUEST["quizId"], 'quiz')) {
31 $smarty->assign('individual', 'y');
32
33 if ($tiki_p_admin != 'y') {
34 $perms = $userlib->get_permissions(0, -1, 'permName_desc', '', 'quizzes');
35
36 foreach ($perms["data"] as $perm) {
37 $permName = $perm["permName"];
38
39 if ($userlib->object_has_permission($user, $_REQUEST["quizId"], 'quiz', $permName)) {
40 $$permName = 'y';
41
42 $smarty->assign("$permName", 'y');
43 } else {
44 $$permName = 'n';
45
46 $smarty->assign("$permName", 'n');
47 }
48 }
49 }
50 }
51
52 if ($tiki_p_admin_quizzes != 'y') {
53 $smarty->assign('msg', tra("You do not have permission to use this feature"));
54
55 $smarty->display("error.tpl");
56 die;
57 }
58
59 $smarty->assign('quizId', $_REQUEST["quizId"]);
60 $quiz_info = $quizlib->get_quiz_result($_REQUEST["quizId"]);
61 $smarty->assign('quiz_info', $quiz_info);
62
63 if (!isset($_REQUEST["resultId"])) {
64 $_REQUEST["resultId"] = 0;
65 }
66
67 $smarty->assign('resultId', $_REQUEST["resultId"]);
68
69 if ($_REQUEST["resultId"]) {
70 $info = $quizlib->get_quiz_result($_REQUEST["resultId"]);
71 } else {
72 $info = array();
73
74 $info["fromPoints"] = 0;
75 $info["toPoints"] = 0;
76 $info["answer"] = '';
77 }
78
79 $smarty->assign('answer', $info["answer"]);
80 $smarty->assign('fromPoints', $info["fromPoints"]);
81 $smarty->assign('toPoints', $info["toPoints"]);
82
83 if (isset($_REQUEST["remove"])) {
84 $area = 'delquizresult';
85 if ($feature_ticketlib2 != 'y' or (isset($_POST['daconfirm']) and isset($_SESSION["ticket_$area"]))) {
86 key_check($area);
87 $quizlib->remove_quiz_result($_REQUEST["remove"]);
88 } else {
89 key_get($area);
90 }
91 }
92
93 if (isset($_REQUEST["save"])) {
94 check_ticket('edit-quiz-result');
95 $quizlib->replace_quiz_result($_REQUEST["resultId"], $_REQUEST["quizId"], $_REQUEST["fromPoints"], $_REQUEST["toPoints"],
96 $_REQUEST["answer"]);
97
98 $smarty->assign('answer', '');
99 $smarty->assign('resultId', 0);
100 }
101
102 if (!isset($_REQUEST["sort_mode"])) {
103 $sort_mode = 'fromPoints_asc';
104 } else {
105 $sort_mode = $_REQUEST["sort_mode"];
106 }
107
108 if (!isset($_REQUEST["offset"])) {
109 $offset = 0;
110 } else {
111 $offset = $_REQUEST["offset"];
112 }
113
114 $smarty->assign_by_ref('offset', $offset);
115
116 if (isset($_REQUEST["find"])) {
117 $find = $_REQUEST["find"];
118 } else {
119 $find = '';
120 }
121
122 $smarty->assign('find', $find);
123
124 $smarty->assign_by_ref('sort_mode', $sort_mode);
125 $channels = $quizlib->list_quiz_results($_REQUEST["quizId"], $offset, $maxRecords, $sort_mode, $find);
126
127 $cant_pages = ceil($channels["cant"] / $maxRecords);
128 $smarty->assign_by_ref('cant_pages', $cant_pages);
129 $smarty->assign('actual_page', 1 + ($offset / $maxRecords));
130
131 if ($channels["cant"] > ($offset + $maxRecords)) {
132 $smarty->assign('next_offset', $offset + $maxRecords);
133 } else {
134 $smarty->assign('next_offset', -1);
135 }
136
137 // If offset is > 0 then prev_offset
138 if ($offset > 0) {
139 $smarty->assign('prev_offset', $offset - $maxRecords);
140 } else {
141 $smarty->assign('prev_offset', -1);
142 }
143
144 $smarty->assign_by_ref('channels', $channels["data"]);
145
146 // Fill array with possible number of questions per page
147 $positions = array();
148
149 for ($i = 1; $i < 100; $i++)
150 $positions[] = $i;
151
152 $smarty->assign('positions', $positions);
153
154 ask_ticket('edit-quiz-result');
155
156 // disallow robots to index page:
157 $smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
158
159 // Display the template
160 $smarty->assign('mid', 'tiki-edit_quiz_results.tpl');
161 $smarty->display("tiki.tpl");
162
163 ?>

  ViewVC Help
Powered by ViewVC 1.1.5