54 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
59 $this->gui_object =& $a_object;
62 $this->ref_id = $a_object->ref_id;
63 $this->ctrl->saveParameter($this,
"p_id");
71 $cmd = $this->ctrl->getCmd();
72 $next_class = $this->ctrl->getNextClass($this);
99 $checked_phrases =
$_POST[
'phrase'];
100 if (count($checked_phrases))
121 global $rbacsystem, $ilToolbar;
123 $this->ctrl->setParameter($this,
"p_id",
"");
125 if ($rbacsystem->checkAccess(
"write", $this->ref_id))
127 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
129 $button->setCaption(
"phrase_new");
130 $button->setUrl($this->ctrl->getLinkTarget($this,
"newPhrase"));
131 $ilToolbar->addButtonInstance($button);
133 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
137 foreach ($phrases as $phrase_id => $phrase_array)
140 array_push($data, array(
'phrase_id' => $phrase_id,
'phrase' => $phrase_array[
"title"],
'answers' => join($categories,
", ")));
142 $table_gui->setData($data);
143 $this->tpl->setContent($table_gui->getHTML());
156 $this->ctrl->redirect($this,
"phrases");
164 $phrases =
$_POST[
'phrase'];
165 $this->
object->deletePhrases($phrases);
167 $this->ctrl->redirect($this,
"phrases");
174 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
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",
182 while ($data = $ilDB->fetchAssoc(
$result))
184 $categories->addCategory($data[
"title"], 0, $data[
"neutral"], null, $data[
'sequence']);
194 $result = $ilDB->queryF(
"SELECT svy_phrase.title FROM svy_phrase WHERE svy_phrase.phrase_id = %s",
201 return $row[
'title'];
213 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
217 foreach ($checked_phrases as $phrase_id)
219 $phrase_array = $phrases[$phrase_id];
221 array_push($data, array(
'phrase_id' => $phrase_id,
'phrase' => $phrase_array[
"title"],
'answers' => join($categories,
", ")));
223 $table_gui->setData($data);
224 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
229 $this->ctrl->redirect($this,
'phrases');
239 $this->
object->updatePhrase(
$_GET[
'p_id']);
244 $this->
object->savePhrase();
247 $this->ctrl->redirect($this,
'phrases');
260 $hasErrors = (!$always) ? $this->
phraseEditor(
true) :
false;
263 $this->
object->title =
$_POST[
"title"];
264 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
266 foreach (
$_POST[
'answers'][
'answer'] as $key => $value)
268 if (strlen($value)) $categories->addCategory($value,
$_POST[
'answers'][
'other'][$key], 0, null,
$_POST[
'answers'][
'scale'][$key]);
270 if (strlen(
$_POST[
'answers'][
'neutral']))
272 $categories->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, null,
$_POST[
'answers_neutral_scale']);
274 $this->
object->categories = $categories;
285 $this->ctrl->redirect($this,
'phraseEditor');
290 if (!array_key_exists(
'phrase',
$_POST))
293 $this->ctrl->redirect($this,
'phrases');
295 if ((array_key_exists(
'phrase',
$_POST)) && count(
$_POST[
'phrase']) > 1)
298 $this->ctrl->redirect($this,
'phrases');
300 $phrase_id = (array_key_exists(
'phrase',
$_POST)) ?
$_POST[
'phrase'][key(
$_POST[
'phrase'])] : null;
303 $this->ctrl->setParameter($this,
'p_id', $phrase_id);
305 $this->ctrl->redirect($this,
'phraseEditor');
310 $save = (strcmp($this->ctrl->getCmd(),
"saveEditPhrase") == 0) ? TRUE : FALSE;
312 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
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");
320 $phrase_id =
$_GET[
'p_id'];
325 $title->setRequired(TRUE);
326 $form->addItem($title);
329 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
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";
340 if (!$categories->getCategoryCount())
342 $categories->addCategory(
"");
344 $answers->setValues($categories);
345 $answers->setDisabledScale(
true);
346 $form->addItem($answers);
348 $form->addCommandButton(
"saveEditPhrase", $this->lng->txt(
"save"));
349 $form->addCommandButton(
"cancelEditPhrase", $this->lng->txt(
"cancel"));
355 $form->setValuesByPost();
356 $errors = !$form->checkInput();
357 $form->setValuesByPost();
358 if (
$errors) $checkonly =
false;
361 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());