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 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
102 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
104 $form->setFormAction($this->ctrl->getFormAction($this));
105 $form->setTitle($this->lng->txt($this->getQuestionType()));
106 $form->setMultipart(FALSE);
107 $form->setTableWidth(
"100%");
108 $form->setId(
"multiplechoice");
112 $title->setValue($this->object->getTitle());
113 $title->setRequired(TRUE);
118 $label->
setValue($this->object->label);
119 $label->setInfo($this->lng->txt(
"label_info"));
120 $label->setRequired(
false);
121 $form->addItem($label);
124 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
125 $author->
setValue($this->object->getAuthor());
126 $author->setRequired(TRUE);
127 $form->addItem($author);
130 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
131 $description->
setValue($this->object->getDescription());
132 $description->setRequired(FALSE);
133 $form->addItem($description);
137 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
138 $question->setRequired(TRUE);
139 $question->setRows(10);
140 $question->setCols(80);
141 $question->setUseRte(TRUE);
142 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
144 $question->addPlugin(
"latex");
145 $question->addButton(
"latex");
146 $question->addButton(
"pastelatex");
147 $question->removePlugin(
"ibrowser");
148 $question->setRTESupport($this->object->getId(),
"spl",
"survey");
149 $form->addItem($question);
154 $subtype->setValue($this->object->getSubtype());
155 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'non_ratio'), 3, $this->lng->txt(
"metric_subtype_description_interval")));
156 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'ratio_non_absolute'), 4, $this->lng->txt(
"metric_subtype_description_rationonabsolute")));
157 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'ratio_absolute'), 5, $this->lng->txt(
"metric_subtype_description_ratioabsolute")));
158 $form->addItem($subtype);
162 $minimum->
setValue($this->object->getMinimum());
163 $minimum->setRequired(
false);
164 $minimum->setSize(6);
165 if ($this->object->getSubtype() > 3)
167 $minimum->setMinValue(0);
169 if ($this->object->getSubtype() == 5)
171 $minimum->setDecimals(0);
173 $form->addItem($minimum);
177 if ($this->object->getSubtype() == 5)
181 $maximum->setValue($this->object->getMaximum());
182 $maximum->setRequired(
false);
183 $maximum->setSize(6);
184 $form->addItem($maximum);
189 $shuffle->setChecked($this->object->getObligatory());
190 $shuffle->setRequired(FALSE);
191 $form->addItem($shuffle);
193 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
199 $form->setValuesByPost();
200 $errors = !$form->checkInput();
201 $form->setValuesByPost();
202 if (
$errors) $checkonly =
false;
205 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
216 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
218 $template =
new ilTemplate(
"tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
219 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
221 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
222 if ($show_questiontext)
228 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
230 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
231 $template->setVariable(
"QUESTION_ID", $this->object->getId());
235 for ($i = 0; $i < 10; $i++) $solution_text .=
" ";
236 $template->setVariable(
"TEXT_SOLUTION", $solution_text);
238 $template->parseCurrentBlock();
239 return $template->get();
249 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
251 $template =
new ilTemplate(
"tpl.il_svy_out_metric.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
252 $template->setCurrentBlock(
"material_metric");
254 $template->parseCurrentBlock();
255 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
271 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
272 if ($show_questiontext)
278 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
280 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
281 $template->setVariable(
"QUESTION_ID", $this->object->getId());
282 if (is_array($working_data))
284 $template->setVariable(
"VALUE_METRIC", $working_data[0][
"value"]);
287 $template->setVariable(
"INPUT_SIZE", 10);
289 if (strcmp($error_message,
"") != 0)
291 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
293 $template->parseCurrentBlock();
294 return $template->get();
306 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
308 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
326 if (count($this->cumulated) == 0)
328 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
330 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
334 include_once
"./classes/class.ilTemplate.php";
335 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
337 $template->setCurrentBlock(
"detail_row");
338 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
339 $questiontext = $this->
object->getQuestiontext();
340 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
341 $template->parseCurrentBlock();
342 $template->setCurrentBlock(
"detail_row");
343 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
344 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
345 $template->parseCurrentBlock();
346 $template->setCurrentBlock(
"detail_row");
347 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
348 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
349 $template->parseCurrentBlock();
350 $template->setCurrentBlock(
"detail_row");
351 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
352 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
353 $template->parseCurrentBlock();
354 $template->setCurrentBlock(
"detail_row");
355 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"subtype"));
356 switch ($this->object->getSubType())
359 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"non_ratio"));
362 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_non_absolute"));
365 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_absolute"));
368 $template->parseCurrentBlock();
371 $template->setCurrentBlock(
"detail_row");
372 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode"));
373 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE"]);
374 $template->parseCurrentBlock();
375 $template->setCurrentBlock(
"detail_row");
376 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode_nr_of_selections"));
377 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE_NR_OF_SELECTIONS"]);
378 $template->parseCurrentBlock();
379 $template->setCurrentBlock(
"detail_row");
380 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
381 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
382 $template->parseCurrentBlock();
383 $template->setCurrentBlock(
"detail_row");
384 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"arithmetic_mean"));
385 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"ARITHMETIC_MEAN"]);
386 $template->parseCurrentBlock();
388 $template->setCurrentBlock(
"detail_row");
389 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"values"));
391 if (is_array($this->cumulated[
"values"]))
393 foreach ($this->cumulated[
"values"] as $key => $value)
395 $values .=
"<li>" . $this->lng->txt(
"value") .
": " .
"<span class=\"bold\">" . $value[
"value"] .
"</span><br />" .
396 $this->lng->txt(
"value_nr_entered") .
": " .
"<span class=\"bold\">" . $value[
"selected"] .
"</span><br />" .
397 $this->lng->txt(
"percentage_of_entered_values") .
": " .
"<span class=\"bold\">" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"</span></li>";
400 $values =
"<ol>$values</ol>";
401 $template->setVariable(
"TEXT_OPTION_VALUE", $values);
402 $template->parseCurrentBlock();
404 $template->setCurrentBlock(
"chart");
406 include_once
"./Services/Administration/classes/class.ilSetting.php";
407 $surveySetting =
new ilSetting(
"survey");
408 if ($surveySetting->get(
"googlechart") == 1)
410 $selections = array();
413 if (is_array($this->cumulated[
"values"]))
415 foreach ($this->cumulated[
"values"] as $val)
417 if ($val[
"selected"] > $maxselection) $maxselection = $val[
"selected"];
418 array_push($selections, $val[
"selected"]);
419 array_push($values, $val[
"value"]);
422 $selectionlabels =
"";
423 if ($maxselection % 2 == 0)
425 $selectionlabels =
"0|" . ($maxselection / 2) .
"|$maxselection";
429 $selectionlabels =
"0|$maxselection";
432 $charturl =
"http://chart.apis.google.com/chart?chco=76A4FB&cht=bvs&chs=$chartwidth" .
"x250&chd=t:" . implode(
",", $selections) .
"&chds=0,$maxselection&chxt=x,y,x,y&chxl=0:|" . implode(
"|", $values) .
"|1:|$selectionlabels|2:||" . $this->lng->txt(
"values").
"||3:||".$this->lng->txt(
"mode_nr_of_selections").
"|" .
"&chxr=1,0,$maxselection&chtt=" . str_replace(
" ",
"+", $this->object->getTitle());
436 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"survey", $survey_id);
437 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"question", $this->object->getId());
438 $charturl = $this->ctrl->getLinkTargetByClass(
"ilsurveyevaluationgui",
"outChart");
440 $template->setVariable(
"CHART", $charturl);
442 $template->setVariable(
"TEXT_CHART", $this->lng->txt(
"chart"));
443 $template->setVariable(
"ALT_CHART",
$data[
"title"] .
"( " . $this->lng->txt(
"chart") .
")");
444 $template->parseCurrentBlock();
446 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
447 return $template->get();