chamilo /
chamilo-lms
| 1 | <?php |
||||
| 2 | /* For licensing terms, see /license.txt */ |
||||
| 3 | |||||
| 4 | use Chamilo\PluginBundle\MigrationMoodle\Script\BaseScript; |
||||
| 5 | use Chamilo\PluginBundle\MigrationMoodle\Task\BaseTask; |
||||
| 6 | |||||
| 7 | ini_set('memory_limit', -1); |
||||
| 8 | ini_set('max_execution_time', 0); |
||||
| 9 | |||||
| 10 | $cidReset = true; |
||||
| 11 | |||||
| 12 | $outputBuffering = false; |
||||
| 13 | |||||
| 14 | require_once __DIR__.'/../../main/inc/global.inc.php'; |
||||
| 15 | |||||
| 16 | api_protect_admin_script(true); |
||||
| 17 | |||||
| 18 | $action = isset($_GET['action']) ? $_GET['action'] : ''; |
||||
| 19 | |||||
| 20 | $plugin = MigrationMoodlePlugin::create(); |
||||
| 21 | |||||
| 22 | if ('true' != $plugin->get('active')) { |
||||
| 23 | api_not_allowed(true); |
||||
| 24 | } |
||||
| 25 | |||||
| 26 | $menuTasks = [ |
||||
| 27 | '_' => [ |
||||
| 28 | 'course_categories', |
||||
| 29 | 'courses', |
||||
| 30 | //'role_assignments', |
||||
| 31 | 'users', |
||||
| 32 | ], |
||||
| 33 | 'courses' => [ |
||||
| 34 | 'course_introductions', |
||||
| 35 | 'course_sections', |
||||
| 36 | 'course_modules_scorm', |
||||
| 37 | ], |
||||
| 38 | 'course_sections' => [ |
||||
| 39 | 'files_for_course_sections', |
||||
| 40 | 'course_modules_lesson', |
||||
| 41 | 'course_modules_quiz', |
||||
| 42 | 'course_modules_url', |
||||
| 43 | //'c_quiz', |
||||
| 44 | 'sort_section_modules', |
||||
| 45 | ], |
||||
| 46 | 'course_modules_lesson' => [ |
||||
| 47 | 'lesson_pages', |
||||
| 48 | ], |
||||
| 49 | 'lesson_pages' => [ |
||||
| 50 | 'lesson_pages_document', |
||||
| 51 | 'lesson_pages_quiz', |
||||
| 52 | ], |
||||
| 53 | 'lesson_pages_document' => [ |
||||
| 54 | 'files_for_lesson_pages', |
||||
| 55 | ], |
||||
| 56 | 'lesson_pages_quiz' => [ |
||||
| 57 | 'lesson_pages_quiz_question', |
||||
| 58 | 'files_for_lesson_answers', |
||||
| 59 | ], |
||||
| 60 | 'lesson_pages_quiz_question' => [ |
||||
| 61 | 'lesson_answers_true_false', |
||||
| 62 | 'lesson_answers_multiple_choice', |
||||
| 63 | 'lesson_answers_multiple_answer', |
||||
| 64 | 'lesson_answers_matching', |
||||
| 65 | 'lesson_answers_essay', |
||||
| 66 | 'lesson_answers_short_answer', |
||||
| 67 | ], |
||||
| 68 | 'course_modules_quiz' => [ |
||||
| 69 | 'quizzes', |
||||
| 70 | 'quizzes_scores', |
||||
| 71 | ], |
||||
| 72 | 'quizzes' => [ |
||||
| 73 | 'files_for_quizzes', |
||||
| 74 | 'question_categories', |
||||
| 75 | 'questions', |
||||
| 76 | ], |
||||
| 77 | 'questions' => [ |
||||
| 78 | 'question_multi_choice_single', |
||||
| 79 | 'question_multi_choice_multiple', |
||||
| 80 | 'questions_true_false', |
||||
| 81 | 'question_short_answer', |
||||
| 82 | 'question_gapselect', |
||||
| 83 | ], |
||||
| 84 | 'course_modules_scorm' => [ |
||||
| 85 | 'scorm_scoes', |
||||
| 86 | ], |
||||
| 87 | 'scorm_scoes' => [ |
||||
| 88 | 'files_for_scorm_scoes', |
||||
| 89 | ], |
||||
| 90 | 'course_introductions' => [ |
||||
| 91 | 'files_for_course_introductions', |
||||
| 92 | ], |
||||
| 93 | 'course_modules_url' => [ |
||||
| 94 | 'urls', |
||||
| 95 | ], |
||||
| 96 | 'users' => [ |
||||
| 97 | 'users_last_login', |
||||
| 98 | 'track_login', |
||||
| 99 | 'user_sessions', |
||||
| 100 | ], |
||||
| 101 | 'user_sessions' => [ |
||||
| 102 | 'users_learn_paths', |
||||
| 103 | 'users_scorms_view', |
||||
| 104 | 'track_course_access', |
||||
| 105 | ], |
||||
| 106 | 'users_learn_paths' => [ |
||||
| 107 | 'users_learn_paths_lesson_timer', |
||||
| 108 | 'users_learn_paths_lesson_branch', |
||||
| 109 | 'users_learn_paths_lesson_attempts', |
||||
| 110 | 'users_learn_paths_quizzes', |
||||
| 111 | ], |
||||
| 112 | 'users_learn_paths_quizzes' => [ |
||||
| 113 | 'users_quizzes_attempts', |
||||
| 114 | 'user_question_attempts_shortanswer', |
||||
| 115 | 'user_question_attempts_gapselect', |
||||
| 116 | 'user_question_attempts_truefalse', |
||||
| 117 | ], |
||||
| 118 | ]; |
||||
| 119 | |||||
| 120 | $menuScripts = [ |
||||
| 121 | '_' => [ |
||||
| 122 | 'user_learn_paths_progress', |
||||
| 123 | 'user_scorms_progress', |
||||
| 124 | ], |
||||
| 125 | ]; |
||||
| 126 | |||||
| 127 | $htmlHeadXtra[] = '<style>.fa-ul {list-style-type: decimal; list-style-position: outside;}</style>'; |
||||
| 128 | |||||
| 129 | Display::display_header($plugin->get_title()); |
||||
| 130 | |||||
| 131 | echo '<div class="row">'; |
||||
| 132 | echo '<div class="col-sm-6 col-sm-push-6">'; |
||||
| 133 | echo '<pre style="max-height: 1190px; overflow: auto; height: 1190px;">'; |
||||
| 134 | |||||
| 135 | if (!empty($action) && isAllowedAction($action, $menuTasks) && !$plugin->isTaskDone($action)) { |
||||
| 136 | $taskName = api_underscore_to_camel_case($action).'Task'; |
||||
| 137 | |||||
| 138 | echo Display::page_subheader( |
||||
| 139 | $plugin->get_lang($taskName) |
||||
| 140 | ); |
||||
| 141 | |||||
| 142 | $taskName = 'Chamilo\\PluginBundle\\MigrationMoodle\\Task\\'.$taskName; |
||||
| 143 | |||||
| 144 | /** @var BaseTask $task */ |
||||
| 145 | $task = new $taskName(); |
||||
| 146 | |||||
| 147 | $task->execute(); |
||||
| 148 | } |
||||
| 149 | |||||
| 150 | if (!empty($action) && isAllowedAction($action, $menuScripts) && !$plugin->isTaskDone($action)) { |
||||
| 151 | $scriptName = api_underscore_to_camel_case($action).'Script'; |
||||
| 152 | |||||
| 153 | echo Display::page_subheader( |
||||
| 154 | $plugin->get_lang($scriptName) |
||||
| 155 | ); |
||||
| 156 | |||||
| 157 | $scriptClass = 'Chamilo\\PluginBundle\\MigrationMoodle\\Script\\'.$scriptName; |
||||
| 158 | |||||
| 159 | /** @var BaseScript $script */ |
||||
| 160 | $script = new $scriptClass(); |
||||
| 161 | |||||
| 162 | $script->run(); |
||||
| 163 | } |
||||
| 164 | |||||
| 165 | echo '</pre>'; |
||||
| 166 | echo '</div>'; |
||||
| 167 | echo '<div class="col-sm-6 col-sm-pull-6">'; |
||||
| 168 | echo Display::page_subheader('Tasks'); |
||||
| 169 | echo displayMenu($menuTasks); |
||||
| 170 | echo Display::page_subheader('Scripts'); |
||||
| 171 | echo displayMenu($menuScripts, 'Script'); |
||||
| 172 | echo '</div>'; |
||||
| 173 | echo '</div>'; |
||||
| 174 | |||||
| 175 | Display::display_footer(); |
||||
| 176 | |||||
| 177 | /** |
||||
| 178 | * @param string $parent |
||||
| 179 | * @param string $type |
||||
| 180 | * |
||||
| 181 | * @return string |
||||
| 182 | */ |
||||
| 183 | function displayMenu(array $menu, $type = 'Task', $parent = '_') |
||||
| 184 | { |
||||
| 185 | $plugin = MigrationMoodlePlugin::create(); |
||||
| 186 | |||||
| 187 | $items = $menu[$parent]; |
||||
| 188 | |||||
| 189 | $isParentDone = $parent === '_' ? true : $plugin->isTaskDone($parent); |
||||
| 190 | |||||
| 191 | $baseUrl = api_get_self()."?action="; |
||||
| 192 | |||||
| 193 | $html = '<ol class="fa-ul">'; |
||||
| 194 | |||||
| 195 | foreach ($items as $item) { |
||||
| 196 | $title = api_underscore_to_camel_case($item); |
||||
| 197 | |||||
| 198 | $html .= '<li>'; |
||||
| 199 | |||||
| 200 | $htmlItem = Display::returnFontAwesomeIcon('check-square-o', '', true); |
||||
|
0 ignored issues
–
show
|
|||||
| 201 | $htmlItem .= $plugin->get_lang($title.$type); |
||||
| 202 | |||||
| 203 | if ($isParentDone) { |
||||
| 204 | if (!$plugin->isTaskDone($item)) { |
||||
| 205 | $htmlItem = Display::returnFontAwesomeIcon('square-o', '', true); |
||||
|
0 ignored issues
–
show
The function
Display::returnFontAwesomeIcon() has been deprecated: Use getMdiIcon() instead
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This function has been deprecated. The supplier of the function has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead. Loading history...
|
|||||
| 206 | $htmlItem .= Display::url( |
||||
| 207 | $plugin->get_lang($title.$type), |
||||
| 208 | $baseUrl.$item |
||||
| 209 | ); |
||||
| 210 | } |
||||
| 211 | } |
||||
| 212 | |||||
| 213 | $html .= $htmlItem; |
||||
| 214 | |||||
| 215 | if (isset($menu[$item])) { |
||||
| 216 | $html .= displayMenu($menu, $type, $item); |
||||
| 217 | } |
||||
| 218 | |||||
| 219 | $html .= '</li>'; |
||||
| 220 | } |
||||
| 221 | |||||
| 222 | $html .= '</ol>'; |
||||
| 223 | |||||
| 224 | return $html; |
||||
| 225 | } |
||||
| 226 | |||||
| 227 | /** |
||||
| 228 | * @param string $action |
||||
| 229 | * |
||||
| 230 | * @return bool |
||||
| 231 | */ |
||||
| 232 | function isAllowedAction($action, array $menu) |
||||
| 233 | { |
||||
| 234 | foreach ($menu as $items) { |
||||
| 235 | if (in_array($action, $items)) { |
||||
| 236 | return true; |
||||
| 237 | } |
||||
| 238 | } |
||||
| 239 | |||||
| 240 | return false; |
||||
| 241 | } |
||||
| 242 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.