ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilSurveySyncTableGUI.php
Go to the documentation of this file.
1<?php
2
24{
27 protected ilTree $tree;
28
29 public function __construct(
30 object $a_parent_obj,
31 string $a_parent_cmd,
32 SurveyQuestion $a_question
33 ) {
34 global $DIC;
35
36 $this->ctrl = $DIC->ctrl();
37 $this->lng = $DIC->language();
38 $this->access = $DIC->access();
39 $this->tree = $DIC->repositoryTree();
40 $ilCtrl = $DIC->ctrl();
41 $lng = $DIC->language();
42
43 $this->question = $a_question;
44
45 parent::__construct($a_parent_obj, $a_parent_cmd);
46
47 $this->setId("il_svy_spl_sync");
48
49 $this->setTitle($this->question->getTitle());
50 $this->setDescription($lng->txt("survey_sync_question_copies_info"));
51
52 $this->addCommandButton("synccopies", $lng->txt("survey_sync_question_copies"));
53 $this->addCommandButton("cancelsync", $lng->txt("cancel"));
54
55 // $this->setSelectAllCheckbox("id[]");
56 $this->addColumn("", "", 1);
57 $this->addColumn($lng->txt("title"), "");
58
59 $this->setDefaultOrderField("title");
60 $this->setDefaultOrderDirection("asc");
61
62 $this->setFormAction($ilCtrl->getFormAction($a_parent_obj));
63 $this->setRowTemplate("tpl.il_svy_qpl_sync.html", "components/ILIAS/SurveyQuestionPool");
64
65 $this->importData();
66 }
67
71 protected function importData(): void
72 {
73 $ilAccess = $this->access;
75
76 $table_data = array();
77 foreach ($this->question->getCopyIds(true) as $survey_obj_id => $questions) {
78 $survey_id = new ilObjSurvey($survey_obj_id, false);
79 $survey_id->loadFromDb();
80 $survey_id = $survey_id->getSurveyId();
81
82 $ref_ids = ilObject::_getAllReferences($survey_obj_id);
83 $message = "";
84
85 // check permissions for "parent" survey
86 $can_write = false;
87 if (!ilObjSurvey::_hasDatasets($survey_id)) {
88 foreach ($ref_ids as $ref_id) {
89 if ($ilAccess->checkAccess("edit", "", $ref_id)) {
90 $can_write = true;
91 break;
92 }
93 }
94
95 if (!$can_write) {
96 $message = $lng->txt("survey_sync_insufficient_permissions");
97 }
98 } else {
99 $message = $lng->txt("survey_has_datasets_warning");
100 }
101
102 $survey_title = ilObject::_lookupTitle($survey_obj_id);
103 $survey_path = $this->buildPath($ref_ids);
104
105 foreach ($questions as $question_id) {
106 $title = SurveyQuestion::_getTitle($question_id);
107
108 if (!$can_write) {
109 $question_id = null;
110 }
111
112 $table_data[] = array(
113 "id" => $question_id,
114 "title" => $title,
115 "path" => $survey_path,
116 "message" => $message
117 );
118 }
119 }
120
121 $this->setData($table_data);
122 }
123
124 protected function fillRow(array $a_set): void
125 {
127
128 $this->tpl->setVariable("TXT_PATH", $lng->txt("path"));
129
130 if ($a_set["message"]) {
131 $this->tpl->setCurrentBlock("message");
132 $this->tpl->setVariable("TXT_MESSAGE", $a_set["message"]);
133 $this->tpl->parseCurrentBlock();
134 }
135
136 // question
137 if ($a_set["id"]) {
138 $this->tpl->setCurrentBlock("checkbox");
139 $this->tpl->setVariable("ID", $a_set["id"]);
140 $this->tpl->parseCurrentBlock();
141 }
142
143
144 $this->tpl->setVariable("TITLE", $a_set["title"]);
145 $this->tpl->setVariable("VALUE_PATH", implode("<br />", $a_set["path"]));
146 }
147
151 protected function buildPath(array $ref_ids): array
152 {
154
155 $result = [];
156 foreach ($ref_ids as $ref_id) {
157 $path = "...";
158
159 $counter = 0;
160 $path_full = $tree->getPathFull($ref_id);
161 if (count($path_full)) {
162 foreach ($path_full as $data) {
163 if (++$counter < (count($path_full) - 1)) {
164 continue;
165 }
166 $path .= " &raquo; ";
167 if ($ref_id != $data['ref_id']) {
168 $path .= $data['title'];
169 } else {
170 $path .= ('<a target="_top" href="' .
171 ilLink::_getLink($data['ref_id'], $data['type']) . '">' .
172 $data['title'] . '</a>');
173 }
174 }
175 }
176
177 $result[] = $path;
178 }
179 return $result;
180 }
181}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getTitle(int $question_id)
Returns the question title of a question with a given id.
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 _hasDatasets(int $survey_id)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
importData()
Import data from DB.
fillRow(array $a_set)
Standard Version of Fill Row.
buildPath(array $ref_ids)
Build path with deep-link.
__construct(object $a_parent_obj, string $a_parent_cmd, SurveyQuestion $a_question)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTitle(string $a_title, string $a_icon="", string $a_icon_alt="")
addCommandButton(string $a_cmd, string $a_text, string $a_onclick='', string $a_id="", string $a_class="")
setDescription(string $a_val)
setFormAction(string $a_form_action, bool $a_multipart=false)
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)
setDefaultOrderField(string $a_defaultorderfield)
setRowTemplate(string $a_template, string $a_template_dir="")
Set row template.
setId(string $a_val)
setDefaultOrderDirection(string $a_defaultorderdirection)
setData(array $a_data)
Set table data.
ilLanguage $lng
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
getPathFull(int $a_endnode_id, int $a_startnode_id=0)
get path from a given startnode to a given endnode if startnode is not given the rootnode is startnod...
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
$ref_id
Definition: ltiauth.php:66
$path
Definition: ltiservices.php:30
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$counter
$message
Definition: xapiexit.php:31