diff --git a/questtypes/choiceinput/ChoiceinputQuesttypeController.inc b/questtypes/choiceinput/ChoiceinputQuesttypeController.inc index e48cb6eb..5c300215 100644 --- a/questtypes/choiceinput/ChoiceinputQuesttypeController.inc +++ b/questtypes/choiceinput/ChoiceinputQuesttypeController.inc @@ -77,18 +77,19 @@ $choiceLists = $this->Choiceinput->getChoiceinputLists($quest['id']); // Match lists with user answers - foreach($choiceLists as $i => &$list) + foreach($choiceLists as &$list) { - if(!array_key_exists($i, $answers)) { + $pos = intval($list['number']) - 1; + if(!array_key_exists($pos, $answers)) { return false; } - if($list['questtypes_choiceinput_choice_id'] != $answers[$i]) { + if($list['questtypes_choiceinput_choice_id'] != $answers[$pos]) { return false; } } - // All answer right + // All answers right return true; } @@ -109,9 +110,6 @@ // Get Task $task = $this->Choiceinput->getChoiceinputQuest($quest['id']); - // Process text - $textParts = preg_split('/(\$\$)/', ' '.$task['text'].' '); - // Get lists $choiceLists = $this->Choiceinput->getChoiceinputLists($quest['id']); foreach($choiceLists as &$list) { @@ -119,8 +117,7 @@ } // Get Character answers - if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']) || $this->request->getGetParam('status') == 'solved') - { + if($this->request->getGetParam('show-answer') == 'true' || !$this->Quests->hasCharacterSolvedQuest($quest['id'], $character['id']) || $this->request->getGetParam('status') == 'solved') { foreach($choiceLists as &$list) { $list['answer'] = $this->Choiceinput->getCharacterSubmission($list['id'], $character['id']); } @@ -128,7 +125,7 @@ // Pass data to view - $this->set('texts', $textParts); + $this->set('task', $task); $this->set('choiceLists', $choiceLists); } @@ -148,9 +145,6 @@ // Get Task $task = $this->Choiceinput->getChoiceinputQuest($quest['id']); - // Process text - $textParts = preg_split('/(\$\$)/', ' '.$task['text'].' '); - // Get lists $choiceLists = $this->Choiceinput->getChoiceinputLists($quest['id']); foreach($choiceLists as &$list) @@ -162,7 +156,7 @@ // Pass data to view - $this->set('texts', $textParts); + $this->set('task', $task); $this->set('choiceLists', $choiceLists); } diff --git a/questtypes/choiceinput/html/quest.tpl b/questtypes/choiceinput/html/quest.tpl index 43a7d2df..88074135 100644 --- a/questtypes/choiceinput/html/quest.tpl +++ b/questtypes/choiceinput/html/quest.tpl @@ -1,15 +1,32 @@
diff --git a/questtypes/choiceinput/html/submission.tpl b/questtypes/choiceinput/html/submission.tpl index 40f60505..c9c2ef41 100644 --- a/questtypes/choiceinput/html/submission.tpl +++ b/questtypes/choiceinput/html/submission.tpl @@ -1,12 +1,29 @@ - ++ t($task['text']); + + // Insert comboboxes + foreach(array_reverse($choiceLists) as &$list) + { + // Get positions + $posStart = mb_strrpos($text, '[choiceinput]', 0, 'UTF-8'); + $posEnd = $posStart + mb_strlen('[choiceinput]', 'UTF-8'); + + // Create combobox + $combobox = ''; + + // Insert input field + $text = mb_substr($text, 0, $posStart, 'UTF-8') . $combobox . mb_substr($text, $posEnd, mb_strlen($text)-$posEnd, 'UTF-8'); + } + ?> + =$text?> +