ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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  $this->lng = $lng;
77  $this->tpl = $tpl;
78  $this->ctrl = $ilCtrl;
79  $this->gui_object = $a_object;
80  $this->object = new ilSurveyPhrases();
81  $this->tree = $tree;
82  $this->ref_id = $a_object->ref_id;
83  $this->ctrl->saveParameter($this, "p_id");
84  }
global $ilCtrl
Definition: ilias.php:18
$DIC
Definition: xapitoken.php:46
Survey phrases class.

Member Function Documentation

◆ cancelDeletePhrase()

ilSurveyPhrasesGUI::cancelDeletePhrase ( )

cancel delete phrases

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

166  {
167  $this->ctrl->redirect($this, "phrases");
168  }

◆ cancelEditPhrase()

ilSurveyPhrasesGUI::cancelEditPhrase ( )

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

235  {
236  $this->ctrl->redirect($this, 'phrases');
237  }

◆ confirmDeletePhrase()

ilSurveyPhrasesGUI::confirmDeletePhrase ( )

confirm delete phrases

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

References $_POST.

174  {
175  $phrases = $_POST['phrase'];
176  $this->object->deletePhrases($phrases);
177  ilUtil::sendSuccess($this->lng->txt("qpl_phrases_deleted"), true);
178  $this->ctrl->redirect($this, "phrases");
179  }
$_POST["username"]

◆ deletePhrase()

ilSurveyPhrasesGUI::deletePhrase ( )

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

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

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

115  {
117 
118  $checked_phrases = $_POST['phrase'];
119  if (count($checked_phrases)) {
120  ilUtil::sendQuestion($this->lng->txt("qpl_confirm_delete_phrases"));
121  $this->deletePhrasesForm($checked_phrases);
122  return;
123  } else {
124  ilUtil::sendInfo($this->lng->txt("qpl_delete_phrase_select_none"));
125  $this->phrases();
126  return;
127  }
128  }
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 220 of file class.ilSurveyPhrasesGUI.php.

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

Referenced by deletePhrase().

221  {
222  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases', true);
224  $data = array();
225  foreach ($checked_phrases as $phrase_id) {
226  $phrase_array = $phrases[$phrase_id];
227  $categories = &ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
228  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join(", ", $categories)));
229  }
230  $table_gui->setData($data);
231  $this->tpl->setVariable('ADM_CONTENT', $table_gui->getHTML());
232  }
static _getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
$data
Definition: storeScorm.php:23
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 287 of file class.ilSurveyPhrasesGUI.php.

References $_POST, and ilUtil\sendFailure().

288  {
289  if (!array_key_exists('phrase', $_POST)) {
290  ilUtil::sendFailure($this->lng->txt('no_phrase_selected'), true);
291  $this->ctrl->redirect($this, 'phrases');
292  }
293  if ((array_key_exists('phrase', $_POST)) && count($_POST['phrase']) > 1) {
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  $this->ctrl->setParameter($this, 'p_id', $phrase_id);
300  }
301  $this->ctrl->redirect($this, 'phraseEditor');
302  }
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 89 of file class.ilSurveyPhrasesGUI.php.

References $ret, and getCommand().

90  {
91  $cmd = $this->ctrl->getCmd();
92  $next_class = $this->ctrl->getNextClass($this);
93 
94  $cmd = $this->getCommand($cmd);
95  switch ($next_class) {
96  default:
97  $ret = &$this->$cmd();
98  break;
99  }
100  return $ret;
101  }
$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 181 of file class.ilSurveyPhrasesGUI.php.

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

Referenced by phraseEditor().

182  {
183  $ilDB = $this->db;
184 
185  $categories = new SurveyCategories();
186  $result = $ilDB->queryF(
187  "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",
188  array('integer'),
189  array($phrase_id)
190  );
191  if ($result->numRows() > 0) {
192  while ($data = $ilDB->fetchAssoc($result)) {
193  $categories->addCategory($data["title"], 0, $data["neutral"], null, $data['sequence']);
194  }
195  }
196  return $categories;
197  }
$data
Definition: storeScorm.php:23
$result
Class SurveyCategories.
global $ilDB
+ Here is the caller graph for this function:

◆ getCommand()

ilSurveyPhrasesGUI::getCommand (   $cmd)

Retrieves the ilCtrl command.

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

Referenced by executeCommand().

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

◆ getPhraseTitle()

ilSurveyPhrasesGUI::getPhraseTitle (   $phrase_id)
protected

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

References $db, $ilDB, and $result.

Referenced by phraseEditor().

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

◆ newPhrase()

ilSurveyPhrasesGUI::newPhrase ( )

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

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

◆ phraseEditor()

ilSurveyPhrasesGUI::phraseEditor (   $checkonly = false)

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

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

Referenced by writePostData().

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

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

Referenced by deletePhrase().

136  {
138  $ilToolbar = $this->toolbar;
139 
140  $this->ctrl->setParameter($this, "p_id", "");
141 
142  if ($rbacsystem->checkAccess("write", $this->ref_id)) {
143  $button = ilLinkButton::getInstance();
144  $button->setCaption("phrase_new");
145  $button->setUrl($this->ctrl->getLinkTarget($this, "newPhrase"));
146  $ilToolbar->addButtonInstance($button);
147 
148  $table_gui = new ilSurveyPhrasesTableGUI($this, 'phrases');
150  $data = array();
151  foreach ($phrases as $phrase_id => $phrase_array) {
152  $categories = &ilSurveyPhrases::_getCategoriesForPhrase($phrase_id);
153  array_push($data, array('phrase_id' => $phrase_id, 'phrase' => $phrase_array["title"], 'answers' => join(", ", $categories)));
154  }
155  $table_gui->setData($data);
156  $this->tpl->setContent($table_gui->getHTML());
157  } else {
158  ilUtil::sendInfo($this->lng->txt("cannot_manage_phrases"));
159  }
160  }
static _getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
$data
Definition: storeScorm.php:23
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
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 239 of file class.ilSurveyPhrasesGUI.php.

References $_GET, $result, and writePostData().

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

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

Referenced by saveEditPhrase().

261  {
262  $ilDB = $this->db;
263  $hasErrors = (!$always) ? $this->phraseEditor(true) : false;
264  if (!$hasErrors) {
265  $this->object->title = $_POST["title"];
266  $categories = new SurveyCategories();
267  foreach ($_POST['answers']['answer'] as $key => $value) {
268  if (strlen($value)) {
269  $categories->addCategory($value, $_POST['answers']['other'][$key], 0, null, $_POST['answers']['scale'][$key]);
270  }
271  }
272  if (strlen($_POST['answers']['neutral'])) {
273  $categories->addCategory($_POST['answers']['neutral'], 0, 1, null, $_POST['answers_neutral_scale']);
274  }
275  $this->object->categories = $categories;
276  return 0;
277  } else {
278  return 1;
279  }
280  }
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 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: