ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSurveyCronNotification.php
Go to the documentation of this file.
1<?php
2
22
30{
31 protected const MAX_MESSAGE_LENGTH = 397;
32
33 protected ilLanguage $lng;
34 protected ilTree $tree;
35
36 public function __construct()
37 {
38 global $DIC;
39
40 $this->lng = $DIC->language();
41 if (isset($DIC["tree"])) {
42 $this->tree = $DIC->repositoryTree();
43 }
44 }
45
46 public function getId(): string
47 {
48 return "survey_notification";
49 }
50
51 public function getTitle(): string
52 {
54
55 $lng->loadLanguageModule("survey");
56 return $lng->txt("survey_reminder_cron");
57 }
58
59 public function getDescription(): string
60 {
62
63 $lng->loadLanguageModule("survey");
64 return $lng->txt("survey_reminder_cron_info");
65 }
66
68 {
69 return JobScheduleType::DAILY;
70 }
71
72 public function getDefaultScheduleValue(): ?int
73 {
74 return null;
75 }
76
77 public function hasAutoActivation(): bool
78 {
79 return true;
80 }
81
82 public function hasFlexibleSchedule(): bool
83 {
84 return false;
85 }
86
87 public function run(): JobResult
88 {
89 global $tree;
90
92 $log->debug("start");
93
94 $status = JobResult::STATUS_NO_ACTION;
95 $message = array();
96
98 foreach ($tree->getSubTree($root, false, ["svy"]) as $svy_ref_id) {
99 $svy = new ilObjSurvey($svy_ref_id);
100 $num = $svy->checkReminder();
101 if (!is_null($num)) {
102 $message[] = $svy_ref_id . "(" . $num . ")";
103 $status = JobResult::STATUS_OK;
104 }
105 }
106
107 $result = new JobResult();
108 $result->setStatus($status);
109
110 if (count($message)) {
111 $full_msg = "Ref-Ids: " . implode(", ", $message) . ' / ' . "#" . count($message);
112
113 if (mb_strlen($full_msg) > self::MAX_MESSAGE_LENGTH) {
114 $short_msg = mb_substr($full_msg, 0, self::MAX_MESSAGE_LENGTH) . '...';
115 $log->info("Notification message was truncated to fit DB limit. Full message: \"$full_msg\"");
116 } else {
117 $short_msg = $full_msg;
118 }
119
120 $result->setMessage($short_msg);
121 }
122
123 $log->debug("end");
124 return $result;
125 }
126}
language handling
loadLanguageModule(string $a_module)
Load language module.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static getLogger(string $a_component_id)
Get component logger.
Cron for survey notifications (reminder to paricipate in the survey)
hasAutoActivation()
Is to be activated on "installation", does only work for ILIAS core cron jobs.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getNodeData(int $a_node_id, ?int $a_tree_pk=null)
get all information of a node.
getSubTree(array $a_node, bool $a_with_data=true, array $a_type=[])
get all nodes in the subtree under specified node
const ROOT_FOLDER_ID
Definition: constants.php:32
$log
Definition: ltiresult.php:34
global $DIC
Definition: shib_login.php:26
$message
Definition: xapiexit.php:31