Ejemplo n.º 1
0
 protected function resetCustomLPDataForUserIds(array $a_user_ids, $a_recursive = true)
 {
     /* @var ilObjTest $testOBJ */
     require_once 'Services/Object/classes/class.ilObjectFactory.php';
     $testOBJ = ilObjectFactory::getInstanceByObjId($this->obj_id);
     $testOBJ->removeTestResults($a_user_ids);
     // :TODO: there has to be a better way
     $test_ref_id = (int) $_REQUEST["ref_id"];
     if ($test_ref_id) {
         require_once "Modules/Course/classes/Objectives/class.ilLOSettings.php";
         $course_obj_id = ilLOSettings::isObjectiveTest($test_ref_id);
         if ($course_obj_id) {
             // is test initial and/or qualified?
             $lo_settings = ilLOSettings::getInstanceByObjId($course_obj_id);
             $is_i = $lo_settings->getInitialTest() == $test_ref_id;
             $is_q = $lo_settings->getQualifiedTest() == $test_ref_id;
             // remove objective results data
             require_once "Modules/Course/classes/Objectives/class.ilLOUserResults.php";
             ilLOUserResults::deleteResultsFromLP($course_obj_id, $a_user_ids, $is_i, $is_q);
             // refresh LP - see ilLPStatusWrapper::_updateStatus()
             require_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
             $lp_status = ilLPStatusFactory::_getInstance($course_obj_id);
             if (strtolower(get_class($lp_status)) != "illpstatus") {
                 foreach ($a_user_ids as $user_id) {
                     $lp_status->_updateStatus($course_obj_id, $user_id);
                 }
             }
         }
     }
 }
 /**
  * Get in progress users for object
  * 
  * @param int $a_obj_id
  * @param array $a_user_ids
  * @return array 
  */
 public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
 {
     $class = ilLPStatusFactory::_getClassById($a_obj_id);
     return $class::_lookupInProgressForObject($a_obj_id, $a_user_ids);
 }
Ejemplo n.º 3
0
 protected function checkLPIcon($a_id)
 {
     global $ilUser;
     // do it once for all chapters
     if ($this->lp_cache[$this->lm_obj->getId()] === null) {
         $this->lp_cache[$this->lm_obj->getId()] = false;
         include_once './Services/Tracking/classes/class.ilLearningProgressAccess.php';
         if (ilLearningProgressAccess::checkAccess($this->lm_obj->getRefId())) {
             $info = null;
             include_once './Services/Object/classes/class.ilObjectLP.php';
             $olp = ilObjectLP::getInstance($this->lm_obj->getId());
             if ($olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_MANUAL || $olp->getCurrentMode() == ilLPObjSettings::LP_MODE_COLLECTION_TLT) {
                 include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
                 $class = ilLPStatusFactory::_getClassById($this->lm_obj->getId(), $olp->getCurrentMode());
                 $info = $class::_getStatusInfo($this->lm_obj->getId());
             }
             // parse collection items
             if (is_array($info["items"])) {
                 foreach ($info["items"] as $item_id) {
                     $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
                     if (is_array($info["in_progress"][$item_id]) && in_array($ilUser->getId(), $info["in_progress"][$item_id])) {
                         $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM;
                     } else {
                         if (is_array($info["completed"][$item_id]) && in_array($ilUser->getId(), $info["completed"][$item_id])) {
                             $status = ilLPStatus::LP_STATUS_COMPLETED_NUM;
                         }
                     }
                     $this->lp_cache[$this->lm_obj->getId()][$item_id] = $status;
                 }
             }
         }
         include_once './Services/Tracking/classes/class.ilLearningProgressBaseGUI.php';
     }
     if (is_array($this->lp_cache[$this->lm_obj->getId()]) && isset($this->lp_cache[$this->lm_obj->getId()][$a_id])) {
         return ilLearningProgressBaseGUI::_getImagePathForStatus($this->lp_cache[$this->lm_obj->getId()][$a_id]);
     }
 }
Ejemplo n.º 4
0
 /**
  * This function checks whether the status for a given number of users is dirty and must be
  * recalculated. "Missing" records are not inserted! 
  *
  * @param
  * @return
  */
 static function checkStatusForObject($a_obj_id, $a_users = false)
 {
     global $ilDB;
     //@todo: there maybe the need to add extra handling for sessions here, since the
     // "in progress" status is time dependent here. On the other hand, if they registered
     // to the session, they already accessed the course and should have a "in progress"
     // anyway. But the status on the session itself may not be correct.
     $sql = "SELECT usr_id FROM ut_lp_marks WHERE " . " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " . " status_dirty = " . $ilDB->quote(1, "integer");
     if (is_array($a_users) && count($a_users) > 0) {
         $sql .= " AND " . $ilDB->in("usr_id", $a_users, false, "integer");
     }
     $set = $ilDB->query($sql);
     $dirty = false;
     if ($rec = $ilDB->fetchAssoc($set)) {
         $dirty = true;
     }
     // check if any records are missing
     $missing = false;
     if (!$dirty && is_array($a_users) && count($a_users) > 0) {
         $set = $ilDB->query("SELECT count(usr_id) cnt FROM ut_lp_marks WHERE " . " obj_id = " . $ilDB->quote($a_obj_id, "integer") . " AND " . $ilDB->in("usr_id", $a_users, false, "integer"));
         $r = $ilDB->fetchAssoc($set);
         if ($r["cnt"] < count($a_users)) {
             $missing = true;
         }
     }
     // refresh status, if records are dirty or missing
     if ($dirty || $missing) {
         require_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
         // #13330
         $trac_obj = ilLPStatusFactory::_getInstance($a_obj_id);
         $trac_obj->refreshStatus($a_obj_id, $a_users);
     }
 }
Ejemplo n.º 5
0
 /**
  * Test LP marks 
  * @param
  * @return
  */
 public function testLPMarks()
 {
     include_once './Services/Tracking/classes/class.ilLPMarks.php';
     include_once './Services/Tracking/classes/class.ilLPStatusFactory.php';
     $marks = new ilLPMarks(999, 888);
     $marks->setMark('Gut');
     $marks->setComment('Weiter so');
     $marks->setCompleted(true);
     $marks->update();
     $marks = new ilLPMarks(999, 888);
     $mark = $marks->getMark();
     $this->assertEquals($mark, 'Gut');
     $comment = ilLPMarks::_lookupComment(888, 999);
     $this->assertEquals($comment, 'Weiter so');
     $class = ilLPStatusFactory::_getClassById(999, ilLPObjSettings::LP_MODE_MANUAL);
     $completed = $class::_getCompleted(999);
     $this->assertEquals(array(888), $completed);
     ilLPMarks::deleteObject(999);
 }
 protected function showtlt()
 {
     global $lng, $ilCtrl, $tpl, $ilUser;
     include_once "Services/Form/classes/class.ilPropertyFormGUI.php";
     $form = new ilPropertyFormGUI();
     $form->setFormAction($ilCtrl->getFormAction($this, "showtlt"));
     $form->setTitle($lng->txt("learning_progress"));
     $form->setDescription($lng->txt("trac_collection_tlt_learner_info"));
     $coll_items = array();
     include_once './Services/Object/classes/class.ilObjectLP.php';
     $olp = ilObjectLP::getInstance($this->getObjId());
     $collection = $olp->getCollectionInstance();
     if ($collection) {
         $coll_items = $collection->getItems();
         $possible_items = $collection->getPossibleItems($this->getRefId());
         // for titles
     }
     include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
     $class = ilLPStatusFactory::_getClassById($this->getObjId(), ilLPObjSettings::LP_MODE_COLLECTION_TLT);
     $info = $class::_getStatusInfo($this->getObjId(), true);
     foreach ($coll_items as $item_id) {
         $field = new ilCustomInputGUI($possible_items[$item_id]["title"]);
         // lp status
         $status = ilLPStatus::LP_STATUS_NOT_ATTEMPTED_NUM;
         if (isset($info["completed"][$item_id]) && in_array($ilUser->getId(), $info["completed"][$item_id])) {
             $status = ilLPStatus::LP_STATUS_COMPLETED_NUM;
         } else {
             if (isset($info["in_progress"][$item_id]) && in_array($ilUser->getId(), $info["in_progress"][$item_id])) {
                 $status = ilLPStatus::LP_STATUS_IN_PROGRESS_NUM;
             }
         }
         $path = ilLearningProgressBaseGUI::_getImagePathForStatus($status);
         $text = ilLearningProgressBaseGUI::_getStatusText($status);
         $field->setHtml(ilUtil::img($path, $text));
         // stats
         $spent = 0;
         if (isset($info["tlt_users"][$item_id][$ilUser->getId()])) {
             $spent = $info["tlt_users"][$item_id][$ilUser->getId()];
         }
         $needed = $info["tlt"][$item_id];
         if ($needed) {
             $field->setInfo(sprintf($lng->txt("trac_collection_tlt_learner_subitem"), ilFormat::_secondsToString($spent), ilFormat::_secondsToString($needed), min(100, round(abs($spent) / $needed * 100))));
         }
         $form->addItem($field);
     }
     $tpl->setContent($form->getHTML());
 }
Ejemplo n.º 7
0
 /**
  * Get (sub)objects for given object, also handles learning objectives (course only)
  *
  * @param	int		$a_parent_obj_id
  * @param	int		$a_parent_ref_id
  * @param	int		$use_collection
  * @param	bool	$a_refresh_status
  * @param	array	$a_user_ids
  * @return	array	object_ids, objectives_parent_id
  */
 public static function getObjectIds($a_parent_obj_id, $a_parent_ref_id = false, $use_collection = true, $a_refresh_status = true, $a_user_ids = null)
 {
     include_once "Services/Object/classes/class.ilObjectLP.php";
     $object_ids = array($a_parent_obj_id);
     $ref_ids = array($a_parent_obj_id => $a_parent_ref_id);
     $objectives_parent_id = $scorm = $subitems = false;
     $olp = ilObjectLP::getInstance($a_parent_obj_id);
     $mode = $olp->getCurrentMode();
     switch ($mode) {
         // what about LP_MODE_SCORM_PACKAGE ?
         case ilLPObjSettings::LP_MODE_SCORM:
             include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
             $status_scorm = ilLPStatusFactory::_getInstance($a_parent_obj_id, ilLPObjSettings::LP_MODE_SCORM);
             $scorm = $status_scorm->_getStatusInfo($a_parent_obj_id);
             break;
         case ilLPObjSettings::LP_MODE_OBJECTIVES:
             if (ilObject::_lookupType($a_parent_obj_id) == "crs") {
                 $objectives_parent_id = $a_parent_obj_id;
             }
             break;
         case ilLPObjSettings::LP_MODE_COLLECTION_MANUAL:
             include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
             $status_coll_man = ilLPStatusFactory::_getInstance($a_parent_obj_id, ilLPObjSettings::LP_MODE_COLLECTION_MANUAL);
             $subitems = $status_coll_man->_getStatusInfo($a_parent_obj_id);
             break;
         case ilLPObjSettings::LP_MODE_COLLECTION_TLT:
             include_once "Services/Tracking/classes/class.ilLPStatusFactory.php";
             $status_coll_tlt = ilLPStatusFactory::_getInstance($a_parent_obj_id, ilLPObjSettings::LP_MODE_COLLECTION_TLT);
             $subitems = $status_coll_tlt->_getStatusInfo($a_parent_obj_id);
             break;
         default:
             // lp collection
             if ($use_collection) {
                 $collection = $olp->getCollectionInstance();
                 if ($collection) {
                     foreach ($collection->getItems() as $child_ref_id) {
                         $child_id = ilObject::_lookupObjId($child_ref_id);
                         $object_ids[] = $child_id;
                         $ref_ids[$child_id] = $child_ref_id;
                     }
                 }
             } else {
                 self::getSubTree($a_parent_ref_id, $object_ids, $ref_ids);
                 $object_ids = array_unique($object_ids);
             }
             foreach ($object_ids as $idx => $object_id) {
                 if (!$object_id) {
                     unset($object_ids[$idx]);
                 }
             }
             break;
     }
     if ($a_refresh_status) {
         self::refreshObjectsStatus($object_ids, $a_user_ids);
     }
     return array("object_ids" => $object_ids, "ref_ids" => $ref_ids, "objectives_parent_id" => $objectives_parent_id, "scorm" => $scorm, "subitems" => $subitems);
 }
 /**
  * Get in progress users for object
  * 
  * @param int $a_obj_id
  * @param array $a_user_ids
  * @return array 
  */
 public static function _lookupInProgressForObject($a_obj_id, $a_user_ids = null)
 {
     $class = ilLPStatusFactory::_getClassById($a_obj_id);
     return call_user_func_array(array($class, "_lookupInProgressForObject"), array($a_obj_id, $a_user_ids));
 }