1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- <?php
- $language_file = 'exercice';
- require_once '../inc/global.inc.php';
- require_once api_get_path(LIBRARY_PATH).'document.lib.php';
- require_once 'exercise.class.php';
- require_once 'question.class.php';
- require_once 'answer.class.php';
- $this_section = SECTION_COURSES;
- if (!api_is_allowed_to_edit(null, true)) {
- api_not_allowed();
- }
- $interbreadcrumb[]= array ("url"=>"exercice.php", "name"=> get_lang('Exercices'));
- $is_allowedToEdit = api_is_allowed_to_edit(null, true);
- function ch_qti2_display_form() {
- $name_tools = get_lang('ImportQtiQuiz');
- $form = '<div class="actions">';
- $form .= '<a href="exercice.php?show=test">' . Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>';
- $form .= '</div>';
- $form_validator = new FormValidator('qti_upload', 'post',api_get_self()."?".api_get_cidreq(), null, array('enctype' => 'multipart/form-data') );
- $form_validator->addElement('header', $name_tools);
- $form_validator->addElement('file', 'userFile', get_lang('DownloadFile'));
- $form_validator->addElement('style_submit_button', 'submit', get_lang('Send'), 'class="upload"');
- $form .= $form_validator->return_form();
- echo $form;
- }
- function ch_qti2_import_file($array_file) {
- $unzip = 0;
- $lib_path = api_get_path(LIBRARY_PATH);
- require_once $lib_path.'fileUpload.lib.php';
- require_once $lib_path.'fileManage.lib.php';
- $process = process_uploaded_file($array_file);
- if (preg_match('/\.zip$/i', $array_file['name'])) {
-
- $unzip = 1;
- }
- if ($process && $unzip == 1) {
- $main_path = api_get_path(SYS_CODE_PATH);
- require_once $main_path.'exercice/export/exercise_import.inc.php';
- require_once $main_path.'exercice/export/qti2/qti2_classes.php';
- $imported = import_exercise($array_file['name']);
- if ($imported) {
- header('Location: exercice.php?'.api_get_cidreq());
- } else {
- Display::display_error_message(get_lang('UplNoFileUploaded'));
- return false;
- }
- }
- }
- Display::display_header(get_lang('ImportQtiQuiz'), 'Exercises');
- if ((api_is_allowed_to_edit(null, true))) {
- if (isset($_POST['submit'])) {
- ch_qti2_import_file($_FILES['userFile']);
- }
- }
- ch_qti2_display_form();
- Display::display_footer();
|