diff --git a/main/exercise/export/exercise_import.inc.php b/main/exercise/export/exercise_import.inc.php index 6f1e4bbb6d..c066908c5d 100755 --- a/main/exercise/export/exercise_import.inc.php +++ b/main/exercise/export/exercise_import.inc.php @@ -11,7 +11,6 @@ use Chamilo\CoreBundle\Component\Utils\ChamiloApi; * @author Yannick Warnier */ - /** * 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 .= ""; } @@ -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); diff --git a/main/exercise/export/exercise_import.php b/main/exercise/export/exercise_import.php index 90853742b5..6fb1ca495e 100755 --- a/main/exercise/export/exercise_import.php +++ b/main/exercise/export/exercise_import.php @@ -1,5 +1,6 @@ '../exercise.php', 'name' => get_lang('Exercises')); @@ -35,17 +30,17 @@ $cmd = (isset($_REQUEST['cmd']) ? $_REQUEST['cmd'] : 'show_import'); switch ($cmd) { case 'show_import': $display = '

' - . get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.').'
' - . '

' - . '
' - . '' - . '

' - . get_lang('Import exercise').' : ' - . ' ' - . claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel')) - . '

' - . ''.get_lang('Max file size').' : 2 MB' - . '
'; + .get_lang('Imported exercises must consist of a zip or an XML file (IMS-QTI) and be compatible with your Claroline version.').'
' + .'

' + .'
' + .'' + .'

' + .get_lang('Import exercise').' : ' + .' ' + .claro_html_button($_SERVER['PHP_SELF'], get_lang('Cancel')) + .'

' + .''.get_lang('Max file size').' : 2 MB' + .'
'; 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) diff --git a/main/exercise/export/qti2/qti2_classes.php b/main/exercise/export/qti2/qti2_classes.php index 71c414005b..5cef6d5f75 100755 --- a/main/exercise/export/qti2/qti2_classes.php +++ b/main/exercise/export/qti2/qti2_classes.php @@ -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 .= ' '."\n"; $out .= ' '."\n"; - return $out; + return $out; } } diff --git a/main/exercise/export/qti2/qti2_export.php b/main/exercise/export/qti2/qti2_export.php index 847799b199..59224528a7 100755 --- a/main/exercise/export/qti2/qti2_export.php +++ b/main/exercise/export/qti2/qti2_export.php @@ -487,6 +487,7 @@ function formatExerciseQtiTitle($text) /** * @param string $text + * @return string */ function cleanAttribute($text) {