ILIAS  release_4-4 Revision
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 151 of file class.ilSurveyPhrasesGUI.php.

152  {
153  $this->ctrl->redirect($this, "phrases");
154  }

◆ cancelEditPhrase()

ilSurveyPhrasesGUI::cancelEditPhrase ( )

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

225  {
226  $this->ctrl->redirect($this, 'phrases');
227  }

◆ confirmDeletePhrase()

ilSurveyPhrasesGUI::confirmDeletePhrase ( )

confirm delete phrases

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

References $_POST, and ilUtil\sendSuccess().

160  {
161  $phrases = $_POST['phrase'];
162  $this->object->deletePhrases($phrases);
163  ilUtil::sendSuccess($this->lng->txt("qpl_phrases_deleted"), true);
164  $this->ctrl->redirect($this, "phrases");
165  }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
$_POST['username']
Definition: cron.php:12
+ 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  }
$_POST['username']
Definition: cron.php:12
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.
+ 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 208 of file class.ilSurveyPhrasesGUI.php.

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

Referenced by deletePhrase().

209  {
210  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
211  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases', true);
213  $data = array();
214  foreach ($checked_phrases as $phrase_id)
215  {
216  $phrase_array = $phrases[$phrase_id];
217  $categories =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
218  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
219  }
220  $table_gui->setData($data);
221  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
222  }
static & _getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
static & _getAvailablePhrases($useronly=0)
Gets the available phrases from the database.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ editPhrase()

ilSurveyPhrasesGUI::editPhrase ( )

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

References $_POST, and ilUtil\sendFailure().

286  {
287  if (!array_key_exists('phrase', $_POST))
288  {
289  ilUtil::sendFailure($this->lng->txt('no_phrase_selected'), true);
290  $this->ctrl->redirect($this, 'phrases');
291  }
292  if ((array_key_exists('phrase', $_POST)) && count($_POST['phrase']) > 1)
293  {
294  ilUtil::sendFailure($this->lng->txt('select_max_one_item'), true);
295  $this->ctrl->redirect($this, 'phrases');
296  }
297  $phrase_id = (array_key_exists('phrase', $_POST)) ? $_POST['phrase'][key($_POST['phrase'])] : null;
298  if ($phrase_id)
299  {
300  $this->ctrl->setParameter($this, 'p_id', $phrase_id);
301  }
302  $this->ctrl->redirect($this, 'phraseEditor');
303  }
$_POST['username']
Definition: cron.php:12
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
+ 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
getCommand($cmd)
Retrieves the ilCtrl command.
+ Here is the call graph for this function:

◆ getCategoriesForPhrase()

ilSurveyPhrasesGUI::getCategoriesForPhrase (   $phrase_id)
protected

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

References $data, $result, and ilDB\fetchAssoc().

Referenced by phraseEditor().

168  {
169  global $ilDB;
170 
171  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
172  $categories = new SurveyCategories();
173  $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",
174  array('integer'),
175  array($phrase_id)
176  );
177  if ($result->numRows() > 0)
178  {
179  while ($data = $ilDB->fetchAssoc($result))
180  {
181  $categories->addCategory($data["title"], 0, $data["neutral"], null, $data['sequence']);
182  }
183  }
184  return $categories;
185  }
$result
fetchAssoc($a_set)
Fetch row as associative array from result set.
Class SurveyCategories.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:
+ 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 187 of file class.ilSurveyPhrasesGUI.php.

References $result, and $row.

Referenced by phraseEditor().

188  {
189  global $ilDB;
190 
191  $result = $ilDB->queryF("SELECT svy_phrase.title FROM svy_phrase WHERE svy_phrase.phrase_id = %s",
192  array('integer'),
193  array($phrase_id)
194  );
195  if ($result->numRows() > 0)
196  {
197  $row = $ilDB->fetchAssoc($result);
198  return $row['title'];
199  }
200  return null;
201  }
$result
+ Here is the caller graph for this function:

◆ newPhrase()

ilSurveyPhrasesGUI::newPhrase ( )

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

281  {
282  $this->ctrl->redirect($this, 'phraseEditor');
283  }

◆ phraseEditor()

ilSurveyPhrasesGUI::phraseEditor (   $checkonly = FALSE)

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

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

Referenced by writePostData().

306  {
307  $save = (strcmp($this->ctrl->getCmd(), "saveEditPhrase") == 0) ? TRUE : FALSE;
308 
309  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
310  $form = new ilPropertyFormGUI();
311  $form->setFormAction($this->ctrl->getFormAction($this, 'phraseEditor'));
312  $form->setTitle($this->lng->txt('edit_phrase'));
313  $form->setMultipart(FALSE);
314  $form->setTableWidth("100%");
315  $form->setId("phraseeditor");
316 
317  $phrase_id = $_GET['p_id'];
318 
319  // title
320  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
321  $title->setValue($this->getPhraseTitle($phrase_id));
322  $title->setRequired(TRUE);
323  $form->addItem($title);
324 
325  // Answers
326  include_once "./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
327  $answers = new ilCategoryWizardInputGUI($this->lng->txt("answers"), "answers");
328  $answers->setRequired(true);
329  $answers->setAllowMove(true);
330  $answers->setShowWizard(false );
331  $answers->setShowSavePhrase(false);
332  $answers->setUseOtherAnswer(false);
333  $answers->setShowNeutralCategory(true);
334  $answers->setNeutralCategoryTitle($this->lng->txt('matrix_neutral_answer'));
335  include_once "./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
336  $categories =& $this->getCategoriesForPhrase($phrase_id);
337  if (!$categories->getCategoryCount())
338  {
339  $categories->addCategory("");
340  }
341  $answers->setValues($categories);
342  $answers->setDisabledScale(true);
343  $form->addItem($answers);
344 
345  $form->addCommandButton("saveEditPhrase", $this->lng->txt("save"));
346  $form->addCommandButton("cancelEditPhrase", $this->lng->txt("cancel"));
347 
348  $errors = false;
349 
350  if ($save)
351  {
352  $form->setValuesByPost();
353  $errors = !$form->checkInput();
354  $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
355  if ($errors) $checkonly = false;
356  }
357 
358  if (!$checkonly) $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
359  return $errors;
360  }
This class represents a property form user interface.
$_GET["client_id"]
$errors
This class represents a text property in a property form.
This class represents a survey question category wizard property in a property form.
setValue($a_value)
Set Value.
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(), 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  $ilToolbar->addButton($this->lng->txt('phrase_new'),
128  $this->ctrl->getLinkTarget($this, 'newPhrase'));
129 
130  include_once "./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
131  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases');
133  $data = array();
134  foreach ($phrases as $phrase_id => $phrase_array)
135  {
136  $categories =& ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
137  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join($categories, ", ")));
138  }
139  $table_gui->setData($data);
140  $this->tpl->setContent($table_gui->getHTML());
141  }
142  else
143  {
144  ilUtil::sendInfo($this->lng->txt("cannot_manage_phrases"));
145  }
146  }
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
static & _getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
static & _getAvailablePhrases($useronly=0)
Gets the available phrases from the database.
while($lm_rec=$ilDB->fetchAssoc($lm_set)) $data
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ saveEditPhrase()

ilSurveyPhrasesGUI::saveEditPhrase ( )

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

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

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

References $_POST, and phraseEditor().

Referenced by saveEditPhrase().

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