diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /public | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'public')
| -rw-r--r-- | public/admin_elearning_interface.php | 2 | ||||
| -rw-r--r-- | public/admin_evaluation.php | 113 | ||||
| -rw-r--r-- | public/api.php | 103 | ||||
| -rw-r--r-- | public/assets.php | 2 | ||||
| -rw-r--r-- | public/dispatch.php | 2 | ||||
| -rw-r--r-- | public/eval_config.php | 140 | ||||
| -rw-r--r-- | public/eval_summary.php | 610 | ||||
| -rw-r--r-- | public/eval_summary_export.php | 699 | ||||
| -rw-r--r-- | public/history.txt | 2 | ||||
| -rw-r--r-- | public/install.php | 55 | ||||
| -rw-r--r-- | public/logout.php | 13 | ||||
| -rw-r--r-- | public/sendfile.php | 6 | ||||
| -rw-r--r-- | public/show_evaluation.php | 272 | ||||
| -rw-r--r-- | public/web_migrate.php | 4 |
14 files changed, 52 insertions, 1971 deletions
diff --git a/public/admin_elearning_interface.php b/public/admin_elearning_interface.php index f53f69c..24eb47c 100644 --- a/public/admin_elearning_interface.php +++ b/public/admin_elearning_interface.php @@ -60,7 +60,7 @@ if (Config::get()->ELEARNING_INTERFACE_ENABLE) } if (!count(array_column($connection_status, 'error'))) { - require_once ("lib/elearning/" . $ELEARNING_INTERFACE_MODULES[$cms_select]["CLASS_PREFIX"] . "ConnectedCMS.class.php"); + require_once ("lib/elearning/" . $ELEARNING_INTERFACE_MODULES[$cms_select]["CLASS_PREFIX"] . "ConnectedCMS.php"); $classname = $ELEARNING_INTERFACE_MODULES[$cms_select]["CLASS_PREFIX"] . "ConnectedCMS"; $connected_cms[$cms_select] = new $classname($cms_select); $connected_cms[$cms_select]->initSubclasses(); diff --git a/public/admin_evaluation.php b/public/admin_evaluation.php deleted file mode 100644 index f702173..0000000 --- a/public/admin_evaluation.php +++ /dev/null @@ -1,113 +0,0 @@ -<?php -# Lifter001: TEST -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// admin_evaluation.php -// -// Show the admin pages -// -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -/** - * admin_evaluation.php - * - * - * @author cb - * @version 10. Juni 2003 - * @access public - * @package evaluation - */ - -require '../lib/bootstrap.php'; - -ob_start(); // start output buffering - -page_open ( ["sess" => "Seminar_Session", - "auth" => "Seminar_Auth", - "perm" => "Seminar_Perm", - "user" => "Seminar_User"]); -$perm->check ("autor"); - -$list = Request::option('list'); -$view = Request::option('view'); - - -include_once 'lib/seminar_open.php'; - -PageLayout::setHelpKeyword("Basis.Evaluationen"); -$title = _('Verwaltung von Evaluationen'); -if (Context::get()) { - $title = Context::getHeaderLine() . ' - ' . $title; -} -PageLayout::setTitle($title); - -require_once 'lib/evaluation/evaluation.config.php'; - -if ($view === 'eval_inst') { - Navigation::activateItem('/admin/institute/evaluation'); - require_once 'lib/admin_search.inc.php'; -} else if (Context::getId() && $view == "eval_sem") { - Navigation::activateItem('/course/admin/evaluation'); -} else { - Navigation::activateItem('/contents/evaluation'); -} - -if ((Context::getId()) && ($view == "eval_sem") || ($view == "eval_inst")) { - $the_range = Context::getId(); -} else { - $the_range = Request::option('rangeID'); -} - -$isUserrange = null; -if ($the_range) { - if (get_Username($the_range)) { - $the_range = get_Username($the_range); - } - if (get_Userid($the_range)) { - $isUserrange = 1; - } -} elseif ($view) { - $the_range = Context::getId(); -} - -if (empty($the_range)) { - $the_range = $user->id; - $isUserrange = 1; -} - -if ($the_range != $auth->auth['uname'] && $the_range != 'studip' && !$isUserrange){ - $view_mode = get_object_type($the_range); - if ($view_mode == "fak"){ - $view_mode = "inst"; - } -} - - -ob_start(); -if (Request::option('page') == "edit"){ - include (EVAL_PATH.EVAL_FILE_EDIT); -}else{ - include (EVAL_PATH.EVAL_FILE_OVERVIEW); -} -$template = $GLOBALS['template_factory']->open('layouts/base.php'); -$template->content_for_layout = ob_get_clean(); -echo $template->render(); -page_close(); diff --git a/public/api.php b/public/api.php deleted file mode 100644 index b2d30fa..0000000 --- a/public/api.php +++ /dev/null @@ -1,103 +0,0 @@ -<?php - -/** @file - * - * Diese Datei stellt den Ausgangspunkt für alle Zugriffe auf die - * RESTful Web Services von Stud.IP dar. - * Grob betrachtet läuft das Routings so ab: - * - * Ein HTTP-Request geht ein. Falls dort eine inkompatible Version der - * REST-API verlangt wird, bricht das Skript ab. Die Authentifizierung - * wird durchgeführt. Bei Erfolg wird die PATH_INFO und die HTTP - * Methode im Router verwendet, um die passende Funktion zu - * finden. Der Router liefert in jedem Fall ein Response-Objekt - * zurück, dass dann anschließende ausgegeben wird, d.h. die Header - * werden gesendet und dann das Ergebnis ausgegeben oder gestreamt. - * - * @deprecated Since Stud.IP 5.0. Will be removed in Stud.IP 6.0. - */ - - -namespace { - require_once '../lib/bootstrap.php'; - - page_open([ - 'sess' => 'Seminar_Session', - 'auth' => 'Seminar_Default_Auth', - 'perm' => 'Seminar_Perm', - 'user' => 'Seminar_User', - ]); -} - -namespace RESTAPI { - - use Config; - - // A potential api exception will lead to an according response with the - // exception code and name as the http status. - try { - if (!Config::get()->API_ENABLED) { - throw new RouterException(503, 'REST API is not available'); - } - - require 'lib/bootstrap-api.php'; - - // Initialize RESTAPI plugins - \PluginEngine::getPlugins('RESTAPIPlugin'); - - $uri = \Request::pathInfo(); - - // Check version - if (defined('RESTAPI\\VERSION') && preg_match('~^/v(\d+)~i', $uri, $match)) { - $version = $match[1]; - if ($version != VERSION) { - throw new RouterException(400, 'Version not supported'); - } - - $uri = mb_substr($uri, mb_strlen($match[0])); - header('X-API-Version: ' . VERSION); - } - - // Get router instance - $router = Router::getInstance(); - - $api_user = $router->setupAuth(); - - // Actual dispatch - $response = $router->dispatch($uri); - - // Tear down - if ($api_user) { - restoreLanguage(); - } - - // Send output - $response->output(); - - } catch (RouterException $e) { - $status = sprintf('%s %u %s', - $_SERVER['SERVER_PROTOCOL'] ?: 'HTTP/1.1', - $e->getCode(), - $e->getMessage()); - $status = trim($status); - if (!headers_sent()) { - if ($e->getCode() === 401) { - header('WWW-Authenticate: Basic realm="' . Config::get()->STUDIP_INSTALLATION_ID . '"'); - } - header($status, true, $e->getCode()); - echo $status; - } else { - echo $status; - } - } catch (\Exception $e) { - error_log("Caught {$e}"); - - $message = explode("\n", $e->getMessage())[0]; - header('Content-Type: application/json; charset=UTF-8'); - header("{$_SERVER['SERVER_PROTOCOL']} 500 {$message}"); - echo $GLOBALS['template_factory']->render('json_exception', [ - 'exception' => $e, - 'status' => 500, - ]); - } -} diff --git a/public/assets.php b/public/assets.php index a0baa6d..3610a13 100644 --- a/public/assets.php +++ b/public/assets.php @@ -19,7 +19,7 @@ $uri = ltrim(Request::pathInfo(), '/'); list($type, $id) = explode('/', $uri, 2); // Setup response -$response = new Trails_Response(); +$response = new Trails\Response(); // Create response if (!$type || !$id) { diff --git a/public/dispatch.php b/public/dispatch.php index 68d0399..77c5933 100644 --- a/public/dispatch.php +++ b/public/dispatch.php @@ -21,5 +21,5 @@ require '../lib/bootstrap.php'; // prepare environment URLHelper::setBaseUrl($GLOBALS['ABSOLUTE_URI_STUDIP']); -$dispatcher = app(\Trails_Dispatcher::class); +$dispatcher = app(\Trails\Dispatcher::class); $dispatcher->dispatch(Request::pathInfo()); diff --git a/public/eval_config.php b/public/eval_config.php deleted file mode 100644 index d064688..0000000 --- a/public/eval_config.php +++ /dev/null @@ -1,140 +0,0 @@ -<?php -# Lifert001: TODO -# Lifter002: TEST -# Lifter003: TEST -# Lifter005: DONE - not applicable -# Lifter007: TEST -# Lifter010: DONE - not applicable - -/** - * eval_config.php - * - * Konfiurationsseite fuer Eval-Auswertungen - * - * - * @author Jan Kulmann <jankul@tzi.de> - * @author Jan-Hendrik Willms <tleilax+studip@gmail.com> - */ - -// +---------------------------------------------------------------------------+ -// This file is part of Stud.IP -// eval_config.php -// Copyright (C) 2005 Jan Kulmann <jankul@tzi.de> -// +---------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +---------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +---------------------------------------------------------------------------+ - - require '../lib/bootstrap.php'; - - page_open([ - 'sess' => 'Seminar_Session', - 'auth' => 'Seminar_Auth', - 'perm' => 'Seminar_Perm', - 'user' => 'Seminar_User' - ]); - - $perm->check('user'); - - include 'lib/seminar_open.php'; // initialise Stud.IP-Session - - // -- here you have to put initialisations for the current page - require_once 'lib/evaluation/evaluation.config.php'; - require_once EVAL_FILE_EVAL; - require_once EVAL_FILE_OBJECTDB; - - // Start of Output - PageLayout::setTitle(_('Evaluations-Auswertung')); - PageLayout::setHelpKeyword('Basis.Evaluationen'); - Navigation::activateItem('/contents/evaluation'); - - // Extract variables from request - $eval_id = Request::option('eval_id'); - $template_id = Request::option('template_id'); - - // Ü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!")); - } - - // Store settings - if (Request::submitted('store')) { - if (!$template_id) { - $template_id = DbView::get_uniqid(); - - $query = "INSERT INTO eval_templates_eval (eval_id, template_id) - VALUES (?, ?)"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$eval_id, $template_id]); - } - - $show_questions = Request::int('show_questions'); - $show_total_stats = Request::int('show_total_stats'); - $show_graphics = Request::int('show_graphics'); - $show_questionblock_headline = Request::int('show_questionblock_headline'); - $show_group_headline = Request::int('show_group_headline'); - - $polscale_gfx_type = Request::option('polscale_gfx_type'); - $likertscale_gfx_type = Request::option('likertscale_gfx_type'); - $mchoice_scale_gfx_type = Request::option('mchoice_scale_gfx_type'); - - $query = "INSERT INTO eval_templates - (template_id, user_id, name, - show_questions, show_total_stats, show_graphics, - show_questionblock_headline, show_group_headline, - polscale_gfx_type, likertscale_gfx_type, mchoice_scale_gfx_type) - VALUES (?, ?, 'nix', ?, ?, ?, ?, ?, ?, ?, ?) - ON DUPLICATE KEY UPDATE show_questions = VALUES(show_questions), - show_total_stats = VALUES(show_total_stats), - show_graphics = VALUES(show_graphics), - show_questionblock_headline = VALUES(show_questionblock_headline), - show_group_headline = VALUES(show_group_headline), - polscale_gfx_type = VALUES(polscale_gfx_type), - likertscale_gfx_type = VALUES(likertscale_gfx_type), - mchoice_scale_gfx_type = VALUES(mchoice_scale_gfx_type)"; - $statement = DBManager::get()->prepare($query); - $statement->execute([ - $template_id, $GLOBALS['user']->id, - $show_questions, $show_total_stats, $show_graphics, - $show_questionblock_headline, $show_group_headline, - $polscale_gfx_type, $likertscale_gfx_type, $mchoice_scale_gfx_type - ]); - - PageLayout::postMessage(MessageBox::success(_('Die Auswertungskonfiguration wurde gespeichert.'))); - } - - // Read template setting from db - $query = "SELECT template_id, - show_total_stats, show_graphics, show_questions, show_group_headline, show_questionblock_headline, - polscale_gfx_type, likertscale_gfx_type, mchoice_scale_gfx_type - 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]); - $templates = $statement->fetch(PDO::FETCH_ASSOC); - - // Open, populate and render template - $template = $GLOBALS['template_factory']->open('evaluation/config'); - $template->set_layout($GLOBALS['template_factory']->open('layouts/base')); - - $template->eval_id = $eval_id; - $template->templates = $templates; - $template->has_template = !empty($templates); - - echo $template->render(); - - // Save data back to database. - page_close(); diff --git a/public/eval_summary.php b/public/eval_summary.php deleted file mode 100644 index cbd6036..0000000 --- a/public/eval_summary.php +++ /dev/null @@ -1,610 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TEST -# Lifter003: TEST -# Lifter010: TODO -/** - * eval_summary.php - Hauptseite fuer Eval-Auswertungen - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * @author Jan Kulmann <jankul@zmml.uni-bremen.de> - * @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; - -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']; - -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 " <tr>\n"; - echo " <td colspan=\"2\">\n"; - echo " <table border=\"0\" width=\"100%\">\n"; - echo " <tr><td colspan=\"2\" class=\"blank\"><font size=\"-1\"><b>"._("Antworten")."</b></font></td></tr>\n"; - - $counter = 1; - while (false !== ($answer = $statement->fetchColumn())) { - echo " <tr>\n"; - echo " <td width=\"1%\" valign=\"TOP\"><font size=\"-1\"><b>".$counter.".</b></font></td><td><font size=\"-1\">".formatReady($answer)."</font></td>\n"; - echo " </tr>\n"; - $counter++; - } - - echo " </table>\n"; - echo " </td>\n"; - echo " </tr>\n"; - echo " <tr><td colspan=\"2\"><font size=\"-1\">"._("Anzahl der Teilnehmenden").": ".$anz_nutzer."</font></td></tr>\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 .= "<tr class=\"table_row_even\"><td width=\"1%\"> </td><td width=\"70%\"><font size=\"-1\"><b>"._("Antworten")."</b></font></td><td width=\"29%\"><font size=\"-1\"><b>"._("Auswertung")."</b></font></td></tr>\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 .= "<tr ".($i==1?'class="content_body"':'')."><td width=\"1%\"><font size=\"-1\"><b>".$antwort_nummer.". </b></font></td><td width=\"70%\"><font size=\"-1\">".($answer['text'] != '' ? formatReady($answer['text']) : $answer['value'])."</font></td>"; - if ($has_residual) $edit .= "<td width=\"29%\"><font size=\"-1\">".$answer_counter." (".$prozente."%) ".($answer['residual'] == 0 ? "(".$prozente_wo_residual."%)<b>*</b>" : "" )."</font></td></tr>\n"; - else $edit .= "<td width=\"29%\"><font size=\"-1\">".$answer_counter." (".$prozente."%)</font></td></tr>\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 .= " <tr>\n"; - $txt .= " <td width=\"70%\" valign=\"TOP\">\n"; - $txt .= " <table width=\"98%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"; - $txt .= $edit."\n"; - $txt .= " <tr class=\"blank\"><td colspan=\"3\"><font size=\"-1\"> </font></td></tr>"; - $txt .= " <tr class=\"blank\"><td colspan=\"3\"><font size=\"-1\"><b>∑</b>=".$gesamte_antworten." "._("Antworten")."</font></td></tr>"; - - $txt .= " <tr class=\"blank\">"; - if ($question_type=="multiplechoice") { - $txt .= " <td colspan=\"3\">"; - } else { - $txt .= "<td colspan=\"2\"><font size=\"-1\"><b>∅</b>-"._("Antwort").": ".$antwort_durchschnitt.($has_residual==0 ? "" : "<b>*</b>")."</font></td><td>"; - } - $txt .= " <font size=\"-1\">"._("Anzahl der Teilnehmenden").": ".$anz_nutzer."</font></td></tr>"; - - if ($has_residual) $txt .= " <tr class=\"blank\"><td colspan=\"3\"><font size=\"-1\"><b>*</b>"._("Werte ohne Enthaltungen").".</font></td></tr>"; - $txt .= " </table>"; - $txt .= " </td>\n"; - $txt .= " <td width=\"30%\" valign=\"TOP\" align=\"RIGHT\">\n"; - if (do_template("show_graphics")) { - $txt .= '<IMG SRC="' . FileManager::getDownloadLinkForTemporaryFile( - 'evalsum'.$parent_id.$auth->auth['uid'].'.'.Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT, - 'evalsum'.$parent_id.$auth->auth['uid'].'.'.Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT) .'">'."\n"; - } else $txt .= " \n"; - $txt .= " </td>\n"; - $txt .= " </tr>\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 " <tr><td class=\"".($ausgabeformat==1 ? "table_header_bold" : "blank")."\" align=\"LEFT\" colspan=\"2\">\n"; - if (do_template("show_group_headline")) - echo " <b>".$global_counter.". ".formatReady($group['title'])."</b> \n"; - else echo " "; - } else { - $local_counter += 1; - - $type_statement->execute([$group['evalgroup_id']]); - $group_type = $type_statement->fetchColumn() ?: 'normal'; - $type_statement->closeCursor(); - - echo " <tr><td class=\"".($ausgabeformat==1 ? "table_row_odd" : "blank")."\" colspan=\"2\">\n"; - if (do_template("show_questionblock_headline")) { - echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td align=\"left\"><b>".$global_counter.".".$local_counter.". ".formatReady($group['title'])."</b></td>"; - echo "<td align=\"RIGHT\">"; - if ($ausgabeformat==1 && !$freetype) { - if ($group_type === 'normal') { - echo '<a href="' . URLHelper::getLink('?eval_id=' . $eval_id . '&evalgroup_id=' . $group['evalgroup_id'] . '&group_type=table&cmd=change_group_type#anker') . '">'; - echo Icon::create('vote-stopped', 'clickable', ['title' => _('Zum Darstellungstyp Tabelle wechseln')])->asImg(); - echo '</a>'; - } else { - echo '<a href="' . URLHelper::getLink('?eval_id=' . $eval_id . '&evalgroup_id=' . $group['evalgroup_id'] . '&group_type=normal&cmd=change_group_type#anker') . '">'; - echo Icon::create('vote', 'clickable', ['title' => _('Zum Darstellungstyp Normal wechseln')])->asImg(); - } - } else { - echo ' '; - } - echo "</td>"; - echo "</tr></table>\n"; - } - if ($evalgroup_id == $group['evalgroup_id']) { - echo " <a name=\"anker\"></a>\n"; - } - } - - echo " </td></tr>"; - - if ($group['child_type'] == 'EvaluationQuestion') { - echo " <tr><td class=\"blank\" colspan=\"2\">\n"; - - echo "<table border=\"". (!empty($group_type) && $group_type=="normal" || $ausgabeformat==1 ? "0" : "1") ."\" width=\"100%\" cellspacing=\"0\">\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 " <tr><td class=\"blank\" colspan=\"2\">\n"; - echo " <b>".$global_counter.".".$local_counter.".".$local_question_counter.". ".formatReady($question['text'])."</b></font>\n"; - echo " </td></tr>\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 " <tr class=\"table_row_even\"><td><font size=\"-1\"> </font></td>"; - foreach ($questions["antwort_texte"] as $k2=>$v2) { // 1. Unterebene, hier sind die Antworttexte abgelegt - echo "<td><font size=\"-1\">".$v2."</font></td>"; - } - echo "<td align=\"center\"><font size=\"-1\"><b>∑</b></font></td><td align=\"center\"><font size=\"-1\"><b>∅</b></font></td><td align=\"center\"><font size=\"-1\">"._("Teilnehmende")."</font></td>"; - echo "</tr>"; - $antworten_angezeigt = TRUE; - } - - echo "<tr ". ($i==1?'class="content_body"':'').">"; - echo " <td><font size=\"-1\">".$questions["frage"]."</font></td>"; - foreach ($questions["auswertung"] as $k3=>$v3) { - echo "<td width=\"10%\" valign=\"TOP\"><font size=\"-1\">"; - echo $v3[0]." (".$v3[1]."%)"; // 2. Unterebene, hier sind die Zahlen abgelegt - if ($v3[2]) echo " (".$v3[2]."%)<b>*</b>"; - echo "</font></td>"; - } - - $i=0; - if ($questions["has_residual"]) $has_residual = 1; - - echo "<td align=\"center\" width=\"3%\" valign=\"TOP\"><font size=\"-1\">".$questions["summe_antworten"]."</font></td><td align=\"center\" width=\"3%\" valign=\"TOP\"><font size=\"-1\">".$questions["antwort_durchschnitt"].($questions["has_residual"]?"<b>*</b>":"")."</font></td><td align=\"center\" width=\"6%\" valign=\"TOP\"><font size=\"-1\">".$questions["anzahl_teilnehmer"]."</font></td>"; - - echo "</tr>"; - } - if ($has_residual) echo "<tr><td><font size=\"-1\"><b>*</b>"._("Werte ohne Enthaltungen").".</font></td></tr>"; - } - - echo "</table>\n"; - echo "</td></tr>\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 "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n"; - echo "<tr><td class=\"table_header_bold\" align=\"left\"><font color=\"".($ausgabeformat==1 ? "white" : "black")."\">"; - echo ($ausgabeformat==1 ? Icon::create('test', 'info_alt')->asImg() : "" ); - echo "<b>"._("Evaluations-Auswertung")."</b></font></td>\n"; - echo "<td class=\"".($ausgabeformat==1 ? "table_header_bold" : "blank" )."\" align=\"RIGHT\">".($ausgabeformat==1 ? "<a href=\"eval_summary_export.php?eval_id=".$eval_id."\" TARGET=\"_blank\"><font color=\"WHITE\">"._("PDF-Export")."</font></a><b> | </b><a href=\"".URLHelper::getLink('?eval_id='.$eval_id.'&ausgabeformat=2')."\" TARGET=\"_blank\"><font color=\"WHITE\">"._("Druckansicht")."</font></a> <a href=\"eval_config.php?eval_id=".$eval_id."\">" . Icon::create('arr_2right', 'info_alt', ['title' => _('Auswertung konfigurieren')])->asImg() . "</a>" : "" ) ." </td>\n"; - echo "</tr>\n"; - echo "<tr><td class=\"blank\" colspan=\"2\" align=\"left\"> </td></tr>\n"; - echo "<tr><td class=\"blank\" colspan=\"2\" align=\"left\"><font size=\"+1\"><b> ".formatReady($evaluation['title'] ?? '')."</b></font></td>\n"; - echo "<tr><td class=\"blank\" colspan=\"2\" align=\"left\"> "; - echo _("Diese Evaluation ist folgenden Bereichen zugeordnet:"); - echo '<ul>'; - echo '<li>' . join('</li><li>', array_map('htmlready', $eval_ranges_names)) . '</li>'; - echo '</ul>'; - echo "</td></tr>\n"; - - echo "</tr>\n"; - - echo "<tr><td class=\"blank\" colspan=\"2\" align=\"left\"> </font></td></tr>\n"; - - // Gesamtstatistik - if (do_template("show_total_stats")) { - echo " <tr>\n"; - echo " <td colspan=\"2\" class=\"blank\"><font size=\"-1\">\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 " </font></td>\n"; - echo " </tr>\n"; - } - - echo " <tr><td colspan=\"2\">\n"; - echo " <table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"8\">\n"; - - groups($evaluation['eval_id']); - - echo " </table>\n"; - echo " </td></tr>\n"; - echo "</table>\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(); diff --git a/public/eval_summary_export.php b/public/eval_summary_export.php deleted file mode 100644 index 77b349a..0000000 --- a/public/eval_summary_export.php +++ /dev/null @@ -1,699 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TEST -# Lifter010: DONE - not applicable -/** -* eval_summary_export.php -* -* PDF-Export fuer Eval-Auswertungen -* -* -* @author Jan Kulmann <jankul@zmml.uni-bremen.de> -*/ - -// +---------------------------------------------------------------------------+ -// This file is part of Stud.IP -// eval_summary_export.php -// Copyright (C) 2007 Jan Kulmann <jankul@zmml.uni-bremen.de> -// +---------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +---------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +---------------------------------------------------------------------------+ - - -require '../lib/bootstrap.php'; - -page_open(["sess" => "Seminar_Session", "auth" => "Seminar_Auth", "perm" => "Seminar_Perm", "user" => "Seminar_User"]); - -$perm->check('user'); - -include 'lib/seminar_open.php'; // initialise Stud.IP-Session - -// -- here you have to put initialisations for the current page -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EVAL; -require_once EVAL_FILE_OBJECTDB; - -// Start of Output -$eval_id = Request::option('eval_id'); - -// Ü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!")); -} - -$tmp_path_export = $GLOBALS['TMP_PATH']; - -// Template vorhanden? -$eval_templates = []; -$has_template = 0; - -$pattern = ["'<img[\s]+[^>]*?src[\s]?=[\s\"\']+(.*?)[\"\']+.*?>'si"]; -$replace = ["<fo:external-graphic src=\"url(\\1)\"/>"]; - - -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)) { - $max_x = max(array_map('next',$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) { - global $fo_file, $pattern, $replace; - - $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]); - - while ($answer = $statement->fetchColumn()) { - $counter++; - fputs($fo_file," <fo:table-row>\n"); - fputs($fo_file," <fo:table-cell ><fo:block linefeed-treatment=\"preserve\" font-size=\"8pt\">".$counter.". ".preg_replace($pattern,$replace,xml_escape($answer))."</fo:block></fo:table-cell>\n"); - fputs($fo_file," </fo:table-row>\n"); - } - fputs($fo_file," <fo:table-row>\n"); - fputs($fo_file," <fo:table-cell ><fo:block font-size=\"8pt\">"._("Anzahl der Teilnehmenden").": ".$anz_nutzer."</fo:block></fo:table-cell>\n"); - fputs($fo_file," </fo:table-row>\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, $fo_file, $has_template, $pattern, $replace; - - // 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; - $gesamte_antworten = 0; - $edit = ""; - $txt = ""; - $antwort_durchschnitt = 0; - $has_residual = user_answers_residual($parent_id); - - $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 = 0; - if ($answers_sum>0) $prozente = ROUND($answer_counter*100/$anz_nutzer); - $prozente_wo_residual = 0; - if ($has_residual && ($answers_sum-$has_residual)>0) $prozente_wo_residual = ROUND($answer_counter*100/($anz_nutzer-$has_residual)); - $edit .= " <fo:table-row>\n"; - $edit .= " <fo:table-cell ><fo:block font-size=\"8pt\">".$antwort_nummer.". ". xml_escape(($answer['text']!="" ? $answer['text'] : $answer['value']))."</fo:block></fo:table-cell>\n"; - - if ($has_residual) $edit .= " <fo:table-cell ><fo:block font-size=\"8pt\">".$answer_counter." (".$prozente."%) ".($answer['residual'] == 0 ? "(".$prozente_wo_residual."%)*" : "" )."</fo:block></fo:table-cell>\n"; - else $edit .= " <fo:table-cell ><fo:block font-size=\"8pt\">".$answer_counter." (".$prozente."%)</fo:block></fo:table-cell>\n"; - $edit .= " </fo:table-row>\n"; - - array_push($summary, [$antwort_nummer."(".$prozente."%)",$answer_counter]); - - array_push($ret_array["antwort_texte"], ($answer['text'] != "" ? $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; - - } - 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 .= $edit; - - if ($question_type=="multiplechoice") { - $txt .= " <fo:table-row>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\">"._("Anzahl der Teilnehmenden").": ".$anz_nutzer."</fo:block></fo:table-cell>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"></fo:block></fo:table-cell>\n"; - $txt .= " </fo:table-row>\n"; - - $txt .= " <fo:table-row>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"><fo:inline font-family=\"Symbol\">∑</fo:inline> ".$gesamte_antworten." "._("Antworten").".</fo:block></fo:table-cell>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"></fo:block></fo:table-cell>\n"; - $txt .= " </fo:table-row>\n"; - } else { - $txt .= " <fo:table-row>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\">"._("Anzahl der Teilnehmenden").": ".$anz_nutzer."</fo:block></fo:table-cell>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"></fo:block></fo:table-cell>\n"; - $txt .= " </fo:table-row>\n"; - - $txt .= " <fo:table-row>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"><fo:inline font-family=\"Symbol\">∅</fo:inline>-"._("Antwort").": ".$antwort_durchschnitt.($has_residual==0 ? "" : "*")."</fo:block></fo:table-cell>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"><fo:inline font-family=\"Symbol\">∑</fo:inline> ".$gesamte_antworten." "._("Antworten").".</fo:block></fo:table-cell>\n"; - $txt .= " </fo:table-row>\n"; - - } - - if ($has_residual) { - $txt .= " <fo:table-row>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\">*"._("Werte ohne Enthaltungen").".</fo:block></fo:table-cell>\n"; - $txt .= " <fo:table-cell ><fo:block space-before.optimum=\"5pt\" font-size=\"8pt\"></fo:block></fo:table-cell>\n"; - $txt .= " </fo:table-row>\n"; - } - - $ret_array["txt"] = $txt; - - return $ret_array; - -} - -function groups ($parent_id) { - global $ausgabeformat, $fo_file, $auth, $global_counter, $local_counter, $tmp_path_export, $pattern, $replace; - - $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; - fputs($fo_file," <!-- Groupblock -->\n"); - fputs($fo_file," <fo:block font-variant=\"small-caps\" font-weight=\"bold\" text-align=\"start\" space-after.optimum=\"2pt\" background-color=\"lightblue\" space-before.optimum=\"10pt\">\n"); - if (do_template("show_group_headline")) - fputs($fo_file," ".$global_counter.". ". xml_escape($group['title']) ."\n"); - fputs($fo_file," </fo:block>\n"); - } else { - $local_counter += 1; - - $type_statement->execute([$group['evalgroup_id']]); - $group_type = $type_statement->fetchColumn() ?: 'normal'; - $type_statement->closeCursor(); - - fputs($fo_file," <!-- Questionblock -->\n"); - fputs($fo_file," <fo:block font-variant=\"small-caps\" font-weight=\"bold\" text-align=\"start\" background-color=\"grey\" color=\"white\" space-after.optimum=\"10pt\">\n"); - if (do_template("show_questionblock_headline")) - fputs($fo_file," ".$global_counter.".".$local_counter.". ". xml_escape($group['title']) ."\n"); - fputs($fo_file," </fo:block>\n"); - } - - if ($group['child_type'] == 'EvaluationQuestion') { - - $local_question_counter = 0; - $answer_arr = []; - - $questions_statement->execute([$group['evalgroup_id']]); - while ($question = $questions_statement->fetch(PDO::FETCH_ASSOC)) { - $question_users_statement->execute([$question['evalquestion_id']]); - $question_users = $question_users_statement->fetchColumn(); - $question_users_statement->closeCursor(); - - if ($group_type=="normal") { - - $local_question_counter += 1; - fputs($fo_file," <!-- Question -->\n"); - fputs($fo_file," <fo:block text-align=\"start\" font-weight=\"bold\" space-before.optimum=\"10pt\" space-after.optimum=\"10pt\">\n"); - if (do_template("show_questions")) { - fputs($fo_file," ".$global_counter.".".$local_counter.".".$local_question_counter.". ". xml_escape($question['text']) ."\n"); - } - fputs($fo_file," </fo:block>\n"); - fputs($fo_file," <!-- table start -->\n"); - fputs($fo_file," <fo:table table-layout=\"fixed\" border-width=\".1mm\" space-after.optimum=\"10pt\">\n"); - if (!($freetype)) { - fputs($fo_file," <fo:table-column column-width=\"100mm\"/>\n"); - fputs($fo_file," <fo:table-column column-width=\"60mm\"/>\n"); - } else { - fputs($fo_file," <fo:table-column column-width=\"160mm\"/>\n"); - } - fputs($fo_file," <fo:table-body>\n"); - fputs($fo_file," <fo:table-row >\n"); - fputs($fo_file," <fo:table-cell ><fo:block start-indent=\"3mm\" end-indent=\"3mm\" padding-left=\"3mm\" padding-right=\"3mm\" padding-top=\"4mm\" padding-bottom=\"4mm\">\n"); - fputs($fo_file," <!-- table start -->\n"); - fputs($fo_file," <fo:table table-layout=\"fixed\">\n"); - if (!($freetype)) { - fputs($fo_file," <fo:table-column column-width=\"60mm\"/>\n"); - fputs($fo_file," <fo:table-column column-width=\"40mm\"/>\n"); - } else { - fputs($fo_file," <fo:table-column column-width=\"160mm\"/>\n"); - } - fputs($fo_file," <fo:table-body>\n"); - - - } // ($group_type=="normal") - - 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") fputs($fo_file, $ret["txt"]); - } else { - // Freitext - freetype_answers($question['evalquestion_id'], $question_users); - } - - - if ($group_type=="normal") { - - fputs($fo_file," </fo:table-body>\n"); - fputs($fo_file," </fo:table>\n"); - fputs($fo_file," <!-- table end -->\n"); - fputs($fo_file," </fo:block></fo:table-cell>\n"); - if (!($freetype)) { - fputs($fo_file," <fo:table-cell ><fo:block start-indent=\"3mm\" end-indent=\"3mm\" padding-left=\"3mm\" padding-right=\"3mm\" padding-top=\"4mm\" padding-bottom=\"4mm\">\n"); - if (do_template("show_graphics")) { - fputs($fo_file," <fo:external-graphic content-width=\"70mm\" content-height=\"60mm\" src=\"url('file:///".$tmp_path_export."/evalsum".$question['evalquestion_id'].$auth->auth["uid"].".".Config::get()->EVAL_AUSWERTUNG_GRAPH_FORMAT."')\"/>\n"); - } - fputs($fo_file," </fo:block></fo:table-cell>\n"); - } - fputs($fo_file," </fo:table-row>\n"); - fputs($fo_file," </fo:table-body>\n"); - fputs($fo_file," </fo:table>\n"); - fputs($fo_file," <!-- table end -->\n"); - - } // ($group_type=="normal") - - - - } - - if (!($freetype) && $group_type=="table") { - - $antworten_angezeigt = FALSE; - $i = 0; - $has_residual = 0; - $col_count = count($answer_arr[0]["antwort_texte"]); - - fputs($fo_file," <!-- table start -->\n"); - fputs($fo_file," <fo:table table-layout=\"fixed\" border-width=\".1mm\" border-style=\"solid\" space-after.optimum=\"10pt\">\n"); - fputs($fo_file," <fo:table-column/>\n"); - for ($a=1; $a<=$col_count; $a++) - fputs($fo_file," <fo:table-column column-width=\"15mm\"/>\n"); - fputs($fo_file," <fo:table-column column-width=\"8mm\"/>\n"); - fputs($fo_file," <fo:table-column column-width=\"8mm\"/>\n"); - fputs($fo_file," <fo:table-column column-width=\"15mm\"/>\n"); - - - fputs($fo_file," <fo:table-body>\n"); - - foreach ($answer_arr as $k1=>$questions) { // Oberste Ebene, hier sind die Questions abgelegt - if (!($antworten_angezeigt)) { - $i = 1; - fputs($fo_file," <fo:table-row >\n"); - fputs($fo_file," <fo:table-cell ><fo:block space-before.optimum=\"10pt\">\n"); - fputs($fo_file," </fo:block></fo:table-cell >"); - foreach ($questions["antwort_texte"] as $k2=>$v2) { // 1. Unterebene, hier sind die Antworttexte abgelegt - fputs($fo_file," <fo:table-cell ><fo:block space-before.optimum=\"10pt\" font-size=\"7pt\">\n"); - fputs($fo_file, xml_escape($v2)); - fputs($fo_file," </fo:block></fo:table-cell >"); - } - - fputs($fo_file," <fo:table-cell ><fo:block text-align=\"center\" space-before.optimum=\"10pt\" font-size=\"7pt\" font-family=\"Symbol\">\n"); - fputs($fo_file, "∑"); - fputs($fo_file," </fo:block></fo:table-cell >"); - fputs($fo_file," <fo:table-cell ><fo:block text-align=\"center\" space-before.optimum=\"10pt\" font-size=\"7pt\" font-family=\"Symbol\">\n"); - fputs($fo_file, "∅"); - fputs($fo_file," </fo:block></fo:table-cell >"); - fputs($fo_file," <fo:table-cell ><fo:block text-align=\"center\" space-before.optimum=\"10pt\" font-size=\"7pt\">\n"); - fputs($fo_file, _("Teilnehmende")); - fputs($fo_file," </fo:block></fo:table-cell >"); - - fputs($fo_file," </fo:table-row>\n"); - $antworten_angezeigt = TRUE; - } - - fputs($fo_file," <fo:table-row >\n"); - - fputs($fo_file," <fo:table-cell ><fo:block font-size=\"6pt\" start-indent=\"3mm\">\n"); - fputs($fo_file, $questions["frage"]); - fputs($fo_file," </fo:block></fo:table-cell >"); - - foreach ($questions["auswertung"] as $k3=>$v3) { - fputs($fo_file," <fo:table-cell ><fo:block font-size=\"7pt\">\n"); - fputs($fo_file, $v3[0]." (".$v3[1]."%)"); // 2. Unterebene, hier sind die Zahlen abgelegt - if ($v3[2]) fputs($fo_file, " (".$v3[2]."%)*"); - fputs($fo_file," </fo:block></fo:table-cell >"); - } - - $i=0; - if ($questions["has_residual"]) $has_residual = 1; - - fputs($fo_file," <fo:table-cell ><fo:block text-align=\"center\" font-size=\"7pt\">\n"); - fputs($fo_file, $questions["summe_antworten"]); - fputs($fo_file," </fo:block></fo:table-cell >"); - - fputs($fo_file," <fo:table-cell ><fo:block text-align=\"center\" font-size=\"7pt\">\n"); - fputs($fo_file, $questions["antwort_durchschnitt"].($questions["has_residual"]?"*":"")); - fputs($fo_file," </fo:block></fo:table-cell >"); - - fputs($fo_file," <fo:table-cell ><fo:block text-align=\"center\" font-size=\"7pt\">\n"); - fputs($fo_file, $questions["anzahl_teilnehmer"]); - fputs($fo_file," </fo:block></fo:table-cell >"); - - fputs($fo_file," </fo:table-row>\n"); - - } - - fputs($fo_file," <fo:table-row >\n"); - fputs($fo_file," <fo:table-cell ><fo:block start-indent=\"3mm\" space-after.optimum=\"10pt\" font-size=\"7pt\">\n"); - if ($has_residual) fputs($fo_file, "* "._("Werte ohne Enthaltungen")."."); - fputs($fo_file," </fo:block></fo:table-cell >"); - fputs($fo_file," </fo:table-row >\n"); - - fputs($fo_file," </fo:table-body>\n"); - fputs($fo_file," </fo:table>\n"); - fputs($fo_file," <!-- table end -->\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)) { - // Evaluation existiert auch... - - $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(); - - $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); - - $eval_ranges_names = []; - 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); - if (file_exists($tmp_path_export."/evalsum".$evaluation['eval_id'].$auth->auth["uid"].".fo")) unlink($tmp_path_export."/evalsum".$evaluation['eval_id'].$auth->auth["uid"].".fo"); - if (file_exists($tmp_path_export."/evalsum".$evaluation['eval_id'].$auth->auth["uid"].".pdf")) unlink($tmp_path_export."/evalsum".$evaluation['eval_id'].$auth->auth["uid"].".pdf"); - - $fo_file = fopen($tmp_path_export."/evalsum".$evaluation['eval_id'].$auth->auth["uid"].".fo","w"); - - // ----- START HEADER ----- - - fputs($fo_file,"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); - fputs($fo_file,"<fo:root xmlns:fo=\"http://www.w3.org/1999/XSL/Format\">\n"); - fputs($fo_file," <!-- defines the layout master -->\n"); - fputs($fo_file," <fo:layout-master-set>\n"); - fputs($fo_file," <fo:simple-page-master master-name=\"first\" page-height=\"29.7cm\" page-width=\"21cm\" margin-top=\"1cm\" margin-bottom=\"2cm\" margin-left=\"2.5cm\" margin-right=\"2.5cm\">\n"); - fputs($fo_file," <fo:region-body margin-top=\"1cm\" margin-bottom=\"1.5cm\"/>\n"); - fputs($fo_file," <fo:region-before extent=\"1cm\"/>\n"); - fputs($fo_file," <fo:region-after extent=\"1.5cm\"/>\n"); - fputs($fo_file," </fo:simple-page-master>\n"); - fputs($fo_file," </fo:layout-master-set>\n"); - fputs($fo_file," <!-- starts actual layout -->\n"); - fputs($fo_file," <fo:page-sequence master-reference=\"first\">\n"); - fputs($fo_file," <fo:static-content flow-name=\"xsl-region-after\">\n"); - fputs($fo_file," <fo:block text-align=\"center\" font-size=\"8pt\" font-family=\"serif\" line-height=\"14pt\" >\n"); - fputs($fo_file," "._("Erstellt mit Stud.IP")." " . xml_escape($SOFTWARE_VERSION) . " - ". _("Seite")." <fo:page-number/>\n"); - fputs($fo_file," </fo:block>\n"); - fputs($fo_file," <fo:block text-align=\"center\" font-size=\"8pt\" font-family=\"serif\" line-height=\"14pt\" >\n"); - fputs($fo_file," <fo:basic-link color=\"blue\" external-destination=\"$ABSOLUTE_URI_STUDIP\">". xml_escape(Config::get()->UNI_NAME_CLEAN) . "</fo:basic-link>\n"); - fputs($fo_file," </fo:block>\n"); - fputs($fo_file," </fo:static-content>\n"); - fputs($fo_file," <fo:flow flow-name=\"xsl-region-body\">\n"); - fputs($fo_file," <!-- this defines a title level 1-->\n"); - fputs($fo_file," <fo:block font-size=\"18pt\" font-variant=\"small-caps\" font-family=\"sans-serif\" line-height=\"24pt\" space-after.optimum=\"15pt\" background-color=\"blue\" color=\"white\" text-align=\"center\" padding-top=\"3pt\">\n"); - fputs($fo_file," "._("Stud.IP Evaluationsauswertung")."\n"); - fputs($fo_file," </fo:block>\n"); - fputs($fo_file," <!-- this defines a title level 2-->\n"); - - fputs($fo_file," <fo:block font-size=\"16pt\" font-weight=\"bold\" font-family=\"sans-serif\" space-before.optimum=\"10pt\" space-after.optimum=\"15pt\" text-align=\"center\">\n"); - fputs($fo_file," ". xml_escape($evaluation['title'])."\n"); - fputs($fo_file," </fo:block>\n"); - fputs($fo_file," <fo:block text-align=\"start\" line-height=\"10pt\" font-size=\"8pt\">\n"); - fputs($fo_file, _("Diese Evaluation ist folgenden Bereichen zugeordnet:")); - fputs($fo_file," </fo:block>\n"); - foreach($eval_ranges_names as $n) { - fputs($fo_file," <fo:block text-align=\"start\" margin-left=\"0.5cm\" line-height=\"10pt\" font-size=\"8pt\">\n"); - fputs($fo_file, xml_escape($n)); - fputs($fo_file," </fo:block>\n"); - } - - - - if (do_template("show_total_stats")) { - fputs($fo_file," <fo:block text-align=\"start\" space-before.optimum=\"10pt\" line-height=\"10pt\" font-size=\"8pt\">\n"); - fputs($fo_file," ". xml_escape($number_of_votes." "._("Teilnehmende insgesamt")).".\n"); - fputs($fo_file," ". xml_escape(($evaluation['anonymous']==0 ? _('Die Teilnahme war nicht anonym.') : _('Die Teilnahme war anonym.'))."\n")); - fputs($fo_file," " . xml_escape(_("Eigentümer").": ". ($db_owner ? $db_owner->getFullName('no_title') : _('Unbekannter Nutzer')) .". "._("Erzeugt am").": ".date("d.m.Y H:i:s"))."\n"); - fputs($fo_file," </fo:block>\n"); - } - - // ----- ENDE HEADER ----- - - groups($evaluation['eval_id']); - - // ----- START FOOTER ----- - - fputs($fo_file," </fo:flow>\n"); - fputs($fo_file," </fo:page-sequence>\n"); - fputs($fo_file,"</fo:root>\n"); - - // ----- ENDE FOOTER ----- - - fclose($fo_file); - - $pdffile = "$tmp_path_export/" . md5($evaluation['eval_id'].$auth->auth["uid"]); - - $str = $FOP_SH_CALL." $tmp_path_export/evalsum".$evaluation['eval_id'].$auth->auth["uid"].".fo $pdffile"; - - $err = exec($str); - - if (file_exists($pdffile) && filesize($pdffile)) { - header('Location: ' . FileManager::getDownloadURLForTemporaryFile( basename($pdffile), "evaluation.pdf", 2, 'force')); - unlink($tmp_path_export."/evalsum".$evaluation['eval_id'].$auth->auth["uid"].".fo"); - } else { - echo "Fehler beim PDF-Export!<BR>".$err; - echo "<BR>\n".$str; - } -} else { - // Evaluation existiert nicht... - echo _("Evaluation NICHT vorhanden oder keine Rechte!"); -} -// Save data back to database. -page_close(); -?> diff --git a/public/history.txt b/public/history.txt index e6d4960..1dc4b3f 100644 --- a/public/history.txt +++ b/public/history.txt @@ -18,8 +18,6 @@ __15.03.2024 V 5.5__ - Courseware: Neue Sortierfunktionen für Lernmaterialien - Courseware: Seiten im Inhaltsverzeichnis anlegen und umbenennen - Courseware: Lerninhalte und Seiten hinzufügen, kopieren und importieren als eine Aktion -- Unter der Haube: Parallelisierte Cronjobs -- Unter der Haube: Integration Storybook.js - Unter der Haube: Mindestanforderung an PHP auf 7.4 angehoben - Unter der Haube: Mehr Bilder werden als WebP gespeichert diff --git a/public/install.php b/public/install.php index 6d71969..9922f84 100644 --- a/public/install.php +++ b/public/install.php @@ -15,22 +15,37 @@ if (file_exists($GLOBALS['STUDIP_BASE_PATH'] . '/config/config_local.inc.php') set_include_path($GLOBALS['STUDIP_BASE_PATH']); -require_once 'composer/autoload.php'; -require_once 'lib/visual.inc.php'; -require_once 'vendor/trails/trails.php'; -require_once 'vendor/flexi/flexi.php'; -require_once 'lib/classes/URLHelper.php'; -require_once 'lib/classes/LayoutMessage.interface.php'; -require_once 'lib/classes/MessageBox.class.php'; -require_once 'lib/classes/Request.class.php'; -require_once 'lib/classes/Interactable.class.php'; -require_once 'lib/classes/Button.class.php'; -require_once 'lib/classes/LinkButton.class.php'; -require_once 'lib/classes/StudipInstaller.php'; -require_once 'lib/classes/SystemChecker.php'; -require_once 'lib/classes/Markup.class.php'; -require_once 'lib/exceptions/AccessDeniedException.php'; -require_once 'vendor/phpass/PasswordHash.php'; +require 'composer/autoload.php'; +require 'lib/visual.inc.php'; +require 'lib/functions.php'; +require 'lib/classes/URLHelper.php'; +require 'lib/classes/LayoutMessage.php'; +require 'lib/classes/MessageBox.php'; +require 'lib/classes/Request.php'; +require 'lib/classes/Interactable.php'; +require 'lib/classes/Button.php'; +require 'lib/classes/LinkButton.php'; +require 'lib/classes/StudipInstaller.php'; +require 'lib/classes/SystemChecker.php'; +require 'lib/classes/Markup.php'; +require 'lib/exceptions/AccessDeniedException.php'; +require 'lib/flexi/Factory.php'; +require 'lib/flexi/Template.php'; +require 'lib/flexi/PhpTemplate.php'; +require 'lib/flexi/TemplateNotFoundException.php'; +require 'lib/trails/Controller.php'; +require 'lib/trails/Dispatcher.php'; +require 'lib/trails/Exception.php'; +require 'lib/trails/Flash.php'; +require 'lib/trails/Inflector.php'; +require 'lib/trails/Response.php'; +require 'lib/trails/Exceptions/DoubleRenderError.php'; +require 'lib/trails/Exceptions/MissingFile.php'; +require 'lib/trails/Exceptions/RoutingError.php'; +require 'lib/trails/Exceptions/SessionRequiredException.php'; +require 'lib/trails/Exceptions/UnknownAction.php'; +require 'lib/trails/Exceptions/UnknownController.php'; +require 'vendor/phpass/PasswordHash.php'; // Mock gettext functions if extension is not available if (!function_exists('_')) { @@ -40,8 +55,8 @@ if (!function_exists('_')) { } else { require_once 'lib/language.inc.php'; - foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $lang) { - list($lang, ) = explode(';', $lang); + foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '') as $lang) { + [$lang, ] = explode(';', $lang); $lang = substr($lang, 0, 2); if (!in_array($lang, ['de', 'en'])) { @@ -53,10 +68,10 @@ if (!function_exists('_')) { } } -$GLOBALS['template_factory'] = new Flexi_TemplateFactory('../templates/'); +$GLOBALS['template_factory'] = new Flexi\Factory('../templates/'); # get plugin class from request $dispatch_to = ltrim(Request::pathInfo(), '/'); -$dispatcher = new Trails_Dispatcher( '../app', $_SERVER['SCRIPT_NAME'], 'admin/install'); +$dispatcher = new Trails\Dispatcher( '../app', $_SERVER['SCRIPT_NAME'], 'admin/install'); $dispatcher->dispatch("admin/install/{$dispatch_to}"); diff --git a/public/logout.php b/public/logout.php index e18a858..2f8fcd8 100644 --- a/public/logout.php +++ b/public/logout.php @@ -30,7 +30,7 @@ page_open(["sess" => "Seminar_Session", "auth" => "Seminar_Default_Auth", "perm" require_once 'lib/messaging.inc.php'; //nur wenn wir angemeldet sind sollten wir dies tun! -if ($auth->auth["uid"]!="nobody") { +if ($auth->auth['uid'] !== 'nobody') { $my_messaging_settings = $GLOBALS['user']->cfg->MESSAGING_SETTINGS; //Wenn Option dafuer gewaehlt, alle ungelsesenen Nachrichten als gelesen speichern @@ -38,13 +38,13 @@ if ($auth->auth["uid"]!="nobody") { Message::markAllAs(); } - $logout_user=$user->id; + $logout_user = $user->id; $_language = $_SESSION['_language']; $contrast = UserConfig::get($GLOBALS['user']->id)->USER_HIGH_CONTRAST; // TODO this needs to be generalized or removed //erweiterung cas - if ($auth->auth["auth_plugin"] == "cas"){ + if ($auth->auth['auth_plugin'] === 'cas') { $casauth = StudipAuthAbstract::GetInstance('cas'); $docaslogout = true; } @@ -67,9 +67,14 @@ if ($auth->auth["uid"]!="nobody") { if ($contrast) { $_SESSION['contrast'] = $contrast; } + + PageLayout::postSuccess( + _('Sie sind nun aus dem System abgemeldet.'), + array_filter([$GLOBALS['UNI_LOGOUT_ADD']]) + ); } else { $sess->delete(); page_close(); } -header("Location:" . URLHelper::getURL("index.php?logout=true")); +header('Location: ' . URLHelper::getURL('index.php')); diff --git a/public/sendfile.php b/public/sendfile.php index 7d6517c..03157b8 100644 --- a/public/sendfile.php +++ b/public/sendfile.php @@ -156,7 +156,7 @@ if ( ) { $link_data = FileManager::fetchURLMetadata($file_ref->file->metadata['url']); if ($link_data['response_code'] != 200) { - throw new Trails_Exception(404, _("Diese Datei wird von einem externen Server geladen und ist dort momentan nicht erreichbar!")); + throw new Trails\Exception(404, _("Diese Datei wird von einem externen Server geladen und ist dort momentan nicht erreichbar!")); } $content_type = $link_data['Content-Type'] ? strstr($link_data['Content-Type'], ';', true) : get_mime_type($file_name); @@ -166,7 +166,7 @@ if ( if (isset($file)) { $filesize = $file->getSize(); if ($filesize === false) { - throw new Trails_Exception(404, _('Fehler beim Laden der Inhalte der Datei')); + throw new Trails\Exception(404, _('Fehler beim Laden der Inhalte der Datei')); } } @@ -186,7 +186,7 @@ if (isset($file_ref, $file_ref->file, $file_ref->file->metadata['access_type']) // Check if file actually exists if (!parse_url($path_file, PHP_URL_SCHEME) && !file_exists($path_file)) { - throw new Trails_Exception(404, _('Fehler beim Laden der Inhalte der Datei')); + throw new Trails\Exception(404, _('Fehler beim Laden der Inhalte der Datei')); } $allowed_mime_types = get_mime_types(); diff --git a/public/show_evaluation.php b/public/show_evaluation.php deleted file mode 100644 index e81510a..0000000 --- a/public/show_evaluation.php +++ /dev/null @@ -1,272 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * the evaluation participation page :) - * - * @author mcohrs <michael A7 cohrs D07 de> - * @author Michael Riehemann <michael.riehemann@uni-oldenburg.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * - */ - -// +---------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +---------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +---------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +---------------------------------------------------------------------------+ - - -//TODO: auf TemplateFactory umstellen - -# PHP-LIB: open session ===================================================== # - -require '../lib/bootstrap.php'; - -page_open ( ["sess" => "Seminar_Session", - "auth" => "Seminar_Auth", - "perm" => "Seminar_Perm", - "user" => "Seminar_User"]); -$auth->login_if ($auth->auth["uid"] == "nobody"); -$perm->check ("autor"); -# ============================================================== end: PHP-LIB # - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once 'lib/seminar_open.php'; - -require_once EVAL_FILE_EVAL; -require_once EVAL_FILE_EVALDB; -require_once EVAL_FILE_SHOW_TREEVIEW; -require_once EVAL_FILE_EVALTREE; - -require_once EVAL_LIB_COMMON; -require_once EVAL_LIB_SHOW; -# ====================================================== end: including files # - -/* Create objects ---------------------------------------------------------- */ -$db = new EvaluationDB(); -$lib = new EvalShow(); -/* ------------------------------------------------------------ end: objects */ - -#error_reporting( E_ALL & ~E_NOTICE ); - -/* Set variables ----------------------------------------------------------- */ -$rangeID = Request::option('rangeID',Context::getId()); -if (empty ($rangeID)) { - $rangeID = $user->id; } - -$evalID = Request::option('evalID'); -$tree = new EvaluationTreeShowUser( $evalID ); - -$eval = $tree->tree->eval; -$evalDB = new EvaluationDB(); - -$isPreview = Request::option('isPreview') ? YES : NO; - -$votedEarlier = $eval->hasVoted( $auth->auth["uid"] ) && $isPreview == NO; -$votedNow = Request::submitted('voteButton') && $votedEarlier == NO; - -if ( $eval->isAnonymous() ) - $userID = StudipObject::createNewID (); -else - $userID = $auth->auth["uid"]; -/* ---------------------------------------------------------- end: variables */ - -$br = new HTMpty( "br" ); - -/* Surrounding Form -------------------------------------------------------- */ -$form = new HTM( "form" ); -$form->attr( "action", URLHelper::getLink(Request::url()) ); -$form->attr( "method", "post" ); -$form->html(CSRFProtection::tokenTag()); - -if (Request::isXHR()) { - PageLayout::setTitle(_("Stud.IP Online-Evaluation")); -} else { - // TODO: This should use Assets::img() but on the other hand it should also use templates - $titlebar = EvalCommon::createTitle( _("Stud.IP Online-Evaluation"), Icon::create('test', 'info_alt')->asImagePath() ); - $form->cont( $titlebar ); -} -/* Surrounding Table ------------------------------------------------------- */ -$table = new HTM( "table" ); -$table->attr( "border","0" ); -$table->attr( "align", "center" ); -$table->attr( "cellspacing", "0" ); -$table->attr( "cellpadding", "3" ); -$table->attr( "width", "100%" ); -$table->attr( "class", "table_row_even" ); - -/* count mandatory items */ -$mandatories = checkMandatoryItems( $eval ); -$answers = Request::quotedArray('answers'); -/* ------------------------------------------------------------------------- */ -if( $votedNow ) { - $answers = Request::quotedArray('answers'); - $freetexts = Request::quotedArray('freetexts'); - if( ! ( is_array($answers) || - /* clicked no answer */ - (is_array($freetexts) && implode("", $freetexts) != "") - /* typed no freetext */ - ) - ) { - - $eval->throwError( 1, _("Sie haben keine Antworten gewählt.") ); - $votedNow = NO; - - } - - /* check if mandatory answers are missing */ - if( count($mandatories) > 0 ) { - $eval->throwError( 1, sprintf(_("Sie haben %s erforderliche Fragen nicht beantwortet. Diese wurden gesondert markiert."), - count($mandatories)) ); - $votedNow = NO; - } -} - -if( $votedNow ) { - /* the vote was OK */ - - /* process the user's selected answers --------------------------------- */ - if( is_array($answers) ) { - foreach( $answers as $question_id => $answer ) { - if( is_array($answer) ) - /* multiple choice question */ - foreach( $answer as $nr => $answer_id ) - voteFor( $answer_id ); - else - /* answer = answer_id */ - voteFor( $answer ); - } - } - - /* process the user's typed-in answers --------------------------------- */ - $freetexts = Request::quotedArray('freetexts'); - if( is_array($freetexts) ) { - foreach( $freetexts as $question_id => $text ) { - if( trim($text) != '' ) { - $question = new EvaluationQuestion( $question_id ); - $answer = new EvaluationAnswer(); - $answer->setText( $text ); - $answer->setRows( 1 ); - $answer->vote( $GLOBALS["userID"] ); - $question->addChild( $answer ); - $question->save(); - $debug .= "added answer text <b>".$answer->getText(). - "</b> for question <b>".$question->getText()."</b>\n"; - } - } - } - - /* connect user with eval */ - $evalDB->connectWithUser( $evalID, $auth->auth["uid"] ); - - /* header ------ */ - $table->cont( $lib->createEvaluationHeader( $eval, $votedNow, $votedEarlier ) ); - -} elseif( $votedEarlier ) { - /* header ------ */ - $table->cont( $lib->createEvaluationHeader( $eval, $votedNow, $votedEarlier ) ); - -} else { - /* header ------ */ - $table->cont( $lib->createEvaluationHeader( $eval, $votedNow, $votedEarlier ) ); - - /* the whole evaluation ------ */ - $table->cont( $lib->createEvaluation( $tree ) ); -} - -/* footer ------ */ -$table->cont( $lib->createEvaluationFooter( $eval, $votedNow || $votedEarlier, $isPreview ) ); - -$form->cont( $table ); - -/* Ausgabe erzeugen---------------------------------------------------------- */ -//Content (TODO: besser mit TemplateFactory) -if (Request::isXHR()) { - echo $form->createContent(); -} else { - $layout = $GLOBALS['template_factory']->open('layouts/base.php'); - $layout->content_for_layout = $form->createContent(); - echo $layout->render(); -} - -page_close(); - - - /** - * checkMandatoryItems: - * put IDs of mandatory questions into global array $mandatories - * (or, if the user has voted, the IDs of the mandatory questions, which he did not answer to) - * - * @param object the Evaluation object (when called externally). - */ - function checkMandatoryItems( $item ) - { - global $mandatories; - - if( $children = $item->getChildren() ) - { - foreach( $children as $child ) - { - checkMandatoryItems( $child ); - } - } - - if( $item->x_instanceof() == INSTANCEOF_EVALQUESTION ) - { - $group = $item->getParentObject(); - $answers = Request::quotedArray('answers'); - $freetexts = Request::quotedArray('freetexts'); - if( $group->isMandatory() && - ( ! is_array($answers) || - ( is_array($answers) && - ! in_array($item->getObjectID(), array_keys($answers)) ) - ) && - trim($freetexts[$item->getObjectID()]) == '' - ) - { - $mandatories[] = $item->getObjectID(); - } - } - return $mandatories ?: []; - - } - - - /** - * vote for an answer of given ID - * @param string the ID. - */ - function voteFor( $answer_id ) - { - global $debug; - global $userID; - - $answer = new EvaluationAnswer( $answer_id ); - $answer->vote($userID); - - $answer->save(); - - $debug .= "voted for answer <b>".$answer->getText()."</b> (". - $answer->getObjectID().")\n"; -} - -?> diff --git a/public/web_migrate.php b/public/web_migrate.php index 79fba05..0ee4de5 100644 --- a/public/web_migrate.php +++ b/public/web_migrate.php @@ -31,11 +31,11 @@ if (empty($_SESSION['_language'])) { $_language_path = init_i18n($_SESSION['_language']); -$GLOBALS['template_factory'] = new Flexi_TemplateFactory('../templates/'); +$GLOBALS['template_factory'] = new Flexi\Factory('../templates/'); # get plugin class from request $dispatch_to = Request::pathInfo() ?: ''; -$dispatcher = app(\Trails_Dispatcher::class); +$dispatcher = app(\Trails\Dispatcher::class); $dispatcher->trails_uri = $_SERVER['SCRIPT_NAME']; $dispatcher->dispatch("web_migrate/{$dispatch_to}"); |
