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);
71 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_metric.html",
"Modules/SurveyQuestionPool");
72 $this->tpl->addBlockFile(
"OTHER_QUESTION_DATA",
"other_question_data",
"tpl.il_svy_qpl_other_question_data.html",
"Modules/SurveyQuestionPool");
73 $internallinks = array(
74 "lm" => $this->lng->txt(
"obj_lm"),
75 "st" => $this->lng->txt(
"obj_st"),
76 "pg" => $this->lng->txt(
"obj_pg"),
77 "glo" => $this->lng->txt(
"glossary_term")
79 foreach ($internallinks as $key => $value)
81 $this->tpl->setCurrentBlock(
"internallink");
82 $this->tpl->setVariable(
"TYPE_INTERNAL_LINK", $key);
83 $this->tpl->setVariable(
"TEXT_INTERNAL_LINK", $value);
84 $this->tpl->parseCurrentBlock();
87 $this->tpl->setCurrentBlock(
"adm_content");
88 $this->tpl->setVariable(
"TEXT_MATERIAL", $this->lng->txt(
"material"));
89 if (count($this->object->material))
91 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
93 $this->tpl->setVariable(
"TEXT_VALUE_MATERIAL",
" <a href=\"$href\" target=\"content\">" . $this->lng->txt(
"material").
"</a> ");
94 $this->tpl->setVariable(
"BUTTON_REMOVE_MATERIAL", $this->lng->txt(
"remove"));
95 $this->tpl->setVariable(
"BUTTON_ADD_MATERIAL", $this->lng->txt(
"change"));
96 $this->tpl->setVariable(
"VALUE_MATERIAL", $this->object->material[
"internal_link"]);
97 $this->tpl->setVariable(
"VALUE_MATERIAL_TITLE", $this->object->material[
"title"]);
98 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
102 $this->tpl->setVariable(
"BUTTON_ADD_MATERIAL", $this->lng->txt(
"add"));
104 $this->tpl->setVariable(
"QUESTION_ID", $this->object->getId());
105 $this->tpl->setVariable(
"VALUE_TITLE", $this->object->getTitle());
106 $this->tpl->setVariable(
"VALUE_DESCRIPTION", $this->object->getDescription());
107 $this->tpl->setVariable(
"VALUE_AUTHOR", $this->object->getAuthor());
108 $questiontext = $this->
object->getQuestiontext();
109 $this->tpl->setVariable(
"VALUE_QUESTION",
ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
110 $this->tpl->setVariable(
"VALUE_MINIMUM", $this->object->getMinimum());
111 $this->tpl->setVariable(
"VALUE_MAXIMUM", $this->object->getMaximum());
112 $this->tpl->setVariable(
"TEXT_MINIMUM", $this->lng->txt(
"minimum"));
113 $this->tpl->setVariable(
"TEXT_MAXIMUM", $this->lng->txt(
"maximum"));
114 $this->tpl->setVariable(
"TEXT_SUBTYPE", $this->lng->txt(
"subtype"));
115 $this->tpl->setVariable(
"DESCRIPTION_NONRATIO", $this->lng->txt(
"metric_subtype_description_interval"));
116 $this->tpl->setVariable(
"TEXT_NONRATIO", $this->lng->txt(
"non_ratio"));
117 $this->tpl->setVariable(
"DESCRIPTION_RATIONONABSOLUTE", $this->lng->txt(
"metric_subtype_description_rationonabsolute"));
118 $this->tpl->setVariable(
"TEXT_RATIONONABSOLUTE", $this->lng->txt(
"ratio_non_absolute"));
119 $this->tpl->setVariable(
"DESCRIPTION_RATIOABSOLUTE", $this->lng->txt(
"metric_subtype_description_ratioabsolute"));
120 $this->tpl->setVariable(
"TEXT_RATIOABSOLUTE", $this->lng->txt(
"ratio_absolute"));
123 $this->tpl->setVariable(
"CHECKED_NONRATIO",
" checked=\"checked\"");
127 $this->tpl->setVariable(
"CHECKED_RATIONONABSOLUTE",
" checked=\"checked\"");
131 $this->tpl->setVariable(
"CHECKED_RATIOABSOLUTE",
" checked=\"checked\"");
133 $this->tpl->setVariable(
"TEXT_TITLE", $this->lng->txt(
"title"));
134 $this->tpl->setVariable(
"TEXT_AUTHOR", $this->lng->txt(
"author"));
135 $this->tpl->setVariable(
"TEXT_DESCRIPTION", $this->lng->txt(
"description"));
136 $this->tpl->setVariable(
"TEXT_QUESTION", $this->lng->txt(
"question"));
137 $this->tpl->setVariable(
"TEXT_OBLIGATORY", $this->lng->txt(
"obligatory"));
138 if ($this->object->getObligatory())
140 $this->tpl->setVariable(
"CHECKED_OBLIGATORY",
" checked=\"checked\"");
142 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->lng->txt(
"questiontype"));
143 $this->tpl->setVariable(
"SAVE",$this->lng->txt(
"save"));
144 $this->tpl->setVariable(
"TXT_REQUIRED_FLD", $this->lng->txt(
"required_field"));
145 $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this));
146 $this->tpl->setVariable(
"TEXT_QUESTION_TYPE", $this->lng->txt($this->getQuestionType()));
147 $this->tpl->parseCurrentBlock();
148 include_once
"./Services/RTE/classes/class.ilRTE.php";
150 include_once
"./Services/RTE/classes/class.$rtestring.php";
151 $rte =
new $rtestring();
152 $rte->addPlugin(
"latex");
153 $rte->addButton(
"latex"); $rte->addButton(
"pastelatex");
154 $rte->removePlugin(
"ibrowser");
155 include_once
"./classes/class.ilObject.php";
156 $obj_id =
$_GET[
"q_id"];
158 $rte->addRTESupport($obj_id, $obj_type,
"survey");
174 if ((!$_POST[
"title"]) or (!$_POST[
"author"]) or (!$_POST[
"question"]))
$result = 1;
177 if ($_POST[
"id"] > 0) $this->
object->setId($_POST[
"id"]);
179 include_once
"./Services/Utilities/classes/class.ilUtil.php";
183 if (strlen($_POST[
"material"]))
185 $this->
object->setMaterial($_POST[
"material"], 0,
ilUtil::stripSlashes($_POST[
"material_title"]));
187 include_once
"./Services/AdvancedEditing/classes/class.ilObjAdvancedEditing.php";
189 $this->
object->setQuestiontext($questiontext);
190 if ($_POST[
"obligatory"])
192 $this->
object->setObligatory(1);
196 $this->
object->setObligatory(0);
198 $this->
object->setSubtype($_POST[
"type"]);
199 $minimum = $_POST[
"minimum"];
200 if ($this->object->getSubtype() > 3)
208 $this->
object->setMinimum($minimum);
209 $this->
object->setMaximum($_POST[
"maximum"]);
216 $this->
object->saveToDb();
228 function getPrintView($question_title = 1, $show_questiontext = 1, $survey_id = null)
230 $template =
new ilTemplate(
"tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
231 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
233 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
234 if ($show_questiontext)
236 $questiontext = $this->
object->getQuestiontext();
237 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
239 if (! $this->object->getObligatory($survey_id))
241 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
245 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
247 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
248 $template->setVariable(
"QUESTION_ID", $this->object->getId());
252 for ($i = 0; $i < 10; $i++) $solution_text .=
" ";
253 $template->setVariable(
"TEXT_SOLUTION", $solution_text);
255 $template->parseCurrentBlock();
256 return $template->get();
266 function getWorkingForm($working_data =
"", $question_title = 1, $show_questiontext = 1, $error_message =
"", $survey_id = null)
268 $template =
new ilTemplate(
"tpl.il_svy_out_metric.html", TRUE, TRUE,
"Modules/SurveyQuestionPool");
269 if (count($this->object->material))
271 $template->setCurrentBlock(
"material_metric");
272 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
274 $template->setVariable(
"TEXT_MATERIAL", $this->lng->txt(
"material") .
": <a href=\"$href\" target=\"content\">" . $this->
object->material[
"title"].
"</a> ");
275 $template->parseCurrentBlock();
277 $template->setVariable(
"MIN_MAX", $this->object->getMinMaxText());
293 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
294 if ($show_questiontext)
296 $questiontext = $this->
object->getQuestiontext();
297 $template->setVariable(
"QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
299 if (! $this->object->getObligatory($survey_id))
301 $template->setVariable(
"OBLIGATORY_TEXT", $this->lng->txt(
"survey_question_optional"));
305 $template->setVariable(
"QUESTION_TITLE", $this->object->getTitle());
307 $template->setVariable(
"TEXT_ANSWER", $this->lng->txt(
"answer"));
308 $template->setVariable(
"QUESTION_ID", $this->object->getId());
309 if (is_array($working_data))
311 $template->setVariable(
"VALUE_METRIC", $working_data[0][
"value"]);
314 $template->setVariable(
"INPUT_SIZE", 10);
316 if (strcmp($error_message,
"") != 0)
318 $template->setVariable(
"ERROR_MESSAGE",
"<p class=\"warning\">$error_message</p>");
320 $template->parseCurrentBlock();
321 return $template->get();
333 $this->tpl->addBlockFile(
"ADM_CONTENT",
"adm_content",
"tpl.il_svy_qpl_preview.html",
"Modules/SurveyQuestionPool");
335 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
353 include_once
"./classes/class.ilTemplate.php";
354 if (count($this->cumulated) == 0)
356 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
358 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
360 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_row.html", TRUE, TRUE,
"Modules/Survey");
361 $template->setVariable(
"QUESTION_TITLE", ($counter+1) .
". ".$this->object->getTitle());
363 $questiontext = preg_replace(
"/<[^>]+?>/ims",
"", $this->object->getQuestiontext());
364 if (strlen($questiontext) > $maxlen + 3)
366 $questiontext = substr($questiontext, 0, $maxlen) .
"...";
368 $template->setVariable(
"QUESTION_TEXT", $questiontext);
369 $template->setVariable(
"USERS_ANSWERED", $this->cumulated[
"USERS_ANSWERED"]);
370 $template->setVariable(
"USERS_SKIPPED", $this->cumulated[
"USERS_SKIPPED"]);
371 $template->setVariable(
"QUESTION_TYPE", $this->lng->txt($this->cumulated[
"QUESTION_TYPE"]));
372 $template->setVariable(
"MODE", $this->cumulated[
"MODE"]);
373 $template->setVariable(
"MODE_NR_OF_SELECTIONS", $this->cumulated[
"MODE_NR_OF_SELECTIONS"]);
374 $template->setVariable(
"MEDIAN", $this->cumulated[
"MEDIAN"]);
375 $template->setVariable(
"ARITHMETIC_MEAN", $this->cumulated[
"ARITHMETIC_MEAN"]);
376 $template->setVariable(
"COLOR_CLASS", $css_class);
377 return $template->get();
392 if (count($this->cumulated) == 0)
394 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
396 $this->cumulated =& $this->
object->getCumulatedResults($survey_id, $nr_of_users);
400 include_once
"./classes/class.ilTemplate.php";
401 $template =
new ilTemplate(
"tpl.il_svy_svy_cumulated_results_detail.html", TRUE, TRUE,
"Modules/Survey");
403 $template->setCurrentBlock(
"detail_row");
404 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question"));
405 $questiontext = $this->
object->getQuestiontext();
406 $template->setVariable(
"TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
407 $template->parseCurrentBlock();
408 $template->setCurrentBlock(
"detail_row");
409 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"question_type"));
410 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
411 $template->parseCurrentBlock();
412 $template->setCurrentBlock(
"detail_row");
413 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_answered"));
414 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_ANSWERED"]);
415 $template->parseCurrentBlock();
416 $template->setCurrentBlock(
"detail_row");
417 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"users_skipped"));
418 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"USERS_SKIPPED"]);
419 $template->parseCurrentBlock();
420 $template->setCurrentBlock(
"detail_row");
421 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"subtype"));
422 switch ($this->object->getSubType())
425 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"non_ratio"));
428 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_non_absolute"));
431 $template->setVariable(
"TEXT_OPTION_VALUE", $this->lng->txt(
"ratio_absolute"));
434 $template->parseCurrentBlock();
437 $template->setCurrentBlock(
"detail_row");
438 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode"));
439 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE"]);
440 $template->parseCurrentBlock();
441 $template->setCurrentBlock(
"detail_row");
442 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"mode_nr_of_selections"));
443 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MODE_NR_OF_SELECTIONS"]);
444 $template->parseCurrentBlock();
445 $template->setCurrentBlock(
"detail_row");
446 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"median"));
447 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"MEDIAN"]);
448 $template->parseCurrentBlock();
449 $template->setCurrentBlock(
"detail_row");
450 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"arithmetic_mean"));
451 $template->setVariable(
"TEXT_OPTION_VALUE", $this->cumulated[
"ARITHMETIC_MEAN"]);
452 $template->parseCurrentBlock();
454 $template->setCurrentBlock(
"detail_row");
455 $template->setVariable(
"TEXT_OPTION", $this->lng->txt(
"values"));
457 if (is_array($this->cumulated[
"values"]))
459 foreach ($this->cumulated[
"values"] as $key => $value)
461 $values .=
"<li>" . $this->lng->txt(
"value") .
": " .
"<span class=\"bold\">" . $value[
"value"] .
"</span><br />" .
462 $this->lng->txt(
"value_nr_entered") .
": " .
"<span class=\"bold\">" . $value[
"selected"] .
"</span><br />" .
463 $this->lng->txt(
"percentage_of_entered_values") .
": " .
"<span class=\"bold\">" . sprintf(
"%.2f", 100*$value[
"percentage"]) .
"</span></li>";
466 $values =
"<ol>$values</ol>";
467 $template->setVariable(
"TEXT_OPTION_VALUE", $values);
468 $template->parseCurrentBlock();
470 $template->setCurrentBlock(
"chart");
472 include_once
"./Services/Administration/classes/class.ilSetting.php";
473 $surveySetting =
new ilSetting(
"survey");
474 if ($surveySetting->get(
"googlechart") == 1)
476 $selections = array();
479 if (is_array($this->cumulated[
"values"]))
481 foreach ($this->cumulated[
"values"] as $val)
483 if ($val[
"selected"] > $maxselection) $maxselection = $val[
"selected"];
484 array_push($selections, $val[
"selected"]);
485 array_push($values, $val[
"value"]);
488 $selectionlabels =
"";
489 if ($maxselection % 2 == 0)
491 $selectionlabels =
"0|" . ($maxselection / 2) .
"|$maxselection";
495 $selectionlabels =
"0|$maxselection";
498 $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());
502 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"survey", $survey_id);
503 $this->ctrl->setParameterByClass(
"ilsurveyevaluationgui",
"question", $this->object->getId());
504 $charturl = $this->ctrl->getLinkTargetByClass(
"ilsurveyevaluationgui",
"outChart");
506 $template->setVariable(
"CHART", $charturl);
508 $template->setVariable(
"TEXT_CHART", $this->lng->txt(
"chart"));
509 $template->setVariable(
"ALT_CHART",
$data[
"title"] .
"( " . $this->lng->txt(
"chart") .
")");
510 $template->parseCurrentBlock();
512 $template->setVariable(
"QUESTION_TITLE",
"$counter. ".$this->object->getTitle());
513 return $template->get();