|
|
|
|
@ -1,11 +1,10 @@ |
|
|
|
|
<?php |
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
/** |
|
|
|
|
* Code for Aiken import integration. |
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
* @author Ronny Velasquez |
|
|
|
|
* @author César Perales <cesar.perales@gmail.com> Updated function names and import files for Aiken format support |
|
|
|
|
* @version $Id: Aiken.php 2010-03-12 12:14:25Z $ |
|
|
|
|
* Code for Aiken import integration. |
|
|
|
|
* @package chamilo.exercise |
|
|
|
|
* @author Ronny Velasquez <ronny.velasquez@beeznest.com> |
|
|
|
|
* @author César Perales <cesar.perales@gmail.com> Updated function names and import files for Aiken format support |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* Code |
|
|
|
|
@ -29,7 +28,7 @@ $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 |
|
|
|
|
@ -39,18 +38,21 @@ $is_allowedToEdit = api_is_allowed_to_edit(null, true); |
|
|
|
|
/** |
|
|
|
|
* This function displays the form for import of the zip file with qti2 |
|
|
|
|
*/ |
|
|
|
|
function aiken_display_form() { |
|
|
|
|
$name_tools = get_lang('ImportAikenQuiz'); |
|
|
|
|
$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>'; |
|
|
|
|
function aiken_display_form($msg = '') { |
|
|
|
|
$name_tools = get_lang('ImportAikenQuiz'); |
|
|
|
|
$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>'; |
|
|
|
|
if (!empty($msg)) { |
|
|
|
|
$form .= $msg; |
|
|
|
|
} |
|
|
|
|
$form_validator = new FormValidator('aiken_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(); |
|
|
|
|
$form .= $form_validator->return_form(); |
|
|
|
|
|
|
|
|
|
echo $form; |
|
|
|
|
echo $form; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -59,43 +61,44 @@ function aiken_display_form() { |
|
|
|
|
*/ |
|
|
|
|
function aiken_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'])) { |
|
|
|
|
// 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/aiken/aiken_import.inc.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); |
|
|
|
|
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/aiken/aiken_import.inc.php'; |
|
|
|
|
require_once $main_path.'exercice/export/aiken/aiken_classes.php'; |
|
|
|
|
$imported = import_exercise($array_file['name']); |
|
|
|
|
|
|
|
|
|
if ($imported) { |
|
|
|
|
header('Location: exercice.php?'.api_get_cidreq()); |
|
|
|
|
header('Location: exercice.php?'.api_get_cidreq()); |
|
|
|
|
} else { |
|
|
|
|
Display::display_error_message(get_lang('UplNoFileUploaded')); |
|
|
|
|
return false; |
|
|
|
|
$msg = Display::return_message(get_lang('UplNoFileUploaded'),'error'); |
|
|
|
|
return $msg; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// display header |
|
|
|
|
Display::display_header(get_lang('ImportAikenQuiz'), 'Exercises'); |
|
|
|
|
|
|
|
|
|
$msg = ''; |
|
|
|
|
// import file |
|
|
|
|
if ((api_is_allowed_to_edit(null, true))) { |
|
|
|
|
if (isset($_POST['submit'])) { |
|
|
|
|
aiken_import_file($_FILES['userFile']); |
|
|
|
|
} |
|
|
|
|
if (isset($_POST['submit'])) { |
|
|
|
|
$msg = aiken_import_file($_FILES['userFile']); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// display header |
|
|
|
|
Display::display_header(get_lang('ImportAikenQuiz'), 'Exercises'); |
|
|
|
|
|
|
|
|
|
// display Aiken form |
|
|
|
|
aiken_display_form(); |
|
|
|
|
aiken_display_form($msg); |
|
|
|
|
|
|
|
|
|
// display the footer |
|
|
|
|
Display::display_footer(); |