ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
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 ilCronJob
 setDateTimeProvider (?Closure $date_time_provider)
 
 isDue (?DateTimeImmutable $last_run, ?CronJobScheduleType $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 (?CronJobScheduleType $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 ()
 
 addCustomSettingsToForm (ilPropertyFormGUI $a_form)
 
 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 ilCronJob
CronJobScheduleType $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

ILIAS DI Container $dic
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilXapiResultsCronjob::__construct ( )

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

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

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

Member Function Documentation

◆ buildReportFilter()

ilXapiResultsCronjob::buildReportFilter ( )
protected

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

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

Referenced by run().

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

◆ getDefaultScheduleType()

ilXapiResultsCronjob::getDefaultScheduleType ( )

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

110  {
111  return CronJobScheduleType::SCHEDULE_TYPE_DAILY;
112  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getDefaultScheduleValue()

ilXapiResultsCronjob::getDefaultScheduleValue ( )

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

114  : ?int
115  {
116  return null;
117  }

◆ getDescription()

ilXapiResultsCronjob::getDescription ( )

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

94  : string
95  {
96  return $this->dic->language()->txt("cron_xapi_results_evaluation_desc");
97  }

◆ getId()

ilXapiResultsCronjob::getId ( )

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

84  : string
85  {
86  return 'xapi_results_evaluation';
87  }

◆ getLastRunTS()

ilXapiResultsCronjob::getLastRunTS ( )

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

References $lastRunTS.

Referenced by buildReportFilter().

79  : int
80  {
81  return $this->lastRunTS;
82  }
+ Here is the caller graph for this function:

◆ getObjectsToBeReported()

ilXapiResultsCronjob::getObjectsToBeReported ( )
protected
Returns
mixed[]

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

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

Referenced by run().

202  : array
203  {
204  return array_unique(array_merge(
207  ));
208  }
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 74 of file class.ilXapiResultsCronjob.php.

References $thisRunTS.

Referenced by buildReportFilter(), and run().

74  : int
75  {
76  return $this->thisRunTS;
77  }
+ Here is the caller graph for this function:

◆ getTitle()

ilXapiResultsCronjob::getTitle ( )

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

89  : string
90  {
91  return $this->dic->language()->txt("cron_xapi_results_evaluation");
92  }

◆ getXapiStatementsReport()

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

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

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

Referenced by run().

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

◆ hasAutoActivation()

ilXapiResultsCronjob::hasAutoActivation ( )

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

99  : bool
100  {
101  return false;
102  }

◆ hasFlexibleSchedule()

ilXapiResultsCronjob::hasFlexibleSchedule ( )

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

104  : bool
105  {
106  return true;
107  }

◆ initThisRunTS()

ilXapiResultsCronjob::initThisRunTS ( )
protected

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

Referenced by __construct().

56  : void
57  {
58  $this->thisRunTS = time();
59  }
+ Here is the caller graph for this function:

◆ readLastRunTS()

ilXapiResultsCronjob::readLastRunTS ( )
protected

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

References ILIAS\LTI\ToolProvider\$settings, and ILIAS\Repository\int().

Referenced by __construct().

61  : void
62  {
63  $settings = new ilSetting('cmix');
64  // Check return value of $settings->get, since this is string but a int is needed for lastRunTS
65  $this->lastRunTS = (int) $settings->get(self::LAST_RUN_TS_SETTING_NAME, "0");
66  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ run()

ilXapiResultsCronjob::run ( )

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

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

120  {
121  $objects = $this->getObjectsToBeReported();
122  $objectIds = [];
123 
124  foreach ($objects as $objId) {
125  $this->log->debug('handle object (' . $objId . ')');
126 
127  $filter = $this->buildReportFilter();
128 
129  $object = ilObjectFactory::getInstanceByObjId($objId, false);
130 
131  $evaluation = new ilXapiStatementEvaluation($this->log, $object);
132 
133  if ($object->getLaunchMode() != ilObjCmiXapi::LAUNCH_MODE_NORMAL) {
134  $this->log->debug('skipped object due to launch mode (' . $objId . ')');
135  continue;
136  }
137 
138  $report = $this->getXapiStatementsReport($object, $filter);
139 
140  $evaluation->evaluateReport($report);
141 
142  //$this->log->debug('update lp for object (' . $objId . ')');
143  //ilLPStatusWrapper::_refreshStatus($objId);
144 
145  $objectIds[] = $objId;
146  }
147 
150  $objectIds
151  );
152 
153  $result = new ilCronJobResult();
154  $result->setStatus(ilCronJobResult::STATUS_OK);
155 
156  $this->writeThisAsLastRunTS();
157  return $result;
158  }
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 68 of file class.ilXapiResultsCronjob.php.

References ILIAS\LTI\ToolProvider\$settings.

Referenced by run().

68  : void
69  {
70  $settings = new ilSetting('cmix');
71  $settings->set(self::LAST_RUN_TS_SETTING_NAME, (string) $this->thisRunTS);
72  }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
+ Here is the caller graph for this function:

Field Documentation

◆ $dic

ILIAS DI Container ilXapiResultsCronjob::$dic
private

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

◆ $lastRunTS

int ilXapiResultsCronjob::$lastRunTS
protected

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

Referenced by getLastRunTS().

◆ $log

ilLogger ilXapiResultsCronjob::$log
protected

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

◆ $thisRunTS

int ilXapiResultsCronjob::$thisRunTS
protected

Definition at line 35 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 33 of file class.ilXapiResultsCronjob.php.


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