35         array $a_finished_ids = []
    39         $this->
lng = $DIC->language();
    40         $this->db = $DIC->database();
    41         $this->question = $a_question;
    42         $this->finished_ids = $a_finished_ids;
    62             (array) ($answers[0] ?? []),
    63             method_exists($this->question, 
"getCategories")
    64                 ? $this->question->getCategories()
    81         $sql = 
"SELECT svy_answer.* FROM svy_answer" .
    82             " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)" .
    83             " WHERE svy_answer.question_fi = " . 
$ilDB->quote($this->question->getId(), 
"integer") .
    84             " AND svy_finished.survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer");
    85         if (count($this->finished_ids) > 0) {
    86             $sql .= 
" AND " . 
$ilDB->in(
"svy_finished.finished_id", $this->finished_ids, 
"", 
"integer");
    88         $set = 
$ilDB->query($sql);
    89         $cnt_answer_records = [];
    90         while ($row = 
$ilDB->fetchAssoc($set)) {
    91             $key = (
int) $row[
"active_fi"];
    92             $cnt_answer_records[$key] = ($cnt_answer_records[$key] ?? 0) + 1;
    94                 $res[$key] = (
$res[$key] ?? 0) + $row[
"value"] + 1;
   100         foreach (
$res as $active_id => $sum_score) {
   102                 $res[$active_id] = null;
   129         $num_users_answered = count($a_answers);
   136         $selections = array();
   137         foreach ($a_answers as $active_id => $answers) {
   139             if (count($answers) > 1) {
   142             foreach ($answers as $answer) {
   145                     $answer[
"value"] != 
"") {
   146                     $scale = $a_categories->getCategoryForScale($answer[
"value"] + 1);
   148                         $answer[
"value"] = $scale->scale;
   153                     (
float) $answer[
"value"],
   154                     (
string) $answer[
"text"],
   159                 if ($answer[
"value"] != 
"") {
   160                     if (!isset($selections[(
string) $answer[
"value"]])) {
   161                         $selections[(string) $answer[
"value"]] = 0;
   163                     $selections[(string) $answer[
"value"]]++;
   168         $total = array_sum($selections);
   172             $mode_nr = max($selections);
   173             $tmp_mode = $selections;
   174             asort($tmp_mode, SORT_NUMERIC);
   175             $mode = array_keys($tmp_mode, $mode_nr);
   176             $a_results->
setMode($mode, $mode_nr);
   180                 ksort($selections, SORT_NUMERIC);
   182                 foreach ($selections as $value => $count) {
   183                     for ($i = 0; $i < $count; $i++) {
   187                 if ($total % 2 === 0) {
   188                     $lower = $median[($total / 2) - 1];
   189                     $upper = $median[($total / 2)];
   190                     $median_value = 0.5 * ($lower + $upper);
   192                         round($median_value) != $median_value) {
   194                         $median_value = array($lower, $upper);
   197                     $median_value = $median[(($total + 1) / 2) - 1];
   205             for (
$c = 0; 
$c < $a_categories->getCategoryCount(); 
$c++) {
   206                 $cat = $a_categories->getCategory(
$c);
   207                 $scale = $cat->scale;
   210                 if ($total && isset($selections[$scale])) {
   211                     $perc = $selections[$scale] / $total;
   215                     $selections[$scale] ?? null,
   228         $parsed_results = array();
   230         if (is_array($a_qres)) {
   231             foreach ($a_qres as $row_idx => $row_results) {
   232                 $row_title = $row_results[0];
   233                 $user_results = $row_results[1]->getUserResults($a_user_id);
   235                     foreach ($user_results as $item) {
   237                         $tmp = $row_title . 
": ";
   238                         if ($item[0] !== 
"") {
   241                         if ($item[1] && $item[0]) {
   242                             $tmp .= 
", \"" . nl2br($item[1]) . 
"\"";
   243                         } elseif ($item[1]) {
   244                             $tmp .= 
"\"" . nl2br($item[1]) . 
"\"";
   246                         $parsed_results[$row_idx . 
"-" . $item[2]] = $tmp;
   251             $user_results = $a_qres->getUserResults($a_user_id);
   253                 foreach ($user_results as $item) {
   255                     if ($item[0] !== 
"") {
   258                     if ($item[1] && $item[0]) {
   259                         $tmp .= 
", \"" . nl2br($item[1]) . 
"\"";
   260                     } elseif ($item[1]) {
   261                         $tmp = 
"\"" . nl2br($item[1]) . 
"\"";
   263                     $parsed_results[(
int) $item[2]] = $tmp;
   268         return $parsed_results;
   287         if ($a_abs && $a_perc) {
   289                 $lng->
txt(
"category_nr_selected"),
   290                 $lng->
txt(
"svy_fraction_of_selections")
   294                 $lng->
txt(
"category_nr_selected")
   298                 $lng->
txt(
"svy_fraction_of_selections")
   307         $vars = $a_results->getVariables();
   309             foreach ($vars as $var) {
   311                     ? sprintf(
"%.2f", $var->perc * 100) . 
"%"   314                 if ($a_abs && $a_perc) {
   315                     $res[
"rows"][] = array(
   321                     $res[
"rows"][] = array(
   326                     $res[
"rows"][] = array(
   344         return $a_results->getMappedTextAnswers();
   351             "#edc240", 
"#afd8f8", 
"#cb4b4b", 
"#4da74d", 
"#9440ed",
   353             "#1CE6FF", 
"#FF34FF", 
"#FF4A46", 
"#008941", 
"#006FA6", 
"#A30059",
   354             "#FFDBE5", 
"#7A4900", 
"#0000A6", 
"#63FFAC", 
"#B79762", 
"#004D43", 
"#8FB0FF", 
"#997D87",
   355             "#5A0007", 
"#809693", 
"#FEFFE6", 
"#1B4400", 
"#4FC601", 
"#3B5DFF", 
"#4A3B53", 
"#FF2F80",
   356             "#61615A", 
"#BA0900", 
"#6B7900", 
"#00C2A0", 
"#FFAA92", 
"#FF90C9", 
"#B903AA", 
"#D16100",
   357             "#DDEFFF", 
"#000035", 
"#7B4F4B", 
"#A1C299", 
"#300018", 
"#0AA6D8", 
"#013349", 
"#00846F",
   358             "#372101", 
"#FFB500", 
"#C2FFED", 
"#A079BF", 
"#CC0744", 
"#C0B9B2", 
"#C2FF99", 
"#001E09",
   359             "#00489C", 
"#6F0062", 
"#0CBD66", 
"#EEC3FF", 
"#456D75", 
"#B77B68", 
"#7A87A1", 
"#788D66",
   360             "#885578", 
"#FAD09F", 
"#FF8A9A", 
"#D157A0", 
"#BEC459", 
"#456648", 
"#0086ED", 
"#886F4C",
   361             "#34362D", 
"#B4A8BD", 
"#00A6AA", 
"#452C2C", 
"#636375", 
"#A3C8C9", 
"#FF913F", 
"#938A81",
   362             "#575329", 
"#00FECF", 
"#B05B6F", 
"#8CD0FF", 
"#3B9700", 
"#04F757", 
"#C8A1A1", 
"#1E6E00",
   363             "#7900D7", 
"#A77500", 
"#6367A9", 
"#A05837", 
"#6B002C", 
"#772600", 
"#D790FF", 
"#9B9700",
   364             "#549E79", 
"#FFF69F", 
"#201625", 
"#72418F", 
"#BC23FF", 
"#99ADC0", 
"#3A2465", 
"#922329",
   365             "#5B4534", 
"#FDE8DC", 
"#404E55", 
"#0089A3", 
"#CB7E98", 
"#A4E804", 
"#324E72", 
"#6A3A4C"   375         $chart->setYAxisToInteger(
true);
   378         $chart->setColors($colors);
   381         $chart->setSize((
string) $this->chart_width, (
string) $this->chart_height);
   383         $vars = $a_results->getVariables();
   385         $legend = $labels = array();
   386         foreach ($vars as $idx => $var) {
   388             $data->setBarOptions(0.5, 
"center");
   390             $chart->addData(
$data);
   398             $data->setLabel($var->cat->title);
   400             $data->addPoint($idx, $var->abs);
   403         $chart->setTicks($labels, 
false, 
true);
   434         $set = 
$ilDB->query(
"SELECT survey_fi" .
   435             " FROM svy_svy_qst" .
   436             " WHERE question_fi = " . 
$ilDB->quote($this->question->getId(), 
"integer"));
   437         $row = 
$ilDB->fetchAssoc($set);
   438         return $row[
"survey_fi"];
   449         if (count($this->finished_ids) > 0) {
   450             return count($this->finished_ids);
   453         $set = 
$ilDB->query(
"SELECT finished_id FROM svy_finished" .
   454             " WHERE survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer"));
   455         return $set->numRows();
   464         $sql = 
"SELECT svy_answer.* FROM svy_answer" .
   465             " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)" .
   466             " WHERE svy_answer.question_fi = " . 
$ilDB->quote($this->question->getId(), 
"integer") .
   467             " AND svy_finished.survey_fi = " . 
$ilDB->quote($this->getSurveyId(), 
"integer");
   468         if (count($this->finished_ids) > 0) {
   469             $sql .= 
" AND " . 
$ilDB->in(
"svy_finished.finished_id", $this->finished_ids, 
"", 
"integer");
   471         $set = 
$ilDB->query($sql);
   472         while ($row = 
$ilDB->fetchAssoc($set)) {
   473             $res[(
int) $row[
"rowvalue"]][(
int) $row[
"active_fi"]][] = array(
   474                 "value" => $row[
"value"],
   475                 "text" => $row[
"textanswer"],
   476                 "tstamp" => $row[
"tstamp"]
   496         $question = $a_results->getQuestion();
   504             $res[] = $question->label;
   510         $res[] = (
int) $a_results->getUsersAnswered();
   511         $res[] = (
int) $a_results->getUsersSkipped();
   514         $res[] = is_array($a_results->getModeValue())
   515             ? implode(
", ", $a_results->getModeValue())
   516             : $a_results->getModeValue();
   518         $res[] = $a_results->getModeValueAsText();
   519         $res[] = (
int) $a_results->getModeNrOfSelections();
   522         $res[] = $a_results->getMedianAsText();
   524         $res[] = $a_results->getMean();
   541                 $lng->
txt(
"category_nr_selected"),
   542                 $lng->
txt(
"svy_fraction_of_selections")
   547         $vars = $a_results->getVariables();
   549             foreach ($vars as $var) {
   550                 $res[
"rows"][] = array(
   555                         ? sprintf(
"%.2f", $var->perc * 100) . 
"%"   573         array &$a_title_row2,
 
getExportGrid($a_results)
Get grid data. 
 
getUserSpecificVariableTitles(array &$a_title_row, array &$a_title_row2, bool $a_do_title, bool $a_do_label)
Get title columns for user-specific export. 
 
setUsersAnswered(int $a_value)
 
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
 
static getSurveySkippedValue()
 
__construct(SurveyQuestion $a_question, array $a_finished_ids=[])
 
setUsersSkipped(int $a_value)
 
static _getQuestionTypeName(string $type_tag)
Return the translation for a given question type. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getNrOfParticipants()
Returns the number of participants for a survey. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
exportResults( $a_results, bool $a_do_title, bool $a_do_label)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
parseUserSpecificResults($a_qres, int $a_user_id)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
addVariable(ilSurveyEvaluationResultsVariable $a_variable)
 
addUserSpecificResults(array &$a_row, int $a_user_id, $a_results)
 
setMode( $a_value, int $a_nr_of_selections)
 
parseResults(ilSurveyEvaluationResults $a_results, array $a_answers, SurveyCategories $a_categories=null)
Parse answer data into results instance. 
 
getSkippedValue()
Get caption for skipped value. 
 
isSumScoreValid(int $nr_answer_records)
Is sum score ok (question needs to be fully answered) 
 
addAnswer(ilSurveyEvaluationResultsAnswer $a_answer)
 
getGrid( $a_results, bool $a_abs=true, bool $a_perc=true)
Get grid data. 
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
getSumScores()
Get sum score for this question for all active ids of run. 
 
static getInstanceByType(int $a_type, string $a_id)
 
getTextAnswers($a_results)
Get text answers.