ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 246 of file class.ilCronFinishUnfinishedTestPasses.php.

Referenced by processPasses().

247  {
248  $this->processLockerFactory->setActiveId($active_id);
249  $processLocker = $this->processLockerFactory->getLocker();
250 
251  $pass_finisher = new ilTestPassFinishTasks($active_id, $obj_id);
252  $pass_finisher->performFinishTasks($processLocker);
253 
254  $this->log->info('Test session with active id ('.$active_id .') and obj_id (' .$obj_id .') is now finished.');
255  }
Class ilTestPassFinishTasks.
+ Here is the caller graph for this function:

◆ gatherUsersWithUnfinishedPasses()

ilCronFinishUnfinishedTestPasses::gatherUsersWithUnfinishedPasses ( )
protected

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

References $query, $result, and $row.

Referenced by run().

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

◆ getDefaultScheduleType()

ilCronFinishUnfinishedTestPasses::getDefaultScheduleType ( )

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

103  {
104  return self::SCHEDULE_TYPE_DAILY;
105  }

◆ getDefaultScheduleValue()

ilCronFinishUnfinishedTestPasses::getDefaultScheduleValue ( )

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

108  {
109  return;
110  }

◆ getDescription()

ilCronFinishUnfinishedTestPasses::getDescription ( )

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

References $lng.

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

◆ getId()

ilCronFinishUnfinishedTestPasses::getId ( )

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

84  {
85  return 'finish_unfinished_passes';
86  }

◆ getTestsFinishAndProcessingTime()

ilCronFinishUnfinishedTestPasses::getTestsFinishAndProcessingTime ( )
protected

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

References $query, $result, and $row.

Referenced by run().

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

◆ getTitle()

ilCronFinishUnfinishedTestPasses::getTitle ( )

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

References $lng.

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

◆ hasAutoActivation()

ilCronFinishUnfinishedTestPasses::hasAutoActivation ( )

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

113  {
114  return false;
115  }

◆ hasCustomSettings()

ilCronFinishUnfinishedTestPasses::hasCustomSettings ( )

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

123  {
124  return true;
125  }

◆ hasFlexibleSchedule()

ilCronFinishUnfinishedTestPasses::hasFlexibleSchedule ( )

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

118  {
119  return true;
120  }

◆ processPasses()

ilCronFinishUnfinishedTestPasses::processPasses ( )
protected

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

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

Referenced by run().

192  {
193  $now = time();
194  foreach($this->unfinished_passes as $key => $data)
195  {
196  $test_id = $data['test_fi'];
197  $can_not_be_finished = true;
198  if(array_key_exists($test_id, $this->test_ending_times))
199  {
200  if($this->test_ending_times[$test_id]['ending_time_enabled'] == 1)
201  {
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)
205  {
206  $this->finishPassForUser($data['active_id'], $this->test_ending_times[$test_id]['obj_fi']);
207  $can_not_be_finished = false;
208  }
209  else
210  {
211  $this->log->info('Test (' . $test_id . ') ending time ('.$this->test_ending_times[$test_id]['ending_time'].') > now ('.$now.') is not reached.' );
212  }
213 
214  }
215  else
216  {
217  $this->log->info('Test (' . $test_id . ') has no ending time.' );
218  }
219  if($this->test_ending_times[$test_id]['enable_processing_time'] == 1)
220  {
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)
227  {
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;
231  }
232  }
233  else
234  {
235  $this->log->info('Test (' . $test_id . ') has no processing time.');
236  }
237 
238  if($can_not_be_finished)
239  {
240  $this->log->info('Test session with active id ('.$data['active_id'].') can not be finished by this cron job.');
241  }
242  }
243  }
244  }
Add data(end) time
Method that wraps PHPs time in order to allow simulations with the workflow.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilCronFinishUnfinishedTestPasses::run ( )

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

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

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