@@ -85,40 +85,40 @@ |
||
85 | 85 | $this->view->render(); |
86 | 86 | } |
87 | 87 | |
88 | - /** |
|
89 | - * This method allow store user blocks from dashboard manager |
|
90 | - * render to dashboard.php view |
|
91 | - */ |
|
92 | - public function store_user_block() |
|
88 | + /** |
|
89 | + * This method allow store user blocks from dashboard manager |
|
90 | + * render to dashboard.php view |
|
91 | + */ |
|
92 | + public function store_user_block() |
|
93 | 93 | { |
94 | - $data = array(); |
|
95 | - $user_id = $this->user_id; |
|
96 | - if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { |
|
97 | - $enabled_blocks = $_POST['enabled_blocks']; |
|
98 | - $columns = $_POST['columns']; |
|
99 | - $affected_rows = DashboardManager::store_user_blocks($user_id, $enabled_blocks, $columns); |
|
100 | - if ($affected_rows) { |
|
101 | - $data['success'] = true; |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - $data['dashboard_view'] = 'list'; |
|
106 | - |
|
107 | - // render to the view |
|
108 | - $this->view->set_data($data); |
|
109 | - $this->view->set_layout('layout'); |
|
110 | - $this->view->set_template('dashboard'); |
|
111 | - $this->view->render(); |
|
112 | - } |
|
113 | - |
|
114 | - /** |
|
115 | - * This method is used when you close a block from dashboard block interface |
|
116 | - * render to dashboard.php view |
|
117 | - */ |
|
118 | - public function close_user_block($path) |
|
94 | + $data = array(); |
|
95 | + $user_id = $this->user_id; |
|
96 | + if (strtoupper($_SERVER['REQUEST_METHOD']) == "POST") { |
|
97 | + $enabled_blocks = $_POST['enabled_blocks']; |
|
98 | + $columns = $_POST['columns']; |
|
99 | + $affected_rows = DashboardManager::store_user_blocks($user_id, $enabled_blocks, $columns); |
|
100 | + if ($affected_rows) { |
|
101 | + $data['success'] = true; |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + $data['dashboard_view'] = 'list'; |
|
106 | + |
|
107 | + // render to the view |
|
108 | + $this->view->set_data($data); |
|
109 | + $this->view->set_layout('layout'); |
|
110 | + $this->view->set_template('dashboard'); |
|
111 | + $this->view->render(); |
|
112 | + } |
|
113 | + |
|
114 | + /** |
|
115 | + * This method is used when you close a block from dashboard block interface |
|
116 | + * render to dashboard.php view |
|
117 | + */ |
|
118 | + public function close_user_block($path) |
|
119 | 119 | { |
120 | - $user_id = $this->user_id; |
|
121 | - $result = DashboardManager::close_user_block($user_id, $path); |
|
122 | - $this->display($result); |
|
123 | - } |
|
120 | + $user_id = $this->user_id; |
|
121 | + $result = DashboardManager::close_user_block($user_id, $path); |
|
122 | + $this->display($result); |
|
123 | + } |
|
124 | 124 | } |
@@ -33,18 +33,18 @@ |
||
33 | 33 | $doc_url = str_replace('/..', '', $doc_url); //echo $doc_url; |
34 | 34 | |
35 | 35 | if (! isset($_course)) { |
36 | - api_not_allowed(true); |
|
36 | + api_not_allowed(true); |
|
37 | 37 | } |
38 | 38 | $full_file_name = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/upload/blog/'.$doc_url; |
39 | 39 | |
40 | 40 | //if the rewrite rule asks for a directory, we redirect to the course view |
41 | 41 | if (is_dir($full_file_name)) { |
42 | - //remove last slash if present |
|
43 | - while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul); |
|
44 | - //create the path |
|
45 | - $document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path |
|
46 | - //redirect |
|
47 | - header('Location: '.$document_explorer); |
|
42 | + //remove last slash if present |
|
43 | + while ($doc_url{$dul = strlen($doc_url)-1}=='/') $doc_url = substr($doc_url,0,$dul); |
|
44 | + //create the path |
|
45 | + $document_explorer = api_get_path(WEB_COURSE_PATH).api_get_course_path(); // home course path |
|
46 | + //redirect |
|
47 | + header('Location: '.$document_explorer); |
|
48 | 48 | exit; |
49 | 49 | } |
50 | 50 |
@@ -1,10 +1,10 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * BLOG HOMEPAGE |
|
5 | - * This file takes care of all blog navigation and displaying. |
|
6 | - * @package chamilo.blogs |
|
7 | - */ |
|
4 | + * BLOG HOMEPAGE |
|
5 | + * This file takes care of all blog navigation and displaying. |
|
6 | + * @package chamilo.blogs |
|
7 | + */ |
|
8 | 8 | require_once '../inc/global.inc.php'; |
9 | 9 | |
10 | 10 | $blog_id = intval($_GET['blog_id']); |
@@ -41,181 +41,181 @@ discard block |
||
41 | 41 | $safe_task_description = isset($_POST['task_description']) ? Security::remove_XSS($_POST['task_description']) : null; |
42 | 42 | |
43 | 43 | if (!empty($_POST['new_post_submit'])) { |
44 | - Blog:: create_post( |
|
45 | - $_POST['title'], |
|
46 | - $_POST['full_text'], |
|
47 | - $_POST['post_file_comment'], |
|
48 | - $blog_id |
|
49 | - ); |
|
50 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogAdded')); |
|
44 | + Blog:: create_post( |
|
45 | + $_POST['title'], |
|
46 | + $_POST['full_text'], |
|
47 | + $_POST['post_file_comment'], |
|
48 | + $blog_id |
|
49 | + ); |
|
50 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogAdded')); |
|
51 | 51 | } |
52 | 52 | if (!empty($_POST['edit_post_submit'])) { |
53 | - Blog:: edit_post( |
|
54 | - $_POST['post_id'], |
|
55 | - $_POST['title'], |
|
56 | - $_POST['full_text'], |
|
57 | - $blog_id |
|
58 | - ); |
|
59 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogEdited')); |
|
53 | + Blog:: edit_post( |
|
54 | + $_POST['post_id'], |
|
55 | + $_POST['title'], |
|
56 | + $_POST['full_text'], |
|
57 | + $blog_id |
|
58 | + ); |
|
59 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogEdited')); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | if (!empty($_POST['new_comment_submit'])) { |
63 | - Blog:: create_comment( |
|
64 | - $_POST['title'], |
|
65 | - $_POST['comment'], |
|
66 | - $_POST['post_file_comment'], |
|
67 | - $blog_id, |
|
68 | - $_GET['post_id'], |
|
69 | - $_POST['comment_parent_id'] |
|
70 | - ); |
|
71 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('CommentAdded')); |
|
63 | + Blog:: create_comment( |
|
64 | + $_POST['title'], |
|
65 | + $_POST['comment'], |
|
66 | + $_POST['post_file_comment'], |
|
67 | + $blog_id, |
|
68 | + $_GET['post_id'], |
|
69 | + $_POST['comment_parent_id'] |
|
70 | + ); |
|
71 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('CommentAdded')); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | if (!empty($_POST['new_task_submit'])) { |
75 | 75 | |
76 | - Blog:: create_task( |
|
77 | - $blog_id, |
|
78 | - $safe_task_name, |
|
79 | - $safe_task_description, |
|
80 | - (isset($_POST['chkArticleDelete']) ? $_POST['chkArticleDelete'] : null), |
|
81 | - (isset($_POST['chkArticleEdit']) ? $_POST['chkArticleEdit'] : null), |
|
82 | - (isset($_POST['chkCommentsDelete']) ? $_POST['chkCommentsDelete'] : null), |
|
83 | - (isset($_POST['task_color']) ? $_POST['task_color'] : null) |
|
84 | - ); |
|
85 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskCreated')); |
|
76 | + Blog:: create_task( |
|
77 | + $blog_id, |
|
78 | + $safe_task_name, |
|
79 | + $safe_task_description, |
|
80 | + (isset($_POST['chkArticleDelete']) ? $_POST['chkArticleDelete'] : null), |
|
81 | + (isset($_POST['chkArticleEdit']) ? $_POST['chkArticleEdit'] : null), |
|
82 | + (isset($_POST['chkCommentsDelete']) ? $_POST['chkCommentsDelete'] : null), |
|
83 | + (isset($_POST['task_color']) ? $_POST['task_color'] : null) |
|
84 | + ); |
|
85 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskCreated')); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | if (isset($_POST['edit_task_submit'])) { |
89 | - Blog:: edit_task( |
|
90 | - $_POST['blog_id'], |
|
91 | - $_POST['task_id'], |
|
92 | - $safe_task_name, |
|
93 | - $safe_task_description, |
|
94 | - $_POST['chkArticleDelete'], |
|
95 | - $_POST['chkArticleEdit'], |
|
96 | - $_POST['chkCommentsDelete'], |
|
97 | - $_POST['task_color'] |
|
98 | - ); |
|
99 | - $return_message = array( |
|
100 | - 'type' => 'confirmation', |
|
101 | - 'message' => get_lang('TaskEdited') |
|
102 | - ); |
|
89 | + Blog:: edit_task( |
|
90 | + $_POST['blog_id'], |
|
91 | + $_POST['task_id'], |
|
92 | + $safe_task_name, |
|
93 | + $safe_task_description, |
|
94 | + $_POST['chkArticleDelete'], |
|
95 | + $_POST['chkArticleEdit'], |
|
96 | + $_POST['chkCommentsDelete'], |
|
97 | + $_POST['task_color'] |
|
98 | + ); |
|
99 | + $return_message = array( |
|
100 | + 'type' => 'confirmation', |
|
101 | + 'message' => get_lang('TaskEdited') |
|
102 | + ); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | if (!empty($_POST['assign_task_submit'])) { |
106 | - Blog:: assign_task( |
|
107 | - $blog_id, |
|
108 | - $_POST['task_user_id'], |
|
109 | - $_POST['task_task_id'], |
|
110 | - $_POST['task_day'] |
|
111 | - ); |
|
112 | - $return_message = array( |
|
113 | - 'type' => 'confirmation', |
|
114 | - 'message' => get_lang('TaskAssigned') |
|
115 | - ); |
|
106 | + Blog:: assign_task( |
|
107 | + $blog_id, |
|
108 | + $_POST['task_user_id'], |
|
109 | + $_POST['task_task_id'], |
|
110 | + $_POST['task_day'] |
|
111 | + ); |
|
112 | + $return_message = array( |
|
113 | + 'type' => 'confirmation', |
|
114 | + 'message' => get_lang('TaskAssigned') |
|
115 | + ); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | if (isset($_POST['assign_task_edit_submit'])) { |
119 | - Blog:: edit_assigned_task( |
|
120 | - $blog_id, |
|
121 | - $_POST['task_user_id'], |
|
122 | - $_POST['task_task_id'], |
|
123 | - $_POST['task_day'], |
|
124 | - $_POST['old_user_id'], |
|
125 | - $_POST['old_task_id'], |
|
126 | - $_POST['old_target_date'] |
|
127 | - ); |
|
128 | - $return_message = array( |
|
129 | - 'type' => 'confirmation', |
|
130 | - 'message' => get_lang('AssignedTaskEdited') |
|
131 | - ); |
|
119 | + Blog:: edit_assigned_task( |
|
120 | + $blog_id, |
|
121 | + $_POST['task_user_id'], |
|
122 | + $_POST['task_task_id'], |
|
123 | + $_POST['task_day'], |
|
124 | + $_POST['old_user_id'], |
|
125 | + $_POST['old_task_id'], |
|
126 | + $_POST['old_target_date'] |
|
127 | + ); |
|
128 | + $return_message = array( |
|
129 | + 'type' => 'confirmation', |
|
130 | + 'message' => get_lang('AssignedTaskEdited') |
|
131 | + ); |
|
132 | 132 | } |
133 | 133 | if (!empty($_POST['new_task_execution_submit'])) { |
134 | - Blog:: create_comment( |
|
135 | - $safe_comment_title, |
|
136 | - $safe_comment_text, |
|
137 | - $blog_id, |
|
138 | - (int)$_GET['post_id'], |
|
139 | - $_POST['comment_parent_id'], |
|
140 | - $_POST['task_id'] |
|
141 | - ); |
|
142 | - $return_message = array( |
|
143 | - 'type' => 'confirmation', |
|
144 | - 'message' => get_lang('CommentCreated') |
|
145 | - ); |
|
134 | + Blog:: create_comment( |
|
135 | + $safe_comment_title, |
|
136 | + $safe_comment_text, |
|
137 | + $blog_id, |
|
138 | + (int)$_GET['post_id'], |
|
139 | + $_POST['comment_parent_id'], |
|
140 | + $_POST['task_id'] |
|
141 | + ); |
|
142 | + $return_message = array( |
|
143 | + 'type' => 'confirmation', |
|
144 | + 'message' => get_lang('CommentCreated') |
|
145 | + ); |
|
146 | 146 | } |
147 | 147 | if (!empty($_POST['register'])) { |
148 | - if (is_array($_POST['user'])) { |
|
149 | - foreach ($_POST['user'] as $index => $user_id) { |
|
150 | - Blog :: set_user_subscribed((int)$_GET['blog_id'], $user_id); |
|
151 | - } |
|
152 | - } |
|
148 | + if (is_array($_POST['user'])) { |
|
149 | + foreach ($_POST['user'] as $index => $user_id) { |
|
150 | + Blog :: set_user_subscribed((int)$_GET['blog_id'], $user_id); |
|
151 | + } |
|
152 | + } |
|
153 | 153 | } |
154 | 154 | if (!empty($_POST['unregister'])) { |
155 | - if (is_array($_POST['user'])) { |
|
156 | - foreach ($_POST['user'] as $index => $user_id) { |
|
157 | - Blog :: set_user_unsubscribed((int)$_GET['blog_id'], $user_id); |
|
158 | - } |
|
159 | - } |
|
155 | + if (is_array($_POST['user'])) { |
|
156 | + foreach ($_POST['user'] as $index => $user_id) { |
|
157 | + Blog :: set_user_unsubscribed((int)$_GET['blog_id'], $user_id); |
|
158 | + } |
|
159 | + } |
|
160 | 160 | } |
161 | 161 | if (!empty($_GET['register'])) { |
162 | - Blog :: set_user_subscribed((int)$_GET['blog_id'], (int)$_GET['user_id']); |
|
163 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('UserRegistered')); |
|
164 | - $flag = 1; |
|
162 | + Blog :: set_user_subscribed((int)$_GET['blog_id'], (int)$_GET['user_id']); |
|
163 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('UserRegistered')); |
|
164 | + $flag = 1; |
|
165 | 165 | } |
166 | 166 | if (!empty($_GET['unregister'])) { |
167 | - Blog :: set_user_unsubscribed((int)$_GET['blog_id'], (int)$_GET['user_id']); |
|
167 | + Blog :: set_user_unsubscribed((int)$_GET['blog_id'], (int)$_GET['user_id']); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | if (isset($_GET['action']) && $_GET['action'] == 'manage_tasks') { |
171 | - if (isset($_GET['do']) && $_GET['do'] == 'delete') { |
|
172 | - Blog :: delete_task($blog_id, (int)$_GET['task_id']); |
|
173 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskDeleted')); |
|
174 | - } |
|
175 | - |
|
176 | - if (isset($_GET['do']) && $_GET['do'] == 'delete_assignment') { |
|
177 | - Blog :: delete_assigned_task($blog_id, intval($_GET['task_id']), intval($_GET['user_id'])); |
|
178 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssignmentDeleted')); |
|
179 | - } |
|
171 | + if (isset($_GET['do']) && $_GET['do'] == 'delete') { |
|
172 | + Blog :: delete_task($blog_id, (int)$_GET['task_id']); |
|
173 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskDeleted')); |
|
174 | + } |
|
175 | + |
|
176 | + if (isset($_GET['do']) && $_GET['do'] == 'delete_assignment') { |
|
177 | + Blog :: delete_assigned_task($blog_id, intval($_GET['task_id']), intval($_GET['user_id'])); |
|
178 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('TaskAssignmentDeleted')); |
|
179 | + } |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | if (isset($_GET['action']) && $_GET['action'] == 'view_post') { |
183 | - $task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0; |
|
184 | - |
|
185 | - if (isset($_GET['do']) && $_GET['do'] == 'delete_comment') { |
|
186 | - if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { |
|
187 | - Blog :: delete_comment($blog_id, (int)$_GET['post_id'],(int)$_GET['comment_id']); |
|
188 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('CommentDeleted')); |
|
189 | - } else { |
|
190 | - $error = true; |
|
191 | - $message = get_lang('ActionNotAllowed'); |
|
192 | - } |
|
193 | - } |
|
194 | - |
|
195 | - if (isset($_GET['do']) && $_GET['do'] == 'delete_article') { |
|
196 | - if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) { |
|
197 | - Blog :: delete_post($blog_id, (int)$_GET['article_id']); |
|
198 | - $action = ''; // Article is gone, go to blog home |
|
199 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogDeleted')); |
|
200 | - } else { |
|
201 | - $error = true; |
|
202 | - $message = get_lang('ActionNotAllowed'); |
|
203 | - } |
|
204 | - } |
|
205 | - if (isset($_GET['do']) && $_GET['do'] == 'rate') { |
|
206 | - if (isset($_GET['type']) && $_GET['type'] == 'post') { |
|
207 | - if (api_is_allowed('BLOG_'.$blog_id, 'article_rate')) { |
|
208 | - Blog :: add_rating('post', $blog_id, (int)$_GET['post_id'], (int)$_GET['rating']); |
|
209 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded')); |
|
210 | - } |
|
211 | - } |
|
212 | - if (isset($_GET['type']) && $_GET['type'] == 'comment') { |
|
213 | - if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) { |
|
214 | - Blog :: add_rating('comment', $blog_id, (int)$_GET['comment_id'], (int)$_GET['rating']); |
|
215 | - $return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded')); |
|
216 | - } |
|
217 | - } |
|
218 | - } |
|
183 | + $task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0; |
|
184 | + |
|
185 | + if (isset($_GET['do']) && $_GET['do'] == 'delete_comment') { |
|
186 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_delete', $task_id)) { |
|
187 | + Blog :: delete_comment($blog_id, (int)$_GET['post_id'],(int)$_GET['comment_id']); |
|
188 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('CommentDeleted')); |
|
189 | + } else { |
|
190 | + $error = true; |
|
191 | + $message = get_lang('ActionNotAllowed'); |
|
192 | + } |
|
193 | + } |
|
194 | + |
|
195 | + if (isset($_GET['do']) && $_GET['do'] == 'delete_article') { |
|
196 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_delete', $task_id)) { |
|
197 | + Blog :: delete_post($blog_id, (int)$_GET['article_id']); |
|
198 | + $action = ''; // Article is gone, go to blog home |
|
199 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('BlogDeleted')); |
|
200 | + } else { |
|
201 | + $error = true; |
|
202 | + $message = get_lang('ActionNotAllowed'); |
|
203 | + } |
|
204 | + } |
|
205 | + if (isset($_GET['do']) && $_GET['do'] == 'rate') { |
|
206 | + if (isset($_GET['type']) && $_GET['type'] == 'post') { |
|
207 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_rate')) { |
|
208 | + Blog :: add_rating('post', $blog_id, (int)$_GET['post_id'], (int)$_GET['rating']); |
|
209 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded')); |
|
210 | + } |
|
211 | + } |
|
212 | + if (isset($_GET['type']) && $_GET['type'] == 'comment') { |
|
213 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_comments_add')) { |
|
214 | + Blog :: add_rating('comment', $blog_id, (int)$_GET['comment_id'], (int)$_GET['rating']); |
|
215 | + $return_message = array('type' => 'confirmation', 'message' => get_lang('RatingAdded')); |
|
216 | + } |
|
217 | + } |
|
218 | + } |
|
219 | 219 | } |
220 | 220 | /* |
221 | 221 | DISPLAY |
@@ -223,67 +223,67 @@ discard block |
||
223 | 223 | |
224 | 224 | // Set breadcrumb |
225 | 225 | switch ($action) { |
226 | - case 'new_post' : |
|
227 | - $nameTools = get_lang('NewPost'); |
|
226 | + case 'new_post' : |
|
227 | + $nameTools = get_lang('NewPost'); |
|
228 | 228 | $interbreadcrumb[] = array( |
229 | 229 | 'url' => "blog.php?blog_id=$blog_id&".api_get_cidreq(), |
230 | 230 | "name" => Blog:: get_blog_title($blog_id), |
231 | 231 | ); |
232 | - Display :: display_header($nameTools, 'Blogs'); |
|
233 | - break; |
|
234 | - case 'manage_tasks' : |
|
235 | - $nameTools = get_lang('TaskManager'); |
|
232 | + Display :: display_header($nameTools, 'Blogs'); |
|
233 | + break; |
|
234 | + case 'manage_tasks' : |
|
235 | + $nameTools = get_lang('TaskManager'); |
|
236 | 236 | $interbreadcrumb[] = array( |
237 | 237 | 'url' => "blog.php?blog_id=$blog_id&".api_get_cidreq(), |
238 | 238 | "name" => Blog:: get_blog_title($blog_id), |
239 | 239 | ); |
240 | - Display :: display_header($nameTools, 'Blogs'); |
|
241 | - break; |
|
242 | - case 'manage_members' : |
|
243 | - $nameTools = get_lang('MemberManager'); |
|
240 | + Display :: display_header($nameTools, 'Blogs'); |
|
241 | + break; |
|
242 | + case 'manage_members' : |
|
243 | + $nameTools = get_lang('MemberManager'); |
|
244 | 244 | $interbreadcrumb[] = array( |
245 | 245 | 'url' => "blog.php?blog_id=$blog_id&".api_get_cidreq(), |
246 | 246 | "name" => Blog:: get_blog_title($blog_id), |
247 | 247 | ); |
248 | - Display :: display_header($nameTools, 'Blogs'); |
|
249 | - break; |
|
250 | - case 'manage_rights' : |
|
251 | - $nameTools = get_lang('RightsManager'); |
|
248 | + Display :: display_header($nameTools, 'Blogs'); |
|
249 | + break; |
|
250 | + case 'manage_rights' : |
|
251 | + $nameTools = get_lang('RightsManager'); |
|
252 | 252 | $interbreadcrumb[] = array( |
253 | 253 | 'url' => "blog.php?blog_id=$blog_id&".api_get_cidreq(), |
254 | 254 | 'name' => Blog:: get_blog_title($blog_id), |
255 | 255 | ); |
256 | - Display :: display_header($nameTools, 'Blogs'); |
|
257 | - break; |
|
258 | - case 'view_search_result' : |
|
259 | - $nameTools = get_lang('SearchResults'); |
|
256 | + Display :: display_header($nameTools, 'Blogs'); |
|
257 | + break; |
|
258 | + case 'view_search_result' : |
|
259 | + $nameTools = get_lang('SearchResults'); |
|
260 | 260 | $interbreadcrumb[] = array( |
261 | 261 | 'url' => "blog.php?blog_id=$blog_id&".api_get_cidreq(), |
262 | 262 | 'name' => Blog:: get_blog_title($blog_id), |
263 | 263 | ); |
264 | - Display :: display_header($nameTools, 'Blogs'); |
|
265 | - break; |
|
266 | - case 'execute_task' : |
|
267 | - $nameTools = get_lang('ExecuteThisTask'); |
|
264 | + Display :: display_header($nameTools, 'Blogs'); |
|
265 | + break; |
|
266 | + case 'execute_task' : |
|
267 | + $nameTools = get_lang('ExecuteThisTask'); |
|
268 | 268 | $interbreadcrumb[] = array( |
269 | 269 | 'url' => "blog.php?blog_id=$blog_id&".api_get_cidreq(), |
270 | 270 | 'name' => Blog:: get_blog_title($blog_id), |
271 | 271 | ); |
272 | - Display :: display_header($nameTools, 'Blogs'); |
|
273 | - break; |
|
274 | - default : |
|
275 | - $nameTools = Blog :: get_blog_title($blog_id); |
|
276 | - Display :: display_header($nameTools, 'Blogs'); |
|
272 | + Display :: display_header($nameTools, 'Blogs'); |
|
273 | + break; |
|
274 | + default : |
|
275 | + $nameTools = Blog :: get_blog_title($blog_id); |
|
276 | + Display :: display_header($nameTools, 'Blogs'); |
|
277 | 277 | } |
278 | 278 | |
279 | 279 | // feedback messages |
280 | 280 | if (!empty($return_message)) { |
281 | - if ($return_message['type'] == 'confirmation') { |
|
282 | - Display::display_confirmation_message($return_message['message']); |
|
283 | - } |
|
284 | - if ($return_message['type'] == 'error') { |
|
285 | - Display::display_error_message($return_message['message']); |
|
286 | - } |
|
281 | + if ($return_message['type'] == 'confirmation') { |
|
282 | + Display::display_confirmation_message($return_message['message']); |
|
283 | + } |
|
284 | + if ($return_message['type'] == 'error') { |
|
285 | + Display::display_error_message($return_message['message']); |
|
286 | + } |
|
287 | 287 | } |
288 | 288 | |
289 | 289 | // actions |
@@ -350,12 +350,12 @@ discard block |
||
350 | 350 | <?php |
351 | 351 | |
352 | 352 | if (isset($error)) { |
353 | - Display :: display_error_message($message); |
|
353 | + Display :: display_error_message($message); |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | if (isset($flag) && $flag == '1') { |
357 | - $action = "manage_tasks"; |
|
358 | - Blog :: display_assign_task_form($blog_id); |
|
357 | + $action = "manage_tasks"; |
|
358 | + Blog :: display_assign_task_form($blog_id); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | $user_task = false; |
@@ -363,12 +363,12 @@ discard block |
||
363 | 363 | $course_id = api_get_course_int_id(); |
364 | 364 | |
365 | 365 | if (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) { |
366 | - $task_id = (int)$_GET['task_id']; |
|
366 | + $task_id = (int)$_GET['task_id']; |
|
367 | 367 | } else { |
368 | - $task_id = 0; |
|
369 | - $tbl_blogs_tasks_rel_user = Database :: get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
368 | + $task_id = 0; |
|
369 | + $tbl_blogs_tasks_rel_user = Database :: get_course_table(TABLE_BLOGS_TASKS_REL_USER); |
|
370 | 370 | |
371 | - $sql = "SELECT COUNT(*) as number |
|
371 | + $sql = "SELECT COUNT(*) as number |
|
372 | 372 | FROM ".$tbl_blogs_tasks_rel_user." |
373 | 373 | WHERE |
374 | 374 | c_id = $course_id AND |
@@ -376,120 +376,120 @@ discard block |
||
376 | 376 | user_id = ".api_get_user_id()." AND |
377 | 377 | task_id = ".$task_id; |
378 | 378 | |
379 | - $result = Database::query($sql); |
|
380 | - $row = Database::fetch_array($result); |
|
379 | + $result = Database::query($sql); |
|
380 | + $row = Database::fetch_array($result); |
|
381 | 381 | |
382 | - if ($row['number'] == 1) |
|
383 | - $user_task = true; |
|
382 | + if ($row['number'] == 1) |
|
383 | + $user_task = true; |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | switch ($action) { |
387 | - case 'new_post': |
|
388 | - if (api_is_allowed('BLOG_'.$blog_id, 'article_add', $user_task ? $task_id : 0)) { |
|
389 | - // we show the form if |
|
390 | - // 1. no post data |
|
391 | - // 2. there is post data and the required field is empty |
|
392 | - if (!$_POST OR (!empty($_POST) AND empty($_POST['title']))) { |
|
393 | - // if there is post data there is certainly an error in the form |
|
394 | - if ($_POST) { |
|
395 | - Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); |
|
396 | - } |
|
397 | - Blog :: display_form_new_post($blog_id); |
|
398 | - } else { |
|
399 | - if (isset($_GET['filter']) && !empty($_GET['filter'])) { |
|
400 | - Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter'])); |
|
401 | - } else { |
|
402 | - Blog :: display_blog_posts($blog_id); |
|
403 | - } |
|
404 | - } |
|
405 | - } else { |
|
406 | - api_not_allowed(); |
|
407 | - } |
|
408 | - break; |
|
409 | - case 'view_post' : |
|
410 | - Blog :: display_post($blog_id, intval($_GET['post_id'])); |
|
411 | - break; |
|
412 | - case 'edit_post' : |
|
413 | - $task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0; |
|
414 | - |
|
415 | - if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id)) { |
|
416 | - // we show the form if |
|
417 | - // 1. no post data |
|
418 | - // 2. there is post data and the required field is empty |
|
419 | - if (!$_POST OR (!empty($_POST) AND empty($_POST['post_title']))) { |
|
420 | - // if there is post data there is certainly an error in the form |
|
421 | - if ($_POST) { |
|
422 | - Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); |
|
423 | - } |
|
387 | + case 'new_post': |
|
388 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_add', $user_task ? $task_id : 0)) { |
|
389 | + // we show the form if |
|
390 | + // 1. no post data |
|
391 | + // 2. there is post data and the required field is empty |
|
392 | + if (!$_POST OR (!empty($_POST) AND empty($_POST['title']))) { |
|
393 | + // if there is post data there is certainly an error in the form |
|
394 | + if ($_POST) { |
|
395 | + Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); |
|
396 | + } |
|
397 | + Blog :: display_form_new_post($blog_id); |
|
398 | + } else { |
|
399 | + if (isset($_GET['filter']) && !empty($_GET['filter'])) { |
|
400 | + Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter'])); |
|
401 | + } else { |
|
402 | + Blog :: display_blog_posts($blog_id); |
|
403 | + } |
|
404 | + } |
|
405 | + } else { |
|
406 | + api_not_allowed(); |
|
407 | + } |
|
408 | + break; |
|
409 | + case 'view_post' : |
|
410 | + Blog :: display_post($blog_id, intval($_GET['post_id'])); |
|
411 | + break; |
|
412 | + case 'edit_post' : |
|
413 | + $task_id = (isset ($_GET['task_id']) && is_numeric($_GET['task_id'])) ? $_GET['task_id'] : 0; |
|
414 | + |
|
415 | + if (api_is_allowed('BLOG_'.$blog_id, 'article_edit', $task_id)) { |
|
416 | + // we show the form if |
|
417 | + // 1. no post data |
|
418 | + // 2. there is post data and the required field is empty |
|
419 | + if (!$_POST OR (!empty($_POST) AND empty($_POST['post_title']))) { |
|
420 | + // if there is post data there is certainly an error in the form |
|
421 | + if ($_POST) { |
|
422 | + Display::display_error_message(get_lang('FormHasErrorsPleaseComplete')); |
|
423 | + } |
|
424 | 424 | Blog :: display_form_edit_post($blog_id, intval($_GET['post_id'])); |
425 | - } else { |
|
426 | - if (isset ($_GET['filter']) && !empty ($_GET['filter'])) { |
|
427 | - Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter'])); |
|
428 | - } else { |
|
429 | - Blog :: display_blog_posts($blog_id); |
|
430 | - } |
|
431 | - } |
|
432 | - } else { |
|
433 | - api_not_allowed(); |
|
434 | - } |
|
435 | - |
|
436 | - break; |
|
437 | - case 'manage_members' : |
|
438 | - if (api_is_allowed('BLOG_'.$blog_id, 'member_management')) { |
|
439 | - Blog :: display_form_user_subscribe($blog_id); |
|
440 | - echo '<br /><br />'; |
|
441 | - Blog :: display_form_user_unsubscribe($blog_id); |
|
442 | - } else { |
|
443 | - api_not_allowed(); |
|
425 | + } else { |
|
426 | + if (isset ($_GET['filter']) && !empty ($_GET['filter'])) { |
|
427 | + Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter'])); |
|
428 | + } else { |
|
429 | + Blog :: display_blog_posts($blog_id); |
|
430 | + } |
|
431 | + } |
|
432 | + } else { |
|
433 | + api_not_allowed(); |
|
434 | + } |
|
435 | + |
|
436 | + break; |
|
437 | + case 'manage_members' : |
|
438 | + if (api_is_allowed('BLOG_'.$blog_id, 'member_management')) { |
|
439 | + Blog :: display_form_user_subscribe($blog_id); |
|
440 | + echo '<br /><br />'; |
|
441 | + Blog :: display_form_user_unsubscribe($blog_id); |
|
442 | + } else { |
|
443 | + api_not_allowed(); |
|
444 | 444 | } |
445 | 445 | |
446 | - break; |
|
447 | - case 'manage_rights' : |
|
448 | - Blog :: display_form_user_rights($blog_id); |
|
449 | - break; |
|
450 | - case 'manage_tasks' : |
|
451 | - if (api_is_allowed('BLOG_'.$blog_id, 'task_management')) { |
|
452 | - if (isset($_GET['do']) && $_GET['do'] == 'add') { |
|
453 | - Blog:: display_new_task_form($blog_id); |
|
454 | - } |
|
455 | - if (isset($_GET['do']) && $_GET['do'] == 'assign') { |
|
456 | - Blog:: display_assign_task_form($blog_id); |
|
457 | - } |
|
458 | - if (isset($_GET['do']) && $_GET['do'] == 'edit') { |
|
459 | - Blog:: display_edit_task_form( |
|
460 | - $blog_id, |
|
461 | - intval($_GET['task_id']) |
|
462 | - ); |
|
463 | - } |
|
464 | - if (isset($_GET['do']) && $_GET['do'] == 'edit_assignment') { |
|
465 | - Blog :: display_edit_assigned_task_form($blog_id, intval($_GET['task_id']), intval($_GET['user_id'])); |
|
466 | - } |
|
467 | - Blog :: display_task_list($blog_id); |
|
468 | - echo '<br /><br />'; |
|
469 | - Blog :: display_assigned_task_list($blog_id); |
|
470 | - echo '<br /><br />'; |
|
471 | - } |
|
472 | - else |
|
473 | - api_not_allowed(); |
|
474 | - |
|
475 | - break; |
|
476 | - case 'execute_task' : |
|
477 | - if (isset ($_GET['post_id'])) |
|
478 | - Blog :: display_post($blog_id, intval($_GET['post_id'])); |
|
479 | - else |
|
480 | - Blog :: display_select_task_post($blog_id, intval($_GET['task_id'])); |
|
481 | - |
|
482 | - break; |
|
483 | - case 'view_search_result' : |
|
484 | - Blog :: display_search_results($blog_id, Database::escape_string($_GET['q'])); |
|
485 | - break; |
|
486 | - case '' : |
|
487 | - default : |
|
488 | - if (isset ($_GET['filter']) && !empty ($_GET['filter'])) { |
|
489 | - Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter'])); |
|
490 | - } else { |
|
491 | - Blog :: display_blog_posts($blog_id); |
|
492 | - } |
|
446 | + break; |
|
447 | + case 'manage_rights' : |
|
448 | + Blog :: display_form_user_rights($blog_id); |
|
449 | + break; |
|
450 | + case 'manage_tasks' : |
|
451 | + if (api_is_allowed('BLOG_'.$blog_id, 'task_management')) { |
|
452 | + if (isset($_GET['do']) && $_GET['do'] == 'add') { |
|
453 | + Blog:: display_new_task_form($blog_id); |
|
454 | + } |
|
455 | + if (isset($_GET['do']) && $_GET['do'] == 'assign') { |
|
456 | + Blog:: display_assign_task_form($blog_id); |
|
457 | + } |
|
458 | + if (isset($_GET['do']) && $_GET['do'] == 'edit') { |
|
459 | + Blog:: display_edit_task_form( |
|
460 | + $blog_id, |
|
461 | + intval($_GET['task_id']) |
|
462 | + ); |
|
463 | + } |
|
464 | + if (isset($_GET['do']) && $_GET['do'] == 'edit_assignment') { |
|
465 | + Blog :: display_edit_assigned_task_form($blog_id, intval($_GET['task_id']), intval($_GET['user_id'])); |
|
466 | + } |
|
467 | + Blog :: display_task_list($blog_id); |
|
468 | + echo '<br /><br />'; |
|
469 | + Blog :: display_assigned_task_list($blog_id); |
|
470 | + echo '<br /><br />'; |
|
471 | + } |
|
472 | + else |
|
473 | + api_not_allowed(); |
|
474 | + |
|
475 | + break; |
|
476 | + case 'execute_task' : |
|
477 | + if (isset ($_GET['post_id'])) |
|
478 | + Blog :: display_post($blog_id, intval($_GET['post_id'])); |
|
479 | + else |
|
480 | + Blog :: display_select_task_post($blog_id, intval($_GET['task_id'])); |
|
481 | + |
|
482 | + break; |
|
483 | + case 'view_search_result' : |
|
484 | + Blog :: display_search_results($blog_id, Database::escape_string($_GET['q'])); |
|
485 | + break; |
|
486 | + case '' : |
|
487 | + default : |
|
488 | + if (isset ($_GET['filter']) && !empty ($_GET['filter'])) { |
|
489 | + Blog :: display_day_results($blog_id, Database::escape_string($_GET['filter'])); |
|
490 | + } else { |
|
491 | + Blog :: display_blog_posts($blog_id); |
|
492 | + } |
|
493 | 493 | } |
494 | 494 | ?> |
495 | 495 | </div> |
@@ -1966,7 +1966,7 @@ discard block |
||
1966 | 1966 | $label = get_lang('NextQuestion'); |
1967 | 1967 | $class = 'btn btn-primary'; |
1968 | 1968 | } |
1969 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1969 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1970 | 1970 | if ($this->type == ONE_PER_PAGE) { |
1971 | 1971 | if ($questionNum != 1) { |
1972 | 1972 | $prev_question = $questionNum - 2; |
@@ -1991,7 +1991,7 @@ discard block |
||
1991 | 1991 | $all_label = get_lang('EndTest'); |
1992 | 1992 | $class = 'btn btn-warning'; |
1993 | 1993 | } |
1994 | - $class .= ' question-validate-btn'; // used to select it with jquery |
|
1994 | + $class .= ' question-validate-btn'; // used to select it with jquery |
|
1995 | 1995 | $all_button = ' <a href="javascript://" class="'.$class.'" onclick="validate_all(); ">'.$all_label.'</a>'; |
1996 | 1996 | $all_button .= ' ' . Display::span(null, ['id' => 'save_all_reponse']); |
1997 | 1997 | $html .= $all_button; |
@@ -3774,7 +3774,7 @@ discard block |
||
3774 | 3774 | |
3775 | 3775 | //Fixes multiple answer question in order to be exact |
3776 | 3776 | //if ($answerType == MULTIPLE_ANSWER || $answerType == GLOBAL_MULTIPLE_ANSWER) { |
3777 | - /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3777 | + /* if ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
3778 | 3778 | $diff = @array_diff($answer_correct_array, $real_answers); |
3779 | 3779 | |
3780 | 3780 | // All good answers or nothing works like exact |
@@ -5073,8 +5073,8 @@ discard block |
||
5073 | 5073 | } |
5074 | 5074 | |
5075 | 5075 | /** |
5076 | - * @return string |
|
5077 | - */ |
|
5076 | + * @return string |
|
5077 | + */ |
|
5078 | 5078 | public function get_formated_title() |
5079 | 5079 | { |
5080 | 5080 | return api_html_entity_decode($this->selectTitle()); |
@@ -1,11 +1,11 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | /* For licensing terms, see /license.txt */ |
3 | 3 | /** |
4 | - * Exercise list: This script shows the list of exercises for administrators and students. |
|
5 | - * @package chamilo.exercise |
|
6 | - * @author hubert.borderiou |
|
7 | - * |
|
8 | - */ |
|
4 | + * Exercise list: This script shows the list of exercises for administrators and students. |
|
5 | + * @package chamilo.exercise |
|
6 | + * @author hubert.borderiou |
|
7 | + * |
|
8 | + */ |
|
9 | 9 | |
10 | 10 | use ChamiloSession as Session; |
11 | 11 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | } |
46 | 46 | |
47 | 47 | if (!$is_allowedToEdit) { |
48 | - // api_not_allowed(); |
|
48 | + // api_not_allowed(); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | if (!empty($_REQUEST['path'])) { |
@@ -190,9 +190,9 @@ discard block |
||
190 | 190 | get_lang('Actions') |
191 | 191 | ); |
192 | 192 | |
193 | - // Column config |
|
194 | - // @todo fix search firstname/lastname that doesn't work. rmove search for the moment |
|
195 | - $column_model = array( |
|
193 | + // Column config |
|
194 | + // @todo fix search firstname/lastname that doesn't work. rmove search for the moment |
|
195 | + $column_model = array( |
|
196 | 196 | array('name'=>'firstname', 'index'=>'firstname', 'width'=>'50', 'align'=>'left', 'search' => 'false'), |
197 | 197 | array('name'=>'lastname', 'index'=>'lastname', 'width'=>'50', 'align'=>'left', 'formatter'=>'action_formatter', 'search' => 'false'), |
198 | 198 | array('name'=>'login', 'hidden'=>'true', 'index'=>'username', 'width'=>'40', 'align'=>'left', 'search' => 'false'), |
@@ -18,10 +18,10 @@ |
||
18 | 18 | $file = file(api_get_path(SYS_LANG_PATH).'english/hotspot.inc.php'); |
19 | 19 | |
20 | 20 | foreach ($file as &$value) { |
21 | - $variable = explode('=', $value , 2); |
|
22 | - if (count($variable) > 1) { |
|
23 | - $variable = substr(trim($variable[0]), 1); |
|
24 | - $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' '; |
|
25 | - echo $variable; |
|
26 | - } |
|
21 | + $variable = explode('=', $value , 2); |
|
22 | + if (count($variable) > 1) { |
|
23 | + $variable = substr(trim($variable[0]), 1); |
|
24 | + $variable = '&'.$variable.'='.api_utf8_encode(get_lang($variable)).' '; |
|
25 | + echo $variable; |
|
26 | + } |
|
27 | 27 | } |
@@ -249,7 +249,7 @@ |
||
249 | 249 | break; |
250 | 250 | case RESULT_DISABLE_SHOW_SCORE_ONLY: |
251 | 251 | if ($objExercise->feedback_type != EXERCISE_FEEDBACK_TYPE_END) { |
252 | - $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
|
252 | + $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score')); |
|
253 | 253 | } |
254 | 254 | else { |
255 | 255 | $header_names = array(get_lang('Attempt'), get_lang('StartDate'), get_lang('IP'), get_lang('Score'), get_lang('Details')); |
@@ -13,11 +13,11 @@ discard block |
||
13 | 13 | public $name; |
14 | 14 | public $description; |
15 | 15 | |
16 | - /** |
|
17 | - * Constructor of the class Category |
|
18 | - * If you give an in_id and no in_name, you get info concerning the category of id=in_id |
|
19 | - * otherwise, you've got an category objet avec your in_id, in_name, in_descr |
|
20 | - * |
|
16 | + /** |
|
17 | + * Constructor of the class Category |
|
18 | + * If you give an in_id and no in_name, you get info concerning the category of id=in_id |
|
19 | + * otherwise, you've got an category objet avec your in_id, in_name, in_descr |
|
20 | + * |
|
21 | 21 | * @param int $id |
22 | 22 | * @param string $name |
23 | 23 | * @param string $description |
@@ -61,9 +61,9 @@ discard block |
||
61 | 61 | } |
62 | 62 | } |
63 | 63 | |
64 | - /** |
|
64 | + /** |
|
65 | 65 | * add TestCategory in the database if name doesn't already exists |
66 | - */ |
|
66 | + */ |
|
67 | 67 | public function addCategoryInBDD() |
68 | 68 | { |
69 | 69 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | |
109 | 109 | return false; |
110 | 110 | } |
111 | - } |
|
111 | + } |
|
112 | 112 | |
113 | - /** |
|
113 | + /** |
|
114 | 114 | * Removes the category from the database |
115 | 115 | * if there were question in this category, the link between question and category is removed |
116 | - */ |
|
116 | + */ |
|
117 | 117 | public function removeCategory() |
118 | 118 | { |
119 | 119 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -143,11 +143,11 @@ discard block |
||
143 | 143 | |
144 | 144 | return true; |
145 | 145 | } |
146 | - } |
|
146 | + } |
|
147 | 147 | |
148 | - /** |
|
148 | + /** |
|
149 | 149 | * Modify category name or description of category with id=in_id |
150 | - */ |
|
150 | + */ |
|
151 | 151 | public function modifyCategory() |
152 | 152 | { |
153 | 153 | $table = Database :: get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
@@ -175,40 +175,40 @@ discard block |
||
175 | 175 | |
176 | 176 | return true; |
177 | 177 | } |
178 | - } |
|
178 | + } |
|
179 | 179 | |
180 | - /** |
|
180 | + /** |
|
181 | 181 | * Gets the number of question of category id=in_id |
182 | - */ |
|
182 | + */ |
|
183 | 183 | public function getCategoryQuestionsNumber() |
184 | 184 | { |
185 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
186 | - $in_id = intval($this->id); |
|
187 | - $sql = "SELECT count(*) AS nb |
|
185 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
186 | + $in_id = intval($this->id); |
|
187 | + $sql = "SELECT count(*) AS nb |
|
188 | 188 | FROM $table |
189 | 189 | WHERE category_id=$in_id AND c_id=".api_get_course_int_id(); |
190 | - $res = Database::query($sql); |
|
191 | - $row = Database::fetch_array($res); |
|
190 | + $res = Database::query($sql); |
|
191 | + $row = Database::fetch_array($res); |
|
192 | 192 | |
193 | - return $row['nb']; |
|
194 | - } |
|
193 | + return $row['nb']; |
|
194 | + } |
|
195 | 195 | |
196 | 196 | /** |
197 | 197 | * @param string $in_color |
198 | 198 | */ |
199 | 199 | public function display($in_color="#E0EBF5") |
200 | 200 | { |
201 | - echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
|
202 | - print_r($this); |
|
203 | - echo "</textarea>"; |
|
204 | - } |
|
201 | + echo "<textarea style='background-color:$in_color; width:60%; height:100px;'>"; |
|
202 | + print_r($this); |
|
203 | + echo "</textarea>"; |
|
204 | + } |
|
205 | 205 | |
206 | - /** |
|
206 | + /** |
|
207 | 207 | * Return an array of all Category objects in the database |
208 | - * If in_field=="" Return an array of all category objects in the database |
|
209 | - * Otherwise, return an array of all in_field value |
|
210 | - * in the database (in_field = id or name or description) |
|
211 | - */ |
|
208 | + * If in_field=="" Return an array of all category objects in the database |
|
209 | + * Otherwise, return an array of all in_field value |
|
210 | + * in the database (in_field = id or name or description) |
|
211 | + */ |
|
212 | 212 | public static function getCategoryListInfo($in_field = "", $courseId = "") |
213 | 213 | { |
214 | 214 | if (empty($courseId) || $courseId=="") { |
@@ -239,8 +239,8 @@ discard block |
||
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | - return $tabres; |
|
243 | - } |
|
242 | + return $tabres; |
|
243 | + } |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * Return the TestCategory id for question with question_id = $questionId |
@@ -251,196 +251,196 @@ discard block |
||
251 | 251 | * |
252 | 252 | * @return int |
253 | 253 | */ |
254 | - public static function getCategoryForQuestion($questionId, $courseId ="") |
|
254 | + public static function getCategoryForQuestion($questionId, $courseId ="") |
|
255 | 255 | { |
256 | - $result = 0; |
|
256 | + $result = 0; |
|
257 | 257 | if (empty($courseId) || $courseId == "") { |
258 | 258 | $courseId = api_get_course_int_id(); |
259 | 259 | } |
260 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
260 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_REL_CATEGORY); |
|
261 | 261 | $questionId = intval($questionId); |
262 | - $sql = "SELECT category_id |
|
262 | + $sql = "SELECT category_id |
|
263 | 263 | FROM $table |
264 | 264 | WHERE question_id = $questionId AND c_id = $courseId"; |
265 | - $res = Database::query($sql); |
|
266 | - if (Database::num_rows($res) > 0) { |
|
265 | + $res = Database::query($sql); |
|
266 | + if (Database::num_rows($res) > 0) { |
|
267 | 267 | $data = Database::fetch_array($res); |
268 | - $result = $data['category_id']; |
|
269 | - } |
|
268 | + $result = $data['category_id']; |
|
269 | + } |
|
270 | 270 | |
271 | - return $result; |
|
272 | - } |
|
271 | + return $result; |
|
272 | + } |
|
273 | 273 | |
274 | - /** |
|
275 | - * true if question id has a category |
|
276 | - */ |
|
277 | - public static function isQuestionHasCategory($questionId) |
|
274 | + /** |
|
275 | + * true if question id has a category |
|
276 | + */ |
|
277 | + public static function isQuestionHasCategory($questionId) |
|
278 | 278 | { |
279 | - if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
280 | - return true; |
|
281 | - } |
|
282 | - return false; |
|
283 | - } |
|
279 | + if (TestCategory::getCategoryForQuestion($questionId) > 0) { |
|
280 | + return true; |
|
281 | + } |
|
282 | + return false; |
|
283 | + } |
|
284 | 284 | |
285 | - /** |
|
285 | + /** |
|
286 | 286 | Return the category name for question with question_id = $questionId |
287 | 287 | In this version, a question has only 1 category. |
288 | 288 | Return the category id, "" if none |
289 | - */ |
|
289 | + */ |
|
290 | 290 | public static function getCategoryNameForQuestion( |
291 | 291 | $questionId, |
292 | 292 | $courseId = "" |
293 | 293 | ) { |
294 | - if (empty($courseId) || $courseId=="") { |
|
295 | - $courseId = api_get_course_int_id(); |
|
296 | - } |
|
297 | - $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
|
298 | - $result = ""; // result |
|
299 | - $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
300 | - $catid = intval($catid); |
|
301 | - $sql = "SELECT title FROM $table |
|
294 | + if (empty($courseId) || $courseId=="") { |
|
295 | + $courseId = api_get_course_int_id(); |
|
296 | + } |
|
297 | + $catid = TestCategory::getCategoryForQuestion($questionId, $courseId); |
|
298 | + $result = ""; // result |
|
299 | + $table = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY); |
|
300 | + $catid = intval($catid); |
|
301 | + $sql = "SELECT title FROM $table |
|
302 | 302 | WHERE id = $catid AND c_id = $courseId"; |
303 | - $res = Database::query($sql); |
|
304 | - $data = Database::fetch_array($res); |
|
305 | - if (Database::num_rows($res) > 0) { |
|
306 | - $result = $data['title']; |
|
307 | - } |
|
308 | - |
|
309 | - return $result; |
|
310 | - } |
|
311 | - |
|
312 | - /** |
|
313 | - * Return the list of differents categories ID for a test in the current course |
|
314 | - * input : test_id |
|
315 | - * return : array of category id (integer) |
|
316 | - * hubert.borderiou 07-04-2011 |
|
317 | - */ |
|
318 | - public static function getListOfCategoriesIDForTest($in_testid) |
|
303 | + $res = Database::query($sql); |
|
304 | + $data = Database::fetch_array($res); |
|
305 | + if (Database::num_rows($res) > 0) { |
|
306 | + $result = $data['title']; |
|
307 | + } |
|
308 | + |
|
309 | + return $result; |
|
310 | + } |
|
311 | + |
|
312 | + /** |
|
313 | + * Return the list of differents categories ID for a test in the current course |
|
314 | + * input : test_id |
|
315 | + * return : array of category id (integer) |
|
316 | + * hubert.borderiou 07-04-2011 |
|
317 | + */ |
|
318 | + public static function getListOfCategoriesIDForTest($in_testid) |
|
319 | 319 | { |
320 | - // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
321 | - $result = array(); |
|
322 | - $quiz = new Exercise(); |
|
323 | - $quiz->read($in_testid); |
|
324 | - $tabQuestionList = $quiz->selectQuestionList(); |
|
325 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
326 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
327 | - if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) { |
|
328 | - $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]); |
|
329 | - } |
|
330 | - } |
|
331 | - |
|
332 | - return $result; |
|
333 | - } |
|
334 | - |
|
335 | - /** |
|
336 | - * return the list of different categories NAME for a test |
|
337 | - * input : test_id |
|
338 | - * return : array of string |
|
339 | - * hubert.borderiou 07-04-2011 |
|
320 | + // parcourir les questions d'un test, recup les categories uniques dans un tableau |
|
321 | + $result = array(); |
|
322 | + $quiz = new Exercise(); |
|
323 | + $quiz->read($in_testid); |
|
324 | + $tabQuestionList = $quiz->selectQuestionList(); |
|
325 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ??? |
|
326 | + for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
327 | + if (!in_array(TestCategory::getCategoryForQuestion($tabQuestionList[$i]), $result)) { |
|
328 | + $result[] = TestCategory::getCategoryForQuestion($tabQuestionList[$i]); |
|
329 | + } |
|
330 | + } |
|
331 | + |
|
332 | + return $result; |
|
333 | + } |
|
334 | + |
|
335 | + /** |
|
336 | + * return the list of different categories NAME for a test |
|
337 | + * input : test_id |
|
338 | + * return : array of string |
|
339 | + * hubert.borderiou 07-04-2011 |
|
340 | 340 | * @author function rewrote by jmontoya |
341 | - */ |
|
342 | - public static function getListOfCategoriesNameForTest($in_testid) |
|
341 | + */ |
|
342 | + public static function getListOfCategoriesNameForTest($in_testid) |
|
343 | 343 | { |
344 | - $tabcatName = array(); |
|
345 | - $tabcatID = self::getListOfCategoriesIDForTest($in_testid); |
|
346 | - for ($i=0; $i < count($tabcatID); $i++) { |
|
347 | - $cat = new TestCategory($tabcatID[$i]); |
|
348 | - $tabcatName[$cat->id] = $cat->name; |
|
349 | - } |
|
350 | - return $tabcatName; |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * return the number of differents categories for a test |
|
355 | - * input : test_id |
|
356 | - * return : integer |
|
357 | - * hubert.borderiou 07-04-2011 |
|
358 | - */ |
|
359 | - public static function getNumberOfCategoriesForTest($in_testid) |
|
344 | + $tabcatName = array(); |
|
345 | + $tabcatID = self::getListOfCategoriesIDForTest($in_testid); |
|
346 | + for ($i=0; $i < count($tabcatID); $i++) { |
|
347 | + $cat = new TestCategory($tabcatID[$i]); |
|
348 | + $tabcatName[$cat->id] = $cat->name; |
|
349 | + } |
|
350 | + return $tabcatName; |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * return the number of differents categories for a test |
|
355 | + * input : test_id |
|
356 | + * return : integer |
|
357 | + * hubert.borderiou 07-04-2011 |
|
358 | + */ |
|
359 | + public static function getNumberOfCategoriesForTest($in_testid) |
|
360 | 360 | { |
361 | - return count(TestCategory::getListOfCategoriesIDForTest($in_testid)); |
|
362 | - } |
|
361 | + return count(TestCategory::getListOfCategoriesIDForTest($in_testid)); |
|
362 | + } |
|
363 | 363 | |
364 | - /** |
|
365 | - * return the number of question of a category id in a test |
|
366 | - * @param int $exerciseId |
|
364 | + /** |
|
365 | + * return the number of question of a category id in a test |
|
366 | + * @param int $exerciseId |
|
367 | 367 | * @param int $categoryId |
368 | 368 | * |
369 | - * @return integer |
|
369 | + * @return integer |
|
370 | 370 | * |
371 | - * @author hubert.borderiou 07-04-2011 |
|
372 | - */ |
|
373 | - public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId) |
|
371 | + * @author hubert.borderiou 07-04-2011 |
|
372 | + */ |
|
373 | + public static function getNumberOfQuestionsInCategoryForTest($exerciseId, $categoryId) |
|
374 | 374 | { |
375 | - $nbCatResult = 0; |
|
376 | - $quiz = new Exercise(); |
|
377 | - $quiz->read($exerciseId); |
|
378 | - $tabQuestionList = $quiz->selectQuestionList(); |
|
379 | - // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
|
380 | - for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
381 | - if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
|
382 | - $nbCatResult++; |
|
383 | - } |
|
384 | - } |
|
385 | - |
|
386 | - return $nbCatResult; |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * return the number of question for a test using random by category |
|
391 | - * input : test_id, number of random question (min 1) |
|
392 | - * hubert.borderiou 07-04-2011 |
|
393 | - * question without categories are not counted |
|
394 | - */ |
|
395 | - public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
375 | + $nbCatResult = 0; |
|
376 | + $quiz = new Exercise(); |
|
377 | + $quiz->read($exerciseId); |
|
378 | + $tabQuestionList = $quiz->selectQuestionList(); |
|
379 | + // the array given by selectQuestionList start at indice 1 and not at indice 0 !!! ? ? ? |
|
380 | + for ($i=1; $i <= count($tabQuestionList); $i++) { |
|
381 | + if (TestCategory::getCategoryForQuestion($tabQuestionList[$i]) == $categoryId) { |
|
382 | + $nbCatResult++; |
|
383 | + } |
|
384 | + } |
|
385 | + |
|
386 | + return $nbCatResult; |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * return the number of question for a test using random by category |
|
391 | + * input : test_id, number of random question (min 1) |
|
392 | + * hubert.borderiou 07-04-2011 |
|
393 | + * question without categories are not counted |
|
394 | + */ |
|
395 | + public static function getNumberOfQuestionRandomByCategory($exerciseId, $in_nbrandom) |
|
396 | 396 | { |
397 | - $nbquestionresult = 0; |
|
398 | - $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
399 | - for ($i=0; $i < count($tabcatid); $i++) { |
|
400 | - if ($tabcatid[$i] > 0) { // 0 = no category for this questio |
|
401 | - $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
402 | - if ($nbQuestionInThisCat > $in_nbrandom) { |
|
403 | - $nbquestionresult += $in_nbrandom; |
|
404 | - } |
|
405 | - else { |
|
406 | - $nbquestionresult += $nbQuestionInThisCat; |
|
407 | - } |
|
408 | - } |
|
409 | - } |
|
410 | - return $nbquestionresult; |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Return an array (id=>name) |
|
415 | - * tabresult[0] = get_lang('NoCategory'); |
|
397 | + $nbquestionresult = 0; |
|
398 | + $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
399 | + for ($i=0; $i < count($tabcatid); $i++) { |
|
400 | + if ($tabcatid[$i] > 0) { // 0 = no category for this questio |
|
401 | + $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
402 | + if ($nbQuestionInThisCat > $in_nbrandom) { |
|
403 | + $nbquestionresult += $in_nbrandom; |
|
404 | + } |
|
405 | + else { |
|
406 | + $nbquestionresult += $nbQuestionInThisCat; |
|
407 | + } |
|
408 | + } |
|
409 | + } |
|
410 | + return $nbquestionresult; |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Return an array (id=>name) |
|
415 | + * tabresult[0] = get_lang('NoCategory'); |
|
416 | 416 | * |
417 | 417 | * @param int $courseId |
418 | 418 | * |
419 | 419 | * @return array |
420 | - * |
|
421 | - */ |
|
420 | + * |
|
421 | + */ |
|
422 | 422 | public static function getCategoriesIdAndName($courseId = "") |
423 | 423 | { |
424 | - if (empty($courseId)) { |
|
425 | - $courseId = api_get_course_int_id(); |
|
426 | - } |
|
427 | - $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
|
428 | - $tabresult = array("0"=>get_lang('NoCategorySelected')); |
|
429 | - for ($i=0; $i < count($tabcatobject); $i++) { |
|
430 | - $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
|
431 | - } |
|
432 | - return $tabresult; |
|
433 | - } |
|
424 | + if (empty($courseId)) { |
|
425 | + $courseId = api_get_course_int_id(); |
|
426 | + } |
|
427 | + $tabcatobject = TestCategory::getCategoryListInfo("", $courseId); |
|
428 | + $tabresult = array("0"=>get_lang('NoCategorySelected')); |
|
429 | + for ($i=0; $i < count($tabcatobject); $i++) { |
|
430 | + $tabresult[$tabcatobject[$i]->id] = $tabcatobject[$i]->name; |
|
431 | + } |
|
432 | + return $tabresult; |
|
433 | + } |
|
434 | 434 | |
435 | 435 | /** |
436 | - * return an array of question_id for each category |
|
437 | - * tabres[0] = array of question id with category id = 0 (i.e. no category) |
|
438 | - * tabres[24] = array of question id with category id = 24 |
|
439 | - * In this version, a question has 0 or 1 category |
|
440 | - * |
|
441 | - * @param int $exerciseId |
|
442 | - * @return array |
|
443 | - */ |
|
436 | + * return an array of question_id for each category |
|
437 | + * tabres[0] = array of question id with category id = 0 (i.e. no category) |
|
438 | + * tabres[24] = array of question id with category id = 24 |
|
439 | + * In this version, a question has 0 or 1 category |
|
440 | + * |
|
441 | + * @param int $exerciseId |
|
442 | + * @return array |
|
443 | + */ |
|
444 | 444 | public static function getQuestionsByCat($exerciseId) |
445 | 445 | { |
446 | 446 | $em = Database::getManager(); |
@@ -469,29 +469,29 @@ discard block |
||
469 | 469 | } |
470 | 470 | $list[$data['categoryId']][] = $data['questionId']; |
471 | 471 | } |
472 | - return $list; |
|
473 | - } |
|
472 | + return $list; |
|
473 | + } |
|
474 | 474 | |
475 | - /** |
|
476 | - * return a tab of $in_number random elements of $in_tab |
|
477 | - */ |
|
475 | + /** |
|
476 | + * return a tab of $in_number random elements of $in_tab |
|
477 | + */ |
|
478 | 478 | public static function getNElementsFromArray($in_tab, $in_number) |
479 | 479 | { |
480 | - $tabres = $in_tab; |
|
481 | - shuffle($tabres); |
|
482 | - if ($in_number < count($tabres)) { |
|
483 | - $tabres = array_slice($tabres, 0, $in_number); |
|
484 | - } |
|
485 | - return $tabres; |
|
486 | - } |
|
487 | - |
|
488 | - /** |
|
489 | - * display the category |
|
490 | - */ |
|
491 | - public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1) |
|
480 | + $tabres = $in_tab; |
|
481 | + shuffle($tabres); |
|
482 | + if ($in_number < count($tabres)) { |
|
483 | + $tabres = array_slice($tabres, 0, $in_number); |
|
484 | + } |
|
485 | + return $tabres; |
|
486 | + } |
|
487 | + |
|
488 | + /** |
|
489 | + * display the category |
|
490 | + */ |
|
491 | + public static function displayCategoryAndTitle($questionId, $in_display_category_name = 1) |
|
492 | 492 | { |
493 | 493 | echo self::returnCategoryAndTitle($questionId, $in_display_category_name); |
494 | - } |
|
494 | + } |
|
495 | 495 | |
496 | 496 | /** |
497 | 497 | * @param int $questionId |
@@ -507,71 +507,71 @@ discard block |
||
507 | 507 | $in_display_category_name = $objExercise->display_category_name; |
508 | 508 | } |
509 | 509 | $content = null; |
510 | - if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) { |
|
510 | + if (TestCategory::getCategoryNameForQuestion($questionId) != "" && ($in_display_category_name == 1 || !$is_student)) { |
|
511 | 511 | $content .= '<div class="page-header">'; |
512 | 512 | $content .= '<h4>'.get_lang('Category').": ".TestCategory::getCategoryNameForQuestion($questionId).'</h4>'; |
513 | 513 | $content .= "</div>"; |
514 | - } |
|
514 | + } |
|
515 | 515 | return $content; |
516 | - } |
|
516 | + } |
|
517 | 517 | |
518 | 518 | /** |
519 | - * Display signs [+] and/or (>0) after question title if question has options |
|
520 | - * scoreAlwaysPositive and/or uncheckedMayScore |
|
521 | - */ |
|
519 | + * Display signs [+] and/or (>0) after question title if question has options |
|
520 | + * scoreAlwaysPositive and/or uncheckedMayScore |
|
521 | + */ |
|
522 | 522 | public function displayQuestionOption($in_objQuestion) |
523 | 523 | { |
524 | - if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
|
525 | - echo "<span style='font-size:75%'> (>0)</span>"; |
|
526 | - } |
|
527 | - if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) { |
|
528 | - echo "<span style='font-size:75%'> [+]</span>"; |
|
529 | - } |
|
530 | - } |
|
531 | - |
|
532 | - /** |
|
533 | - * sortTabByBracketLabel ($tabCategoryQuestions) |
|
534 | - * key of $tabCategoryQuestions are the category id (0 for not in a category) |
|
535 | - * value is the array of question id of this category |
|
536 | - * Sort question by Category |
|
537 | - */ |
|
524 | + if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->scoreAlwaysPositive) { |
|
525 | + echo "<span style='font-size:75%'> (>0)</span>"; |
|
526 | + } |
|
527 | + if ($in_objQuestion->type == MULTIPLE_ANSWER && $in_objQuestion->uncheckedMayScore) { |
|
528 | + echo "<span style='font-size:75%'> [+]</span>"; |
|
529 | + } |
|
530 | + } |
|
531 | + |
|
532 | + /** |
|
533 | + * sortTabByBracketLabel ($tabCategoryQuestions) |
|
534 | + * key of $tabCategoryQuestions are the category id (0 for not in a category) |
|
535 | + * value is the array of question id of this category |
|
536 | + * Sort question by Category |
|
537 | + */ |
|
538 | 538 | public static function sortTabByBracketLabel($in_tab) |
539 | 539 | { |
540 | - $tabResult = array(); |
|
541 | - $tabCatName = array(); // tab of category name |
|
542 | - while (list($cat_id, $tabquestion) = each($in_tab)) { |
|
543 | - $catTitle = new TestCategory($cat_id); |
|
544 | - $tabCatName[$cat_id] = $catTitle->name; |
|
545 | - } |
|
546 | - reset($in_tab); |
|
547 | - // sort table by value, keeping keys as they are |
|
548 | - asort($tabCatName); |
|
549 | - // keys of $tabCatName are keys order for $in_tab |
|
550 | - while (list($key, $val) = each($tabCatName)) { |
|
551 | - $tabResult[$key] = $in_tab[$key]; |
|
552 | - } |
|
553 | - return $tabResult; |
|
554 | - } |
|
540 | + $tabResult = array(); |
|
541 | + $tabCatName = array(); // tab of category name |
|
542 | + while (list($cat_id, $tabquestion) = each($in_tab)) { |
|
543 | + $catTitle = new TestCategory($cat_id); |
|
544 | + $tabCatName[$cat_id] = $catTitle->name; |
|
545 | + } |
|
546 | + reset($in_tab); |
|
547 | + // sort table by value, keeping keys as they are |
|
548 | + asort($tabCatName); |
|
549 | + // keys of $tabCatName are keys order for $in_tab |
|
550 | + while (list($key, $val) = each($tabCatName)) { |
|
551 | + $tabResult[$key] = $in_tab[$key]; |
|
552 | + } |
|
553 | + return $tabResult; |
|
554 | + } |
|
555 | 555 | |
556 | 556 | /** |
557 | 557 | * return the number max of question in a category |
558 | 558 | * count the number of questions in all categories, and return the max |
559 | 559 | * @param int $exerciseId |
560 | 560 | * @author - hubert borderiou |
561 | - */ |
|
561 | + */ |
|
562 | 562 | public static function getNumberMaxQuestionByCat($exerciseId) |
563 | 563 | { |
564 | 564 | $res_num_max = 0; |
565 | 565 | // foreach question |
566 | - $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
567 | - for ($i=0; $i < count($tabcatid); $i++) { |
|
568 | - if ($tabcatid[$i] > 0) { // 0 = no category for this question |
|
569 | - $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
566 | + $tabcatid = TestCategory::getListOfCategoriesIDForTest($exerciseId); |
|
567 | + for ($i=0; $i < count($tabcatid); $i++) { |
|
568 | + if ($tabcatid[$i] > 0) { // 0 = no category for this question |
|
569 | + $nbQuestionInThisCat = TestCategory::getNumberOfQuestionsInCategoryForTest($exerciseId, $tabcatid[$i]); |
|
570 | 570 | if ($nbQuestionInThisCat > $res_num_max) { |
571 | 571 | $res_num_max = $nbQuestionInThisCat; |
572 | 572 | } |
573 | - } |
|
574 | - } |
|
573 | + } |
|
574 | + } |
|
575 | 575 | return $res_num_max; |
576 | 576 | } |
577 | 577 | |
@@ -677,8 +677,8 @@ discard block |
||
677 | 677 | * @param int $categoryId |
678 | 678 | * @param int $questionId |
679 | 679 | * @param int $courseId |
680 | - * |
|
681 | - * @return int |
|
680 | + * |
|
681 | + * @return int |
|
682 | 682 | */ |
683 | 683 | public static function add_category_for_question_id($categoryId, $questionId, $courseId) |
684 | 684 | { |
@@ -686,18 +686,18 @@ discard block |
||
686 | 686 | // if question doesn't have a category |
687 | 687 | // @todo change for 1.10 when a question can have several categories |
688 | 688 | if (TestCategory::getCategoryForQuestion($questionId, $courseId) == 0 && |
689 | - $questionId > 0 && |
|
690 | - $courseId > 0 |
|
689 | + $questionId > 0 && |
|
690 | + $courseId > 0 |
|
691 | 691 | ) { |
692 | 692 | $sql = "INSERT INTO $table (c_id, question_id, category_id) |
693 | 693 | VALUES (".intval($courseId).", ".intval($questionId).", ".intval($categoryId).")"; |
694 | 694 | Database::query($sql); |
695 | - $id = Database::insert_id(); |
|
695 | + $id = Database::insert_id(); |
|
696 | 696 | |
697 | - return $id; |
|
697 | + return $id; |
|
698 | 698 | } |
699 | 699 | |
700 | - return false; |
|
700 | + return false; |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | $locked = api_resource_is_locked_by_gradebook($exercise_id, LINK_EXERCISE); |
93 | 93 | |
94 | 94 | if (empty($objExercise)) { |
95 | - $objExercise = new Exercise(); |
|
95 | + $objExercise = new Exercise(); |
|
96 | 96 | $objExercise->read($exercise_id); |
97 | 97 | } |
98 | 98 | $feedback_type = $objExercise->feedback_type; |
@@ -100,16 +100,16 @@ discard block |
||
100 | 100 | //Only users can see their own results |
101 | 101 | if (!$is_allowedToEdit) { |
102 | 102 | if ($student_id != $current_user_id) { |
103 | - api_not_allowed(true); |
|
103 | + api_not_allowed(true); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | 107 | if (isset($_SESSION['gradebook'])) { |
108 | - $gradebook= Security::remove_XSS($_SESSION['gradebook']); |
|
108 | + $gradebook= Security::remove_XSS($_SESSION['gradebook']); |
|
109 | 109 | } |
110 | 110 | |
111 | 111 | if (!empty($gradebook) && $gradebook=='view') { |
112 | - $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); |
|
112 | + $interbreadcrumb[]= array ('url' => '../gradebook/'.$_SESSION['gradebook_dest'],'name' => get_lang('ToolGradebook')); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | $fromlink = ''; |
@@ -124,14 +124,14 @@ discard block |
||
124 | 124 | $htmlHeadXtra[] = '<script src="' . api_get_path(WEB_LIBRARY_JS_PATH) . 'hotspot/js/hotspot.js"></script>'; |
125 | 125 | |
126 | 126 | if ($origin != 'learnpath') { |
127 | - Display::display_header(''); |
|
127 | + Display::display_header(''); |
|
128 | 128 | } else { |
129 | 129 | $htmlHeadXtra[] = " |
130 | 130 | <style> |
131 | 131 | body { background: none;} |
132 | 132 | </style> |
133 | 133 | "; |
134 | - Display::display_reduced_header(); |
|
134 | + Display::display_reduced_header(); |
|
135 | 135 | } |
136 | 136 | ?> |
137 | 137 | <script> |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | } |
211 | 211 | } |
212 | 212 | } else { |
213 | - Display::display_warning_message(get_lang('CantViewResults')); |
|
214 | - $show_results = false; |
|
213 | + Display::display_warning_message(get_lang('CantViewResults')); |
|
214 | + $show_results = false; |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | if ($origin == 'learnpath' && !isset($_GET['fb_type']) ) { |
218 | - $show_results = false; |
|
218 | + $show_results = false; |
|
219 | 219 | } |
220 | 220 | |
221 | 221 | if ($show_results || $show_only_total_score) { |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | $exerciseResult = array(); |
261 | 261 | |
262 | 262 | while ($row = Database::fetch_array($result)) { |
263 | - $question_list_from_database[] = $row['question_id']; |
|
264 | - $exerciseResult[$row['question_id']] = $row['answer']; |
|
263 | + $question_list_from_database[] = $row['question_id']; |
|
264 | + $exerciseResult[$row['question_id']] = $row['answer']; |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | //Fixing #2073 Fixing order of questions |
268 | 268 | if (!empty($track_exercise_info['data_tracking'])) { |
269 | - $temp_question_list = explode(',', $track_exercise_info['data_tracking']); |
|
269 | + $temp_question_list = explode(',', $track_exercise_info['data_tracking']); |
|
270 | 270 | |
271 | 271 | // Getting question list from data_tracking |
272 | 272 | if (!empty($temp_question_list)) { |
@@ -306,64 +306,64 @@ discard block |
||
306 | 306 | |
307 | 307 | foreach ($questionList as $questionId) { |
308 | 308 | |
309 | - $choice = $exerciseResult[$questionId]; |
|
310 | - // destruction of the Question object |
|
311 | - unset($objQuestionTmp); |
|
309 | + $choice = $exerciseResult[$questionId]; |
|
310 | + // destruction of the Question object |
|
311 | + unset($objQuestionTmp); |
|
312 | 312 | |
313 | - // creates a temporary Question object |
|
314 | - $objQuestionTmp = Question::read($questionId); |
|
315 | - $questionWeighting = $objQuestionTmp->selectWeighting(); |
|
316 | - $answerType = $objQuestionTmp->selectType(); |
|
313 | + // creates a temporary Question object |
|
314 | + $objQuestionTmp = Question::read($questionId); |
|
315 | + $questionWeighting = $objQuestionTmp->selectWeighting(); |
|
316 | + $answerType = $objQuestionTmp->selectType(); |
|
317 | 317 | |
318 | - // Start buffer |
|
318 | + // Start buffer |
|
319 | 319 | ob_start(); |
320 | 320 | |
321 | 321 | /* Use switch |
322 | 322 | switch ($answerType) { |
323 | 323 | }*/ |
324 | 324 | |
325 | - if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { |
|
325 | + if ($answerType == MULTIPLE_ANSWER || $answerType == MULTIPLE_ANSWER_TRUE_FALSE) { |
|
326 | 326 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
327 | 327 | $questionScore = $question_result['score']; |
328 | 328 | $totalScore += $question_result['score']; |
329 | - } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { |
|
330 | - $choice = array(); |
|
329 | + } elseif ($answerType == MULTIPLE_ANSWER_COMBINATION || $answerType == MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE) { |
|
330 | + $choice = array(); |
|
331 | + $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
|
332 | + $questionScore = $question_result['score']; |
|
333 | + $totalScore += $question_result['score']; |
|
334 | + } elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) { |
|
331 | 335 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
332 | 336 | $questionScore = $question_result['score']; |
333 | 337 | $totalScore += $question_result['score']; |
334 | - } elseif ($answerType == UNIQUE_ANSWER || $answerType == UNIQUE_ANSWER_NO_OPTION) { |
|
338 | + echo '</table>'; |
|
339 | + } elseif ($answerType == FILL_IN_BLANKS) { |
|
335 | 340 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
336 | 341 | $questionScore = $question_result['score']; |
337 | 342 | $totalScore += $question_result['score']; |
338 | - echo '</table>'; |
|
339 | - } elseif ($answerType == FILL_IN_BLANKS) { |
|
343 | + } elseif ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
340 | 344 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
341 | 345 | $questionScore = $question_result['score']; |
342 | 346 | $totalScore += $question_result['score']; |
343 | - } elseif ($answerType == GLOBAL_MULTIPLE_ANSWER) { |
|
347 | + } elseif ($answerType == FREE_ANSWER) { |
|
348 | + $answer = $str; |
|
344 | 349 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
345 | 350 | $questionScore = $question_result['score']; |
346 | 351 | $totalScore += $question_result['score']; |
347 | - } elseif ($answerType == FREE_ANSWER) { |
|
352 | + } elseif ($answerType == ORAL_EXPRESSION) { |
|
348 | 353 | $answer = $str; |
349 | 354 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
350 | 355 | $questionScore = $question_result['score']; |
351 | 356 | $totalScore += $question_result['score']; |
352 | - } elseif ($answerType == ORAL_EXPRESSION) { |
|
353 | - $answer = $str; |
|
354 | - $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
|
355 | - $questionScore = $question_result['score']; |
|
356 | - $totalScore += $question_result['score']; |
|
357 | 357 | } elseif (in_array($answerType, [MATCHING, DRAGGABLE, MATCHING_DRAGGABLE])) { |
358 | 358 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
359 | 359 | $questionScore = $question_result['score']; |
360 | 360 | $totalScore += $question_result['score']; |
361 | - } elseif ($answerType == HOT_SPOT) { |
|
362 | - if ($show_results) { |
|
363 | - echo '<table width="500" border="0"><tr> |
|
361 | + } elseif ($answerType == HOT_SPOT) { |
|
362 | + if ($show_results) { |
|
363 | + echo '<table width="500" border="0"><tr> |
|
364 | 364 | <td valign="top" align="center" style="padding-left:0px;" > |
365 | 365 | <table border="1" bordercolor="#A4A4A4" style="border-collapse: collapse;" width="552">'; |
366 | - } |
|
366 | + } |
|
367 | 367 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg()); |
368 | 368 | $questionScore = $question_result['score']; |
369 | 369 | $totalScore += $question_result['score']; |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | <br> |
393 | 393 | "; |
394 | 394 | } |
395 | - } else if($answerType == HOT_SPOT_DELINEATION) { |
|
395 | + } else if($answerType == HOT_SPOT_DELINEATION) { |
|
396 | 396 | |
397 | 397 | $question_result = $objExercise->manage_answer($id, $questionId, $choice,'exercise_show', array(), false, true, $show_results, $objExercise->selectPropagateNeg(), 'database'); |
398 | 398 | |
@@ -535,15 +535,15 @@ discard block |
||
535 | 535 | </table> |
536 | 536 | "; |
537 | 537 | } |
538 | - } |
|
538 | + } |
|
539 | 539 | |
540 | - if ($show_results) { |
|
541 | - if ($answerType != HOT_SPOT) { |
|
542 | - echo '</table>'; |
|
543 | - } |
|
544 | - } |
|
540 | + if ($show_results) { |
|
541 | + if ($answerType != HOT_SPOT) { |
|
542 | + echo '</table>'; |
|
543 | + } |
|
544 | + } |
|
545 | 545 | |
546 | - $comnt = null; |
|
546 | + $comnt = null; |
|
547 | 547 | |
548 | 548 | if ($show_results) { |
549 | 549 | if ( |
@@ -560,40 +560,40 @@ discard block |
||
560 | 560 | |
561 | 561 | $marksname = ''; |
562 | 562 | |
563 | - if ($isFeedbackAllowed) { |
|
564 | - $name = "fckdiv".$questionId; |
|
565 | - $marksname = "marksName".$questionId; |
|
566 | - if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
567 | - $url_name = get_lang('EditCommentsAndMarks'); |
|
568 | - } else { |
|
569 | - if ($action=='edit') { |
|
570 | - $url_name = get_lang('EditIndividualComment'); |
|
571 | - } else { |
|
572 | - $url_name = get_lang('AddComments'); |
|
573 | - } |
|
574 | - } |
|
563 | + if ($isFeedbackAllowed) { |
|
564 | + $name = "fckdiv".$questionId; |
|
565 | + $marksname = "marksName".$questionId; |
|
566 | + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
567 | + $url_name = get_lang('EditCommentsAndMarks'); |
|
568 | + } else { |
|
569 | + if ($action=='edit') { |
|
570 | + $url_name = get_lang('EditIndividualComment'); |
|
571 | + } else { |
|
572 | + $url_name = get_lang('AddComments'); |
|
573 | + } |
|
574 | + } |
|
575 | 575 | echo '<br />'; |
576 | 576 | echo Display::url($url_name, 'javascript://', array('class' => 'btn', 'onclick'=>"showfck('".$name."', '".$marksname."');")); |
577 | - echo '<br />'; |
|
577 | + echo '<br />'; |
|
578 | 578 | |
579 | 579 | echo '<div id="feedback_'.$name.'" style="width:100%">'; |
580 | - $comnt = trim(Event::get_comments($id, $questionId)); |
|
581 | - if (empty($comnt)) { |
|
582 | - echo '<br />'; |
|
583 | - } else { |
|
584 | - echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
585 | - } |
|
586 | - echo '</div>'; |
|
580 | + $comnt = trim(Event::get_comments($id, $questionId)); |
|
581 | + if (empty($comnt)) { |
|
582 | + echo '<br />'; |
|
583 | + } else { |
|
584 | + echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
585 | + } |
|
586 | + echo '</div>'; |
|
587 | 587 | |
588 | 588 | echo '<div id="'.$name.'" style="display:none">'; |
589 | - $arrid[] = $questionId; |
|
590 | - $feedback_form = new FormValidator('frmcomments'.$questionId,'post',''); |
|
591 | - $feedback_form->addElement('html','<br>'); |
|
592 | - $renderer =& $feedback_form->defaultRenderer(); |
|
593 | - $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>'); |
|
594 | - $renderer->setCustomElementTemplate('<div align="left">{element}</div>'); |
|
595 | - $comnt = Event::get_comments($id, $questionId); |
|
596 | - $default = array('comments_'.$questionId => $comnt); |
|
589 | + $arrid[] = $questionId; |
|
590 | + $feedback_form = new FormValidator('frmcomments'.$questionId,'post',''); |
|
591 | + $feedback_form->addElement('html','<br>'); |
|
592 | + $renderer =& $feedback_form->defaultRenderer(); |
|
593 | + $renderer->setFormTemplate('<form{attributes}><div align="left">{content}</div></form>'); |
|
594 | + $renderer->setCustomElementTemplate('<div align="left">{element}</div>'); |
|
595 | + $comnt = Event::get_comments($id, $questionId); |
|
596 | + $default = array('comments_'.$questionId => $comnt); |
|
597 | 597 | |
598 | 598 | if ($useAdvancedEditor) { |
599 | 599 | $feedback_form->addElement( |
@@ -610,52 +610,52 @@ discard block |
||
610 | 610 | } else { |
611 | 611 | $feedback_form->addElement('textarea', 'comments_' . $questionId); |
612 | 612 | } |
613 | - $feedback_form->addElement('html','<br>'); |
|
614 | - $feedback_form->setDefaults($default); |
|
615 | - $feedback_form->display(); |
|
616 | - echo '</div>'; |
|
617 | - |
|
618 | - } else { |
|
619 | - $comnt = Event::get_comments($id, $questionId); |
|
620 | - echo '<br />'; |
|
621 | - if (!empty($comnt)) { |
|
622 | - echo '<b>'.get_lang('Feedback').'</b>'; |
|
623 | - echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
624 | - } |
|
625 | - } |
|
626 | - |
|
627 | - if ($is_allowedToEdit && $isFeedbackAllowed) { |
|
628 | - if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
629 | - $marksname = "marksName".$questionId; |
|
613 | + $feedback_form->addElement('html','<br>'); |
|
614 | + $feedback_form->setDefaults($default); |
|
615 | + $feedback_form->display(); |
|
616 | + echo '</div>'; |
|
617 | + |
|
618 | + } else { |
|
619 | + $comnt = Event::get_comments($id, $questionId); |
|
620 | + echo '<br />'; |
|
621 | + if (!empty($comnt)) { |
|
622 | + echo '<b>'.get_lang('Feedback').'</b>'; |
|
623 | + echo '<div id="question_feedback">'.$comnt.'</div>'; |
|
624 | + } |
|
625 | + } |
|
626 | + |
|
627 | + if ($is_allowedToEdit && $isFeedbackAllowed) { |
|
628 | + if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) { |
|
629 | + $marksname = "marksName".$questionId; |
|
630 | 630 | echo '<div id="'.$marksname.'" style="display:none">'; |
631 | 631 | echo '<form name="marksform_'.$questionId.'" method="post" action="">'; |
632 | - $arrmarks[] = $questionId; |
|
633 | - echo get_lang("AssignMarks"); |
|
634 | - echo " <select name='marks' id='marks'>"; |
|
635 | - for ($i=0;$i<=$questionWeighting;$i++) { |
|
636 | - echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>'; |
|
637 | - } |
|
638 | - echo '</select>'; |
|
639 | - echo '</form><br /></div>'; |
|
640 | - |
|
641 | - if ($questionScore == -1 ) { |
|
642 | - $questionScore = 0; |
|
643 | - echo Display::return_message(get_lang('notCorrectedYet')); |
|
644 | - } |
|
645 | - } else { |
|
646 | - $arrmarks[] = $questionId; |
|
647 | - echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action=""> |
|
632 | + $arrmarks[] = $questionId; |
|
633 | + echo get_lang("AssignMarks"); |
|
634 | + echo " <select name='marks' id='marks'>"; |
|
635 | + for ($i=0;$i<=$questionWeighting;$i++) { |
|
636 | + echo '<option '.(($i==$questionScore)?"selected='selected'":'').'>'.$i.'</option>'; |
|
637 | + } |
|
638 | + echo '</select>'; |
|
639 | + echo '</form><br /></div>'; |
|
640 | + |
|
641 | + if ($questionScore == -1 ) { |
|
642 | + $questionScore = 0; |
|
643 | + echo Display::return_message(get_lang('notCorrectedYet')); |
|
644 | + } |
|
645 | + } else { |
|
646 | + $arrmarks[] = $questionId; |
|
647 | + echo '<div id="'.$marksname.'" style="display:none"><form name="marksform_'.$questionId.'" method="post" action=""> |
|
648 | 648 | <select name="marks" id="marks" style="display:none;"><option>'.$questionScore.'</option></select></form><br/ ></div>'; |
649 | - } |
|
650 | - } else { |
|
651 | - if ($questionScore == -1) { |
|
652 | - $questionScore = 0; |
|
653 | - } |
|
654 | - } |
|
655 | - } |
|
649 | + } |
|
650 | + } else { |
|
651 | + if ($questionScore == -1) { |
|
652 | + $questionScore = 0; |
|
653 | + } |
|
654 | + } |
|
655 | + } |
|
656 | 656 | |
657 | 657 | $my_total_score = $questionScore; |
658 | - $my_total_weight = $questionWeighting; |
|
658 | + $my_total_weight = $questionWeighting; |
|
659 | 659 | $totalWeighting += $questionWeighting; |
660 | 660 | $category_was_added_for_this_test = false; |
661 | 661 | |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | |
702 | 702 | $score = array(); |
703 | 703 | if ($show_results) { |
704 | - $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false); |
|
704 | + $score['result'] = get_lang('Score')." : ".ExerciseLib::show_score($my_total_score, $my_total_weight, false, false); |
|
705 | 705 | $score['pass'] = $my_total_score >= $my_total_weight ? true : false; |
706 | 706 | $score['type'] = $answerType; |
707 | 707 | $score['score'] = $my_total_score; |
@@ -709,18 +709,18 @@ discard block |
||
709 | 709 | $score['comments'] = isset($comnt) ? $comnt : null; |
710 | 710 | } |
711 | 711 | |
712 | - unset($objAnswerTmp); |
|
713 | - $i++; |
|
712 | + unset($objAnswerTmp); |
|
713 | + $i++; |
|
714 | 714 | |
715 | 715 | $contents = ob_get_clean(); |
716 | 716 | |
717 | 717 | $question_content = '<div class="question_row">'; |
718 | 718 | |
719 | - if ($show_results) { |
|
719 | + if ($show_results) { |
|
720 | 720 | //Shows question title an description |
721 | - $question_content .= $objQuestionTmp->return_header(null, $counter, $score); |
|
722 | - } |
|
723 | - $counter++; |
|
721 | + $question_content .= $objQuestionTmp->return_header(null, $counter, $score); |
|
722 | + } |
|
723 | + $counter++; |
|
724 | 724 | $question_content .= $contents; |
725 | 725 | $question_content .= '</div>'; |
726 | 726 | $exercise_content .= $question_content; |
@@ -730,12 +730,12 @@ discard block |
||
730 | 730 | |
731 | 731 | //Total score |
732 | 732 | if ($origin!='learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { |
733 | - if ($show_results || $show_only_total_score) { |
|
733 | + if ($show_results || $show_only_total_score) { |
|
734 | 734 | $total_score_text .= '<div class="question_row">'; |
735 | 735 | $my_total_score_temp = $totalScore; |
736 | - if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { |
|
737 | - $my_total_score_temp = 0; |
|
738 | - } |
|
736 | + if ($objExercise->selectPropagateNeg() == 0 && $my_total_score_temp < 0) { |
|
737 | + $my_total_score_temp = 0; |
|
738 | + } |
|
739 | 739 | $total_score_text .= ExerciseLib::get_question_ribbon( |
740 | 740 | $objExercise, |
741 | 741 | $my_total_score_temp, |
@@ -743,7 +743,7 @@ discard block |
||
743 | 743 | true |
744 | 744 | ); |
745 | 745 | $total_score_text .= '</div>'; |
746 | - } |
|
746 | + } |
|
747 | 747 | } |
748 | 748 | |
749 | 749 | if (!empty($category_list) && ($show_results || $show_only_total_score)) { |
@@ -767,25 +767,25 @@ discard block |
||
767 | 767 | } |
768 | 768 | |
769 | 769 | if ($isFeedbackAllowed) { |
770 | - if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) { |
|
771 | - echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">'; |
|
772 | - echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">'; |
|
773 | - echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">'; |
|
774 | - echo '<input type = "hidden" name="student_id" value="'.$student_id.'">'; |
|
775 | - echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> '; |
|
776 | - echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> '; |
|
777 | - } else { |
|
778 | - echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">'; |
|
779 | - } |
|
780 | - if ($origin !='learnpath' && $origin!='student_progress') { |
|
770 | + if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) { |
|
771 | + echo '<form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">'; |
|
772 | + echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">'; |
|
773 | + echo '<input type = "hidden" name="lp_item_view_id" value="'.$lp_item_view_id.'">'; |
|
774 | + echo '<input type = "hidden" name="student_id" value="'.$student_id.'">'; |
|
775 | + echo '<input type = "hidden" name="total_score" value="'.$totalScore.'"> '; |
|
776 | + echo '<input type = "hidden" name="my_exe_exo_id" value="'.$exercise_id.'"> '; |
|
777 | + } else { |
|
778 | + echo ' <form name="myform" id="myform" action="'.api_get_path(WEB_CODE_PATH).'exercice/exercise_report.php?'.api_get_cidreq().'&exerciseId='.$exercise_id.'&filter=1&comments=update&exeid='.$id.'" method="post">'; |
|
779 | + } |
|
780 | + if ($origin !='learnpath' && $origin!='student_progress') { |
|
781 | 781 | echo '<label><input type= "checkbox" name="send_notification"> '.get_lang('SendEmail').'</label>'; |
782 | - ?> |
|
782 | + ?> |
|
783 | 783 | <button type="submit" class="btn btn-primary" value="<?php echo get_lang('Ok'); ?>" onclick="getFCK('<?php echo $strids; ?>','<?php echo $marksid; ?>');"> |
784 | 784 | <?php echo get_lang('CorrectTest'); ?> |
785 | 785 | </button> |
786 | 786 | </form> |
787 | 787 | <?php |
788 | - } |
|
788 | + } |
|
789 | 789 | } |
790 | 790 | |
791 | 791 | //Came from lpstats in a lp |
@@ -802,21 +802,21 @@ discard block |
||
802 | 802 | } |
803 | 803 | |
804 | 804 | if ($origin != 'learnpath') { |
805 | - //we are not in learnpath tool |
|
806 | - Display::display_footer(); |
|
805 | + //we are not in learnpath tool |
|
806 | + Display::display_footer(); |
|
807 | 807 | } else { |
808 | - if (!isset($_GET['fb_type'])) { |
|
809 | - $lp_mode = $_SESSION['lp_mode']; |
|
810 | - $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type; |
|
811 | - $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; |
|
812 | - echo '<script type="text/javascript">'.$href.'</script>'; |
|
813 | - // Record the results in the learning path, using the SCORM interface (API) |
|
814 | - echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>"; |
|
815 | - echo '</body></html>'; |
|
816 | - } else { |
|
817 | - Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu')); |
|
808 | + if (!isset($_GET['fb_type'])) { |
|
809 | + $lp_mode = $_SESSION['lp_mode']; |
|
810 | + $url = '../newscorm/lp_controller.php?'.api_get_cidreq().'&action=view&lp_id='.$learnpath_id.'&lp_item_id='.$learnpath_item_id.'&exeId='.$exeId.'&fb_type='.$feedback_type; |
|
811 | + $href = ($lp_mode == 'fullscreen')?' window.opener.location.href="'.$url.'" ':' top.location.href="'.$url.'" '; |
|
812 | + echo '<script type="text/javascript">'.$href.'</script>'; |
|
813 | + // Record the results in the learning path, using the SCORM interface (API) |
|
814 | + echo "<script>window.parent.API.void_save_asset('$totalScore', '$totalWeighting', 0, 'completed'); </script>"; |
|
815 | + echo '</body></html>'; |
|
816 | + } else { |
|
817 | + Display::display_normal_message(get_lang('ExerciseFinished').' '.get_lang('ToContinueUseMenu')); |
|
818 | 818 | echo '<br />'; |
819 | - } |
|
819 | + } |
|
820 | 820 | } |
821 | 821 | |
822 | 822 | // Destroying the session |