Esempio n. 1
0
 public static function hasActiveRun($a_container_id, $a_test_ref_id, $a_objective_id)
 {
     // check if pass exists
     include_once './Modules/Test/classes/class.ilObjTest.php';
     if (!ilObjTest::isParticipantsLastPassActive($a_test_ref_id, $GLOBALS['ilUser']->getId())) {
         return false;
     }
     // check if multiple pass exists
     include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
     $last_objectives = ilLOTestRun::lookupObjectives($a_container_id, $GLOBALS['ilUser']->getId(), ilObject::_lookupObjId($a_test_ref_id));
     if (count((array) $last_objectives) and in_array((int) $a_objective_id, (array) $last_objectives)) {
         return true;
     }
     return false;
 }
 /**
  * 
  * @param type $a_test_ref_id
  * @param type $a_objective_id
  * @return int 1 confirmation is shown, 2 new pass must be forced, 3 if no new pass must be forced 
  */
 protected function handleActivePass($a_test_ref_id, $a_objective_id)
 {
     // check if pass exists
     include_once './Modules/Test/classes/class.ilObjTest.php';
     if (!ilObjTest::isParticipantsLastPassActive($a_test_ref_id, $GLOBALS['ilUser']->getId())) {
         $GLOBALS['ilLog']->write(__METHOD__ . ' No previous pass exists.');
         return 2;
     }
     $GLOBALS['ilLog']->write(__METHOD__ . ' Active test pass exists... ');
     // check if multiple pass exists
     include_once './Modules/Course/classes/Objectives/class.ilLOTestRun.php';
     $last_objectives = ilLOTestRun::lookupObjectives($this->object->getId(), $GLOBALS['ilUser']->getId(), ilObject::_lookupObjId($a_test_ref_id));
     if (count((array) $last_objectives) > 1) {
         // if multi objective call and last run is multi call
         // => force no new run
         if (!$a_objective_id) {
             $GLOBALS['ilLog']->write(__METHOD__ . ': Continuing multi objective test pass.');
             return 3;
         } else {
             $this->redirectLocToTestConfirmation($a_objective_id, $a_test_ref_id);
             return 1;
         }
     }
     if (count((array) $last_objectives) == 1) {
         // continue old run =>
         if ($a_objective_id && in_array($a_objective_id, (array) $last_objectives)) {
             return 3;
         } elseif ($a_objective_id && !in_array($a_objective_id, (array) $last_objectives)) {
             $this->redirectLocToTestConfirmation($a_objective_id, $a_test_ref_id);
             return 1;
         }
     }
     $this->redirectLocToTestConfirmation($a_objective_id, $a_test_ref_id);
     return 1;
 }