|
|
|
@ -88,7 +88,7 @@ function import_exercise($file) { |
|
|
|
|
|
|
|
|
|
// create parser and array to retrieve info from manifest |
|
|
|
|
$element_pile = array (); //pile to known the depth in which we are |
|
|
|
|
$module_info = array (); //array to store the info we need |
|
|
|
|
//$module_info = array (); //array to store the info we need |
|
|
|
|
|
|
|
|
|
// if file is not a .zip, then we cancel all |
|
|
|
|
if (!preg_match('/.zip$/i', $file)) { |
|
|
|
@ -107,7 +107,7 @@ function import_exercise($file) { |
|
|
|
|
//$question_number = 0; |
|
|
|
|
$file_found = false; |
|
|
|
|
$operation = false; |
|
|
|
|
|
|
|
|
|
$result = false; |
|
|
|
|
// parse every subdirectory to search xml question files |
|
|
|
|
while (false !== ($file = readdir($exerciseHandle))) { |
|
|
|
|
if (is_dir($baseWorkDir . '/' . $file) && $file != "." && $file != "..") { |
|
|
|
@ -115,27 +115,29 @@ function import_exercise($file) { |
|
|
|
|
$questionHandle = opendir($baseWorkDir . '/' . $file); |
|
|
|
|
while (false !== ($questionFile = readdir($questionHandle))) { |
|
|
|
|
if (preg_match('/.xml$/i', $questionFile)) { |
|
|
|
|
parse_file($baseWorkDir, $file, $questionFile); |
|
|
|
|
$result = parse_file($baseWorkDir, $file, $questionFile); |
|
|
|
|
$file_found = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
elseif (preg_match('/.xml$/i', $file)) { |
|
|
|
|
parse_file($baseWorkDir, '', $file); |
|
|
|
|
} elseif (preg_match('/.xml$/i', $file)) { |
|
|
|
|
$result = parse_file($baseWorkDir, '', $file); |
|
|
|
|
$file_found = true; |
|
|
|
|
} // else ignore file |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!$file_found) { |
|
|
|
|
Display :: display_error_message(get_lang('No XML file found in the zip')); |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if ($result == false ) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//add exercise in tool |
|
|
|
|
|
|
|
|
|
//1.create exercise |
|
|
|
|
$exercise = new Exercise(); |
|
|
|
|
$exercise->exercise = $exercise_info['name']; |
|
|
|
|
|
|
|
|
|
$exercise->save(); |
|
|
|
|
$last_exercise_id = $exercise->selectId(); |
|
|
|
|
if (!empty($last_exercise_id)) { |
|
|
|
@ -414,12 +416,12 @@ function startElement($parser, $name, $attributes) { |
|
|
|
|
//retrieve answers id for MCUA and MCMA questions |
|
|
|
|
|
|
|
|
|
case 'SIMPLECHOICE' : |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
$current_answer_id = $attributes['IDENTIFIER']; |
|
|
|
|
if (!isset($exercise_info['question'][$current_question_ident]['answer'][$current_answer_id])) { |
|
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id] = array (); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'MAPENTRY' : |
|
|
|
@ -529,13 +531,12 @@ function elementData($parser, $data) { |
|
|
|
|
|
|
|
|
|
switch ($current_element) { |
|
|
|
|
case 'SIMPLECHOICE' : |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
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); |
|
|
|
|
} else { |
|
|
|
|
$exercise_info['question'][$current_question_ident]['answer'][$current_answer_id]['value'] .= ''.trim($data); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
case 'FEEDBACKINLINE' : |
|
|
|
@ -594,4 +595,3 @@ function elementData($parser, $data) { |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
?> |
|
|
|
|