ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
SurveyMetricQuestionGUI Class Reference

Metric survey question GUI representation. More...

+ Inheritance diagram for SurveyMetricQuestionGUI:
+ Collaboration diagram for SurveyMetricQuestionGUI:

Public Member Functions

 setQuestionTabs ()
 
 getParsedAnswers (array $a_working_data=null, $a_only_user_anwers=false)
 
 getPrintView ($question_title=1, $show_questiontext=1, $survey_id=null, array $a_working_data=null)
 Creates a HTML representation of the question. More...
 
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 Creates the question output form for the learner. More...
 
 getCumulatedResultsDetails ($survey_id, $counter, $finished_ids)
 Creates the detailed output of the cumulated results for the question. More...
 
- Public Member Functions inherited from SurveyQuestionGUI
 __construct ($a_id=-1)
 
 setQuestionTabs ()
 
executeCommand ()
 
 _getGUIClassNameForId ($a_q_id)
 
 _getClassNameForQType ($q_type)
 
 getQuestionType ()
 Returns the question type string. More...
 
 setBackUrl ($a_url)
 
 setQuestionTabsForClass ($guiclass)
 
 getPrintView ($question_title=1, $show_questiontext=1)
 
 preview ()
 Creates a preview of the question. More...
 
 getWorkingForm ($working_data="", $question_title=1, $show_questiontext=1, $error_message="", $survey_id=null)
 
 getCumulatedResultsDetails ($survey_id, $counter, $finished_ids)
 
 material ($checkonly=FALSE)
 Material tab of the survey questions. More...
 
 deleteMaterial ()
 
 addMaterial ()
 Add materials to a question. More...
 
 removeMaterial ()
 
 cancelExplorer ()
 
 addPG ()
 
 addST ()
 
 addGIT ()
 
 linkChilds ()
 
 savePhrase ($a_reload=false)
 Creates an output to save the current answers as a phrase. More...
 
 confirmSavePhrase ()
 Save a new phrase to the database. More...
 

Protected Member Functions

 initObject ()
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
 renderChart ($a_id, $a_values)
 
- Protected Member Functions inherited from SurveyQuestionGUI
 initObject ()
 
 outQuestionText ($template)
 
 initEditForm ()
 
 addCommandButtons ($a_form)
 
 editQuestion (ilPropertyFormGUI $a_form=null)
 
 saveSync ()
 
 saveReturn ()
 
 saveForm ()
 
 save ($a_return=false, $a_sync=false)
 
 copySyncForm ()
 
 syncCopies ()
 
 originalSyncForm ()
 
 sync ()
 
 cancelSync ()
 
 redirectAfterSaving ($a_return=false)
 Redirect to calling survey or to edit form. More...
 
 cancel ()
 
 validateEditForm (ilPropertyFormGUI $a_form)
 
 addFieldsToEditForm (ilPropertyFormGUI $a_form)
 
 importEditFormValues (ilPropertyFormGUI $a_form)
 
 getPrintViewQuestionTitle ($question_title=1)
 
 getMaterialOutput ()
 Creates the HTML output of the question material(s) More...
 
 renderChart ($a_id, $a_variables)
 
 initPhrasesForm ()
 
 addPhrase (ilPropertyFormGUI $a_form=null)
 Creates an output for the addition of phrases. More...
 
 addSelectedPhrase ()
 
 renderStatisticsDetailsTable (array $a_head, array $a_rows, array $a_foot=null)
 

Additional Inherited Members

- Static Public Member Functions inherited from SurveyQuestionGUI
static & _getQuestionGUI ($questiontype, $question_id=-1)
 Creates a question gui representation. More...
 
- Data Fields inherited from SurveyQuestionGUI
 $object
 
- Protected Attributes inherited from SurveyQuestionGUI
 $tpl
 
 $lng
 
 $ctrl
 
 $cumulated
 
 $parent_url
 

Detailed Description

Metric survey question GUI representation.

The SurveyMetricQuestionGUI class encapsulates the GUI representation for metric survey question types.

Author
Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
Version
$Id$

Definition at line 37 of file class.SurveyMetricQuestionGUI.php.

Member Function Documentation

◆ addFieldsToEditForm()

SurveyMetricQuestionGUI::addFieldsToEditForm ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 55 of file class.SurveyMetricQuestionGUI.php.

56 {
57 // subtype
58 $subtype = new ilRadioGroupInputGUI($this->lng->txt("subtype"), "type");
59 $subtype->setRequired(true);
60 $a_form->addItem($subtype);
61
62 // #10652
63 $opt = new ilRadioOption($this->lng->txt('non_ratio'), SurveyMetricQuestion::SUBTYPE_NON_RATIO, $this->lng->txt("metric_subtype_description_interval"));
64 $subtype->addOption($opt);
65
66 // minimum value
67 $minimum1 = new ilNumberInputGUI($this->lng->txt("minimum"), "minimum3");
68 $minimum1->setRequired(false);
69 $minimum1->setSize(6);
70 $opt->addSubItem($minimum1);
71
72 // maximum value
73 $maximum1 = new ilNumberInputGUI($this->lng->txt("maximum"), "maximum3");
74 $maximum1->setRequired(false);
75 $maximum1->setSize(6);
76 $opt->addSubItem($maximum1);
77
78 $opt = new ilRadioOption($this->lng->txt('ratio_non_absolute'), SurveyMetricQuestion::SUBTYPE_RATIO_NON_ABSOLUTE, $this->lng->txt("metric_subtype_description_rationonabsolute"));
79 $subtype->addOption($opt);
80
81 // minimum value
82 $minimum2 = new ilNumberInputGUI($this->lng->txt("minimum"), "minimum4");
83 $minimum2->setRequired(false);
84 $minimum2->setSize(6);
85 $minimum2->setMinValue(0);
86 $opt->addSubItem($minimum2);
87
88 // maximum value
89 $maximum2 = new ilNumberInputGUI($this->lng->txt("maximum"), "maximum4");
90 $maximum2->setRequired(false);
91 $maximum2->setSize(6);
92 $opt->addSubItem($maximum2);
93
94 $opt = new ilRadioOption($this->lng->txt('ratio_absolute'), SurveyMetricQuestion::SUBTYPE_RATIO_ABSOLUTE, $this->lng->txt("metric_subtype_description_ratioabsolute"));
95 $subtype->addOption($opt);
96
97 // minimum value
98 $minimum3 = new ilNumberInputGUI($this->lng->txt("minimum"), "minimum5");
99 $minimum3->setRequired(false);
100 $minimum3->setSize(6);
101 $minimum3->setMinValue(0);
102 $minimum3->setDecimals(0);
103 $opt->addSubItem($minimum3);
104
105 // maximum value
106 $maximum3 = new ilNumberInputGUI($this->lng->txt("maximum"), "maximum5");
107 $maximum3->setDecimals(0);
108 $maximum3->setRequired(false);
109 $maximum3->setSize(6);
110 $opt->addSubItem($maximum3);
111
112
113 // values
114 $subtype->setValue($this->object->getSubtype());
115
116 switch($this->object->getSubtype())
117 {
119 $minimum1->setValue($this->object->getMinimum());
120 $maximum1->setValue($this->object->getMaximum());
121 break;
122
124 $minimum2->setValue($this->object->getMinimum());
125 $maximum2->setValue($this->object->getMaximum());
126 break;
127
129 $minimum3->setValue($this->object->getMinimum());
130 $maximum3->setValue($this->object->getMaximum());
131 break;
132 }
133 }
This class represents a number property in a property form.
addItem($a_item)
Add Item (Property, SectionHeader).
This class represents a property in a property form.
This class represents an option in a radio group.

References ilPropertyFormGUI\addItem(), SurveyMetricQuestion\SUBTYPE_NON_RATIO, SurveyMetricQuestion\SUBTYPE_RATIO_ABSOLUTE, and SurveyMetricQuestion\SUBTYPE_RATIO_NON_ABSOLUTE.

+ Here is the call graph for this function:

◆ getCumulatedResultsDetails()

SurveyMetricQuestionGUI::getCumulatedResultsDetails (   $survey_id,
  $counter,
  $finished_ids 
)

Creates the detailed output of the cumulated results for the question.

Parameters
integer$survey_idThe database ID of the survey
integer$counterThe counter of the question position in the survey
Returns
string HTML text with the cumulated results @access private

Reimplemented from SurveyQuestionGUI.

Definition at line 275 of file class.SurveyMetricQuestionGUI.php.

276 {
277 if (count($this->cumulated) == 0)
278 {
279 if(!$finished_ids)
280 {
281 include_once "./Modules/Survey/classes/class.ilObjSurvey.php";
282 $nr_of_users = ilObjSurvey::_getNrOfParticipants($survey_id);
283 }
284 else
285 {
286 $nr_of_users = sizeof($finished_ids);
287 }
288 $this->cumulated =& $this->object->getCumulatedResults($survey_id, $nr_of_users, $finished_ids);
289 }
290
291 $output = "";
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");
294
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())
315 {
317 $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("non_ratio"));
318 break;
320 $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("ratio_non_absolute"));
321 break;
323 $template->setVariable("TEXT_OPTION_VALUE", $this->lng->txt("ratio_absolute"));
324 break;
325 }
326 $template->parseCurrentBlock();
327
328 /*
329 $template->setCurrentBlock("detail_row");
330 $template->setVariable("TEXT_OPTION", $this->lng->txt("mode"));
331 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE"]);
332 $template->parseCurrentBlock();
333 $template->setCurrentBlock("detail_row");
334 $template->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections"));
335 $template->setVariable("TEXT_OPTION_VALUE", $this->cumulated["MODE_NR_OF_SELECTIONS"]);
336 $template->parseCurrentBlock();
337 */
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();
346
347 $template->setCurrentBlock("detail_row");
348 $template->setVariable("TEXT_OPTION", $this->lng->txt("values"));
349 $table = array();
350 $idx = $selsum = 0;
351 if (is_array($this->cumulated["values"]))
352 {
353 foreach ($this->cumulated["values"] as $key => $value)
354 {
355 $table[] = array(
356 (++$idx).".",
357 $value["title"],
358 $value["selected"],
359 sprintf("%.2f", 100*$value["percentage"])."%"
360 );
361 }
362 $selsum += (int)$value["selected"];
363 }
364 $head = array(
365 "",
366 $this->lng->txt("title"),
367 $this->lng->txt("category_nr_selected"),
368 $this->lng->txt("percentage_of_selections")
369 );
370 $foot = array(null, null, $selsum, null);
371 $template->setVariable("TEXT_OPTION_VALUE",
372 $this->renderStatisticsDetailsTable($head, $table, $foot));
373 $template->parseCurrentBlock();
374
375 // chart
376 $template->setCurrentBlock("detail_row");
377 $template->setVariable("TEXT_OPTION", $this->lng->txt("chart"));
378 $template->setVariable("TEXT_OPTION_VALUE", $this->renderChart("svy_ch_".$this->object->getId(), $this->cumulated["values"]));
379 $template->parseCurrentBlock();
380
381
382 $template->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
383 return $template->get();
384 }
renderStatisticsDetailsTable(array $a_head, array $a_rows, array $a_foot=null)
_getNrOfParticipants($survey_id)
Returns the number of participants for a survey.
special template class to simplify handling of ITX/PEAR

References ilObjSurvey\_getNrOfParticipants(), renderChart(), SurveyQuestionGUI\renderStatisticsDetailsTable(), SurveyMetricQuestion\SUBTYPE_NON_RATIO, SurveyMetricQuestion\SUBTYPE_RATIO_ABSOLUTE, and SurveyMetricQuestion\SUBTYPE_RATIO_NON_ABSOLUTE.

+ Here is the call graph for this function:

◆ getParsedAnswers()

SurveyMetricQuestionGUI::getParsedAnswers ( array  $a_working_data = null,
  $a_only_user_anwers = false 
)

Definition at line 144 of file class.SurveyMetricQuestionGUI.php.

145 {
146 $res = array();
147
148 if(is_array($a_working_data))
149 {
150 $res[] = array("value" => $a_working_data[0]["value"]);
151 }
152
153 return $res;
154 }

References $res.

Referenced by getPrintView().

+ Here is the caller graph for this function:

◆ getPrintView()

SurveyMetricQuestionGUI::getPrintView (   $question_title = 1,
  $show_questiontext = 1,
  $survey_id = null,
array  $a_working_data = null 
)

Creates a HTML representation of the question.

Creates a HTML representation of the question

@access private

Definition at line 163 of file class.SurveyMetricQuestionGUI.php.

164 {
165 $user_answer = null;
166 if($a_working_data)
167 {
168 $user_answer = $this->getParsedAnswers($a_working_data);
169 $user_answer = $user_answer[0]["value"];
170 }
171
172 $template = new ilTemplate("tpl.il_svy_qpl_metric_printview.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
173 $template->setVariable("MIN_MAX", $this->object->getMinMaxText());
174
175 if ($show_questiontext)
176 {
177 $this->outQuestionText($template);
178 }
179 if ($question_title)
180 {
181 $template->setVariable("QUESTION_TITLE", $this->getPrintViewQuestionTitle($question_title));
182 }
183 $template->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
184 $template->setVariable("QUESTION_ID", $this->object->getId());
185
186 if(!is_array($a_working_data) || !trim($user_answer))
187 {
188 $solution_text = "";
189 $len = 10;
190 for ($i = 0; $i < 10; $i++) $solution_text .= "&#160;";
191 }
192 else
193 {
194 $solution_text = $user_answer;
195 }
196 $template->setVariable("TEXT_SOLUTION", $solution_text);
197
198 $template->parseCurrentBlock();
199 return $template->get();
200 }
getParsedAnswers(array $a_working_data=null, $a_only_user_anwers=false)
getPrintViewQuestionTitle($question_title=1)

References getParsedAnswers(), SurveyQuestionGUI\getPrintViewQuestionTitle(), and SurveyQuestionGUI\outQuestionText().

+ Here is the call graph for this function:

◆ getWorkingForm()

SurveyMetricQuestionGUI::getWorkingForm (   $working_data = "",
  $question_title = 1,
  $show_questiontext = 1,
  $error_message = "",
  $survey_id = null 
)

Creates the question output form for the learner.

Creates the question output form for the learner

@access public

Reimplemented from SurveyQuestionGUI.

Definition at line 214 of file class.SurveyMetricQuestionGUI.php.

215 {
216 $template = new ilTemplate("tpl.il_svy_out_metric.html", TRUE, TRUE, "Modules/SurveyQuestionPool");
217 $template->setCurrentBlock("material_metric");
218 $template->setVariable("TEXT_MATERIAL", $this->getMaterialOutput());
219 $template->parseCurrentBlock();
220 $template->setVariable("MIN_MAX", $this->object->getMinMaxText());
221 /*if (strlen($this->object->getMinimum()))
222 {
223 $template->setCurrentBlock("minimum");
224 $template->setVariable("TEXT_MINIMUM", $this->lng->txt("minimum"));
225 $template->setVariable("VALUE_MINIMUM", $this->object->getMinimum());
226 $template->parseCurrentBlock();
227 }
228 if (strlen($this->object->getMaximum()))
229 {
230 $template->setCurrentBlock("maximum");
231 $template->setVariable("TEXT_MAXIMUM", $this->lng->txt("maximum"));
232 $template->setVariable("VALUE_MAXIMUM", $this->object->getMaximum());
233 $template->parseCurrentBlock();
234 }*/
235
236 $template->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
237 if ($show_questiontext)
238 {
239 $this->outQuestionText($template);
240 }
241 if ($question_title)
242 {
243 $template->setVariable("QUESTION_TITLE", $this->object->getTitle());
244 }
245 $template->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
246 $template->setVariable("QUESTION_ID", $this->object->getId());
247 if (is_array($working_data))
248 {
249 $template->setVariable("VALUE_METRIC", $working_data[0]["value"]);
250 }
251
252 $template->setVariable("INPUT_SIZE", 10);
253
254 if (strcmp($error_message, "") != 0)
255 {
256 $template->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
257 }
258 $template->parseCurrentBlock();
259 return $template->get();
260 }
getMaterialOutput()
Creates the HTML output of the question material(s)

References SurveyQuestionGUI\getMaterialOutput(), and SurveyQuestionGUI\outQuestionText().

+ Here is the call graph for this function:

◆ importEditFormValues()

SurveyMetricQuestionGUI::importEditFormValues ( ilPropertyFormGUI  $a_form)
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 135 of file class.SurveyMetricQuestionGUI.php.

136 {
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));
142 }
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.

References ilPropertyFormGUI\getInput().

+ Here is the call graph for this function:

◆ initObject()

SurveyMetricQuestionGUI::initObject ( )
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 39 of file class.SurveyMetricQuestionGUI.php.

40 {
41 include_once "./Modules/SurveyQuestionPool/classes/class.SurveyMetricQuestion.php";
42 $this->object = new SurveyMetricQuestion();
43 }

◆ renderChart()

SurveyMetricQuestionGUI::renderChart (   $a_id,
  $a_values 
)
protected

Reimplemented from SurveyQuestionGUI.

Definition at line 386 of file class.SurveyMetricQuestionGUI.php.

387 {
388 include_once "Services/Chart/classes/class.ilChart.php";
390 $chart->setsize(700, 400);
391
392 $legend = new ilChartLegend();
393 $chart->setLegend($legend);
394
395 $data = $chart->getDataInstance(ilChartGrid::DATA_BARS);
396 $data->setLabel($this->lng->txt("users_answered"));
397 $data->setBarOptions(0.1, "center");
398
399 if($a_values)
400 {
401 $labels = array();
402 foreach($a_values as $idx => $answer)
403 {
404 $data->addPoint($answer["value"], $answer["selected"]);
405 $labels[$answer["value"]] = $answer["value"];
406 }
407 $chart->addData($data);
408
409 $chart->setTicks($labels, false, true);
410 }
411
412 return "<div style=\"margin:10px\">".$chart->getHTML()."</div>";
413 }
static getInstanceByType($a_type, $a_id)
Get type instance.
const TYPE_GRID
$data
$legend

References $data, $legend, ilChartGrid\DATA_BARS, ilChart\getInstanceByType(), and ilChart\TYPE_GRID.

Referenced by getCumulatedResultsDetails().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setQuestionTabs()

SurveyMetricQuestionGUI::setQuestionTabs ( )

Reimplemented from SurveyQuestionGUI.

Definition at line 50 of file class.SurveyMetricQuestionGUI.php.

51 {
52 $this->setQuestionTabsForClass("surveymetricquestiongui");
53 }

References SurveyQuestionGUI\setQuestionTabsForClass().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: