ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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...
 
 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 233 of file class.ilCronFinishUnfinishedTestPasses.php.

Referenced by processPasses().

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

◆ gatherUsersWithUnfinishedPasses()

ilCronFinishUnfinishedTestPasses::gatherUsersWithUnfinishedPasses ( )
protected

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

References $query, $result, and $row.

Referenced by run().

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
$row
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilCronFinishUnfinishedTestPasses::getDefaultScheduleType ( )

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

109  {
110  return self::SCHEDULE_TYPE_DAILY;
111  }

◆ getDefaultScheduleValue()

ilCronFinishUnfinishedTestPasses::getDefaultScheduleValue ( )

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

114  {
115  return;
116  }

◆ getDescription()

ilCronFinishUnfinishedTestPasses::getDescription ( )

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

References $DIC, and $lng.

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

◆ getId()

ilCronFinishUnfinishedTestPasses::getId ( )

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.

References $query, $result, and $row.

Referenced by run().

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  }
$result
$query
$row
+ Here is the caller graph for this function:

◆ getTitle()

ilCronFinishUnfinishedTestPasses::getTitle ( )

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

References $DIC, and $lng.

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

◆ hasAutoActivation()

ilCronFinishUnfinishedTestPasses::hasAutoActivation ( )

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

119  {
120  return false;
121  }

◆ hasCustomSettings()

ilCronFinishUnfinishedTestPasses::hasCustomSettings ( )

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

129  {
130  return true;
131  }

◆ hasFlexibleSchedule()

ilCronFinishUnfinishedTestPasses::hasFlexibleSchedule ( )

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.

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

Referenced by run().

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  $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;
221  }
222  } else {
223  $this->log->info('Test (' . $test_id . ') has no processing time.');
224  }
225 
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.');
228  }
229  }
230  }
231  }
$key
Definition: croninfo.php:18
$data
Definition: bench.php:6
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilCronFinishUnfinishedTestPasses::run ( )

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

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

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  }
$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: