2 require_once
'Services/Cron/classes/class.ilCronJob.php';
3 require_once
'Services/Cron/classes/class.ilCronJobResult.php';
4 require_once
'Modules/Test/classes/class.ilObjTest.php';
5 require_once
'Modules/Test/classes/class.ilTestPassFinishTasks.php';
6 require_once
'Services/Logging/classes/public/class.ilLoggerFactory.php';
56 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';
79 new ilSetting(
'assessment'), $DIC->database()
85 return 'finish_unfinished_passes';
92 return $lng->txt(
"finish_unfinished_passes");
99 return $lng->txt(
"finish_unfinished_passes_desc");
104 return self::SCHEDULE_TYPE_DAILY;
129 $this->log->info(
'start inf cronjob...');
134 if(count($this->unfinished_passes) > 0)
136 $this->log->info(
'found ' . count($this->unfinished_passes).
' unfinished passes starting analyses.');
142 $this->log->info(
'No unfinished passes found.');
147 $this->log->info(
' ...finishing cronjob.');
154 $query =
"SELECT tst_active.active_id, 156 tst_active.user_fi usr_id, 157 tst_active.test_fi test_fi, 161 tst_active.submitted test_finished, 162 usr_data.matriculation, 164 tst_active.lastindex, 165 tst_active.last_started_pass last_started 168 ON tst_active.user_fi = usr_data.usr_id 169 WHERE IFNULL(tst_active.last_finished_pass, -1) <> tst_active.last_started_pass 174 $this->unfinished_passes[] =
$row;
175 $this->test_ids[] =
$row[
'test_fi'];
181 $query =
'SELECT test_id, obj_fi, ending_time, ending_time_enabled, processing_time, enable_processing_time FROM tst_tests WHERE '.
182 $this->db->in(
'test_id', $this->test_ids,
false,
'integer');
186 $this->test_ending_times[
$row[
'test_id']] =
$row;
188 $this->log->info(
'Gathered data for ' . count($this->test_ids) .
' test id(s) => (' . implode(
',', $this->test_ids) .
')');
194 foreach($this->unfinished_passes as $key =>
$data)
196 $test_id =
$data[
'test_fi'];
197 $can_not_be_finished =
true;
198 if(array_key_exists($test_id, $this->test_ending_times))
200 if($this->test_ending_times[$test_id][
'ending_time_enabled'] == 1)
202 $this->log->info(
'Test (' . $test_id .
') has ending time ('.$this->test_ending_times[$test_id][
'ending_time'].
')' );
203 $ending_time = $this->test_ending_times[$test_id][
'ending_time'];
204 if($ending_time <
$now)
207 $can_not_be_finished =
false;
211 $this->log->info(
'Test (' . $test_id .
') ending time ('.$this->test_ending_times[$test_id][
'ending_time'].
') > now ('.
$now.
') is not reached.' );
217 $this->log->info(
'Test (' . $test_id .
') has no ending time.' );
219 if($this->test_ending_times[$test_id][
'enable_processing_time'] == 1)
221 $this->log->info(
'Test (' . $test_id .
') has processing time ('.$this->test_ending_times[$test_id][
'processing_time'].
')' );
222 $obj_id = $this->test_ending_times[$test_id][
'obj_fi'];
223 $test_obj =
new ilObjTest($obj_id,
false);
224 $startingTime = $test_obj->getStartingTimeOfUser(
$data[
'active_id'],
$data[
'last_started_pass']);
225 $max_processing_time = $test_obj->isMaxProcessingTimeReached($startingTime,
$data[
'active_id']);
226 if($max_processing_time)
228 $this->log->info(
'Max Processing time reached for user id ('.
$data[
'usr_id'].
') so test with active id ('.
$data[
'active_id'].
') will be finished.');
229 $this->
finishPassForUser($data[
'active_id'], $this->test_ending_times[$test_id][
'obj_fi']);
230 $can_not_be_finished =
false;
235 $this->log->info(
'Test (' . $test_id .
') has no processing time.');
238 if($can_not_be_finished)
240 $this->log->info(
'Test session with active id ('.
$data[
'active_id'].
') can not be finished by this cron job.');
248 $this->processLockerFactory->setActiveId($active_id);
249 $processLocker = $this->processLockerFactory->getLocker();
252 $pass_finisher->performFinishTasks($processLocker);
254 $this->log->info(
'Test session with active id ('.$active_id .
') and obj_id (' .$obj_id .
') is now finished.');
Class ilTestPassFinishTasks.
Cron job application base class.
gatherUsersWithUnfinishedPasses()
getDefaultScheduleValue()
Class ilCronFinishUnfinishedTestPasses.
finishPassForUser($active_id, $obj_id)
Create styles array
The data for the language used.
static getLogger($a_component_id)
Get component logger.
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
Cron job result data container.
getTestsFinishAndProcessingTime()