public function setValue($a_value)
 {
     $this->values = array();
     if (is_array($a_value) && is_array($a_value['answer'])) {
         foreach ($a_value['answer'] as $index => $value) {
             $answer = new ilAssKprimChoiceAnswer();
             $answer->setPosition($index);
             $answer->setAnswertext($value);
             $answer->setImageFile($a_value['imagename'][$index]);
             if (strlen($a_value['correctness'][$index])) {
                 $answer->setCorrectness((bool) $a_value['correctness'][$index]);
             }
             $answer->setThumbPrefix($this->qstObject->getThumbPrefix());
             $answer->setImageFsDir($this->qstObject->getImagePath());
             $answer->setImageWebDir($this->qstObject->getImagePathWeb());
             $this->values[] = $answer;
         }
     }
     #vd($this->values);
 }
示例#2
0
 private function loadAnswerData($questionId)
 {
     global $ilDB;
     $res = $this->db->queryF("SELECT * FROM {$this->getAnswerTableName()} WHERE question_fi = %s ORDER BY position ASC", array('integer'), array($questionId));
     require_once 'Modules/TestQuestionPool/classes/class.ilAssKprimChoiceAnswer.php';
     require_once 'Services/RTE/classes/class.ilRTE.php';
     while ($data = $ilDB->fetchAssoc($res)) {
         $answer = new ilAssKprimChoiceAnswer();
         $answer->setPosition($data['position']);
         $answer->setAnswertext(ilRTE::_replaceMediaObjectImageSrc($data['answertext'], 1));
         $answer->setImageFile($data['imagefile']);
         $answer->setThumbPrefix($this->getThumbPrefix());
         $answer->setImageFsDir($this->getImagePath());
         $answer->setImageWebDir($this->getImagePathWeb());
         $answer->setCorrectness($data['correctness']);
         $this->answers[$answer->getPosition()] = $answer;
     }
     for ($i = count($this->answers); $i < self::NUM_REQUIRED_ANSWERS; $i++) {
         $answer = new ilAssKprimChoiceAnswer();
         $answer->setPosition($i);
         $this->answers[$answer->getPosition()] = $answer;
     }
 }