Moodle import: Fix question creation multichoice is now MULTIPLE_ANSWER

Instead of UNIQUE_ANSWER see BT#18172
pull/3745/head^2
Julio 5 years ago
parent 93e1094b14
commit b6b57d2de5
  1. 39
      main/inc/lib/MoodleImport.php

@ -282,9 +282,7 @@ class MoodleImport
error_log('question: '.$question['questionid']); error_log('question: '.$question['questionid']);
} }
$questionInstance->updateTitle( $questionInstance->updateTitle($moduleValues['question_instances'][$index]['name']);
$moduleValues['question_instances'][$index]['name']
);
$questionText = $moduleValues['question_instances'][$index]['questiontext']; $questionText = $moduleValues['question_instances'][$index]['questiontext'];
// Replace the path from @@PLUGINFILE@@ to a correct chamilo path // Replace the path from @@PLUGINFILE@@ to a correct chamilo path
@ -699,7 +697,7 @@ class MoodleImport
{ {
switch ($moodleQuestionType) { switch ($moodleQuestionType) {
case 'multichoice': case 'multichoice':
return UNIQUE_ANSWER; return MULTIPLE_ANSWER;
case 'multianswer': case 'multianswer':
case 'shortanswer': case 'shortanswer':
case 'match': case 'match':
@ -759,7 +757,7 @@ class MoodleImport
$objAnswer = new Answer($questionInstance->id); $objAnswer = new Answer($questionInstance->id);
$questionWeighting = 0; $questionWeighting = 0;
foreach ($questionList as $slot => $answer) { foreach ($questionList as $slot => $answer) {
$this->processUniqueAnswer( $this->processMultipleAnswer(
$objAnswer, $objAnswer,
$answer, $answer,
$slot + 1, $slot + 1,
@ -939,6 +937,37 @@ class MoodleImport
); );
} }
public function processMultipleAnswer(
Answer $objAnswer,
$answerValues,
$position,
&$questionWeighting,
$importedFiles
) {
$answer = $answerValues['answertext'];
$comment = $answerValues['feedback'];
$weighting = $answerValues['fraction'];
//$weighting = abs($weighting);
if ($weighting > 0) {
$questionWeighting += $weighting;
}
$goodAnswer = $weighting > 0;
$this->fixPathInText($importedFiles, $answer);
$objAnswer->createAnswer(
$answer,
$goodAnswer,
$comment,
$weighting,
$position,
null,
null,
''
);
}
/** /**
* Process Chamilo True False. * Process Chamilo True False.
* *

Loading…
Cancel
Save