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 public function __construct()
64 $ilObjDataCache = $DIC[
'ilObjDataCache'];
72 $this->lng->loadLanguageModule(
'assessment');
74 $this->obj_data_cache = $ilObjDataCache;
76 $this->unfinished_passes = array();
77 $this->test_ids = array();
78 $this->test_ending_times = array();
80 require_once
'Modules/Test/classes/class.ilTestProcessLockerFactory.php';
89 return 'finish_unfinished_passes';
97 return $lng->txt(
"finish_unfinished_passes");
105 return $lng->txt(
"finish_unfinished_passes_desc");
110 return self::SCHEDULE_TYPE_DAILY;
135 $this->log->info(
'start inf cronjob...');
140 if (count($this->unfinished_passes) > 0) {
141 $this->log->info(
'found ' . count($this->unfinished_passes) .
' unfinished passes starting analyses.');
145 $this->log->info(
'No unfinished passes found.');
150 $this->log->info(
' ...finishing cronjob.');
157 $query =
"SELECT tst_active.active_id, 159 tst_active.user_fi usr_id, 160 tst_active.test_fi test_fi, 164 tst_active.submitted test_finished, 165 usr_data.matriculation, 167 tst_active.lastindex, 168 tst_active.last_started_pass last_started 171 ON tst_active.user_fi = usr_data.usr_id 172 WHERE IFNULL(tst_active.last_finished_pass, -1) <> tst_active.last_started_pass 176 $this->unfinished_passes[] =
$row;
177 $this->test_ids[] =
$row[
'test_fi'];
183 $query =
'SELECT test_id, obj_fi, ending_time, ending_time_enabled, processing_time, enable_processing_time FROM tst_tests WHERE ' .
184 $this->db->in(
'test_id', $this->test_ids,
false,
'integer');
187 $this->test_ending_times[
$row[
'test_id']] =
$row;
189 $this->log->info(
'Gathered data for ' . count($this->test_ids) .
' test id(s) => (' . implode(
',', $this->test_ids) .
')');
195 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)) {
199 if ($this->test_ending_times[$test_id][
'ending_time_enabled'] == 1) {
200 $this->log->info(
'Test (' . $test_id .
') has ending time (' . $this->test_ending_times[$test_id][
'ending_time'] .
')');
201 $ending_time = $this->test_ending_times[$test_id][
'ending_time'];
202 if ($ending_time <
$now) {
204 $can_not_be_finished =
false;
206 $this->log->info(
'Test (' . $test_id .
') ending time (' . $this->test_ending_times[$test_id][
'ending_time'] .
') > now (' .
$now .
') is not reached.');
209 $this->log->info(
'Test (' . $test_id .
') has no ending time.');
211 if ($this->test_ending_times[$test_id][
'enable_processing_time'] == 1) {
212 $this->log->info(
'Test (' . $test_id .
') has processing time (' . $this->test_ending_times[$test_id][
'processing_time'] .
')');
213 $obj_id = $this->test_ending_times[$test_id][
'obj_fi'];
214 $test_obj =
new ilObjTest($obj_id,
false);
215 $startingTime = $test_obj->getStartingTimeOfUser(
$data[
'active_id'],
$data[
'last_started_pass']);
216 $max_processing_time = $test_obj->isMaxProcessingTimeReached($startingTime,
$data[
'active_id']);
217 if ($max_processing_time) {
218 $this->log->info(
'Max Processing time reached for user id (' .
$data[
'usr_id'] .
') so test with active id (' .
$data[
'active_id'] .
') will be finished.');
219 $this->
finishPassForUser($data[
'active_id'], $this->test_ending_times[$test_id][
'obj_fi']);
220 $can_not_be_finished =
false;
223 $this->log->info(
'Test (' . $test_id .
') has no processing time.');
226 if ($can_not_be_finished) {
227 $this->log->info(
'Test session with active id (' .
$data[
'active_id'] .
') can not be finished by this cron job.');
235 $this->processLockerFactory->setActiveId($active_id);
236 $processLocker = $this->processLockerFactory->getLocker();
239 $pass_finisher->performFinishTasks($processLocker);
241 $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)
static getLogger($a_component_id)
Get component logger.
Cron job result data container.
getTestsFinishAndProcessingTime()