Skip to content

Commit

Permalink
Tracking: personal learning progress shows courses without period as …
Browse files Browse the repository at this point in the history
…current, titles as links
  • Loading branch information
schmitz-ilias committed Dec 9, 2024
1 parent b2f153b commit a82d785
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
use ILIAS\UI\URLBuilder;
use ILIAS\Data\Factory as DataFactory;
use ILIAS\UI\Component\Item\Standard as UIStandardItem;
use ILIAS\StaticURL\Services as StaticURL;
use ILIAS\Data\URI as URI;

/**
* @ilCtrl_IsCalledBy ilLPPersonalGUI: ilDashboardGUI
Expand Down Expand Up @@ -60,11 +62,13 @@ class ilLPPersonalGUI
protected RefineryFactory $refinery;
protected DataFactory $data_factory;
protected ilAccessHandler $access;
protected StaticURL $static_url;
protected ViewFactoryInterface $tracking_view;

public function __construct()
{
global $DIC;

$this->ui = $DIC->ui();
$this->ctrl = $DIC->ctrl();
$this->user = $DIC->user();
Expand All @@ -73,6 +77,7 @@ public function __construct()
$this->refinery = $DIC->refinery();
$this->access = $DIC->access();
$this->data_factory = new DataFactory();
$this->static_url = $DIC['static_url'];
$this->tracking_view = new ViewFactory();
$this->lng->loadLanguageModule("trac");
}
Expand Down Expand Up @@ -167,7 +172,8 @@ protected function buildPanelItems(
->withProperty($this->lng->txt(self::LNG_VAR_PROPERTY_CRS_ONLINE), $offline_str);
$item = $this->tracking_view->renderer()->service()->standardItem(
$combinedInfo->getObjectInfo(),
$property_builder->getList()
$property_builder->getList(),
$this->buildLinkToCourse($obj_id)
);
if (
$combinedInfo->getLPInfo()->getLPMode() !== ilLPObjSettings::LP_MODE_UNDEFINED &&
Expand All @@ -187,28 +193,28 @@ protected function isPresentable(
ilDateTime|null $crs_end
): bool {
$now = new ilDateTime(time(), IL_CAL_UNIX);
$crs_start = is_null($crs_start) ? $crs_end : $crs_start;
$crs_end = is_null($crs_end) ? $crs_start : $crs_end;
$dates_set = !is_null($crs_start) && !is_null($crs_end);
$crs_start = (is_null($crs_start) || $crs_start->isNull()) ? $now : $crs_start;
$crs_end = (is_null($crs_end) || $crs_end->isNull()) ? $now : $crs_end;
if ($presentation_mode === self::PRESENTATION_OPTION_ALL) {
return true;
}
// courses without end are never in the past
if (
$dates_set &&
$presentation_mode === self::PRESENTATION_OPTION_PAST &&
ilDateTime::_after($now, $crs_end)
) {
return true;
}
// courses without start are never in the future
if (
$dates_set &&
$presentation_mode === self::PRESENTATION_OPTION_FUTURE &&
ilDateTime::_before($now, $crs_start)
) {
return true;
}
// courses without start and end are always current
// courses without start or end are current if their end/start is not in the past/future
if (
$dates_set &&
$presentation_mode === self::PRESENTATION_OPTION_CURRENT &&
ilDateTime::_within($now, $crs_start, $crs_end)
) {
Expand Down Expand Up @@ -241,4 +247,16 @@ protected function hasReadAccess(int $obj_id): bool
}
return false;
}

protected function buildLinkToCourse(int $obj_id): ?URI
{
$ref_ids = ilObject::_getAllReferences($obj_id);
if (count($ref_ids) === 0) {
return null;
}
return $this->static_url->builder()->build(
'crs',
$this->data_factory->refId((int) current($ref_ids))
);
}
}
10 changes: 8 additions & 2 deletions components/ILIAS/Tracking/classes/View/Renderer/Renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
use ILIAS\UI\Component\Symbol\Icon\Standard as UIStandardIcon;
use ilLPObjSettings;
use ilLPStatus;
use ILIAS\Data\URI;

class Renderer implements RendererInterface
{
Expand Down Expand Up @@ -59,7 +60,8 @@ public function fixedSizeProgressMeter(

public function standardItem(
ObjectDataInterface $object_info,
PropertyListInterface $property_list
PropertyListInterface $property_list,
?URI $title_link = null
): UIStandardItem {
$properties = [];
foreach ($property_list as $property) {
Expand All @@ -70,7 +72,11 @@ public function standardItem(
$object_info->getType() . " Icon",
UIIconIcon::MEDIUM
);
return $this->ui->factory()->item()->standard($object_info->getTitle())
$title = $object_info->getTitle();
if ($title_link !== null) {
$title = $this->ui->factory()->link()->standard($title, (string) $title_link);
}
return $this->ui->factory()->item()->standard($title)
->withProperties($properties)
->withDescription($object_info->getDescription())
->withLeadIcon($icon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,21 @@
use ILIAS\Tracking\View\PropertyList\PropertyListInterface;
use ILIAS\UI\Component\Item\Standard as UIStandardItem;
use ILIAS\UI\Component\Chart\ProgressMeter\Standard as UIStandardProgressMeter;
use ILIAS\Data\URI;

interface RendererInterface
{
public function standardProgressMeter(
LPInterface $lp_info
): UIStandardProgressMeter;

/**
* The optional link is applied to the title.
*/
public function standardItem(
ObjectDataInterface $object_info,
PropertyListInterface $property_list
PropertyListInterface $property_list,
?URI $title_link = null
): UIStandardItem;

public function fixedSizeProgressMeter(
Expand Down

0 comments on commit a82d785

Please sign in to comment.