19 declare(strict_types=1);
42 string $certificatePath,
43 bool $hasAdditionalElements,
61 if (null === $settingsFormFactory) {
65 $hasAdditionalElements,
70 $placeholderDescriptionObject
75 if (null === $learningProgressObject) {
80 if (null === $trackingHelper) {
85 if (null === $objectHelper) {
90 if (null === $lpHelper) {
101 if (null === $setting) {
119 $form = $this->settingsFormFactory->createForm($certificateGUI);
123 $mode = $objectLearningProgressSettings->
getMode();
129 $form->addItem($formSection);
131 $exp = $subitems->getExplorerGUI();
132 $exp->setSkipRootNode(
true);
133 $exp->setRootId($this->
object->getRefId());
134 $exp->setTypeWhiteList($this->getLPTypes($this->
object->getRefId()));
138 $subitems->setTitleModifier(
function (
$id) use ($objectHelper, $lpHelper) {
147 $mode = $olp->getModeText($olp->getCurrentMode());
149 if (in_array($olp->getCurrentMode(), $invalid_modes,
true)) {
150 $mode =
'<strong>' . $mode .
'</strong>';
152 return $objectHelper->
lookupTitle($obj_id) .
' (' . $mode .
')';
155 $subitems->setRequired(
true);
156 $form->addItem($subitems);
166 public function save(array $formFields): void
170 $titlesOfObjectsWithInvalidModes = [];
171 $refIds = $formFields[
'subitems'] ?? [];
173 foreach ($refIds as
$refId) {
174 $objectId = $this->objectHelper->lookupObjId((
int) $refId);
175 $learningProgressObject = $this->lpHelper->
getInstance($objectId);
177 if (in_array($currentMode, $invalidModes,
true)) {
178 $titlesOfObjectsWithInvalidModes[] = $this->objectHelper->lookupTitle($objectId);
182 if (count($titlesOfObjectsWithInvalidModes) > 0) {
184 $this->
language->txt(
'certificate_learning_progress_must_be_active'),
185 implode(
', ', $titlesOfObjectsWithInvalidModes)
191 'cert_subitems_' . $this->
object->getId(),
192 json_encode($formFields[
'subitems'] ?? [], JSON_THROW_ON_ERROR)
198 $formFields = $this->settingsFormFactory->fetchFormFieldData($content);
200 $formFields[
'subitems'] = json_decode($this->setting->get(
201 'cert_subitems_' . $this->object->getId(),
202 json_encode([], JSON_THROW_ON_ERROR)
203 ),
true, 512, JSON_THROW_ON_ERROR);
204 if ($formFields[
'subitems'] ===
'null' || $formFields[
'subitems'] === null) {
205 $formFields[
'subitems'] = [];
214 private function getLPTypes(
int $a_parent_ref_id): array
218 $root = $this->tree->getNodeData($a_parent_ref_id);
219 $sub_items = $this->tree->getSubTree($root);
220 array_shift($sub_items);
222 foreach ($sub_items as $node) {
223 if ($this->lpHelper->isSupportedObjectType($node[
'type'])) {
224 $class = $this->lpHelper->getTypeClass($node[
'type']);
226 $modes = $class::getDefaultModes($this->trackingHelper->enabledLearningProgress());
228 if (count($modes) > 1) {
229 $result[] = $node[
'type'];
248 if (!$this->trackingHelper->enabledLearningProgress()) {
262 return $invalid_modes;
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
const LP_MODE_MANUAL_BY_TUTOR
const LP_MODE_COLLECTION_MANUAL
const LP_MODE_COLLECTION_TLT
GUI class to create PDF certificates.
lookupTitle(int $objectId)
const LP_MODE_DEACTIVATED
const LP_MODE_COLLECTION_MOBS
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static getInstance(int $obj_id)