38 $this->lng = $DIC->language();
39 $this->db = $DIC->database();
40 $this->question = $a_question;
41 $this->finished_ids = $a_finished_ids;
62 method_exists($this->question,
"getCategories")
63 ? $this->question->getCategories()
79 $num_users_answered =
sizeof($a_answers);
86 $selections = array();
87 foreach ($a_answers as $active_id => $answers) {
89 if (
sizeof($answers) > 1) {
92 foreach ($answers as $answer) {
95 $answer[
"value"] !=
"") {
96 $scale = $a_categories->getCategoryForScale($answer[
"value"] + 1);
98 $answer[
"value"] = $scale->scale;
109 if ($answer[
"value"] !=
"") {
110 $selections[$answer[
"value"]]++;
115 $total = array_sum($selections);
119 $mode_nr = max($selections);
120 $tmp_mode = $selections;
121 asort($tmp_mode, SORT_NUMERIC);
122 $mode = array_keys($tmp_mode, $mode_nr);
123 $a_results->
setMode($mode, $mode_nr);
127 ksort($selections, SORT_NUMERIC);
129 foreach ($selections as $value => $count) {
130 for (
$i = 0;
$i < $count;
$i++) {
135 $lower = $median[(
$total / 2) - 1];
136 $upper = $median[(
$total / 2)];
137 $median_value = 0.5 * ($lower + $upper);
139 round($median_value) != $median_value) {
141 $median_value = array($lower, $upper);
144 $median_value = $median[((
$total + 1) / 2) - 1];
152 for (
$c = 0;
$c < $a_categories->getCategoryCount();
$c++) {
153 $cat = $a_categories->getCategory(
$c);
154 $scale = $cat->scale;
160 ? $selections[$scale] /
$total 170 $parsed_results = array();
172 if (is_array($a_qres)) {
173 foreach ($a_qres as $row_idx => $row_results) {
174 $row_title = $row_results[0];
175 $user_results = $row_results[1]->getUserResults($a_user_id);
177 foreach ($user_results as $item) {
179 $tmp = $row_title .
": ";
180 if ($item[0] !==
"") {
183 if ($item[1] && $item[0]) {
184 $tmp .=
", \"" . nl2br($item[1]) .
"\"";
185 } elseif ($item[1]) {
186 $tmp .=
"\"" . nl2br($item[1]) .
"\"";
188 $parsed_results[$row_idx .
"-" . $item[2]] = $tmp;
193 $user_results = $a_qres->getUserResults($a_user_id);
195 foreach ($user_results as $item) {
197 if ($item[0] !==
"") {
200 if ($item[1] && $item[0]) {
201 $tmp .=
", \"" . nl2br($item[1]) .
"\"";
202 } elseif ($item[1]) {
203 $tmp =
"\"" . nl2br($item[1]) .
"\"";
205 $parsed_results[$item[2]] = $tmp;
210 return $parsed_results;
226 public function getGrid($a_results, $a_abs =
true, $a_perc =
true)
230 if ((
bool) $a_abs && (
bool) $a_perc) {
232 $lng->txt(
"category_nr_selected"),
233 $lng->txt(
"svy_fraction_of_selections")
235 } elseif ((
bool) $a_abs) {
237 $lng->txt(
"category_nr_selected")
241 $lng->txt(
"svy_fraction_of_selections")
250 $vars = $a_results->getVariables();
252 foreach ($vars as $var) {
254 ? sprintf(
"%.2f", $var->perc * 100) .
"%" 257 if ((
bool) $a_abs && (
bool) $a_perc) {
258 $res[
"rows"][] = array(
263 } elseif ((
bool) $a_abs) {
264 $res[
"rows"][] = array(
269 $res[
"rows"][] = array(
288 return $a_results->getMappedTextAnswers();
295 "#edc240",
"#afd8f8",
"#cb4b4b",
"#4da74d",
"#9440ed",
297 "#1CE6FF",
"#FF34FF",
"#FF4A46",
"#008941",
"#006FA6",
"#A30059",
298 "#FFDBE5",
"#7A4900",
"#0000A6",
"#63FFAC",
"#B79762",
"#004D43",
"#8FB0FF",
"#997D87",
299 "#5A0007",
"#809693",
"#FEFFE6",
"#1B4400",
"#4FC601",
"#3B5DFF",
"#4A3B53",
"#FF2F80",
300 "#61615A",
"#BA0900",
"#6B7900",
"#00C2A0",
"#FFAA92",
"#FF90C9",
"#B903AA",
"#D16100",
301 "#DDEFFF",
"#000035",
"#7B4F4B",
"#A1C299",
"#300018",
"#0AA6D8",
"#013349",
"#00846F",
302 "#372101",
"#FFB500",
"#C2FFED",
"#A079BF",
"#CC0744",
"#C0B9B2",
"#C2FF99",
"#001E09",
303 "#00489C",
"#6F0062",
"#0CBD66",
"#EEC3FF",
"#456D75",
"#B77B68",
"#7A87A1",
"#788D66",
304 "#885578",
"#FAD09F",
"#FF8A9A",
"#D157A0",
"#BEC459",
"#456648",
"#0086ED",
"#886F4C",
305 "#34362D",
"#B4A8BD",
"#00A6AA",
"#452C2C",
"#636375",
"#A3C8C9",
"#FF913F",
"#938A81",
306 "#575329",
"#00FECF",
"#B05B6F",
"#8CD0FF",
"#3B9700",
"#04F757",
"#C8A1A1",
"#1E6E00",
307 "#7900D7",
"#A77500",
"#6367A9",
"#A05837",
"#6B002C",
"#772600",
"#D790FF",
"#9B9700",
308 "#549E79",
"#FFF69F",
"#201625",
"#72418F",
"#BC23FF",
"#99ADC0",
"#3A2465",
"#922329",
309 "#5B4534",
"#FDE8DC",
"#404E55",
"#0089A3",
"#CB7E98",
"#A4E804",
"#324E72",
"#6A3A4C" 322 $chart->setYAxisToInteger(
true);
325 $chart->setColors($colors);
328 $chart->setsize($this->chart_width, $this->chart_height);
330 $vars = $a_results->getVariables();
332 $legend = $labels = array();
333 foreach ($vars as $idx => $var) {
335 $data->setBarOptions(0.5,
"center");
337 $chart->addData(
$data);
345 $data->setLabel($var->cat->title);
347 $data->addPoint($idx, $var->abs);
350 $chart->setTicks($labels,
false,
true);
383 $set =
$ilDB->query(
"SELECT survey_fi" .
384 " FROM svy_svy_qst" .
385 " WHERE question_fi = " .
$ilDB->quote($this->question->getId(),
"integer"));
386 $row =
$ilDB->fetchAssoc($set);
387 return $row[
"survey_fi"];
400 if (is_array($this->finished_ids)) {
404 $set =
$ilDB->query(
"SELECT finished_id FROM svy_finished" .
405 " WHERE survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer"));
406 return $set->numRows();
415 $sql =
"SELECT svy_answer.* FROM svy_answer" .
416 " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)" .
417 " WHERE svy_answer.question_fi = " .
$ilDB->quote($this->question->getId(),
"integer") .
418 " AND svy_finished.survey_fi = " .
$ilDB->quote($this->getSurveyId(),
"integer");
419 if (is_array($this->finished_ids)) {
420 $sql .=
" AND " .
$ilDB->in(
"svy_finished.finished_id", $this->finished_ids,
"",
"integer");
422 $set =
$ilDB->query($sql);
423 while ($row =
$ilDB->fetchAssoc($set)) {
424 $res[(int) $row[
"rowvalue"]][(
int) $row[
"active_fi"]][] = array(
425 "value" => $row[
"value"],
426 "text" => $row[
"textanswer"]
454 $res[] = (int) $a_results->getUsersAnswered();
455 $res[] = (int) $a_results->getUsersSkipped();
458 $res[] = is_array($a_results->getModeValue())
459 ? implode(
", ", $a_results->getModeValue())
460 : $a_results->getModeValue();
462 $res[] = $a_results->getModeValueAsText();
463 $res[] = (int) $a_results->getModeNrOfSelections();
466 $res[] = $a_results->getMedianAsText();
468 $res[] = $a_results->getMean();
487 $lng->txt(
"category_nr_selected"),
488 $lng->txt(
"svy_fraction_of_selections")
493 $vars = $a_results->getVariables();
495 foreach ($vars as $var) {
496 $res[
"rows"][] = array(
501 ? 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.