48 $this->rbacsystem = $DIC->rbac()->system();
49 $this->
toolbar = $DIC->toolbar();
50 $this->db = $DIC->database();
51 $lng = $DIC->language();
53 $ilCtrl = $DIC->ctrl();
54 $tree = $DIC->repositoryTree();
58 $this->
ctrl = $ilCtrl;
61 $this->ref_id = $a_object->
getRefId();
62 $this->
ctrl->saveParameter($this,
"p_id");
63 $this->request = $DIC->surveyQuestionPool()
72 $cmd = $this->
ctrl->getCmd();
73 $next_class = $this->
ctrl->getNextClass($this);
75 switch ($next_class) {
88 $checked_phrases = $this->request->getPhraseIds();
89 if (count($checked_phrases) > 0) {
90 $this->tpl->setOnScreenMessage(
'question', $this->
lng->txt(
"qpl_confirm_delete_phrases"));
93 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_delete_phrase_select_none"));
106 $this->
ctrl->setParameter($this,
"p_id",
"");
108 if ($rbacsystem->
checkAccess(
"write", $this->ref_id)) {
110 $button->setCaption(
"phrase_new");
111 $button->setUrl($this->
ctrl->getLinkTarget($this,
"newPhrase"));
112 $ilToolbar->addButtonInstance($button);
117 foreach ($phrases as $phrase_id => $phrase_array) {
119 $data[] = array(
'phrase_id' => $phrase_id,
120 'phrase' => $phrase_array[
"title"],
121 'answers' => implode(
", ", $categories)
124 $table_gui->setData(
$data);
125 $this->tpl->setContent($table_gui->getHTML());
127 $this->tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"cannot_manage_phrases"));
133 $this->
ctrl->redirect($this,
"phrases");
138 $phrases = $this->request->getPhraseIds();
139 $this->
object->deletePhrases($phrases);
140 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
"qpl_phrases_deleted"),
true);
141 $this->
ctrl->redirect($this,
"phrases");
155 $result =
$ilDB->queryF(
156 "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",
160 if ($result->numRows() > 0) {
162 $categories->addCategory(
$data[
"title"], 0,
$data[
"neutral"], null,
$data[
'sequence']);
176 $result =
$ilDB->queryF(
177 "SELECT svy_phrase.title FROM svy_phrase WHERE svy_phrase.phrase_id = %s",
181 if ($result->numRows() > 0) {
182 $row =
$ilDB->fetchAssoc($result);
183 return $row[
'title'];
193 array $checked_phrases
198 foreach ($checked_phrases as $phrase_id) {
199 $phrase_array = $phrases[$phrase_id];
201 $data[] = array(
'phrase_id' => $phrase_id,
202 'phrase' => $phrase_array[
"title"],
203 'answers' => implode(
", ", $categories)
206 $table_gui->setData(
$data);
207 $this->tpl->setVariable(
'ADM_CONTENT', $table_gui->getHTML());
212 $this->
ctrl->redirect($this,
'phrases');
219 if ($this->request->getPhraseId()) {
220 $this->
object->updatePhrase($this->request->getPhraseId());
221 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'phrase_saved'),
true);
223 $this->
object->savePhrase();
224 $this->tpl->setOnScreenMessage(
'success', $this->
lng->txt(
'phrase_added'),
true);
226 $this->
ctrl->redirect($this,
'phrases');
240 $this->
object->title = $form->
getInput(
"title");
243 $answers = $this->request->getAnswers();
244 foreach ($answers[
'answer'] as
$key => $value) {
245 if (strlen($value)) {
246 $categories->addCategory($value, $answers[
'other'][
$key] ?? 0, 0, null, $answers[
'scale'][$key] ?? null);
249 if ($this->request->getNeutral() !==
"") {
250 $categories->addCategory(
251 $this->request->getNeutral(),
255 $this->request->getNeutralScale() ? (
int) $this->request->getNeutralScale() : null
258 $this->
object->categories = $categories;
267 $this->
ctrl->redirect($this,
'phraseEditor');
272 $ids = $this->request->getPhraseIds();
273 if (count($ids) === 0) {
274 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'no_phrase_selected'),
true);
275 $this->
ctrl->redirect($this,
'phrases');
277 if (count($ids) > 1) {
278 $this->tpl->setOnScreenMessage(
'failure', $this->
lng->txt(
'select_max_one_item'),
true);
279 $this->
ctrl->redirect($this,
'phrases');
281 $phrase_id = $ids[key($ids)];
283 $this->
ctrl->setParameter($this,
'p_id', $phrase_id);
285 $this->
ctrl->redirect($this,
'phraseEditor');
289 bool $checkonly =
false 291 $save = strcmp($this->
ctrl->getCmd(),
"saveEditPhrase") === 0;
294 $form->setFormAction($this->
ctrl->getFormAction($this,
'phraseEditor'));
295 $form->setTitle($this->
lng->txt(
'edit_phrase'));
296 $form->setMultipart(
false);
297 $form->setTableWidth(
"100%");
298 $form->setId(
"phraseeditor");
300 $phrase_id = $this->request->getPhraseId();
305 $title->setRequired(
true);
306 $form->addItem($title);
311 $answers->setAllowMove(
true);
312 $answers->setShowWizard(
false);
313 $answers->setShowSavePhrase(
false);
314 $answers->setUseOtherAnswer(
false);
315 $answers->setShowNeutralCategory(
true);
316 $answers->setNeutralCategoryTitle($this->
lng->txt(
'matrix_neutral_answer'));
318 if (!$categories->getCategoryCount()) {
319 $categories->addCategory(
"");
321 $answers->setValues($categories);
322 $answers->setDisabledScale(
true);
323 $form->addItem($answers);
325 $form->addCommandButton(
"saveEditPhrase", $this->
lng->txt(
"save"));
326 $form->addCommandButton(
"cancelEditPhrase", $this->
lng->txt(
"cancel"));
331 $form->setValuesByPost();
332 $errors = !$form->checkInput();
333 $form->setValuesByPost();
340 $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
Class ilObjSurveyQuestionPoolGUI.
deletePhrasesForm(array $checked_phrases)
Creates a confirmation form to delete personal phases from the database.
EditingGUIRequest $request
getPhraseTitle(int $phrase_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getCategoriesForPhrase(int $phrase_id)
Survey phrases GUI class The ilSurveyPhrases GUI class creates the GUI output for survey phrases (col...
checkAccess(string $a_operations, int $a_ref_id, string $a_type="")
checkAccess represents the main method of the RBAC-system in ILIAS3 developers want to use With this ...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
form( $class_path, string $cmd)
static _getCategoriesForPhrase(int $phrase_id)
Gets the available categories for a given phrase.
static _getAvailablePhrases(bool $useronly=false)
Gets the available phrases from the database.
writePostData(bool $always=false)
Evaluates a posted edit form and writes the form data in the question object.
phraseEditor(bool $checkonly=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
deletePhrase()
Creates a confirmation form to delete personal phases from the database.
__construct(ilObjSurveyQuestionPoolGUI $a_object)