attributes['subtype'] = 'dmitem'; $this->attributes['access_id'] = ACCESS_PUBLIC; $this->deleted = 0; $this->dmcompetencymodel = ""; $this->dmperformancelevel = ""; } /** * Build From XML */ function buildFromXML($resource_dom, $item_dom) { } /** * Return node text content * * @param DOMNode $node Node * * @return string */ function findNodeText($node) { $children = $node->childNodes; for ($i=0; $i<$children->length; $i++) { $item = $children->item($i); if ($item->nodeType == XML_TEXT_NODE || $item->nodeType == XML_CDATA_SECTION_NODE) { $child_text = $children->item($i)->textContent; if (trim($child_text) != "") { return $children->item($i)->textContent; } } } return ""; } /** * Return item title from xml * * @param DOMDocument $item_dom Item DOM document * * @return string */ function getTitleFromXML($item_dom) { $assessmentItem = $item_dom->getElementsByTagName("assessmentItem")->item(0); return $assessmentItem->getAttribute("title"); } /** * Return item body from xml * * @param DOMDocument $item_dom Item DOM document * * @return string */ function getItemBodyFromXML($item_dom) { $item_body = $item_dom->getElementsByTagName("itemBody")->item(0); $children = $item_body->childNodes; for ($i=0; $i<$children->length; $i++) { $item = $children->item($i); if ($item->nodeType != XML_TEXT_NODE && $item->nodeType != XML_CDATA_SECTION_NODE) { return $children->item($i)->textContent; } } return ""; } /** * Checks can this item be connected with performance level * Each performance item can have only one extendedText item or multiple automatic response items * * @param int $performance_level_guid * * @return bool */ function is_connectable_with_performance_level($performance_level_guid) { if ($this->itemtype == "extendedText") { $items = digimina_get_performance_level_items($performance_level_guid); } else { $options = array( "types" => "object", "subtypes" => "dmitem", "limit" => 0, "metadata_name_value_pairs" => array(array("name" => "itemtype", "value" => "extendedText"), array("name" => "dmperformancelevel", "value" => $performance_level_guid)) ); $items = elgg_get_entities_from_metadata($options); } if (count($items) > 0) { return false; } return true; } /** * Detects if current item type allows automated testing * * @return bool */ public function detectAutomatedTesting() { if (in_array($this->itemtype, array('multipleChoice', 'multipleResponse'))) { return true; } return false; } /** * Returns true or false based on given answer * * @param mixed $answer User answer * @return bool * */ function answer($answer) { if (in_array($this->itemtype, array("multipleChoice", "multipleResponse"))) { if ($answer == $this->correct) { return true; } return false; } return true; } }