ILIAS  release_8 Revision v8.23
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, ?int $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 (?int $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'
 
- Data Fields inherited from ilCronJob
const SCHEDULE_TYPE_DAILY = 1
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_MINUTES = 2
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_HOURS = 3
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_IN_DAYS = 4
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_WEEKLY = 5
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_MONTHLY = 6
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_QUARTERLY = 7
 This will be replaced with an ENUM in ILIAS 9 More...
 
const SCHEDULE_TYPE_YEARLY = 8
 This will be replaced with an ENUM in ILIAS 9 More...
 

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
int $schedule_type = null
 
int $schedule_value = null
 
Closure $date_time_provider = null
 

Private Attributes

ILIAS DI Container $dic
 

Detailed Description

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

Constructor & Destructor Documentation

◆ __construct()

ilXapiResultsCronjob::__construct ( )

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

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

43  {
44  global $DIC; /* @var \ILIAS\DI\Container $DIC */
45  $this->dic = $DIC;
46 
47  $DIC->language()->loadLanguageModule('cmix');
48 
49  $this->log = ilLoggerFactory::getLogger('cmix');
50 
51  $this->initThisRunTS();
52  $this->readLastRunTS();
53  }
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 179 of file class.ilXapiResultsCronjob.php.

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

Referenced by run().

180  {
181  $filter = new ilCmiXapiStatementsReportFilter();
182 
183  $start = $end = null;
184 
185  if ($this->getLastRunTS() !== 0) {
186  $filter->setStartDate(new ilCmiXapiDateTime($this->getLastRunTS(), IL_CAL_UNIX));
187  $start = $filter->getStartDate()->get(IL_CAL_DATETIME);
188  }
189 
190  $filter->setEndDate(new ilCmiXapiDateTime($this->getThisRunTS(), IL_CAL_UNIX));
191  $end = $filter->getEndDate()->get(IL_CAL_DATETIME);
192 
193  $this->log->debug("use filter from ($start) until ($end)");
194 
195  return $filter;
196  }
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 108 of file class.ilXapiResultsCronjob.php.

108  : int
109  {
110  return self::SCHEDULE_TYPE_DAILY;
111  }

◆ getDefaultScheduleValue()

ilXapiResultsCronjob::getDefaultScheduleValue ( )

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

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

◆ getDescription()

ilXapiResultsCronjob::getDescription ( )

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

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

◆ getId()

ilXapiResultsCronjob::getId ( )

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

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

◆ getLastRunTS()

ilXapiResultsCronjob::getLastRunTS ( )

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

References $lastRunTS.

Referenced by buildReportFilter().

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

◆ getObjectsToBeReported()

ilXapiResultsCronjob::getObjectsToBeReported ( )
protected
Returns
mixed[]

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

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

Referenced by run().

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

References $thisRunTS.

Referenced by buildReportFilter(), and run().

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

◆ getTitle()

ilXapiResultsCronjob::getTitle ( )

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

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

◆ getXapiStatementsReport()

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

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

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

Referenced by run().

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

◆ hasAutoActivation()

ilXapiResultsCronjob::hasAutoActivation ( )

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

98  : bool
99  {
100  return false;
101  }

◆ hasFlexibleSchedule()

ilXapiResultsCronjob::hasFlexibleSchedule ( )

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

103  : bool
104  {
105  return true;
106  }

◆ initThisRunTS()

ilXapiResultsCronjob::initThisRunTS ( )
protected

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

Referenced by __construct().

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

◆ readLastRunTS()

ilXapiResultsCronjob::readLastRunTS ( )
protected

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

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

Referenced by __construct().

60  : void
61  {
62  $settings = new ilSetting('cmix');
63  // Check return value of $settings->get, since this is string but a int is needed for lastRunTS
64  $this->lastRunTS = (int) $settings->get(self::LAST_RUN_TS_SETTING_NAME, "0");
65  }
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 118 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().

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

References ILIAS\LTI\ToolProvider\$settings.

Referenced by run().

67  : void
68  {
69  $settings = new ilSetting('cmix');
70  $settings->set(self::LAST_RUN_TS_SETTING_NAME, (string) $this->thisRunTS);
71  }
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 40 of file class.ilXapiResultsCronjob.php.

◆ $lastRunTS

int ilXapiResultsCronjob::$lastRunTS
protected

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

Referenced by getLastRunTS().

◆ $log

ilLogger ilXapiResultsCronjob::$log
protected

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

◆ $thisRunTS

int ilXapiResultsCronjob::$thisRunTS
protected

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


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