/** * Create a new CustomInteraction object. * * @param string $responseIdentifier The identifier of the Response Variable bound to the interaction. * @param string $xmlString The xml data representing the whole customInteraction component and its content. * @param string $id The id of the bodyElement. * @param string $class The class of the bodyElement. * @param string $lang The language of the bodyElement. * @param string $label The label of the bodyElement. */ public function __construct($responseIdentifier, $xmlString, $id = '', $class = '', $lang = '', $label = '') { parent::__construct($responseIdentifier, $id, $class, $lang, $label); $this->setXmlString($xmlString); $this->setExternalComponent(new ExternalQtiComponent($xmlString)); }
/** * Create a new BlockInteraction object. * * @param string $responseIdentifier The identifier of the associated response. * @param string $id The id of the bodyElement. * @param string $class The class of the bodyElement. * @param string $lang The language of the bodyElement. * @param string $label The label of the bodyElement. * @throws InvalidArgumentException If one of the argument is invalid. */ public function __construct($responseIdentifier, $id = '', $class = '', $lang = '', $label = '') { parent::__construct($responseIdentifier, $id, $class, $lang, $label); }
/** * Create a new PositionObjectInteraction object. * * @param string $responseIdentifier The identifier of the associated response. * @param \qtism\data\content\xhtml\Object $object An image as an Object object. * @param string $id The id of the bodyElement. * @param string $class The class of the bodyElement. * @param string $lang The language of the bodyElement. * @param string $label The label of the bodyElement. * @throws \InvalidArgumentException If one of the argument is invalid. */ public function __construct($responseIdentifier, Object $object, $id = '', $class = '', $lang = '', $label = '') { parent::__construct($responseIdentifier, $id, $class, $lang, $label); $this->setObject($object); }
/** * Create a Shuffling component from a given Interaction object. * * A Shuffling object will be created depending on the $interaction object given. * If $interaction is an interaction type subject to shuffling e.g. choiceInteraction, * orderInteraction, associateInteraction, matchInteraction, gapMatchInteraction, * inlineChoiceInteraction, a Shuffling object is returned. * * Otherwise, the method returns false to indicate that no Shuffling component * can be built from the given $interaction object. * * @param \qtism\data\content\interactions\Interaction $interaction * @return \qtism\data\state\Shuffling|boolean */ public static function createShufflingFromInteraction(Interaction $interaction) { $className = $interaction->getQtiClassName(); $groups = array(); $shufflableInteractions = array('choiceInteraction', 'orderInteraction', 'associateInteraction', 'matchInteraction', 'gapMatchInteraction', 'inlineChoiceInteraction'); $returnValue = false; if (in_array($className, $shufflableInteractions) === true && $interaction->mustShuffle() === true) { if ($className === 'choiceInteraction' || $className === 'orderInteraction') { $choices = $interaction->getComponentsByClassName('simpleChoice'); $groups[] = array('identifiers' => array(), 'fixed' => array()); foreach ($choices as $choice) { $groups[0]['identifiers'][] = $choice->getIdentifier(); if ($choice->isFixed() === true) { $groups[0]['fixed'][] = $choice->getIdentifier(); } } } elseif ($className === 'associateInteraction') { $choices = $interaction->getComponentsByClassName('simpleAssociableChoice'); $groups[] = array('identifiers' => array(), 'fixed' => array()); foreach ($choices as $choice) { $groups[0]['identifiers'][] = $choice->getIdentifier(); if ($choice->isFixed() === true) { $groups[0]['fixed'][] = $choice->getIdentifier(); } } } elseif ($className === 'matchInteraction') { $matchSets = $interaction->getComponentsByClassName('simpleMatchSet'); $groups[] = array('identifiers' => array(), 'fixed' => array()); $groups[] = array('identifiers' => array(), 'fixed' => array()); for ($i = 0; $i < count($matchSets); $i++) { foreach ($matchSets[$i]->getComponentsByClassName('simpleAssociableChoice') as $choice) { $groups[$i]['identifiers'][] = $choice->getIdentifier(); if ($choice->isFixed() === true) { $groups[0]['fixed'][] = $choice->getIdentifier(); } } } } elseif ($className === 'gapMatchInteraction') { $choices = $interaction->getComponentsByClassName(array('gapText', 'gapImg')); $groups[] = array('identifiers' => array(), 'fixed' => array()); foreach ($choices as $choice) { $groups[0]['identifiers'][] = $choice->getIdentifier(); if ($choice->isFixed() === true) { $groups[0]['fixed'][] = $choice->getIdentifier(); } } } elseif ($className === 'inlineChoiceInteraction') { $choices = $interaction->getComponentsByClassName('inlineChoice'); $groups[] = array('identifiers' => array(), 'fixed' => array()); foreach ($choices as $choice) { $groups[0]['identifiers'][] = $choice->getIdentifier(); if ($choice->isFixed() === true) { $groups[0]['fixed'][] = $choice->getIdentifier(); } } } $responseIdentifier = $interaction->getResponseIdentifier(); $shufflingGroups = new ShufflingGroupCollection(); foreach ($groups as $group) { $shufflingGroup = new ShufflingGroup(new IdentifierCollection($group['identifiers'])); $shufflingGroup->setFixedIdentifiers(new IdentifierCollection($group['fixed'])); $shufflingGroups[] = $shufflingGroup; } $returnValue = new Shuffling($responseIdentifier, $shufflingGroups); } return $returnValue; }