Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,8 @@ protected function isLOMAvailable(): bool
'cmix',
'mep',
'mep:mpg',
'wiki'
'wiki',
'lso'
])
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\LearningSequence\Setup;

use ILIAS\MetaData\Setup\InitLOMForObjectTypeMigration;

class InitLOMForLearningSequenceMigration extends InitLOMForObjectTypeMigration
{
protected function objectType(): string
{
return 'lso';
}

public function getLabel(): string
{
return 'Creates LOM sets for pre-existing Learning Sequences.';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function buildForm(
protected function buildFormElements(
ilObjLearningSequence $lso,
ILIAS\UI\Component\Input\Factory $if
) {
): array {
$txt = fn($id) => $this->lng->txt($id);
$shift_trafo = $this->refinery->custom()->transformation(
static fn(array $v) => current($v)
Expand Down Expand Up @@ -154,9 +154,38 @@ protected function buildFormElements(
$this->refinery->always(false)
])
);
// Metadata
$custom_md = $if->field()->checkbox($this->lng->txt('obj_tool_setting_custom_metadata'))
->withValue((bool) ilContainer::_lookupContainerSetting(
$lso->getId(),
ilObjectServiceSettingsGUI::CUSTOM_METADATA,
'0'
))
->withAdditionalTransformation(
$this->refinery->byTrying([
$this->refinery->kindlyTo()->bool(),
$this->refinery->always(false)
])
);
//Taxonomies
$taxonomies = $if->field()->checkbox($this->lng->txt('obj_tool_setting_taxonomies'))
->withValue((bool) ilContainer::_lookupContainerSetting(
$lso->getId(),
ilObjectServiceSettingsGUI::TAXONOMIES,
'0'
))
->withAdditionalTransformation(
$this->refinery->byTrying([
$this->refinery->kindlyTo()->bool(),
$this->refinery->always(false)
])
);

$section_additional = $if->field()->section(
[
self::PROP_GALLERY => $gallery
self::PROP_GALLERY => $gallery,
ilObjectServiceSettingsGUI::CUSTOM_METADATA => $custom_md,
ilObjectServiceSettingsGUI::TAXONOMIES => $taxonomies
],
$txt('obj_features')
);
Expand Down Expand Up @@ -212,10 +241,21 @@ protected function update(): ?string
$lso = $this->obj;
$obj_props = $lso->getObjectProperties();

$obj_props->storePropertyTitleAndDescription($data['object']);
list($online, $availability) = $data['online'];
$obj_props->storePropertyIsOnline($online);
$lso->storeAvailabilityPeriod($availability);
ilContainer::_writeContainerSetting(
$lso->getId(),
ilObjectServiceSettingsGUI::CUSTOM_METADATA,
$values['additional'][ilObjectServiceSettingsGUI::CUSTOM_METADATA] ? '1' : '0'
);
ilContainer::_writeContainerSetting(
$lso->getId(),
ilObjectServiceSettingsGUI::TAXONOMIES,
$values['additional'][ilObjectServiceSettingsGUI::TAXONOMIES] ? '1' : '0'
);

$status = ilObjLearningSequenceAccess::isOffline($lso->getRefId());
$lso->getObjectProperties()->storePropertyIsOnline(
new Online(! $status)
);

$settings = $lso->getLSSettings()
->withMembersGallery($data['additional'][self::PROP_GALLERY]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,33 @@ public function getXmlExportTailDependencies(string $a_entity, string $a_target_
"entity" => "common",
"ids" => $a_ids
];

// metadata
$md_ids = [];
foreach ($a_ids as $id) {
$md_ids[] = $id . ":0:lso";
}
$res[] = [
"component" => "components/ILIAS/MetaData",
"entity" => "md",
"ids" => $md_ids
];

// taxonomies
$tax_ids = [];
foreach ($a_ids as $id) {
$t_ids = ilObjTaxonomy::getUsageOfObject((int) $id);
foreach ($t_ids as $t_id) {
$tax_ids[$t_id] = $t_id;
}
}
if ($tax_ids !== []) {
$res[] = [
"component" => "components/ILIAS/Taxonomy",
"entity" => "tax",
"ids" => $tax_ids
];
}
}

// container pages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,26 @@ public function importXmlRepresentation(string $a_entity, string $a_id, string $
LSOPageType::EXTRO->value . ':' . $a_id,
LSOPageType::EXTRO->value . ':' . (string) $this->obj->getId()
);

$a_mapping->addMapping(
'components/ILIAS/MetaData',
'md',
$a_id . ':0:lso',
(string) $this->obj->getId() . ':0:lso'
);

$a_mapping->addMapping(
"components/ILIAS/Taxonomy",
"tax_item",
"lso:obj:" . $a_id,
(string) $this->obj->getId()
);
$a_mapping->addMapping(
"components/ILIAS/Taxonomy",
"tax_item_obj_id",
"lso:obj:" . $a_id,
(string) $this->obj->getId()
);
}

public function finalProcessing(ilImportMapping $a_mapping): void
Expand All @@ -77,6 +97,20 @@ public function finalProcessing(ilImportMapping $a_mapping): void
$new_obj_id = $this->obj->getId();
ilPageObject::_writeParentId($pg_type, (int) $new_pg_id, (int) $new_obj_id);
}

// taxonomy usages
$maps = $a_mapping->getMappingsOfEntity("components/ILIAS/LearningSequence", "lso");
foreach ($maps as $old => $new) {
if ($old !== "new_id" && (int) $old > 0) {
$new_tax_ids = $a_mapping->getMapping("components/ILIAS/Taxonomy", "tax_usage_of_obj", (string) $old);
if ($new_tax_ids !== "") {
$tax_ids = explode(":", (string) $new_tax_ids);
foreach ($tax_ids as $tid) {
ilObjTaxonomy::saveUsage((int) $tid, (int) $new);
}
}
}
}
}

public function afterContainerImportProcessing(ilImportMapping $mapping): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ public function create(): int
if (!$id) {
return 0;
}
$this->ref_props = $this->repo_ref_props->getFor(null);

$this->createMetaData();
$this->raiseEvent(self::E_CREATE);

return $this->getId();
Expand All @@ -108,13 +109,17 @@ public function update(): bool
if (!parent::update()) {
return false;
}

$this->updateMetaData();
$this->raiseEvent(self::E_UPDATE);

return true;
}

public function delete(): bool
{
$this->deleteMetaData();

if (!parent::delete()) {
return false;
}
Expand All @@ -123,6 +128,8 @@ public function delete(): bool
$this->getSettingsDB()->delete($this->getId());
$this->getStateDB()->deleteFor($this->getRefId());

ilObjTaxonomy::deleteUsagesOfObject($this->getId());

$this->raiseEvent(self::E_DELETE);

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@
* @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjSurveyGUI
* @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjFileUploadHandlerGUI
* @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjLearningSequenceEditIntroGUI, ilObjLearningSequenceEditExtroGUI
* @ilCtrl_Calls ilObjLearningSequenceGUI: ilObjectMetaDataGUI, ilTaxonomySettingsGUI, ilObjTaxonomyGUI
*/
class ilObjLearningSequenceGUI extends ilContainerGUI implements ilCtrlBaseClassInterface
class ilObjLearningSequenceGUI extends ilContainerGUI implements ilCtrlBaseClassInterface, \ILIAS\Taxonomy\Settings\ModifierGUIInterface
{
protected \ILIAS\Taxonomy\Service $taxonomy;
public const CMD_VIEW = "view";
public const CMD_LEARNER_VIEW = "learnerView";
public const CMD_CONTENT = "manageContent";
Expand Down Expand Up @@ -228,6 +230,7 @@ public function __construct()
$this->post_wrapper = $DIC->http()->wrapper()->post();
$this->refinery = $DIC->refinery();
$this->content_style = $DIC->contentStyle();
$this->taxonomy = $DIC->taxonomy();

$this->help->setScreenIdComponent($this->type);
$this->lng->loadLanguageModule($this->type);
Expand Down Expand Up @@ -292,6 +295,7 @@ public function executeCommand(): void
}

$this->tabs->activateTab(self::TAB_SETTINGS);
$this->setEditTabs();
$this->ctrl->forwardCommand($this->getGUISettings());
break;
case "ilobjlearningsequencecontentgui":
Expand Down Expand Up @@ -350,6 +354,23 @@ public function executeCommand(): void
$gui = $this->object->getLocalDI()["gui.learner.lp"];
$this->ctrl->forwardCommand($gui);
break;
case "ilobjectmetadatagui":
$this->tabs->activateTab("meta_data");
$mdgui = new ilObjectMetaDataGUI($this->object);
$this->ctrl->forwardCommand($mdgui);
break;
case "iltaxonomysettingsgui":
case "ilobjtaxonomygui":
$this->tabs->activateTab(self::TAB_SETTINGS);
$this->setEditTabs("taxonomy");
$tax_gui = $this->taxonomy->gui()->getSettingsGUI(
$this->object->getId(),
$this->lng->txt("cntr_tax_settings_info"),
true,
$this
);
$this->ctrl->forwardCommand($tax_gui);
break;
case "ilobjlearningsequenceeditintrogui":
$which_page = LSOPageType::INTRO;
$which_tab = self::TAB_EDIT_INTRO;
Expand Down Expand Up @@ -519,7 +540,9 @@ public function addToNavigationHistory(): void

protected function getGUIInfo(): ilInfoScreenGUI
{
return new ilInfoScreenGUI($this);
$info = new ilInfoScreenGUI($this);
$info->addMetaDataSections($this->object->getId(), 0, 'lso');
return $info;
}

protected function getGUIPermissions(): ilPermissionGUI
Expand Down Expand Up @@ -666,6 +689,40 @@ public function unparticipate(): void
$this->ctrl->redirectByClass('ilObjLearningSequenceLearnerGUI', self::CMD_LEARNER_VIEW);
}

protected function getSubServices(): array
{
$subs = [
ilObjectServiceSettingsGUI::CUSTOM_METADATA,
ilObjectServiceSettingsGUI::TAXONOMIES,
ilObjectServiceSettingsGUI::CALENDAR_CONFIGURATION,
ilObjectServiceSettingsGUI::TAG_CLOUD,
ilObjectServiceSettingsGUI::BADGES,
ilObjectServiceSettingsGUI::SKILLS
];

return $subs;
}

protected function setEditTabs(string $active_tab = "settings_misc"): void
{
$this->tabs->addSubTab(
"settings_misc",
$this->lng->txt("general"),
$this->ctrl->getLinkTargetByClass("ilobjlearningsequencesettingsgui", "settings")
);

if (ilContainer::_lookupContainerSetting(
$this->object->getId(),
ilObjectServiceSettingsGUI::TAXONOMIES,
'0'
)) {
$this->taxonomy->gui()->addSettingsSubTab($this->object->getId());
}

$this->tabs->activateTab(self::TAB_SETTINGS);
$this->tabs->activateSubTab($active_tab);
}

protected function getTabs(): void
{
if ($this->checkAccess("read")) {
Expand All @@ -691,6 +748,17 @@ protected function getTabs(): void
$this->lng->txt(self::TAB_SETTINGS),
$this->getLinkTarget(self::CMD_SETTINGS)
);

// metadata
$mdgui = new ilObjectMetaDataGUI($this->object);
$mdtab = $mdgui->getTab();
if ($mdtab) {
$this->tabs->addTab(
"meta_data",
$this->lng->txt("meta_data"),
$mdtab
);
}
}

if ($this->checkAccess("read")) {
Expand Down Expand Up @@ -773,6 +841,16 @@ protected function addSubTabsForContent(string $active): void
$this->tabs->activateSubTab($active);
}

public function getProperties(int $tax_id): array
{
return [];
}

public function getActions(int $tax_id): array
{
return [];
}

protected function checkAccess(string $which): bool
{
return $this->access->checkAccess($which, "", $this->ref_id);
Expand Down Expand Up @@ -880,6 +958,7 @@ function (array $c, ProfileData $v) use ($a_data, $udfs): array {
$field_id = $field->getIdentifier();
$c[$v->getId()]['udf_' . $field_id] = (string) $v->getAdditionalFieldByIdentifier($field_id);
}
return $c;
},
[]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

declare(strict_types=1);

declare(strict_types=1);

class ilObjLearningSequenceListGUI extends ilObjectListGUI
{
public function __construct()
Expand Down
Loading
Loading