24 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
25 include_once
"./Modules/Survey/classes/inc.SurveyConstants.php";
67 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyCategories.php";
88 return $ilDB->fetchAssoc(
$result);
119 include_once(
"./Services/RTE/classes/class.ilRTE.php");
126 $this->categories->flushCategories();
127 $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",
135 $this->categories->addCategory(
$data[
"title"]);
150 if (strlen($this->title) && strlen($this->author) && strlen($this->questiontext) && $this->categories->getCategoryCount())
170 if ($affectedRows == 1)
172 $affectedRows = $ilDB->manipulateF(
"DELETE FROM " . $this->
getAdditionalTableName() .
" WHERE question_fi = %s",
174 array($this->
getId())
176 $affectedRows = $ilDB->manipulateF(
"INSERT INTO " . $this->
getAdditionalTableName() .
" (question_fi, orientation) VALUES (%s, %s)",
177 array(
'integer',
'text'),
191 $affectedRows = $ilDB->manipulateF(
"DELETE FROM svy_variable WHERE question_fi = %s",
193 array($this->
getId())
196 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
199 $next_id = $ilDB->nextId(
'svy_variable');
200 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_variable (variable_id, category_fi, question_fi, value1, sequence, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
201 array(
'integer',
'integer',
'integer',
'float',
'integer',
'integer'),
202 array($next_id, $category_id, $this->
getId(), ($i + 1), $i, time())
214 function toXML($a_include_header = TRUE, $obligatory_state =
"")
216 include_once(
"./classes/class.ilXmlWriter.php");
219 $this->
insertXML($a_xml_writer, $a_include_header, $obligatory_state);
220 $xml = $a_xml_writer->xmlDumpMem(FALSE);
221 if (!$a_include_header)
223 $pos = strpos($xml,
"?>");
224 $xml = substr($xml, $pos + 2);
237 function insertXML(&$a_xml_writer, $a_include_header = TRUE, $obligatory_state =
"")
240 "id" => $this->
getId(),
242 "type" => $this->getQuestiontype(),
245 $a_xml_writer->xmlStartTag(
"question", $attrs);
247 $a_xml_writer->xmlElement(
"description", NULL, $this->
getDescription());
248 $a_xml_writer->xmlElement(
"author", NULL, $this->
getAuthor());
249 $a_xml_writer->xmlStartTag(
"questiontext");
251 $a_xml_writer->xmlEndTag(
"questiontext");
253 $a_xml_writer->xmlStartTag(
"responses");
255 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
260 $a_xml_writer->xmlStartTag(
"response_multiple", $attrs);
261 $this->
addMaterialTag($a_xml_writer, $this->categories->getCategory($i));
262 $a_xml_writer->xmlEndTag(
"response_multiple");
265 $a_xml_writer->xmlEndTag(
"responses");
267 if (count($this->material))
269 if (preg_match(
"/il_(\d*?)_(\w+)_(\d+)/", $this->material[
"internal_link"], $matches))
272 "label" => $this->material[
"title"]
274 $a_xml_writer->xmlStartTag(
"material", $attrs);
275 $intlink =
"il_" . IL_INST_ID .
"_" . $matches[2] .
"_" . $matches[3];
276 if (strcmp($matches[1],
"") != 0)
278 $intlink = $this->material[
"internal_link"];
280 $a_xml_writer->xmlElement(
"mattext", NULL, $intlink);
281 $a_xml_writer->xmlEndTag(
"material");
285 $a_xml_writer->xmlStartTag(
"metadata");
286 $a_xml_writer->xmlStartTag(
"metadatafield");
287 $a_xml_writer->xmlElement(
"fieldlabel", NULL,
"orientation");
288 $a_xml_writer->xmlElement(
"fieldentry", NULL, $this->
getOrientation());
289 $a_xml_writer->xmlEndTag(
"metadatafield");
290 $a_xml_writer->xmlEndTag(
"metadata");
292 $a_xml_writer->xmlEndTag(
"question");
303 return "SurveyMultipleChoiceQuestion";
325 $entered_value = $post_data[$this->
getId() .
"_value"];
327 if (is_array($entered_value))
329 foreach ($entered_value as $value)
331 array_push(
$data, array(
"value" => $value));
349 $entered_value = $post_data[$this->
getId() .
"_value"];
352 if (!is_array($entered_value))
354 return $this->lng->txt(
"question_mr_not_checked");
368 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
372 $next_id = $ilDB->nextId(
'svy_answer');
373 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
374 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
375 array($next_id, $this->
getId(), $active_id, $i, NULL, time())
385 if (is_array($post_data[$this->
getId() .
"_value"]))
387 foreach ($post_data[$this->
getId() .
"_value"] as $value)
389 $entered_value = $value;
390 if (strlen($entered_value) > 0)
392 $next_id = $ilDB->nextId(
'svy_answer');
393 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
394 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
395 array($next_id, $this->
getId(), $active_id, (strlen($entered_value)) ? $entered_value : NULL, NULL, time())
402 $entered_value = $post_data[$this->
getId() .
"_value"];
403 if (strlen($entered_value) == 0)
return;
404 $next_id = $ilDB->nextId(
'svy_answer');
405 $affectedRows = $ilDB->manipulateF(
"INSERT INTO svy_answer (answer_id, question_fi, active_fi, value, textanswer, tstamp) VALUES (%s, %s, %s, %s, %s, %s)",
406 array(
'integer',
'integer',
'integer',
'float',
'text',
'integer'),
407 array($next_id, $this->
getId(), $active_id, (strlen($entered_value)) ? $entered_value : NULL, NULL, time())
416 $question_id = $this->
getId();
418 $result_array = array();
421 $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",
422 array(
'integer',
'integer'),
435 $mcmr_result = $ilDB->queryF(
"SELECT svy_answer.answer_id, svy_answer.question_fi, svy_answer.active_fi 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",
436 array(
'integer',
'integer'),
440 while (
$row = $ilDB->fetchAssoc($mcmr_result))
442 $found[
$row[
"question_fi"] .
"_" .
$row[
"active_fi"]] = 1;
444 $result_array[
"USERS_ANSWERED"] = count($found);
445 $result_array[
"USERS_SKIPPED"] = $nr_of_users - count($found);
446 $numrows = count($found);
448 $result_array[
"MEDIAN"] =
"";
449 $result_array[
"ARITHMETIC_MEAN"] =
"";
455 $result_array[
"MODE"] = $prefix . $this->categories->getCategory(key(
$cumulated));
456 $result_array[
"MODE_VALUE"] = key(
$cumulated)+1;
458 $result_array[
"QUESTION_TYPE"] =
"SurveyMultipleChoiceQuestion";
460 for (
$key = 0;
$key < $this->categories->getCategoryCount();
$key++)
464 for (
$key = 0;
$key < $this->categories->getCategoryCount();
$key++)
471 $percentage = ($result_array[
"USERS_ANSWERED"] > 0) ? (
float)((int)
$cumulated[
$key]/$result_array[
"USERS_ANSWERED"]) : 0;
474 $result_array[
"variables"][
$key] = array(
"title" => $this->categories->getCategory(
$key),
"selected" => (int)
$cumulated[
$key],
"percentage" => $percentage);
476 return $result_array;
490 include_once (
"./Services/Excel/classes/class.ilExcelUtils.php");
491 $worksheet =& $workbook->addWorksheet();
499 $worksheet->write(3, 1, $eval_data[
"USERS_ANSWERED"]);
501 $worksheet->write(4, 1, $eval_data[
"USERS_SKIPPED"]);
515 foreach ($eval_data[
"variables"] as
$key => $value)
518 $worksheet->write($rowcounter, 2,
$key+1);
533 for ($index = 0; $index < $this->categories->getCategoryCount(); $index++)
535 $category = $this->categories->getCategory($index);
536 array_push($a_array, ($index+1) .
" - $category");
549 if (count($resultset[
"answers"][$this->
getId()]))
551 array_push($a_array,
"");
552 for ($index = 0; $index < $this->categories->getCategoryCount(); $index++)
554 $category = $this->categories->getCategory($index);
556 foreach ($resultset[
"answers"][$this->
getId()] as $answerdata)
558 if (strcmp($index, $answerdata[
"value"]) == 0)
565 array_push($a_array,
"1");
569 array_push($a_array,
"0");
575 array_push($a_array, $this->lng->txt(
"skipped"));
576 for ($index = 0; $index < $this->categories->getCategoryCount(); $index++)
578 array_push($a_array,
"");
596 $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",
597 array(
'integer',
'integer'),
602 $category = $this->categories->getCategory(
$row[
"value"]);
603 if (!is_array($answers[
$row[
"active_fi"]]))
605 $answers[$row[
"active_fi"]] = array();
607 array_push($answers[$row[
"active_fi"]], $row[
"value"] + 1 .
" - " . $category);
622 foreach ($a_meta as
$key => $value)
624 switch ($value[
"label"])
646 $categorytext .= $material[
"text"];
648 $this->categories->addCategory($categorytext);
671 return array(
"=",
"<>");
684 include_once
"./classes/class.ilTemplate.php";
685 $template =
new ilTemplate(
"tpl.il_svy_svy_precondition_select_value_combobox.html", TRUE, TRUE,
"Modules/Survey");
686 for ($i = 0; $i < $this->categories->getCategoryCount(); $i++)
688 $template->setCurrentBlock(
"option_v");
689 $template->setVariable(
"OPTION_VALUE", $i);
690 $template->setVariable(
"OPTION_TEXT", ($i+1) .
" - " . $this->categories->getCategory($i));
693 $template->setVariable(
"OPTION_CHECKED",
" selected=\"selected\"");
695 $template->parseCurrentBlock();
697 $template->setVariable(
"SELECT_VALUE", $lng->txt(
"step") .
" 3: " . $lng->txt(
"select_value"));
698 return $template->get();
710 return ($value + 1) .
" - " . $this->categories->getCategory($value);
724 if (count($this->cumulated) == 0)
726 include_once
"./Modules/Survey/classes/class.ilObjSurvey.php";
731 foreach ($this->cumulated[
"variables"] as
$key => $value)
733 foreach ($value as $key2 => $value2)
735 $this->cumulated[
"variables"][
$key][$key2] = utf8_decode($value2);
738 include_once
"./Modules/SurveyQuestionPool/classes/class.SurveyChart.php";
739 $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"]);