24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestionGUI.php";
41 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyMetricQuestion.php";
64 $subtype->addOption($opt);
69 $minimum1->setSize(6);
70 $opt->addSubItem($minimum1);
75 $maximum1->setSize(6);
76 $opt->addSubItem($maximum1);
79 $subtype->addOption($opt);
84 $minimum2->setSize(6);
85 $minimum2->setMinValue(0);
86 $opt->addSubItem($minimum2);
91 $maximum2->setSize(6);
92 $opt->addSubItem($maximum2);
95 $subtype->addOption($opt);
100 $minimum3->setSize(6);
101 $minimum3->setMinValue(0);
102 $minimum3->setDecimals(0);
103 $opt->addSubItem($minimum3);
108 $maximum3->setRequired(
false);
109 $maximum3->setSize(6);
110 $opt->addSubItem($maximum3);
114 $subtype->setValue($this->object->getSubtype());
116 switch($this->object->getSubtype())
119 $minimum1->setValue($this->object->getMinimum());
120 $maximum1->setValue($this->object->getMaximum());
124 $minimum2->setValue($this->object->getMinimum());
125 $maximum2->setValue($this->object->getMaximum());
129 $minimum3->setValue($this->object->getMinimum());
130 $maximum3->setValue($this->object->getMaximum());
137 $type = (int)$a_form->
getInput(
"type");
138 $this->
object->setOrientation($a_form->
getInput(
"orientation"));
139 $this->
object->setSubtype($type);
140 $this->
object->setMinimum($a_form->
getInput(
"minimum".$type));
141 $this->
object->setMaximum($a_form->
getInput(
"maximum".$type));
144 public function getParsedAnswers(array $a_working_data = null, $a_only_user_anwers =
false)
148 if(is_array($a_working_data))
150 $res[] = array(
"value" => $a_working_data[0][
"value"]);
163 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null, array $a_working_data = null)
169 $user_answer = $user_answer[0][
"value"];
172 $template =
new ilTemplate(
"tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
173 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
175 if ($show_questiontext)
183 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
184 $template->setVariable(
"QUESTION_ID", $this->object->getId());
186 if(!is_array($a_working_data) || !trim($user_answer))
190 for ($i = 0; $i < 10; $i++) $solution_text .=
" ";
194 $solution_text = $user_answer;
196 $template->setVariable(
"TEXT_SOLUTION", $solution_text);
198 $template->parseCurrentBlock();
199 return $template->get();
214 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
216 $template =
new ilTemplate(
"tpl.il_svy_out_metric.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
217 $template->setCurrentBlock(
"material_metric");
219 $template->parseCurrentBlock();
220 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
236 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
237 if ($show_questiontext)
243 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
245 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
246 $template->setVariable(
"QUESTION_ID", $this->object->getId());
247 if (is_array($working_data))
249 $template->setVariable(
"VALUE_METRIC", $working_data[0][
"value"]);
252 $template->setVariable(
"INPUT_SIZE", 10);
254 if (strcmp($error_message,
"") != 0)
256 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
258 $template->parseCurrentBlock();
259 return $template->get();
277 if (count($this->cumulated) == 0)
281 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
286 $nr_of_users =
sizeof($finished_ids);
288 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
292 include_once
"./Services/UICore/classes/class.ilTemplate.php";
293 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
295 $template->setCurrentBlock(
"detail_row");
296 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
297 $questiontext = $this->
object->getQuestiontext();
298 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
299 $template->parseCurrentBlock();
300 $template->setCurrentBlock(
"detail_row");
301 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
302 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
303 $template->parseCurrentBlock();
304 $template->setCurrentBlock(
"detail_row");
305 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
306 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
307 $template->parseCurrentBlock();
308 $template->setCurrentBlock(
"detail_row");
309 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
310 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
311 $template->parseCurrentBlock();
312 $template->setCurrentBlock(
"detail_row");
313 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"subtype"));
314 switch ($this->object->getSubType())
317 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"non_ratio"));
320 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_non_absolute"));
323 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_absolute"));
326 $template->parseCurrentBlock();
338 $template->setCurrentBlock(
"detail_row");
339 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
340 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
341 $template->parseCurrentBlock();
342 $template->setCurrentBlock(
"detail_row");
343 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"arithmetic_mean"));
344 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"ARITHMETIC_MEAN"]);
345 $template->parseCurrentBlock();
347 $template->setCurrentBlock(
"detail_row");
348 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"values"));
351 if (is_array($this->cumulated[
"values"]))
353 foreach ($this->cumulated[
"values"] as $key => $value)
359 sprintf(
"%.2f", 100*$value[
"percentage"]).
"%" 362 $selsum += (int)$value[
"selected"];
366 $this->lng->txt(
"title"),
367 $this->lng->txt(
"category_nr_selected"),
368 $this->lng->txt(
"percentage_of_selections")
370 $foot = array(null, null, $selsum, null);
371 $template->setVariable(
"TEXT_OPTION_VALUE",
373 $template->parseCurrentBlock();
376 $template->setCurrentBlock(
"detail_row");
377 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
378 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId(), $this->cumulated[
"values"]));
379 $template->parseCurrentBlock();
382 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
383 return $template->get();
388 include_once
"Services/Chart/classes/class.ilChart.php";
390 $chart->setsize(700, 400);
396 $data->setLabel($this->lng->txt(
"users_answered"));
397 $data->setBarOptions(0.1,
"center");
402 foreach($a_values as $idx => $answer)
404 $data->addPoint($answer[
"value"], $answer[
"selected"]);
405 $labels[$answer[
"value"]] = $answer[
"value"];
407 $chart->addData(
$data);
409 $chart->setTicks($labels,
false,
true);
412 return "<div style=\"margin:10px\">".$chart->getHTML().
"</div>";
const SUBTYPE_RATIO_NON_ABSOLUTE
setQuestionTabsForClass($guiclass)
This class represents an option in a radio group.
getMaterialOutput()
Creates the HTML output of the question material(s)
Metric survey question GUI representation.
outQuestionText($template)
getPrintView($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
Creates a HTML representation of the question.
renderStatisticsDetailsTable(array $a_head, array $a_rows, array $a_foot=null)
special template class to simplify handling of ITX/PEAR
renderChart($a_id, $a_values)
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
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.
const SUBTYPE_RATIO_ABSOLUTE
getPrintViewQuestionTitle($question_title=1)
getCumulatedResultsDetails($survey_id, $counter, $finished_ids)
Creates the detailed output of the cumulated results for the question.
_getNrOfParticipants($survey_id)
Returns the number of participants for a survey.
Basic class for all survey question types.
importEditFormValues(ilPropertyFormGUI $a_form)
static getInstanceByType($a_type, $a_id)
Get type instance.