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)
181 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
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"));
350 if (is_array($this->cumulated[
"values"]))
352 foreach ($this->cumulated[
"values"] as $key => $value)
354 $values .=
"<li>" . $value[
"value"] .
": n=" . $value[
"selected"] .
355 " (" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"%)</li>";
358 $values =
"<ol>$values</ol>";
359 $template->setVariable(
"TEXT_OPTION_VALUE", $values);
360 $template->parseCurrentBlock();
364 $template->setCurrentBlock(
"detail_row");
365 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
366 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId(), $this->cumulated[
"values"]));
367 $template->parseCurrentBlock();
370 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
371 return $template->get();
376 include_once
"Services/Chart/classes/class.ilChart.php";
378 $chart->setsize(700, 400);
381 $chart->setLegend($legend);
384 $data->setLabel($this->lng->txt(
"users_answered"));
385 $data->setBarOptions(0.1,
"center");
390 foreach($a_values as $idx => $answer)
392 $data->addPoint($answer[
"value"], $answer[
"selected"]);
393 $labels[$answer[
"value"]] = $answer[
"value"];
395 $chart->addData($data);
397 $chart->setTicks($labels,
false,
true);
400 return "<div style=\"margin:10px\">".$chart->getHTML().
"</div>";