|
@@ -149,7 +149,7 @@ function import_exercise($file)
|
|
|
if ($result == false) {
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
+ //var_dump($exerciseInfo);exit;
|
|
|
// 1. Create exercise.
|
|
|
$exercise = new Exercise();
|
|
|
$exercise->exercise = $exerciseInfo['name'];
|
|
@@ -265,6 +265,7 @@ function import_exercise($file)
|
|
|
$question->save($exercise);
|
|
|
$answer->save();
|
|
|
}
|
|
|
+
|
|
|
// delete the temp dir where the exercise was unzipped
|
|
|
my_delete($baseWorkDir.$uploadPath);
|
|
|
|
|
@@ -358,19 +359,19 @@ function parseQti2($xmlData)
|
|
|
$currentQuestionItemBody = '';
|
|
|
$cardinality = '';
|
|
|
$nonHTMLTagToAvoid = [
|
|
|
- "simpleChoice",
|
|
|
- "choiceInteraction",
|
|
|
- "inlineChoiceInteraction",
|
|
|
- "inlineChoice",
|
|
|
- "soMPLEMATCHSET",
|
|
|
- "simpleAssociableChoice",
|
|
|
- "textEntryInteraction",
|
|
|
- "feedbackInline",
|
|
|
- "matchInteraction",
|
|
|
+ 'simpleChoice',
|
|
|
+ 'choiceInteraction',
|
|
|
+ 'inlineChoiceInteraction',
|
|
|
+ 'inlineChoice',
|
|
|
+ 'soMPLEMATCHSET',
|
|
|
+ 'simpleAssociableChoice',
|
|
|
+ 'textEntryInteraction',
|
|
|
+ 'feedbackInline',
|
|
|
+ 'matchInteraction',
|
|
|
'extendedTextInteraction',
|
|
|
- "itemBody",
|
|
|
- "br",
|
|
|
- "img",
|
|
|
+ 'itemBody',
|
|
|
+ 'br',
|
|
|
+ 'img',
|
|
|
];
|
|
|
$currentMatchSet = null;
|
|
|
|
|
@@ -466,13 +467,20 @@ function parseQti2($xmlData)
|
|
|
$exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId] = [];
|
|
|
}
|
|
|
|
|
|
+ //$simpleChoiceValue = $node->nodeValue;
|
|
|
+ $simpleChoiceValue = '';
|
|
|
+ /** @var DOMElement $childNode */
|
|
|
+ foreach ($node->childNodes as $childNode) {
|
|
|
+ if ('feedbackInline' === $childNode->nodeName) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ $simpleChoiceValue .= $childNode->nodeValue;
|
|
|
+ }
|
|
|
+ $simpleChoiceValue = trim($simpleChoiceValue);
|
|
|
if (!isset($exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['value'])) {
|
|
|
- $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['value'] = trim(
|
|
|
- $node->nodeValue
|
|
|
- );
|
|
|
+ $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['value'] = $simpleChoiceValue;
|
|
|
} else {
|
|
|
- $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['value'] .= ''
|
|
|
- .trim($node->nodeValue);
|
|
|
+ $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['value'] .= $simpleChoiceValue;
|
|
|
}
|
|
|
break;
|
|
|
case 'mapEntry':
|
|
@@ -490,14 +498,12 @@ function parseQti2($xmlData)
|
|
|
break;
|
|
|
case 'mapping':
|
|
|
$defaultValue = $node->getAttribute('defaultValue');
|
|
|
-
|
|
|
if (!empty($defaultValue)) {
|
|
|
$exerciseInfo['question'][$currentQuestionIdent]['default_weighting'] = $defaultValue;
|
|
|
}
|
|
|
// no break ?
|
|
|
case 'itemBody':
|
|
|
$nodeValue = $node->nodeValue;
|
|
|
-
|
|
|
$currentQuestionItemBody = '';
|
|
|
|
|
|
/** @var DOMElement $childNode */
|
|
@@ -515,18 +521,14 @@ function parseQti2($xmlData)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $currentQuestionItemBody .= '>'
|
|
|
- .$childNode->nodeValue
|
|
|
- .'</'.$node->nodeName.'>';
|
|
|
+ $currentQuestionItemBody .= '>'.$childNode->nodeValue.'</'.$node->nodeName.'>';
|
|
|
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
if ('inlineChoiceInteraction' === $childNode->nodeName) {
|
|
|
- $currentQuestionItemBody .= "**claroline_start**"
|
|
|
- .$childNode->attr('responseIdentifier')
|
|
|
+ $currentQuestionItemBody .= "**claroline_start**".$childNode->attr('responseIdentifier')
|
|
|
."**claroline_end**";
|
|
|
-
|
|
|
continue;
|
|
|
}
|
|
|
|
|
@@ -578,14 +580,13 @@ function parseQti2($xmlData)
|
|
|
break;
|
|
|
case 'feedbackInline':
|
|
|
if (!isset($exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['feedback'])) {
|
|
|
- $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId] = trim(
|
|
|
+ $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['feedback'] = trim(
|
|
|
$node->nodeValue
|
|
|
);
|
|
|
} else {
|
|
|
- $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['feedback'] .= ''
|
|
|
- .trim(
|
|
|
- $node->nodeValue
|
|
|
- );
|
|
|
+ $exerciseInfo['question'][$currentQuestionIdent]['answer'][$currentAnswerId]['feedback'] .= trim(
|
|
|
+ $node->nodeValue
|
|
|
+ );
|
|
|
}
|
|
|
break;
|
|
|
case 'value':
|