24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
54 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyMetricQuestion.php";
58 $this->
object->loadFromDb($id);
70 $hasErrors = (!$always) ? $this->
editQuestion(
true) :
false;
73 $this->
object->setTitle(
$_POST[
"title"]);
74 $this->
object->setAuthor(
$_POST[
"author"]);
75 $this->
object->setDescription(
$_POST[
"description"]);
76 $questiontext =
$_POST[
"question"];
77 $this->
object->setQuestiontext($questiontext);
78 $this->
object->setObligatory((
$_POST[
"obligatory"]) ? 1 : 0);
79 $this->
object->setOrientation(
$_POST[
"orientation"]);
80 $this->
object->label =
$_POST[
'label'];
82 $this->
object->setSubtype(
$_POST[
"type"]);
83 $this->
object->setMinimum(
$_POST[
"minimum".(
int)
$_POST[
"type"]]);
84 $this->
object->setMaximum($_POST[
"maximum".(
int)$_POST[
"type"]]);
100 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
102 $form->setFormAction($this->ctrl->getFormAction($this));
103 $form->setTitle($this->lng->txt($this->getQuestionType()));
104 $form->setMultipart(FALSE);
105 $form->setTableWidth(
"100%");
106 $form->setId(
"multiplechoice");
110 $title->setValue($this->object->getTitle());
111 $title->setRequired(TRUE);
116 $label->
setValue($this->object->label);
117 $label->setInfo($this->lng->txt(
"label_info"));
118 $label->setRequired(
false);
119 $form->addItem($label);
122 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
123 $author->
setValue($this->object->getAuthor());
124 $author->setRequired(TRUE);
125 $form->addItem($author);
128 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
129 $description->
setValue($this->object->getDescription());
130 $description->setRequired(FALSE);
131 $form->addItem($description);
135 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
136 $question->setRequired(TRUE);
137 $question->setRows(10);
138 $question->setCols(80);
139 $question->setUseRte(TRUE);
140 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
142 $question->addPlugin(
"latex");
143 $question->addButton(
"latex");
144 $question->addButton(
"pastelatex");
145 $question->setRTESupport($this->object->getId(),
"spl",
"survey", null,
false,
"3.4.7");
146 $form->addItem($question);
152 $subtype->setValue($this->object->getSubtype());
153 $form->addItem($subtype);
156 $opt =
new ilRadioOption($this->lng->txt(
'non_ratio'), 3, $this->lng->txt(
"metric_subtype_description_interval"));
157 $subtype->addOption($opt);
161 if($this->object->getSubtype() == 3)
163 $minimum->
setValue($this->object->getMinimum());
165 $minimum->setRequired(
false);
166 $minimum->setSize(6);
167 $opt->addSubItem($minimum);
171 if($this->object->getSubtype() == 3)
173 $maximum->
setValue($this->object->getMaximum());
175 $maximum->setRequired(
false);
176 $maximum->setSize(6);
177 $opt->addSubItem($maximum);
179 $opt =
new ilRadioOption($this->lng->txt(
'ratio_non_absolute'), 4, $this->lng->txt(
"metric_subtype_description_rationonabsolute"));
180 $subtype->addOption($opt);
184 if($this->object->getSubtype() == 4)
186 $minimum->
setValue($this->object->getMinimum());
188 $minimum->setRequired(
false);
189 $minimum->setSize(6);
190 $minimum->setMinValue(0);
191 $opt->addSubItem($minimum);
195 if($this->object->getSubtype() == 4)
197 $maximum->
setValue($this->object->getMaximum());
199 $maximum->setRequired(
false);
200 $maximum->setSize(6);
201 $opt->addSubItem($maximum);
203 $opt =
new ilRadioOption($this->lng->txt(
'ratio_absolute'), 5, $this->lng->txt(
"metric_subtype_description_ratioabsolute"));
204 $subtype->addOption($opt);
208 if($this->object->getSubtype() == 5)
210 $minimum->
setValue($this->object->getMinimum());
212 $minimum->setRequired(
false);
213 $minimum->setSize(6);
214 $minimum->setMinValue(0);
215 $minimum->setDecimals(0);
216 $opt->addSubItem($minimum);
221 if($this->object->getSubtype() == 5)
223 $maximum->setValue($this->object->getMaximum());
225 $maximum->setRequired(
false);
226 $maximum->setSize(6);
227 $opt->addSubItem($maximum);
233 $shuffle->setChecked($this->object->getObligatory());
234 $shuffle->setRequired(FALSE);
235 $form->addItem($shuffle);
243 $form->setValuesByPost();
244 $errors = !$form->checkInput();
245 $form->setValuesByPost();
246 if (
$errors) $checkonly =
false;
249 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
260 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
262 $template =
new ilTemplate(
"tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
263 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
265 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
266 if ($show_questiontext)
272 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
274 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
275 $template->setVariable(
"QUESTION_ID", $this->object->getId());
279 for ($i = 0; $i < 10; $i++) $solution_text .=
" ";
280 $template->setVariable(
"TEXT_SOLUTION", $solution_text);
282 $template->parseCurrentBlock();
283 return $template->get();
293 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
295 $template =
new ilTemplate(
"tpl.il_svy_out_metric.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
296 $template->setCurrentBlock(
"material_metric");
298 $template->parseCurrentBlock();
299 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
315 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
316 if ($show_questiontext)
322 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
324 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
325 $template->setVariable(
"QUESTION_ID", $this->object->getId());
326 if (is_array($working_data))
328 $template->setVariable(
"VALUE_METRIC", $working_data[0][
"value"]);
331 $template->setVariable(
"INPUT_SIZE", 10);
333 if (strcmp($error_message,
"") != 0)
335 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
337 $template->parseCurrentBlock();
338 return $template->get();
356 if (count($this->cumulated) == 0)
358 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
360 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
364 include_once
"./Services/UICore/classes/class.ilTemplate.php";
365 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
367 $template->setCurrentBlock(
"detail_row");
368 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
369 $questiontext = $this->
object->getQuestiontext();
370 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
371 $template->parseCurrentBlock();
372 $template->setCurrentBlock(
"detail_row");
373 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
374 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
375 $template->parseCurrentBlock();
376 $template->setCurrentBlock(
"detail_row");
377 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
378 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
379 $template->parseCurrentBlock();
380 $template->setCurrentBlock(
"detail_row");
381 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
382 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
383 $template->parseCurrentBlock();
384 $template->setCurrentBlock(
"detail_row");
385 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"subtype"));
386 switch ($this->object->getSubType())
389 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"non_ratio"));
392 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_non_absolute"));
395 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_absolute"));
398 $template->parseCurrentBlock();
410 $template->setCurrentBlock(
"detail_row");
411 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
412 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
413 $template->parseCurrentBlock();
414 $template->setCurrentBlock(
"detail_row");
415 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"arithmetic_mean"));
416 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"ARITHMETIC_MEAN"]);
417 $template->parseCurrentBlock();
419 $template->setCurrentBlock(
"detail_row");
420 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"values"));
422 if (is_array($this->cumulated[
"values"]))
424 foreach ($this->cumulated[
"values"] as $key => $value)
426 $values .=
"<li>" . $value[
"value"] .
": n=" . $value[
"selected"] .
427 " (" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"%)</li>";
430 $values =
"<ol>$values</ol>";
431 $template->setVariable(
"TEXT_OPTION_VALUE", $values);
432 $template->parseCurrentBlock();
436 $template->setCurrentBlock(
"detail_row");
437 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
438 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId(), $this->cumulated[
"values"]));
439 $template->parseCurrentBlock();
442 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
443 return $template->get();
448 include_once
"Services/Chart/classes/class.ilChart.php";
449 $chart =
new ilChart($a_id, 700, 400);
455 $data->setLabel($this->lng->txt(
"users_answered"));
456 $data->setBarOptions(0.1,
"center");
461 foreach($a_values as $idx => $answer)
463 $data->addPoint($answer[
"value"], $answer[
"selected"]);
464 $labels[$answer[
"value"]] = $answer[
"value"];
466 $chart->addData(
$data);
468 $chart->setTicks($labels,
false,
true);
471 return "<div style=\"margin:10px\">".$chart->getHTML().
"</div>";