ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ilXapiResultsCronjob Class Reference
+ Inheritance diagram for ilXapiResultsCronjob:
+ Collaboration diagram for ilXapiResultsCronjob:

Public Member Functions

 __construct ()
 
 getThisRunTS ()
 
 getLastRunTS ()
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 
- Public Member Functions inherited from ILIAS\Cron\CronJob
 setDateTimeProvider (?\Closure $date_time_provider)
 
 isDue (?\DateTimeImmutable $last_run, ?JobScheduleType $schedule_type, ?int $schedule_value, bool $is_manually_executed=false)
 
 getScheduleType ()
 Get current schedule type (if flexible) More...
 
 getScheduleValue ()
 Get current schedule value (if flexible) More...
 
 setSchedule (?JobScheduleType $a_type, ?int $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...
 
 isManuallyExecutable ()
 
 hasCustomSettings ()
 
 usesLegacyForms ()
 
 getCustomConfigurationInput (\ILIAS\UI\Factory $ui_factory, \ILIAS\Refinery\Factory $factory, \ilLanguage $lng)
 
 addCustomSettingsToForm (\ilPropertyFormGUI $a_form)
 
 saveCustomConfiguration (mixed $form_data)
 
 saveCustomSettings (\ilPropertyFormGUI $a_form)
 
 addToExternalSettingsForm (int $a_form_id, array &$a_fields, bool $a_is_active)
 
 activationWasToggled (\ilDBInterface $db, \ilSetting $setting, bool $a_currently_active)
 Important: This method is (also) called from the setup process, where the constructor of an ilCronJob ist NOT executed. More...
 
 getId ()
 
 getTitle ()
 
 getDescription ()
 
 hasAutoActivation ()
 Is to be activated on "installation", does only work for ILIAS core cron jobs. More...
 
 hasFlexibleSchedule ()
 
 getDefaultScheduleType ()
 
 getDefaultScheduleValue ()
 
 run ()
 

Data Fields

const LAST_RUN_TS_SETTING_NAME = 'cron_xapi_res_eval_last_run'
 

Protected Member Functions

 initThisRunTS ()
 
 readLastRunTS ()
 
 writeThisAsLastRunTS ()
 
 getXapiStatementsReport (ilObject $object, ilCmiXapiStatementsReportFilter $filter)
 
 buildReportFilter ()
 
 getObjectsToBeReported ()
 

Protected Attributes

int $thisRunTS
 
int $lastRunTS
 
ilLogger $log
 
- Protected Attributes inherited from ILIAS\Cron\CronJob
JobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

ILIAS DI Container $dic
 

Detailed Description

Definition at line 34 of file class.ilXapiResultsCronjob.php.

Constructor & Destructor Documentation

◆ __construct()

ilXapiResultsCronjob::__construct ( )

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

References $DIC, ilLoggerFactory\getLogger(), initThisRunTS(), and readLastRunTS().

47  {
48  global $DIC; /* @var \ILIAS\DI\Container $DIC */
49  $this->dic = $DIC;
50 
51  $DIC->language()->loadLanguageModule('cmix');
52 
53  $this->log = ilLoggerFactory::getLogger('cmix');
54 
55  $this->initThisRunTS();
56  $this->readLastRunTS();
57  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ buildReportFilter()

ilXapiResultsCronjob::buildReportFilter ( )
protected

Definition at line 183 of file class.ilXapiResultsCronjob.php.

References getLastRunTS(), getThisRunTS(), IL_CAL_DATETIME, IL_CAL_UNIX, and null.

Referenced by run().

184  {
185  $filter = new ilCmiXapiStatementsReportFilter();
186 
187  $start = $end = null;
188 
189  if ($this->getLastRunTS() !== 0) {
190  $filter->setStartDate(new ilCmiXapiDateTime($this->getLastRunTS(), IL_CAL_UNIX));
191  $start = $filter->getStartDate()->get(IL_CAL_DATETIME);
192  }
193 
194  $filter->setEndDate(new ilCmiXapiDateTime($this->getThisRunTS(), IL_CAL_UNIX));
195  $end = $filter->getEndDate()->get(IL_CAL_DATETIME);
196 
197  $this->log->debug("use filter from ($start) until ($end)");
198 
199  return $filter;
200  }
const IL_CAL_DATETIME
const IL_CAL_UNIX
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultScheduleType()

ilXapiResultsCronjob::getDefaultScheduleType ( )

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

113  {
114  return JobScheduleType::DAILY;
115  }

◆ getDefaultScheduleValue()

ilXapiResultsCronjob::getDefaultScheduleValue ( )

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

References null.

117  : ?int
118  {
119  return null;
120  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getDescription()

ilXapiResultsCronjob::getDescription ( )

Definition at line 97 of file class.ilXapiResultsCronjob.php.

97  : string
98  {
99  return $this->dic->language()->txt("cron_xapi_results_evaluation_desc");
100  }

◆ getId()

ilXapiResultsCronjob::getId ( )

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

87  : string
88  {
89  return 'xapi_results_evaluation';
90  }

◆ getLastRunTS()

ilXapiResultsCronjob::getLastRunTS ( )

Definition at line 82 of file class.ilXapiResultsCronjob.php.

References $lastRunTS.

Referenced by buildReportFilter().

82  : int
83  {
84  return $this->lastRunTS;
85  }
+ Here is the caller graph for this function:

◆ getObjectsToBeReported()

ilXapiResultsCronjob::getObjectsToBeReported ( )
protected
Returns
mixed[]

Definition at line 205 of file class.ilXapiResultsCronjob.php.

References ilCmiXapiUser\getCmixObjectsHavingUsersMissingProxySuccess(), and ilObjCmiXapi\getObjectsHavingBypassProxyEnabledAndRegisteredUsers().

Referenced by run().

205  : array
206  {
207  return array_unique(array_merge(
210  ));
211  }
static getObjectsHavingBypassProxyEnabledAndRegisteredUsers()
static getCmixObjectsHavingUsersMissingProxySuccess()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getThisRunTS()

ilXapiResultsCronjob::getThisRunTS ( )

Definition at line 77 of file class.ilXapiResultsCronjob.php.

References $thisRunTS.

Referenced by buildReportFilter(), and run().

77  : int
78  {
79  return $this->thisRunTS;
80  }
+ Here is the caller graph for this function:

◆ getTitle()

ilXapiResultsCronjob::getTitle ( )

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

92  : string
93  {
94  return $this->dic->language()->txt("cron_xapi_results_evaluation");
95  }

◆ getXapiStatementsReport()

ilXapiResultsCronjob::getXapiStatementsReport ( ilObject  $object,
ilCmiXapiStatementsReportFilter  $filter 
)
protected

Definition at line 163 of file class.ilXapiResultsCronjob.php.

References ilObject\getId(), and ilCmiXapiStatementsReportFilter\setActivityId().

Referenced by run().

167  $filter->setActivityId($object->getActivityId());
168 
169  $linkBuilder = new ilCmiXapiStatementsReportLinkBuilder(
170  $object->getId(),
171  $object->getLrsType()->getLrsEndpointStatementsAggregationLink(),
172  $filter
173  );
174 
175  $request = new ilCmiXapiStatementsReportRequest(
176  $object->getLrsType()->getBasicAuth(),
177  $linkBuilder
178  );
179 
180  return $request->queryReport($object->getId());
181  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ hasAutoActivation()

ilXapiResultsCronjob::hasAutoActivation ( )

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

102  : bool
103  {
104  return false;
105  }

◆ hasFlexibleSchedule()

ilXapiResultsCronjob::hasFlexibleSchedule ( )

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

107  : bool
108  {
109  return true;
110  }

◆ initThisRunTS()

ilXapiResultsCronjob::initThisRunTS ( )
protected

Definition at line 59 of file class.ilXapiResultsCronjob.php.

Referenced by __construct().

59  : void
60  {
61  $this->thisRunTS = time();
62  }
+ Here is the caller graph for this function:

◆ readLastRunTS()

ilXapiResultsCronjob::readLastRunTS ( )
protected

Definition at line 64 of file class.ilXapiResultsCronjob.php.

References ILIAS\Repository\int().

Referenced by __construct().

64  : void
65  {
66  $settings = new ilSetting('cmix');
67  // Check return value of $settings->get, since this is string but a int is needed for lastRunTS
68  $this->lastRunTS = (int) $settings->get(self::LAST_RUN_TS_SETTING_NAME, "0");
69  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilXapiResultsCronjob::run ( )

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

References $objId, buildReportFilter(), ilObjectFactory\getInstanceByObjId(), getObjectsToBeReported(), getThisRunTS(), getXapiStatementsReport(), IL_CAL_UNIX, ilObjCmiXapi\LAUNCH_MODE_NORMAL, ilCmiXapiUser\updateFetchedUntilForObjects(), and writeThisAsLastRunTS().

122  : JobResult
123  {
124  $objects = $this->getObjectsToBeReported();
125  $objectIds = [];
126 
127  foreach ($objects as $objId) {
128  $this->log->debug('handle object (' . $objId . ')');
129 
130  $filter = $this->buildReportFilter();
131 
132  $object = ilObjectFactory::getInstanceByObjId($objId, false);
133 
134  $evaluation = new ilXapiStatementEvaluation($this->log, $object);
135 
136  if ($object->getLaunchMode() != ilObjCmiXapi::LAUNCH_MODE_NORMAL) {
137  $this->log->debug('skipped object due to launch mode (' . $objId . ')');
138  continue;
139  }
140 
141  $report = $this->getXapiStatementsReport($object, $filter);
142 
143  $evaluation->evaluateReport($report);
144 
145  //$this->log->debug('update lp for object (' . $objId . ')');
146  //ilLPStatusWrapper::_refreshStatus($objId);
147 
148  $objectIds[] = $objId;
149  }
150 
153  $objectIds
154  );
155 
156  $result = new JobResult();
157  $result->setStatus(JobResult::STATUS_OK);
158 
159  $this->writeThisAsLastRunTS();
160  return $result;
161  }
getXapiStatementsReport(ilObject $object, ilCmiXapiStatementsReportFilter $filter)
$objId
Definition: xapitoken.php:57
const IL_CAL_UNIX
static updateFetchedUntilForObjects(ilCmiXapiDateTime $fetchedUntil, array $objectIds)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
+ Here is the call graph for this function:

◆ writeThisAsLastRunTS()

ilXapiResultsCronjob::writeThisAsLastRunTS ( )
protected

Definition at line 71 of file class.ilXapiResultsCronjob.php.

Referenced by run().

71  : void
72  {
73  $settings = new ilSetting('cmix');
74  $settings->set(self::LAST_RUN_TS_SETTING_NAME, (string) $this->thisRunTS);
75  }
+ Here is the caller graph for this function:

Field Documentation

◆ $dic

ILIAS DI Container ilXapiResultsCronjob::$dic
private

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

◆ $lastRunTS

int ilXapiResultsCronjob::$lastRunTS
protected

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

Referenced by getLastRunTS().

◆ $log

ilLogger ilXapiResultsCronjob::$log
protected

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

◆ $thisRunTS

int ilXapiResultsCronjob::$thisRunTS
protected

Definition at line 38 of file class.ilXapiResultsCronjob.php.

Referenced by getThisRunTS().

◆ LAST_RUN_TS_SETTING_NAME

const ilXapiResultsCronjob::LAST_RUN_TS_SETTING_NAME = 'cron_xapi_res_eval_last_run'

Definition at line 36 of file class.ilXapiResultsCronjob.php.


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