ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSurveyCronNotification.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
15  protected $lng;
16 
20  protected $tree;
21 
22 
26  public function __construct()
27  {
28  global $DIC;
29 
30  $this->lng = $DIC->language();
31  if (isset($DIC["tree"])) {
32  $this->tree = $DIC->repositoryTree();
33  }
34  }
35 
36  public function getId()
37  {
38  return "survey_notification";
39  }
40 
41  public function getTitle()
42  {
43  $lng = $this->lng;
44 
45  $lng->loadLanguageModule("survey");
46  return $lng->txt("survey_reminder_cron");
47  }
48 
49  public function getDescription()
50  {
51  $lng = $this->lng;
52 
53  $lng->loadLanguageModule("survey");
54  return $lng->txt("survey_reminder_cron_info");
55  }
56 
57  public function getDefaultScheduleType()
58  {
59  return self::SCHEDULE_TYPE_DAILY;
60  }
61 
62  public function getDefaultScheduleValue()
63  {
64  return;
65  }
66 
67  public function hasAutoActivation()
68  {
69  return true;
70  }
71 
72  public function hasFlexibleSchedule()
73  {
74  return false;
75  }
76 
77  public function run()
78  {
80  global $tree;
81 
83  $log->debug("start");
84 
85  include_once "Modules/Survey/classes/class.ilObjSurvey.php";
86 
88  $message = array();
89 
91 
92  $log->debug(var_export($tutor_res, true));
93 
94  $root = $tree->getNodeData(ROOT_FOLDER_ID);
95  foreach ($tree->getSubTree($root, false, "svy") as $svy_ref_id) {
96  $svy = new ilObjSurvey($svy_ref_id);
97  $num = $svy->checkReminder();
98  if ($num !== false) {
99  $message[] = $svy_ref_id . "(" . $num . ")";
100  $status = ilCronJobResult::STATUS_OK;
101  }
102 
103  // separate cron-job?
104  if (in_array($svy->getId(), $tutor_res)) {
105  if ($svy->sendTutorResults()) {
106  $message[] = $svy_ref_id;
107  $status = ilCronJobResult::STATUS_OK;
108  }
109  }
110  }
111 
112  $result = new ilCronJobResult();
113  $result->setStatus($status);
114 
115  if (sizeof($message)) {
116  $result->setMessage("Ref-Ids: " . implode(", ", $message));
117  $result->setCode("#" . sizeof($message));
118  }
119  $log->debug("end");
120  return $result;
121  }
122 }
$result
const ROOT_FOLDER_ID
Definition: constants.php:30
Cron job application base class.
Class ilObjSurvey.
Cron for survey notifications.
$log
Definition: result.php:15
global $DIC
Definition: goto.php:24
static getSurveysWithTutorResults()
$message
Definition: xapiexit.php:14
static getLogger($a_component_id)
Get component logger.
Cron job result data container.