ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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
 
 $ilias
 
 $tree
 
 $ref_id
 

Protected Member Functions

 getCategoriesForPhrase ($phrase_id)
 
 getPhraseTitle ($phrase_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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilSurveyPhrasesGUI::__construct (   $a_object)

ilSurveyPhrasesGUI constructor

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

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

51  {
52  global $lng, $tpl, $ilCtrl, $ilias, $tree;
53 
54  include_once "./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
55  $this->lng = $lng;
56  $this->tpl = $tpl;
57  $this->ctrl = $ilCtrl;
58  $this->ilias = $ilias;
59  $this->gui_object = $a_object;
60  $this->object = new ilSurveyPhrases();
61  $this->tree = $tree;
62  $this->ref_id = $a_object->ref_id;
63  $this->ctrl->saveParameter($this, "p_id");
64  }
global $ilCtrl
Definition: ilias.php:18
redirection script todo: (a better solution should control the processing via a xml file) ...
Survey phrases class.

Member Function Documentation

◆ cancelDeletePhrase()

ilSurveyPhrasesGUI::cancelDeletePhrase ( )

cancel delete phrases

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

155  {
156  $this->ctrl->redirect($this, "phrases");
157  }

◆ cancelEditPhrase()

ilSurveyPhrasesGUI::cancelEditPhrase ( )

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

228  {
229  $this->ctrl->redirect($this, 'phrases');
230  }

◆ confirmDeletePhrase()

ilSurveyPhrasesGUI::confirmDeletePhrase ( )

confirm delete phrases

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

References $_POST, and ilUtil\sendSuccess().

163  {
164  $phrases = $_POST['phrase'];
165  $this->object->deletePhrases($phrases);
166  ilUtil::sendSuccess($this->lng->txt("qpl_phrases_deleted"), true);
167  $this->ctrl->redirect($this, "phrases");
168  }
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 95 of file class.ilSurveyPhrasesGUI.php.

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

96  {
98 
99  $checked_phrases = $_POST['phrase'];
100  if (count($checked_phrases))
101  {
102  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_phrases"));
103  $this->deletePhrasesForm($checked_phrases);
104  return;
105  }
106  else
107  {
108  ilUtil::sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
109  $this->phrases();
110  return;
111  }
112  }
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 211 of file class.ilSurveyPhrasesGUI.php.

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

Referenced by deletePhrase().

212  {
213  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
214  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases', true);
216  $data = array();
217  foreach ($checked_phrases as $phrase_id)
218  {
219  $phrase_array = $phrases[$phrase_id];
220  $categories =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
221  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
222  }
223  $table_gui->setData($data);
224  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
225  }
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 288 of file class.ilSurveyPhrasesGUI.php.

References $_POST, and ilUtil\sendFailure().

289  {
290  if (!array_key_exists('phrase', $_POST))
291  {
292  ilUtil::sendFailure($this->lng->txt('no_phrase_selected'), true);
293  $this->ctrl->redirect($this, 'phrases');
294  }
295  if ((array_key_exists('phrase', $_POST)) && count($_POST['phrase']) > 1)
296  {
297  ilUtil::sendFailure($this->lng->txt('select_max_one_item'), true);
298  $this->ctrl->redirect($this, 'phrases');
299  }
300  $phrase_id = (array_key_exists('phrase', $_POST)) ? $_POST['phrase'][key($_POST['phrase'])] : null;
301  if ($phrase_id)
302  {
303  $this->ctrl->setParameter($this, 'p_id', $phrase_id);
304  }
305  $this->ctrl->redirect($this, 'phraseEditor');
306  }
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 69 of file class.ilSurveyPhrasesGUI.php.

References $cmd, $ret, and getCommand().

70  {
71  $cmd = $this->ctrl->getCmd();
72  $next_class = $this->ctrl->getNextClass($this);
73 
74  $cmd = $this->getCommand($cmd);
75  switch($next_class)
76  {
77  default:
78  $ret =& $this->$cmd();
79  break;
80  }
81  return $ret;
82  }
$cmd
Definition: sahs_server.php:35
$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 170 of file class.ilSurveyPhrasesGUI.php.

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

Referenced by phraseEditor().

171  {
172  global $ilDB;
173 
174  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
175  $categories = new SurveyCategories();
176  $result = $ilDB->queryF("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",
177  array('integer'),
178  array($phrase_id)
179  );
180  if ($result->numRows() > 0)
181  {
182  while ($data = $ilDB->fetchAssoc($result))
183  {
184  $categories->addCategory($data["title"], 0, $data["neutral"], null, $data['sequence']);
185  }
186  }
187  return $categories;
188  }
$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 87 of file class.ilSurveyPhrasesGUI.php.

References $cmd.

Referenced by executeCommand().

88  {
89  return $cmd;
90  }
$cmd
Definition: sahs_server.php:35
+ Here is the caller graph for this function:

◆ getPhraseTitle()

ilSurveyPhrasesGUI::getPhraseTitle (   $phrase_id)
protected

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

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

Referenced by phraseEditor().

191  {
192  global $ilDB;
193 
194  $result = $ilDB->queryF("SELECT svy_phrase.title FROM svy_phrase WHERE svy_phrase.phrase_id = %s",
195  array('integer'),
196  array($phrase_id)
197  );
198  if ($result->numRows() > 0)
199  {
200  $row = $ilDB->fetchAssoc($result);
201  return $row['title'];
202  }
203  return null;
204  }
$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 283 of file class.ilSurveyPhrasesGUI.php.

284  {
285  $this->ctrl->redirect($this, 'phraseEditor');
286  }

◆ phraseEditor()

ilSurveyPhrasesGUI::phraseEditor (   $checkonly = FALSE)

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

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

Referenced by writePostData().

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

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

Referenced by deletePhrase().

120  {
121  global $rbacsystem, $ilToolbar;
122 
123  $this->ctrl->setParameter($this, "p_id", "");
124 
125  if ($rbacsystem->checkAccess("write", $this->ref_id))
126  {
127  include_once "Services/UIComponent/Button/classes/class.ilLinkButton.php";
128  $button = ilLinkButton::getInstance();
129  $button->setCaption("phrase_new");
130  $button->setUrl($this->ctrl->getLinkTarget($this, "newPhrase"));
131  $ilToolbar->addButtonInstance($button);
132 
133  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
134  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases');
136  $data = array();
137  foreach ($phrases as $phrase_id => $phrase_array)
138  {
139  $categories =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
140  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
141  }
142  $table_gui->setData($data);
143  $this->tpl->setContent($table_gui->getHTML());
144  }
145  else
146  {
147  ilUtil::sendInfo($this->lng->txt("cannot_manage_phrases"));
148  }
149  }
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 232 of file class.ilSurveyPhrasesGUI.php.

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

233  {
234  $result = $this->writePostData();
235  if ($result == 0)
236  {
237  if ($_GET['p_id'])
238  {
239  $this->object->updatePhrase($_GET['p_id']);
240  ilUtil::sendSuccess($this->lng->txt('phrase_saved'), true);
241  }
242  else
243  {
244  $this->object->savePhrase();
245  ilUtil::sendSuccess($this->lng->txt('phrase_added'), true);
246  }
247  $this->ctrl->redirect($this, 'phrases');
248  }
249  }
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 257 of file class.ilSurveyPhrasesGUI.php.

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

Referenced by saveEditPhrase().

258  {
259  global $ilDB;
260  $hasErrors = (!$always) ? $this->phraseEditor(true) : false;
261  if (!$hasErrors)
262  {
263  $this->object->title = $_POST["title"];
264  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
265  $categories = new SurveyCategories();
266  foreach ($_POST['answers']['answer'] as $key => $value)
267  {
268  if (strlen($value)) $categories->addCategory($value, $_POST['answers']['other'][$key], 0, null, $_POST['answers']['scale'][$key]);
269  }
270  if (strlen($_POST['answers']['neutral']))
271  {
272  $categories->addCategory($_POST['answers']['neutral'], 0, 1, null, $_POST['answers_neutral_scale']);
273  }
274  $this->object->categories = $categories;
275  return 0;
276  }
277  else
278  {
279  return 1;
280  }
281  }
phraseEditor($checkonly=FALSE)
Class SurveyCategories.
global $ilDB
$_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 41 of file class.ilSurveyPhrasesGUI.php.

◆ $gui_object

ilSurveyPhrasesGUI::$gui_object

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

◆ $ilias

ilSurveyPhrasesGUI::$ilias

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

Referenced by __construct().

◆ $lng

ilSurveyPhrasesGUI::$lng

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

Referenced by __construct().

◆ $object

ilSurveyPhrasesGUI::$object

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

◆ $ref_id

ilSurveyPhrasesGUI::$ref_id

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

◆ $tpl

ilSurveyPhrasesGUI::$tpl

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

Referenced by __construct().

◆ $tree

ilSurveyPhrasesGUI::$tree

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

Referenced by __construct().


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