From 0f1d1b14280562f5ff6a64d103979204d8d2a22d Mon Sep 17 00:00:00 2001 From: David Siegfried Date: Wed, 15 May 2024 13:57:30 +0000 Subject: remove old evaluation, fixes #3787 Closes #3787 Merge request studip/studip!2661 --- app/controllers/admin/user.php | 4 - app/controllers/course/overview.php | 2 - app/controllers/evaluation.php | 61 - app/controllers/institute/overview.php | 3 - app/controllers/profile.php | 3 - app/controllers/vote.php | 94 - app/views/course/overview/index.php | 5 - app/views/evaluation/_actions.php | 4 - app/views/evaluation/_admin_list_vote.php | 27 - app/views/evaluation/_buttons.php | 22 - app/views/evaluation/_evaluation.php | 57 - app/views/evaluation/display.php | 27 - app/views/institute/overview/index.php | 1 - app/views/profile/index.php | 2 - app/views/siteinfo/help.php | 1 - composer.json | 1 - composer.lock | 41 +- db/migrations/6.0.5_remove_old_evaluation.php | 33 + lib/bootstrap-autoload.php | 2 - lib/classes/MyRealmModel.php | 35 +- lib/classes/Privacy.php | 1 - lib/classes/Siteinfo.php | 4 - lib/classes/UserManagement.class.php | 2 - lib/evaluation/classes/Evaluation.class.php | 539 ---- lib/evaluation/classes/EvaluationAnswer.class.php | 277 -- .../classes/EvaluationExportManager.class.php | 267 -- .../classes/EvaluationExportManagerCSV.class.php | 341 -- lib/evaluation/classes/EvaluationGroup.class.php | 193 -- lib/evaluation/classes/EvaluationObject.class.php | 530 ---- .../classes/EvaluationQuestion.class.php | 179 -- lib/evaluation/classes/EvaluationTree.class.php | 166 - .../classes/EvaluationTreeEditView.class.php | 3245 -------------------- .../classes/EvaluationTreeShowUser.class.php | 539 ---- lib/evaluation/classes/HTML.class.php | 185 -- lib/evaluation/classes/HTMLempty.class.php | 184 -- lib/evaluation/classes/LazyHTML.class.php | 71 - .../classes/db/EvaluationAnswerDB.class.php | 284 -- lib/evaluation/classes/db/EvaluationDB.class.php | 291 -- .../classes/db/EvaluationGroupDB.class.php | 225 -- .../classes/db/EvaluationObjectDB.class.php | 365 --- .../classes/db/EvaluationQuestionDB.class.php | 298 -- lib/evaluation/evaluation.config.php | 157 - lib/evaluation/evaluation.lib.php | 246 -- lib/evaluation/evaluation_admin_edit.inc.php | 210 -- lib/evaluation/evaluation_admin_edit.lib.php | 97 - lib/evaluation/evaluation_admin_overview.inc.php | 391 --- lib/evaluation/evaluation_admin_overview.lib.php | 2215 ------------- lib/evaluation/evaluation_admin_template.inc.php | 655 ---- lib/evaluation/evaluation_admin_template.lib.php | 1102 ------- lib/evaluation/evaluation_show.lib.php | 417 --- lib/functions.php | 2 +- lib/include/header.php | 2 +- lib/models/StudipEvaluation.php | 90 - lib/models/User.class.php | 20 +- lib/modules/CoreAdmin.class.php | 6 - lib/modules/CoreStudygroupAdmin.class.php | 4 - lib/modules/EvaluationsWidget.php | 8 +- lib/navigation/AdminNavigation.php | 3 - lib/navigation/ContentsNavigation.php | 7 - lib/navigation/StartNavigation.php | 3 - lib/object.inc.php | 2 - public/admin_evaluation.php | 120 - public/eval_config.php | 140 - public/eval_summary.php | 610 ---- public/eval_summary_export.php | 699 ----- public/show_evaluation.php | 272 -- resources/assets/stylesheets/scss/evaluation.scss | 40 - resources/assets/stylesheets/studip.scss | 1 - templates/evaluation/config.php | 125 - 69 files changed, 40 insertions(+), 16215 deletions(-) delete mode 100644 app/controllers/evaluation.php delete mode 100644 app/controllers/vote.php delete mode 100644 app/views/evaluation/_actions.php delete mode 100644 app/views/evaluation/_admin_list_vote.php delete mode 100644 app/views/evaluation/_buttons.php delete mode 100644 app/views/evaluation/_evaluation.php delete mode 100644 app/views/evaluation/display.php create mode 100644 db/migrations/6.0.5_remove_old_evaluation.php delete mode 100644 lib/evaluation/classes/Evaluation.class.php delete mode 100644 lib/evaluation/classes/EvaluationAnswer.class.php delete mode 100644 lib/evaluation/classes/EvaluationExportManager.class.php delete mode 100644 lib/evaluation/classes/EvaluationExportManagerCSV.class.php delete mode 100644 lib/evaluation/classes/EvaluationGroup.class.php delete mode 100644 lib/evaluation/classes/EvaluationObject.class.php delete mode 100644 lib/evaluation/classes/EvaluationQuestion.class.php delete mode 100644 lib/evaluation/classes/EvaluationTree.class.php delete mode 100644 lib/evaluation/classes/EvaluationTreeEditView.class.php delete mode 100644 lib/evaluation/classes/EvaluationTreeShowUser.class.php delete mode 100644 lib/evaluation/classes/HTML.class.php delete mode 100644 lib/evaluation/classes/HTMLempty.class.php delete mode 100644 lib/evaluation/classes/LazyHTML.class.php delete mode 100644 lib/evaluation/classes/db/EvaluationAnswerDB.class.php delete mode 100644 lib/evaluation/classes/db/EvaluationDB.class.php delete mode 100644 lib/evaluation/classes/db/EvaluationGroupDB.class.php delete mode 100644 lib/evaluation/classes/db/EvaluationObjectDB.class.php delete mode 100644 lib/evaluation/classes/db/EvaluationQuestionDB.class.php delete mode 100644 lib/evaluation/evaluation.config.php delete mode 100644 lib/evaluation/evaluation.lib.php delete mode 100644 lib/evaluation/evaluation_admin_edit.inc.php delete mode 100644 lib/evaluation/evaluation_admin_edit.lib.php delete mode 100644 lib/evaluation/evaluation_admin_overview.inc.php delete mode 100644 lib/evaluation/evaluation_admin_overview.lib.php delete mode 100644 lib/evaluation/evaluation_admin_template.inc.php delete mode 100644 lib/evaluation/evaluation_admin_template.lib.php delete mode 100644 lib/evaluation/evaluation_show.lib.php delete mode 100644 lib/models/StudipEvaluation.php delete mode 100644 public/admin_evaluation.php delete mode 100644 public/eval_config.php delete mode 100644 public/eval_summary.php delete mode 100644 public/eval_summary_export.php delete mode 100644 public/show_evaluation.php delete mode 100644 resources/assets/stylesheets/scss/evaluation.scss delete mode 100644 templates/evaluation/config.php diff --git a/app/controllers/admin/user.php b/app/controllers/admin/user.php index 70dfdf1..214c290 100644 --- a/app/controllers/admin/user.php +++ b/app/controllers/admin/user.php @@ -1447,10 +1447,6 @@ class Admin_UserController extends AuthenticatedController '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) FROM (file_refs INNER JOIN files ON file_refs.file_id = files.id) diff --git a/app/controllers/course/overview.php b/app/controllers/course/overview.php index 96e7f5a..402137e 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 4a157a9..0000000 --- a/app/controllers/evaluation.php +++ /dev/null @@ -1,61 +0,0 @@ -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 66d55e1..3713dcc 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 a4e7c56a..3fa3777 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 19f92a2..0000000 --- a/app/controllers/vote.php +++ /dev/null @@ -1,94 +0,0 @@ -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 39d801d..4e69b4a 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 e702ff2..0000000 --- a/app/views/evaluation/_actions.php +++ /dev/null @@ -1,4 +0,0 @@ -asImg() ?> -asImg() ?> -asImg() ?> -asImg() ?> diff --git a/app/views/evaluation/_admin_list_vote.php b/app/views/evaluation/_admin_list_vote.php deleted file mode 100644 index a98335b..0000000 --- a/app/views/evaluation/_admin_list_vote.php +++ /dev/null @@ -1,27 +0,0 @@ - - - - title) ?> - - - author) ?> - - - startdate) ?> - - - stopdate): ?> - stopdate) ?> - - timespan): ?> - startdate + $vote->timespan) ?> - - - - - - - render_partial("vote/_actions.php", ['vote' => $vote]) ?> - - - \ 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 b5a3b33..0000000 --- a/app/views/evaluation/_buttons.php +++ /dev/null @@ -1,22 +0,0 @@ -showResult($vote)): ?> - isRunning() && !$nobody) : ?> - $vote->id]) ?> - - id, ['preview[]' => $vote->id])) ?> - - id, ['preview' => 0])) ?> - id, ['preview[]' => $vote->id, 'sort' => 0])) - : Studip\LinkButton::create(_('Sortieren'), ContentBoxHelper::href($vote->id, ['preview[]' => $vote->id, 'sort' => 1])) - ?> - changeable && $vote->state == 'active' && !$nobody): ?> - id, ['change' => 1])) ?> - - anonymous && ($admin || $vote->namesvisibility)): ?> - id) : ?> - id, ['revealNames' => null])) ?> - - id, ['revealNames' => $vote->id])); ?> - - - \ 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 82c6fd1..0000000 --- a/app/views/evaluation/_evaluation.php +++ /dev/null @@ -1,57 +0,0 @@ -chdate >= object_get_visit($evaluation->id, 'eval', false, false)) && ($evaluation->author_id != $GLOBALS['user']->id); -?> -
-
-

- - title) ?> - -

- -
-
- text); ?> -
-
- $evaluation->id]), ['data-dialog' => '', 'target' => '_blank']) ?> -
-
-

- : getNumberOfVotes() ?> -

-

- : anonymous ? _('Ja') : _('Nein') ?> -

-

- : enddate ? strftime('%d.%m.%y, %H:%M', $evaluation->enddate) : _('Unbekannt') ?> -

-
-
diff --git a/app/views/evaluation/display.php b/app/views/evaluation/display.php deleted file mode 100644 index 35d3178..0000000 --- a/app/views/evaluation/display.php +++ /dev/null @@ -1,27 +0,0 @@ - -
-
-

- asImg(); ?> - -

- -
- - -
- -
- - - render_partial('evaluation/_evaluation.php', ['evaluation' => $evaluation]); ?> - - -
- diff --git a/app/views/institute/overview/index.php b/app/views/institute/overview/index.php index cb347b0..3e80f98 100644 --- a/app/views/institute/overview/index.php +++ b/app/views/institute/overview/index.php @@ -50,7 +50,6 @@ - - - diff --git a/app/views/siteinfo/help.php b/app/views/siteinfo/help.php index 54d0d09..e2a6762 100644 --- a/app/views/siteinfo/help.php +++ b/app/views/siteinfo/help.php @@ -59,7 +59,6 @@
  • news
  • vote
  • test
  • -
  • evaluation
  • wiki_pages
  • lernmodul
  • resource
  • diff --git a/composer.json b/composer.json index 18ffadb..6a1190c 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 d47ed8c..95d389a 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", @@ -191,45 +191,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", "source": { 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 0000000..ff1a26e --- /dev/null +++ b/db/migrations/6.0.5_remove_old_evaluation.php @@ -0,0 +1,33 @@ +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 21219fd..1f3f6d4 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 94bb30d..ab9aa20 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,7 +477,7 @@ 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) ( @@ -514,10 +485,6 @@ class MyRealmModel 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` JOIN `plugins` ON (`pluginclassname` = 'CoreOverview') diff --git a/lib/classes/Privacy.php b/lib/classes/Privacy.php index 38e6e80..0ba296a 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 247b836..9043ce3 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 e3d9aa3..7805594 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 5f269a7..0000000 --- a/lib/evaluation/classes/Evaluation.class.php +++ /dev/null @@ -1,539 +0,0 @@ - - * - * @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 0116e3b..0000000 --- a/lib/evaluation/classes/EvaluationAnswer.class.php +++ /dev/null @@ -1,277 +0,0 @@ - - * @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() . "
    \n"; - } -} diff --git a/lib/evaluation/classes/EvaluationExportManager.class.php b/lib/evaluation/classes/EvaluationExportManager.class.php deleted file mode 100644 index 0c88e7f..0000000 --- a/lib/evaluation/classes/EvaluationExportManager.class.php +++ /dev/null @@ -1,267 +0,0 @@ - - * - * @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 4baa3f8..0000000 --- a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php +++ /dev/null @@ -1,341 +0,0 @@ - - * - * @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 fbe84af..0000000 --- a/lib/evaluation/classes/EvaluationGroup.class.php +++ /dev/null @@ -1,193 +0,0 @@ - - * @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 e42dfb0..0000000 --- a/lib/evaluation/classes/EvaluationObject.class.php +++ /dev/null @@ -1,530 +0,0 @@ - - * @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 ""; - $i = 0; - while ($child = $this->getNextChild ()) { - echo ""; - } - echo "
    "; - echo "Typ: ".$this->x_instanceof ()."
    "; - echo "ObjectID: ".$this->getObjectID ()."
    "; - echo "ParentID: ".$this->getParentID ()."
    "; - echo "ParentObject: ".$this->getParentObject ()."
    "; - echo "Author: ".$this->getAuthorID ()."
    "; - echo "Titel: ".$this->getTitle ()."
    "; - echo "Text: ".$this->getText ()."
    "; - echo "Position: ".$this->getPosition ()."
    "; - echo "Untergruppen: ".$this->getNumberChildren ()."
    "; - echo "
    "; - $i++; - echo "Kind $i"."
    "; - $child->toString (); - echo "
    "; - } -# ==================================================== end: private functions # - -} - -?> diff --git a/lib/evaluation/classes/EvaluationQuestion.class.php b/lib/evaluation/classes/EvaluationQuestion.class.php deleted file mode 100644 index c3c1da3..0000000 --- a/lib/evaluation/classes/EvaluationQuestion.class.php +++ /dev/null @@ -1,179 +0,0 @@ - - * @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 a369d69..0000000 --- a/lib/evaluation/classes/EvaluationTree.class.php +++ /dev/null @@ -1,166 +0,0 @@ -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 3bfe92a..0000000 --- a/lib/evaluation/classes/EvaluationTreeEditView.class.php +++ /dev/null @@ -1,3245 +0,0 @@ - - * @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 = "\n"; - - if ($this->startItemID != ROOT_BLOCK) { - - $html .= " \n" - . " \n" - . " \n"; - } - # display the infos when moving a block =================================== # - - if ($this->moveItemID) { - - $html .= " \n"; -# . " \n" - $html .= " \n"; - } - # ============================= END: display the infos when moving a block # - - $html .= " \n" - . " \n" - . " \n" - . "
    moveItemID) ? "1" : "1"; - $html .= "\"" - . ">\n" - . $this->getEvalPath() -# . "\n" - . "
    " -# . "" -# . "\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 %s 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 %s 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("

    " - . _("Oder wollen Sie die Aktion abbrechen?") - . " " - . LinkButton::createCancel(_('Abbrechen'), - $this->getSelf('abbort_move=1'))); - - $td->addContent($font); - $tr->addContent($td); - $table->addContent($tr); - - $html .= "
    " . $table->createContent() . "
    "; - - $html .= "
    moveItemID) ? "1" : "1"; - $html .= "\"" - . ">\n"; - - if (!$this->startItemID != ROOT_BLOCK) { - $html .= "\n"; - } - - $html .= $this->showTree($this->startItemID, 1) - . "
    \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 = " \n" - . _("Sie sind hier:") - . " "; - $path .= "getSelf("itemID=" . ROOT_BLOCK, false)) - . "\">" - . htmlready(my_substr( - $this->tree->tree_data[ROOT_BLOCK]["name"], 0, 60)) - . ""; - - # 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 .= " > " - . "getSelf("itemID={$parents[$i]}", false)) - . "\">" - . htmlready(my_substr( - $this->tree->tree_data[$parents[$i]]["name"], 0, 60)) - . ""; - } - } - # ====================================== 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 .= "
    " . $table->createContent(); - } - - - $content .= "
    getSelf("item_id={$itemID}", 1)) - . "\" method=\"POST\" style=\"display:inline;\">\n"; - $content .= CSRFProtection::tokenTag(); - - $content .= "
    "; - - $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 .= "
    \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 = "" - . Assets::img('forumstrich2.gif') - . ""; //last - else - $level_output = " " - . Assets::img('forumstrich3.gif') - . ""; //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 = "" - . Assets::img('forumleer.gif') - . "" - . $level_output; //nothing - } else { - $level_output = " " - . Assets::img('forumstrich.gif') - . "" - . $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 = "" - . Assets::img('forumleer.gif') - . "" - . $level_output; //nothing - } - - } - - $html = "" - . " $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 = " \n" - . " \n" - . " \n" - . " \n" - . "
    \n" - . $this->getItemHeadPics($item_id) . "\n" - . " \n"; - if ($this->anchor == $item_id) - $html .= ""; - $html .= Assets::img('forumleer.gif'); - if ($this->anchor == $item_id) - $html .= ""; - $html .= "\n" - . " " - . $this->getItemHead($item_id) - . "
    \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 = " \n" - . " \n" - . "" - . _("Vorlage") . ": " - . $templateTitle - . " "; - - } - - $head = " 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 .= ""; - - 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 = " \n" - . " \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 .= " \n" - . " \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], '
    ')) { - $details = explode("
    ", $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] .= "
    " . _("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] .= "
    " . 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] .= "
    " . _("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] . "
    " . $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 %s 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 %s inklusive aller Fragen zu löschen. "), - $title); - } - $this->msg[$this->itemID] .= "
    " - . _("Wollen Sie diesen Fragenblock wirklich löschen?"); - } else { - if ($numberofchildren) { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Gruppierungsblock %s 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 %s inklusive aller Unterblöcke zu löschen. "), - $title); - } - $this->msg[$this->itemID] .= "
    " - . _("Wollen Sie diesen Gruppierungsblock wirklich löschen?"); - } - - $this->msg[$this->itemID] .= "

    " - . 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 %s und alle darin enthaltenen Fragen (insgesamt %s) wurden gelöscht. "), $title, $numberofchildren); - } else { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Fragenblock %s wurde gelöscht. "), $title); - } - } else { - if ($numberofchildren) { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Gruppierungsblock %s und alle Unterblöcke (insgesamt %s) wurden gelöscht. "), $title, $numberofchildren); - } else { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Gruppierungsblock %s 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 %s 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 %s 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 %s im rechten Bereich Antworten zuweisen.") -# , $questiontitle) -# . "
    " - . _("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 %s 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] .= "
    " . _("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] .= "
    " . _("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 %s 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 %s 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 %s 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 = "
    "; - - $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 = "\n" - . " \n" - . " \n" - . " \n" -// . " \n" - . "
    \n" -// . " \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 .= "
    \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 %s 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 e999cb5..0000000 --- a/lib/evaluation/classes/EvaluationTreeShowUser.class.php +++ /dev/null @@ -1,539 +0,0 @@ - - * @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 .= - "" . - Assets::img('forumleer.gif', ['size' => INDENT_PIXELS . '@1']) . - ""; - } - - echo "\n"; - echo "\n"; - echo "\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 "\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 ""; - - echo ""; - - echo "\n"; - - } else { - echo ""; - } - - echo "\n"; - echo "
    \n"; - echo "
    \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 ""; - echo htmlReady($this->tree->tree_data[$group_id]['name']); - echo ""; - echo "\n"; - echo Assets::img('forumleer.gif', ['size' => '2@1']); - echo "
    \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 = "" . - Assets::img('forumleer.gif', ['size' => INDENT_PIXELS . '@1']) . - "" . - $level_output; - } - - /* print table */ - echo "\n"; - echo "\n"; - echo "\n" . $level_output; - echo "\n"; - echo "
    getChildType() == "EvaluationQuestion" - ? ">" - : ">"); - echo $this->getGroupContent($group); - echo "
    \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() - ? "" . formatReady($group->getTitle()) . "
    \n" - : ""; - - /* get text */ - $content .= $group->getText() - ? formatReady($group->getText()) . "
    \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\n"; - } - - $content .= $this->getQuestionContent($question, $group); - $closeTable = YES; - } - } - if ($closeTable) - $content .= "
    \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\n"; - $html .= "\n"; - $html .= "\n"; - $html .= "\n"; - $html .= "
    \n"; - $html .= $content; - $html .= "
    \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 .= " \n"; - $html .= " "; -# $html .= mb_strlen( $group->getText() ) < 100 ? formatReady( $group->getText() ) : " "; - $html .= " "; - $html .= "\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 .= - " "; - } - - $html .= - " "; - $html .= $headCell; - $html .= "\n"; - } - } - $html .= " \n"; - } - $class = $question->getPosition() % 2 ? "table_row_even" : "table_row_odd"; - $extraStyle = ($question->getPosition() == $group->getNumberChildren() - 1 - ? "border-bottom: $answerBorder" - : ""); - $html .= " \n"; - $html .= " "; - $html .= formatReady($question->getText()); - $html .= ($group->isMandatory() ? "**" : ""); - $html .= "\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 .= - " "; - } - - $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 .= " "; - $html .= "getObjectID() . "]" . $number . "\" " . - "value=\"" . $answer->getObjectID() . "\" " . $checked . ">"; - $html .= "\n"; - } - } - $html .= " \n"; - /* -------------------------------------------- */ - } /* Normal (question with long answers) ----------------------------- */ - else { - $class = $question->getPosition() % 2 ? "table_row_even" : "table_row_odd"; - - /* Question ----------------------------------- */ - $html .= - "" . - "" . - formatReady($question->getText()) . - ($group->isMandatory() ? "**" : "") . - "" . - "\n"; - - $html .= ""; - $html .= ""; - $html .= "\n"; - /* -------------------------------------------- */ - - $numberOfVisibleAnswers = 0; - foreach ($answerArray as $answer) - if (!($answer->isFreetext() && $answer->getText() != '')) - $numberOfVisibleAnswers++; - - if ($numberOfVisibleAnswers == 0) { - $html .= "\n"; - $html .= - "\n"; - $html .= "\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 .= "\n"; - - /* show text input field ---------- */ - if ($answer->isFreetext()) { - - // not really needed anymore - if ($numberOfVisibleAnswers > 1) - /* show a check/radio-box */ - $html .= - "\n"; - - /* one row input field */ - $freetexts = Request::getArray('freetexts'); - if ($answer->getRows() == 1) - $html .= - "\n"; - - /* multiple row input field (textarea) */ - else - $html .= - "\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 .= - "\n"; - $html .= - "\n"; - } - $html .= "\n"; - } - } - /* ------------------------------- End: Answers */ - } - - $html .= "
    " . - _("Dieser Frage wurden keine Antworten zugeordnet!") . - "
    " . - "getObjectID() . "]" . $number . "\"" . - " value=\"" . $answer->getObjectID() . "\">" . - "" . - "getObjectID() . "]\"" . - " value=\"" . htmlReady(isset($freetexts[$question->getObjectID()]) ? $freetexts[$question->getObjectID()] : '') . "\" size=\"60\">" . - "" . - "getObjectID() . "]\"" . - " cols=\"60\" rows=\"" . $answer->getRows() . "\">" . - htmlReady(isset($freetexts[$question->getObjectID()]) ? $freetexts[$question->getObjectID()] : '') . - "" . - "" . - "getObjectID() . "]" . $number . "\"" . - " value=\"" . $answer->getObjectID() . "\" " . $checked . ">" . - "" . - formatReady($answer->getText()) . - "
    \n"; - $html .= ""; - } - - return $html; - } -} diff --git a/lib/evaluation/classes/HTML.class.php b/lib/evaluation/classes/HTML.class.php deleted file mode 100644 index 50b01eb..0000000 --- a/lib/evaluation/classes/HTML.class.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * @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() . ">\"
    "; - } - } - - 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