ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilCronFinishUnfinishedTestPasses Class Reference

Class ilCronFinishUnfinishedTestPasses. More...

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

Public Member Functions

 getId ()
 
 getTitle ()
 
 getDescription ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 hasCustomSettings ()
 
 run ()
 
- 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...
 
 getValidScheduleTypes ()
 Get all available schedule types. 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 228 of file class.ilCronFinishUnfinishedTestPasses.php.

Referenced by processPasses().

229  {
230  $this->processLockerFactory->setActiveId($active_id);
231  $processLocker = $this->processLockerFactory->getLocker();
232 
233  $pass_finisher = new ilTestPassFinishTasks($active_id, $obj_id);
234  $pass_finisher->performFinishTasks($processLocker);
235 
236  $this->log->info('Test session with active id (' . $active_id . ') and obj_id (' . $obj_id . ') is now finished.');
237  }
Class ilTestPassFinishTasks.
+ Here is the caller graph for this function:

◆ gatherUsersWithUnfinishedPasses()

ilCronFinishUnfinishedTestPasses::gatherUsersWithUnfinishedPasses ( )
protected

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

References $query, $result, and $row.

Referenced by run().

151  {
152  $query = "SELECT tst_active.active_id,
153  tst_active.tries,
154  tst_active.user_fi usr_id,
155  tst_active.test_fi test_fi,
156  usr_data.login,
157  usr_data.lastname,
158  usr_data.firstname,
159  tst_active.submitted test_finished,
160  usr_data.matriculation,
161  usr_data.active,
162  tst_active.lastindex,
163  tst_active.last_started_pass last_started
164  FROM tst_active
165  LEFT JOIN usr_data
166  ON tst_active.user_fi = usr_data.usr_id
167  WHERE IFNULL(tst_active.last_finished_pass, -1) <> tst_active.last_started_pass
168  ";
169  $result = $this->db->query($query);
170  while ($row = $this->db->fetchAssoc($result)) {
171  $this->unfinished_passes[] = $row;
172  $this->test_ids[] = $row['test_fi'];
173  }
174  }
$result
$query
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilCronFinishUnfinishedTestPasses::getDefaultScheduleType ( )

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

104  {
105  return self::SCHEDULE_TYPE_DAILY;
106  }

◆ getDefaultScheduleValue()

ilCronFinishUnfinishedTestPasses::getDefaultScheduleValue ( )

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

109  {
110  return;
111  }

◆ getDescription()

ilCronFinishUnfinishedTestPasses::getDescription ( )

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

References $lng.

97  {
98  global $lng;
99 
100  return $lng->txt("finish_unfinished_passes_desc");
101  }

◆ getId()

ilCronFinishUnfinishedTestPasses::getId ( )

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

85  {
86  return 'finish_unfinished_passes';
87  }

◆ getTestsFinishAndProcessingTime()

ilCronFinishUnfinishedTestPasses::getTestsFinishAndProcessingTime ( )
protected

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

References $query, $result, and $row.

Referenced by run().

177  {
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');
180  $result = $this->db->query($query);
181  while ($row = $this->db->fetchAssoc($result)) {
182  $this->test_ending_times[$row['test_id']] = $row;
183  }
184  $this->log->info('Gathered data for ' . count($this->test_ids) . ' test id(s) => (' . implode(',', $this->test_ids) . ')');
185  }
$result
$query
+ Here is the caller graph for this function:

◆ getTitle()

ilCronFinishUnfinishedTestPasses::getTitle ( )

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

References $lng.

90  {
91  global $lng;
92 
93  return $lng->txt("finish_unfinished_passes");
94  }

◆ hasAutoActivation()

ilCronFinishUnfinishedTestPasses::hasAutoActivation ( )

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

114  {
115  return false;
116  }

◆ hasCustomSettings()

ilCronFinishUnfinishedTestPasses::hasCustomSettings ( )

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

124  {
125  return true;
126  }

◆ hasFlexibleSchedule()

ilCronFinishUnfinishedTestPasses::hasFlexibleSchedule ( )

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

119  {
120  return true;
121  }

◆ processPasses()

ilCronFinishUnfinishedTestPasses::processPasses ( )
protected

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

References $data, $key, $now, finishPassForUser(), and time.

Referenced by run().

188  {
189  $now = time();
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) {
198  $this->finishPassForUser($data['active_id'], $this->test_ending_times[$test_id]['obj_fi']);
199  $can_not_be_finished = false;
200  } else {
201  $this->log->info('Test (' . $test_id . ') ending time (' . $this->test_ending_times[$test_id]['ending_time'] . ') > now (' . $now . ') is not reached.');
202  }
203  } else {
204  $this->log->info('Test (' . $test_id . ') has no ending time.');
205  }
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;
216  }
217  } else {
218  $this->log->info('Test (' . $test_id . ') has no processing time.');
219  }
220 
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.');
223  }
224  }
225  }
226  }
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilCronFinishUnfinishedTestPasses::run ( )

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

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

129  {
130  $this->log->info('start inf cronjob...');
131 
132  $result = new ilCronJobResult();
133 
135  if (count($this->unfinished_passes) > 0) {
136  $this->log->info('found ' . count($this->unfinished_passes) . ' unfinished passes starting analyses.');
138  $this->processPasses();
139  } else {
140  $this->log->info('No unfinished passes found.');
141  }
142 
144 
145  $this->log->info(' ...finishing cronjob.');
146 
147  return $result;
148  }
$result
Cron job result data container.
+ 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: