4include_once 
"Modules/Survey/classes/class.ilSurveyEvaluationResults.php";
 
   28                $this->question = $a_question;
 
   29                $this->finished_ids = $a_finished_ids;
 
   50                        method_exists($this->question, 
"getCategories")
 
   51                                ? $this->question->getCategories()
 
   67                $num_users_answered = 
sizeof($a_answers);                       
 
   74                $selections = array();
 
   75                foreach($a_answers as $active_id => $answers)
 
   78                        if(
sizeof($answers) > 1)
 
   82                        foreach($answers as $answer)
 
   86                                        $answer[
"value"] != 
"")
 
   88                                        $scale = $a_categories->getCategoryForScale($answer[
"value"]+1);
 
   91                                                $answer[
"value"] = $scale->scale;
 
  102                                if($answer[
"value"] != 
"")
 
  104                                        $selections[$answer[
"value"]]++;
 
  109                $total = array_sum($selections);
 
  114                        $mode_nr = max($selections);            
 
  115                        $tmp_mode = $selections;
 
  116                        asort($tmp_mode, SORT_NUMERIC);
 
  117                        $mode = array_keys($tmp_mode, $mode_nr);
 
  118                        $a_results->
setMode($mode, $mode_nr);
 
  123                                ksort($selections, SORT_NUMERIC);
 
  125                                foreach($selections as $value => $count)
 
  127                                        for($i = 0; $i < $count; $i++)
 
  134                                        $lower = $median[(
$total/2)-1];
 
  135                                        $upper = $median[(
$total/2)];
 
  136                                        $median_value = 0.5 * ($lower + $upper);
 
  138                                                round($median_value) != $median_value)
 
  141                                                $median_value = array($lower, $upper);
 
  146                                        $median_value = $median[((
$total+1)/2)-1];
 
  155                        for ($c = 0; $c < $a_categories->getCategoryCount(); $c++)
 
  157                                $cat = $a_categories->getCategory($c);
 
  158                                $scale = $cat->scale;
 
  164                                                        ? $selections[$scale]/
$total 
  174                $parsed_results = array();
 
  176                if(is_array($a_qres))
 
  178                        foreach($a_qres as $row_idx => $row_results)                            
 
  180                                $row_title = $row_results[0];
 
  181                                $user_results = $row_results[1]->getUserResults($a_user_id);
 
  184                                        foreach($user_results as $item)
 
  187                                                $tmp = $row_title.
": ";
 
  192                                                if($item[1] && $item[0])
 
  194                                                        $tmp .= 
", \"".nl2br($item[1]).
"\"";
 
  198                                                        $tmp .= 
"\"".nl2br($item[1]).
"\"";
 
  200                                                $parsed_results[$row_idx.
"-".$item[2]] = $tmp;
 
  208                        $user_results = $a_qres->getUserResults($a_user_id);
 
  211                                foreach($user_results as $item)
 
  218                                        if($item[1] && $item[0])
 
  220                                                $tmp .= 
", \"".nl2br($item[1]).
"\"";
 
  224                                                $tmp = 
"\"".nl2br($item[1]).
"\"";
 
  226                                        $parsed_results[$item[2]] = $tmp;
 
  231                return $parsed_results;
 
  247        public function getGrid($a_results, $a_abs = 
true, $a_perc = 
true)
 
  251                if((
bool)$a_abs && (
bool)$a_perc)
 
  254                                $lng->txt(
"category_nr_selected"),
 
  255                                $lng->txt(
"svy_fraction_of_selections")
 
  258                else if((
bool)$a_abs)
 
  261                                $lng->txt(
"category_nr_selected")
 
  267                                $lng->txt(
"svy_fraction_of_selections")
 
  276                $vars = $a_results->getVariables();
 
  279                        foreach($vars as $var)
 
  282                                        ? 
sprintf(
"%.2f", $var->perc*100).
"%" 
  285                                if((
bool)$a_abs && (
bool)$a_perc)
 
  287                                        $res[
"rows"][] = array(
 
  293                                else if((
bool)$a_abs)
 
  295                                        $res[
"rows"][] = array(
 
  302                                        $res[
"rows"][] = array(
 
  321                return $a_results->getMappedTextAnswers();              
 
  328                        "#edc240", 
"#afd8f8", 
"#cb4b4b", 
"#4da74d", 
"#9440ed",
 
  330                        "#1CE6FF", 
"#FF34FF", 
"#FF4A46", 
"#008941", 
"#006FA6", 
"#A30059",
 
  331                        "#FFDBE5", 
"#7A4900", 
"#0000A6", 
"#63FFAC", 
"#B79762", 
"#004D43", 
"#8FB0FF", 
"#997D87",
 
  332                        "#5A0007", 
"#809693", 
"#FEFFE6", 
"#1B4400", 
"#4FC601", 
"#3B5DFF", 
"#4A3B53", 
"#FF2F80",
 
  333                        "#61615A", 
"#BA0900", 
"#6B7900", 
"#00C2A0", 
"#FFAA92", 
"#FF90C9", 
"#B903AA", 
"#D16100",
 
  334                        "#DDEFFF", 
"#000035", 
"#7B4F4B", 
"#A1C299", 
"#300018", 
"#0AA6D8", 
"#013349", 
"#00846F",
 
  335                        "#372101", 
"#FFB500", 
"#C2FFED", 
"#A079BF", 
"#CC0744", 
"#C0B9B2", 
"#C2FF99", 
"#001E09",
 
  336                        "#00489C", 
"#6F0062", 
"#0CBD66", 
"#EEC3FF", 
"#456D75", 
"#B77B68", 
"#7A87A1", 
"#788D66",
 
  337                        "#885578", 
"#FAD09F", 
"#FF8A9A", 
"#D157A0", 
"#BEC459", 
"#456648", 
"#0086ED", 
"#886F4C",
 
  338                        "#34362D", 
"#B4A8BD", 
"#00A6AA", 
"#452C2C", 
"#636375", 
"#A3C8C9", 
"#FF913F", 
"#938A81",
 
  339                        "#575329", 
"#00FECF", 
"#B05B6F", 
"#8CD0FF", 
"#3B9700", 
"#04F757", 
"#C8A1A1", 
"#1E6E00",
 
  340                        "#7900D7", 
"#A77500", 
"#6367A9", 
"#A05837", 
"#6B002C", 
"#772600", 
"#D790FF", 
"#9B9700",
 
  341                        "#549E79", 
"#FFF69F", 
"#201625", 
"#72418F", 
"#BC23FF", 
"#99ADC0", 
"#3A2465", 
"#922329",
 
  342                        "#5B4534", 
"#FDE8DC", 
"#404E55", 
"#0089A3", 
"#CB7E98", 
"#A4E804", 
"#324E72", 
"#6A3A4C" 
  354                include_once 
"Services/Chart/classes/class.ilChart.php";
 
  356                $chart->setYAxisToInteger(
true);
 
  359                $chart->setColors($colors);
 
  362                $chart->setsize($this->chart_width, $this->chart_height);
 
  364                $vars = $a_results->getVariables();
 
  367                foreach($vars as $idx => $var)
 
  370                        $data->setBarOptions(0.5, 
"center");
 
  380                        $data->setLabel($var->cat->title);
 
  382                        $data->addPoint($idx, $var->abs);               
 
  385                $chart->setTicks($labels, 
false, 
true);
 
  405                include_once 
"Modules/Survey/classes/class.ilObjSurvey.php";
 
  419                $set = 
$ilDB->query(
"SELECT survey_fi".
 
  421                        " WHERE question_fi = ".
$ilDB->quote($this->question->getId(), 
"integer"));             
 
  423                return $row[
"survey_fi"];
 
  436                if(is_array($this->finished_ids))
 
  441                $set = 
$ilDB->query(
"SELECT finished_id FROM svy_finished".
 
  442                        " WHERE survey_fi = ".
$ilDB->quote($this->getSurveyId(), 
"integer"));           
 
  443                return $set->numRows();
 
  452                $sql = 
"SELECT svy_answer.* FROM svy_answer".
 
  453                        " JOIN svy_finished ON (svy_finished.finished_id = svy_answer.active_fi)".
 
  454                        " WHERE svy_answer.question_fi = ".$ilDB->quote($this->question->getId(), 
"integer").
 
  455                        " AND svy_finished.survey_fi = ".$ilDB->quote($this->
getSurveyId(), 
"integer");         
 
  456                if(is_array($this->finished_ids))
 
  458                        $sql .= 
" AND ".$ilDB->in(
"svy_finished.finished_id", $this->finished_ids, 
"", 
"integer");
 
  460                $set = 
$ilDB->query($sql);
 
  463                        $res[(int)
$row[
"rowvalue"]][(
int)
$row[
"active_fi"]][] = array(                  
 
  464                                "value" => 
$row[
"value"],                       
 
  465                                "text" => 
$row[
"textanswer"]
 
  495                $res[] = (int)$a_results->getUsersAnswered();
 
  496                $res[] = (int)$a_results->getUsersSkipped();
 
  499                $res[] = is_array($a_results->getModeValue())
 
  500                        ? implode(
", ", $a_results->getModeValue())
 
  501                        : $a_results->getModeValue();
 
  503                $res[] = $a_results->getModeValueAsText();
 
  504                $res[] = (int)$a_results->getModeNrOfSelections();
 
  507                $res[] = $a_results->getMedianAsText();
 
  509                $res[] = $a_results->getMean();
 
  528                                $lng->txt(
"category_nr_selected"),
 
  529                                $lng->txt(
"svy_fraction_of_selections")
 
  534                $vars = $a_results->getVariables();
 
  537                        foreach($vars as $var)
 
  539                                $res[
"rows"][] = array(
 
  544                                                ? 
sprintf(
"%.2f", $var->perc*100).
"%" 
sprintf('%.4f', $callTime)
An exception for terminatinating execution or to throw for unit testing.
Survey question evaluation.
__construct(SurveyQuestion $a_question, array $a_finished_ids=null)
Constructor.
getSkippedValue()
Get caption for skipped value.
parseResults(ilSurveyEvaluationResults $a_results, array $a_answers, SurveyCategories $a_categories=null)
Parse answer data into results instance.
getChart($a_results)
Get chart.
getExportGrid($a_results)
Get grid data.
addUserSpecificResults(array &$a_row, $a_user_id, $a_results)
exportResults($a_results, $a_do_title, $a_do_label)
getUserSpecificVariableTitles(array &$a_title_row, array &$a_title_row2, $a_do_title, $a_do_label)
Get title columns for user-specific export.
getGrid($a_results, $a_abs=true, $a_perc=true)
Get grid data.
getTextAnswers($a_results)
Get text answers.
getNrOfParticipants()
Returns the number of participants for a survey.
parseUserSpecificResults($a_qres, $a_user_id)
Basic class for all survey question types.
static _getQuestionTypeName($type_tag)
Return the translation for a given question type tag.
static getInstanceByType($a_type, $a_id)
Get type instance.
static getSurveySkippedValue()
Survey evaluation answers.
setUsersAnswered($a_value)
setMode($a_value, $a_nr_of_selections)
addVariable(ilSurveyEvaluationResultsVariable $a_variable)
addAnswer(ilSurveyEvaluationResultsAnswer $a_answer)
setUsersSkipped($a_value)