ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\LearningSequence\Content\Condition\AbstractCondition Class Reference
+ Inheritance diagram for ILIAS\LearningSequence\Content\Condition\AbstractCondition:
+ Collaboration diagram for ILIAS\LearningSequence\Content\Condition\AbstractCondition:

Public Member Functions

 check ()
 Checks if the condition is fulfilled. More...
 
 getAdditionalForm ()
 Returns the additional form for the condition. More...
 
 getAdditionalDisplayInformation ()
 Returns additional condition-specific information for table overviews. More...
 
 getValidationMessages ()
 
 hasValidationMessages ()
 
 clearValidationMessages ()
 
 getAdditionalDisplayObjectTitles ()
 Returns condition-specific object titles for table overviews. More...
 
 applyAdditionalFormData (array $data)
 Applies validated additional form data to the condition before create()/edit(). More...
 
 getName ()
 
 setSubtype (string $subtype)
 
 setupSteps ()
 Returns an array of steps to configure the condition. More...
 
 getObjRefId ()
 
 setObjRefId (?int $obj_ref_id)
 
 getLsoRefId ()
 
 setLsoRefId (?int $lso_ref_id)
 
 getConditionId ()
 
 setConditionId (?int $condition_id)
 
 setTypeId (?int $type_id)
 
 getTypeId ()
 
 create (bool $is_import=false)
 Saves the condition to the DB. More...
 
 edit ()
 Edits the condition. More...
 
 delete ()
 Deletes the condition from the database. More...
 
 setConditionFactory (ConditionFactory $condition_factory)
 Sets the factory which created this condition. More...
 
 allowMultipleConditionsOfSameType ()
 Determines whether multiple conditions of the same type are allowed for the same object. More...
 
 supportsDuplicateCheck ()
 Whether create() and edit() check for an identically configured condition, see isDuplicateOf(). More...
 
 isDuplicateOf (AbstractCondition $other)
 Determines whether this condition is configured identically to the given one. More...
 
 getStaticInputConditionConstraints ()
 Returns statically analyzable input-condition constraints. More...
 
 hasStaticInputConfigurationConflict (array $context=[])
 Allows concrete conditions to report static misconfigurations that depend on context information such as the configured start object. More...
 
 getStaticInputConfigurationIssues (array $context=[])
 Returns static input-configuration issues contributed by this condition. More...
 
 read ()
 Reads the condition data from the database and populates the properties. More...
 
 getData ()
 
 export ()
 
 import (array $payload, int $new_condition_id)
 
 setImportMapping (array $mapping)
 

Static Public Member Functions

static migrate ()
 Returns an array of table definitions for the condition. More...
 
static getIdentifierForClass (string $class)
 Extracts the identifier for the condition type from the class name. More...
 

Protected Member Functions

 addValidationMessage (string $message)
 
 buildUrl (string $command, bool $with_configuration_gui=false)
 Builds a URL for the given command. More...
 
 assertContextSet ()
 Asserts that the context (lso_ref_id and obj_ref_id) is set. More...
 
 createConditionData (int $condition_id)
 Hook for condition-specific payload persistence during create(). More...
 
 editConditionData (int $condition_id)
 Hook for condition-specific payload persistence during edit(). More...
 
 deleteConditionData (int $condition_id)
 Hook for condition-specific payload cleanup during delete(). More...
 
 assertConditionDataHookImplemented (string $hook_method)
 Ensures condition-specific payload hooks are implemented if migrate() defines extra tables. More...
 
 getDatabase ()
 Returns the database interface. More...
 
 getConditionFactory ()
 Returns the factory which created this condition. More...
 
 getObjectTitleByRefId (int $ref_id)
 
 getTypeIdFromDb ()
 Returns the type ID for this condition. More...
 
 conditionTypeExistsInContext (?int $type_id)
 
 duplicateExistsInContext (?int $type_id)
 Checks whether another condition of the same type on the same object in the same learning sequence is configured identically, see isDuplicateOf(). More...
 
 getStepCommand ()
 Determines the command to use for the next step based on whether configuration is required. More...
 
 buildStep (array $additional_parameters=[], ?string $label=null, ?string $command=null,)
 Builds a bulky link for the next step in the condition setup. More...
 
 requiresConfiguration ()
 Determines whether the condition requires additional configuration. More...
 
 referencesMissingLsoItems (array $referenced_ref_ids, array $context=[])
 
 getStaticInputConfigurationConflictAffectedRefIds ()
 
 getValidLsoRefIds (array $context=[])
 
 getConfiguredStartRefId (array $context=[])
 
 getMissingReferencedLsoRefIds (array $referenced_ref_ids, array $context=[])
 
 getLso ()
 Returns the learning sequence object associated with this condition. More...
 
 getLsoItems ()
 Returns the items of the learning sequence associated with this condition. More...
 
 exportPayload ()
 Default export based on migrate() table definitions. More...
 
 importPayload (array $payload, int $new_condition_id)
 Default import for payload exported by exportPayload(). More...
 

Protected Attributes

const string NAME = ''
 
const string CREATE_COMMAND = 'createCondition'
 
const string CONFIGURE_COMMAND = 'configure'
 
ilLanguage $lang
 
Container $dic
 
int $obj_ref_id = null
 
int $lso_ref_id = null
 
int $condition_id = null
 
int $type_id = null
 
string $subtype = null
 
Factory $ui_factory
 
ConditionFactory $condition_factory = null
 Factory which created this condition, used to resolve other conditions. More...
 
array $import_mapping = []
 

Private Attributes

array $validation_messages = []
 

Detailed Description

Definition at line 43 of file AbstractCondition.php.

Member Function Documentation

◆ addValidationMessage()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::addValidationMessage ( string  $message)
protected

Definition at line 143 of file AbstractCondition.php.

143 : void
144 {
145 if ($message === '' || in_array($message, $this->validation_messages, true)) {
146 return;
147 }
148
149 $this->validation_messages[] = $message;
150 }

References $message.

Referenced by ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\applyAdditionalFormData(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\applyAdditionalFormData(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\applyAdditionalFormData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\applyAdditionalFormData(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\create(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\edit(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\setPoints(), ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\setPoints(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\setSourceRefIds(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\setSourceRefIds(), and ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\setSubset().

+ Here is the caller graph for this function:

◆ allowMultipleConditionsOfSameType()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::allowMultipleConditionsOfSameType ( )

Determines whether multiple conditions of the same type are allowed for the same object.

Override this method in child classes if multiple conditions of the same type are NOT allowed.

Returns
bool

Reimplemented in ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition, ILIAS\LearningSequence\Content\Condition\OutputCondition\AlwaysOutputCondition\AlwaysOutputCondition, and ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition.

Definition at line 691 of file AbstractCondition.php.

691 : bool
692 {
693 return true;
694 }

Referenced by ilObjLearningSequenceConditionConfigurationGUI\checkIfConditionAlreadyExistsInItem(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\create().

+ Here is the caller graph for this function:

◆ applyAdditionalFormData()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::applyAdditionalFormData ( array  $data)

Applies validated additional form data to the condition before create()/edit().

Parameters
array$data

Reimplemented in ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition, ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition, ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition, and ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition.

Definition at line 167 of file AbstractCondition.php.

167 : void
168 {
169 // If a condition exposes an additional form it MUST implement this hook
170 if (self::migrate()) {
171 $method = new \ReflectionMethod(static::class, 'applyAdditionalFormData');
172 if ($method->getDeclaringClass()->getName() === self::class) {
173 throw new \LogicException(
174 sprintf(
175 $this->lang->txt('lso_exception_additional_form_no_override'),
176 static::class
177 )
178 );
179 }
180 }
181 }

◆ assertConditionDataHookImplemented()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::assertConditionDataHookImplemented ( string  $hook_method)
protected

Ensures condition-specific payload hooks are implemented if migrate() defines extra tables.

Exceptions
ReflectionException

Definition at line 468 of file AbstractCondition.php.

468 : void
469 {
470 if (count(static::migrate()) === 0) {
471 return;
472 }
473
474 $method = new ReflectionMethod(static::class, $hook_method);
475 if ($method->getDeclaringClass()->getName() === self::class) {
476 throw new LogicException(
477 sprintf(
478 "%s defines additional migration tables but does not override %s().",
479 static::class,
480 $hook_method
481 )
482 );
483 }
484 }

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\create(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\delete(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\edit().

+ Here is the caller graph for this function:

◆ assertContextSet()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::assertContextSet ( )
protected

Asserts that the context (lso_ref_id and obj_ref_id) is set.

Exceptions
LogicExceptionif the context is not set

Definition at line 431 of file AbstractCondition.php.

431 : void
432 {
433 if ($this->lso_ref_id === null || $this->obj_ref_id === null) {
434 throw new LogicException(
435 "Context not set: lso_ref_id and obj_ref_id must be set before calling this method."
436 );
437 }
438 }

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\create(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\edit(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\setupSteps(), ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\setupSteps(), and ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\setupSteps().

+ Here is the caller graph for this function:

◆ buildStep()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::buildStep ( array  $additional_parameters = [],
?string  $label = null,
?string  $command = null 
)
protected

Builds a bulky link for the next step in the condition setup.

Parameters
array$additional_parameters,e.g.subtypes
string | null$label
string | null$command,e.g.'save' or 'configure'
Returns
Bulky
Exceptions
ilCtrlException

Definition at line 635 of file AbstractCondition.php.

639 : Bulky {
640 $this->dic->ctrl()->setParameterByClass(
641 ilObjLearningSequenceConditionsGUI::class,
642 'type_id',
643 $this->getTypeId()
644 );
645 $this->dic->ctrl()->setParameterByClass(
646 ilObjLearningSequenceConditionsGUI::class,
647 'item_ref_id',
648 (string) $this->obj_ref_id
649 );
650 $this->dic->ctrl()->setParameterByClass(
651 ilObjLearningSequenceConditionsGUI::class,
652 'ref_id',
653 (string) $this->lso_ref_id
654 );
655
656 foreach ($additional_parameters as $name => $value) {
657 $this->dic->ctrl()->setParameterByClass(
658 ilObjLearningSequenceConditionsGUI::class,
659 (string) $name,
660 (string) $value
661 );
662 }
663
664 $uri = $this->buildUrl($command ?? $this->getStepCommand());
665 $this->dic->ctrl()->clearParametersByClass(ilObjLearningSequenceConditionsGUI::class);
666
667 return $this->ui_factory->link()->bulky(
668 $this->ui_factory->symbol()->icon()->custom('', ''),
669 $label ?? $this->lang->txt($this->getName()),
670 $uri
671 );
672 }
buildUrl(string $command, bool $with_configuration_gui=false)
Builds a URL for the given command.
getStepCommand()
Determines the command to use for the next step based on whether configuration is required.

Referenced by ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\buildSubtypeStep(), ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\buildSubtypeStep(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\setupSteps().

+ Here is the caller graph for this function:

◆ buildUrl()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::buildUrl ( string  $command,
bool  $with_configuration_gui = false 
)
protected

Builds a URL for the given command.

Parameters
string$command
bool$with_configuration_gui
Returns
URI
Exceptions
ilCtrlException

Definition at line 393 of file AbstractCondition.php.

393 : URI
394 {
395 $this->dic->ctrl()->setParameterByClass(
396 ilObjLearningSequenceConditionsGUI::class,
397 'type_id',
398 $this->getTypeId()
399 );
400
401 $route = [
402 ilRepositoryGUI::class,
403 ilObjLearningSequenceGUI::class,
404 ilObjLearningSequenceContentGUI::class,
405 ilObjLearningSequenceConditionsGUI::class
406 ];
407
408 if ($command === self::CONFIGURE_COMMAND || $with_configuration_gui) {
409 if ($this->condition_id !== null) {
410 $this->dic->ctrl()->setParameterByClass(
411 \ilObjLearningSequenceConditionConfigurationGUI::class,
412 'condition_id',
413 (string) $this->condition_id
414 );
415 }
416 $route[] = \ilObjLearningSequenceConditionConfigurationGUI::class;
417 }
418
419 $url = $this->dic->ctrl()->getLinkTargetByClass(
420 $route,
421 $command
422 );
423 return new URI(ILIAS_HTTP_PATH . '/' . $url);
424 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\getTypeId().

Referenced by ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\getAdditionalForm(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getAdditionalForm(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\getAdditionalForm(), and ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\getAdditionalForm().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ check()

◆ clearValidationMessages()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::clearValidationMessages ( )

Definition at line 138 of file AbstractCondition.php.

138 : void
139 {
140 $this->validation_messages = [];
141 }

◆ conditionTypeExistsInContext()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::conditionTypeExistsInContext ( ?int  $type_id)
protected

Definition at line 549 of file AbstractCondition.php.

549 : bool
550 {
551 if ($type_id === null) {
552 throw new LogicException('Condition type ID is not set.');
553 }
554 $res = $this->getDatabase()->queryF(
555 'SELECT condition_id FROM lso_conditions WHERE lso_ref_id = %s AND obj_ref_id = %s AND type_id = %s',
556 ['integer', 'integer', 'integer'],
557 [$this->lso_ref_id, $this->obj_ref_id, $type_id]
558 );
559
560 return $this->getDatabase()->fetchAssoc($res) !== null;
561 }
foreach($_POST as $key=> $value) $res

References $res, ILIAS\LearningSequence\Content\Condition\AbstractCondition\$type_id, and ILIAS\LearningSequence\Content\Condition\AbstractCondition\getDatabase().

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ create()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::create ( bool  $is_import = false)

Saves the condition to the DB.

Parameters
bool$is_importIf true, skips createConditionData() (data will be filled by importPayload())
Exceptions
ReflectionException

Definition at line 289 of file AbstractCondition.php.

289 : void
290 {
291 if ($this->hasValidationMessages()) {
292 return;
293 }
294
295 $this->assertContextSet();
296 $this->assertConditionDataHookImplemented('createConditionData');
297 $type_id = $this->getTypeId();
298
299 if (
302 ) {
303 $this->addValidationMessage($this->lang->txt('condition_already_exists'));
304 return;
305 }
306
307 // Imports and copies fill the payload later via importPayload(), so the
308 // configuration needed for the duplicate check is not available here.
309 if (!$is_import && $this->supportsDuplicateCheck() && $this->duplicateExistsInContext($type_id)) {
310 $this->addValidationMessage($this->lang->txt('condition_already_exists'));
311 return;
312 }
313
314 $db = $this->getDatabase();
315 $condition_id = $db->nextId('lso_conditions');
316 $db->insert('lso_conditions', [
317 'condition_id' => ['integer', $condition_id],
318 'lso_ref_id' => ['integer', $this->lso_ref_id],
319 'obj_ref_id' => ['integer', $this->obj_ref_id],
320 'type_id' => ['integer', $type_id]
321 ]);
322
323 $this->condition_id = $condition_id;
324
325 // Only call createConditionData if this is NOT an import
326 // (during import, data will be filled by importPayload())
327 if (!$is_import) {
329 }
330 }
allowMultipleConditionsOfSameType()
Determines whether multiple conditions of the same type are allowed for the same object.
assertConditionDataHookImplemented(string $hook_method)
Ensures condition-specific payload hooks are implemented if migrate() defines extra tables.
assertContextSet()
Asserts that the context (lso_ref_id and obj_ref_id) is set.
createConditionData(int $condition_id)
Hook for condition-specific payload persistence during create().
duplicateExistsInContext(?int $type_id)
Checks whether another condition of the same type on the same object in the same learning sequence is...
supportsDuplicateCheck()
Whether create() and edit() check for an identically configured condition, see isDuplicateOf().

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$condition_id, ILIAS\$db, ILIAS\LearningSequence\Content\Condition\AbstractCondition\$type_id, ILIAS\LearningSequence\Content\Condition\AbstractCondition\addValidationMessage(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\allowMultipleConditionsOfSameType(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\assertConditionDataHookImplemented(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\assertContextSet(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\conditionTypeExistsInContext(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\duplicateExistsInContext(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\getDatabase(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\getTypeId(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\hasValidationMessages(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\supportsDuplicateCheck().

+ Here is the call graph for this function:

◆ createConditionData()

◆ delete()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::delete ( )

Deletes the condition from the database.

Exceptions
ReflectionException

Definition at line 370 of file AbstractCondition.php.

370 : void
371 {
372 $this->assertConditionDataHookImplemented('deleteConditionData');
373
374 $this->deleteConditionData($this->condition_id);
375
376 $this->getDatabase()->manipulateF(
377 'DELETE FROM lso_conditions WHERE condition_id = %s',
378 ['integer'],
379 [$this->condition_id]
380 );
381
382 $this->condition_id = null;
383 }
deleteConditionData(int $condition_id)
Hook for condition-specific payload cleanup during delete().

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\assertConditionDataHookImplemented(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\deleteConditionData(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\getDatabase().

+ Here is the call graph for this function:

◆ deleteConditionData()

◆ duplicateExistsInContext()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::duplicateExistsInContext ( ?int  $type_id)
protected

Checks whether another condition of the same type on the same object in the same learning sequence is configured identically, see isDuplicateOf().

The condition itself is excluded, so editing without changes is possible.

Exceptions
LogicException

Definition at line 570 of file AbstractCondition.php.

570 : bool
571 {
572 if ($type_id === null) {
573 throw new LogicException('Condition type ID is not set.');
574 }
575
576 $db = $this->getDatabase();
577 $res = $db->queryF(
578 'SELECT condition_id FROM lso_conditions WHERE lso_ref_id = %s AND obj_ref_id = %s AND type_id = %s',
579 ['integer', 'integer', 'integer'],
580 [$this->lso_ref_id, $this->obj_ref_id, $type_id]
581 );
582
583 while ($row = $db->fetchAssoc($res)) {
584 $condition_id = (int) $row['condition_id'];
585 if ($condition_id === $this->condition_id) {
586 continue;
587 }
588
589 try {
590 $other = $this->getConditionFactory()->getConditionInstanceById($condition_id);
591 } catch (ilException) {
592 continue;
593 }
594
595 if ($this->isDuplicateOf($other)) {
596 return true;
597 }
598 }
599
600 return false;
601 }
getConditionFactory()
Returns the factory which created this condition.
isDuplicateOf(AbstractCondition $other)
Determines whether this condition is configured identically to the given one.
Base class for ILIAS Exception handling.

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$condition_id, ILIAS\$db, $res, ILIAS\LearningSequence\Content\Condition\AbstractCondition\$type_id, ILIAS\LearningSequence\Content\Condition\AbstractCondition\getConditionFactory(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\getDatabase(), ILIAS\Repository\int(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\isDuplicateOf().

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\create(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\edit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ edit()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::edit ( )

Edits the condition.

Exceptions
ReflectionException

Definition at line 336 of file AbstractCondition.php.

336 : void
337 {
338 if ($this->hasValidationMessages()) {
339 return;
340 }
341
342 $this->assertContextSet();
343 $this->assertConditionDataHookImplemented('editConditionData');
344 $type_id = $this->getTypeId();
345
347 $this->addValidationMessage($this->lang->txt('condition_already_exists'));
348 return;
349 }
350
351 $this->getDatabase()->update(
352 'lso_conditions',
353 [
354 'lso_ref_id' => ['integer', $this->lso_ref_id],
355 'obj_ref_id' => ['integer', $this->obj_ref_id],
356 'type_id' => ['integer', $type_id]
357 ],
358 [
359 'condition_id' => ['integer', $this->condition_id]
360 ]
361 );
362
363 $this->editConditionData($this->condition_id);
364 }
editConditionData(int $condition_id)
Hook for condition-specific payload persistence during edit().

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$type_id, ILIAS\LearningSequence\Content\Condition\AbstractCondition\addValidationMessage(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\assertConditionDataHookImplemented(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\assertContextSet(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\duplicateExistsInContext(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\getDatabase(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\getTypeId(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\hasValidationMessages(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\supportsDuplicateCheck().

+ Here is the call graph for this function:

◆ editConditionData()

◆ export()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::export ( )
final

Definition at line 1135 of file AbstractCondition.php.

1135 : array
1136 {
1137 return $this->exportPayload();
1138 }
exportPayload()
Default export based on migrate() table definitions.

◆ exportPayload()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::exportPayload ( )
protected

Default export based on migrate() table definitions.

Returns
array<int, array{ table:string, fields:array, rows:array<int, array<string, mixed>> }>

Definition at line 990 of file AbstractCondition.php.

990 : array
991 {
992 if ($this->condition_id === null) {
993 return [];
994 }
995
996 $definitions = static::migrate();
997 if ($definitions === []) {
998 return [];
999 }
1000
1001 $db = $this->getDatabase();
1002 $result = [];
1003
1004 foreach ($definitions as $def) {
1005 $table = $def->tableName;
1006 if (!$db->tableExists($table) || !$db->tableColumnExists($table, 'condition_id')) {
1007 continue;
1008 }
1009
1010 $res = $db->queryF(
1011 'SELECT * FROM ' . $table . ' WHERE condition_id = %s',
1012 ['integer'],
1013 [$this->condition_id]
1014 );
1015
1016 $rows = [];
1017 while ($row = $db->fetchAssoc($res)) {
1018 $rows[] = $row;
1019 }
1020
1021 $result[] = [
1022 'ilias_version_numeric' => defined('ILIAS_VERSION_NUMERIC') ? (int) ILIAS_VERSION_NUMERIC : null,
1023 'table' => $table,
1024 'fields' => $def->fields,
1025 'rows' => $rows,
1026 ];
1027 }
1028
1029 return $result;
1030 }
const ILIAS_VERSION_NUMERIC

References ILIAS\$db, $res, ILIAS\Scripts\PHPStan\$rows, ILIAS_VERSION_NUMERIC, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getAdditionalDisplayInformation()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getAdditionalDisplayInformation ( )

◆ getAdditionalDisplayObjectTitles()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getAdditionalDisplayObjectTitles ( )

◆ getAdditionalForm()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getAdditionalForm ( )

◆ getConditionFactory()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getConditionFactory ( )
protected

Returns the factory which created this condition.

A condition which was not created by a factory gets its own one.

Definition at line 509 of file AbstractCondition.php.

510 {
511 return $this->condition_factory ??= new ConditionFactory(
512 $this->dic[ConditionTypes::class],
513 $this->getDatabase()
514 );
515 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\getDatabase().

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\duplicateExistsInContext().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getConditionId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getConditionId ( )
Returns
int|null

Definition at line 255 of file AbstractCondition.php.

255 : ?int
256 {
257 return $this->condition_id;
258 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$condition_id.

◆ getConfiguredStartRefId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getConfiguredStartRefId ( array  $context = [])
protected
Parameters
array<string,mixed>$context

Definition at line 822 of file AbstractCondition.php.

822 : int
823 {
824 $start_ref_id = (int) ($context['start_ref_id'] ?? 0);
825 if ($start_ref_id > 0) {
826 return $start_ref_id;
827 }
828
829 if ($this->getLsoRefId() === null) {
830 return 0;
831 }
832
833 try {
834 return (new LSOAdaptiveBoundaries($this->getDatabase()))
835 ->getBoundariesFor($this->getLso()->getId())['start_ref_id'] ?? 0;
836 } catch (LogicException) {
837 return 0;
838 }
839 }
getLso()
Returns the learning sequence object associated with this condition.

References ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ getData()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getData ( )
Returns
array

Definition at line 939 of file AbstractCondition.php.

939 : array
940 {
941 if ($this->condition_id === null) {
942 return [];
943 }
944
945 $definitions = static::migrate();
946 if ($definitions === []) {
947 return [];
948 }
949
950 $db = $this->getDatabase();
951 $result = [];
952
953 foreach ($definitions as $def) {
954 $table = $def->tableName;
955
956 if (!$db->tableExists($table) || !$db->tableColumnExists($table, 'condition_id')) {
957 continue;
958 }
959
960 $res = $db->queryF(
961 'SELECT * FROM ' . $table . ' WHERE condition_id = %s',
962 ['integer'],
963 [$this->condition_id]
964 );
965
966 $rows = [];
967 while ($row = $db->fetchAssoc($res)) {
968 $rows[] = $row;
969 }
970
971 $result[] = [
972 'table' => $table,
973 'fields' => $def->fields,
974 'rows' => $rows,
975 ];
976 }
977
978 return $result;
979 }

References ILIAS\$db, $res, and ILIAS\Scripts\PHPStan\$rows.

◆ getDatabase()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getDatabase ( )
protected

Returns the database interface.

Returns
ilDBInterface

Definition at line 491 of file AbstractCondition.php.

492 {
493 return $this->dic->database();
494 }
Interface ilDBInterface.

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\conditionTypeExistsInContext(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\create(), ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\delete(), ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\duplicateExistsInContext(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\edit(), ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\getConditionFactory(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getOutputConditionIdForItem(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getPoints(), ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\getPoints(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getSourceRefIds(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\getSourceRefIds(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\getSubset(), ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\getSubtype(), ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\getSubtype(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\getTypeIdFromDb(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\storeSourceRefIds(), and ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\storeSourceRefIds().

+ Here is the caller graph for this function:

◆ getIdentifierForClass()

static ILIAS\LearningSequence\Content\Condition\AbstractCondition::getIdentifierForClass ( string  $class)
static

Extracts the identifier for the condition type from the class name.

Parameters
string$class
Returns
string

Definition at line 609 of file AbstractCondition.php.

609 : string
610 {
611 $parts = explode('\\', $class);
612 $short_name = end($parts);
613 return preg_replace('/Condition$/', '', $short_name);
614 }

Referenced by ILIAS\LearningSequence\Content\Condition\ConditionTypeRegistry\getConditionByName(), ILIAS\LearningSequence\Content\Condition\ConditionHandler\getConditionsFromDb(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getOutputConditionIdForItem(), and ILIAS\LearningSequence\Content\Condition\ConditionTypeRegistry\validate().

+ Here is the caller graph for this function:

◆ getLso()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getLso ( )
protected

Returns the learning sequence object associated with this condition.

Returns
ilObjLearningSequence
Exceptions
LogicExceptionif the LSO ref id is not set or the object is not an ilObjLearningSequence

Definition at line 865 of file AbstractCondition.php.

866 {
867 $lso_ref_id = $this->getLsoRefId();
868 if ($lso_ref_id === null) {
869 throw new LogicException("LSO ref id is not set.");
870 }
871
873 if (!$object instanceof ilObjLearningSequence) {
874 throw new LogicException("Object is not an ilObjLearningSequence.");
875 }
876
877 return $object;
878 }
static getInstanceByRefId(int $ref_id, bool $stop_on_error=true)
get an instance of an Ilias object by reference id

References ilObjectFactory\getInstanceByRefId().

+ Here is the call graph for this function:

◆ getLsoItems()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getLsoItems ( )
protected

Returns the items of the learning sequence associated with this condition.

Returns
\LSItem[]

Definition at line 885 of file AbstractCondition.php.

885 : array
886 {
887 return $this->getLso()->getLSItems();
888 }

◆ getLsoRefId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getLsoRefId ( )
Returns
int|null

Definition at line 239 of file AbstractCondition.php.

239 : ?int
240 {
241 return $this->lso_ref_id;
242 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$lso_ref_id.

◆ getMissingReferencedLsoRefIds()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getMissingReferencedLsoRefIds ( array  $referenced_ref_ids,
array  $context = [] 
)
protected
Parameters
int[]$referenced_ref_ids
array<string,mixed>$context
Returns
int[]

Definition at line 846 of file AbstractCondition.php.

846 : array
847 {
848 $valid_ref_ids = $this->getValidLsoRefIds($context);
849 if ($valid_ref_ids === []) {
850 return [];
851 }
852
853 return array_values(array_filter(
854 array_values(array_unique(array_map('intval', $referenced_ref_ids))),
855 static fn(int $ref_id): bool => !in_array($ref_id, $valid_ref_ids, true)
856 ));
857 }

Referenced by ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\getStaticInputConfigurationIssues(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getStaticInputConfigurationIssues(), and ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\getStaticInputConfigurationIssues().

+ Here is the caller graph for this function:

◆ getName()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getName ( )
Returns
string|null

Definition at line 186 of file AbstractCondition.php.

186 : ?string
187 {
188 return static::NAME;
189 }

◆ getObjectTitleByRefId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getObjectTitleByRefId ( int  $ref_id)
protected

Definition at line 517 of file AbstractCondition.php.

517 : string
518 {
519 $obj_id = \ilObject::_lookupObjId($ref_id);
520 if ($obj_id > 0) {
521 return \ilObject::_lookupTitle($obj_id);
522 }
523
524 return sprintf('Ref-ID %d', $ref_id);
525 }
static _lookupObjId(int $ref_id)

References ilObject\_lookupObjId().

Referenced by ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\getAdditionalDisplayObjectTitles(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getAdditionalDisplayObjectTitles(), and ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\getAdditionalDisplayObjectTitles().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjRefId()

◆ getStaticInputConditionConstraints()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getStaticInputConditionConstraints ( )

Returns statically analyzable input-condition constraints.

Returns
array<int, array{kind: string, ref_ids: int[]}>

Definition at line 723 of file AbstractCondition.php.

723 : array
724 {
725 return [];
726 }

◆ getStaticInputConfigurationConflictAffectedRefIds()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getStaticInputConfigurationConflictAffectedRefIds ( )
protected

◆ getStaticInputConfigurationIssues()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getStaticInputConfigurationIssues ( array  $context = [])

Returns static input-configuration issues contributed by this condition.

Parameters
array<string,mixed>$context
Returns
StaticInputConfigurationIssue[]

Reimplemented in ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition, ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition, and ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition.

Definition at line 745 of file AbstractCondition.php.

745 : array
746 {
747 if (!$this->hasStaticInputConfigurationConflict($context)) {
748 return [];
749 }
750
751 $affected_ref_ids = $this->getStaticInputConfigurationConflictAffectedRefIds();
752 if ($affected_ref_ids === []) {
753 return [];
754 }
755
756 return [new StaticInputConfigurationIssue(
757 'static_input_configuration_conflict',
758 $affected_ref_ids,
759 details: array_map(
760 static fn(int $ref_id): StaticInputConfigurationIssueDetail => new StaticInputConfigurationIssueDetail(
761 $ref_id,
762 'lso_static_input_configuration_conflict_detail'
763 ),
764 $affected_ref_ids
765 )
766 )];
767 }
hasStaticInputConfigurationConflict(array $context=[])
Allows concrete conditions to report static misconfigurations that depend on context information such...

Referenced by ilObjLearningSequenceConditionConfigurationGUI\getStaticInputConfigurationMessages().

+ Here is the caller graph for this function:

◆ getStepCommand()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getStepCommand ( )
protected

Determines the command to use for the next step based on whether configuration is required.

Returns
string

Definition at line 621 of file AbstractCondition.php.

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\CONFIGURE_COMMAND, ILIAS\LearningSequence\Content\Condition\AbstractCondition\CREATE_COMMAND, and ILIAS\LearningSequence\Content\Condition\AbstractCondition\requiresConfiguration().

+ Here is the call graph for this function:

◆ getTypeId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getTypeId ( )

◆ getTypeIdFromDb()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getTypeIdFromDb ( )
protected

Returns the type ID for this condition.

Returns
int
Exceptions
LogicExceptionif the condition type is not registered

Definition at line 533 of file AbstractCondition.php.

533 : int
534 {
535 $res = $this->getDatabase()->queryF(
536 'SELECT type_id FROM lso_condition_types WHERE condition_name = %s',
537 ['text'],
538 [self::getIdentifierForClass(static::class)]
539 );
540 $row = $this->getDatabase()->fetchAssoc($res);
541
542 if ($row === null) {
543 throw new LogicException("Condition type is not registered.");
544 }
545
546 return (int) $row['type_id'];
547 }

References $res, and ILIAS\LearningSequence\Content\Condition\AbstractCondition\getDatabase().

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\getTypeId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValidationMessages()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getValidationMessages ( )

◆ getValidLsoRefIds()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::getValidLsoRefIds ( array  $context = [])
protected
Parameters
array<string,mixed>$context
Returns
int[]

Definition at line 792 of file AbstractCondition.php.

792 : array
793 {
794 $valid_ref_ids = $context['valid_ref_ids'] ?? null;
795 if (is_array($valid_ref_ids) && $valid_ref_ids !== []) {
796 return array_values(array_unique(array_filter(
797 array_map('intval', $valid_ref_ids),
798 static fn(int $ref_id): bool => $ref_id > 0
799 )));
800 }
801
802 if ($this->getLsoRefId() === null) {
803 return [];
804 }
805
806 try {
807 return array_values(array_unique(array_filter(
808 array_map(
809 static fn(\LSItem $item): int => $item->getRefId(),
810 $this->getLsoItems()
811 ),
812 static fn(int $ref_id): bool => $ref_id > 0
813 )));
814 } catch (LogicException) {
815 return [];
816 }
817 }
Data holding class LSItem .
Definition: LSItem.php:25
getRefId()
Definition: LSItem.php:93

References LSItem\getRefId().

+ Here is the call graph for this function:

◆ hasStaticInputConfigurationConflict()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::hasStaticInputConfigurationConflict ( array  $context = [])

Allows concrete conditions to report static misconfigurations that depend on context information such as the configured start object.

Parameters
array<string,mixed>$context

Reimplemented in ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition, ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition, and ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition.

Definition at line 734 of file AbstractCondition.php.

734 : bool
735 {
736 return false;
737 }

◆ hasValidationMessages()

◆ import()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::import ( array  $payload,
int  $new_condition_id 
)
final

Definition at line 1140 of file AbstractCondition.php.

1140 : void
1141 {
1142 $this->importPayload($payload, $new_condition_id);
1143 }
importPayload(array $payload, int $new_condition_id)
Default import for payload exported by exportPayload().

◆ importPayload()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::importPayload ( array  $payload,
int  $new_condition_id 
)
protected

Default import for payload exported by exportPayload().

$new_condition_id must already be created in lso_conditions.

The payload comes from an uploaded file and is untrusted: only the tables and columns declared in migrate() of this condition are written, and the column types are taken from these definitions, never from the payload.

Exceptions

RuntimeException if the payload references a table this condition does not own

Definition at line 1042 of file AbstractCondition.php.

1042 : void
1043 {
1044 $db = $this->getDatabase();
1045 $ref_mapping = $this->import_mapping;
1046
1047 $definitions = [];
1048 foreach (static::migrate() as $def) {
1049 $definitions[$def->tableName] = $def;
1050 }
1051
1052 foreach ($payload as $tableData) {
1053 $table = (string) ($tableData['table'] ?? '');
1054 $rows = is_array($tableData['rows'] ?? null) ? $tableData['rows'] : [];
1055
1056 if (!isset($definitions[$table])) {
1057 throw new \RuntimeException(
1058 "Table '{$table}' is not defined for condition '" . static::class . "'."
1059 );
1060 }
1061
1062 $field_map = [];
1063 foreach ($definitions[$table]->fields as $col_name => $field_def) {
1064 $field_map[$col_name] = [
1065 'type' => $field_def['type'] ?? 'text',
1066 'nullable' => !($field_def['notnull'] ?? true),
1067 ];
1068 }
1069
1070 if (!$db->tableExists($table)) {
1071 continue;
1072 }
1073
1074 $table_has_item_column = $db->tableColumnExists($table, 'item_ref_id');
1075
1076 if ($table_has_item_column && $rows === []) {
1077 throw new \RuntimeException("Payload for table '{$table}' is empty, but table requires 'item' rows.");
1078 }
1079
1080 $inserted_item_rows = 0;
1081
1082 foreach ($rows as $row) {
1083 if (!is_array($row)) {
1084 continue;
1085 }
1086
1087 $insert = [
1088 'condition_id' => ['integer', $new_condition_id],
1089 ];
1090
1091 foreach ($row as $col => $value) {
1092 $col = (string) $col;
1093
1094 // Always enforce the new condition id
1095 if ($col === 'condition_id') {
1096 continue;
1097 }
1098
1099 // Only import declared columns that actually exist in the target table
1100 if (!isset($field_map[$col]) || !$db->tableColumnExists($table, $col)) {
1101 continue;
1102 }
1103
1104 $field_info = $field_map[$col];
1105
1106 // Remap ref_id values using the container refs mapping
1107 if ($col === 'item_ref_id') {
1108 if (!isset($ref_mapping[$value])) {
1109 continue 2;
1110 }
1111
1112 $value = (int) $ref_mapping[$value];
1113 $insert['item_ref_id'] = ['integer', $value];
1114 $inserted_item_rows++;
1115 }
1116
1117 // Handle NULL values based on field definition
1118 if ($value === null) {
1119 $insert[$col] = [$field_info['type'], $field_info['nullable'] ? null : ''];
1120 continue;
1121 }
1122
1123 $insert[$col] = [$field_info['type'], $value];
1124 }
1125
1126 $db->insert($table, $insert);
1127 }
1128
1129 if ($table_has_item_column && $inserted_item_rows === 0) {
1130 throw new \RuntimeException("No valid 'item' rows imported for item-based table '{$table}'.");
1131 }
1132 }
1133 }

References ILIAS\$db, ILIAS\Scripts\PHPStan\$rows, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ isDuplicateOf()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::isDuplicateOf ( AbstractCondition  $other)

Determines whether this condition is configured identically to the given one.

create() and edit() refuse to save a condition that duplicates another condition of the same type on the same object in the same learning sequence. Override this method together with supportsDuplicateCheck() in child classes that allow multiple conditions of the same type, but not with the same configuration.

Reimplemented in ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition.

Definition at line 713 of file AbstractCondition.php.

713 : bool
714 {
715 return false;
716 }

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\duplicateExistsInContext().

+ Here is the caller graph for this function:

◆ migrate()

◆ read()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::read ( )

Reads the condition data from the database and populates the properties.

Exceptions
LogicExceptionif the condition id is not set or the condition does not exist

Definition at line 895 of file AbstractCondition.php.

895 : void
896 {
897 if ($this->condition_id === null) {
898 throw new LogicException("Condition id is not set.");
899 }
900
901 $res = $this->getDatabase()->queryF(
902 'SELECT condition_id, lso_ref_id, obj_ref_id, type_id FROM lso_conditions WHERE condition_id = %s',
903 ['integer'],
904 [$this->condition_id]
905 );
906 $row = $this->getDatabase()->fetchAssoc($res);
907
908 if ($row === null) {
909 throw new LogicException("Condition does not exist.");
910 }
911
912 $this->setLsoRefId((int) $row['lso_ref_id']);
913 $this->setObjRefId((int) $row['obj_ref_id']);
914 $this->setTypeId((int) $row['type_id']);
915 if ($this instanceof SubtypeAwareInterface) {
916 $db = $this->dic->database();
917 $table_name = "lso_c_{$this->getName()}";
918
919 if (
920 $db->tableExists($table_name)
921 && $db->tableColumnExists($table_name, 'condition_id')
922 && $db->tableColumnExists($table_name, 'subtype')
923 ) {
924 $query = $this->dic->database()->queryF(
925 "SELECT * FROM $table_name WHERE condition_id = %s",
926 ['integer'],
927 [$this->condition_id]
928 );
929 if ($record = $db->fetchObject($query)) {
930 $this->setSubtype($record->subtype);
931 }
932 }
933 }
934 }

References ILIAS\$db, and $res.

◆ referencesMissingLsoItems()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::referencesMissingLsoItems ( array  $referenced_ref_ids,
array  $context = [] 
)
protected

◆ requiresConfiguration()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::requiresConfiguration ( )
protected

◆ setConditionFactory()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::setConditionFactory ( ConditionFactory  $condition_factory)

Sets the factory which created this condition.

Conditions resolving other conditions use it, so the caches of the factory are shared.

Definition at line 500 of file AbstractCondition.php.

500 : void
501 {
502 $this->condition_factory = $condition_factory;
503 }
ConditionFactory $condition_factory
Factory which created this condition, used to resolve other conditions.

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$condition_factory.

◆ setConditionId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::setConditionId ( ?int  $condition_id)
Parameters
int | null$condition_id

Definition at line 263 of file AbstractCondition.php.

263 : void
264 {
265 $this->condition_id = $condition_id;
266 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$condition_id.

◆ setImportMapping()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::setImportMapping ( array  $mapping)

Definition at line 1145 of file AbstractCondition.php.

1145 : void
1146 {
1147 $this->import_mapping = $mapping;
1148 }

◆ setLsoRefId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::setLsoRefId ( ?int  $lso_ref_id)
Parameters
int | null$lso_ref_id

Definition at line 247 of file AbstractCondition.php.

247 : void
248 {
249 $this->lso_ref_id = $lso_ref_id;
250 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$lso_ref_id.

◆ setObjRefId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::setObjRefId ( ?int  $obj_ref_id)
Parameters
int | null$obj_ref_id

Definition at line 231 of file AbstractCondition.php.

231 : void
232 {
233 $this->obj_ref_id = $obj_ref_id;
234 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$obj_ref_id.

◆ setSubtype()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::setSubtype ( string  $subtype)
Parameters
string$subtype

Definition at line 194 of file AbstractCondition.php.

194 : void
195 {
196 if (!$this instanceof SubtypeAwareInterface) {
197 throw new LogicException(sprintf("This Condition doesn't support Subtypes: %s", static::class));
198 }
199
200 if (!in_array($subtype, $this->getSupportedSubtypes(), true)) {
201 throw new LogicException(sprintf("The subtype %s isn't supported by the condition", $subtype));
202 }
203
204 $this->subtype = $subtype;
205 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$subtype.

Referenced by ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\getSubtype(), and ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\getSubtype().

+ Here is the caller graph for this function:

◆ setTypeId()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::setTypeId ( ?int  $type_id)
Parameters
int | null$type_id

Definition at line 271 of file AbstractCondition.php.

271 : void
272 {
273 $this->type_id = $type_id;
274 }

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\$type_id.

◆ setupSteps()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::setupSteps ( )

Returns an array of steps to configure the condition.

Has to be implemented by the child class if additional steps are needed.

Returns
array
Exceptions
ilCtrlException

Reimplemented in ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition, and ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition.

Definition at line 214 of file AbstractCondition.php.

214 : array
215 {
216 $this->assertContextSet();
217 return [$this->buildStep()];
218 }
buildStep(array $additional_parameters=[], ?string $label=null, ?string $command=null,)
Builds a bulky link for the next step in the condition setup.

References ILIAS\LearningSequence\Content\Condition\AbstractCondition\assertContextSet(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\buildStep().

+ Here is the call graph for this function:

◆ supportsDuplicateCheck()

ILIAS\LearningSequence\Content\Condition\AbstractCondition::supportsDuplicateCheck ( )

Whether create() and edit() check for an identically configured condition, see isDuplicateOf().

Off by default, so types without a duplicate check do not load the other conditions of the item.

Reimplemented in ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition.

Definition at line 701 of file AbstractCondition.php.

701 : bool
702 {
703 return false;
704 }

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\create(), and ILIAS\LearningSequence\Content\Condition\AbstractCondition\edit().

+ Here is the caller graph for this function:

Field Documentation

◆ $condition_factory

ConditionFactory ILIAS\LearningSequence\Content\Condition\AbstractCondition::$condition_factory = null
protected

Factory which created this condition, used to resolve other conditions.

Definition at line 60 of file AbstractCondition.php.

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\setConditionFactory().

◆ $condition_id

int ILIAS\LearningSequence\Content\Condition\AbstractCondition::$condition_id = null
protected

Definition at line 53 of file AbstractCondition.php.

Referenced by ILIAS\LearningSequence\Content\Condition\AbstractCondition\create(), ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\createConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\LearningProgressOutputConditions\LearningProgressOutputAwareCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\OutputCondition\PointsOutputCondition\PointsOutputCondition\deleteConditionData(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\duplicateExistsInContext(), ILIAS\LearningSequence\Content\Condition\InputCondition\LearningProgressInputConditions\LearningProgressInputAwareCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\editConditionData(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\getConditionId(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getConfiguredPointsFromItem(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\getPointsFromItem(), ILIAS\LearningSequence\Content\Condition\AbstractCondition\setConditionId(), ILIAS\LearningSequence\Content\Condition\InputCondition\PointsInputCondition\PointsInputCondition\storeSourceRefIds(), and ILIAS\LearningSequence\Content\Condition\InputCondition\SubsetInputCondition\SubsetInputCondition\storeSourceRefIds().

◆ $dic

Container ILIAS\LearningSequence\Content\Condition\AbstractCondition::$dic
protected

Definition at line 50 of file AbstractCondition.php.

◆ $import_mapping

array ILIAS\LearningSequence\Content\Condition\AbstractCondition::$import_mapping = []
protected

Definition at line 67 of file AbstractCondition.php.

◆ $lang

ilLanguage ILIAS\LearningSequence\Content\Condition\AbstractCondition::$lang
protected

Definition at line 49 of file AbstractCondition.php.

◆ $lso_ref_id

int ILIAS\LearningSequence\Content\Condition\AbstractCondition::$lso_ref_id = null
protected

◆ $obj_ref_id

◆ $subtype

◆ $type_id

◆ $ui_factory

Factory ILIAS\LearningSequence\Content\Condition\AbstractCondition::$ui_factory
protected

Definition at line 56 of file AbstractCondition.php.

◆ $validation_messages

array ILIAS\LearningSequence\Content\Condition\AbstractCondition::$validation_messages = []
private

◆ CONFIGURE_COMMAND

const string ILIAS\LearningSequence\Content\Condition\AbstractCondition::CONFIGURE_COMMAND = 'configure'
protected

◆ CREATE_COMMAND

const string ILIAS\LearningSequence\Content\Condition\AbstractCondition::CREATE_COMMAND = 'createCondition'
protected

◆ NAME

const string ILIAS\LearningSequence\Content\Condition\AbstractCondition::NAME = ''
protected

Definition at line 45 of file AbstractCondition.php.


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