68 $this->rbacsystem = $DIC->rbac()->system();
69 $this->toolbar = $DIC->toolbar();
70 $this->db = $DIC->database();
71 $lng = $DIC->language();
74 $tree = $DIC->repositoryTree();
76 include_once
"./Modules/SurveyQuestionPool/classes/class.ilSurveyPhrases.php";
80 $this->gui_object = $a_object;
83 $this->ref_id = $a_object->ref_id;
84 $this->ctrl->saveParameter($this,
"p_id");
92 $cmd = $this->ctrl->getCmd();
93 $next_class = $this->ctrl->getNextClass($this);
96 switch ($next_class) {
98 $ret = &$this->$cmd();
119 $checked_phrases =
$_POST[
'phrase'];
120 if (count($checked_phrases)) {
141 $this->ctrl->setParameter($this,
"p_id",
"");
143 if (
$rbacsystem->checkAccess(
"write", $this->ref_id)) {
144 include_once
"Services/UIComponent/Button/classes/class.ilLinkButton.php";
146 $button->setCaption(
"phrase_new");
147 $button->setUrl($this->ctrl->getLinkTarget($this,
"newPhrase"));
148 $ilToolbar->addButtonInstance($button);
150 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
154 foreach ($phrases as $phrase_id => $phrase_array) {
156 array_push(
$data, array(
'phrase_id' => $phrase_id,
'phrase' => $phrase_array[
"title"],
'answers' => join(
", ", $categories)));
158 $table_gui->setData(
$data);
159 $this->tpl->setContent($table_gui->getHTML());
170 $this->ctrl->redirect($this,
"phrases");
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");
188 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
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",
197 $categories->addCategory(
$data[
"title"], 0,
$data[
"neutral"], null,
$data[
'sequence']);
208 "SELECT svy_phrase.title FROM svy_phrase WHERE svy_phrase.phrase_id = %s",
214 return $row[
'title'];
226 include_once
"./Modules/SurveyQuestionPool/classes/tables/class.ilSurveyPhrasesTableGUI.php";
230 foreach ($checked_phrases as $phrase_id) {
231 $phrase_array = $phrases[$phrase_id];
233 array_push(
$data, array(
'phrase_id' => $phrase_id,
'phrase' => $phrase_array[
"title"],
'answers' => join(
", ", $categories)));
235 $table_gui->setData(
$data);
236 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
241 $this->ctrl->redirect($this,
'phrases');
249 $this->
object->updatePhrase(
$_GET[
'p_id']);
250 ilUtil::sendSuccess($this->lng->txt(
'phrase_saved'),
true);
252 $this->
object->savePhrase();
253 ilUtil::sendSuccess($this->lng->txt(
'phrase_added'),
true);
255 $this->ctrl->redirect($this,
'phrases');
268 $hasErrors = (!$always) ? $this->
phraseEditor(
true) :
false;
270 $this->
object->title =
$_POST[
"title"];
271 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
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]);
278 if (strlen(
$_POST[
'answers'][
'neutral'])) {
279 $categories->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, null,
$_POST[
'answers_neutral_scale']);
281 $this->
object->categories = $categories;
290 $this->ctrl->redirect($this,
'phraseEditor');
295 if (!array_key_exists(
'phrase',
$_POST)) {
297 $this->ctrl->redirect($this,
'phrases');
299 if ((array_key_exists(
'phrase',
$_POST)) && count(
$_POST[
'phrase']) > 1) {
301 $this->ctrl->redirect($this,
'phrases');
303 $phrase_id = (array_key_exists(
'phrase',
$_POST)) ?
$_POST[
'phrase'][key(
$_POST[
'phrase'])] : null;
305 $this->ctrl->setParameter($this,
'p_id', $phrase_id);
307 $this->ctrl->redirect($this,
'phraseEditor');
312 $save = (strcmp($this->ctrl->getCmd(),
"saveEditPhrase") == 0) ? true :
false;
314 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
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");
322 $phrase_id =
$_GET[
'p_id'];
327 $title->setRequired(
true);
331 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
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";
342 if (!$categories->getCategoryCount()) {
343 $categories->addCategory(
"");
345 $answers->setValues($categories);
346 $answers->setDisabledScale(
true);
347 $form->addItem($answers);
349 $form->addCommandButton(
"saveEditPhrase", $this->lng->txt(
"save"));
350 $form->addCommandButton(
"cancelEditPhrase", $this->lng->txt(
"cancel"));
355 $form->setValuesByPost();
357 $form->setValuesByPost();
364 $this->tpl->setVariable(
"ADM_CONTENT",
$form->getHTML());
confirmDeletePhrase()
confirm delete phrases
phraseEditor($checkonly=false)
static _getCategoriesForPhrase($phrase_id)
Gets the available categories for a given phrase.
Survey phrases GUI class.
executeCommand()
execute command
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
writePostData($always=false)
Evaluates a posted edit form and writes the form data in the question object.
if(isset($_POST['submit'])) $form
This class represents a text property in a property form.
__construct($a_object)
ilSurveyPhrasesGUI constructor
static sendQuestion($a_info="", $a_keep=false)
Send Question to Screen.
getPhraseTitle($phrase_id)
getCategoriesForPhrase($phrase_id)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
deletePhrasesForm($checked_phrases)
Creates a confirmation form to delete personal phases from the database.
cancelDeletePhrase()
cancel delete phrases
static _getAvailablePhrases($useronly=0)
Gets the available phrases from the database.
phrases()
Displays a form to manage the user created phrases.
getCommand($cmd)
Retrieves the ilCtrl command.
deletePhrase()
Creates a confirmation form to delete personal phases from the database.