ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilSurveyPhrasesGUI Class Reference

Survey phrases GUI class The ilSurveyPhrases GUI class creates the GUI output for survey phrases (collections of survey categories) of ordinal survey question types. More...

+ Collaboration diagram for ilSurveyPhrasesGUI:

Public Member Functions

 __construct (ilObjSurveyQuestionPoolGUI $a_object)
 
 executeCommand ()
 
 deletePhrase ()
 Creates a confirmation form to delete personal phases from the database. More...
 
 phrases ()
 List phrases. More...
 
 cancelDeletePhrase ()
 
 confirmDeletePhrase ()
 
 deletePhrasesForm (array $checked_phrases)
 Creates a confirmation form to delete personal phases from the database. More...
 
 cancelEditPhrase ()
 
 saveEditPhrase ()
 
 writePostData (bool $always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 newPhrase ()
 
 editPhrase ()
 
 phraseEditor (bool $checkonly=false)
 

Protected Member Functions

 getCategoriesForPhrase (int $phrase_id)
 
 getPhraseTitle (int $phrase_id)
 

Protected Attributes

ilPropertyFormGUI $form
 
EditingGUIRequest $request
 
ilRbacSystem $rbacsystem
 
ilToolbarGUI $toolbar
 
ilDBInterface $db
 
ilSurveyPhrases $object
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilCtrl $ctrl
 
ilTree $tree
 
int $ref_id
 

Detailed Description

Survey phrases GUI class The ilSurveyPhrases GUI class creates the GUI output for survey phrases (collections of survey categories) of ordinal survey question types.

Author
Helmut Schottmüller ilias.nosp@m.@aur.nosp@m.ealis.nosp@m..de

Definition at line 28 of file class.ilSurveyPhrasesGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilSurveyPhrasesGUI::__construct ( ilObjSurveyQuestionPoolGUI  $a_object)

Definition at line 43 of file class.ilSurveyPhrasesGUI.php.

References $DIC, $lng, $tpl, $tree, ILIAS\Repository\ctrl(), ilObjectGUI\getRefId(), ILIAS\Repository\lng(), and ILIAS\Repository\toolbar().

45  {
46  global $DIC;
47 
48  $this->rbacsystem = $DIC->rbac()->system();
49  $this->toolbar = $DIC->toolbar();
50  $this->db = $DIC->database();
51  $lng = $DIC->language();
52  $tpl = $DIC["tpl"];
53  $ilCtrl = $DIC->ctrl();
54  $tree = $DIC->repositoryTree();
55 
56  $this->lng = $lng;
57  $this->tpl = $tpl;
58  $this->ctrl = $ilCtrl;
59  $this->object = new ilSurveyPhrases();
60  $this->tree = $tree;
61  $this->ref_id = $a_object->getRefId();
62  $this->ctrl->saveParameter($this, "p_id");
63  $this->request = $DIC->surveyQuestionPool()
64  ->internal()
65  ->gui()
66  ->editing()
67  ->request();
68  }
global $DIC
Definition: feed.php:28
ilGlobalTemplateInterface $tpl
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

Member Function Documentation

◆ cancelDeletePhrase()

ilSurveyPhrasesGUI::cancelDeletePhrase ( )

Definition at line 131 of file class.ilSurveyPhrasesGUI.php.

References ILIAS\Repository\ctrl().

131  : void
132  {
133  $this->ctrl->redirect($this, "phrases");
134  }
+ Here is the call graph for this function:

◆ cancelEditPhrase()

ilSurveyPhrasesGUI::cancelEditPhrase ( )

Definition at line 210 of file class.ilSurveyPhrasesGUI.php.

References ILIAS\Repository\ctrl().

210  : void
211  {
212  $this->ctrl->redirect($this, 'phrases');
213  }
+ Here is the call graph for this function:

◆ confirmDeletePhrase()

ilSurveyPhrasesGUI::confirmDeletePhrase ( )

Definition at line 136 of file class.ilSurveyPhrasesGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

136  : void
137  {
138  $phrases = $this->request->getPhraseIds();
139  $this->object->deletePhrases($phrases);
140  $this->tpl->setOnScreenMessage('success', $this->lng->txt("qpl_phrases_deleted"), true);
141  $this->ctrl->redirect($this, "phrases");
142  }
+ Here is the call graph for this function:

◆ deletePhrase()

ilSurveyPhrasesGUI::deletePhrase ( )

Creates a confirmation form to delete personal phases from the database.

Definition at line 86 of file class.ilSurveyPhrasesGUI.php.

References deletePhrasesForm(), ILIAS\Repository\lng(), and phrases().

86  : void
87  {
88  $checked_phrases = $this->request->getPhraseIds();
89  if (count($checked_phrases) > 0) {
90  $this->tpl->setOnScreenMessage('question', $this->lng->txt("qpl_confirm_delete_phrases"));
91  $this->deletePhrasesForm($checked_phrases);
92  } else {
93  $this->tpl->setOnScreenMessage('info', $this->lng->txt("qpl_delete_phrase_select_none"));
94  $this->phrases();
95  }
96  }
deletePhrasesForm(array $checked_phrases)
Creates a confirmation form to delete personal phases from the database.
+ Here is the call graph for this function:

◆ deletePhrasesForm()

ilSurveyPhrasesGUI::deletePhrasesForm ( array  $checked_phrases)

Creates a confirmation form to delete personal phases from the database.

Parameters
array$checked_phrasesarray with the id's of the phrases checked for deletion

Definition at line 192 of file class.ilSurveyPhrasesGUI.php.

References $data, ilSurveyPhrases\_getAvailablePhrases(), and ilSurveyPhrases\_getCategoriesForPhrase().

Referenced by deletePhrase().

194  : void {
195  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases', true);
197  $data = array();
198  foreach ($checked_phrases as $phrase_id) {
199  $phrase_array = $phrases[$phrase_id];
200  $categories = ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
201  $data[] = array('phrase_id' => $phrase_id,
202  'phrase' => $phrase_array["title"],
203  'answers' => implode(", ", $categories)
204  );
205  }
206  $table_gui->setData($data);
207  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
208  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getCategoriesForPhrase(int $phrase_id)
Gets the available categories for a given phrase.
static _getAvailablePhrases(bool $useronly=false)
Gets the available phrases from the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editPhrase()

ilSurveyPhrasesGUI::editPhrase ( )

Definition at line 270 of file class.ilSurveyPhrasesGUI.php.

References ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

270  : void
271  {
272  $ids = $this->request->getPhraseIds();
273  if (count($ids) === 0) {
274  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('no_phrase_selected'), true);
275  $this->ctrl->redirect($this, 'phrases');
276  }
277  if (count($ids) > 1) {
278  $this->tpl->setOnScreenMessage('failure', $this->lng->txt('select_max_one_item'), true);
279  $this->ctrl->redirect($this, 'phrases');
280  }
281  $phrase_id = $ids[key($ids)];
282  if ($phrase_id) {
283  $this->ctrl->setParameter($this, 'p_id', $phrase_id);
284  }
285  $this->ctrl->redirect($this, 'phraseEditor');
286  }
+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyPhrasesGUI::executeCommand ( )

Definition at line 70 of file class.ilSurveyPhrasesGUI.php.

References ILIAS\Repository\ctrl().

70  : string
71  {
72  $cmd = $this->ctrl->getCmd();
73  $next_class = $this->ctrl->getNextClass($this);
74 
75  switch ($next_class) {
76  default:
77  $ret = $this->$cmd();
78  break;
79  }
80  return (string) $ret;
81  }
+ Here is the call graph for this function:

◆ getCategoriesForPhrase()

ilSurveyPhrasesGUI::getCategoriesForPhrase ( int  $phrase_id)
protected
Todo:
move this to a repo class
Parameters
int$phrase_id
Returns
SurveyCategories

Definition at line 149 of file class.ilSurveyPhrasesGUI.php.

References $data, $db, and $ilDB.

Referenced by phraseEditor().

151  : SurveyCategories {
152  $ilDB = $this->db;
153 
154  $categories = new SurveyCategories();
155  $result = $ilDB->queryF(
156  "SELECT svy_category.title, svy_category.neutral, svy_phrase_cat.sequence FROM svy_phrase_cat, svy_category WHERE svy_phrase_cat.phrase_fi = %s AND svy_phrase_cat.category_fi = svy_category.category_id ORDER BY svy_phrase_cat.sequence ASC",
157  array('integer'),
158  array($phrase_id)
159  );
160  if ($result->numRows() > 0) {
161  while ($data = $ilDB->fetchAssoc($result)) {
162  $categories->addCategory($data["title"], 0, $data["neutral"], null, $data['sequence']);
163  }
164  }
165  return $categories;
166  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getPhraseTitle()

ilSurveyPhrasesGUI::getPhraseTitle ( int  $phrase_id)
protected
Todo:
move this to a repo class

Definition at line 171 of file class.ilSurveyPhrasesGUI.php.

References $db, and $ilDB.

Referenced by phraseEditor().

173  : string {
174  $ilDB = $this->db;
175 
176  $result = $ilDB->queryF(
177  "SELECT svy_phrase.title FROM svy_phrase WHERE svy_phrase.phrase_id = %s",
178  array('integer'),
179  array($phrase_id)
180  );
181  if ($result->numRows() > 0) {
182  $row = $ilDB->fetchAssoc($result);
183  return $row['title'];
184  }
185  return "";
186  }
+ Here is the caller graph for this function:

◆ newPhrase()

ilSurveyPhrasesGUI::newPhrase ( )

Definition at line 265 of file class.ilSurveyPhrasesGUI.php.

References ILIAS\Repository\ctrl().

265  : void
266  {
267  $this->ctrl->redirect($this, 'phraseEditor');
268  }
+ Here is the call graph for this function:

◆ phraseEditor()

ilSurveyPhrasesGUI::phraseEditor ( bool  $checkonly = false)

Definition at line 288 of file class.ilSurveyPhrasesGUI.php.

References $errors, $form, ILIAS\Repository\ctrl(), ILIAS\Repository\form(), getCategoriesForPhrase(), getPhraseTitle(), ILIAS\Repository\lng(), and ilFormPropertyGUI\setRequired().

Referenced by writePostData().

290  : bool {
291  $save = strcmp($this->ctrl->getCmd(), "saveEditPhrase") === 0;
292 
293  $form = new ilPropertyFormGUI();
294  $form->setFormAction($this->ctrl->getFormAction($this, 'phraseEditor'));
295  $form->setTitle($this->lng->txt('edit_phrase'));
296  $form->setMultipart(false);
297  $form->setTableWidth("100%");
298  $form->setId("phraseeditor");
299 
300  $phrase_id = $this->request->getPhraseId();
301 
302  // title
303  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
304  $title->setValue($this->getPhraseTitle($phrase_id));
305  $title->setRequired(true);
306  $form->addItem($title);
307 
308  // Answers
309  $answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
310  $answers->setRequired(true);
311  $answers->setAllowMove(true);
312  $answers->setShowWizard(false);
313  $answers->setShowSavePhrase(false);
314  $answers->setUseOtherAnswer(false);
315  $answers->setShowNeutralCategory(true);
316  $answers->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
317  $categories = $this->getCategoriesForPhrase($phrase_id);
318  if (!$categories->getCategoryCount()) {
319  $categories->addCategory("");
320  }
321  $answers->setValues($categories);
322  $answers->setDisabledScale(true);
323  $form->addItem($answers);
324 
325  $form->addCommandButton("saveEditPhrase", $this->lng->txt("save"));
326  $form->addCommandButton("cancelEditPhrase", $this->lng->txt("cancel"));
327 
328  $errors = false;
329 
330  if ($save) {
331  $form->setValuesByPost();
332  $errors = !$form->checkInput();
333  $form->setValuesByPost(); // again, because checkInput now performs the whole stripSlashes handling and we need this if we don't want to have duplication of backslashes
334  if ($errors) {
335  $checkonly = false;
336  }
337  }
338 
339  if (!$checkonly) {
340  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
341  }
342  $this->form = $form;
343  return $errors;
344  }
$errors
Definition: imgupload.php:65
getCategoriesForPhrase(int $phrase_id)
setRequired(bool $a_required)
form( $class_path, string $cmd)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phrases()

ilSurveyPhrasesGUI::phrases ( )

List phrases.

Definition at line 101 of file class.ilSurveyPhrasesGUI.php.

References $data, $rbacsystem, $toolbar, ilSurveyPhrases\_getAvailablePhrases(), ilSurveyPhrases\_getCategoriesForPhrase(), ilRbacSystem\checkAccess(), ILIAS\Repository\ctrl(), ilLinkButton\getInstance(), and ILIAS\Repository\lng().

Referenced by deletePhrase().

101  : void
102  {
104  $ilToolbar = $this->toolbar;
105 
106  $this->ctrl->setParameter($this, "p_id", "");
107 
108  if ($rbacsystem->checkAccess("write", $this->ref_id)) {
109  $button = ilLinkButton::getInstance();
110  $button->setCaption("phrase_new");
111  $button->setUrl($this->ctrl->getLinkTarget($this, "newPhrase"));
112  $ilToolbar->addButtonInstance($button);
113 
114  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases');
116  $data = array();
117  foreach ($phrases as $phrase_id => $phrase_array) {
118  $categories = ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
119  $data[] = array('phrase_id' => $phrase_id,
120  'phrase' => $phrase_array["title"],
121  'answers' => implode(", ", $categories)
122  );
123  }
124  $table_gui->setData($data);
125  $this->tpl->setContent($table_gui->getHTML());
126  } else {
127  $this->tpl->setOnScreenMessage('info', $this->lng->txt("cannot_manage_phrases"));
128  }
129  }
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getCategoriesForPhrase(int $phrase_id)
Gets the available categories for a given phrase.
static _getAvailablePhrases(bool $useronly=false)
Gets the available phrases from the database.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveEditPhrase()

ilSurveyPhrasesGUI::saveEditPhrase ( )

Definition at line 215 of file class.ilSurveyPhrasesGUI.php.

References ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and writePostData().

215  : void
216  {
217  $result = $this->writePostData();
218  if ($result === 0) {
219  if ($this->request->getPhraseId()) {
220  $this->object->updatePhrase($this->request->getPhraseId());
221  $this->tpl->setOnScreenMessage('success', $this->lng->txt('phrase_saved'), true);
222  } else {
223  $this->object->savePhrase();
224  $this->tpl->setOnScreenMessage('success', $this->lng->txt('phrase_added'), true);
225  }
226  $this->ctrl->redirect($this, 'phrases');
227  }
228  }
writePostData(bool $always=false)
Evaluates a posted edit form and writes the form data in the question object.
+ Here is the call graph for this function:

◆ writePostData()

ilSurveyPhrasesGUI::writePostData ( bool  $always = false)

Evaluates a posted edit form and writes the form data in the question object.

Returns
int a positive value, if one of the required fields wasn't set, else 0

Definition at line 234 of file class.ilSurveyPhrasesGUI.php.

References $form, ILIAS\LTI\ToolProvider\$key, ilPropertyFormGUI\getInput(), ILIAS\Repository\int(), and phraseEditor().

Referenced by saveEditPhrase().

236  : int {
237  $hasErrors = !$always && $this->phraseEditor(true);
238  if (!$hasErrors) {
239  $form = $this->form;
240  $this->object->title = $form->getInput("title");
241  $categories = new SurveyCategories();
242 
243  $answers = $this->request->getAnswers();
244  foreach ($answers['answer'] as $key => $value) {
245  if (strlen($value)) {
246  $categories->addCategory($value, $answers['other'][$key] ?? 0, 0, null, $answers['scale'][$key] ?? null);
247  }
248  }
249  if ($this->request->getNeutral() !== "") {
250  $categories->addCategory(
251  $this->request->getNeutral(),
252  0,
253  1,
254  null,
255  $this->request->getNeutralScale() ? (int) $this->request->getNeutralScale() : null
256  );
257  }
258  $this->object->categories = $categories;
259  return 0;
260  }
261 
262  return 1;
263  }
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
string $key
Consumer key/client ID value.
Definition: System.php:193
phraseEditor(bool $checkonly=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ilSurveyPhrasesGUI::$ctrl
protected

Definition at line 39 of file class.ilSurveyPhrasesGUI.php.

◆ $db

ilDBInterface ilSurveyPhrasesGUI::$db
protected

Definition at line 34 of file class.ilSurveyPhrasesGUI.php.

Referenced by getCategoriesForPhrase(), and getPhraseTitle().

◆ $form

ilPropertyFormGUI ilSurveyPhrasesGUI::$form
protected

Definition at line 30 of file class.ilSurveyPhrasesGUI.php.

Referenced by phraseEditor(), and writePostData().

◆ $lng

ilLanguage ilSurveyPhrasesGUI::$lng
protected

Definition at line 37 of file class.ilSurveyPhrasesGUI.php.

Referenced by __construct().

◆ $object

ilSurveyPhrases ilSurveyPhrasesGUI::$object
protected

Definition at line 36 of file class.ilSurveyPhrasesGUI.php.

◆ $rbacsystem

ilRbacSystem ilSurveyPhrasesGUI::$rbacsystem
protected

Definition at line 32 of file class.ilSurveyPhrasesGUI.php.

Referenced by phrases().

◆ $ref_id

int ilSurveyPhrasesGUI::$ref_id
protected

Definition at line 41 of file class.ilSurveyPhrasesGUI.php.

◆ $request

EditingGUIRequest ilSurveyPhrasesGUI::$request
protected

Definition at line 31 of file class.ilSurveyPhrasesGUI.php.

◆ $toolbar

ilToolbarGUI ilSurveyPhrasesGUI::$toolbar
protected

Definition at line 33 of file class.ilSurveyPhrasesGUI.php.

Referenced by phrases().

◆ $tpl

ilGlobalTemplateInterface ilSurveyPhrasesGUI::$tpl
protected

Definition at line 38 of file class.ilSurveyPhrasesGUI.php.

Referenced by __construct().

◆ $tree

ilTree ilSurveyPhrasesGUI::$tree
protected

Definition at line 40 of file class.ilSurveyPhrasesGUI.php.

Referenced by __construct().


The documentation for this class was generated from the following file: