public function testModel()
 {
     $myItem = new Item();
     $myItem->setAttribute('title', 'My Coolest Item');
     $myItem->getBody()->edit('sth');
     $myInteraction = new ChoiceInteraction();
     $myInteraction->getPrompt()->edit('Prompt you');
     $myChoice1 = $myInteraction->createChoice(array('fixed' => true), 'This is correct');
     $myChoice2 = $myInteraction->createChoice(array('fixed' => true), 'This is not correct');
     $this->assertInstanceOf('\\oat\\taoQtiItem\\model\\qti\\choice\\SimpleChoice', $myChoice2);
     $this->assertEquals(count($myInteraction->getChoices()), 2);
     $myChoice1->setContent('answer #1');
     $myChoice2->setContent('answer #2');
     $myInteraction->removeChoice($myChoice1);
     $this->assertEquals(count($myInteraction->getChoices()), 1);
     $myItem->addInteraction($myInteraction, "Adding my interaction here {$myInteraction->getPlaceholder()}. And not there.");
     $this->assertNotNull($myInteraction->getRelatedItem());
     $this->assertEquals($myInteraction->getRelatedItem()->getSerial(), $myItem->getSerial());
     $myResponse = new ResponseDeclaration();
     $myItem->addResponse($myResponse);
     $this->assertNotNull($myResponse->getRelatedItem());
     $this->assertEquals($myResponse->getRelatedItem()->getSerial(), $myItem->getSerial());
     $myItem->removeResponse($myResponse);
     $responses = $myItem->getResponses();
     $this->assertTrue(empty($responses));
 }
 /**
  * Remove unused response declaration from the items and rp template misuse
  *
  * @param oat\taoQtiItem\modal\Item $item
  * @param string $itemFile
  * @return boolean
  */
 protected function updateItem(\oat\taoQtiItem\model\qti\Item $item, $itemFile)
 {
     $changed = false;
     $responses = $item->getResponses();
     $interactions = $item->getInteractions();
     $usedResponses = [];
     foreach ($interactions as $interaction) {
         $usedResponses[] = $interaction->attr('responseIdentifier');
     }
     foreach ($responses as $response) {
         $responseIdentifier = $response->attr('identifier');
         if (!in_array($responseIdentifier, $usedResponses)) {
             $changed = true;
             $item->removeResponse($response);
         }
     }
     $xml = simplexml_load_file($itemFile);
     $rpTemplate = (string) $xml->responseProcessing['template'];
     //detect wrong usage for standard standard response declaration
     $rp = $item->getResponseProcessing();
     if ($rp instanceof \oat\taoQtiItem\model\qti\response\TemplatesDriven && $rpTemplate) {
         if (count($interactions) > 1) {
             $changed = true;
         } else {
             $interaction = reset($interactions);
             if ($interaction && $interaction->attr('responseIdentifier') != 'RESPONSE') {
                 $changed = true;
             }
         }
     }
     return $changed;
 }