ILIAS
trunk Revision v11.0_alpha-3011-gc6b235a2e85
◀ ilDoc Overview
class.PageRenderer.php
Go to the documentation of this file.
1
<?php
2
19
namespace
ILIAS\Survey\Page
;
20
25
class
PageRenderer
26
{
27
protected
int
$question_title_mode
;
28
protected \ilCtrl
$ctrl
;
29
protected \ilLanguage
$lng
;
30
protected
array
$page_data
;
31
protected
array
$working_data
= [];
32
protected
array
$errors
= [];
33
protected \ilObjSurvey
$survey
;
34
39
public
function
__construct
(
40
\
ilObjSurvey
$survey
,
41
array
$page_data
,
42
array
$working_data
= [],
43
array
$errors
= [],
44
int
$question_title_mode
= 1
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
}
56
57
public
function
render
(): string
58
{
59
$page =
$this->page_data
;
60
61
$required =
false
;
62
$stpl = new \ilTemplate(
"tpl.page.html"
,
true
,
true
,
"components/ILIAS/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
// question heading
94
if
(
$data
[
"heading"
]) {
95
$stpl->setCurrentBlock(
"heading"
);
96
$stpl->setVariable(
"QUESTION_HEADING"
,
$data
[
"heading"
]);
97
$stpl->parseCurrentBlock();
98
}
99
$stpl->setCurrentBlock(
"survey_content"
);
100
// get question gui
101
$question_gui = $this->survey->getQuestionGUI(
$data
[
"type_tag"
],
$data
[
"question_id"
]);
102
103
// set obligatory flag
104
$question_gui->object->setObligatory(
$data
[
"obligatory"
]);
105
106
// get show questiontext flag
107
$show_questiontext = (
$data
[
"questionblock_show_questiontext"
]) ? 1 : 0;
108
109
// question title mode
110
$question_title_mode
=
$this->question_title_mode
;
111
if
(!$this->survey->getShowQuestionTitles() ||
$data
[
"compressed_first"
]) {
112
$question_title_mode
= 0;
113
}
114
$working_data
= $this->working_data[
$data
[
"question_id"
]] ??
null
;
115
$error
= $this->errors[
$data
[
"question_id"
]] ??
""
;
116
117
// get question output
118
// getWorkingData($qid)
119
// showQuestionTitle()
120
$question_output = $question_gui->getWorkingForm(
121
$working_data
,
122
$question_title_mode
,
123
$show_questiontext,
124
$error
,
125
$this->survey->getSurveyId(),
126
$compress_view
127
);
128
129
// tweak compressed view
130
if
(
$data
[
"compressed"
]) {
131
//$question_output = '<div class="il-svy-qst-compressed">' . $question_output . '</div>';
132
133
$stpl->setVariable(
"CMPR_CLASS"
,
"il-svy-qst-compressed"
);
134
}
135
$stpl->setVariable(
"QUESTION_OUTPUT"
, $question_output);
136
137
// update qid ctrl parameter
138
$this->
ctrl
->setParameter($this,
"qid"
,
$data
[
"question_id"
]);
139
140
if
(
$data
[
"obligatory"
]) {
141
$required =
true
;
142
}
143
$stpl->parseCurrentBlock();
144
}
145
146
// required text action
147
if
($required) {
148
$stpl->setCurrentBlock(
"required"
);
149
$stpl->setVariable(
"TEXT_REQUIRED"
, $this->
lng
->txt(
"required_field"
));
150
$stpl->parseCurrentBlock();
151
}
152
153
return
$stpl->get();
154
}
155
156
protected
function
compressQuestion
(
157
?array $previous_page,
158
array $page
159
): bool {
160
if
(is_null($previous_page)) {
161
return
false
;
162
}
163
164
if
($previous_page[
"type_tag"
] === $page[
"type_tag"
] &&
165
$page[
"type_tag"
] ===
"SurveySingleChoiceQuestion"
) {
166
if
(\SurveySingleChoiceQuestion::compressable($previous_page[
"question_id"
], $page[
"question_id"
])) {
167
return
true
;
168
}
169
}
170
171
return
false
;
172
}
173
}
ILIAS\Survey\Page\PageRenderer
Survey page renderer.
Definition:
class.PageRenderer.php:26
ILIAS\Survey\Page\PageRenderer\$errors
array $errors
Definition:
class.PageRenderer.php:32
ILIAS\Survey\Page\PageRenderer\$lng
ilLanguage $lng
Definition:
class.PageRenderer.php:29
ILIAS\Survey\Page\PageRenderer\$ctrl
ilCtrl $ctrl
Definition:
class.PageRenderer.php:28
ILIAS\Survey\Page\PageRenderer\$page_data
array $page_data
Definition:
class.PageRenderer.php:30
ILIAS\Survey\Page\PageRenderer\$working_data
array $working_data
Definition:
class.PageRenderer.php:31
ILIAS\Survey\Page\PageRenderer\render
render()
Definition:
class.PageRenderer.php:57
ILIAS\Survey\Page\PageRenderer\compressQuestion
compressQuestion(?array $previous_page, array $page)
Definition:
class.PageRenderer.php:156
ILIAS\Survey\Page\PageRenderer\$question_title_mode
int $question_title_mode
Definition:
class.PageRenderer.php:27
ILIAS\Survey\Page\PageRenderer\__construct
__construct(\ilObjSurvey $survey, array $page_data, array $working_data=[], array $errors=[], int $question_title_mode=1)
Definition:
class.PageRenderer.php:39
ILIAS\Survey\Page\PageRenderer\$survey
ilObjSurvey $survey
Definition:
class.PageRenderer.php:33
ILIAS\$error
ilErrorHandling $error
Definition:
class.ilias.php:69
ilObjSurvey
Definition:
class.ilObjSurvey.php:27
$data
$data
Definition:
ltiregistration.php:29
ILIAS\Repository\ctrl
ctrl()
Definition:
trait.GlobalDICGUIServices.php:63
ILIAS\Repository\lng
lng()
Definition:
trait.GlobalDICDomainServices.php:61
ILIAS\Survey\Page
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition:
class.PageRenderer.php:19
if
if(!file_exists('../ilias.ini.php'))
Definition:
sessioncheck.php:23
$DIC
global $DIC
Definition:
shib_login.php:26
components
ILIAS
Survey
Page
class.PageRenderer.php
Generated on Sat Oct 18 2025 23:04:27 for ILIAS by
1.9.4 (using
Doxyfile
)