@@ -25,16 +25,16 @@ |
||
25 | 25 | $audioFileName = Database::escape_string($audioFileName); |
26 | 26 | $audioFileName = api_replace_dangerous_char($audioFileName); |
27 | 27 | $audioFileName = disable_dangerous_file($audioFileName); |
28 | -$audioDir = Security::remove_XSS($audioDir); |
|
28 | +$audioDir = Security::remove_XSS($audioDir); |
|
29 | 29 | |
30 | -$dirBaseDocuments = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document'; |
|
31 | -$saveDir = $dirBaseDocuments . $audioDir; |
|
30 | +$dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$courseInfo['path'].'/document'; |
|
31 | +$saveDir = $dirBaseDocuments.$audioDir; |
|
32 | 32 | |
33 | 33 | if (!is_dir($saveDir)) { |
34 | 34 | DocumentManager::createDefaultAudioFolder($courseInfo); |
35 | 35 | } |
36 | 36 | |
37 | -$documentPath = $saveDir . '/' . $audioFileName; |
|
37 | +$documentPath = $saveDir.'/'.$audioFileName; |
|
38 | 38 | |
39 | 39 | $file['file'] = $file; |
40 | 40 |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | // Do not use here check Fileinfo method because return: text/plain |
49 | 49 | |
50 | 50 | $dirBaseDocuments = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
51 | -$saveDir = $dirBaseDocuments . $wamidir; |
|
51 | +$saveDir = $dirBaseDocuments.$wamidir; |
|
52 | 52 | |
53 | 53 | if (!is_dir($saveDir)) { |
54 | 54 | DocumentManager::createDefaultAudioFolder($_course); |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | ob_start(); |
89 | 89 | |
90 | 90 | // Strangely the file path changes with a double extension |
91 | -copy($documentPath, $documentPath . '.wav'); |
|
91 | +copy($documentPath, $documentPath.'.wav'); |
|
92 | 92 | |
93 | 93 | $documentData = DocumentManager::upload_document( |
94 | 94 | $file, |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | ); |
150 | 150 | } |
151 | 151 | } else { |
152 | - foreach($document_data['parents'] as $document_sub_data) { |
|
153 | - if (!isset($_GET['createdir']) && $document_sub_data['id'] == $document_data['id']) { |
|
152 | + foreach ($document_data['parents'] as $document_sub_data) { |
|
153 | + if (!isset($_GET['createdir']) && $document_sub_data['id'] == $document_data['id']) { |
|
154 | 154 | $document_sub_data['document_url'] = '#'; |
155 | 155 | } |
156 | 156 | $interbreadcrumb[] = array( |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | } |
181 | 181 | $js_glossary_in_documents = ''; |
182 | 182 | |
183 | -$js_glossary_in_documents = ' |
|
183 | +$js_glossary_in_documents = ' |
|
184 | 184 | $.frameReady(function(){ |
185 | 185 | // $("<div>I am a div courses</div>").prependTo("body"); |
186 | 186 | }, "top.mainFrame", |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | // PDF should be displayed with viewerJS |
201 | 201 | $web_odf_supported_files[] = 'pdf'; |
202 | 202 | if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) { |
203 | - $show_web_odf = true; |
|
203 | + $show_web_odf = true; |
|
204 | 204 | /* |
205 | 205 | $htmlHeadXtra[] = api_get_js('webodf/webodf.js'); |
206 | 206 | $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/webodf/webodf.css'); |
@@ -243,7 +243,7 @@ discard block |
||
243 | 243 | $htmlHeadXtra[] = api_get_js('highlight/highlight.pack.js'); |
244 | 244 | $htmlHeadXtra[] = api_get_css(api_get_path(WEB_CSS_PATH).'chat.css'); |
245 | 245 | $htmlHeadXtra[] = api_get_css( |
246 | - api_get_path(WEB_LIBRARY_PATH) . 'javascript/highlight/styles/github.css' |
|
246 | + api_get_path(WEB_LIBRARY_PATH).'javascript/highlight/styles/github.css' |
|
247 | 247 | ); |
248 | 248 | $htmlHeadXtra[] = ' |
249 | 249 | <script> |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | $execute_iframe = true; |
255 | 255 | if ($jplayer_supported) { |
256 | 256 | $extension = api_strtolower($pathinfo['extension']); |
257 | - if ($extension == 'mp4') { |
|
257 | + if ($extension == 'mp4') { |
|
258 | 258 | $extension = 'm4v'; |
259 | 259 | } |
260 | 260 | $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | $execute_iframe = false; |
296 | 296 | } |
297 | 297 | |
298 | -$is_freemind_available = $pathinfo['extension']=='mm' && api_get_setting('enable_freemind') == 'true'; |
|
298 | +$is_freemind_available = $pathinfo['extension'] == 'mm' && api_get_setting('enable_freemind') == 'true'; |
|
299 | 299 | if ($is_freemind_available) { |
300 | 300 | $execute_iframe = false; |
301 | 301 | } |
@@ -339,18 +339,18 @@ discard block |
||
339 | 339 | $file_url_web = $file_url.'?'.api_get_cidreq(); |
340 | 340 | |
341 | 341 | if (in_array(strtolower($pathinfo['extension']), array('html', "htm"))) { |
342 | - echo '<a class="btn btn-default" href="' . $file_url_web . '" target="_blank">' . get_lang('CutPasteLink') . '</a>'; |
|
342 | + echo '<a class="btn btn-default" href="'.$file_url_web.'" target="_blank">'.get_lang('CutPasteLink').'</a>'; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | if ($show_web_odf) { |
346 | 346 | $browser = api_get_navigator(); |
347 | - $pdfUrl = api_get_path(WEB_LIBRARY_PATH) . 'javascript/ViewerJS/index.html#' . $file_url; |
|
347 | + $pdfUrl = api_get_path(WEB_LIBRARY_PATH).'javascript/ViewerJS/index.html#'.$file_url; |
|
348 | 348 | if ($browser['name'] == 'Mozilla' && preg_match('|.*\.pdf|i', $header_file)) { |
349 | 349 | $pdfUrl = $file_url; |
350 | 350 | } |
351 | 351 | echo '<div id="viewerJS">'; |
352 | 352 | echo '<iframe id="viewerJSContent" frameborder="0" allowfullscreen="allowfullscreen" webkitallowfullscreen style="width:100%;" |
353 | - src="' . $pdfUrl. '"> |
|
353 | + src="' . $pdfUrl.'"> |
|
354 | 354 | </iframe>'; |
355 | 355 | echo '</div>'; |
356 | 356 | } elseif (!$originIsLearnpath) { |
@@ -91,11 +91,11 @@ |
||
91 | 91 | $pathinfo = pathinfo($header_file); |
92 | 92 | |
93 | 93 | if ($pathinfo['extension']=='swf') { |
94 | - $width='83%'; |
|
95 | - $height='83%'; |
|
94 | + $width='83%'; |
|
95 | + $height='83%'; |
|
96 | 96 | } else { |
97 | - $width='100%'; |
|
98 | - $height='100%'; |
|
97 | + $width='100%'; |
|
98 | + $height='100%'; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | echo '<iframe border="0" frameborder="0" scrolling="no" style="width:'.$width.'; height:'.$height.';background-color:#ffffff;" id="mainFrame" name="mainFrame" src="'.$file_url_web.'?'.api_get_cidreq().'&rand='.mt_rand(1, 1000).'"></iframe>'; |
@@ -90,12 +90,12 @@ |
||
90 | 90 | $file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file.'?'.api_get_cidreq(); |
91 | 91 | $pathinfo = pathinfo($header_file); |
92 | 92 | |
93 | -if ($pathinfo['extension']=='swf') { |
|
94 | - $width='83%'; |
|
95 | - $height='83%'; |
|
93 | +if ($pathinfo['extension'] == 'swf') { |
|
94 | + $width = '83%'; |
|
95 | + $height = '83%'; |
|
96 | 96 | } else { |
97 | - $width='100%'; |
|
98 | - $height='100%'; |
|
97 | + $width = '100%'; |
|
98 | + $height = '100%'; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | echo '<iframe border="0" frameborder="0" scrolling="no" style="width:'.$width.'; height:'.$height.';background-color:#ffffff;" id="mainFrame" name="mainFrame" src="'.$file_url_web.'?'.api_get_cidreq().'&rand='.mt_rand(1, 1000).'"></iframe>'; |
@@ -15,16 +15,16 @@ discard block |
||
15 | 15 | //Add the JS needed to use the jqgrid |
16 | 16 | $htmlHeadXtra[] = api_get_jqgrid_js(); |
17 | 17 | // setting breadcrumbs |
18 | -$interbreadcrumb[] = array('url' => 'index.php','name' => get_lang('PlatformAdmin')); |
|
18 | +$interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin')); |
|
19 | 19 | $action = isset($_GET['action']) ? $_GET['action'] : null; |
20 | 20 | if ($action == 'add') { |
21 | - $interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes')); |
|
22 | - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Add')); |
|
21 | + $interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes')); |
|
22 | + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Add')); |
|
23 | 23 | } elseif ($action == 'edit') { |
24 | - $interbreadcrumb[] = array('url' => 'usergroups.php','name' => get_lang('Classes')); |
|
25 | - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Edit')); |
|
24 | + $interbreadcrumb[] = array('url' => 'usergroups.php', 'name' => get_lang('Classes')); |
|
25 | + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Edit')); |
|
26 | 26 | } else { |
27 | - $interbreadcrumb[] = array('url' => '#','name' => get_lang('Classes')); |
|
27 | + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Classes')); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | // The header. |
@@ -55,13 +55,13 @@ discard block |
||
55 | 55 | ); |
56 | 56 | |
57 | 57 | //Column config |
58 | -$column_model = array( |
|
59 | - array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'), |
|
60 | - array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'), |
|
61 | - array('name'=>'courses', 'index'=>'courses', 'width'=>'15', 'align'=>'left'), |
|
62 | - array('name'=>'sessions', 'index'=>'sessions', 'width'=>'15', 'align'=>'left'), |
|
63 | - array('name'=>'group_type', 'index'=>'group_type', 'width'=>'15', 'align'=>'center'), |
|
64 | - array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'center', 'sortable'=>'false','formatter'=>'action_formatter'), |
|
58 | +$column_model = array( |
|
59 | + array('name'=>'name', 'index'=>'name', 'width'=>'35', 'align'=>'left'), |
|
60 | + array('name'=>'users', 'index'=>'users', 'width'=>'15', 'align'=>'left'), |
|
61 | + array('name'=>'courses', 'index'=>'courses', 'width'=>'15', 'align'=>'left'), |
|
62 | + array('name'=>'sessions', 'index'=>'sessions', 'width'=>'15', 'align'=>'left'), |
|
63 | + array('name'=>'group_type', 'index'=>'group_type', 'width'=>'15', 'align'=>'center'), |
|
64 | + array('name'=>'actions', 'index'=>'actions', 'width'=>'20', 'align'=>'center', 'sortable'=>'false', 'formatter'=>'action_formatter'), |
|
65 | 65 | ); |
66 | 66 | |
67 | 67 | //Autowidth |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | //With this function we can add actions to the jgrid |
74 | 74 | $action_links = 'function action_formatter (cellvalue, options, rowObject) { |
75 | 75 | return \'' |
76 | - .' <a href="add_users_to_usergroup.php?id=\'+options.rowId+\'">' . Display::return_icon('user_to_class.png', get_lang('SubscribeUsersToClass'), null, ICON_SIZE_MEDIUM) . '</a>' |
|
77 | - .' <a href="add_courses_to_usergroup.php?id=\'+options.rowId+\'">' . Display::return_icon('course_to_class.png', get_lang('SubscribeClassToCourses'), null, ICON_SIZE_MEDIUM) . '</a>' |
|
78 | - .' <a href="add_sessions_to_usergroup.php?id=\'+options.rowId+\'">' . Display::return_icon('sessions_to_class.png', get_lang('SubscribeClassToSessions'), null, ICON_SIZE_MEDIUM) . '</a>' |
|
79 | - .' <a href="?action=edit&id=\'+options.rowId+\'">' . Display::return_icon('edit.png', get_lang('Edit'), null, ICON_SIZE_SMALL) . '</a>' |
|
80 | - .' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'">' . Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL) . '</a>\'; |
|
76 | + .' <a href="add_users_to_usergroup.php?id=\'+options.rowId+\'">'.Display::return_icon('user_to_class.png', get_lang('SubscribeUsersToClass'), null, ICON_SIZE_MEDIUM).'</a>' |
|
77 | + .' <a href="add_courses_to_usergroup.php?id=\'+options.rowId+\'">'.Display::return_icon('course_to_class.png', get_lang('SubscribeClassToCourses'), null, ICON_SIZE_MEDIUM).'</a>' |
|
78 | + .' <a href="add_sessions_to_usergroup.php?id=\'+options.rowId+\'">'.Display::return_icon('sessions_to_class.png', get_lang('SubscribeClassToSessions'), null, ICON_SIZE_MEDIUM).'</a>' |
|
79 | + .' <a href="?action=edit&id=\'+options.rowId+\'">'.Display::return_icon('edit.png', get_lang('Edit'), null, ICON_SIZE_SMALL).'</a>' |
|
80 | + .' <a onclick="javascript:if(!confirm('."\'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"), ENT_QUOTES))."\'".')) return false;" href="?action=delete&id=\'+options.rowId+\'">'.Display::return_icon('delete.png', get_lang('Delete'), null, ICON_SIZE_SMALL).'</a>\'; |
|
81 | 81 | }'; |
82 | 82 | |
83 | 83 | ?> |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | } else { |
129 | 129 | echo '<div class="actions">'; |
130 | 130 | echo '<a href="'.api_get_self().'">'. |
131 | - Display::return_icon('back.png',get_lang('Back'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
131 | + Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM).'</a>'; |
|
132 | 132 | echo '</div>'; |
133 | 133 | $token = Security::get_token(); |
134 | 134 | $form->addElement('hidden', 'sec_token'); |
@@ -42,7 +42,7 @@ |
||
42 | 42 | |
43 | 43 | return $this->render( |
44 | 44 | '@ChamiloPage/latest.html.twig', |
45 | - [ 'pages' => $pagesToShow ] |
|
45 | + ['pages' => $pagesToShow] |
|
46 | 46 | ); |
47 | 47 | } |
48 | 48 | } |
49 | 49 | \ No newline at end of file |
@@ -136,7 +136,7 @@ |
||
136 | 136 | ); |
137 | 137 | /** @var Category $category */ |
138 | 138 | foreach ($categories as $category) { |
139 | - $faq->addChild( |
|
139 | + $faq->addChild( |
|
140 | 140 | $category->getHeadline(), |
141 | 141 | array( |
142 | 142 | 'route' => 'faq', |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | $iso = api_get_language_isocode(api_get_interface_language()); |
26 | 26 | $languageCondition = ''; |
27 | 27 | |
28 | - if (file_exists(api_get_path(SYS_PATH) . "web/assets/select2/dist/js/i18n/$iso.js")) { |
|
28 | + if (file_exists(api_get_path(SYS_PATH)."web/assets/select2/dist/js/i18n/$iso.js")) { |
|
29 | 29 | $html .= api_get_asset("select2/dist/js/i18n/$iso.js"); |
30 | 30 | $languageCondition = "language: '$iso',"; |
31 | 31 | } |
@@ -50,8 +50,7 @@ discard block |
||
50 | 50 | |
51 | 51 | //Get the minimumInputLength for select2 |
52 | 52 | $minimumInputLength = $this->getAttribute('minimumInputLength') > 3 ? |
53 | - $this->getAttribute('minimumInputLength') : |
|
54 | - 3 |
|
53 | + $this->getAttribute('minimumInputLength') : 3 |
|
55 | 54 | ; |
56 | 55 | |
57 | 56 | $plHolder = $this->getAttribute('placeholder'); |
@@ -81,7 +80,7 @@ discard block |
||
81 | 80 | $multiple = $multiple ? 'true' : 'false'; |
82 | 81 | |
83 | 82 | $max = $this->getAttribute('maximumSelectionLength'); |
84 | - $max = !empty($max) ? "maximumSelectionLength: $max, ": ''; |
|
83 | + $max = !empty($max) ? "maximumSelectionLength: $max, " : ''; |
|
85 | 84 | |
86 | 85 | $html .= <<<JS |
87 | 86 | <script> |
@@ -125,7 +124,7 @@ discard block |
||
125 | 124 | $this->removeAttribute('url_function'); |
126 | 125 | $this->setAttribute('style', 'width: 100%;'); |
127 | 126 | |
128 | - return parent::toHtml() . $html; |
|
127 | + return parent::toHtml().$html; |
|
129 | 128 | } |
130 | 129 | |
131 | 130 | /** |
@@ -8,48 +8,48 @@ discard block |
||
8 | 8 | */ |
9 | 9 | class AttendanceLink extends AbstractLink |
10 | 10 | { |
11 | - private $attendance_table = null; |
|
12 | - private $itemprop_table = null; |
|
11 | + private $attendance_table = null; |
|
12 | + private $itemprop_table = null; |
|
13 | 13 | |
14 | - /** |
|
15 | - * Constructor |
|
16 | - */ |
|
17 | - public function __construct() |
|
18 | - { |
|
19 | - parent::__construct(); |
|
20 | - $this->set_type(LINK_ATTENDANCE); |
|
21 | - } |
|
14 | + /** |
|
15 | + * Constructor |
|
16 | + */ |
|
17 | + public function __construct() |
|
18 | + { |
|
19 | + parent::__construct(); |
|
20 | + $this->set_type(LINK_ATTENDANCE); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * @return string |
|
25 | - */ |
|
26 | - public function get_type_name() |
|
27 | - { |
|
28 | - return get_lang('Attendance'); |
|
29 | - } |
|
23 | + /** |
|
24 | + * @return string |
|
25 | + */ |
|
26 | + public function get_type_name() |
|
27 | + { |
|
28 | + return get_lang('Attendance'); |
|
29 | + } |
|
30 | 30 | |
31 | - /** |
|
32 | - * @return bool |
|
33 | - */ |
|
34 | - public function is_allowed_to_change_name() |
|
35 | - { |
|
36 | - return false; |
|
37 | - } |
|
31 | + /** |
|
32 | + * @return bool |
|
33 | + */ |
|
34 | + public function is_allowed_to_change_name() |
|
35 | + { |
|
36 | + return false; |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * Generate an array of attendances that a teacher hasn't created a link for. |
|
41 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
42 | - * @todo seems to be depracated |
|
43 | - */ |
|
44 | - public function get_not_created_links() |
|
45 | - { |
|
46 | - return false; |
|
47 | - if (empty($this->course_code)) { |
|
48 | - die('Error in get_not_created_links() : course code not set'); |
|
49 | - } |
|
50 | - $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
39 | + /** |
|
40 | + * Generate an array of attendances that a teacher hasn't created a link for. |
|
41 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
42 | + * @todo seems to be depracated |
|
43 | + */ |
|
44 | + public function get_not_created_links() |
|
45 | + { |
|
46 | + return false; |
|
47 | + if (empty($this->course_code)) { |
|
48 | + die('Error in get_not_created_links() : course code not set'); |
|
49 | + } |
|
50 | + $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK); |
|
51 | 51 | |
52 | - $sql = 'SELECT att.id, att.name, att.attendance_qualify_title |
|
52 | + $sql = 'SELECT att.id, att.name, att.attendance_qualify_title |
|
53 | 53 | FROM '.$this->get_attendance_table().' att |
54 | 54 | WHERE |
55 | 55 | att.c_id = '.$this->course_id.' AND |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | course_code = "'.Database::escape_string($this->get_course_code()).'" |
61 | 61 | ) |
62 | 62 | AND att.session_id='.api_get_session_id().''; |
63 | - $result = Database::query($sql); |
|
63 | + $result = Database::query($sql); |
|
64 | 64 | |
65 | 65 | $cats = array(); |
66 | 66 | while ($data = Database::fetch_array($result)) { |
@@ -71,13 +71,13 @@ discard block |
||
71 | 71 | } |
72 | 72 | } |
73 | 73 | |
74 | - return $cats; |
|
75 | - } |
|
74 | + return $cats; |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * Generate an array of all attendances available. |
|
79 | - * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | - */ |
|
77 | + /** |
|
78 | + * Generate an array of all attendances available. |
|
79 | + * @return array 2-dimensional array - every element contains 2 subelements (id, name) |
|
80 | + */ |
|
81 | 81 | public function get_all_links() |
82 | 82 | { |
83 | 83 | if (empty($this->course_code)) { |
@@ -104,55 +104,55 @@ discard block |
||
104 | 104 | $my_cats = isset($cats) ? $cats : null; |
105 | 105 | |
106 | 106 | return $my_cats; |
107 | - } |
|
107 | + } |
|
108 | 108 | |
109 | - /** |
|
110 | - * Has anyone done this exercise yet ? |
|
111 | - */ |
|
112 | - public function has_results() |
|
113 | - { |
|
114 | - $tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT); |
|
115 | - $session_id = api_get_session_id(); |
|
116 | - $sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." |
|
109 | + /** |
|
110 | + * Has anyone done this exercise yet ? |
|
111 | + */ |
|
112 | + public function has_results() |
|
113 | + { |
|
114 | + $tbl_attendance_result = Database :: get_course_table(TABLE_ATTENDANCE_RESULT); |
|
115 | + $session_id = api_get_session_id(); |
|
116 | + $sql = 'SELECT count(*) AS number FROM '.$tbl_attendance_result." |
|
117 | 117 | WHERE |
118 | 118 | session_id = $session_id AND |
119 | 119 | c_id = '.$this->course_id.' AND |
120 | 120 | attendance_id = '".intval($this->get_ref_id())."'"; |
121 | - $result = Database::query($sql); |
|
122 | - $number = Database::fetch_row($result); |
|
121 | + $result = Database::query($sql); |
|
122 | + $number = Database::fetch_row($result); |
|
123 | 123 | |
124 | - return $number[0] != 0; |
|
125 | - } |
|
124 | + return $number[0] != 0; |
|
125 | + } |
|
126 | 126 | |
127 | - /** |
|
128 | - * @param int $stud_id |
|
129 | - * @return array|null |
|
130 | - */ |
|
131 | - public function calc_score($stud_id = null, $type = null) |
|
132 | - { |
|
133 | - $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
134 | - $session_id = api_get_session_id(); |
|
127 | + /** |
|
128 | + * @param int $stud_id |
|
129 | + * @return array|null |
|
130 | + */ |
|
131 | + public function calc_score($stud_id = null, $type = null) |
|
132 | + { |
|
133 | + $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); |
|
134 | + $session_id = api_get_session_id(); |
|
135 | 135 | |
136 | - // get attendance qualify max |
|
137 | - $sql = 'SELECT att.attendance_qualify_max |
|
136 | + // get attendance qualify max |
|
137 | + $sql = 'SELECT att.attendance_qualify_max |
|
138 | 138 | FROM '.$this->get_attendance_table().' att |
139 | 139 | WHERE |
140 | 140 | att.c_id = '.$this->course_id.' AND |
141 | 141 | att.id = '.intval($this->get_ref_id()).' AND |
142 | 142 | att.session_id='.intval($session_id).''; |
143 | - $query = Database::query($sql); |
|
144 | - $attendance = Database::fetch_array($query, 'ASSOC'); |
|
143 | + $query = Database::query($sql); |
|
144 | + $attendance = Database::fetch_array($query, 'ASSOC'); |
|
145 | 145 | |
146 | - // Get results |
|
147 | - $sql = 'SELECT * |
|
146 | + // Get results |
|
147 | + $sql = 'SELECT * |
|
148 | 148 | FROM '.$tbl_attendance_result.' |
149 | 149 | WHERE c_id = '.$this->course_id.' AND attendance_id = '.intval($this->get_ref_id()); |
150 | - if (isset($stud_id)) { |
|
151 | - $sql .= ' AND user_id = '.intval($stud_id); |
|
152 | - } |
|
153 | - $scores = Database::query($sql); |
|
154 | - // for 1 student |
|
155 | - if (isset($stud_id)) { |
|
150 | + if (isset($stud_id)) { |
|
151 | + $sql .= ' AND user_id = '.intval($stud_id); |
|
152 | + } |
|
153 | + $scores = Database::query($sql); |
|
154 | + // for 1 student |
|
155 | + if (isset($stud_id)) { |
|
156 | 156 | if ($data = Database::fetch_array($scores, 'ASSOC')) { |
157 | 157 | return array( |
158 | 158 | $data['score'], |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | //We sent the 0/attendance_qualify_max instead of null for correct calculations |
163 | 163 | return array(0, $attendance['attendance_qualify_max']); |
164 | 164 | } |
165 | - } else { |
|
165 | + } else { |
|
166 | 166 | // all students -> get average |
167 | 167 | $students = array(); // user list, needed to make sure we only |
168 | 168 | // take first attempts into account |
@@ -171,144 +171,144 @@ discard block |
||
171 | 171 | $sumResult = 0; |
172 | 172 | $bestResult = 0; |
173 | 173 | |
174 | - while ($data = Database::fetch_array($scores)) { |
|
175 | - if (!(array_key_exists($data['user_id'], $students))) { |
|
176 | - if ($attendance['attendance_qualify_max'] != 0) { |
|
177 | - $students[$data['user_id']] = $data['score']; |
|
178 | - $rescount++; |
|
179 | - $sum += $data['score'] / $attendance['attendance_qualify_max']; |
|
180 | - $sumResult += $data['score']; |
|
181 | - if ($data['score'] > $bestResult) { |
|
182 | - $bestResult = $data['score']; |
|
183 | - } |
|
184 | - $weight = $attendance['attendance_qualify_max']; |
|
185 | - } |
|
186 | - } |
|
187 | - } |
|
174 | + while ($data = Database::fetch_array($scores)) { |
|
175 | + if (!(array_key_exists($data['user_id'], $students))) { |
|
176 | + if ($attendance['attendance_qualify_max'] != 0) { |
|
177 | + $students[$data['user_id']] = $data['score']; |
|
178 | + $rescount++; |
|
179 | + $sum += $data['score'] / $attendance['attendance_qualify_max']; |
|
180 | + $sumResult += $data['score']; |
|
181 | + if ($data['score'] > $bestResult) { |
|
182 | + $bestResult = $data['score']; |
|
183 | + } |
|
184 | + $weight = $attendance['attendance_qualify_max']; |
|
185 | + } |
|
186 | + } |
|
187 | + } |
|
188 | 188 | |
189 | - if ($rescount == 0) { |
|
190 | - return null; |
|
191 | - } else { |
|
192 | - switch ($type) { |
|
193 | - case 'best': |
|
194 | - return array($bestResult, $weight); |
|
195 | - break; |
|
196 | - case 'average': |
|
197 | - return array($sumResult / $rescount, $weight); |
|
198 | - break; |
|
199 | - case 'ranking': |
|
200 | - return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
201 | - break; |
|
202 | - default: |
|
203 | - return array($sum, $rescount); |
|
204 | - break; |
|
205 | - } |
|
206 | - } |
|
207 | - } |
|
208 | - } |
|
189 | + if ($rescount == 0) { |
|
190 | + return null; |
|
191 | + } else { |
|
192 | + switch ($type) { |
|
193 | + case 'best': |
|
194 | + return array($bestResult, $weight); |
|
195 | + break; |
|
196 | + case 'average': |
|
197 | + return array($sumResult / $rescount, $weight); |
|
198 | + break; |
|
199 | + case 'ranking': |
|
200 | + return AbstractLink::getCurrentUserRanking($stud_id, $students); |
|
201 | + break; |
|
202 | + default: |
|
203 | + return array($sum, $rescount); |
|
204 | + break; |
|
205 | + } |
|
206 | + } |
|
207 | + } |
|
208 | + } |
|
209 | 209 | |
210 | - /** |
|
211 | - * Lazy load function to get the database table of the student publications |
|
212 | - */ |
|
213 | - private function get_attendance_table() |
|
214 | - { |
|
215 | - $this->attendance_table = Database::get_course_table(TABLE_ATTENDANCE); |
|
216 | - return $this->attendance_table; |
|
217 | - } |
|
210 | + /** |
|
211 | + * Lazy load function to get the database table of the student publications |
|
212 | + */ |
|
213 | + private function get_attendance_table() |
|
214 | + { |
|
215 | + $this->attendance_table = Database::get_course_table(TABLE_ATTENDANCE); |
|
216 | + return $this->attendance_table; |
|
217 | + } |
|
218 | 218 | |
219 | - public function needs_name_and_description() |
|
220 | - { |
|
221 | - return false; |
|
222 | - } |
|
219 | + public function needs_name_and_description() |
|
220 | + { |
|
221 | + return false; |
|
222 | + } |
|
223 | 223 | |
224 | - public function needs_max() |
|
225 | - { |
|
226 | - return false; |
|
227 | - } |
|
224 | + public function needs_max() |
|
225 | + { |
|
226 | + return false; |
|
227 | + } |
|
228 | 228 | |
229 | - public function needs_results() |
|
230 | - { |
|
231 | - return false; |
|
232 | - } |
|
229 | + public function needs_results() |
|
230 | + { |
|
231 | + return false; |
|
232 | + } |
|
233 | 233 | |
234 | - /** |
|
235 | - * @return string |
|
236 | - */ |
|
237 | - public function get_name() |
|
238 | - { |
|
239 | - $this->get_attendance_data(); |
|
240 | - $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
|
241 | - $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
|
242 | - if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | - return $this->attendance_data['attendance_qualify_title']; |
|
244 | - } else { |
|
245 | - return $attendance_title; |
|
246 | - } |
|
247 | - } |
|
234 | + /** |
|
235 | + * @return string |
|
236 | + */ |
|
237 | + public function get_name() |
|
238 | + { |
|
239 | + $this->get_attendance_data(); |
|
240 | + $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
|
241 | + $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
|
242 | + if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | + return $this->attendance_data['attendance_qualify_title']; |
|
244 | + } else { |
|
245 | + return $attendance_title; |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | - /** |
|
250 | - * @return string |
|
251 | - */ |
|
252 | - public function get_description() |
|
253 | - { |
|
254 | - return ''; |
|
255 | - } |
|
249 | + /** |
|
250 | + * @return string |
|
251 | + */ |
|
252 | + public function get_description() |
|
253 | + { |
|
254 | + return ''; |
|
255 | + } |
|
256 | 256 | |
257 | - /** |
|
258 | - * Check if this still links to an exercise |
|
259 | - */ |
|
260 | - public function is_valid_link() |
|
261 | - { |
|
262 | - $session_id = api_get_session_id(); |
|
263 | - $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att |
|
257 | + /** |
|
258 | + * Check if this still links to an exercise |
|
259 | + */ |
|
260 | + public function is_valid_link() |
|
261 | + { |
|
262 | + $session_id = api_get_session_id(); |
|
263 | + $sql = 'SELECT count(att.id) FROM '.$this->get_attendance_table().' att |
|
264 | 264 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
265 | - $result = Database::query($sql); |
|
266 | - $number = Database::fetch_row($result); |
|
267 | - return ($number[0] != 0); |
|
268 | - } |
|
265 | + $result = Database::query($sql); |
|
266 | + $number = Database::fetch_row($result); |
|
267 | + return ($number[0] != 0); |
|
268 | + } |
|
269 | 269 | |
270 | - public function get_test_id() |
|
271 | - { |
|
272 | - return 'DEBUG:ID'; |
|
273 | - } |
|
270 | + public function get_test_id() |
|
271 | + { |
|
272 | + return 'DEBUG:ID'; |
|
273 | + } |
|
274 | 274 | |
275 | - public function get_link() |
|
276 | - { |
|
277 | - //it was extracts the attendance id |
|
278 | - $session_id = api_get_session_id(); |
|
279 | - $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
275 | + public function get_link() |
|
276 | + { |
|
277 | + //it was extracts the attendance id |
|
278 | + $session_id = api_get_session_id(); |
|
279 | + $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
280 | 280 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
281 | - $result = Database::query($sql); |
|
282 | - $row = Database::fetch_array($result,'ASSOC'); |
|
283 | - $attendance_id = $row['id']; |
|
284 | - $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&'.api_get_cidreq_params($this->get_course_code(), $session_id); |
|
281 | + $result = Database::query($sql); |
|
282 | + $row = Database::fetch_array($result,'ASSOC'); |
|
283 | + $attendance_id = $row['id']; |
|
284 | + $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&'.api_get_cidreq_params($this->get_course_code(), $session_id); |
|
285 | 285 | |
286 | - return $url; |
|
287 | - } |
|
286 | + return $url; |
|
287 | + } |
|
288 | 288 | |
289 | - /** |
|
290 | - * @return array|bool |
|
291 | - */ |
|
292 | - private function get_attendance_data() |
|
293 | - { |
|
294 | - $tbl_name = $this->get_attendance_table(); |
|
295 | - $session_id = api_get_session_id(); |
|
296 | - if ($tbl_name == '') { |
|
297 | - return false; |
|
298 | - } elseif (!isset($this->attendance_data)) { |
|
299 | - $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
289 | + /** |
|
290 | + * @return array|bool |
|
291 | + */ |
|
292 | + private function get_attendance_data() |
|
293 | + { |
|
294 | + $tbl_name = $this->get_attendance_table(); |
|
295 | + $session_id = api_get_session_id(); |
|
296 | + if ($tbl_name == '') { |
|
297 | + return false; |
|
298 | + } elseif (!isset($this->attendance_data)) { |
|
299 | + $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
|
300 | 300 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
301 | - $query = Database::query($sql); |
|
302 | - $this->attendance_data = Database::fetch_array($query); |
|
303 | - } |
|
304 | - return $this->attendance_data; |
|
305 | - } |
|
301 | + $query = Database::query($sql); |
|
302 | + $this->attendance_data = Database::fetch_array($query); |
|
303 | + } |
|
304 | + return $this->attendance_data; |
|
305 | + } |
|
306 | 306 | |
307 | - /** |
|
308 | - * @return string |
|
309 | - */ |
|
310 | - public function get_icon_name() |
|
311 | - { |
|
312 | - return 'attendance'; |
|
313 | - } |
|
307 | + /** |
|
308 | + * @return string |
|
309 | + */ |
|
310 | + public function get_icon_name() |
|
311 | + { |
|
312 | + return 'attendance'; |
|
313 | + } |
|
314 | 314 | } |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | } |
165 | 165 | } else { |
166 | 166 | // all students -> get average |
167 | - $students = array(); // user list, needed to make sure we only |
|
167 | + $students = array(); // user list, needed to make sure we only |
|
168 | 168 | // take first attempts into account |
169 | 169 | $rescount = 0; |
170 | 170 | $sum = 0; |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | $this->get_attendance_data(); |
240 | 240 | $attendance_title = isset($this->attendance_data['name']) ? $this->attendance_data['name'] : ''; |
241 | 241 | $attendance_qualify_title = isset($this->attendance_data['attendance_qualify_title']) ? $this->attendance_data['attendance_qualify_title'] : ''; |
242 | - if ( isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
242 | + if (isset($attendance_qualify_title) && $attendance_qualify_title != '') { |
|
243 | 243 | return $this->attendance_data['attendance_qualify_title']; |
244 | 244 | } else { |
245 | 245 | return $attendance_title; |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $sql = 'SELECT * FROM '.$this->get_attendance_table().' att |
280 | 280 | WHERE att.c_id = '.$this->course_id.' AND att.id = '.intval($this->get_ref_id()).' '; |
281 | 281 | $result = Database::query($sql); |
282 | - $row = Database::fetch_array($result,'ASSOC'); |
|
282 | + $row = Database::fetch_array($result, 'ASSOC'); |
|
283 | 283 | $attendance_id = $row['id']; |
284 | 284 | $url = api_get_path(WEB_PATH).'main/attendance/index.php?action=attendance_sheet_list&gradebook=view&attendance_id='.$attendance_id.'&'.api_get_cidreq_params($this->get_course_code(), $session_id); |
285 | 285 |