ILIAS  release_8 Revision v8.23
ILIAS\Survey\Page\PageRenderer Class Reference

Survey page renderer. More...

+ Collaboration diagram for ILIAS\Survey\Page\PageRenderer:

Public Member Functions

 __construct (\ilObjSurvey $survey, array $page_data, array $working_data=[], array $errors=[], int $question_title_mode=1)
 
 render ()
 

Protected Member Functions

 compressQuestion (?array $previous_page, array $page)
 

Protected Attributes

int $question_title_mode
 
ilCtrl $ctrl
 
ilLanguage $lng
 
array $page_data
 
array $working_data = []
 
array $errors = []
 
ilObjSurvey $survey
 

Detailed Description

Survey page renderer.

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Survey\Page\PageRenderer::__construct ( \ilObjSurvey  $survey,
array  $page_data,
array  $working_data = [],
array  $errors = [],
int  $question_title_mode = 1 
)
Parameters
array$page_dataas returned by ilObjSurvey->getNextPage()
Todo:
use data objects

Definition at line 39 of file class.PageRenderer.php.

References $DIC, ILIAS\Survey\Page\PageRenderer\$errors, ILIAS\Survey\Page\PageRenderer\$page_data, ILIAS\Survey\Page\PageRenderer\$question_title_mode, ILIAS\Survey\Page\PageRenderer\$survey, ILIAS\Survey\Page\PageRenderer\$working_data, ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

45  {
46  global $DIC;
47 
48  $this->ctrl = $DIC->ctrl();
49  $this->lng = $DIC->language();
50  $this->survey = $survey;
51  $this->page_data = $page_data;
52  $this->working_data = $working_data;
53  $this->errors = $errors;
54  $this->question_title_mode = $question_title_mode;
55  }
global $DIC
Definition: feed.php:28
+ Here is the call graph for this function:

Member Function Documentation

◆ compressQuestion()

ILIAS\Survey\Page\PageRenderer::compressQuestion ( ?array  $previous_page,
array  $page 
)
protected

Definition at line 157 of file class.PageRenderer.php.

Referenced by ILIAS\Survey\Page\PageRenderer\render().

160  : bool {
161  if (is_null($previous_page)) {
162  return false;
163  }
164 
165  if ($previous_page["type_tag"] === $page["type_tag"] &&
166  $page["type_tag"] === "SurveySingleChoiceQuestion") {
167  if (\SurveySingleChoiceQuestion::compressable($previous_page["question_id"], $page["question_id"])) {
168  return true;
169  }
170  }
171 
172  return false;
173  }
+ Here is the caller graph for this function:

◆ render()

ILIAS\Survey\Page\PageRenderer::render ( )

Definition at line 57 of file class.PageRenderer.php.

References $data, ILIAS\$error, ILIAS\Survey\Page\PageRenderer\$page_data, ILIAS\Survey\Page\PageRenderer\$question_title_mode, ILIAS\Survey\Page\PageRenderer\compressQuestion(), ILIAS\Repository\ctrl(), and ILIAS\Repository\lng().

57  : string
58  {
59  $page = $this->page_data;
60 
61  $required = false;
62  $stpl = new \ilTemplate("tpl.page.html", true, true, "Modules/Survey/Page");
63 
64  // question block title
65  if (count($page) > 1 && $page[0]["questionblock_show_blocktitle"]) {
66  $stpl->setCurrentBlock("questionblock_title");
67  $stpl->setVariable("TEXT_QUESTIONBLOCK_TITLE", $page[0]["questionblock_title"]);
68  $stpl->parseCurrentBlock();
69  }
70 
71  // dealing with compressed view
72  $compress_view = false;
73  if (count($page) > 1) {
74  $compress_view = $page[0]["questionblock_compress_view"];
75  }
76  $previous_page = null;
77  $previous_key = null;
78  foreach ($page as $k => $data) {
79  $page[$k]["compressed"] = false;
80  $page[$k]["compressed_first"] = false;
81  if ($compress_view && $this->compressQuestion($previous_page, $data)) {
82  $page[$k]["compressed"] = true;
83  if ($previous_key !== null && $page[$previous_key]["compressed"] == false) {
84  $page[$previous_key]["compressed_first"] = true;
85  }
86  }
87  $previous_key = $k;
88  $previous_page = $data;
89  }
90 
91  // questions
92  foreach ($page as $data) {
93 
94  // question heading
95  if ($data["heading"]) {
96  $stpl->setCurrentBlock("heading");
97  $stpl->setVariable("QUESTION_HEADING", $data["heading"]);
98  $stpl->parseCurrentBlock();
99  }
100  $stpl->setCurrentBlock("survey_content");
101  // get question gui
102  $question_gui = $this->survey->getQuestionGUI($data["type_tag"], $data["question_id"]);
103 
104  // set obligatory flag
105  $question_gui->object->setObligatory($data["obligatory"]);
106 
107  // get show questiontext flag
108  $show_questiontext = ($data["questionblock_show_questiontext"]) ? 1 : 0;
109 
110  // question title mode
112  if (!$this->survey->getShowQuestionTitles() || $data["compressed_first"]) {
114  }
115  $working_data = $this->working_data[$data["question_id"]] ?? null;
116  $error = $this->errors[$data["question_id"]] ?? "";
117 
118  // get question output
119  // getWorkingData($qid)
120  // showQuestionTitle()
121  $question_output = $question_gui->getWorkingForm(
124  $show_questiontext,
125  $error,
126  $this->survey->getSurveyId(),
127  $compress_view
128  );
129 
130  // tweak compressed view
131  if ($data["compressed"]) {
132  //$question_output = '<div class="il-svy-qst-compressed">' . $question_output . '</div>';
133 
134  $stpl->setVariable("CMPR_CLASS", "il-svy-qst-compressed");
135  }
136  $stpl->setVariable("QUESTION_OUTPUT", $question_output);
137 
138  // update qid ctrl parameter
139  $this->ctrl->setParameter($this, "qid", $data["question_id"]);
140 
141  if ($data["obligatory"]) {
142  $required = true;
143  }
144  $stpl->parseCurrentBlock();
145  }
146 
147  // required text action
148  if ($required) {
149  $stpl->setCurrentBlock("required");
150  $stpl->setVariable("TEXT_REQUIRED", $this->lng->txt("required_field"));
151  $stpl->parseCurrentBlock();
152  }
153 
154  return $stpl->get();
155  }
ilErrorHandling $error
Definition: class.ilias.php:55
compressQuestion(?array $previous_page, array $page)
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrl ILIAS\Survey\Page\PageRenderer::$ctrl
protected

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

◆ $errors

array ILIAS\Survey\Page\PageRenderer::$errors = []
protected

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

Referenced by ILIAS\Survey\Page\PageRenderer\__construct().

◆ $lng

ilLanguage ILIAS\Survey\Page\PageRenderer::$lng
protected

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

◆ $page_data

array ILIAS\Survey\Page\PageRenderer::$page_data
protected

◆ $question_title_mode

int ILIAS\Survey\Page\PageRenderer::$question_title_mode
protected

◆ $survey

ilObjSurvey ILIAS\Survey\Page\PageRenderer::$survey
protected

Definition at line 33 of file class.PageRenderer.php.

Referenced by ILIAS\Survey\Page\PageRenderer\__construct().

◆ $working_data

array ILIAS\Survey\Page\PageRenderer::$working_data = []
protected

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

Referenced by ILIAS\Survey\Page\PageRenderer\__construct().


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