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"]);
81 $this->
object->setSubtype(
$_POST[
"type"]);
82 $this->
object->setMinimum(
$_POST[
"minimum"]);
83 $this->
object->setMaximum(
$_POST[
"maximum"]);
99 $save = ((strcmp($this->ctrl->getCmd(),
"save") == 0) || (strcmp($this->ctrl->getCmd(),
"saveEdit") == 0)) ? TRUE : FALSE;
101 include_once(
"./Services/Form/classes/class.ilPropertyFormGUI.php");
103 $form->setFormAction($this->ctrl->getFormAction($this));
104 $form->setTitle($this->lng->txt($this->getQuestionType()));
105 $form->setMultipart(FALSE);
106 $form->setTableWidth(
"100%");
107 $form->setId(
"multiplechoice");
111 $title->setValue($this->object->getTitle());
112 $title->setRequired(TRUE);
116 $author =
new ilTextInputGUI($this->lng->txt(
"author"),
"author");
117 $author->
setValue($this->object->getAuthor());
118 $author->setRequired(TRUE);
119 $form->addItem($author);
122 $description =
new ilTextInputGUI($this->lng->txt(
"description"),
"description");
123 $description->
setValue($this->object->getDescription());
124 $description->setRequired(FALSE);
125 $form->addItem($description);
129 $question->
setValue($this->object->prepareTextareaOutput($this->object->getQuestiontext()));
130 $question->setRequired(TRUE);
131 $question->setRows(10);
132 $question->setCols(80);
133 $question->setUseRte(TRUE);
134 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
136 $question->addPlugin(
"latex");
137 $question->addButton(
"latex");
138 $question->addButton(
"pastelatex");
139 $question->removePlugin(
"ibrowser");
140 $question->setRTESupport($this->object->getId(),
"spl",
"survey");
141 $form->addItem($question);
146 $subtype->setValue($this->object->getSubtype());
147 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'non_ratio'), 3, $this->lng->txt(
"metric_subtype_description_interval")));
148 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'ratio_non_absolute'), 4, $this->lng->txt(
"metric_subtype_description_rationonabsolute")));
149 $subtype->addOption(
new ilRadioOption($this->lng->txt(
'ratio_absolute'), 5, $this->lng->txt(
"metric_subtype_description_ratioabsolute")));
150 $form->addItem($subtype);
154 $minimum->
setValue($this->object->getMinimum());
155 $minimum->setRequired(
false);
156 $minimum->setSize(6);
157 if ($this->object->getSubtype() > 3)
159 $minimum->setMinValue(0);
161 if ($this->object->getSubtype() == 5)
163 $minimum->setDecimals(0);
165 $form->addItem($minimum);
169 if ($this->object->getSubtype() == 5)
173 $maximum->setValue($this->object->getMaximum());
174 $maximum->setRequired(
false);
175 $maximum->setSize(6);
176 $form->addItem($maximum);
181 $shuffle->setChecked($this->object->getObligatory());
182 $shuffle->setRequired(FALSE);
183 $form->addItem($shuffle);
185 $form->addCommandButton(
"save", $this->lng->txt(
"save"));
191 $form->setValuesByPost();
192 $errors = !$form->checkInput();
193 $form->setValuesByPost();
194 if (
$errors) $checkonly =
false;
197 if (!$checkonly) $this->tpl->setVariable(
"ADM_CONTENT", $form->getHTML());
208 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
210 $template =
new ilTemplate(
"tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
211 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
213 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
214 if ($show_questiontext)
216 $questiontext = $this->
object->getQuestiontext();
217 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
219 if (! $this->object->getObligatory($survey_id))
221 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
225 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
227 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
228 $template->setVariable(
"QUESTION_ID", $this->object->getId());
232 for ($i = 0; $i < 10; $i++) $solution_text .=
" ";
233 $template->setVariable(
"TEXT_SOLUTION", $solution_text);
235 $template->parseCurrentBlock();
236 return $template->get();
246 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
248 $template =
new ilTemplate(
"tpl.il_svy_out_metric.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
249 $template->setCurrentBlock(
"material_metric");
251 $template->parseCurrentBlock();
252 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
268 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
269 if ($show_questiontext)
271 $questiontext = $this->
object->getQuestiontext();
272 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
274 if (! $this->object->getObligatory($survey_id))
276 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
280 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
282 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
283 $template->setVariable(
"QUESTION_ID", $this->object->getId());
284 if (is_array($working_data))
286 $template->setVariable(
"VALUE_METRIC", $working_data[0][
"value"]);
289 $template->setVariable(
"INPUT_SIZE", 10);
291 if (strcmp($error_message,
"") != 0)
293 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
295 $template->parseCurrentBlock();
296 return $template->get();
308 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
310 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
328 if (count($this->cumulated) == 0)
330 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
332 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
336 include_once
"./classes/class.ilTemplate.php";
337 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
339 $template->setCurrentBlock(
"detail_row");
340 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
341 $questiontext = $this->
object->getQuestiontext();
342 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
343 $template->parseCurrentBlock();
344 $template->setCurrentBlock(
"detail_row");
345 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
346 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
347 $template->parseCurrentBlock();
348 $template->setCurrentBlock(
"detail_row");
349 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
350 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
351 $template->parseCurrentBlock();
352 $template->setCurrentBlock(
"detail_row");
353 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
354 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
355 $template->parseCurrentBlock();
356 $template->setCurrentBlock(
"detail_row");
357 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"subtype"));
358 switch ($this->object->getSubType())
361 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"non_ratio"));
364 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_non_absolute"));
367 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_absolute"));
370 $template->parseCurrentBlock();
373 $template->setCurrentBlock(
"detail_row");
374 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode"));
375 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE"]);
376 $template->parseCurrentBlock();
377 $template->setCurrentBlock(
"detail_row");
378 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode_nr_of_selections"));
379 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE_NR_OF_SELECTIONS"]);
380 $template->parseCurrentBlock();
381 $template->setCurrentBlock(
"detail_row");
382 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
383 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
384 $template->parseCurrentBlock();
385 $template->setCurrentBlock(
"detail_row");
386 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"arithmetic_mean"));
387 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"ARITHMETIC_MEAN"]);
388 $template->parseCurrentBlock();
390 $template->setCurrentBlock(
"detail_row");
391 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"values"));
393 if (is_array($this->cumulated[
"values"]))
395 foreach ($this->cumulated[
"values"] as
$key => $value)
397 $values .=
"<li>" . $this->lng->txt(
"value") .
": " .
"<span class=\"bold\">" . $value[
"value"] .
"</span><br />" .
398 $this->lng->txt(
"value_nr_entered") .
": " .
"<span class=\"bold\">" . $value[
"selected"] .
"</span><br />" .
399 $this->lng->txt(
"percentage_of_entered_values") .
": " .
"<span class=\"bold\">" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"</span></li>";
402 $values =
"<ol>$values</ol>";
403 $template->setVariable(
"TEXT_OPTION_VALUE", $values);
404 $template->parseCurrentBlock();
406 $template->setCurrentBlock(
"chart");
408 include_once
"./Services/Administration/classes/class.ilSetting.php";
409 $surveySetting =
new ilSetting(
"survey");
410 if ($surveySetting->get(
"googlechart") == 1)
412 $selections = array();
415 if (is_array($this->cumulated[
"values"]))
417 foreach ($this->cumulated[
"values"] as $val)
419 if ($val[
"selected"] > $maxselection) $maxselection = $val[
"selected"];
420 array_push($selections, $val[
"selected"]);
421 array_push($values, $val[
"value"]);
424 $selectionlabels =
"";
425 if ($maxselection % 2 == 0)
427 $selectionlabels =
"0|" . ($maxselection / 2) .
"|$maxselection";
431 $selectionlabels =
"0|$maxselection";
434 $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());
438 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"survey", $survey_id);
439 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"question", $this->object->getId());
440 $charturl = $this->ctrl->getLinkTargetByClass(
"ilsurveyevaluationgui",
"outChart");
442 $template->setVariable(
"CHART", $charturl);
444 $template->setVariable(
"TEXT_CHART", $this->lng->txt(
"chart"));
445 $template->setVariable(
"ALT_CHART",
$data[
"title"] .
"( " . $this->lng->txt(
"chart") .
")");
446 $template->parseCurrentBlock();
448 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
449 return $template->get();