| Total Complexity | 16 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | class Ims2Question extends Question |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * Create the proper Answer handler. |
||
| 14 | * Messages/strings in code must be English. |
||
| 15 | */ |
||
| 16 | public function setAnswer() |
||
| 17 | { |
||
| 18 | $questionId = 0; |
||
| 19 | |||
| 20 | if (method_exists($this, 'getIid')) { |
||
| 21 | $questionId = (int) $this->getIid(); |
||
| 22 | } elseif (property_exists($this, 'iid')) { |
||
| 23 | $questionId = (int) $this->iid; |
||
| 24 | } elseif (property_exists($this, 'id')) { |
||
| 25 | $questionId = (int) $this->id; |
||
| 26 | } |
||
| 27 | |||
| 28 | // Avoid null IDs: use 0 as safe fallback (some flows set the ID later). |
||
| 29 | if ($questionId < 0) { |
||
| 30 | $questionId = 0; |
||
| 31 | } |
||
| 32 | |||
| 33 | switch ($this->type) { |
||
| 34 | case TF: |
||
| 35 | case MCUA: |
||
| 36 | case MCMA: |
||
| 37 | $answer = new ImsAnswerMultipleChoice($questionId); |
||
| 38 | break; |
||
| 39 | |||
| 40 | case FIB: |
||
| 41 | $answer = new ImsAnswerFillInBlanks($questionId); |
||
| 42 | break; |
||
| 43 | |||
| 44 | case MATCHING: |
||
| 45 | case MATCHING_DRAGGABLE: |
||
| 46 | $answer = new ImsAnswerMatching($questionId); |
||
| 47 | break; |
||
| 48 | |||
| 49 | case FREE_ANSWER: |
||
| 50 | $answer = new ImsAnswerFree($questionId); |
||
| 51 | break; |
||
| 52 | |||
| 53 | case HOT_SPOT: |
||
| 54 | $answer = new ImsAnswerHotspot($questionId); |
||
| 55 | break; |
||
| 56 | |||
| 57 | default: |
||
| 58 | $answer = null; |
||
| 59 | } |
||
| 60 | |||
| 61 | // If the parent Question class expects an internal property, keep it. |
||
| 62 | if (property_exists($this, 'answer')) { |
||
| 63 | $this->answer = $answer; |
||
| 64 | } |
||
| 65 | |||
| 66 | return $answer; |
||
| 67 | } |
||
| 68 | |||
| 69 | public function createAnswersForm($form) |
||
| 70 | { |
||
| 71 | return true; |
||
| 72 | } |
||
| 73 | |||
| 74 | public function processAnswersCreation($form, $exercise) |
||
| 77 | } |
||
| 78 | } |
||
| 79 |