ILIAS  release_7 Revision v7.30-3-g800a261c036
ilCronFinishUnfinishedTestPasses Class Reference

Class ilCronFinishUnfinishedTestPasses. More...

+ Inheritance diagram for ilCronFinishUnfinishedTestPasses:
+ Collaboration diagram for ilCronFinishUnfinishedTestPasses:

Public Member Functions

 getId ()
 Get id. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 run ()
 Run job. More...
 
- Public Member Functions inherited from ilCronJob
 isActive ($a_ts_last_run, $a_schedule_type, $a_schedule_value, $a_manual=false)
 Is job currently active? More...
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule ($a_type, $a_value)
 Update current schedule (if flexible) More...
 
 getAllScheduleTypes ()
 Get all available schedule types. More...
 
 getScheduleTypesWithValues ()
 
 getValidScheduleTypes ()
 Returns a collection of all valid schedule types for a specific job. More...
 
 getTitle ()
 Get title. More...
 
 getDescription ()
 Get description. More...
 
 isManuallyExecutable ()
 Defines whether or not a cron job can be started manually. More...
 
 hasCustomSettings ()
 Has cron job any custom setting which can be edited? More...
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 Add custom settings to form. More...
 
 saveCustomSettings (ilPropertyFormGUI $a_form)
 Save custom settings. More...
 
 addToExternalSettingsForm ($a_form_id, array &$a_fields, $a_is_active)
 Add external settings to form. More...
 
 activationWasToggled ($a_currently_active)
 Cron job status was changed. More...
 
 getId ()
 Get id. More...
 
 hasAutoActivation ()
 Is to be activated on "installation". More...
 
 hasFlexibleSchedule ()
 Can the schedule be configured? More...
 
 getDefaultScheduleType ()
 Get schedule type. More...
 
 getDefaultScheduleValue ()
 Get schedule value. More...
 
 run ()
 Run job. More...
 

Protected Member Functions

 gatherUsersWithUnfinishedPasses ()
 
 getTestsFinishAndProcessingTime ()
 
 processPasses ()
 
 finishPassForUser ($active_id, $obj_id)
 
- Protected Member Functions inherited from ilCronJob
 checkSchedule ($a_ts_last_run, $a_schedule_type, $a_schedule_value)
 

Protected Attributes

 $log
 
 $lng
 
 $db
 
 $obj_data_cache
 
 $now
 
 $unfinished_passes
 
 $test_ids
 
 $test_ending_times
 
 $processLockerFactory
 

Additional Inherited Members

- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 
const SCHEDULE_TYPE_IN_HOURS = 3
 
const SCHEDULE_TYPE_IN_DAYS = 4
 
const SCHEDULE_TYPE_WEEKLY = 5
 
const SCHEDULE_TYPE_MONTHLY = 6
 
const SCHEDULE_TYPE_QUARTERLY = 7
 
const SCHEDULE_TYPE_YEARLY = 8
 

Detailed Description

Member Function Documentation

◆ finishPassForUser()

ilCronFinishUnfinishedTestPasses::finishPassForUser (   $active_id,
  $obj_id 
)
protected

Definition at line 239 of file class.ilCronFinishUnfinishedTestPasses.php.

240 {
241 $processLocker = $this->processLockerFactory->withContextId((int) $active_id)->getLocker();
242
243 $testSession = new ilTestSession();
244 $testSession->loadFromDb($active_id);
245
246 if(ilObject::_exists($obj_id)) {
247 $test = new ilObjTest($obj_id, false);
248
249 assQuestion::_updateTestPassResults(
250 $active_id,
251 $testSession->getPass(),
252 $test->areObligationsEnabled(),
253 null,
254 $obj_id
255 );
256
257 $pass_finisher = new ilTestPassFinishTasks($active_id, $obj_id);
258 $pass_finisher->performFinishTasks($processLocker);
259
260 $this->log->info('Test session with active id (' . $active_id . ') and obj_id (' . $obj_id . ') is now finished.');
261 } else {
262 $this->log->info('Test object with id (' . $obj_id . ') does not exist.');
263 }
264 }
$test
Definition: Utf8Test.php:84
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
Class ilTestPassFinishTasks.
Test session handler.

References $test, and ilObject\_exists().

Referenced by processPasses().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gatherUsersWithUnfinishedPasses()

ilCronFinishUnfinishedTestPasses::gatherUsersWithUnfinishedPasses ( )
protected

Definition at line 155 of file class.ilCronFinishUnfinishedTestPasses.php.

156 {
157 $query = "SELECT tst_active.active_id,
158 tst_active.tries,
159 tst_active.user_fi usr_id,
160 tst_active.test_fi test_fi,
161 usr_data.login,
162 usr_data.lastname,
163 usr_data.firstname,
164 tst_active.submitted test_finished,
165 usr_data.matriculation,
166 usr_data.active,
167 tst_active.lastindex,
168 tst_active.last_started_pass last_started
169 FROM tst_active
170 LEFT JOIN usr_data
171 ON tst_active.user_fi = usr_data.usr_id
172 WHERE IFNULL(tst_active.last_finished_pass, -1) <> tst_active.last_started_pass
173 ";
174 $result = $this->db->query($query);
175 while ($row = $this->db->fetchAssoc($result)) {
176 $this->unfinished_passes[] = $row;
177 $this->test_ids[] = $row['test_fi'];
178 }
179 }
$result
$query

References $query, and $result.

Referenced by run().

+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilCronFinishUnfinishedTestPasses::getDefaultScheduleType ( )

Get schedule type.

Returns
int

Reimplemented from ilCronJob.

Definition at line 108 of file class.ilCronFinishUnfinishedTestPasses.php.

109 {
111 }
const SCHEDULE_TYPE_DAILY

References ilCronJob\SCHEDULE_TYPE_DAILY.

◆ getDefaultScheduleValue()

ilCronFinishUnfinishedTestPasses::getDefaultScheduleValue ( )

Get schedule value.

Returns
int|array

Reimplemented from ilCronJob.

Definition at line 113 of file class.ilCronFinishUnfinishedTestPasses.php.

114 {
115 return;
116 }

◆ getDescription()

ilCronFinishUnfinishedTestPasses::getDescription ( )

Get description.

Returns
string

Reimplemented from ilCronJob.

Definition at line 100 of file class.ilCronFinishUnfinishedTestPasses.php.

101 {
102 global $DIC;
103 $lng = $DIC['lng'];
104
105 return $lng->txt("finish_unfinished_passes_desc");
106 }
global $DIC
Definition: goto.php:24

References $DIC, and $lng.

◆ getId()

ilCronFinishUnfinishedTestPasses::getId ( )

Get id.

Returns
string

Reimplemented from ilCronJob.

Definition at line 87 of file class.ilCronFinishUnfinishedTestPasses.php.

88 {
89 return 'finish_unfinished_passes';
90 }

◆ getTestsFinishAndProcessingTime()

ilCronFinishUnfinishedTestPasses::getTestsFinishAndProcessingTime ( )
protected

Definition at line 181 of file class.ilCronFinishUnfinishedTestPasses.php.

182 {
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');
185 $result = $this->db->query($query);
186 while ($row = $this->db->fetchAssoc($result)) {
187 $this->test_ending_times[$row['test_id']] = $row;
188 }
189 $this->log->info('Gathered data for ' . count($this->test_ids) . ' test id(s) => (' . implode(',', $this->test_ids) . ')');
190 }

References $query, and $result.

Referenced by run().

+ Here is the caller graph for this function:

◆ getTitle()

ilCronFinishUnfinishedTestPasses::getTitle ( )

Get title.

Returns
string

Reimplemented from ilCronJob.

Definition at line 92 of file class.ilCronFinishUnfinishedTestPasses.php.

93 {
94 global $DIC;
95 $lng = $DIC['lng'];
96
97 return $lng->txt("finish_unfinished_passes");
98 }

References $DIC, and $lng.

◆ hasAutoActivation()

ilCronFinishUnfinishedTestPasses::hasAutoActivation ( )

Is to be activated on "installation".

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 118 of file class.ilCronFinishUnfinishedTestPasses.php.

119 {
120 return false;
121 }

◆ hasCustomSettings()

ilCronFinishUnfinishedTestPasses::hasCustomSettings ( )

Has cron job any custom setting which can be edited?

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 128 of file class.ilCronFinishUnfinishedTestPasses.php.

129 {
130 return true;
131 }

◆ hasFlexibleSchedule()

ilCronFinishUnfinishedTestPasses::hasFlexibleSchedule ( )

Can the schedule be configured?

Returns
boolean

Reimplemented from ilCronJob.

Definition at line 123 of file class.ilCronFinishUnfinishedTestPasses.php.

124 {
125 return true;
126 }

◆ processPasses()

ilCronFinishUnfinishedTestPasses::processPasses ( )
protected

Definition at line 192 of file class.ilCronFinishUnfinishedTestPasses.php.

193 {
194 $now = time();
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) {
203 $this->finishPassForUser($data['active_id'], $this->test_ending_times[$test_id]['obj_fi']);
204 $can_not_be_finished = false;
205 } else {
206 $this->log->info('Test (' . $test_id . ') ending time (' . $this->test_ending_times[$test_id]['ending_time'] . ') > now (' . $now . ') is not reached.');
207 }
208 } else {
209 $this->log->info('Test (' . $test_id . ') has no ending time.');
210 }
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 if(ilObject::_exists($obj_id)) {
215 $test_obj = new ilObjTest($obj_id, false);
216 $startingTime = $test_obj->getStartingTimeOfUser($data['active_id']);
217 $max_processing_time = $test_obj->isMaxProcessingTimeReached($startingTime, $data['active_id']);
218 if ($max_processing_time) {
219 $this->log->info('Max Processing time reached for user id (' . $data['usr_id'] . ') so test with active id (' . $data['active_id'] . ') will be finished.');
220 $this->finishPassForUser($data['active_id'], $this->test_ending_times[$test_id]['obj_fi']);
221 $can_not_be_finished = false;
222 } else {
223 $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');
224 }
225 } else {
226 $this->log->info('Test object with id (' . $obj_id . ') does not exist.');
227 }
228 } else {
229 $this->log->info('Test (' . $test_id . ') has no processing time.');
230 }
231
232 if ($can_not_be_finished) {
233 $this->log->info('Test session with active id (' . $data['active_id'] . ') can not be finished by this cron job.');
234 }
235 }
236 }
237 }
$data
Definition: storeScorm.php:23

References $data, $now, ilObject\_exists(), and finishPassForUser().

Referenced by run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilCronFinishUnfinishedTestPasses::run ( )

Run job.

Returns
ilCronJobResult

Reimplemented from ilCronJob.

Definition at line 133 of file class.ilCronFinishUnfinishedTestPasses.php.

134 {
135 $this->log->info('start inf cronjob...');
136
137 $result = new ilCronJobResult();
138
140 if (count($this->unfinished_passes) > 0) {
141 $this->log->info('found ' . count($this->unfinished_passes) . ' unfinished passes starting analyses.');
143 $this->processPasses();
144 } else {
145 $this->log->info('No unfinished passes found.');
146 }
147
149
150 $this->log->info(' ...finishing cronjob.');
151
152 return $result;
153 }
Cron job result data container.

References $result, gatherUsersWithUnfinishedPasses(), getTestsFinishAndProcessingTime(), processPasses(), and ilCronJobResult\STATUS_OK.

+ Here is the call graph for this function:

Field Documentation

◆ $db

ilCronFinishUnfinishedTestPasses::$db
protected

Definition at line 30 of file class.ilCronFinishUnfinishedTestPasses.php.

◆ $lng

ilCronFinishUnfinishedTestPasses::$lng
protected

Definition at line 25 of file class.ilCronFinishUnfinishedTestPasses.php.

Referenced by getDescription(), and getTitle().

◆ $log

ilCronFinishUnfinishedTestPasses::$log
protected

Definition at line 20 of file class.ilCronFinishUnfinishedTestPasses.php.

◆ $now

ilCronFinishUnfinishedTestPasses::$now
protected

Definition at line 40 of file class.ilCronFinishUnfinishedTestPasses.php.

Referenced by processPasses().

◆ $obj_data_cache

ilCronFinishUnfinishedTestPasses::$obj_data_cache
protected

Definition at line 35 of file class.ilCronFinishUnfinishedTestPasses.php.

◆ $processLockerFactory

ilCronFinishUnfinishedTestPasses::$processLockerFactory
protected

Definition at line 51 of file class.ilCronFinishUnfinishedTestPasses.php.

◆ $test_ending_times

ilCronFinishUnfinishedTestPasses::$test_ending_times
protected

Definition at line 46 of file class.ilCronFinishUnfinishedTestPasses.php.

◆ $test_ids

ilCronFinishUnfinishedTestPasses::$test_ids
protected

Definition at line 44 of file class.ilCronFinishUnfinishedTestPasses.php.

◆ $unfinished_passes

ilCronFinishUnfinishedTestPasses::$unfinished_passes
protected

Definition at line 42 of file class.ilCronFinishUnfinishedTestPasses.php.


The documentation for this class was generated from the following file: