24 include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
   25 include_once 
"./Modules/Survey/classes/inc.SurveyConstants.php";
 
   27 define(
"SUBTYPE_NON_RATIO", 3);
 
   28 define(
"SUBTYPE_RATIO_NON_ABSOLUTE", 4);
 
   29 define(
"SUBTYPE_RATIO_ABSOLUTE", 5);
 
  150                 if ((strlen($this->minimum) == 0) && ($this->
getSubtype() > 3))
 
  154                 return (strlen($this->minimum)) ? $this->minimum : NULL;
 
  166                 return (strlen($this->maximum)) ? $this->maximum : NULL;
 
  186                         return $ilDB->fetchAssoc(
$result);
 
  217                         $this->label = 
$data[
'label'];
 
  218                         include_once(
"./Services/RTE/classes/class.ilRTE.php");
 
  225                         $result = $ilDB->queryF(
"SELECT svy_variable.* FROM svy_variable WHERE svy_variable.question_fi = %s",
 
  233                                         $this->minimum = 
$data[
"value1"];
 
  234                                         if ((
$data[
"value2"] < 0) or (strcmp(
$data[
"value2"], 
"") == 0))
 
  240                                                 $this->maximum = 
$data[
"value2"];
 
  256                 if ($this->title and $this->author and $this->questiontext)
 
  276                 if ($affectedRows == 1) 
 
  278                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() . 
" WHERE question_fi = %s",
 
  280                                 array($this->
getId())
 
  282                         $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() . 
" (question_fi, subtype) VALUES (%s, %s)",
 
  283                                 array(
'integer', 
'text'),
 
  284                                 array($this->
getId(), $this->getSubType())
 
  291                         $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_variable WHERE question_fi = %s",
 
  293                                 array($this->
getId())
 
  296                         if (preg_match(
"/[\D]/", $this->maximum) or (strcmp($this->maximum, 
"∞") == 0))
 
  304                         $next_id = $ilDB->nextId(
'svy_variable');
 
  305                         $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)",
 
  306                                 array(
'integer',
'integer',
'integer',
'float',
'float',
'integer',
'integer'),
 
  307                                 array($next_id, 0, $this->
getId(), $this->
getMinimum(), $max, 0, time())
 
  318         function toXML($a_include_header = TRUE, $obligatory_state = 
"")
 
  320                 include_once(
"./Services/Xml/classes/class.ilXmlWriter.php");
 
  323                 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
 
  324                 $xml = $a_xml_writer->xmlDumpMem(FALSE);
 
  325                 if (!$a_include_header)
 
  327                         $pos = strpos($xml, 
"?>");
 
  328                         $xml = substr($xml, $pos + 2);
 
  341         function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state = 
"")
 
  344                         "id" => $this->
getId(),
 
  346                         "type" => $this->getQuestiontype(),
 
  350                 $a_xml_writer->xmlStartTag(
"question", $attrs);
 
  352                 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
 
  353                 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
 
  354                 $a_xml_writer->xmlStartTag(
"questiontext");
 
  356                 $a_xml_writer->xmlEndTag(
"questiontext");
 
  358                 $a_xml_writer->xmlStartTag(
"responses");
 
  392                                         "format" => 
"integer" 
  404                 $a_xml_writer->xmlStartTag(
"response_num", $attrs);
 
  405                 $a_xml_writer->xmlEndTag(
"response_num");
 
  407                 $a_xml_writer->xmlEndTag(
"responses");
 
  409                 if (count($this->material))
 
  411                         if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
 
  414                                         "label" => $this->material[
"title"]
 
  416                                 $a_xml_writer->xmlStartTag(
"material", $attrs);
 
  417                                 $intlink = 
"il_" . IL_INST_ID . 
"_" . $matches[2] . 
"_" . $matches[3];
 
  418                                 if (strcmp($matches[1], 
"") != 0)
 
  420                                         $intlink = $this->material[
"internal_link"];
 
  422                                 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
 
  423                                 $a_xml_writer->xmlEndTag(
"material");
 
  427                 $a_xml_writer->xmlEndTag(
"question");
 
  439                 $result = $ilDB->queryF(
"SELECT questiontype_id FROM svy_qtype WHERE type_tag = %s",
 
  444                 return $row[
"questiontype_id"];
 
  455                 return "SurveyMetricQuestion";
 
  466                 return "svy_qst_metric";
 
  477                 $entered_value = $post_data[$this->
getId() . 
"_metric_question"];
 
  479                 if (strlen($entered_value))
 
  481                         array_push(
$data, array(
"value" => $entered_value));
 
  497                 $entered_value = $post_data[$this->
getId() . 
"_metric_question"];
 
  499                 $entered_value = str_replace(
",", 
".", $entered_value);
 
  503                 if (strlen($entered_value) == 0) 
return $this->lng->txt(
"survey_question_obligatory");
 
  509                                 return $this->lng->txt(
"metric_question_out_of_bounds");
 
  523                                         return $this->lng->txt(
"metric_question_out_of_bounds");
 
  528                 if (!is_numeric($entered_value))
 
  530                         return $this->lng->txt(
"metric_question_not_a_value");
 
  533                 if (($this->getSubType() == 
SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value)))
 
  535                         return $this->lng->txt(
"metric_question_floating_point");
 
  550                 $next_id = $ilDB->nextId(
'svy_answer');
 
  551                 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
  552                         array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
 
  553                         array($next_id, $this->
getId(), $active_id, $number, NULL, time())
 
  561                 $entered_value = $post_data[$this->
getId() . 
"_metric_question"];
 
  562                 if (strlen($entered_value) == 0) 
return;
 
  564                 $entered_value = str_replace(
",", 
".", $entered_value);
 
  565                 $next_id = $ilDB->nextId(
'svy_answer');
 
  566                 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
 
  567                         array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
 
  568                         array($next_id, $this->
getId(), $active_id, (strlen($entered_value)) ? $entered_value : NULL, NULL, time())
 
  576                 $question_id = $this->
getId();
 
  578                 $result_array = array();
 
  581                 $result = $ilDB->queryF(
"SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_answer.question_fi = %s AND svy_finished.survey_fi = %s AND svy_finished.finished_id = svy_answer.active_fi",
 
  582                         array(
'integer', 
'integer'),
 
  593                 $result_array[
"USERS_ANSWERED"] = 
$result->numRows();
 
  594                 $result_array[
"USERS_SKIPPED"] = $nr_of_users - 
$result->numRows();
 
  596                 $result_array[
"MODE_VALUE"] = key(
$cumulated);
 
  600                 foreach (
$cumulated as $value => $nr_of_users)
 
  605                                 $percentage = (float)($nr_of_users/$numrows);
 
  607                         $result_array[
"values"][$counter++] = array(
"value" => $value, 
"selected" => (
int)$nr_of_users, 
"percentage" => $percentage);
 
  614                 $sum_part_zero = 
false;
 
  618                         for ($i = 0; $i < $key; $i++)
 
  620                                 array_push($median, $value);
 
  625                                         $sum_part_zero = 
true;
 
  626                                         $x_i_inv += 1/$value;
 
  634                                 $median_value = 0.5 * ($median[(
$total/2)-1] + $median[(
$total/2)]);
 
  638                                 $median_value = $median[((
$total+1)/2)-1];
 
  649                                 $result_array[
"ARITHMETIC_MEAN"] = $x_i/
$total;
 
  653                                 $result_array[
"ARITHMETIC_MEAN"] = sprintf(
"%.2f", $x_i/
$total);
 
  658                         $result_array[
"ARITHMETIC_MEAN"] = 
"";
 
  660                 $result_array[
"MEDIAN"] = $median_value;
 
  661                 $result_array[
"QUESTION_TYPE"] = 
"SurveyMetricQuestion";
 
  662                 return $result_array;
 
  676                 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
 
  677                 $worksheet =& $workbook->addWorksheet();
 
  679                 switch ($export_label)
 
  705                 $worksheet->write($rowcounter, 1, $eval_data[
"USERS_ANSWERED"]);
 
  708                 $worksheet->write($rowcounter, 1, $eval_data[
"USERS_SKIPPED"]);
 
  711                 $worksheet->write($rowcounter, 0, $this->lng->txt(
"subtype"), $format_bold);
 
  739                 if (is_array($eval_data[
"values"]))
 
  741                         foreach ($eval_data[
"values"] as $key => $value)
 
  759                 if (count($resultset[
"answers"][$this->
getId()]))
 
  761                         foreach ($resultset[
"answers"][$this->
getId()] as $key => $answer)
 
  763                                 array_push($a_array, $answer[
"value"]);
 
  768                         array_push($a_array, $this->lng->txt(
"skipped"));
 
  785                 $result = $ilDB->queryF(
"SELECT svy_answer.* FROM svy_answer, svy_finished WHERE svy_finished.survey_fi = %s AND svy_answer.question_fi = %s AND svy_finished.finished_id = svy_answer.active_fi",
 
  786                         array(
'integer',
'integer'),
 
  791                         $answers[
$row[
"active_fi"]] = $row[
"value"];
 
  830                 return array(
"<", 
"<=", 
"=", 
"<>", 
">=", 
">");
 
  841                 $template->setCurrentBlock(
"textfield");
 
  842                 $template->setVariable(
"TEXTFIELD_VALUE", 
"");
 
  843                 $template->parseCurrentBlock();
 
  854                 include_once 
"./Services/Form/classes/class.ilNumberInputGUI.php";
 
  856                 $step3->setValue($default);
 
  870                 if (count($this->cumulated) == 0)
 
  872                         include_once 
"./Modules/Survey/classes/class.ilObjSurvey.php";
 
  877                 foreach ($this->cumulated[
"values"] as $key => $value)
 
  879                         foreach ($value as $key2 => $value2)
 
  881                                 $this->cumulated[
"variables"][$key][$key2] = utf8_decode($value2);
 
  884                 include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyChart.php";
 
  885                 $b1 = 
new SurveyChart(
"bars",400,250,utf8_decode($this->
getTitle()),utf8_decode($this->lng->txt(
"answers")),utf8_decode($this->lng->txt(
"users_answered")),$this->cumulated[
"values"]);
 
  898                 if (strlen($min) && strlen($max))
 
  900                         return "(" . $min . 
" " . strtolower($this->lng->txt(
"to")) . 
" " . $max . 
")";
 
  902                 else if (strlen($min))
 
  904                         return "(>= " . $min . 
")";
 
  906                 else if (strlen($max))
 
  908                         return "(<= " . $max . 
")";