ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilSurveyParticipantsTableGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
25 {
26  protected Participants\InvitationsManager $invitation_manager;
27  protected \ILIAS\Survey\InternalService $survey_service;
28 
29  public function __construct(
30  object $a_parent_obj,
31  string $a_parent_cmd,
32  ilObjSurvey $a_svy
33  ) {
34  global $DIC;
35 
36  $this->survey_service = $DIC->survey()->internal();
37 
38  $this->lng = $DIC->language();
39  $this->ctrl = $DIC->ctrl();
40  $lng = $DIC->language();
41  $ilCtrl = $DIC->ctrl();
42  $this->invitation_manager = $this
43  ->survey_service
44  ->domain()
45  ->participants()
46  ->invitations();
47 
48 
49  parent::__construct($a_parent_obj, $a_parent_cmd);
50 
51  $this->setTitle($lng->txt("svy_anonymous_participants_svy"));
52 
53  $this->addColumn($this->lng->txt("name"), "name");
54  $this->addColumn($this->lng->txt("login"), "login");
55  // $this->addColumn($this->lng->txt("gender"), "gender");
56  $this->addColumn($this->lng->txt("status"), "status");
57 
58  $this->setRowTemplate("tpl.il_svy_svy_participants_row.html", "Modules/Survey/Participants");
59  $this->setFormAction($ilCtrl->getFormAction($a_parent_obj, $a_parent_cmd));
60  $this->setDefaultOrderField("name");
61 
62  $this->getItems($a_svy);
63  }
64 
65  protected function getItems(ilObjSurvey $a_svy): void
66  {
67  $lng = $this->lng;
68 
69  $data = array();
70 
71  foreach ($a_svy->getSurveyParticipants(null, true) as $user) {
72  if ($user["finished"]) {
73  $status = $lng->txt("survey_results_finished");
74  } else {
75  $status = $lng->txt("survey_results_started");
76  }
77 
78  $data[$user["login"]] = array(
79  "name" => $user["sortname"],
80  "login" => $user["login"],
81  "status" => $status
82  );
83  }
84 
85  foreach ($this->invitation_manager->getAllForSurvey($a_svy->getSurveyId()) as $user_id) {
86  $user = ilObjUser::_lookupName($user_id);
87  if ($user["login"] &&
88  !array_key_exists($user["login"], $data)) {
89  $data[$user["login"]] = array(
90  "name" => $user["lastname"] . ", " . $user["firstname"],
91  "login" => $user["login"],
92  "status" => $lng->txt("survey_results_not_started")
93  );
94  }
95  }
96 
97  $this->setData($data);
98  }
99 
100  protected function fillRow(array $a_set): void
101  {
102  $this->tpl->setVariable("NAME", $a_set["name"]);
103  $this->tpl->setVariable("LOGIN", $a_set["login"]);
104  $this->tpl->setVariable("STATUS", $a_set["status"]);
105  }
106 }
setData(array $a_data)
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...
setFormAction(string $a_form_action, bool $a_multipart=false)
static _lookupName(int $a_user_id)
lookup user name
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getSurveyParticipants(?array $finished_ids=null, bool $force_non_anonymous=false, bool $include_invites=false)
Participants InvitationsManager $invitation_manager
ilLanguage $lng
global $DIC
Definition: feed.php:28
setDefaultOrderField(string $a_defaultorderfield)
__construct(object $a_parent_obj, string $a_parent_cmd, ilObjSurvey $a_svy)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
__construct(Container $dic, ilPlugin $plugin)
addColumn(string $a_text, string $a_sort_field="", string $a_width="", bool $a_is_checkbox_action_column=false, string $a_class="", string $a_tooltip="", bool $a_tooltip_with_html=false)