ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.SurveyMetricQuestion.php
Go to the documentation of this file.
1<?php
2 /*
3 +----------------------------------------------------------------------------+
4 | ILIAS open source |
5 +----------------------------------------------------------------------------+
6 | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7 | |
8 | This program is free software; you can redistribute it and/or |
9 | modify it under the terms of the GNU General Public License |
10 | as published by the Free Software Foundation; either version 2 |
11 | of the License, or (at your option) any later version. |
12 | |
13 | This program is distributed in the hope that it will be useful, |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | GNU General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU General Public License |
19 | along with this program; if not, write to the Free Software |
20 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21 +----------------------------------------------------------------------------+
22*/
23
24include_once "./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
25
38{
42
51
58
65
78 $title = "",
79 $description = "",
80 $author = "",
81 $questiontext = "",
82 $owner = -1,
83 $subtype = self::SUBTYPE_NON_RATIO
84 )
85 {
87 $this->subtype = $subtype;
88 $this->minimum = "";
89 $this->maximum = "";
90 }
91
99 function setSubtype($subtype = self::SUBTYPE_NON_RATIO)
100 {
101 $this->subtype = $subtype;
102 }
103
111 function setMinimum($minimum = 0)
112 {
113 if($minimum !== NULL)
114 {
115 $minimum = (float)$minimum;
116 }
117 if(!$minimum)
118 {
119 $minimum = NULL;
120 }
121 $this->minimum = $minimum;
122 }
123
131 function setMaximum($maximum = "")
132 {
133 if($maximum !== NULL)
134 {
135 $maximum = (float)$maximum;
136 }
137 if(!$maximum)
138 {
139 $maximum = NULL;
140 }
141 $this->maximum = $maximum;
142 }
143
151 function getSubtype()
152 {
153 return $this->subtype;
154 }
155
163 function getMinimum()
164 {
165 if ((strlen($this->minimum) == 0) && ($this->getSubtype() > 3))
166 {
167 $this->minimum = 0;
168 }
169 return (strlen($this->minimum)) ? $this->minimum : NULL;
170 }
171
179 function getMaximum()
180 {
181 return (strlen($this->maximum)) ? $this->maximum : NULL;
182 }
183
192 {
193 global $ilDB;
194
195 $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question, " . $this->getAdditionalTableName() . " WHERE svy_question.question_id = %s AND svy_question.question_id = " . $this->getAdditionalTableName() . ".question_fi",
196 array('integer'),
197 array($id)
198 );
199 if ($result->numRows() == 1)
200 {
201 return $ilDB->fetchAssoc($result);
202 }
203 else
204 {
205 return array();
206 }
207 }
208
215 function loadFromDb($id)
216 {
217 global $ilDB;
218
219 $result = $ilDB->queryF("SELECT svy_question.*, " . $this->getAdditionalTableName() . ".* FROM svy_question LEFT JOIN " . $this->getAdditionalTableName() . " ON " . $this->getAdditionalTableName() . ".question_fi = svy_question.question_id WHERE svy_question.question_id = %s",
220 array('integer'),
221 array($id)
222 );
223 if ($result->numRows() == 1)
224 {
225 $data = $ilDB->fetchAssoc($result);
226 $this->setId($data["question_id"]);
227 $this->setTitle($data["title"]);
228 $this->setDescription($data["description"]);
229 $this->setObjId($data["obj_fi"]);
230 $this->setAuthor($data["author"]);
231 $this->setOwner($data["owner_fi"]);
232 $this->label = $data['label'];
233 include_once("./Services/RTE/classes/class.ilRTE.php");
234 $this->setQuestiontext(ilRTE::_replaceMediaObjectImageSrc($data["questiontext"], 1));
235 $this->setObligatory($data["obligatory"]);
236 $this->setComplete($data["complete"]);
237 $this->setOriginalId($data["original_id"]);
238 $this->setSubtype($data["subtype"]);
239
240 $result = $ilDB->queryF("SELECT svy_variable.* FROM svy_variable WHERE svy_variable.question_fi = %s",
241 array('integer'),
242 array($id)
243 );
244 if ($result->numRows() > 0)
245 {
246 if ($data = $ilDB->fetchAssoc($result))
247 {
248 $this->minimum = $data["value1"];
249 if (($data["value2"] < 0) or (strcmp($data["value2"], "") == 0))
250 {
251 $this->maximum = "";
252 }
253 else
254 {
255 $this->maximum = $data["value2"];
256 }
257 }
258 }
259 }
260 parent::loadFromDb($id);
261 }
262
269 function isComplete()
270 {
271 if (
272 strlen($this->getTitle()) &&
273 strlen($this->getAuthor()) &&
274 strlen($this->getQuestiontext())
275 )
276 {
277 return 1;
278 }
279 else
280 {
281 return 0;
282 }
283 }
284
290 function saveToDb($original_id = "")
291 {
292 global $ilDB;
293
294 $affectedRows = parent::saveToDb($original_id);
295 if ($affectedRows == 1)
296 {
297 $affectedRows = $ilDB->manipulateF("DELETE FROM " . $this->getAdditionalTableName() . " WHERE question_fi = %s",
298 array('integer'),
299 array($this->getId())
300 );
301 $affectedRows = $ilDB->manipulateF("INSERT INTO " . $this->getAdditionalTableName() . " (question_fi, subtype) VALUES (%s, %s)",
302 array('integer', 'text'),
303 array($this->getId(), $this->getSubType())
304 );
305
306 // saving material uris in the database
307 $this->saveMaterial();
308
309 // save categories
310 $affectedRows = $ilDB->manipulateF("DELETE FROM svy_variable WHERE question_fi = %s",
311 array('integer'),
312 array($this->getId())
313 );
314
315 if (preg_match("/[\D]/", $this->maximum) or (strcmp($this->maximum, "&infin;") == 0))
316 {
317 $max = -1;
318 }
319 else
320 {
321 $max = $this->getMaximum();
322 }
323 $next_id = $ilDB->nextId('svy_variable');
324 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, value2, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s, %s)",
325 array('integer','integer','integer','float','float','integer','integer'),
326 array($next_id, 0, $this->getId(), $this->getMinimum(), $max, 0, time())
327 );
328 }
329 }
330
337 function toXML($a_include_header = TRUE, $obligatory_state = "")
338 {
339 include_once("./Services/Xml/classes/class.ilXmlWriter.php");
340 $a_xml_writer = new ilXmlWriter;
341 $a_xml_writer->xmlHeader();
342 $this->insertXML($a_xml_writer, $a_include_header, $obligatory_state);
343 $xml = $a_xml_writer->xmlDumpMem(FALSE);
344 if (!$a_include_header)
345 {
346 $pos = strpos($xml, "?>");
347 $xml = substr($xml, $pos + 2);
348 }
349 return $xml;
350 }
351
360 function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state = "")
361 {
362 $attrs = array(
363 "id" => $this->getId(),
364 "title" => $this->getTitle(),
365 "type" => $this->getQuestiontype(),
366 "subtype" => $this->getSubtype(),
367 "obligatory" => $this->getObligatory()
368 );
369 $a_xml_writer->xmlStartTag("question", $attrs);
370
371 $a_xml_writer->xmlElement("description", NULL, $this->getDescription());
372 $a_xml_writer->xmlElement("author", NULL, $this->getAuthor());
373 $a_xml_writer->xmlStartTag("questiontext");
374 $this->addMaterialTag($a_xml_writer, $this->getQuestiontext());
375 $a_xml_writer->xmlEndTag("questiontext");
376
377 $a_xml_writer->xmlStartTag("responses");
378 switch ($this->getSubtype())
379 {
380 case 3:
381 $attrs = array(
382 "id" => "0",
383 "format" => "double"
384 );
385 if (strlen($this->getMinimum()))
386 {
387 $attrs["min"] = $this->getMinimum();
388 }
389 if (strlen($this->getMaximum()))
390 {
391 $attrs["max"] = $this->getMaximum();
392 }
393 break;
394 case 4:
395 $attrs = array(
396 "id" => "0",
397 "format" => "double"
398 );
399 if (strlen($this->getMinimum()))
400 {
401 $attrs["min"] = $this->getMinimum();
402 }
403 if (strlen($this->getMaximum()))
404 {
405 $attrs["max"] = $this->getMaximum();
406 }
407 break;
408 case 5:
409 $attrs = array(
410 "id" => "0",
411 "format" => "integer"
412 );
413 if (strlen($this->getMinimum()))
414 {
415 $attrs["min"] = $this->getMinimum();
416 }
417 if (strlen($this->getMaximum()))
418 {
419 $attrs["max"] = $this->getMaximum();
420 }
421 break;
422 }
423 $a_xml_writer->xmlStartTag("response_num", $attrs);
424 $a_xml_writer->xmlEndTag("response_num");
425
426 $a_xml_writer->xmlEndTag("responses");
427
428 if (count($this->material))
429 {
430 if (preg_match("/il_(\d*?)_(\w+)_(\d+)/", $this->material["internal_link"], $matches))
431 {
432 $attrs = array(
433 "label" => $this->material["title"]
434 );
435 $a_xml_writer->xmlStartTag("material", $attrs);
436 $intlink = "il_" . IL_INST_ID . "_" . $matches[2] . "_" . $matches[3];
437 if (strcmp($matches[1], "") != 0)
438 {
439 $intlink = $this->material["internal_link"];
440 }
441 $a_xml_writer->xmlElement("mattext", NULL, $intlink);
442 $a_xml_writer->xmlEndTag("material");
443 }
444 }
445
446 $a_xml_writer->xmlEndTag("question");
447 }
448
456 {
457 global $ilDB;
458 $result = $ilDB->queryF("SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
459 array('text'),
460 array($this->getQuestionType())
461 );
462 $row = $ilDB->fetchAssoc($result);
463 return $row["questiontype_id"];
464 }
465
473 {
474 return "SurveyMetricQuestion";
475 }
476
484 {
485 return "svy_qst_metric";
486 }
487
494 function &getWorkingDataFromUserInput($post_data)
495 {
496 $entered_value = $post_data[$this->getId() . "_metric_question"];
497 $data = array();
498 if (strlen($entered_value))
499 {
500 array_push($data, array("value" => $entered_value));
501 }
502 return $data;
503 }
504
514 function checkUserInput($post_data, $survey_id)
515 {
516 $entered_value = $post_data[$this->getId() . "_metric_question"];
517 // replace german notation with international notation
518 $entered_value = str_replace(",", ".", $entered_value);
519
520 if ((!$this->getObligatory($survey_id)) && (strlen($entered_value) == 0)) return "";
521
522 if (strlen($entered_value) == 0) return $this->lng->txt("survey_question_obligatory");
523
524 if (strlen($this->getMinimum()))
525 {
526 if ($entered_value < $this->getMinimum())
527 {
528 return $this->lng->txt("metric_question_out_of_bounds");
529 }
530 }
531
532 if (strlen($this->getMaximum()))
533 {
534 if (($this->getMaximum() == 1) && ($this->getMaximum() < $this->getMinimum()))
535 {
536 // old &infty; values as maximum
537 }
538 else
539 {
540 if ($entered_value > $this->getMaximum())
541 {
542 return $this->lng->txt("metric_question_out_of_bounds");
543 }
544 }
545 }
546
547 if (!is_numeric($entered_value))
548 {
549 return $this->lng->txt("metric_question_not_a_value");
550 }
551
552 if (($this->getSubType() == self::SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value)))
553 {
554 return $this->lng->txt("metric_question_floating_point");
555 }
556 return "";
557 }
558
564 public function saveRandomData($active_id)
565 {
566 global $ilDB;
567 // single response
568 $number = rand($this->getMinimum(), (strlen($this->getMaximum())) ? $this->getMaximum() : 100);
569 $next_id = $ilDB->nextId('svy_answer');
570 $affectedRows = $ilDB->manipulateF("INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
571 array('integer','integer','integer','float','text','integer'),
572 array($next_id, $this->getId(), $active_id, $number, NULL, time())
573 );
574 }
575
576 function saveUserInput($post_data, $active_id, $a_return = false)
577 {
578 global $ilDB;
579
580 $entered_value = $post_data[$this->getId() . "_metric_question"];
581
582 // replace german notation with international notation
583 $entered_value = str_replace(",", ".", $entered_value);
584
585 if($a_return)
586 {
587 return array(array("value"=>$entered_value, "textanswer"=>null));
588 }
589 if (strlen($entered_value) == 0) return;
590
591 $next_id = $ilDB->nextId('svy_answer');
592 #20216
593 $fields = array();
594 $fields['answer_id'] = array("integer", $next_id);
595 $fields['question_fi'] = array("integer", $this->getId());
596 $fields['active_fi'] = array("integer", $active_id);
597 $fields['value'] = array("float", (strlen($entered_value)) ? $entered_value : NULL);
598 $fields['textanswer'] = array("clob", NULL);
599 $fields['tstamp'] = array("integer", time());
600
601 $affectedRows = $ilDB->insert("svy_answer", $fields);
602 }
603
604 function &getCumulatedResults($survey_id, $nr_of_users, $finished_ids)
605 {
606 global $ilDB;
607
608 $question_id = $this->getId();
609
610 $result_array = array();
611 $cumulated = array();
612
613 $sql = "SELECT svy_answer.* FROM svy_answer".
614 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
615 " WHERE svy_answer.question_fi = ".$ilDB->quote($question_id, "integer").
616 " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
617 if($finished_ids)
618 {
619 $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
620 }
621
622 $result = $ilDB->query($sql);
623 while ($row = $ilDB->fetchAssoc($result))
624 {
625 $cumulated[$row["value"]]++;
626 }
627 asort($cumulated, SORT_NUMERIC);
628 end($cumulated);
629 $numrows = $result->numRows();
630 $result_array["USERS_ANSWERED"] = $result->numRows();
631 $result_array["USERS_SKIPPED"] = $nr_of_users - $result->numRows();
632 if(sizeof($cumulated))
633 {
634 $result_array["MODE"] = key($cumulated);
635 $result_array["MODE_VALUE"] = key($cumulated);
636 $result_array["MODE_NR_OF_SELECTIONS"] = $cumulated[key($cumulated)];
637 ksort($cumulated, SORT_NUMERIC);
638 }
639 $counter = 0;
640 foreach ($cumulated as $value => $nr_of_users)
641 {
642 $percentage = 0;
643 if ($numrows > 0)
644 {
645 $percentage = (float)($nr_of_users/$numrows);
646 }
647 $result_array["values"][$counter++] = array("value" => $value, "selected" => (int)$nr_of_users, "percentage" => $percentage);
648 }
649 $median = array();
650 $total = 0;
651 $x_i = 0;
652 $p_i = 1;
653 $x_i_inv = 0;
654 $sum_part_zero = false;
655 foreach ($cumulated as $value => $key)
656 {
657 $total += $key;
658 for ($i = 0; $i < $key; $i++)
659 {
660 array_push($median, $value);
661 $x_i += $value;
662 $p_i *= $value;
663 if ($value != 0)
664 {
665 $sum_part_zero = true;
666 $x_i_inv += 1/$value;
667 }
668 }
669 }
670 if ($total > 0)
671 {
672 if (($total % 2) == 0)
673 {
674 $median_value = 0.5 * ($median[($total/2)-1] + $median[($total/2)]);
675 }
676 else
677 {
678 $median_value = $median[(($total+1)/2)-1];
679 }
680 }
681 else
682 {
683 $median_value = "";
684 }
685 if ($total > 0)
686 {
687 if (($x_i/$total) == (int)($x_i/$total))
688 {
689 $result_array["ARITHMETIC_MEAN"] = $x_i/$total;
690 }
691 else
692 {
693 $result_array["ARITHMETIC_MEAN"] = sprintf("%.2f", $x_i/$total);
694 }
695 }
696 else
697 {
698 $result_array["ARITHMETIC_MEAN"] = "";
699 }
700 $result_array["MEDIAN"] = $median_value;
701 $result_array["QUESTION_TYPE"] = "SurveyMetricQuestion";
702 return $result_array;
703 }
704
714 function setExportDetailsXLS(&$workbook, &$format_title, &$format_bold, &$eval_data, $export_label)
715 {
716 include_once ("./Services/Excel/classes/class.ilExcelUtils.php");
717 $worksheet =& $workbook->addWorksheet();
718 $rowcounter = 0;
719 switch ($export_label)
720 {
721 case 'label_only':
722 $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("label")), $format_bold);
723 $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->label));
724 break;
725 case 'title_only':
726 $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
727 $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
728 break;
729 default:
730 $worksheet->writeString(0, 0, ilExcelUtils::_convert_text($this->lng->txt("title")), $format_bold);
731 $worksheet->writeString(0, 1, ilExcelUtils::_convert_text($this->getTitle()));
732 $rowcounter++;
733 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("label")), $format_bold);
734 $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->label));
735 break;
736 }
737 $rowcounter++;
738 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("question")), $format_bold);
739 $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->getQuestiontext()));
740 $rowcounter++;
741 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("question_type")), $format_bold);
742 $worksheet->writeString($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt($this->getQuestionType())));
743 $rowcounter++;
744 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("users_answered")), $format_bold);
745 $worksheet->write($rowcounter, 1, $eval_data["USERS_ANSWERED"]);
746 $rowcounter++;
747 $worksheet->writeString($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("users_skipped")), $format_bold);
748 $worksheet->write($rowcounter, 1, $eval_data["USERS_SKIPPED"]);
749 $rowcounter++;
750
751 $worksheet->write($rowcounter, 0, $this->lng->txt("subtype"), $format_bold);
752 switch ($this->getSubtype())
753 {
755 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("non_ratio")), $format_bold);
756 break;
758 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("ratio_non_absolute")), $format_bold);
759 break;
761 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($this->lng->txt("ratio_absolute")), $format_bold);
762 break;
763 }
764 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode")), $format_bold);
765 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE"]));
766 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_text")), $format_bold);
767 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE"]));
768 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("mode_nr_of_selections")), $format_bold);
769 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MODE_NR_OF_SELECTIONS"]));
770 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("median")), $format_bold);
771 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["MEDIAN"]));
772 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("arithmetic_mean")), $format_bold);
773 $worksheet->write($rowcounter++, 1, ilExcelUtils::_convert_text($eval_data["ARITHMETIC_MEAN"]));
774 $worksheet->write($rowcounter, 0, ilExcelUtils::_convert_text($this->lng->txt("values")), $format_bold);
775 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($this->lng->txt("value")), $format_title);
776 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($this->lng->txt("category_nr_selected")), $format_title);
777 $worksheet->write($rowcounter++, 3, ilExcelUtils::_convert_text($this->lng->txt("svy_fraction_of_selections")), $format_title);
778 $values = "";
779 if (is_array($eval_data["values"]))
780 {
781 foreach ($eval_data["values"] as $key => $value)
782 {
783 $worksheet->write($rowcounter, 1, ilExcelUtils::_convert_text($value["value"]));
784 $worksheet->write($rowcounter, 2, ilExcelUtils::_convert_text($value["selected"]));
785 $worksheet->write($rowcounter++, 3, ilExcelUtils::_convert_text($value["percentage"]), $format_percent);
786 }
787 }
788 }
789
797 function addUserSpecificResultsData(&$a_array, &$resultset)
798 {
799 if (count($resultset["answers"][$this->getId()]))
800 {
801 foreach ($resultset["answers"][$this->getId()] as $key => $answer)
802 {
803 array_push($a_array, $answer["value"]);
804 }
805 }
806 else
807 {
808 array_push($a_array, $this->getSkippedValue());
809 }
810 }
811
819 function &getUserAnswers($survey_id, $finished_ids)
820 {
821 global $ilDB;
822
823 $answers = array();
824
825 $sql = "SELECT svy_answer.* FROM svy_answer".
826 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
827 " WHERE svy_answer.question_fi = ".$ilDB->quote($this->getId(), "integer").
828 " AND svy_finished.survey_fi = ".$ilDB->quote($survey_id, "integer");
829 if($finished_ids)
830 {
831 $sql .= " AND ".$ilDB->in("svy_finished.finished_id", $finished_ids, "", "integer");
832 }
833
834 $result = $ilDB->query($sql);
835 while ($row = $ilDB->fetchAssoc($result))
836 {
837 $answers[$row["active_fi"]] = $row["value"];
838 }
839 return $answers;
840 }
841
848 function importResponses($a_data)
849 {
850 foreach ($a_data as $id => $data)
851 {
852 $this->setMinimum($data["min"]);
853 $this->setMaximum($data["max"]);
854 }
855 }
856
864 {
865 return TRUE;
866 }
867
875 {
876 return array("<", "<=", "=", "<>", ">=", ">");
877 }
878
885 function outPreconditionSelectValue(&$template)
886 {
887 $template->setCurrentBlock("textfield");
888 $template->setVariable("TEXTFIELD_VALUE", "");
889 $template->parseCurrentBlock();
890 }
891
898 public function getPreconditionSelectValue($default = "", $title, $variable)
899 {
900 include_once "./Services/Form/classes/class.ilNumberInputGUI.php";
901 $step3 = new ilNumberInputGUI($title, $variable);
902 $step3->setValue($default);
903 return $step3;
904 }
905
912 function getMinMaxText()
913 {
914 $min = $this->getMinimum();
915 $max = $this->getMaximum();
916 if (strlen($min) && strlen($max))
917 {
918 return "(" . $min . " " . strtolower($this->lng->txt("to")) . " " . $max . ")";
919 }
920 else if (strlen($min))
921 {
922 return "(&gt;= " . $min . ")";
923 }
924 else if (strlen($max))
925 {
926 return "(&lt;= " . $max . ")";
927 }
928 else
929 {
930 return "";
931 }
932 }
933}
934?>
$result
getQuestionType()
Returns the question type of the question.
& getUserAnswers($survey_id, $finished_ids)
Returns an array containing all answers to this question in a given survey.
saveToDb($original_id="")
Saves a SurveyMetricQuestion object to a database.
getQuestionTypeID()
Returns the question type ID of the question.
getSubtype()
Gets the question subtype.
setMaximum($maximum="")
Sets the maximum value.
outPreconditionSelectValue(&$template)
Creates a value selection for preconditions.
getPreconditionSelectValue($default="", $title, $variable)
Creates a form property for the precondition value.
SurveyMetricQuestion( $title="", $description="", $author="", $questiontext="", $owner=-1, $subtype=self::SUBTYPE_NON_RATIO)
SurveyMetricQuestion constructor.
addUserSpecificResultsData(&$a_array, &$resultset)
Adds the values for the user specific results export for a given user.
getAvailableRelations()
Returns the available relations for the question.
checkUserInput($post_data, $survey_id)
Checks the input of the active user for obligatory status and entered values.
getMinMaxText()
Creates a text for the input range of the metric question.
saveRandomData($active_id)
Saves random answers for a given active user in the database.
getMinimum()
Returns the minimum value of the question.
getAdditionalTableName()
Returns the name of the additional question data table in the database.
saveUserInput($post_data, $active_id, $a_return=false)
& getCumulatedResults($survey_id, $nr_of_users, $finished_ids)
setSubtype($subtype=self::SUBTYPE_NON_RATIO)
Sets the question subtype.
insertXML(&$a_xml_writer, $a_include_header=TRUE, $obligatory_state="")
Adds the question XML to a given XMLWriter object.
isComplete()
Returns true if the question is complete for use.
getMaximum()
Returns the maximum value of the question.
toXML($a_include_header=TRUE, $obligatory_state="")
Returns an xml representation of the question.
loadFromDb($id)
Loads a SurveyMetricQuestion object from the database.
& getWorkingDataFromUserInput($post_data)
Creates the user data of the svy_answer table from the POST data.
setExportDetailsXLS(&$workbook, &$format_title, &$format_bold, &$eval_data, $export_label)
Creates an Excel worksheet for the detailed cumulated results of this question.
_getQuestionDataArray($id)
Returns the question data fields from the database.
importResponses($a_data)
Import response data from the question import file.
setMinimum($minimum=0)
Sets the minimum value.
usableForPrecondition()
Returns if the question is usable for preconditions.
Basic class for all survey question types.
setQuestiontext($questiontext="")
Sets the questiontext of the SurveyQuestion object.
setId($id=-1)
Sets the id of the SurveyQuestion object.
setAuthor($author="")
Sets the authors name of the SurveyQuestion object.
SurveyQuestion( $title="", $description="", $author="", $questiontext="", $owner=-1)
SurveyQuestion constructor The constructor takes possible arguments an creates an instance of the Sur...
getDescription()
Gets the description string of the SurveyQuestion object.
getId()
Gets the id of the SurveyQuestion object.
setDescription($description="")
Sets the description string of the SurveyQuestion object.
setObjId($obj_id=0)
Set the reference id of the container object.
getAuthor()
Gets the authors name of the SurveyQuestion object.
setOriginalId($original_id)
getQuestiontext()
Gets the questiontext of the SurveyQuestion object.
getObligatory($survey_id="")
Gets the obligatory state of the question.
getTitle()
Gets the title string of the SurveyQuestion object.
setComplete($a_complete)
Sets the complete state of the question.
saveMaterial()
save material to db
setOwner($owner="")
Sets the creator/owner ID of the SurveyQuestion object.
setTitle($title="")
Sets the title string of the SurveyQuestion object.
$cumulated
An array containing the cumulated results of the question for a given survey.
addMaterialTag(&$a_xml_writer, $a_material, $close_material_tag=TRUE, $add_mobs=TRUE, $a_attrs=null)
Creates an XML material tag from a plain text or xhtml text.
setObligatory($obligatory=1)
Sets the obligatory state of the question.
_convert_text($a_text, $a_target="has been removed")
This class represents a number property in a property form.
static _replaceMediaObjectImageSrc($a_text, $a_direction=0, $nic=IL_INST_ID)
replaces image source from mob image urls with the mob id or replaces mob id with the correct image s...
XML writer class.
xmlHeader()
Writes xml header @access public.
$data
global $ilDB