ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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

Constructor & Destructor Documentation

◆ __construct()

ilSurveyConstraintsGUI::__construct ( ilObjSurveyGUI  $a_parent_gui)

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

References $ilCtrl, $lng, and $tpl.

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:17

Member Function Documentation

◆ confirmDeleteConstraintsObject()

ilSurveyConstraintsGUI::confirmDeleteConstraintsObject ( )

Delete constraint confirmation.

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

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

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  }
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
static _getQuestionType($question_id)
Returns the question type of a question with a given id.
validateConstraintForEdit($a_id)
Validate if given constraint id is part of current survey and there are sufficient permissions to edi...
Confirmation screen class.
+ 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.

References $_GET, $_SESSION, $header, $options, $step, $title, SurveyQuestion\_getQuestionTypeName(), SurveyQuestion\_includeClass(), ilRadioGroupInputGUI\addOption(), array, and ilSelectInputGUI\setOptions().

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

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  }
This class represents an option in a radio group.
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
This class represents a property form user interface.
$_GET["client_id"]
This class represents a section header in a property form.
static _includeClass($question_type, $gui=0)
Include the php class file for a given question type.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
This class represents a property in a property form.
addOption($a_option)
Add Option.
if(!is_array($argv)) $options
$header
foreach( $_REQUEST as $var) foreach(array('_POST'=> 'HTTP_POST_VARS', '_GET'=> 'HTTP_GET_VARS', '_COOKIE'=> 'HTTP_COOKIE_VARS', '_SERVER'=> 'HTTP_SERVER_VARS', '_ENV'=> 'HTTP_ENV_VARS', '_FILES'=> 'HTTP_POST_FILES') as $array=> $other) $step
Definition: cssgen.php:155
setOptions($a_options)
Set Options.
Create styles array
The data for the language used.
+ 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.

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

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  }
$_SESSION["AccountId"]
$_GET["client_id"]
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
constraintStep3Object()
Handles the third step of the precondition add action.
$_POST["username"]
+ 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.

References $_GET, $_SESSION, $step, $tbl, ilObjSurvey\_hasDatasets(), constraintStep1Object(), object, and ilUtil\sendInfo().

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 = ilObjSurvey::_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  }
constraintStep1Object()
Handles the first step of the precondition add action.
$_SESSION["AccountId"]
$_GET["client_id"]
$tbl
Definition: example_048.php:81
static _hasDatasets($survey_id)
TableGUI class for survey constraints.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
foreach( $_REQUEST as $var) foreach(array('_POST'=> 'HTTP_POST_VARS', '_GET'=> 'HTTP_GET_VARS', '_COOKIE'=> 'HTTP_COOKIE_VARS', '_SERVER'=> 'HTTP_SERVER_VARS', '_ENV'=> 'HTTP_ENV_VARS', '_FILES'=> 'HTTP_POST_FILES') as $array=> $other) $step
Definition: cssgen.php:155
Create new PHPExcel object
obj_idprivate
+ 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.

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

Referenced by constraintsObject(), and createConstraintsObject().

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  }
$_SESSION["AccountId"]
$_GET["client_id"]
constraintForm($step, $postvalues, &$survey_questions, $questions=FALSE)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Create styles array
The data for the language used.
$_POST["username"]
+ 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.

References $_POST, array, and constraintForm().

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  }
constraintForm($step, $postvalues, &$survey_questions, $questions=FALSE)
Create styles array
The data for the language used.
$_POST["username"]
+ 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.

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

Referenced by constraintsAddObject().

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  }
$_GET["client_id"]
constraintForm($step, $postvalues, &$survey_questions, $questions=FALSE)
Create styles array
The data for the language used.
validateConstraintForEdit($a_id)
Validate if given constraint id is part of current survey and there are sufficient permissions to edi...
$_POST["username"]
+ 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.

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

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  }
constraintStep1Object()
Handles the first step of the precondition add action.
$_SESSION["AccountId"]
$_GET["client_id"]
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
$_POST["username"]
+ 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.

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

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.
validateConstraintForEdit($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:

◆ editPreconditionObject()

ilSurveyConstraintsGUI::editPreconditionObject ( )

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

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

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  }
$_SESSION["AccountId"]
$_GET["client_id"]
Create styles array
The data for the language used.
validateConstraintForEdit($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 28 of file class.ilSurveyConstraintsGUI.php.

References $cmd, and $ilCtrl.

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

◆ 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.

References ilObjSurvey\_hasDatasets(), and object.

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

307  {
308  global $ilAccess;
309 
310  if(ilObjSurvey::_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  }
static _hasDatasets($survey_id)
Create new PHPExcel object
obj_idprivate
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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