24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
68 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
84 $result = $ilDB->queryF(
"SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s ORDER BY svy_phrase_cat.sequence",
90 if ((
$row[
"defaultvalue"] == 1) and (
$row[
"owner_fi"] == 0))
113 $result = $ilDB->queryF(
"SELECT svy_category.* FROM svy_category, svy_phrase_cat WHERE svy_phrase_cat.category_fi = svy_category.category_id AND svy_phrase_cat.phrase_fi = %s AND (svy_category.owner_fi = 0 OR svy_category.owner_fi = %s) ORDER BY svy_phrase_cat.sequence",
114 array(
'integer',
'integer'),
115 array($phrase_id, $ilUser->getId())
119 if ((
$row[
"defaultvalue"] == 1) and (
$row[
"owner_fi"] == 0))
121 $this->categories->addCategory($this->lng->txt(
$row[
"title"]));
125 $this->categories->addCategory(
$row[
"title"]);
147 return $ilDB->fetchAssoc(
$result);
178 include_once(
"./Services/RTE/classes/class.ilRTE.php");
185 $this->categories->flushCategories();
186 $result = $ilDB->queryF(
"SELECT svy_variable.*, svy_category.title FROM svy_variable, svy_category WHERE svy_variable.question_fi = %s AND svy_variable.category_fi = svy_category.category_id ORDER BY sequence ASC",
194 $this->categories->addCategory(
$data[
"title"]);
209 if ($this->title and $this->author and $this->questiontext and $this->categories->getCategoryCount())
229 if ($affectedRows == 1)
231 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
233 array($this->
getId())
235 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, orientation) VALUES (%s, %s)",
236 array(
'integer',
'text'),
249 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_variable WHERE question_fi = %s",
251 array($this->
getId())
254 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
257 $next_id = $ilDB->nextId(
'svy_variable');
258 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
259 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer'),
260 array($next_id, $category_id, $this->
getId(), ($i + 1), $i, time())
272 function toXML($a_include_header = TRUE, $obligatory_state =
"")
274 include_once(
"./classes/class.ilXmlWriter.php");
277 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
278 $xml = $a_xml_writer->xmlDumpMem(FALSE);
279 if (!$a_include_header)
281 $pos = strpos($xml,
"?>");
282 $xml = substr($xml, $pos + 2);
295 function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state =
"")
298 "id" => $this->
getId(),
300 "type" => $this->getQuestiontype(),
303 $a_xml_writer->xmlStartTag(
"question", $attrs);
305 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
306 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
307 $a_xml_writer->xmlStartTag(
"questiontext");
309 $a_xml_writer->xmlEndTag(
"questiontext");
311 $a_xml_writer->xmlStartTag(
"responses");
313 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
318 $a_xml_writer->xmlStartTag(
"response_single", $attrs);
319 $this->
addMaterialTag($a_xml_writer, $this->categories->getCategory($i));
320 $a_xml_writer->xmlEndTag(
"response_single");
323 $a_xml_writer->xmlEndTag(
"responses");
325 if (count($this->material))
327 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
330 "label" => $this->material[
"title"]
332 $a_xml_writer->xmlStartTag(
"material", $attrs);
333 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
334 if (strcmp($matches[1],
"") != 0)
336 $intlink = $this->material[
"internal_link"];
338 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
339 $a_xml_writer->xmlEndTag(
"material");
343 $a_xml_writer->xmlStartTag(
"metadata");
344 $a_xml_writer->xmlStartTag(
"metadatafield");
345 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"orientation");
346 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getOrientation());
347 $a_xml_writer->xmlEndTag(
"metadatafield");
348 $a_xml_writer->xmlEndTag(
"metadata");
350 $a_xml_writer->xmlEndTag(
"question");
363 foreach ($a_meta as
$key => $value)
365 switch ($value[
"label"])
383 for ($i = $lower_limit; $i <= $upper_limit; $i++)
385 $this->categories->addCategory($i);
401 $next_id = $ilDB->nextId(
'svy_phrase');
402 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_phrase (phrase_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
403 array(
'integer',
'text',
'text',
'integer',
'integer'),
404 array($next_id,
$title, 1, $ilUser->getId(), time())
406 $phrase_id = $next_id;
409 foreach ($phrases as $category)
411 $next_id = $ilDB->nextId(
'svy_category');
412 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_category (category_id, title, defaultvalue, owner_fi, tstamp) VALUES (%s, %s, %s, %s, %s)",
413 array(
'integer',
'text',
'text',
'integer',
'integer'),
414 array($next_id, $category, 1, $ilUser->getId(), time())
416 $category_id = $next_id;
417 $next_id = $ilDB->nextId(
'svy_phrase_cat');
418 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_phrase_cat (phrase_category_id, phrase_fi, category_fi, sequence) VALUES (%s, %s, %s, %s)",
419 array(
'integer',
'integer',
'integer',
'integer'),
420 array($next_id, $phrase_id, $category_id, $counter)
434 return "SurveySingleChoiceQuestion";
456 $entered_value = $post_data[$this->
getId() .
"_value"];
458 if (strlen($entered_value))
460 array_push(
$data, array(
"value" => $entered_value));
476 $entered_value = $post_data[$this->
getId() .
"_value"];
480 if (strlen($entered_value) == 0)
return $this->lng->txt(
"question_not_checked");
494 $category = rand(0, $this->categories->getCategoryCount()-1);
495 $next_id = $ilDB->nextId(
'svy_answer');
496 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
497 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
498 array($next_id, $this->
getId(), $active_id, $category, NULL, time())
506 $entered_value = $post_data[$this->
getId() .
"_value"];
507 if (strlen($entered_value) == 0)
return;
508 $next_id = $ilDB->nextId(
'svy_answer');
509 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
510 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
511 array($next_id, $this->
getId(), $active_id, (strlen($entered_value)) ? $entered_value : NULL, NULL, time())
519 $question_id = $this->
getId();
521 $result_array = array();
524 $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",
525 array(
'integer',
'integer'),
536 $result_array[
"USERS_ANSWERED"] =
$result->numRows();
537 $result_array[
"USERS_SKIPPED"] = $nr_of_users -
$result->numRows();
544 $result_array[
"MODE"] = $prefix . $this->categories->getCategory(key(
$cumulated));
545 $result_array[
"MODE_VALUE"] = key(
$cumulated)+1;
547 for (
$key = 0;
$key < $this->categories->getCategoryCount();
$key++)
554 $result_array[
"variables"][
$key] = array(
"title" => $this->categories->getCategory(
$key),
"selected" => (int)
$cumulated[
$key],
"percentage" => $percentage);
562 for ($i = 0; $i <
$key; $i++)
564 array_push($median, $value+1);
571 $median_value = 0.5 * ($median[(
$total/2)-1] + $median[(
$total/2)]);
572 if (round($median_value) != $median_value)
574 $median_value = $median_value .
"<br />" .
"(" . $this->lng->txt(
"median_between") .
" " . (floor($median_value)) .
"-" . $this->categories->getCategory((
int)floor($median_value)-1) .
" " . $this->lng->txt(
"and") .
" " . (ceil($median_value)) .
"-" . $this->categories->getCategory((
int)ceil($median_value)-1) .
")";
579 $median_value = $median[((
$total+1)/2)-1];
586 $result_array[
"ARITHMETIC_MEAN"] =
"";
587 $result_array[
"MEDIAN"] = $median_value;
588 $result_array[
"QUESTION_TYPE"] =
"SurveySingleChoiceQuestion";
589 return $result_array;
603 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
604 $worksheet =& $workbook->addWorksheet();
612 $worksheet->write(3, 1, $eval_data[
"USERS_ANSWERED"]);
614 $worksheet->write(4, 1, $eval_data[
"USERS_SKIPPED"]);
617 preg_match(
"/(.*?)\s+-\s+(.*)/", $eval_data[
"MODE"], $matches);
632 foreach ($eval_data[
"variables"] as
$key => $value)
635 $worksheet->write($rowcounter, 2,
$key+1);
650 if (count($resultset[
"answers"][$this->
getId()]))
652 foreach ($resultset[
"answers"][$this->
getId()] as
$key => $answer)
654 array_push($a_array, $answer[
"value"]+1);
659 array_push($a_array, $this->lng->txt(
"skipped"));
676 $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",
677 array(
'integer',
'integer'),
682 $category = $this->categories->getCategory(
$row[
"value"]);
683 $answers[
$row[
"active_fi"]] = $row[
"value"] + 1 .
" - " . $category;
701 $categorytext .= $material[
"text"];
703 $this->categories->addCategory($categorytext);
726 return array(
"<",
"<=",
"=",
"<>",
">=",
">");
739 include_once
"./classes/class.ilTemplate.php";
740 $template =
new ilTemplate(
"tpl.il_svy_svy_precondition_select_value_combobox.html", TRUE, TRUE,
"Modules/Survey");
741 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
743 $template->setCurrentBlock(
"option_v");
744 $template->setVariable(
"OPTION_VALUE", $i);
745 $template->setVariable(
"OPTION_TEXT", ($i+1) .
" - " . $this->categories->getCategory($i));
748 $template->setVariable(
"OPTION_CHECKED",
" selected=\"selected\"");
750 $template->parseCurrentBlock();
752 $template->setVariable(
"SELECT_VALUE", $lng->txt(
"step") .
" 3: " . $lng->txt(
"select_value"));
753 return $template->get();
765 return ($value + 1) .
" - " . $this->categories->getCategory($value);
778 if (count($this->cumulated) == 0)
780 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
785 foreach ($this->cumulated[
"variables"] as
$key => $value)
787 foreach ($value as $key2 => $value2)
789 $this->cumulated[
"variables"][
$key][$key2] = utf8_decode($value2);
792 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyChart.php";
793 $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[
"variables"]);