* @copyright 2007-2010 Stud.IP Core-Group * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 * @category Stud.IP */ require '../lib/bootstrap.php'; require_once 'lib/evaluation/evaluation.config.php'; require_once EVAL_FILE_EVAL; require_once EVAL_FILE_OBJECTDB; require_once 'lib/export/export_tmp_gc.inc.php'; ob_start(); page_open(["sess" => "Seminar_Session", "auth" => "Seminar_Auth", "perm" => "Seminar_Perm", "user" => "Seminar_User"]); include ('lib/seminar_open.php'); // initialise Stud.IP-Session $eval_id = Request::option('eval_id'); /* 1 = normale HTML-Ansicht in Stud.IP 2 = Druckansicht, ohne HTML-Elemente */ $ausgabeformat = Request::int('ausgabeformat', 1); $cmd = Request::option('cmd'); $evalgroup_id = Request::option('evalgroup_id'); $group_type = Request::option('group_type'); // Überprüfen, ob die Evaluation existiert oder der Benutzer genügend Rechte hat $eval = new Evaluation($eval_id); $eval->check(); if (EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval) == YES || count($eval->errorArray) > 0) { throw new Exception(_("Diese Evaluation ist nicht vorhanden oder Sie haben nicht ausreichend Rechte!")); } // Template vorhanden? $has_template = 0; $eval_templates = []; $question_type = ""; $tmp_path_export = $GLOBALS['TMP_PATH']; export_tmp_gc(); if (isset($cmd)) { if ($cmd=="change_group_type" && isset($evalgroup_id) && isset($group_type)) { $query = "SELECT 1 FROM eval_group_template WHERE evalgroup_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$evalgroup_id]); $present = $statement->fetchColumn(); if ($present) { // Datensatz schon vorhanden --> UPDATE if ($group_type == "normal") { $query = "DELETE FROM eval_group_template WHERE group_type = 'table' AND evalgroup_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$evalgroup_id]); } else { $query = "UPDATE eval_group_template SET group_type = ? WHERE evalgroup_id = ? AND user_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$group_type, $evalgroup_id, $GLOBALS['user']->id]); } } else { // Datensatz nicht vorhanden --> INSERT $query = "INSERT INTO eval_group_template (evalgroup_id, user_id, group_type) VALUES (?, ?, ?)"; $statement = DBManager::get()->prepare($query); $statement->execute([$evalgroup_id, $GLOBALS['user']->id, $group_type]); } } } function do_template($column) { global $has_template, $eval_templates; return ($has_template==0 || ($has_template==1 && $eval_templates[$column])); } /** * returning the type of the graph * * @return string */ function do_graph_template() { global $eval_templates, $has_template, $question_type; if ($has_template == 1) { if ($question_type == 'likertskala') { return $eval_templates['likertscale_gfx_type']; } if ($question_type == 'multiplechoice') { return $eval_templates['mchoice_scale_gfx_type']; } if ($question_type == 'polskala') { return $eval_templates['polscale_gfx_type']; } } return 'bars'; } /** * drawing the graph for a evaluation question * * @param array() $data * @param string $evalquestion_id */ function do_graph($data, $evalquestion_id) { global $tmp_path_export, $auth; $type = do_graph_template(); //Define the object if ($type == "pie") { // Beim pie muss die Zeichenflaeche etwas groesser gewaehlt werden... $graph = new PHPlot(500,300); } else { $graph = new PHPlot(300,250); } if ($type == "pie") { // Beim pie muss das Array umgeformt werden. Bug in PHPlot? $tmp = []; $tmp2 = []; $legend = []; array_push($tmp,"Test"); foreach($data as $k=>$d) { array_push($tmp, $d[1]); array_push($legend, $d[0]); } array_push($tmp2, $tmp); $data = $tmp2; $graph->SetLegend($legend); } //Data Colors $graph->SetDataColors( ["blue", "green", "yellow", "red", "PeachPuff", "orange", "pink", "lavender", "navy", "peru", "salmon", "maroon", "magenta", "orchid", "ivory"], ["black"] //Border Colors ); if(!empty($data)) { $_data = []; array_walk($data, function($d) use (&$_data) { $_data[] = next($d); }); $max_x = max($_data); $graph->SetPlotAreaWorld(NULL, 0); // y-achse bei 0 starten $graph->SetPrecisionY(0); //anzahl kommastellen y-achse $graph->SetYTickIncrement($max_x < 10 ? 1 : round($max_x/10)); $graph->SetPlotBgColor([222,222,222]); $graph->SetDataType("text-data"); $graph->SetFileFormat(Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT); $graph->SetOutputFile($tmp_path_export."/evalsum".$evalquestion_id.$auth->auth["uid"].".".Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT); $graph->SetIsInline(true); $graph->SetDataValues($data); $graph->SetPlotType($type); $graph->SetXLabelAngle(count($data) < 10 ? 0 : 90); //$graph->SetShading(0); // kein 3D $graph->SetLineWidth(1); $graph->SetDrawXDataLabels(true); //Draw it $graph->DrawGraph(); } } function freetype_answers($parent_id, $anz_nutzer) { $query = "SELECT `text` FROM evalanswer INNER JOIN evalanswer_user USING(evalanswer_id) WHERE parent_id = ? AND `text` != '' ORDER BY position"; $statement = DBManager::get()->prepare($query); $statement->execute([$parent_id]); echo " \n"; echo " \n"; echo " \n"; echo " \n"; $counter = 1; while (false !== ($answer = $statement->fetchColumn())) { echo " \n"; echo " \n"; echo " \n"; $counter++; } echo "
"._("Antworten")."
".$counter.".".formatReady($answer)."
\n"; echo " \n"; echo " \n"; echo " "._("Anzahl der Teilnehmenden").": ".$anz_nutzer."\n"; } function user_answers_residual($parent_id) { $query = "SELECT COUNT(*) FROM evalanswer JOIN evalanswer_user USING (evalanswer_id) WHERE parent_id = ? AND residual = 1"; $statement = DBManager::get()->prepare($query); $statement->execute([$parent_id]); return $statement->fetchColumn(); } function user_answers($evalanswer_id) { $query = "SELECT COUNT(*) FROM evalanswer_user WHERE evalanswer_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$evalanswer_id]); return $statement->fetchColumn(); } function answers($parent_id, $anz_nutzer, $question_type) { global $graph_switch, $auth, $ausgabeformat, $has_template; // Rueckgabearray, damit die Daten noch aufzutrennen sind... $ret_array = ["id"=>$parent_id, // Question-ID "txt"=>"", // HTML-Ausgabe "antwort_texte"=>[], // Antwort-Texte "frage"=>"", // Frage-Text "has_residual"=>0, // Enthaltungen? "antwort_durchschnitt"=>"", // Antwort-Durchschnitt "summe_antworten"=>"", // Summe der Antworten "anzahl_teilnehmer"=>$anz_nutzer, // Anzahl der Teilnehmer dieser Frage "auswertung"=>[] // 1. Anzahl der Antworten zu einer Antwort // 2. Prozente einer Antwort // 3. Prozente einer Antwort ohne Enthaltungen ]; $summary = []; $query = "SELECT COUNT(*) FROM evalanswer JOIN evalanswer_user USING (evalanswer_id) WHERE parent_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$parent_id]); $answers_sum = $statement->fetchColumn(); $antwort_nummer = 0; $edit = ""; $txt = ""; $gesamte_antworten = 0; $antwort_durchschnitt = 0; $has_residual = user_answers_residual($parent_id); $i = 1; $edit .= " "._("Antworten").""._("Auswertung")."\n"; $query = "SELECT evalanswer_id, `text`, value, residual FROM evalanswer WHERE parent_id = ? ORDER BY position"; $statement = DBManager::get()->prepare($query); $statement->execute([$parent_id]); while ($answer = $statement->fetch(PDO::FETCH_ASSOC)) { $antwort_nummer++; $answer_counter = user_answers($answer['evalanswer_id']); if ($answer['residual'] == 0) { $gesamte_antworten += $answer_counter; $antwort_durchschnitt += $answer_counter * $antwort_nummer; } $prozente_wo_residual = 0; if ($has_residual && ($answers_sum - $has_residual)>0) $prozente_wo_residual = ROUND($answer_counter*100/($anz_nutzer-$has_residual)); $prozente = 0; if ($answers_sum > 0) $prozente = ROUND($answer_counter*100/$anz_nutzer); $edit .= "".$antwort_nummer.". ".($answer['text'] != '' ? formatReady($answer['text']) : $answer['value']).""; if ($has_residual) $edit .= "".$answer_counter." (".$prozente."%) ".($answer['residual'] == 0 ? "(".$prozente_wo_residual."%)*" : "" )."\n"; else $edit .= "".$answer_counter." (".$prozente."%)\n"; array_push($summary, [$antwort_nummer."(".$prozente."%)",$answer_counter]); array_push($ret_array["antwort_texte"], ($answer['text'] != '' ? formatReady($answer['text']) : $answer['value'])); array_push($ret_array["auswertung"], [$answer_counter, $prozente, ($answer['residual'] == 0 ? $prozente_wo_residual : null)]); if ($has_residual) $ret_array["has_residual"] = 1; $i = 0; } do_graph($summary, $parent_id); if ($gesamte_antworten > 0 && $antwort_durchschnitt > 0) $antwort_durchschnitt = ROUND($antwort_durchschnitt / $gesamte_antworten, 3); $ret_array["antwort_durchschnitt"] = $antwort_durchschnitt; $ret_array["summe_antworten"] = $gesamte_antworten; $txt .= " \n"; $txt .= " \n"; $txt .= " "; $txt .= $edit."\n"; $txt .= " "; $txt .= " "; $txt .= " "; if ($question_type=="multiplechoice") { $txt .= " "; if ($has_residual) $txt .= " "; $txt .= "
 
=".$gesamte_antworten." "._("Antworten")."
"; } else { $txt .= "-"._("Antwort").": ".$antwort_durchschnitt.($has_residual==0 ? "" : "*").""; } $txt .= " "._("Anzahl der Teilnehmenden").": ".$anz_nutzer."
*"._("Werte ohne Enthaltungen").".
"; $txt .= " \n"; $txt .= " \n"; if (do_template("show_graphics")) { $txt .= ''."\n"; } else $txt .= " \n"; $txt .= " \n"; $txt .= " \n"; $ret_array['txt'] = $txt; return $ret_array; } function groups($parent_id) { global $ausgabeformat, $global_counter, $local_counter, $question_type, $eval_id, $evalgroup_id; $query = "SELECT group_type FROM eval_group_template WHERE evalgroup_id = ?"; $type_statement = DBManager::get()->prepare($query); $query = "SELECT LOCATE('Freitext', `text`) > 0 FROM evalquestion WHERE evalquestion_id = ?"; $freetext_statement = DBManager::get()->prepare($query); $query = "SELECT evalquestion_id, `text`, type FROM evalquestion WHERE parent_id = ? ORDER BY position"; $questions_statement = DBManager::get()->prepare($query); $query = "SELECT COUNT(DISTINCT user_id) FROM evalanswer JOIN evalanswer_user USING(evalanswer_id) WHERE parent_id = ?"; $question_users_statement = DBManager::get()->prepare($query); $query = "SELECT evalgroup_id, child_type, title, template_id FROM evalgroup WHERE parent_id = ? ORDER BY position"; $statement = DBManager::get()->prepare($query); $statement->execute([$parent_id]); while ($group = $statement->fetch(PDO::FETCH_ASSOC)) { // Heraussuchen, ob es sich um ein Freitext-Template handelt... $freetext_statement->execute([$group['template_id']]); $freetype = $freetext_statement->fetchColumn(); $freetext_statement->closeCursor(); if ($group['child_type'] == 'EvaluationGroup') { $global_counter += 1; $local_counter = 0; echo " \n"; if (do_template("show_group_headline")) echo " ".$global_counter.". ".formatReady($group['title'])." \n"; else echo " "; } else { $local_counter += 1; $type_statement->execute([$group['evalgroup_id']]); $group_type = $type_statement->fetchColumn() ?: 'normal'; $type_statement->closeCursor(); echo " \n"; if (do_template("show_questionblock_headline")) { echo ""; echo ""; echo "
".$global_counter.".".$local_counter.". ".formatReady($group['title']).""; if ($ausgabeformat==1 && !$freetype) { if ($group_type === 'normal') { echo ''; echo Icon::create('vote-stopped', 'clickable', ['title' => _('Zum Darstellungstyp Tabelle wechseln')])->asImg(); echo ''; } else { echo ''; echo Icon::create('vote', 'clickable', ['title' => _('Zum Darstellungstyp Normal wechseln')])->asImg(); } } else { echo ' '; } echo "
\n"; } if ($evalgroup_id == $group['evalgroup_id']) { echo " \n"; } } echo " "; if ($group['child_type'] == 'EvaluationQuestion') { echo " \n"; echo "\n"; $local_question_counter = 0; $answer_arr = []; $questions_statement->execute([$group['evalgroup_id']]); while ($question = $questions_statement->fetch(PDO::FETCH_ASSOC)) { $question_type = $question['type']; $question_users_statement->execute([$question['evalquestion_id']]); $question_users = $question_users_statement->fetchColumn(); $question_users_statement->closeCursor(); $local_question_counter += 1; if (do_template('show_questions') && !empty($group_type) && $group_type === 'normal') { echo " \n"; } if (!($freetype)) { // Keine Freitext-Eingabe $ret = answers($question['evalquestion_id'], $question_users, $question['type']); $ret["frage"] = $question['text']; array_push($answer_arr, $ret); if ($group_type=="normal") echo $ret["txt"]; } else { // Freitext freetype_answers($question['evalquestion_id'], $question_users); } } $questions_statement->closeCursor(); if (!$freetype && !empty($group_type) && $group_type === 'table') { $antworten_angezeigt = FALSE; $i = 0; $has_residual = 0; foreach ($answer_arr as $k1=>$questions) { // Oberste Ebene, hier sind die Questions abgelegt if (!($antworten_angezeigt)) { $i = 1; echo " "; foreach ($questions["antwort_texte"] as $k2=>$v2) { // 1. Unterebene, hier sind die Antworttexte abgelegt echo ""; } echo ""; echo ""; $antworten_angezeigt = TRUE; } echo ""; echo " "; foreach ($questions["auswertung"] as $k3=>$v3) { echo ""; } $i=0; if ($questions["has_residual"]) $has_residual = 1; echo ""; echo ""; } if ($has_residual) echo ""; } echo "
\n"; echo " ".$global_counter.".".$local_counter.".".$local_question_counter.". ".formatReady($question['text'])."\n"; echo "
 ".$v2.""._("Teilnehmende")."
".$questions["frage"].""; echo $v3[0]." (".$v3[1]."%)"; // 2. Unterebene, hier sind die Zahlen abgelegt if ($v3[2]) echo " (".$v3[2]."%)*"; echo "".$questions["summe_antworten"]."".$questions["antwort_durchschnitt"].($questions["has_residual"]?"*":"")."".$questions["anzahl_teilnehmer"]."
*"._("Werte ohne Enthaltungen").".
\n"; echo "\n"; } groups($group['evalgroup_id']); } } $query = "SELECT eval_id, title, author_id, anonymous FROM eval WHERE eval_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([ $eval_id ]); if ($evaluation = $statement->fetch(PDO::FETCH_ASSOC)) { $query = "SELECT t.* FROM eval_templates AS t JOIN eval_templates_eval AS te USING (template_id) WHERE te.eval_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$eval_id]); $eval_templates = $statement->fetch(PDO::FETCH_ASSOC); $has_template = !empty($eval_templates); $db_owner = User::find($evaluation['author_id']); $global_counter = 0; $local_counter = 0; $query = "SELECT COUNT(DISTINCT user_id) FROM eval_user WHERE eval_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$eval_id]); $number_of_votes = $statement->fetchColumn(); $eval_ranges_names = []; $query = "SELECT range_id FROM eval_range WHERE eval_id = ?"; $statement = DBManager::get()->prepare($query); $statement->execute([$eval_id]); $eval_ranges = $statement->fetchAll(PDO::FETCH_COLUMN); foreach ($eval_ranges as $eval_range) { $o_type = get_object_type($eval_range, ['studip','user','sem','inst']); switch($o_type) { case 'global': $name = _('Systemweite Evaluationen'); break; case 'sem': $name = _('Veranstaltung') . ':'; $seminar = Seminar::getInstance($eval_range); $name .= ' ' . $seminar->getName(); $name .= ' (' . Semester::findByTimestamp($seminar->semester_start_time)->name; if ($seminar->semester_duration_time == -1) { $name .= ' - ' . _('unbegrenzt'); } if ($seminar->semester_duration_time > 0) { $name .= ' - ' . Semester::findByTimestamp($seminar->semester_start_time + $seminar->semester_duration_time)->name; } $name .= ')'; $dozenten = array_map(function($v){return $v['Nachname'];}, $seminar->getMembers('dozent')); $name .= ' (' . join(', ' , $dozenten) . ')'; break; case 'user': $name = _('Profil') . ':'; $name .= ' ' . get_fullname($eval_range); break; case 'inst': case 'fak': $name = _('Einrichtung') . ':'; $name .= ' ' . Institute::find($eval_range)->name; break; default: $name = _('unbekannt'); } $eval_ranges_names[] = $name; } sort($eval_ranges_names); // Evaluation existiert auch... echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; // Gesamtstatistik if (do_template("show_total_stats")) { echo " \n"; echo " \n"; echo " \n"; } echo " \n"; echo "
"; echo ($ausgabeformat==1 ? Icon::create('test', 'info_alt')->asImg() : "" ); echo ""._("Evaluations-Auswertung")."".($ausgabeformat==1 ? ""._("PDF-Export")." | "._("Druckansicht")."  " . Icon::create('arr_2right', 'info_alt', ['title' => _('Auswertung konfigurieren')])->asImg() . "" : "" ) ." 
 
  ".formatReady($evaluation['title'] ?? '')."
  "; echo _("Diese Evaluation ist folgenden Bereichen zugeordnet:"); echo '
    '; echo '
  • ' . join('
  • ', array_map('htmlready', $eval_ranges_names)) . '
  • '; echo '
'; echo "
 
\n"; echo "   ".$number_of_votes." "._("Teilnehmende insgesamt").". "; echo " ". ($evaluation['anonymous'] == 0 ? _('Die Teilnahme war nicht anonym.') : _('Die Teilnahme war anonym.')) . ' '; echo " "._("Eigentümer").": ".($db_owner ? htmlReady($db_owner->getFullName('no_title')) : _('Unbekannter Nutzer')).". ".("Erzeugt am").": ".date('d.m.Y H:i:s'); echo "
\n"; echo " \n"; groups($evaluation['eval_id']); echo "
\n"; echo "
\n"; } PageLayout::setHelpKeyword("Basis.Evaluationen"); Navigation::activateItem('/contents/evaluation'); PageLayout::setTitle(_("Evaluations-Auswertung")); if ($ausgabeformat == 2) { PageLayout::removeStylesheet('studip-base.css'); PageLayout::addStylesheet('print.css'); } $layout = $GLOBALS['template_factory']->open('layouts/base.php'); $layout->content_for_layout = ob_get_clean(); echo $layout->render(); page_close();