ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ReadingTimeManager.php
Go to the documentation of this file.
1<?php
2
20
25{
26 protected \ILIAS\COPage\ReadingTime\ReadingTimeManager $page_manager;
28 protected \ilSetting $lm_set;
29
30 public function __construct()
31 {
32 $this->lm_set = new \ilSetting("lm");
33 $this->repo = new ReadingTimeDBRepo();
34 $this->page_manager = new \ILIAS\COPage\ReadingTime\ReadingTimeManager();
35 }
36
37 public function isGloballyActivated(): bool
38 {
39 return (bool) $this->lm_set->get("est_reading_time");
40 }
41
42 public function isActivated(int $lm_id): bool
43 {
44 return $this->repo->isActivated($lm_id);
45 }
46
51 public function activate(int $lm_id, bool $activate): void
52 {
53 $is_active = $this->repo->isActivated($lm_id);
54 $this->repo->activate($lm_id, $activate);
55 if (!$is_active && $activate) {
56 $this->page_manager->setMissingReadingTimes("lm", $lm_id);
57 $this->updateReadingTime($lm_id);
58 }
59 }
60
66 public function updateReadingTime(int $lm_id): void
67 {
68 $reading_time = $this->page_manager->getParentReadingTime("lm", $lm_id);
69 $this->repo->saveReadingTime($lm_id, $reading_time);
70 }
71
72 public function loadData(array $lm_ids): void
73 {
74 $this->repo->loadData($lm_ids);
75 }
76
80 public function getReadingTime(int $lm_id): ?int
81 {
82 return $this->repo->getReadingTime($lm_id);
83 }
84}
updateReadingTime(int $lm_id)
Gets the calculated reading time from all pages of the LM and stores it (redundantly for quick access...
activate(int $lm_id, bool $activate)
Set activation.
ILIAS COPage ReadingTime ReadingTimeManager $page_manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...