4 include_once
"Modules/Survey/classes/class.ilSurveyEvaluationResults.php";
40 $this->lng = $DIC->language();
41 $this->db = $DIC->database();
42 $this->question = $a_question;
43 $this->finished_ids = $a_finished_ids;
64 method_exists($this->question,
"getCategories")
65 ? $this->question->getCategories()
81 $num_users_answered =
sizeof($a_answers);
88 $selections = array();
89 foreach ($a_answers as $active_id => $answers) {
91 if (
sizeof($answers) > 1) {
94 foreach ($answers as $answer) {
97 $answer[
"value"] !=
"") {
98 $scale = $a_categories->getCategoryForScale($answer[
"value"] + 1);
100 $answer[
"value"] = $scale->scale;
111 if ($answer[
"value"] !=
"") {
112 $selections[$answer[
"value"]]++;
117 $total = array_sum($selections);
121 $mode_nr = max($selections);
122 $tmp_mode = $selections;
123 asort($tmp_mode, SORT_NUMERIC);
124 $mode = array_keys($tmp_mode, $mode_nr);
125 $a_results->
setMode($mode, $mode_nr);
129 ksort($selections, SORT_NUMERIC);
131 foreach ($selections as $value => $count) {
132 for (
$i = 0;
$i < $count;
$i++) {
137 $lower = $median[(
$total / 2) - 1];
138 $upper = $median[(
$total / 2)];
139 $median_value = 0.5 * ($lower + $upper);
141 round($median_value) != $median_value) {
143 $median_value = array($lower, $upper);
146 $median_value = $median[((
$total + 1) / 2) - 1];
154 for (
$c = 0;
$c < $a_categories->getCategoryCount();
$c++) {
155 $cat = $a_categories->getCategory(
$c);
156 $scale = $cat->scale;
162 ? $selections[$scale] /
$total 172 $parsed_results = array();
174 if (is_array($a_qres)) {
175 foreach ($a_qres as $row_idx => $row_results) {
176 $row_title = $row_results[0];
177 $user_results = $row_results[1]->getUserResults($a_user_id);
179 foreach ($user_results as $item) {
181 $tmp = $row_title .
": ";
182 if ($item[0] !==
"") {
185 if ($item[1] && $item[0]) {
186 $tmp .=
", \"" . nl2br($item[1]) .
"\"";
187 } elseif ($item[1]) {
188 $tmp .=
"\"" . nl2br($item[1]) .
"\"";
190 $parsed_results[$row_idx .
"-" . $item[2]] = $tmp;
195 $user_results = $a_qres->getUserResults($a_user_id);
197 foreach ($user_results as $item) {
199 if ($item[0] !==
"") {
202 if ($item[1] && $item[0]) {
203 $tmp .=
", \"" . nl2br($item[1]) .
"\"";
204 } elseif ($item[1]) {
205 $tmp =
"\"" . nl2br($item[1]) .
"\"";
207 $parsed_results[$item[2]] = $tmp;
212 return $parsed_results;
228 public function getGrid($a_results, $a_abs =
true, $a_perc =
true)
232 if ((
bool) $a_abs && (
bool) $a_perc) {
234 $lng->txt(
"category_nr_selected"),
235 $lng->txt(
"svy_fraction_of_selections")
237 } elseif ((
bool) $a_abs) {
239 $lng->txt(
"category_nr_selected")
243 $lng->txt(
"svy_fraction_of_selections")
252 $vars = $a_results->getVariables();
254 foreach ($vars as $var) {
256 ? sprintf(
"%.2f", $var->perc * 100) .
"%" 259 if ((
bool) $a_abs && (
bool) $a_perc) {
260 $res[
"rows"][] = array(
265 } elseif ((
bool) $a_abs) {
266 $res[
"rows"][] = array(
271 $res[
"rows"][] = array(
290 return $a_results->getMappedTextAnswers();
297 "#edc240",
"#afd8f8",
"#cb4b4b",
"#4da74d",
"#9440ed",
299 "#1CE6FF",
"#FF34FF",
"#FF4A46",
"#008941",
"#006FA6",
"#A30059",
300 "#FFDBE5",
"#7A4900",
"#0000A6",
"#63FFAC",
"#B79762",
"#004D43",
"#8FB0FF",
"#997D87",
301 "#5A0007",
"#809693",
"#FEFFE6",
"#1B4400",
"#4FC601",
"#3B5DFF",
"#4A3B53",
"#FF2F80",
302 "#61615A",
"#BA0900",
"#6B7900",
"#00C2A0",
"#FFAA92",
"#FF90C9",
"#B903AA",
"#D16100",
303 "#DDEFFF",
"#000035",
"#7B4F4B",
"#A1C299",
"#300018",
"#0AA6D8",
"#013349",
"#00846F",
304 "#372101",
"#FFB500",
"#C2FFED",
"#A079BF",
"#CC0744",
"#C0B9B2",
"#C2FF99",
"#001E09",
305 "#00489C",
"#6F0062",
"#0CBD66",
"#EEC3FF",
"#456D75",
"#B77B68",
"#7A87A1",
"#788D66",
306 "#885578",
"#FAD09F",
"#FF8A9A",
"#D157A0",
"#BEC459",
"#456648",
"#0086ED",
"#886F4C",
307 "#34362D",
"#B4A8BD",
"#00A6AA",
"#452C2C",
"#636375",
"#A3C8C9",
"#FF913F",
"#938A81",
308 "#575329",
"#00FECF",
"#B05B6F",
"#8CD0FF",
"#3B9700",
"#04F757",
"#C8A1A1",
"#1E6E00",
309 "#7900D7",
"#A77500",
"#6367A9",
"#A05837",
"#6B002C",
"#772600",
"#D790FF",
"#9B9700",
310 "#549E79",
"#FFF69F",
"#201625",
"#72418F",
"#BC23FF",
"#99ADC0",
"#3A2465",
"#922329",
311 "#5B4534",
"#FDE8DC",
"#404E55",
"#0089A3",
"#CB7E98",
"#A4E804",
"#324E72",
"#6A3A4C" 323 include_once
"Services/Chart/classes/class.ilChart.php";
325 $chart->setYAxisToInteger(
true);
328 $chart->setColors($colors);
331 $chart->setsize($this->chart_width, $this->chart_height);
333 $vars = $a_results->getVariables();
336 foreach ($vars as $idx => $var) {
338 $data->setBarOptions(0.5,
"center");
340 $chart->addData(
$data);
348 $data->setLabel($var->cat->title);
350 $data->addPoint($idx, $var->abs);
353 $chart->setTicks($labels,
false,
true);
373 include_once
"Modules/Survey/classes/class.ilObjSurvey.php";
387 $set =
$ilDB->query(
"SELECT survey_fi" .
388 " FROM svy_svy_qst" .
389 " WHERE question_fi = " .
$ilDB->quote($this->question->getId(),
"integer"));
391 return $row[
"survey_fi"];
404 if (is_array($this->finished_ids)) {
408 $set =
$ilDB->query(
"SELECT finished_id FROM svy_finished" .
409 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer"));
410 return $set->numRows();
419 $sql =
"SELECT svy_answer.* FROM svy_answer" .
420 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)" .
421 " WHERE svy_answer.question_fi = " .
$ilDB->quote($this->question->getId(),
"integer") .
422 " AND svy_finished.survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer");
423 if (is_array($this->finished_ids)) {
424 $sql .=
" AND " .
$ilDB->in(
"svy_finished.finished_id", $this->finished_ids,
"",
"integer");
426 $set =
$ilDB->query($sql);
428 $res[(int)
$row[
"rowvalue"]][(
int)
$row[
"active_fi"]][] = array(
429 "value" =>
$row[
"value"],
430 "text" =>
$row[
"textanswer"]
458 $res[] = (int) $a_results->getUsersAnswered();
459 $res[] = (int) $a_results->getUsersSkipped();
462 $res[] = is_array($a_results->getModeValue())
463 ? implode(
", ", $a_results->getModeValue())
464 : $a_results->getModeValue();
466 $res[] = $a_results->getModeValueAsText();
467 $res[] = (int) $a_results->getModeNrOfSelections();
470 $res[] = $a_results->getMedianAsText();
472 $res[] = $a_results->getMean();
491 $lng->txt(
"category_nr_selected"),
492 $lng->txt(
"svy_fraction_of_selections")
497 $vars = $a_results->getVariables();
499 foreach ($vars as $var) {
500 $res[
"rows"][] = array(
505 ? sprintf(
"%.2f", $var->perc * 100) .
"%" parseUserSpecificResults($a_qres, $a_user_id)
getExportGrid($a_results)
Get grid data.
static getSurveySkippedValue()
exportResults($a_results, $a_do_title, $a_do_label)
Survey question evaluation.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
getUserSpecificVariableTitles(array &$a_title_row, array &$a_title_row2, $a_do_title, $a_do_label)
Get title columns for user-specific export.
getNrOfParticipants()
Returns the number of participants for a survey.
Survey evaluation answers.
getGrid($a_results, $a_abs=true, $a_perc=true)
Get grid data.
foreach($_POST as $key=> $value) $res
Basic class for all survey question types.
addVariable(ilSurveyEvaluationResultsVariable $a_variable)
setMode($a_value, $a_nr_of_selections)
setUsersAnswered($a_value)
parseResults(ilSurveyEvaluationResults $a_results, array $a_answers, SurveyCategories $a_categories=null)
Parse answer data into results instance.
__construct(SurveyQuestion $a_question, array $a_finished_ids=null)
Constructor.
getSkippedValue()
Get caption for skipped value.
addUserSpecificResults(array &$a_row, $a_user_id, $a_results)
addAnswer(ilSurveyEvaluationResultsAnswer $a_answer)
setUsersSkipped($a_value)
static getInstanceByType($a_type, $a_id)
Get type instance.
getChart($a_results)
Get chart.
getTextAnswers($a_results)
Get text answers.