ILIAS  release_7 Revision v7.30-3-g800a261c036
ilSurveyConstraintsGUI Class Reference

Class ilSurveyConstraintsGUI. More...

+ Collaboration diagram for ilSurveyConstraintsGUI:

Public Member Functions

 __construct (ilObjSurveyGUI $a_parent_gui)
 
 executeCommand ()
 
 constraintsObject ()
 Administration page for survey constraints. More...
 
 constraintsAddObject ()
 Add a precondition for a survey question or question block. More...
 
 constraintStep1Object ()
 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 ($step, $postvalues, &$survey_questions, $questions=false)
 
 confirmDeleteConstraintsObject ()
 Delete constraint confirmation. More...
 
 deleteConstraintsObject ()
 Delete constraints of a survey. More...
 
 createConstraintsObject ()
 
 editPreconditionObject ()
 

Protected Member Functions

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

Protected Attributes

 $ctrl
 
 $lng
 
 $tpl
 
 $access
 

Detailed Description

Class ilSurveyConstraintsGUI.

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
Version
Id
class.ilObjSurveyGUI.php 43670 2013-07-26 08:41:31Z jluetzen

@ilCtrl_Calls ilSurveyConstraintsGUI:

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

Constructor & Destructor Documentation

◆ __construct()

ilSurveyConstraintsGUI::__construct ( ilObjSurveyGUI  $a_parent_gui)

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

37 {
38 global $DIC;
39
40 $this->access = $DIC->access();
41 $ilCtrl = $DIC->ctrl();
42 $lng = $DIC->language();
43 $tpl = $DIC["tpl"];
44
45 $this->parent_gui = $a_parent_gui;
46 $this->object = $this->parent_gui->object;
47
48 $this->ctrl = $ilCtrl;
49 $this->lng = $lng;
50 $this->tpl = $tpl;
51 }
global $DIC
Definition: goto.php:24

References $DIC, $lng, and $tpl.

Member Function Documentation

◆ confirmDeleteConstraintsObject()

ilSurveyConstraintsGUI::confirmDeleteConstraintsObject ( )

Delete constraint confirmation.

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

315 {
316 $id = (int) $_REQUEST["precondition"];
317 if (!$this->validateConstraintForEdit($id)) {
318 $this->ctrl->redirect($this, "constraints");
319 }
320
321 $constraint = $this->object->getPrecondition($id);
322 $questions = $this->object->getSurveyQuestions();
323 $question = $questions[$constraint["question_fi"]];
324 $relation = $questions[$constraint["ref_question_fi"]];
325 $relation = $relation["title"];
326
327 // see ilSurveyConstraintsTableGUI
328 $question_type = SurveyQuestion::_getQuestionType($constraint["question_fi"]);
329 SurveyQuestion::_includeClass($question_type);
330 $question_obj = new $question_type();
331 $question_obj->loadFromDb($constraint["question_fi"]);
332 $valueoutput = $question_obj->getPreconditionValueOutput($constraint["value"]);
333
334 $title = $question["title"] . " " . $constraint["shortname"] . " " . $valueoutput;
335
336 $this->ctrl->saveParameter($this, "precondition");
337
338 $cgui = new ilConfirmationGUI();
339 $cgui->setHeaderText(sprintf($this->lng->txt("survey_sure_delete_constraint"), $title, $relation));
340
341 $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteConstraints"));
342 $cgui->setCancel($this->lng->txt("cancel"), "constraints");
343 $cgui->setConfirm($this->lng->txt("confirm"), "deleteConstraints");
344
345 $this->tpl->setContent($cgui->getHTML());
346 }
static _getQuestionType($question_id)
Returns the question type of a question with a given id.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
Confirmation screen class.
validateConstraintForEdit($a_id)
Validate if given constraint id is part of current survey and there are sufficient permissions to edi...

References SurveyQuestion\_getQuestionType(), SurveyQuestion\_includeClass(), and validateConstraintForEdit().

+ Here is the call graph for this function:

◆ constraintForm()

ilSurveyConstraintsGUI::constraintForm (   $step,
  $postvalues,
$survey_questions,
  $questions = false 
)

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

198 {
199 if (strlen($_GET["start"])) {
200 $this->ctrl->setParameter($this, "start", $_GET["start"]);
201 }
202 $this->ctrl->saveParameter($this, "precondition");
203 $form = new ilPropertyFormGUI();
204 $form->setFormAction($this->ctrl->getFormAction($this));
205 $form->setTableWidth("100%");
206 $form->setId("constraintsForm");
207
208 // #9366
209 $title = array();
210 $title_ids = $_SESSION["includeElements"];
211 if (!$title_ids) {
212 $title_ids = array($_GET["start"]);
213 }
214 foreach ($title_ids as $title_id) {
215 // question block
216 if ($survey_questions[$_SESSION["constraintstructure"][$title_id][0]]["questionblock_id"] > 0) {
217 $title[] = $this->lng->txt("questionblock") . ": " . $survey_questions[$_SESSION["constraintstructure"][$title_id][0]]["questionblock_title"];
218 }
219 // question
220 else {
221 $title[] = $this->lng->txt($survey_questions[$_SESSION["constraintstructure"][$title_id][0]]["type_tag"]) . ": " .
222 $survey_questions[$_SESSION["constraintstructure"][$title_id][0]]["title"];
223 }
224 }
225 $header = new ilFormSectionHeaderGUI();
226 $header->setTitle(implode("<br/>", $title));
227 $form->addItem($header);
228
229 $fulfilled = new ilRadioGroupInputGUI($this->lng->txt("constraint_fulfilled"), "c");
230 $fulfilled->addOption(new ilRadioOption($this->lng->txt("conjunction_and"), '0', ''));
231 $fulfilled->addOption(new ilRadioOption($this->lng->txt("conjunction_or"), '1', ''));
232 $fulfilled->setValue((strlen($postvalues['c'])) ? $postvalues['c'] : 0);
233 $form->addItem($fulfilled);
234
235 $step1 = new ilSelectInputGUI($this->lng->txt("step") . " 1: " . $this->lng->txt("select_prior_question"), "q");
236 $options = array();
237 if (is_array($questions)) {
238 foreach ($questions as $question) {
239 $options[$question["question_id"]] = $question["title"] . " (" . SurveyQuestion::_getQuestionTypeName($question["type_tag"]) . ")";
240 }
241 }
242 $step1->setOptions($options);
243 $step1->setValue($postvalues["q"]);
244 $form->addItem($step1);
245
246 if ($step > 1) {
247 $relations = $this->object->getAllRelations();
248 $step2 = new ilSelectInputGUI($this->lng->txt("step") . " 2: " . $this->lng->txt("select_relation"), "r");
249 $options = array();
250 foreach ($relations as $rel_id => $relation) {
251 if (in_array($relation["short"], $survey_questions[$postvalues["q"]]["availableRelations"])) {
252 $options[$rel_id] = $relation['short'];
253 }
254 }
255 $step2->setOptions($options);
256 $step2->setValue($postvalues["r"]);
257 $form->addItem($step2);
258 }
259
260 if ($step > 2) {
261 $variables = &$this->object->getVariables($postvalues["q"]);
262 $question_type = $survey_questions[$postvalues["q"]]["type_tag"];
263 SurveyQuestion::_includeClass($question_type);
264 $question = new $question_type();
265 $question->loadFromDb($postvalues["q"]);
266
267 $step3 = $question->getPreconditionSelectValue($postvalues["v"], $this->lng->txt("step") . " 3: " . $this->lng->txt("select_value"), "v");
268 $form->addItem($step3);
269 }
270
271 switch ($step) {
272 case 1:
273 $cmd_continue = "constraintStep2";
274 $cmd_back = "constraints";
275 break;
276 case 2:
277 $cmd_continue = "constraintStep3";
278 $cmd_back = "constraintStep1";
279 break;
280 case 3:
281 $cmd_continue = "constraintsAdd";
282 $cmd_back = "constraintStep2";
283 break;
284 }
285 $form->addCommandButton($cmd_back, $this->lng->txt("back"));
286 $form->addCommandButton($cmd_continue, $this->lng->txt("continue"));
287
288 $this->tpl->setVariable("ADM_CONTENT", $form->getHTML());
289 }
$_GET["client_id"]
$_SESSION["AccountId"]
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
This class represents a section header in a property form.
This class represents a property form user interface.
This class represents a property in a property form.
This class represents an option in a radio group.
This class represents a selection list property in a property form.

References $_GET, $_SESSION, SurveyQuestion\_getQuestionTypeName(), and SurveyQuestion\_includeClass().

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

+ 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 103 of file class.ilSurveyConstraintsGUI.php.

104 {
105 if (strlen($_POST["v"]) == 0) {
106 ilUtil::sendFailure($this->lng->txt("msg_enter_value_for_valid_constraint"));
107 return $this->constraintStep3Object();
108 }
109 $survey_questions = &$this->object->getSurveyQuestions();
110 $structure = &$_SESSION["constraintstructure"];
111 $include_elements = $_SESSION["includeElements"];
112 foreach ($include_elements as $elementCounter) {
113 if (is_array($structure[$elementCounter])) {
114 if (strlen($_GET["precondition"])) {
115 $this->object->updateConstraint($_GET['precondition'], $_POST["q"], $_POST["r"], $_POST["v"], $_POST['c']);
116 } else {
117 $constraint_id = $this->object->addConstraint($_POST["q"], $_POST["r"], $_POST["v"], $_POST['c']);
118 foreach ($structure[$elementCounter] as $key => $question_id) {
119 $this->object->addConstraintToQuestion($question_id, $constraint_id);
120 }
121 }
122 if (count($structure[$elementCounter]) > 1) {
123 $this->object->updateConjunctionForQuestions($structure[$elementCounter], $_POST['c']);
124 }
125 }
126 }
127 unset($_SESSION["includeElements"]);
128 unset($_SESSION["constraintstructure"]);
129 $this->ctrl->redirect($this, "constraints");
130 }
$_POST["username"]
constraintStep3Object()
Handles the third step of the precondition add action.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.

References $_GET, $_POST, $_SESSION, constraintStep3Object(), and ilUtil\sendFailure().

+ Here is the call graph for this function:

◆ constraintsObject()

ilSurveyConstraintsGUI::constraintsObject ( )

Administration page for survey constraints.

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

67 {
68 $step = 0;
69 if (array_key_exists("step", $_GET)) {
70 $step = (int) $_GET["step"];
71 }
72 switch ($step) {
73 case 1:
74 $this->constraintStep1Object();
75 return;
76 break;
77 case 2:
78 return;
79 break;
80 case 3:
81 return;
82 break;
83 }
84
85 $hasDatasets = ilObjSurvey::_hasDatasets($this->object->getSurveyId());
86
87 $tbl = new SurveyConstraintsTableGUI($this, "constraints", $this->object, $hasDatasets);
88
89 $mess = "";
90 if ($hasDatasets) {
92 $mess = $mbox->getHTML();
93 } else {
94 $_SESSION["constraintstructure"] = $tbl->getStructure();
95 }
96
97 $this->tpl->setContent($mess . $tbl->getHTML());
98 }
TableGUI class for survey constraints.
static _hasDatasets($survey_id)
constraintStep1Object()
Handles the first step of the precondition add action.
Message box for survey, when data is alrady available.

References $_GET, $_SESSION, ilObjSurvey\_hasDatasets(), and constraintStep1Object().

+ Here is the call graph for this function:

◆ constraintStep1Object()

ilSurveyConstraintsGUI::constraintStep1Object ( )

Handles the first step of the precondition add action.

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

136 {
137 $survey_questions = &$this->object->getSurveyQuestions();
138 $structure = &$_SESSION["constraintstructure"];
139 $start = $_GET["start"];
140 $option_questions = array();
141 for ($i = 1; $i < $start; $i++) {
142 if (is_array($structure[$i])) {
143 foreach ($structure[$i] as $key => $question_id) {
144 if ($survey_questions[$question_id]["usableForPrecondition"]) {
145 array_push($option_questions, array("question_id" => $survey_questions[$question_id]["question_id"], "title" => $survey_questions[$question_id]["title"], "type_tag" => $survey_questions[$question_id]["type_tag"]));
146 }
147 }
148 }
149 }
150 if (count($option_questions) == 0) {
151 unset($_SESSION["includeElements"]);
152 unset($_SESSION["constraintstructure"]);
153 ilUtil::sendInfo($this->lng->txt("constraints_no_nonessay_available"), true);
154 $this->ctrl->redirect($this, "constraints");
155 }
156 $this->constraintForm(1, $_POST, $survey_questions, $option_questions);
157 }
constraintForm($step, $postvalues, &$survey_questions, $questions=false)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$i
Definition: metadata.php:24

References $_GET, $_POST, $_SESSION, $i, constraintForm(), and ilUtil\sendInfo().

Referenced by constraintsObject(), and createConstraintsObject().

+ 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 162 of file class.ilSurveyConstraintsGUI.php.

163 {
164 $survey_questions = &$this->object->getSurveyQuestions();
165 $option_questions = array();
166 array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
167 $this->constraintForm(2, $_POST, $survey_questions, $option_questions);
168 }

References $_POST, and constraintForm().

+ Here is the call graph for this function:

◆ constraintStep3Object()

ilSurveyConstraintsGUI::constraintStep3Object ( )

Handles the third step of the precondition add action.

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

174 {
175 $survey_questions = &$this->object->getSurveyQuestions();
176 $option_questions = array();
177 if (strlen($_GET["precondition"])) {
178 if (!$this->validateConstraintForEdit($_GET["precondition"])) {
179 $this->ctrl->redirect($this, "constraints");
180 }
181
182 $pc = $this->object->getPrecondition($_GET["precondition"]);
183 $postvalues = array(
184 "c" => $pc["conjunction"],
185 "q" => $pc["question_fi"],
186 "r" => $pc["relation_id"],
187 "v" => $pc["value"]
188 );
189 array_push($option_questions, array("question_id" => $pc["question_fi"], "title" => $survey_questions[$pc["question_fi"]]["title"], "type_tag" => $survey_questions[$pc["question_fi"]]["type_tag"]));
190 $this->constraintForm(3, $postvalues, $survey_questions, $option_questions);
191 } else {
192 array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
193 $this->constraintForm(3, $_POST, $survey_questions, $option_questions);
194 }
195 }

References $_GET, $_POST, constraintForm(), and validateConstraintForEdit().

Referenced by constraintsAddObject().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createConstraintsObject()

ilSurveyConstraintsGUI::createConstraintsObject ( )

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

363 {
364 $include_elements = $_POST["includeElements"];
365 if ((!is_array($include_elements)) || (count($include_elements) == 0)) {
366 ilUtil::sendInfo($this->lng->txt("constraints_no_questions_or_questionblocks_selected"), true);
367 $this->ctrl->redirect($this, "constraints");
368 } elseif (count($include_elements) >= 1) {
369 $_SESSION["includeElements"] = $include_elements;
370 sort($include_elements, SORT_NUMERIC);
371 $_GET["start"] = $include_elements[0];
372 $this->constraintStep1Object();
373 }
374 }

References $_GET, $_POST, $_SESSION, constraintStep1Object(), and ilUtil\sendInfo().

+ Here is the call graph for this function:

◆ deleteConstraintsObject()

ilSurveyConstraintsGUI::deleteConstraintsObject ( )

Delete constraints of a survey.

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

352 {
353 $id = (int) $_REQUEST["precondition"];
354 if ($this->validateConstraintForEdit($id)) {
355 ilUtil::sendSuccess($this->lng->txt("survey_constraint_deleted"), true);
356 $this->object->deleteConstraint($id);
357 }
358
359 $this->ctrl->redirect($this, "constraints");
360 }

References validateConstraintForEdit().

+ Here is the call graph for this function:

◆ editPreconditionObject()

ilSurveyConstraintsGUI::editPreconditionObject ( )

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

377 {
378 if (!$this->validateConstraintForEdit($_GET["precondition"])) {
379 $this->ctrl->redirect($this, "constraints");
380 }
381
382 $_SESSION["includeElements"] = array($_GET["start"]);
383 $this->ctrl->setParameter($this, "precondition", $_GET["precondition"]);
384 $this->ctrl->setParameter($this, "start", $_GET["start"]);
385 $this->ctrl->redirect($this, "constraintStep3");
386 }

References $_GET, $_SESSION, and validateConstraintForEdit().

+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyConstraintsGUI::executeCommand ( )

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

54 {
55 $ilCtrl = $this->ctrl;
56
57 $cmd = $ilCtrl->getCmd("constraints");
58 $cmd .= "Object";
59
60 $this->$cmd();
61 }

References $ctrl.

◆ validateConstraintForEdit()

ilSurveyConstraintsGUI::validateConstraintForEdit (   $a_id)
protected

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

Parameters
int$a_id
Returns
bool

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

298 {
299 $ilAccess = $this->access;
300
301 if (ilObjSurvey::_hasDatasets($this->object->getSurveyId())) {
302 return false;
303 }
304 if (!$ilAccess->checkAccess("write", "", $this->object->getRefId())) {
305 return false;
306 }
307
308 return true;
309 }

References $access, and ilObjSurvey\_hasDatasets().

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

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $access

ilSurveyConstraintsGUI::$access
protected

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

Referenced by validateConstraintForEdit().

◆ $ctrl

ilSurveyConstraintsGUI::$ctrl
protected

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

Referenced by executeCommand().

◆ $lng

ilSurveyConstraintsGUI::$lng
protected

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

Referenced by __construct().

◆ $tpl

ilSurveyConstraintsGUI::$tpl
protected

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

Referenced by __construct().


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