@@ -20,24 +20,18 @@ |
||
20 | 20 | * src/Chamilo/CourseBundle/Tool |
21 | 21 | * |
22 | 22 | * All this classes are registered as a service with the tag "chamilo_course.tool" here: |
23 | - |
|
24 | 23 | * src/Chamilo/CourseBundle/Resources/config/services.yml |
25 | 24 | * |
26 | 25 | * The register process is made using the class ToolCompilerClass: |
27 | 26 | * |
28 | 27 | * src/Chamilo/CourseBundle/DependencyInjection/Compiler/ToolCompilerClass.php |
29 | - |
|
30 | 28 | * The tool chain is just an array that includes all the tools registered in services.yml |
31 | 29 | * |
32 | 30 | * The tool chain is hook when a new course is created via a listener here: |
33 | - |
|
34 | 31 | * src/Chamilo/CoreBundle/Entity/Listener/CourseListener.php |
35 | - |
|
36 | 32 | * After a course is created this function is called: CourseListener::prePersist() |
37 | 33 | * This function includes the called to the function "addToolsInCourse" inside the tool chain. |
38 | - |
|
39 | 34 | * This allows to create course tools more easily. Steps: |
40 | - |
|
41 | 35 | * 1. Create a new tool class here: src/Chamilo/CourseBundle/Tool |
42 | 36 | * 2. Add the class as a service here: src/Chamilo/CourseBundle/Resources/config/services.yml (see examples there) |
43 | 37 | * 3. Create a new course. When you create a new course the new tool will be created |
@@ -48,59 +48,59 @@ discard block |
||
48 | 48 | // Please, do not modify this dirname formatting |
49 | 49 | |
50 | 50 | if (strstr($dir, '..')) { |
51 | - $dir = '/'; |
|
51 | + $dir = '/'; |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | if ($dir[0] == '.') { |
55 | - $dir = substr($dir, 1); |
|
55 | + $dir = substr($dir, 1); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | if ($dir[0] != '/') { |
59 | - $dir = '/'.$dir; |
|
59 | + $dir = '/'.$dir; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | if ($dir[strlen($dir) - 1] != '/') { |
63 | - $dir .= '/'; |
|
63 | + $dir .= '/'; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; |
67 | 67 | |
68 | 68 | if (!is_dir($filepath)) { |
69 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
70 | - $dir = '/'; |
|
69 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
70 | + $dir = '/'; |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | $groupId = api_get_group_id(); |
74 | 74 | |
75 | 75 | if (!empty($groupId)) { |
76 | - $interbreadcrumb[] = array ( |
|
76 | + $interbreadcrumb[] = array ( |
|
77 | 77 | "url" => "../group/group_space.php?".api_get_cidreq(), |
78 | 78 | "name" => get_lang('GroupSpace') |
79 | 79 | ); |
80 | - $noPHP_SELF = true; |
|
81 | - $group = GroupManager :: get_group_properties($groupId); |
|
82 | - $path = explode('/', $dir); |
|
83 | - if ('/'.$path[1] != $group['directory']) { |
|
84 | - api_not_allowed(true); |
|
85 | - } |
|
80 | + $noPHP_SELF = true; |
|
81 | + $group = GroupManager :: get_group_properties($groupId); |
|
82 | + $path = explode('/', $dir); |
|
83 | + if ('/'.$path[1] != $group['directory']) { |
|
84 | + api_not_allowed(true); |
|
85 | + } |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | $interbreadcrumb[] = array( |
89 | - "url" => "./document.php?".api_get_cidreq(), |
|
90 | - "name" => get_lang('Documents') |
|
89 | + "url" => "./document.php?".api_get_cidreq(), |
|
90 | + "name" => get_lang('Documents') |
|
91 | 91 | ); |
92 | 92 | |
93 | 93 | if (!api_is_allowed_in_course()) { |
94 | - api_not_allowed(true); |
|
94 | + api_not_allowed(true); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | if (!($is_allowed_to_edit || $groupRights || |
98 | - DocumentManager::is_my_shared_folder( |
|
99 | - api_get_user_id(), |
|
100 | - Security::remove_XSS($dir), |
|
101 | - api_get_session_id())) |
|
98 | + DocumentManager::is_my_shared_folder( |
|
99 | + api_get_user_id(), |
|
100 | + Security::remove_XSS($dir), |
|
101 | + api_get_session_id())) |
|
102 | 102 | ) { |
103 | - api_not_allowed(true); |
|
103 | + api_not_allowed(true); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | |
@@ -108,10 +108,10 @@ discard block |
||
108 | 108 | Event::event_access_tool(TOOL_DOCUMENT); |
109 | 109 | $display_dir = $dir; |
110 | 110 | if (isset ($group)) { |
111 | - $display_dir = explode('/', $dir); |
|
112 | - unset ($display_dir[0]); |
|
113 | - unset ($display_dir[1]); |
|
114 | - $display_dir = implode('/', $display_dir); |
|
111 | + $display_dir = explode('/', $dir); |
|
112 | + unset ($display_dir[0]); |
|
113 | + unset ($display_dir[1]); |
|
114 | + $display_dir = implode('/', $display_dir); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | // Interbreadcrumb for the current directory root path |
@@ -125,9 +125,9 @@ discard block |
||
125 | 125 | } else { |
126 | 126 | foreach ($document_data['parents'] as $document_sub_data) { |
127 | 127 | $interbreadcrumb[] = array( |
128 | - 'url' => $document_sub_data['document_url'], |
|
129 | - 'name' => $document_sub_data['title'] |
|
130 | - ); |
|
128 | + 'url' => $document_sub_data['document_url'], |
|
129 | + 'name' => $document_sub_data['title'] |
|
130 | + ); |
|
131 | 131 | } |
132 | 132 | } |
133 | 133 | Display :: display_header($nameTools, 'Doc'); |
@@ -138,13 +138,13 @@ discard block |
||
138 | 138 | echo '</div>'; |
139 | 139 | |
140 | 140 | if (api_browser_support('svg')) { |
141 | - //automatic loading the course language |
|
142 | - $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); |
|
143 | - $langsvgedit = api_get_language_isocode(); |
|
144 | - $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; |
|
145 | - $langsvgedit = file_exists(api_get_path(WEB_LIBRARY_JS_PATH).'svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; |
|
146 | - $svg_url= api_get_path(WEB_CODE_PATH).'document/svg-editor.php?lang='.$langsvgedit; |
|
147 | - ?> |
|
141 | + //automatic loading the course language |
|
142 | + $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); |
|
143 | + $langsvgedit = api_get_language_isocode(); |
|
144 | + $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; |
|
145 | + $langsvgedit = file_exists(api_get_path(WEB_LIBRARY_JS_PATH).'svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; |
|
146 | + $svg_url= api_get_path(WEB_CODE_PATH).'document/svg-editor.php?lang='.$langsvgedit; |
|
147 | + ?> |
|
148 | 148 | <script> |
149 | 149 | document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'); |
150 | 150 | function resizeIframe() { |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | |
163 | 163 | <?php |
164 | 164 | echo '<noscript>'; |
165 | - echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0" src="'.$svg_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'; |
|
166 | - echo '</noscript>'; |
|
165 | + echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0" src="'.$svg_url.'"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'; |
|
166 | + echo '</noscript>'; |
|
167 | 167 | } else { |
168 | - Display::display_error_message(get_lang('BrowserDontSupportsSVG')); |
|
168 | + Display::display_error_message(get_lang('BrowserDontSupportsSVG')); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | Display :: display_footer(); |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | //path for svg-edit save |
47 | 47 | $_SESSION['draw_dir'] = Security::remove_XSS($dir); |
48 | 48 | if ($_SESSION['draw_dir'] == '/') { |
49 | - $_SESSION['draw_dir'] = ''; |
|
49 | + $_SESSION['draw_dir'] = ''; |
|
50 | 50 | } |
51 | 51 | $_SESSION['draw_file'] = basename(Security::remove_XSS($file_path)); |
52 | 52 | $get_file = Security::remove_XSS($file_path); |
@@ -62,26 +62,26 @@ discard block |
||
62 | 62 | /* Please, do not modify this dirname formatting */ |
63 | 63 | |
64 | 64 | if (strstr($dir, '..')) { |
65 | - $dir = '/'; |
|
65 | + $dir = '/'; |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | if ($dir[0] == '.') { |
69 | - $dir = substr($dir, 1); |
|
69 | + $dir = substr($dir, 1); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | if ($dir[0] != '/') { |
73 | - $dir = '/'.$dir; |
|
73 | + $dir = '/'.$dir; |
|
74 | 74 | } |
75 | 75 | |
76 | 76 | if ($dir[strlen($dir) - 1] != '/') { |
77 | - $dir .= '/'; |
|
77 | + $dir .= '/'; |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'.$dir; |
81 | 81 | |
82 | 82 | if (!is_dir($filepath)) { |
83 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
84 | - $dir = '/'; |
|
83 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
84 | + $dir = '/'; |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | //groups //TODO:clean |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | 'url' => api_get_path(WEB_CODE_PATH).'group/group_space.php?'.api_get_cidreq(), |
91 | 91 | 'name' => get_lang('GroupSpace'), |
92 | 92 | ); |
93 | - $group_document = true; |
|
94 | - $noPHP_SELF = true; |
|
93 | + $group_document = true; |
|
94 | + $noPHP_SELF = true; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | $is_certificate_mode = DocumentManager::is_certificate_mode($dir); |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | } |
118 | 118 | |
119 | 119 | $is_allowedToEdit = api_is_allowed_to_edit(null, true) || $groupRights || |
120 | - DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); |
|
120 | + DocumentManager::is_my_shared_folder(api_get_user_id(), $dir, $current_session_id); |
|
121 | 121 | |
122 | 122 | if (!$is_allowedToEdit) { |
123 | - api_not_allowed(true); |
|
123 | + api_not_allowed(true); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | Event::event_access_tool(TOOL_DOCUMENT); |
@@ -134,13 +134,13 @@ discard block |
||
134 | 134 | echo '</div>'; |
135 | 135 | |
136 | 136 | if (api_browser_support('svg')) { |
137 | - //automatic loading the course language |
|
138 | - $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); |
|
139 | - $langsvgedit = api_get_language_isocode(); |
|
140 | - $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; |
|
141 | - $langsvgedit = file_exists(api_get_path(WEB_LIBRARY_JS_PATH).'svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; |
|
142 | - $svg_url = api_get_path(WEB_CODE_PATH).'document/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit; |
|
143 | - ?> |
|
137 | + //automatic loading the course language |
|
138 | + $svgedit_code_translation_table = array('' => 'en', 'pt' => 'pt-Pt', 'sr' => 'sr_latn'); |
|
139 | + $langsvgedit = api_get_language_isocode(); |
|
140 | + $langsvgedit = isset($svgedit_code_translation_table[$langsvgedit]) ? $svgedit_code_translation_table[$langsvgedit] : $langsvgedit; |
|
141 | + $langsvgedit = file_exists(api_get_path(WEB_LIBRARY_JS_PATH).'svgedit/locale/lang.'.$langsvgedit.'.js') ? $langsvgedit : 'en'; |
|
142 | + $svg_url = api_get_path(WEB_CODE_PATH).'document/svg-editor.php?url=../../../../../courses/'.$courseDir.$dir.$file.'&lang='.$langsvgedit; |
|
143 | + ?> |
|
144 | 144 | <script> |
145 | 145 | document.write ('<iframe id="frame" frameborder="0" scrolling="no" src="<?php echo $svg_url; ?>" width="100%" height="100%"><noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'); |
146 | 146 | function resizeIframe() { |
@@ -158,9 +158,9 @@ discard block |
||
158 | 158 | |
159 | 159 | <?php |
160 | 160 | echo '<noscript>'; |
161 | - echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'; |
|
162 | - echo '</noscript>'; |
|
161 | + echo '<iframe style="height: 550px; width: 100%;" scrolling="no" frameborder="0\' src="'.$svg_url.'"<noframes><p>Sorry, your browser does not handle frames</p></noframes></iframe>'; |
|
162 | + echo '</noscript>'; |
|
163 | 163 | } else { |
164 | - Display::display_error_message(get_lang('BrowserDontSupportsSVG')); |
|
164 | + Display::display_error_message(get_lang('BrowserDontSupportsSVG')); |
|
165 | 165 | } |
166 | 166 | Display::display_footer(); |
@@ -34,21 +34,21 @@ discard block |
||
34 | 34 | |
35 | 35 | // "Link" type |
36 | 36 | if ($_REQUEST['format'] == 'link') { |
37 | - // converting post vars to get uri |
|
38 | - $params = ''; |
|
39 | - $kv = array(); |
|
40 | - foreach ($_POST as $key => $value) |
|
41 | - if ($key != 'format') |
|
42 | - $kv[] = $key.'='.urlencode($value); |
|
43 | - $query_string = join("&", $kv); |
|
44 | - die('<a href="reports.php?format=directlink&'.$query_string.'">'.get_lang('ReportTypeLink').'</a>'); |
|
37 | + // converting post vars to get uri |
|
38 | + $params = ''; |
|
39 | + $kv = array(); |
|
40 | + foreach ($_POST as $key => $value) |
|
41 | + if ($key != 'format') |
|
42 | + $kv[] = $key.'='.urlencode($value); |
|
43 | + $query_string = join("&", $kv); |
|
44 | + die('<a href="reports.php?format=directlink&'.$query_string.'">'.get_lang('ReportTypeLink').'</a>'); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | if ($_REQUEST['format'] == 'directlink') { |
48 | - foreach (array('jquery.dataTables.min.js') as $js) |
|
49 | - $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).$js.'" type="text/javascript" language="javascript"></script>'."\n"; |
|
48 | + foreach (array('jquery.dataTables.min.js') as $js) |
|
49 | + $htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_JS_PATH).$js.'" type="text/javascript" language="javascript"></script>'."\n"; |
|
50 | 50 | |
51 | - $htmlCSSXtra[] = 'dataTable.css'; |
|
51 | + $htmlCSSXtra[] = 'dataTable.css'; |
|
52 | 52 | |
53 | 53 | ?> |
54 | 54 | <script type="text/javascript"> |
@@ -63,62 +63,62 @@ discard block |
||
63 | 63 | } |
64 | 64 | </script> |
65 | 65 | <?php |
66 | - Display::display_header($tool_name); |
|
67 | - echo '<div id="result" class="result">'; |
|
66 | + Display::display_header($tool_name); |
|
67 | + echo '<div id="result" class="result">'; |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // outputing a link to csv file instead of outputing csv data directly |
71 | 71 | if ($_REQUEST['format'] == 'csv') { |
72 | - // converting post vars to get uri |
|
73 | - $params = ''; |
|
74 | - $kv = array(); |
|
75 | - foreach ($_POST as $key => $value) |
|
76 | - if ($key != 'format') |
|
77 | - $kv[] = $key.'='.urlencode($value); |
|
78 | - $query_string = join("&", $kv); |
|
79 | - die('<a href="reports.php?format=downloadcsv&'.$query_string.'">'.get_lang('DownloadFile').'</a>'); |
|
72 | + // converting post vars to get uri |
|
73 | + $params = ''; |
|
74 | + $kv = array(); |
|
75 | + foreach ($_POST as $key => $value) |
|
76 | + if ($key != 'format') |
|
77 | + $kv[] = $key.'='.urlencode($value); |
|
78 | + $query_string = join("&", $kv); |
|
79 | + die('<a href="reports.php?format=downloadcsv&'.$query_string.'">'.get_lang('DownloadFile').'</a>'); |
|
80 | 80 | } else if ($_REQUEST['format'] == 'downloadcsv') { |
81 | - if ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') == false)) { |
|
82 | - header("Pragma: must-revalidate"); |
|
83 | - header("Cache-Control: must-revalidate"); |
|
84 | - header("Content-type: application/vnd.ms-excel"); |
|
85 | - } |
|
86 | - else { |
|
87 | - header("Content-type: text/csv"); |
|
88 | - } |
|
89 | - $date = date("Y-m-d"); |
|
90 | - $filename = "reporting-$date.csv"; |
|
91 | - header("Content-Disposition: attachment; filename=$filename"); |
|
92 | - $_REQUEST['format'] = 'csv'; |
|
81 | + if ((strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) && (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') == false)) { |
|
82 | + header("Pragma: must-revalidate"); |
|
83 | + header("Cache-Control: must-revalidate"); |
|
84 | + header("Content-type: application/vnd.ms-excel"); |
|
85 | + } |
|
86 | + else { |
|
87 | + header("Content-type: text/csv"); |
|
88 | + } |
|
89 | + $date = date("Y-m-d"); |
|
90 | + $filename = "reporting-$date.csv"; |
|
91 | + header("Content-Disposition: attachment; filename=$filename"); |
|
92 | + $_REQUEST['format'] = 'csv'; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | |
96 | 96 | |
97 | 97 | if (is_array($reports_template[$_REQUEST['type']])) { |
98 | - $query = $reports_template[$_REQUEST['type']]['getSQL'](); |
|
99 | - if (! is_array($query)) |
|
100 | - $query = array($query); |
|
101 | - if ($_REQUEST['format'] == 'sql') |
|
102 | - die(var_export($query, true)); |
|
98 | + $query = $reports_template[$_REQUEST['type']]['getSQL'](); |
|
99 | + if (! is_array($query)) |
|
100 | + $query = array($query); |
|
101 | + if ($_REQUEST['format'] == 'sql') |
|
102 | + die(var_export($query, true)); |
|
103 | 103 | |
104 | - $result = multiquery_query($query); |
|
104 | + $result = multiquery_query($query); |
|
105 | 105 | |
106 | 106 | |
107 | - // check number of result |
|
108 | - $numberOfResult = multiquery_num_rows($result); |
|
109 | - if ($numberOfResult == 0) { |
|
110 | - // This case should be taken care of by the display template itself, we should let the script run |
|
111 | - //die(get_lang('NoDataAvailable')); |
|
112 | - } |
|
107 | + // check number of result |
|
108 | + $numberOfResult = multiquery_num_rows($result); |
|
109 | + if ($numberOfResult == 0) { |
|
110 | + // This case should be taken care of by the display template itself, we should let the script run |
|
111 | + //die(get_lang('NoDataAvailable')); |
|
112 | + } |
|
113 | 113 | } else { |
114 | - die('<b>'.get_lang('ErrorWhileBuildingReport').'</b>'); |
|
114 | + die('<b>'.get_lang('ErrorWhileBuildingReport').'</b>'); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') { |
118 | - if (isset($reports_template[$_REQUEST['type']]['html_header'])) { |
|
119 | - echo $reports_template[$_REQUEST['type']]['html_header']; |
|
120 | - } |
|
121 | - echo '<script type="text/javascript" charset="utf-8"> |
|
118 | + if (isset($reports_template[$_REQUEST['type']]['html_header'])) { |
|
119 | + echo $reports_template[$_REQUEST['type']]['html_header']; |
|
120 | + } |
|
121 | + echo '<script type="text/javascript" charset="utf-8"> |
|
122 | 122 | $(document).ready(function() { |
123 | 123 | |
124 | 124 | $("#reportsData'.$idsuffix.'").dataTable({ |
@@ -143,50 +143,50 @@ discard block |
||
143 | 143 | }); |
144 | 144 | } ); |
145 | 145 | </script>'; |
146 | - echo '<table id="reportsData'.$idsuffix.'" class="display">'; // FIXME style |
|
147 | - |
|
148 | - // counting fields |
|
149 | - $nfields = multiquery_num_fields($result); |
|
150 | - $columns = array(); |
|
151 | - $columns_islink = array(); |
|
152 | - echo '<thead><tr>'; |
|
153 | - for ($i=0; $i < $nfields; $i++) { |
|
154 | - $columns[$i] = multiquery_field_name($result, $i); |
|
155 | - if (substr($columns[$i], -5, 5) != '_link') { |
|
156 | - $column_islink[$i] = false; |
|
157 | - echo '<th>'.$columns[$i].'</th>'; |
|
158 | - } else |
|
159 | - $columns_islink[$i] = true; |
|
160 | - } |
|
161 | - |
|
162 | - // checking resolving link column id |
|
163 | - $columns_flip = array_flip($columns); |
|
164 | - $columns_link = array(); |
|
165 | - for ($i=0; $i < $nfields; $i++) |
|
166 | - if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip)) |
|
167 | - $columns_link[$i] = $columns_flip[$columns[$i].'_link']; |
|
168 | - else |
|
169 | - $columns_link[$i] = ''; |
|
170 | - echo '</tr></thead><tbody>'; |
|
171 | - while ($row = multiquery_fetch_row($result)) { |
|
172 | - echo '<tr>'; |
|
173 | - for ($i = 0; $i<$nfields; $i++) |
|
174 | - if (!$columns_islink[$i]){ // ignore links |
|
175 | - if ($columns_link[$i] != '') // link is defined |
|
176 | - if (substr($columns_link[$i],0,10) == 'javascript') { |
|
177 | - echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
|
178 | - } |
|
179 | - else { |
|
180 | - echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
|
181 | - } |
|
182 | - else |
|
183 | - echo '<td>'.$row[$i].'</td>'; |
|
184 | - } |
|
185 | - echo "</tr>\n"; |
|
186 | - } |
|
187 | - echo '</tbody></table>'; |
|
188 | - if ($_REQUEST['format'] == 'directlink') { |
|
189 | - echo '</div> |
|
146 | + echo '<table id="reportsData'.$idsuffix.'" class="display">'; // FIXME style |
|
147 | + |
|
148 | + // counting fields |
|
149 | + $nfields = multiquery_num_fields($result); |
|
150 | + $columns = array(); |
|
151 | + $columns_islink = array(); |
|
152 | + echo '<thead><tr>'; |
|
153 | + for ($i=0; $i < $nfields; $i++) { |
|
154 | + $columns[$i] = multiquery_field_name($result, $i); |
|
155 | + if (substr($columns[$i], -5, 5) != '_link') { |
|
156 | + $column_islink[$i] = false; |
|
157 | + echo '<th>'.$columns[$i].'</th>'; |
|
158 | + } else |
|
159 | + $columns_islink[$i] = true; |
|
160 | + } |
|
161 | + |
|
162 | + // checking resolving link column id |
|
163 | + $columns_flip = array_flip($columns); |
|
164 | + $columns_link = array(); |
|
165 | + for ($i=0; $i < $nfields; $i++) |
|
166 | + if ($column_islink[$i] == false && array_key_exists($columns[$i].'_link', $columns_flip)) |
|
167 | + $columns_link[$i] = $columns_flip[$columns[$i].'_link']; |
|
168 | + else |
|
169 | + $columns_link[$i] = ''; |
|
170 | + echo '</tr></thead><tbody>'; |
|
171 | + while ($row = multiquery_fetch_row($result)) { |
|
172 | + echo '<tr>'; |
|
173 | + for ($i = 0; $i<$nfields; $i++) |
|
174 | + if (!$columns_islink[$i]){ // ignore links |
|
175 | + if ($columns_link[$i] != '') // link is defined |
|
176 | + if (substr($columns_link[$i],0,10) == 'javascript') { |
|
177 | + echo '<td><a href="#" onclick="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
|
178 | + } |
|
179 | + else { |
|
180 | + echo '<td><a href="'.$row[$columns_link[$i]].'">'.$row[$i].'</a></td>'; |
|
181 | + } |
|
182 | + else |
|
183 | + echo '<td>'.$row[$i].'</td>'; |
|
184 | + } |
|
185 | + echo "</tr>\n"; |
|
186 | + } |
|
187 | + echo '</tbody></table>'; |
|
188 | + if ($_REQUEST['format'] == 'directlink') { |
|
189 | + echo '</div> |
|
190 | 190 | <div id="result2" class="result" style="margin: 50px;"> |
191 | 191 | </div> |
192 | 192 | <div id="result3" class="result" style="margin: 100px;"> |
@@ -194,36 +194,36 @@ discard block |
||
194 | 194 | <div id="result4" class="result" style="margin: 150px;"> |
195 | 195 | </div>'; |
196 | 196 | |
197 | - Display::display_footer(); |
|
197 | + Display::display_footer(); |
|
198 | 198 | |
199 | - } |
|
199 | + } |
|
200 | 200 | } else if ($_REQUEST['format'] == 'csv') { |
201 | - $nfields = multiquery_num_fields($result); |
|
202 | - $columns = array(); |
|
203 | - $columns_islink = array(); |
|
204 | - for ($i=0; $i < $nfields; $i++) { |
|
205 | - $columns[$i] = multiquery_field_name($result, $i); |
|
206 | - if (substr($columns[$i], -5, 5) != '_link') { |
|
207 | - $column_islink[$i] = false; |
|
208 | - echo csv_escaping($columns[$i]).','; |
|
209 | - } else |
|
210 | - $columns_islink[$i] = true; |
|
211 | - } |
|
212 | - |
|
213 | - echo "\n"; |
|
214 | - while ($row = multiquery_fetch_row($result)) { |
|
215 | - for ($i = 0; $i<$nfields; $i++) |
|
216 | - if (!$columns_islink[$i]) // ignore links |
|
217 | - echo csv_escaping($row[$i]).','; // fixme |
|
218 | - echo "\n"; |
|
219 | - } |
|
201 | + $nfields = multiquery_num_fields($result); |
|
202 | + $columns = array(); |
|
203 | + $columns_islink = array(); |
|
204 | + for ($i=0; $i < $nfields; $i++) { |
|
205 | + $columns[$i] = multiquery_field_name($result, $i); |
|
206 | + if (substr($columns[$i], -5, 5) != '_link') { |
|
207 | + $column_islink[$i] = false; |
|
208 | + echo csv_escaping($columns[$i]).','; |
|
209 | + } else |
|
210 | + $columns_islink[$i] = true; |
|
211 | + } |
|
212 | + |
|
213 | + echo "\n"; |
|
214 | + while ($row = multiquery_fetch_row($result)) { |
|
215 | + for ($i = 0; $i<$nfields; $i++) |
|
216 | + if (!$columns_islink[$i]) // ignore links |
|
217 | + echo csv_escaping($row[$i]).','; // fixme |
|
218 | + echo "\n"; |
|
219 | + } |
|
220 | 220 | } else die(get_lang('UnknownFormat')); |
221 | 221 | |
222 | 222 | function csv_escaping($value, $csv_separator = ',') { |
223 | - $value = str_replace('"','""',$value); |
|
224 | - if (strpos($value, '""') or strpos($value, $csv_separator) or $value != trim($value) ) { |
|
225 | - $value = '"'.$value.'"'; |
|
226 | - } |
|
227 | - return $value; |
|
223 | + $value = str_replace('"','""',$value); |
|
224 | + if (strpos($value, '""') or strpos($value, $csv_separator) or $value != trim($value) ) { |
|
225 | + $value = '"'.$value.'"'; |
|
226 | + } |
|
227 | + return $value; |
|
228 | 228 | } |
229 | 229 | ?> |
@@ -20,140 +20,140 @@ discard block |
||
20 | 20 | { |
21 | 21 | public $js_id; |
22 | 22 | public $answer; |
23 | - /** |
|
24 | - * Returns the HTML + JS flow corresponding to one question |
|
25 | - * |
|
26 | - * @param int $questionId The question ID |
|
27 | - * @param bool $standalone (ie including XML tag, DTD declaration, etc) |
|
28 | - * @param int $js_id The JavaScript ID for this question. |
|
29 | - * Due to the nature of interactions, we must have a natural sequence for |
|
30 | - * questions in the generated JavaScript. |
|
31 | - * @param integer $js_id |
|
23 | + /** |
|
24 | + * Returns the HTML + JS flow corresponding to one question |
|
25 | + * |
|
26 | + * @param int $questionId The question ID |
|
27 | + * @param bool $standalone (ie including XML tag, DTD declaration, etc) |
|
28 | + * @param int $js_id The JavaScript ID for this question. |
|
29 | + * Due to the nature of interactions, we must have a natural sequence for |
|
30 | + * questions in the generated JavaScript. |
|
31 | + * @param integer $js_id |
|
32 | 32 | * @return string|array |
33 | - */ |
|
34 | - public static function export_question($questionId, $standalone = true, $js_id) |
|
35 | - { |
|
36 | - $question = new ScormQuestion(); |
|
37 | - $qst = $question->read($questionId); |
|
38 | - if (!$qst) { |
|
39 | - return ''; |
|
40 | - } |
|
41 | - $question->id = $qst->id; |
|
42 | - $question->js_id = $js_id; |
|
43 | - $question->type = $qst->type; |
|
44 | - $question->question = $qst->question; |
|
45 | - $question->description = $qst->description; |
|
46 | - $question->weighting=$qst->weighting; |
|
47 | - $question->position=$qst->position; |
|
48 | - $question->picture=$qst->picture; |
|
49 | - $assessmentItem = new ScormAssessmentItem($question, $standalone); |
|
50 | - |
|
51 | - return $assessmentItem->export(); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Include the correct answer class and create answer |
|
56 | - */ |
|
57 | - public function setAnswer() |
|
58 | - { |
|
59 | - switch ($this->type) { |
|
60 | - case MCUA: |
|
61 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
62 | - $this->answer->questionJSId = $this->js_id; |
|
63 | - break; |
|
64 | - case MCMA: |
|
65 | - case GLOBAL_MULTIPLE_ANSWER: |
|
66 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
67 | - $this->answer->questionJSId = $this->js_id; |
|
68 | - break; |
|
69 | - case TF: |
|
70 | - $this->answer = new ScormAnswerTrueFalse($this->id); |
|
71 | - $this->answer->questionJSId = $this->js_id; |
|
72 | - break; |
|
73 | - case FIB: |
|
74 | - $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
75 | - $this->answer->questionJSId = $this->js_id; |
|
76 | - break; |
|
77 | - case MATCHING: |
|
78 | - case MATCHING_DRAGGABLE: |
|
79 | - case DRAGGABLE: |
|
80 | - $this->answer = new ScormAnswerMatching($this->id); |
|
81 | - $this->answer->questionJSId = $this->js_id; |
|
82 | - break; |
|
83 | - case ORAL_EXPRESSION: |
|
84 | - case FREE_ANSWER: |
|
85 | - $this->answer = new ScormAnswerFree($this->id); |
|
86 | - $this->answer->questionJSId = $this->js_id; |
|
87 | - break; |
|
88 | - case HOT_SPOT: |
|
89 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
90 | - $this->answer->questionJSId = $this->js_id; |
|
91 | - break; |
|
92 | - case MULTIPLE_ANSWER_COMBINATION: |
|
93 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
94 | - $this->answer->questionJSId = $this->js_id; |
|
95 | - break; |
|
96 | - case HOT_SPOT_ORDER: |
|
97 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
98 | - $this->answer->questionJSId = $this->js_id; |
|
99 | - break; |
|
100 | - case HOT_SPOT_DELINEATION: |
|
101 | - $this->answer = new ScormAnswerHotspot($this->id); |
|
102 | - $this->answer->questionJSId = $this->js_id; |
|
103 | - break; |
|
104 | - // not supported |
|
105 | - case UNIQUE_ANSWER_NO_OPTION: |
|
106 | - case MULTIPLE_ANSWER_TRUE_FALSE: |
|
107 | - case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
|
108 | - case UNIQUE_ANSWER_IMAGE: |
|
109 | - case CALCULATED_ANSWER: |
|
110 | - $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
111 | - $this->answer->questionJSId = $this->js_id; |
|
112 | - break; |
|
113 | - default: |
|
114 | - $this->answer = new stdClass(); |
|
115 | - $this->answer->questionJSId = $this->js_id; |
|
116 | - break; |
|
117 | - } |
|
118 | - |
|
119 | - return true; |
|
120 | - } |
|
121 | - |
|
122 | - function export() |
|
123 | - { |
|
124 | - $html = $this->getQuestionHTML(); |
|
125 | - $js = $this->getQuestionJS(); |
|
126 | - |
|
127 | - if (is_object($this->answer) && $this->answer instanceof Answer) { |
|
128 | - list($js2, $html2) = $this->answer->export(); |
|
129 | - $js .= $js2; |
|
130 | - $html .= $html2; |
|
131 | - } else { |
|
132 | - throw new \Exception('Question not supported. Exercise: '.$this->selectTitle()); |
|
133 | - } |
|
134 | - |
|
135 | - return array($js, $html); |
|
136 | - } |
|
137 | - |
|
138 | - function createAnswersForm($form) |
|
139 | - { |
|
140 | - return true; |
|
141 | - } |
|
142 | - |
|
143 | - function processAnswersCreation($form) |
|
144 | - { |
|
145 | - return true; |
|
146 | - } |
|
147 | - |
|
148 | - /** |
|
149 | - * Returns an HTML-formatted question |
|
150 | - */ |
|
151 | - function getQuestionHTML() |
|
152 | - { |
|
33 | + */ |
|
34 | + public static function export_question($questionId, $standalone = true, $js_id) |
|
35 | + { |
|
36 | + $question = new ScormQuestion(); |
|
37 | + $qst = $question->read($questionId); |
|
38 | + if (!$qst) { |
|
39 | + return ''; |
|
40 | + } |
|
41 | + $question->id = $qst->id; |
|
42 | + $question->js_id = $js_id; |
|
43 | + $question->type = $qst->type; |
|
44 | + $question->question = $qst->question; |
|
45 | + $question->description = $qst->description; |
|
46 | + $question->weighting=$qst->weighting; |
|
47 | + $question->position=$qst->position; |
|
48 | + $question->picture=$qst->picture; |
|
49 | + $assessmentItem = new ScormAssessmentItem($question, $standalone); |
|
50 | + |
|
51 | + return $assessmentItem->export(); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * Include the correct answer class and create answer |
|
56 | + */ |
|
57 | + public function setAnswer() |
|
58 | + { |
|
59 | + switch ($this->type) { |
|
60 | + case MCUA: |
|
61 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
62 | + $this->answer->questionJSId = $this->js_id; |
|
63 | + break; |
|
64 | + case MCMA: |
|
65 | + case GLOBAL_MULTIPLE_ANSWER: |
|
66 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
67 | + $this->answer->questionJSId = $this->js_id; |
|
68 | + break; |
|
69 | + case TF: |
|
70 | + $this->answer = new ScormAnswerTrueFalse($this->id); |
|
71 | + $this->answer->questionJSId = $this->js_id; |
|
72 | + break; |
|
73 | + case FIB: |
|
74 | + $this->answer = new ScormAnswerFillInBlanks($this->id); |
|
75 | + $this->answer->questionJSId = $this->js_id; |
|
76 | + break; |
|
77 | + case MATCHING: |
|
78 | + case MATCHING_DRAGGABLE: |
|
79 | + case DRAGGABLE: |
|
80 | + $this->answer = new ScormAnswerMatching($this->id); |
|
81 | + $this->answer->questionJSId = $this->js_id; |
|
82 | + break; |
|
83 | + case ORAL_EXPRESSION: |
|
84 | + case FREE_ANSWER: |
|
85 | + $this->answer = new ScormAnswerFree($this->id); |
|
86 | + $this->answer->questionJSId = $this->js_id; |
|
87 | + break; |
|
88 | + case HOT_SPOT: |
|
89 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
90 | + $this->answer->questionJSId = $this->js_id; |
|
91 | + break; |
|
92 | + case MULTIPLE_ANSWER_COMBINATION: |
|
93 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
94 | + $this->answer->questionJSId = $this->js_id; |
|
95 | + break; |
|
96 | + case HOT_SPOT_ORDER: |
|
97 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
98 | + $this->answer->questionJSId = $this->js_id; |
|
99 | + break; |
|
100 | + case HOT_SPOT_DELINEATION: |
|
101 | + $this->answer = new ScormAnswerHotspot($this->id); |
|
102 | + $this->answer->questionJSId = $this->js_id; |
|
103 | + break; |
|
104 | + // not supported |
|
105 | + case UNIQUE_ANSWER_NO_OPTION: |
|
106 | + case MULTIPLE_ANSWER_TRUE_FALSE: |
|
107 | + case MULTIPLE_ANSWER_COMBINATION_TRUE_FALSE: |
|
108 | + case UNIQUE_ANSWER_IMAGE: |
|
109 | + case CALCULATED_ANSWER: |
|
110 | + $this->answer = new ScormAnswerMultipleChoice($this->id); |
|
111 | + $this->answer->questionJSId = $this->js_id; |
|
112 | + break; |
|
113 | + default: |
|
114 | + $this->answer = new stdClass(); |
|
115 | + $this->answer->questionJSId = $this->js_id; |
|
116 | + break; |
|
117 | + } |
|
118 | + |
|
119 | + return true; |
|
120 | + } |
|
121 | + |
|
122 | + function export() |
|
123 | + { |
|
124 | + $html = $this->getQuestionHTML(); |
|
125 | + $js = $this->getQuestionJS(); |
|
126 | + |
|
127 | + if (is_object($this->answer) && $this->answer instanceof Answer) { |
|
128 | + list($js2, $html2) = $this->answer->export(); |
|
129 | + $js .= $js2; |
|
130 | + $html .= $html2; |
|
131 | + } else { |
|
132 | + throw new \Exception('Question not supported. Exercise: '.$this->selectTitle()); |
|
133 | + } |
|
134 | + |
|
135 | + return array($js, $html); |
|
136 | + } |
|
137 | + |
|
138 | + function createAnswersForm($form) |
|
139 | + { |
|
140 | + return true; |
|
141 | + } |
|
142 | + |
|
143 | + function processAnswersCreation($form) |
|
144 | + { |
|
145 | + return true; |
|
146 | + } |
|
147 | + |
|
148 | + /** |
|
149 | + * Returns an HTML-formatted question |
|
150 | + */ |
|
151 | + function getQuestionHTML() |
|
152 | + { |
|
153 | 153 | $title = $this->selectTitle(); |
154 | 154 | $description = $this->selectDescription(); |
155 | - $cols = 2; |
|
156 | - $s = '<tr> |
|
155 | + $cols = 2; |
|
156 | + $s = '<tr> |
|
157 | 157 | <td colspan="'.$cols.'" id="question_'.$this->id.'_title" valign="middle" style="background-color:#d6d6d6;"> |
158 | 158 | '.$title.' |
159 | 159 | </td> |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | <i>'.$description.'</i> |
164 | 164 | </td> |
165 | 165 | </tr>'; |
166 | - return $s; |
|
167 | - } |
|
166 | + return $s; |
|
167 | + } |
|
168 | 168 | |
169 | - /** |
|
170 | - * Return the JavaScript code bound to the question |
|
171 | - */ |
|
172 | - public function getQuestionJS() |
|
173 | - { |
|
174 | - $weight = $this->selectWeighting(); |
|
175 | - $js = 'questions.push('.$this->js_id.');'."\n"; |
|
169 | + /** |
|
170 | + * Return the JavaScript code bound to the question |
|
171 | + */ |
|
172 | + public function getQuestionJS() |
|
173 | + { |
|
174 | + $weight = $this->selectWeighting(); |
|
175 | + $js = 'questions.push('.$this->js_id.');'."\n"; |
|
176 | 176 | |
177 | 177 | switch ($this->type) { |
178 | 178 | case ORAL_EXPRESSION: |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | $script .= file_get_contents(api_get_path(LIBRARY_PATH) . 'wami-recorder/gui.js'); |
182 | 182 | $js .= $script;*/ |
183 | 183 | break; |
184 | - case HOT_SPOT: |
|
184 | + case HOT_SPOT: |
|
185 | 185 | //put the max score to 0 to avoid discounting the points of |
186 | 186 | //non-exported quiz types in the SCORM |
187 | 187 | $weight = 0; |
@@ -189,8 +189,8 @@ discard block |
||
189 | 189 | } |
190 | 190 | $js .= 'questions_score_max['.$this->js_id.'] = '.$weight.";"; |
191 | 191 | |
192 | - return $js; |
|
193 | - } |
|
192 | + return $js; |
|
193 | + } |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | /** |
@@ -200,29 +200,29 @@ discard block |
||
200 | 200 | */ |
201 | 201 | class ScormAnswerMultipleChoice extends Answer |
202 | 202 | { |
203 | - /** |
|
204 | - * Return HTML code for possible answers |
|
205 | - */ |
|
206 | - function export() |
|
207 | - { |
|
208 | - $js = ''; |
|
209 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
210 | - $type = $this->getQuestionType(); |
|
211 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'; |
|
212 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'; |
|
203 | + /** |
|
204 | + * Return HTML code for possible answers |
|
205 | + */ |
|
206 | + function export() |
|
207 | + { |
|
208 | + $js = ''; |
|
209 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
210 | + $type = $this->getQuestionType(); |
|
211 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'; |
|
212 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'; |
|
213 | 213 | |
214 | 214 | $jstmpw .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'; |
215 | 215 | |
216 | - //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
217 | - //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
|
218 | - if ($type == MCMA) { |
|
216 | + //not sure if we are going to export also the MULTIPLE_ANSWER_COMBINATION to SCORM |
|
217 | + //if ($type == MCMA || $type == MULTIPLE_ANSWER_COMBINATION ) { |
|
218 | + if ($type == MCMA) { |
|
219 | 219 | $id = 1; |
220 | - $jstmp = ''; |
|
221 | - $jstmpc = ''; |
|
220 | + $jstmp = ''; |
|
221 | + $jstmpc = ''; |
|
222 | 222 | foreach ($this->answer as $i => $answer) { |
223 | - $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
224 | - $html .= |
|
225 | - '<tr> |
|
223 | + $identifier = 'question_'.$this->questionJSId.'_multiple_'.$i; |
|
224 | + $html .= |
|
225 | + '<tr> |
|
226 | 226 | <td align="center" width="5%"> |
227 | 227 | <input name="'.$identifier.'" id="'.$identifier.'" value="'.$i.'" type="checkbox" /> |
228 | 228 | </td> |
@@ -231,19 +231,19 @@ discard block |
||
231 | 231 | </td> |
232 | 232 | </tr>'; |
233 | 233 | |
234 | - $jstmp .= $i.','; |
|
234 | + $jstmp .= $i.','; |
|
235 | 235 | if ($this->correct[$i]) { |
236 | 236 | $jstmpc .= $i.','; |
237 | 237 | } |
238 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";"; |
|
238 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";"; |
|
239 | 239 | $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';'; |
240 | - $id++; |
|
241 | - } |
|
242 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
240 | + $id++; |
|
241 | + } |
|
242 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
243 | 243 | $js .= 'questions_types['.$this->questionJSId.'] = \'mcma\';'."\n"; |
244 | - $js .= $jstmpw; |
|
245 | - } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { |
|
246 | - $js = ''; |
|
244 | + $js .= $jstmpw; |
|
245 | + } elseif ($type == MULTIPLE_ANSWER_COMBINATION) { |
|
246 | + $js = ''; |
|
247 | 247 | $id = 1; |
248 | 248 | $jstmp = ''; |
249 | 249 | $jstmpc = ''; |
@@ -270,15 +270,15 @@ discard block |
||
270 | 270 | $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'; |
271 | 271 | $js .= 'questions_types['.$this->questionJSId.'] = "exact";'; |
272 | 272 | $js .= $jstmpw; |
273 | - } else { |
|
274 | - $id = 1; |
|
275 | - $jstmp = ''; |
|
276 | - $jstmpc = ''; |
|
273 | + } else { |
|
274 | + $id = 1; |
|
275 | + $jstmp = ''; |
|
276 | + $jstmpc = ''; |
|
277 | 277 | foreach ($this->answer as $i => $answer) { |
278 | 278 | $identifier = 'question_'.$this->questionJSId.'_unique_'.$i; |
279 | - $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
280 | - $html .= |
|
281 | - '<tr> |
|
279 | + $identifier_name = 'question_'.$this->questionJSId.'_unique_answer'; |
|
280 | + $html .= |
|
281 | + '<tr> |
|
282 | 282 | <td align="center" width="5%"> |
283 | 283 | <input name="'.$identifier_name.'" id="'.$identifier.'" value="'.$i.'" type="checkbox"/> |
284 | 284 | </td> |
@@ -286,22 +286,22 @@ discard block |
||
286 | 286 | <label for="'.$identifier.'">' . Security::remove_XSS($this->answer[$i]) . '</label> |
287 | 287 | </td> |
288 | 288 | </tr>'; |
289 | - $jstmp .= $i.','; |
|
289 | + $jstmp .= $i.','; |
|
290 | 290 | if ($this->correct[$i]) { |
291 | 291 | $jstmpc .= $i; |
292 | 292 | } |
293 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";"; |
|
293 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$this->weighting[$i].";"; |
|
294 | 294 | $jstmpw .= 'questions_answers_correct['.$this->questionJSId.']['.$i.'] = '.$this->correct[$i].';'; |
295 | - $id++; |
|
296 | - } |
|
297 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'; |
|
298 | - $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'; |
|
299 | - $js .= $jstmpw; |
|
300 | - } |
|
301 | - $html .= '</table></td></tr>'; |
|
302 | - |
|
303 | - return array($js, $html); |
|
304 | - } |
|
295 | + $id++; |
|
296 | + } |
|
297 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'; |
|
298 | + $js .= 'questions_types['.$this->questionJSId.'] = \'mcua\';'; |
|
299 | + $js .= $jstmpw; |
|
300 | + } |
|
301 | + $html .= '</table></td></tr>'; |
|
302 | + |
|
303 | + return array($js, $html); |
|
304 | + } |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -310,21 +310,21 @@ discard block |
||
310 | 310 | */ |
311 | 311 | class ScormAnswerTrueFalse extends Answer |
312 | 312 | { |
313 | - /** |
|
314 | - * Return the XML flow for the possible answers. |
|
315 | - * That's one <response_lid>, containing several <flow_label> |
|
316 | - * |
|
317 | - * @author Amand Tihon <[email protected]> |
|
318 | - */ |
|
319 | - function export() |
|
320 | - { |
|
321 | - $js = ''; |
|
322 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
323 | - $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
324 | - $identifier_true = $identifier.'_true'; |
|
325 | - $identifier_false = $identifier.'_false'; |
|
326 | - $html .= |
|
327 | - '<tr> |
|
313 | + /** |
|
314 | + * Return the XML flow for the possible answers. |
|
315 | + * That's one <response_lid>, containing several <flow_label> |
|
316 | + * |
|
317 | + * @author Amand Tihon <[email protected]> |
|
318 | + */ |
|
319 | + function export() |
|
320 | + { |
|
321 | + $js = ''; |
|
322 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
323 | + $identifier = 'question_'.$this->questionJSId.'_tf'; |
|
324 | + $identifier_true = $identifier.'_true'; |
|
325 | + $identifier_false = $identifier.'_false'; |
|
326 | + $html .= |
|
327 | + '<tr> |
|
328 | 328 | <td align="center" width="5%"> |
329 | 329 | <input name="'.$identifier_true.'" id="'.$identifier_true.'" value="'.$this->trueGrade.'" type="radio" /> |
330 | 330 | </td> |
@@ -332,8 +332,8 @@ discard block |
||
332 | 332 | <label for="'.$identifier_true.'">' . get_lang('True') . '</label> |
333 | 333 | </td> |
334 | 334 | </tr>'; |
335 | - $html .= |
|
336 | - '<tr> |
|
335 | + $html .= |
|
336 | + '<tr> |
|
337 | 337 | <td align="center" width="5%"> |
338 | 338 | <input name="'.$identifier_false.'" id="'.$identifier_false.'" value="'.$this->falseGrade.'" type="radio" /> |
339 | 339 | </td> |
@@ -341,20 +341,20 @@ discard block |
||
341 | 341 | <label for="'.$identifier_false.'">' . get_lang('False') . '</label> |
342 | 342 | </td> |
343 | 343 | </tr></table></td></tr>'; |
344 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
345 | - $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
346 | - if ($this->response === 'TRUE') { |
|
347 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
348 | - } else { |
|
349 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
350 | - } |
|
351 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
352 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
353 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
354 | - $js .= $jstmpw; |
|
355 | - |
|
356 | - return array($js, $html); |
|
357 | - } |
|
344 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array(\'true\',\'false\');'."\n"; |
|
345 | + $js .= 'questions_types['.$this->questionJSId.'] = \'tf\';'."\n"; |
|
346 | + if ($this->response === 'TRUE') { |
|
347 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'true\');'."\n"; |
|
348 | + } else { |
|
349 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array(\'false\');'."\n"; |
|
350 | + } |
|
351 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
352 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
353 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = '.$this->weighting[1].";\n"; |
|
354 | + $js .= $jstmpw; |
|
355 | + |
|
356 | + return array($js, $html); |
|
357 | + } |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | /** |
@@ -363,76 +363,76 @@ discard block |
||
363 | 363 | */ |
364 | 364 | class ScormAnswerFillInBlanks extends Answer |
365 | 365 | { |
366 | - /** |
|
367 | - * Export the text with missing words. |
|
368 | - * |
|
369 | - * As a side effect, it stores two lists in the class : |
|
370 | - * the missing words and their respective weightings. |
|
371 | - */ |
|
372 | - function export() |
|
373 | - { |
|
374 | - global $charset; |
|
375 | - $js = ''; |
|
376 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
377 | - // get all enclosed answers |
|
378 | - $blankList = array(); |
|
379 | - // build replacement |
|
380 | - $replacementList = array(); |
|
381 | - foreach ($this->answer as $i => $answer) { |
|
382 | - $blankList[] = '['.$answer.']'; |
|
383 | - } |
|
384 | - |
|
385 | - // splits text and weightings that are joined with the character '::' |
|
386 | - list($answer,$weight)=explode('::',$answer); |
|
387 | - $weights = explode(',',$weight); |
|
388 | - // because [] is parsed here we follow this procedure: |
|
389 | - // 1. find everything between the [ and ] tags |
|
390 | - $i=1; |
|
391 | - $jstmp = ''; |
|
392 | - $jstmpc = ''; |
|
393 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
394 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
395 | - $startlocations=api_strpos($answer,'['); |
|
396 | - $endlocations=api_strpos($answer,']'); |
|
397 | - while ($startlocations !== false && $endlocations !== false) { |
|
398 | - $texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
399 | - $answer = api_substr_replace( |
|
366 | + /** |
|
367 | + * Export the text with missing words. |
|
368 | + * |
|
369 | + * As a side effect, it stores two lists in the class : |
|
370 | + * the missing words and their respective weightings. |
|
371 | + */ |
|
372 | + function export() |
|
373 | + { |
|
374 | + global $charset; |
|
375 | + $js = ''; |
|
376 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
377 | + // get all enclosed answers |
|
378 | + $blankList = array(); |
|
379 | + // build replacement |
|
380 | + $replacementList = array(); |
|
381 | + foreach ($this->answer as $i => $answer) { |
|
382 | + $blankList[] = '['.$answer.']'; |
|
383 | + } |
|
384 | + |
|
385 | + // splits text and weightings that are joined with the character '::' |
|
386 | + list($answer,$weight)=explode('::',$answer); |
|
387 | + $weights = explode(',',$weight); |
|
388 | + // because [] is parsed here we follow this procedure: |
|
389 | + // 1. find everything between the [ and ] tags |
|
390 | + $i=1; |
|
391 | + $jstmp = ''; |
|
392 | + $jstmpc = ''; |
|
393 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
394 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
395 | + $startlocations=api_strpos($answer,'['); |
|
396 | + $endlocations=api_strpos($answer,']'); |
|
397 | + while ($startlocations !== false && $endlocations !== false) { |
|
398 | + $texstring = api_substr($answer,$startlocations,($endlocations-$startlocations)+1); |
|
399 | + $answer = api_substr_replace( |
|
400 | 400 | $answer, |
401 | 401 | '<input type="text" name="question_'.$this->questionJSId.'_fib_'.$i.'" id="question_'.$this->questionJSId.'_fib_'.$i.'" size="10" value="" />', |
402 | 402 | $startlocations, |
403 | 403 | ($endlocations-$startlocations)+1 |
404 | 404 | ); |
405 | 405 | $jstmp .= $i.','; |
406 | - if (!empty($texstring)) { |
|
407 | - $sub = api_substr($texstring, 1, -1); |
|
408 | - if (!empty($sub)) { |
|
409 | - $jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',"; |
|
410 | - } |
|
411 | - } |
|
406 | + if (!empty($texstring)) { |
|
407 | + $sub = api_substr($texstring, 1, -1); |
|
408 | + if (!empty($sub)) { |
|
409 | + $jstmpc .= "'" . api_htmlentities($sub, ENT_QUOTES, $charset) . "',"; |
|
410 | + } |
|
411 | + } |
|
412 | 412 | $my_weight = explode('@', $weights[$i - 1]); |
413 | 413 | if (count($my_weight) == 2) { |
414 | 414 | $weight_db = $my_weight[0]; |
415 | 415 | } else { |
416 | 416 | $weight_db = $my_weight[0]; |
417 | 417 | } |
418 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
419 | - $i++; |
|
420 | - $startlocations = api_strpos($answer, '['); |
|
421 | - $endlocations = api_strpos($answer, ']'); |
|
422 | - } |
|
418 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.']['.$i.'] = '.$weight_db.";\n"; |
|
419 | + $i++; |
|
420 | + $startlocations = api_strpos($answer, '['); |
|
421 | + $endlocations = api_strpos($answer, ']'); |
|
422 | + } |
|
423 | 423 | |
424 | - $html .= '<tr> |
|
424 | + $html .= '<tr> |
|
425 | 425 | <td> |
426 | 426 | '.$answer.' |
427 | 427 | </td> |
428 | 428 | </tr></table></td></tr>'; |
429 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
430 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
431 | - $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
432 | - $js .= $jstmpw; |
|
429 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.api_substr($jstmp,0,-1).');'."\n"; |
|
430 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.api_substr($jstmpc,0,-1).');'."\n"; |
|
431 | + $js .= 'questions_types['.$this->questionJSId.'] = \'fib\';'."\n"; |
|
432 | + $js .= $jstmpw; |
|
433 | 433 | |
434 | - return array($js,$html); |
|
435 | - } |
|
434 | + return array($js,$html); |
|
435 | + } |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | /** |
@@ -441,65 +441,65 @@ discard block |
||
441 | 441 | */ |
442 | 442 | class ScormAnswerMatching extends Answer |
443 | 443 | { |
444 | - /** |
|
445 | - * Export the question part as a matrix-choice, with only one possible answer per line. |
|
446 | - * @author Amand Tihon <[email protected]> |
|
447 | - */ |
|
448 | - function export() |
|
449 | - { |
|
450 | - $js = ''; |
|
451 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
452 | - // prepare list of right proposition to allow |
|
453 | - // - easiest display |
|
454 | - // - easiest randomisation if needed one day |
|
455 | - // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
456 | - |
|
457 | - // get max length of displayed array |
|
458 | - |
|
459 | - $nbrAnswers = $this->selectNbrAnswers(); |
|
460 | - $cpt1='A'; |
|
461 | - $cpt2=1; |
|
462 | - $Select = array(); |
|
463 | - $qId = $this->questionJSId; |
|
464 | - $s = ''; |
|
465 | - $jstmp = ''; |
|
466 | - $jstmpc = ''; |
|
467 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
468 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
469 | - |
|
470 | - for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
471 | - $identifier = 'question_'.$qId.'_matching_'; |
|
472 | - $answer=$this->selectAnswer($answerId); |
|
473 | - $answerCorrect=$this->isCorrect($answerId); |
|
474 | - $weight=$this->selectWeighting($answerId); |
|
475 | - $jstmp .= $answerId.','; |
|
476 | - |
|
477 | - if (!$answerCorrect) { |
|
478 | - // options (A, B, C, ...) that will be put into the list-box |
|
479 | - $Select[$answerId]['Lettre']=$cpt1; |
|
480 | - // answers that will be shown at the right side |
|
481 | - $Select[$answerId]['Reponse'] = $answer; |
|
482 | - $cpt1++; |
|
483 | - } else { |
|
484 | - $s.='<tr>'; |
|
485 | - $s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>. '.$answer."</td>"; |
|
486 | - $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
487 | - $s.=' <option value="0">--</option>'; |
|
488 | - // fills the list-box |
|
444 | + /** |
|
445 | + * Export the question part as a matrix-choice, with only one possible answer per line. |
|
446 | + * @author Amand Tihon <[email protected]> |
|
447 | + */ |
|
448 | + function export() |
|
449 | + { |
|
450 | + $js = ''; |
|
451 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
452 | + // prepare list of right proposition to allow |
|
453 | + // - easiest display |
|
454 | + // - easiest randomisation if needed one day |
|
455 | + // (here I use array_values to change array keys from $code1 $code2 ... to 0 1 ...) |
|
456 | + |
|
457 | + // get max length of displayed array |
|
458 | + |
|
459 | + $nbrAnswers = $this->selectNbrAnswers(); |
|
460 | + $cpt1='A'; |
|
461 | + $cpt2=1; |
|
462 | + $Select = array(); |
|
463 | + $qId = $this->questionJSId; |
|
464 | + $s = ''; |
|
465 | + $jstmp = ''; |
|
466 | + $jstmpc = ''; |
|
467 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
468 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
469 | + |
|
470 | + for ($answerId=1;$answerId <= $nbrAnswers;$answerId++) { |
|
471 | + $identifier = 'question_'.$qId.'_matching_'; |
|
472 | + $answer=$this->selectAnswer($answerId); |
|
473 | + $answerCorrect=$this->isCorrect($answerId); |
|
474 | + $weight=$this->selectWeighting($answerId); |
|
475 | + $jstmp .= $answerId.','; |
|
476 | + |
|
477 | + if (!$answerCorrect) { |
|
478 | + // options (A, B, C, ...) that will be put into the list-box |
|
479 | + $Select[$answerId]['Lettre']=$cpt1; |
|
480 | + // answers that will be shown at the right side |
|
481 | + $Select[$answerId]['Reponse'] = $answer; |
|
482 | + $cpt1++; |
|
483 | + } else { |
|
484 | + $s.='<tr>'; |
|
485 | + $s.='<td width="40%" valign="top"><b>'.$cpt2.'</b>. '.$answer."</td>"; |
|
486 | + $s.='<td width="20%" align="center"> <select name="'.$identifier.$cpt2.'" id="'.$identifier.$cpt2.'">'; |
|
487 | + $s.=' <option value="0">--</option>'; |
|
488 | + // fills the list-box |
|
489 | 489 | foreach ($Select as $key => $val) { |
490 | 490 | $s .= '<option value="'.$key.'">'.$val['Lettre'].'</option>'; |
491 | 491 | } // end foreach() |
492 | 492 | |
493 | - $s.='</select> </td>'; |
|
494 | - $s.='<td width="40%" valign="top">'; |
|
493 | + $s.='</select> </td>'; |
|
494 | + $s.='<td width="40%" valign="top">'; |
|
495 | 495 | if (isset($Select[$cpt2])) { |
496 | 496 | $s .= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
497 | 497 | } else { |
498 | 498 | $s .= ' '; |
499 | 499 | } |
500 | - $s.="</td></tr>"; |
|
500 | + $s.="</td></tr>"; |
|
501 | 501 | |
502 | - $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
502 | + $jstmpc .= '['.$answerCorrect.','.$cpt2.'],'; |
|
503 | 503 | |
504 | 504 | $my_weight = explode('@', $weight); |
505 | 505 | if (count($my_weight) == 2) { |
@@ -507,32 +507,32 @@ discard block |
||
507 | 507 | } else { |
508 | 508 | $weight = $my_weight[0]; |
509 | 509 | } |
510 | - $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
511 | - $cpt2++; |
|
512 | - |
|
513 | - // if the left side of the "matching" has been completely shown |
|
514 | - if ($answerId == $nbrAnswers) { |
|
515 | - // if there remain answers to be shown on the right side |
|
516 | - while (isset($Select[$cpt2])) { |
|
517 | - $s.= '<tr>'; |
|
518 | - $s.= '<td width="60%" colspan="2"> </td>'; |
|
519 | - $s.= '<td width="40%" valign="top">'; |
|
520 | - $s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
521 | - $s.= "</td></tr>"; |
|
522 | - $cpt2++; |
|
523 | - } // end while() |
|
524 | - } // end if() |
|
525 | - } |
|
526 | - } |
|
527 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
528 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
529 | - $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
530 | - $js .= $jstmpw; |
|
531 | - $html .= $s; |
|
532 | - $html .= '</table></td></tr>' . "\n"; |
|
533 | - |
|
534 | - return array($js, $html); |
|
535 | - } |
|
510 | + $jstmpw .= 'questions_answers_ponderation['.$qId.']['.$cpt2.'] = '.$weight.";\n"; |
|
511 | + $cpt2++; |
|
512 | + |
|
513 | + // if the left side of the "matching" has been completely shown |
|
514 | + if ($answerId == $nbrAnswers) { |
|
515 | + // if there remain answers to be shown on the right side |
|
516 | + while (isset($Select[$cpt2])) { |
|
517 | + $s.= '<tr>'; |
|
518 | + $s.= '<td width="60%" colspan="2"> </td>'; |
|
519 | + $s.= '<td width="40%" valign="top">'; |
|
520 | + $s.= '<b>'.$Select[$cpt2]['Lettre'].'.</b> '.$Select[$cpt2]['Reponse']; |
|
521 | + $s.= "</td></tr>"; |
|
522 | + $cpt2++; |
|
523 | + } // end while() |
|
524 | + } // end if() |
|
525 | + } |
|
526 | + } |
|
527 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array('.substr($jstmp,0,-1).');'."\n"; |
|
528 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = new Array('.substr($jstmpc,0,-1).');'."\n"; |
|
529 | + $js .= 'questions_types['.$this->questionJSId.'] = \'matching\';'."\n"; |
|
530 | + $js .= $jstmpw; |
|
531 | + $html .= $s; |
|
532 | + $html .= '</table></td></tr>' . "\n"; |
|
533 | + |
|
534 | + return array($js, $html); |
|
535 | + } |
|
536 | 536 | } |
537 | 537 | |
538 | 538 | /** |
@@ -541,19 +541,19 @@ discard block |
||
541 | 541 | */ |
542 | 542 | class ScormAnswerFree extends Answer |
543 | 543 | { |
544 | - /** |
|
545 | - * Export the text with missing words. |
|
546 | - * |
|
547 | - * As a side effect, it stores two lists in the class : |
|
548 | - * the missing words and their respective weightings. |
|
549 | - * |
|
550 | - */ |
|
551 | - function export() |
|
552 | - { |
|
553 | - $js = ''; |
|
544 | + /** |
|
545 | + * Export the text with missing words. |
|
546 | + * |
|
547 | + * As a side effect, it stores two lists in the class : |
|
548 | + * the missing words and their respective weightings. |
|
549 | + * |
|
550 | + */ |
|
551 | + function export() |
|
552 | + { |
|
553 | + $js = ''; |
|
554 | 554 | $identifier = 'question_'.$this->questionJSId.'_free'; |
555 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
556 | - $html = '<tr><td colspan="2">'; |
|
555 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
556 | + $html = '<tr><td colspan="2">'; |
|
557 | 557 | $type = $this->getQuestionType(); |
558 | 558 | |
559 | 559 | if ($type == ORAL_EXPRESSION) { |
@@ -565,21 +565,21 @@ discard block |
||
565 | 565 | $layout = $template->get_template('document/record_audio.tpl'); |
566 | 566 | $html .= $template->fetch($layout);*/ |
567 | 567 | |
568 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
568 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
569 | 569 | |
570 | 570 | return array($js, $html); |
571 | 571 | } |
572 | 572 | |
573 | 573 | $html .= '<textarea minlength="20" name="'.$identifier.'" id="'.$identifier.'" ></textarea>'; |
574 | 574 | $html .= '</td></tr>'; |
575 | - $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'; |
|
576 | - $js .= 'questions_answers_correct['.$this->questionJSId.'] = "";'; |
|
577 | - $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'; |
|
578 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";'; |
|
579 | - $js .= $jstmpw; |
|
580 | - |
|
581 | - return array($js, $html); |
|
582 | - } |
|
575 | + $js .= 'questions_answers['.$this->questionJSId.'] = new Array();'; |
|
576 | + $js .= 'questions_answers_correct['.$this->questionJSId.'] = "";'; |
|
577 | + $js .= 'questions_types['.$this->questionJSId.'] = \'free\';'; |
|
578 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = "0";'; |
|
579 | + $js .= $jstmpw; |
|
580 | + |
|
581 | + return array($js, $html); |
|
582 | + } |
|
583 | 583 | } |
584 | 584 | /** |
585 | 585 | * This class handles the SCORM export of hotpot questions |
@@ -587,63 +587,63 @@ discard block |
||
587 | 587 | */ |
588 | 588 | class ScormAnswerHotspot extends Answer |
589 | 589 | { |
590 | - /** |
|
591 | - * Returns the javascript code that goes with HotSpot exercises |
|
592 | - * @return string The JavaScript code |
|
593 | - */ |
|
594 | - function get_js_header() |
|
595 | - { |
|
596 | - if ($this->standalone) { |
|
597 | - $header = '<script>'; |
|
598 | - $header .= file_get_contents(api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js'); |
|
599 | - $header .= '</script>'; |
|
600 | - //because this header closes so many times the <script> tag, we have to reopen our own |
|
601 | - $header .= '<script>'; |
|
602 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
603 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
604 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
605 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
606 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
607 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
608 | - $header .= $jstmpw; |
|
609 | - } else { |
|
610 | - $header = ''; |
|
611 | - $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
612 | - $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
613 | - $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
614 | - $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
615 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
616 | - $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
617 | - $header .= $jstmpw; |
|
618 | - } |
|
619 | - |
|
620 | - return $header; |
|
621 | - } |
|
622 | - /** |
|
623 | - * Export the text with missing words. |
|
624 | - * |
|
625 | - * As a side effect, it stores two lists in the class : |
|
626 | - * the missing words and their respective weightings. |
|
627 | - * |
|
628 | - */ |
|
629 | - function export() |
|
630 | - { |
|
631 | - $js = $this->get_js_header(); |
|
632 | - $html = '<tr><td colspan="2"><table width="100%">'; |
|
633 | - // some javascript must be added for that kind of questions |
|
634 | - $html .= ''; |
|
635 | - |
|
636 | - // Get the answers, make a list |
|
637 | - $nbrAnswers=$this->selectNbrAnswers(); |
|
638 | - |
|
639 | - $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
590 | + /** |
|
591 | + * Returns the javascript code that goes with HotSpot exercises |
|
592 | + * @return string The JavaScript code |
|
593 | + */ |
|
594 | + function get_js_header() |
|
595 | + { |
|
596 | + if ($this->standalone) { |
|
597 | + $header = '<script>'; |
|
598 | + $header .= file_get_contents(api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js'); |
|
599 | + $header .= '</script>'; |
|
600 | + //because this header closes so many times the <script> tag, we have to reopen our own |
|
601 | + $header .= '<script>'; |
|
602 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
603 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
604 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
605 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
606 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
607 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'.";\n"; |
|
608 | + $header .= $jstmpw; |
|
609 | + } else { |
|
610 | + $header = ''; |
|
611 | + $header .= 'questions_answers['.$this->questionJSId.'] = new Array();'."\n"; |
|
612 | + $header .= 'questions_answers_correct['.$this->questionJSId.'] = new Array();'."\n"; |
|
613 | + $header .= 'questions_types['.$this->questionJSId.'] = \'hotspot\';'."\n"; |
|
614 | + $jstmpw = 'questions_answers_ponderation['.$this->questionJSId.'] = new Array();'."\n"; |
|
615 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][0] = 0;'."\n"; |
|
616 | + $jstmpw .= 'questions_answers_ponderation['.$this->questionJSId.'][1] = 0;'."\n"; |
|
617 | + $header .= $jstmpw; |
|
618 | + } |
|
619 | + |
|
620 | + return $header; |
|
621 | + } |
|
622 | + /** |
|
623 | + * Export the text with missing words. |
|
624 | + * |
|
625 | + * As a side effect, it stores two lists in the class : |
|
626 | + * the missing words and their respective weightings. |
|
627 | + * |
|
628 | + */ |
|
629 | + function export() |
|
630 | + { |
|
631 | + $js = $this->get_js_header(); |
|
632 | + $html = '<tr><td colspan="2"><table width="100%">'; |
|
633 | + // some javascript must be added for that kind of questions |
|
634 | + $html .= ''; |
|
635 | + |
|
636 | + // Get the answers, make a list |
|
637 | + $nbrAnswers=$this->selectNbrAnswers(); |
|
638 | + |
|
639 | + $answer_list = '<div style="padding: 10px; margin-left: -8px; border: 1px solid #4271b5; height: 448px; width: 200px;"><b>'.get_lang('HotspotZones').'</b><ol>'; |
|
640 | 640 | for ($answerId = 1; $answerId <= $nbrAnswers; $answerId++) { |
641 | 641 | $answer_list .= '<li>'.$this->selectAnswer($answerId).'</li>'; |
642 | 642 | } |
643 | 643 | $answer_list .= '</ol></div>'; |
644 | - $canClick = true; |
|
645 | - $relPath = api_get_path(REL_PATH); |
|
646 | - $html .= <<<HTML |
|
644 | + $canClick = true; |
|
645 | + $relPath = api_get_path(REL_PATH); |
|
646 | + $html .= <<<HTML |
|
647 | 647 | <tr> |
648 | 648 | <td> |
649 | 649 | <div id="hotspot-{$this->questionJSId}"></div> |
@@ -663,13 +663,13 @@ discard block |
||
663 | 663 | </td> |
664 | 664 | <tr> |
665 | 665 | HTML; |
666 | - $html .= '</table></td></tr>'; |
|
666 | + $html .= '</table></td></tr>'; |
|
667 | 667 | |
668 | - // currently the free answers cannot be displayed, so ignore the textarea |
|
669 | - $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
668 | + // currently the free answers cannot be displayed, so ignore the textarea |
|
669 | + $html = '<tr><td colspan="2">'.get_lang('ThisItemIsNotExportable').'</td></tr>'; |
|
670 | 670 | |
671 | - return array($js, $html); |
|
672 | - } |
|
671 | + return array($js, $html); |
|
672 | + } |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | /** |
@@ -684,32 +684,32 @@ discard block |
||
684 | 684 | */ |
685 | 685 | class ScormAssessmentItem |
686 | 686 | { |
687 | - public $question; |
|
688 | - public $question_ident; |
|
689 | - public $answer; |
|
690 | - public $standalone; |
|
691 | - |
|
692 | - /** |
|
693 | - * Constructor. |
|
694 | - * |
|
695 | - * @param ScormQuestion $question The Question object we want to export. |
|
696 | - */ |
|
697 | - public function __construct($question, $standalone = false) |
|
698 | - { |
|
699 | - $this->question = $question; |
|
700 | - $this->question->setAnswer(); |
|
701 | - $this->questionIdent = "QST_" . $question->id ; |
|
702 | - $this->standalone = $standalone; |
|
703 | - } |
|
704 | - |
|
705 | - /** |
|
706 | - * Start the XML flow. |
|
707 | - * |
|
708 | - * This opens the <item> block, with correct attributes. |
|
709 | - * |
|
710 | - */ |
|
711 | - function start_page() |
|
712 | - { |
|
687 | + public $question; |
|
688 | + public $question_ident; |
|
689 | + public $answer; |
|
690 | + public $standalone; |
|
691 | + |
|
692 | + /** |
|
693 | + * Constructor. |
|
694 | + * |
|
695 | + * @param ScormQuestion $question The Question object we want to export. |
|
696 | + */ |
|
697 | + public function __construct($question, $standalone = false) |
|
698 | + { |
|
699 | + $this->question = $question; |
|
700 | + $this->question->setAnswer(); |
|
701 | + $this->questionIdent = "QST_" . $question->id ; |
|
702 | + $this->standalone = $standalone; |
|
703 | + } |
|
704 | + |
|
705 | + /** |
|
706 | + * Start the XML flow. |
|
707 | + * |
|
708 | + * This opens the <item> block, with correct attributes. |
|
709 | + * |
|
710 | + */ |
|
711 | + function start_page() |
|
712 | + { |
|
713 | 713 | $head = ''; |
714 | 714 | if ($this->standalone) { |
715 | 715 | $charset = 'UTF-8'; |
@@ -717,89 +717,89 @@ discard block |
||
717 | 717 | $head .= '<html>'; |
718 | 718 | } |
719 | 719 | |
720 | - return $head; |
|
721 | - } |
|
720 | + return $head; |
|
721 | + } |
|
722 | 722 | |
723 | - /** |
|
724 | - * End the XML flow, closing the </item> tag. |
|
725 | - * |
|
726 | - */ |
|
727 | - function end_page() |
|
723 | + /** |
|
724 | + * End the XML flow, closing the </item> tag. |
|
725 | + * |
|
726 | + */ |
|
727 | + function end_page() |
|
728 | + { |
|
729 | + if ($this->standalone) { |
|
730 | + return '</html>'; |
|
731 | + } |
|
732 | + |
|
733 | + return ''; |
|
734 | + } |
|
735 | + |
|
736 | + /** |
|
737 | + * Start document header |
|
738 | + */ |
|
739 | + function start_header() |
|
740 | + { |
|
741 | + if ($this->standalone) { |
|
742 | + return '<head>'; |
|
743 | + } |
|
744 | + |
|
745 | + return ''; |
|
746 | + } |
|
747 | + |
|
748 | + /** |
|
749 | + * Print CSS inclusion |
|
750 | + */ |
|
751 | + function css() |
|
752 | + { |
|
753 | + $css = ''; |
|
754 | + if ($this->standalone) { |
|
755 | + $css = '<style type="text/css" media="screen, projection">'; |
|
756 | + $css .= '/*<![CDATA[*/'."\n"; |
|
757 | + $css .= '/*]]>*/'."\n"; |
|
758 | + $css .= '</style>'."\n"; |
|
759 | + $css .= '<style type="text/css" media="print">'; |
|
760 | + $css .= '/*<![CDATA[*/'."\n"; |
|
761 | + $css .= '/*]]>*/'."\n"; |
|
762 | + $css .= '</style>'; |
|
763 | + } |
|
764 | + |
|
765 | + return $css; |
|
766 | + } |
|
767 | + |
|
768 | + /** |
|
769 | + * End document header |
|
770 | + */ |
|
771 | + function end_header() |
|
772 | + { |
|
773 | + if ($this->standalone) { |
|
774 | + return '</head>'; |
|
775 | + } |
|
776 | + |
|
777 | + return ''; |
|
778 | + } |
|
779 | + /** |
|
780 | + * Start the itemBody |
|
781 | + * |
|
782 | + */ |
|
783 | + function start_js() |
|
728 | 784 | { |
729 | - if ($this->standalone) { |
|
730 | - return '</html>'; |
|
731 | - } |
|
732 | - |
|
733 | - return ''; |
|
734 | - } |
|
735 | - |
|
736 | - /** |
|
737 | - * Start document header |
|
738 | - */ |
|
739 | - function start_header() |
|
740 | - { |
|
741 | - if ($this->standalone) { |
|
742 | - return '<head>'; |
|
743 | - } |
|
744 | - |
|
745 | - return ''; |
|
746 | - } |
|
747 | - |
|
748 | - /** |
|
749 | - * Print CSS inclusion |
|
750 | - */ |
|
751 | - function css() |
|
752 | - { |
|
753 | - $css = ''; |
|
754 | - if ($this->standalone) { |
|
755 | - $css = '<style type="text/css" media="screen, projection">'; |
|
756 | - $css .= '/*<![CDATA[*/'."\n"; |
|
757 | - $css .= '/*]]>*/'."\n"; |
|
758 | - $css .= '</style>'."\n"; |
|
759 | - $css .= '<style type="text/css" media="print">'; |
|
760 | - $css .= '/*<![CDATA[*/'."\n"; |
|
761 | - $css .= '/*]]>*/'."\n"; |
|
762 | - $css .= '</style>'; |
|
763 | - } |
|
764 | - |
|
765 | - return $css; |
|
766 | - } |
|
767 | - |
|
768 | - /** |
|
769 | - * End document header |
|
770 | - */ |
|
771 | - function end_header() |
|
772 | - { |
|
773 | - if ($this->standalone) { |
|
774 | - return '</head>'; |
|
775 | - } |
|
776 | - |
|
777 | - return ''; |
|
778 | - } |
|
779 | - /** |
|
780 | - * Start the itemBody |
|
781 | - * |
|
782 | - */ |
|
783 | - function start_js() |
|
784 | - { |
|
785 | 785 | $js = '<script type="text/javascript" src="assets/api_wrapper.js"></script>'; |
786 | - if ($this->standalone) { |
|
787 | - return '<script>'; |
|
788 | - } |
|
789 | - return $js; |
|
790 | - } |
|
791 | - |
|
792 | - /** |
|
793 | - * Common JS functions |
|
794 | - */ |
|
795 | - function common_js() |
|
796 | - { |
|
797 | - $js = 'var questions = new Array();'; |
|
798 | - $js .= 'var questions_answers = new Array();'; |
|
799 | - $js .= 'var questions_answers_correct = new Array();'; |
|
800 | - $js .= 'var questions_types = new Array();'; |
|
801 | - $js .= "\n" . |
|
802 | - '/** |
|
786 | + if ($this->standalone) { |
|
787 | + return '<script>'; |
|
788 | + } |
|
789 | + return $js; |
|
790 | + } |
|
791 | + |
|
792 | + /** |
|
793 | + * Common JS functions |
|
794 | + */ |
|
795 | + function common_js() |
|
796 | + { |
|
797 | + $js = 'var questions = new Array();'; |
|
798 | + $js .= 'var questions_answers = new Array();'; |
|
799 | + $js .= 'var questions_answers_correct = new Array();'; |
|
800 | + $js .= 'var questions_types = new Array();'; |
|
801 | + $js .= "\n" . |
|
802 | + '/** |
|
803 | 803 | * Assigns any event handler to any element |
804 | 804 | * @param object Element on which the event is added |
805 | 805 | * @param string Name of event |
@@ -834,79 +834,79 @@ discard block |
||
834 | 834 | addEvent(window,\'unload\',unloadPage,false); |
835 | 835 | }'."\n\n"; |
836 | 836 | |
837 | - $js .= ''; |
|
838 | - $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
|
837 | + $js .= ''; |
|
838 | + $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
|
839 | 839 | if ($this->standalone) { |
840 | 840 | return $js."\n"; |
841 | 841 | } |
842 | - return ''; |
|
843 | - } |
|
844 | - |
|
845 | - /** |
|
846 | - * End the itemBody part. |
|
847 | - * |
|
848 | - */ |
|
849 | - function end_js() |
|
850 | - { |
|
842 | + return ''; |
|
843 | + } |
|
844 | + |
|
845 | + /** |
|
846 | + * End the itemBody part. |
|
847 | + * |
|
848 | + */ |
|
849 | + function end_js() |
|
850 | + { |
|
851 | 851 | if ($this->standalone) { |
852 | 852 | return '</script>'; |
853 | 853 | } |
854 | 854 | |
855 | 855 | return ''; |
856 | - } |
|
857 | - |
|
858 | - /** |
|
859 | - * Start the itemBody |
|
860 | - * |
|
861 | - */ |
|
862 | - function start_body() |
|
863 | - { |
|
864 | - if ($this->standalone) { |
|
865 | - return '<body><form id="dokeos_scorm_form" method="post" action="">'; |
|
866 | - } |
|
867 | - |
|
868 | - return ''; |
|
869 | - } |
|
870 | - |
|
871 | - /** |
|
872 | - * End the itemBody part. |
|
873 | - * |
|
874 | - */ |
|
875 | - function end_body() |
|
876 | - { |
|
877 | - if ($this->standalone) { |
|
878 | - return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; |
|
879 | - } |
|
880 | - |
|
881 | - return ''; |
|
882 | - } |
|
883 | - |
|
884 | - /** |
|
885 | - * Export the question as a SCORM Item. |
|
886 | - * This is a default behaviour, some classes may want to override this. |
|
887 | - * @return string|array A string, the XML flow for an Item. |
|
888 | - */ |
|
889 | - function export() |
|
890 | - { |
|
891 | - list($js, $html) = $this->question->export(); |
|
892 | - if ($this->standalone) { |
|
893 | - $res = $this->start_page() |
|
894 | - . $this->start_header() |
|
895 | - . $this->css() |
|
896 | - . $this->start_js() |
|
897 | - . $this->common_js() |
|
898 | - . $js |
|
899 | - . $this->end_js() |
|
900 | - . $this->end_header() |
|
901 | - . $this->start_body() |
|
856 | + } |
|
857 | + |
|
858 | + /** |
|
859 | + * Start the itemBody |
|
860 | + * |
|
861 | + */ |
|
862 | + function start_body() |
|
863 | + { |
|
864 | + if ($this->standalone) { |
|
865 | + return '<body><form id="dokeos_scorm_form" method="post" action="">'; |
|
866 | + } |
|
867 | + |
|
868 | + return ''; |
|
869 | + } |
|
870 | + |
|
871 | + /** |
|
872 | + * End the itemBody part. |
|
873 | + * |
|
874 | + */ |
|
875 | + function end_body() |
|
876 | + { |
|
877 | + if ($this->standalone) { |
|
878 | + return '<br /><input class="btn" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; |
|
879 | + } |
|
880 | + |
|
881 | + return ''; |
|
882 | + } |
|
883 | + |
|
884 | + /** |
|
885 | + * Export the question as a SCORM Item. |
|
886 | + * This is a default behaviour, some classes may want to override this. |
|
887 | + * @return string|array A string, the XML flow for an Item. |
|
888 | + */ |
|
889 | + function export() |
|
890 | + { |
|
891 | + list($js, $html) = $this->question->export(); |
|
892 | + if ($this->standalone) { |
|
893 | + $res = $this->start_page() |
|
894 | + . $this->start_header() |
|
895 | + . $this->css() |
|
896 | + . $this->start_js() |
|
897 | + . $this->common_js() |
|
898 | + . $js |
|
899 | + . $this->end_js() |
|
900 | + . $this->end_header() |
|
901 | + . $this->start_body() |
|
902 | 902 | . $html |
903 | - . $this->end_body() |
|
904 | - . $this->end_page(); |
|
905 | - return $res; |
|
906 | - } else { |
|
907 | - return array($js, $html); |
|
908 | - } |
|
909 | - } |
|
903 | + . $this->end_body() |
|
904 | + . $this->end_page(); |
|
905 | + return $res; |
|
906 | + } else { |
|
907 | + return array($js, $html); |
|
908 | + } |
|
909 | + } |
|
910 | 910 | } |
911 | 911 | |
912 | 912 | /** |
@@ -923,103 +923,103 @@ discard block |
||
923 | 923 | */ |
924 | 924 | class ScormSection |
925 | 925 | { |
926 | - public $exercise; |
|
927 | - public $standalone; |
|
928 | - |
|
929 | - /** |
|
930 | - * Send a complete exercise in SCORM format, from its ID |
|
931 | - * |
|
932 | - * @param Exercise $exercise The exercise to export |
|
933 | - * @param boolean $standalone Wether it should include XML tag and DTD line. |
|
934 | - * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
935 | - */ |
|
936 | - public static function export_exercise_to_scorm(Exercise $exercise, $standalone = true) |
|
937 | - { |
|
938 | - $ims = new ScormSection($exercise); |
|
939 | - $xml = $ims->export($standalone); |
|
940 | - |
|
941 | - return $xml; |
|
942 | - } |
|
943 | - |
|
944 | - /** |
|
945 | - * Constructor. |
|
946 | - * @param Exercise $exe The Exercise instance to export |
|
947 | - * @author Amand Tihon <[email protected]> |
|
948 | - */ |
|
949 | - public function __construct($exe) |
|
950 | - { |
|
951 | - $this->exercise = $exe; |
|
952 | - } |
|
953 | - |
|
954 | - /** |
|
955 | - * Start the XML flow. |
|
956 | - * |
|
957 | - * This opens the <item> block, with correct attributes. |
|
958 | - * |
|
959 | - */ |
|
960 | - function start_page() |
|
961 | - { |
|
926 | + public $exercise; |
|
927 | + public $standalone; |
|
928 | + |
|
929 | + /** |
|
930 | + * Send a complete exercise in SCORM format, from its ID |
|
931 | + * |
|
932 | + * @param Exercise $exercise The exercise to export |
|
933 | + * @param boolean $standalone Wether it should include XML tag and DTD line. |
|
934 | + * @return string XML as a string, or an empty string if there's no exercise with given ID. |
|
935 | + */ |
|
936 | + public static function export_exercise_to_scorm(Exercise $exercise, $standalone = true) |
|
937 | + { |
|
938 | + $ims = new ScormSection($exercise); |
|
939 | + $xml = $ims->export($standalone); |
|
940 | + |
|
941 | + return $xml; |
|
942 | + } |
|
943 | + |
|
944 | + /** |
|
945 | + * Constructor. |
|
946 | + * @param Exercise $exe The Exercise instance to export |
|
947 | + * @author Amand Tihon <[email protected]> |
|
948 | + */ |
|
949 | + public function __construct($exe) |
|
950 | + { |
|
951 | + $this->exercise = $exe; |
|
952 | + } |
|
953 | + |
|
954 | + /** |
|
955 | + * Start the XML flow. |
|
956 | + * |
|
957 | + * This opens the <item> block, with correct attributes. |
|
958 | + * |
|
959 | + */ |
|
960 | + function start_page() |
|
961 | + { |
|
962 | 962 | $charset = 'UTF-8'; |
963 | - $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>'; |
|
964 | - |
|
965 | - return $head; |
|
966 | - } |
|
967 | - |
|
968 | - /** |
|
969 | - * End the XML flow, closing the </item> tag. |
|
970 | - * |
|
971 | - */ |
|
972 | - function end_page() |
|
973 | - { |
|
974 | - return '</html>'; |
|
975 | - } |
|
976 | - |
|
977 | - /** |
|
978 | - * Start document header |
|
979 | - */ |
|
980 | - function start_header() |
|
981 | - { |
|
982 | - return '<head>'; |
|
983 | - } |
|
984 | - |
|
985 | - /** |
|
986 | - * Print CSS inclusion |
|
987 | - */ |
|
988 | - private function css() |
|
989 | - { |
|
990 | - return ''; |
|
991 | - } |
|
992 | - |
|
993 | - /** |
|
994 | - * End document header |
|
995 | - */ |
|
963 | + $head = '<?xml version="1.0" encoding="'.$charset.'" standalone="no"?><html>'; |
|
964 | + |
|
965 | + return $head; |
|
966 | + } |
|
967 | + |
|
968 | + /** |
|
969 | + * End the XML flow, closing the </item> tag. |
|
970 | + * |
|
971 | + */ |
|
972 | + function end_page() |
|
973 | + { |
|
974 | + return '</html>'; |
|
975 | + } |
|
976 | + |
|
977 | + /** |
|
978 | + * Start document header |
|
979 | + */ |
|
980 | + function start_header() |
|
981 | + { |
|
982 | + return '<head>'; |
|
983 | + } |
|
984 | + |
|
985 | + /** |
|
986 | + * Print CSS inclusion |
|
987 | + */ |
|
988 | + private function css() |
|
989 | + { |
|
990 | + return ''; |
|
991 | + } |
|
992 | + |
|
993 | + /** |
|
994 | + * End document header |
|
995 | + */ |
|
996 | 996 | private function end_header() |
997 | - { |
|
998 | - return '</head>'; |
|
999 | - } |
|
1000 | - |
|
1001 | - /** |
|
1002 | - * Start the itemBody |
|
1003 | - * |
|
1004 | - */ |
|
997 | + { |
|
998 | + return '</head>'; |
|
999 | + } |
|
1000 | + |
|
1001 | + /** |
|
1002 | + * Start the itemBody |
|
1003 | + * |
|
1004 | + */ |
|
1005 | 1005 | private function start_js() |
1006 | - { |
|
1007 | - return '<script>'; |
|
1008 | - } |
|
1009 | - |
|
1010 | - /** |
|
1011 | - * Common JS functions |
|
1012 | - */ |
|
1013 | - public function common_js() |
|
1014 | - { |
|
1015 | - $js = file_get_contents(api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js'); |
|
1016 | - |
|
1017 | - $js .= 'var questions = new Array();' . "\n"; |
|
1018 | - $js .= 'var questions_answers = new Array();' . "\n"; |
|
1019 | - $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
1020 | - $js .= 'var questions_types = new Array();' . "\n"; |
|
1021 | - $js .= "\n" . |
|
1022 | - '/** |
|
1006 | + { |
|
1007 | + return '<script>'; |
|
1008 | + } |
|
1009 | + |
|
1010 | + /** |
|
1011 | + * Common JS functions |
|
1012 | + */ |
|
1013 | + public function common_js() |
|
1014 | + { |
|
1015 | + $js = file_get_contents(api_get_path(WEB_LIBRARY_JS_PATH).'hotspot/js/hotspot.js'); |
|
1016 | + |
|
1017 | + $js .= 'var questions = new Array();' . "\n"; |
|
1018 | + $js .= 'var questions_answers = new Array();' . "\n"; |
|
1019 | + $js .= 'var questions_answers_correct = new Array();' . "\n"; |
|
1020 | + $js .= 'var questions_types = new Array();' . "\n"; |
|
1021 | + $js .= "\n" . |
|
1022 | + '/** |
|
1023 | 1023 | * Assigns any event handler to any element |
1024 | 1024 | * @param object Element on which the event is added |
1025 | 1025 | * @param string Name of event |
@@ -1061,76 +1061,76 @@ discard block |
||
1061 | 1061 | } |
1062 | 1062 | '."\n"; |
1063 | 1063 | |
1064 | - $js .= ''; |
|
1065 | - $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
|
1066 | - return $js. "\n"; |
|
1067 | - } |
|
1064 | + $js .= ''; |
|
1065 | + $js .= 'addEvent(window,\'load\',addListeners,false);'."\n"; |
|
1066 | + return $js. "\n"; |
|
1067 | + } |
|
1068 | + |
|
1069 | + /** |
|
1070 | + * End the itemBody part. |
|
1071 | + * |
|
1072 | + */ |
|
1073 | + function end_js() |
|
1074 | + { |
|
1075 | + return '</script>'; |
|
1076 | + } |
|
1077 | + |
|
1078 | + /** |
|
1079 | + * Start the itemBody |
|
1080 | + * |
|
1081 | + */ |
|
1082 | + function start_body() |
|
1083 | + { |
|
1084 | + return '<body>'. |
|
1085 | + '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>". |
|
1086 | + '<form id="dokeos_scorm_form" method="post" action="">'. |
|
1087 | + '<table width="100%">'; |
|
1088 | + } |
|
1089 | + |
|
1090 | + /** |
|
1091 | + * End the itemBody part. |
|
1092 | + * |
|
1093 | + */ |
|
1094 | + function end_body() |
|
1095 | + { |
|
1096 | + return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; |
|
1097 | + } |
|
1068 | 1098 | |
1069 | - /** |
|
1070 | - * End the itemBody part. |
|
1071 | - * |
|
1072 | - */ |
|
1073 | - function end_js() |
|
1099 | + /** |
|
1100 | + * Export the question as a SCORM Item. |
|
1101 | + * |
|
1102 | + * This is a default behaviour, some classes may want to override this. |
|
1103 | + * |
|
1104 | + * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
1105 | + * @return string string, the XML flow for an Item. |
|
1106 | + */ |
|
1107 | + function export() |
|
1074 | 1108 | { |
1075 | - return '</script>'; |
|
1076 | - } |
|
1077 | - |
|
1078 | - /** |
|
1079 | - * Start the itemBody |
|
1080 | - * |
|
1081 | - */ |
|
1082 | - function start_body() |
|
1083 | - { |
|
1084 | - return '<body>'. |
|
1085 | - '<h1>'.$this->exercise->selectTitle().'</h1><p>'.$this->exercise->selectDescription()."</p>". |
|
1086 | - '<form id="dokeos_scorm_form" method="post" action="">'. |
|
1087 | - '<table width="100%">'; |
|
1088 | - } |
|
1089 | - |
|
1090 | - /** |
|
1091 | - * End the itemBody part. |
|
1092 | - * |
|
1093 | - */ |
|
1094 | - function end_body() |
|
1095 | - { |
|
1096 | - return '</table><br /><input class="btn btn-primary" type="button" id="dokeos_scorm_submit" name="dokeos_scorm_submit" value="OK" /></form></body>'; |
|
1097 | - } |
|
1098 | - |
|
1099 | - /** |
|
1100 | - * Export the question as a SCORM Item. |
|
1101 | - * |
|
1102 | - * This is a default behaviour, some classes may want to override this. |
|
1103 | - * |
|
1104 | - * @param $standalone: Boolean stating if it should be exported as a stand-alone question |
|
1105 | - * @return string string, the XML flow for an Item. |
|
1106 | - */ |
|
1107 | - function export() |
|
1108 | - { |
|
1109 | - global $charset; |
|
1110 | - |
|
1111 | - $head = ''; |
|
1112 | - if ($this->standalone) { |
|
1113 | - $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n" |
|
1114 | - . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"; |
|
1115 | - } |
|
1116 | - |
|
1117 | - list($js, $html) = $this->export_questions(); |
|
1118 | - $res = $this->start_page() |
|
1119 | - . $this->start_header() |
|
1120 | - . $this->css() |
|
1109 | + global $charset; |
|
1110 | + |
|
1111 | + $head = ''; |
|
1112 | + if ($this->standalone) { |
|
1113 | + $head = '<?xml version = "1.0" encoding = "' . $charset . '" standalone = "no"?>' . "\n" |
|
1114 | + . '<!DOCTYPE questestinterop SYSTEM "ims_qtiasiv2p1.dtd">' . "\n"; |
|
1115 | + } |
|
1116 | + |
|
1117 | + list($js, $html) = $this->export_questions(); |
|
1118 | + $res = $this->start_page() |
|
1119 | + . $this->start_header() |
|
1120 | + . $this->css() |
|
1121 | 1121 | . $this->globalAssets() |
1122 | - . $this->start_js() |
|
1123 | - . $this->common_js() |
|
1124 | - . $js |
|
1125 | - . $this->end_js() |
|
1126 | - . $this->end_header() |
|
1127 | - . $this->start_body() |
|
1128 | - . $html |
|
1129 | - . $this->end_body() |
|
1130 | - . $this->end_page(); |
|
1131 | - |
|
1132 | - return $res; |
|
1133 | - } |
|
1122 | + . $this->start_js() |
|
1123 | + . $this->common_js() |
|
1124 | + . $js |
|
1125 | + . $this->end_js() |
|
1126 | + . $this->end_header() |
|
1127 | + . $this->start_body() |
|
1128 | + . $html |
|
1129 | + . $this->end_body() |
|
1130 | + . $this->end_page(); |
|
1131 | + |
|
1132 | + return $res; |
|
1133 | + } |
|
1134 | 1134 | |
1135 | 1135 | /** |
1136 | 1136 | * @return string |
@@ -1144,21 +1144,21 @@ discard block |
||
1144 | 1144 | return $assets; |
1145 | 1145 | } |
1146 | 1146 | |
1147 | - /** |
|
1148 | - * Export the questions, as a succession of <items> |
|
1149 | - * @author Amand Tihon <[email protected]> |
|
1150 | - */ |
|
1151 | - function export_questions() |
|
1152 | - { |
|
1153 | - $js = $html = ""; |
|
1154 | - $js_id = 0; |
|
1155 | - foreach ($this->exercise->selectQuestionList() as $q) { |
|
1156 | - list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id); |
|
1157 | - $js .= $jstmp."\n"; |
|
1158 | - $html .= $htmltmp."\n"; |
|
1159 | - ++$js_id; |
|
1160 | - } |
|
1161 | - |
|
1162 | - return array($js, $html); |
|
1163 | - } |
|
1147 | + /** |
|
1148 | + * Export the questions, as a succession of <items> |
|
1149 | + * @author Amand Tihon <[email protected]> |
|
1150 | + */ |
|
1151 | + function export_questions() |
|
1152 | + { |
|
1153 | + $js = $html = ""; |
|
1154 | + $js_id = 0; |
|
1155 | + foreach ($this->exercise->selectQuestionList() as $q) { |
|
1156 | + list($jstmp, $htmltmp)= ScormQuestion::export_question($q, false, $js_id); |
|
1157 | + $js .= $jstmp."\n"; |
|
1158 | + $html .= $htmltmp."\n"; |
|
1159 | + ++$js_id; |
|
1160 | + } |
|
1161 | + |
|
1162 | + return array($js, $html); |
|
1163 | + } |
|
1164 | 1164 | } |
@@ -25,9 +25,9 @@ |
||
25 | 25 | return 'chamilo_core.block.breadcrumb'; |
26 | 26 | } |
27 | 27 | |
28 | - /** |
|
29 | - * {@inheritdoc} |
|
30 | - */ |
|
28 | + /** |
|
29 | + * {@inheritdoc} |
|
30 | + */ |
|
31 | 31 | public function configureSettings(OptionsResolver $resolver) |
32 | 32 | { |
33 | 33 | parent::configureSettings($resolver); |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | $is_certificate_mode = false; |
62 | 62 | |
63 | 63 | if (isset($_REQUEST['certificate']) && $_REQUEST['certificate'] == 'true') { |
64 | - $is_certificate_mode = true; |
|
64 | + $is_certificate_mode = true; |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | if ($is_certificate_mode) { |
68 | - $nameTools = get_lang('CreateCertificate'); |
|
68 | + $nameTools = get_lang('CreateCertificate'); |
|
69 | 69 | } else { |
70 | - $nameTools = get_lang('CreateDocument'); |
|
70 | + $nameTools = get_lang('CreateDocument'); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /* Constants and variables */ |
@@ -124,26 +124,26 @@ discard block |
||
124 | 124 | |
125 | 125 | // Please, do not modify this dirname formatting |
126 | 126 | if (strstr($dir, '..')) { |
127 | - $dir = '/'; |
|
127 | + $dir = '/'; |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | if ($dir[0] == '.') { |
131 | - $dir = substr($dir, 1); |
|
131 | + $dir = substr($dir, 1); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | if ($dir[0] != '/') { |
135 | - $dir = '/'.$dir; |
|
135 | + $dir = '/'.$dir; |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | if ($dir[strlen($dir) - 1] != '/') { |
139 | - $dir .= '/'; |
|
139 | + $dir .= '/'; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | if ($is_certificate_mode) { |
143 | - $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); |
|
144 | - $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); |
|
145 | - $folder_id = $document_data['id']; |
|
146 | - $dir = '/certificates/'; |
|
143 | + $document_id = DocumentManager::get_document_id(api_get_course_info(), '/certificates'); |
|
144 | + $document_data = DocumentManager::get_document_data_by_id($document_id, api_get_course_id(), true); |
|
145 | + $folder_id = $document_data['id']; |
|
146 | + $dir = '/certificates/'; |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | $doc_tree = explode('/', $dir); |
@@ -154,16 +154,16 @@ discard block |
||
154 | 154 | |
155 | 155 | // Level correction for group documents. |
156 | 156 | if (!empty($group_properties['directory'])) { |
157 | - $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
157 | + $count_dir = $count_dir > 0 ? $count_dir - 1 : 0; |
|
158 | 158 | } |
159 | 159 | } |
160 | 160 | $relative_url = ''; |
161 | 161 | for ($i = 0; $i < ($count_dir); $i++) { |
162 | - $relative_url .= '../'; |
|
162 | + $relative_url .= '../'; |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | if ($relative_url== '') { |
166 | - $relative_url = '/'; |
|
166 | + $relative_url = '/'; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | $is_allowed_to_edit = api_is_allowed_to_edit(null, true); |
@@ -175,11 +175,11 @@ discard block |
||
175 | 175 | 'cols-size' => [2, 10, 0], |
176 | 176 | 'FullPage' => true, |
177 | 177 | 'InDocument' => true, |
178 | - 'CreateDocumentDir' => $relative_url, |
|
179 | - 'CreateDocumentWebDir' => (empty($group_properties['directory'])) |
|
180 | - ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/' |
|
181 | - : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/', |
|
182 | - 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir |
|
178 | + 'CreateDocumentDir' => $relative_url, |
|
179 | + 'CreateDocumentWebDir' => (empty($group_properties['directory'])) |
|
180 | + ? api_get_path(WEB_COURSE_PATH).$_course['path'].'/document/' |
|
181 | + : api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/', |
|
182 | + 'BaseHref' => api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$dir |
|
183 | 183 | ); |
184 | 184 | |
185 | 185 | if ($is_certificate_mode) { |
@@ -191,41 +191,41 @@ discard block |
||
191 | 191 | $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document'; |
192 | 192 | |
193 | 193 | if (!is_dir($filepath)) { |
194 | - $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
195 | - $dir = '/'; |
|
194 | + $filepath = api_get_path(SYS_COURSE_PATH).$_course['path'].'/document/'; |
|
195 | + $dir = '/'; |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | $to_group_id = 0; |
199 | 199 | if (!$is_certificate_mode) { |
200 | - if (api_is_in_group()) { |
|
200 | + if (api_is_in_group()) { |
|
201 | 201 | $interbreadcrumb[] = array( |
202 | 202 | "url" => "../group/group_space.php?".api_get_cidreq(), |
203 | 203 | "name" => get_lang('GroupSpace'), |
204 | 204 | ); |
205 | - $noPHP_SELF = true; |
|
206 | - $to_group_id = $group_properties['iid']; |
|
207 | - $path = explode('/', $dir); |
|
208 | - if ('/'.$path[1] != $group_properties['directory']) { |
|
209 | - api_not_allowed(true); |
|
210 | - } |
|
211 | - } |
|
205 | + $noPHP_SELF = true; |
|
206 | + $to_group_id = $group_properties['iid']; |
|
207 | + $path = explode('/', $dir); |
|
208 | + if ('/'.$path[1] != $group_properties['directory']) { |
|
209 | + api_not_allowed(true); |
|
210 | + } |
|
211 | + } |
|
212 | 212 | $interbreadcrumb[] = array( |
213 | 213 | "url" => "./document.php?curdirpath=".urlencode($dir)."&".api_get_cidreq(), |
214 | 214 | "name" => get_lang('Documents'), |
215 | 215 | ); |
216 | 216 | } else { |
217 | - $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
217 | + $interbreadcrumb[]= array('url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'name' => get_lang('Gradebook')); |
|
218 | 218 | } |
219 | 219 | |
220 | 220 | if (!api_is_allowed_in_course()) { |
221 | - api_not_allowed(true); |
|
221 | + api_not_allowed(true); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if (!($is_allowed_to_edit || |
225 | 225 | $groupRights || |
226 | 226 | DocumentManager::is_my_shared_folder($userId, $dir, api_get_session_id())) |
227 | 227 | ) { |
228 | - api_not_allowed(true); |
|
228 | + api_not_allowed(true); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /* Header */ |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | |
234 | 234 | $display_dir = $dir; |
235 | 235 | if (isset($group_properties)) { |
236 | - $display_dir = explode('/', $dir); |
|
237 | - unset($display_dir[0]); |
|
238 | - unset($display_dir[1]); |
|
239 | - $display_dir = implode('/', $display_dir); |
|
236 | + $display_dir = explode('/', $dir); |
|
237 | + unset($display_dir[0]); |
|
238 | + unset($display_dir[1]); |
|
239 | + $display_dir = implode('/', $display_dir); |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | $select_cat = isset($_GET['selectcat']) ? intval($_GET['selectcat']) : null; |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | $form->addElement('header', $nameTools); |
254 | 254 | |
255 | 255 | if ($is_certificate_mode) {//added condition for certicate in gradebook |
256 | - $form->addElement('hidden','certificate','true',array('id'=>'certificate')); |
|
257 | - if (isset($_GET['selectcat'])) { |
|
258 | - $form->addElement('hidden','selectcat', $select_cat); |
|
256 | + $form->addElement('hidden','certificate','true',array('id'=>'certificate')); |
|
257 | + if (isset($_GET['selectcat'])) { |
|
258 | + $form->addElement('hidden','selectcat', $select_cat); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | // new document created |
315 | 315 | |
316 | 316 | if (!$is_certificate_mode && |
317 | - !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id) |
|
317 | + !DocumentManager::is_my_shared_folder($userId, $dir, $current_session_id) |
|
318 | 318 | ) { |
319 | 319 | $folders = DocumentManager::get_all_document_folders( |
320 | 320 | $_course, |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | array('cols-size' => [2, 10, 0]) |
330 | 330 | ); |
331 | 331 | |
332 | - $folder_titles = array(); |
|
332 | + $folder_titles = array(); |
|
333 | 333 | if (is_array($folders)) { |
334 | 334 | $escaped_folders = array(); |
335 | 335 | foreach ($folders as $key => & $val) { |
@@ -366,22 +366,22 @@ discard block |
||
366 | 366 | } |
367 | 367 | } |
368 | 368 | |
369 | - if (empty($group_dir)) { |
|
370 | - $parent_select -> addOption(get_lang('HomeDirectory'), '/'); |
|
371 | - if (is_array($folders)) { |
|
372 | - foreach ($folders as & $folder) { |
|
373 | - //Hide some folders |
|
374 | - if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') { |
|
369 | + if (empty($group_dir)) { |
|
370 | + $parent_select -> addOption(get_lang('HomeDirectory'), '/'); |
|
371 | + if (is_array($folders)) { |
|
372 | + foreach ($folders as & $folder) { |
|
373 | + //Hide some folders |
|
374 | + if ($folder=='/HotPotatoes_files' || $folder=='/certificates' || basename($folder)=='css') { |
|
375 | 375 | continue; |
376 | - } |
|
377 | - //Admin setting for Hide/Show the folders of all users |
|
378 | - if (api_get_setting('show_users_folders') == 'false' && |
|
376 | + } |
|
377 | + //Admin setting for Hide/Show the folders of all users |
|
378 | + if (api_get_setting('show_users_folders') == 'false' && |
|
379 | 379 | (strstr($folder, '/shared_folder') || strstr($folder, 'shared_folder_session_')) |
380 | 380 | ){ |
381 | - continue; |
|
382 | - } |
|
383 | - //Admin setting for Hide/Show Default folders to all users |
|
384 | - if (api_get_setting('show_default_folders') == 'false' && |
|
381 | + continue; |
|
382 | + } |
|
383 | + //Admin setting for Hide/Show Default folders to all users |
|
384 | + if (api_get_setting('show_default_folders') == 'false' && |
|
385 | 385 | ( |
386 | 386 | $folder == '/images' || |
387 | 387 | $folder == '/flash' || |
@@ -391,82 +391,82 @@ discard block |
||
391 | 391 | $folder == '/video/flv' |
392 | 392 | ) |
393 | 393 | ){ |
394 | - continue; |
|
395 | - } |
|
396 | - //Admin setting for Hide/Show chat history folder |
|
397 | - if (api_get_setting('show_chat_folder') == 'false' && |
|
394 | + continue; |
|
395 | + } |
|
396 | + //Admin setting for Hide/Show chat history folder |
|
397 | + if (api_get_setting('show_chat_folder') == 'false' && |
|
398 | 398 | $folder=='/chat_files' |
399 | 399 | ){ |
400 | - continue; |
|
401 | - } |
|
400 | + continue; |
|
401 | + } |
|
402 | 402 | |
403 | - $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : ''; |
|
404 | - $path_parts = explode('/', $folder); |
|
405 | - $folder_titles[$folder] = cut($folder_titles[$folder], 80); |
|
403 | + $selected = (substr($dir,0,-1) == $folder) ? ' selected="selected"' : ''; |
|
404 | + $path_parts = explode('/', $folder); |
|
405 | + $folder_titles[$folder] = cut($folder_titles[$folder], 80); |
|
406 | 406 | $space_counter =count($path_parts) - 2; |
407 | 407 | if ($space_counter > 0) { |
408 | 408 | $label = str_repeat(' ', $space_counter).' — '.$folder_titles[$folder]; |
409 | 409 | } else { |
410 | 410 | $label = ' — '.$folder_titles[$folder]; |
411 | 411 | } |
412 | - $parent_select -> addOption($label, $folder); |
|
413 | - if ($selected != '') { |
|
414 | - $parent_select->setSelected($folder); |
|
415 | - } |
|
416 | - } |
|
417 | - } |
|
418 | - } else { |
|
419 | - if (is_array($folders) && !empty($folders)) { |
|
420 | - foreach ($folders as & $folder) { |
|
421 | - $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : ''; |
|
422 | - $label = $folder_titles[$folder]; |
|
423 | - if ($folder == $group_dir) { |
|
424 | - $label = '/ (' . get_lang('HomeDirectory') . ')'; |
|
425 | - } else { |
|
426 | - $path_parts = explode('/', str_replace($group_dir, '', $folder)); |
|
427 | - $label = cut($label, 80); |
|
428 | - $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; |
|
429 | - } |
|
430 | - $parent_select->addOption($label, $folder); |
|
431 | - if ($selected != '') { |
|
432 | - $parent_select->setSelected($folder); |
|
433 | - } |
|
434 | - } |
|
435 | - } |
|
436 | - } |
|
412 | + $parent_select -> addOption($label, $folder); |
|
413 | + if ($selected != '') { |
|
414 | + $parent_select->setSelected($folder); |
|
415 | + } |
|
416 | + } |
|
417 | + } |
|
418 | + } else { |
|
419 | + if (is_array($folders) && !empty($folders)) { |
|
420 | + foreach ($folders as & $folder) { |
|
421 | + $selected = (substr($dir, 0, -1) == $folder) ? ' selected="selected"' : ''; |
|
422 | + $label = $folder_titles[$folder]; |
|
423 | + if ($folder == $group_dir) { |
|
424 | + $label = '/ (' . get_lang('HomeDirectory') . ')'; |
|
425 | + } else { |
|
426 | + $path_parts = explode('/', str_replace($group_dir, '', $folder)); |
|
427 | + $label = cut($label, 80); |
|
428 | + $label = str_repeat(' ', count($path_parts) - 2) . ' — ' . $label; |
|
429 | + } |
|
430 | + $parent_select->addOption($label, $folder); |
|
431 | + if ($selected != '') { |
|
432 | + $parent_select->setSelected($folder); |
|
433 | + } |
|
434 | + } |
|
435 | + } |
|
436 | + } |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | $form->addHidden('dirValue', ''); |
440 | 440 | |
441 | 441 | if ($is_certificate_mode) { |
442 | - $form->addButtonCreate(get_lang('CreateCertificate')); |
|
442 | + $form->addButtonCreate(get_lang('CreateCertificate')); |
|
443 | 443 | } else { |
444 | - $form->addButtonCreate(get_lang('CreateDoc')); |
|
444 | + $form->addButtonCreate(get_lang('CreateDoc')); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | $form->setDefaults($defaults); |
448 | 448 | |
449 | 449 | // If form validates -> save the new document |
450 | 450 | if ($form->validate()) { |
451 | - $values = $form->exportValues(); |
|
452 | - $readonly = isset($values['readonly']) ? 1 : 0; |
|
453 | - $values['title'] = trim($values['title']); |
|
451 | + $values = $form->exportValues(); |
|
452 | + $readonly = isset($values['readonly']) ? 1 : 0; |
|
453 | + $values['title'] = trim($values['title']); |
|
454 | 454 | |
455 | 455 | if (!empty($values['dirValue'])) { |
456 | 456 | $dir = $values['dirValue']; |
457 | 457 | } |
458 | 458 | |
459 | 459 | if ($dir[strlen($dir) - 1] != '/') { |
460 | - $dir .= '/'; |
|
461 | - } |
|
460 | + $dir .= '/'; |
|
461 | + } |
|
462 | 462 | $filepath = $filepath.$dir; |
463 | 463 | |
464 | 464 | // Setting the filename |
465 | - $filename = $values['title']; |
|
466 | - $filename = addslashes(trim($filename)); |
|
467 | - $filename = Security::remove_XSS($filename); |
|
468 | - $filename = api_replace_dangerous_char($filename); |
|
469 | - $filename = disable_dangerous_file($filename); |
|
465 | + $filename = $values['title']; |
|
466 | + $filename = addslashes(trim($filename)); |
|
467 | + $filename = Security::remove_XSS($filename); |
|
468 | + $filename = api_replace_dangerous_char($filename); |
|
469 | + $filename = disable_dangerous_file($filename); |
|
470 | 470 | $filename .= DocumentManager::getDocumentSuffix( |
471 | 471 | $_course, |
472 | 472 | api_get_session_id(), |
@@ -474,14 +474,14 @@ discard block |
||
474 | 474 | ); |
475 | 475 | |
476 | 476 | // Setting the title |
477 | - $title = $values['title']; |
|
477 | + $title = $values['title']; |
|
478 | 478 | |
479 | 479 | // Setting the extension |
480 | - $extension = 'html'; |
|
480 | + $extension = 'html'; |
|
481 | 481 | |
482 | - $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); |
|
482 | + $content = Security::remove_XSS($values['content'], COURSEMANAGERLOWSECURITY); |
|
483 | 483 | |
484 | - /*if (strpos($content, '/css/frames.css') == false) { |
|
484 | + /*if (strpos($content, '/css/frames.css') == false) { |
|
485 | 485 | $content = str_replace('</head>', '<link rel="stylesheet" href="./css/frames.css" type="text/css" /><style> body{margin:50px;}</style></head>', $content); |
486 | 486 | }*/ |
487 | 487 | |
@@ -494,21 +494,21 @@ discard block |
||
494 | 494 | exit; |
495 | 495 | } |
496 | 496 | |
497 | - if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { |
|
497 | + if ($fp = @fopen($filepath.$filename.'.'.$extension, 'w')) { |
|
498 | 498 | |
499 | - $content = str_replace( |
|
500 | - api_get_path(WEB_COURSE_PATH), |
|
499 | + $content = str_replace( |
|
500 | + api_get_path(WEB_COURSE_PATH), |
|
501 | 501 | api_get_configuration_value('url_append').api_get_path(REL_COURSE_PATH), |
502 | 502 | $content |
503 | 503 | ); |
504 | 504 | |
505 | - fputs($fp, $content); |
|
506 | - fclose($fp); |
|
507 | - chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files()); |
|
505 | + fputs($fp, $content); |
|
506 | + fclose($fp); |
|
507 | + chmod($filepath.$filename.'.'.$extension, api_get_permissions_for_new_files()); |
|
508 | 508 | |
509 | 509 | |
510 | - $file_size = filesize($filepath.$filename.'.'.$extension); |
|
511 | - $save_file_path = $dir.$filename.'.'.$extension; |
|
510 | + $file_size = filesize($filepath.$filename.'.'.$extension); |
|
511 | + $save_file_path = $dir.$filename.'.'.$extension; |
|
512 | 512 | |
513 | 513 | $document_id = add_document( |
514 | 514 | $_course, |
@@ -520,8 +520,8 @@ discard block |
||
520 | 520 | $readonly |
521 | 521 | ); |
522 | 522 | |
523 | - if ($document_id) { |
|
524 | - api_item_property_update( |
|
523 | + if ($document_id) { |
|
524 | + api_item_property_update( |
|
525 | 525 | $_course, |
526 | 526 | TOOL_DOCUMENT, |
527 | 527 | $document_id, |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | null, |
534 | 534 | $current_session_id |
535 | 535 | ); |
536 | - // Update parent folders |
|
537 | - item_property_update_on_folder($_course, $dir, $userId); |
|
538 | - $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
539 | - $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
536 | + // Update parent folders |
|
537 | + item_property_update_on_folder($_course, $dir, $userId); |
|
538 | + $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; |
|
539 | + $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; |
|
540 | 540 | $new_title = htmlspecialchars($new_title); |
541 | - if ($new_comment || $new_title) { |
|
542 | - $ct = ''; |
|
541 | + if ($new_comment || $new_title) { |
|
542 | + $ct = ''; |
|
543 | 543 | $params = []; |
544 | 544 | if ($new_comment) { |
545 | 545 | $params['comment'] = $new_comment; |
@@ -554,39 +554,39 @@ discard block |
||
554 | 554 | ['c_id = ? AND id = ?' => [$course_id, $document_id]] |
555 | 555 | ); |
556 | 556 | } |
557 | - } |
|
558 | - $dir= substr($dir,0,-1); |
|
559 | - $selectcat = ''; |
|
557 | + } |
|
558 | + $dir= substr($dir,0,-1); |
|
559 | + $selectcat = ''; |
|
560 | 560 | if (isset($_REQUEST['selectcat'])) { |
561 | 561 | $selectcat = "&selectcat=".intval($_REQUEST['selectcat']); |
562 | 562 | } |
563 | - $certificate_condition = ''; |
|
564 | - if ($is_certificate_mode) { |
|
565 | - $df = DocumentManager::get_default_certificate_id($_course['real_id']); |
|
563 | + $certificate_condition = ''; |
|
564 | + if ($is_certificate_mode) { |
|
565 | + $df = DocumentManager::get_default_certificate_id($_course['real_id']); |
|
566 | 566 | if (!isset($df)) { |
567 | 567 | DocumentManager::attach_gradebook_certificate($_course['real_id'], $document_id); |
568 | - } |
|
569 | - $certificate_condition = '&certificate=true&curdirpath=/certificates'; |
|
570 | - } |
|
568 | + } |
|
569 | + $certificate_condition = '&certificate=true&curdirpath=/certificates'; |
|
570 | + } |
|
571 | 571 | Display::addFlash(Display::return_message(get_lang('ItemAdded'))); |
572 | - header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); |
|
573 | - exit(); |
|
574 | - } else { |
|
575 | - Display :: display_header($nameTools, 'Doc'); |
|
576 | - Display :: display_error_message(get_lang('Impossible')); |
|
577 | - Display :: display_footer(); |
|
578 | - } |
|
579 | - } else { |
|
580 | - Display :: display_header($nameTools, 'Doc'); |
|
581 | - Display :: display_error_message(get_lang('Impossible')); |
|
582 | - Display :: display_footer(); |
|
583 | - } |
|
572 | + header('Location: document.php?'.api_get_cidreq().'&id='.$folder_id.$selectcat.$certificate_condition); |
|
573 | + exit(); |
|
574 | + } else { |
|
575 | + Display :: display_header($nameTools, 'Doc'); |
|
576 | + Display :: display_error_message(get_lang('Impossible')); |
|
577 | + Display :: display_footer(); |
|
578 | + } |
|
579 | + } else { |
|
580 | + Display :: display_header($nameTools, 'Doc'); |
|
581 | + Display :: display_error_message(get_lang('Impossible')); |
|
582 | + Display :: display_footer(); |
|
583 | + } |
|
584 | 584 | } else { |
585 | - // Copied from document.php |
|
586 | - $dir_array = explode('/', $dir); |
|
587 | - $array_len = count($dir_array); |
|
585 | + // Copied from document.php |
|
586 | + $dir_array = explode('/', $dir); |
|
587 | + $array_len = count($dir_array); |
|
588 | 588 | |
589 | - // Breadcrumb for the current directory root path |
|
589 | + // Breadcrumb for the current directory root path |
|
590 | 590 | if (!empty($document_data)) { |
591 | 591 | if (empty($document_data['parents'])) { |
592 | 592 | $interbreadcrumb[] = array( |
@@ -603,11 +603,11 @@ discard block |
||
603 | 603 | } |
604 | 604 | } |
605 | 605 | |
606 | - Display :: display_header($nameTools, "Doc"); |
|
607 | - // actions |
|
606 | + Display :: display_header($nameTools, "Doc"); |
|
607 | + // actions |
|
608 | 608 | |
609 | - // link back to the documents overview |
|
610 | - if ($is_certificate_mode) { |
|
609 | + // link back to the documents overview |
|
610 | + if ($is_certificate_mode) { |
|
611 | 611 | $actionsLeft = '<a href="document.php?certificate=true&id='.$folder_id.'&selectcat=' . Security::remove_XSS($_GET['selectcat']).'">'. |
612 | 612 | Display::return_icon('back.png',get_lang('Back').' '.get_lang('To').' '.get_lang('CertificateOverview'),'',ICON_SIZE_MEDIUM).'</a>'; |
613 | 613 | $actionsLeft .= '<a id="hide_bar_template" href="#" role="button">'. |
@@ -622,19 +622,19 @@ discard block |
||
622 | 622 | |
623 | 623 | echo $toolbar = Display::toolbarAction('actions-documents', array($actionsLeft)); |
624 | 624 | |
625 | - if ($is_certificate_mode) { |
|
625 | + if ($is_certificate_mode) { |
|
626 | 626 | $all_information_by_create_certificate = DocumentManager::get_all_info_to_certificate( |
627 | 627 | api_get_user_id(), |
628 | 628 | api_get_course_id() |
629 | 629 | ); |
630 | 630 | |
631 | - $str_info = ''; |
|
632 | - foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
633 | - $str_info.=$info_value.'<br/>'; |
|
634 | - } |
|
635 | - $create_certificate = get_lang('CreateCertificateWithTags'); |
|
636 | - Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false); |
|
637 | - } |
|
631 | + $str_info = ''; |
|
632 | + foreach ($all_information_by_create_certificate[0] as $info_value) { |
|
633 | + $str_info.=$info_value.'<br/>'; |
|
634 | + } |
|
635 | + $create_certificate = get_lang('CreateCertificateWithTags'); |
|
636 | + Display::display_normal_message($create_certificate.': <br /><br/>'.$str_info,false); |
|
637 | + } |
|
638 | 638 | |
639 | 639 | // HTML-editor |
640 | 640 | echo '<div class="page-create"> |
@@ -650,5 +650,5 @@ discard block |
||
650 | 650 | '.$form->returnForm().' |
651 | 651 | </div> |
652 | 652 | </div></div>'; |
653 | - Display :: display_footer(); |
|
653 | + Display :: display_footer(); |
|
654 | 654 | } |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | */ |
18 | 18 | class CourseSelectForm |
19 | 19 | { |
20 | - /** |
|
21 | - * Display the form |
|
20 | + /** |
|
21 | + * Display the form |
|
22 | 22 | * @param array $course |
23 | - * @param array $hidden_fields Hidden fields to add to the form. |
|
24 | - * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file |
|
25 | - */ |
|
26 | - public static function display_form($course, $hidden_fields = null, $avoid_serialize = false) |
|
23 | + * @param array $hidden_fields Hidden fields to add to the form. |
|
24 | + * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file |
|
25 | + */ |
|
26 | + public static function display_form($course, $hidden_fields = null, $avoid_serialize = false) |
|
27 | 27 | { |
28 | 28 | global $charset; |
29 | 29 | $resource_titles[RESOURCE_GRADEBOOK] = get_lang('Gradebook'); |
@@ -138,48 +138,48 @@ discard block |
||
138 | 138 | } |
139 | 139 | </script> |
140 | 140 | <?php |
141 | - // get destination course title |
|
142 | - if (!empty($hidden_fields['destination_course'])) { |
|
141 | + // get destination course title |
|
142 | + if (!empty($hidden_fields['destination_course'])) { |
|
143 | 143 | $sessionTitle = !empty($hidden_fields['destination_session']) ? ' (' . api_get_session_name($hidden_fields['destination_session']) . ')' : null; |
144 | 144 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
145 | - echo '<h3>'; |
|
146 | - echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; |
|
147 | - echo '</h3>'; |
|
148 | - } |
|
145 | + echo '<h3>'; |
|
146 | + echo get_lang('DestinationCourse').' : '.$course_infos['title'] . ' ('.$course_infos['code'].') '.$sessionTitle; |
|
147 | + echo '</h3>'; |
|
148 | + } |
|
149 | 149 | echo api_get_js('js/upload.js'); |
150 | - echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
150 | + echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
151 | 151 | $icon = Display::returnIconPath('myprogress_bar.gif'); |
152 | 152 | echo '<div class="tool-backups-options">'; |
153 | - echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">'; |
|
154 | - echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
153 | + echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="javascript: myUpload.start(\'dynamic_div\',\''.$icon.',\''.get_lang('PleaseStandBy', '').'\',\'upload_form\')">'; |
|
154 | + echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
155 | 155 | |
156 | - if (!empty($hidden_fields['destination_course']) && |
|
156 | + if (!empty($hidden_fields['destination_course']) && |
|
157 | 157 | !empty($hidden_fields['origin_course']) && |
158 | 158 | !empty($hidden_fields['destination_session']) && |
159 | 159 | !empty($hidden_fields['origin_session']) |
160 | 160 | ) { |
161 | - echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>'; |
|
162 | - echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>'; |
|
163 | - echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>'; |
|
164 | - echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>'; |
|
165 | - } |
|
161 | + echo '<input type="hidden" name="destination_course" value="'.$hidden_fields['destination_course'].'"/>'; |
|
162 | + echo '<input type="hidden" name="origin_course" value="'.$hidden_fields['origin_course'].'"/>'; |
|
163 | + echo '<input type="hidden" name="destination_session" value="'.$hidden_fields['destination_session'].'"/>'; |
|
164 | + echo '<input type="hidden" name="origin_session" value="'.$hidden_fields['origin_session'].'"/>'; |
|
165 | + } |
|
166 | 166 | |
167 | - $element_count = 0; |
|
167 | + $element_count = 0; |
|
168 | 168 | $forum_categories = array(); |
169 | 169 | $forums = array(); |
170 | 170 | $forum_topics = array(); |
171 | 171 | |
172 | 172 | echo '<p>'; |
173 | - echo get_lang('SelectResources'); |
|
174 | - echo '</p>'; |
|
173 | + echo get_lang('SelectResources'); |
|
174 | + echo '</p>'; |
|
175 | 175 | |
176 | 176 | Display::display_normal_message(get_lang('DontForgetToSelectTheMediaFilesIfYourResourceNeedIt')); |
177 | 177 | |
178 | 178 | foreach ($course->resources as $type => $resources) { |
179 | 179 | if (count($resources) > 0) { |
180 | - switch ($type) { |
|
181 | - //Resources to avoid |
|
182 | - case RESOURCE_FORUMCATEGORY: |
|
180 | + switch ($type) { |
|
181 | + //Resources to avoid |
|
182 | + case RESOURCE_FORUMCATEGORY: |
|
183 | 183 | foreach ($resources as $id => $resource) { |
184 | 184 | $forum_categories[$id] = $resource; |
185 | 185 | } |
@@ -206,29 +206,29 @@ discard block |
||
206 | 206 | break; |
207 | 207 | default: |
208 | 208 | echo '<div class="item-backup" onclick="javascript:exp('."'$type'".');">'; |
209 | - echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>'; |
|
210 | - echo '<span class="title">'.$resource_titles[$type].'</span></div>'; |
|
211 | - echo '<div class="item-content" id="div_'.$type.'">'; |
|
212 | - if ($type == RESOURCE_LEARNPATH) { |
|
213 | - Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz')); |
|
214 | - Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments')); |
|
215 | - } |
|
216 | - if ($type == RESOURCE_DOCUMENT) { |
|
209 | + echo '<em id="img_'.$type.'" class="fa fa-minus-square-o fa-lg" ></em>'; |
|
210 | + echo '<span class="title">'.$resource_titles[$type].'</span></div>'; |
|
211 | + echo '<div class="item-content" id="div_'.$type.'">'; |
|
212 | + if ($type == RESOURCE_LEARNPATH) { |
|
213 | + Display::display_warning_message(get_lang('ToExportLearnpathWithQuizYouHaveToSelectQuiz')); |
|
214 | + Display::display_warning_message(get_lang('IfYourLPsHaveAudioFilesIncludedYouShouldSelectThemFromTheDocuments')); |
|
215 | + } |
|
216 | + if ($type == RESOURCE_DOCUMENT) { |
|
217 | 217 | if (api_get_setting('show_glossary_in_documents') != 'none') { |
218 | 218 | Display::display_warning_message(get_lang('ToExportDocumentsWithGlossaryYouHaveToSelectGlossary')); |
219 | 219 | } |
220 | - } |
|
220 | + } |
|
221 | 221 | |
222 | - echo '<div class="well">'; |
|
222 | + echo '<div class="well">'; |
|
223 | 223 | echo '<div class="btn-group">'; |
224 | - echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>"; |
|
224 | + echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript: setCheckbox('$type',true);\" >".get_lang('All')."</a>"; |
|
225 | 225 | echo "<a class=\"btn btn-default\" href=\"javascript: void(0);\" onclick=\"javascript:setCheckbox('$type',false);\" >".get_lang('None')."</a>"; |
226 | - echo '</div>'; |
|
226 | + echo '</div>'; |
|
227 | 227 | echo '<ul class="list-backups-options">'; |
228 | - foreach ($resources as $id => $resource) { |
|
228 | + foreach ($resources as $id => $resource) { |
|
229 | 229 | if ($resource) { |
230 | 230 | echo '<li>'; |
231 | - // Event obj in 1.9.x in 1.10.x the class is CalendarEvent |
|
231 | + // Event obj in 1.9.x in 1.10.x the class is CalendarEvent |
|
232 | 232 | Resource::setClassType($resource); |
233 | 233 | echo '<label class="checkbox">'; |
234 | 234 | echo '<input type="checkbox" name="resource['.$type.']['.$id.']" id="resource['.$type.']['.$id.']" />'; |
@@ -236,15 +236,15 @@ discard block |
||
236 | 236 | echo '</label>'; |
237 | 237 | echo '</li>'; |
238 | 238 | } |
239 | - } |
|
239 | + } |
|
240 | 240 | echo '</ul>'; |
241 | - echo '</div>'; |
|
242 | - echo '</div>'; |
|
243 | - echo '<script language="javascript">exp('."'$type'".')</script>'; |
|
244 | - $element_count++; |
|
241 | + echo '</div>'; |
|
242 | + echo '</div>'; |
|
243 | + echo '<script language="javascript">exp('."'$type'".')</script>'; |
|
244 | + $element_count++; |
|
245 | 245 | } |
246 | - } |
|
247 | - } |
|
246 | + } |
|
247 | + } |
|
248 | 248 | |
249 | 249 | //Fixes forum order |
250 | 250 | if (!empty($forum_categories)) { |
@@ -300,66 +300,66 @@ discard block |
||
300 | 300 | echo '<script language="javascript">exp('."'$type'".')</script>'; |
301 | 301 | } |
302 | 302 | |
303 | - if ($avoid_serialize) { |
|
304 | - /*Documents are avoided due the huge amount of memory that the serialize php function "eats" |
|
303 | + if ($avoid_serialize) { |
|
304 | + /*Documents are avoided due the huge amount of memory that the serialize php function "eats" |
|
305 | 305 | (when there are directories with hundred/thousand of files) */ |
306 | - // this is a known issue of serialize |
|
307 | - $course->resources['document']= null; |
|
308 | - } |
|
306 | + // this is a known issue of serialize |
|
307 | + $course->resources['document']= null; |
|
308 | + } |
|
309 | 309 | |
310 | - echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
310 | + echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
311 | 311 | |
312 | - if (is_array($hidden_fields)) { |
|
313 | - foreach ($hidden_fields as $key => $value) { |
|
314 | - echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
315 | - } |
|
316 | - } |
|
312 | + if (is_array($hidden_fields)) { |
|
313 | + foreach ($hidden_fields as $key => $value) { |
|
314 | + echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
315 | + } |
|
316 | + } |
|
317 | 317 | |
318 | 318 | $recycleOption = isset($_POST['recycle_option']) ? true : false; |
319 | 319 | |
320 | - if (empty($element_count)) { |
|
321 | - Display::display_warning_message(get_lang('NoDataAvailable')); |
|
322 | - } else { |
|
323 | - if (!empty($hidden_fields['destination_session'])) { |
|
324 | - echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
320 | + if (empty($element_count)) { |
|
321 | + Display::display_warning_message(get_lang('NoDataAvailable')); |
|
322 | + } else { |
|
323 | + if (!empty($hidden_fields['destination_session'])) { |
|
324 | + echo '<br /><button class="save" type="submit" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang("ConfirmYourChoice"),ENT_QUOTES, $charset))."'".')) return false;" >'. |
|
325 | 325 | get_lang('Ok').'</button>'; |
326 | - } else { |
|
326 | + } else { |
|
327 | 327 | if ($recycleOption) { |
328 | 328 | echo '<br /><button class="save" type="submit">'. |
329 | 329 | get_lang('Ok').'</button>'; |
330 | 330 | } else { |
331 | - echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'. |
|
331 | + echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'. |
|
332 | 332 | get_lang('Ok').'</button>'; |
333 | 333 | } |
334 | - } |
|
335 | - } |
|
334 | + } |
|
335 | + } |
|
336 | 336 | |
337 | - CourseSelectForm::display_hidden_quiz_questions($course); |
|
338 | - CourseSelectForm::display_hidden_scorm_directories($course); |
|
339 | - echo '</form>'; |
|
337 | + CourseSelectForm::display_hidden_quiz_questions($course); |
|
338 | + CourseSelectForm::display_hidden_scorm_directories($course); |
|
339 | + echo '</form>'; |
|
340 | 340 | echo '</div>'; |
341 | - echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
342 | - } |
|
341 | + echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
342 | + } |
|
343 | 343 | |
344 | 344 | /** |
345 | 345 | * @param $course |
346 | 346 | */ |
347 | 347 | public static function display_hidden_quiz_questions($course) |
348 | 348 | { |
349 | - if(is_array($course->resources)){ |
|
350 | - foreach ($course->resources as $type => $resources) { |
|
351 | - if (count($resources) > 0) { |
|
352 | - switch ($type) { |
|
353 | - case RESOURCE_QUIZQUESTION: |
|
354 | - foreach ($resources as $id => $resource) { |
|
355 | - echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />'; |
|
356 | - } |
|
357 | - break; |
|
358 | - } |
|
359 | - } |
|
360 | - } |
|
361 | - } |
|
362 | - } |
|
349 | + if(is_array($course->resources)){ |
|
350 | + foreach ($course->resources as $type => $resources) { |
|
351 | + if (count($resources) > 0) { |
|
352 | + switch ($type) { |
|
353 | + case RESOURCE_QUIZQUESTION: |
|
354 | + foreach ($resources as $id => $resource) { |
|
355 | + echo '<input type="hidden" name="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" id="resource['.RESOURCE_QUIZQUESTION.']['.$id.']" value="On" />'; |
|
356 | + } |
|
357 | + break; |
|
358 | + } |
|
359 | + } |
|
360 | + } |
|
361 | + } |
|
362 | + } |
|
363 | 363 | |
364 | 364 | /** |
365 | 365 | * @param $course |
@@ -367,30 +367,30 @@ discard block |
||
367 | 367 | public static function display_hidden_scorm_directories($course) |
368 | 368 | { |
369 | 369 | if (is_array($course->resources)){ |
370 | - foreach ($course->resources as $type => $resources) { |
|
371 | - if (count($resources) > 0) { |
|
372 | - switch($type) { |
|
373 | - case RESOURCE_SCORM: |
|
374 | - foreach ($resources as $id => $resource) { |
|
375 | - echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />'; |
|
376 | - } |
|
377 | - break; |
|
378 | - } |
|
379 | - } |
|
380 | - } |
|
381 | - } |
|
382 | - } |
|
370 | + foreach ($course->resources as $type => $resources) { |
|
371 | + if (count($resources) > 0) { |
|
372 | + switch($type) { |
|
373 | + case RESOURCE_SCORM: |
|
374 | + foreach ($resources as $id => $resource) { |
|
375 | + echo '<input type="hidden" name="resource['.RESOURCE_SCORM.']['.$id.']" id="resource['.RESOURCE_SCORM.']['.$id.']" value="On" />'; |
|
376 | + } |
|
377 | + break; |
|
378 | + } |
|
379 | + } |
|
380 | + } |
|
381 | + } |
|
382 | + } |
|
383 | 383 | |
384 | - /** |
|
385 | - * Get the posted course |
|
386 | - * @param string $from who calls the function? |
|
384 | + /** |
|
385 | + * Get the posted course |
|
386 | + * @param string $from who calls the function? |
|
387 | 387 | * It can be copy_course, create_backup, import_backup or recycle_course |
388 | 388 | * @param int $session_id |
389 | 389 | * @param string $course_code |
390 | - * @return course The course-object with all resources selected by the user |
|
391 | - * in the form given by display_form(...) |
|
392 | - */ |
|
393 | - public static function get_posted_course($from = '', $session_id = 0, $course_code = '') |
|
390 | + * @return course The course-object with all resources selected by the user |
|
391 | + * in the form given by display_form(...) |
|
392 | + */ |
|
393 | + public static function get_posted_course($from = '', $session_id = 0, $course_code = '') |
|
394 | 394 | { |
395 | 395 | $course = null; |
396 | 396 | |
@@ -400,30 +400,30 @@ discard block |
||
400 | 400 | return false; |
401 | 401 | } |
402 | 402 | |
403 | - // Create the resource DOCUMENT objects |
|
404 | - // Loading the results from the checkboxes of ethe javascript |
|
405 | - $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
403 | + // Create the resource DOCUMENT objects |
|
404 | + // Loading the results from the checkboxes of ethe javascript |
|
405 | + $resource = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
406 | 406 | |
407 | - $course_info = api_get_course_info($course_code); |
|
408 | - $table_doc = Database::get_course_table(TABLE_DOCUMENT); |
|
409 | - $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
410 | - $course_id = $course_info['real_id']; |
|
407 | + $course_info = api_get_course_info($course_code); |
|
408 | + $table_doc = Database::get_course_table(TABLE_DOCUMENT); |
|
409 | + $table_prop = Database::get_course_table(TABLE_ITEM_PROPERTY); |
|
410 | + $course_id = $course_info['real_id']; |
|
411 | 411 | |
412 | - /* Searching the documents resource that have been set to null because |
|
412 | + /* Searching the documents resource that have been set to null because |
|
413 | 413 | $avoid_serialize is true in the display_form() function*/ |
414 | - if ($from === 'copy_course') { |
|
415 | - if (is_array($resource)) { |
|
416 | - $resource = array_keys($resource); |
|
414 | + if ($from === 'copy_course') { |
|
415 | + if (is_array($resource)) { |
|
416 | + $resource = array_keys($resource); |
|
417 | 417 | |
418 | - foreach ($resource as $resource_item) { |
|
418 | + foreach ($resource as $resource_item) { |
|
419 | 419 | |
420 | - $condition_session = ''; |
|
421 | - if (!empty($session_id)) { |
|
422 | - $session_id = intval($session_id); |
|
423 | - $condition_session = ' AND d.session_id ='.$session_id; |
|
424 | - } |
|
420 | + $condition_session = ''; |
|
421 | + if (!empty($session_id)) { |
|
422 | + $session_id = intval($session_id); |
|
423 | + $condition_session = ' AND d.session_id ='.$session_id; |
|
424 | + } |
|
425 | 425 | |
426 | - $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size |
|
426 | + $sql = 'SELECT d.id, d.path, d.comment, d.title, d.filetype, d.size |
|
427 | 427 | FROM '.$table_doc.' d, '.$table_prop.' p |
428 | 428 | WHERE |
429 | 429 | d.c_id = '.$course_id.' AND |
@@ -432,8 +432,8 @@ discard block |
||
432 | 432 | p.ref = d.id AND p.visibility != 2 AND |
433 | 433 | d.id = '.$resource_item.$condition_session.' |
434 | 434 | ORDER BY path'; |
435 | - $db_result = Database::query($sql); |
|
436 | - while ($obj = Database::fetch_object($db_result)) { |
|
435 | + $db_result = Database::query($sql); |
|
436 | + while ($obj = Database::fetch_object($db_result)) { |
|
437 | 437 | $doc = new Document( |
438 | 438 | $obj->id, |
439 | 439 | $obj->path, |
@@ -457,25 +457,25 @@ discard block |
||
457 | 457 | } |
458 | 458 | $course->resources[RESOURCE_DOCUMENT][$resource_item]->item_properties = $all_properties; |
459 | 459 | } |
460 | - } |
|
461 | - } |
|
462 | - } |
|
463 | - } |
|
460 | + } |
|
461 | + } |
|
462 | + } |
|
463 | + } |
|
464 | 464 | |
465 | - if (is_array($course->resources)) { |
|
466 | - foreach ($course->resources as $type => $resources) { |
|
465 | + if (is_array($course->resources)) { |
|
466 | + foreach ($course->resources as $type => $resources) { |
|
467 | 467 | |
468 | - switch ($type) { |
|
469 | - case RESOURCE_SURVEYQUESTION: |
|
470 | - foreach($resources as $id => $obj) { |
|
471 | - if (isset($_POST['resource'][RESOURCE_SURVEY]) && |
|
468 | + switch ($type) { |
|
469 | + case RESOURCE_SURVEYQUESTION: |
|
470 | + foreach($resources as $id => $obj) { |
|
471 | + if (isset($_POST['resource'][RESOURCE_SURVEY]) && |
|
472 | 472 | is_array($_POST['resource'][RESOURCE_SURVEY]) && |
473 | 473 | !in_array($obj->survey_id, array_keys($_POST['resource'][RESOURCE_SURVEY])) |
474 | 474 | ) { |
475 | - unset($course->resources[$type][$id]); |
|
476 | - } |
|
477 | - } |
|
478 | - break; |
|
475 | + unset($course->resources[$type][$id]); |
|
476 | + } |
|
477 | + } |
|
478 | + break; |
|
479 | 479 | case RESOURCE_FORUMTOPIC: |
480 | 480 | case RESOURCE_FORUMPOST: |
481 | 481 | //Add post from topic |
@@ -527,63 +527,63 @@ discard block |
||
527 | 527 | } |
528 | 528 | } |
529 | 529 | } |
530 | - case RESOURCE_LINKCATEGORY: |
|
531 | - case RESOURCE_FORUMCATEGORY: |
|
532 | - case RESOURCE_QUIZQUESTION: |
|
533 | - case RESOURCE_DOCUMENT: |
|
534 | - // Mark folders to import which are not selected by the user to import, |
|
535 | - // but in which a document was selected. |
|
536 | - $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
537 | - if (!empty($resources) && is_array($resources)) |
|
538 | - foreach ($resources as $id => $obj) { |
|
539 | - if (isset($obj->file_type) && $obj->file_type == 'folder' && |
|
530 | + case RESOURCE_LINKCATEGORY: |
|
531 | + case RESOURCE_FORUMCATEGORY: |
|
532 | + case RESOURCE_QUIZQUESTION: |
|
533 | + case RESOURCE_DOCUMENT: |
|
534 | + // Mark folders to import which are not selected by the user to import, |
|
535 | + // but in which a document was selected. |
|
536 | + $documents = isset($_POST['resource'][RESOURCE_DOCUMENT]) ? $_POST['resource'][RESOURCE_DOCUMENT] : null; |
|
537 | + if (!empty($resources) && is_array($resources)) |
|
538 | + foreach ($resources as $id => $obj) { |
|
539 | + if (isset($obj->file_type) && $obj->file_type == 'folder' && |
|
540 | 540 | !isset($_POST['resource'][RESOURCE_DOCUMENT][$id]) && |
541 | 541 | is_array($documents) |
542 | 542 | ) { |
543 | - foreach ($documents as $id_to_check => $post_value) { |
|
544 | - $obj_to_check = $resources[$id_to_check]; |
|
545 | - $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
|
546 | - if ($id_to_check != $id && $obj->path == $shared_path_part) { |
|
547 | - $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
|
548 | - break; |
|
549 | - } |
|
550 | - } |
|
551 | - } |
|
552 | - } |
|
553 | - default : |
|
554 | - if (!empty($resources) && is_array($resources)) { |
|
555 | - foreach ($resources as $id => $obj) { |
|
556 | - $resource_is_used_elsewhere = $course->is_linked_resource($obj); |
|
557 | - // check if document is in a quiz (audio/video) |
|
558 | - if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) { |
|
559 | - foreach($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
543 | + foreach ($documents as $id_to_check => $post_value) { |
|
544 | + $obj_to_check = $resources[$id_to_check]; |
|
545 | + $shared_path_part = substr($obj_to_check->path,0,strlen($obj->path)); |
|
546 | + if ($id_to_check != $id && $obj->path == $shared_path_part) { |
|
547 | + $_POST['resource'][RESOURCE_DOCUMENT][$id] = 1; |
|
548 | + break; |
|
549 | + } |
|
550 | + } |
|
551 | + } |
|
552 | + } |
|
553 | + default : |
|
554 | + if (!empty($resources) && is_array($resources)) { |
|
555 | + foreach ($resources as $id => $obj) { |
|
556 | + $resource_is_used_elsewhere = $course->is_linked_resource($obj); |
|
557 | + // check if document is in a quiz (audio/video) |
|
558 | + if ($type == RESOURCE_DOCUMENT && $course->has_resources(RESOURCE_QUIZ)) { |
|
559 | + foreach($course->resources[RESOURCE_QUIZ] as $quiz) { |
|
560 | 560 | $quiz = $quiz->obj; |
561 | - if (isset($quiz->media) && $quiz->media == $id) { |
|
562 | - $resource_is_used_elsewhere = true; |
|
563 | - } |
|
564 | - } |
|
565 | - } |
|
566 | - if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) { |
|
567 | - unset($course->resources[$type][$id]); |
|
568 | - } |
|
569 | - } |
|
570 | - } |
|
571 | - } |
|
572 | - } |
|
573 | - } |
|
561 | + if (isset($quiz->media) && $quiz->media == $id) { |
|
562 | + $resource_is_used_elsewhere = true; |
|
563 | + } |
|
564 | + } |
|
565 | + } |
|
566 | + if (!isset($_POST['resource'][$type][$id]) && !$resource_is_used_elsewhere) { |
|
567 | + unset($course->resources[$type][$id]); |
|
568 | + } |
|
569 | + } |
|
570 | + } |
|
571 | + } |
|
572 | + } |
|
573 | + } |
|
574 | 574 | |
575 | - return $course; |
|
576 | - } |
|
575 | + return $course; |
|
576 | + } |
|
577 | 577 | |
578 | - /** |
|
579 | - * Display the form session export |
|
578 | + /** |
|
579 | + * Display the form session export |
|
580 | 580 | * @param array $list_course |
581 | - * @param array $hidden_fields Hidden fields to add to the form. |
|
581 | + * @param array $hidden_fields Hidden fields to add to the form. |
|
582 | 582 | * @param boolean $avoid_serialize the document array will be serialize. This is used in the course_copy.php file |
583 | - */ |
|
584 | - public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) |
|
585 | - { |
|
586 | - ?> |
|
583 | + */ |
|
584 | + public static function display_form_session_export($list_course, $hidden_fields = null, $avoid_serialize = false) |
|
585 | + { |
|
586 | + ?> |
|
587 | 587 | <script> |
588 | 588 | function exp(item) { |
589 | 589 | el = document.getElementById('div_'+item); |
@@ -625,68 +625,68 @@ discard block |
||
625 | 625 | </script> |
626 | 626 | <?php |
627 | 627 | |
628 | - //get destination course title |
|
629 | - if(!empty($hidden_fields['destination_course'])) { |
|
630 | - if (!empty($hidden_fields['destination_session'])) { |
|
631 | - $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')'; |
|
632 | - } else { |
|
633 | - $sessionTitle = null; |
|
634 | - } |
|
628 | + //get destination course title |
|
629 | + if(!empty($hidden_fields['destination_course'])) { |
|
630 | + if (!empty($hidden_fields['destination_session'])) { |
|
631 | + $sessionTitle = ' (' . api_get_session_name($hidden_fields['destination_session']) . ')'; |
|
632 | + } else { |
|
633 | + $sessionTitle = null; |
|
634 | + } |
|
635 | 635 | $course_infos = CourseManager::get_course_information($hidden_fields['destination_course']); |
636 | - echo '<h3>'; |
|
637 | - echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle; |
|
638 | - echo '</h3>'; |
|
639 | - } |
|
636 | + echo '<h3>'; |
|
637 | + echo get_lang('DestinationCourse') . ' : ' . $course_infos['title'] . $sessionTitle; |
|
638 | + echo '</h3>'; |
|
639 | + } |
|
640 | 640 | |
641 | - echo api_get_js('js/upload.js'); |
|
642 | - echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
641 | + echo api_get_js('js/upload.js'); |
|
642 | + echo '<script type="text/javascript">var myUpload = new upload(1000);</script>'; |
|
643 | 643 | $icon = Display::returnIconPath('progress_bar.gif'); |
644 | 644 | echo '<div class="tool-backups-options">'; |
645 | - echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">'; |
|
646 | - echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
647 | - foreach ($list_course as $course) { |
|
648 | - foreach ($course->resources as $type => $resources) { |
|
649 | - if (count($resources) > 0) { |
|
645 | + echo '<form method="post" id="upload_form" name="course_select_form" onsubmit="myUpload.start(\'dynamic_div\',\''.$icon.'\',\''.get_lang('PleaseStandBy').'\',\'upload_form\')">'; |
|
646 | + echo '<input type="hidden" name="action" value="course_select_form"/>'; |
|
647 | + foreach ($list_course as $course) { |
|
648 | + foreach ($course->resources as $type => $resources) { |
|
649 | + if (count($resources) > 0) { |
|
650 | 650 | echo '<div class="item-backup" onclick="javascript:exp('."'$course->code'".');">'; |
651 | - echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>'; |
|
652 | - echo '<span class="title"> '.$course->code.'</span></div>'; |
|
653 | - echo '<div class="item-content" id="div_'.$course->code.'">'; |
|
654 | - echo '<blockquote>'; |
|
651 | + echo '<em id="img_'.$course->code.'" class="fa fa-minus-square-o fa-lg"></em>'; |
|
652 | + echo '<span class="title"> '.$course->code.'</span></div>'; |
|
653 | + echo '<div class="item-content" id="div_'.$course->code.'">'; |
|
654 | + echo '<blockquote>'; |
|
655 | 655 | |
656 | 656 | echo '<div class="btn-group">'; |
657 | - echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>"; |
|
657 | + echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',true);\" >".get_lang('All')."</a>"; |
|
658 | 658 | echo "<a class=\"btn\" href=\"#\" onclick=\"javascript:setCheckbox('".$course->code."',false);\" >".get_lang('None')."</a>"; |
659 | - echo '</div>'; |
|
659 | + echo '</div>'; |
|
660 | 660 | |
661 | - foreach ($resources as $id => $resource) { |
|
662 | - echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">'; |
|
661 | + foreach ($resources as $id => $resource) { |
|
662 | + echo '<label class="checkbox" for="resource['.$course->code.']['.$id.']">'; |
|
663 | 663 | echo '<input type="checkbox" name="resource['.$course->code.']['.$id.']" id="resource['.$course->code.']['.$id.']"/>'; |
664 | - $resource->show(); |
|
665 | - echo '</label>'; |
|
666 | - } |
|
667 | - echo '</blockquote>'; |
|
668 | - echo '</div>'; |
|
669 | - echo '<script type="text/javascript">exp('."'$course->code'".')</script>'; |
|
670 | - } |
|
671 | - } |
|
672 | - } |
|
673 | - if ($avoid_serialize) { |
|
674 | - //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files) |
|
675 | - // this is a known issue of serialize |
|
676 | - $course->resources['document']= null; |
|
677 | - } |
|
678 | - echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
679 | - if (is_array($hidden_fields)) { |
|
680 | - foreach ($hidden_fields as $key => $value) { |
|
681 | - echo "\n"; |
|
682 | - echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
683 | - } |
|
684 | - } |
|
685 | - echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>'; |
|
686 | - CourseSelectForm :: display_hidden_quiz_questions($course); |
|
687 | - CourseSelectForm :: display_hidden_scorm_directories($course); |
|
688 | - echo '</form>'; |
|
664 | + $resource->show(); |
|
665 | + echo '</label>'; |
|
666 | + } |
|
667 | + echo '</blockquote>'; |
|
668 | + echo '</div>'; |
|
669 | + echo '<script type="text/javascript">exp('."'$course->code'".')</script>'; |
|
670 | + } |
|
671 | + } |
|
672 | + } |
|
673 | + if ($avoid_serialize) { |
|
674 | + //Documents are avoided due the huge amount of memory that the serialize php function "eats" (when there are directories with hundred/thousand of files) |
|
675 | + // this is a known issue of serialize |
|
676 | + $course->resources['document']= null; |
|
677 | + } |
|
678 | + echo '<input type="hidden" name="course" value="'.base64_encode(Course::serialize($course)).'"/>'; |
|
679 | + if (is_array($hidden_fields)) { |
|
680 | + foreach ($hidden_fields as $key => $value) { |
|
681 | + echo "\n"; |
|
682 | + echo '<input type="hidden" name="'.$key.'" value="'.$value.'"/>'; |
|
683 | + } |
|
684 | + } |
|
685 | + echo '<br /><button class="save" type="submit" onclick="checkLearnPath(\''.addslashes(get_lang('DocumentsWillBeAddedToo')).'\')">'.get_lang('Ok').'</button>'; |
|
686 | + CourseSelectForm :: display_hidden_quiz_questions($course); |
|
687 | + CourseSelectForm :: display_hidden_scorm_directories($course); |
|
688 | + echo '</form>'; |
|
689 | 689 | echo '</div>'; |
690 | - echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
691 | - } |
|
690 | + echo '<div id="dynamic_div" style="display:block;margin-left:40%;margin-top:10px;height:50px;"></div>'; |
|
691 | + } |
|
692 | 692 | } |
@@ -14,9 +14,9 @@ |
||
14 | 14 | */ |
15 | 15 | class SettingsHelper extends Helper implements SettingsHelperInterface |
16 | 16 | { |
17 | - /** |
|
18 | - * @var SettingsManager |
|
19 | - */ |
|
17 | + /** |
|
18 | + * @var SettingsManager |
|
19 | + */ |
|
20 | 20 | private $settingsManager; |
21 | 21 | |
22 | 22 | /** |