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"]);
84 $this->
object->setMaximum(
$_POST[
"maximum"]);
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->removePlugin(
"ibrowser");
146 $question->setRTESupport($this->object->getId(),
"spl",
"survey", null,
false,
"3.4.7");
147 $form->addItem($question);
152 $subtype->setValue($this->object->getSubtype());
153 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'non_ratio'), 3, $this->lng->txt(
"metric_subtype_description_interval")));
154 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'ratio_non_absolute'), 4, $this->lng->txt(
"metric_subtype_description_rationonabsolute")));
155 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'ratio_absolute'), 5, $this->lng->txt(
"metric_subtype_description_ratioabsolute")));
156 $form->addItem($subtype);
160 $minimum->
setValue($this->object->getMinimum());
161 $minimum->setRequired(
false);
162 $minimum->setSize(6);
163 if ($this->object->getSubtype() > 3)
165 $minimum->setMinValue(0);
167 if ($this->object->getSubtype() == 5)
169 $minimum->setDecimals(0);
171 $form->addItem($minimum);
175 if ($this->object->getSubtype() == 5)
179 $maximum->setValue($this->object->getMaximum());
180 $maximum->setRequired(
false);
181 $maximum->setSize(6);
182 $form->addItem($maximum);
187 $shuffle->setChecked($this->object->getObligatory());
188 $shuffle->setRequired(FALSE);
189 $form->addItem($shuffle);
197 $form->setValuesByPost();
198 $errors = !$form->checkInput();
199 $form->setValuesByPost();
200 if (
$errors) $checkonly =
false;
203 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
214 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
216 $template =
new ilTemplate(
"tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
217 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
219 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
220 if ($show_questiontext)
226 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
228 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
229 $template->setVariable(
"QUESTION_ID", $this->object->getId());
233 for ($i = 0; $i < 10; $i++) $solution_text .=
" ";
234 $template->setVariable(
"TEXT_SOLUTION", $solution_text);
236 $template->parseCurrentBlock();
237 return $template->get();
247 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
249 $template =
new ilTemplate(
"tpl.il_svy_out_metric.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
250 $template->setCurrentBlock(
"material_metric");
252 $template->parseCurrentBlock();
253 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
269 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
270 if ($show_questiontext)
276 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
278 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
279 $template->setVariable(
"QUESTION_ID", $this->object->getId());
280 if (is_array($working_data))
282 $template->setVariable(
"VALUE_METRIC", $working_data[0][
"value"]);
285 $template->setVariable(
"INPUT_SIZE", 10);
287 if (strcmp($error_message,
"") != 0)
289 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
291 $template->parseCurrentBlock();
292 return $template->get();
310 if (count($this->cumulated) == 0)
312 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
314 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
318 include_once
"./classes/class.ilTemplate.php";
319 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
321 $template->setCurrentBlock(
"detail_row");
322 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
323 $questiontext = $this->
object->getQuestiontext();
324 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
325 $template->parseCurrentBlock();
326 $template->setCurrentBlock(
"detail_row");
327 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
328 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
329 $template->parseCurrentBlock();
330 $template->setCurrentBlock(
"detail_row");
331 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
332 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
333 $template->parseCurrentBlock();
334 $template->setCurrentBlock(
"detail_row");
335 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
336 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
337 $template->parseCurrentBlock();
338 $template->setCurrentBlock(
"detail_row");
339 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"subtype"));
340 switch ($this->object->getSubType())
343 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"non_ratio"));
346 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_non_absolute"));
349 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_absolute"));
352 $template->parseCurrentBlock();
364 $template->setCurrentBlock(
"detail_row");
365 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
366 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
367 $template->parseCurrentBlock();
368 $template->setCurrentBlock(
"detail_row");
369 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"arithmetic_mean"));
370 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"ARITHMETIC_MEAN"]);
371 $template->parseCurrentBlock();
373 $template->setCurrentBlock(
"detail_row");
374 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"values"));
376 if (is_array($this->cumulated[
"values"]))
378 foreach ($this->cumulated[
"values"] as $key => $value)
380 $values .=
"<li>" . $value[
"value"] .
": n=" . $value[
"selected"] .
381 " (" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"%)</li>";
384 $values =
"<ol>$values</ol>";
385 $template->setVariable(
"TEXT_OPTION_VALUE", $values);
386 $template->parseCurrentBlock();
390 $template->setCurrentBlock(
"detail_row");
391 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"chart"));
392 $template->setVariable(
"TEXT_OPTION_VALUE", $this->
renderChart(
"svy_ch_".$this->object->getId(), $this->cumulated[
"values"]));
393 $template->parseCurrentBlock();
396 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
397 return $template->get();
402 include_once
"Services/Chart/classes/class.ilChart.php";
403 $chart =
new ilChart($a_id, 700, 400);
409 $data->setLabel($this->lng->txt(
"users_answered"));
410 $data->setBarOptions(0.1,
"center");
415 foreach($a_values as $idx => $answer)
417 $data->addPoint($answer[
"value"], $answer[
"selected"]);
418 $labels[$answer[
"value"]] = $answer[
"value"];
420 $chart->addData(
$data);
422 $chart->setTicks($labels,
false,
true);
425 return "<div style=\"margin:10px\">".$chart->getHTML().
"</div>";