|
|
|
@ -1,11 +1,11 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
/** |
|
|
|
|
* Code for Qti2 import integration. |
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
* @author Ronny Velasquez |
|
|
|
|
* @version $Id: qti2.php 2010-03-12 12:14:25Z $ |
|
|
|
|
*/ |
|
|
|
|
* Code for Qti2 import integration. |
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
* @author Ronny Velasquez |
|
|
|
|
* @version $Id: qti2.php 2010-03-12 12:14:25Z $ |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* Code |
|
|
|
|
*/ |
|
|
|
@ -14,19 +14,13 @@ $language_file = array('exercice', 'document'); |
|
|
|
|
|
|
|
|
|
// including the global Chamilo file |
|
|
|
|
require_once '../inc/global.inc.php'; |
|
|
|
|
require_once api_get_path(LIBRARY_PATH).'document.lib.php'; |
|
|
|
|
|
|
|
|
|
// including additional libraries |
|
|
|
|
require_once 'exercise.class.php'; |
|
|
|
|
require_once 'question.class.php'; |
|
|
|
|
require_once 'answer.class.php'; |
|
|
|
|
|
|
|
|
|
// section (for the tabs) |
|
|
|
|
$this_section = SECTION_COURSES; |
|
|
|
|
|
|
|
|
|
// access restriction: only teachers are allowed here |
|
|
|
|
if (!api_is_allowed_to_edit(null, true)) { |
|
|
|
|
api_not_allowed(); |
|
|
|
|
api_not_allowed(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// the breadcrumbs |
|
|
|
@ -41,11 +35,11 @@ $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="'.api_get_path(WEB_CODE_PATH).'exercice/exercice.php?show=test&'.api_get_cidreq().'">'. |
|
|
|
|
Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
$form .= '</div>'; |
|
|
|
|
$name_tools = get_lang('ImportQtiQuiz'); |
|
|
|
|
$form = '<div class="actions">'; |
|
|
|
|
$form .= '<a href="'.api_get_path(WEB_CODE_PATH).'exercice/exercice.php?show=test&'.api_get_cidreq().'">'. |
|
|
|
|
Display :: return_icon('back.png', get_lang('BackToExercisesList'),'',ICON_SIZE_MEDIUM).'</a>'; |
|
|
|
|
$form .= '</div>'; |
|
|
|
|
$formValidator = new FormValidator( |
|
|
|
|
'qti_upload', |
|
|
|
|
'post', |
|
|
|
@ -57,7 +51,7 @@ function ch_qti2_display_form() |
|
|
|
|
$formValidator->addElement('file', 'userFile', get_lang('DownloadFile')); |
|
|
|
|
$formValidator->addElement('style_submit_button', 'submit', get_lang('Send'), 'class="upload"'); |
|
|
|
|
$form .= $formValidator->return_form(); |
|
|
|
|
echo $form; |
|
|
|
|
echo $form; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -66,25 +60,25 @@ function ch_qti2_display_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'; |
|
|
|
|
$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, false); |
|
|
|
|
$process = process_uploaded_file($array_file, false); |
|
|
|
|
|
|
|
|
|
if (preg_match('/\.zip$/i', $array_file['name'])) { |
|
|
|
|
// if it's a zip, allow zip upload |
|
|
|
|
$unzip = 1; |
|
|
|
|
} |
|
|
|
|
if (preg_match('/\.zip$/i', $array_file['name'])) { |
|
|
|
|
// if it's a zip, allow zip upload |
|
|
|
|
$unzip = 1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($process && $unzip == 1) { |
|
|
|
|
$main_path = api_get_path(SYS_CODE_PATH); |
|
|
|
|
require_once $main_path.'exercice/export/exercise_import.inc.php'; |
|
|
|
|
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'; |
|
|
|
|
|
|
|
|
|
return import_exercise($array_file['name']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 'langFileError'; |
|
|
|
|
} |
|
|
|
|