ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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 $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7

References $DIC, $ilCtrl, $lng, and $tpl.

Member Function Documentation

◆ confirmDeleteConstraintsObject()

ilSurveyConstraintsGUI::confirmDeleteConstraintsObject ( )

Delete constraint confirmation.

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

318 {
319 $id = (int) $_REQUEST["precondition"];
320 if (!$this->validateConstraintForEdit($id)) {
321 $this->ctrl->redirect($this, "constraints");
322 }
323
324 $constraint = $this->object->getPrecondition($id);
325 $questions = $this->object->getSurveyQuestions();
326 $question = $questions[$constraint["question_fi"]];
327 $relation = $questions[$constraint["ref_question_fi"]];
328 $relation = $relation["title"];
329
330 // see ilSurveyConstraintsTableGUI
331 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
332 $question_type = SurveyQuestion::_getQuestionType($constraint["question_fi"]);
333 SurveyQuestion::_includeClass($question_type);
334 $question_obj = new $question_type();
335 $question_obj->loadFromDb($constraint["question_fi"]);
336 $valueoutput = $question_obj->getPreconditionValueOutput($constraint["value"]);
337
338 $title = $question["title"] . " " . $constraint["shortname"] . " " . $valueoutput;
339
340 $this->ctrl->saveParameter($this, "precondition");
341
342 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
343 $cgui = new ilConfirmationGUI();
344 $cgui->setHeaderText(sprintf($this->lng->txt("survey_sure_delete_constraint"), $title, $relation));
345
346 $cgui->setFormAction($this->ctrl->getFormAction($this, "deleteConstraints"));
347 $cgui->setCancel($this->lng->txt("cancel"), "constraints");
348 $cgui->setConfirm($this->lng->txt("confirm"), "deleteConstraints");
349
350 $this->tpl->setContent($cgui->getHTML());
351 }
sprintf('%.4f', $callTime)
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...
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id, $title, SurveyQuestion\_getQuestionType(), SurveyQuestion\_includeClass(), sprintf, and validateConstraintForEdit().

+ Here is the call graph for this function:

◆ constraintForm()

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

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

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

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

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

References $_GET, $_POST, $_SESSION, $key, 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 include_once "Modules/Survey/classes/tables/class.SurveyConstraintsTableGUI.php";
88 $tbl = new SurveyConstraintsTableGUI($this, "constraints", $this->object, $hasDatasets);
89 $this->tpl->setContent($tbl->getHTML());
90
91 if ($hasDatasets) {
92 // ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning"));
93 $link = $this->ctrl->getLinkTargetByClass("ilSurveyParticipantsGUI", "maintenance");
94 $link = "<a href=\"" . $link . "\">" . $this->lng->txt("survey_has_datasets_warning_page_view_link") . "</a>";
95 ilUtil::sendInfo($this->lng->txt("survey_has_datasets_warning_page_view") . " " . $link);
96 } else {
97 $_SESSION["constraintstructure"] = $tbl->getStructure();
98 }
99 }
TableGUI class for survey constraints.
static _hasDatasets($survey_id)
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, ilObjSurvey\_hasDatasets(), 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 136 of file class.ilSurveyConstraintsGUI.php.

137 {
138 $survey_questions =&$this->object->getSurveyQuestions();
139 $structure =&$_SESSION["constraintstructure"];
140 $start = $_GET["start"];
141 $option_questions = array();
142 for ($i = 1; $i < $start; $i++) {
143 if (is_array($structure[$i])) {
144 foreach ($structure[$i] as $key => $question_id) {
145 if ($survey_questions[$question_id]["usableForPrecondition"]) {
146 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"]));
147 }
148 }
149 }
150 }
151 if (count($option_questions) == 0) {
152 unset($_SESSION["includeElements"]);
153 unset($_SESSION["constraintstructure"]);
154 ilUtil::sendInfo($this->lng->txt("constraints_no_nonessay_available"), true);
155 $this->ctrl->redirect($this, "constraints");
156 }
157 $this->constraintForm(1, $_POST, $survey_questions, $option_questions);
158 }
constraintForm($step, $postvalues, &$survey_questions, $questions=false)
$i
Definition: disco.tpl.php:19

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

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

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

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

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

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

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

357 {
358 $id = (int) $_REQUEST["precondition"];
359 if ($this->validateConstraintForEdit($id)) {
360 ilUtil::sendSuccess($this->lng->txt("survey_constraint_deleted"), true);
361 $this->object->deleteConstraint($id);
362 }
363
364 $this->ctrl->redirect($this, "constraints");
365 }
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.

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

+ Here is the call graph for this function:

◆ editPreconditionObject()

ilSurveyConstraintsGUI::editPreconditionObject ( )

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

382 {
383 if (!$this->validateConstraintForEdit($_GET["precondition"])) {
384 $this->ctrl->redirect($this, "constraints");
385 }
386
387 $_SESSION["includeElements"] = array($_GET["start"]);
388 $this->ctrl->setParameter($this, "precondition", $_GET["precondition"]);
389 $this->ctrl->setParameter($this, "start", $_GET["start"]);
390 $this->ctrl->redirect($this, "constraintStep3");
391 }

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 {
56
57 $cmd = $ilCtrl->getCmd("constraints");
58 $cmd .= "Object";
59
60 $this->$cmd();
61 }

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

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

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: