44 $this->
lng = $DIC[
'lng'];
45 $this->
lng->loadLanguageModule(
'assessment');
46 $this->db = $DIC->database();
47 $this->obj_data_cache = $DIC[
'ilObjDataCache'];
49 $this->unfinished_passes = array();
50 $this->test_ids = array();
51 $this->test_ending_times = array();
53 require_once
'Modules/Test/classes/class.ilTestProcessLockerFactory.php';
62 return 'finish_unfinished_passes';
70 return $lng->
txt(
"finish_unfinished_passes");
78 return $lng->
txt(
"finish_unfinished_passes_desc");
83 return self::SCHEDULE_TYPE_DAILY;
108 $this->log->info(
'start inf cronjob...');
113 if (count($this->unfinished_passes) > 0) {
114 $this->log->info(
'found ' . count($this->unfinished_passes) .
' unfinished passes starting analyses.');
118 $this->log->info(
'No unfinished passes found.');
123 $this->log->info(
' ...finishing cronjob.');
130 $query =
"SELECT tst_active.active_id, 132 tst_active.user_fi usr_id, 133 tst_active.test_fi test_fi, 137 tst_active.submitted test_finished, 138 usr_data.matriculation, 140 tst_active.lastindex, 141 tst_active.last_started_pass last_started 144 ON tst_active.user_fi = usr_data.usr_id 145 WHERE IFNULL(tst_active.last_finished_pass, -1) <> tst_active.last_started_pass 147 $result = $this->db->query(
$query);
148 while ($row = $this->db->fetchAssoc($result)) {
149 $this->unfinished_passes[] = $row;
150 $this->test_ids[] = $row[
'test_fi'];
156 $query =
'SELECT test_id, obj_fi, ending_time, ending_time_enabled, processing_time, enable_processing_time FROM tst_tests WHERE ' .
157 $this->db->in(
'test_id', $this->test_ids,
false,
'integer');
158 $result = $this->db->query(
$query);
159 while ($row = $this->db->fetchAssoc($result)) {
160 $this->test_ending_times[$row[
'test_id']] = $row;
162 $this->log->info(
'Gathered data for ' . count($this->test_ids) .
' test id(s) => (' . implode(
',', $this->test_ids) .
')');
168 foreach ($this->unfinished_passes as
$key =>
$data) {
169 $test_id =
$data[
'test_fi'];
170 $can_not_be_finished =
true;
171 if (array_key_exists($test_id, $this->test_ending_times)) {
172 if ($this->test_ending_times[$test_id][
'ending_time_enabled'] == 1) {
173 $this->log->info(
'Test (' . $test_id .
') has ending time (' . $this->test_ending_times[$test_id][
'ending_time'] .
')');
174 $ending_time = $this->test_ending_times[$test_id][
'ending_time'];
175 if ($ending_time < $now) {
177 $can_not_be_finished =
false;
179 $this->log->info(
'Test (' . $test_id .
') ending time (' . $this->test_ending_times[$test_id][
'ending_time'] .
') > now (' . $now .
') is not reached.');
182 $this->log->info(
'Test (' . $test_id .
') has no ending time.');
184 if ($this->test_ending_times[$test_id][
'enable_processing_time'] == 1) {
185 $this->log->info(
'Test (' . $test_id .
') has processing time (' . $this->test_ending_times[$test_id][
'processing_time'] .
')');
186 $obj_id = $this->test_ending_times[$test_id][
'obj_fi'];
188 $test_obj =
new ilObjTest($obj_id,
false);
189 $startingTime = $test_obj->getStartingTimeOfUser(
$data[
'active_id']);
190 $max_processing_time = $test_obj->isMaxProcessingTimeReached($startingTime,
$data[
'active_id']);
191 if ($max_processing_time) {
192 $this->log->info(
'Max Processing time reached for user id (' .
$data[
'usr_id'] .
') so test with active id (' .
$data[
'active_id'] .
') will be finished.');
193 $this->
finishPassForUser($data[
'active_id'], $this->test_ending_times[$test_id][
'obj_fi']);
194 $can_not_be_finished =
false;
196 $this->log->info(
'Max Processing time not reached for user id (' .
$data[
'usr_id'] .
') in test with active id (' .
$data[
'active_id'] .
'). Starting time: ' . $startingTime .
' Processing time: ' . $test_obj->getProcessingTime() .
' / ' . $test_obj->getProcessingTimeInSeconds() .
's');
199 $this->log->info(
'Test object with id (' . $obj_id .
') does not exist.');
202 $this->log->info(
'Test (' . $test_id .
') has no processing time.');
205 if ($can_not_be_finished) {
206 $this->log->info(
'Test session with active id (' .
$data[
'active_id'] .
') can not be finished by this cron job.');
214 $processLocker = $this->processLockerFactory->withContextId((
int) $active_id)->getLocker();
217 $testSession->loadFromDb($active_id);
222 assQuestion::_updateTestPassResults(
224 $testSession->getPass(),
225 $test->areObligationsEnabled(),
231 $pass_finisher->performFinishTasks($processLocker);
233 $this->log->info(
'Test session with active id (' . $active_id .
') and obj_id (' . $obj_id .
') is now finished.');
235 $this->log->info(
'Test object with id (' . $obj_id .
') does not exist.');
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLogger(string $a_component_id)
Get component logger.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
gatherUsersWithUnfinishedPasses()
getDefaultScheduleValue()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
finishPassForUser($active_id, $obj_id)
ilObjectDataCache $obj_data_cache
getTestsFinishAndProcessingTime()
ilTestProcessLockerFactory $processLockerFactory