ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSurveyConstraintsGUI Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilSurveyConstraintsGUI:

Public Member Functions

 executeCommand ()
 
 constraintsObject ()
 Administration page for survey constraints. More...
 
 constraintsAddObject ()
 Add a precondition for a survey question or question block. More...
 
 constraintStep1Object ($start=null)
 Handles the first step of the precondition add action. More...
 
 constraintStep2Object ()
 Handles the second step of the precondition add action. More...
 
 constraintStep3Object ()
 Handles the third step of the precondition add action. More...
 
 constraintForm (int $step, array $postvalues, array $survey_questions, ?array $questions=null)
 
 confirmDeleteConstraintsObject ()
 Delete constraint confirmation. More...
 
 deleteConstraintsObject ()
 
 createConstraintsObject ()
 
 editPreconditionObject ()
 

Protected Member Functions

 getConstraintParsFromPost ()
 
 validateConstraintForEdit (int $a_id)
 Validate if given constraint id is part of current survey and there are sufficient permissions to edit. More...
 

Protected Attributes

ILIAS Survey Editing EditingGUIRequest $request
 
ILIAS Survey Editing EditManager $edit_manager
 
ilObjSurvey $object
 
ilObjSurveyGUI $parent_gui
 
ilCtrl $ctrl
 
ilLanguage $lng
 
ilGlobalTemplateInterface $tpl
 
ilAccessHandler $access
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m ilSurveyConstraintsGUI:

Definition at line 23 of file class.ilSurveyConstraintsGUI.php.

Member Function Documentation

◆ confirmDeleteConstraintsObject()

ilSurveyConstraintsGUI::confirmDeleteConstraintsObject ( )

Delete constraint confirmation.

Definition at line 371 of file class.ilSurveyConstraintsGUI.php.

References $id, $relation, SurveyQuestion\_getQuestionType(), SurveyQuestion\_includeClass(), ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and validateConstraintForEdit().

371  : void
372  {
373  $id = (int) $this->request->getPrecondition();
374  if (!$this->validateConstraintForEdit($id)) {
375  $this->ctrl->redirect($this, "constraints");
376  }
377 
378  $constraint = $this->object->getPrecondition($id);
379  $questions = $this->object->getSurveyQuestions();
380  $question = $questions[$constraint["question_fi"]];
381  $relation = $questions[$constraint["ref_question_fi"]];
382  $relation = $relation["title"];
383 
384  // see ilSurveyConstraintsTableGUI
385  $question_type = SurveyQuestion::_getQuestionType($constraint["question_fi"]);
386  SurveyQuestion::_includeClass($question_type);
387  $question_obj = new $question_type();
388  $question_obj->loadFromDb($constraint["question_fi"]);
389  $valueoutput = $question_obj->getPreconditionValueOutput($constraint["value"]);
390 
391  $title = $question["title"] . " " . $constraint["shortname"] . " " . $valueoutput;
392 
393  $this->ctrl->saveParameter($this, "precondition");
394 
395  $cgui = new ilConfirmationGUI();
396  $cgui->setHeaderText(sprintf($this->lng->txt("survey_sure_delete_constraint"), $title, $relation));
397 
398  $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteConstraints"));
399  $cgui->setCancel($this->lng->txt("cancel"), "constraints");
400  $cgui->setConfirm($this->lng->txt("confirm"), "deleteConstraints");
401 
402  $this->tpl->setContent($cgui->getHTML());
403  }
$relation
static _getQuestionType(int $question_id)
Returns the question type of a question with a given id.
validateConstraintForEdit(int $a_id)
Validate if given constraint id is part of current survey and there are sufficient permissions to edi...
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ constraintForm()

ilSurveyConstraintsGUI::constraintForm ( int  $step,
array  $postvalues,
array  $survey_questions,
?array  $questions = null 
)

Definition at line 245 of file class.ilSurveyConstraintsGUI.php.

References $relation, SurveyQuestion\_getQuestionTypeName(), SurveyQuestion\_includeClass(), ilRadioGroupInputGUI\addOption(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

Referenced by constraintStep1Object(), constraintStep2Object(), and constraintStep3Object().

250  : void {
251  if ((string) $this->request->getStart() !== '') {
252  $this->ctrl->setParameter($this, "start", $this->request->getStart());
253  }
254  $this->ctrl->saveParameter($this, "precondition");
255  $form = new ilPropertyFormGUI();
256  $form->setFormAction($this->ctrl->getFormAction($this));
257  $form->setTableWidth("100%");
258  $form->setId("constraintsForm");
259 
260  $constraint_structure = $this->edit_manager->getConstraintStructure();
261 
262  // #9366
263  $title = array();
264  $title_ids = $this->edit_manager->getConstraintElements();
265  if (!$title_ids) {
266  $title_ids = array($this->request->getStart());
267  }
268  foreach ($title_ids as $title_id) {
269  // question block
270  if ($survey_questions[$constraint_structure[$title_id][0]]["questionblock_id"] > 0) {
271  $title[] = $this->lng->txt("questionblock") . ": " . $survey_questions[$constraint_structure[$title_id][0]]["questionblock_title"];
272  }
273  // question
274  else {
275  $title[] = $this->lng->txt($survey_questions[$constraint_structure[$title_id][0]]["type_tag"]) . ": " .
276  $survey_questions[$constraint_structure[$title_id][0]]["title"];
277  }
278  }
279  $header = new ilFormSectionHeaderGUI();
280  $header->setTitle(implode("<br/>", $title));
281  $form->addItem($header);
282 
283  $fulfilled = new ilRadioGroupInputGUI($this->lng->txt("constraint_fulfilled"), "c");
284  $fulfilled->addOption(new ilRadioOption($this->lng->txt("conjunction_and"), '0', ''));
285  $fulfilled->addOption(new ilRadioOption($this->lng->txt("conjunction_or"), '1', ''));
286  $fulfilled->setValue((strlen($postvalues['c'])) ? $postvalues['c'] : 0);
287  $form->addItem($fulfilled);
288 
289  $step1 = new ilSelectInputGUI($this->lng->txt("step") . " 1: " . $this->lng->txt("select_prior_question"), "q");
290  $options = array();
291  if (is_array($questions)) {
292  foreach ($questions as $question) {
293  $options[$question["question_id"]] = $question["title"] . " (" . SurveyQuestion::_getQuestionTypeName($question["type_tag"]) . ")";
294  }
295  }
296  $step1->setOptions($options);
297  $step1->setValue($postvalues["q"]);
298  $form->addItem($step1);
299 
300  if ($step > 1) {
301  $relations = $this->object->getAllRelations();
302  $step2 = new ilSelectInputGUI($this->lng->txt("step") . " 2: " . $this->lng->txt("select_relation"), "r");
303  $options = array();
304  foreach ($relations as $rel_id => $relation) {
305  if (in_array($relation["short"], $survey_questions[$postvalues["q"]]["availableRelations"])) {
306  $options[$rel_id] = $relation['short'];
307  }
308  }
309  $step2->setOptions($options);
310  $step2->setValue($postvalues["r"]);
311  $form->addItem($step2);
312  }
313 
314  if ($step > 2) {
315  $variables = $this->object->getVariables($postvalues["q"]);
316  $question_type = $survey_questions[$postvalues["q"]]["type_tag"];
317  SurveyQuestion::_includeClass($question_type);
318  $question = new $question_type();
319  $question->loadFromDb($postvalues["q"]);
320 
321  $step3 = $question->getPreconditionSelectValue($postvalues["v"], $this->lng->txt("step") . " 3: " . $this->lng->txt("select_value"), "v");
322  $form->addItem($step3);
323  }
324 
325  $cmd_back = "";
326  $cmd_continue = "";
327 
328  switch ($step) {
329  case 1:
330  $cmd_continue = "constraintStep2";
331  $cmd_back = "constraints";
332  break;
333  case 2:
334  $cmd_continue = "constraintStep3";
335  $cmd_back = "constraintStep1";
336  break;
337  case 3:
338  $cmd_continue = "constraintsAdd";
339  $cmd_back = "constraintStep2";
340  break;
341  }
342  $form->addCommandButton($cmd_back, $this->lng->txt("back"));
343  $form->addCommandButton($cmd_continue, $this->lng->txt("continue"));
344 
345  $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
346  }
This class represents an option in a radio group.
$relation
This class represents a selection list property in a property form.
static _getQuestionTypeName(string $type_tag)
Return the translation for a given question type.
addOption(ilRadioOption $a_option)
This class represents a property in a property form.
static _includeClass(string $question_type, int $gui=0)
Include the php class file for a given question type.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constraintsAddObject()

ilSurveyConstraintsGUI::constraintsAddObject ( )

Add a precondition for a survey question or question block.

Definition at line 107 of file class.ilSurveyConstraintsGUI.php.

References $structure, constraintStep3Object(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

107  : void
108  {
109  if ($this->request->getConstraintPar("v") === '') {
110  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("msg_enter_value_for_valid_constraint"));
111  $this->constraintStep3Object();
112  return;
113  }
114  $survey_questions = $this->object->getSurveyQuestions();
115  $structure = $this->edit_manager->getConstraintStructure();
116  $include_elements = $this->edit_manager->getConstraintElements();
117  foreach ($include_elements as $elementCounter) {
118  if (is_array($structure[$elementCounter])) {
119  if ($this->request->getPrecondition() !== '') {
120  $this->object->updateConstraint(
121  $this->request->getPrecondition(),
122  $this->request->getConstraintPar("q"),
123  $this->request->getConstraintPar("r"),
124  $this->request->getConstraintPar("v"),
125  $this->request->getConstraintPar("c")
126  );
127  } else {
128  $constraint_id = $this->object->addConstraint(
129  $this->request->getConstraintPar("q"),
130  $this->request->getConstraintPar("r"),
131  $this->request->getConstraintPar("v"),
132  $this->request->getConstraintPar("c")
133  );
134  foreach ($structure[$elementCounter] as $key => $question_id) {
135  $this->object->addConstraintToQuestion($question_id, $constraint_id);
136  }
137  }
138  if (count($structure[$elementCounter]) > 1) {
139  $this->object->updateConjunctionForQuestions(
140  $structure[$elementCounter],
141  $this->request->getConstraintPar("c")
142  );
143  }
144  }
145  }
146  $this->edit_manager->clearConstraintElements();
147  $this->edit_manager->clearConstraintStructure();
148  $this->ctrl->redirect($this, "constraints");
149  }
$structure
TOTAL STRUCTURE.
constraintStep3Object()
Handles the third step of the precondition add action.
+ Here is the call graph for this function:

◆ constraintsObject()

ilSurveyConstraintsGUI::constraintsObject ( )

Administration page for survey constraints.

Definition at line 77 of file class.ilSurveyConstraintsGUI.php.

References ilObjSurvey\_hasDatasets(), constraintStep1Object(), and ILIAS\Repository\object().

77  : void
78  {
79  $step = $this->request->getStep();
80  switch ($step) {
81  case 1:
82  $this->constraintStep1Object();
83  return;
84  case 3:
85  case 2:
86  return;
87  }
88 
89  $hasDatasets = ilObjSurvey::_hasDatasets($this->object->getSurveyId());
90 
91  $tbl = new SurveyConstraintsTableGUI($this, "constraints", $this->object, $hasDatasets);
92 
93  $mess = "";
94  if ($hasDatasets) {
96  $mess = $mbox->getHTML();
97  } else {
98  $this->edit_manager->setConstraintStructure($tbl->getStructure());
99  }
100 
101  $this->tpl->setContent($mess . $tbl->getHTML());
102  }
static _hasDatasets(int $survey_id)
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...
constraintStep1Object($start=null)
Handles the first step of the precondition add action.
+ Here is the call graph for this function:

◆ constraintStep1Object()

ilSurveyConstraintsGUI::constraintStep1Object (   $start = null)

Handles the first step of the precondition add action.

Definition at line 154 of file class.ilSurveyConstraintsGUI.php.

References $structure, constraintForm(), ILIAS\Repository\ctrl(), getConstraintParsFromPost(), and ILIAS\Repository\lng().

Referenced by constraintsObject(), and createConstraintsObject().

154  : void
155  {
156  $survey_questions = $this->object->getSurveyQuestions();
157  $structure = $this->edit_manager->getConstraintStructure();
158  if (is_null($start)) {
159  $start = $this->request->getStart();
160  }
161  $option_questions = array();
162  for ($i = 1; $i < $start; $i++) {
163  if (is_array($structure[$i])) {
164  foreach ($structure[$i] as $key => $question_id) {
165  if ($survey_questions[$question_id]["usableForPrecondition"]) {
166  $option_questions[] = array("question_id" => $survey_questions[$question_id]["question_id"],
167  "title" => $survey_questions[$question_id]["title"],
168  "type_tag" => $survey_questions[$question_id]["type_tag"]
169  );
170  }
171  }
172  }
173  }
174  if (count($option_questions) === 0) {
175  $this->edit_manager->clearConstraintElements();
176  $this->edit_manager->clearConstraintStructure();
177  $this->tpl->setOnScreenMessage('info', $this->lng->txt("constraints_no_nonessay_available"), true);
178  $this->ctrl->redirect($this, "constraints");
179  }
180  $this->constraintForm(1, $this->getConstraintParsFromPost(), $survey_questions, $option_questions);
181  }
$structure
TOTAL STRUCTURE.
constraintForm(int $step, array $postvalues, array $survey_questions, ?array $questions=null)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ constraintStep2Object()

ilSurveyConstraintsGUI::constraintStep2Object ( )

Handles the second step of the precondition add action.

Definition at line 186 of file class.ilSurveyConstraintsGUI.php.

References $q, constraintForm(), and getConstraintParsFromPost().

186  : void
187  {
188  $survey_questions = $this->object->getSurveyQuestions();
189  $option_questions = array();
190  $q = $this->request->getConstraintPar("q");
191  $option_questions[] = array(
192  "question_id" => $q,
193  "title" => $survey_questions[$q]["title"],
194  "type_tag" => $survey_questions[$q]["type_tag"]
195  );
196  $this->constraintForm(2, $this->getConstraintParsFromPost(), $survey_questions, $option_questions);
197  }
constraintForm(int $step, array $postvalues, array $survey_questions, ?array $questions=null)
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

◆ constraintStep3Object()

ilSurveyConstraintsGUI::constraintStep3Object ( )

Handles the third step of the precondition add action.

Definition at line 202 of file class.ilSurveyConstraintsGUI.php.

References $q, constraintForm(), ILIAS\Repository\ctrl(), getConstraintParsFromPost(), and validateConstraintForEdit().

Referenced by constraintsAddObject().

202  : void
203  {
204  $survey_questions = $this->object->getSurveyQuestions();
205  $option_questions = array();
206  if ($this->request->getPrecondition() !== '') {
207  if (!$this->validateConstraintForEdit($this->request->getPrecondition())) {
208  $this->ctrl->redirect($this, "constraints");
209  }
210 
211  $pc = $this->object->getPrecondition($this->request->getPrecondition());
212  $postvalues = array(
213  "c" => $pc["conjunction"],
214  "q" => $pc["question_fi"],
215  "r" => $pc["relation_id"],
216  "v" => $pc["value"]
217  );
218  $option_questions[] = array("question_id" => $pc["question_fi"],
219  "title" => $survey_questions[$pc["question_fi"]]["title"],
220  "type_tag" => $survey_questions[$pc["question_fi"]]["type_tag"]
221  );
222  $this->constraintForm(3, $postvalues, $survey_questions, $option_questions);
223  } else {
224  $q = $this->request->getConstraintPar("q");
225  $option_questions[] = array(
226  "question_id" => $q,
227  "title" => $survey_questions[$q]["title"],
228  "type_tag" => $survey_questions[$q]["type_tag"]
229  );
230  $this->constraintForm(3, $this->getConstraintParsFromPost(), $survey_questions, $option_questions);
231  }
232  }
validateConstraintForEdit(int $a_id)
Validate if given constraint id is part of current survey and there are sufficient permissions to edi...
constraintForm(int $step, array $postvalues, array $survey_questions, ?array $questions=null)
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createConstraintsObject()

ilSurveyConstraintsGUI::createConstraintsObject ( )

Definition at line 416 of file class.ilSurveyConstraintsGUI.php.

References constraintStep1Object(), ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), and ILIAS\UI\examples\Symbol\Glyph\Sort\sort().

416  : void
417  {
418  $include_elements = $this->request->getIncludeElements();
419  if (count($include_elements) === 0) {
420  $this->tpl->setOnScreenMessage('info', $this->lng->txt("constraints_no_questions_or_questionblocks_selected"), true);
421  $this->ctrl->redirect($this, "constraints");
422  } elseif (count($include_elements) >= 1) {
423  $this->edit_manager->setConstraintElements($include_elements);
424  sort($include_elements, SORT_NUMERIC);
425  $this->constraintStep1Object($include_elements[0]);
426  }
427  }
sort()
description: > Example for rendering a Sort Glyph.
Definition: sort.php:41
constraintStep1Object($start=null)
Handles the first step of the precondition add action.
+ Here is the call graph for this function:

◆ deleteConstraintsObject()

ilSurveyConstraintsGUI::deleteConstraintsObject ( )

Definition at line 405 of file class.ilSurveyConstraintsGUI.php.

References $id, ILIAS\Repository\ctrl(), ILIAS\Repository\int(), ILIAS\Repository\lng(), and validateConstraintForEdit().

405  : void
406  {
407  $id = (int) $this->request->getPrecondition();
408  if ($this->validateConstraintForEdit($id)) {
409  $this->tpl->setOnScreenMessage('success', $this->lng->txt("survey_constraint_deleted"), true);
410  $this->object->deleteConstraint($id);
411  }
412 
413  $this->ctrl->redirect($this, "constraints");
414  }
validateConstraintForEdit(int $a_id)
Validate if given constraint id is part of current survey and there are sufficient permissions to edi...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ editPreconditionObject()

ilSurveyConstraintsGUI::editPreconditionObject ( )
Exceptions
ilCtrlException

Definition at line 432 of file class.ilSurveyConstraintsGUI.php.

References ILIAS\Repository\ctrl(), and validateConstraintForEdit().

432  : void
433  {
434  if (!$this->validateConstraintForEdit($this->request->getPrecondition())) {
435  $this->ctrl->redirect($this, "constraints");
436  }
437 
438  $this->edit_manager->setConstraintElements([$this->request->getStart()]);
439  $this->ctrl->setParameter($this, "precondition", $this->request->getPrecondition());
440  $this->ctrl->setParameter($this, "start", $this->request->getStart());
441  $this->ctrl->redirect($this, "constraintStep3");
442  }
validateConstraintForEdit(int $a_id)
Validate if given constraint id is part of current survey and there are sufficient permissions to edi...
+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyConstraintsGUI::executeCommand ( )

Definition at line 64 of file class.ilSurveyConstraintsGUI.php.

References $ctrl, and ilCtrl\getCmd().

64  : void
65  {
66  $ilCtrl = $this->ctrl;
67 
68  $cmd = $ilCtrl->getCmd("constraints");
69  $cmd .= "Object";
70 
71  $this->$cmd();
72  }
getCmd(?string $fallback_command=null)
+ Here is the call graph for this function:

◆ getConstraintParsFromPost()

ilSurveyConstraintsGUI::getConstraintParsFromPost ( )
protected

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

Referenced by constraintStep1Object(), constraintStep2Object(), and constraintStep3Object().

234  : array
235  {
236  return [
237  "c" => $this->request->getConstraintPar("c"),
238  "q" => $this->request->getConstraintPar("q"),
239  "r" => $this->request->getConstraintPar("r"),
240  "v" => $this->request->getConstraintPar("v")
241  ];
242  }
+ Here is the caller graph for this function:

◆ validateConstraintForEdit()

ilSurveyConstraintsGUI::validateConstraintForEdit ( int  $a_id)
protected

Validate if given constraint id is part of current survey and there are sufficient permissions to edit.

Todo:
actually the ID is not checked against the survey

Definition at line 353 of file class.ilSurveyConstraintsGUI.php.

References $access, ilObjSurvey\_hasDatasets(), and ILIAS\Repository\object().

Referenced by confirmDeleteConstraintsObject(), constraintStep3Object(), deleteConstraintsObject(), and editPreconditionObject().

355  : bool {
356  $ilAccess = $this->access;
357 
358  if (ilObjSurvey::_hasDatasets($this->object->getSurveyId())) {
359  return false;
360  }
361  if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
362  return false;
363  }
364 
365  return true;
366  }
static _hasDatasets(int $survey_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilAccessHandler ilSurveyConstraintsGUI::$access
protected

Definition at line 32 of file class.ilSurveyConstraintsGUI.php.

Referenced by validateConstraintForEdit().

◆ $ctrl

ilCtrl ilSurveyConstraintsGUI::$ctrl
protected

Definition at line 29 of file class.ilSurveyConstraintsGUI.php.

Referenced by executeCommand().

◆ $edit_manager

ILIAS Survey Editing EditManager ilSurveyConstraintsGUI::$edit_manager
protected

Definition at line 26 of file class.ilSurveyConstraintsGUI.php.

◆ $lng

ilLanguage ilSurveyConstraintsGUI::$lng
protected

Definition at line 30 of file class.ilSurveyConstraintsGUI.php.

◆ $object

ilObjSurvey ilSurveyConstraintsGUI::$object
protected

Definition at line 27 of file class.ilSurveyConstraintsGUI.php.

◆ $parent_gui

ilObjSurveyGUI ilSurveyConstraintsGUI::$parent_gui
protected

Definition at line 28 of file class.ilSurveyConstraintsGUI.php.

◆ $request

ILIAS Survey Editing EditingGUIRequest ilSurveyConstraintsGUI::$request
protected

Definition at line 25 of file class.ilSurveyConstraintsGUI.php.

◆ $tpl

ilGlobalTemplateInterface ilSurveyConstraintsGUI::$tpl
protected

Definition at line 31 of file class.ilSurveyConstraintsGUI.php.


The documentation for this class was generated from the following file: