2require_once 
'Services/Cron/classes/class.ilCronJob.php';
 
    3require_once 
'Services/Cron/classes/class.ilCronJobResult.php';
 
    4require_once 
'Modules/Test/classes/class.ilObjTest.php';
 
    5require_once 
'Modules/Test/classes/class.ilTestPassFinishTasks.php';
 
    6require_once 
'Services/Logging/classes/public/class.ilLoggerFactory.php';
 
   56    public function __construct()
 
   69        $this->lng->loadLanguageModule(
'assessment');
 
   71        $this->obj_data_cache   = $ilObjDataCache;
 
   73        $this->unfinished_passes= array();
 
   74        $this->test_ids                 = array();
 
   75        $this->test_ending_times= array();
 
   77        require_once 
'Modules/Test/classes/class.ilTestProcessLockerFactory.php';
 
   86        return 'finish_unfinished_passes';
 
   93        return $lng->txt(
"finish_unfinished_passes");
 
  100        return $lng->txt(
"finish_unfinished_passes_desc");
 
  130        $this->log->info(
'start inf cronjob...');
 
  135        if (count($this->unfinished_passes) > 0) {
 
  136            $this->log->info(
'found ' . count($this->unfinished_passes) . 
' unfinished passes starting analyses.');
 
  140            $this->log->info(
'No unfinished passes found.');
 
  145        $this->log->info(
' ...finishing cronjob.');
 
  152        $query = 
"SELECT        tst_active.active_id, 
  154                                                tst_active.user_fi usr_id, 
  155                                                tst_active.test_fi test_fi, 
  159                                                tst_active.submitted test_finished, 
  160                                                usr_data.matriculation, 
  162                                                tst_active.lastindex, 
  163                                                tst_active.last_started_pass last_started 
  166                                ON tst_active.user_fi = usr_data.usr_id 
  167                                WHERE IFNULL(tst_active.last_finished_pass, -1) <> tst_active.last_started_pass  
  171            $this->unfinished_passes[]  = 
$row;
 
  172            $this->test_ids[]                   = 
$row[
'test_fi'];
 
  178        $query = 
'SELECT test_id, obj_fi, ending_time, ending_time_enabled, processing_time, enable_processing_time FROM tst_tests WHERE ' .
 
  179                    $this->db->in(
'test_id', $this->test_ids, 
false, 
'integer');
 
  182            $this->test_ending_times[
$row[
'test_id']] = 
$row;
 
  184        $this->log->info(
'Gathered data for ' . count($this->test_ids) . 
' test id(s) => (' . implode(
',', $this->test_ids) . 
')');
 
  190        foreach ($this->unfinished_passes as 
$key => 
$data) {
 
  191            $test_id                            = 
$data[
'test_fi'];
 
  192            $can_not_be_finished        = 
true;
 
  193            if (array_key_exists($test_id, $this->test_ending_times)) {
 
  194                if ($this->test_ending_times[$test_id][
'ending_time_enabled'] == 1) {
 
  195                    $this->log->info(
'Test (' . $test_id . 
') has ending time (' . $this->test_ending_times[$test_id][
'ending_time'] . 
')');
 
  196                    $ending_time = $this->test_ending_times[$test_id][
'ending_time'];
 
  197                    if ($ending_time < 
$now) {
 
  199                        $can_not_be_finished = 
false;
 
  201                        $this->log->info(
'Test (' . $test_id . 
') ending time (' . $this->test_ending_times[$test_id][
'ending_time'] . 
') > now (' . 
$now . 
') is not reached.');
 
  204                    $this->log->info(
'Test (' . $test_id . 
') has no ending time.');
 
  206                if ($this->test_ending_times[$test_id][
'enable_processing_time'] == 1) {
 
  207                    $this->log->info(
'Test (' . $test_id . 
') has processing time (' . $this->test_ending_times[$test_id][
'processing_time'] . 
')');
 
  208                    $obj_id                                     = $this->test_ending_times[$test_id][
'obj_fi'];
 
  209                    $test_obj                           = 
new ilObjTest($obj_id, 
false);
 
  210                    $startingTime                       = $test_obj->getStartingTimeOfUser(
$data[
'active_id'], 
$data[
'last_started_pass']);
 
  211                    $max_processing_time        = $test_obj->isMaxProcessingTimeReached($startingTime, 
$data[
'active_id']);
 
  212                    if ($max_processing_time) {
 
  213                        $this->log->info(
'Max Processing time reached for user id (' . 
$data[
'usr_id'] . 
') so test with active id (' . 
$data[
'active_id'] . 
') will be finished.');
 
  214                        $this->
finishPassForUser($data[
'active_id'], $this->test_ending_times[$test_id][
'obj_fi']);
 
  215                        $can_not_be_finished = 
false;
 
  218                    $this->log->info(
'Test (' . $test_id . 
') has no processing time.');
 
  221                if ($can_not_be_finished) {
 
  222                    $this->log->info(
'Test session with active id (' . 
$data[
'active_id'] . 
') can not be finished by this cron job.');
 
  230        $this->processLockerFactory->setActiveId($active_id);
 
  231        $processLocker = $this->processLockerFactory->getLocker();
 
  234        $pass_finisher->performFinishTasks($processLocker);
 
  236        $this->log->info(
'Test session with active id (' . $active_id . 
') and obj_id (' . $obj_id . 
') is now finished.');
 
An exception for terminatinating execution or to throw for unit testing.
Class ilCronFinishUnfinishedTestPasses.
gatherUsersWithUnfinishedPasses()
getDefaultScheduleType()
Get schedule type.
getDefaultScheduleValue()
Get schedule value.
getDescription()
Get description.
hasCustomSettings()
Has cron job any custom setting which can be edited?
getTestsFinishAndProcessingTime()
hasFlexibleSchedule()
Can the schedule be configured?
finishPassForUser($active_id, $obj_id)
hasAutoActivation()
Is to be activated on "installation".
Cron job result data container.
Cron job application base class.
const SCHEDULE_TYPE_DAILY
static getLogger($a_component_id)
Get component logger.
Class ilTestPassFinishTasks.