ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ReadingTimeManager.php
Go to the documentation of this file.
1<?php
2
20
25{
29 protected $page_manager;
33 protected $repo;
37 protected $lm_set;
38
39 public function __construct()
40 {
41 $this->lm_set = new \ilSetting("lm");
42 $this->repo = new ReadingTimeDBRepo();
43 $this->page_manager = new \ILIAS\COPage\ReadingTime\ReadingTimeManager();
44 }
45
46 public function isGloballyActivated(): bool
47 {
48 return (bool) $this->lm_set->get("est_reading_time");
49 }
50
51 public function isActivated(int $lm_id): bool
52 {
53 return $this->repo->isActivated($lm_id);
54 }
55
60 public function activate(int $lm_id, bool $activate): void
61 {
62 $is_active = $this->repo->isActivated($lm_id);
63 $this->repo->activate($lm_id, $activate);
64 if (!$is_active && $activate) {
65 $this->page_manager->setMissingReadingTimes("lm", $lm_id);
66 $this->updateReadingTime($lm_id);
67 }
68 }
69
75 public function updateReadingTime(int $lm_id): void
76 {
77 $reading_time = $this->page_manager->getParentReadingTime("lm", $lm_id);
78 $this->repo->saveReadingTime($lm_id, $reading_time);
79 }
80
81 public function loadData(array $lm_ids): void
82 {
83 $this->repo->loadData($lm_ids);
84 }
85
89 public function getReadingTime(int $lm_id): ?int
90 {
91 return $this->repo->getReadingTime($lm_id);
92 }
93}
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...