diff --git a/app/controllers/admin/user.php b/app/controllers/admin/user.php index 70dfdf16e7002ecdeeca5c3d3cf3e3fe30025def..214c2908b640eb45531dd9470382354453bb33bb 100644 --- a/app/controllers/admin/user.php +++ b/app/controllers/admin/user.php @@ -1446,10 +1446,6 @@ class Admin_UserController extends AuthenticatedController 'desc' => _("Anzahl der Umfragen"), 'query' => "SELECT COUNT(*) FROM questionnaires WHERE user_id = ? GROUP BY user_id", ]; - $queries[] = [ - 'desc' => _("Anzahl der Evaluationen"), - 'query' => "SELECT COUNT(*) FROM eval WHERE author_id = ? GROUP BY author_id", - ]; $queries[] = [ 'desc' => _("Anzahl der Dateien in Veranstaltungen und Einrichtungen"), 'query' => "SELECT COUNT(file_refs.id) diff --git a/app/controllers/course/overview.php b/app/controllers/course/overview.php index 96e7f5abefc6d861851369ece0bd1d48c70981bb..402137e9a4941868bc974e8f49153da7ccdb0e90 100644 --- a/app/controllers/course/overview.php +++ b/app/controllers/course/overview.php @@ -58,8 +58,6 @@ class Course_OverviewController extends AuthenticatedController // Fetch votes if (Config::get()->VOTE_ENABLE) { - $response = $this->relay('evaluation/display/' . $this->course_id); - $this->evaluations = $response->body; $response = $this->relay('questionnaire/widget/' . $this->course_id); $this->questionnaires = $response->body; } diff --git a/app/controllers/evaluation.php b/app/controllers/evaluation.php deleted file mode 100644 index 4a157a9643b22e59f1d96d5eaca94efba2fb00fa..0000000000000000000000000000000000000000 --- a/app/controllers/evaluation.php +++ /dev/null @@ -1,61 +0,0 @@ -<?php - -# Lifter010: TODO -/** - * vote.php - Votecontroller controller - * - * 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. - */ - -class EvaluationController extends AuthenticatedController -{ - public function display_action($range_id) - { - // Bind some params - URLHelper::bindLinkParam('show_expired', $null1); - - // Bind range_id - $this->range_id = $range_id; - - $this->nobody = !$GLOBALS['user']->id || $GLOBALS['user']->id == 'nobody'; - - // Check if we ned administration icons - $this->admin = $range_id == $GLOBALS['user']->id || $GLOBALS['perm']->have_studip_perm('tutor', $range_id); - - // Load evaluations - if (!$this->nobody) { - $eval_db = new EvaluationDB(); - $this->evaluations = StudipEvaluation::findMany($eval_db->getEvaluationIDs($range_id, EVAL_STATE_ACTIVE)); - } else { - $this->evaluations = []; - } - // Check if we got expired - if (Request::get('show_expired')) { - if ($this->admin) { - $this->evaluations = array_merge($this->evaluations, StudipEvaluation::findMany($eval_db->getEvaluationIDs($range_id, EVAL_STATE_STOPPED))); - } - } - if (!empty($this->suppress_empty_output) && count($this->evaluations) === 0) { - $this->render_nothing(); - } else { - $this->visit(); - } - } - - public function visit() - { - if ($GLOBALS['user']->id && $GLOBALS['user']->id != 'nobody' && Request::option('contentbox_open') && in_array(Request::option('contentbox_type'), words('vote eval'))) { - object_set_visit(Request::option('contentbox_open'), Request::option('contentbox_type')); - } - } - - public function visit_action() - { - $this->visit(); - $this->render_nothing(); - } - -} diff --git a/app/controllers/institute/overview.php b/app/controllers/institute/overview.php index 66d55e1b42b31663c2d2bd50de6456f147217f40..3713dccb0b9770edfca73af993880729e702e46e 100644 --- a/app/controllers/institute/overview.php +++ b/app/controllers/institute/overview.php @@ -138,9 +138,6 @@ class Institute_OverviewController extends AuthenticatedController // Fetch votes if (Config::get()->VOTE_ENABLE) { - $response = $this->relay('evaluation/display/' . $this->institute_id . '/institute'); - $this->evaluations = $response->body; - $response = $this->relay('questionnaire/widget/' . $this->institute_id . '/institute'); $this->questionnaires = $response->body; } diff --git a/app/controllers/profile.php b/app/controllers/profile.php index a4e7c56a6665b374b1a61d3561518e8e5590389c..3fa377728369965b0f43cce1ecbf52e8ab6f6106 100644 --- a/app/controllers/profile.php +++ b/app/controllers/profile.php @@ -159,9 +159,6 @@ class ProfileController extends AuthenticatedController // include and show votes and tests if (Config::get()->VOTE_ENABLE && Visibility::verify('votes', $this->current_user->user_id)) { - $response = $this->relay('evaluation/display/' . $this->current_user->user_id); - $this->evaluations = $response->body; - $response = $this->relay('questionnaire/widget/' . $this->current_user->user_id . "/user"); $this->questionnaires = $response->body; } diff --git a/app/controllers/vote.php b/app/controllers/vote.php deleted file mode 100644 index 19f92a2983a8f6c832f29e875f5349c7e899a188..0000000000000000000000000000000000000000 --- a/app/controllers/vote.php +++ /dev/null @@ -1,94 +0,0 @@ -<?php - -# Lifter010: TODO -/** - * vote.php - Votecontroller controller - * - * 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. - */ - -class VoteController extends AuthenticatedController { - - public function display_action($range_id) { - - // Bind some params - URLHelper::bindLinkParam('show_expired', $null1); - URLHelper::bindLinkParam('preview', $null2); - URLHelper::bindLinkParam('revealNames', $null3); - URLHelper::bindLinkParam('sort', $null4); - - // Bind range_id - $this->range_id = $range_id; - - $this->nobody = !$GLOBALS['user']->id || $GLOBALS['user']->id == 'nobody'; - - /* - * Insert vote - */ - if ($vote = Request::get('vote')) { - $vote = new Vote($vote); - if (!$this->nobody && $vote && $vote->isRunning() && (!$vote->userVoted() || $vote->changeable)) { - try { - $vote->insertVote(Request::getArray('vote_answers'), $GLOBALS['user']->id); - } catch (Exception $exc) { - $GLOBALS['vote_message'][$vote->id] = MessageBox::error($exc->getMessage()); - } - } - } - - // Check if we need administration icons - $this->admin = $range_id == $GLOBALS['user']->id || $GLOBALS['perm']->have_studip_perm('tutor', $range_id); - - - // Load evaluations - if (!$this->nobody) { - $eval_db = new EvaluationDB(); - $this->evaluations = StudipEvaluation::findMany($eval_db->getEvaluationIDs($range_id, EVAL_STATE_ACTIVE)); - } else { - $this->evaluations = []; - } - $show_votes[] = 'active'; - // Check if we got expired - if (Request::get('show_expired')) { - $show_votes[] = 'stopvis'; - if ($this->admin) { - $this->evaluations = array_merge($this->evaluations, StudipEvaluation::findMany($eval_db->getEvaluationIDs($range_id, EVAL_STATE_STOPPED))); - $show_votes[] = 'stopinvis'; - } - } - - $this->votes = Vote::findBySQL('range_id = ? AND state IN (?) ORDER BY mkdate desc', [$range_id,$show_votes]); - $this->visit(); - - } - - function visit() - { - if ($GLOBALS['user']->id && $GLOBALS['user']->id != 'nobody' && Request::option('contentbox_open') && in_array(Request::option('contentbox_type'), words('vote eval'))) { - object_set_visit(Request::option('contentbox_open'), Request::option('contentbox_type')); - } - } - - function visit_action() - { - $this->visit(); - $this->render_nothing(); - } - - /** - * Determines if a vote should show its result - * - * @param Vote $vote the vote to check - * @return boolean true if result should be shown - */ - public function showResult($vote) { - if (Request::submitted('change') && $vote->changeable) { - return false; - } - return $vote->userVoted() || in_array($vote->id, Request::getArray('preview')); - } - -} diff --git a/app/views/course/overview/index.php b/app/views/course/overview/index.php index 39d801d9dba9b399726afeaadc43550b3566a406..4e69b4a18e28190b39e37e88b5be4cc5890bcd7e 100644 --- a/app/views/course/overview/index.php +++ b/app/views/course/overview/index.php @@ -64,11 +64,6 @@ if (!empty($dates)) { echo $dates; } -// Anzeige von Umfragen -if (!empty($evaluations)) { - echo $evaluations; -} - if (!empty($questionnaires)) { echo $questionnaires; } diff --git a/app/views/evaluation/_actions.php b/app/views/evaluation/_actions.php deleted file mode 100644 index e702ff2a66fe3a142e0d069c2fdeb6c1918cd0df..0000000000000000000000000000000000000000 --- a/app/views/evaluation/_actions.php +++ /dev/null @@ -1,4 +0,0 @@ -<?= Icon::create('pause', 'clickable')->asImg() ?> -<?= Icon::create('decline', 'clickable')->asImg() ?> -<?= Icon::create('admin', 'clickable')->asImg() ?> -<?= Icon::create('trash', 'clickable')->asImg() ?> diff --git a/app/views/evaluation/_admin_list_vote.php b/app/views/evaluation/_admin_list_vote.php deleted file mode 100644 index a98335bbff437d3088a5505445877a5c50856777..0000000000000000000000000000000000000000 --- a/app/views/evaluation/_admin_list_vote.php +++ /dev/null @@ -1,27 +0,0 @@ -<? foreach ($votes as $vote): ?> - <tr> - <td> - <?= htmlReady($vote->title) ?> - </td> - <td> - <?= ObjectdisplayHelper::link($vote->author) ?> - </td> - <td> - <?= strftime("%d.%m.%Y %T", $vote->startdate) ?> - </td> - <td> - <? if ($vote->stopdate): ?> - <?= strftime("%d.%m.%Y %T", $vote->stopdate) ?> - <? else: ?> - <? if ($vote->timespan): ?> - <?= strftime("%d.%m.%Y %T", $vote->startdate + $vote->timespan) ?> - <? else: ?> - <?= _('Unbegrenzt') ?> - <? endif; ?> - <? endif; ?> - </td> - <td class="actions"> - <?= $this->render_partial("vote/_actions.php", ['vote' => $vote]) ?> - </td> - </tr> -<? endforeach; ?> \ No newline at end of file diff --git a/app/views/evaluation/_buttons.php b/app/views/evaluation/_buttons.php deleted file mode 100644 index b5a3b338284663c5c0a25a7486a0fd00370a4491..0000000000000000000000000000000000000000 --- a/app/views/evaluation/_buttons.php +++ /dev/null @@ -1,22 +0,0 @@ -<? if (!$controller->showResult($vote)): ?> - <? if ($vote->isRunning() && !$nobody) : ?> - <?= Studip\Button::create(_('Abstimmen'), 'vote', ['value' => $vote->id]) ?> - <? endif ?> - <?= Studip\LinkButton::create(_('Ergebnisse'), ContentBoxHelper::href($vote->id, ['preview[]' => $vote->id])) ?> -<? else: ?> - <?= Studip\LinkButton::create(_('Ergebnisse ausblenden'), ContentBoxHelper::href($vote->id, ['preview' => 0])) ?> - <?= Request::get('sort') - ? Studip\LinkButton::create(_('Nicht sortieren'), ContentBoxHelper::href($vote->id, ['preview[]' => $vote->id, 'sort' => 0])) - : Studip\LinkButton::create(_('Sortieren'), ContentBoxHelper::href($vote->id, ['preview[]' => $vote->id, 'sort' => 1])) - ?> - <? if ($vote->changeable && $vote->state == 'active' && !$nobody): ?> - <?= Studip\LinkButton::create(_('Antwort ändern'), ContentBoxHelper::href($vote->id, ['change' => 1])) ?> - <? endif; ?> - <? if (!$vote->anonymous && ($admin || $vote->namesvisibility)): ?> - <? if (Request::get('revealNames') === $vote->id) : ?> - <?= Studip\LinkButton::create(_('Namen ausblenden'), ContentBoxHelper::href($vote->id, ['revealNames' => null])) ?> - <? else : ?> - <?= Studip\LinkButton::create(_('Namen zeigen'), ContentBoxHelper::href($vote->id, ['revealNames' => $vote->id])); ?> - <? endif; ?> - <? endif; ?> -<? endif; ?> \ No newline at end of file diff --git a/app/views/evaluation/_evaluation.php b/app/views/evaluation/_evaluation.php deleted file mode 100644 index 82c6fd1194c04c20e7dc7bd1315404e5328fe046..0000000000000000000000000000000000000000 --- a/app/views/evaluation/_evaluation.php +++ /dev/null @@ -1,57 +0,0 @@ -<? $is_new = ($evaluation->chdate >= object_get_visit($evaluation->id, 'eval', false, false)) && ($evaluation->author_id != $GLOBALS['user']->id); -?> -<article class="studip toggle <?=($is_new ? 'new' : '')?>" id="<?= $evaluation->id ?>" data-visiturl="<?=URLHelper::getScriptLink('dispatch.php/vote/visit')?>"> - <header> - <h1> - <a href="<?= ContentBoxHelper::switchhref($evaluation->id, ['contentbox_type' => 'eval']) ?>"> - <?= htmlReady($evaluation->title) ?> - </a> - </h1> - <nav> - <a href="<?= $evaluation->author ? URLHelper::getLink('dispatch.php/profile', ['username' => $evaluation->author->username]) : '' ?>"> - <?= $evaluation->author ? htmlReady($evaluation->author->getFullName()) : '' ?> - </a> | - <?= strftime("%d.%m.%Y", $evaluation->mkdate) ?> - <? if ($admin): ?> - <a title="<?= _("Evaluation bearbeiten") ?>" href="<?= URLHelper::getLink('admin_evaluation.php', ['openID' => $evaluation->id, 'rangeID' => $range_id]) ?>"> - <?= Icon::create('admin', 'clickable')->asImg() ?> - </a> - <? if (!$evaluation->enddate || $evaluation->enddate > time()): ?> - <a title="<?= _("Evaluation stoppen") ?>" href="<?= URLHelper::getLink('admin_evaluation.php', ['evalID' => $evaluation->id, 'evalAction' => 'stop']) ?>"> - <?= Icon::create('pause', 'clickable')->asImg() ?> - </a> - <? else: ?> - <a title="<?= _("Evaluation fortsetzen") ?>" href="<?= URLHelper::getLink('admin_evaluation.php', ['evalID' => $evaluation->id, 'evalAction' => 'continue']) ?>"> - <?= Icon::create('play', 'clickable')->asImg() ?> - </a> - <? endif; ?> - <a title="<?= _("Evaluation löschen") ?>" href="<?= URLHelper::getLink('admin_evaluation.php', ['evalID' => $evaluation->id, 'evalAction' => 'delete_request']) ?>"> - <?= Icon::create('trash', 'clickable')->asImg() ?> - </a> - <a title="<?= _("Evaluation exportieren") ?>" href="<?= URLHelper::getLink('admin_evaluation.php', ['evalID' => $evaluation->id, 'evalAction' => 'export_request']) ?>"> - <?= Icon::create('export', 'clickable')->asImg() ?> - </a> - <a title="<?= _("Evaluation auswerten") ?>" href="<?= URLHelper::getLink('eval_summary.php', ['eval_id' => $evaluation->id]) ?>"> - <?= Icon::create('vote', 'clickable')->asImg() ?> - </a> - <? endif; ?> - </nav> - </header> - <section> - <?= formatReady($evaluation->text); ?> - </section> - <section> - <?= \Studip\LinkButton::create(_('Anzeigen'), URLHelper::getURL('show_evaluation.php', ['evalID' => $evaluation->id]), ['data-dialog' => '', 'target' => '_blank']) ?> - </section> - <footer> - <p> - <?= _('Teilnehmende') ?>: <?= $evaluation->getNumberOfVotes() ?> - </p> - <p> - <?= _('Anonym') ?>: <?= $evaluation->anonymous ? _('Ja') : _('Nein') ?> - </p> - <p> - <?= _('Endzeitpunkt') ?>: <?= $evaluation->enddate ? strftime('%d.%m.%y, %H:%M', $evaluation->enddate) : _('Unbekannt') ?> - </p> - </footer> -</article> diff --git a/app/views/evaluation/display.php b/app/views/evaluation/display.php deleted file mode 100644 index 35d31782741be132f7eb1b3dab42a04df8343c88..0000000000000000000000000000000000000000 --- a/app/views/evaluation/display.php +++ /dev/null @@ -1,27 +0,0 @@ -<? if ($admin || $evaluations): ?> -<article class="studip"> - <header> - <h1> - <?= Icon::create('vote', 'info')->asImg(); ?> - <?= _('Evaluationen') ?> - </h1> - <nav> - <? if ($admin): ?> - <a href="<?= URLHelper::getLink('admin_evaluation.php', ['rangeID' => $range_id]) ?>"> - <?= Icon::create('edit', 'clickable')->asImg(); ?> - </a> - <? endif; ?> - </nav> - </header> - - <? if (!$evaluations): ?> - <section> - <?= _('Keine Evaluationen vorhanden. Um neue Umfragen zu erstellen, klicken Sie rechts auf das Bearbeiten-Zeichen.') ?> - </section> - <? else: ?> - <? foreach ($evaluations as $evaluation): ?> - <?= $this->render_partial('evaluation/_evaluation.php', ['evaluation' => $evaluation]); ?> - <? endforeach; ?> - <? endif; ?> -</article> -<? endif; ?> diff --git a/app/views/institute/overview/index.php b/app/views/institute/overview/index.php index cb347b002d5e2abe30894568ed2762a7f531eb8b..3e80f98f481aff1d7ab022530074a36e601b32b7 100644 --- a/app/views/institute/overview/index.php +++ b/app/views/institute/overview/index.php @@ -50,7 +50,6 @@ </article> <?= $news ?> -<?= $evaluations ?> <?= $questionnaires ?> <? diff --git a/app/views/profile/index.php b/app/views/profile/index.php index 82a001a48af2c443c14e3a2e9d29858716ad2eae..b1911513eb9eabcc0ecc14c3c8f1d487a9cfb051 100644 --- a/app/views/profile/index.php +++ b/app/views/profile/index.php @@ -87,8 +87,6 @@ <?= $dates ?> -<?= $evaluations ?? '' ?> - <?= $questionnaires ?? '' ?> <? if (!empty($ausgabe_inhalt)) : ?> diff --git a/app/views/siteinfo/help.php b/app/views/siteinfo/help.php index 54d0d09f3533111be17636e9352399a2bd9372a8..e2a6762dc4212a4fbaf9d6843f0ddffb970e2d0f 100644 --- a/app/views/siteinfo/help.php +++ b/app/views/siteinfo/help.php @@ -59,7 +59,6 @@ <li>news</li> <li>vote</li> <li>test</li> - <li>evaluation</li> <li>wiki_pages</li> <li>lernmodul</li> <li>resource</li> diff --git a/composer.json b/composer.json index 18ffadb8a29a5c5239e03f5326c7e661ee8ae6c6..6a1190c8de830cfabb5ca1da5c10bc83e259e893 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,6 @@ "scssphp/scssphp": "1.12.1", "symfony/yaml": "^5.0", "ezyang/htmlpurifier": "^4.13", - "davefx/phplot": "^6.2", "jasig/phpcas": "1.5", "phpxmlrpc/phpxmlrpc": "^4.9.0", "phpxmlrpc/extras": "^1.0.0-beta2", diff --git a/composer.lock b/composer.lock index d47ed8c658cfda14df86f09222bde934ca327ffb..95d389af1f0efd0f58e053ee039487c33970e97b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "fcafb6aa7ae481f3523dda004973c010", + "content-hash": "73b508e157437e29fceffadbfa22aa2e", "packages": [ { "name": "algo26-matthias/idna-convert", @@ -190,45 +190,6 @@ }, "time": "2023-11-05T23:49:04+00:00" }, - { - "name": "davefx/phplot", - "version": "6.2.1", - "source": { - "type": "git", - "url": "https://github.com/davefx/PHPlot.git", - "reference": "d2e201ecaabb0428116c89cebe281a8f54096450" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/davefx/PHPlot/zipball/d2e201ecaabb0428116c89cebe281a8f54096450", - "reference": "d2e201ecaabb0428116c89cebe281a8f54096450", - "shasum": "" - }, - "require": { - "php": ">5.3.0" - }, - "type": "library", - "autoload": { - "classmap": [ - "phplot/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "LGPL" - ], - "description": "PHPlot - Create charts in PHP", - "homepage": "http://phplot.sourceforge.net", - "keywords": [ - "chart", - "phplot" - ], - "support": { - "issues": "https://github.com/davefx/PHPlot/issues", - "source": "https://github.com/davefx/PHPlot/tree/master" - }, - "time": "2016-10-19T07:14:15+00:00" - }, { "name": "defuse/php-encryption", "version": "v2.4.0", diff --git a/db/migrations/6.0.5_remove_old_evaluation.php b/db/migrations/6.0.5_remove_old_evaluation.php new file mode 100644 index 0000000000000000000000000000000000000000..ff1a26ea9d1b92a6f327764118afc44ec5fd204b --- /dev/null +++ b/db/migrations/6.0.5_remove_old_evaluation.php @@ -0,0 +1,33 @@ +<?php + +final class RemoveOldEvaluation extends Migration +{ + public function description() + { + return 'removes old evaluation tables'; + } + + public function up() + { + DBManager::get()->exec('DROP TABLE `eval`'); + DBManager::get()->exec('DROP TABLE `eval_group_template`'); + DBManager::get()->exec('DROP TABLE `eval_range`'); + DBManager::get()->exec('DROP TABLE `eval_templates`'); + DBManager::get()->exec('DROP TABLE `eval_templates_eval`'); + DBManager::get()->exec('DROP TABLE `eval_templates_user`'); + DBManager::get()->exec('DROP TABLE `eval_user`'); + DBManager::get()->exec('DROP TABLE `evalanswer`'); + DBManager::get()->exec('DROP TABLE `evalanswer_user`'); + DBManager::get()->exec('DROP TABLE `evalgroup`'); + DBManager::get()->exec('DROP TABLE `evalquestion`'); + + $query = "DELETE `config`, `config_values` + FROM `config` + LEFT JOIN `config_values` USING (`field`) + WHERE field IN ( + 'EVAL_AUSWERTUNG_GRAPH_FORMAT', + 'EVAL_ENABLE', 'EVAL_AUSWERTUNG_CONFIG_ENABLE' + )"; + DBManager::get()->exec($query); + } +} diff --git a/lib/bootstrap-autoload.php b/lib/bootstrap-autoload.php index 21219fd325eb4d704f66fdc0c9412b520a44a7b9..1f3f6d462b77bc3c7188d5573b9e1fe39a177ba8 100644 --- a/lib/bootstrap-autoload.php +++ b/lib/bootstrap-autoload.php @@ -50,8 +50,6 @@ StudipAutoloader::addAutoloadPath('lib/phplib'); StudipAutoloader::addAutoloadPath('lib/raumzeit'); StudipAutoloader::addAutoloadPath('lib/resources'); StudipAutoloader::addAutoloadPath('lib/activities', 'Studip\\Activity'); -StudipAutoloader::addAutoloadPath('lib/evaluation/classes'); -StudipAutoloader::addAutoloadPath('lib/evaluation/classes/db'); StudipAutoloader::addAutoloadPath('lib/extern'); StudipAutoloader::addAutoloadPath('lib/calendar/lib'); diff --git a/lib/classes/MyRealmModel.php b/lib/classes/MyRealmModel.php index 94bb30d8109e9c0029469e4f71fc6242e9951f56..ab9aa20877e2574740689a03cfc440ccf4f9073a 100644 --- a/lib/classes/MyRealmModel.php +++ b/lib/classes/MyRealmModel.php @@ -93,35 +93,6 @@ class MyRealmModel } } - $sql = "SELECT COUNT(a.eval_id) as count, - COUNT(IF((chdate > IFNULL(b.visitdate, :threshold) AND d.author_id !=:user_id ), a.eval_id, NULL)) AS neue, - MAX(IF ((chdate > IFNULL(b.visitdate, :threshold) AND d.author_id != :user_id), chdate, 0)) AS last_modified - FROM eval_range a - INNER JOIN eval d - ON (a.eval_id = d.eval_id AND d.startdate < UNIX_TIMESTAMP() AND (d.stopdate > UNIX_TIMESTAMP() OR d.startdate + d.timespan > UNIX_TIMESTAMP() OR (d.stopdate IS NULL AND d.timespan IS NULL))) - LEFT JOIN object_user_visits b - ON (b.object_id = a.eval_id AND b.user_id = :user_id AND b.plugin_id = :plugin_id) - WHERE a.range_id = :course_id - GROUP BY a.range_id"; - - $statement = DBManager::get()->prepare($sql); - $statement->bindValue(':user_id', $user_id); - $statement->bindValue(':course_id', $object_id); - $statement->bindValue(':threshold', object_get_visit_threshold()); - $statement->bindValue(':plugin_id', -2); - $statement->execute(); - $result = $statement->fetch(PDO::FETCH_ASSOC); - if (!empty($result)) { - $count += $result['count']; - $neue += $result['neue']; - if (isset($my_obj['last_modified'], $result['last_modified']) && $result['last_modified']) { - if ($my_obj['last_modified'] < $result['last_modified']) { - $my_obj['last_modified'] = $result['last_modified']; - } - } - } - - if ($neue || $count > 0) { $nav = new Navigation('vote', '#vote'); if ($neue) { @@ -506,17 +477,13 @@ class MyRealmModel // load plugins, so they have a chance to register themselves as observers PluginEngine::getPlugins('StandardPlugin'); - // Update news, votes and evaluations + // Update news and votes $query = "INSERT INTO object_user_visits (object_id, user_id, plugin_id, visitdate, last_visitdate) ( SELECT questionnaire_id, :user_id, '-1', :timestamp, 0 FROM questionnaire_assignments WHERE range_id = :id - ) UNION ( - SELECT eval_id, :user_id, '-2', :timestamp, 0 - FROM eval_range - WHERE range_id = :id ) UNION ( SELECT `news_id`, :user_id, `pluginid`, :timestamp, 0 FROM `news_range` diff --git a/lib/classes/Privacy.php b/lib/classes/Privacy.php index 38e6e80c4afac49753e4920c2aa336f441cc9edc..0ba296a52c3f830dc857de3ab1307e22093bdfd6 100644 --- a/lib/classes/Privacy.php +++ b/lib/classes/Privacy.php @@ -59,7 +59,6 @@ class Privacy Courseware\UserProgress::class, ], 'quest' => [ - Evaluation::class, Questionnaire::class, QuestionnaireAnswer::class, QuestionnaireAnonymousAnswer::class, diff --git a/lib/classes/Siteinfo.php b/lib/classes/Siteinfo.php index 247b836867dad7bb172dc0d0e2604278949de57b..9043ce36db8962773bf84babe56afce21f68dcbe 100644 --- a/lib/classes/Siteinfo.php +++ b/lib/classes/Siteinfo.php @@ -576,10 +576,6 @@ class SiteinfoMarkupEngine { "title" => _("Fragebögen"), "detail" => "", "constraint" => Config::get()->VOTE_ENABLE]; - $indicator['evaluation'] = ["count" => ['count_table_rows','eval'], - "title" => _("Evaluationen"), - "detail" => "", - "constraint" => Config::get()->VOTE_ENABLE]; $indicator['wiki_pages'] = ["query" => "SELECT COUNT(*) AS count FROM wiki_pages", "title" => _("Wiki-Seiten"), "detail" => "", diff --git a/lib/classes/UserManagement.class.php b/lib/classes/UserManagement.class.php index e3d9aa38be2be383085413dfdb79df90d057465b..780559415e4aca5ff7c437ac7d880150f897677b 100644 --- a/lib/classes/UserManagement.class.php +++ b/lib/classes/UserManagement.class.php @@ -1209,8 +1209,6 @@ class UserManagement "DELETE FROM priorities WHERE user_id = ?", "DELETE FROM api_oauth_user_mapping WHERE user_id = ?", "DELETE FROM api_user_permissions WHERE user_id = ?", - "DELETE FROM eval_user WHERE user_id = ?", - "DELETE FROM evalanswer_user WHERE user_id = ?", "DELETE FROM help_tour_user WHERE user_id = ?", "DELETE FROM personal_notifications_user WHERE user_id = ?", "DELETE FROM forum_abo_users WHERE user_id = ?", diff --git a/lib/evaluation/classes/Evaluation.class.php b/lib/evaluation/classes/Evaluation.class.php deleted file mode 100644 index 5f269a78212d3ffdd130debcdfc68a60aa19eba8..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/Evaluation.class.php +++ /dev/null @@ -1,539 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EVALDB; -require_once EVAL_FILE_OBJECT; -require_once EVAL_FILE_GROUP; -# ====================================================== end: including files # - - -# Define all required constants ============================================= # -/** - * @const INSTANCEOF_EVAL Is instance of an evaluation object - * @access public - */ -define("INSTANCEOF_EVAL", "Evaluation"); -# ===================================================== end: define constants # - - -/** - * The mainclass for an evaluation for the Stud.IP-project. - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class Evaluation extends EvaluationObject implements PrivacyObject -{ -# Define all required variables ============================================= # - /** - * Startdate - * @access private - * @var integer $startdate - */ - var $startdate; - - /** - * Stopdate - * @access private - * @var integer $stopdate - */ - var $stopdate; - - /** - * Timespan - * @access private - * @var integer $timespan - */ - var $timespan; - - /** - * Time of creation. Is set automatically. - * @access private - * @var integer $mkdate - */ - var $mkdate; - - /** - * Time of last change. Is set automatically. - * @access private - * @var integer $chdate - */ - var $chdate; - - /** - * Defines wheter the evaluation is anonymous - * @access private - * @var boolean $anonymous - */ - var $anonymous; - - /** - * Defines whether the evaluation is visible - * @access private - * @var boolean $visible - */ - var $visible; - - /** - * Defines whether the evaluation template is shared - * @access private - * @var boolean $shared - */ - var $shared; - - /** - * Counts the number of connected ranges - * @access private - * @var integer $numberRanges - */ - var $numberRanges; - - /** - * Counts the number of connected ranges - * @access private - * @var integer $rangeNum - */ - var $rangeNum; - - /** - * Constructor - * @access public - * @param string $objectID The ID of an existing evaluation - * @param object $parentObject The parent object if exists - * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN - */ - public function __construct($objectID = "", $parentObject = null, $loadChildren = EVAL_LOAD_NO_CHILDREN) - { - parent::__construct($objectID, $parentObject, $loadChildren); - $this->instanceof = INSTANCEOF_EVAL; - - $this->rangeID = []; - $this->startdate = NULL; - $this->stopdate = NULL; - $this->timespan = NULL; - $this->mkdate = time(); - $this->chdate = time(); - $this->anonymous = NO; - $this->visible = NO; - $this->shared = NO; - $this->rangeNum = 0; - $this->db = new EvaluationDB (); - if ($this->db->isError()) { - return $this->throwErrorFromClass($this->db); - } - $this->init($objectID); - } - - /** - * Sets the startdate - * @access public - * @param integer $startdate The startdate. - * @throws error - */ - public function setStartdate($startdate) - { - if (!empty ($startdate)) { - if (!empty ($this->stopdate) && $startdate > $this->stopdate) { - return $this->throwError(1, _("Das Startdatum ist nach dem Stoppdatum.")); - } - if ($startdate <= 0) { - return $this->throwError(1, _("Das Startdatum ist leider ungültig.")); - } - } - $this->startdate = $startdate; - } - - /** - * Gets the startdate - * @access public - * @return integer The startdate - */ - public function getStartdate() - { - return $this->startdate; - } - - /** - * Sets the stopdate - * @access public - * @param integer $stopdate The stopdate. - * @throws error - */ - public function setStopdate($stopdate) - { - if (!empty ($stopdate)) { - if ($stopdate <= 0) - return $this->throwError(1, _("Das Stoppdatum ist leider ungültig.")); - if ($stopdate < $this->startdate) - return $this->throwError(1, _("Das Stoppdatum ist vor dem Startdatum.")); - if (!empty ($this->timespan)) - $this->timespan = NULL; - } - $this->stopdate = $stopdate; - } - - /** - * Gets the stopdate - * @access public - * @return string The stopdate - */ - public function getStopdate() - { - return $this->stopdate; - } - - /** - * Gets the real stop date as a UNIX-timestamp (e.g. startdate + timespan) - * @access public - * @return integer The UNIX-timestamp with the real stopdate - */ - public function getRealStopdate() - { - $stopdate = $this->getStopdate(); - - if ($this->getTimespan() != NULL) - $stopdate = $this->getStartdate() + $this->getTimespan(); - - return $stopdate; - } - - /** - * Sets the timespan - * @access public - * @param string $timespan The timespan. - * @throws error - */ - public function setTimespan($timespan) - { - if (!empty ($timespan) && !empty ($this->stopdate)) - $this->stopdate = NULL; - $this->timespan = $timespan; - } - - /** - * Gets the timespan - * @access public - * @return string The timespan - */ - public function getTimespan() - { - return $this->timespan; - } - - /** - * Gets the creationdate - * @access public - * @return integer The creationdate - */ - public function getCreationdate() - { - return $this->mkdate; - } - - /** - * Gets the changedate - * @access public - * @return integer The changedate - */ - public function getChangedate() - { - return $this->chdate; - } - - /** - * Sets anonymous - * @access public - * @param string $anonymous The anonymous. - * @throws error - */ - public function setAnonymous($anonymous) - { - $this->anonymous = $anonymous == YES ? YES : NO; - } - - /** - * Gets anonymous - * @access public - * @return string The anonymous - */ - public function isAnonymous() - { - return $this->anonymous == YES ? YES : NO; - } - - /** - * Sets visible - * @access public - * @param string $visible The visible. - * @throws error - */ - public function setVisible($visible) - { - $this->visible = $visible == YES ? YES : NO; - } - - /** - * Gets visible - * @access public - * @return string The visible - */ - public function isVisible() - { - return $this->visible == YES ? YES : NO; - } - - /** - * Set shared for a public search - * @access public - * @param boolean $shared if true it is shared - */ - public function setShared($shared) - { - if ($shared == YES && $this->isTemplate() == NO) - return $this->throwError(1, _("Nur ein Template kann freigegeben werden")); - $this->shared = $shared == YES ? YES : NO; - } - - /** - * Is shared for a public search? - * @access public - * @return boolen true if it is shared template - */ - public function isShared() - { - return $this->shared == YES ? YES : NO; - } - - /** - * Is this evaluation a template? - * @access public - * @return boolen true if it is a template - */ - public function isTemplate() - { - return empty ($this->rangeID) ? YES : NO; - } - - /** - * Has a user used this evaluation? - * @access public - * @param string $userID Optional an user id - * @return string YES if a user used this evaluation - */ - public function hasVoted($userID = "") - { - return $this->db->hasVoted($this->getObjectID(), $userID); - } - - /** - * Removes a range from the object (not from the DB!) - * @access public - * @param string $rangeID The range id - */ - public function removeRangeID($rangeID) - { - $temp = []; - while ($oldRangeID = $this->getNextRangeID()) { - if ($oldRangeID != $rangeID) { - $temp[] = $oldRangeID; - } - } - $this->rangeID = $temp; - $this->numberRanges = count($temp); - } - - /** - * Removes all rangeIDs - * @access public - */ - public function removeRangeIDs() - { - while ($this->getRangeID()) ; - } - - /** - * Adds a rangeID - * @access public - * @param string $rangeID The rangeID - * @throws error - */ - public function addRangeID($rangeID) - { - $this->rangeID[] = $rangeID; - $this->numberRanges++; - } - - /** - * Gets the first rangeID and removes it - * @access public - * @return string The first object - */ - public function getRangeID() - { - if ($this->numberRanges) - $this->numberRanges--; - return array_pop($this->rangeID); - } - - /** - * Gets the next rangeID - * @access public - * @return string The rangeID - */ - public function getNextRangeID() - { - if ($this->rangeNum >= $this->numberRanges) { - $this->rangeNum = 0; - return NULL; - } - return $this->rangeID[$this->rangeNum++]; - } - - /** - * Gets all the rangeIDs from the evaluation - * @access public - * @return array An array full of rangeIDs - */ - public function getRangeIDs() - { - return $this->rangeID; - } - - /** - * Gets the number of ranges - * @access public - * @return integer Number of ranges - */ - public function getNumberRanges() - { - return $this->numberRanges; - } - - /** - * Resets all answers for this evaluation - * @access public - */ - public function resetAnswers() - { - // Für diesen Mist habe ich jetzt ca. 3 Stunden gebraucht :( - $answers = $this->getSpecialChildobjects($this, INSTANCEOF_EVALANSWER); - - $number = count($answers); - for ($i = 0; $i < $number; $i++) { - $answer = &$answers[$i]; -#while ($answer->getUserID ()); // delete users... - $answer->db->resetVotes($answer); - } - - } - - /** - * Export available data of a given user into a storage object - * (an instance of the StoredUserData class) for that user. - * - * @param StoredUserData $storage object to store data into - */ - public static function exportUserData(StoredUserData $storage) - { - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval WHERE author_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('Evaluation'), 'eval', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM evalanswer_user WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationAnswerUser'), 'evalanswer_user', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval_group_template WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationGroupTemplate'), 'eval_group_template', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval_templates WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationTemplates'), 'eval_templates', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval_templates_user WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationTemplatesUser'), 'eval_templates_user', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval_user WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationUser'), 'eval_user', $field_data); - } - - } - - /** - * Sets the creationdate - * @access private - * @param integer $creationdate The creationdate. - * @throws error - */ - public function setCreationdate($creationdate) - { - $this->mkdate = $creationdate; - } - - /** - * Sets the changedate - * @access private - * @param integer $changedate The changedate. - * @throws error - */ - public function setChangedate($changedate) - { - $this->chdate = $changedate; - } - - /** - * Checks if object is in a valid state - * @access private - */ - public function check() - { - parent::check(); - if (empty ($this->title)) { - $this->throwError(1, _("Der Titel darf nicht leer sein.")); - } - - if ($this->isTemplate() && $this->hasVoted()) { - $this->throwError(2, _("Ungültiges Objekt: Bei einer Vorlage wurde abgestimmt.")); - } - - if (!$this->isTemplate() && $this->isShared()) { - $this->throwError(3, _("Ungültiges Objekt: Eine aktive Evaluation wurde freigegeben.")); - } - - } -} diff --git a/lib/evaluation/classes/EvaluationAnswer.class.php b/lib/evaluation/classes/EvaluationAnswer.class.php deleted file mode 100644 index 0116e3b46311475891e63adfcd6dd555f77f3b37..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationAnswer.class.php +++ /dev/null @@ -1,277 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_ANSWERDB; -require_once EVAL_FILE_OBJECT; - -/** - * @const INSTANCEOF_EVALANSWER Is instance of an evaluationanswer object - * @access public - */ -define("INSTANCEOF_EVALANSWER", "EvaluationAnswer"); - -class EvaluationAnswer extends EvaluationObject -{ - - /** - * The value for an answer - * @access private - * @var integer $value ; - */ - var $value; - - /** - * If >0 the answer is a freetext with $rows rows - * @access private - * @var integer $rows - */ - var $rows; - - /** - * The userIDs of users who voted for this answer - * @access private - * @var array $users - */ - var $users; - - /** - * The number of users voted for this answer - * @access private - * @var integer $userNum - */ - var $userNum; - - /** - * For internal use (getNextUserID) - * @access private - * @var integer $userNumIterator - */ - var $userNumIterator; - - /** - * If true this is the residual answer for a question - * @access private - * @var boolean $residual - */ - var $residual; - - /** - * Constructor - * @access public - * @param string $objectID The ID of an existing answer - * @param object $parentObject The parent object if exists - * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN - */ - public function __construct($objectID = "", $parentObject = null, $loadChildren = EVAL_LOAD_NO_CHILDREN) - { - /* Set default values ------------------------------------------------- */ - parent::__construct($objectID, $parentObject, $loadChildren); - $this->instanceof = INSTANCEOF_EVALANSWER; - - $this->value = 0; - $this->rows = 0; - $this->users = []; - $this->userNum = 0; - $this->userNumIterator = 0; - $this->residual = NO; - - $this->db = new EvaluationAnswerDB (); - if ($this->db->isError()) { - return $this->throwErrorFromClass($this->db); - } - $this->init($objectID); - - } - - /** - * Gets the number of votes for this answer - * @access public - * @return string The counter of the answer - */ - public function getNumberOfVotes() - { - return $this->userNum; - } - - /** - * Gets the number of rows from freetext answers - * @access public - * @return integer The number of rows - */ - public function getRows() - { - return $this->rows; - } - - /** - * Gets the number of rows for freetext answers - * @access public - * @param integer $rows The number of rows - */ - public function setRows($rows) - { - $this->rows = $rows; - } - - /** - * Gets the value of an answer - * @access public - * @return integer The value - */ - public function getValue() - { - return $this->value;; - } - - /** - * Sets the value of an answer - * @access public - * @param integer $value The value - */ - public function setValue($value) - { - $this->value = $value; - } - - /** - * Checks whether the answer is a residual answer - * @access public - * @return boolean YES if it is a residual answer - */ - public function isResidual() - { - return $this->residual == YES ? YES : NO; - } - - /** - * Sets the answers as an residual answer - * @access public - * @param boolean $boolean YES to set it as a residual answer - */ - public function setResidual($boolean) - { - $this->residual = $boolean == YES ? YES : NO; - } - - /** - * Vote for this answer - * @access public - * @param string $userID The user id - */ - public function vote($userID) - { - $this->addUserID($userID); - } - - /** - * Non-Anonymous vote for this answer - * @access public - * @param string $userID The user id - */ - public function addUserID($userID) - { - if (empty ($userID)) { - return $this->throwError(1, _("Nur pseudonyme Abstimmung erlaubt! Neue ID mit StudipObject::createNewID () erzeugen")); - } - - $this->userNum++; - array_push($this->users, $userID); - } - - /** - * Gets the first user and removes it - * @access public - * @return string The first user id - */ - public function getUserID() - { - if ($this->userNum > 0) - $this->userNum--; - return array_pop($this->users); - } - - /** - * Gets the next user - * @access public - * @return string The next user id, otherwise NULL - */ - public function getNextUserID() - { - if ($this->userNumIterator >= $this->userNum) { - $this->userNumIterator = 0; - return NULL; - } - return $this->users[$this->userNumIterator++]; - } - - /** - * Gets all the user ids - * @access public - * @return array An array full of user ids - */ - public function getUserIDs() - { - return $this->users; - } - - /** - * @access public - * @return integer YES, if the Answer is a textfield - */ - public function isFreetext() - { - return ($this->rows == 0) ? NO : YES; - } - - /** - * Checks if object is in a valid state - * @access private - */ - public function check() - { - parent::check(); - } - - /** - * Debugfunction - * @access private - */ - public function toString() - { - parent::toString(); - echo "Anzahl der Stimmen: " . $this->getNumberOfVotes() . "<br>\n"; - } -} diff --git a/lib/evaluation/classes/EvaluationExportManager.class.php b/lib/evaluation/classes/EvaluationExportManager.class.php deleted file mode 100644 index 0c88e7f2dd6407c46760c9688c922d5ea18c3354..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationExportManager.class.php +++ /dev/null @@ -1,267 +0,0 @@ -<?php -# Lifter002: TEST -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EVALDB; -require_once EVAL_FILE_ANSWERDB; -require_once EVAL_FILE_OBJECT; -require_once EVAL_FILE_GROUP; - -/** - * @const INSTANCEOF_EVALEXPORTMANAGER Is instance of an export manager - * @access public - */ -define("INSTANCEOF_EVALEXPORTMANAGER", "EvaluationExportManager"); - -/** - * @const EVALEXPORT_PREFIX The prefix for temporary filenames - * @access public - */ -define("EVALEXPORT_PREFIX", "evaluation"); - -/** - * @const EVALEXPORT_LIFETIME The lifetime in seconds for temporary files - * @access public - */ -define("EVALEXPORT_LIFETIME", 1800); - - -/** - * The mainclass for the evaluation export manager - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationExportManager extends AuthorObject -{ - - /** - * The temporary filename - * @access private - * @var string $filename - */ - public $filename; - - /** - * The filehandle for the temporary filename - * @access private - * @public integer $filehandle - */ - public $filehandle; - - /** - * The ID for the evaluation to export - * @access private - * @var string $evalID - */ - public $evalID; - - /** - * The evaluation to export - * @access private - * @var object Evaluation $eval - */ - public $eval; - - /** - * Array full of questionobjects - * @access private - * @var array $evalquestions - */ - public $evalquestions; - - /** - * The extension for the FILENAME - * @access private - * @var string $extension - */ - public $extension; - - /** - * UserIDs of all persons which used the evaluation - * @access private - * @var array $users - */ - public $users; - - /** - * Constructor - * @access public - * @param string $evalID The ID of the evaluation for export - */ - public function __construct($evalID) - { - register_shutdown_function([&$this, "_EvaluationExportManager"]); - - parent::__construct(); - $this->instanceof = INSTANCEOF_EVALEXPORTMANAGER; - - $this->filename = ""; - $this->filehandle = ""; - $this->evalID = $evalID; - $this->eval = new Evaluation ($evalID, NULL, EVAL_LOAD_FIRST_CHILDREN); - $this->evalquestions = []; - $this->extension = EVALEXPORT_EXTENSION; - - $this->createNewFile(); - $this->getQuestionobjects($this->eval); - /* -------------------------------------------------------------------- */ - } - - /** - * Destructor. Closes all files and removes old temp files - * @access public - */ - public function _EvaluationExportManager() - { - $this->closeFile(); - $this->cleanUp(); - } - - /** - * Returns the temnporary filename - * @access public - * @returns string The temporary filename - */ - public function getTempFilename() - { - return $this->filename; - } - - /** - * Exports the evaluation - * @access public - */ - public function export() - { - if (empty ($this->filehandle)) { - return $this->throwError(1, _("ExportManager::Konnte temporäre Datei nicht öffnen.")); - } - - if (!$this->eval->isAnonymous()) { - $this->users = EvaluationDB::getUserVoted($this->eval->getObjectID()); - } else { - $questions = $this->eval->getSpecialChildobjects($this->eval, INSTANCEOF_EVALQUESTION); - $questionIDs = []; - foreach ($questions as $question) { - array_push($questionIDs, $question->getObjectID()); - } - $this->users = EvaluationDB::getUserVoted($this->eval->getObjectID(), null, $questionIDs); - } - - if (empty ($this->users)) { - return $this->throwError(1, _("ExportManager::Es haben noch keine Benutzer abgestimmt oder angegebene Evaluation existiert nicht.")); - } - } - - /** - * Gets the filname for the user - * @access public - */ - public function getFilename() - { - return (rawurlencode($this->eval->getTitle()) . "." . $this->extension); - } - - /** - * Gets all questionobjects of the evaluation - * @access private - * @param EvaluationObject &$object An evaluationobject object - */ - public function getQuestionobjects(&$object) - { - if ($object->x_instanceof() == INSTANCEOF_EVALQUESTION) { - array_push($this->evalquestions, $object); - } else { - while ($child = $object->getNextChild()) { - $this->getQuestionobjects($child); - } - } - } - - /** - * Closes all opened files - * @access public - */ - public function closeFile() - { - if (empty($this->filehandle)) { - return $this->throwError(1, _("ExportManager::Konnte temporäre Datei nicht schließen.")); - } - - fclose($this->filehandle); - } - - /** - * Removes old temporary files - * @access private - */ - public function cleanUp() - { - if (empty ($this->filehandle)) { - return $this->throwError(1, _("ExportManager::Konnte temporäre Datei nicht öffnen.")); - } - - $dirhandle = dir($GLOBALS['TMP_PATH']); - while (($file = $dirhandle->read()) != false) { - $file = $GLOBALS['TMP_PATH'] . "/" . $file; - $part = pathinfo($file); - - if (filemtime($file) < (time() - EVALEXPORT_LIFETIME) && - $part["extension"] == $this->extension && - mb_substr($part["basename"], 0, mb_strlen(EVALEXPORT_PREFIX)) == EVALEXPORT_PREFIX) - unlink($file); - } - $dirhandle->close(); - } - - /** - * Creates a new temporary file - * @access public - */ - public function createNewFile() - { - $randomID = StudipObject::createNewID(); - $this->filename = $randomID . "." . $this->extension; - if (!is_dir($GLOBALS['TMP_PATH'])) { - return $this->throwError(1, sprintf(_("ExportManager::Das Verzeichnis %s existiert nicht."), $GLOBALS['TMP_PATH'])); - } - if (!is_writable($GLOBALS['TMP_PATH'])) { - return $this->throwError(2, sprintf(_("ExportManager::Das Verzeichnis %s ist nicht schreibbar nicht."), $GLOBALS['TMP_PATH'])); - } - - $this->filehandle = @fopen($GLOBALS['TMP_PATH'] . "/" . $this->filename, "w"); - - if (empty ($this->filehandle)) { - return $this->throwError(3, _("ExportManager::Konnte temporäre Datei nicht erstellen.")); - } - } - -} - diff --git a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php b/lib/evaluation/classes/EvaluationExportManagerCSV.class.php deleted file mode 100644 index 4baa3f8677e5f04a0b239f782f7f12703e38977f..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php +++ /dev/null @@ -1,341 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EXPORTMANAGER; -# ====================================================== end: including files # - - -# Define all required constants ============================================= # -/** - * @const INSTANCEOF_EVALEXPORTMANAGER Is instance of an export manager - * @access public - */ -define ("INSTANCEOF_EVALEXPORTMANAGERCSV", "EvaluationExportManagerCSV"); - -/** - * @const EVALEXPORT_SEPERATOR The seperator for values - * @access public - */ -define ("EVALEXPORT_SEPERATOR", ";"); - -/** - * @const EVALEXPORT_DELIMITER The delimiter for values - * @access public - */ -define ("EVALEXPORT_DELIMITER", "\""); - -/** - * @const EVALEXPORT_NODELIMITER Character to substitute the delimiter in a text - * @access public - */ -define ("EVALEXPORT_NODELIMITER", "'"); - -/** - * @const EVALEXPORT_ENDROW The characters to end a row - * @access public - */ -define ("EVALEXPORT_ENDROW", EVALEXPORT_DELIMITER.EVALEXPORT_DELIMITER."\n"); - -/** - * @const EVALEXPORT_EXTENSION The extension for the filenames - * @access public - */ -define ("EVALEXPORT_EXTENSION", "csv"); -# ===================================================== end: define constants # - - -/** - * The mainclass for the evaluation export manager - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationExportManagerCSV extends EvaluationExportManager { -# Define all required variables ============================================= # - var $evalquestions_residual = []; -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param string $evalID The ID of the evaluation for export - */ - function __construct($evalID) { - /* Set default values ------------------------------------------------- */ - register_shutdown_function([&$this, "_EvaluationExportManagerCSV"]); - ini_set('memory_limit', '256M'); - parent::__construct($evalID); - $this->instanceof = INSTANCEOF_EVALEXPORTMANAGERCSV; - - $this->extension = EVALEXPORT_EXTENSION; - /* -------------------------------------------------------------------- */ - } - - /** - * Destructor. Closes all files and removes old temp files - * @access public - */ - function _EvaluationExportManagerCSV () { - - } -# =========================================== end: constructor and destructor # - - -# Define public functions =================================================== # - /** - * Exports the evaluation - * @access public - */ - function export () { - parent::export (); - if ($this->isError ()) - return; - $this->exportHeader (); - $this->exportContent(); - } - - /** - * Exports the headline - * @access public - */ - function exportHeader () { - if (empty ($this->filehandle)) - return $this->throwError (1, _("ExportManager::Konnte temporäre Datei nicht öffnen.")); - fputs ($this->filehandle, "\xEF\xBB\xBF"); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Nummer") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Datum") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Benutzername") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Nachname") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Vorname") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("E-Mail") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - - /* for each question -------------------------------------------------- */ - foreach ($this->evalquestions as $evalquestion) { - $type = $evalquestion->getType (); - $residual = ""; - - /* Questiontype: likert scale -------------------------------------- */ - if ($type == EVALQUESTION_TYPE_LIKERT) { - EvaluationAnswerDB::addChildren($evalquestion); - $header = $evalquestion->getText ().":"; - while ($answer = &$evalquestion->getNextChild ()) { - if ($answer->isResidual ()) { - $residual = $evalquestion->getText ().":".$answer->getText (); - } else { - $header .= $answer->getText (); - $header .= "(".$answer->getPosition ().")"; - $header .= ","; - } - } - $header = mb_substr ($header, 0, mb_strlen ($header) - 1); - - $this->addCol ($header); - - if (!empty ($residual)) { - $this->addCol ($residual); - $this->evalquestions_residual[$evalquestion->getObjectID()] = true; - } - /* ----------------------------------------------------- end: likert */ - - - /* Questiontype: pol scale ----------------------------------------- */ - } elseif ($type == EVALQUESTION_TYPE_POL) { - EvaluationAnswerDB::addChildren($evalquestion); - $header = $evalquestion->getText ().":"; - $answer = $evalquestion->getNextChild (); - $header .= $answer->getText (); - $header .= "(".$answer->getPosition ().")"; - $header .= "-"; - while ($answer = &$evalquestion->getNextChild ()) { - if ($answer->isResidual ()) - $residual = $evalquestion->getText ().":".$answer->getText (); - else - $last = $answer->getText ()."(".$answer->getPosition ().")"; - } - $header .= $last; - $this->addCol ($header); - if (!empty ($residual)) { - $this->addCol ($residual); - $this->evalquestions_residual[$evalquestion->getObjectID()] = true; - } - /* -------------------------------------------------------- end: pol */ - - - /* Questiontype: multiple chioice ---------------------------------- */ - } elseif ($type == EVALQUESTION_TYPE_MC) { - if ($evalquestion->isMultiplechoice ()) { - EvaluationAnswerDB::addChildren($evalquestion); - while ($answer = &$evalquestion->getNextChild ()) { - $header = $evalquestion->getText (); - $header .= ":".$answer->getText (); - $this->addCol ($header); - } - } else { - $header = $evalquestion->getText (); - $this->addCol ($header); - } - /* --------------------------------------------------------- end: mc */ - - - /* Questiontype: undefined ----------------------------------------- */ - } else { - return $this->throwError (2, _("ExportManager::Ungültiger Typ.")); - } - /* -------------------------------------------------- end: undefined */ - } - /* ---------------------------------------------- end: foreach question */ - - fputs ($this->filehandle, EVALEXPORT_ENDROW); - } - - /** - * Exports the content - * @access public - */ - function exportContent () { - $counter = 0; - $answers = []; - $db = DBManager::get(); - $stmt = $db->prepare("SELECT user_id,text,value,position,residual, - MAX(evaldate) as evaldate, - GROUP_CONCAT(evalanswer_id) as evalanswer_id - FROM evalanswer - INNER JOIN evalanswer_user - USING ( evalanswer_id ) - WHERE parent_id = ? GROUP BY user_id"); - foreach ($this->evalquestions as $evalquestion) { - $stmt->execute([$evalquestion->getObjectID()]); - $answers[$evalquestion->getObjectID()] = $stmt->fetchGrouped(); - } - - /* One row for each user --------------------------------------------- */ - foreach ($this->users as $userID) { - - /* Userinformation if available ----------------------------------- */ - $username = ""; - $name = ""; - $surname = ""; - $email = ""; - $evaldate = ""; - if (!$this->eval->isAnonymous ()) { - $data = DBManager::get()->query("SELECT username, Vorname, Nachname, Email " - . "FROM auth_user_md5 WHERE user_id = " - . DBManager::get()->quote($userID))->fetchAll(PDO::FETCH_NUM); - if (is_array($data[0])) { - list($username, $name, $surname, $email) = $data[0]; - } - } - if ($timestamp = $answers[$this->evalquestions[0]->getObjectID()][$userID]['evaldate']) { - $evaldate = date('Y-m-d H:i:s', $timestamp); - } - fputs ($this->filehandle, EVALEXPORT_DELIMITER . ++$counter . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $evaldate . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $username . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $surname . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $name . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $email . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - - /* ------------------------------------------------- end: user info */ - - /* One colum for each question ------------------------------------ */ - foreach ($this->evalquestions as $evalquestion) { - $type = $evalquestion->getType (); - - /* Questiontype: pol or likert scale --------------------------- */ - if ($type == EVALQUESTION_TYPE_LIKERT || - $type == EVALQUESTION_TYPE_POL) { - $hasResidual = $this->evalquestions_residual[$evalquestion->getObjectID()]; - $entry = ""; - $residual = 0; - if ($answer = $answers[$evalquestion->getObjectID()][$userID]) { - if ($answer['residual']) { - $residual = 1; - } else { - $entry = $answer['position']; - } - } - $this->addCol ($entry); - - if ($hasResidual) { - $this->addCol ($residual); - } - } - /* ------------------------------------------------- end: likert */ - - - /* Questiontype: multiple chioice ------------------------------ */ - elseif ($type == EVALQUESTION_TYPE_MC) { - if ($evalquestion->isMultiplechoice ()) { - $mc_answers = explode(',', $answers[$evalquestion->getObjectID()][$userID]['evalanswer_id']); - while ($answer = &$evalquestion->getNextChild ()) { - $this->addCol ((int)in_array($answer->getObjectID(), $mc_answers)); - } - } else { - $entry = ""; - if ($answer = $answers[$evalquestion->getObjectID()][$userID]) { - $entry = preg_replace ("(\r\n|\n|\r)", " ", $answer['text']); - } - $this->addCol ($entry); - } - } - /* ------------------------------------------------------ end: mc */ - - - /* Questiontype: undefined -------------------------------------- */ - else { - return $this->throwError (1, _("ExportManager::Ungültiger Fragetyp.")); - } - /* ----------------------------------------------- end: undefined */ - } - /* ------------------------------------------ end: col for question */ - - fputs ($this->filehandle, EVALEXPORT_ENDROW); - } - /* -------------------------------------------- end: row for each user */ - } -# ===================================================== end: public functions # - -# Define private functions ================================================== # - /** - * Adds a row for the text - * @param string $text The text for the row - * @access private - */ - function addCol ($text) { - $col = str_replace (EVALEXPORT_DELIMITER, EVALEXPORT_NODELIMITER, $text); - fputs ($this->filehandle, EVALEXPORT_DELIMITER.$col.EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - } -# ==================================================== end: private functions # - -} - -?> diff --git a/lib/evaluation/classes/EvaluationGroup.class.php b/lib/evaluation/classes/EvaluationGroup.class.php deleted file mode 100644 index fbe84af3bc6736d77d59e11c206eb74cc6fa0815..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationGroup.class.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_GROUPDB; -require_once EVAL_FILE_OBJECT; -require_once EVAL_FILE_QUESTION; -# ====================================================== end: including files # - - -# Define constants ========================================================== # -/** - * @const INSTANCEOF_EVALGROUP Is instance of an evaluationgroup object - * @access public - */ -define ("INSTANCEOF_EVALGROUP", "EvaluationGroup"); -# ===================================================== end: define constants # - - -/** - * This class provides a group for an evaluation for the Stud.IP-project. - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ - -class EvaluationGroup extends EvaluationObject { - -#Define all required variables ============================================= # - /** - * Possible Type of thechildren - * @access private - * @var string $childType - */ - var $childType; - - /** - * Is it mandatory to answer sub questions - * @access private - * @var boolean $mandatory - */ - var $mandatory; - - /** - * ID of the templateID for the childs - * @access private - * @var string $templateID - */ - var $templateID; -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param string $objectID The ID of an existing group - * @param EvaluationObject $parentObject The parent object if exists - * @param string $loadChildren See const EVAL_LOAD_*_CHILDREN - */ - function __construct($objectID = "", $parentObject = null, - $loadChildren = EVAL_LOAD_NO_CHILDREN) { - /* Set default values ------------------------------------------------- */ - parent::__construct($objectID, $parentObject, $loadChildren); - $this->instanceof = INSTANCEOF_EVALGROUP; - - $this->childType = NULL; - $this->mandatory = NO; - /* --------------------------------------------------------------------- */ - - /* Connect to database ------------------------------------------------- */ - $this->db = new EvaluationGroupDB (); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - $this->init ($objectID); - /* --------------------------------------------------------------------- */ - } -# =========================================== end: constructor and destructor # - -# Define public functions =================================================== # - /** - * Returns wheter the childs are groups or questions - * @access public - */ - function getChildType () { - return $this->childType; - } - - /** - * Adds a child - * @access public - * @param object EvaluationObject &$child The child object - */ - function addChild (&$child) { - parent::addChild ($child); - $this->childType = $child->x_instanceof (); - } - - /** - * Defines which type of childs the group have - * @access public - * @param string $childType The child type - */ - function setChildType ($childType) { - $this->childType = $childType; - } - - /** - * Is it mandatory to answer sub questions - * @access public - * @param boolean $boolean true if it is mandatory - */ - function setMandatory ($boolean) { - $this->mandatory = $boolean == YES ? YES : NO; - } - - /** - * Is it mandatory to answer sub questions? - * @access public - * @return boolean YES if it is true, else NO - */ - function isMandatory () { - return $this->mandatory == YES ? YES : NO; - } - - /** - * Gets the template id - * @access public - * @return string The template id - */ - function getTemplateID () { - return $this->templateID; - } - - /** - * Sets the template id - * @access public - * @param string $templateID The template id - */ - function setTemplateID ($templateID) { - $newQuestionTexts = []; - -# if ($templateID == $this->templateID) -# return; // for performance reasons - - $this->templateID = $templateID; - - while ($child = &$this->getChild ()) { - array_push ($newQuestionTexts, $child->getText ()); - $child->delete (); - } - - while ($text = array_pop ($newQuestionTexts)) { - $template = new EvaluationQuestion ($templateID, NULL, - EVAL_LOAD_ALL_CHILDREN); - $child = &$template->duplicate (); - $child->setText ($text); - $this->addChild ($child); - } - } -# ======================================================= end: public nctions # - - -# Define private functions ================================================== # -# ==================================================== end: private functions # -} - -?> diff --git a/lib/evaluation/classes/EvaluationObject.class.php b/lib/evaluation/classes/EvaluationObject.class.php deleted file mode 100644 index e42dfb0e1c924561d6786ce9918751b222009f58..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationObject.class.php +++ /dev/null @@ -1,530 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -# ====================================================== end: including files # - - -# Define constants ========================================================== # -/** - * @const INSTANCEOF_EVALOBJECT Is instance of an abstrakt evaluation object - * @access public - */ -define ("INSTANCEOF_EVALOBJECT", "EvaluationObject"); - -/** - * @const EVAL_LOAD_NO_CHILDREN Load no children from DB - * @access public - */ -define ("EVAL_LOAD_NO_CHILDREN", 0); - -/** - * @const EVAL_LOAD_FIRST_CHILDREN Load just the direct children from DB - * @access public - */ -define ("EVAL_LOAD_FIRST_CHILDREN", 1); - -/** - * @const EVAL_LOAD_ALL_CHILDREN Load all children from DB - * @access public - */ -define ("EVAL_LOAD_ALL_CHILDREN", 2); - -/** - * @const EVAL_LOAD_ONLY_EVALGROUP Load just the groups for performance reasons - * @access public - */ -define ("EVAL_LOAD_ONLY_EVALGROUP", 3); -# ===================================================== end: define constants # - - -/** - * This abstract class provides functions for evaluation objects - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationObject extends StudipObject { -# Define all required variables ============================================= # - /** - * The parent object - * @access private - * @var string $parentObject - */ - var $parentObject; - - /** - * The parent object id - * @access private - * @var string $parentObjectCD - */ - var $parentObjectID; - - /** - * Array with all linked childobjects - * @access private - * @var array $childObjects - */ - var $childObjects; - - /** - * Counts the number of childs - * @access private - * @var integer $numberChildren - */ - var $numberChildren; - - /** - * Title of the group - * @access private - * @var integer $title - */ - var $title; - - /** - * Text of the group - * @access private - * @var integer $text - */ - var $text; - - /** - * Position of this group in parent object - * @access private - * @var integer $position - */ - var $position; - - /** - * Holds the DB object - * @access private - * @var object DatabaseObject $db - */ - var $db; - - /** - * Is used as a counter for getNextChild ) - * @access private - * @var integer $childNum - */ - var $childNum; - - /** - * Defines how many children to load. See EVAL_LOAD_*_CHILDREN - * @access private - * @var integer $loadChildren - */ - var $loadChildren; -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @param string $objectID The ID of an existing object - * @param EvaluationObject $parentObject The parent object - * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN - * @access public - */ - function __construct($objectID = "", $parentObject = NULL, - $loadChildren = EVAL_LOAD_NO_CHILDREN) { - - /* Set default values -------------------------------------------------- */ - parent::__construct($objectID); - $this->instanceof = INSTANCEOF_EVALOBJECT; - - $this->parentObject = $parentObject; - $this->loadChildren = $loadChildren; - $this->db = NULL; - $this->childObjects = []; - $this->numberChildren = 0; - $this->title = ""; - $this->text = ""; - $this->position = 0; - $this->childNum = 0; - /* --------------------------------------------------------------------- */ - } -# =========================================== end: constructor and destructor # - - -# Define public functions =================================================== # - /** - * Sets the title - * @access public - * @param string $title The title. - * @throws error - */ - function setTitle ($title) { - $this->title = $title; - } - - /** - * Gets the title - * @access public - * @return string The title - */ - function getTitle () { - return $this->title; - } - - /** - * Sets the text - * @access public - * @param string $text The text. - * @throws error - */ - function setText ($text) { - $this->text = $text; - } - - /** - * Gets the text - * @access public - * @return string The text - */ - function getText () { - return $this->text; - } - - - /** - * Sets the position - * @access public - * @param string $position The position. - */ - function setPosition ($position) { - $this->position = $position; - } - - /** - * Gets the position - * @access public - * @return string The position - */ - function getPosition () { - return $this->position; - } - - /** - * Sets the parentObject - * @access public - * @param string &$parentObject The parentObject. - */ - function setParentObject (&$parentObject) { - $this->parentObject = &$parentObject; - $this->parentObjectID = $this->parentObject->getObjectID (); - } - - /** - * Gets the parentObject - * @access public - * @returns object The parentObject. - */ - function getParentObject () { - return $this->parentObject; - } - - /** - * Gets the parentObjectID - * @access public - * @returns string The parentObjectID - */ - function getParentID () { - return $this->parentObjectID; - } - - - /** - * Sets the parentObjectID - * @access public - * @param string $parentID The parent id - */ - function setParentID ($parentID) { - $this->parentObjectID = $parentID; - } - - /** - * Removes a child from the object (not from the DB!) - * @access public - * @param string $childID The child id - */ - function removeChildID ($childID) { - $temp = []; - $childRemoved = NO; - - while ($child = &$this->getNextChild ()) { - if ($childRemoved) - $child->setPosition ($child->getPosition () - 1); - - if ($child->getObjectID () != $childID) { - array_push ($temp, $child); - } else { - $childRemoved = YES; - } - } - - $this->childObjects = $temp; - - if ($childRemoved) - $this->numberChildren--; - } - - /** - * Adds a child - * @access public - * @param object EvaluationObject &$child The child object - */ - function addChild (&$child) { - $child->setPosition ($this->numberChildren++); - $child->setParentObject ($this); - array_push ($this->childObjects, $child); - } - - /** - * Gets the first child and removes it (if no id is given) - * @access public - * @param string $childID The child id - * @return object The first object - */ - function &getChild ($childID = "") { - if (!empty ($childID)) { - while ($child = $this->getNextChild ()) - if ($child->getObjectID () == $childID) { - $this->childNum = 0; - return $child; - } - $ret = null; - return $ret; - } else { - if ($this->numberChildren > 0) - $this->numberChildren--; - $ret = array_pop ($this->childObjects); - return $ret; - } - } - - /** - * Gets the next child - * @access public - * @return object The next object, otherwise NULL - */ - function &getNextChild () { - if ($this->childNum >= $this->numberChildren) { - $this->childNum = 0; - $ret = null; - return $ret; - } - return $this->childObjects[$this->childNum++]; - } - - /** - * Gets all the childs in the object - * @access public - * @return array An array full of childObjects - */ - function getChildren () { - return $this->childObjects; - } - - /** - * Gets the number of children - * @access public - * @return integer Number of children - */ - function getNumberChildren () { - return $this->numberChildren; - } - - /** - * Saves the object into the database - * @access public - */ - function save () { - /* Check own object --------------------------------------------------- */ - $this->check (); - if ($this->isError ()) - return; - /* --------------------------------------------------------- end: check */ - - /* save own object ---------------------------------------------------- */ - $this->db->save ($this); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - /* ----------------------------------------------- end: save own object */ - - /* save children ------------------------------------------------------ */ - while ($childObject = $this->getNextChild ()) { - $childObject->save (); - if ($childObject->isError ()) - return $this->throwErrorFromClass ($childObject); - } - /* ------------------------------------------------- end: save children */ - } - - /** - * Deletes the object from the database - * @access public - */ - function delete () { - /* remove id from parentobject if exists ------------------------------ */ - if (!empty ($this->parentObject)) { - $this->parentObject->removeChildID ($this->getObjectID ()); - } - /* ----------------------------------------- end: remove id from parent */ - - /* delete own object -------------------------------------------------- */ - $this->db->delete ($this); - /* --------------------------------------------- end: delete own object */ - - /* delete children ---------------------------------------------------- */ - while ($childObject = $this->getChild ()) { - $childObject->delete (); - if ($childObject->isError ()) - $this->throwErrorFromClass ($childObject); - } - /* ----------------------------------------------- end: delete children */ - } - - /** - * Duplicates the evaluation object. WARNING: Stored childs will be - * modified :( - * @access public - */ - function &duplicate () { - $newObject = $this; - $newObject->duplicate_init (); - return $newObject; - } -# ===================================================== end: public functions # - - -# Define private functions ================================================== # - /** - * Initialisation for duplicated objects - * @access private - */ - function duplicate_init () { - $this->init (); - while ($childObject =& $this->getNextChild ()) { - $childObject->setParentID ($this->getObjectID ()); - $childObject->duplicate_init (); - } - } - - /** - * Initialisation for objects - * @access private - * @param string $objectID The object id - */ - function init ($objectID = "") { - /* Load an evaluationobject or create a new one ----------------------- */ - if (empty ($objectID)) { - $this->setObjectID(self::createNewID()); - } else { - $this->setObjectID ($objectID); - $this->load (); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - } - /* -------------------------------------------------------------------- */ - - } - - /** - * Loads the Object from the database - * @access private - */ - function load () { - $this->db->load ($this); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - } - - /** - * Checks if object is in a valid state - * @access private - */ - function check () { - if (empty ($this->db)) - $this->throwError (1, _("Es existiert kein DB-Objekt")); - } - - /** - * Gets all children of a special kind - * @param EvaluationObject &$object the parent object - * @param string $instanceof instance of the searched child - * @param boolean $reset for internal use - * @access public - */ - function getSpecialChildobjects (&$object, $instanceof, $reset = false) { - static $specialchildobjects = []; - if ($reset == YES) { - $specialchildobjects = []; - } - - if ($object->x_instanceof () == $instanceof) { - array_push ($specialchildobjects, $object); - } else { - while ($child = &$object->getNextChild ()) { - $this->getSpecialChildobjects ($child, $instanceof, NO); - } - } - return $specialchildobjects; - } - - /** - * Debugfunction - * @access public - */ - function toString () { - echo "<table border=1 cellpadding=5><tr><td>"; - echo "Typ: ".$this->x_instanceof ()."<br>"; - echo "ObjectID: ".$this->getObjectID ()."<br>"; - echo "ParentID: ".$this->getParentID ()."<br>"; - echo "ParentObject: ".$this->getParentObject ()."<br>"; - echo "Author: ".$this->getAuthorID ()."<br>"; - echo "Titel: ".$this->getTitle ()."<br>"; - echo "Text: ".$this->getText ()."<br>"; - echo "Position: ".$this->getPosition ()."<br>"; - echo "Untergruppen: ".$this->getNumberChildren ()."<br>"; - echo "</td></tr>"; - $i = 0; - while ($child = $this->getNextChild ()) { - echo "<tr><td>"; - $i++; - echo "<b>Kind $i</b>"."<br>"; - $child->toString (); - echo "</td></tr>"; - } - echo "</table>"; - } -# ==================================================== end: private functions # - -} - -?> diff --git a/lib/evaluation/classes/EvaluationQuestion.class.php b/lib/evaluation/classes/EvaluationQuestion.class.php deleted file mode 100644 index c3c1da3839df43aa68bfd577e11578bdf373e3e2..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationQuestion.class.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_QUESTIONDB; -require_once EVAL_FILE_OBJECT; -require_once EVAL_FILE_ANSWER; -# ====================================================== end: including files # - - -# Define constants ========================================================== # -/** - * @const INSTANCEOF_EVALGROUP Is instance of an evaluationquestion object - * @access public - */ -define ("INSTANCEOF_EVALQUESTION", "EvaluationQuestion"); - -/** - * @const EVALQUESTION_TYPE_LIKERT Type of question is skala - * @access public - */ -define ("EVALQUESTION_TYPE_LIKERT", "likertskala"); - -/** - * @const EVALQUESTION_TYPE_MC Type of question is normal - * @access public - */ -define ("EVALQUESTION_TYPE_MC", "multiplechoice"); - -/** - * @const EVALQUESTION_TYPE_POL Type of question is pol - * @access public - */ -define ("EVALQUESTION_TYPE_POL", "polskala"); -# ===================================================== end: define constants # - - -class EvaluationQuestion extends EvaluationObject { - -# Define all required variables ============================================= # - /** - * Type of question (skala/normal) => see EVALQUESTION_TYPE_* - * @access private - * @var string $type - */ - var $type; - - /** - * If set YES it is allowed to choose more than one answer - * @access private - * @var string $isMultiplechoice - */ - var $isMultiplechoice; - - var $templateID; - -# ============================================================ end: variables # - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param string $objectID The ID of an existing question - * @param object $parentObject The parent object if exists - * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN - */ - function __construct($objectID = "", $parentObject = NULL, - $loadChildren = EVAL_LOAD_NO_CHILDREN) { - /* Set default values ------------------------------------------------- */ - parent::__construct($objectID, $parentObject, $loadChildren); - $this->instanceof = INSTANCEOF_EVALQUESTION; - - $this->type = EVALQUESTION_TYPE_MC; - $this->isMultiplechoice = NO; - $this->templateID = YES; - /* ------------------------------------------------------------------- */ - - /* Connect to database ------------------------------------------------- */ - $this->db = new EvaluationQuestionDB (); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - $this->init ($objectID); - /* --------------------------------------------------------------------- */ - } -# =========================================== end: constructor and destructor # - - -# Define public functions =================================================== # - /** - * Sets the type of a question - * @access public - * @param string $type The type of the question. ('skala','normal','pol') - */ - function setType ($type) { - $this->type = $type; - } - - /** - * Sets the type of a question - * @access public - * @return string The type of the question.('likert','multiplechoice','pol') - */ - function getType () { - return $this->type; - } - - - /** - * Sets multiplechoice value of a question - * @access public - * @param $tinyint The multiplechoice Value. - */ - function setMultiplechoice ($multiplechoice) { - $this->isMultiplechoice = $multiplechoice == YES ? YES : NO; - } - - /** - * Checks for multiplechoice - * @access public - * @return boolean YES if it is an multiplechoice question - */ - function isMultiplechoice () { - return $this->isMultiplechoice == YES ? YES : NO; - } - - - /** - * Adds a child and sets the value to pos+1 - * @access public - * @param object EvaluationObject &$child The child object - * @throws error - */ - function addChild (&$child) { - parent::addChild ($child); - if ($child->getValue () == 0) - $child->setValue ($child->getPosition () + 1); - } -# ===================================================== end: public functions # - - -# Define private functions ================================================== # -# ==================================================== end: private functions # - -} - -?> diff --git a/lib/evaluation/classes/EvaluationTree.class.php b/lib/evaluation/classes/EvaluationTree.class.php deleted file mode 100644 index a369d692a3360fef1de92788563f2b480fd90aac..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationTree.class.php +++ /dev/null @@ -1,166 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * The treeclass for an evaluation. - * - * @author mcohrs - * - * @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. -// +--------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EVAL; -require_once EVAL_FILE_GROUP; -# ====================================================== end: including files # - - -class EvaluationTree extends TreeAbstract { -# Define all required variables ============================================= # - - /** - * Holds the Evaluation object - * @access public - * @var object Evaluation $eval - */ - var $eval; - - /** - * Holds the Evaluation ID - * @access public - * @var string $evalID - */ - var $evalID; - - /** - * Holds the eval constructor load mode - * @access public - * @var integer $load_mode - */ - var $load_mode; - - var $root_content; - -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param array the eval's ID (optional - if not given, it must be in $_REQUEST). - */ - function __construct( $args ) { - - - if (isset($args['evalID'])) - $this->evalID = $args['evalID']; - else - $this->evalID = Request::option("evalID"); - - $this->load_mode = ($args['load_mode'] ? $args['load_mode'] : EVAL_LOAD_NO_CHILDREN); - if (empty($this->evalID)){ - print _("Fehler in EvaluationTree: Es wurde keine evalID übergeben"); - exit (); - } - - /* ------------------------------------------------------------------- */ - parent::__construct(); - } -# =========================================== end: constructor and destructor # - - -# Define public functions =================================================== # - - /** - * initializes the tree - * store rows from evaluation tables in array $tree_data - * @access public - */ - function init() { - /* create the evaluation -------------------> */ - $this->eval = new Evaluation( $this->evalID, NULL, $this->load_mode ); - $this->root_name = $this->eval->getTitle(); - $this->root_content = $this->eval->getText(); - - /* create the tree structure ---------------> */ - parent::init(); - - foreach( $this->eval->getChildren() as $group ) { - $this->recursiveInit( $group ); - - $this->tree_data[$group->getObjectID()]["text"] = $group->getText(); - $this->tree_data[$group->getObjectID()]["object"] = $group; - $this->storeItem( $group->getObjectID(), "root", - $group->getTitle(), $group->getPosition() ); - } - /* <---------------------------------------- */ - } - - - /** - * initialize the sub-groups. - * - * @access private - * @param object EvaluationGroup the current group to be initialized. - */ - function recursiveInit( $group ) { - // only groups are interesting here. - if( $group->x_instanceof() != INSTANCEOF_EVALGROUP ) - return; - - if( $children = $group->getChildren() ) { - foreach( $children as $child ) { - $this->recursiveInit( $child ); - } - } - - // store current object itself - $this->tree_data[$group->getObjectID()]["object"] = $group; - - $this->storeItem( $group->getObjectID(), $group->getParentID(), - $group->getTitle(), $group->getPosition() ); - - } - - function &getGroupObject($item_id, $renew = false){ - if (isset($this->tree_data[$item_id]['object']) && is_object($this->tree_data[$item_id]['object'])) { - if ($renew) $this->recursiveInit(new EvaluationGroup($item_id,null,$this->load_mode)); - return $this->tree_data[$item_id]['object']; - } else { - $evalGroup = new EvaluationGroup($item_id, null, $this->load_mode); - return $evalGroup; - } - } - -# ===================================================== end: public functions # - - -} - -?> diff --git a/lib/evaluation/classes/EvaluationTreeEditView.class.php b/lib/evaluation/classes/EvaluationTreeEditView.class.php deleted file mode 100644 index 3bfe92ac3c62307404192cf500e67a8579e2efdd..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationTreeEditView.class.php +++ /dev/null @@ -1,3245 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter005: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - -use Studip\Button, Studip\LinkButton; - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_LIB_COMMON; -require_once EVAL_FILE_EVALTREE; -require_once EVAL_FILE_EVAL; -# ====================================================== end: including files # - -/** - * Class to print out the an evaluation's admin-tree - * - * @author Christian Bauer <alfredhitchcock@gmx.net> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - */ - - -# defines ==================================================================== # - -/** - * @const NO_TEMPLATE_GROUP title of the template without temtplateID - * @access private - */ -define('NO_TEMPLATE_GROUP', _('keine Vorlage')); - -/** - * @const NO_TEMPLATE_GROUP_TITLE title of questiongroup without title - * @access private - */ -define('NO_QUESTION_GROUP_TITLE', _('*Fragenblock*')); - -/** - * @const NO_TEMPLATE title of a template without title - * @access private - */ -define('NO_TEMPLATE', _('*unbekannt*')); -/** - * @const NEW_ARRANGMENT_BLOCK_TITLE title of a new arrangment block - * @access private - */ -define('NEW_ARRANGMENT_BLOCK_TITLE', _('Neuer Gruppierungsblock')); - -/** - * @const NEW_QUESTION_BLOCK_BLOCK_TITLE title of a new question block - * @access private - */ -define('NEW_QUESTION_BLOCK_BLOCK_TITLE', _('Neuer Fragenblock')); - -/** - * @const ROOT_BLOCK the root item - * @access private - */ -define('ROOT_BLOCK', 'root'); - -/** - * @const ARRANGMENT_BLOCK the arrangment block item - * @access private - */ -define('ARRANGMENT_BLOCK', 'ARRANGMENT_BLOCK'); - -/** - * @const QUESTION_BLOCK the question block item - * @access private - */ -define('QUESTION_BLOCK', 'QUESTION_BLOCK'); - -# =============================================================== end: defines # - - -# classes ==================================================================== # - -class EvaluationTreeEditView -{ - - /** - * Reference to the tree structure - * - * @access public - * @var object EvaluationTree $tree - */ - var $tree; - - /** - * contains the item with the current html anchor - * - * @access public - * @var string $anchor - */ - var $anchor; - - /** - * the item to start with - * - * @access public - * @var string $startItemID - */ - var $startItemID; - - /** - * true if changedate should be set - * - * @access private - * @var boolean $changed - */ - var $changed; - - /** - * Holds the Evaluation object - * @access private - * @var object Evaluation $eval - */ - var $eval; - - /** - * Holds the current Item-ID - * @access private - * @var string $itemID - */ - var $itemID; - - /** - * Holds the currently moved Item-ID - * @var string $moveItemID - */ - var $moveItemID; - - /** - * Holds the current evalID - * @access private - * @var integer $evalID - */ - var $evalID; - - /** - * The itemID instance - * @access private - * @var string $itemInstance - */ - var $itemInstance; - - /** - * Possible messages - * - * @var array $msg - */ - var $msg = []; - - /** - * constructor - * - * @access public - * @param string $itemID the item to display - * @param string $evalID the evaluation of the item - */ - function __construct($itemID = ROOT_BLOCK, $evalID = NULL) - { - global $sess; - - $this->itemID = ($itemID) ? $itemID : ROOT_BLOCK; - $this->startItemID = ($itemID) ? $itemID : ROOT_BLOCK; - $this->evalID = $evalID; - $this->itemInstance = $this->getInstance($this->itemID); - $this->changed = false; - - $this->tree = TreeAbstract::GetInstance("EvaluationTree", ['evalID' => $this->evalID, - 'load_mode' => EVAL_LOAD_ALL_CHILDREN]); - - # filter out an old session itemID ======================================= # - if (is_array($this->tree->tree_data) && !is_null($itemID)) { - if (!array_key_exists($itemID, $this->tree->tree_data)) { - $this->itemID = ROOT_BLOCK; - $this->startItemID = ROOT_BLOCK; - $this->tree->init(); - } - } else { - $this->itemID = ROOT_BLOCK; - $this->startItemID = ROOT_BLOCK; - $this->tree->init(); - } - - # handling the moveItemID =============================================== # - if (Request::submitted('create_moveItemID')) - $this->moveItemID = Request::option("itemID"); - elseif (Request::option("moveItemID")) - $this->moveItemID = Request::get("moveItemID"); - - if (Request::submitted("abbort_move")) - $this->moveItemID = NULL; - - if ($this->moveItemID != NULL) { - if (is_array($this->tree->tree_data)) { - if (!array_key_exists($this->moveItemID, $this->tree->tree_data)) { - $this->moveItemID = NULL; - } - } else { - $this->moveItemID = NULL; - } - } - - - # execute the comand ==================================================== # - $this->parseCommand(); - - # set the new changedate ================================================ # - if ($this->changed) { - $this->tree->eval->setChangedate(time()); - $this->tree->eval->save(); - } - - } - - -################################################################################ -# # -# public functions # -# # -################################################################################ - - /** - * displays the EvaluationTree - * - * @access public - * @return string the eval-tree (html) - */ - function showEvalTree() - { - - $html = "<table width=\"99%\" border=\"0\" cellpadding=\"0\" " - . "cellspacing=\"0\">\n"; - - if ($this->startItemID != ROOT_BLOCK) { - - $html .= " <tr>\n" - . " <td class=\"table_row_odd\" align=\"left\" valign=\"top\" " - . "colspan=\""; - $html .= ($this->moveItemID) ? "1" : "1"; - $html .= "\"" - . ">\n" - . $this->getEvalPath() -# . "<img src=\"". -# . "/forumleer.gif\" border=\"0\" height=\"20\" width=\"1\">\n" - . " </td>\n" - . " </tr>\n"; - } - # display the infos when moving a block =================================== # - - if ($this->moveItemID) { - - $html .= " <tr>\n"; -# . " <td width=\"10\"class=\"blank tree-indent\" " -# . "background=\"".."forumstrich.gif\">" -# . "<img src=\"" -# . ."forumstrich.gif\" width=\"10\" border=\"0\" >" -# . "</td>\n" - $html .= " <td class=\"graulight\" align=\"left\" valign=\"top\" width=\"100%\">\n"; - - - $mode = $this->getInstance($this->moveItemID); - - switch ($mode) { - - case ARRANGMENT_BLOCK: - $group =& $this->tree->getGroupObject($this->moveItemID); - $title = htmlready($group->getTitle()); - $msg = sprintf(_("Sie haben den Gruppierungsblock <b>%s</b> zum Verschieben ausgewählt. Sie können ihn nun in einen leeren Gruppierungsblock, einen Gruppierungsblock ohne Frageblöcke oder in die oberste Ebene verschieben."), $title); - - break; - - case QUESTION_BLOCK: - $group = &$this->tree->getGroupObject($this->moveItemID); - $title = htmlready($group->getTitle()); - if (!$title) - $title = NO_QUESTION_GROUP_TITLE; - $msg = sprintf(_("Sie haben den Fragenblock <b>%s</b> zum Verschieben ausgewählt. Sie können ihn nun in einen leeren Gruppierungsblock oder einen Gruppierungsblock mit Frageblöcke verschieben."), $title); - break; - - default: - - $msg = _("Es wurde ein ungültiger Block zum verschieben ausgewählt."); - break; - } - - - $table = new HTML ("table"); - $table->addAttr("border", "0"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "100%"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("align", "center"); - $td->addAttr("class", "graulight"); - $td->addAttr("width", "25"); - - $img = new HTMLempty ("img"); - $img->addAttr("width", "32"); - $img->addAttr("height", "32"); - $img->addAttr("src", EVAL_PIC_INFO); - - $td->addContent($img); - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("align", "left"); - - $font = new HTML ("font"); - $font->addAttr("color", "black"); - $font->addHTMLContent($msg); - $font->addHTMLContent(" " . sprintf( - _("Benutzen Sie dieses %s Symbol, um den Block zu verschieben."), - $this->createImage(EVAL_PIC_MOVE_GROUP, _("Block verschieben Symbol")))); - $font->addHTMLContent("<br><br>" - . _("Oder wollen Sie die Aktion abbrechen?") - . " " - . LinkButton::createCancel(_('Abbrechen'), - $this->getSelf('abbort_move=1'))); - - $td->addContent($font); - $tr->addContent($td); - $table->addContent($tr); - - $html .= "<br>" . $table->createContent() . "<br>"; - - $html .= "</td></tr>\n"; - } - # ============================= END: display the infos when moving a block # - - $html .= " <tr>\n" - . " <td class=\"blank\" align=\"left\" valign=\"top\" " - . "colspan=\""; - $html .= ($this->moveItemID) ? "1" : "1"; - $html .= "\"" - . ">\n"; - - if (!$this->startItemID != ROOT_BLOCK) { - $html .= "<a name=\"anchor\"></a>\n"; - } - - $html .= $this->showTree($this->startItemID, 1) - . " </td>\n" - . " </tr>\n" - . "</table>\n"; - - return $html; - } - -# ###################################################### end: public functions # - - -################################################################################ -# # -# show tree functions # -# # -################################################################################ - - /** - * prints out the tree beginning at the parent-item - * - * @access public - * @param string $itemID the item to display - * @param string $start YES if its the basecall - * @return string the tree (html) - */ - function showTree($itemID = ROOT_BLOCK, $start = NULL) - { - - $items = []; - if (!is_array($itemID)) { - $items[0] = $itemID; - - $mode = $this->getInstance($itemID); - - switch ($mode) { - - case ROOT_BLOCK: - $this->startItemID = $itemID; - break; - - case ARRANGMENT_BLOCK: - - case QUESTION_BLOCK: - $parentgroup = &$this->tree->getGroupObject($itemID); - $this->startItemID = $parentgroup->getObjectID(); - break; - } - - $this->startItemID = $itemID; - } else { - $items = $itemID; - } - $num_items = count($items); - - $html = ""; - - // this is the first / the opened item - if ($start) { - - $mode = $this->getInstance($itemID); - - switch ($mode) { - - case ROOT_BLOCK: - - break; - - case ARRANGMENT_BLOCK: - - case QUESTION_BLOCK: - - $group = &$this->tree->getGroupObject($itemID); - $parentID = $group->getParentID(); - - $mode = $this->getInstance($parentID); - $items2 = []; - if ($mode == ROOT_BLOCK) { - - $eval = new Evaluation ($this->evalID, NULL, EVAL_LOAD_FIRST_CHILDREN); - while ($child = $eval->getNextChild()) - $items2[] = $child->getObjectID(); - } else { - - $parentgroup = &$this->tree->getGroupObject($parentID, NULL, EVAL_LOAD_FIRST_CHILDREN); - while ($child = $parentgroup->getNextChild()) - $items2[] = $child->getObjectID(); - } - - $num_items2 = count($items2); - - $num_items = $num_items2; - $items = $items2; - break; - - } - - } - - for ($j = 0; $j < $num_items; ++$j) { - - $html .= $this->createTreeLevelOutput($items[$j]); - $html .= $this->createTreeItemOutput($items[$j]); - - if ($this->tree->hasKids($items[$j]) && - $this->itemID == $items[$j]) - $html .= $this->showTree($this->tree->tree_childs[$items[$j]]); - } - - return $html; - } - - - /** - * creates the parentslinks - * - * @access private - * @return string the eval path as html-links - */ - function getEvalPath() - { - - $path = "<a name=\"anchor\"> </a>\n" - . _("Sie sind hier:") - . " "; - $path .= "<a class=\"tree\" href=\"" - . URLHelper::getLink($this->getSelf("itemID=" . ROOT_BLOCK, false)) - . "\">" - . htmlready(my_substr( - $this->tree->tree_data[ROOT_BLOCK]["name"], 0, 60)) - . "</a>"; - - # collecting the parent blocks =========================================== # - - if ($parents = $this->tree->getParents($this->startItemID)) { - for ($i = count($parents) - 1; $i >= 0; --$i) { - if ($parents[$i] != ROOT_BLOCK) - $path .= " > " - . "<a class=\"tree\" href=\"" - . URLHelper::getLink($this->getSelf("itemID={$parents[$i]}", false)) - . "\">" - . htmlready(my_substr( - $this->tree->tree_data[$parents[$i]]["name"], 0, 60)) - . "</a>"; - } - } - # ====================================== END: collecting the parent blocks # - return $path; - } - - - /** - * returns html for the icons in front of the name of the item - * - * @access private - * @param string $itemID the item-heas id - * @return string the item head (html) - */ - function getItemHeadPics($itemID) - { - - $mode = $this->getInstance($itemID); - - if ($this->itemID == $itemID) { - - $img = new HTMLempty ("img"); - $img->addAttr("src", EVAL_PIC_TREE_ARROW_ACTIVE); - $img->addAttr("border", "0"); - $img->addAttr("align", "baseline"); - $img->addAttr("hspace", "2"); - $img->addString(tooltip(_("Dieser Block ist geöffnet."), true)); - $head = $img->createContent(); - - } else { - - $a = new HTML ("a"); - $a->addAttr("href", URLHelper::getLink($this->getSelf("itemID={$itemID}"))); - - $img = new HTMLempty ("img"); - $img->addAttr("src", EVAL_PIC_TREE_ARROW); - $img->addAttr("border", "0"); - $img->addAttr("align", "baseline"); - $img->addAttr("hspace", "2"); - $img->addString(tooltip(_("Diesen Block öffnen."), true)); - - $a->addContent($img); - - $head = $a->createContent(); - - } - - # collecting the image and tooltip for this item ========================== # - - switch ($mode) { - - case ROOT_BLOCK: - - $tooltip = _("Dies ist Ihre Evaluation."); - $image = EVAL_PIC_ICON; - break; - - case ARRANGMENT_BLOCK: - - $group = &$this->tree->getGroupObject($itemID); - - $tooltip = ($group->getNumberChildren() == 0) - ? _("Dieser Gruppierungsblock enthält keine Blöcke.") - : sprintf(_("Dieser Grupppierungsblock enthält %s Blöcke."), - $group->getNumberChildren()); - - $image = ($group->getNumberChildren() == 0) - ? EVAL_PIC_TREE_GROUP - : EVAL_PIC_TREE_GROUP_FILLED; - - break; - - case QUESTION_BLOCK: - - $group = &$this->tree->getGroupObject($itemID); - - $tooltip = ($group->getNumberChildren() == 0) - ? _("Dieser Fragenblock enthält keine Fragen.") - : sprintf(_("Dieser Fragenblock enthält %s Fragen."), - $group->getNumberChildren()); - - $image = ($group->getNumberChildren() == 0) - ? EVAL_PIC_TREE_QUESTIONGROUP - : EVAL_PIC_TREE_QUESTIONGROUP_FILLED; - - break; - - default: - - $tooltip = _("Kein Blocktyp."); - $image = EVAL_PIC_TREE_GROUP; - - break; - } - - # ===================== END: collecting the image and toolpi for this item # - - $img = new HTMLempty ("img"); - $img->addAttr("border", "0"); - $img->addAttr("align", "baseline"); - $img->addAttr("src", $image); - $img->addString(tooltip($tooltip, true)); - - $head .= $img->createContent(); - - return $head; - } - - - /** - * creates the content for all item-types - * - * @access private - * @param string $itemID the item-heas id - * @return string the item content (html) - */ - function getItemContent($itemID) - { - - $content = ""; - - if ($this->getItemMessage($itemID)) { - - $table = new HTML ("table"); - $table->addAttr("width", "99%"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("cellspacing", "2"); - $table->addAttr("style", "font-size:10pt;"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addHTMLContent($this->getItemMessage($itemID)); - - $tr->addContent($td); - $table->addContent($tr); - - $content .= "<br>" . $table->createContent(); - } - - - $content .= "<form class=\"default\" action=\"" . URLHelper::getLink($this->getSelf("item_id={$itemID}", 1)) - . "\" method=\"POST\" style=\"display:inline;\">\n"; - $content .= CSRFProtection::tokenTag(); - - $content .= "<br>"; - - $mode = $this->getInstance($itemID); - - switch ($mode) { - case ROOT_BLOCK: - - $content .= $this->createTitleInput(ROOT_BLOCK) - . $this->createGlobalFeatures() - - . $this->createButtonbar(ROOT_BLOCK); - break; - - case ARRANGMENT_BLOCK: - - $content .= $this->createTitleInput(ARRANGMENT_BLOCK); - - $group = &$this->tree->getGroupObject($itemID); - if ($children = $group->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) == ARRANGMENT_BLOCK) - $show = ARRANGMENT_BLOCK; - else - $show = QUESTION_BLOCK; - } else - $show = "both"; - $content .= $this->createButtonbar($show); - break; - - case QUESTION_BLOCK: - - $content .= $this->createTitleInput(QUESTION_BLOCK) - . $this->createQuestionFeatures() - . $this->createQuestionForm() - . $this->createButtonbar(NULL); - break; - } - - $content .= "</form>\n"; - - return $content; - } - - - /** - * prints out the lines before an item ("Strichlogik" (c) rstockm) - * - * @access private - * @param string $item_id the current item - * @param string $start_itemID the start item - * @return string the level output (html) - */ - function createTreeLevelOutput($item_id, $start_itemID = NULL) - { - - $level_output = ""; - - // without the first strichcode - $item_parent = $this->tree->tree_data[$item_id]['parent_id']; - $startitem_parent = $this->tree->tree_data[$this->startItemID]['parent_id']; - - if (($item_parent != $startitem_parent) && ($item_parent != NULL) - && ( - ($item_id != ROOT_BLOCK) || - ($item_id != $this->tree->tree_data[$this->startItemID]['parent_id']))) { - if ($this->tree->isLastKid($item_id) || $item_id == ROOT_BLOCK) - $level_output = "<td class=\"blank tree-indent\" valign=\"top\" " - . "nowrap>" - . Assets::img('forumstrich2.gif') - . "</td>"; //last - else - $level_output = " <td class=\"blank tree-indent\" valign=\"top\" " - . "nowrap>" - . Assets::img('forumstrich3.gif') - . "</td>"; //crossing - - $parent_id = $item_id; - $counter = 0; - while ( - (0) && - ($this->tree->tree_data[$parent_id]['parent_id'] != $this->tree->tree_data[$this->startItemID]['parent_id']) && - ($this->tree->tree_data[$parent_id]['parent_id'] != $start_itemID) && - ($this->tree->tree_data[$parent_id]['parent_id'] != ROOT_BLOCK)) { - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - $counter++; - - if ($this->tree->isLastKid($parent_id)) { - $level_output = "<td class=\"blank\" valign=\"top\" " - . "width=\"10\" nowrap>" - . Assets::img('forumleer.gif') - . "</td>" - . $level_output; //nothing - } else { - $level_output = " <td class=\"blank tree-indent\" valign=\"top\" " - . "nowrap>" - . Assets::img('forumstrich.gif') - . "</td>" - . $level_output; //vertical line - } - - } - - // the root-item - if ((0) && - ($this->startItemID == ROOT_BLOCK) && - ($this->tree->tree_data[$item_id]['parent_id'] == ROOT_BLOCK)) { - $level_output = "<td class=\"blank\" valign=\"top\" " - . "width=\"10\" nowrap>" - . Assets::img('forumleer.gif') - . "</td>" - . $level_output; //nothing - } - - } - - $html = "<table border=\"0\" width=\"100%\" cellspacing=\"0\" " - . "cellpadding=\"0\">" - . " <tr>$level_output"; - return $html; - } - - - /** - * prints out one item - * - * @access private - * @param string $item_id the items id - * @return string one item (html) - */ - function createTreeItemOutput($item_id) - { - - $html = " <td class=\"printhead\" nowrap align=\"left\" " - . "valign=\"bottom\">\n" - . $this->getItemHeadPics($item_id) . "\n" - . " </td>\n" - . " <td class=\"printhead\" nowrap width=\"1\" valign=\"middle\">\n"; - if ($this->anchor == $item_id) - $html .= "<a name=\"anchor\">"; - $html .= Assets::img('forumleer.gif'); - if ($this->anchor == $item_id) - $html .= "</a>"; - $html .= "\n" - . " </td>\n" - . " <td class=\"printhead\" align=\"left\" width=\"99%\" " - . "nowrap valign=\"bottom\">" - . $this->getItemHead($item_id) - . " </td>\n" - . " </tr>\n" - . "</table>\n"; - if ($this->itemID == $item_id) - $html .= $this->createTreeItemDetails($item_id); - return $html; - } - - - /** - * prints out the item details - * - * @access private - * @param string $item_id the current item - * @return string the item details (html) - */ - private function createTreeItemDetails($item_id) - { - $mode = $this->getInstance($item_id); - - switch ($mode) { - case ROOT_BLOCK: - $eval = new Evaluation($this->evalID, NULL, EVAL_LOAD_FIRST_CHILDREN); - $hasKids = $eval->getNumberChildren() == 0 ? NO : YES; - break; - case ARRANGMENT_BLOCK: - $group = $this->tree->getGroupObject($item_id); - $hasKids = $group->getNumberChildren() == 0 ? NO : YES; - break; - default: - $hasKids = NO; - break; - } - - if (!$hasKids || $this->itemID != $item_id) { - $level_output = $this->createLevelOutputTD(); - } else { - $level_output = $this->createLevelOutputTD("forumstrich.gif"); - } - - $table = new HTML ("table"); - $table->addAttr("border", "0"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "0"); - $table->addAttr("width", "100%"); - - $tr = new HTML ("tr"); - $tr->addHTMLContent($level_output); - - $td = new HTML ("td"); - $td->addAttr("class", "printcontent"); - $td->addAttr("width", "100%"); - - $div = new HTML ("div"); - $div->addAttr("align", "center"); - $div->setTextareaCheck(); - $div->addHTMLContent($this->getItemContent($item_id)); - - $td->addContent($div); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - - /** - * creates the items head - * - * @access private - * @param string $itemID the current item - * @return string the item head (html) - */ - function getItemHead($itemID) - { - - $mode = $this->getInstance($itemID); - - if ($this->itemID == $itemID) { - -# $group = new EvaluationGroup($itemID); - $head = " "; - if ($this->tree->tree_data[$itemID]['name'] == "" && $mode == QUESTION_BLOCK) - $head .= NO_QUESTION_GROUP_TITLE; - else - $head .= htmlready(my_substr( - $this->tree->tree_data[$itemID]['name'], 0, 60)); - - } else { - - if ($mode == QUESTION_BLOCK) { - - $group = &$this->tree->getGroupObject($itemID); - $templateID = $group->getTemplateID(); - if ($templateID) { - $template = new EvaluationQuestion($templateID); - $templateTitle = htmlReady($template->getText()); - } else - $templateTitle = NO_TEMPLATE_GROUP; - - if ($templateTitle == "") - $templateTitle = NO_TEMPLATE; - - $template = " </td>\n" - . " <td align=\"right\" valign=\"bottom\" " - . "class=\"printhead\" nowrap=\"nowrap\">\n" - . "<b>" - . _("Vorlage") . ": " - . $templateTitle - . "</b> "; - - } - - $head = " <a class=\"tree\" href=\"" - . URLHelper::getLink($this->getSelf("itemID={$itemID}", false)) . "\"" . tooltip(_("Diesen Block öffnen"), true) . ">"; - - if ($this->tree->tree_data[$itemID]['name'] == "" && $mode == QUESTION_BLOCK) - $head .= NO_QUESTION_GROUP_TITLE; - else - $head .= htmlready(my_substr( - $this->tree->tree_data[$itemID]['name'], 0, 60)); - $head .= "</a>"; - - if (!empty($template)) - $head .= $template; - } - $moveItem = []; - $moveItemIsParent = 0; - if ($itemID == ROOT_BLOCK) - $itemID2 = $this->evalID; - else - $itemID2 = $itemID; - - // the "verschiebäfinger" - if ($this->moveItemID && - ($this->tree->tree_data[$itemID]['parent_id'] != $this->moveItemID) && - ($mode == ARRANGMENT_BLOCK || $itemID == ROOT_BLOCK) && - $this->moveItemID != $itemID2) { - - $parentID = $this->tree->tree_data[$itemID]['parent_id']; - if (!$parentID) $parentID = ROOT_BLOCK; - while ($parentID != ROOT_BLOCK && $parentID != $this->moveItemID) { - $parentID = $this->tree->tree_data[$parentID]['parent_id']; - if ($parentID == $this->moveItemID) - $moveItemIsParent = 1; - } - - $moveItem = " </td>\n" - . " <td align=\"right\" valign=\"middle\" class=\"printhead\" nowrap=\"nowrap\">\n" - . $this->createLinkImage(EVAL_PIC_MOVE_GROUP, - _("Den ausgwählten Block in diesen Block verschieben"), - "&itemID=$itemID&cmd=MoveGroup", - NO, NULL, NO) - . " "; - } - - if ($moveItem && !$moveItemIsParent) { - $move_mode = $this->getInstance($this->moveItemID); - - if ($mode == ARRANGMENT_BLOCK) { - $group = &$this->tree->getGroupObject($itemID); - if ($children = $group->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) == ARRANGMENT_BLOCK) - $move_type = ARRANGMENT_BLOCK; - else - $move_type = QUESTION_BLOCK; - } else - $move_type = "both"; - } elseif ($mode == ROOT_BLOCK) - $move_type = ARRANGMENT_BLOCK; - else - $move_type = "no"; - - - if (($move_type == "both") || - ($move_mode == $move_type)) { - $head .= $moveItem; - } - } - - if (!($this->tree->isFirstKid($itemID) && $this->tree->isLastKid($itemID)) && - ($itemID != $this->startItemID) && - ($this->tree->tree_data[$itemID]['parent_id'] == $this->startItemID)) { - $head .= " </td>\n" - . " <td align=\"right\" valign=\"bottom\" class=\"printhead\" nowrap=\"nowrap\">\n" - . $this->createLinkImage(EVAL_PIC_MOVE_UP, - _("Block nach oben verschieben"), - "cmd=Move&direction=up&groupID=$itemID", - NO) - . $this->createLinkImage(EVAL_PIC_MOVE_DOWN, - _("Block nach unten verschieben"), - "cmd=Move&direction=down&groupID=$itemID", - NO) - . " "; - } - return $head; - } - - - /** - * creates a table and calls the ItemMessages - * - * @access private - * @param string $itemID the current item - * @param integer $colspan the needed colspan (optional) - * @return string the item message (html) - */ - function getItemMessage($itemID, $colspan = 1) - { - if (!empty($this->msg[$itemID])) { - $msg = explode("§", $this->msg[$itemID]); - $details = []; - if ($msg[0] == 'msg') { - $msg[0] = 'success'; - } - if (mb_strpos($msg[1], '<br>')) { - $details = explode("<br>", $msg[1]); - $msg[1] = array_shift($details); - } - - return (string)MessageBox::{$msg[0]}($msg[1], $details); - } else { - return NULL; - } - } - - - /** - * creates a self-url with add. items - * - * @access private - * @param string $param params (optional) - * @param boolean $with_start_item startItem needed? (optional) - * @return string the self url - */ - function getSelf($param = "", $with_start_item = true) - { - - $url = "?page=edit"; - - if ($this->evalID) - $url .= "&evalID=" . $this->evalID; - else - $url .= "&evalID=" . Request::option("evalID"); - - if ($param) { - $url .= (($with_start_item) - ? "&itemID=" . $this->startItemID . "&" - : "&") . $param; - } else { - $url .= (($with_start_item) - ? "&itemID=" . $this->startItemID - : ""); - } - - if ($this->moveItemID) - $url .= "&moveItemID=" . $this->moveItemID; - - $url .= "#anchor"; - - return $url; - } - -# ################################################### end: show tree functions # - - -################################################################################ -# # -# command functions # -# # -################################################################################ - - /** - * parses the _Request-commands and calls the avaible functions - * - * @access private - */ - function parseCommand() - { - $exec_func = ''; - if (Request::option('cmd') || Request::optionArray('cmd')) { - # extract the command from Request (array) =========================== # - - if (Request::optionArray('cmd')) - $exec_func = "execCommand" . key(Request::optionArray('cmd')); - else - $exec_func = "execCommand" . Request::option('cmd'); - - } else { - $found = 0; - # extract the command from the template-site ========================= # - foreach ($_REQUEST as $key => $value) { - if (preg_match("/template_(.*)_#(.*)_button?/", $key, $command)) { - $found = 1; - break; - } - } - - if (!$found) { - foreach ($_REQUEST as $key => $value) { - if (preg_match("/cmd_(.*)_#(.*)_§(.*)_button?/", $key, $command)) - break; - } - } - - - if (isset($command[1])) { - if ($command[1] == "create_question_answers") - $exec_func = "execCommandQuestionAnswersCreate"; - else - $exec_func = "execCommand" . $command[1]; - } - # ==================== END: extract the command from the template-site # - } - - if (method_exists($this, $exec_func)) { - if ($this->$exec_func()) { - $this->tree->init(); - $this->tree->eval->save(); - } - } - } - - - /** - * Creates cancel-message - * @access public - * @return boolean true (reinits the tree) - */ - function execCommandCancel() - { - - - $itemID = Request::option('startItemID'); - - $this->anchor = $itemID; - $this->msg[$this->startItemID] .= "info§" - . sprintf(_("Die Aktion wurde abgebrochen.")); - return false; - } - - /** - * Updates the item content of any kind - * - * @access private - * @param boolean $no_delete YES/NO (optional) - * @return boolean true (reinits the tree) - */ - function execCommandUpdateItem($no_delete = false) - { - - - $mode = $this->getInstance($this->itemID); - - $title = Request::get('title'); - if ($title == "" && $mode != QUESTION_BLOCK) - $title = _("Kein Titel angegeben."); - $text = Studip\Markup::purifyHtml(trim(Request::get('text'))); - - switch ($mode) { - case ROOT_BLOCK: - - $this->tree->eval->setTitle($title); - $this->tree->eval->setText($text); - - //global features - $this->tree->eval->setAnonymous(Request::get('anonymous')); - - $this->tree->eval->save(); - - if (!empty($this->tree->eval->isError)) { - return MessageBox::error(_("Fehler beim Einlesen (root-item)")); - } - $this->msg[$this->itemID] = "msg§" - . _("Veränderungen wurden gespeichert."); - - break; - case ARRANGMENT_BLOCK: - - $group = &$this->tree->getGroupObject($this->itemID, true); - - $group->setTitle($title); - $group->setText($text); - $group->save(); - if (!empty($group->isError)) { - return MessageBox::error(_("Fehler beim Einlesen (Block)")); - } - $this->msg[$this->itemID] = "msg§" - . _("Veränderungen wurden gespeichert."); - $group = null; - break; - case QUESTION_BLOCK: - - $group = &$this->tree->getGroupObject($this->itemID, true); - $group->setTitle($title); - $group->setText($text); - $group->setMandatory(Request::get('mandatory')); - $group->save(); - - // update the questions - $msg = $this->execCommandUpdateQuestions(); - - $no_answers = 0; - $group = &$this->tree->getGroupObject($this->itemID, true); - // info about missing answers - if ($group->getChildren() && $group->getTemplateID() == NULL) { - foreach ($group->getChildren() as $question) { - if ($question->getChildren() == NULL) - $no_answers++; - } - if ($no_answers == 1) { - if ($this->msg[$this->itemID]) - $this->msg[$this->itemID] .= "<br>" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); - else - $this->msg[$this->itemID] .= "info§" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); - } elseif ($no_answers > 1) { - if ($this->msg[$this->itemID]) - $this->msg[$this->itemID] .= "<br>" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); - else - $this->msg[$this->itemID] .= "info§" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); - } - - } - - if (!empty($group->isError)) { - return MessageBox::error("Fehler beim Einlesen (Fragenblock)"); - } - if (!isset($this->msg[$this->itemID])) { - $this->msg[$this->itemID] = ''; - } - if (!empty($this->msg[$this->itemID])) - $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert."); - else - $this->msg[$this->itemID] .= "msg§" - . _("Veränderungen wurden gespeichert."); - - if (!empty($msg)) { - if (!isset($this->msg[$this->itemID])) { - $this->msg[$this->itemID] = ''; - } - $this->msg[$this->itemID] = $this->msg[$this->itemID] . "<br>" . $msg; - } - break; - default: - $this->msg[$this->itemID] .= "info§" - . _("Falscher Blocktyp. Es wurden keine Veränderungen vorgenommen."); - break; - } - - $this->changed = true; - - return true; - } - - - /** - * Creates a delete-request - * - * @access public - * @return boolean false - */ - function execCommandAssertDeleteItem() - { - $group = &$this->tree->getGroupObject($this->itemID); - if ($group->getChildType() == "EvaluationQuestion") - $numberofchildren = $group->getNumberChildren(); - else - $numberofchildren = $this->tree->getNumKidsKids($this->itemID); - - $title = htmlready($group->getTitle()); - - // constructing the message - $this->msg[$this->itemID] = "info§"; - - if ($group->getChildType() == "EvaluationQuestion") { - if ($numberofchildren) { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Fragenblock <b>%s</b> inklusive aller Fragen zu löschen. "), - $title) - . sprintf(_("Es werden insgesamt %s Fragen gelöscht!"), $numberofchildren); - } else { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Fragenblock <b>%s</b> inklusive aller Fragen zu löschen. "), - $title); - } - $this->msg[$this->itemID] .= "<br>" - . _("Wollen Sie diesen Fragenblock wirklich löschen?"); - } else { - if ($numberofchildren) { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Gruppierungsblock <b>%s</b> inklusive aller Unterblöcke zu löschen. "), - $title) - . sprintf(_("Es werden insgesamt %s Unterblöcke gelöscht!"), $numberofchildren); - } else { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Gruppierungsblock <b>%s</b> inklusive aller Unterblöcke zu löschen. "), - $title); - } - $this->msg[$this->itemID] .= "<br>" - . _("Wollen Sie diesen Gruppierungsblock wirklich löschen?"); - } - - $this->msg[$this->itemID] .= "<br><br>" - . LinkButton::createAccept(_('JA!'), - $this->getSelf('cmd[DeleteItem]=1'), - ['title' => _('Löschen')]) - . " " - . LinkButton::createCancel(_('NEIN!'), - $this->getSelf('cmd[Cancel]=1')) - . "\n"; - - return false; - } - - /** - * Deletes an Item and its kids - * @access public - * @return boolean true (reinits the tree) - */ - function execCommandDeleteItem() - { - - $title = $this->tree->tree_data[$this->itemID]['name']; - $parentID = $this->tree->tree_data[$this->itemID]['parent_id']; - - $group = &$this->tree->getGroupObject($this->startItemID); - if ($group->getChildType() == "EvaluationQuestion") - $numberofchildren = $group->getNumberChildren(); - else - $numberofchildren = $this->tree->getNumKidsKids($this->itemID); - - $group->delete(); - - if (!empty($group->isError)) { - return MessageBox::error(_("Fehler beim Löschen eines Block.")); - } - - if ($group->getChildType() == "EvaluationQuestion") { - if ($numberofchildren) { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Fragenblock <b>%s</b> und alle darin enthaltenen Fragen (insgesamt %s) wurden gelöscht. "), $title, $numberofchildren); - } else { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Fragenblock <b>%s</b> wurde gelöscht. "), $title); - } - } else { - if ($numberofchildren) { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Gruppierungsblock <b>%s</b> und alle Unterblöcke (insgesamt %s) wurden gelöscht. "), $title, $numberofchildren); - } else { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Gruppierungsblock <b>%s</b> wurde gelöscht. "), $title); - } - } - - $this->changed = true; - - $this->startItemID = $parentID; - $this->itemID = $parentID; - - return true; - } - - /** - * Creates a new Group and adds it to the tree - * - * @access public - * @return boolean true (reinits the tree) - */ - function execCommandAddGroup() - { - - - $group = new EvaluationGroup(); - $group->setTitle(NEW_ARRANGMENT_BLOCK_TITLE); - $group->setText(""); - - $mode = $this->getInstance($this->itemID); - - if ($mode == ROOT_BLOCK) { - $this->tree->eval->addChild($group); - $this->tree->eval->save(); - if (!empty($this->tree->eval->isError)) { - return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks.")); - } - $this->msg[$this->itemID] = "msg§" - . _("Ein neuer Gruppierungsblock wurde angelegt."); - } elseif ($mode == ARRANGMENT_BLOCK) { - $parentgroup = &$this->tree->getGroupObject($this->itemID); - $parentgroup->addChild($group); - $parentgroup->save(); - if (!empty($parentgroup->isError)) { - return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks.")); - } - $this->msg[$this->itemID] = "msg§" - . _("Ein neuer Gruppierungsblock wurde angelegt."); - } - - $this->execCommandUpdateItem(); - - return true; - } - - /** - * adds a questions-group - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandAddQGroup() - { - - - $group = new EvaluationGroup(); - $group->setTitle(NEW_QUESTION_BLOCK_BLOCK_TITLE); - $group->setText(""); - $group->setChildType("EvaluationQuestion"); - $group->setTemplateID(Request::option("templateID")); - $template = new EvaluationQuestion (Request::option("templateID"), - NULL, EVAL_LOAD_FIRST_CHILDREN); - - $mode = $this->getInstance($this->itemID); - - if ($mode == ROOT_BLOCK) { - $this->tree->eval->addChild($group); - $this->tree->eval->save(); - if (!empty($this->tree->eval->isError)) { - return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks.")); - } - $this->msg[$this->itemID] = "msg§" - . _("Ein neuer Fragenblock wurde angelegt."); - }// group - elseif ($mode == ARRANGMENT_BLOCK) { - $parentgroup =& $this->tree->getGroupObject($this->itemID); - $parentgroup->addChild($group); - $parentgroup->save(); - if (!empty($parentgroup->isError)) { - return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks.")); - } - if (Request::option("templateID") != "") - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Ein neuer Fragenblock mit der Antwortenvorlage <b>%s</b> wurde angelegt."), - htmlReady($template->getText())); - else - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Ein neuer Fragenblock mit keiner Antwortenvorlage wurde angelegt."), - 1); - } - $this->execCommandUpdateItem(); - - return true; - } - - /** - * Updates the templateID of a group - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandChangeTemplate() - { - - - $this->execCommandUpdateItem(); - - $group = &$this->tree->getGroupObject($this->itemID); - $group->setTemplateID(Request::option("templateID")); - $group->save(); - - if (!empty($group->isError)) { - return MessageBox::error(_("Fehler beim Zuordnen eines Templates.")); - } - - $templateID = $group->getTemplateID(); - if ($templateID) { - - $template = new EvaluationQuestion($templateID); - $templateTitle = htmlReady($template->getText()); - - } else - $templateTitle = NO_TEMPLATE_GROUP; - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Die Vorlage <b>%s</b> wurde dem Fragenblock zugeordnet."), - $templateTitle); - - return true; - } - - /** - * Update the Question content - * - * @access private - * @param boolean $no_delete YES/NO (optional) - * @return string the udpatemessage - */ - function execCommandUpdateQuestions($no_delete = false) - { - - $questions = Request::getArray('questions'); - $deleteQuestions = Request::getArray('DeleteQuestions'); - - // remove any empty questions - $deletecount = 0; - - $qgroup = &$this->tree->getGroupObject($this->itemID); - $questionsDB = $qgroup->getChildren(); - $cmd = Request::optionArray('cmd'); - if (!empty($cmd)) - if (key($cmd) == "UpdateItem") - $delete_empty_questions = 1; - - for ($i = 0; $i < count($questions); $i++) { - - if (!isset($deleteQuestions[$i])) { - $question = new EvaluationQuestion($questions[$i]['questionID'], NULL, - EVAL_LOAD_FIRST_CHILDREN); - - // remove any empty questions - if ((empty($questions[$i]['text'])) && $delete_empty_questions) { - - $question->delete(); - $deletecount++; - - // upadate the questiontext to the db - } else { - - $question->setText($questions[$i]['text']); - $question->save(); - } - } - } - $msg = NULL; - if ($deletecount == 1) - $msg = _("Es wurde eine leere Frage entfernt."); - elseif ($deletecount > 1) - $msg = sprintf(_("Es wurden %s leere Fragen entfernt."), $deletecount); - - return $msg; - } - - /** - * Adds Questions - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandAddQuestions() - { - - $addquestions = Request::get('newQuestionFields'); - - $qgroup = &$this->tree->getGroupObject($this->itemID); - $templateID = $qgroup->getTemplateID(); - - for ($i = 1; $i <= $addquestions; $i++) { - $template = new EvaluationQuestion ($templateID, NULL, EVAL_LOAD_FIRST_CHILDREN); - $newquestion = $template->duplicate(); - $newquestion->setText(""); - $qgroup->addChild($newquestion); - $qgroup->save(); - if (!empty($qgroup->isError)) { - return MessageBox::error(_("Fehler beim Anlegen neuer Fragen.")); - } - } - - if ($addquestions == "1") - $this->msg[$this->itemID] = "msg§" - . _("Es wurde eine neue Frage hinzugefügt."); - else - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Es wurden %s neue Fragen hinzugefügt."), $addquestions); - - $this->execCommandUpdateItem(NO); - - return true; - } - - /** - * deletes questions - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandDeleteQuestions() - { - - $questions = Request::getArray('questions'); - $deleteQuestions = Request::getArray('DeleteQuestions'); - - $deletecount = 0; - for ($i = 0; $i < count($questions); $i++) { - - $question = new EvaluationQuestion($questions[$i]['questionID'], NULL, - EVAL_LOAD_ALL_CHILDREN); - - // remove any empty questions - if ($deleteQuestions[$i]) { - $question->delete(); - $deletecount++; - } - } - - if ($deletecount == "1") - $this->msg[$this->itemID] = "msg§" - . _("Es wurde eine Frage gelöscht."); - elseif ($deletecount > 1) - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Es wurden %s Fragen gelöscht."), $deletecount); - else - $this->msg[$this->itemID] = "msg§" - . _("Es wurde keine Frage gelöscht."); - - $this->execCommandUpdateItem(); - - return true; - } - - /** - * creates an info-message and updates the item - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandQuestionAnswersCreate() - { - - $this->execCommandUpdateItem(); - - // extract the questionID from the command - foreach ($_REQUEST as $key => $value) { - if (preg_match("/template_(.*)_button?/", $key, $command)) - break; - } - if (preg_match("/(.*)_#(.*)/", $command[1], $command_parts)) - $questionID = $command_parts[2]; - - $question = new EvaluationQuestion($questionID); - $questiontitle = htmlReady($question->getText()); - - $this->msg[$this->itemID] = "msg§" -# . sprintf(_("Sie können nun der Frage <b>%s</b> im rechten Bereich Antworten zuweisen.") -# , $questiontitle) -# . "<br>" - . _("Veränderungen wurden gespeichert."); - - return true; - } - - /** - * creates an confirm-message if answers were created - * - * @access private - * @return boolean false - */ - function execCommandQuestionAnswersCreated() - { - - $id = $this->itemID; - - $question = new EvaluationQuestion(Request::get("questionID")); - $title = htmlready($question->getTitle()); - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Der Frage <b>%s</b> wurden Antwortenmöglichkeiten zugewiesen."), $title); - - $this->changed = true; - - return false; - } - - /** - * Moves a Questions - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandMoveQuestionUp() - { - - $this->execCommandUpdateItem(); - - foreach ($_REQUEST as $key => $value) { - if (preg_match("/cmd_(.*)_#(.*)_§(.*)_button(_x)?/", $key, $command)) - break; - } - - $questionID = $command[2]; - $oldposition = $command[3]; - - $this->swapPosition($this->itemID, $questionID, $oldposition, - "up"); - - if ($oldposition == 0) - $this->msg[$this->itemID] = "msg§" - . _("Die Frage wurde von Position 1 an die letzte Stelle verschoben."); - else - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Die Frage wurde von Position %s nach oben verschoben."), $oldposition + 1); - - $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert."); - return true; - } - - /** - * Moves a Questions - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandMoveQuestionDown() - { - - $this->execCommandUpdateItem(); - - foreach ($_REQUEST as $key => $value) { - if (preg_match("/cmd_(.*)_#(.*)_§(.*)_button(_x)?/", $key, $command)) - break; - } - - $questionID = $command[2]; - $oldposition = $command[3]; - - $this->swapPosition($this->itemID, $questionID, $oldposition, - "down"); - - $this->msg[$this->itemID] = "msg§" . sprintf( - _("Die Frage wurde von Position %s nach unten verschoben."), - $oldposition + 1 - ); - - $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert."); - return true; - } - - - public function execCommandMove() - { - $direction = Request::option('direction'); - - $group = &$this->tree->getGroupObject(Request::option('groupID')); - $oldposition = $group->getPosition(); - - $this->swapPosition($this->itemID, $group->objectID, $oldposition, $direction); - - $this->msg[$this->itemID] = "msg§ "; - if (($this->itemID != ROOT_BLOCK) - && ($group->getChildType() == "EvaluationQuestion")) - $this->msg[$this->itemID] .= _("Fragenblock"); - else - $this->msg[$this->itemID] .= _("Gruppierungsblock"); - - if (($oldposition == 0) && ($direction == "up")) - $this->msg[$this->itemID] .= - _(" wurde von Position 1 an die letzte Stelle verschoben."); - elseif (($oldposition == $group->getNumberChildren() - 1) - && ($direction == "down")) - $this->msg[$this->itemID] .= - sprintf(_(" wurde von Position %s an die erste Stelle verschoben.") - , $oldposition + 1); - else - $this->msg[$this->itemID] .= (($direction == "up") - ? sprintf(_(" wurde von Position %s nach oben verschoben."), $oldposition + 1) - : sprintf(_(" wurde von Position %s nach unten verschoben."), $oldposition + 1)); - - $this->changed = true; - - return true; - } - - /** - * Moves a Group from one parent to another - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandMoveGroup() - { - - - $moveGroupeID = Request::option('moveGroupeID'); - - if (!$this->moveItemID) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Es wurde kein Block zum verschieben ausgewählt."); - return false; - } - - $mode = $this->getInstance($this->itemID); - - if (!$mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der Zielblock besitzt keinen Typ."); - return false; - } - - $move_mode = $this->getInstance($this->moveItemID); - - if (!$move_mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der Zielblock besitzt keinen Typ."); - return false; - } - - $move_group =& $this->tree->getGroupObject($this->moveItemID); - $move_group_title = htmlready($move_group->getTitle()); - $oldparentID = $move_group->getParentID(); - - switch ($mode) { - - case ROOT_BLOCK: - - if ($children = $this->tree->eval->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) != $move_mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der ausgewählte Block und der Zielblock besitzen verschiedene Typen."); - return false; - } - } - - $newgroup = $move_group->duplicate(); - - $this->tree->eval->addChild($newgroup); - $this->tree->eval->save(); - - if (($oldparentID == $this->evalID) || $oldparentID == "root") { - - $grouptodelete = $this->tree->eval->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $this->tree->eval->save(); - if (!empty($this->tree->eval->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - } else { - - $oldparentgroup = &$this->tree->getGroupObject($oldparentID); - $grouptodelete = $oldparentgroup->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $oldparentgroup->save(); - } - - if (!empty($this->tree->eval->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($move_group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($newgroup->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($grouptodelete->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Der Block <b>%s</b> wurde in die Hauptebene verschoben."), - $move_group_title); - break; - - case ARRANGMENT_BLOCK: - - $group = &$this->tree->getGroupObject($this->itemID); - if ($children = $group->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) != $move_mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der ausgewählte Block und der Zielblock besitzen verschiedene Typen."); - return false; - } - } - if ($oldparentID == $this->evalID) { - $grouptodelete = $this->tree->eval->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $this->tree->eval->save(); - if (!empty($this->tree->eval->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - } else { - - $oldparentgroup = &$this->tree->getGroupObject($oldparentID); - $grouptodelete = $oldparentgroup->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $oldparentgroup->save(); - if (!empty($oldparentgroup->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - } - $newgroup = $move_group->duplicate(); - - $group->addChild($newgroup); - $group->save(); - - - if (!empty($group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($move_group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($newgroup->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($grouptodelete->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Der Block <b>%s</b> wurde in diesen Gruppierungsblock verschoben."), - $move_group_title); - break; - - case QUESTION_BLOCK: - - $group = &$this->tree->getGroupObject($this->itemID); - - if ($children = $group->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) != $move_mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der ausgewählte Block und der Zielblock besitzen verschiedene Typen."); - return false; - } - } - - $oldparentID = $move_group->getParentID(); - if ($oldparentID == ROOT_BLOCK) { - - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Ein Fragenblock kann nicht auf die oberste Ebene verschoben werden."); - return false; - } elseif ($oldparentID == $this->evalID) { - - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Ein Fragenblock kann nicht auf die oberste Ebene verschoben werden."); - return false; - } else { - - $oldparent = &$this->tree->getGroupObject($oldparentID); - } - - $newgroup = $move_group->duplicate(); - - $group->addChild($newgroup); - $group->save(); - - $grouptodelete = $oldparent->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $oldparent->save(); - - - if (!empty($group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($move_group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($newgroup->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($grouptodelete->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($oldparent->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Der Block <b>%s</b> wurde in diesen Fragenblock verschoben."), - $move_group_title); - - break; - } - - $this->moveItemID = NULL; - - $this->changed = true; - - return true; - } - -# ##################################################### end: command functions # - - -################################################################################ -# # -# HTML functions # -# # -################################################################################ - - /** - * creates the html for the create new group options - * - * @access private - * - * @param string $show the blocktyp to display - * @return string the buttons (html) - */ - function createButtonbar($show = ARRANGMENT_BLOCK) - { - - $infotext = _("Sie können ...") . "\n"; - - $table = new HTML ("table"); - $table->addAttr("width", "100%"); - $table->addAttr("class", "blank"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "6"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("div", "left"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "steelgrau"); - $td->addAttr("align", "center"); - - $seperator = " | "; - - // the update-button - $buttons = " " - . Button::create(_('Übernehmen'), - 'cmd[UpdateItem]', - ['title' => _('Die Veränderungen innerhalb des Blockes speichern.')]); - - $infotext .= "\n" - . _("- die Veränderungen dieses Blocks speichern."); - - // the new group-button - if ($show == "both" || $show == ARRANGMENT_BLOCK || $show == ROOT_BLOCK) { - $buttons .= $seperator - . Button::create(_('Erstellen'), - 'cmd[AddGroup]', - ['title' => _('Einen neuen Gruppierungsblock erstellen.')]); - $infotext .= "\n" - . _("- einen neuen Gruppierungsblock innerhalb dieses Blockes erstellen, in welchem Sie weitere Gruppierungs- oder Fragenblöcke anlegen können."); - } - - // the new question-group-button - if ($show == "both" || $show == QUESTION_BLOCK) { - - $buttons .= $seperator - . $this->createTemplateSelection() - . Button::create(_('Erstellen'), - 'cmd[AddQGroup]', - ['title' => _('Einen neuen Fragenblock mit der ausgewählten Antwortenvorlage erstellen.')]); - $infotext .= "\n" - . _("- einen neuen Fragenblock innherhalb dieses Blockes erstellen. Geben Sie dazu bitte eine Antwortenvorlage an, welche für alle Fragen des neuen Fragenblockes verwendet wird."); - } - - // the move-button - if ($this->itemID != ROOT_BLOCK && !$this->moveItemID) { - - $a = new HTML ("a"); - $a->addAttr("href", - URLHelper::getLink($this->getSelf("&moveItemID=" . $this->itemID))); - - $img = new HTMLempty ("img"); - $img->addAttr("border", "0"); - $img->addAttr("style", "vertical-align:middle;"); - $img->addAttr("src", EVAL_PIC_MOVE_BUTTON); - $img->addAttr("style", "vertical-align:middle;"); - $img->addString(tooltip(_("Diesen Block verschieben."))); - - $a->addContent($img); - - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "&moveItemID=" . $this->itemID); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", EVAL_PIC_MOVE_BUTTON); - $button->addString(Tooltip(_("Diesen Block verschieben."))); - - $buttons .= $seperator - . Button::create(_('verschieben'), - 'create_moveItemID', - ['title' => _('Diesen Block verschieben.')]); -# . $a->createContent (); - $infotext .= "\n" - . _("- diesen Block zum Verschieben markieren."); - - $movebutton = 1; - } - - - // the delete-button - if ($this->itemID != ROOT_BLOCK) { - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "cmd[AssertDeleteItem]"); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", EVAL_PIC_DELETE_GROUP); - $button->addString(Tooltip(_("Diesen Block und alle seine Unterblöcke löschen."))); - - $buttons .= ($movebutton) - ? " " - : $seperator; - $buttons .= Button::create(_('Löschen'), - 'cmd[AssertDeleteItem]', - ['title' => _('Diesen Block (und alle seine Unterblöcke) löschen..')]); -# $buttons .= $button->createContent (); - - $infotext .= "\n" - . _("- diesen Block und seine Unterblöcke löschen."); - } - - // the abort-button - $child = $this->tree->eval->getNextChild(); - $number_of_childs = $this->tree->eval->getNumberChildren(); - if ($number_of_childs == 1 && - $this->itemID == ROOT_BLOCK && - $this->tree->eval->getTitle() == NEW_EVALUATION_TITLE && - $this->tree->eval->getText() == "" && - $child && - $child->getTitle() == FIRST_ARRANGMENT_BLOCK_TITLE && - $child->getChildren() == NULL && - isset($child->getText) && $child->getText == "") { - - $a_content = LinkButton::createCancel(_('Abbrechen'), - URLHelper::getURL(EVAL_FILE_ADMIN . "?evalID=") . $this->tree->eval->getObjectID() . "&abort_creation_button=1", - ['title' => _("Erstellung einer Evaluation abbrechen")]); - - $buttons .= $seperator - . $a_content; - $infotext .= "\n" - . _("Die Erstellung dieser Evaluation abbrechen."); - } - - $td->addHTMLContent( - $this->createImage(EVAL_PIC_HELP, $infotext)); - $td->addHTMLContent($buttons); - $tr->addContent($td); - $table->addContent($tr); - - - return $table->createContent(); - } - - /** - * creates the html for the create new group options - * - * @access private - * @param string $show - * @return string the html - */ - function createFormNew($show = ARRANGMENT_BLOCK) - { - - $table = new HTML ("table"); - $table->addAttr("width", "100%"); - $table->addAttr("class", "blank"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "6"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("div", "left"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "blank"); - $td->addAttr("align", "center"); - $td->addContent(new HTMLempty ("br")); - -# $tr->addContent ($td); -# $table->addContent ($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "content_body"); -# $td->addAttr ("class","steelgrau"); - $td->addAttr("align", "center"); - - $img = new HTMLempty ("img"); - $img->addAttr("src", Assets::image_path("blank.gif")); - $img->addAttr("width", "30"); - $img->addAttr("height", "1"); - $img->addAttr("alt", ""); - -# $td->addContent ($img); -# $td->addContent (new HTMLempty ("br")); - - - $group_selection = _("Gruppierungsblock") - . " " - . Button::create(_('Erstellen'), - 'cmd[AddGroup]', - ['title' => _('Einen neuen Gruppierungsblock erstellen')]); - - $qgroup_selection = _("Fragenblock mit") - . " " - . $this->createTemplateSelection() - . Button::create(_('Erstellen'), - 'cmd[AddQGroup]', - ['title' => _('Einen neuen Fragenblock erstellen')]); - - $seperator = " | "; - - switch ($show) { - case ARRANGMENT_BLOCK: - $td->addHTMLContent($group_selection); - break; - case QUESTION_BLOCK: - $td->addHTMLContent($qgroup_selection); - break; - case "both": - $td->addHTMLContent( - $group_selection - . $seperator - . $qgroup_selection); - break; - } - - // abort-button - $child = $this->tree->eval->getNextChild(); - $number_of_childs = $this->tree->eval->getNumberChildren(); - if ($number_of_childs == 1 && - $this->itemID == ROOT_BLOCK && - $this->tree->eval->getTitle() == _("Neue Evaluation") && - $this->tree->eval->getText() == "" && - $child && - $child->getTitle() == _("Erster Gruppierungsblock") && - $child->getChildren() == NULL && - $child->getText == "") { - - - $cancel = $seperator . " "; - - $a_content = LinkButton::createCancel(_('Abbrechen'), - URLHelper::getURL(EVAL_FILE_ADMIN . "?evalID=" . $this->tree->eval->getObjectID() . "&abort_creation_button=1"), - ['title' => _("Erstellung einer Evaluation abbrechen")]); - - $cancel .= $a_content; - - $td->addHTMLContent($cancel); - - } - - $tr->addContent($td); - $table->addContent($tr); - - - return $table->createContent(); - } - - /** - * creates the html for the title and text input - * - * @access private - * @param string $mode - * @return string the html - */ - function createTitleInput($mode = ROOT_BLOCK) - { - - switch ($mode) { - - case ROOT_BLOCK: - $title_label = _("Titel der Evaluation"); - $title = htmlReady($this->tree->eval->getTitle()); - $text_label = _("Zusätzlicher Text"); - $text = wysiwygReady($this->tree->eval->getText()); - break; - - case ARRANGMENT_BLOCK: - $title_label = _("Titel des Gruppierungsblocks"); - $group = &$this->tree->getGroupObject($this->itemID); - $title = htmlReady($group->getTitle()); - $text_label = _("Zusätzlicher Text"); - $text = wysiwygReady($group->getText()); - break; - - case QUESTION_BLOCK: - $title_label = _("Titel des Fragenblocks"); - $title_info = _("Die Angabe des Titels ist bei einem Fragenblock optional."); - $group = &$this->tree->getGroupObject($this->itemID); - $title = htmlReady($group->getTitle()); - $text_label = _("Zusätzlicher Text"); - $text = wysiwygReady($group->getText()); - break; - } - $text_info = _("Die Angabe des zusätzlichen Textes ist optional."); - - $table = new HTML ("table"); - $table->addAttr("width", "98%"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("cellpadding", "0"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr('colspan', '2'); - $label = new HTML('label'); - $label->addContent($title_label); - if ($mode == QUESTION_BLOCK) - $label->addHTMLContent($this->createImage(EVAL_PIC_HELP, $title_info)); - - - $input = new HTMLempty ("input"); - $input->addAttr("type", "text"); - $input->addAttr("name", "title"); - $input->addString("value=\"" . $title . "\""); - $input->addAttr("size", "60"); - $input->addAttr("style", "vertical-align:middle; width: 100%;"); - - $label->addContent($input); - - $td->addContent($label); - $tr->addContent($td); - $table->addContent($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr('colspan', '2'); - - $label = new HTML('label'); - $label->addContent($text_label); - $label->addHTMLContent($this->createImage(EVAL_PIC_HELP, $text_info)); - - $textarea = "<br><textarea class=\"wysiwyg\" name=\"text\" rows=\"4\" " - . "style=\"vertical-align:top; width: 100%;\">"; - $textarea .= ($text) - ? $text - : ""; - $textarea .= "</textarea>"; - - $label->addHTMLContent($textarea); - $label->setTextareaCheck(); - - $td->addContent($label); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - /** - * creates the html for the update button - * - * @access private - * @param string $mode - * @return string the html - */ - function createUpdateButton($mode = NULL) - { - - $button = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" " - . "cellspacing=\"2\">\n" - . " <tr>\n" - . " <td align=center>\n" -// . " <input type=hidden name=\"cmd\" value=\"UpdateItem\">\n" - . Button::create(_('Übernehmen'), - 'cmd[UpdateItem]', - ['title' => _('Änderungen übernehmen.')]); - - if ($mode == NULL) { - $button .= " | " . _("Diesen Block") . " " - . Button::create(_('Löschen'), - 'cmd[AssertDeleteItem]', - ['title', _('Diesen Block und alle seine Unterblöcke löschen.')]); - } - - $button .= " </td>\n" - . " </tr>\n" -// . " </form></tr>\n" - . "</table>\n"; - return $button; - } - - /** - * creates the html for the global features-input - * - * @access private - * @return string the html - */ - function createGlobalFeatures() - { - - $table = new HTML ("table"); - $table->addAttr("width", "99%"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("cellspacing", "2"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "table_row_odd"); - $td->addAttr("colspan", "2"); - - $b = new HTML ("b"); - $b->addContent(_("Globale Eigenschaften")); - - $td->addContent($b); - $tr->addContent($td); - $table->addContent($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr('colspan', '2'); - - $div = new HTML('div'); - $div->addContent(_("Die Auswertung der Evaluation läuft")); - - $td->addContent($div); - - $section = new HTML('section'); - $section->addAttr('class', 'hgroup'); - - $l1 = new HTML('label'); - $input = new HTMLempty ("input"); - $input->addAttr("type", "radio"); - $input->addAttr("value", "1"); - $input->addAttr("name", "anonymous"); - if ($this->tree->eval->isAnonymous()) - $input->addAttr("checked", "checked"); - $l1->addContent($input); - $l1->addContent(_("anonym")); - - $l2 = new HTML('label'); - $input2 = new HTMLempty ("input"); - $input2->addAttr("type", "radio"); - $input2->addAttr("value", "0"); - $input2->addAttr("name", "anonymous"); - if (!$this->tree->eval->isAnonymous()) - $input2->addAttr("checked", "checked"); - $l2->addContent($input2); - $l2->addContent(_("personalisiert")); - - $section->addContent($l1); - $section->addContent($l2); - - $td->addContent($section); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - /** - * creates the html for the global features-input - * - * @access private - * @return string the html - */ - function createQuestionFeatures() - { - - $group = &$this->tree->getGroupObject($this->itemID); - $templateID = $group->getTemplateID(); - - if ($templateID) { - $template = new EvaluationQuestion($templateID); - $templateTitle = htmlReady($template->getText()); - } else - $templateTitle = NO_TEMPLATE_GROUP;//_("keine Vorlage"); - - if ($templateTitle == "") - $templateTitle = NO_TEMPLATE; - - $table = new HTML ("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "0"); - $table->addAttr("width", "98%"); -// $table->addAttr ("style", "border:5px solid white;"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "table_row_odd"); - $td->addAttr("colspan", "2"); - - $b = new HTML ("b"); - $b->addContent(_("Eigenschaften")); - $b->addContent(":"); - - $td->addContent($b); - $tr->addContent($td); - $table->addContent($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("style", "border-bottom:0px dotted black;"); - $td->addContent(_("Die Fragen dieses Blocks müssen beantwortet werden (Pflichtfelder):")); - - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("style", "border-bottom:0px dotted black;"); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "radio"); - $input->addAttr("value", "0"); - $input->addAttr("name", "mandatory"); - if (!$group->isMandatory()) $input->addAttr("checked", "checked"); - - $td->addContent($input); - $td->addContent(_("nein")); - $td->addContent(new HTMLempty ("br")); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "radio"); - $input->addAttr("value", "1"); - $input->addAttr("name", "mandatory"); - if ($group->isMandatory()) $input->addAttr("checked", "checked"); - - $td->addContent($input); - $td->addContent(_("ja")); - - $tr->addContent($td); - $table->addContent($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("style", "border-bottom:0px dotted black;"); - $td->addHTMLContent(sprintf(_("Diesem Fragenblock ist die Antwortenvorlage <b>%s</b> zugewiesen."), - $templateTitle)); - $text = _("Das Zuweisen einer Antwortenvorlage ändert alle Antwortenmöglichkeiten der Fragen dieses Fragenblocks."); - if ($templateTitle == NO_TEMPLATE_GROUP) - $text .= " " . _("Da dieser Fragenblock keine Antwortenvorlage benutzt, würde ein Zuweisen einer Antwortenvorlage zum Verlust aller eingegebenen Antworten führen."); - - $td->addHTMLContent($this->createImage(EVAL_PIC_HELP, - $text)); - - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("style", "border-bottom:0px dotted black;"); - $td->addAttr("nowrap", "nowrap"); - $td->addHTMLContent($this->createTemplateSelection($templateID)); - $td->addContent(" "); - $td->addHTMLContent(Button::create(_('Zuweisen'), - 'cmd[ChangeTemplate]', - ['title' => _('Eine andere Antwortenvorlage für diesen Fragenblock auswählen')])); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - /** - * creates the html for the question-input - * - * @access private - * @return string the html - */ - function createQuestionForm() - { - - $qgroup = &$this->tree->getGroupObject($this->itemID); - $questions = $qgroup->getChildren(); - $templateID = $qgroup->getTemplateID(); - - $table = new HTML ("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "98%"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("align", "center"); - - $table2 = new HTML ("table"); - $table2->addAttr("border", "0"); - $table2->addAttr("class", "blank"); - $table2->addAttr("cellspacing", "0"); - $table2->addAttr("cellpadding", "0"); - $table2->addAttr("width", "100%"); - - // captions - $tr2 = new HTML ("tr"); - - $showclass = "table_row_odd"; - - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - $td2->addAttr("align", "center"); - $td2->addAttr("width", "15"); - - $b = new HTML ("b"); - $b->addContent("#"); - - $td2->addContent($b); - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - - $b = new HTML ("b"); - $b->addContent(_("Frage")); - - $td2->addContent($b); - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - - if (count($questions) > 1) { - $b = new HTML ("b"); - $b->addContent(_("Position")); - - $td2->addContent($b); - - } else { - - $td2->addContent(""); - - } - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - - $b = new HTML ("b"); - $b->addContent(_("Löschen")); - - $td2->addContent($b); - $tr2->addContent($td2); - - // only if template is NO_TEMPLATE_GROUP - if ($templateID == NULL) { - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - - $b = new HTML ("b"); - $b->addContent(_("Antworten")); - - $td2->addContent($b); - $tr2->addContent($td2); - } - - $table2->addContent($tr2); - - $i = 0; - foreach ($questions as $question) { - $tr2 = new HTML ("tr"); - - // brrr :) - // extract the questionID from the command - foreach ($_REQUEST as $key => $value) { - if (preg_match("/template_(.*)_button?/", $key, $command)) - break; - } - if (isset($command[1]) && preg_match("/(.*)_#(.*)/", $command[1], $command_parts)) - $questionID = $command_parts[2]; - else - $questionID = Request::submitted('template_save2_button') ? "" : Request::get("template_id"); - - if ($question->getObjectID() == $questionID) - $tr2->addAttr("class", "eval_highlight"); - else - $tr2->addAttr("class", ($i % 2 == 1 ? "table_row_odd" : "table_row_even")); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - - $font = new HTML ("font"); - $font->addAttr("size", "-1"); - $font->addContent(($i + 1) . "."); - - $td2->addContent($font); - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "left"); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "tex"); - $input->addAttr("size", "70"); - $input->addAttr("name", "questions[$i][text]"); - $input->addAttr("value", $question->getText()); - $input->addAttr("tabindex", 3 + $i); - - $td2->addContent($input); -# $td2->addHTMLContent ("POST: -".$question->getPosition()."-!"); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("name", "questions[$i][questionID]"); - $input->addAttr("value", $question->getObjectID()); - - $td2->addContent($input); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("name", "questions[$i][position]"); - $input->addAttr("value", $question->getPosition()); - - $td2->addContent($input); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("name", "questions[$i][counter]"); - $input->addAttr("value", $question->getPosition()); - - $td2->addContent($input); - - $tr2->addContent($td2); - - // move-up/down arrows and counter - if (count($questions) > 1) { - - $numberchildren = $qgroup->getNumberChildren(); - - if ($question->getPosition() == 0) - $tooltipup = _("Diese Frage mit der letzten Frage vertauschen."); - else - $tooltipup = _("Diese Frage eine Position nach oben verschieben."); - - if ($question->getPosition() == $numberchildren - 1) - $tooltipdown = _("Diese Frage mit der ersten Frage vertauschen."); - else - $tooltipdown = _("Diese Frage eine Position nach unten verschieben."); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "cmd_MoveQuestionUp_#" . $question->getObjectID() . "_§" . $question->getPosition() . "_button"); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", EVAL_PIC_MOVE_UP); - $button->addString(Tooltip($tooltipup)); - - $td2->addContent($button); - - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "cmd_MoveQuestionDown_#" . $question->getObjectID() . "_§" . $question->getPosition() . "_button"); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", EVAL_PIC_MOVE_DOWN); - $button->addString(Tooltip($tooltipdown)); - - $td2->addContent($button); - - } else { - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - $td2->addContent(" "); - } - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "checkbox"); - $input->addAttr("id", "deleteCheckboxes"); - $input->addAttr("name", "DeleteQuestions[" . $question->getPosition() . "]"); - - $td2->addContent($input); - $tr2->addContent($td2); - - // if template is NO_TEMPLATE_GROUP - if ($templateID == NULL) { - - // hat noch keine antworten - if ($question->getChildren() == NULL) { - $image = EVAL_PIC_CREATE_ANSWERS; - $text = _("Dieser Frage wurden noch keine Antwortenmöglichkeiten zugewiesen. Drücken Sie auf den Doppelfpeil, um dies jetzt zu tun."); - $tooltip = tooltip(_("Dieser Frage Antwortenmöglichkeiten zuweisen.")); - } else { - $image = EVAL_PIC_EDIT_ANSWERS; - $text = _("Dieser Frage wurden bereits folgende Antwortenmöglichkeiten zugewiesen:") - . " "; - $tooltip = tooltip(_("Die zugewiesenen Antwortenmöglichkeiten bearbeiten.")); - $text .= "\n"; - while ($answer = $question->getNextChild()) { - $text .= "\"" . $answer->getText() . "\"\n "; - } - $text .= ""; - } - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - $td2->addAttr("valign", "middle"); - $td2->addHTMLContent( - $this->createImage(EVAL_PIC_HELP, $text)); - - $questionID = $question->getObjectID(); - - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "template_create_question_answers_#" . $questionID . "_button"); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", $image); - $button->addString($tooltip); - - $td2->addContent($button); - - - $tr2->addContent($td2); - } - - $table2->addContent($tr2); - $i++; - } - - if (sizeof($questions) == 0) { - - $tr2 = new HTML ("tr"); - $td2->addAttr("class", "table_row_even"); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - $td2->addContent(" "); - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addContent(_("Dieser Block besitzt keine Fragen.")); - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addContent(" "); - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addContent(" "); - - $tr2->addContent($td2); - $table2->addContent($tr2); - } - - $td->addContent($table2); - - // the new questions und delete questions buttons - $table2 = new HTML ("table"); - $table2->addAttr("width", "100%"); - $table2->addAttr("border", "0"); - $table2->addAttr("class", - ($i % 2 == 6) - ? "content_body" - : "content_body"); - $table2->addAttr("cellspacing", "0"); - $table2->addAttr("cellpadding", "2"); - - // buttons - $tr2 = new HTML ("tr"); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "left"); - - $select = new HTML ("select"); - $select->addAttr("style", "vertical-align:middle;"); - $select->addAttr("name", "newQuestionFields"); - $select->addAttr("size", "1"); - - for ($i = 1; $i <= 10; $i++) { - - $option = new HTML ("option"); - $option->addAttr("value", $i); - $option->addContent($i); - - $select->addContent($option); - } - - $td2->addContent($select); - $td2->addContent(_("Frage/en")); - $td2->addContent(" "); - $td2->addHTMLContent( - Button::create(_('Hinzufügen'), - 'cmd[AddQuestions]', - ['title' => _('Fragen hinzufügen')]) - ); - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "right"); - - $font = new HTML ("font"); - $font->addAttr("size", "-1"); - $font->addContent(_("markierte Fragen ")); - - $td2->addContent($font); - $td2->addHTMLContent( - Button::create(_('Löschen'), - 'cmd[DeleteQuestions]', - ['title' => _('Markierte Fragen löschen')]) - ); - - $tr2->addContent($td2); - $table2->addContent($tr2); - - $td->addContent($table2); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } -# ######################################################## end: HTML functions # - - -################################################################################ -# # -# additional HTML functions # -# # -################################################################################ - - /** - * creates a link-image - * - * @access private - * @param string $pic the image - * @param string $alt the alt-text (optional) - * @param string $value the value (optional) - * @param boolean $tooltip display as tooltip? (optional) - * @param string $args additional options (optional) - * @param boolean $self get self? (optional) - * @return string the image with a link (html) - */ - function createLinkImage($pic, - $alt = "", - $value = "", - $tooltip = true, - $args = NULL, - $self = true) - { - - $a = new HTML ("a"); - $a->addAttr("href", URLHelper::getLink($this->getSelf($value))); - - $img = new HTMLempty ("img"); - $img->addAttr("src", $pic); - $img->addAttr("border", "0"); - $img->addAttr("style", "vertical-align:middle;"); - if ($tooltip) - $img->addString(tooltip($alt, TRUE, TRUE)); - else - $img->addAttr("alt", $alt); - if ($args) - $img->addString($args); - - $a->addContent($img); - - return $a->createContent(); - } - - - /** - * creates an image - * - * @access private - * @param string $pic the image - * @param string $alt the alt-text (optional) - * @param string $args additional options (optional) - * @return string the image (html) - */ - function createImage($pic, - $alt = "", - $args = NULL) - { - - if (!isset($args['alt'])) { - $args['alt'] = $alt; - $args['title'] = $alt; - } - - $args['border'] = 0; - $args['style'] = "vertical-align:middle;"; - - $img = new HTMLempty ("img"); - $img->addString(tooltip($alt, TRUE, TRUE)); - $img->addAttr("src", $pic); - $img->addAttr("border", "0"); - $img->addAttr("style", "vertical-align:middle;"); - if (empty($args)) { - $img->addAttr("alt", $alt); - $img->addAttr("title", $alt); - } else - $img->addString($alt); - if ($args) ; - $img->addString($args); - - return $img->createContent(); - } - - - /** - * creates an td with an image - * - * @access private - * @param string $pic the image - * @return string the image - */ - function createLevelOutputTD($pic = "forumleer.gif") - { - $td = new HTML ("td"); - $td->addAttr("class", "blank"); - $td->addAttr("background", Assets::image_path($pic)); - - $img = new HTMLempty ("img"); - $img->addAttr("width", "10"); - $img->addAttr("height", "20"); - $img->addAttr("src", Assets::image_path($pic)); - - $td->addContent($img); - - return $td->createContent(); - } - - - /** - * creates the template selection - * - * @access private - * @param string $selected the entry to be preselected (optional) - * @return string the html - */ - function createTemplateSelection($selected = NULL) - { - global $user; - - $question_show = new EvaluationQuestionDB(); - $arrayOfTemplateIDs = $question_show->getTemplateID($user->id); - $arrayOfPolTemplates = []; - $arrayOfSkalaTemplates = []; - $arrayOfNormalTemplates = []; - $arrayOfFreetextTemplates = []; - - if (is_array($arrayOfTemplateIDs)) { - foreach ($arrayOfTemplateIDs as $templateID) { - $question = new EvaluationQuestion ($templateID, NULL, - EVAL_LOAD_FIRST_CHILDREN); - $question->load(); - $questiontyp = $question->getType(); - - $questiontext = $question->getText(); - - if ($question->getParentID() == '0') - $questiontext .= " " . EVAL_ROOT_TAG; - - - switch ($questiontyp) { - - case EVALQUESTION_TYPE_POL: - array_push($arrayOfPolTemplates, [$question->getObjectID(), - ($questiontext)]); - break; - - case EVALQUESTION_TYPE_LIKERT: - array_push($arrayOfSkalaTemplates, [$question->getObjectID(), - ($questiontext)]); - break; - - case EVALQUESTION_TYPE_MC: - $answer = $question->getNextChild(); - if ($answer && $answer->isFreetext()) - array_push($arrayOfFreetextTemplates, [ - $question->getObjectID(), - ($questiontext)]); - else - array_push($arrayOfNormalTemplates, [ - $question->getObjectID(), - ($questiontext)]); - break; - } - } - - } // End: if (is_array ($arrayOfTemplateIDs)) - - - $select = new HTML ("select"); - $select->addAttr("name", "templateID"); - $select->addAttr("style", "vertical-align:middle; max-width: 250px;"); - - $option = new HTML ("option"); - $option->addAttr("value", ""); - $option->addContent(NO_TEMPLATE_GROUP); - - $select->addContent($option); - - - if (!empty($arrayOfPolTemplates) && is_array($arrayOfPolTemplates)) { - - $optgroup = new HTML ("optgroup"); - $optgroup->addAttr("label", _("Polskalen:")); - - foreach ($arrayOfPolTemplates as $template) { - $option = new HTML ("option"); - $option->addAttr("value", $template[0]); - if ($template[0] == $selected) - $option->addAttr("selected", "selected"); - $option->addHTMLContent($template[1]); - $optgroup->addContent($option); - } - - $select->addContent($optgroup); - - } - - - if (!empty($arrayOfSkalaTemplates) && is_array($arrayOfSkalaTemplates)) { - - $optgroup = new HTML ("optgroup"); - $optgroup->addAttr("label", _("Likertskalen:")); - - foreach ($arrayOfSkalaTemplates as $template) { - $option = new HTML ("option"); - $option->addAttr("value", $template[0]); - if ($template[0] == $selected) - $option->addAttr("selected", "selected"); - $option->addContent($template[1]); - $optgroup->addContent($option); - } - - $select->addContent($optgroup); - - } - - - if (!empty($arrayOfNormalTemplates) && is_array($arrayOfNormalTemplates)) { - - $optgroup = new HTML ("optgroup"); - $optgroup->addAttr("label", _("Multiple Choice:")); - - foreach ($arrayOfNormalTemplates as $template) { - $option = new HTML ("option"); - $option->addAttr("value", $template[0]); - if ($template[0] == $selected) - $option->addAttr("selected", "selected"); - $option->addContent($template[1]); - $optgroup->addContent($option); - } - - $select->addContent($optgroup); - - } - - - if (!empty($arrayOfFreetextTemplates) && is_array($arrayOfFreetextTemplates)) { - - $optgroup = new HTML ("optgroup"); - $optgroup->addAttr("label", _("Freitextantworten:")); - - foreach ($arrayOfFreetextTemplates as $template) { - $option = new HTML ("option"); - $option->addAttr("value", $template[0]); - if ($template[0] == $selected) - $option->addAttr("selected", "selected"); - $option->addContent($template[1]); - $optgroup->addContent($option); - } - - $select->addContent($optgroup); - - } - - return $select->createContent(); - - } - -# ############################################# end: additional HTML functions # - - -################################################################################ -# # -# additional functions # -# # -################################################################################ - - /** - * detects the type of an object by its itemID - * - * @access private - * @param string $itemID - * @return string the insctance of an object - */ - function getInstance($itemID) - { - - if ($itemID == ROOT_BLOCK || $itemID == $this->evalID) - return ROOT_BLOCK; - else { - $tree = TreeAbstract::GetInstance("EvaluationTree", ['evalID' => $this->evalID, - 'load_mode' => EVAL_LOAD_FIRST_CHILDREN]); - $group = &$tree->getGroupObject($itemID); - $childtype = $group->getChildType(); - - if ($childtype == "EvaluationQuestion") - return QUESTION_BLOCK; - else - return ARRANGMENT_BLOCK; - } - } - - - /** - * swaps positions of two objects - * - * @access private - * @param string $parentID the parentID - * @param string $objectID the object to swap - * @param string $oldposition the old position - * @param string $direction the direction to swap - */ - function swapPosition($parentID, - $objectID, - $oldposition, - $direction) - { - - if ($parentID == ROOT_BLOCK) $group = $this->tree->eval; - else $group = &$this->tree->getGroupObject($parentID); - - $numberchildren = $group->getNumberChildren(); - - if ($direction == "up") { - if ($oldposition == 0) - $newposition = $numberchildren - 1; - else - $newposition = $oldposition - 1; - } else { - if ($oldposition == $numberchildren - 1) - $newposition = 0; - else - $newposition = $oldposition + 1; - } - - while ($swapitem = $group->getNextChild()) { - if ($swapitem->getPosition() == $newposition) { - $swapitem->setPosition($oldposition); - $swapitem->save(); - } - } - if (($parentID != ROOT_BLOCK) && - $group->getChildType() == "EvaluationQuestion") - $object = new EvaluationQuestion ($objectID); - else - $object = &$this->tree->getGroupObject($objectID); - $object->setPosition($newposition); - $object->save(); - - if (!empty($swapitem->isError)) { - return MessageBox::error(_("Fehler beim verschieben.")); - } - if (!empty($object->isError)) { - return MessageBox::error(_("Fehler beim verschieben.")); - } - } -} diff --git a/lib/evaluation/classes/EvaluationTreeShowUser.class.php b/lib/evaluation/classes/EvaluationTreeShowUser.class.php deleted file mode 100644 index e999cb5620669c09b19258b8c11b29cc11f1b8f2..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/EvaluationTreeShowUser.class.php +++ /dev/null @@ -1,539 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +---------------------------------------------------------------------------+ -// 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. -// +---------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once HTML; -# ====================================================== end: including files # - -# Define constants ========================================================== # - -/** - * The number of pixels by which each sub-group is indented. - * @const INDENT_PIXELS - * @access private - */ -define("INDENT_PIXELS", 5); - -# ===================================================== end: define constants # - - -/** - * Class to print out html representation of an evaluation's tree - * for the participation page - * (based on /lib/classes/TreeView.class) - * - * @author mcohrs <michael A7 cohrs D07 de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - */ -class EvaluationTreeShowUser -{ - - /** - * Reference to the tree structure - * - * @access private - * @var object EvaluationTree $tree - */ - var $tree; - - /** - * contains the item with the current html anchor (currently unused) - * - * @access public - * @var string $anchor - */ - var $anchor; - - /** - * the item to start with - * - * @access private - * @var string $start_item_id - */ - var $start_item_id; - - - /** - * constructor - * @access public - * @param string the eval's ID - */ - public function __construct($evalID) - { - - $this->tree = TreeAbstract::GetInstance("EvaluationTree", ['evalID' => $evalID, - 'load_mode' => EVAL_LOAD_ALL_CHILDREN]); - - } - - - /** - * prints out the tree beginning with a given item - * - * @access public - * @param string ID of the start item, shouldnt be needed. - */ - public function showTree($item_id = "root") - { - $items = []; - - if (!is_array($item_id)) { - $items[0] = $item_id; - $this->start_item_id = $item_id; - } else { - $items = $item_id; - } - - $num_items = count($items); - for ($j = 0; $j < $num_items; ++$j) { - - $this->printLevelOutput($items[$j]); - $this->printItemOutput($items[$j]); - - if ($this->tree->hasKids($items[$j])) { - $this->showTree($this->tree->tree_childs[$items[$j]]); - } - } - return; - } - - - /** - * prints out ... hmm ... the group's level indentation space, and a table start - * - * @access private - * @param string ID of the item (which is an EvaluationGroup) to print the space for. - */ - public function printLevelOutput($group_id) - { - if ($group_id == "root") - return; - - $level_output = ""; - - $parent_id = $group_id; - while ($this->tree->tree_data[$parent_id]['parent_id'] != $this->start_item_id) { - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - - /* a little space to indent subgroups */ - $level_output .= - "<td valign=\"top\" width=\"" . INDENT_PIXELS . "\" height=\"1\" nowrap>" . - Assets::img('forumleer.gif', ['size' => INDENT_PIXELS . '@1']) . - "</td>"; - } - - echo "<!-- printLevelOutput ----------------- -->\n"; - echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n"; - echo "<tr>\n"; - echo $level_output; - return; - } - - - /** - * prints out one group - * - * @access private - * @param string ID of the item to print (which is an EvaluationGroup). - */ - public function printItemOutput($group_id) - { - if ($group_id == "root") - return; - $group = &$this->tree->getGroupObject($group_id); - - echo "<td width=\"1\">\n"; - echo "</td>\n"; - - /* show group headline, if it's not a question group */ - if ($group->getChildType() != "EvaluationQuestion") { - - /* add space after a top-level group */ - $parent = $group->getParentObject(); - if ($parent->x_instanceof() == "Evaluation" && $group->getPosition() != 0) - echo "<td colspan=\"2\" width=\"100%\"><br></td><tr>"; - - echo "<td align=\"left\" width=\"100%\" valign=\"bottom\" class=\"content_body\" style=\"padding:1px;\">\n"; - $parent_id = $group_id; - $chapter_num = ''; - while ($parent_id != "root") { - $chapter_num = ($this->tree->tree_data[$parent_id]['priority'] + 1) . "." . $chapter_num; - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - } - echo " " . $chapter_num . " "; - echo "<b>"; - echo htmlReady($this->tree->tree_data[$group_id]['name']); - echo "</b>"; - echo "</td>"; - - echo "<td width=\"1\">\n"; - echo Assets::img('forumleer.gif', ['size' => '2@1']); - echo "</td>\n"; - - } else { - echo "<td width=\"100%\"></td>"; - } - - echo "</tr>\n"; - echo "</table>\n"; - - $this->printItemDetails($group); - - return; - } - - - /** - * prints out the details for a group - * - * @access private - * @param object EvaluationGroup the group object. - */ - public function printItemDetails($group) - { - $group_id = $group->getObjectID(); - - $parent_id = $group_id; - $level_output = ''; - while ($this->tree->tree_data[$parent_id]['parent_id'] != $this->start_item_id) { - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - - /* a little space to indent subgroups */ - $level_output = "<td width=\"" . INDENT_PIXELS . "\">" . - Assets::img('forumleer.gif', ['size' => INDENT_PIXELS . '@1']) . - "</td>" . - $level_output; - } - - /* print table */ - echo "<!-- printItemDetails ----------------- -->\n"; - echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n"; - echo "<tr>\n" . $level_output; - echo "<td class=\"printcontent\" width=\"100%\" " . - ($group->getChildType() == "EvaluationQuestion" - ? ">" - : ">"); - echo $this->getGroupContent($group); - echo "</td></tr>\n"; - echo "</table>\n"; - return; - } - - - /** - * returns html for the content of a group - * - * @access private - * @param object EvaluationGroup the group object. - * @return string - */ - public function getGroupContent($group) - { - $closeTable = NO; - $html = ""; - $content = ""; - - /* get title */ - $content .= $group->getChildType() == "EvaluationQuestion" && $group->getTitle() - ? "<b>" . formatReady($group->getTitle()) . "</b><br>\n" - : ""; - - /* get text */ - $content .= $group->getText() - ? formatReady($group->getText()) . "<br>\n" - : ""; - - /* get the content of questions under this group, if any */ - foreach ($group->getChildren() as $question) { - if ($question->x_instanceof() == INSTANCEOF_EVALQUESTION) { - - if ($question->getPosition() == 0) { - $content .= "\n<table width=\"100%\" cellpadding=\"3\" cellspacing=\"0\" " . - "align=\"center\" style=\"margin-top:3px;\">\n"; - } - - $content .= $this->getQuestionContent($question, $group); - $closeTable = YES; - } - } - if ($closeTable) - $content .= "</table>\n"; - - /* return if there is nothing to show */ - if (empty($content)) - return ""; - - /* build table of content */ - $style = $group->getChildType() != "EvaluationQuestion" - ? "" - : ""; - - $class = $group->getChildType() != "EvaluationQuestion" - ? "eval_gray" - : "steelgroup7"; - $html .= "\n<!-- getGroupContent ----------------- -->\n"; - $html .= "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" " . $style . ">\n"; - $html .= "<tr>\n"; - $html .= "<td align=\"left\" class=\"" . $class . "\">\n"; - $html .= $content; - $html .= "</td></tr>\n"; - $html .= "</table>\n"; - - return $html; - } - - - /** - * returns html for a question and its answers - * - * @access private - * @param object EvaluationQuestion the question object. - * @param object EvaluationGroup the question's parent-group object. - * @return string - */ - public function getQuestionContent($question, $group) - { - $type = $question->isMultipleChoice() ? "checkbox" : "radio"; - $answerBorder = "1px dotted #909090"; - $residualBorder = "1px dotted #909090"; - $answerArray = $question->getChildren(); - $hasResidual = NO; - $leftOutStyle = ($group->isMandatory() && - Request::submitted('voteButton') && - is_array($GLOBALS["mandatories"]) && - in_array($question->getObjectID(), $GLOBALS["mandatories"])) - ? "background-image:url(" . Assets::image_path("steelgroup1.gif") . "); border-left:3px solid red; border-right:3px solid red;" - : ""; - - $html = ''; - $cellWidth = null; - /* Skala (one row question) ---------------------------------------- */ - if ($question->getType() == EVALQUESTION_TYPE_LIKERT || $question->getType() == EVALQUESTION_TYPE_POL) { - - if (($numAnswers = $question->getNumberChildren()) > 0) - $cellWidth = (int)(40 / $numAnswers); - - if ($numAnswers > 0 && $answerArray[$numAnswers - 1]->isResidual()) - $hasResidual = YES; - - $lastTextAnswer = $hasResidual ? ($numAnswers - 3) : ($numAnswers - 2); - - /* Headline, only shown for first question */ - if ($question->getPosition() == 0) { - $html .= " <tr>\n"; - $html .= " <td width=\"60%\" style=\"border-bottom: $answerBorder; border-top: $answerBorder;\">"; -# $html .= mb_strlen( $group->getText() ) < 100 ? formatReady( $group->getText() ) : " "; - $html .= " "; - $html .= "</td>\n"; - foreach ($answerArray as $answer) { - $noWrap = NO; - - if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) { - if (!$answer->getText()) { - /* answer has NO text ------------ */ - if ($answer->getPosition() <= $lastTextAnswer / 2) //&& $numAnswers > 4 ) - $headCell = "<--"; - elseif ($answer->getPosition() >= round($lastTextAnswer / 2) + $lastTextAnswer % 2) //&& $numAnswers > 4 ) - $headCell = "-->"; - else - $headCell = "<- ->"; - - $noWrap = YES; - } else { - /* answer has its own text ------ */ - $headCell = formatReady($answer->getText()); - } - - $extraStyle = ""; - if ($answer->isResidual()) { - $extraStyle = "border-left: $residualBorder;"; - $html .= - "<td align=\"center\" style=\"$extraStyle\" " . - "width=\"1\"> </td>"; - } - - $html .= - " <td align=\"center\" class=\"steelgroup6\" " . - "style=\"border-bottom: $answerBorder; " . - "border-left: $answerBorder; border-top: $answerBorder; $extraStyle;\" " . - "width=\"" . $cellWidth . "%\" " . ($noWrap ? "nowrap" : "") . ">"; - $html .= $headCell; - $html .= "</td>\n"; - } - } - $html .= " </tr>\n"; - } - $class = $question->getPosition() % 2 ? "table_row_even" : "table_row_odd"; - $extraStyle = ($question->getPosition() == $group->getNumberChildren() - 1 - ? "border-bottom: $answerBorder" - : ""); - $html .= " <tr class=\"" . $class . "\">\n"; - $html .= " <td align=\"left\" width=\"60%\" style=\"$extraStyle; $leftOutStyle;\">"; - $html .= formatReady($question->getText()); - $html .= ($group->isMandatory() ? "<span class=\"eval_error\"><b>**</b></span>" : ""); - $html .= "</td>\n"; - - foreach ($answerArray as $answer) { - $number = $question->isMultipleChoice() ? "[" . $answer->getPosition() . "]" : ""; - - if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) { - $extraStyle = ""; - if ($answer->isResidual()) { - $extraStyle = "border-left: $residualBorder;"; - $html .= - "<td align=\"center\" class=\"steelgroup7\" style=\"$extraStyle\" " . - "width=\"1%\"> </td>"; - } - - $extraStyle .= ($question->getPosition() == $group->getNumberChildren() - 1 - ? " border-bottom: $answerBorder;" - : ""); - $answers = Request::getArray('answers'); - $checked = isset($answers[$question->getObjectID()]) && $answers[$question->getObjectID()] == $answer->getObjectID() ? "checked" : ""; - - $html .= " <td align=\"center\" style=\"border-left: $answerBorder; $extraStyle;\" " . - "width=\"" . $cellWidth . "%\">"; - $html .= "<input type=\"" . $type . "\" name=\"answers[" . $question->getObjectID() . "]" . $number . "\" " . - "value=\"" . $answer->getObjectID() . "\" " . $checked . ">"; - $html .= "</td>\n"; - } - } - $html .= " </tr>\n"; - /* -------------------------------------------- */ - } /* Normal (question with long answers) ----------------------------- */ - else { - $class = $question->getPosition() % 2 ? "table_row_even" : "table_row_odd"; - - /* Question ----------------------------------- */ - $html .= - "<tr class=\"" . $class . "\">" . - "<td align=\"left\" style=\"$leftOutStyle;\">" . - formatReady($question->getText()) . - ($group->isMandatory() ? "<span class=\"eval_error\"><b>**</b></span>" : "") . - "</td>" . - "</tr>\n"; - - $html .= "<tr class=\"" . $class . "\">"; - $html .= "<td>"; - $html .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\">\n"; - /* -------------------------------------------- */ - - $numberOfVisibleAnswers = 0; - foreach ($answerArray as $answer) - if (!($answer->isFreetext() && $answer->getText() != '')) - $numberOfVisibleAnswers++; - - if ($numberOfVisibleAnswers == 0) { - $html .= "<tr valign=\"middle\">\n"; - $html .= - "<td class=\"eval_error\">" . - _("Dieser Frage wurden keine Antworten zugeordnet!") . - "</td>\n"; - $html .= "</tr>\n"; - } - - /* Answers ------------------------------------ */ - foreach ($answerArray as $answer) { - if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) { - $number = $question->isMultipleChoice() ? "[" . $answer->getPosition() . "]" : ""; - - /* if not a user's answer */ - if (!($answer->isFreetext() && $answer->getText() != '')) { - $html .= "<tr valign=\"middle\">\n"; - - /* show text input field ---------- */ - if ($answer->isFreetext()) { - - // not really needed anymore - if ($numberOfVisibleAnswers > 1) - /* show a check/radio-box */ - $html .= - "<td width=\"2%\">" . - "<input type=\"" . $type . "\"" . - " name=\"answers[" . $question->getObjectID() . "]" . $number . "\"" . - " value=\"" . $answer->getObjectID() . "\">" . - "</td>\n"; - - /* one row input field */ - $freetexts = Request::getArray('freetexts'); - if ($answer->getRows() == 1) - $html .= - "<td colspan=\"2\">" . - "<input type=\"text\"" . - " name=\"freetexts[" . $question->getObjectID() . "]\"" . - " value=\"" . htmlReady(isset($freetexts[$question->getObjectID()]) ? $freetexts[$question->getObjectID()] : '') . "\" size=\"60\">" . - "</td>\n"; - - /* multiple row input field (textarea) */ - else - $html .= - "<td colspan=\"2\">" . - "<textarea" . - " name=\"freetexts[" . $question->getObjectID() . "]\"" . - " cols=\"60\" rows=\"" . $answer->getRows() . "\">" . - htmlReady(isset($freetexts[$question->getObjectID()]) ? $freetexts[$question->getObjectID()] : '') . - "</textarea>" . - "</td>\n"; - } /* show normal answer ------------- */ - else { - $answers = Request::getArray('answers'); - /* see if it must be checked */ - if ($type == "radio") - $checked = isset($answers[$question->getObjectID()]) && $answers[$question->getObjectID()] == $answer->getObjectID() - ? "checked" - : ""; - else - $checked = (is_array($answers[$question->getObjectID()]) && - in_array($answer->getObjectID(), $answers[$question->getObjectID()])) - ? "checked" - : ""; - - /* show a check/radio-box */ - $html .= - "<td width=\"2%\">" . - "<input type=\"" . $type . "\"" . - " name=\"answers[" . $question->getObjectID() . "]" . $number . "\"" . - " value=\"" . $answer->getObjectID() . "\" " . $checked . ">" . - "</td>\n"; - $html .= - "<td align=\"left\" width=\"98%\">" . - formatReady($answer->getText()) . - "</td>\n"; - } - $html .= "</tr>\n"; - } - } - /* ------------------------------- End: Answers */ - } - - $html .= "</table>\n"; - $html .= "</td></tr>"; - } - - return $html; - } -} diff --git a/lib/evaluation/classes/HTML.class.php b/lib/evaluation/classes/HTML.class.php deleted file mode 100644 index 50b01eb69e6b982b8d64f86b0653fdbfd170c2fe..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/HTML.class.php +++ /dev/null @@ -1,185 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * HTML-class for the Stud.IP-project. - * Based on scripts from "http://tut.php-q.net/". - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ -require_once 'HTMLempty.class.php'; - -class HTML extends HTMLempty -{ - /** - * Holds the content. - * - * @access private - * @var object $_content - */ - var $_content; - - /** - */ - var $has_textarea = false; - - public function addHTMLContent($_content) - { - if (is_object($_content)) { - $classname = mb_strtolower(get_class($_content)); - $valid_classes = ['htmlempty', 'html', 'htm', 'htmpty', 'studip\button', 'studip\linkbutton', 'messagebox']; - if (in_array($classname, $valid_classes)) { - $this->_content[] = $_content; - } else { - trigger_error('Ungültiges Objekt: "' . $classname . '"', E_USER_ERROR); - } - } elseif (is_scalar($_content)) { - $this->_content[] = (string)$_content; - } else { - echo "Fehler in HTML.class.php: Es fehlt ein addHTMLContent-Element für ein Element des Typs \"<" . $this->getName() . ">\"<br>"; - } - } - - public function addContent($_content) - { - if (is_object($_content)) { - $this->addHTMLContent($_content); - } elseif (is_scalar($_content)) { - $this->addHTMLContent(htmlReady(((string)$_content))); - } else { - $this->addHTMLContent(""); - } - } - - /** - * - */ - public function getContent() - { - return $this->_content; - } - - /** - * avoid indentation of <textarea>... - */ - public function setTextareaCheck() - { - $this->has_textarea = true; - } - - /** - * - */ - public function printContent($indent = 0) - { - echo $this->createContent($indent); - } - - /** - * - */ - public function createContent($indent = 0) - { - $output = ""; - - $str_indent = str_repeat(' ', $indent); - - $_content = $this->getContent(); - $output .= ($str_indent . "<" . $this->getName()); - - $attribute = $this->getAttr(); - foreach ($attribute as $name => $value) { - $output .= (' ' . $name . '="' . $value . '"'); - } - - $output .= $this->_string; - $output .= (">\n"); - if (!is_array($_content)) { - $attributes = ""; - foreach ($attribute as $name => $value) { - $attributes .= ($name . '=>"' . $value . '"; '); - } - print "Fehler in HTML.class.php: Es fehlt ein Content-Element für ein Element des Typs \"<" . $this->getName() . ">\" (Attribute: $attributes)."; - - return; - } - - foreach ($_content as $content) { - if (is_object($content)) { - // der aktuelle Content ist ein Object - // also ein HTML-Element. Also geben - // wir es aus - $classname = mb_strtolower(get_class($content)); - $valid_classes = ['studip\button', 'studip\linkbutton', 'messagebox']; - if (in_array($classname, $valid_classes)) { - $output .= $content; - } else { - $output .= $content->createContent($indent + 4); - } - // Rekursion lässt grüßen ... - } else { - // Content ist ein String. Jeden Zeile - // geben wir getrennt aus - $zeilen = explode("\n", $content); - $echo = ""; - - if ($this->has_textarea) { - - // look for textarea in content - $text_area = false; - foreach ($zeilen as $zeile) { - - if (mb_strstr($zeile, "<textarea")) - $text_area = true; - - if ($text_area) - $echo .= $zeile . "\n"; - else - $echo .= $str_indent . " " . $zeile . "\n"; - - if (mb_strstr($zeile, "</textarea")) - $text_area = false; - } - } else { - // standard - foreach ($zeilen as $zeile) { - $echo .= $str_indent . " " . $zeile . "\n"; - } - } - $output .= $echo; - } - } - $output .= ($str_indent . "</" . $this->getName() . ">\n"); - - return $output; - } -} - -include_once("LazyHTML.class.php"); - diff --git a/lib/evaluation/classes/HTMLempty.class.php b/lib/evaluation/classes/HTMLempty.class.php deleted file mode 100644 index 574816f24fe8dff87c28a88553864b6887897bd0..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/HTMLempty.class.php +++ /dev/null @@ -1,184 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * HTML-class for the Stud.IP-project. - * Based on scripts from "http://tut.php-q.net/". - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ - -class HTMLempty -{ - -# Define all required variables ============================================= # - /** - * Holds the name of the element. - * - * @access private - * @var string $_name - */ - var $_name = ""; - - /** - * Holds the attributes of the element. - * - * @access private - * @var array $_attribute - */ - var $_attribute = []; - - /** - * Holds additional attributes (strings generated from studip functions) - * - * @access private - * @var array $_string - */ - var $_string = ""; -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - public function __construct($name) - { - if (preg_match('/^[a-zA-Z.:][\w\-_\.:]*$/i', $name)) { - $this->_name = $name; - } else { - trigger_error("Unerlaubter Name für ein HTML-Element : '" . $name . "'", E_USER_ERROR); - } - } - - /** - * - */ - public function addAttr($name, $wert = null) - { - if (isset ($wert)) { - $name = (string)$name; - if (preg_match('/^[a-zA-Z.:][\w\-_\.:]*$/i', $name)) { - $this->_attribute[$name] = $wert; - } else { - trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . $name . "'", E_USER_ERROR); - } - } else { - if (is_scalar($name)) { - // Dies braucht man, falls man Attribute hinzufügen - // will, die keinen Wert haben, wie man es bei - // <option selected> kennt - if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $name)) { - $this->_attribute[$name] = $name; - // Da wir gültiges HTML bzw XML schreiben - // muss jedes Attribut auch einen Wert haben - // selected wird dann zu selected="selected" - } else { - trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . $name . "'", E_USER_ERROR); - } - } elseif (is_array($name)) { - // Jedes Arrayelement durchgehen - foreach ($name as $key => $wert) { - if (is_int($key)) { - // Arrayelement wurde mit $foo[] hinzugefügt - // also ohne Schlüssel. Ich nehme dann an - // das es sich um ein Attribut wie - // 'selected' oder 'readonly' handelt - if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $wert)) { - $this->_attribute[$wert] = $wert; - } else { - trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . - $wert . "'", E_USER_ERROR); - } - } else { - $key = (string)$key; - if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $key)) { - $this->_attribute[$key] = $wert; - } else { - trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . - $key . "'", E_USER_ERROR); - } - } - } - } else { - trigger_error("Erster Parameter muss ein Scalar oder ein Array sein", - E_USER_ERROR); - } - } - } - - /** - * to support Stud.IP legacy functions like makeButton... - */ - public function addString($string) - { - if (is_array($string)) { - $string = implode(' ', $string); - } - $this->_string .= " " . $string; - } - - /** - * - */ - public function getName() - { - return $this->_name; - } - - /** - * - */ - public function getAttr() - { - return $this->_attribute; - } - - /** - * - */ - public function printContent($indent = 0) - { - echo $this->createContent($indent); - } - - /** - * - */ - public function createContent($indent = 0) - { - $str = str_repeat(' ', $indent); - $str .= "<" . $this->getName(); - $attrib = $this->getAttr(); - foreach ($attrib as $name => $value) { - $str .= ' ' . $name . '="' . htmlReady($value) . '"'; - } - $str .= $this->_string; - $str .= ">\n"; - - return ($str); - } -} diff --git a/lib/evaluation/classes/LazyHTML.class.php b/lib/evaluation/classes/LazyHTML.class.php deleted file mode 100644 index 98f2f5ef28e3f28da8068374f187b336cb697fe7..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/LazyHTML.class.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -/** - * HTML-class for the Stud.IP-project. - * Based on scripts from "http://tut.php-q.net/". - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ -require_once 'HTML.class.php'; - -class HTMpty extends HTMLempty -{ - - public function attr($name, $wert = null) - { - parent::addAttr($name, $wert); - } - - public function stri($string) - { - parent::addString($string); - } - -} - -class HTM extends HTML -{ - - public function stri($string) - { - parent::addString($string); - } - - public function attr($name, $wert = null) - { - parent::addAttr($name, $wert); - } - - public function html($_content) - { - parent::addHTMLContent($_content); - } - - public function cont($_content) - { - parent::addContent($_content); - } -} diff --git a/lib/evaluation/classes/db/EvaluationAnswerDB.class.php b/lib/evaluation/classes/db/EvaluationAnswerDB.class.php deleted file mode 100644 index 54bdb7dda72b465f474de6b0753a42fffb16e021..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/db/EvaluationAnswerDB.class.php +++ /dev/null @@ -1,284 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ - -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_OBJECTDB; - - -class EvaluationAnswerDB extends EvaluationObjectDB -{ - /** - * Constructor - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalANSWERDB'; - } - - /** - * Loads answers of a group from the DB - * @access public - * @param EvaluationAnswer &&$answerObject The answer object - */ - public function load(&$answerObject) - { - /* load answer --------------------------------------------------------- */ - $row = DBManager::get()->fetchOne( - "SELECT * FROM evalanswer WHERE evalanswer_id= ?", [$answerObject->getObjectID()] - ); - if (!count($row)) { - return $this->throwError(2, _("Keine Antwort mit dieser ID gefunden.")); - } - - $answerObject->setObjectID($row['evalanswer_id']); - $answerObject->setParentID($row['parent_id']); - $answerObject->setPosition($row['position']); - $answerObject->setText($row['text']); - $answerObject->setValue($row['value']); - $answerObject->setRows($row['rows']); - $answerObject->setResidual($row['residual']); - } - - - /** - * Loads the votes from the users for this answer - * @access public - * @param EvaluationAnswer &$answerObject The answer object - */ - function loadVotes(&$answerObject) - { - /* load users -------------------------------------------------------- */ - $result = DBManager::get()->fetchFirst("SELECT user_id FROM evalanswer_user - WHERE evalanswer_id= ?", [$answerObject->getObjectID()]); - foreach ($result as $row) { - $answerObject->addUserID($row, NO); - } - } - /* ----------------------------------------------------------- end: users */ - - /** - * Writes answers into the DB - * @access public - * @param EvaluationAnswer &$answerObject The answerobject - * @throws error - */ - function save(&$answerObject) - { - /* save answers -------------------------------------------------------- */ - DBManager::get()->execute( - "REPLACE INTO evalanswer SET - `evalanswer_id` = ?, - `parent_id` = ?, - `position` = ?, - `text` = ?, - `value` = ?, - `rows` = ?, - `residual` = ? - ", - [$answerObject->getObjectID(), - $answerObject->getParentID(), - $answerObject->getPosition(), - $answerObject->getText(), - $answerObject->getValue(), - $answerObject->getRows(), - $answerObject->isResidual()]); - /* ----------------------------------------------------- end: answersave */ - - /* connect answer to users --------------------------------------------- */ - while ($userID = $answerObject->getNextUserID()) { - DBManager::get()->execute( - "INSERT INTO evalanswer_user SET - evalanswer_id = ?, - user_id = ?, - evaldate = UNIX_TIMESTAMP()", - [$answerObject->getObjectID(), $userID]); - } - /* ----------------------------------------------------- end: connecting */ - - } // saved - - /** - * Deletes all votes from the users for this answers - * @access public - * @param EvaluationAnswer &$answerObject The answer object - */ - function resetVotes(&$answerObject) - { - /* delete userconnects ------------------------------------------------- */ - DBManager::get()->execute(" - DELETE FROM evalanswer_user - WHERE evalanswer_id = ?", - [$answerObject->getObjectID()]); - /* ------------------------------------------------------- end: deleting */ - } - - /** - * Deletes a answer - * @access public - * @param EvaluationAnswer &$answerObject The answer to delete - * @throws error - */ - function delete(&$answerObject) - { - /* delete answer ----------------------------------------------------- */ - DBManager::get()->execute(" - DELETE FROM evalanswer - WHERE evalanswer_id = ?", - [$answerObject->getObjectID()]); - /* ------------------------------------------------------- end: deleting */ - $this->resetVotes($answerObject); - } // deleted - - - /** - * Checks if answer with this ID exists - * @access public - * @param string $answerID The answerID - * @return bool YES if exists - */ - function exists($answerID) - { - $result = DBManager::get()->fetchOne("SELECT 1 FROM evalanswer - WHERE evalanswer_id= ?", [$answerID]); - if (count($result) > 0) - return true; - return false; - } - - - /** - * Adds the children to a parent object - * @access public - * @param EvaluationObject &$parentObject The parent object - */ - public static function addChildren(&$parentObject) - { - $result = DBManager::get()->fetchFirst("SELECT evalanswer_id FROM evalanswer - WHERE parent_id= ? ORDER by position", - [$parentObject->getObjectID()]); - - $loadChildren = - $parentObject->loadChildren == EVAL_LOAD_ALL_CHILDREN ? EVAL_LOAD_ALL_CHILDREN : EVAL_LOAD_NO_CHILDREN; - - foreach ($result as $row) { - $child = new EvaluationAnswer($row, $parentObject, $loadChildren); - $parentObject->addChild($child); - } - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - function getType($objectID) - { - if ($this->exists($objectID)) { - return INSTANCEOF_EVALANSWER; - } else { - return NO; - } - } - - /** - * Returns the id from the parent object - * @access public - * @param string $objectID The object id - * @return string The id from the parent object - */ - public static function getParentID($objectID) - { - return DBManager::get()->fetchColumn("SELECT parent_id FROM evalanswer - WHERE evalanswer_id = ?", - [$objectID]); - } - - /** - * Give all textanswers for a user and question for the export - * @access public - * @param string $questionID The question id - * @param string $userID The user id - */ - function getUserAnwerIDs($questionID, $userID) - { - /* ask database ------------------------------------------------------- */ - $sql = "SELECT a.evalanswer_id as ttt FROM evalanswer a, evalanswer_user b - WHERE a.parent_id = ? AND a.evalanswer_id = b.evalanswer_id"; - if (empty ($userID)) - $answer_ids = DBManager::get()->fetchFirst($sql, [$questionID]); - else - $answer_ids = DBManager::get()->fetchFirst($sql . " AND b.user_id = ?", [$questionID, $userID]); - /* -------------------------------------------------------- end: asking */ - return $answer_ids; - } - - /** - * Checks whether a user has voted for an answer - * @access public - * @param string $answerID The answer id - * @param string $userID The user id - * @return boolean YES if user has voted for the answer - */ - function hasVoted($answerID, $userID) - { - $result = DBManager::get()->fetchOne("SELECT 1 FROM evalanswer_user - WHERE evalanswer_id= ? AND user_id", [$answerID, $userID]); - if (count($result) > 0) - return true; - return false; - } - - function getAllAnswers($question_id, $userID, $only_user_answered = false) - { - if ($only_user_answered) - return DBManager::get()->fetchAll(" - SELECT evalanswer.*, COUNT(IF(user_id=?,1,NULL)) AS has_voted - FROM evalanswer LEFT JOIN evalanswer_user USING(evalanswer_id) - WHERE parent_id = ? AND user_id = ? - GROUP BY evalanswer.evalanswer_id ORDER BY position", - [$userID, $question_id, $userID]); - else - return DBManager::get()->fetchAll(" - SELECT evalanswer.*, COUNT(IF(user_id=?,1,NULL)) AS has_voted - FROM evalanswer LEFT JOIN evalanswer_user USING(evalanswer_id) - WHERE parent_id = ? - GROUP BY evalanswer.evalanswer_id ORDER BY position", - [$userID, $question_id]); - } -} - -?> diff --git a/lib/evaluation/classes/db/EvaluationDB.class.php b/lib/evaluation/classes/db/EvaluationDB.class.php deleted file mode 100644 index fd1c2b6a84f70e83940b3335a326531513efc0b2..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/db/EvaluationDB.class.php +++ /dev/null @@ -1,291 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - - -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_OBJECTDB; -require_once EVAL_FILE_GROUPDB; - - -/** - * @const EVAL_STATE_NEW Beschreibung - * @access public - */ -define("EVAL_STATE_NEW", "new"); - -/** - * @const EVAL_STATE_ACTIVE Beschreibung - * @access public - */ -define("EVAL_STATE_ACTIVE", "active"); - -/** - * @const EVAL_STATE_STOPPED Beschreibung - * @access public - */ -define("EVAL_STATE_STOPPED", "stopped"); -# =========================================================================== # - - -/** - * Databaseclass for all evaluations - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationDB extends EvaluationObjectDB -{ - - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalDB'; - } - - /** - * Loads an evaluation from DB into an object - * - * @access public - * @param object EvaluationObject &$evalObject The evaluation to load - * @throws error - */ - public function load(&$evalObject) - { - $row = DBManager::get()->fetchOne("SELECT * FROM eval WHERE eval_id = ?", [$evalObject->getObjectID()]); - - if (!count($row)) { - return $this->throwError(1, _("Keine Evaluation mit dieser ID gefunden.")); - } - - $evalObject->setAuthorID($row['author_id']); - $evalObject->setTitle($row['title']); - $evalObject->setText($row['text']); - $evalObject->setStartdate($row['startdate']); - $evalObject->setStopdate($row['stopdate']); - $evalObject->setTimespan($row['timespan']); - $evalObject->setCreationdate($row['mkdate']); - $evalObject->setChangedate($row['chdate']); - $evalObject->setAnonymous($row['anonymous']); - $evalObject->setVisible($row['visible']); - $evalObject->setShared($row['shared']); - - $range_ids = DBManager::get()->fetchFirst("SELECT range_id FROM eval_range WHERE eval_id = ?", - [$evalObject->getObjectID()]); - - foreach ($range_ids as $range_id) { - $evalObject->addRangeID($range_id); - } - if ($evalObject->loadChildren != EVAL_LOAD_NO_CHILDREN) { - EvaluationGroupDB::addChildren($evalObject); - } - } - - /** - * Saves an evaluation - * @access public - * @param object Evaluation &$evalObject The evaluation to save - * @throws error - */ - public function save(&$evalObject) - { - $startdate = $evalObject->getStartdate(); - $stopdate = $evalObject->getStopdate(); - $timespan = $evalObject->getTimespan(); - - $evalObject->setChangedate(time()); - if ($this->exists($evalObject->getObjectID())) { - DBManager::get()->execute( - "UPDATE eval SET title = ?, text = ?, startdate = ?, - stopdate = ?, timespan = ?, mkdate = ?, - chdate = ?, anonymous = ?, visible = ?, shared = ? - WHERE eval_id = ?", - [$evalObject->getTitle(), $evalObject->getText(), - $startdate, $stopdate, $timespan, $evalObject->getCreationdate(), - $evalObject->getChangedate(), $evalObject->isAnonymous(), - $evalObject->isVisible(), $evalObject->isShared(), $evalObject->getObjectID()]); - } else { - DBManager::get()->execute( - "INSERT INTO eval SET eval_id = ?, - author_id = ?, title = ?, text = ?, startdate = ?, - stopdate = ?, timespan = ?, mkdate = ?, chdate = ?, - anonymous = ?, visible = ?, shared = ?", - [$evalObject->getObjectID(), $evalObject->getAuthorID(), - $evalObject->getTitle(), $evalObject->getText(), - $startdate, $stopdate, $timespan, $evalObject->getCreationdate(), - $evalObject->getChangedate(), $evalObject->isAnonymous(), - $evalObject->isVisible(), $evalObject->isShared()]); - } - DBManager::get()->execute("DELETE FROM eval_range WHERE eval_id = ?", [$evalObject->getObjectID()]); - - while ($rangeID = $evalObject->getNextRangeID()) { - DBManager::get()->execute("INSERT INTO eval_range SET eval_id = ?, range_id = ?", - [$evalObject->getObjectID(), $rangeID]); - } - } - - /** - * Deletes an evaluation - * @access public - * @param object Evaluation &$evalObject The evaluation to delete - * @throws error - */ - public function delete(&$evalObject) - { - DBManager::get()->execute("DELETE FROM eval WHERE eval_id = ?", [$evalObject->getObjectID()]); - - DBManager::get()->execute("DELETE FROM eval_range WHERE eval_id = ?", [$evalObject->getObjectID()]); - DBManager::get()->execute("DELETE FROM eval_user WHERE eval_id = ?", [$evalObject->getObjectID()]); - - } - - /** - * Checks if evaluation with this ID exists - * @access public - * @param string $evalID The evalID - * @return bool YES if exists - */ - public function exists($evalID) - { - $entry = DBManager::get()->fetchOne("SELECT 1 FROM eval WHERE eval_id = ?", [$evalID]); - if (count($entry) > 0) - return true; - return false; - } - - /** - * Checks if someone used the evaluation - * @access public - * @param string $evalID The eval id - * @param string $userID The user id - * @return bool YES if evaluation was used - */ - public function hasVoted($evalID, $userID = "") - { - /* ask database ------------------------------------------------------- */ - $sql = "SELECT 1 FROM eval_user WHERE eval_id = ?"; - if (empty($userID)) - $entry = DBManager::get()->fetchOne($sql, [$evalID]); - else - $entry = DBManager::get()->fetchOne($sql . " AND user_id = ?", [$evalID, $userID]); - /* --------------------------------------------------------- end: asking */ - if (count($entry) > 0) - return true; - return false; - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - public function getType($objectID) - { - if ($this->exists($objectID)) { - return INSTANCEOF_EVAL; - } else { - $dbObject = new EvaluationGroupDB(); - return $dbObject->getType($objectID); - } - } - - /** - * Connect a user with an evaluation - * @access public - * @param string $evalID The evaluation id - * @param string $userID The user id - */ - public function connectWithUser($evalID, $userID) - { - if (empty($userID)) - die ("EvaluationDB::connectWithUser: UserID leer!!"); - DBManager::get()->execute("INSERT IGNORE INTO eval_user SET eval_id = ?, user_id = ?", [$evalID, $userID]); - } - - /** - * Removes the connection of an evaluation with a user or all users - * @access public - * @param string $evalID The evaluation id - * @param string $userID The user id - */ - public function removeUser($evalID, $userID = "") - { - $sql = "DELETE FROM eval_user WHERE eval_id = ?"; - - if (empty($userID)) - DBManager::get()->execute($sql, [$evalID]); - else - DBManager::get()->execute($sql . " AND user_id = ?", [$evalID, $userID]); - } - - /** - * Get number of users who participated in the eval - * @access public - * @param string $evalID The eval id - * @return integer The number of users - */ - public static function getNumberOfVotes($evalID) - { - return DBManager::get()->fetchColumn("SELECT count(DISTINCT user_id) AS number FROM eval_user WHERE eval_id = ?", [$evalID]); - } - - /** - * Get users who participated in the eval - * @access public - * @param string $evalID The eval id - * @param array $answerIDs The answerIDs to get the pseudonym users - * @return string[] Ids of the users who voted - */ - public static function getUserVoted($evalID, $answerIDs = [], $questionIDs = []) - { - $sql = "SELECT DISTINCT user_id FROM "; - - if (empty($answerIDs) && empty($questionIDs)) { - $sql .= "eval_user WHERE eval_id = ?"; - $search_criteria = $evalID; - } elseif (empty ($questionIDs)) { - $sql .= "evalanswer_user WHERE evalanswer_id IN (?)"; - $search_criteria = $answerIDs; - } else { - $sql .= "evalanswer INNER JOIN evalanswer_user USING(evalanswer_id) WHERE parent_id IN (?)"; - $search_criteria = $questionIDs; - } - - return DBManager::get()->fetchFirst($sql, [$search_criteria]); - } - - /** - * - * @access public - * @param string $search_str - * @return array - */ - public function search_range($search_str) - { - return search_range($search_str, true); - } -} diff --git a/lib/evaluation/classes/db/EvaluationGroupDB.class.php b/lib/evaluation/classes/db/EvaluationGroupDB.class.php deleted file mode 100644 index 60842ada7389e5d52e52d5ebcefca2dcf5629c03..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/db/EvaluationGroupDB.class.php +++ /dev/null @@ -1,225 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_OBJECTDB; -require_once EVAL_FILE_ANSWERDB; - -/** - * Databaseclass for all evaluationgroups - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationGroupDB extends EvaluationObjectDB -{ - - /** - * Constructor - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalGroupDB'; - } - - /** - * Loads an evaluationgroup from DB into an object - * - * @access private - * @param object EvaluationGroup &$groupObject The group to load - * @throws error - */ - public function load(&$groupObject) - { - /* load group ---------------------------------------------------------- */ - $row = DBManager::get()->fetchOne(" - SELECT * FROM evalgroup - WHERE evalgroup_id = ? - ORDER BY position ", [$groupObject->getObjectID()]); - - if (count($row) === 0) { - return $this->throwError(1, _("Keine Gruppe mit dieser ID gefunden.")); - } - - $groupObject->setParentID($row['parent_id']); - $groupObject->setTitle($row['title']); - $groupObject->setText($row['text']); - $groupObject->setPosition($row['position']); - $groupObject->setChildType($row['child_type']); - $groupObject->setMandatory($row['mandatory']); - $groupObject->setTemplateID($row['template_id']); - if ($groupObject->loadChildren != EVAL_LOAD_NO_CHILDREN) { - if ($groupObject->loadChildren == EVAL_LOAD_ONLY_EVALGROUP) { - EvaluationGroupDB::addChildren($groupObject); - } else { - EvaluationGroupDB::addChildren($groupObject); - EvaluationQuestionDB::addChildren($groupObject); - } - } - } - - - /** - * Saves a group - * @access public - * @param object EvaluationGroup &$groupObject The group to save - * @throws error - */ - public function save(&$groupObject) - { - if ($this->exists($groupObject->getObjectID())) { - DBManager::get()->execute(" - UPDATE evalgroup SET - title = ?, - text = ?, - child_type = ?, - position = ?, - template_id = ?, - mandatory = ? - WHERE - evalgroup_id = ? - ", [(string)$groupObject->getTitle(), - (string)$groupObject->getText(), - (string)$groupObject->getChildType(), - (int)$groupObject->getPosition(), - (string)$groupObject->getTemplateID(), - (int)$groupObject->isMandatory(), - (string)$groupObject->getObjectID() - ]); - } else { - DBManager::get()->execute(" - INSERT INTO evalgroup SET - evalgroup_id = ?, - parent_id = ?, - title = ?, - text = ?, - child_type = ?, - mandatory = ?, - template_id = ?, - position = ? - ", [ - (string)$groupObject->getObjectID(), - (string)$groupObject->getParentID(), - (string)$groupObject->getTitle(), - (string)$groupObject->getText(), - (string)$groupObject->getChildType(), - (int)$groupObject->isMandatory(), - (string)$groupObject->getTemplateID(), - (int)$groupObject->getPosition() - ]); - } - } - - /** - * Deletes a group - * @access public - * @param object EvaluationGroup &$groupObject The group to delete - * @throws error - */ - public function delete(&$groupObject) - { - DBManager::get()->execute("DELETE FROM evalgroup WHERE evalgroup_id = ?", [$groupObject->getObjectID()]); - } - - /** - * Checks if group with this ID exists - * @access public - * @param string $groupID The groupID - * @return bool YES if exists - */ - public function exists($groupID) - { - $result = DBManager::get()->fetchColumn("SELECT 1 FROM evalgroup WHERE evalgroup_id = ?", [$groupID]); - return (bool)$result; - } - - /** - * Adds the children to a parent object - * @access public - * @param EvaluationObject &$parentObject The parent object - */ - public static function addChildren(&$parentObject) - { - $result = DBManager::get()->fetchFirst(" - SELECT evalgroup_id FROM evalgroup - WHERE parent_id = ? - ORDER BY position", [$parentObject->getObjectID()]); - - if (($loadChildren = $parentObject->loadChildren) == EVAL_LOAD_NO_CHILDREN) - $loadChildren = EVAL_LOAD_NO_CHILDREN; - - foreach ($result as $groupID) { - $child = new EvaluationGroup ($groupID, $parentObject, $loadChildren); - $parentObject->addChild($child); - } - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - public function getType($objectID) - { - if ($this->exists($objectID)) { - return INSTANCEOF_EVALGROUP; - } else { - $dbObject = new EvaluationQuestionDB (); - return $dbObject->getType($objectID); - } - } - - - /** - * Returns whether the childs are groups or questions - * @access public - * @param string $objectID The object id - */ - public function getChildType($objectID) - { - $result = DBManager::get()->fetchColumn(" - SELECT child_type FROM evalgroup WHERE evalgroup_id = ?", [$objectID]); - if ($result) return $result; - return NULL; - } - - /** - * Returns the id from the parent object - * @access public - * @param string $objectID The object id - * @return string The id from the parent object - */ - public static function getParentID($objectID) - { - return DBManager::get()->fetchColumn(" - SELECT parent_id FROM evalgroup WHERE evalgroup_id = ?", [$objectID]); - } -} diff --git a/lib/evaluation/classes/db/EvaluationObjectDB.class.php b/lib/evaluation/classes/db/EvaluationObjectDB.class.php deleted file mode 100644 index fd5728d035cdfa3b3ed8d023bb535c1708bee688..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/db/EvaluationObjectDB.class.php +++ /dev/null @@ -1,365 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. - -require_once 'lib/evaluation/evaluation.config.php'; - -/** - * Databaseclass for all evaluationobjects - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationObjectDB extends DatabaseObject -{ - /** - * Constructor - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalDBObject'; - } - - /** - * Gets the name of the range. Copied somewhere from Stud.IP... - * @access public - * @param string $rangeID the rangeID - * @param boolean $html_decode (optional) - * @return string The name of the range - */ - public function getRangename($rangeID, $html_decode = true) - { - if ($rangeID == "studip") { - return _('Systemweite Evaluationen'); - } - $o_type = get_object_type($rangeID, ['sem', 'user', 'inst']); - if (in_array($o_type, ['sem','inst','fak'])) { - $range = get_object_by_range_id($rangeID); - if ($range) { - $rangename = $range->getFullName('number-name-semester'); - } else { - $rangename = _('Kein Titel gefunden.'); - } - return $rangename; - } - if ($o_type != 'user') { - $user_id = get_userid($rangeID); - } else { - $user_id = $rangeID; - } - - if ($user_id != $GLOBALS['user']->id) { - $rangename = _('Profil') . ': ' - . get_fullname($user_id, 'full', true) - . ' (' . get_username($user_id) . ')'; - } else { - $rangename = _('Profil'); - } - return $rangename; - } - - /** - * Gets the global Studi.IP perm - * @access public - * @param boolean $as_value If YES return as value - * @return string the perm or NULL - */ - public static function getGlobalPerm($as_value = false) - { - if ($GLOBALS['perm']->have_perm("root")) { - return $as_value ? 63 : "root"; - } elseif ($GLOBALS['perm']->have_perm("admin")) { - return $as_value ? 31 : "admin"; - } elseif ($GLOBALS['perm']->have_perm("dozent")) { - return $as_value ? 15 : "dozent"; - } elseif ($GLOBALS['perm']->have_perm("tutor")) { - return $as_value ? 7 : "dozent"; - } elseif ($GLOBALS['perm']->have_perm("autor")) { - return $as_value ? 3 : "autor"; - } elseif ($GLOBALS['perm']->have_perm("user")) { - return $as_value ? 1 : "user"; - } else { - return $as_value ? 0 : NULL; - } - } - - /** - * Get the Stud.IP-Perm for a range - * @param string $rangeID The range id - * @param string $userID The user id - * @param boolean $as_value If YES return as value - * @access public - * @return string - */ - public static function getRangePerm($rangeID, $userID = NULL, $as_value = false) - { - if (!$rangeID) { - print "no rangeID!<br>"; - return NULL; - } - $userID = ($userID) ? $userID : $GLOBALS['user']->id; - $range_perm = $GLOBALS['perm']->get_studip_perm($rangeID, $userID); - - if ($rangeID == $userID) { - return ($as_value) ? 63 : "root"; - } - - if (($rangeID == "studip") && ($GLOBALS['perm']->have_perm("root"))) { - return ($as_value) ? 63 : "root"; - } - - switch ($range_perm) { - case "root": - return ($as_value) ? 63 : "root"; - case "admin": - return ($as_value) ? 31 : "admin"; - case "dozent": - return ($as_value) ? 15 : "dozent"; - case "tutor": - return ($as_value) ? 7 : "dozent"; - case "autor": - return ($as_value) ? 3 : "autor"; - case "user": - return ($as_value) ? 1 : "user"; - default: - return 0; - } - - } - - /** - * Look for all rangeIDs for my permissions - * @param object Perm &$permObj PHP-LIB-Perm-Object - * @param object User &$userObj PHP-LIB-User-Object - * @param string $rangeID RangeID of actual page - */ - public function getValidRangeIDs(&$permObj, &$userObj, $rangeID) - { - $range_ids = []; - $username = $userObj->username; - - $range_ids += [ - $username => ["name" => _("Profil")] - ]; - - if ($permObj->have_perm("root")) { - $range_ids += ["studip" => ["name" => _("Stud.IP-System")]]; - if (($adminRange = $this->getRangename($rangeID)) && - $rangeID != $userObj->id) - $range_ids += [$rangeID => ["name" => - $adminRange]]; - } else if ($permObj->have_perm("admin")) { - if (($adminRange = $this->getRangename($rangeID)) && - $rangeID != $userObj->id) { - $range_ids += [$rangeID => ["name" => - $adminRange]]; - } - } else if ($permObj->have_perm("dozent") || $permObj->have_perm("tutor")) { - if ($ranges = search_range("")) { - $range_ids += $ranges; - } - } - return $range_ids; - } - - /** - * Returns the number of ranges with no permission - * @access public - * @param EvaluationObject &$eval The evaluation - * @param boolean $return_ids If YES return the ids - * @return array|integer Number of ranges with no permission or array of ids - */ - public static function getEvalUserRangesWithNoPermission(&$eval, $return_ids = false) - { - $no_permisson = 0; - $rangeIDs = $eval->getRangeIDs(); - $no_permisson_ranges = []; - if (!is_array($rangeIDs)) { - $rangeIDs = [$rangeIDs]; - } - - foreach ($eval->getRangeIDs() as $rangeID) { - $user_perm = EvaluationObjectDB::getRangePerm($rangeID, $GLOBALS['user']->id, YES); - // every range with a lower perm than Tutor - if ($user_perm < 7) { - $no_permisson++; - $no_permisson_ranges[] = $rangeID; - } - } - if ($return_ids == YES) { - return $no_permisson_ranges; - } - return ($no_permisson > 0) ? $no_permisson : NO; - } - - /** - * Gets the public template ids - * @access public - * @param string $searchString The name of the template - * @return array The public template ids - */ - public function getPublicTemplateIDs($searchString) - { - $sql = " - SELECT eval_id FROM eval - LEFT JOIN auth_user_md5 ON user_id = author_id - WHERE shared = 1 - AND author_id <> :current_user - AND (title LIKE :search_string - OR text LIKE :search_string - OR Vorname LIKE :search_string - OR Nachname LIKE :search_string - OR username LIKE :search_string - ) - ORDER BY title"; - - return DBManager::get()->fetchFirst( - $sql, [':current_user' => $GLOBALS['user']->id, ':search_string' => '%' . $searchString . '%'] - ); - } - - /** - * Return all evaluationIDs in a specific range - * - * @access public - * @param string $rangeID Specific rangeID or it is a template - * @param string $state Specific state - * @return array All evaluations in this range and this state - */ - public function getEvaluationIDs($rangeID = "", $state = "") - { - if (!empty ($rangeID) && !is_scalar($rangeID)) { - return $this->throwError(1, _("Übergebene RangeID ist ungültig.")); - } - if ($state != "" && - $state != EVAL_STATE_NEW && - $state != EVAL_STATE_ACTIVE && - $state != EVAL_STATE_STOPPED) { - return $this->throwError(2, _("Übergebener Status ist ungültig.")); - } - - if (get_userid($rangeID) != NULL && $rangeID != NULL) { - $rangeID = get_userid($rangeID); - } - - if (!empty ($rangeID)) { - $sql = - "SELECT" . - " a.eval_id " . - "FROM" . - " eval_range a, eval b " . - "WHERE" . - " a.eval_id = b.eval_id" . - " AND " . - " a.range_id = ?"; - $param = $rangeID; - } else { - $sql = - "SELECT" . - " b.eval_id " . - "FROM" . - " eval b " . - "LEFT JOIN" . - " eval_range " . - "ON" . - " b.eval_id = eval_range.eval_id " . - "WHERE" . - " eval_range.eval_id IS NULL" . - " AND" . - " b.author_id = ?"; - $param = $GLOBALS['user']->id; - } - - if ($state == EVAL_STATE_NEW) - $sql .= " AND (b.startdate IS NULL OR b.startdate > " . time() . ")"; - - elseif ($state == EVAL_STATE_ACTIVE) - $sql .= - " AND b.startdate < " . time() . "" . - " AND (" . - " (b.timespan IS NULL AND b.stopdate > " . time() . ")" . - " OR" . - " (b.stopdate IS NULL AND (b.startdate+b.timespan) > " . time() . ")" . - " OR" . - " (b.timespan IS NULL AND b.stopdate IS NULL)" . - " )"; - - elseif ($state == EVAL_STATE_STOPPED) - $sql .= - " AND b.startdate < " . time() . "" . - " AND (" . - " (b.timespan IS NULL AND b.stopdate <= " . time() . ")" . - " OR" . - " (b.stopdate IS NULL AND (b.startdate+b.timespan) <= " . time() . ")" . - " )"; - - $sql .= " ORDER BY chdate DESC"; - - return DBManager::get()->fetchFirst($sql, [$param]); - } - - /** - * Gets the evaluation id for a object id - * @access public - * @param string $objectID The object id - * @return string The evaluation id or nothing - */ - public function getEvalID($objectID) - { - if (empty ($objectID)) { - throw new Exception("FATAL ERROR in getEvalID ;)"); - } - - $type = EvaluationObjectDB::getType($objectID); - - switch ($type) { - case INSTANCEOF_EVALANSWER: - $parentID = EvaluationAnswerDB::getParentID($objectID); - break; - case INSTANCEOF_EVALQUESTION: - $parentID = EvaluationQuestionDB::getParentID($objectID); - break; - case INSTANCEOF_EVALGROUP: - $parentID = EvaluationGroupDB::getParentID($objectID); - break; - default: - return $objectID; - } - return EvaluationObjectDB::getEvalID($parentID); - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - public function getType($objectID) - { - return (new EvaluationDB ())->getType($objectID); - } -} diff --git a/lib/evaluation/classes/db/EvaluationQuestionDB.class.php b/lib/evaluation/classes/db/EvaluationQuestionDB.class.php deleted file mode 100644 index b6cea2499bebe62caec3f6573ba069588a47f896..0000000000000000000000000000000000000000 --- a/lib/evaluation/classes/db/EvaluationQuestionDB.class.php +++ /dev/null @@ -1,298 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_OBJECTDB; -require_once EVAL_FILE_ANSWERDB; -# ====================================================== end: including files # - -# Define all required constants ============================================= # -/** - * @const INSTANCEOF_EVALQUESTIONDB Instance of an evaluationQuestionDB object - * @access public - */ -define("INSTANCEOF_EVALQUESTIONDB", "EvalQuestionDB"); - -# =========================================================================== # - - -class EvaluationQuestionDB extends EvaluationObjectDB -{ - - /** - * Constructor - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalQuestionDB'; - } - - /** - * Loads a question from the DB - * @access public - * @param EvaluationQuestion &$questionObject The question object - */ - public function load(&$questionObject) - { - $db = DBManager::get(); - $query = - "SELECT" . - " * " . - "FROM" . - " evalquestion " . - "WHERE" . - " evalquestion_id = ? " . - "ORDER BY" . - " position "; - $row = $db->fetchOne($query, [$questionObject->getObjectID()]); - - if (!count($row)) { - return $this->throwError(1, _("Keine Frage mit dieser ID gefunden.")); - } - - $questionObject->setParentID($row['parent_id']); - $questionObject->setType($row['type']); - $questionObject->setPosition($row['position']); - $questionObject->setText($row['text']); - $questionObject->setMultiplechoice($row['multiplechoice']); - - if ($questionObject->loadChildren != EVAL_LOAD_NO_CHILDREN) { - EvaluationAnswerDB::addChildren($questionObject); - } - } - - - /** - * Writes or updates a question into the DB - * @access public - * @param EvaluationQuestion &$questionObject The question object - */ - public function save(&$questionObject) - { - $db = DBManager::get(); - - if ($this->exists($questionObject->getObjectID())) { - $sql = - "UPDATE" . - " evalquestion " . - "SET" . - " parent_id = ?," . - " type = ?," . - " position = ?," . - " text = ?," . - " multiplechoice = ? " . - "WHERE" . - " evalquestion_id = ?"; - } else { - $sql = - "INSERT INTO" . - " evalquestion " . - "SET" . - " parent_id = ?," . - " type = ?," . - " position = ?," . - " text = ?," . - " multiplechoice = ?," . - " evalquestion_id = ?";; - } - $db->execute($sql, [ - (string)$questionObject->getParentID(), - (string)$questionObject->getType(), - (int)$questionObject->getPosition(), - (string)$questionObject->getText(), - (int)$questionObject->isMultiplechoice(), - $questionObject->getObjectID() - ]); - } - - /** - * Deletes a question - * @access public - * @param object EvaluationQuestion &$questionObject The question to delete - * @throws error - */ - public function delete(&$questionObject) - { - $db = DBManager::get(); - - $sql = "DELETE FROM evalquestion WHERE evalquestion_id = ?"; - $db->execute($sql, [$questionObject->getObjectID()]); - } - - /** - * Checks if question with this ID exists - * @access public - * @param string $questionID The questionID - * @return bool YES if exists - */ - public function exists($questionID) - { - $db = DBManager::get(); - - $sql = - "SELECT" . - " 1 " . - "FROM" . - " evalquestion " . - "WHERE" . - " evalquestion_id = ?"; - $result = $db->fetchColumn($sql, [$questionID]); - - return (bool)$result; - } - - /** - * Checks if a template exists with this title - * @access public - * @param string $questionTitle The title of the question - * @param string $userID The user id - * @return bool YES if exists - */ - public function titleExists($questionTitle, $userID) - { - $db = DBManager::get(); - - $sql = - "SELECT" . - " 1 " . - "FROM" . - " evalquestion " . - "WHERE" . - " text = ? " . - " AND " . - " parent_id = ?"; - - $result = $db->fetchColumn($sql, [$questionTitle, $userID]); - - return (bool)$result; - } - - - /** - * Adds the children to a parent object - * @access public - * @param EvaluationObject &$parentObject The parent object - */ - public static function addChildren(&$parentObject) - { - $db = DBManager::get(); - - $sql = - "SELECT" . - " evalquestion_id " . - "FROM" . - " evalquestion " . - "WHERE" . - " parent_id = ? " . - "ORDER BY" . - " position"; - $result = $db->fetchFirst($sql, [$parentObject->getObjectID()]); - - $loadChildren = $parentObject->loadChildren == EVAL_LOAD_ALL_CHILDREN - ? EVAL_LOAD_ALL_CHILDREN - : EVAL_LOAD_NO_CHILDREN; - - foreach ($result as $evalquestion_id) { - $child = new EvaluationQuestion($evalquestion_id, $parentObject, $loadChildren); - $parentObject->addChild($child); - } - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - public function getType($objectID) - { - if ($this->exists($objectID)) { - return INSTANCEOF_EVALQUESTION; - } else { - $dbObject = new EvaluationAnswerDB (); - return $dbObject->getType($objectID); - } - } - - /** - * Returns the id from the parent object - * @access public - * @param string $objectID The object id - * @return string The id from the parent object - */ - public static function getParentID($objectID) - { - $db = DBManager::get(); - - $sql = - "SELECT" . - " parent_id " . - "FROM" . - " evalquestion " . - "WHERE" . - " evalquestion_id = ?"; - $result = $db->fetchColumn($sql, [$objectID]); - return $result; - } - - /** - * Returns the ids of the Answertemplates of a user - * @access public - * @param string $userID The user id - * @return array The ids of the answertemplates - */ - public function getTemplateID($userID) - { - $db = DBManager::get(); - - if (EvaluationObjectDB::getGlobalPerm() === 'root') { - $sql = "SELECT evalquestion_id - FROM evalquestion - WHERE parent_id = '0' - ORDER BY text"; - return $db->fetchFirst($sql); - } else { - $sql = "SELECT evalquestion_id - FROM evalquestion - WHERE parent_id = ? - OR parent_id = '0' - ORDER BY text"; - return $db->fetchFirst($sql, [$userID]); - } - } -} diff --git a/lib/evaluation/evaluation.config.php b/lib/evaluation/evaluation.config.php deleted file mode 100644 index e9d46db0aebb32eafa172958813038d5e9a07c7e..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation.config.php +++ /dev/null @@ -1,157 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Configurationfile for the evaluation module - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # - -# ====================================================== end: including files # - - -# Define public constants =================================================== # - -/* General constants ------------------------------------------------------- */ -define ("YES", 1); -define ("NO", 0); -define ("DEBUG", 1); -define ("QUOTED", 1); -define ("UNQUOTED", 0); -define ("EVAL_MIN_SEARCHLEN", 3); -define ("EVAL_MAX_TEMPLATENAMELEN", 22); -define("NEW_EVALUATION_TITLE", _("Neue Evaluation")); -define('FIRST_ARRANGMENT_BLOCK_TITLE', _('Erster Gruppierungsblock')); -define('EVAL_ROOT_TAG', "[R]"); -/* -------------------------------------------------- end: general constants */ - -/* Path constants ---------------------------------------------------------- */ -define ("EVAL_PATH_RELATIV", "lib/evaluation/"); -define ("EVAL_PATH", EVAL_PATH_RELATIV); -define ("EVAL_PATH_CLASSES", EVAL_PATH."classes/"); -define ("EVAL_PATH_DBCLASSES", EVAL_PATH_CLASSES."db/"); -/* ----------------------------------------------------- end: path constatns */ - -/* Class constants --------------------------------------------------------- */ -define ("EVAL_FILE_EDIT", "evaluation_admin_edit.inc.php"); -define ("EVAL_FILE_TEMPLATE", "evaluation_admin_template.inc.php"); -define ("EVAL_FILE_OVERVIEW", "evaluation_admin_overview.inc.php"); -define ("EVAL_FILE_SHOW", "show_evaluation.php"); -define ("EVAL_FILE_ADMIN", "admin_evaluation.php"); - -define ("EVAL_FILE_OBJECT", EVAL_PATH_CLASSES."EvaluationObject.class.php"); -define ("EVAL_FILE_OBJECTDB", EVAL_PATH_DBCLASSES."EvaluationObjectDB.class.php"); -define ("EVAL_FILE_EVAL", EVAL_PATH_CLASSES."Evaluation.class.php"); -define ("EVAL_FILE_EVALDB", EVAL_PATH_DBCLASSES."EvaluationDB.class.php"); -define ("EVAL_FILE_GROUP", EVAL_PATH_CLASSES."EvaluationGroup.class.php"); -define ("EVAL_FILE_GROUPDB", EVAL_PATH_DBCLASSES."EvaluationGroupDB.class.php"); -define ("EVAL_FILE_QUESTION", EVAL_PATH_CLASSES."EvaluationQuestion.class.php"); -define ("EVAL_FILE_QUESTIONDB", EVAL_PATH_DBCLASSES."EvaluationQuestionDB.class.php"); -define ("EVAL_FILE_ANSWER", EVAL_PATH_CLASSES."EvaluationAnswer.class.php"); -define ("EVAL_FILE_ANSWERDB", EVAL_PATH_DBCLASSES."EvaluationAnswerDB.class.php"); -define ("EVAL_FILE_EXPORTMANAGER", EVAL_PATH_CLASSES."EvaluationExportManager.class.php"); -define ("EVAL_FILE_EXPORTMANAGERCSV", EVAL_PATH_CLASSES."EvaluationExportManagerCSV.class.php"); -define ("EVAL_FILE_EVALTREE", EVAL_PATH_CLASSES."EvaluationTree.class.php"); -define ("EVAL_FILE_EDIT_TREEVIEW", EVAL_PATH_CLASSES."EvaluationTreeEditView.class.php"); -define ("EVAL_FILE_SHOW_TREEVIEW", EVAL_PATH_CLASSES."EvaluationTreeShowUser.class.php"); - -define ("HTML", EVAL_PATH_CLASSES."HTML.class.php"); -define ("HTMLempty", EVAL_PATH_CLASSES."HTMLempty.class.php"); -/* --------------------------------------------------- end: class constants */ - -/* Library constants ------------------------------------------------------- */ -define ("EVAL_LIB_COMMON", EVAL_PATH."evaluation.lib.php"); -define ("EVAL_LIB_OVERVIEW", EVAL_PATH."evaluation_admin_overview.lib.php"); -define ("EVAL_LIB_EDIT", EVAL_PATH."evaluation_admin_edit.lib.php"); -define ("EVAL_LIB_TEMPLATE", EVAL_PATH."evaluation_admin_template.lib.php"); -define ("EVAL_LIB_SHOW", EVAL_PATH."evaluation_show.lib.php"); -/* -------------------------------------------------- end: library constants */ - -/* Picture constants ------------------------------------------------------- */ -define ("EVAL_PIC_ICON", Icon::create('test', 'inactive')->asImagePath()); -define ("EVAL_PIC_PREVIEW", Icon::create('question-circle', 'clickable')->asImagePath()); -define ("EVAL_PIC_ADMIN", Icon::create('admin', 'clickable')->asImagePath()); -define ("EVAL_PIC_LOGO", Assets::image_path('sidebar/evaluation-sidebar.png')); -define ("EVAL_PIC_ARROW", Icon::create('arr_1right', 'accept')->asImagePath()); -define ("EVAL_PIC_ARROW_ACTIVE", Icon::create('arr_1down', 'accept')->asImagePath()); -define ("EVAL_PIC_SUCCESS", Icon::create('accept', 'accept')->asImagePath()); -define ("EVAL_PIC_ERROR", Icon::create('decline', 'attention')->asImagePath()); -define ("EVAL_PIC_INFO", Icon::create('exclaim', 'inactive')->asImagePath()); -define ("EVAL_PIC_INFO_SMALL", Icon::create('info', 'info')->asImagePath()); -define ("EVAL_PIC_HELP", Icon::create('info-circle', 'inactive')->asImagePath()); -define ("EVAL_PIC_MOVE_GROUP", Icon::create('arr_2left', 'sort')->asImagePath()); -define ("EVAL_PIC_MOVE_UP", Icon::create('arr_2up', 'sort')->asImagePath()); -define ("EVAL_PIC_MOVE_DOWN", Icon::create('arr_2down', 'sort')->asImagePath()); -define ("EVAL_PIC_MOVE_RIGHT", Icon::create('arr_2right', 'sort')->asImagePath()); -define ("EVAL_PIC_MOVE_LEFT", Icon::create('arr_2left', 'sort')->asImagePath()); -define ("EVAL_PIC_CREATE_ANSWERS", Assets::image_path('eval_create_answers.gif')); -define ("EVAL_PIC_EDIT_ANSWERS", Assets::image_path('eval_edit_answers.gif')); -define ("EVAL_PIC_TIME", Icon::create('date', 'info')->asImagePath()); -define ("EVAL_PIC_EXCLAIM", Icon::create('info', 'info')->asImagePath()); -define ("EVAL_PIC_DELETE_GROUP", Icon::create('trash', 'clickable')->asImagePath()); -define ("EVAL_PIC_MOVE_BUTTON", Icon::create('arr_2right', 'sort')->asImagePath()); -define ("EVAL_PIC_ADD", Icon::create('add', 'clickable')->asImagePath()); -define ("EVAL_PIC_ADD_TEMPLATE", Icon::create('add', 'clickable')->asImagePath()); -define ("EVAL_PIC_REMOVE", Icon::create('trash', 'clickable')->asImagePath()); -define ("EVAL_PIC_EDIT", Icon::create('edit', 'clickable')->asImagePath()); -define ("EVAL_PIC_BACK", Icon::create('link-intern', 'clickable')->asImagePath()); -define ("EVAL_PIC_ARROW_TEMPLATE", Icon::create('arr_1right', 'clickable')->asImagePath()); -define ("EVAL_PIC_ARROW_TEMPLATE_OPEN", Icon::create('arr_1down', 'clickable')->asImagePath()); -define ("EVAL_PIC_ARROW_NEW", Icon::create('arr_1right', 'sort')->asImagePath()); -define ("EVAL_PIC_ARROW_NEW_OPEN", Icon::create('arr_1down', 'sort')->asImagePath()); -define ("EVAL_PIC_ARROW_RUNNING", Icon::create('arr_1right', 'accept')->asImagePath()); -define ("EVAL_PIC_ARROW_RUNNING_OPEN", Icon::create('arr_1down', 'accept')->asImagePath()); -define ("EVAL_PIC_ARROW_STOPPED", Icon::create('arr_1right', 'attention')->asImagePath()); -define ("EVAL_PIC_ARROW_STOPPED_OPEN", Icon::create('arr_1down', 'attention')->asImagePath()); -define ("EVAL_PIC_TREE_ARROW", Icon::create('arr_1right', 'clickable')->asImagePath()); -define ("EVAL_PIC_TREE_ARROW_ACTIVE", Icon::create('arr_1down', 'clickable')->asImagePath()); -define ("EVAL_PIC_TREE_BLANC", Assets::image_path('forumleer.gif')); -define ("EVAL_PIC_TREE_ROOT", Icon::create('vote', 'inactive')->asImagePath()); -define ("EVAL_PIC_TREE_GROUP", Icon::create('test', 'info')->asImagePath()); -define ("EVAL_PIC_TREE_GROUP_FILLED", Assets::image_path('eval_group_filled.gif')); -define ("EVAL_PIC_TREE_QUESTIONGROUP", Icon::create('test', 'info')->asImagePath()); -define ("EVAL_PIC_TREE_QUESTIONGROUP_FILLED", Assets::image_path('eval_qgroup_filled.gif')); -define ("EVAL_PIC_EXPORT_FILE", Icon::create('file-xls', 'clickable')->asImagePath()); -define ("EVAL_PIC_YES", Icon::create('accept', 'accept')->asImagePath()); -define ("EVAL_PIC_NO", Icon::create('decline', 'attention')->asImagePath()); -define ("EVAL_PIC_SHARED", Icon::create('checkbox-checked', 'clickable')->asImagePath()); -define ("EVAL_PIC_NOTSHARED", Icon::create('checkbox-unchecked', 'clickable')->asImagePath()); -/* -------------------------------------------------- end: picture constants */ - -/* CSS constants ----------------------------------------------------------- */ -define ("EVAL_CSS_SUCCESS", "eval_success"); -define ("EVAL_CSS_ERROR", "eval_error"); -define ("EVAL_CSS_INFO", "eval_info"); -/* ------------------------------------------------------ end: css constants */ - -# ===================================================== end: define constants # -?> diff --git a/lib/evaluation/evaluation.lib.php b/lib/evaluation/evaluation.lib.php deleted file mode 100644 index 811e27db67ee5e9921c112cc0cbd47e8bbb5b3d3..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation.lib.php +++ /dev/null @@ -1,246 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter005: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - - -# Define constants ========================================================== # -# ===================================================== end: define constants # - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once HTML; -# ====================================================== end: including files # - - -/** - * Library with common static functions for the evaluation module - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvalCommon -{ - /** - * Creates this funny blue title bar - * @param string $title The title - * @param string $iconURL The URL for the icon - */ - public static function createTitle($title, $iconURL = "", $padding = 0) - { - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("class", "blank"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", $padding); - $table->addAttr("width", "100%"); - - $trTitle = new HTML("tr"); - $trTitle->AddAttr("valign", "top"); - $trTitle->AddAttr("align", "center"); - - $tdTitle = new HTML("td"); - if ($iconURL) { - $tdTitle->addAttr("class", "table_header_bold"); - } else { - $tdTitle->addAttr("class", "content_body"); - } - $tdTitle->addAttr("colspan", "2"); - $tdTitle->addAttr("align", "left"); - $tdTitle->addAttr("valign", "middle"); - - if ($iconURL) { - $imgTitle = new HTMLempty ("img"); - $imgTitle->addAttr("src", $iconURL); - $imgTitle->addAttr("alt", $title); - $imgTitle->addAttr("align", "bottom"); - $tdTitle->addContent($imgTitle); - } - - $bTitle = new HTML ("b"); - $bTitle->addContent($title); - $tdTitle->addContent($bTitle); - - $trTitle->addContent($tdTitle); - $table->addContent($trTitle); - - return $table; - } - - /** - * Creates a simple image for the normal top of an modulepage - * @param string $imgURL The URL for the icon - * @param string $imgALT The description for the icon - */ - public static function createImage($imgURL, $imgALT, $extra = "") - { - $img = new HTMLempty ("img"); - $img->addAttr("border", "0"); - $img->addAttr("valign", "middle"); - $img->addAttr("src", $imgURL); - if (empty($extra)) { - $img->addAttr("alt", $imgALT); - $img->addAttr("title", $imgALT); - } else { - $img->addString($extra); - } - - return $img; - } - - /** - * Creates the Javascript static function, which will open an evaluation popup - */ - static function createEvalShowJS($isPreview = NO, $as_object = YES) - { - $html = ""; - $html .= - "<script type=\"text/javascript\" language=\"JavaScript\">" . - " function openEval( evalID ) {" . - " evalwin = window.open(STUDIP.URLHelper.getURL('show_evaluation.php?evalID=' + evalID + '&isPreview=" . $isPreview . "'), " . - " evalID, 'width=790,height=500,scrollbars=yes,resizable=yes');" . - " evalwin.focus();" . - " }\n" . - "</script>\n"; - - $div = new HTML ("div"); - $div->addHTMLContent($html); - - if ($as_object) { - return $div; - } - return $html; - } - - /** - * Creates a link, which will open an evaluation popup - */ - static function createEvalShowLink($evalID, $content, $isPreview = NO, $as_object = YES) - { - $html = ""; - - $html .= - "<a " . - "href=\"" . URLHelper::getLink('show_evaluation.php?evalID=' . $evalID . '&isPreview=' . $isPreview) . "\" " . - "target=\"" . $evalID . "\" " . - "onClick=\"openEval('" . $evalID . "'); return false;\">" . - (is_object($content) ? str_replace("\n", "", $content->createContent()) : $content) . - "</a>"; - - $div = new HTML ("div"); - $div->addHTMLContent($html); - - if ($as_object) { - return $div; - } - return $html; - } - - - /** - * @param $object - * @param string $errortitle - * @return MessageBox - * @deprecated - */ - public static function createErrorReport(AuthorObject $object, string $errortitle = ''): MessageBox - { - $errors = $object->getErrors(); - - if (!$errortitle) { - if (count($errors) > 1) { - $errortitle = _('Es sind Fehler aufgetreten.'); - } else { - $errortitle = _('Es ist ein Fehler aufgetreten.'); - } - } - - $details = array_map( - function ($error) { - return "#{$error['code']}: {$error['string']}"; - }, - $errors - ); - - return MessageBox::error($errortitle, $details); - } - - /** - * Returns the rangeID - */ - public static function getRangeID() - { - $rangeID = Request::option('range_id') ?: Context::getId(); - - if (empty ($rangeID) || ($rangeID == get_username($GLOBALS['user']->id))) - $rangeID = $GLOBALS['user']->id; - - return $rangeID; - } - - - /** - * Checks and transforms a date into a UNIX (r)(tm) timestamp - * @access public - * @static - * @param integer $day The day - * @param integer $month The month - * @param integer $year The year - * @param integer $hour The hour (optional) - * @param integer $minute The minute (optional) - * @param integer $second The second (optional) - * @return integer If an error occurs -> -1. Otherwise the UNIX-timestamp - */ - public static function date2timestamp( - $day, - $month, - $year, - $hour = 0, - $minute = 0, - $second = 0 - ) - { - if (!checkdate((int)$month, (int)$day, (int)$year) || - $hour < 0 || $hour > 24 || - $minute < 0 || $minute > 59 || - $second < 0 || $second > 59) { - return -1; - } - - // windows cant count that mutch - if ($year < 1971) { - $year = 1971; - } elseif ($year > 2037) { - $year = 2037; - } - - return mktime($hour, $minute, $second, $month, $day, $year); - } -} - -?> diff --git a/lib/evaluation/evaluation_admin_edit.inc.php b/lib/evaluation/evaluation_admin_edit.inc.php deleted file mode 100644 index 39def65bfb6ba45386a7f42b92b4d53a55bada53..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation_admin_edit.inc.php +++ /dev/null @@ -1,210 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Christian Bauer <alfredhitchcock@gmx.net> - * @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. -// +---------------------------------------------------------------------------+ - -# PHP-LIB: open session ===================================================== # -/*page_open (array ("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 EVAL_LIB_EDIT; -require_once EVAL_FILE_EDIT_TREEVIEW; - -# ====================================================== end: define constancs # - -$debug = "<pre class=\"steelgroup6\" style=\"font-size:10pt\">" - . "<pre class=\"steelgroup3\" style=\"font-size:10pt\">" - . "Welcome to BugReport 1.02 " - . "[Sharewareversion]" - . "</pre>"; - -# check the evalID ========================================================= # - -global $user; - -if (Request::submitted('newButton')) { - $debug .= "neue Eval!<br>"; - // create the first group - $group = new EvaluationGroup(); - $group->setTitle(FIRST_ARRANGMENT_BLOCK_TITLE, QUOTED); - $group->setText(""); - if ($group->isError()) { - return MessageBox::error(_("Fehler beim Anlegen einer Gruppe")); - } - // create a new eval - $eval = new Evaluation (); - $rangeID = Request::option("rangeID"); - if ($rangeID == $user->username) { - $rangeID = $user->id; - } - - $eval->setAuthorID($user->id); - $eval->setTitle(NEW_EVALUATION_TITLE); - $eval->setAnonymous(YES); - $evalID = $eval->getObjectID(); - $eval->addChild($group); - $eval->save(); - - if ($eval->isError()) { - return MessageBox::error(_("Fehler beim Anlegen einer Evaluation")); - } - - $groupID = $group->getObjectID(); - $evalID = $eval->getObjectID(); - -} elseif (Request::option("evalID") && (Request::option("evalID") != NULL)) { - $debug .= "isset _REQUTEST[evalID]!<br>"; - $evalID = Request::option("evalID"); - $eval = new Evaluation ($evalID, NULL, EVAL_LOAD_NO_CHILDREN); - if ($eval->isError()) { - PageLayout::postError(_("Es wurde eine ungültige Evaluations-ID übergeben.")); - } elseif ($evalID == NULL) { - PageLayout::postError(_("Es wurde keine Evaluations-ID übergeben")); - } - -} else { - PageLayout::postError(_("Es wurde keine Evaluations-ID übergeben")); -} - -# ===================================================== END: check the evalID # - -# check the itemID ========================================================= # -$itemID = Request::option('itemID'); -if ($itemID) { - $_SESSION['itemID'] = $itemID; -} elseif (Request::submitted('newButton')) { - $_SESSION['itemID'] = "root"; -} -# ===================================================== END: check the itemID # - -# check the rangeID ======================================================== # - -if (Request::option("rangeID")) { - $_SESSION['rangeID'] = Request::option("rangeID"); - -} - -# ==================================================== END: check the rangeID # - -# EVTAU: employees of the vote-team against urlhacking ====================== # - -$eval = new Evaluation($evalID ?? '', NULL, EVAL_LOAD_NO_CHILDREN); - -// someone has voted -if ($eval->hasVoted()) { - $error = MessageBox::error( - _("An dieser Evaluation hat bereits jemand teilgenommen. Sie darf nicht mehr verändert werden.") - ); -} - - -// only the author or user with tutor perm in all evalRangeIDs should edit an eval -$authorID = $eval->getAuthorID(); - -if ($authorID != $user->id) { - - $no_permisson = 0; - - if (is_array($eval->getRangeIDs())) { - - foreach ($eval->getRangeIDs() as $rangeID) { - - $user_perm = EvaluationObjectDB::getRangePerm($rangeID, $user->id, YES); - - // every range with a lower perm than Tutor - if ($user_perm < 7) - $no_permisson++; - } - - if ($no_permisson > 0) { - if ($no_permisson == 1) { - $no_permisson_msg = _("Sie haben in einem Bereich, in welchem diese Evaluation hängt, nicht aussreichene Rechte, um diese Eval zu bearbeiten."); - } else { - $no_permisson_msg = sprintf(_("Sie haben in %s Bereichen, in denen diese Evaluation hängt, nicht aussreichene Rechte, um diese Eval zu bearbeiten."), $no_permisson); - } - $error_msgs[] = MessageBox::error($no_permisson_msg); - } - } -} - - -# ============================================ end: Collection post/get-vars # - -# Print Error MSG and end Site ============================================= # - -if (!empty($error_msgs)) { - - $back_button = (" ") - . "<a href=\"" . URLHelper::getLink('admin_evaluation.php?page=overview&rangeID=' . Request::option('rangeID')) . "\">" - . _("Zur Evaluations-Verwaltung") - . "</a>"; - $errors = ''; - if (is_array($error_msgs)) { - foreach ($error_msgs as $error_msg) { - $errors .= $error_msg . "<br>"; - } - - } - echo EvalEdit::createSite($errors . $back_button, " "); - include_once('lib/include/html_end.inc.php'); - page_close(); - exit (); - -} - - -# ======================================== end: Print Error MSG and end Site # - -/* Do first all actions for templates -------------------------------------- */ -$templateSite = include(EVAL_FILE_TEMPLATE); -/* --------------------------------- end: do first all actions for templates */ - - -# Creating the Tree ======================================================== # -$EditTree = new EvaluationTreeEditView($itemID, $evalID ?? null); - -# Send messages to the tree ================================================ # - -if (Request::submitted('newButton')) { - $EditTree->msg["root"] = "msg§" - . _("Erstellen Sie nun eine Evaluation.<br> Der erste Gruppierungsblock ist bereits angelegt worden. Wenn Sie ihn öffnen, können Sie dort weitere Gruppierungsblöcke oder Fragenblöcke anlegen."); -} -$editSite = $EditTree->showEvalTree($itemID, 1); -echo EvalEdit::createSite($editSite, $templateSite); diff --git a/lib/evaluation/evaluation_admin_edit.lib.php b/lib/evaluation/evaluation_admin_edit.lib.php deleted file mode 100644 index 45ce428fa206d04e2291a524ad42b4f3260eadcd..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation_admin_edit.lib.php +++ /dev/null @@ -1,97 +0,0 @@ -<?php -/** - * Beschreibung - * - * @author Christian Bauer <alfredhitchcock@gmx.net> - * @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. -// +---------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once HTML; -//require_once (HTMLempty); -# ====================================================== end: including files # -class EvalEdit -{ - - /** - * creates the main-table - * @access public - * @param string $title the title - * @param string $left the left site of the table - * @param string $rigt the right site of the table - * @return string the html-table - */ - public static function createSite($left = "", $right = "") - { - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("class", "blank"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "100%"); - - $tr = new HTML("tr"); - - $td = new HTML("td"); - $td->addAttr("class", "blank"); - $td->addAttr("width", "100%"); - $td->addAttr("align", "left"); - $td->addAttr("valign", "top"); - $td->setTextareaCheck(YES); - $td->addHTMLContent($left); - - $tr->addContent($td); - - $td = new HTML("td"); - $td->addAttr("class", "blank"); - $td->addAttr("align", "right"); - $td->addAttr("valign", "top"); - $td->addHTMLContent($right); - - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - public static function createHiddenIDs() - { - $input = new HTML ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("evalID", Request::option('evalID')); - - $input = new HTML ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("itemID", Request::option('itemID')); - - $input = new HTML ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("rangeID", Request::option("rangeID")); - - return; - } -} diff --git a/lib/evaluation/evaluation_admin_overview.inc.php b/lib/evaluation/evaluation_admin_overview.inc.php deleted file mode 100644 index d8ba9a31cb87709cdcc2142ac62314d5bbb942b9..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation_admin_overview.inc.php +++ /dev/null @@ -1,391 +0,0 @@ -<?php -/** - * Overview of all existing evaluations - * - * @author Alexander Willner <mail@AlexanderWillner.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. -// +--------------------------------------------------------------------------+ - -# PHP-LIB: open session ===================================================== # -// page_open (array ("sess" => "Seminar_Session", -// "auth" => "Seminar_Auth", -// "perm" => "Seminar_Perm", -// "user" => "Seminar_User")); -// $auth->login_if ($auth->auth["uid"] == "nobody"); -// $GLOBALS['perm']->check ("autor"); -# ============================================================== end: PHP-LIB # - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_LIB_COMMON; -require_once EVAL_LIB_OVERVIEW; -require_once EVAL_FILE_EVAL; -require_once EVAL_FILE_EVALDB; -# ====================================================== end: including files # - -define("DISCARD_OPENID", "discard_openid"); - -/* Create objects ---------------------------------------------------------- */ -$db = new EvaluationObjectDB (); -if ($db->getErrors()) { - return MessageBox::error(_("Datenbankfehler")); -} -$lib = new EvalOverview ($db, $GLOBALS['perm'], $GLOBALS['user']); -/* ------------------------------------------------------------ end: objects */ - - -/* Set variables ----------------------------------------------------------- */ -if (isset($_SESSION['evalID'])) { - unset($_SESSION['evalID']); -} -if (isset($_SESSION['rangeID'])) { - unset($_SESSION['rangeID']); -} - -if (!empty($the_range)) { - $rangeID = $the_range; -} - -$rangeID = $rangeID ?? Context::getId(); - -if (empty ($rangeID) || ($rangeID == $GLOBALS['user']->username)) { - $rangeID = $GLOBALS['user']->id; -} -$_SESSION['rangeID'] = $rangeID; -$debug = 0; - -$evalAction = $lib->getPageCommand(); - -$openID = Request::option("openID"); -$evalID = Request::option("evalID"); -$search = Request::get("search"); // range -$templates_search = Request::get("templates_search"); -$search = $templates_search; -/* ---------------------------------------------------------- end: variables */ - -/* Javascript function ----------------------------------------------------- */ -$js = EvalCommon::createEvalShowJS(YES); -echo $js->createContent(); - -/* Maintable with white border --------------------------------------------- */ -$table = $lib->createMainTable(); -/* -----------------------------------------------------------end: maintable */ - -/* Check permissions and call safeguard ------------------------------------ */ -if (!$GLOBALS['perm']->have_studip_perm("tutor", $rangeID) && $GLOBALS['user']->id != $rangeID) { - echo MessageBox::error(_("Sie haben keinen Zugriff auf diesen Bereich.")); - return; -} - -$safeguard = $lib->callSafeguard($evalAction, $evalID, $rangeID, $search, null); -/* ---------------------------------------------------------- end: safeguard */ - -$foundTable = ''; -/* found public templates -------------------------------------------------- */ -if ($templates_search) { - $search = trim($search); - $evalIDArray = $db->getPublicTemplateIDs($search); - if (mb_strlen($search) >= EVAL_MIN_SEARCHLEN && !empty ($evalIDArray)) { - $foundTable = new HTML ("table"); - $foundTable->addAttr("border", "0"); - $foundTable->addAttr("align", "center"); - $foundTable->addAttr("cellspacing", "0"); - $foundTable->addAttr("cellpadding", "0"); - $foundTable->addAttr("width", "100%"); - $foundTr = new HTML ("tr"); - $foundTd = new HTML ("td"); - $foundTd->addAttr("align", "left"); - $foundTd->addAttr("colspan", "10"); - $foundTd->addContent(new HTMLempty ("br")); - - $b = new HTML ("b"); - $b->addContent(_("Gefundene öffentliche Evaluationsvorlagen:")); - $foundTd->addContent($b); - $foundTr->addContent($foundTd); - $foundTable->addContent($foundTr); - - $foundTable->addContent($lib->createGroupTitle([ - " ", - _("Titel"), -# " ", - _("Autor"), - _("Letzte Änderung"), - _("Anonym"), - "", - _("Ansehen"), - _("Kopieren"), - " " - ], YES, "public_template")); - foreach ($evalIDArray as $number => $evalID) { - $eval = new Evaluation ($evalID); - $foundTable->addContent($lib->createEvalRow($eval, $number, "public_template", NO, YES)); - } - } -} -/* --------------------------------------------- end: found public templates */ - -/* Own templates ----------------------------------------------------------- */ -$evalIDArray = $db->getEvaluationIDs(); -$templateTable = new HTML ("table"); -$templateTable->addAttr("border", "0"); -#$templateTable->addAttr ("style","border:1px solid black"); -$templateTable->addAttr("align", "center"); -$templateTable->addAttr("cellspacing", "0"); -$templateTable->addAttr("cellpadding", "2"); -$templateTable->addAttr("width", "100%"); -$templateTr = new HTML ("tr"); -$templateTd = new HTML ("td"); -$templateTd->addAttr("colspan", "7"); - -$b = new HTML ("h2"); -$b->addContent(_("Eigene Evaluationsvorlagen:")); -$templateTd->addContent($b); -$templateTr->addContent($templateTd); -$templateTable->addContent($templateTr); - -if (!empty ($evalIDArray)) { - $templateTable->addContent($lib->createGroupTitle([ - " ", - _("Titel"), - _("Freigeben"), - " ", - " ", - " ", - _("Bearbeiten"), - _("Löschen")], YES, "user_template")); - foreach ($evalIDArray as $number => $evalID) { - $eval = new Evaluation ($evalID); - $open = ($openID == $evalID); - $templateTable->addContent($lib->createEvalRow($eval, $number, "user_template", $open, YES)); - if ($open) { - $tr = new HTML ("tr"); - $td = new HTML ("td"); - $td->addAttr("colspan", "10"); - $td->addContent($lib->createEvalContent($eval, $number, "user_template", $safeguard)); - $tr->addContent($td); - $templateTable->addContent($tr); - } - } -} else { - $tr = new HTML ("tr"); - $td = new HTML ("td"); - $td->addAttr("colspan", "10"); - $td->addContent($lib->createInfoCol(_("Keine eigenen Evaluationsvorlagen vorhanden."))); - $tr->addContent($td); - $templateTable->addContent($tr); -} - -/* ------------------------------------------------------ end: own templates */ - - -/* Create header with logo and safeguard messages -------------------------- */ -if (is_array($safeguard)) { - if ($safeguard["option"] == DISCARD_OPENID) - $openID = NULL; - $safeguard = $safeguard["msg"]; -} - -if (empty($openID)) { - $table->addContent($lib->createHeader($safeguard, $templateTable, $foundTable)); -} else { - $table->addContent($lib->createHeader(" ", $templateTable, $foundTable)); -} -/* ------------------------------------------------------------- end: header */ - -$table->addContent($lib->createClosingRow()); -/* ---------------------------------------------------------- end: templates */ - - -/* Create line with informations ------------------------------------------- */ -$tr = new HTML ("tr"); -$td = new HTML ("td"); -$td->addAttr("class", "blank"); - - -if (EvaluationObjectDB::getGlobalPerm() !== 'autor') { - $td->addContent($lib->createShowRangeForm()); -} else { - $td->addHTMLContent("Evaluationen aus dem Bereich \"" . - htmlReady($db->getRangename($rangeID)) . "\":"); - $td->addContent(new HTMLempty ("br")); -} -$td->addContent(new HTMLempty ("br")); - - -$tr->addContent($td); -$table->addContent($tr); -/* ----------------------------------------------------------- end: infoline */ - -/* Show showrange search results ------------------------------------------- */ -if ($evalAction == "search_showrange" && Request::get("search")) { - $tr = new HTML ("tr"); - $td = new HTML ("td"); - $td->addAttr("class", "blank"); - $td->addAttr("align", "left"); - $td->addContent(new HTMLempty ("br")); - $b = new HTML ("b"); - $line = new HTMLempty ("hr"); - $line->addAttr("size", "1"); - $line->addAttr("noshade", "noshade"); -#$td->addContent ($line); - $b->addContent(_('Suchergebnisse') . ':'); - $td->addContent($b); - - $td->addHTMLContent($lib->createDomainLinks(Request::get("search"))); - $tr->addContent($td); - $table->addContent($tr); - $table->addContent($lib->createClosingRow()); - echo $table->createContent(); - return; -} -/* -------------------------------------- end: Show showrange search results */ - -/* Show not started evaluations -------------------------------------------- */ -$evalIDArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_NEW); - -$tr = new HTML ("tr"); -$td = new HTML ("td"); -$td->addAttr("class", "blank"); -$b = new HTML ("b"); -$b->addContent(_("Noch nicht gestartete Evaluationen: ")); -$td->addContent($b); - -if (!empty ($evalIDArray)) { - $td->addContent($lib->createGroupTitle([_("Titel"), - _("Autor"), - _("Startdatum"), - _("Status"), - "", - _("Bearbeiten"), - _("Löschen"), - ""])); - foreach ($evalIDArray as $number => $evalID) { - $eval = new Evaluation ($evalID); - $open = ($openID == $evalID); - $td->addContent($lib->createEvalRow($eval, $number, EVAL_STATE_NEW, $open)); - if ($open) - $td->addContent($lib->createEvalContent($eval, $number, EVAL_STATE_NEW, $safeguard)); - } - -} else { - $td->addContent($lib->createInfoCol(_("Keine neuen Evaluationen vorhanden."))); -} -$tr->addContent($td); -$table->addContent($tr); -$table->addContent($lib->createClosingRow()); -/* -------------------------------------------------------- end: not started */ - - -/* Show running evaluations ------------------------------------------------ */ -$evalIDArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_ACTIVE); - -$tr = new HTML ("tr"); -$td = new HTML ("td"); -$td->addAttr("class", "blank"); -$td->addContent(new HTMLempty("br")); -$b = new HTML ("b"); -$b->addContent(_("Laufende Evaluationen:")); -$td->addContent($b); -if (!empty ($evalIDArray)) { - $td->addContent($lib->createGroupTitle([_("Titel"), - _("Autor"), - _("Ablaufdatum"), - _("Status"), - "", - _("Exportieren"), - _("Löschen"), - _("Auswertung")])); - foreach ($evalIDArray as $number => $evalID) { - $eval = new Evaluation ($evalID); - $open = ($openID == $evalID); - $td->addContent($lib->createEvalRow($eval, $number, EVAL_STATE_ACTIVE, $open)); - if ($open) - $td->addContent($lib->createEvalContent($eval, $number, EVAL_STATE_ACTIVE, $safeguard)); - } -} else { - $td->addContent($lib->createInfoCol(_("Keine laufenden Evaluationen vorhanden."))); -} -$tr->addContent($td); -$table->addContent($tr); -$table->addContent($lib->createClosingRow()); -/* ------------------------------------------------------------ end: running */ - - -/* Show stopped evaluations ------------------------------------------------ */ -$evalIDArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_STOPPED); -$tr = new HTML ("tr"); -$td = new HTML ("td"); -$td->addAttr("class", "blank"); -$td->addContent(new HTMLempty("br")); -$b = new HTML ("b"); -$b->addContent(_("Beendete Evaluationen:")); -$td->addContent($b); - -if (!empty ($evalIDArray)) { - $td->addContent($lib->createGroupTitle([_("Titel"), - _("Autor"), - "", - _("Status"), - "", - _("Exportieren"), - _("Löschen"), - _("Auswertung")])); - foreach ($evalIDArray as $number => $evalID) { - $eval = new Evaluation ($evalID); - $open = ($openID == $evalID); - $td->addContent($lib->createEvalRow($eval, $number, EVAL_STATE_STOPPED, $open)); - if ($open) - $td->addContent($lib->createEvalContent($eval, $number, EVAL_STATE_STOPPED, $safeguard)); - } -} else { - $td->addContent($lib->createInfoCol(_("Keine gestoppten Evaluationen vorhanden."))); -} -$tr->addContent($td); -$table->addContent($tr); -$table->addContent($lib->createClosingRow()); -/* ------------------------------------------------------------ end: stopped */ - -echo $table->createContent(); - - -if ($debug) { - echo "<pre>"; - echo "rangeid = $rangeID\n"; - echo "<font color=red>Nach Evaluationen suchen...</font><br>"; - $evalArray = $db->getEvaluationIDs($rangeID); - echo "ed(n) " . count($evalArray) . " Evaluation(en) gefunden...</font><br>"; - $evalArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_NEW); - echo "Es wurde(n) " . count($evalArray) . " neue Evaluation(en) gefunden...</font><br>"; - $evalArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_ACTIVE); - echo "Es wurde(n) " . count($evalArray) . " laufende Evaluation(en) gefunden...</font><br>"; - $evalArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_STOPPED); - echo "Es wurde(n) " . count($evalArray) . " gestoppte Evaluation(en) gefunden...</font><br>"; - - echo EvalCommon::createErrorReport($db); - - print_r($_POST); -} diff --git a/lib/evaluation/evaluation_admin_overview.lib.php b/lib/evaluation/evaluation_admin_overview.lib.php deleted file mode 100644 index 40174eca4071af963a5d671918d285e2e32fd1ff..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation_admin_overview.lib.php +++ /dev/null @@ -1,2215 +0,0 @@ -<?php - -# Lifter002: TODO -# Lifter005: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// 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. -// +--------------------------------------------------------------------------+ - -use Studip\Button, - Studip\LinkButton; - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once HTML; -require_once EVAL_LIB_COMMON; -require_once EVAL_LIB_SHOW; -require_once EVAL_FILE_EXPORTMANAGERCSV; -# ====================================================== end: including files # -# Define constants ========================================================== # -/** - * @const EVAL_TITLE Blah... - */ -define("EVAL_TITLE", _("Evaluations-Verwaltung")); -# ===================================================== end: define constants # - -/** - * Library for the overview of all existing evaluations - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvalOverview -{ -# Define all required variables ============================================= # - /** - * Databaseobject - * @access private - * @var object DatabaseObject $db - */ - - var $db; - - /** - * Permobject - * @access private - * @var object Perm $perm - */ - var $perm; - - /** - * Userobject - * @access private - * @var object User $user - */ - var $user; -# ============================================================ end: variables # -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param object DatabaseObject $db The database object - * @param object Perm $perm The permission object - * @param object User $user The user object - */ - - function __construct($db, $perm, $user) - { - /* Set default values ------------------------------------------------- */ - $this->db = $db; - $this->perm = $perm; - $this->user = $user; - /* -------------------------------------------------------------------- */ - } - -# =========================================== end: constructor and destructor # -# Define public functions =================================================== # - /** - * - */ - - function createMainTable() - { - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "0"); - $table->addAttr("width", "100%"); - $table->addAttr("style", "border:5px solid white;"); - return $table; - } - - /** - * Creates the funny blue small titlerows - * @access public - * @param array $rowTitles An array with all col-titles - * @param boolean $returnRow If YES it returns the row not the table - * @param string $state - */ - function createGroupTitle($rowTitles, $returnRow = false, $state = false) - { - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "100%"); - - $tr = new HTML("tr"); - - if ($state == "user_template") - $style = "steel_with_table_row_even_bg"; - elseif ($state == "public_template") - $style = "eval_grey_border"; - else - $style = "table_header"; - - for ($i = 0; $rowTitles != NULL; $i++) { - - $td = new HTML("td"); - $td->addAttr("style", "vertical-align:bottom; font-weight:bold; white-space:nowrap"); - $td->addAttr("nowrap", "nowrap"); - $td->addAttr("height", "22"); - $td->addAttr("class", $style); - - if ($i == 0) { - $td->addAttr("width", $state == "public_template" ? "1" : "10"); - $td->addHTMLContent(" "); - } else { - if ($i == 2 && $state == "user_template") { - // the title - $td->addAttr("width", "100%"); - $td->addAttr("align", "left"); - } elseif ($i == 2 && $state == "public_template") { - // the title - $td->addAttr("width", "100%"); - $td->addAttr("align", "left"); - } elseif ($i > 1) { - $td->addAttr("width", "96"); - $td->addAttr("align", "center"); - } elseif ($i == 1 && $state == "public_template") { - // the preview - $td->addAttr("width", "20"); - $td->addAttr("align", "left"); - $td->addHTMLContent(" "); - } else { - $td->addAttr("align", "left"); - } - $title = array_shift($rowTitles); - $title = empty($title) ? " " : $title; - $td->addHTMLContent($title); - } - - # filter out not needed headlines - if ($state == "user_template" && - (($i == 4) || ($i == 5))) { - //nothing - } elseif ($state == "public_template" && - (($i == 6) || ($i == 7) || ($i == 9))) { - //nothing - } else - $tr->addContent($td); - } // for - - $table->addContent($tr); - - return $returnRow ? $tr : $table; - } - - /** - * Test... - * @access public - * @param object Evaluation $eval The evaluation - * @param string $number - * @param string $state - * @param string $open - * @param boolean $returnRow - */ - function createEvalRow($eval, $number, $state, $open, $returnRow = false) - { - - /* initialize variables -------- */ - $evalID = $eval->getObjectID(); - $numberOfVotes = EvaluationDB::getNumberOfVotes($evalID); - - $no_permissons = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval); - $no_buttons = 0; - if ($eval->getAuthor() != $GLOBALS['user']->id && $no_permissons) - $no_buttons = 1; - - $style = ($number % 2) ? "table_row_odd" : ($number == 0 ? "content_body" : "table_row_even"); - - $startDate = $eval->getStartdate() == NULL ? " " : date("d.m.Y", $eval->getStartdate()); - - $stopDate = $eval->getRealStopdate() == NULL ? " " : date("d.m.Y", $eval->getRealStopdate()); - - $link = "?rangeID=" . $_SESSION["rangeID"]; - if ($open == NO) - $link .= '&openID=' . $evalID . '#open'; - - $titleLink = new HTML('a'); - $titleLink->addAttr('href', URLHelper::getLink($link)); - $arrowLink = new HTML('a'); - $arrowLink->addAttr('href', URLHelper::getLink($link)); - - $titleLink->addContent(($eval->getTitle()) ? $eval->getTitle() : ' '); - - switch ($state) { - - case "public_template": - $arrowLink = " "; - $titleLink = $eval->getTitle() ? $eval->getTitle() : " "; - $content[0] = $eval->getFullName() ? $eval->getFullName() : " "; - $content[1] = $eval->getChangedate() == NULL ? " " : date("d.m.Y", $eval->getChangedate()); - - $button = LinkButton::create(_('Vorschau'), URLHelper::getURL('show_evaluation.php?evalID=' . $evalID . '&isPreview=' . YES), ['title' => _('Vorschau dieser öffentlichen Evaluationsvorlage.'), - 'onClick' => 'openEval(\'' . $evalID . '\'); return false;']); - $div = new HTML("div"); - $div->addHTMLContent($button); - $content[4] = $div; - - $content[2] = $eval->isAnonymous() ? EvalCommon::createImage(EVAL_PIC_YES, _("ja")) : EvalCommon::createImage(EVAL_PIC_NO, _("nein")); - - $copyButton = new HTMLempty("input"); - $copyButton->addAttr("style", "vertical-align:middle;"); - $copyButton->addAttr("type", "image"); - $copyButton->addAttr("name", "copy_public_template_button"); - $copyButton->addAttr("src", Icon::create('arr_2down', 'sort')->asImagePath()); - $copyButton->addAttr("border", "0"); - $copyButton->addAttr("alt", _("Kopieren")); - $copyButton->addAttr("title", _("Diese öffentliche Evaluationsvorlagen zu den eigenen Evaluationsvorlagen kopieren")); - $content[5] = $copyButton; - - break; - - case "user_template": - $arrowLink->addContent(EvalCommon::createImage(($open ? EVAL_PIC_ARROW_TEMPLATE_OPEN : EVAL_PIC_ARROW_TEMPLATE), _("Aufklappen"))); - $isShared = $eval->isShared() ? YES : NO; - $shareButton = new HTMLempty("input"); - $shareButton->addAttr("style", "vertical-align:middle;"); - $shareButton->addAttr("type", "image"); - $shareButton->addAttr("name", "share_template_button"); - $shareButton->addAttr("src", $isShared ? EVAL_PIC_SHARED : EVAL_PIC_NOTSHARED); - $shareButton->addAttr("border", "0"); - $shareButton->addAttr("alt", $isShared ? _("als öffentliche Evaluationsvorlage Freigeben") : _("Freigabe entziehen")); - $shareButton->addAttr("title", $isShared ? _("Die Freigabe für diese Evaluationsvorlage entziehen") : _("Diese Evaluationsvorlage öffentlich freigeben")); - - $content[0] = $shareButton; - $content[3] = Button::create(_('Kopie erstellen'), 'copy_own_template_button', ['title' => _('Evaluationsvorlage kopieren')]); - - $content[4] = LinkButton::create(_('Bearbeiten'), URLHelper::getURL("admin_evaluation.php?page=edit&evalID=" . $evalID), ['title' => _('Evaluation bearbeiten')]); - - $content[5] = Button::create(_('Löschen'), 'delete_request_button', ['title' => _('Evaluation löschen')]); - break; - - case EVAL_STATE_NEW: - $arrowLink->addContent(EvalCommon::createImage(($open ? EVAL_PIC_ARROW_NEW_OPEN : EVAL_PIC_ARROW_NEW), _("Aufklappen"))); - $content[0] = $eval->getFullName() ? $eval->getFullName() : " "; - $content[1] = $startDate; - if (!$no_buttons) { - $content[2] = Button::create(_('Start'), 'start_button', ['title' => _('Evaluation starten')]); - - $content[4] = LinkButton::create(_('Bearbeiten'), URLHelper::getURL("admin_evaluation.php?page=edit&evalID=" . $evalID), ['title' => _('Evaluation bearbeiten')]); - - $content[5] = Button::create(_('Löschen'), 'delete_request_button', ['title' => _('Evaluation löschen')]); - } - break; - - case EVAL_STATE_ACTIVE: - $arrowLink->addContent(EvalCommon::createImage(($open ? EVAL_PIC_ARROW_RUNNING_OPEN : EVAL_PIC_ARROW_RUNNING), _("Aufklappen"))); - $content[0] = $eval->getFullName() ? $eval->getFullName() : " "; - $content[1] = $stopDate; - if (!$no_buttons) { - $content[2] = Button::createCancel(_('Stop'), 'stop_button', ['title' => _('Evaluation stoppen')]);; - // Kann hier noch optimiert werden, da hasVoted () immer einen DB-Aufruf startet - $content[3] = ($eval->hasVoted()) ? Button::create(_('Zurücksetzen'), 'restart_request_button', ['title' => _('Evaluation zurücksetzen')]) : Button::create(_('Zurücksetzen'), 'restart_confirmed_button', ['title' => _('Evaluation zurücksetzen')]); - $content[4] = Button::create(_('Export'), 'export_request_button', ['title' => _('Evaluation exportieren')]); - $content[5] = Button::create(_('Löschen'), 'delete_request_button', ['title' => _('Evaluation löschen')]); - //$content[6] = EvalCommon::createSubmitButton ("auswertung", _("Auswertung"), "export_gfx_request_button"); - $content[6] = LinkButton::create(_('Auswertung'), URLHelper::getURL("eval_summary.php?eval_id=" . $evalID), ['title' => _('Auswertung')]); - } - break; - - case EVAL_STATE_STOPPED: - $arrowLink->addContent(EvalCommon::createImage(($open ? EVAL_PIC_ARROW_STOPPED_OPEN : EVAL_PIC_ARROW_STOPPED), _("Aufklappen"))); - $content[0] = $eval->getFullName() ? $eval->getFullName() : " "; - //$content[1] = $eval->isVisible() ? "yes" : "no"; - if (!$no_buttons) { - $content[2] = Button::create(_('Fortsetzen'), 'continue_button', ['title' => _('Evaluation fortsetzen')]); - $content[3] = ($eval->hasVoted()) ? Button::create(_('Zurücksetzen'), 'restart_request_button', ['title' => _('Evaluation zurücksetzen')]) : Button::create(_('Zurücksetzen'), 'restart_confirmed_button', ['title' => _('Evaluation zurücksetzen')]); - $content[4] = Button::create(_('Export'), 'export_request_button', ['title' => _('Evaluation exportieren')]); - $content[5] = Button::create(_('Löschen'), 'delete_request_button', ['title' => _('Evaluation löschen')]); - //$content[6] = EvalCommon::createSubmitButton ("auswertung", _("Auswertung"), "export_gfx_request_button"); - $content[6] = LinkButton::create(_('Auswertung'), URLHelper::getURL("eval_summary.php?eval_id=" . $evalID), ['title' => _('Auswertung')]); - } - break; - } - - $form = new HTML("form"); - $form->addAttr("action", URLHelper::getLink("?rangeID=" . $_SESSION["rangeID"])); - $form->addAttr("method", "post"); - $form->addAttr("style", "display:inline;"); - $form->addHTMLContent(CSRFProtection::tokenTag()); - - $input = new HTMLempty("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("name", "evalID"); - $input->addAttr("value", $evalID); - - $form->addContent($input); - - - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "100%"); - - $tr = new HTML("tr"); - $tr->addAttr("align", "center"); - - /* opening arrow */ - $td = new HTML("td"); - $td->addAttr("class", $style); - $td->addAttr("width", "10"); - if ($open) { - $anchor = new HTML("a"); - $anchor->addAttr("name", "open"); - $anchor->addContent($arrowLink); - $td->addContent($anchor); - } else { - $td->addHTMLContent($arrowLink); - } - - if ($state != "public_template") - $tr->addContent($td); - else { - $td = new HTML("td"); - $td->addAttr("class", $style); - $td->addAttr("width", "1"); - - // create a blindgif - $blingif = new HTMLempty("img"); - $blingif->addAttr("border", "0"); - $blingif->addAttr("valign", "middle"); - $blingif->addAttr("width", "1"); - $blingif->addAttr("height", "24"); - $blingif->addAttr("alt", " "); - $blingif->addAttr("src", Assets::image_path('forumleer.gif')); - $td->addContent($blingif); - $tr->addContent($td); - } - - /* preview icon */ - $td = new HTML("td"); - $td->addAttr("width", $state == "public_template" ? "20" : "1%"); - $td->addAttr("class", $style); - $td->addAttr("align", "left"); - $icon = EvalCommon::createImage(EVAL_PIC_PREVIEW, _("Vorschau")); - $td->addContent(EvalCommon::createEvalShowLink($evalID, $icon, YES)); - $tr->addContent($td); - - /* title */ - $td = new HTML("td"); - $td->addAttr("class", $style); - $td->addAttr("align", "left"); - if ($returnRow) - $td->addAttr("width", "100%"); - - $td->addContent($titleLink); - - if ($state == EVAL_STATE_ACTIVE || $state == EVAL_STATE_STOPPED) { - $td->addContent("|"); - $font = new HTML("font"); - $font->addAttr("color", "#005500"); - $font->addContent($numberOfVotes); - $td->addContent($font); - $td->addContent("|"); - } - $tr->addContent($td); - /* the content fields */ - //for( $i = 0; $i < 6; $i++ ) { - for ($i = 0; $i < 7; $i++) { - $td = new HTML("td"); - $td->addAttr("width", "96"); - $td->addAttr("class", $style); - $td->addAttr("nowrap", "nowrap"); - $td->addAttr("style", "white-space:nowrap"); - #if (is_object($content[$i])) - $td->addContent(($content[$i] ?? " ")); - #$td->addHTMLContent ( ($content[$i] ? $content[$i] : "-") ); - # filter out not needed datacells - if ($state == "user_template" && - (($i == 1) || ($i == 2))) { - //nothing - } elseif ($state == "public_template" && - (($i == 3) || ($i == 4))) { - //nothing - } else { - $tr->addContent($td); - } - } // end: for - - $table->addContent($tr); - if ($returnRow) - $form->addContent($tr); - else - $form->addContent($table); - - return $form; - } - - /** - * Test... - * @access public - * @param object Evaluation $eval The evaluation - */ - function createEvalContent($eval, $number, $state, $safeguard) - { - - /* initialize variables -------- */ - $evalID = $eval->getObjectID(); - - $style = ($number % 2) ? "table_row_odd" : "table_row_even"; - - $form = new HTML("form"); - $form->addAttr("name", "settingsForm"); - $form->addAttr("action", URLHelper::getLink("?rangeID=" . - $_SESSION["rangeID"] . "&openID=" . $evalID . "#open")); - $form->addAttr("method", "post"); - $form->addAttr("style", "display:inline;"); - $form->addHTMLContent(CSRFProtection::tokenTag()); - - $input = new HTMLempty("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("name", "evalID"); - $input->addAttr("value", $evalID); - - $form->addContent($input); - - $a = new HTMLempty("a"); - $a->addAttr("name", "open"); - - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "100%"); - - $tr = new HTML("tr"); - $tr->addAttr("align", "center"); - - $td = new HTML("td"); - $td->addAttr("class", $style); - - - $table2 = new HTML("table"); - $table2->addAttr("align", "center"); - $table2->addAttr("cellspacing", "0"); - $table2->addAttr("cellpadding", "3"); - $table2->addAttr("width", "90%"); - - $tr2 = new HTML("tr"); - $td2 = new HTML("td"); - $td2->addAttr("colspan", "2"); -#$td2->addAttr ("style", "padding-bottom:0; border-top:1px solid black;"); - $td2->addAttr("align", "center"); - $td2->addAttr("class", ($number % 2 ? "table_row_odd" : "table_row_even")); - - $td2->addHTMLContent($safeguard); - - $globalperm = EvaluationObjectDB::getGlobalPerm(); - - $no_permission = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval); - - if (($globalperm == "root" || $globalperm == "admin") && - !Request::get("search") && $eval->isTemplate()) { - // no RuntimeSettings and Save-Button for Template if there are no ranges - $td2->addHTMLContent($this->createDomainSettings($eval, $state, $number % 2 ? "eval_grey_border" : "eval_light_border")); - } elseif ($no_permission) { - // no RuntimeSettings if there are ranges with no permission - $td2->addHTMLContent($this->createDomainSettings($eval, $state, $number % 2 ? "eval_grey_border" : "eval_light_border")); - - $td2->addContent(new HTMLempty("br")); - - $saveButton = Button::create(_('Übernehmen'), 'save_button', ['title' => _('Einstellungen speichern')]); - $td2->addContent($saveButton); - } else { - $td2->addHTMLContent($this->createRuntimeSettings($eval, $state, $number % 2 ? "eval_grey_border" : "eval_light_border")); - - $td2->addHTMLContent($this->createDomainSettings($eval, $state, $number % 2 ? "eval_grey_border" : "eval_light_border")); - $td2->addContent(new HTMLempty("br")); - - $saveButton = Button::create(_('Übernehmen'), 'save_button', ['title' => _('Einstellungen speichern')]); - - $td2->addContent($saveButton); - } - - if (!$eval->isTemplate()) { - /* No Infotext for templates, it makes no sense */ - $show = new EvalShow (); - $td2->addContent($show->createEvalMetaInfo($eval, NO, NO)); - } - - $tr2->addContent($td2); - $table2->addContent($tr2); - - $td->addContent($table2); - $tr->addContent($td); - $table->addContent($tr); - -# $form->addContent ($a); - $form->addContent($table); - - return $form; - } - - - /** - * - */ - function createHeader($safeguard, $templates = NULL, $foundTable = "") - { - Helpbar::Get()->addPlainText(_('Übersicht'), _('Auf dieser Seite haben Sie eine Übersicht aller in dem ausgewählten Bereich existierenden Evaluationen sowie Ihrer eigenen Evaluationsvorlagen.')); - Helpbar::Get()->addPlainText(_('Ansicht'), _("Sie können eine Evaluation aufklappen und dann Bereichen zuordnen und ihre Laufzeit bestimmen.")); - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "5"); - $table->addAttr("width", "100%"); - - /* create new ---------------------------------------------------------- */ - $actions = new ActionsWidget(); - $actions->addLink(_('Neue Evaluationsvorlage'), - URLHelper::getURL('?rangeID=' . $_SESSION['rangeID'] . '&page=edit&newButton=1'), - Icon::create('add', 'clickable')); - Sidebar::get()->addWidget($actions); - /* ----------------------------------------------------- end: create new */ - - /* search template ----------------------------------------------------- */ - $tr = new HTML("tr"); - $td = new HTML("td"); - $td->addAttr("class", "table_row_odd"); - $td->addAttr("valign", "top"); - $td->addContent(EvalOverview::createSearchTemplateForm()); - $tr->addContent($td); - $table->addContent($tr); - /* --------------------------------------------------------- end: search */ - - /* Show found templates ------------------------------------------------ */ - if ($foundTable) { - $tr = new HTML("tr"); - $td = new HTML("td"); - $td->addAttr("class", "table_row_odd"); - $td->addContent($foundTable); - $tr->addContent($td); - $table->addContent($tr); - } - /* ------------------------------------------------- end: show templates */ - - /* Show templates ------------------------------------------------------ */ - $tr = new HTML("tr"); - $td = new HTML("td"); - $td->addAttr("class", "content_body"); - $td->addContent(" "); - $tr->addContent($td); - $table->addContent($tr); - $tr = new HTML("tr"); - $td = new HTML("td"); - $td->addAttr("valign", "top"); - $td->addAttr("class", "table_row_even"); - $td->addContent($templates ? $templates : " "); - $tr->addContent($td); - $table->addContent($tr); - /* -------------------------------------------------- end: show templates */ - - /* Create result ------------------------------------------------------- */ - $tr = new HTML("tr"); - $td = new HTML("td"); - $td->addAttr("class", "blank"); - - $tr->addHTMLContent($safeguard); - - $td->addContent($table); - $tr->addContent($td); - /* --------------------------------------------------------- end: result */ - - return $tr; - } - - /** - * - */ - function createShowRangeForm() - { - - $currentRangeID = $_SESSION['rangeID']; - - $form = new HTML("form"); - $form->addAttr('class', 'default'); - $form->addAttr("method", "post"); - $form->addAttr("action", URLHelper::getLink()); - $form->addHTMLContent(CSRFProtection::tokenTag()); - - $form->addHTMLContent('<fieldset>'); - - $headline = new HTML ("legend"); - $headline->addAttr("class", "eval"); - $headline->addContent(_("Evaluationen")); - $form->addContent($headline); - - $select = new HTML("select"); - $select->addAttr("name", "rangeID"); - $select->addAttr("style", "vertical-align:middle;"); - - /* get allowed range id's for user */ - $rangeIDs = $this->db->getValidRangeIDs($this->perm, $this->user, $currentRangeID); - /* add the currently shown range if neccessary */ - if (is_array($rangeIDs) && !in_array($currentRangeID, array_keys($rangeIDs))) { - $rangeIDs[$currentRangeID] = ["name" => $this->db->getRangename($currentRangeID)]; - } - - foreach ($rangeIDs as $rangeID => $object) { - $option = new HTML("option"); - if ($currentRangeID == $rangeID) - $option->addAttr("selected", "selected"); - - $option->addAttr("value", $rangeID); - if (empty($object["name"])) - $object["name"] = " "; - $option->addHTMLContent(htmlReady($object["name"])); - $select->addContent($option); - } - /* --------------------------------------------------------------------- */ - - $form->addHTMLContent('<label>'); - $form->addContent(_("Evaluationen aus folgendem Bereich anzeigen")); - $form->addContent($select); - $form->addHTMLContent('</label>'); - $form->addContent(" "); - $form->addContent(Button::create(_('Anzeigen'), ['title' => _('Evaluationen aus gewähltem Bereich anzeigen')])); - $form->addContent(new HTMLempty("br")); - - /* search field for showing ranges (admin/root) */ - if ($GLOBALS["perm"]->have_perm("admin")) { - $form->addHTMLContent('<label>'); - $form->addContent(_("Nach weiteren Bereichen suchen")); - $input = new HTMLempty("input"); - $input->addAttr("type", "text"); - $input->addAttr("name", "search"); - $input->addAttr("size", "30"); - $form->addContent($input); - $form->addHTMLContent('</label>'); - $form->addContent(Button::create(_('Suchen'), 'search_showrange_button', ['title' => _('Weitere Bereiche suchen')])); - } - - $form->addHTMLContent('</fieldset>'); - - return $form; - } - - /** - * - */ - function createSearchTemplateForm() - { - $form = new HTML("form"); - $form->addAttr('class', 'default'); - $form->addAttr("method", "post"); - $form->addAttr("action", URLHelper::getLink("?rangeID=" . $_SESSION["rangeID"])); - $form->addHTMLContent(CSRFProtection::tokenTag()); - - $form->addHTMLContent('<fieldset><legend>'); - $form->addContent(_("Öffentliche Evaluationsvorlage suchen")); - $form->addHTMLContent('</legend>'); - - $form->addHTMLContent('<label>'); - $form->addContent(_("Name der Vorlage")); - - $input = new HTMLempty("input"); - $input->addAttr("type", "text"); - $input->addAttr("name", "templates_search"); - $input->addAttr("value", stripslashes($GLOBALS['templates_search'])); - $input->addAttr("style", "vertical-align:middle;"); - - $form->addContent($input); - $form->addHTMLContent('</label>'); - - $form->addHTMLContent('</fieldset><footer>'); - $form->addContent(Button::create(_('Suchen'), 'search_template_button', ['title' => _('Öffentliche Vorlage suchen')])); - $form->addHTMLContent('</footer>'); - - return $form; - } - - /** - * Creates a gray col with text - * @access public - * @param string $text The information - */ - function createInfoCol($text) - { - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "100%"); - - $tr = new HTML("tr"); - - $td = new HTML("td"); - $td->addAttr("class", "content_body"); - $td->addContent($text); - - $tr->addContent($td); - - $table->addContent($tr); - return $table; - } - - /** - * Creates a row with black line above (and "open all evals" link...?) - * @access public - */ - function createClosingRow() - { - $tr = new HTML("tr"); - $tr->addAttr("height", "2"); - $td = new HTML("td"); - $td->addAttr("class", "content_body"); - $td->addContent(""); - $tr->addContent($td); - - return $tr; - } - - /* - * modifies the eval and calls createSafeguard - * - * @access private - * @param evalAction string comprised the action - */ - - public function callSafeguard($evalAction, $evalID = "", $showrangeID = NULL, $search = NULL, $referer = NULL) - { - if (!($evalAction || $evalAction == "search")) { - return " "; - } - - if (!($GLOBALS['perm']->have_studip_perm("tutor", $showrangeID)) && $GLOBALS['user']->id != $showrangeID && - !(Deputy::isEditActivated() && Deputy::isDeputy($GLOBALS['user']->id, $showrangeID, true))) { - return $this->createSafeguard("ausruf", _("Sie haben keinen Zugriff auf diesen Bereich.")); - } - - $evalDB = new EvaluationDB; - $evalChanged = NULL; - $safeguard = " "; - $startDate = NULL; - $stopDate = NULL; - $timeSpan = NULL; - /* Actions without any permissions ---------------------------------- */ - switch ($evalAction) { - case "search_template": - $search = trim($search); - $templates = $evalDB->getPublicTemplateIDs($search); - if (mb_strlen($search) < EVAL_MIN_SEARCHLEN) { - return MessageBox::error(sprintf(_("Bitte einen Suchbegriff mit mindestens %d Buchstaben eingeben."), EVAL_MIN_SEARCHLEN)); - } elseif (count($templates) == 0) { - return MessageBox::error(_("Es wurden keine passenden öffentlichen Evaluationsvorlagen gefunden.")); - } else { - return MessageBox::error(sprintf(_("Es wurde(n) %d passende öffentliche Evaluationsvorlagen gefunden."), count($templates))); - } - case "export_request": - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN); - $haveNoPerm = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval); - if ($haveNoPerm == YES) { - return MessageBox::error(_("Sie haben nicht die Berechtigung diese Evaluation zu exportieren.")); - } - /* -------------------------------------- end: check permissions */ - - - /* Export evaluation ------------------------------------------- */ - $exportManager = new EvaluationExportManagerCSV($evalID); - $exportManager->export(); - /* -------------------------------------- end: export evaluation */ - - - /* Create report ----------------------------------------------- */ - if ($exportManager->isError()) { - return MessageBox::error(_("Fehler beim Exportieren")); - } else { - return MessageBox::success( - _("Die Daten wurden erfolgreich exportiert. Sie können die Ausgabedatei jetzt herunterladen."), - [ - sprintf(_("Bitte klicken Sie %s um die Datei herunter zu laden.") . "<br><br>", '<a href="' . FileManager::getDownloadLinkForTemporaryFile($exportManager->getTempFilename(), $exportManager->getFilename()) . '">' . _("auf diese Verknüpfung") . '</a>') - ] - ); - } - } - /* ----------------------------------- end: actions without permissions */ - - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN); - $evalName = htmlready($eval->getTitle()); - - /* Check for errors while loading ------------------------------------- */ - if ($eval->isError()) { - EvalCommon::createErrorReport($eval); - return $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - } - /* -------------------------------------- end: errorcheck while loading */ - - /* Check for permissions in all ranges of the evaluation -------------- */ - $no_permission_msg = ''; - if (!$eval->isTemplate() && ($GLOBALS['user']->id != $eval->getAuthorID())) { - - $no_permisson = (int)EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval); - if ($no_permisson > 0) { - if ($no_permisson === 1) { - $no_permission_msg .= sprintf(_("Die Evaluation %s ist einem Bereich zugeordnet, für den Sie keine Veränderungsrechte besitzen."), $evalName); - } else { - $no_permission_msg .= sprintf(_("Die Evaluation %s ist %s Bereichen zugeordnet, für die Sie keine Veränderungsrechte besitzen."), $evalName, $no_permisson); - } - - if ($evalAction != "save") { - $no_permission_msg .= " " . _("Der Besitzer wurde durch eine systeminterne Nachricht informiert."); - $author = User::find($eval->getAuthorID()); - $sms = new messaging(); - $sms->insert_message( - sprintf(_("Benutzer **%s** hat versucht eine unzulässige Änderung an Ihrer Evaluation **%s** vorzunehmen."), - $GLOBALS['user']->username, - $eval->getTitle() - ), - $author->username, - "____%system%____", - false, - false, - "1", - false, - _("Versuchte Änderung an Ihrer Evaluation") - ); - } - } - } else if ($eval->isTemplate() && - $GLOBALS['user']->id != $eval->getAuthorID() && - $evalAction != "copy_public_template" && - $evalAction != "search_showrange") { - $author = User::find($eval->getAuthorID()); - $sms = new messaging(); - $sms->insert_message( - sprintf( - _("Benutzer **%s** hat versucht eine unzulässige Änderung an Ihrem Template **%s** vorzunehmen."), - $GLOBALS['user']->username, - $eval->getTitle() - ), $author->username, - "____%system%____", - false, - false, - "1", - false, - _("Versuchte Änderung an Ihrem Template") - ); - return MessageBox::error(sprintf(_("Sie besitzen keine Rechte für das Tempate <b>%s</b>. Der Besitzer wurde durch eine systeminterne Nachricht informiert."), $evalName)); - } - /* ----------------------------------------- end: check for permissions */ - switch ($evalAction) { - case "share_template": - if ($eval->isShared()) { - $eval->setShared(NO); - $eval->save(); - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage %s kann jetzt nicht mehr von anderen Benutzern gefunden werden."), $evalName)); - } else { - $eval->setShared(YES); - $eval->save(); - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage %s kann jetzt von anderen Benutzern gefunden werden."), $evalName)); - } - break; - - case "copy_public_template": - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); - $newEval = $eval->duplicate(); - $newEval->setAuthorID($GLOBALS['user']->id); - $newEval->setShared(NO); - $newEval->setStartdate(NULL); - $newEval->setStopdate(NULL); - $newEval->setTimespan(NULL); - $newEval->removeRangeIDs(); - $newEval->save(); - if ($newEval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval)); - return $safeguard; - } - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die öffentliche Evaluationsvorlage <b>%s</b> wurde zu den eigenen Evaluationsvorlagen kopiert."), $evalName)); - break; - - case "start": - - if ($no_permission_msg) - return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gestartet.")); - - $eval->setStartdate(time() - 500); - $eval->save(); - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde gestartet."), $evalName)); - $evalChanged = YES; - break; - - case "stop": - if ($no_permission_msg) - return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht beendet.")); - - $eval->setStopdate(time()); - $eval->save(); - if ($eval->isError()) { - EvalCommon::createErrorReport($eval); - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde beendet."), $evalName)); - $evalChanged = YES; - break; - - case "continue": - - if ($no_permission_msg) - return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht fortgesetzt.")); - - $eval->setStopdate(NULL); - $eval->setStartdate(time() - 500); - $eval->save(); - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde fortgesetzt."), $evalName)); - $evalChanged = YES; - break; - - case "restart_request": - - if ($no_permission_msg) - return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht zurücksetzen.")); - - $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Die Evaluation %s wirklich zurücksetzen? Dabei werden alle bisher abgegebenen Antworten gelöscht!"), $evalName), "restart_request", $evalID, $showrangeID, $referer); - break; - - case "restart_confirmed": - - if ($no_permission_msg) - return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht zurücksetzen.")); - - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); - $eval->resetAnswers(); - - $evalDB->removeUser($eval->getObjectID()); - $eval->setStartdate(NULL); - $eval->setStopdate(NULL); - $eval->save(); - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde zurückgesetzt."), $evalName)); - $evalChanged = YES; - break; - - case "restart_aborted": - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde nicht zurückgesetzt."), $evalName), "", "", "", $referer); - break; - - case "copy_own_template": - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); - $newEval = $eval->duplicate(); - $newEval->setShared(NO); - $newEval->save(); - if ($newEval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval)); - return $safeguard; - } - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage %s wurde kopiert."), $evalName)); - break; - - case "delete_request": - - if ($no_permission_msg) { - return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gelöscht.")); - } - - $text = $eval->isTemplate() ? sprintf(_("Die Evaluationsvorlage %s wirklich löschen?"), $evalName) : sprintf(_("Die Evaluation %s wirklich löschen?"), $evalName); - $safeguard .= $this->createSafeguard("ausruf", $text, "delete_request", $evalID, $showrangeID, $referer); - break; - - case "delete_confirmed": - - if ($no_permission_msg) - return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gelöscht.")); - - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); - $eval->delete(); - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - - $text = $eval->isTemplate() ? _("Die Evaluationsvorlage %s wurde gelöscht.") : _("Die Evaluation %s wurde gelöscht."); - $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer); - $evalChanged = YES; - break; - - case "delete_aborted": - $text = $eval->isTemplate() ? _("Die Evaluationsvorlage %s wurde nicht gelöscht.") : _("Die Evaluation %s wurde nicht gelöscht."); - $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer); - break; - - case "unlink_delete_aborted": - $text = _("Die Evaluation %s wurde nicht verändert."); - $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer); - break; - - case "unlink_and_move": - - if ($no_permission_msg) - return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht ausgehängt und zu den eigenen Evaluationsvorlagen verschoben.")); - - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); - $eval->removeRangeIDs(); - $eval->setAuthorID($GLOBALS['user']->id); - $eval->resetAnswers(); - $evalDB->removeUser($eval->getObjectID()); - $eval->setStartdate(NULL); - $eval->setStopdate(NULL); - $eval->save(); - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - $text = _("Die Evaluation %s wurde aus allen Bereichen ausgehängt und zu den eigenen Evaluationsvorlagen verschoben."); - $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer); - break; - - case "created": - $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde angelegt."), $evalName)); - break; - - - case "save2": - case "save": - - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); - $update_message = sprintf(_("Die Evaluation %s wurde mit den Veränderungen gespeichert."), $evalName); - $time_msg = ''; - /* Timesettings ---------------------------------------------------- */ - if (Request::option("startMode")) { - switch (Request::option("startMode")) { - case "manual": - $startDate = NULL; - break; - case "timeBased": - $startDate = EvalCommon::date2timestamp(Request::int("startDay"), Request::int("startMonth"), Request::int("startYear"), Request::int("startHour"), Request::int("startMinute")); - break; - case "immediate": - $startDate = time() - 1; - break; - } - if ($no_permission_msg && ($eval->getStartdate != $startDate)) { - $time_msg = $no_permission_msg . "<br>" . _("Die Einstellungen zur Startzeit wurden nicht verändert."); - } - } - - if (Request::option("stopMode")) { - switch (Request::option("stopMode")) { - case "manual": - $stopDate = NULL; - $timeSpan = NULL; - break; - case "timeBased": - $stopDate = EvalCommon::date2timestamp(Request::int("stopDay"), Request::int("stopMonth"), Request::int("stopYear"), Request::int("stopHour"), Request::int("stopMinute")); - $timeSpan = NULL; - break; - case "timeSpanBased": - $stopDate = NULL; - $timeSpan = Request::get("timeSpan"); - break; - } - - if ($no_permission_msg && - ($eval->getStopdate() != $stopDate && - $eval->getTimespan() != $timeSpan)) { - $time_msg = $time_msg ? $time_msg . "<br>" : $no_permission_msg; - $time_msg .= _("Die Einstellungen zur Endzeit wurden nicht verändert."); - } - } - /* ----------------------------------------------- end: timesettings */ - - $message = ''; - - /* link eval to ranges --------------------------------------------- */ - $link_range_Array = Request::optionArray("link_range"); - if ($link_range_Array) { - $isTemplate = $eval->isTemplate(); - if ($isTemplate) { - $newEval = $eval->duplicate(); - if ($newEval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval)); - return $safeguard; - } - $update_message = sprintf(_("Die Evaluationsvorlage %s wurde als Evaluation angelegt."), $evalName); - $newEval->setStartdate($startDate); - $newEval->setStopdate($stopDate); - $newEval->setTimespan($timeSpan); - $newEval->setShared(NO); - } else { - $newEval = &$eval; - } - - $counter_linked = 0; - foreach ($link_range_Array as $link_rangeID => $v) { - if ($userid = get_userid($link_rangeID)) - $link_rangeID = $userid; - $newEval->addRangeID($link_rangeID); - $counter_linked++; - } - - if ($isTemplate) - $newEval->save(); - - if ($newEval->isError()) { - $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Einhängen von Bereichen.") . EvalCommon::createErrorReport($newEval)); - return $safeguard; - } - - $message .= $message ? "<br>" : " "; - $message .= ($counter_linked > 1) ? sprintf(_("Die Evaluation wurde in %s Bereiche eingehängt."), $counter_linked) : sprintf(_("Die Evaluation wurde in einen Bereich eingehängt."), $counter_linked); - } - /* ---------------------------------------- end: link eval to ranges */ - - - /* copy eval to ranges --------------------------------------------- */ - $copy_range_Array = Request::optionArray("copy_range"); - if (!empty($copy_range_Array)) { - $counter_copy = 0; - foreach ($copy_range_Array as $copy_rangeID => $v) { - if ($userid = get_userid($copy_rangeID)) - $copy_rangeID = $userid; - $newEval = $eval->duplicate(); - if (Request::option("startMode")) - $newEval->setStartdate($startDate); - if (Request::get("stopMode")) { - $newEval->setStopdate($stopDate); - $newEval->setTimespan($timeSpan); - } - $newEval->setShared(NO); - $newEval->removeRangeIDs(); - $evalDB->removeUser($newEval->getObjectID()); - $newEval->addRangeID($copy_rangeID); - $newEval->save(); - $counter_copy++; - - if ($newEval->isError()) { - $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Kopieren von Evaluationen in Bereiche.") . EvalCommon::createErrorReport($newEval)); - return $safeguard; - } - } - - $message .= $message ? "<br>" : " "; - $message .= ($counter_copy > 1) ? sprintf(_("Die Evaluation wurde in %s Bereiche kopiert."), $counter_copy) : sprintf(_("Die Evaluation wurde in einen Bereich kopiert."), $counter_copy); - } - /* ------------------------------------------- end: copy eval to ranges */ - - /* unlink ranges ------------------------------------------------------- */ - $remove_range_Array = Request::optionArray("remove_range"); - if (!empty($remove_range_Array)) { - - /* if all rangeIDs will be removed, so ask if it should be deleted -- */ - if (is_array($remove_range_Array) && count($remove_range_Array) == $eval->getNumberRanges()) { - $text = _("Sie wollen die Evaluation <b>%s</b> aus allen ihr zugeordneten Bereichen aushängen.<br>Soll die Evaluation gelöscht oder zu Ihren eigenen Evaluationsvorlagen verschoben werden?"); - $safeguard .= $this->createSafeguard("ausruf", sprintf($text, $evalName), "unlink_delete_request", $evalID, $showrangeID, $referer); - $update_message = NULL; - return $safeguard; - } - /* -------------------------------- end: ask if it should be deleted */ - $no_permission_ranges = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval, YES); - $counter_no_permisson = 0; - if (is_array($no_permission_ranges)) { - foreach ($remove_range_Array as $remove_rangeID => $v) { - - if ($userid = get_userid($remove_rangeID)) - $remove_rangeID = $userid; - - // no permisson to unlink this range - if (in_array($remove_rangeID, $no_permission_ranges)) - $counter_no_permisson++; - } - } - - // if there are no_permisson_ranges to unlink, return - if ($counter_no_permisson > 0) { - - if ($counter_no_permisson == 1) - $safeguard .= $this->createSafeguard("ausruf", _("Sie wollen die Evaluation aus einem Bereich aushängen, für den Sie keine Berechtigung besitzten.<br> Die Aktion wurde nicht ausgeführt.")); - else - $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Sie wollen die Evaluation aus %d Bereichen aushängen, für die Sie keine Berechtigung besitzten.<br> Die Aktion wurde nicht ausgeführt."), $counter_no_permisson)); - return $safeguard; - } - - reset($remove_range_Array); - $counter_copy = 0; - foreach ($remove_range_Array as $remove_rangeID => $v) { - - if ($userid = get_userid($remove_rangeID)) - $remove_rangeID = $userid; - - // the current range will be removed - if ($showrangeID == $remove_rangeID) - $current_range_removed = 1; - - $eval->removeRangeID($remove_rangeID); - $counter_copy++; - } - - - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Aushängen von Bereichen.") . EvalCommon::createErrorReport($eval)); - return $safeguard; - } - - $message .= $message ? "<br>" : " "; - $message .= ($counter_copy > 1) ? sprintf(_("Die Evaluation wurde aus %s Bereichen ausgehängt."), $counter_copy) : sprintf(_("Die Evaluation wurde aus einem Bereich ausgehängt."), $counter_copy); - - if ($eval->getNumberRanges() == 0) { - $message .= $message ? "<br>" : ""; - $message .= _("Sie ist nun keinem Bereich mehr zugeordnet und wurde zu den eigenen Evaluationsvorlagen verschoben."); - $eval->setStartdate(NULL); - $eval->setStopdate(NULL); - $evalDB->removeUser($eval->getObjectID()); - - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Kopieren von Evaluationen in Bereiche.") . EvalCommon::createErrorReport($newEval)); - return $safeguard; - } - } else { - - $no_permission_ranges = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval); - $number_of_ranges = $eval->getNumberRanges(); - - if ($number_of_ranges == $no_permission_ranges) { - $return["msg"] = $this->createSafeguard("ausruf", $message . "<br>" . sprintf(_("Sie haben die Evaluation <b>%s</b> aus allen ihren Bereichen ausgehängt."), $evalName)); - $return["option"] = DISCARD_OPENID; - $eval->save(); - if ($eval->isError()) { - return $this->createSafeguard("ausruf", _("Fehler beim Aushängen einer Evaluationen aus allen Bereichen auf die Sie Zugriff haben.") . EvalCommon::createErrorReport($newEval)); - } - return $return; - } - } - } - - if ($eval->isTemplate()) { - if (empty($link_range) && empty($copy_range) && empty($remove_range)) { - $update_message = sprintf(_("Es wurden keine Veränderungen an der Evaluationsvorlage <b>%s</b> gespeichert."), $evalName); - } - } else { - // nothing changed - if (!Request::option('startMode') && !Request::option('stopMode') && - empty($link_range) && empty($copy_range) && empty($remove_range)) - $update_message = _("Es wurden keine Veränderungen gespeichert."); - - // set new start date - if (Request::option("startMode") && !$time_msg) { - $eval->setStartDate($startDate); - - if ($startDate != NULL && $startDate <= time() - 1) { - $message .= $message ? "<br>" : " "; - $message .= _("Die Evaluation wurde gestartet."); - } - } - - // set new stop date - if (Request::get("stopMode") && !$time_msg) { - $eval->setStopDate($stopDate); - $eval->setTimeSpan($timeSpan); - - if (($stopDate != NULL && $stopDate <= time() - 1) || - ($timeSpan != NULL && $eval->getStartdate() != NULL && ((int)$eval->getStartdate() + (int)$timeSpan) <= time() - 1)) { - $message .= $message ? "<br>" : " "; - $message .= _("Die Evaluation wurde beendet."); - } - } - - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - - $eval->save(); - } - - $evalChanged = YES; - - // start/endtime aren't saved, because of ranges with no permisson - if ($time_msg) - $safeguard .= $this->createSafeguard( - "ausruf", $time_msg); - - // everything is just fine so print the all messages - if ($update_message && !$time_msg) - $safeguard .= $this->createSafeguard( - "ok", $update_message . "<br>" . $message); - // messages from un/linking an making copys - elseif ($time_msg && $message) - $safeguard .= $this->createSafeguard( - "ok", $message); - - break; - - case "search_showrange": - case "search_range": - $search = Request::get("search"); - - if (EvaluationObjectDB::getGlobalPerm(YES) < 31) { - return $this->createSafeguard("ausruf", _("Sie besitzen keine Berechtigung eine Suche durchzuführen.")); - } - - $results = $evalDB->search_range($search); - if (empty($search)) - $safeguard .= $this->createSafeguard("ausruf", _("Bitte einen Suchbegriff eingeben."), $search); - elseif (empty($results)) - $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Es wurde kein Bereich gefunden, der den Suchbegriff <b>%s</b> enthält."), htmlReady($search)), $search); - else - $safeguard .= $this->createSafeguard("ok", sprintf(_("Es wurden %s Bereiche gefunden, die den Suchbegriff <b>%s</b> enthalten."), count($results), htmlReady($search)), $search); - break; - - case "check_abort_creation": - - # check if the evaluation is new and not yet edited - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN); - $abort_creation = false; - if ($eval->getTitle() == _("Neue Evaluation") && - $eval->getText() == "") { - # the evaluationen may be not edited yet ... so continue checking - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); - $number_of_childs = $eval->getNumberChildren(); - $child = $eval->getNextChild(); - if ($number_of_childs == 1 && - $child && - $child->getTitle() == _("Erster Gruppierungsblock") && - $child->getChildren() == NULL && - $child->getText() == "") { - $abort_creation = true; - } - } - - if (!$abort_creation) - break; - # continue abort_creation - - case "abort_creation": - $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN); - $eval->delete(); - // error_ausgabe - if ($eval->isError()) { - $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval)); - return $safeguard; - } - - $safeguard .= $this->createSafeguard("ok", _("Die Erstellung einer Evaluation wurde abgebrochen."), "", "", "", $referer); - break; - - case "nothing": - break; - - default: - $safeguard .= $this->createSafeguard("ausruf", _("Fehler! Es wurde versucht, eine nicht vorhandene Aktion auszuführen.")); - break; - } - - /* Send SMS when eval has been modified by admin/root ----------------- */ - if (($evalChanged) && ($eval->getAuthorID() != $GLOBALS['user']->id)) { - $sms = new messaging(); - $sms->insert_message(sprintf(_("An Ihrer Evaluation \"%s\" wurden von %s Änderungen vorgenommen."), $eval->getTitle(), $GLOBALS['user']->username), get_username($eval->getAuthorID()), "____%system%____", FALSE, FALSE, "1"); - } - /* ------------------------------------------------------ end: send SMS */ - - // the current range has been removed from the eval - if (!empty($current_range_removed)) { - $return["msg"] = $safeguard; - $return["option"] = DISCARD_OPENID; - return $return; - } else { - return $safeguard; - } - } - -// callSafeguard - - /** - * creates the 'Safeguard' - * - * @access private - * @param sign string Sign to draw (must be "ok" or "ausruf") - * @param text string The Text to draw - * @param evalID string needed if you want to delete an evaluation (not needed) - */ - public function createSafeguard($sign, $text, $mode = NULL, $evalID = NULL, $showrangeID = NULL, $referer = NULL) - { - //TODO: auf messagebox bzw. createQuestion umstellen!!! - - if (mb_stripos($mode, 'request') === false && $sign != '') { - if($sign === 'ok') { - return MessageBox::success($text); - } else { - return MessageBox::error($text); - } - } - $label = [ - "referer" => _("Zum vorherigen Bereich zurückkehren."), - "yes" => _("Ja!"), - "no" => _("Nein!"), - "delete" => _("Löschen."), - "template" => _("Zu den eigenen Evaluationsvorlagen verschieben."), - "cancel" => _("Abbrechen") - ]; - - if ($referer) { - $linkreferer = "&referer=" . $referer; - } - $request = NO; - $value1 = ''; - $value2 = ''; - if ($mode == "delete_request") { - $value1 = "delete_confirmed"; - $value2 = "delete_aborted"; - $request = YES; - } - if ($mode == "restart_request") { - $value1 = "restart_confirmed"; - $value2 = "restart_aborted"; - $request = YES; - } - - if ($referer) { - URLHelper::bindLinkParam('referer', $referer); - } - - if ($request) { - return QuestionBox::create( - $text, - URLHelper::getURL('admin_evaluation.php?evalAction=' . $value1 . '&evalID=' . $evalID . '&rangeID=' . $showrangeID), - URLHelper::getURL('admin_evaluation.php?evalAction=' . $value2 . '&evalID=' . $evalID . '&rangeID=' . $showrangeID) - ); - } - - if ($mode == "unlink_delete_request") { - $add_cancel = !$referer ?: "&referer=" . $referer; - $links = [ - URLHelper::getURL('admin_evaluation.php?evalAction=delete_confirmed&evalID=' . $evalID . '&rangeID=' . $showrangeID), - URLHelper::getURL('admin_evaluation.php?evalAction=unlink_delete_aborted&evalID=' . $evalID . '&rangeID=' . $showrangeID), - URLHelper::getURL('admin_evaluation.php?evalAction=unlink_and_move&evalID=' . $evalID . '&rangeID=' . $showrangeID . $add_cancel) - ]; - $details[] = LinkButton::create(_('Löschen'), $links[0], ['title' => $label["delete"]]); - $details[] = LinkButton::create(_('Verschieben'), $links[1], ['title' => $label["template"]]); - $details[] = LinkButton::createCancel(_('Abbrechen'), $links[2], ['title' => $label["cancel"]]); - - return MessageBox::info($text, $details); - } - - if ($referer) { - return LinkButton::create($label["referer"], URLHelper::getLink($referer)); - } - } - - /** - * prints the tables for the runtime settings (start date, stop date...) - * - * @access private - * @param $eval the eval object - * @param $state the eval's state (EVAL_STATE_NEW, EVAL_STATE_ACTIVE, ...) - * @param $style the background style - * @return string the runtime settings (html) - */ - function createRuntimeSettings($eval, $state, $style) - { - $html = ""; - $startDate = $eval->getStartdate(); - $stopDate = $eval->getStopdate(); - $timeSpan = $eval->getTimespan(); - - if ($startDate == NULL) - $startMode = "manual"; - else - $startMode = "timeBased"; - - if ($stopDate == NULL) - $stopMode = "manual"; - else - $stopMode = "timeBased"; - - if ($timeSpan != NULL) - $stopMode = "timeSpanBased"; - - if (!$startDate || $startDate == -1) - $startDate = time(); - - $startDay = date("d", $startDate); - $startMonth = date("m", $startDate); - $startYear = date("Y", $startDate); - $startHour = date("H", $startDate); - $startMinute = date("i", $startDate); - - if (!$stopDate || $stopDate == -1) - $stopDate = mktime(0, 0, 0, date("m") + 1, date("d"), date("Y")); - - $stopDay = date("d", $stopDate); - $stopMonth = date("m", $stopDate); - $stopYear = date("Y", $stopDate); - $stopHour = date("H", $stopDate); - $stopMinute = date("i", $stopDate); - - if (!$timeSpan) - $timeSpan = 1209600; // default: 2 weeks - - $html .= "<table border=0 align=center cellspacing=0 cellpadding=4 width=\"100%\">\n"; - $html .= "<tr><td colspan=\"2\">\n"; - $html .= "<b>" . _("Einstellungen zur Start- und Endzeit:") . "</b>"; - $tooltip = $eval->isTemplate() - ? _('Legen Sie fest, von wann bis wann alle eingehängten und kopierten Instanzen dieser Evaluationsvorlage in Stud.IP öffentlich sichtbar sein sollen.') - : _('Legen Sie fest, von wann bis wann die Evaluation in Stud.IP öffentlich sichtbar sein soll.'); - $html .= " "; - $html .= Icon::create('info-circle', 'inactive', ['title' => $tooltip])->asImg(['class' => 'middle']); - $html .= "</td></tr>"; - $html .= "<tr>"; - - /* START TIME settings ------------------------------------------------- */ - $html .= "<td width=\"50%\" valign=\"top\">" - . "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0>\n" - . "<tr>" - . "<td class=\"$style\" height=\"22\" align=\"left\" " - . "style=\"vertical-align:bottom;\">" - . "<b>" - . " " - . _("Anfang") - . "</b>" - . "</td>" - . "</tr>\n"; - - /* Eval has NOT started yet --- */ - if ($state == EVAL_STATE_NEW || $eval->isTemplate()) { - $html .= "<tr><td class=\"table_row_even\">"; - $html .= "<input type=radio name=\"startMode\" value=\"manual\" " . ($startMode == "manual" ? "checked" : "") . "> "; - $html .= _("später manuell starten"); - $html .= "</td></tr>"; - - $html .= "<tr><td class=table_row_odd>"; - $html .= "<input type=radio name=\"startMode\" value=\"timeBased\" " . ($startMode == "timeBased" ? "checked" : "") . "> "; - $html .= _("Startzeitpunkt:"); - $html .= " <input type=text name=\"startDay\" size=3 maxlength=2 value=\"" . $startDay . "\"> . " - . "<input type=text name=\"startMonth\" size=3 maxlength=2 value=\"" . $startMonth . "\"> . " - . "<input type=text name=\"startYear\" size=5 maxlength=4 value=\"" . $startYear . "\"> " - . sprintf(_("um %s Uhr"), " <input type=text name=\"startHour\" size=3 maxlength=2 value=\"" . $startHour . "\"> :" . - " <input type=text name=\"startMinute\" size=3 maxlength=2 value=\"" . $startMinute . "\"> "); - $html .= "</td></tr>"; - - $html .= "<tr><td class=table_row_even valign=middle>"; - $html .= "<input type=radio name=\"startMode\" value=\"immediate\"> "; - $html .= _("sofort"); - $html .= "</td></tr>"; - } /* Eval is already running or finished --- */ else { - $html .= "<tr><td><font size=\"+2\"> </font></td></tr>"; - $html .= "<tr><td valign=\"middle\" align=\"center\">"; - $html .= sprintf(_("Startzeitpunkt war der <b>%s</b> um <b>%s</b> Uhr."), date("d.m.Y", $startDate), date("H:i", $startDate)); - $html .= "</td></tr>"; - $html .= "<tr><td><font size=\"+2\"> </font></td></tr>"; - } - $html .= "</table></td>"; - - - /* END TIME settings --------------------------------------------------- */ - $html .= "<td width=\"50%\" valign=\"top\">" - . "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0>\n" - . "<tr>" - . "<td class=\"$style\" height=\"22\" align=\"left\" " - . "style=\"vertical-align:bottom;\">" - . "<b>" - . " " - . _("Ende") - . "</b>" - . "</td>" - . "</tr>\n"; - - /* Eval has NOT finished yet --- */ - if ($state != EVAL_STATE_STOPPED) { - $html .= "<tr><td class=table_row_even>\n" - . "<input type=radio name=\"stopMode\" value=\"manual\" " . ($stopMode == "manual" ? "checked" : "") . "> " - . _("manuell beenden") - . "</td></tr>" - . "<tr><td class=table_row_odd>\n" - . "<input type=radio name=\"stopMode\" value=\"timeBased\" " . ($stopMode == "timeBased" ? "checked" : "") . "> " - . _("Endzeitpunkt:"); - - $html .= " " - . "<input type=text name=\"stopDay\" size=3 maxlength=2 value=\"" . $stopDay . "\"> . " - . "<input type=text name=\"stopMonth\" size=3 maxlength=2 value=\"" . $stopMonth . "\"> . " - . "<input type=text name=\"stopYear\" size=5 maxlength=4 value=\"" . $stopYear . "\"> " - . sprintf(_("um %s Uhr"), " <input type=text name=\"stopHour\" size=3 maxlength=2 value=\"" . $stopHour . "\"> :" . - " <input type=text name=\"stopMinute\" size=3 maxlength=2 value=\"" . $stopMinute . "\"> "); - $html .= " " - . "</td></tr>" - . "<tr><td class=table_row_even valign=middle>" - . "<input type=radio name=\"stopMode\" value=\"timeSpanBased\" " . ($stopMode == "timeSpanBased" ? "checked" : "") - . "> " - . _("Zeitspanne") - . " " - . "<select name=\"timeSpan\" style=\"vertical-align:middle\" size=1 " - . ">"; - - for ($i = 1; $i <= 12; $i++) { - $secs = $i * 604800; // == weeks * seconds per week - - $html .= "\n<option value=\"" . $secs . "\" "; - if ($timeSpan == $secs) - $html .= "selected"; - $html .= ">"; - $html .= sprintf( - ngettext( - '%d Woche', - '%d Wochen', - $i - ), - $i - ); - $html .= "</option>"; - } - $html .= "</select>"; - - if ($stopMode == "timeSpanBased" && $startMode != "manual") { - - $startDate = ($startMode == "immediate") ? time() : $startDate; - - $html .= " "; - $html .= Icon::create('refresh', 'clickable', ['title' => _('Endzeitpunkt neu berechnen')])->asInput(['name' => 'save2_button', 'align' => 'middle',]); - $html .= sprintf(_(" (<b>%s</b> um <b>%s</b> Uhr)"), strftime("%d.%m.%Y", $startDate + $timeSpan), strftime("%H:%M", $startDate + $timeSpan)); - } - $html .= "</td></tr>"; - } else { - $html .= "<tr><td><font size=\"+2\"> </font></td></tr>"; - $html .= "<tr><td valign=\"middle\" align=\"center\">"; - $html .= sprintf(_("Endzeitpunkt war der <b>%s</b> um <b>%s</b> Uhr."), date("d.m.Y", $stopDate), date("H:i", $stopDate)); - $html .= "</td></tr>"; - $html .= "<tr><td><font size=\"+2\"> </font></td></tr>"; - } - $html .= "</table>"; - - $html .= "</td></tr>"; - $html .= "</table>"; - - return $html; - } - - /** - * the current eval-ranges and the options to copy and link ranges - * - * @access private - * @param $eval the eval object - * @param $state the eval's state (EVAL_STATE_NEW, EVAL_STATE_ACTIVE, ...) - * @param $style the background style - * @return string the domain settings (html) - */ - public function createDomainSettings($eval, $state, $style) - { - $db = new EvaluationObjectDB (); - $evalDB = new EvaluationDB (); - $evalID = $eval->getObjectID(); - $globalperm = EvaluationObjectDB::getGlobalPerm(); - - // linked ranges - $rangeIDs = $eval->getRangeIDs(); - - // search results - if (Request::get("search")) - $results = $evalDB->search_range(Request::get("search")); - else - $results = $evalDB->search_range(""); - - if ($globalperm == "root") { - $results["studip"] = ["type" => "system", "name" => _("Systemweite Evaluationen")]; - } elseif ($globalperm == "dozent" || $globalperm == "autor" || $globalperm == "admin") { - $results[$GLOBALS['user']->id] = ["type" => "user", "name" => _("Profil")]; - } - - if ($globalperm == "dozent" || $globalperm == "autor" || Request::get("search")) - $showsearchresults = 1; - - - if ($globalperm == "autor") - $range_types = [ - "user" => _("Benutzer"), - "sem" => _("Veranstaltung")]; - elseif ($globalperm == "dozent") - $range_types = [ - "user" => _("Benutzer"), - "sem" => _("Veranstaltung"), - "inst" => _("Einrichtung")]; - elseif ($globalperm == "admin") - $range_types = [ - "user" => _("Benutzer"), - "sem" => _("Veranstaltung"), - "inst" => _("Einrichtung"), - "fak" => _("Fakultät")]; - elseif ($globalperm == "root") - $range_types = [ - "user" => _("Benutzer"), - "sem" => _("Veranstaltung"), - "inst" => _("Einrichtung"), - "fak" => _("Fakultät"), - "system" => _("System")]; - - - // zugewiesene Bereiche - $table_r = new HTML("table"); -# $table_r->addAttr ("class","white"); - $table_r->addAttr("border", "0"); - $table_r->addAttr("align", "center"); - $table_r->addAttr("cellspacing", "0"); - $table_r->addAttr("cellpadding", "0"); - $table_r->addAttr("width", "100%"); - $table_r->addAttr('class', 'default'); - - // Überschriften - $tr_r = new HTML("tr"); - - $td_r = new HTML("td"); - $td_r->addAttr("class", "$style"); - $td_r->addAttr("style", "vertical-align:bottom;"); - $td_r->addAttr("height", "22"); - $b_r = new HTML("b"); - $b_r->addHTMLContent(" "); - $b_r->addContent(_("Bereich")); - $td_r->addContent($b_r); - $tr_r->addContent($td_r); - - $td_r = new HTML("td"); - $td_r->addAttr("class", "$style"); - $td_r->addAttr("height", "22"); - $td_r->addAttr("align", "center"); - $td_r->addAttr("style", "vertical-align:bottom;"); - $b_r = new HTML("b"); - $b_r->addContent(_("aushängen")); - $td_r->addContent($b_r); - $tr_r->addContent($td_r); - - $table_r->addContent($tr_r); - - if ($rangeIDs) { - - // die verknüpften bereiche - foreach ($rangeIDs as $k => $assigned_rangeID) { - $tr_r = new HTML("tr"); - - // title - $td_r = new HTML("td"); - $td_r->addHTMLContent(" "); - $td_r->addContent($db->getRangename($assigned_rangeID, NO)); -# $td_r->addContent ($db->getRangename($assigned_rangeID)); - $tr_r->addContent($td_r); - - if (($this->perm->have_studip_perm("tutor", $assigned_rangeID)) || - $assigned_rangeID == $GLOBALS['user']->id) { - // link - $td_r = new HTML("td"); - $td_r->addAttr("align", "center"); - $input = new HTMLempty("input"); - $input->addAttr("type", "checkbox"); - $input->addAttr("name", "remove_range[$assigned_rangeID]"); - $input->addAttr("value", "1"); - $td_r->addContent($input); - } else { - // no permission - $td_r = new HTML("td"); - $td_r->addAttr("align", "center"); - $td_r->addContent(_("Sie haben keine Berechtigung die Evaluation aus diesem Bereich auszuhängen.")); - } - $tr_r->addContent($td_r); - $table_r->addContent($tr_r); - } - } else { - $td_r = new HTML("td"); - $td_r->addAttr("class", "content_body"); - $td_r->addAttr("width", "40"); - $td_r->addAttr("align", "center"); - $td_r->addAttr("style", "vertical-align:bottom;"); - $td_r->addAttr("colspan", "2"); - $b_r = new HTML("b"); - $b_r->addHTMLContent(" "); - $b_r->addContent(_("Diese Evaluation wurde keinem Bereich zugeordnet.")); - $td_r->addContent($b_r); - $tr_r->addContent($td_r); - - $table_r->addContent($tr_r); - } - - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "4"); - $table->addAttr("width", "100%"); - - $tr = new HTML("tr"); - - $td = new HTML("td"); - $td->addAttr("colspan", "2"); - $td->addAttr("style", "padding-bottom:0; border-top:1px solid black;"); - $b = new HTML("b"); - $b->addContent(_("Diese Evaluation ist folgenden Bereichen zugeordnet:")); - $td->addContent($b); - $td->addContent(EvalCommon::createImage(EVAL_PIC_HELP, "", tooltip(_(" können Sie Ihre Evaluation aus den verknüpften Bereichen entfernen."), TRUE, TRUE))); - $tr->addContent($td); - if (!$eval->isTemplate()) - $table->addContent($tr); - - $tr = new HTML("tr"); - - $td = new HTML("td"); - $td->addAttr("colspan", "2"); - $td->addContent($table_r); - $tr->addContent($td); - if (!$eval->isTemplate()) - $table->addContent($tr); - - // display search_results - if ($results) { - foreach ($results as $k => $v) { - if (!empty($range_types)) { - foreach ($range_types as $type_key => $type_value) { - if ($v["type"] == $type_key) { - $ranges["$type_key"][] = ["id" => $k, "name" => $v["name"]]; - } - } - reset($range_types); - } - } - - $table_s = new HTML("table"); - $table_s->addAttr("border", "0"); - $table_s->addAttr("align", "center"); - $table_s->addAttr("cellspacing", "0"); - $table_s->addAttr("cellpadding", "0"); - $table_s->addAttr("width", "100%"); - - if (!empty($range_types)) { - foreach ($range_types as $type_key => $type_value) { - - // Überschriften - $tr_s = new HTML("tr"); - - // Typ - $td_s = new HTML("td"); - $td_s->addAttr("colspan", "1"); - $td_s->addAttr("class", "$style"); - $td_s->addAttr("height", "22"); - $td_s->addAttr("style", "vertical-align:bottom;"); - $b_s = new HTML("b"); - $b_s->addHTMLContent(" "); - $b_s->addContent($type_value . ":"); - $td_s->addContent($b_s); - $tr_s->addContent($td_s); - - // link - $td_s = new HTML("td"); - $td_s->addAttr("class", "$style"); - $td_s->addAttr("height", "22"); - $td_s->addAttr("align", "center"); - $td_s->addAttr("style", "vertical-align:bottom;"); - $b_s = new HTML("b"); - $b_s->addContent(_("einhängen")); - $td_s->addContent($b_s); - $tr_s->addContent($td_s); - - // kopie - $td_s = new HTML("td"); - $td_s->addAttr("class", "$style"); - $td_s->addAttr("height", "22"); - $td_s->addAttr("align", "center"); - $td_s->addAttr("style", "vertical-align:bottom;"); - $b_s = new HTML("b"); - $b_s->addContent(_("kopieren")); - $td_s->addContent($b_s); - $tr_s->addContent($td_s); - - $table_s->addContent($tr_s); - - $counter = 0; - - if (!empty($ranges[$type_key])) { - foreach ($ranges["$type_key"] as $range) { - - if ($counter == 0) - $displayclass = "content_body"; - elseif (($counter % 2) == 0) - $displayclass = "table_row_even"; - else - $displayclass = "table_row_odd"; - - $tr_s = new HTML("tr"); - - // name - $td_s = new HTML("td"); - $td_s->addHTMLContent(" "); - $td_s->addHTMLContent(htmlready($range["name"])); - $tr_s->addContent($td_s); - - // if the rangeID is a username, convert it to the userID - $new_rangeID = (get_userid($range['id'])) ? get_userid($range['id']) : $range['id']; - - if (!in_array($new_rangeID, $rangeIDs)) { - - // link - $td_s = new HTML("td"); - $td_s->addAttr("align", "center"); - $input = new HTMLempty("input"); - $input->addAttr("type", "checkbox"); - $input->addAttr("name", "link_range[{$range['id']}]"); - $input->addAttr("value", "1"); - $td_s->addContent($input); - $tr_s->addContent($td_s); - } else { - - // no link - $td_s = new HTML("td"); - $td_s->addAttr("align", "center"); - $td_s->addAttr("colspan", "1"); - $input = new HTMLempty("input"); - $td_s->addContent(_("Die Evaluation ist bereits diesem Bereich zugeordnet.")); - $tr_s->addContent($td_s); - } - - // copy - $td_s = new HTML("td"); - $td_s->addAttr("align", "center"); - $input = new HTMLempty("input"); - $input->addAttr("type", "checkbox"); - $input->addAttr("name", "copy_range[{$range['id']}]"); - $input->addAttr("value", "1"); - $td_s->addContent($input); - $tr_s->addContent($td_s); - - $table_s->addContent($tr_s); - $counter++; - } - } elseif ($globalperm == "root" || $globalperm == "admin") { - $tr_s = new HTML("tr"); - $td_s = new HTML("td"); - $td_s->addAttr("class", "content_body"); - $td_s->addAttr("colspan", "4"); - $td_s->addHTMLContent(" "); - $td_s->addContent(_("Es wurden keine Ergebnisse aus diesem Bereich gefunden.")); - $tr_s->addContent($td_s); - $table_s->addContent($tr_s); - } - reset($ranges); - } - } - } - if (!empty($showsearchresults)) { - $tr = new HTML("tr"); - $td = new HTML("td"); - $td->addAttr("colspan", "2"); -// $td->addContent(new HTMLempty("hr")); - $b = new HTML("b"); -# $b->addContent (_('Suchergebnisse') . ':'); - if (Request::get("search")) - $b->addContent(_("Sie können die Evaluation folgenden Bereichen zuordnen (Suchergebnisse):")); - else - $b->addContent(_("Sie können die Evaluation folgenden Bereichen zuordnen:")); - $td->addContent($b); - $td->addContent(EvalCommon::createImage(EVAL_PIC_HELP, "", tooltip(_("Hängen Sie die Evaluation in die gewünschten Bereiche ein (abhängige Kopie mit gemeinsamer Auswertung) oder kopieren Sie sie in Bereiche (unabhängige Kopie mit getrennter Auswertung)."), TRUE, TRUE))); - $td->addContent(($results) ? $table_s : _("Die Suche ergab keine Treffer.")); - $tr->addContent($td); - $table->addContent($tr); - } - - // the seach-button - if ($globalperm == "root" || $globalperm == "admin") { - $tr = new HTML("tr"); - - $td = new HTML("td"); - $td->addAttr("colspan", "2"); - $td->addAttr("style", "padding-bottom:0; border-top:1px solid black;"); - $td->addContent(_("Nach Bereichen suchen:")); - $td->addContent(" "); - - $input = new HTMLempty("input"); - $input->addAttr("type", "text"); - $input->addAttr("name", "search"); - $input->addAttr("style", "vertical-align:middle;"); - $input->addAttr("value", "" . Request::get("search") . ""); - $td->addContent($input); - - $td->addContent(Button::create(_('Suchen'), 'search_range_button', ['title' => _('Bereiche suchen')])); - $tr->addContent($td); - - $table->addContent($tr); - } - - return $table->createContent(); - } - - function createDomainLinks($search) - { - $evalDB = new EvaluationDB (); - $globalperm = EvaluationObjectDB::getGlobalPerm(); - - // search results - $results = $evalDB->search_range($search); - - if ($globalperm == "root") { - $results["studip"] = ["type" => "system", "name" => _("Systemweite Evaluationen")]; - } else { - $results[$GLOBALS['user']->id] = ["type" => "user", "name" => _("Profil")]; - } - - if ($globalperm == "dozent" || $globalperm == "autor" || $search) - $showsearchresults = 1; - $range_types = []; - if ($globalperm == "admin") - $range_types = [ - "user" => _("Benutzer"), - "sem" => _("Veranstaltung"), - "inst" => _("Einrichtung"), - "fak" => _("Fakultät")]; - - elseif ($globalperm == "root") - $range_types = [ - "user" => _("Benutzer"), - "sem" => _("Veranstaltung"), - "inst" => _("Einrichtung"), - "fak" => _("Fakultät"), - "system" => _("System")]; - - // display search_results - if ($results) { - foreach ($results as $k => $v) { - foreach ($range_types as $type_key => $type_value) { - if ($v["type"] == $type_key) { - $ranges["$type_key"][] = ["id" => $k, "name" => $v["name"]]; - } - } - reset($range_types); - } - - $table = new HTML("table"); - $table->addAttr("class", "default"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "0"); - $table->addAttr("width", "100%"); - - foreach ($range_types as $type_key => $type_value) { - // Überschriften - $tr = new HTML("tr"); - - // Typ - $td = new HTML("td"); - $td->addAttr("colspan", "1"); - $td->addAttr("class", "table_header"); - $td->addAttr("height", "22"); - $td->addAttr("width", "50%"); - $td->addAttr("style", "vertical-align:bottom;"); - $b = new HTML("b"); - $b->addHTMLContent(" "); - $b->addContent($type_value . ":"); - $td->addContent($b); - $tr->addContent($td); - - // Typ - $td = new HTML("td"); - $td->addAttr("class", "table_header"); - $td->addAttr("height", "22"); - $td->addAttr("align", "center"); - $td->addAttr("style", "vertical-align:bottom;"); - $b = new HTML("b"); - $b->addContent(" "); - $td->addContent($b); - $tr->addContent($td); - - // Typ - $td = new HTML("td"); - $td->addAttr("class", "table_header"); - $td->addAttr("height", "22"); - $td->addAttr("align", "center"); - $td->addAttr("style", "vertical-align:bottom;"); - $b = new HTML("b"); - $b->addContent(" "); - $td->addContent($b); - $tr->addContent($td); - - $table->addContent($tr); - - $counter = 0; - - if (!empty($ranges[$type_key])) { - foreach ($ranges["$type_key"] as $range) { - - if ($counter == 0) - $displayclass = "content_body"; - elseif (($counter % 2) == 0) - $displayclass = "table_row_even"; - else - $displayclass = "table_row_odd"; - - $tr = new HTML("tr"); - - // name - $td = new HTML("td"); - $td->addHTMLContent(" "); - $td->addContent($range["name"]); - $tr->addContent($td); - - // if the rangeID is a username, convert it to the userID - $new_rangeID = (get_userid($range['id'])) ? get_userid($range['id']) : $range['id']; - - - // link - $td = new HTML("td"); - $td->addAttr("align", "center"); - $link = new HTML("a"); - $link->addAttr("href", URLHelper::getLink(EVAL_FILE_ADMIN . "?rangeID=" . $range['id'])); - $link->addContent(_("Diesen Bereich anzeigen.")); - $td->addContent($link); - $tr->addContent($td); - - // copy - $td = new HTML("td"); - $td->addAttr("align", "center"); - $td->addContent(" "); - $tr->addContent($td); - - $table->addContent($tr); - $counter++; - } - } elseif ($globalperm == "root" || $globalperm == "admin") { - $tr = new HTML("tr"); - $td = new HTML("td"); - $td->addAttr("class", "content_body"); - $td->addAttr("colspan", "4"); - $td->addHTMLContent(" "); - $td->addContent(_("Es wurden keine Ergebnisse aus diesem Bereich gefunden.")); - $tr->addContent($td); - $table->addContent($tr); - } - reset($ranges); - } - } - - return !empty($table) ? $table->createContent() : ''; - } - - /** - * checks which button was pressed - * - * @access public - * @returns string the command - * - */ - function getPageCommand() - { - if (Request::option('evalAction')) { - return Request::option('evalAction'); - } - $command = []; - foreach ($_REQUEST as $key => $value) { - if (preg_match("/(.*)_button(_x)?/", $key, $command)) - break; - } - return $command[1] ?? ''; - } - -# ===================================================== end: public functions # -} diff --git a/lib/evaluation/evaluation_admin_template.inc.php b/lib/evaluation/evaluation_admin_template.inc.php deleted file mode 100644 index 79969476117681fb43fd40a70e1d2645b2fee39b..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation_admin_template.inc.php +++ /dev/null @@ -1,655 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * the form to create/edit templates for answers - * - * @author JPWowra - * - * @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. -// +--------------------------------------------------------------------------+ - -use Studip\Button, Studip\LinkButton; - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once 'lib/evaluation/classes/db/EvaluationQuestionDB.class.php'; -require_once 'lib/evaluation/classes/EvaluationQuestion.class.php'; -require_once EVAL_LIB_COMMON; -require_once EVAL_LIB_OVERVIEW; -require_once EVAL_LIB_TEMPLATE; -require_once EVAL_FILE_EVAL; -require_once EVAL_FILE_EVALDB; -require_once EVAL_FILE_QUESTION; -require_once EVAL_FILE_QUESTIONDB; -require_once EVAL_FILE_OBJECTDB; -# ====================================================== end: including files # - - -/* Create objects ---------------------------------------------------------- */ -$db = new EvaluationQuestionDB(); -$lib = new EvalTemplateGUI(); -/* ------------------------------------------------------------ end: objects */ - -#error_reporting( E_ALL ); - -/* Set variables ----------------------------------------------------------- */ -$rangeID = $rangeID ?? Context::getId(); - -if (empty ($rangeID)) { - $rangeID = $user->id; -} - -$command = $lib->getPageCommand(); -if (EvaluationObjectDB::getGlobalPerm() === 'root') { - $myuserid = 0; -} else { - $myuserid = $user->id; - -} -if (empty($parentID)) { - $parentID = Request::option('parentID'); -} -$template_name = Request::get('template_name', $template_name ?? null); -$template_type = Request::get('template_type', $template_type ?? null); -$template_multiple = Request::get('template_multiple', $template_multiple ?? null); -$template_answers = Request::getArray('template_answers'); -$template_add_num_answers = Request::int('template_add_num_answers', $template_add_num_answers ?? 0); -if (empty($template_answers)) { - if (mb_strstr($command, "edit")) - for ($i = 0; $i < 5; $i++) - $template_answers[$i] = $lib->makeNewAnswer(); - else - $template_answers = []; -} -if (empty($template_id)) { - $template_id = Request::option('template_id'); -} - -/* ---------------------------------------------------------- end: variables */ - -if (Request::option('onthefly') && ($command == "delete" || $command == "add_answers" - || $command == "delete_answers" || $command == "save2")) { - $question = new EvaluationQuestion ($template_id, - NULL, EVAL_LOAD_ALL_CHILDREN); - $question->setMultiplechoice($template_multiple); - $question->setText(trim($template_name), YES); - $question->setType($template_type); - $question->setParentID($parentID); - $question->setPosition($template_position ?? ''); - while ($answerrem = $question->getChild()) { - $id = $answerrem->getObjectID(); - $answerrem->delete(); - $question->removeChildID($id); - } - $controlnumber = count($template_answers); - for ($i = 0; $i < $controlnumber; $i++) { - $text = $template_answers[$i]['text']; - $answerID = $template_answers[$i]['answer_id']; - $answer = new EvaluationAnswer(); - $answer->setObjectID($answerID); - $answer->setText(trim($text), YES); - $answer->setParentID($template_id); - $question->addChild($answer); - } - -} - -switch ($command) { - /* -------------------------------------------------------------------- */ - case "savefree": - $qdb = new EvaluationQuestionDB(); - if ($qdb->exists($template_id)) { - $question = new EvaluationQuestion ($template_id, NULL, - EVAL_LOAD_ALL_CHILDREN); - if ($question->getParentID() != $myuserid) { - $question = new EvaluationQuestion(); - $question->setParentID($myuserid); - } else { - $question->delete(); - $question = new EvaluationQuestion(); - } - } else { - $question = new EvaluationQuestion(); - } - /*wenn root, dann id = 0 setzen ---und Text Brandmarken!!--------------*/ - $question->setParentID($myuserid); - $question->setText(trim($template_name), YES); - while ($answerrem = $question->getChild()) { - $id = $answerrem->getObjectID(); - $answerrem->delete(); - $question->removeChildID($id); - } - $answer = new EvaluationAnswer(); - $answer->setRows(Request::option('template_add_num_answers')); - $question->addChild($answer); - $lib->setUniqueName($question, $db, $myuserid); - $question->save(); - $command = ""; - - break; - /* -------------------------------------------------------------------- */ - case "delete": - $question = new EvaluationQuestion ($template_id, null, EVAL_LOAD_ALL_CHILDREN); - if ($question->getParentID() == $myuserid) { - $question->delete(); - } elseif (get_username($question->getParentID()) == "") { - while ($answer = $question->getChild()) { - $answer->delete(); - } - } else { - $report = MessageBox::error(_("Keine Berechtigung zum Löschen.")); - } - $command = ""; - break; - - /* -------------------------------------------------------------------- */ - case "add_answers": - // Bevor etwas hinzugefügt wird nochmal die Speicherungsroutine laufen lassen - if (!Request::option('onthefly')) { - $question = save1($myuserid); - } else { - $question->save(); - } - //$question->setMultiplechoice($template_multiple); - //$question->setText(trim($template_name), YES); - //$question->setType($template_type); - $command = "continue_edit"; - if ($question->getType() == EVALQUESTION_TYPE_MC || - $question->getType() == EVALQUESTION_TYPE_LIKERT) { - while ($template_add_num_answers--) { - $answer = new EvaluationAnswer(); - $answer->setText(""); - $question->addChild($answer); - } - #echo "Nummer: ".$question->getNumberChildren()."<br>"; - break; - - } elseif ($question->getType() == EVALQUESTION_TYPE_POL) { - echo(_("Diese Option gibt es nicht")); - } else { - echo(_("Unbekanntes Objekt")); - } - $command = "continue_edit"; - - break; - - - /* delete answers ----------------------------------------------------- */ - case "delete_answers": - if (!Request::option('onthefly')) { - $question = save1($myuserid); - $question->setParentID($myuserid); - } else - $question->save(); - $template_delete_answers = Request::getArray("template_delete_answers"); - if (!empty($template_delete_answers)) - foreach ($template_delete_answers as $answerID) { - $question->removeChildID($answerID); - $answer = new EvaluationAnswer ($answerID); - $answer->delete(); - } - $command = "continue_edit"; - - break; - /* ------------------------------------------------ end: delete answers */ - - - /* -------------------------------------------------------------------- */ - case "save": - $question = save1($myuserid); - /* Check userinput ----------------------------------------------------- */ - if ($question->getType() == EVALQUESTION_TYPE_MC || - $question->getType() == EVALQUESTION_TYPE_LIKERT) { - $nummer = $question->getNumberChildren(); - for ($i = 0; $i < count($template_answers); $i++) { - $text = $template_answers[$i]['text']; - if ($text == "") { - $question->removeChildID($template_answers[$i]['answer_id']); - $nummer--; - } - } - - if ($nummer == 0) { - $report = MessageBox::error(_("Dem Template wurden keine Antworten zugewiesen oder keine der Antworten enthielt einen Text. Fügen Sie Antworten an, oder löschen Sie das Template.")); - $command = "continue_edit"; - break; - } - } - - if ($question->getType() == EVALQUESTION_TYPE_POL) { - for ($i = 0; $i < count($template_answers); $i++) { - $text = $template_answers[$i]['text']; - if ($text == "") { - $report = MessageBox::error(_("Leere Antworten sind nicht zulässig, löschen Sie betreffende Felder oder geben Sie einen Text ein.")); - $command = "continue_edit"; - break; - } - } - if ($command == "continue_edit") { - break; - } - } - if (!empty($template_residual) && empty($template_residual_text)) { - $report = MessageBox::error(_("Geben Sie eine Ausweichantwort ein oder deaktivieren Sie diese.")); - $command = "continue_edit"; - break; - } - if (!Request::option('onthefly') && !$question->getText()) { - $report = MessageBox::error(_("Geben Sie einen Namen für die Vorlage ein.")); - $command = "continue_edit"; - break; - } - $question->save(); - if ($question->isError()) { - $report = MessageBox::error(_("Fehler beim Speichern.")); - } - $command = ""; - $template_answers = ""; - break; - case "save2": - if ($question) { - $question->save(); - if ($question->isError()) { - $report = MessageBox::error(_("Fehler beim Speichern.")); - } - } - $command = ""; - $template_answers = ""; - break; -} - -/* Surrounding Table ------------------------------------------------------- */ -$br = new HTMpty("br"); - -$tableA = new HTM ("table"); -$tableA->attr("border", "0"); -$tableA->attr("align", "center"); -$tableA->attr("cellspacing", "0"); -$tableA->attr("cellpadding", "2"); -$tableA->attr("width", "250"); - -$lib->createInfoBox(); - -$trA = new HTM("tr"); -$tdA = new HTM("td"); -$tdA->cont(EvalCommon::createTitle(_("Antwortenvorlagen"), NULL, 2)); -$trA->cont($tdA); -$tableA->cont($trA); - -$trA = new HTM("tr"); -$tdA = new HTM("td"); - -$table = new HTM ("table"); -$table->attr("border", "0"); -$table->attr("align", "center"); -$table->attr("cellspacing", "0"); -$table->attr("cellpadding", "3"); -$table->attr("width", "100%"); - -$tr = new HTM("tr"); -$td = new HTM("td"); -$td->attr("class", "table_row_even"); - -if (!$command || $command == "back") { - /* the template selection lists --------------------------------------- */ - - $question_show = new EvaluationQuestionDB(); - $arrayOfTemplateIDs = $question_show->getTemplateID($myuserid); - $arrayOfPolTemplates = []; - $arrayOfSkalaTemplates = []; - $arrayOfNormalTemplates = []; - $arrayOfFreeTemplates = []; - - foreach ($arrayOfTemplateIDs as $templateID) { - $questionload = new EvaluationQuestion ($templateID, - NULL, EVAL_LOAD_FIRST_CHILDREN); - $typ = $questionload->getType(); - $text = my_substr($questionload->getText(), 0, EVAL_MAX_TEMPLATENAMELEN); - /*Root kennzeichnung hier entfernen!!*/ - //if($questionload->getParentID()==0) - // $text="<b>".$text."</b>"; - if ($questionload->getParentID() == '0') { - $text = $questionload->getText() . " " . EVAL_ROOT_TAG; - } - if (($answer = $questionload->getChild()) == NULL) - $answer = new EvaluationAnswer (); - /* --------------------------------------------------------------- */ - switch ($typ) { - - case EVALQUESTION_TYPE_POL: - $arrayOfPolTemplates[] = [$questionload->getObjectID(), $text]; - break; - case EVALQUESTION_TYPE_LIKERT: - $arrayOfSkalaTemplates[] = [$questionload->getObjectID(), $text]; - break; - case EVALQUESTION_TYPE_MC: - if ($answer->isFreetext()) { - $arrayOfFreeTemplates[] = [$questionload->getObjectID(), $text]; - } else { - $arrayOfNormalTemplates[] = [$questionload->getObjectID(), $text]; - } - break; - } - /* -------------------------------------------------------- */ - } - - /* report messages ---------------------------------------------------- */ - $td->cont($report ?? ''); - - $td->cont($lib->createSelections($arrayOfPolTemplates, - $arrayOfSkalaTemplates, - $arrayOfNormalTemplates, - $arrayOfFreeTemplates, - $myuserid)); - -} else { - $form = new HTM("form"); - $form->attr("action", URLHelper::getLink("?page=edit&evalID=" . $evalID ?? '')); - $form->attr("method", "post"); - $form->html(CSRFProtection::tokenTag()); - $form->cont(Button::create(_('zurück'), 'template_back_button', ['title' => _('Zurück zur Auswahl')])); - $td->cont($form); - $report = ''; - /* on the fly info message -------------------------------------------- */ - if ($command == "create_question_answers" || Request::option('onthefly')) { - $report = MessageBox::info(sprintf(_("Weisen Sie der links %sausgewählten%s Frage hier Antworten zu:"), - "<span class=\"eval_highlight\">", "</span>")); - } - /* report messages ---------------------------------------------------- */ - $td->cont($report); -} - - -$tr->cont($td); -$table->cont($tr); -$tdA->cont($table); -$trA->cont($tdA); -$tableA->cont($trA); - - -if ($command) { - /* the template editing fields */ - $trA = new HTM("tr"); - $tdA = new HTM("td"); - - $table = new HTM ("table"); - $table->attr("border", "0"); - $table->attr("align", "center"); - $table->attr("cellspacing", "0"); - $table->attr("cellpadding", "0"); - $table->attr("width", "100%"); - - $tr = new HTM("tr"); - $td = new HTM("td"); - $td->attr("class", "table_row_odd"); - - /*übergebe an create Form das template, dass verändert werden soll*/ - - switch ($command) { - case "editpol_scale": - $question = new EvaluationQuestion (Request::option('template_editpol_scale'), NULL, EVAL_LOAD_ALL_CHILDREN); - $td->cont($lib->createTemplateForm($question)); - break; - case "createpol_scale": - $question = new EvaluationQuestion(); - $question->setObjectID(md5(uniqid(rand()))); - $question->setType(EVALQUESTION_TYPE_POL); - $question->setText(""); - for ($i = 0; $i < 2; $i++) { - $answer = new EvaluationAnswer(); - $answer->setParentID($question->getObjectID()); - if ($i == 0) - $answer->setText(_("Anfang")); - else - $answer->setText(_("Ende")); - $question->addChild($answer); - } - // $td->cont( $lib->createTemplateFormPol( $question ) ); - $td->cont($lib->createTemplateForm($question)); - break; - case "editlikert_scale": - $question = new EvaluationQuestion (Request::option('template_editlikert_scale'), - NULL, EVAL_LOAD_ALL_CHILDREN); - $question->setType(EVALQUESTION_TYPE_LIKERT); - //$td->cont( $lib->createTemplateFormLikert( $question ) ); - $td->cont($lib->createTemplateForm($question)); - break; - case "createlikert_scale": - $question = new EvaluationQuestion(); - $question->setObjectID(md5(uniqid(rand()))); - $question->setType(EVALQUESTION_TYPE_LIKERT); - $question->setText(""); - for ($i = 0; $i < 4; $i++) { - $answer = new EvaluationAnswer(); - $answer->setParentID($question->getObjectID()); - $answer->setText(""); - $answer->setPosition(1); - $question->addChild($answer); - } - $td->cont($lib->createTemplateForm($question)); - break; - case "editnormal_scale": - $question = new EvaluationQuestion (Request::option('template_editnormal_scale'), - NULL, EVAL_LOAD_ALL_CHILDREN); - $question->setType(EVALQUESTION_TYPE_MC); - $td->cont($lib->createTemplateForm($question)); - break; - case "createnormal_scale": - $question = new EvaluationQuestion(); - $question->setObjectID(md5(uniqid(rand()))); - $question->setType(EVALQUESTION_TYPE_MC); - $question->setText(""); - for ($i = 0; $i < 4; $i++) { - $answer = new EvaluationAnswer(); - $answer->setParentID($question->getObjectID()); - $answer->setText(""); - $answer->setPosition(1); - $question->addChild($answer); - } - $td->cont($lib->createTemplateForm($question)); - //$td->cont( $lib->createTemplateFormMul( $question ) ); - break; - case "continue_edit": - /*Im Fall direkt question->answers flag mitübergeben*/ - /*$template_type überprüfen------------------------------------------*/ - switch (Request::option('template_type')) { - /* --------------------------------------------------------------- */ - case EVALQUESTION_TYPE_LIKERT: - case EVALQUESTION_TYPE_POL: - $td->cont($lib->createTemplateForm($question)); - break; - case EVALQUESTION_TYPE_MC: - $td->cont($lib->createTemplateForm($question, Request::int('onthefly'))); - break; - } - break; - - case "create_question_answers": - $onthefly = 1; - // extract the questionID from the command - foreach ($_REQUEST as $key => $value) { - if (preg_match("/template_(.*)_button?/", $key, $command)) - break; - } - if (preg_match("/(.*)_#(.*)/", $command[1], $command_parts)) - $questionID = $command_parts[2]; - $question = new EvaluationQuestion ($questionID ?? '', NULL, EVAL_LOAD_ALL_CHILDREN); - - if ($question->getNumberChildren() == 0) { - $question->setType(EVALQUESTION_TYPE_MC); - for ($i = 0; $i < 4; $i++) { - $answer = new EvaluationAnswer(); - $answer->setParentID($question->getObjectID()); - $answer->setText(("")); - $answer->setPosition(1); - $question->addChild($answer); - } - } - $td->cont($lib->createTemplateForm($question, $onthefly)); - break; - case "createfree_scale": - $question = new EvaluationQuestion(); - $question->setObjectID(md5(uniqid(rand()))); - $question->setType(EVALQUESTION_TYPE_MC); - $question->setText(_("Freitext")); - $answer = new EvaluationAnswer(); - $answer->setParentID($question->getObjectID()); - $answer->setText(""); - $answer->setRows(1); - $question->addChild($answer); - $td->cont($lib->createTemplateFormFree($question)); - break; - case "editfree_scale": - $question = new EvaluationQuestion (Request::option('template_editfree_scale'), - NULL, EVAL_LOAD_ALL_CHILDREN); - $td->cont($lib->createTemplateFormFree($question)); - break; - - case "back": - $td->cont(" "); - break; - - } - - $tr->cont($td); - $table->cont($tr); - $tdA->cont($table); - $trA->cont($tdA); - $tableA->cont($trA); - -} - -/* Javascript function for preview-link */ -$js = EvalCommon::createEvalShowJS(YES); - -/* --------------------------------------------------------------------- */ -return $js->createContent() . $tableA->createContent(); -/* --------------------------------------------------------------------- */ - - -/* --------------------------------------------------------------------- */ -function save1($myuserid) -{ - $mineexists = 0; - /*Existiert Question/Template schon?*/ - $qdb = new EvaluationQuestionDB(); - if (empty($template_id)) { - $template_id = Request::option("template_id"); - } - if ($qdb->exists($template_id)) { - $question = new EvaluationQuestion ($template_id, - NULL, EVAL_LOAD_ALL_CHILDREN); - if ($question->getParentID() != $myuserid) { - $foreign = TRUE; - $question = new EvaluationQuestion(); - $question->setParentID($myuserid); - } else { - $overwrite = 1; - //$question->delete(); - //$question = new EvaluationQuestion(); - //$template_id=$question->getObjectID(); - } - } else { - $question = new EvaluationQuestion(); - } - - /*Get Vars ----------------------------------------------------*/ - $template_name = Request::get("template_name"); - $template_type = Request::get("template_type"); - $template_multiple = Request::get("template_multiple"); - $template_add_num_answers = Request::option("template_add_num_answers"); - $template_residual = Request::get("template_residual"); - $template_residual_text = Request::get("template_residual_text"); - $template_answers = Request::getArray("template_answers"); - /*end: Get Vars -----------------------------------------------*/ - - $question->setParentID($myuserid); - $question->setMultiplechoice($template_multiple); - $question->setText(trim($template_name), YES); - $question->setType($template_type); - - while ($answerrem = $question->getChild()) { - $id = $answerrem->getObjectID(); - $answerrem->delete(); - $question->removeChildID($id); - } - - $controlnumber = count($template_answers); - $ausgleich = 0; - - for ($i = 0; $i < $controlnumber; $i++) { - $text = $template_answers[$i]['text']; - $answerID = $template_answers[$i]['answer_id']; - $answer = new EvaluationAnswer(); - if (empty($foreign)) - $answer->setObjectID($answerID); - $answer->setText(trim($text), YES); - $question->addChild($answer); - - if ($template_type == EVALQUESTION_TYPE_POL && $i == 0) { - $answerdiff = $controlnumber - $template_add_num_answers; - - if ($answerdiff > 0) { - $i = $i + $answerdiff; - $ausgleich = $ausgleich - $answerdiff; - } - while ($answerdiff < 0) { - $ausgleich = $ausgleich + 1; - $answer = new EvaluationAnswer(); - $answer->setText(""); - $answer->setParentID($question->getObjectID()); - $answer->setPosition($i + $ausgleich); - $answer->setValue($i + 1 + $ausgleich); - $question->addChild($answer); - $answerdiff++; - } - } - } - - if ($template_residual) { - $answer = new EvaluationAnswer(); - $answer->setResidual($template_residual); - $answer->setText(trim($template_residual_text), QUOTED); - $answer->setParentID($question->getObjectID()); - $answer->setPosition($i + $ausgleich + 1); - $answer->setValue(-1); - $question->addChild($answer); - } - - if (empty($overwrite)) { - $db = new EvaluationQuestionDB(); - $lib = new EvalTemplateGUI(); - $lib->setUniqueName($question, $db, $myuserid, YES); - } - - if ($question->isError()) { - return MessageBox::error(_("Fehler beim Speichern.")); - } - return $question; - -} diff --git a/lib/evaluation/evaluation_admin_template.lib.php b/lib/evaluation/evaluation_admin_template.lib.php deleted file mode 100644 index 4cbf727bb5c88f9d0b24cb07584f4aac333d9c34..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation_admin_template.lib.php +++ /dev/null @@ -1,1102 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Library for template gui - * - * @author JPWowra - * - * @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. -// +--------------------------------------------------------------------------+ - -use Studip\Button; - -class EvalTemplateGUI -{ - public $BR; - public $command; - - public function __construct() - { - $this->BR = new HTMpty("br"); - $this->command = $this->getPageCommand(); - } - - /** - * Creates the two (?) template selection lists - * @param - */ - public function createSelections( - $polTemplates, - $skalaTemplates, - $normalTemplates, - $freeTemplates, - $myuserid - ) - { - - global $evalID; - - $form = new HTM("form"); - - $form->attr("action", URLHelper::getLink("?page=edit&evalID=" . $evalID)); - $form->attr("method", "post"); - $form->html(CSRFProtection::tokenTag()); - - $table = new HTML("table"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("cellspacing", "0"); - - $table->addAttr("width", "100%"); - $tr = new HTML ("tr"); - $td = new HTML ("td"); - $td->addAttr("align", "right"); - - /* Polskalen ------------------------------------------------ */ - $b = new HTM("b"); - $b->cont(_("Polskala")); - $td->addContent($b); - $tr->addContent($td); - - $td = new HTML ("td"); - - /* create button ------------------------------------ */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_createpol_scale_button"); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $input->stri(tooltip(_("Neue Vorlage erstellen."), TRUE)); - $input->attr("src", EVAL_PIC_ADD_TEMPLATE); - - $td->addContent($input); - $tr->addContent($td); - $table->addContent($tr); - - if (!empty($polTemplates)) { - $tr = new HTML ("tr"); - $td = new HTML ("td"); - $td->addAttr("align", "right"); - - $select = new HTM("select"); - $select->attr("name", "template"); - $select->attr("size", "1"); - foreach ($polTemplates as $templatearray) { - $option = new HTM("option"); - $select->attr("name", "template_editpol_scale"); - $option->attr("value", $templatearray[0]); - $option->cont("$templatearray[1]"); - $select->cont($option); - } - $td->addContent($select); - $tr->addContent($td); - $td = new HTML ("td"); - - /* edit button ----------------------------------- */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_editpol_scale_button"); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $input->stri(tooltip(_("Ausgewählte Vorlage bearbeiten."), TRUE)); - $input->attr("src", EVAL_PIC_EDIT); - - $td->addContent($input); - $tr->addContent($td); - $table->addContent($tr); - } - /* end: Polskalen ----------------------------------------------- */ - - - /* Likertskalen ------------------------------------------------- */ - $td = new HTML ("td"); - $td->addAttr("align", "right"); - $td->addAttr("class", "content_body"); - $tr = new HTML ("tr"); - - $b = new HTM("b"); - $b->cont(_("Likertskala")); - $td->addContent($b); - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("class", "content_body"); - - /* create button ------------------------------------ */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_createlikert_scale_button"); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $input->stri(tooltip(_("Neue Vorlage erstellen."), TRUE)); - $input->attr("src", EVAL_PIC_ADD_TEMPLATE); - - $td->addContent($input); - $tr->addContent($td); - $table->addContent($tr); - - if (!empty($skalaTemplates)) { - $td = new HTML ("td"); - $tr = new HTML ("tr"); - $td->addAttr("align", "right"); - $select = new HTM("select"); - $select->attr("name", "template"); - $select->attr("size", "1"); - - foreach ($skalaTemplates as $templatearray) { - $option = new HTM("option"); - $select->attr("name", "template_editlikert_scale"); - $option->attr("value", $templatearray[0]); - $option->cont("$templatearray[1]"); - $select->cont($option); - } - $td->addContent($select); - $tr->addContent($td); - - $td = new HTML ("td"); - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_editlikert_scale_button"); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $input->stri(tooltip(_("Ausgewählte Vorlage bearbeiten."), TRUE)); - $input->attr("src", EVAL_PIC_EDIT); - - $td->addContent($input); - $tr->addContent($td); - $table->addContent($tr); - } - /* end: Likertskalen ----------------------------------------------- */ - - - /* Normale / Multiplechoice ---------------------------------------- */ - $td = new HTML ("td"); - $td->addAttr("class", "content_body"); - $tr = new HTML ("tr"); - $td->addAttr("align", "right"); - - $b = new HTM("b"); - $b->cont(_("Multiple Choice")); - $td->addContent($b); - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("class", "content_body"); - - /* create button ------------------------------------ */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_createnormal_scale_button"); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $input->stri(tooltip(_("Neue Vorlage erstellen."), TRUE)); - $input->attr("src", EVAL_PIC_ADD_TEMPLATE); - - $td->addContent($input); - $tr->addContent($td); - $table->addContent($tr); - - if (!empty($normalTemplates)) { - $td = new HTML ("td"); - $tr = new HTML ("tr"); - $td->addAttr("align", "right"); - $select = new HTM("select"); - $select->attr("name", "template"); - $select->attr("size", "1"); - - foreach ($normalTemplates as $templatearray) { - $option = new HTM("option"); - $select->attr("name", "template_editnormal_scale"); - $option->attr("value", $templatearray[0]); - $option->cont("$templatearray[1]"); - $select->cont($option); - } - $td->addContent($select); - $tr->addContent($td); - $td = new HTML ("td"); - - /* edit button */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_editnormal_scale_button"); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $input->stri(tooltip(_("Ausgewählte Vorlage bearbeiten."), TRUE)); - $input->attr("src", EVAL_PIC_EDIT); - - $td->addContent($input); - $tr->addContent($td); - $table->addContent($tr); - } - /* end: Normale / Multiplechoice-------------------------------------- */ - - - /* Freitext ----------------------------------------------------- */ - - $td = new HTML ("td"); - $td->addAttr("class", "content_body"); - $tr = new HTML ("tr"); - $td->addAttr("align", "right"); - - $b = new HTM("b"); - $b->cont(_("Freitext-Antwort")); - $td->addContent($b); - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("class", "content_body"); - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_createfree_scale_button"); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $input->stri(tooltip(_("Neue Vorlage erstellen."), TRUE)); - $input->attr("src", EVAL_PIC_ADD_TEMPLATE); - $td->addContent($input); - $tr->addContent($td); - $table->addContent($tr); - - if (!empty($freeTemplates)) { - $td = new HTML ("td"); - $tr = new HTML ("tr"); - $td->addAttr("align", "right"); - - $select = new HTM("select"); - $select->attr("name", "template"); - $select->attr("size", "1"); - - foreach ($freeTemplates as $templatearray) { - $option = new HTM("option"); - $select->attr("name", "template_editfree_scale"); - $option->attr("value", $templatearray[0]); - $option->cont("$templatearray[1]"); - $select->cont($option); - } - $td->addContent($select); - $tr->addContent($td); - $td = new HTML ("td"); - - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_editfree_scale_button"); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $input->stri(tooltip(_("Ausgewählte Vorlage bearbeiten."), TRUE)); - $input->attr("src", EVAL_PIC_EDIT); - $td->addContent($input); - $tr->addContent($td); - $table->addContent($tr); - } - /* end: Freitext -------------------------------------- */ - - $form->cont($table); - - return $form; - } - - /** - * Creates the form for the template - * @param - */ - public function createTemplateForm(&$question, $onthefly = "") - { - global $evalID, $itemID; - - $type = $question->getType(); - $tableA = new HTM("table"); - $tableA->attr("border", "0"); - $tableA->attr("cellpadding", "2"); - $tableA->attr("cellspacing", "0"); - $tableA->attr("width", "100%"); - - $trA = new HTM("tr"); - $tdA = new HTM("td"); - $tdA->attr("class", "table_header_bold"); - $tdA->attr("align", "left"); - if ($onthefly) { - $tdA->html(_("<b>Freie Antworten definieren</b>")); - } else { - $isCreate = mb_strstr($this->getPageCommand(), "create"); - $tdA->html("<b>"); - switch ($type) { - case EVALQUESTION_TYPE_MC: - //$answer = $question->getChild(); - //if ($answer->isFreetext ()) {} - //else - $tdA->html($isCreate - ? _("Multiple Choice erstellen") - : _("Multiple Choice bearbeiten")); - break; - case EVALQUESTION_TYPE_LIKERT: - $tdA->html($isCreate - ? _("Likertskala erstellen") - : _("Likertskala bearbeiten")); - break; - case EVALQUESTION_TYPE_POL: - $tdA->html($isCreate - ? _("Polskala erstellen") - : _("Polskala bearbeiten")); - break; - } - $tdA->html("</b>"); - } - $trA->cont($tdA); - $tableA->cont($trA); - - $trA = new HTM("tr"); - $tdA = new HTM("td"); - - $form = new HTM("form"); - $form->attr("action", URLHelper::getLink('', ['page' => 'edit', 'evalID' => $evalID, 'itemID' => $itemID])); - - $form->attr("method", "post"); - $form->html(CSRFProtection::tokenTag()); - /* template name --------------------------------- */ - if ($onthefly != 1) { - $b = new HTM("b"); - $b->cont(_("Name") . ": "); - $form->cont($b); - $input = new HTMpty("input"); - $input->attr("type", "text"); - $input->attr("name", "template_name"); - $input->attr("value", $question->getText()); - $input->attr("style", "vertical-align:middle;"); - $input->attr("size", 22); - $input->attr("maxlength", 22); - $input->attr("tabindex", 1); - $form->cont($input); - } else { - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_name"); - $input->attr("value", $question->getText()); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "onthefly"); - $input->attr("value", $onthefly); - $form->cont($input); - } - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_id"); - $input->attr("value", $question->getObjectID()); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_type"); - $input->attr("value", $question->getType()); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_residual"); - $input->attr("value", NO); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_position"); - $input->attr("value", $question->getPosition()); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "parentID"); - $input->attr("value", $question->getParentID()); - $form->cont($input); - - if ($onthefly != 1) { - $img = new HTMpty("img"); - $img->attr("src", Icon::create('info-circle', 'inactive')->asImagePath(16)); - $img->attr("class", "middle"); - $img->stri(tooltip(_("Geben Sie hier einen Namen für Ihre Vorlage ein. Wenn Sie eine systemweite Vorlage bearbeiten, und speichern, wird eine neue Vorlage für Sie persönlich angelegt."), - FALSE, TRUE)); - $form->cont($img); - $form->cont($this->BR); - } - if ($type == EVALQUESTION_TYPE_MC) { - /* multiple - radiobuttons ----------------------- */ - $form->cont($this->createSubHeadline - (_("Mehrfachantwort erlaubt") . ": ")); - $radio = new HTMpty("input"); - $radio->attr("type", "radio"); - $radio->attr("name", "template_multiple"); - $radio->attr("value", YES); - $question->isMultiplechoice() - ? $radio->attr("checked") : 0; - $form->cont($radio); - $form->cont(_("ja")); - - $radio = new HTMpty("input"); - $radio->attr("type", "radio"); - $radio->attr("name", "template_multiple"); - $radio->attr("value", NO); - $question->isMultiplechoice() - ? 0 : $radio->attr("checked"); - $form->cont($radio); - $form->cont(_("nein")); - $form->cont($this->BR); - /*end: multiple - radiobuttons -------------------- */ - - /* show multiple choice checkboxes & answers------------------------- */ - $form->cont($this->createSubHeadline(_("Antworten") . ": ")); - for ($i = 0; $answer = $question->getNextChild(); $i++) { - $form->cont(($i < 9 ? "0" : "") . ($i + 1) . ". "); - $input = new HTMpty("input"); - $input->attr("type", "text"); - $input->attr("name", "template_answers[" . $i . "][text]"); - $input->attr("value", $answer->getText()); - $input->attr("size", 23); - $input->attr("tabindex", $i + 2); - $form->cont($input); - $input = new HTMpty("input"); - $input->attr("type", "checkbox"); - $input->attr("name", "template_delete_answers[" . $i . "]"); - $input->attr("value", $answer->getObjectID()); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_answers[" . $i . "][answer_id]"); - $input->attr("value", $answer->getObjectID()); - $form->cont($input); - $form->cont($this->BR); - } - /* ------------------------- end: multiple choice checkboxes &answers */ - - /* add button ------------------------------------ */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_add_answers_button"); - $input->addAttr("src", EVAL_PIC_ADD); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $form->html(" "); - $form->cont($input); - - /* add number of answers - list ------------------ */ - $select = new HTM("select"); - $select->attr("name", "template_add_num_answers"); - $select->attr("size", "1"); - $select->attr("style", "vertical-align:middle;"); - for ($i = 1; $i <= 10; $i++) { - $option = new HTM("option"); - $option->attr("value", $i); - $option->cont($i); - $select->cont($option); - } - $form->cont($select); - - /* delete button --------------------------------- */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_delete_answers_button"); - $input->addAttr("src", EVAL_PIC_REMOVE); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $form->html(" "); - $form->cont($input); - $form->cont($this->BR); - } else { - if ($type == EVALQUESTION_TYPE_POL) { - $form->cont($this->createSubHeadline(_("Antworten") . ": ")); - /* answers --------------------------------------- */ - $isResidual = NO; - for ($i = 0; $answer = $question->getNextChild(); $i++) { - /*Einbau der Residualkategorie hier komplizierter*/ - $residualAnswer = $answer; - if (!$answer->isResidual()) { - if ($i == 0 || $i >= ($question->getNumberChildren() - 2)) { - if ($i == 0) { - $form->cont(_("Beschriftung erste Antwort")); - $input = new HTMpty("input"); - $input->attr("type", "text"); - $input->attr("name", "template_answers[0][text]"); - $input->attr("value", $answer->getText()); - $input->attr("size", 29); - $form->cont($input); - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_answers[0][answer_id]"); - $input->attr("value", $answer->getObjectID()); - $form->cont($input); - $form->cont($this->BR); - } else { - - if ($answer->getText() == "") { - $oldid = $answer->getObjectID(); - //continue; - } else { - $form->cont(_("Beschriftung letzte Antwort")); - $lastone = -1; - $input = new HTMpty("input"); - $input->attr("type", "text"); - $input->attr("name", "template_answers[1][text]"); - $input->attr("value", $answer->getText()); - $input->attr("size", 29); - $form->cont($input); - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_answers[1][answer_id]"); - $input->attr("value", $answer->getObjectID()); - $form->cont($input); - } - - } - - } - - } else { - $isResidual = YES; - - } - if (isset($lastone) && $lastone != -1 && $i == ($question->getNumberChildren() - 1)) { - $form->cont(_("Beschriftung letzte Antwort")); - $lastone = YES; - $input = new HTMpty("input"); - $input->attr("type", "text"); - $input->attr("name", "template_answers[1][text]"); - $input->attr("value", ""); - $input->attr("size", 29); - $form->cont($input); - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_answers[1][answer_id]"); - $input->attr("value", $oldid ?? ''); - $form->cont($input); - } - } - $form->cont($this->BR); - $form->cont($this-> - createSubHeadline(_("Anzahl Abstufungen") . ": ")); - /* NUMBER OF ANSWERS------------------------------------------ */ - $select = new HTM("select"); - $select->attr("name", "template_add_num_answers"); - $select->attr("size", "1"); - $select->attr("style", "vertical-align:middle;"); - $res = 0; - if ($isResidual == YES) { - $res = 1; - } - for ($i = 4; $i <= 20; $i++) { - $option = new HTM("option"); - $option->attr("value", $i); - $option->cont($i); - if ($i == $question->getNumberChildren() - $res) - $option->addAttr("selected", "selected"); - $select->cont($option); - } - $form->cont($select); - $form->cont($this->BR); - - - } - if ($type == EVALQUESTION_TYPE_LIKERT) { - $form->cont($this->createSubHeadline(_("Antworten") . ": ")); - $residualAnswer = NULL; - $isResidual = NO; - for ($i = 0; $answer = $question->getNextChild(); $i++) { - if (!$answer->isResidual()) { - $form->cont(($i < 9 ? "0" : "") . ($i + 1) . ". "); - $input = new HTMpty("input"); - $input->attr("type", "text"); - $input->attr("name", "template_answers[" . $i . "][text]"); - $input->attr("value", $answer->getText()); - $input->attr("size", 23); - $input->attr("tabindex", $i + 2); - $form->cont($input); - $input = new HTMpty("input"); - $input->attr("type", "checkbox"); - $input->attr("name", "template_delete_answers[" . $i . "]"); - $input->attr("value", $answer->getObjectID()); - $form->cont($input); - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_answers[" . $i . "][answer_id]"); - $input->attr("value", $answer->getObjectID()); - $form->cont($input); - $form->cont($this->BR); - if (!$residualAnswer) - $residualAnswer = $answer; - } else { - $i--; - $isResidual = YES; - $residualAnswer = $answer; - } - } - - /* add button ------------------------------------ */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_add_answers_button"); - $input->addAttr("src", EVAL_PIC_ADD); - - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $form->html(" "); - $form->cont($input); - - /* add number of answers - list ------------------ */ - $select = new HTM("select"); - $select->attr("name", "template_add_num_answers"); - $select->attr("size", "1"); - $select->attr("style", "vertical-align:middle;"); - for ($i = 1; $i <= 10; $i++) { - $option = new HTM("option"); - $option->attr("value", $i); - $option->cont($i); - $select->cont($option); - } - $form->cont($select); - - /* delete answers button --------------------------------- */ - $input = new HTMpty("input"); - $input->attr("type", "image"); - $input->attr("name", "template_delete_answers_button"); - $input->addAttr("src", EVAL_PIC_REMOVE); - $input->attr("border", "0"); - $input->attr("style", "vertical-align:middle;"); - $form->html(" "); - $form->cont($input); - $form->cont($this->BR); - - - } - - } - if ($type == EVALQUESTION_TYPE_LIKERT || $type == EVALQUESTION_TYPE_POL) { - /* residual category ------------------------------------ */ - $form->cont($this->createSubHeadline(_("Ausweichantwort") . ": ")); - - /* residual - radiobuttons ------------------------------ */ - $radio = new HTMpty("input"); - $radio->attr("type", "radio"); - $radio->attr("name", "template_residual"); - $radio->attr("value", YES); - - $value = !empty($isResidual) ? "checked" : "unchecked"; - $radio->attr($value); - - $form->cont($radio); - $form->cont(_("ja") . ":"); - - /* residual text field -------------> */ - $input = new HTMpty("input"); - $input->attr("type", "text"); - $input->attr("name", "template_residual_text"); - if (!empty($isResidual)) - $input->attr("value", !empty($residualAnswer) ? $residualAnswer->getText() : ''); - else - $input->attr("value", ""); - $input->attr("size", 22); - $form->cont($input); - /* <------------- residual text field */ - $form->cont($this->BR); - $radio = new HTMpty("input"); - $radio->attr("type", "radio"); - $radio->attr("name", "template_residual"); - $radio->attr("value", NO); - - $value = $value == "unchecked" ? "checked" : "unchecked"; - $radio->attr($value); - - $form->cont($radio); - $form->cont(_("nein")); - /*end: residual - radiobuttons -------------------- */ - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_residual_id"); - $input->attr("value", !empty($residualAnswer) ? $residualAnswer->getObjectID() : ''); - $form->cont($input); - /*end: residual - kategorie -------------------- */ - } - /* uebernehmen button ---------------------------- */ - if ($onthefly == 1) { - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "cmd"); - $input->attr("value", "QuestionAnswersCreated"); - $form->cont($input); - - $input = Button::create(_('Übernehmen'), - 'template_save2_button'); - } else { - $input = Button::create(_('Übernehmen'), - 'template_save_button'); - } - - if (!mb_strstr($this->command, "create")) { - $showDelete = YES; - $input2 = Button::createAccept(_('Löschen'), - 'template_delete_button'); - } - - $table = new HTM("table"); - $table->attr("border", "0"); - $table->attr("align", "center"); - $table->attr("cellspacing", "0"); - $table->attr("cellpadding", "3"); - $table->attr("width", "100%"); - $tr = new HTM("tr"); - $td = new HTM("td"); - $td->attr("class", "content_body"); - $td->attr("align", "center"); - $td->cont($input); - $tr->cont($td); - - if (!empty($showDelete)) { - $td = new HTM("td"); - $td->attr("class", "content_body"); - $td->attr("align", "center"); - $td->cont($input2 ?? ''); - $tr->cont($td); - } - - $table->cont($tr); - $form->cont($table); - - /* ----------------------------------------------- */ - $tdA->cont($form); - $trA->cont($tdA); - $tableA->cont($trA); - return $tableA; - - } - - - /** - * Creates the form for the Polskala templates - * @param - */ - public function createTemplateFormFree(&$question) - { - global $evalID; - $answer = $question->getNextChild(); - - $tableA = new HTM("table"); - $tableA->attr("border", "0"); - $tableA->attr("cellpadding", "2"); - $tableA->attr("cellspacing", "0"); - $tableA->attr("width", "100%"); - - $trA = new HTM("tr"); - $tdA = new HTM("td"); - $tdA->attr("class", "table_header_bold"); - $tdA->attr("align", "left"); - $tdA->html("<b>" . (mb_strstr($this->getPageCommand(), "create") - ? _("Freitextvorlage erstellen") - : _("Freitextvorlage bearbeiten")) . "</b>"); - $trA->cont($tdA); - $tableA->cont($trA); - - $trA = new HTM("tr"); - $tdA = new HTM("td"); - $form = new HTM("form"); - $form->attr("action", URLHelper::getLink("?page=edit&evalID=" . $evalID)); - $form->attr("method", "post"); - $form->html(CSRFProtection::tokenTag()); - - $b = new HTM("b"); - $b->cont(_("Name") . ": "); - $form->cont($b); - - $input = new HTMpty("input"); - $input->attr("type", "text"); - $input->attr("name", "template_name"); - $name = $question->getText(); - $input->attr("value", $question->getText()); - // $input->attr( "value", $name ); - $input->attr("style", "vertical-align:middle;"); - $input->attr("size", 22); - $input->attr("maxlength", 22); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_id"); - $input->attr("value", $question->getObjectID()); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_type"); - $input->attr("value", $question->getType()); - $form->cont($input); - - $input = new HTMpty("input"); - $input->attr("type", "hidden"); - $input->attr("name", "template_multiple"); - $input->attr("value", NO); - $form->cont($input); - - $img = new HTMpty("img"); - $img->attr("src", Icon::create('info-circle', 'inactive')->asImagePath(16)); - $img->attr("class", "middle"); - $img->stri(tooltip(_("Geben Sie hier einen Namen für Ihre Vorlage ein. Ändern Sie den Namen, um eine neue Vorlage anzulegen."), - FALSE, TRUE)); - $form->cont($img); - $form->cont($this->BR); - - //$answer = $question->getNextChild(); - //$answer->toString(); - /* Anzahl Zeilen------------------------------------------------------ */ - $form->cont($this->createSubHeadline(_("Anzahl Zeilen") . ": ")); - - $select = new HTM("select"); - $select->attr("name", "template_add_num_answers"); - $select->attr("size", "1"); - $select->attr("style", "vertical-align:middle;"); - for ($i = 1; $i <= 25; $i++) { - $option = new HTM("option"); - $option->attr("value", $i); - $option->cont($i); - if ($i == $answer->getRows()) - $option->addAttr("selected", "selected"); - $select->cont($option); - } - $form->cont($select); - $form->cont($this->BR); - - /* uebernehmen / loeschen Button ---------------------------- */ - $input = Button::create(_('Übernehmen'), - 'template_savefree_button'); - if (!mb_strstr($this->command, "create")) { - $showDelete = YES; - $input2 = Button::createAccept(_('Löschen'), - 'template_delete_button'); - } - - $table = new HTM("table"); - $table->attr("border", "0"); - $table->attr("align", "center"); - $table->attr("cellspacing", "0"); - $table->attr("cellpadding", "3"); - $table->attr("width", "100%"); - $tr = new HTM("tr"); - $td = new HTM("td"); - $td->attr("class", "content_body"); - $td->attr("align", "center"); - $td->cont($input); - $tr->cont($td); - - if (!empty($showDelete)) { - $td = new HTM("td"); - $td->attr("class", "content_body"); - $td->attr("align", "center"); - $td->cont($input2 ?? ''); - $tr->cont($td); - } - $table->cont($tr); - $form->cont($table); - - $tdA->cont($form); - $trA->cont($tdA); - $tableA->cont($trA); - return $tableA; - } - - - /** - * create a blue headline - */ - public function createHeadline($text) - { - $div = new HTM("div"); - $div->attr("class", "eval_title"); - $div->attr("style", "margin-bottom:4px; margin-top:4px;"); - $div->cont($text); - return $div; - } - - /** - * create a fat-printed sub headline with some space - */ - public function createSubHeadline($text) - { - $div = new HTM("div"); - $div->attr("style", "margin-bottom:4px; margin-top:4px;"); - $b = new HTM("b"); - $b->cont($text); - $div->cont($b); - return $div; - } - - - /** - * creates the infobox - * - */ - public function createInfoBox() - { - global $evalID, $rangeID; - - if (get_Username($rangeID)) { - $rangeID = get_Username($rangeID); - } - - if (empty($rangeID)) { - $rangeID = get_Username($GLOBALS['user']->id); - } - - $actions = new ActionsWidget(); - $actions->addLink(_('Vorschau der Evaluation'), - URLHelper::getURL('show_evaluation.php', - ['evalID' => $evalID, - 'isPreview' => YES]), Icon::create('question-circle', 'clickable'), - ['target' => $evalID, - 'onClick' => "openEval('" . $evalID . "'); return false;"]); - $actions->addLink(_('Zurück zur Evaluations-Verwaltung'), URLHelper::getURL('admin_evaluation.php', - ['page' => 'overview', - 'check_abort_creation_button' => '1', - 'evalID' => $evalID, - 'rangeID' => $rangeID]), - Icon::create('link-intern', 'clickable')); - Sidebar::Get()->addWidget($actions); - } - - -# Define private functions ================================================== # - - /** - * creates a new answer - * - * @access private - * @return array the created answer as an array with keys 'answer_id' => new md5 id, - * 'text' => "", - * 'counter' => 0, - * 'correct' => NO - */ - public function makeNewAnswer() - { - return ['answer_id' => md5(uniqid(rand())), - 'text' => rand() - ]; - } - - - /** - * deletes the answer at position 'pos' from the array 'answers' - * and modifies the array 'deleteAnswers' respectively - * - * @access public - * @param array &$answers the answerarray - * @param array &$deleteAnswers the array containing the deleteCheckbox-bool-value for each answer - * @param int $pos the position of the answer to be deleted - * - */ - public function deleteAnswer($pos, &$answers, &$deleteAnswers) - { - - unset($answers[$pos]); - if (is_array($deleteAnswers)) - unset($deleteAnswers[$pos]); - - for ($i = $pos; $i < count($answers); $i++) { - - if (!isset($answers[$i])) { - $answers[$i] = $answers[$i + 1]; - unset($answers[$i + 1]); - if (is_array($deleteAnswers)) { - $deleteAnswers[$i] = $deleteAnswers[$i + 1]; - unset($deleteAnswers[$i + 1]); - } - } - } - return; - } - - /** - * checks which button was pressed - * - * @access public - * @returns string the command "add_answers", "delete_answers", etc. - * - */ - public function getPageCommand() - { - foreach ($_REQUEST as $key => $value) { - if (preg_match("/template_(.*)_button?/", $key, $command)) - break; - } - - $return_command = $command[1] ?? ''; - - // extract the command if theres a questionID in the commandname - if (preg_match("/(.*)_#(.*)/", $return_command, $new_command)) - $return_command = $new_command[1]; - - - return $return_command; - } - - - /** - * Checks if a template with the same name already exists and modifies the - * text of the template if necessary. - * @param object $template The template - * @param object $db The EvaluationQuestionDB - * @param string $myuserid My userid - * @param boolean $rootTag If yes, add the root tag if necessary - * @access private - */ - public function setUniqueName(&$question, $db, $myuserid, $rootTag = NO) - { - $text = $question->getText(); - - /* Add root tag if necessary ----------------------------------------- */ - //if ($rootTag && $myuserid == "0" && !mb_strstr ($text, EVAL_ROOT_TAG)) - // $question->setText ($text." ".EVAL_ROOT_TAG); - /* ------------------------------------------------- end: add root tag */ - - /* Remove root tag if necessary -------------------------------------- */ - if ($myuserid != "0" && mb_strstr($text, EVAL_ROOT_TAG)) { - $question->setText(trim(implode("", explode(EVAL_ROOT_TAG, $text)))); - } - /* ---------------------------------------------- end: remove root tag */ - - /* Change text if necessary with increasing number ------------------- */ - $originalName = $question->getText(); - for ($i = 1; $db->titleExists($question->getText(), $myuserid); $i++) { - $question->setText($originalName . " (" . $i . ")"); - } - /* -------------------------------------------------- end: change text */ - } - -# ==================================================== end: private functions # - -} - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once HTML; -# ====================================================== end: including files # diff --git a/lib/evaluation/evaluation_show.lib.php b/lib/evaluation/evaluation_show.lib.php deleted file mode 100644 index 40701fb787b5fe36fa7fc456c0395dc9cbea640b..0000000000000000000000000000000000000000 --- a/lib/evaluation/evaluation_show.lib.php +++ /dev/null @@ -1,417 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Library for evaluation participation page - * - * @author mcohrs <michael A7 cohrs D07 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. -// +---------------------------------------------------------------------------+ - -use Studip\Button, Studip\LinkButton; - -class EvalShow -{ - - /** - * createEvaluationHeader: generate the head of an evaluation (title and base text) - * @param the evaluation - * @returns a table row - */ - function createEvaluationHeader( $eval, $votedNow, $votedEarlier ) - { - $br = new HTMpty( "br" ); - - $tr = new HTM( "tr" ); - $td = new HTM( "td" ); - $td->attr( "class", "table_row_even" ); - - $table2 = new HTM( "table" ); - $table2->attr( "width", "100%" ); - $tr2 = new HTM( "tr" ); - $td2 = new HTM( "td" ); - $td2->attr( "width", "90%" ); - $td2->attr( "valign", "top" ); - - if( $eval->isError() ) { - $td2->html( EvalCommon::createErrorReport ($eval, _("Fehler")) ); - $td2->html( $br ); - } - - $span = new HTM( "span" ); - $span->attr( "class", "eval_title" ); - $span->html( htmlReady($eval->getTitle()) ); - $td2->cont( $span ); - $td2->cont( $br ); - - $td2->cont( $br ); - if( $votedNow ) { - $message = new HTML('div'); - $message->_content = [(string) MessageBox::success(_("Vielen Dank für Ihre Teilnahme."))]; - $td2->cont($message); - } elseif( $votedEarlier ) { - $message = new HTML('div'); - $message->_content = [(string) MessageBox::info(_("Sie haben an dieser Evaluation bereits teilgenommen."))]; - $td2->cont($message); - } else { - $td2->html( formatReady($eval->getText()) ); - $td2->cont( $br ); - } - $tr2->cont( $td2 ); - $voted = $votedNow || $votedEarlier; - $message = new HTML('div'); - $message->_content = [(string)MessageBox::info(EvalShow::getAnonymousText($eval, $voted))]; - $table2->cont($message); - $message = new HTML('div'); - $message->_content = [(string)EvalShow::getStopdateText( $eval, $voted)]; - $table2->cont($message); - - if(!$voted && $GLOBALS["mandatories"] != 0) { - $message = new HTML('div'); - $message->_content = [(string)sprintf(_("Mit %s gekennzeichnete Fragen müssen beantwortet werden."), - "<b><span class=\"eval_error\">**</span></b>")]; - $table2->cont($message); - } - - - - $td->cont( $table2 ); - $tr->cont( $td ); - - return $tr; - } - - - /** - * createEvaluation: generate the evaluation itself (questions and answers) - * @param the evaluation - * @returns a table row - */ - function createEvaluation( $tree ) { - $tr = new HTM( "tr" ); - $td = new HTM( "td" ); - $td->attr( "class", "table_row_even" ); - $td->html( "<hr noshade=\"noshade\" size=\"1\">\n" ); - - ob_start(); - $tree->showTree(); - $html = ob_get_contents(); - ob_end_clean(); - - $td->html( $html ); - $td->setTextareaCheck(); - $tr->cont( $td ); - - return $tr; - } - - - - /** - * create html for the meta-information about an evaluation. - * @param Object $eval The evaluation - * @param bool $isAssociated whether the current user has used the eval - * @returns String a table row - */ - function createEvalMetaInfo( $eval, $votedNow = NO, $votedEarlier = NO ) { - $html = ""; - $stopdate = $eval->getRealStopdate(); - $number = EvaluationDB::getNumberOfVotes( $eval->getObjectID() ); - $voted = $votedNow || $votedEarlier; - - $html .= "<div align=\"left\" style=\"margin-left:3px; margin-right:3px;\">\n"; - $html .= "<hr noshade=\"noshade\" size=\"1\">\n"; - -# $html .= $votedEarlier ? _("Sie haben an dieser Evaluation bereits teilgenommen.") : ""; -# $html .= $votedNow ? _("Vielen Dank für Ihre Teilnahme.") : ""; -# $html .= $voted ? "<hr noshade=\"noshade\" size=\"1\">\n" : ""; - - /* multiple choice? ----------------------------------------------------- */ -# if ($eval->isMultipleChoice()) { -# $html .= ($voted || $eval->isStopped()) -# ? _("Sie konnten mehrere Antworten auswählen.") -# : _("Sie können mehrere Antworten auswählen."); -# $html .= " \n"; -# } - /* ---------------------------------------------------------------------- */ - - $html .= EvalShow::getNumberOfVotesText( $eval, $voted ); - $html .= "<br>"; - $html .= EvalShow::getAnonymousText( $eval, $voted ); - $html .= "<br>"; - $html .= EvalShow::getStopdateText( $eval, $voted ); - - $html .= "<br>\n"; - $html .= "</div>\n"; - /* ---------------------------------------------------------------------- */ - - /* create html tr object ------------------------------------------------ */ - $tr = new HTM( "tr" ); - $td = new HTM( "td" ); - $td->attr( "align", "left" ); - $td->attr( "style", "font-size:0.8em;" ); - $td->html( $html ); - $tr->cont( $td ); - return $tr; - } - - - function getNumberOfVotesText( $eval, $voted ) { - $stopdate = $eval->getRealStopdate(); - $number = EvaluationDB::getNumberOfVotes( $eval->getObjectID() ); - $html = ""; - - /* Get number of participants ------------------------------------------- */ - if( $stopdate < time() && $stopdate > 0 ) { - if ($number != 1) - $html .= sprintf (_("Es haben insgesamt <b>%s</b> Personen teilgenommen"), $number); - else - $html .= $voted - ? _("Sie waren die einzige Person die teilgenommen hat") - : _("Es hat insgesamt <b>eine</b> Person teilgenommen"); - } - else { - if ($number != 1) - $html .= sprintf (_("Es haben bisher <b>%s</b> Personen teilgenommen"), $number); - else - $html .= $voted - ? _("Sie waren bisher der/die einzige Person die teilgenommen hat") - : _("Es hat bisher <b>eine</b> Person teilgenommen"); - } - /* ---------------------------------------------------------------------- */ - - if ($voted && $number > 1) - $html .= _(", Sie ebenfalls"); - - $html .= ".\n"; - return $html; - } - - function getStopdateText( $eval, $voted ) { - $stopdate = $eval->getRealStopdate(); - $html = ""; - - /* stopdate ------------------------------------------------------------- */ - if (!empty ($stopdate)) { - if( $stopdate < time() ) { - $html .= sprintf (_("Die Evaluation wurde beendet am <b>%s</b> um <b>%s</b> Uhr."), - date ("d.m.Y", $stopdate), - date ("H:i", $stopdate)); - } - else { - if( $voted ) { - $html .= sprintf (_("Die Evaluation wird voraussichtlich beendet am <b>%s</b> um <b>%s</b> Uhr."), - date ("d.m.Y", $stopdate), - date ("H:i", $stopdate)); - } - else { - $html .= sprintf (_("Sie können teilnehmen bis zum <b>%s</b> um <b>%s</b> Uhr."), - date ("d.m.Y", $stopdate), - date ("H:i", $stopdate)); - } - } - } - else { - $html .= _("Der Endzeitpunkt dieser Evaluation steht noch nicht fest."); - } - $html .= " \n"; - - return $html; - } - - function getAnonymousText( $eval, $voted ) { - $stopdate = $eval->getRealStopdate(); - $html = ""; - - /* Is anonymous --------------------------------------------------------- */ - if( ($stopdate < time() && $stopdate > 0) || - $voted ) - $html .= ($eval->isAnonymous()) - ? _("Die Teilnahme war anonym.") - : _("Die Teilnahme war <b>nicht</b> anonym."); - else - $html .= ($eval->isAnonymous()) - ? _("Die Teilnahme ist anonym.") -# : _("Die Teilnahme ist <b>nicht</b> anonym."); - : ("<span style=\"color:red;\">" . - _("Dies ist eine personalisierte Evaluation. Ihre Angaben werden verknüpft mit Ihrem Namen gespeichert.") . - "</span>"); - - return $html; - } - - - /** - * createEvaluationFooter: generate the foot of an evaluation (buttons etc.) - * @param the evaluation - * @returns a table row - */ - function createEvaluationFooter( $eval, $voted, $isPreview ) { - if( $isPreview ) - $voted = YES; - - $br = new HTMpty( "br" ); - - $tr = new HTM( "tr" ); - $td = new HTM( "td" ); - $td->attr( "class", "content_body" ); - $td->attr( "align", "center" ); - $td->attr( "data-dialog-button",""); - $td->cont( $br ); - - /* vote button */ - if( ! $voted ) { - $button = Button::createAccept(_('Abschicken'), - 'voteButton', - ['title' => _('Senden Sie Ihre Antworten hiermit ab.'), 'data-dialog' => '']); - $td->cont( $button ); - } - - /* close button */ - if (!Request::isXHR()) { - $button = new HTM( "p" ); - $button->cont( _("Sie können dieses Fenster jetzt schließen.") ); - $td->cont( $button ); - } - - - /* reload button */ - if( $isPreview ) { - $button = LinkButton::create(_('Aktualisieren'), - URLHelper::getURL('show_evaluation.php?evalID='.$eval->getObjectID().'&isPreview=1'), - ['title' => _('Vorschau aktualisieren.')]); - $td->cont( $button ); - } - - $td->cont( $br ); - $td->cont( $br ); - - $tr->cont( $td ); - - return $tr; - } - - function createVoteButton ($eval) { - $button = LinkButton::create(_('Anzeigen'), - URLHelper::getURL('show_evaluation.php?evalID=' .$eval->getObjectID().'&isPreview=' . NO), - ['title' => _('Evaluation anzeigen.'), - 'onClick' => 'openEval(\''.$eval->getObjectID().'\'); return false;']); - $div = new HTML ("div"); - $div->addHTMLContent( $button ); - return $div; - - // keine Ahnung warum das hier nicht funktioniert, bekomme eine JS-Fehlermeldung :( - - // <grusel> das da oben reicht ja auch :) - - /* - $script = new HTML ("script"); - $script->addAttr ("type", "text/javascript"); - $script->addAttr ("language", "JavaScript"); - - $aScript = new HTML ("a"); - $aScript->addAttr ("href", "javascript:void();"); - $aScript->addAttr ("onClick", - "window.open(\'show_evaluation.php?evalID=".$eval->getObjectID ()."\', ". - "\'_blank\', ". - "\'width=790,height=500,scrollbars=yes,resizable=yes\');"); - $aScript->addContent ("Teilnehmen"); // Eigentlich kommt hier ein button hin - $script->addContent ("document.write ('"); - $script->addContent ($aScript); - $script->addContent ("');"); - - $noscript = new HTML ("noscript"); - $aNoScript = new HTML ("a"); - $aNoScript->addAttr ("href", "show_evaluation.php?evalID=".$eval->getObjectID ()); - $aNoScript->addAttr ("target", "_blank"); - $aNoScript->addContent ("Teilnehmen"); // Eigentlich kommt hier ein button hin - $noscript->addContent ($aNoScript); - - $div = new HTML ("div"); - $div->addContent ($script); - $div->addContent ($noscript); - $tr = new HTML ("tr"); - $td = new HTML ("td"); - $td->addContent($script); - $td->addContent($noscript); - $tr->addContent($td); - return $tr; - */ - } - - function createEditButton ($eval) { - return LinkButton::create(_('Bearbeiten'), - URLHelper::getURL(EVAL_FILE_ADMIN."?page=edit&evalID=".$eval->getObjectID()), - ['title' => _('Evaluation bearbeiten.')]); - } - - function createOverviewButton ($rangeID, $evalID) { - return LinkButton::create(_('Bearbeiten'), - URLHelper::getURL(EVAL_FILE_ADMIN."?rangeID=".$rangeID."&openID=".$evalID."#open"), - ['title' => _('Evaluationsverwaltung.')]); - } - - function createDeleteButton ($eval) { - return LinkButton::create(_('Löschen'), - URLHelper::getURL(EVAL_FILE_ADMIN."?evalAction=delete_request&evalID=".$eval->getObjectID ()), - ['title' => _('Evaluation löschen.')]); - } - - function createStopButton ($eval) { - return LinkButton::createCancel(_('Stop'), - URLHelper::getURL(EVAL_FILE_ADMIN."?evalAction=stop&evalID=".$eval->getObjectID ()), - ['title' => _('Evaluation stoppen.')]); - } - - function createContinueButton ($eval) { - return LinkButton::create(_('Fortsetzen'), - URLHelper::getURL(EVAL_FILE_ADMIN."?evalAction=continue&evalID=".$eval->getObjectID ()), - ['title' => _('Evaluation fortsetzen')]); - } - - function createExportButton ($eval) { - return LinkButton::create(_('Export'), - URLHelper::getURL(EVAL_FILE_ADMIN."?evalAction=export_request&evalID=".$eval->getObjectID ()), - ['title' => _('Evaluation exportieren.')]); - } - - function createReportButton($eval) { - return LinkButton::create(_('Auswertung'), URLHelper::getURL("eval_summary.php?eval_id=" . $eval->getObjectID()), ['title' => _('Auswertung')]); - } - - /* ----------------------------------------------------------------------- */ -} - -# Define constants ========================================================== # -# ===================================================== end: define constants # - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once HTML; -require_once EVAL_LIB_COMMON; -# ====================================================== end: including files # diff --git a/lib/functions.php b/lib/functions.php index 7d9f4f2defba00312b50ba76e729a0bf19d1a881..6b006084e77189673e022a88c4e021eba5e06d3a 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -849,7 +849,7 @@ function search_range($search_str = false, $search_user = false, $show_sem = tru } } } elseif ($GLOBALS['perm']->have_perm('tutor') || $GLOBALS['perm']->have_perm('autor')) { - // autors my also have evaluations and news in studygroups with proper rights + // autors my also have news in studygroups with proper rights $_hidden = _('(versteckt)'); $query = "SELECT s.Seminar_id, IF(s.visible = 0, CONCAT(s.Name, ' {$_hidden}'), s.Name) AS Name %s FROM seminar_user AS a diff --git a/lib/include/header.php b/lib/include/header.php index e7a4ea8e293b2408e2302f70018069fce182c326..81281ac352c6298cd0fda572549921e40eb26a0e 100644 --- a/lib/include/header.php +++ b/lib/include/header.php @@ -24,7 +24,7 @@ * Bei Nutzung dieser Funktion unbedingt die Texte unter locale/de/LC_HELP/visibility_decision.php bzw. * locale/en/LC_HELP/visibility_decision.php an die lokalen Verhältnisse anpassen! */ -if (PageLayout::isHeaderEnabled()) //Einige Seiten benötigen keinen Header, sprich Navigation (Evaluation usw.) +if (PageLayout::isHeaderEnabled()) //Einige Seiten benötigen keinen Header, sprich Navigation { $header_template = $GLOBALS['template_factory']->open('header'); $header_template->current_page = PageLayout::getTitle(); diff --git a/lib/models/StudipEvaluation.php b/lib/models/StudipEvaluation.php deleted file mode 100644 index 5441db82f51489771368a0c393d221582dc83323..0000000000000000000000000000000000000000 --- a/lib/models/StudipEvaluation.php +++ /dev/null @@ -1,90 +0,0 @@ -<?php -/** - * Evaluation.php - * model class for table Evaluation - * - * 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 Florian Bieringer <florian.bieringer@uni-passau.de> - * @copyright 2014 Stud.IP Core-Group - * @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2 - * @category Stud.IP - * @since 3.0 - * - * @property string $id alias column for eval_id - * @property string $eval_id database column - * @property string $author_id database column - * @property string $title database column - * @property string $text database column - * @property int|null $startdate database column - * @property int|null $stopdate database column - * @property int|null $timespan database column - * @property int $mkdate database column - * @property int $chdate database column - * @property int $anonymous database column - * @property int $visible database column - * @property int $shared database column - * @property User $author belongs_to User - * @property SimpleORMapCollection|User[] $participants has_and_belongs_to_many User - * @property mixed $enddate additional field - */ -class StudipEvaluation extends SimpleORMap -{ - protected static function configure($config = []) - { - $config['db_table'] = 'eval'; - - $config['belongs_to']['author'] = [ - 'class_name' => User::class, - 'foreign_key' => 'author_id' - ]; - $config['has_and_belongs_to_many']['participants'] = [ - 'class_name' => User::class, - 'thru_table' => 'eval_user' - ]; - - $config['additional_fields']['enddate'] = true; - - parent::configure($config); - } - - /** - * Fetches all evaluations for a specific range_id - * - * @param String $range_id the range id - * @return Array All evaluations for that range - */ - public static function findByRange_id($range_id) - { - return self::findThru($range_id, [ - 'thru_table' => 'eval_range', - 'thru_key' => 'range_id', - 'thru_assoc_key' => 'eval_id', - 'assoc_foreign_key' => 'eval_id' - ]); - } - - /** - * Returns the enddate of a evaluation. Returns null if stop is manual - * - * @return stopdate or null - */ - public function getEnddate() - { - if ($this->stopdate) { - return $this->stopdate; - } - if ($this->timespan) { - return $this->startdate + $this->timespan; - } - return null; - } - - function getNumberOfVotes () - { - return DBManager::get()->fetchColumn("SELECT count(DISTINCT user_id) FROM eval_user WHERE eval_id = ?", [$this->id]); - } -} diff --git a/lib/models/User.class.php b/lib/models/User.class.php index ab92bade91297faddc679da133943db30ffa9e12..b71464cf3d2e79dc9ba48ed4cf6bcf0ef79ce9d8 100644 --- a/lib/models/User.class.php +++ b/lib/models/User.class.php @@ -812,9 +812,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject, Studip\Calendar\ $activeVotes = []; $stoppedVotes = []; } - // Evaluations - $evalDB = new EvaluationDB(); - $activeEvals = $evalDB->getEvaluationIDs($this->id, EVAL_STATE_ACTIVE); + // Free datafields $data_fields = DataFieldEntry::getDataFieldEntries($this->id, 'user'); @@ -891,7 +889,7 @@ class User extends AuthUserMd5 implements Range, PrivacyObject, Studip\Calendar\ 'identifier' => 'commondata' ]; } - if (Config::get()->VOTE_ENABLE && ($activeVotes || $stoppedVotes || $activeEvals) && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['votes'])) { + if (Config::get()->VOTE_ENABLE && ($activeVotes || $stoppedVotes) && empty($GLOBALS['NOT_HIDEABLE_FIELDS'][$this->perms]['votes'])) { $homepage_elements['votes'] = [ 'name' => _('Fragebögen'), 'visibility' => $homepage_visibility['votes'] ?? get_default_homepage_visibility($this->id), @@ -1228,20 +1226,6 @@ class User extends AuthUserMd5 implements Range, PrivacyObject, Studip\Calendar\ $statement = DBManager::get()->prepare($query); $statement->execute([$new_id, $old_id]); - // Evaluationen - $query = "UPDATE IGNORE eval SET author_id = ? WHERE author_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$new_id, $old_id]); - - self::removeDoubles('eval_user', 'eval_id', $new_id, $old_id); - $query = "UPDATE IGNORE eval_user SET user_id = ? WHERE user_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$new_id, $old_id]); - - $query = "UPDATE IGNORE evalanswer_user SET user_id = ? WHERE user_id = ?"; - $statement = DBManager::get()->prepare($query); - $statement->execute([$new_id, $old_id]); - // Kategorien $query = "UPDATE IGNORE kategorien SET range_id = ? WHERE range_id = ?"; $statement = DBManager::get()->prepare($query); diff --git a/lib/modules/CoreAdmin.class.php b/lib/modules/CoreAdmin.class.php index 948809cf51424e9f280cca629770bf699fe7399e..4bf1880561d1a6158c7e2146f6cda34a80b9e07b 100644 --- a/lib/modules/CoreAdmin.class.php +++ b/lib/modules/CoreAdmin.class.php @@ -80,12 +80,6 @@ class CoreAdmin extends CorePlugin implements StudipModule $item->setDescription(_('Erstellen und bearbeiten von Fragebögen.')); $navigation->addSubNavigation('questionnaires', $item); } - if (Config::get()->EVAL_ENABLE) { - $item = new Navigation(_('Evaluationen'), 'admin_evaluation.php?view=eval_sem'); - $item->setImage(Icon::create('evaluation')); - $item->setDescription(_('Richten Sie fragebogenbasierte Umfragen und Lehrevaluationen ein.')); - $navigation->addSubNavigation('evaluation', $item); - } } /* diff --git a/lib/modules/CoreStudygroupAdmin.class.php b/lib/modules/CoreStudygroupAdmin.class.php index d31139066f6af5ee22976644edb957830040b140..d299adf14834b43a6e340554c0d36bc35f7e6f7d 100644 --- a/lib/modules/CoreStudygroupAdmin.class.php +++ b/lib/modules/CoreStudygroupAdmin.class.php @@ -43,10 +43,6 @@ class CoreStudygroupAdmin extends CorePlugin implements StudipModule $item = new Navigation(_('Fragebögen'), 'dispatch.php/questionnaire/courseoverview'); $item->setDescription(_('Erstellen und bearbeiten von Fragebögen.')); $navigation->addSubNavigation('questionnaires', $item); - - $item = new Navigation(_('Evaluationen'), 'admin_evaluation.php?view=eval_sem'); - $item->setDescription(_('Richten Sie fragebogenbasierte Umfragen und Lehrevaluationen ein.')); - $navigation->addSubNavigation('evaluation', $item); } return ['admin' => $navigation]; } diff --git a/lib/modules/EvaluationsWidget.php b/lib/modules/EvaluationsWidget.php index 64458d98dde07afc8f611d195bf3a2d34e8729c1..dab271f932a6efd91e29e9e568335862a1a08937 100644 --- a/lib/modules/EvaluationsWidget.php +++ b/lib/modules/EvaluationsWidget.php @@ -45,13 +45,7 @@ class EvaluationsWidget extends CorePlugin implements PortalPlugin // include and show votes and tests $controller = app(AuthenticatedController::class, ['dispatcher' => app(\Trails_Dispatcher::class)]); $controller->suppress_empty_output = true; - - if (Config::get()->EVAL_ENABLE) { - $response = $controller->relay('evaluation/display/studip')->body; - } - - $controller->suppress_empty_output = (bool)$response; - $response .= $controller->relay('questionnaire/widget/start')->body; + $response = $controller->relay('questionnaire/widget/start')->body; $template = $GLOBALS['template_factory']->open('shared/string'); $template->content = $response; diff --git a/lib/navigation/AdminNavigation.php b/lib/navigation/AdminNavigation.php index 8e86e0452aa9d85a6a3cc295455f56f761afc90a..a1762c6742522be7db7b97682007c8ea77cef950 100644 --- a/lib/navigation/AdminNavigation.php +++ b/lib/navigation/AdminNavigation.php @@ -75,9 +75,6 @@ class AdminNavigation extends Navigation $navigation->addSubNavigation('faculty', new Navigation(_('Mitarbeiter'), 'dispatch.php/institute/members?admin_view=1')); $navigation->addSubNavigation('groups', new Navigation(_('Funktionen / Gruppen'), 'dispatch.php/admin/statusgroups?type=inst')); - if (Config::get()->EVAL_ENABLE) { - $navigation->addSubNavigation('evaluation', new Navigation(_('Evaluationen'), 'admin_evaluation.php?view=eval_inst')); - } if (Config::get()->EXTERN_ENABLE) { $navigation->addSubNavigation('external', new Navigation(_('Externe Seiten'), 'dispatch.php/institute/extern')); diff --git a/lib/navigation/ContentsNavigation.php b/lib/navigation/ContentsNavigation.php index 821d3ad2bf5d7815290c5b97f77f3d5738114548..f6190e2f3e90cf10c2bd0ce690ea3b33df8e830d 100644 --- a/lib/navigation/ContentsNavigation.php +++ b/lib/navigation/ContentsNavigation.php @@ -124,13 +124,6 @@ class ContentsNavigation extends Navigation } } - if (Config::get()->EVAL_ENABLE) { - $eval = new Navigation(_('Evaluationen'), 'admin_evaluation.php', ['rangeID' => $GLOBALS['user']->username]); - $eval->setImage(Icon::create('test')); - $eval->setDescription(_('Erstellen Sie komplexe Befragungen')); - $this->addSubNavigation('evaluation', $eval); - } - // elearning if (Config::get()->ELEARNING_INTERFACE_ENABLE) { $elearning = new Navigation(_('Lernmodule'), 'dispatch.php/elearning/my_accounts'); diff --git a/lib/navigation/StartNavigation.php b/lib/navigation/StartNavigation.php index 913f3faad48e996a8834611a3e95c4837901926b..acd5ee32d607e19af3da9bcdae17bf19f5abf7f6 100644 --- a/lib/navigation/StartNavigation.php +++ b/lib/navigation/StartNavigation.php @@ -231,9 +231,6 @@ class StartNavigation extends Navigation if (Config::get()->VOTE_ENABLE) { $navigation->addSubNavigation('questionnaire', new Navigation(_('Ankündigungen'), 'dispatch.php/news/admin_news')); } - if (Config::get()->EVAL_ENABLE) { - $navigation->addSubNavigation('evaluation', new Navigation(_('Evaluationen'), 'admin_evaluation.php', ['rangeID' => $auth->auth['uname']])); - } // elearning if (Config::get()->ELEARNING_INTERFACE_ENABLE) { diff --git a/lib/object.inc.php b/lib/object.inc.php index 5f231da6de6ee41a48c746055d8e1b24fb444e0f..c23efa45380a24e822cb786af764b3dbedb7d4b3 100644 --- a/lib/object.inc.php +++ b/lib/object.inc.php @@ -354,7 +354,6 @@ function object_type_to_id($type) 'inst'=> 0, 'basicdata' => 0, 'vote' => -1, - 'eval' => -2, 'news' => 'CoreOverview', 'documents' => 'CoreDocuments', 'schedule' => 'CoreSchedule', @@ -393,7 +392,6 @@ function object_id_to_type($id) 'inst'=> 0, 'basicdata' => 0, 'vote' => -1, - 'eval' => -2, 'news' => 'CoreOverview', 'documents' => 'CoreDocuments', 'schedule' => 'CoreSchedule', diff --git a/public/admin_evaluation.php b/public/admin_evaluation.php deleted file mode 100644 index bee8ccece17186177d4e1759acccc74a205e2fe6..0000000000000000000000000000000000000000 --- a/public/admin_evaluation.php +++ /dev/null @@ -1,120 +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'); - if ($GLOBALS['perm']->have_studip_perm('admin', Context::getId())) { - // Ensure the select widget is added last - NotificationCenter::on('SidebarWillRender', function () { - $widget = new CourseManagementSelectWidget(); - Sidebar::get()->addWidget($widget); - }); - } -} 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/eval_config.php b/public/eval_config.php deleted file mode 100644 index d06468805df02d7a778cb91efada28eb727e86ef..0000000000000000000000000000000000000000 --- 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 cbd6036d6cb9afc220d2551537bb591e50fad008..0000000000000000000000000000000000000000 --- 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 77b349a89c1ff413d7700542dddb725fb555068b..0000000000000000000000000000000000000000 --- 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/show_evaluation.php b/public/show_evaluation.php deleted file mode 100644 index e81510a3a0acd28ad90f94096f94dbe990924061..0000000000000000000000000000000000000000 --- 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/resources/assets/stylesheets/scss/evaluation.scss b/resources/assets/stylesheets/scss/evaluation.scss deleted file mode 100644 index 63fcef657b5b1019c01794446ee6e83e0a2a4129..0000000000000000000000000000000000000000 --- a/resources/assets/stylesheets/scss/evaluation.scss +++ /dev/null @@ -1,40 +0,0 @@ -/* classes for the evaluation modules in Stud.IP ---------------------------- */ -.eval_title { - font-size: 1.2em; - font-weight: bold; - color: var(--base-color); -} - -.eval_error { - color: var(--red); -} - -.eval_success { - color: var(--green); -} - -.eval_info { - color: var(--base-gray); -} - -.eval_metainfo { - font-size: 0.8em; -} - -.eval_highlight { - background-color: var(--content-color-60); -} - -.eval_gray { - background: var(--dark-gray-color-20) none; -} -.evaluation_item { - box-sizing: border-box; - margin: 3px; -} - -h3.eval { - font-size: 1.3em; - color: var(--black); - font-weight: bold; -} diff --git a/resources/assets/stylesheets/studip.scss b/resources/assets/stylesheets/studip.scss index d19621a586ea5772927b4abf2f3adfb3205289fd..037aad4509bc4915a7f204c2d8a6dbd4e5b8c174 100644 --- a/resources/assets/stylesheets/studip.scss +++ b/resources/assets/stylesheets/studip.scss @@ -42,7 +42,6 @@ @import "scss/documents"; @import "scss/drag-handle"; @import "scss/enrolment"; -@import "scss/evaluation"; @import "scss/files"; @import "scss/feedback"; @import "scss/forms"; diff --git a/templates/evaluation/config.php b/templates/evaluation/config.php deleted file mode 100644 index e328cf66193ff8872a48c0b3b061cc47a248358d..0000000000000000000000000000000000000000 --- a/templates/evaluation/config.php +++ /dev/null @@ -1,125 +0,0 @@ -<? -# Lifter010: TODO - -use Studip\Button, Studip\LinkButton, Studip\ResetButton; - -$options = [ - 'show_total_stats' => _('Zeige Gesamtstatistik an'), - 'show_graphics' => _('Zeige Grafiken an'), - 'show_questions' => _('Zeige Fragen an'), - 'show_group_headline' => _('Zeige Gruppenüberschriften an'), - 'show_questionblock_headline' => _('Zeige Fragenblocküberschriften an'), -]; - -$graphtypes = [ - 'polscale_gfx_type' => [ - 'title' => _('Grafiktyp für Polskalen'), - 'options' => [ - 'bars' => _('Balken'), - 'pie' => _('Tortenstücke'), - 'lines' => _('Linien'), - 'linepoints' => _('Linienpunkte'), - 'area' => _('Bereich'), - 'points' => _('Punkte'), - 'thinbarline' => _('Linienbalken'), - ], - ], - 'likertscale_gfx_type' => [ - 'title' => _('Grafiktyp für Likertskalen'), - 'options' => [ - 'bars' => _('Balken'), - 'pie' => _('Tortenstücke'), - 'lines' => _('Linien'), - 'linepoints' => _('Linienpunkte'), - 'area' => _('Bereich'), - 'points' => _('Punkte'), - 'thinbarline' => _('Linienbalken'), - ], - ], - 'mchoice_scale_gfx_type' => [ - 'title' => _('Grafiktyp für Multiplechoice'), - 'options' => [ - 'bars' => _('Balken'), - 'points' => _('Punkte'), - 'thinbarline' => _('Linienbalken'), - ], - ], -]; -?> - -<form class="default" action="<?= URLHelper::getLink() ?>" method="post"> - <?= CSRFProtection::tokenTag() ?> - - <input type="hidden" name="template_id" value="<?= $templates['template_id'] ?>"> - <input type="hidden" name="eval_id" value="<?= $eval_id ?>"> - - <table class="default"> - <caption> - <?= _('Auswertungskonfiguration') ?> - </caption> - <colgroup> - <col width="50%"> - <col width="25%"> - <col width="25%"> - </colgroup> - <thead> - <tr> - <th><?= _('Optionen') ?></th> - <th style="text-align: center;"><?= _('Ja') ?></th> - <th style="text-align: center;"><?= _('Nein') ?></th> - </tr> - </thead> - <tbody> - <? foreach ($options as $option => $title): ?> - <tr> - <td><?= htmlReady($title) ?>:</td> - <td style="text-align: center;"> - <input type="radio" name="<?= $option ?>" value="1" - <? if ($templates[$option] || !$has_template) echo 'checked'; ?>> - </td> - <td style="text-align: center;"> - <input type="radio" name="<?= $option ?>" value="0" - <? if ($has_template && !$templates[$option]) echo 'checked'; ?>> - </td> - </tr> - <? endforeach; ?> - - <? foreach ($graphtypes as $type => $data): ?> - <tr> - <td> - <label for="<?= $type ?>"><?= htmlReady($data['title']) ?>:</label> - </td> - <td style="text-align: center;" colspan="2"> - <select class="size-s" id="<?= $type ?>" name="<?= $type ?>" style="120px"> - <? foreach ($data['options'] as $k => $v): ?> - <option value="<?= htmlReady($k) ?>" - <? if ($templates[$type] == $k) echo "selected"; ?>> - <?= htmlReady($v) ?> - </option> - <? endforeach; ?> - </select> - </td> - </tr> - <? endforeach; ?> - </tbody> - - <tfoot> - <tr> - <td> - <?= LinkButton::create('<< ' . _('Zurück'), - URLHelper::getURL('eval_summary.php', compact('eval_id'))) ?> - </td> - <td colspan="2" style="text-align: right;"> - <?= Button::createAccept(_('Speichern'), 'store') ?> - <?= ResetButton::createCancel(_('Zurücksetzen')) ?> - </td> - </tr> - </tfoot> - </table> -</form> - -<? -Helpbar::Get()->addPlainText(_('Information'), _('Auf dieser Seite können Sie die Auswertung Ihrer Evaluation konfigurieren.')); -Helpbar::Get()->addPlainText(_('Information'), ('Wählen Sie Ihre Einstellungen und drücken Sie auf "Template speichern". ' - .'Anschließend kommen Sie mit dem Button unten links zurück zu Ihrer Evaluation.')); -?>