refs #7010 Inclusión formato Aiken
parent
4554068b07
commit
f3ca712c67
@ -0,0 +1,101 @@ |
||||
<?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 |
||||
*/ |
||||
// name of the language file that needs to be included |
||||
$language_file = 'exercice'; |
||||
|
||||
// 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'; |
||||
require_once 'unique_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(); |
||||
} |
||||
|
||||
// the breadcrumbs |
||||
$interbreadcrumb[]= array ("url"=>"exercice.php", "name"=> get_lang('Exercices')); |
||||
$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>'; |
||||
$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(); |
||||
|
||||
echo $form; |
||||
} |
||||
|
||||
/** |
||||
* This function will import the zip file with the respective qti2 |
||||
* @param array $uploaded_file ($_FILES) |
||||
*/ |
||||
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'; |
||||
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()); |
||||
} else { |
||||
Display::display_error_message(get_lang('UplNoFileUploaded')); |
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
|
||||
// display header |
||||
Display::display_header(get_lang('ImportAikenQuiz'), 'Exercises'); |
||||
|
||||
// import file |
||||
if ((api_is_allowed_to_edit(null, true))) { |
||||
if (isset($_POST['submit'])) { |
||||
aiken_import_file($_FILES['userFile']); |
||||
} |
||||
} |
||||
|
||||
// display Aiken form |
||||
aiken_display_form(); |
||||
|
||||
// display the footer |
||||
Display::display_footer(); |
@ -0,0 +1,142 @@ |
||||
<?php // $Id: $
|
||||
/* For licensing terms, see /license.txt */ |
||||
/** |
||||
* @author Claro Team <cvs@claroline.net> |
||||
* @author Yannick Warnier <yannick.warnier@beeznest.com> - updated ImsAnswerHotspot to match QTI norms |
||||
* @author César Perales <cesar.perales@gmail.com> Updated function names and import files for Aiken format support |
||||
* @package chamilo.exercise |
||||
*/ |
||||
/** |
||||
* Code |
||||
*/ |
||||
if ( count( get_included_files() ) == 1 ) die( '---' ); |
||||
|
||||
if (!function_exists('mime_content_type')) { |
||||
require_once api_get_path(LIBRARY_PATH).'document.lib.php'; |
||||
function mime_content_type($filename) { |
||||
return DocumentManager::file_get_mime_type((string)$filename); |
||||
} |
||||
} |
||||
|
||||
require_once(api_get_path(SYS_CODE_PATH).'/exercice/answer.class.php'); |
||||
require_once(api_get_path(SYS_CODE_PATH).'/exercice/exercise.class.php'); |
||||
require_once(api_get_path(SYS_CODE_PATH).'/exercice/question.class.php'); |
||||
//require_once(api_get_path(SYS_CODE_PATH).'/exercice/hotspot.class.php'); |
||||
require_once(api_get_path(SYS_CODE_PATH).'/exercice/unique_answer.class.php'); |
||||
//require_once(api_get_path(SYS_CODE_PATH).'/exercice/multiple_answer.class.php'); |
||||
//require_once(api_get_path(SYS_CODE_PATH).'/exercice/multiple_answer_combination.class.php'); |
||||
//require_once(api_get_path(SYS_CODE_PATH).'/exercice/matching.class.php'); |
||||
//require_once(api_get_path(SYS_CODE_PATH).'/exercice/freeanswer.class.php'); |
||||
//require_once(api_get_path(SYS_CODE_PATH).'/exercice/fill_blanks.class.php'); |
||||
//include_once $path . '/../../lib/answer_multiplechoice.class.php'; |
||||
//include_once $path . '/../../lib/answer_truefalse.class.php'; |
||||
//include_once $path . '/../../lib/answer_fib.class.php'; |
||||
//include_once $path . '/../../lib/answer_matching.class.php'; |
||||
/** |
||||
* |
||||
* @package chamilo.exercise |
||||
*/ |
||||
class Aiken2Question extends Question |
||||
{ |
||||
/** |
||||
* Include the correct answer class and create answer |
||||
*/ |
||||
function setAnswer() |
||||
{ |
||||
switch($this->type) |
||||
{ |
||||
case MCUA : |
||||
$answer = new AikenAnswerMultipleChoice($this->id); |
||||
return $answer; |
||||
default : |
||||
$answer = null; |
||||
break; |
||||
} |
||||
return $answer; |
||||
} |
||||
function createAnswersForm($form) |
||||
{ |
||||
return true; |
||||
} |
||||
function processAnswersCreation($form) |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
|
||||
/** |
||||
* Class |
||||
* @package chamilo.exercise |
||||
*/ |
||||
class AikenAnswerMultipleChoice extends Answer |
||||
{ |
||||
/** |
||||
* Return the XML flow for the possible answers. |
||||
* |
||||
*/ |
||||
function imsExportResponses($questionIdent, $questionStatment) |
||||
{ |
||||
$this->answerList = $this->getAnswersList(true); |
||||
$out = ' <choiceInteraction responseIdentifier="' . $questionIdent . '" >' . "\n"; |
||||
$out .= ' <prompt> ' . $questionStatment . ' </prompt>'. "\n"; |
||||
if (is_array($this->answerList)) { |
||||
foreach ($this->answerList as $current_answer) { |
||||
|
||||
|
||||
$out .= ' <simpleChoice identifier="answer_' . $current_answer['id'] . '" fixed="false">' . $current_answer['answer']; |
||||
if (isset($current_answer['comment']) && $current_answer['comment'] != '') |
||||
{ |
||||
$out .= '<feedbackInline identifier="answer_' . $current_answer['id'] . '">' . $current_answer['comment'] . '</feedbackInline>'; |
||||
} |
||||
$out .= '</simpleChoice>'. "\n"; |
||||
} |
||||
} |
||||
$out .= ' </choiceInteraction>'. "\n"; |
||||
return $out; |
||||
} |
||||
|
||||
/** |
||||
* Return the XML flow of answer ResponsesDeclaration |
||||
* |
||||
*/ |
||||
function imsExportResponsesDeclaration($questionIdent) |
||||
{ |
||||
$this->answerList = $this->getAnswersList(true); |
||||
$type = $this->getQuestionType(); |
||||
if ($type == MCMA) $cardinality = 'multiple'; else $cardinality = 'single'; |
||||
|
||||
$out = ' <responseDeclaration identifier="' . $questionIdent . '" cardinality="' . $cardinality . '" baseType="identifier">' . "\n"; |
||||
|
||||
//Match the correct answers |
||||
|
||||
$out .= ' <correctResponse>'. "\n"; |
||||
if (is_array($this->answerList)) { |
||||
foreach($this->answerList as $current_answer) { |
||||
if ($current_answer['correct']) |
||||
{ |
||||
$out .= ' <value>answer_'. $current_answer['id'] .'</value>'. "\n"; |
||||
} |
||||
} |
||||
} |
||||
$out .= ' </correctResponse>'. "\n"; |
||||
|
||||
//Add the grading |
||||
|
||||
$out .= ' <mapping>'. "\n"; |
||||
if (is_array($this->answerList)) { |
||||
foreach($this->answerList as $current_answer) |
||||
{ |
||||
if (isset($current_answer['grade'])) |
||||
{ |
||||
$out .= ' <mapEntry mapKey="answer_'. $current_answer['id'] .'" mappedValue="'.$current_answer['grade'].'" />'. "\n"; |
||||
} |
||||
} |
||||
} |
||||
$out .= ' </mapping>'. "\n"; |
||||
|
||||
$out .= ' </responseDeclaration>'. "\n"; |
||||
|
||||
return $out; |
||||
} |
||||
} |
Loading…
Reference in new issue