|
|
@ -109,7 +109,7 @@ function import_exercise($file) |
|
|
|
$file_found = false; |
|
|
|
$file_found = false; |
|
|
|
$operation = false; |
|
|
|
$operation = false; |
|
|
|
$result = false; |
|
|
|
$result = false; |
|
|
|
|
|
|
|
$filePath = null; |
|
|
|
// parse every subdirectory to search xml question files |
|
|
|
// parse every subdirectory to search xml question files |
|
|
|
while (false !== ($file = readdir($exerciseHandle))) { |
|
|
|
while (false !== ($file = readdir($exerciseHandle))) { |
|
|
|
if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") { |
|
|
|
if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") { |
|
|
@ -118,23 +118,32 @@ function import_exercise($file) |
|
|
|
while (false !== ($questionFile = readdir($questionHandle))) { |
|
|
|
while (false !== ($questionFile = readdir($questionHandle))) { |
|
|
|
if (preg_match('/.xml$/i', $questionFile)) { |
|
|
|
if (preg_match('/.xml$/i', $questionFile)) { |
|
|
|
$result = parse_file($baseWorkDir, $file, $questionFile); |
|
|
|
$result = parse_file($baseWorkDir, $file, $questionFile); |
|
|
|
|
|
|
|
$filePath = $baseWorkDir.$file; |
|
|
|
$file_found = true; |
|
|
|
$file_found = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} elseif (preg_match('/.xml$/i', $file)) { |
|
|
|
} elseif (preg_match('/.xml$/i', $file)) { |
|
|
|
|
|
|
|
// Else ignore file |
|
|
|
$result = parse_file($baseWorkDir, '', $file); |
|
|
|
$result = parse_file($baseWorkDir, '', $file); |
|
|
|
|
|
|
|
$filePath = $baseWorkDir.'/'.$file; |
|
|
|
$file_found = true; |
|
|
|
$file_found = true; |
|
|
|
} // else ignore file |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!$file_found) { |
|
|
|
if (!$file_found) { |
|
|
|
Display :: display_error_message(get_lang('No XML file found in the zip')); |
|
|
|
Display :: display_error_message(get_lang('No XML file found in the zip')); |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
if ($result == false ) { |
|
|
|
|
|
|
|
|
|
|
|
if ($result == false) { |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$doc = new DOMDocument(); |
|
|
|
|
|
|
|
$doc->load($filePath); |
|
|
|
|
|
|
|
$encoding = $doc->encoding; |
|
|
|
|
|
|
|
|
|
|
|
// 1. Create exercise. |
|
|
|
// 1. Create exercise. |
|
|
|
$exercise = new Exercise(); |
|
|
|
$exercise = new Exercise(); |
|
|
|
$exercise->exercise = $exercise_info['name']; |
|
|
|
$exercise->exercise = $exercise_info['name']; |
|
|
@ -143,15 +152,16 @@ function import_exercise($file) |
|
|
|
$last_exercise_id = $exercise->selectId(); |
|
|
|
$last_exercise_id = $exercise->selectId(); |
|
|
|
if (!empty($last_exercise_id)) { |
|
|
|
if (!empty($last_exercise_id)) { |
|
|
|
// For each question found... |
|
|
|
// For each question found... |
|
|
|
foreach ($exercise_info['question'] as $key => $question_array) { |
|
|
|
foreach ($exercise_info['question'] as $question_array) { |
|
|
|
//2. Create question |
|
|
|
//2. Create question |
|
|
|
$question = new Ims2Question(); |
|
|
|
$question = new Ims2Question(); |
|
|
|
$question->type = $question_array['type']; |
|
|
|
$question->type = $question_array['type']; |
|
|
|
$question->setAnswer(); |
|
|
|
$question->setAnswer(); |
|
|
|
$question->updateTitle($question_array['title']); // question ... |
|
|
|
$question->updateTitle(formatText($question_array['title'])); |
|
|
|
|
|
|
|
//$question->updateDescription($question_array['title']); |
|
|
|
$type = $question->selectType(); |
|
|
|
$type = $question->selectType(); |
|
|
|
$question->type = constant($type); // type ... |
|
|
|
$question->type = constant($type); |
|
|
|
$question->save($last_exercise_id); // save computed grade |
|
|
|
$question->save($last_exercise_id); |
|
|
|
$last_question_id = $question->selectId(); |
|
|
|
$last_question_id = $question->selectId(); |
|
|
|
//3. Create answer |
|
|
|
//3. Create answer |
|
|
|
$answer = new Answer($last_question_id); |
|
|
|
$answer = new Answer($last_question_id); |
|
|
@ -161,9 +171,9 @@ function import_exercise($file) |
|
|
|
$split = explode('_', $key); |
|
|
|
$split = explode('_', $key); |
|
|
|
$i = $split[1]; |
|
|
|
$i = $split[1]; |
|
|
|
// Answer |
|
|
|
// Answer |
|
|
|
$answer->new_answer[$i] = $answers['value']; |
|
|
|
$answer->new_answer[$i] = formatText($answers['value']); |
|
|
|
// Comment |
|
|
|
// Comment |
|
|
|
$answer->new_comment[$i] = isset($answers['feedback']) ? $answers['feedback'] : null; |
|
|
|
$answer->new_comment[$i] = isset($answers['feedback']) ? formatText($answers['feedback']) : null; |
|
|
|
// Position |
|
|
|
// Position |
|
|
|
$answer->new_position[$i] = $i; |
|
|
|
$answer->new_position[$i] = $i; |
|
|
|
// Correct answers |
|
|
|
// Correct answers |
|
|
@ -188,6 +198,13 @@ function import_exercise($file) |
|
|
|
} |
|
|
|
} |
|
|
|
return $operation; |
|
|
|
return $operation; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* We assume the file charset is UTF8 |
|
|
|
|
|
|
|
**/ |
|
|
|
|
|
|
|
function formatText($text) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return api_html_entity_decode($text); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function parse_file($exercisePath, $file, $questionFile) |
|
|
|
function parse_file($exercisePath, $file, $questionFile) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -199,6 +216,7 @@ function parse_file($exercisePath, $file, $questionFile) |
|
|
|
|
|
|
|
|
|
|
|
$questionTempDir = $exercisePath . '/' . $file . '/'; |
|
|
|
$questionTempDir = $exercisePath . '/' . $file . '/'; |
|
|
|
$questionFilePath = $questionTempDir . $questionFile; |
|
|
|
$questionFilePath = $questionTempDir . $questionFile; |
|
|
|
|
|
|
|
|
|
|
|
if (!($fp = fopen($questionFilePath, 'r'))) { |
|
|
|
if (!($fp = fopen($questionFilePath, 'r'))) { |
|
|
|
Display :: display_error_message(get_lang('Error opening question\'s XML file')); |
|
|
|
Display :: display_error_message(get_lang('Error opening question\'s XML file')); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -245,15 +263,15 @@ function parse_file($exercisePath, $file, $questionFile) |
|
|
|
"RESPONSECONDITION", |
|
|
|
"RESPONSECONDITION", |
|
|
|
"RESPONSEIF" |
|
|
|
"RESPONSEIF" |
|
|
|
); |
|
|
|
); |
|
|
|
$question_format_supported = true; |
|
|
|
|
|
|
|
|
|
|
|
$question_format_supported = true; |
|
|
|
|
|
|
|
|
|
|
|
$xml_parser = xml_parser_create(); |
|
|
|
$xml_parser = xml_parser_create(); |
|
|
|
xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, false); |
|
|
|
xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, false); |
|
|
|
xml_set_element_handler($xml_parser, 'startElement', 'endElement'); |
|
|
|
xml_set_element_handler($xml_parser, 'startElement', 'endElement'); |
|
|
|
xml_set_character_data_handler($xml_parser, 'elementData'); |
|
|
|
xml_set_character_data_handler($xml_parser, 'elementData'); |
|
|
|
|
|
|
|
|
|
|
|
if (!xml_parse($xml_parser, $data, feof($fp))) { |
|
|
|
if (!xml_parse($xml_parser, $data, feof($fp))) { |
|
|
|
// if reading of the xml file in not successfull : |
|
|
|
// if reading of the xml file in not successful : |
|
|
|
// set errorFound, set error msg, break while statement |
|
|
|
// set errorFound, set error msg, break while statement |
|
|
|
Display :: display_error_message(get_lang('Error reading XML file')); |
|
|
|
Display :: display_error_message(get_lang('Error reading XML file')); |
|
|
|
return false; |
|
|
|
return false; |
|
|
@ -329,143 +347,89 @@ function startElement($parser, $name, $attributes) { |
|
|
|
$current_question_item_body .= "<BR/>"; |
|
|
|
$current_question_item_body .= "<BR/>"; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch ($current_element) { |
|
|
|
switch ($current_element) { |
|
|
|
case 'ASSESSMENTITEM' : |
|
|
|
case 'ASSESSMENTITEM' : |
|
|
|
{ |
|
|
|
//retrieve current question |
|
|
|
//retrieve current question |
|
|
|
$current_question_ident = $attributes['IDENTIFIER']; |
|
|
|
|
|
|
|
$exercise_info['question'][$current_question_ident] = array (); |
|
|
|
$current_question_ident = $attributes['IDENTIFIER']; |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'] = array (); |
|
|
|
$exercise_info['question'][$current_question_ident] = array (); |
|
|
|
$exercise_info['question'][$current_question_ident]['correct_answers'] = array (); |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'] = array (); |
|
|
|
$exercise_info['question'][$current_question_ident]['title'] = $attributes['TITLE']; |
|
|
|
$exercise_info['question'][$current_question_ident]['correct_answers'] = array (); |
|
|
|
$exercise_info['question'][$current_question_ident]['tempdir'] = $questionTempDir; |
|
|
|
$exercise_info['question'][$current_question_ident]['title'] = $attributes['TITLE']; |
|
|
|
break; |
|
|
|
$exercise_info['question'][$current_question_ident]['tempdir'] = $questionTempDir; |
|
|
|
case 'SECTION': |
|
|
|
} |
|
|
|
//retrieve exercise name |
|
|
|
break; |
|
|
|
$exercise_info['name'] = $attributes['TITLE']; |
|
|
|
|
|
|
|
|
|
|
|
case 'SECTION' : |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
//retrieve exercise name |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$exercise_info['name'] = $attributes['TITLE']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'RESPONSEDECLARATION': |
|
|
|
case 'RESPONSEDECLARATION' : |
|
|
|
// Retrieve question type |
|
|
|
{ |
|
|
|
if ("multiple" == $attributes['CARDINALITY']) { |
|
|
|
//retrieve question type |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'MCMA'; |
|
|
|
|
|
|
|
$cardinality = 'multiple'; |
|
|
|
if ("multiple" == $attributes['CARDINALITY']) { |
|
|
|
} |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'MCMA'; |
|
|
|
if ("single" == $attributes['CARDINALITY']) { |
|
|
|
$cardinality = 'multiple'; |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'MCUA'; |
|
|
|
} |
|
|
|
$cardinality = 'single'; |
|
|
|
if ("single" == $attributes['CARDINALITY']) { |
|
|
|
} |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'MCUA'; |
|
|
|
//needed for FIB |
|
|
|
$cardinality = 'single'; |
|
|
|
$current_answer_id = $attributes['IDENTIFIER']; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//needed for FIB |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$current_answer_id = $attributes['IDENTIFIER']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'INLINECHOICEINTERACTION' : |
|
|
|
case 'INLINECHOICEINTERACTION' : |
|
|
|
{ |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'FIB'; |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'FIB'; |
|
|
|
$exercise_info['question'][$current_question_ident]['subtype'] = 'LISTBOX_FILL'; |
|
|
|
$exercise_info['question'][$current_question_ident]['subtype'] = 'LISTBOX_FILL'; |
|
|
|
$current_answer_id = $attributes['RESPONSEIDENTIFIER']; |
|
|
|
$current_answer_id = $attributes['RESPONSEIDENTIFIER']; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'INLINECHOICE' : |
|
|
|
case 'INLINECHOICE' : |
|
|
|
{ |
|
|
|
$current_inlinechoice_id = $attributes['IDENTIFIER']; |
|
|
|
$current_inlinechoice_id = $attributes['IDENTIFIER']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'TEXTENTRYINTERACTION': |
|
|
|
case 'TEXTENTRYINTERACTION' : |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'FIB'; |
|
|
|
{ |
|
|
|
$exercise_info['question'][$current_question_ident]['subtype'] = 'TEXTFIELD_FILL'; |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'FIB'; |
|
|
|
$exercise_info['question'][$current_question_ident]['response_text'] = $current_question_item_body; |
|
|
|
$exercise_info['question'][$current_question_ident]['subtype'] = 'TEXTFIELD_FILL'; |
|
|
|
//replace claroline tags |
|
|
|
$exercise_info['question'][$current_question_ident]['response_text'] = $current_question_item_body; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//replace claroline tags |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'MATCHINTERACTION': |
|
|
|
case 'MATCHINTERACTION' : |
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'MATCHING'; |
|
|
|
{ |
|
|
|
|
|
|
|
$exercise_info['question'][$current_question_ident]['type'] = 'MATCHING'; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'SIMPLEMATCHSET' : |
|
|
|
case 'SIMPLEMATCHSET' : |
|
|
|
{ |
|
|
|
if (!isset ($current_match_set)) { |
|
|
|
if (!isset ($current_match_set)) { |
|
|
|
$current_match_set = 1; |
|
|
|
$current_match_set = 1; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$current_match_set++; |
|
|
|
$current_match_set++; |
|
|
|
} |
|
|
|
} |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_match_set] = array (); |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_match_set] = array (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'SIMPLEASSOCIABLECHOICE': |
|
|
|
case 'SIMPLEASSOCIABLECHOICE' : |
|
|
|
$currentAssociableChoice = $attributes['IDENTIFIER']; |
|
|
|
{ |
|
|
|
|
|
|
|
$currentAssociableChoice = $attributes['IDENTIFIER']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
//retrieve answers id for MCUA and MCMA questions |
|
|
|
//retrieve answers id for MCUA and MCMA questions |
|
|
|
|
|
|
|
case 'SIMPLECHOICE': |
|
|
|
case 'SIMPLECHOICE' : |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$current_answer_id = $attributes['IDENTIFIER']; |
|
|
|
$current_answer_id = $attributes['IDENTIFIER']; |
|
|
|
if (!isset($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id])) { |
|
|
|
if (!isset($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id])) { |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id] = array (); |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id] = array (); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'MAPENTRY': |
|
|
|
|
|
|
|
if ($parent_element == "MAPPING") { |
|
|
|
|
|
|
|
$answer_id = $attributes['MAPKEY']; |
|
|
|
|
|
|
|
|
|
|
|
case 'MAPENTRY' : |
|
|
|
if (!isset ($exercise_info['question'][$current_question_ident]['weighting'])) { |
|
|
|
{ |
|
|
|
$exercise_info['question'][$current_question_ident]['weighting'] = array (); |
|
|
|
if ($parent_element == "MAPPING") { |
|
|
|
} |
|
|
|
$answer_id = $attributes['MAPKEY']; |
|
|
|
$exercise_info['question'][$current_question_ident]['weighting'][$answer_id] = $attributes['MAPPEDVALUE']; |
|
|
|
|
|
|
|
} |
|
|
|
if (!isset ($exercise_info['question'][$current_question_ident]['weighting'])) { |
|
|
|
|
|
|
|
$exercise_info['question'][$current_question_ident]['weighting'] = array (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$exercise_info['question'][$current_question_ident]['weighting'][$answer_id] = $attributes['MAPPEDVALUE']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'MAPPING': |
|
|
|
case 'MAPPING' : |
|
|
|
if (isset ($attributes['DEFAULTVALUE'])) { |
|
|
|
{ |
|
|
|
$exercise_info['question'][$current_question_ident]['default_weighting'] = $attributes['DEFAULTVALUE']; |
|
|
|
if (isset ($attributes['DEFAULTVALUE'])) { |
|
|
|
} |
|
|
|
$exercise_info['question'][$current_question_ident]['default_weighting'] = $attributes['DEFAULTVALUE']; |
|
|
|
case 'ITEMBODY': |
|
|
|
} |
|
|
|
$record_item_body = true; |
|
|
|
} |
|
|
|
$current_question_item_body = ''; |
|
|
|
|
|
|
|
|
|
|
|
case 'ITEMBODY' : |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$record_item_body = true; |
|
|
|
|
|
|
|
$current_question_item_body = ''; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'IMG': |
|
|
|
case 'IMG' : |
|
|
|
$exercise_info['question'][$current_question_ident]['attached_file_url'] = $attributes['SRC']; |
|
|
|
{ |
|
|
|
|
|
|
|
$exercise_info['question'][$current_question_ident]['attached_file_url'] = $attributes['SRC']; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -495,15 +459,13 @@ function endElement($parser, $name) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch ($name) { |
|
|
|
switch ($name) { |
|
|
|
case 'ITEMBODY' : |
|
|
|
case 'ITEMBODY': |
|
|
|
{ |
|
|
|
$record_item_body = false; |
|
|
|
$record_item_body = false; |
|
|
|
if ($exercise_info['question'][$current_question_ident]['type'] == 'FIB') { |
|
|
|
if ($exercise_info['question'][$current_question_ident]['type'] == 'FIB') { |
|
|
|
$exercise_info['question'][$current_question_ident]['response_text'] = $current_question_item_body; |
|
|
|
$exercise_info['question'][$current_question_ident]['response_text'] = $current_question_item_body; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$exercise_info['question'][$current_question_ident]['statement'] = $current_question_item_body; |
|
|
|
$exercise_info['question'][$current_question_ident]['statement'] = $current_question_item_body; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
array_pop($element_pile); |
|
|
|
array_pop($element_pile); |
|
|
@ -541,68 +503,47 @@ function elementData($parser, $data) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
switch ($current_element) { |
|
|
|
switch ($current_element) { |
|
|
|
case 'SIMPLECHOICE' : |
|
|
|
case 'SIMPLECHOICE': |
|
|
|
|
|
|
|
if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) { |
|
|
|
if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'])) { |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data); |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] = trim($data); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data); |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'FEEDBACKINLINE' : |
|
|
|
case 'FEEDBACKINLINE' : |
|
|
|
{ |
|
|
|
if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) { |
|
|
|
if (!isset ($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'])) { |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data); |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] = trim($data); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data); |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['feedback'] .= ' ' . trim($data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
case 'SIMPLEASSOCIABLECHOICE': |
|
|
|
case 'SIMPLEASSOCIABLECHOICE' : |
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_match_set][$currentAssociableChoice] = trim($data); |
|
|
|
{ |
|
|
|
|
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_match_set][$currentAssociableChoice] = trim($data); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'VALUE' : |
|
|
|
case 'VALUE' : |
|
|
|
{ |
|
|
|
if ($parent_element == "CORRECTRESPONSE") { |
|
|
|
if ($parent_element == "CORRECTRESPONSE") { |
|
|
|
if ($cardinality == "single") { |
|
|
|
if ($cardinality == "single") { |
|
|
|
$exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id] = $data; |
|
|
|
$exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id] = $data; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$exercise_info['question'][$current_question_ident]['correct_answers'][] = $data; |
|
|
|
$exercise_info['question'][$current_question_ident]['correct_answers'][] = $data; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'ITEMBODY' : |
|
|
|
case 'ITEMBODY' : |
|
|
|
{ |
|
|
|
$current_question_item_body .= $data; |
|
|
|
$current_question_item_body .= $data; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
case 'INLINECHOICE' : |
|
|
|
case 'INLINECHOICE' : |
|
|
|
{ |
|
|
|
// if this is the right answer, then we must replace the claroline tags in the FIB text bye the answer between "[" and "]" : |
|
|
|
|
|
|
|
$answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
|
|
|
// if this is the right answer, then we must replace the claroline tags in the FIB text bye the answer between "[" and "]" : |
|
|
|
if ($current_inlinechoice_id == $answer_identifier) { |
|
|
|
|
|
|
|
$current_question_item_body = str_replace("**claroline_start**" . $current_answer_id . "**claroline_end**", "[" . $data . "]", $current_question_item_body); |
|
|
|
$answer_identifier = $exercise_info['question'][$current_question_ident]['correct_answers'][$current_answer_id]; |
|
|
|
} else { |
|
|
|
|
|
|
|
if (!isset ($exercise_info['question'][$current_question_ident]['wrong_answers'])) { |
|
|
|
if ($current_inlinechoice_id == $answer_identifier) { |
|
|
|
$exercise_info['question'][$current_question_ident]['wrong_answers'] = array (); |
|
|
|
|
|
|
|
} |
|
|
|
$current_question_item_body = str_replace("**claroline_start**" . $current_answer_id . "**claroline_end**", "[" . $data . "]", $current_question_item_body); |
|
|
|
$exercise_info['question'][$current_question_ident]['wrong_answers'][] = $data; |
|
|
|
} else // save wrong answers in an array |
|
|
|
} |
|
|
|
{ |
|
|
|
|
|
|
|
if (!isset ($exercise_info['question'][$current_question_ident]['wrong_answers'])) { |
|
|
|
|
|
|
|
$exercise_info['question'][$current_question_ident]['wrong_answers'] = array (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
$exercise_info['question'][$current_question_ident]['wrong_answers'][] = $data; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|