ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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...
 

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

17 {
18 global $ilCtrl, $lng, $tpl;
19
20 $this->parent_gui = $a_parent_gui;
21 $this->object = $this->parent_gui->object;
22
23 $this->ctrl = $ilCtrl;
24 $this->lng = $lng;
25 $this->tpl = $tpl;
26 }
global $tpl
Definition: ilias.php:8
global $ilCtrl
Definition: ilias.php:18
global $lng
Definition: privfeed.php:40

References $ilCtrl, $lng, and $tpl.

Member Function Documentation

◆ confirmDeleteConstraintsObject()

ilSurveyConstraintsGUI::confirmDeleteConstraintsObject ( )

Delete constraint confirmation.

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

326 {
327 $id = (int)$_REQUEST["precondition"];
328 if(!$this->validateConstraintForEdit($id))
329 {
330 $this->ctrl->redirect($this, "constraints");
331 }
332
333 $constraint = $this->object->getPrecondition($id);
334 $questions = $this->object->getSurveyQuestions();
335 $question = $questions[$constraint["question_fi"]];
336 $relation = $questions[$constraint["ref_question_fi"]];
337 $relation = $relation["title"];
338
339 // see ilSurveyConstraintsTableGUI
340 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
341 $question_type = SurveyQuestion::_getQuestionType($constraint["question_fi"]);
342 SurveyQuestion::_includeClass($question_type);
343 $question_obj = new $question_type();
344 $question_obj->loadFromDb($constraint["question_fi"]);
345 $valueoutput = $question_obj->getPreconditionValueOutput($constraint["value"]);
346
347 $title = $question["title"]." ".$constraint["shortname"]." ".$valueoutput;
348
349 $this->ctrl->saveParameter($this, "precondition");
350
351 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
352 $cgui = new ilConfirmationGUI();
353 $cgui->setHeaderText(sprintf($this->lng->txt("survey_sure_delete_constraint"), $title, $relation));
354
355 $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteConstraints"));
356 $cgui->setCancel($this->lng->txt("cancel"), "constraints");
357 $cgui->setConfirm($this->lng->txt("confirm"), "deleteConstraints");
358
359 $this->tpl->setContent($cgui->getHTML());
360 }
_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...
if($_REQUEST['ilias_path']) define('ILIAS_HTTP_PATH' $_REQUEST['ilias_path']
Definition: index.php:7

References $_REQUEST, 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 195 of file class.ilSurveyConstraintsGUI.php.

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

References $_GET, $_SESSION, $header, $options, 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 84 of file class.ilSurveyConstraintsGUI.php.

85 {
86 if (strlen($_POST["v"]) == 0)
87 {
88 ilUtil::sendFailure($this->lng->txt("msg_enter_value_for_valid_constraint"));
89 return $this->constraintStep3Object();
90 }
91 $survey_questions =& $this->object->getSurveyQuestions();
92 $structure =& $_SESSION["constraintstructure"];
93 $include_elements = $_SESSION["includeElements"];
94 foreach ($include_elements as $elementCounter)
95 {
96 if (is_array($structure[$elementCounter]))
97 {
98 if (strlen($_GET["precondition"]))
99 {
100 $this->object->updateConstraint($_GET['precondition'], $_POST["q"], $_POST["r"], $_POST["v"], $_POST['c']);
101 }
102 else
103 {
104 $constraint_id = $this->object->addConstraint($_POST["q"], $_POST["r"], $_POST["v"], $_POST['c']);
105 foreach ($structure[$elementCounter] as $key => $question_id)
106 {
107 $this->object->addConstraintToQuestion($question_id, $constraint_id);
108 }
109 }
110 if (count($structure[$elementCounter]) > 1)
111 {
112 $this->object->updateConjunctionForQuestions($structure[$elementCounter], $_POST['c']);
113 }
114 }
115 }
116 unset($_SESSION["includeElements"]);
117 unset($_SESSION["constraintstructure"]);
118 $this->ctrl->redirect($this, "constraints");
119 }
constraintStep3Object()
Handles the third step of the precondition add action.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$_POST['username']
Definition: cron.php:12

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

42 {
43 $step = 0;
44 if (array_key_exists("step", $_GET))
45 {
46 $step = (int)$_GET["step"];
47 }
48 switch ($step)
49 {
50 case 1:
51 $this->constraintStep1Object();
52 return;
53 break;
54 case 2:
55 return;
56 break;
57 case 3:
58 return;
59 break;
60 }
61
62 $hasDatasets = $this->object->_hasDatasets($this->object->getSurveyId());
63
64 include_once "Modules/Survey/classes/tables/class.SurveyConstraintsTableGUI.php";
65 $tbl = new SurveyConstraintsTableGUI($this, "constraints", $this->object, $hasDatasets);
66 $this->tpl->setContent($tbl->getHTML());
67
68 if ($hasDatasets)
69 {
70 // ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning"));
71 $link = $this->ctrl->getLinkTargetByClass("ilSurveyParticipantsGUI", "maintenance");
72 $link = "<a href=\"".$link."\">".$this->lng->txt("survey_has_datasets_warning_page_view_link")."</a>";
73 ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning_page_view")." ".$link);
74 }
75 else
76 {
77 $_SESSION["constraintstructure"] = $tbl->getStructure();
78 }
79 }
TableGUI class for survey constraints.
constraintStep1Object()
Handles the first step of the precondition add action.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$tbl
Definition: example_048.php:81

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

+ Here is the call graph for this function:

◆ constraintStep1Object()

ilSurveyConstraintsGUI::constraintStep1Object ( )

Handles the first step of the precondition add action.

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

125 {
126 $survey_questions =& $this->object->getSurveyQuestions();
127 $structure =& $_SESSION["constraintstructure"];
128 $start = $_GET["start"];
129 $option_questions = array();
130 for ($i = 1; $i < $start; $i++)
131 {
132 if (is_array($structure[$i]))
133 {
134 foreach ($structure[$i] as $key => $question_id)
135 {
136 if ($survey_questions[$question_id]["usableForPrecondition"])
137 {
138 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"]));
139 }
140 }
141 }
142 }
143 if (count($option_questions) == 0)
144 {
145 unset($_SESSION["includeElements"]);
146 unset($_SESSION["constraintstructure"]);
147 ilUtil::sendInfo($this->lng->txt("constraints_no_nonessay_available"), true);
148 $this->ctrl->redirect($this, "constraints");
149 }
150 $this->constraintForm(1, $_POST, $survey_questions, $option_questions);
151 }
constraintForm($step, $postvalues, &$survey_questions, $questions=FALSE)

References $_GET, $_POST, $_SESSION, 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 156 of file class.ilSurveyConstraintsGUI.php.

157 {
158 $survey_questions =& $this->object->getSurveyQuestions();
159 $option_questions = array();
160 array_push($option_questions, array("question_id" => $_POST["q"], "title" => $survey_questions[$_POST["q"]]["title"], "type_tag" => $survey_questions[$_POST["q"]]["type_tag"]));
161 $this->constraintForm(2, $_POST, $survey_questions, $option_questions);
162 }

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

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

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

378 {
379 $include_elements = $_POST["includeElements"];
380 if ((!is_array($include_elements)) || (count($include_elements) == 0))
381 {
382 ilUtil::sendInfo($this->lng->txt("constraints_no_questions_or_questionblocks_selected"), true);
383 $this->ctrl->redirect($this, "constraints");
384 }
385 else if (count($include_elements) >= 1)
386 {
387 $_SESSION["includeElements"] = $include_elements;
388 sort($include_elements, SORT_NUMERIC);
389 $_GET["start"] = $include_elements[0];
390 $this->constraintStep1Object();
391 }
392 }

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

366 {
367 $id = (int)$_REQUEST["precondition"];
368 if($this->validateConstraintForEdit($id))
369 {
370 ilUtil::sendSuccess($this->lng->txt("survey_constraint_deleted"), true);
371 $this->object->deleteConstraint($id);
372 }
373
374 $this->ctrl->redirect($this, "constraints");
375 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

References $_REQUEST, ilUtil\sendSuccess(), and validateConstraintForEdit().

+ Here is the call graph for this function:

◆ editPreconditionObject()

ilSurveyConstraintsGUI::editPreconditionObject ( )

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

395 {
396 if(!$this->validateConstraintForEdit($_GET["precondition"]))
397 {
398 $this->ctrl->redirect($this, "constraints");
399 }
400
401 $_SESSION["includeElements"] = array($_GET["start"]);
402 $this->ctrl->setParameter($this, "precondition", $_GET["precondition"]);
403 $this->ctrl->setParameter($this, "start", $_GET["start"]);
404 $this->ctrl->redirect($this, "constraintStep3");
405 }

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

+ Here is the call graph for this function:

◆ executeCommand()

ilSurveyConstraintsGUI::executeCommand ( )

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

29 {
30 global $ilCtrl;
31
32 $cmd = $ilCtrl->getCmd("constraints");
33 $cmd .= "Object";
34
35 $this->$cmd();
36 }
$cmd
Definition: sahs_server.php:35

References $cmd, and $ilCtrl.

◆ 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 306 of file class.ilSurveyConstraintsGUI.php.

307 {
308 global $ilAccess;
309
310 if($this->object->_hasDatasets($this->object->getSurveyId()))
311 {
312 return false;
313 }
314 if(!$ilAccess->checkAccess("write", "", $this->object->getRefId()))
315 {
316 return false;
317 }
318
319 return true;
320 }

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

+ Here is the caller graph for this function:

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