function _getStatusInfo($a_obj_id, $a_include_tlt_data = false)
 {
     global $ilDB;
     $status_info = array();
     include_once "Services/Object/classes/class.ilObjectLP.php";
     $olp = ilObjectLP::getInstance($a_obj_id);
     $collection = $olp->getCollectionInstance();
     if ($collection) {
         $status_info["items"] = $collection->getItems($a_obj_id);
         include_once './Services/MetaData/classes/class.ilMDEducational.php';
         foreach ($status_info["items"] as $item_id) {
             $status_info["in_progress"][$item_id] = array();
             $status_info["completed"][$item_id] = array();
             $status_info["tlt"][$item_id] = ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id, $item_id);
         }
         $ref_ids = ilObject::_getAllReferences($a_obj_id);
         $ref_id = end($ref_ids);
         $possible_items = $collection->getPossibleItems($ref_id);
         $chapter_ids = array_intersect(array_keys($possible_items), $status_info["items"]);
         // fix order (adapt from possible items)
         $status_info["items"] = $chapter_ids;
         if ($chapter_ids) {
             foreach ($chapter_ids as $item_id) {
                 $status_info["item_titles"][$item_id] = $possible_items[$item_id]["title"];
             }
             $set = $ilDB->query("SELECT obj_id,usr_id,spent_seconds" . " FROM lm_read_event" . " WHERE " . $ilDB->in("obj_id", $chapter_ids, "", "integer"));
             while ($row = $ilDB->fetchAssoc($set)) {
                 if ($row["spent_seconds"] < $status_info["tlt"][$row["obj_id"]]) {
                     $status_info["in_progress"][$row["obj_id"]][] = $row["usr_id"];
                 } else {
                     $status_info["completed"][$row["obj_id"]][] = $row["usr_id"];
                 }
                 if ($a_include_tlt_data) {
                     $status_info["tlt_users"][$row["obj_id"]][$row["usr_id"]] = $row["spent_seconds"];
                 }
             }
         }
     }
     if (!$a_include_tlt_data) {
         unset($status_info["tlt"]);
     }
     return $status_info;
 }
 public function getPossibleItems($a_ref_id)
 {
     if (!isset(self::$possible_items[$a_ref_id])) {
         $obj_id = ilObject::_lookupObjectId($a_ref_id);
         $items = array();
         // only top-level chapters
         include_once "Services/MetaData/classes/class.ilMDEducational.php";
         $tree = new ilTree($obj_id);
         $tree->setTableNames('lm_tree', 'lm_data');
         $tree->setTreeTablePK("lm_id");
         foreach ($tree->getChilds($tree->readRootId()) as $child) {
             if ($child["type"] == "st") {
                 $child["tlt"] = ilMDEducational::_getTypicalLearningTimeSeconds($obj_id, $child["obj_id"]);
                 $items[$child["obj_id"]] = $child;
             }
         }
         self::$possible_items[$a_ref_id] = $items;
     }
     return self::$possible_items[$a_ref_id];
 }
 function __renderItem($item, $level)
 {
     global $ilUser, $ilAccess;
     include_once 'Modules/Course/classes/Timings/class.ilTimingPlaned.php';
     include_once './Services/Link/classes/class.ilLink.php';
     include_once './Services/MetaData/classes/class.ilMDEducational.php';
     if (!$ilAccess->checkAccess('visible', '', $item['ref_id'])) {
         return false;
     }
     $this->lng->loadLanguageModule('meta');
     $usr_planed = new ilTimingPlaned($item['ref_id'], $ilUser->getId());
     for ($i = 0; $i < $level; $i++) {
         $this->tpl->touchBlock('start_indent');
         $this->tpl->touchBlock('end_indent');
     }
     if (strlen($item['description'])) {
         $this->tpl->setCurrentBlock("item_description");
         $this->tpl->setVariable("DESC", $item['description']);
         $this->tpl->parseCurrentBlock();
     }
     if ($tlt = ilMDEducational::_getTypicalLearningTimeSeconds($item['obj_id'])) {
         $this->tpl->setCurrentBlock("tlt");
         $this->tpl->setVariable("TXT_TLT", $this->lng->txt('meta_typical_learning_time'));
         $this->tpl->setVariable("TLT_VAL", ilFormat::_secondsToString($tlt));
         $this->tpl->parseCurrentBlock();
     }
     if ($ilAccess->checkAccess('read', '', $item['ref_id'])) {
         $this->tpl->setCurrentBlock("title_as_link");
         $this->tpl->setVariable("TITLE_LINK", ilLink::_getLink($item['ref_id'], $item['type']));
         $this->tpl->setVariable("TITLE_NAME", $item['title']);
         $this->tpl->parseCurrentBlock();
     } else {
         $this->tpl->setCurrentBlock("title_plain");
         $this->tpl->setVariable("TITLE", $item['title']);
         $this->tpl->parseCurrentBlock();
     }
     $this->tpl->setCurrentBlock("container_standard_row");
     if (isset($this->invalid["{$item['ref_id']}"])) {
         $this->tpl->setVariable("ROWCLASS", 'tblrowmarked');
     } else {
         $this->tpl->setVariable("ROWCLASS", ilUtil::switchColor($this->counter++, 'tblrow1', 'tblrow2'));
     }
     #$this->tpl->setVariable("TYPE_IMG",ilUtil::getImagePath('icon_'.$item['type'].'.png'));
     $this->tpl->setVariable('TYPE_IMG', ilUtil::getTypeIconPath($item['type'], $item['obj_id'], 'small'));
     $this->tpl->setVariable("TYPE_ALT_IMG", $this->lng->txt('obj_' . $item['type']));
     if ($item['timing_type'] == ilObjectActivation::TIMINGS_PRESETTING) {
         $this->tpl->setVariable('SUG_START', ilDatePresentation::formatDate(new ilDate($item['suggestion_start'], IL_CAL_UNIX)));
         $this->tpl->setVariable('SUG_END', ilDatePresentation::formatDate(new ilDate($item['suggestion_end'], IL_CAL_UNIX)));
     }
     if ($item['changeable']) {
         $item_prefix = "item[" . $item['ref_id'] . ']';
         if (is_array($_POST['item']["{$item['ref_id']}"]['own_start'])) {
             #echo "Start post<br>";
             $start = $this->__toUnix($_POST['item']["{$item['ref_id']}"]['own_start']);
         } elseif ($usr_planed->getPlanedStartingTime()) {
             #echo "Own start<br>";
             $start = $usr_planed->getPlanedStartingTime();
         } else {
             #echo "Empfehlung start<br>";
             $start = $item['suggestion_start'];
         }
         $date = $this->__prepareDateSelect($start);
         $this->tpl->setVariable("OWN_START", ilUtil::makeDateSelect($item_prefix . "[own_start]", $date['y'], $date['m'], $date['d'], date('Y', time()), false));
         if ($usr_planed->getPlanedEndingTime()) {
             #echo "Own End<br>";
             $end = $usr_planed->getPlanedEndingTime();
         } else {
             #echo "Empfehlung end<br>";
             $end = $item['suggestion_end'];
         }
         $this->tpl->setVariable('OWN_END', ilDatePresentation::formatDate(new ilDate($end, IL_CAL_UNIX)));
         $this->tpl->setVariable("NAME_DURATION", $item_prefix . "[duration]");
         // Duration
         if (isset($_POST['item']["{$item['ref_id']}"]['duration'])) {
             $this->tpl->setVariable("VAL_DURATION", $_POST['item']["{$item['ref_id']}"]['duration']);
         } else {
             $this->tpl->setVariable("VAL_DURATION", intval(($end - $start) / (60 * 60 * 24)));
         }
         $this->tpl->setVariable('LIM_START', ilDatePresentation::formatDate(new ilDate($item['earliest_start'], IL_CAL_UNIX)));
         $this->tpl->setVariable('LIM_END', ilDatePresentation::formatDate(new ilDate($item['latest_end'], IL_CAL_UNIX)));
     }
     $this->tpl->parseCurrentBlock();
     if (!$_SESSION['crs_timings_user_hidden']) {
         return true;
     }
     foreach (ilObjectActivation::getTimingsItems($item['ref_id']) as $item_data) {
         $this->__renderItem($item_data, $level + 1);
     }
 }
Ejemplo n.º 4
0
 /**
  * test Educational
  * @group IL_Init 
  * @return
  */
 public function testEducational()
 {
     include_once './Services/MetaData/classes/class.ilMDEducational.php';
     include_once 'Services/MetaData/classes/class.ilMDLanguageItem.php';
     $con = new ilMDEducational(1, 2, 'xxx');
     $con->setDifficulty('Easy');
     $ret = $con->save();
     $this->assertGreaterThan(0, $ret);
     $con->setDifficulty('Medium');
     $con->update();
     $con->read();
     $desc = $con->getDifficulty();
     $this->assertEquals('Medium', $desc);
     $con->delete();
 }
Ejemplo n.º 5
0
 function &getEducational()
 {
     include_once 'Services/Migration/DBUpdate_426/classes/class.ilMDEducational.php';
     if ($id = ilMDEducational::_getId($this->getRBACId(), $this->getObjId())) {
         $edu =& new ilMDEducational();
         $edu->setMetaId($id);
         return $edu;
     }
     return false;
 }
 /**
  * Determine percentage
  *
  * @param	integer		object id
  * @param	integer		user id
  * @param	object		object (optional depends on object type)
  * @return	integer		percentage
  */
 function determinePercentage($a_obj_id, $a_user_id, $a_obj = null)
 {
     $tlt = (int) ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
     $re = ilChangeEvent::_lookupReadEvents($a_obj_id, $a_user_id);
     $spent = (int) $re[0]["spent_seconds"];
     if ($tlt > 0) {
         $per = min(100, 100 / $tlt * $spent);
     } else {
         $per = 100;
     }
     return $per;
 }
 function __readItemStatusInfo($a_items)
 {
     global $ilObjDataCache;
     include_once 'Services/Object/classes/class.ilObjectLP.php';
     foreach ($a_items as $item_id) {
         $olp = ilObjectLP::getInstance($item_id);
         $this->obj_data[$item_id]['type'] = $ilObjDataCache->lookupType($item_id);
         $this->obj_data[$item_id]['mode'] = $olp->getCurrentMode();
         if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_TLT) {
             include_once './Services/MetaData/classes/class.ilMDEducational.php';
             $this->obj_data[$item_id]['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($item_id);
         }
         if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_VISITS) {
             $this->obj_data[$item_id]['visits'] = ilLPObjSettings::_lookupVisits($item_id);
         }
         if ($this->obj_data[$item_id]['mode'] == ilLPObjSettings::LP_MODE_SCORM) {
             $collection = $olp->getCollectionInstance();
             if ($collection) {
                 $this->obj_data[$item_id]['scos'] = count($collection->getItems());
             }
         }
     }
 }
Ejemplo n.º 8
0
 function _getTypicalLearningTime($a_obj_id)
 {
     include_once 'Services/MetaData/classes/class.ilMDEducational.php';
     return ilMDEducational::_getTypicalLearningTimeSeconds($a_obj_id);
 }
 function __readItemStatusInfo($a_items)
 {
     global $ilObjDataCache;
     foreach ($a_items as $item_id) {
         $this->obj_data[$item_id]['mode'] = ilLPObjSettings::_lookupMode($item_id);
         $this->obj_data[$item_id]['type'] = $ilObjDataCache->lookupType($item_id);
         if ($this->obj_data[$item_id]['mode'] == LP_MODE_TLT) {
             include_once './Services/MetaData/classes/class.ilMDEducational.php';
             $this->obj_data[$item_id]['tlt'] = ilMDEducational::_getTypicalLearningTimeSeconds($item_id);
         }
         if ($this->obj_data[$item_id]['mode'] == LP_MODE_VISITS) {
             include_once './Services/Tracking/classes/class.ilLPObjSettings.php';
             $this->obj_data[$item_id]['visits'] = ilLPObjSettings::_lookupVisits($item_id);
         }
         if ($this->obj_data[$item_id]['mode'] == LP_MODE_SCORM) {
             include_once './Services/Tracking/classes/class.ilLPCollectionCache.php';
             $this->obj_data[$item_id]['scos'] = count(ilLPCollectionCache::_getItems($item_id));
         }
     }
 }