ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilSurveyPhrasesGUI Class Reference

Survey phrases GUI class. More...

+ Collaboration diagram for ilSurveyPhrasesGUI:

Public Member Functions

 __construct ($a_object)
 ilSurveyPhrasesGUI constructor More...
 
 executeCommand ()
 execute command More...
 
 getCommand ($cmd)
 Retrieves the ilCtrl command. More...
 
 deletePhrase ()
 Creates a confirmation form to delete personal phases from the database. More...
 
 phrases ()
 Displays a form to manage the user created phrases. More...
 
 cancelDeletePhrase ()
 cancel delete phrases More...
 
 confirmDeletePhrase ()
 confirm delete phrases More...
 
 deletePhrasesForm ($checked_phrases)
 Creates a confirmation form to delete personal phases from the database. More...
 
 cancelEditPhrase ()
 
 saveEditPhrase ()
 
 writePostData ($always=false)
 Evaluates a posted edit form and writes the form data in the question object. More...
 
 newPhrase ()
 
 editPhrase ()
 
 phraseEditor ($checkonly=false)
 

Data Fields

 $object
 
 $gui_object
 
 $lng
 
 $tpl
 
 $ctrl
 
 $tree
 
 $ref_id
 

Protected Member Functions

 getCategoriesForPhrase ($phrase_id)
 
 getPhraseTitle ($phrase_id)
 

Protected Attributes

 $rbacsystem
 
 $toolbar
 
 $db
 

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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilSurveyPhrasesGUI::__construct (   $a_object)

ilSurveyPhrasesGUI constructor

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

References $DIC, $ilCtrl, $lng, $tpl, and $tree.

65  {
66  global $DIC;
67 
68  $this->rbacsystem = $DIC->rbac()->system();
69  $this->toolbar = $DIC->toolbar();
70  $this->db = $DIC->database();
71  $lng = $DIC->language();
72  $tpl = $DIC["tpl"];
73  $ilCtrl = $DIC->ctrl();
74  $tree = $DIC->repositoryTree();
75 
76  include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
77  $this->lng = $lng;
78  $this->tpl = $tpl;
79  $this->ctrl = $ilCtrl;
80  $this->gui_object = $a_object;
81  $this->object = new ilSurveyPhrases();
82  $this->tree = $tree;
83  $this->ref_id = $a_object->ref_id;
84  $this->ctrl->saveParameter($this, "p_id");
85  }
global $DIC
Definition: saml.php:7
global $ilCtrl
Definition: ilias.php:18
Survey phrases class.

Member Function Documentation

◆ cancelDeletePhrase()

ilSurveyPhrasesGUI::cancelDeletePhrase ( )

cancel delete phrases

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

169  {
170  $this->ctrl->redirect($this, "phrases");
171  }

◆ cancelEditPhrase()

ilSurveyPhrasesGUI::cancelEditPhrase ( )

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

240  {
241  $this->ctrl->redirect($this, 'phrases');
242  }

◆ confirmDeletePhrase()

ilSurveyPhrasesGUI::confirmDeletePhrase ( )

confirm delete phrases

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

References $_POST, and ilUtil\sendSuccess().

177  {
178  $phrases = $_POST['phrase'];
179  $this->object->deletePhrases($phrases);
180  ilUtil::sendSuccess($this->lng->txt("qpl_phrases_deleted"), true);
181  $this->ctrl->redirect($this, "phrases");
182  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST["username"]
+ 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 115 of file class.ilSurveyPhrasesGUI.php.

References $_POST, deletePhrasesForm(), phrases(), ilUtil\sendInfo(), and ilUtil\sendQuestion().

116  {
118 
119  $checked_phrases = $_POST['phrase'];
120  if (count($checked_phrases)) {
121  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_phrases"));
122  $this->deletePhrasesForm($checked_phrases);
123  return;
124  } else {
125  ilUtil::sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
126  $this->phrases();
127  return;
128  }
129  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
deletePhrasesForm($checked_phrases)
Creates a confirmation form to delete personal phases from the database.
phrases()
Displays a form to manage the user created phrases.
$_POST["username"]
+ Here is the call graph for this function:

◆ deletePhrasesForm()

ilSurveyPhrasesGUI::deletePhrasesForm (   $checked_phrases)

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

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

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

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

Referenced by deletePhrase().

225  {
226  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
227  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases', true);
229  $data = array();
230  foreach ($checked_phrases as $phrase_id) {
231  $phrase_array = $phrases[$phrase_id];
232  $categories =&ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
233  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
234  }
235  $table_gui->setData($data);
236  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
237  }
static _getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
Create styles array
The data for the language used.
static _getAvailablePhrases($useronly=0)
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 293 of file class.ilSurveyPhrasesGUI.php.

References $_POST, and ilUtil\sendFailure().

294  {
295  if (!array_key_exists('phrase', $_POST)) {
296  ilUtil::sendFailure($this->lng->txt('no_phrase_selected'), true);
297  $this->ctrl->redirect($this, 'phrases');
298  }
299  if ((array_key_exists('phrase', $_POST)) && count($_POST['phrase']) > 1) {
300  ilUtil::sendFailure($this->lng->txt('select_max_one_item'), true);
301  $this->ctrl->redirect($this, 'phrases');
302  }
303  $phrase_id = (array_key_exists('phrase', $_POST)) ? $_POST['phrase'][key($_POST['phrase'])] : null;
304  if ($phrase_id) {
305  $this->ctrl->setParameter($this, 'p_id', $phrase_id);
306  }
307  $this->ctrl->redirect($this, 'phraseEditor');
308  }
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST["username"]
+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyPhrasesGUI::executeCommand ( )

execute command

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

References $ret, and getCommand().

91  {
92  $cmd = $this->ctrl->getCmd();
93  $next_class = $this->ctrl->getNextClass($this);
94 
95  $cmd = $this->getCommand($cmd);
96  switch ($next_class) {
97  default:
98  $ret =&$this->$cmd();
99  break;
100  }
101  return $ret;
102  }
$ret
Definition: parser.php:6
getCommand($cmd)
Retrieves the ilCtrl command.
+ Here is the call graph for this function:

◆ getCategoriesForPhrase()

ilSurveyPhrasesGUI::getCategoriesForPhrase (   $phrase_id)
protected

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

References $data, $db, $ilDB, $result, and array.

Referenced by phraseEditor().

185  {
186  $ilDB = $this->db;
187 
188  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
189  $categories = new SurveyCategories();
190  $result = $ilDB->queryF(
191  "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",
192  array('integer'),
193  array($phrase_id)
194  );
195  if ($result->numRows() > 0) {
196  while ($data = $ilDB->fetchAssoc($result)) {
197  $categories->addCategory($data["title"], 0, $data["neutral"], null, $data['sequence']);
198  }
199  }
200  return $categories;
201  }
$result
Class SurveyCategories.
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ getCommand()

ilSurveyPhrasesGUI::getCommand (   $cmd)

Retrieves the ilCtrl command.

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

Referenced by executeCommand().

108  {
109  return $cmd;
110  }
+ Here is the caller graph for this function:

◆ getPhraseTitle()

ilSurveyPhrasesGUI::getPhraseTitle (   $phrase_id)
protected

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

References $db, $ilDB, $result, $row, and array.

Referenced by phraseEditor().

204  {
205  $ilDB = $this->db;
206 
207  $result = $ilDB->queryF(
208  "SELECT svy_phrase.title FROM svy_phrase WHERE svy_phrase.phrase_id = %s",
209  array('integer'),
210  array($phrase_id)
211  );
212  if ($result->numRows() > 0) {
213  $row = $ilDB->fetchAssoc($result);
214  return $row['title'];
215  }
216  return null;
217  }
$result
Create styles array
The data for the language used.
global $ilDB
+ Here is the caller graph for this function:

◆ newPhrase()

ilSurveyPhrasesGUI::newPhrase ( )

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

289  {
290  $this->ctrl->redirect($this, 'phraseEditor');
291  }

◆ phraseEditor()

ilSurveyPhrasesGUI::phraseEditor (   $checkonly = false)

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

References $_GET, $errors, $form, $title, getCategoriesForPhrase(), getPhraseTitle(), and ilFormPropertyGUI\setRequired().

Referenced by writePostData().

311  {
312  $save = (strcmp($this->ctrl->getCmd(), "saveEditPhrase") == 0) ? true : false;
313 
314  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
315  $form = new ilPropertyFormGUI();
316  $form->setFormAction($this->ctrl->getFormAction($this, 'phraseEditor'));
317  $form->setTitle($this->lng->txt('edit_phrase'));
318  $form->setMultipart(false);
319  $form->setTableWidth("100%");
320  $form->setId("phraseeditor");
321 
322  $phrase_id = $_GET['p_id'];
323 
324  // title
325  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
326  $title->setValue($this->getPhraseTitle($phrase_id));
327  $title->setRequired(true);
328  $form->addItem($title);
329 
330  // Answers
331  include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
332  $answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
333  $answers->setRequired(true);
334  $answers->setAllowMove(true);
335  $answers->setShowWizard(false);
336  $answers->setShowSavePhrase(false);
337  $answers->setUseOtherAnswer(false);
338  $answers->setShowNeutralCategory(true);
339  $answers->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
340  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
341  $categories =&$this->getCategoriesForPhrase($phrase_id);
342  if (!$categories->getCategoryCount()) {
343  $categories->addCategory("");
344  }
345  $answers->setValues($categories);
346  $answers->setDisabledScale(true);
347  $form->addItem($answers);
348 
349  $form->addCommandButton("saveEditPhrase", $this->lng->txt("save"));
350  $form->addCommandButton("cancelEditPhrase", $this->lng->txt("cancel"));
351 
352  $errors = false;
353 
354  if ($save) {
355  $form->setValuesByPost();
356  $errors = !$form->checkInput();
357  $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
358  if ($errors) {
359  $checkonly = false;
360  }
361  }
362 
363  if (!$checkonly) {
364  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
365  }
366  return $errors;
367  }
This class represents a property form user interface.
$_GET["client_id"]
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
This class represents a survey question category wizard property in a property form.
$errors
Definition: index.php:6
setRequired($a_required)
Set Required.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ phrases()

ilSurveyPhrasesGUI::phrases ( )

Displays a form to manage the user created phrases.

public

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

References $data, $rbacsystem, $toolbar, ilSurveyPhrases\_getAvailablePhrases(), ilSurveyPhrases\_getCategoriesForPhrase(), array, ilLinkButton\getInstance(), and ilUtil\sendInfo().

Referenced by deletePhrase().

137  {
139  $ilToolbar = $this->toolbar;
140 
141  $this->ctrl->setParameter($this, "p_id", "");
142 
143  if ($rbacsystem->checkAccess("write", $this->ref_id)) {
144  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
145  $button = ilLinkButton::getInstance();
146  $button->setCaption("phrase_new");
147  $button->setUrl($this->ctrl->getLinkTarget($this, "newPhrase"));
148  $ilToolbar->addButtonInstance($button);
149 
150  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
151  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases');
153  $data = array();
154  foreach ($phrases as $phrase_id => $phrase_array) {
155  $categories =&ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
156  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
157  }
158  $table_gui->setData($data);
159  $this->tpl->setContent($table_gui->getHTML());
160  } else {
161  ilUtil::sendInfo($this->lng->txt("cannot_manage_phrases"));
162  }
163  }
static _getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Create styles array
The data for the language used.
static _getAvailablePhrases($useronly=0)
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 244 of file class.ilSurveyPhrasesGUI.php.

References $_GET, $result, ilUtil\sendSuccess(), and writePostData().

245  {
246  $result = $this->writePostData();
247  if ($result == 0) {
248  if ($_GET['p_id']) {
249  $this->object->updatePhrase($_GET['p_id']);
250  ilUtil::sendSuccess($this->lng->txt('phrase_saved'), true);
251  } else {
252  $this->object->savePhrase();
253  ilUtil::sendSuccess($this->lng->txt('phrase_added'), true);
254  }
255  $this->ctrl->redirect($this, 'phrases');
256  }
257  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$result
$_GET["client_id"]
writePostData($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 (   $always = false)

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

Returns
integer A positive value, if one of the required fields wasn't set, else 0 private

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

References $_POST, $db, $ilDB, $key, and phraseEditor().

Referenced by saveEditPhrase().

266  {
267  $ilDB = $this->db;
268  $hasErrors = (!$always) ? $this->phraseEditor(true) : false;
269  if (!$hasErrors) {
270  $this->object->title = $_POST["title"];
271  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
272  $categories = new SurveyCategories();
273  foreach ($_POST['answers']['answer'] as $key => $value) {
274  if (strlen($value)) {
275  $categories->addCategory($value, $_POST['answers']['other'][$key], 0, null, $_POST['answers']['scale'][$key]);
276  }
277  }
278  if (strlen($_POST['answers']['neutral'])) {
279  $categories->addCategory($_POST['answers']['neutral'], 0, 1, null, $_POST['answers_neutral_scale']);
280  }
281  $this->object->categories = $categories;
282  return 0;
283  } else {
284  return 1;
285  }
286  }
phraseEditor($checkonly=false)
Class SurveyCategories.
global $ilDB
$key
Definition: croninfo.php:18
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $ctrl

ilSurveyPhrasesGUI::$ctrl

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

◆ $db

ilSurveyPhrasesGUI::$db
protected

◆ $gui_object

ilSurveyPhrasesGUI::$gui_object

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

◆ $lng

ilSurveyPhrasesGUI::$lng

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

Referenced by __construct().

◆ $object

ilSurveyPhrasesGUI::$object

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

◆ $rbacsystem

ilSurveyPhrasesGUI::$rbacsystem
protected

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

Referenced by phrases().

◆ $ref_id

ilSurveyPhrasesGUI::$ref_id

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

◆ $toolbar

ilSurveyPhrasesGUI::$toolbar
protected

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

Referenced by phrases().

◆ $tpl

ilSurveyPhrasesGUI::$tpl

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

Referenced by __construct().

◆ $tree

ilSurveyPhrasesGUI::$tree

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

Referenced by __construct().


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