Minor - format code, fix php warning

pull/2487/head
jmontoyaa 9 years ago
parent ea5d3788b0
commit 277360488f
  1. 36
      main/exercise/export/exercise_import.inc.php
  2. 35
      main/exercise/export/exercise_import.php
  3. 4
      main/exercise/export/qti2/qti2_classes.php
  4. 1
      main/exercise/export/qti2/qti2_export.php

@ -11,7 +11,6 @@ use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
* @author Yannick Warnier <yannick.warnier@beeznest.com>
*/
/**
* Unzip the exercise in the temp folder
* @param string The path of the temporary directory where the exercise was uploaded and unzipped
@ -427,13 +426,13 @@ function startElementQti2($parser, $name, $attributes)
switch ($current_element) {
case 'ASSESSMENTITEM':
//retrieve current question
// retrieve current question
$current_question_ident = $attributes['IDENTIFIER'];
$exercise_info['question'][$current_question_ident] = array();
$exercise_info['question'][$current_question_ident]['answer'] = array();
$exercise_info['question'][$current_question_ident]['correct_answers'] = array();
$exercise_info['question'][$current_question_ident]['title'] = $attributes['TITLE'];
$exercise_info['question'][$current_question_ident]['category'] = $attributes['CATEGORY'];
$exercise_info['question'][$current_question_ident] = [];
$exercise_info['question'][$current_question_ident]['answer'] = [];
$exercise_info['question'][$current_question_ident]['correct_answers'] = [];
$exercise_info['question'][$current_question_ident]['title'] = isset($attributes['TITLE']) ? $attributes['TITLE'] : '';
$exercise_info['question'][$current_question_ident]['category'] = isset($attributes['CATEGORY']) ? $attributes['CATEGORY'] : '';
$exercise_info['question'][$current_question_ident]['tempdir'] = $questionTempDir;
break;
case 'SECTION':
@ -444,11 +443,11 @@ function startElementQti2($parser, $name, $attributes)
break;
case 'RESPONSEDECLARATION':
// Retrieve question type
if ("multiple" == $attributes['CARDINALITY']) {
if ('multiple' == $attributes['CARDINALITY']) {
$exercise_info['question'][$current_question_ident]['type'] = MCMA;
$cardinality = 'multiple';
}
if ("single" == $attributes['CARDINALITY']) {
if ('single' == $attributes['CARDINALITY']) {
$exercise_info['question'][$current_question_ident]['type'] = MCUA;
$cardinality = 'single';
}
@ -540,21 +539,20 @@ function endElementQti2($parser, $name)
if (sizeof($element_pile) >= 2) {
$parent_element = $element_pile[sizeof($element_pile) - 2];
} else {
$parent_element = "";
$parent_element = '';
}
if (sizeof($element_pile) >= 3) {
$grand_parent_element = $element_pile[sizeof($element_pile) - 3];
} else {
$grand_parent_element = "";
$grand_parent_element = '';
}
if (sizeof($element_pile) >= 4) {
$great_grand_parent_element = $element_pile[sizeof($element_pile) - 4];
} else {
$great_grand_parent_element = "";
$great_grand_parent_element = '';
}
//treat the record of the full content of itembody tag :
//treat the record of the full content of itembody tag:
if ($record_item_body && (!in_array($current_element, $non_HTML_tag_to_avoid))) {
$current_question_item_body .= "</".$name.">";
}
@ -595,17 +593,17 @@ function elementDataQti2($parser, $data)
if (sizeof($element_pile) >= 2) {
$parent_element = $element_pile[sizeof($element_pile) - 2];
} else {
$parent_element = "";
$parent_element = '';
}
if (sizeof($element_pile) >= 3) {
$grand_parent_element = $element_pile[sizeof($element_pile) - 3];
} else {
$grand_parent_element = "";
$grand_parent_element = '';
}
if (sizeof($element_pile) >= 4) {
$great_grand_parent_element = $element_pile[sizeof($element_pile) - 4];
} else {
$great_grand_parent_element = "";
$great_grand_parent_element = '';
}
//treat the record of the full content of itembody tag (needed for question statment and/or FIB text:
@ -1076,9 +1074,9 @@ function qtiProcessManifest($filePath)
$specialHref = Database::escape_string(preg_replace('/_/', '-', strtolower($href)));
$specialHref = preg_replace('/(-){2,8}/', '-', $specialHref);
$sql = "SELECT iid FROM ".$tableDocuments."
$sql = "SELECT iid FROM $tableDocuments
WHERE
c_id = " . $course['real_id']." AND
c_id = ".$course['real_id']." AND
session_id = $sessionId AND
path = '/".$specialHref."'";
$result = Database::query($sql);

@ -1,5 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* @copyright (c) 2001-2006 Universite catholique de Louvain (UCL)
* @package chamilo.exercise
@ -16,16 +17,10 @@ if (api_is_platform_admin()) {
require_once 'exercise_import.inc.php';
//SQL table name
$tbl_exercise = Database::get_course_table(TABLE_QUIZ_TEST);
$tbl_question = Database::get_course_table(TABLE_QUIZ_QUESTION);
$tbl_rel_exercise_question = Database::get_course_table(TABLE_QUIZ_TEST_QUESTION);
// tool libraries
//Tool title
$nameTools = get_lang('ImportExercise');
$interbredcrump[] = array('url' => '../exercise.php', 'name' => get_lang('Exercises'));
@ -35,17 +30,17 @@ $cmd = (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'show_import');
switch ($cmd) {
case 'show_import':
$display = '<p>'
. get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.').'<br>'
. '</p>'
. '<form enctype="multipart/form-data" action="" method="post">'
. '<input name="cmd" type="hidden" value="import" />'
. '<input name="uploadedExercise" type="file" /><br><br>'
. get_lang('Import exercise').' : '
. '<input value="'.get_lang('Ok').'" type="submit" /> '
. claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel'))
. '<br><br>'
. '<small>'.get_lang('Max file size').' : 2&nbsp;MB</small>'
. '</form>';
.get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.').'<br>'
.'</p>'
.'<form enctype="multipart/form-data" action="" method="post">'
.'<input name="cmd" type="hidden" value="import" />'
.'<input name="uploadedExercise" type="file" /><br><br>'
.get_lang('Import exercise').' : '
.'<input value="'.get_lang('Ok').'" type="submit" /> '
.claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel'))
.'<br><br>'
.'<small>'.get_lang('Max file size').' : 2&nbsp;MB</small>'
.'</form>';
break;
case 'import':
//include needed librabries for treatment
@ -67,10 +62,10 @@ include api_get_path(SYS_INC_PATH).'/header.inc.php';
Display::display_introduction_section(
TOOL_QUIZ,
array(
'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
'CreateDocumentWebDir' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/',
'CreateDocumentDir' => '../../..'.api_get_path(REL_COURSE_PATH).api_get_course_path().'/document/',
'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
)
'BaseHref' => api_get_path(WEB_COURSE_PATH).api_get_course_path().'/'
)
);
// Display Forms or dialog box(if needed)

@ -331,7 +331,7 @@ class ImsAnswerHotspot extends Answer
$type = 'poly';
$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
break;
case 'delineation':
case 'delineation':
$type = 'delineation';
$coords = str_replace(array(';', '|'), array(',', ','), $answer['hotspot_coord']);
break;
@ -366,7 +366,7 @@ class ImsAnswerHotspot extends Answer
$out .= ' </correctResponse>'."\n";
$out .= ' </responseDeclaration>'."\n";
return $out;
return $out;
}
}

@ -487,6 +487,7 @@ function formatExerciseQtiTitle($text)
/**
* @param string $text
* @return string
*/
function cleanAttribute($text)
{

Loading…
Cancel
Save