24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
41 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveySingleChoiceQuestion.php";
60 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'vertical'), 0));
61 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'horizontal'), 1));
62 $orientation->addOption(
new ilRadioOption($this->lng->txt(
'combobox'), 2));
66 include_once
"./Modules/SurveyQuestionPool/classes/class.ilCategoryWizardInputGUI.php";
69 $answers->setAllowMove(
true);
70 $answers->setShowWizard(
true);
71 $answers->setShowSavePhrase(
true);
72 $answers->setUseOtherAnswer(
true);
73 $answers->setShowNeutralCategory(
true);
74 $answers->setNeutralCategoryTitle($this->lng->txt(
'svy_neutral_answer'));
75 $answers->setDisabledScale(
false);
79 $orientation->setValue($this->
object->getOrientation());
80 if (!$this->
object->getCategories()->getCategoryCount()) {
81 $this->
object->getCategories()->addCategory(
"");
83 $answers->setValues($this->
object->getCategories());
88 $this->log->debug(
"importing edit values");
90 $this->
object->setOrientation($a_form->
getInput(
"orientation"));
92 $this->
object->categories->flushCategories();
93 foreach (
$_POST[
'answers'][
'answer'] as
$key => $value) {
95 $this->
object->getCategories()->addCategory($value,
$_POST[
'answers'][
'other'][
$key], 0, null,
$_POST[
'answers'][
'scale'][$key]);
98 if (strlen(
$_POST[
'answers'][
'neutral'])) {
99 $this->
object->getCategories()->addCategory(
$_POST[
'answers'][
'neutral'], 0, 1, null,
$_POST[
'answers_neutral_scale']);
105 if (is_array($a_working_data)) {
106 $user_answer = $a_working_data[0];
110 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
111 $cat = $this->
object->categories->getCategory(
$i);
112 $value = ($cat->scale) ? ($cat->scale - 1) :
$i;
114 $checked =
"unchecked";
116 if (is_array($a_working_data) &&
117 is_array($user_answer)) {
118 if ($value == $user_answer[
"value"]) {
119 $checked =
"checked";
120 if ($user_answer[
"textanswer"]) {
121 $text = $user_answer[
"textanswer"];
127 $idx = $cat->other .
"_" . $value;
129 if (!$a_only_user_anwers || $checked ==
"checked") {
132 ,
"title" => trim($cat->title)
133 ,
"other" => (
bool) $cat->other
134 ,
"checked" => $checked
135 ,
"textanswer" =>
$text 150 public function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null,
array $a_working_data = null)
156 $template =
new ilTemplate(
"tpl.il_svy_qpl_sc_printview.html",
true,
true,
"Modules/SurveyQuestionPool");
157 switch ($this->
object->orientation) {
161 if ($option[
"other"]) {
164 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
165 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
167 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
169 :
" ");
174 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
175 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
186 $template->setVariable(
"ALT_RADIO", $this->lng->txt($option[
"checked"]));
187 $template->setVariable(
"TITLE_RADIO", $this->lng->txt($option[
"checked"]));
191 if ($option[
"other"]) {
192 $template->setCurrentBlock(
"other_text_col");
194 $template->setVariable(
"OTHER_ANSWER", $option[
"textanswer"]
196 :
" ");
209 $template->setVariable(
"VALUE_SC", $option[
"value"]);
210 if ($option[
"checked"] ==
"checked") {
211 $template->setVariable(
"SELECTED_SC",
' selected="selected"');
215 $template->setCurrentBlock(
"combooutput");
217 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
218 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
222 if ($question_title) {
225 if ($show_questiontext) {
242 public function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
244 $template =
new ilTemplate(
"tpl.il_svy_out_sc.html",
true,
true,
"Modules/SurveyQuestionPool");
248 switch ($this->
object->orientation) {
251 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
252 $cat = $this->
object->categories->getCategory(
$i);
254 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
255 $this->log->debug(
"Vertical orientation - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
259 if (strlen($cat->title)) {
260 $template->setVariable(
"OTHER_LABEL", $cat->title);
262 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
264 if (is_array($working_data)) {
265 foreach ($working_data as $value) {
266 if (strlen($value[
"value"])) {
267 if ($value[
"value"] == $cat->scale-1) {
268 if (strlen($value[
'textanswer'])) {
271 if (!$value[
'uncheck']) {
272 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
282 $template->setVariable(
'ROWCLASS',
' class="neutral"');
285 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
287 if (is_array($working_data)) {
288 foreach ($working_data as $value) {
289 if (strcmp($value[
"value"],
"") != 0) {
290 if ($value[
"value"] == $cat->scale-1) {
291 if (!$value[
'uncheck']) {
292 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
305 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
306 $cat = $this->
object->categories->getCategory(
$i);
308 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
309 $this->log->debug(
"Horizontal orientation - Original NEUTRAL scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
313 $template->setVariable(
'COLCLASS',
' neutral');
315 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
317 if (is_array($working_data)) {
318 foreach ($working_data as $value) {
319 if (strcmp($value[
"value"],
"") != 0) {
320 if ($value[
"value"] == $cat->scale-1) {
321 if (!$value[
'uncheck']) {
322 $template->setVariable(
"CHECKED_SC",
" checked=\"checked\"");
330 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
331 $cat = $this->
object->categories->getCategory(
$i);
333 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
334 $this->log->debug(
"Horizontal orientation - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
337 $template->setCurrentBlock(
"text_other_col");
338 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
340 if (strlen($cat->title)) {
341 $template->setVariable(
"OTHER_LABEL", $cat->title);
343 if (is_array($working_data)) {
344 foreach ($working_data as $value) {
345 if (strlen($value[
"value"])) {
346 if ($value[
"value"] == $cat->scale-1 && strlen($value[
'textanswer'])) {
356 $template->setVariable(
'COLCLASS',
' neutral');
358 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
368 for (
$i = 0;
$i < $this->
object->categories->getCategoryCount();
$i++) {
369 $cat = $this->
object->categories->getCategory(
$i);
371 $debug_scale = ($cat->scale) ? ($cat->scale - 1) :
$i;
372 $this->log->debug(
"Combobox - Original scale = " . $cat->scale .
" If(scale) scale -1 else i. The new scale value is = " . $debug_scale);
375 $template->setVariable(
"TEXT_SC", $cat->title);
376 $template->setVariable(
"VALUE_SC", ($cat->scale) ? ($cat->scale - 1) :
$i);
377 if (is_array($working_data)) {
378 if (strcmp($working_data[0][
"value"],
"") != 0) {
379 if ($working_data[0][
"value"] == $cat->scale-1) {
380 $template->setVariable(
"SELECTED_SC",
" selected=\"selected\"");
386 $template->setCurrentBlock(
"combooutput");
388 $template->setVariable(
"SELECT_OPTION", $this->lng->txt(
"select_option"));
389 $template->setVariable(
"TEXT_SELECTION", $this->lng->txt(
"selection"));
393 if ($question_title) {
396 $template->setCurrentBlock(
"question_data");
397 if (strcmp($error_message,
"") != 0) {
398 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
400 if ($show_questiontext) {
setQuestionTabsForClass($guiclass)
static prepareFormOutput($a_str, $a_strip=false)
prepares string output for html forms public
This class represents an option in a radio group.
getMaterialOutput()
Creates the HTML output of the question material(s)
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
SingleChoice survey question.
outQuestionText($template)
SingleChoice survey question GUI representation.
addFieldsToEditForm(ilPropertyFormGUI $a_form)
getWorkingForm($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
Creates the question output form for the learner.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static getHtmlPath($relative_path)
get url of path
Create styles array
The data for the language used.
importEditFormValues(ilPropertyFormGUI $a_form)
Create new PHPExcel object
obj_idprivate
getPrintView($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
Creates a HTML representation of the question.
getPrintViewQuestionTitle($question_title=1)
Basic class for all survey question types.
if(!isset($_REQUEST['ReturnTo'])) if(!isset($_REQUEST['AuthId'])) $options