aboutsummaryrefslogtreecommitdiff
path: root/lib/evaluation
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:07:19 +0200
committerJan-Hendrik Willms <tleilax+github@gmail.com>2021-07-22 16:19:12 +0200
commita3da1483a9e689846179159355badfec8073dbec (patch)
tree770dcca6bdf5f6f2a11b0e7fcbbeda6919a3fc52 /lib/evaluation
current code from svn, revision 62608
Diffstat (limited to 'lib/evaluation')
-rw-r--r--lib/evaluation/classes/Evaluation.class.php535
-rw-r--r--lib/evaluation/classes/EvaluationAnswer.class.php278
-rw-r--r--lib/evaluation/classes/EvaluationExportManager.class.php271
-rw-r--r--lib/evaluation/classes/EvaluationExportManagerCSV.class.php345
-rw-r--r--lib/evaluation/classes/EvaluationGroup.class.php195
-rw-r--r--lib/evaluation/classes/EvaluationObject.class.php528
-rw-r--r--lib/evaluation/classes/EvaluationQuestion.class.php176
-rw-r--r--lib/evaluation/classes/EvaluationTree.class.php163
-rw-r--r--lib/evaluation/classes/EvaluationTreeEditView.class.php3305
-rw-r--r--lib/evaluation/classes/EvaluationTreeShowUser.class.php536
-rw-r--r--lib/evaluation/classes/HTML.class.php185
-rw-r--r--lib/evaluation/classes/HTMLempty.class.php181
-rw-r--r--lib/evaluation/classes/LazyHTML.class.php71
-rw-r--r--lib/evaluation/classes/db/EvaluationAnswerDB.class.php284
-rw-r--r--lib/evaluation/classes/db/EvaluationDB.class.php291
-rw-r--r--lib/evaluation/classes/db/EvaluationGroupDB.class.php226
-rw-r--r--lib/evaluation/classes/db/EvaluationObjectDB.class.php368
-rw-r--r--lib/evaluation/classes/db/EvaluationQuestionDB.class.php307
-rw-r--r--lib/evaluation/evaluation.config.php154
-rw-r--r--lib/evaluation/evaluation.lib.php263
-rw-r--r--lib/evaluation/evaluation_admin_edit.inc.php229
-rw-r--r--lib/evaluation/evaluation_admin_edit.lib.php99
-rw-r--r--lib/evaluation/evaluation_admin_overview.inc.php390
-rw-r--r--lib/evaluation/evaluation_admin_overview.lib.php2222
-rw-r--r--lib/evaluation/evaluation_admin_template.inc.php672
-rw-r--r--lib/evaluation/evaluation_admin_template.lib.php1115
-rw-r--r--lib/evaluation/evaluation_show.lib.php424
27 files changed, 13813 insertions, 0 deletions
diff --git a/lib/evaluation/classes/Evaluation.class.php b/lib/evaluation/classes/Evaluation.class.php
new file mode 100644
index 0000000..df8a2ce
--- /dev/null
+++ b/lib/evaluation/classes/Evaluation.class.php
@@ -0,0 +1,535 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_EVALDB;
+require_once EVAL_FILE_OBJECT;
+require_once EVAL_FILE_GROUP;
+# ====================================================== end: including files #
+
+
+# Define all required constants ============================================= #
+/**
+ * @const INSTANCEOF_EVAL Is instance of an evaluation object
+ * @access public
+ */
+define("INSTANCEOF_EVAL", "Evaluation");
+# ===================================================== end: define constants #
+
+
+/**
+ * The mainclass for an evaluation for the Stud.IP-project.
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class Evaluation extends EvaluationObject implements PrivacyObject
+{
+# Define all required variables ============================================= #
+ /**
+ * Startdate
+ * @access private
+ * @var integer $startdate
+ */
+ var $startdate;
+
+ /**
+ * Stopdate
+ * @access private
+ * @var integer $stopdate
+ */
+ var $stopdate;
+
+ /**
+ * Timespan
+ * @access private
+ * @var integer $timespan
+ */
+ var $timespan;
+
+ /**
+ * Time of creation. Is set automatically.
+ * @access private
+ * @var integer $mkdate
+ */
+ var $mkdate;
+
+ /**
+ * Time of last change. Is set automatically.
+ * @access private
+ * @var integer $chdate
+ */
+ var $chdate;
+
+ /**
+ * Defines wheter the evaluation is anonymous
+ * @access private
+ * @var boolean $anonymous
+ */
+ var $anonymous;
+
+ /**
+ * Defines whether the evaluation is visible
+ * @access private
+ * @var boolean $visible
+ */
+ var $visible;
+
+ /**
+ * Defines whether the evaluation template is shared
+ * @access private
+ * @var boolean $shared
+ */
+ var $shared;
+
+ /**
+ * Counts the number of connected ranges
+ * @access private
+ * @var integer $numberRanges
+ */
+ var $numberRanges;
+
+ /**
+ * 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->setAuthorEmail("mail@AlexanderWillner.de");
+ $this->setAuthorName("Alexander Willner");
+ $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->isUsed = 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) {
+ array_push($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)
+ {
+ array_push($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
new file mode 100644
index 0000000..ac42aef
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationAnswer.class.php
@@ -0,0 +1,278 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * Beschreibung
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_ANSWERDB;
+require_once EVAL_FILE_OBJECT;
+
+/**
+ * @const INSTANCEOF_EVALANSWER Is instance of an evaluationanswer object
+ * @access public
+ */
+define("INSTANCEOF_EVALANSWER", "EvaluationAnswer");
+
+class EvaluationAnswer extends EvaluationObject
+{
+
+ /**
+ * The value for an answer
+ * @access private
+ * @var integer $value ;
+ */
+ var $value;
+
+ /**
+ * If >0 the answer is a freetext with $rows rows
+ * @access private
+ * @var integer $rows
+ */
+ var $rows;
+
+ /**
+ * The userIDs of users who voted for this answer
+ * @access private
+ * @var array $users
+ */
+ var $users;
+
+ /**
+ * The number of users voted for this answer
+ * @access private
+ * @var integer $userNum
+ */
+ var $userNum;
+
+ /**
+ * For internal use (getNextUserID)
+ * @access private
+ * @var integer $userNumIterator
+ */
+ var $userNumIterator;
+
+ /**
+ * If true this is the residual answer for a question
+ * @access private
+ * @var boolean $residual
+ */
+ var $residual;
+
+ /**
+ * Constructor
+ * @access public
+ * @param string $objectID The ID of an existing answer
+ * @param object $parentObject The parent object if exists
+ * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN
+ */
+ public function __construct($objectID = "", $parentObject = null, $loadChildren = EVAL_LOAD_NO_CHILDREN)
+ {
+ /* Set default values ------------------------------------------------- */
+ parent::__construct($objectID, $parentObject, $loadChildren);
+ $this->instanceof = INSTANCEOF_EVALANSWER;
+
+ $this->value = 0;
+ $this->rows = 0;
+ $this->users = [];
+ $this->userNum = 0;
+ $this->userNumIterator = 0;
+ $this->residual = NO;
+
+ $this->db = new EvaluationAnswerDB ();
+ if ($this->db->isError()) {
+ return $this->throwErrorFromClass($this->db);
+ }
+ $this->init($objectID);
+
+ }
+
+ /**
+ * Gets the number of votes for this answer
+ * @access public
+ * @return string The counter of the answer
+ */
+ public function getNumberOfVotes()
+ {
+ return $this->userNum;
+ }
+
+ /**
+ * Gets the number of rows from freetext answers
+ * @access public
+ * @return integer The number of rows
+ */
+ public function getRows()
+ {
+ return $this->rows;
+ }
+
+ /**
+ * Gets the number of rows for freetext answers
+ * @access public
+ * @param integer $rows The number of rows
+ */
+ public function setRows($rows)
+ {
+ $this->rows = $rows;
+ return;
+ }
+
+ /**
+ * Gets the value of an answer
+ * @access public
+ * @return integer The value
+ */
+ public function getValue()
+ {
+ return $this->value;;
+ }
+
+ /**
+ * Sets the value of an answer
+ * @access public
+ * @param integer $value The value
+ */
+ public function setValue($value)
+ {
+ $this->value = $value;
+ }
+
+ /**
+ * Checks whether the answer is a residual answer
+ * @access public
+ * @return boolean YES if it is a residual answer
+ */
+ public function isResidual()
+ {
+ return $this->residual == YES ? YES : NO;
+ }
+
+ /**
+ * Sets the answers as an residual answer
+ * @access public
+ * @param boolean $boolean YES to set it as a residual answer
+ */
+ public function setResidual($boolean)
+ {
+ $this->residual = $boolean == YES ? YES : NO;
+ }
+
+ /**
+ * Vote for this answer
+ * @access public
+ * @param string $userID The user id
+ */
+ public function vote($userID)
+ {
+ $this->addUserID($userID);
+ }
+
+ /**
+ * Non-Anonymous vote for this answer
+ * @access public
+ * @param string $userID The user id
+ */
+ public function addUserID($userID)
+ {
+ if (empty ($userID)) {
+ return $this->throwError(1, _("Nur pseudonyme Abstimmung erlaubt! Neue ID mit StudipObject::createNewID () erzeugen"));
+ }
+
+ $this->userNum++;
+ array_push($this->users, $userID);
+ }
+
+ /**
+ * Gets the first user and removes it
+ * @access public
+ * @return string The first user id
+ */
+ public function getUserID()
+ {
+ if ($this->userNum > 0)
+ $this->userNum--;
+ return array_pop($this->users);
+ }
+
+ /**
+ * Gets the next user
+ * @access public
+ * @return string The next user id, otherwise NULL
+ */
+ public function getNextUserID()
+ {
+ if ($this->userNumIterator >= $this->userNum) {
+ $this->userNumIterator = 0;
+ return NULL;
+ }
+ return $this->users[$this->userNumIterator++];
+ }
+
+ /**
+ * Gets all the user ids
+ * @access public
+ * @return array An array full of user ids
+ */
+ public function getUserIDs()
+ {
+ return $this->users;
+ }
+
+ /**
+ * @access public
+ * @return integer YES, if the Answer is a textfield
+ */
+ public function isFreetext()
+ {
+ return ($this->rows == 0) ? NO : YES;
+ }
+
+ /**
+ * Checks if object is in a valid state
+ * @access private
+ */
+ public function check()
+ {
+ parent::check();
+ }
+
+ /**
+ * Debugfunction
+ * @access private
+ */
+ public function toString()
+ {
+ parent::toString();
+ echo "Anzahl der Stimmen: " . $this->getNumberOfVotes() . "<br>\n";
+ }
+}
diff --git a/lib/evaluation/classes/EvaluationExportManager.class.php b/lib/evaluation/classes/EvaluationExportManager.class.php
new file mode 100644
index 0000000..6155f36
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationExportManager.class.php
@@ -0,0 +1,271 @@
+<?php
+# Lifter002: TEST
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once 'lib/export/export_tmp_gc.inc.php';
+require_once EVAL_FILE_EVALDB;
+require_once EVAL_FILE_ANSWERDB;
+require_once EVAL_FILE_OBJECT;
+require_once EVAL_FILE_GROUP;
+
+/**
+ * @const INSTANCEOF_EVALEXPORTMANAGER Is instance of an export manager
+ * @access public
+ */
+define("INSTANCEOF_EVALEXPORTMANAGER", "EvaluationExportManager");
+
+/**
+ * @const EVALEXPORT_PREFIX The prefix for temporary filenames
+ * @access public
+ */
+define("EVALEXPORT_PREFIX", "evaluation");
+
+/**
+ * @const EVALEXPORT_LIFETIME The lifetime in seconds for temporary files
+ * @access public
+ */
+define("EVALEXPORT_LIFETIME", 1800);
+
+
+/**
+ * The mainclass for the evaluation export manager
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class EvaluationExportManager extends AuthorObject
+{
+
+ /**
+ * The temporary filename
+ * @access private
+ * @var string $filename
+ */
+ public $filename;
+
+ /**
+ * The filehandle for the temporary filename
+ * @access private
+ * @public integer $filehandle
+ */
+ public $filehandle;
+
+ /**
+ * The ID for the evaluation to export
+ * @access private
+ * @var string $evalID
+ */
+ public $evalID;
+
+ /**
+ * The evaluation to export
+ * @access private
+ * @var object Evaluation $eval
+ */
+ public $eval;
+
+ /**
+ * Array full of questionobjects
+ * @access private
+ * @var array $evalquestions
+ */
+ public $evalquestions;
+
+ /**
+ * The extension for the FILENAME
+ * @access private
+ * @var string $extension
+ */
+ public $extension;
+
+ /**
+ * UserIDs of all persons which used the evaluation
+ * @access private
+ * @var array $users
+ */
+ public $users;
+
+ /**
+ * Constructor
+ * @access public
+ * @param string $evalID The ID of the evaluation for export
+ */
+ public function __construct($evalID)
+ {
+ register_shutdown_function([&$this, "_EvaluationExportManager"]);
+
+ parent::__construct();
+ $this->setAuthorEmail("mail@AlexanderWillner.de");
+ $this->setAuthorName("Alexander Willner");
+ $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;
+ export_tmp_gc();
+ 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
new file mode 100644
index 0000000..ca3374f
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationExportManagerCSV.class.php
@@ -0,0 +1,345 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_EXPORTMANAGER;
+# ====================================================== end: including files #
+
+
+# Define all required constants ============================================= #
+/**
+ * @const INSTANCEOF_EVALEXPORTMANAGER Is instance of an export manager
+ * @access public
+ */
+define ("INSTANCEOF_EVALEXPORTMANAGERCSV", "EvaluationExportManagerCSV");
+
+/**
+ * @const EVALEXPORT_SEPERATOR The seperator for values
+ * @access public
+ */
+define ("EVALEXPORT_SEPERATOR", ";");
+
+/**
+ * @const EVALEXPORT_DELIMITER The delimiter for values
+ * @access public
+ */
+define ("EVALEXPORT_DELIMITER", "\"");
+
+/**
+ * @const EVALEXPORT_NODELIMITER Character to substitute the delimiter in a text
+ * @access public
+ */
+define ("EVALEXPORT_NODELIMITER", "'");
+
+/**
+ * @const EVALEXPORT_ENDROW The characters to end a row
+ * @access public
+ */
+define ("EVALEXPORT_ENDROW", EVALEXPORT_DELIMITER.EVALEXPORT_DELIMITER."\n");
+
+/**
+ * @const EVALEXPORT_EXTENSION The extension for the filenames
+ * @access public
+ */
+define ("EVALEXPORT_EXTENSION", "csv");
+# ===================================================== end: define constants #
+
+
+/**
+ * The mainclass for the evaluation export manager
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class EvaluationExportManagerCSV extends EvaluationExportManager {
+# Define all required variables ============================================= #
+
+# ============================================================ 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->setAuthorEmail ("mail@AlexanderWillner.de");
+ $this->setAuthorName ("Alexander Willner");
+ $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);
+
+ $db = new EvaluationAnswerDB ();
+
+ /* for each question -------------------------------------------------- */
+ foreach ($this->evalquestions as $evalquestion) {
+ $type = $evalquestion->getType ();
+ $residual = "";
+
+ /* Questiontype: likert scale -------------------------------------- */
+ if ($type == EVALQUESTION_TYPE_LIKERT) {
+ $db->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) {
+ $db->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 ()) {
+ $db->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
new file mode 100644
index 0000000..daa0480
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationGroup.class.php
@@ -0,0 +1,195 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_GROUPDB;
+require_once EVAL_FILE_OBJECT;
+require_once EVAL_FILE_QUESTION;
+# ====================================================== end: including files #
+
+
+# Define constants ========================================================== #
+/**
+ * @const INSTANCEOF_EVALGROUP Is instance of an evaluationgroup object
+ * @access public
+ */
+define ("INSTANCEOF_EVALGROUP", "EvaluationGroup");
+# ===================================================== end: define constants #
+
+
+/**
+ * This class provides a group for an evaluation for the Stud.IP-project.
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+
+class EvaluationGroup extends EvaluationObject {
+
+#Define all required variables ============================================= #
+ /**
+ * Possible Type of thechildren
+ * @access private
+ * @var string $childType
+ */
+ var $childType;
+
+ /**
+ * Is it mandatory to answer sub questions
+ * @access private
+ * @var boolean $mandatory
+ */
+ var $mandatory;
+
+ /**
+ * ID of the templateID for the childs
+ * @access private
+ * @var string $templateID
+ */
+ var $templateID;
+# ============================================================ end: variables #
+
+
+# Define constructor and destructor ========================================= #
+ /**
+ * Constructor
+ * @access public
+ * @param string $objectID The ID of an existing group
+ * @param EvaluationObject $parentObject The parent object if exists
+ * @param string $loadChildren See const EVAL_LOAD_*_CHILDREN
+ */
+ function __construct($objectID = "", $parentObject = null,
+ $loadChildren = EVAL_LOAD_NO_CHILDREN) {
+ /* Set default values ------------------------------------------------- */
+ parent::__construct($objectID, $parentObject, $loadChildren);
+ $this->setAuthorEmail ("mail@AlexanderWillner.de");
+ $this->setAuthorName ("Alexander Willner");
+ $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
new file mode 100644
index 0000000..26b2d5e
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationObject.class.php
@@ -0,0 +1,528 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+# ====================================================== end: including files #
+
+
+# Define constants ========================================================== #
+/**
+ * @const INSTANCEOF_EVALOBJECT Is instance of an abstrakt evaluation object
+ * @access public
+ */
+define ("INSTANCEOF_EVALOBJECT", "EvaluationObject");
+
+/**
+ * @const EVAL_LOAD_NO_CHILDREN Load no children from DB
+ * @access public
+ */
+define ("EVAL_LOAD_NO_CHILDREN", 0);
+
+/**
+ * @const EVAL_LOAD_FIRST_CHILDREN Load just the direct children from DB
+ * @access public
+ */
+define ("EVAL_LOAD_FIRST_CHILDREN", 1);
+
+/**
+ * @const EVAL_LOAD_ALL_CHILDREN Load all children from DB
+ * @access public
+ */
+define ("EVAL_LOAD_ALL_CHILDREN", 2);
+
+/**
+ * @const EVAL_LOAD_ONLY_EVALGROUP Load just the groups for performance reasons
+ * @access public
+ */
+define ("EVAL_LOAD_ONLY_EVALGROUP", 3);
+# ===================================================== end: define constants #
+
+
+/**
+ * This abstract class provides functions for evaluation objects
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class EvaluationObject extends StudipObject {
+# Define all required variables ============================================= #
+ /**
+ * The parent object
+ * @access private
+ * @var string $parentObject
+ */
+ var $parentObject;
+
+ /**
+ * The parent object id
+ * @access private
+ * @var string $parentObjectCD
+ */
+ var $parentObjectID;
+
+ /**
+ * Array with all linked childobjects
+ * @access private
+ * @var array $childObjects
+ */
+ var $childObjects;
+
+ /**
+ * Counts the number of childs
+ * @access private
+ * @var integer $numberChildren
+ */
+ var $numberChildren;
+
+ /**
+ * Title of the group
+ * @access private
+ * @var integer $title
+ */
+ var $title;
+
+ /**
+ * Text of the group
+ * @access private
+ * @var integer $text
+ */
+ var $text;
+
+ /**
+ * Position of this group in parent object
+ * @access private
+ * @var integer $position
+ */
+ var $position;
+
+ /**
+ * Holds the DB object
+ * @access private
+ * @var object DatabaseObject $db
+ */
+ var $db;
+
+ /**
+ * Is used as a counter for getNextChild )
+ * @access private
+ * @var integer $childNum
+ */
+ var $childNum;
+
+ /**
+ * Defines how many children to load. See EVAL_LOAD_*_CHILDREN
+ * @access private
+ * @var integer $loadChildren
+ */
+ var $loadChildren;
+# ============================================================ end: variables #
+
+
+# Define constructor and destructor ========================================= #
+ /**
+ * Constructor
+ * @param string $objectID The ID of an existing object
+ * @param EvaluationObject $parentObject The parent object
+ * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN
+ * @access public
+ */
+ function __construct($objectID = "", $parentObject = NULL,
+ $loadChildren = EVAL_LOAD_NO_CHILDREN) {
+
+ /* Set default values -------------------------------------------------- */
+ parent::__construct($objectID);
+ $this->setAuthorEmail ("mail@AlexanderWillner.de");
+ $this->setAuthorName ("Alexander Willner");
+ $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;
+ }
+ return NULL;
+ } else {
+ if ($this->numberChildren > 0)
+ $this->numberChildren--;
+ return array_pop ($this->childObjects);
+ }
+ }
+
+ /**
+ * Gets the next child
+ * @access public
+ * @return object The next object, otherwise NULL
+ */
+ function &getNextChild () {
+ if ($this->childNum >= $this->numberChildren) {
+ $this->childNum = 0;
+ return NULL;
+ }
+ 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 ($this->createNewID ());
+ } else {
+ $this->setObjectID ($objectID);
+ $this->load ();
+ if ($this->db->isError ())
+ return $this->throwErrorFromClass ($this->db);
+ }
+ /* -------------------------------------------------------------------- */
+
+ }
+
+ /**
+ * Loads the Object from the database
+ * @access private
+ */
+ function load () {
+ $this->db->load ($this);
+ if ($this->db->isError ())
+ return $this->throwErrorFromClass ($this->db);
+ }
+
+ /**
+ * Checks if object is in a valid state
+ * @access private
+ */
+ function check () {
+ if (empty ($this->db))
+ $this->throwError (1, _("Es existiert kein DB-Objekt"));
+ }
+
+ /**
+ * Gets all children of a special kind
+ * @param EvaluationObject &$object the parent object
+ * @param string $instanceof instance of the searched child
+ * @param boolean $reset for internal use
+ * @access public
+ */
+ function getSpecialChildobjects (&$object, $instanceof, $reset = false) {
+ static $specialchildobjects = [];
+ if ($reset == YES) {
+ $specialchildobjects = [];
+ }
+
+ if ($object->x_instanceof () == $instanceof) {
+ array_push ($specialchildobjects, $object);
+ } else {
+ while ($child = &$object->getNextChild ()) {
+ $this->getSpecialChildobjects ($child, $instanceof, NO);
+ }
+ }
+ return $specialchildobjects;
+ }
+
+ /**
+ * Debugfunction
+ * @access public
+ */
+ function toString () {
+ echo "<table border=1 cellpadding=5><tr><td>";
+ echo "Typ: ".$this->x_instanceof ()."<br>";
+ echo "ObjectID: ".$this->getObjectID ()."<br>";
+ echo "ParentID: ".$this->getParentID ()."<br>";
+ echo "ParentObject: ".$this->getParentObject ()."<br>";
+ echo "Author: ".$this->getAuthorID ()."<br>";
+ echo "Titel: ".$this->getTitle ()."<br>";
+ echo "Text: ".$this->getText ()."<br>";
+ echo "Position: ".$this->getPosition ()."<br>";
+ echo "Untergruppen: ".$this->getNumberChildren ()."<br>";
+ echo "</td></tr>";
+ while ($child = $this->getNextChild ()) {
+ echo "<tr><td>";
+ $i++;
+ echo "<b>Kind $i</b>"."<br>";
+ $child->toString ();
+ echo "</td></tr>";
+ }
+ echo "</table>";
+ }
+# ==================================================== end: private functions #
+
+}
+
+?>
diff --git a/lib/evaluation/classes/EvaluationQuestion.class.php b/lib/evaluation/classes/EvaluationQuestion.class.php
new file mode 100644
index 0000000..1ee2f9d
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationQuestion.class.php
@@ -0,0 +1,176 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * Beschreibung
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+*/
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_QUESTIONDB;
+require_once EVAL_FILE_OBJECT;
+require_once EVAL_FILE_ANSWER;
+# ====================================================== end: including files #
+
+
+# Define constants ========================================================== #
+/**
+ * @const INSTANCEOF_EVALGROUP Is instance of an evaluationquestion object
+ * @access public
+ */
+define ("INSTANCEOF_EVALQUESTION", "EvaluationQuestion");
+
+/**
+ * @const EVALQUESTION_TYPE_LIKERT Type of question is skala
+ * @access public
+ */
+define ("EVALQUESTION_TYPE_LIKERT", "likertskala");
+
+/**
+ * @const EVALQUESTION_TYPE_MC Type of question is normal
+ * @access public
+ */
+define ("EVALQUESTION_TYPE_MC", "multiplechoice");
+
+/**
+ * @const EVALQUESTION_TYPE_POL Type of question is pol
+ * @access public
+ */
+define ("EVALQUESTION_TYPE_POL", "polskala");
+# ===================================================== end: define constants #
+
+
+class EvaluationQuestion extends EvaluationObject {
+
+# Define all required variables ============================================= #
+ /**
+ * Type of question (skala/normal) => see EVALQUESTION_TYPE_*
+ * @access private
+ * @var string $type
+ */
+ var $type;
+
+ /**
+ * If set YES it is allowed to choose more than one answer
+ * @access private
+ * @var string $isMultiplechoice
+ */
+ var $isMultiplechoice;
+# ============================================================ 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->multiplechoice = $multiplechoice == YES ? YES : NO;
+ }
+
+ /**
+ * Checks for multiplechoice
+ * @access public
+ * @return boolean YES if it is an multiplechoice question
+ */
+ function isMultiplechoice () {
+ return $this->multiplechoice == 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
new file mode 100644
index 0000000..9a03a35
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationTree.class.php
@@ -0,0 +1,163 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * The treeclass for an evaluation.
+ *
+ * @author mcohrs
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_EVAL;
+require_once EVAL_FILE_GROUP;
+# ====================================================== end: including files #
+
+
+class EvaluationTree extends TreeAbstract {
+# Define all required variables ============================================= #
+
+ /**
+ * Holds the Evaluation object
+ * @access public
+ * @var object Evaluation $eval
+ */
+ var $eval;
+
+ /**
+ * Holds the Evaluation ID
+ * @access public
+ * @var string $evalID
+ */
+ var $evalID;
+
+ /**
+ * Holds the eval constructor load mode
+ * @access public
+ * @var integer $load_mode
+ */
+ var $load_mode;
+
+# ============================================================ end: variables #
+
+
+# Define constructor and destructor ========================================= #
+ /**
+ * Constructor
+ * @access public
+ * @param array the eval's ID (optional - if not given, it must be in $_REQUEST).
+ */
+ function __construct( $args ) {
+
+
+ if (isset($args['evalID']))
+ $this->evalID = $args['evalID'];
+ else
+ $this->evalID = Request::option("evalID");
+
+ $this->load_mode = ($args['load_mode'] ? $args['load_mode'] : EVAL_LOAD_NO_CHILDREN);
+ if (empty($this->evalID)){
+ print _("Fehler in EvaluationTree: Es wurde keine evalID übergeben");
+ exit ();
+ }
+
+ /* ------------------------------------------------------------------- */
+ parent::__construct();
+ }
+# =========================================== end: constructor and destructor #
+
+
+# Define public functions =================================================== #
+
+ /**
+ * initializes the tree
+ * store rows from evaluation tables in array $tree_data
+ * @access public
+ */
+ function init() {
+ /* create the evaluation -------------------> */
+ $this->eval = new Evaluation( $this->evalID, NULL, $this->load_mode );
+ $this->root_name = $this->eval->getTitle();
+ $this->root_content = $this->eval->getText();
+
+ /* create the tree structure ---------------> */
+ parent::init();
+
+ foreach( $this->eval->getChildren() as $group ) {
+ $this->recursiveInit( $group );
+
+ $this->tree_data[$group->getObjectID()]["text"] = $group->getText();
+ $this->tree_data[$group->getObjectID()]["object"] = $group;
+ $this->storeItem( $group->getObjectID(), "root",
+ $group->getTitle(), $group->getPosition() );
+ }
+ /* <---------------------------------------- */
+ }
+
+
+ /**
+ * initialize the sub-groups.
+ *
+ * @access private
+ * @param object EvaluationGroup the current group to be initialized.
+ */
+ function recursiveInit( $group ) {
+ // only groups are interesting here.
+ if( $group->x_instanceof() != INSTANCEOF_EVALGROUP )
+ return;
+
+ if( $children = $group->getChildren() ) {
+ foreach( $children as $child ) {
+ $this->recursiveInit( $child );
+ }
+ }
+
+ // store current object itself
+ $this->tree_data[$group->getObjectID()]["object"] = $group;
+
+ $this->storeItem( $group->getObjectID(), $group->getParentID(),
+ $group->getTitle(), $group->getPosition() );
+
+ }
+
+ function &getGroupObject($item_id, $renew = false){
+ if (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 {
+ return new EvaluationGroup($item_id,null,$this->load_mode);
+ }
+ }
+
+# ===================================================== end: public functions #
+
+
+}
+
+?>
diff --git a/lib/evaluation/classes/EvaluationTreeEditView.class.php b/lib/evaluation/classes/EvaluationTreeEditView.class.php
new file mode 100644
index 0000000..aa42394
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationTreeEditView.class.php
@@ -0,0 +1,3305 @@
+<?php
+# Lifter002: TODO
+# Lifter005: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+use Studip\Button, Studip\LinkButton;
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_LIB_COMMON;
+require_once EVAL_FILE_EVALTREE;
+require_once EVAL_FILE_EVAL;
+# ====================================================== end: including files #
+
+/**
+ * Class to print out the an evaluation's admin-tree
+ *
+ * @author Christian Bauer <alfredhitchcock@gmx.net>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ */
+
+
+# defines ==================================================================== #
+
+/**
+ * @const NO_TEMPLATE_GROUP title of the template without temtplateID
+ * @access private
+ */
+define('NO_TEMPLATE_GROUP', _('keine Vorlage'));
+
+/**
+ * @const NO_TEMPLATE_GROUP_TITLE title of questiongroup without title
+ * @access private
+ */
+define('NO_QUESTION_GROUP_TITLE', _('*Fragenblock*'));
+
+/**
+ * @const NO_TEMPLATE title of a template without title
+ * @access private
+ */
+define('NO_TEMPLATE', _('*unbekannt*'));
+
+/**
+ * @const NEW_EVALUATION_TITLE title of a new question block
+ * @access public
+ */
+define('NEW_EVALUATION_TITLE', _('Neue Evaluation'));
+
+/**
+ * @const FIRST_ARRANGMENT_BLOCK_TITLE title of a new arrangment block
+ * @access public
+ */
+define('FIRST_ARRANGMENT_BLOCK_TITLE', _('Erster Gruppierungsblock'));
+
+/**
+ * @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 current evalID
+ * @access private
+ * @var integer $evalID
+ */
+ var $evalID;
+
+ /**
+ * The itemID instance
+ * @access private
+ * @var string $itemInstance
+ */
+ var $itemInstance;
+
+ /**
+ * constructor
+ *
+ * @access public
+ * @param string $itemID the item to display
+ * @param string $evalID the evaluation of the item
+ */
+ function __construct($itemID = ROOT_BLOCK, $evalID = NULL)
+ {
+ global $sess;
+
+ $this->itemID = ($itemID) ? $itemID : ROOT_BLOCK;
+ $this->startItemID = ($itemID) ? $itemID : ROOT_BLOCK;
+ $this->evalID = $evalID;
+ $this->itemInstance = $this->getInstance($this->itemID);
+ $this->changed = false;
+
+ $this->tree = TreeAbstract::GetInstance("EvaluationTree", ['evalID' => $this->evalID,
+ 'load_mode' => EVAL_LOAD_ALL_CHILDREN]);
+
+ # filter out an old session itemID ======================================= #
+ if (is_array($this->tree->tree_data) && !is_null($itemID)) {
+ if (!array_key_exists($itemID, $this->tree->tree_data)) {
+ $this->itemID = ROOT_BLOCK;
+ $this->startItemID = ROOT_BLOCK;
+ $this->tree->init();
+ }
+ } else {
+ $this->itemID = ROOT_BLOCK;
+ $this->startItemID = ROOT_BLOCK;
+ $this->tree->init();
+ }
+
+ # handling the moveItemID =============================================== #
+ if (Request::submitted('create_moveItemID'))
+ $this->moveItemID = Request::option("itemID");
+ elseif (Request::option("moveItemID"))
+ $this->moveItemID = Request::get("moveItemID");
+
+ if (Request::submitted("abbort_move"))
+ $this->moveItemID = NULL;
+
+ if ($this->moveItemID != NULL) {
+ if (is_array($this->tree->tree_data)) {
+ if (!array_key_exists($this->moveItemID, $this->tree->tree_data)) {
+ $this->moveItemID = NULL;
+ }
+ } else {
+ $this->moveItemID = NULL;
+ }
+ }
+
+
+ # execute the comand ==================================================== #
+ $this->parseCommand();
+
+ # set the new changedate ================================================ #
+ if ($this->changed) {
+ $this->tree->eval->setChangedate(time());
+ $this->tree->eval->save();
+ }
+
+ }
+
+
+################################################################################
+# #
+# public functions #
+# #
+################################################################################
+
+ /**
+ * displays the EvaluationTree
+ *
+ * @access public
+ * @return string the eval-tree (html)
+ */
+ function showEvalTree()
+ {
+
+ $html = "<table width=\"99%\" border=\"0\" cellpadding=\"0\" "
+ . "cellspacing=\"0\">\n";
+
+ if ($this->startItemID != ROOT_BLOCK) {
+
+ $html .= " <tr>\n"
+ . " <td class=\"table_row_odd\" align=\"left\" valign=\"top\" "
+ . "colspan=\"";
+ $html .= ($this->moveItemID) ? "1" : "1";
+ $html .= "\""
+ . ">\n"
+ . $this->getEvalPath()
+# . "<img src=\"".
+# . "/forumleer.gif\" border=\"0\" height=\"20\" width=\"1\">\n"
+ . " </td>\n"
+ . " </tr>\n";
+ }
+ # display the infos when moving a block =================================== #
+
+ if ($this->moveItemID) {
+
+ $html .= " <tr>\n";
+# . " <td width=\"10\"class=\"blank tree-indent\" "
+# . "background=\"".."forumstrich.gif\">"
+# . "<img src=\""
+# . ."forumstrich.gif\" width=\"10\" border=\"0\" >"
+# . "</td>\n"
+ $html .= " <td class=\"graulight\" align=\"left\" valign=\"top\" width=\"100%\">\n";
+
+
+ $mode = $this->getInstance($this->moveItemID);
+
+ switch ($mode) {
+
+ case ARRANGMENT_BLOCK:
+ $group =& $this->tree->getGroupObject($this->moveItemID);
+ $title = htmlready($group->getTitle());
+ $msg = sprintf(_("Sie haben den Gruppierungsblock <b>%s</b> zum Verschieben ausgewählt. Sie können ihn nun in einen leeren Gruppierungsblock, einen Gruppierungsblock ohne Frageblöcke oder in die oberste Ebene verschieben."), $title);
+
+ break;
+
+ case QUESTION_BLOCK:
+ $group = &$this->tree->getGroupObject($this->moveItemID);
+ $title = htmlready($group->getTitle());
+ if (!$title)
+ $title = NO_QUESTION_GROUP_TITLE;
+ $msg = sprintf(_("Sie haben den Fragenblock <b>%s</b> zum Verschieben ausgewählt. Sie können ihn nun in einen leeren Gruppierungsblock oder einen Gruppierungsblock mit Frageblöcke verschieben."), $title);
+ break;
+
+ default:
+
+ $msg = _("Es wurde ein ungültiger Block zum verschieben ausgewählt.");
+ break;
+ }
+
+
+ $table = new HTML ("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("width", "100%");
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addAttr("align", "center");
+ $td->addAttr("class", "graulight");
+ $td->addAttr("width", "25");
+
+ $img = new HTMLempty ("img");
+ $img->addAttr("width", "32");
+ $img->addAttr("height", "32");
+ $img->addAttr("src", EVAL_PIC_INFO);
+
+ $td->addContent($img);
+ $tr->addContent($td);
+
+ $td = new HTML ("td");
+ $td->addAttr("align", "left");
+
+ $font = new HTML ("font");
+ $font->addAttr("color", "black");
+ $font->addHTMLContent($msg);
+ $font->addHTMLContent(" " . sprintf(
+ _("Benutzen Sie dieses %s Symbol, um den Block zu verschieben."),
+ $this->createImage(EVAL_PIC_MOVE_GROUP, _("Block verschieben Symbol"))));
+ $font->addHTMLContent("<br><br>"
+ . _("Oder wollen Sie die Aktion abbrechen?")
+ . " "
+ . LinkButton::createCancel(_('Abbrechen'),
+ $this->getSelf('abbort_move=1')));
+
+ $td->addContent($font);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ $html .= "<br>" . $table->createContent() . "<br>";
+
+ $html .= "</td></tr>\n";
+ }
+ # ============================= END: display the infos when moving a block #
+
+ $html .= " <tr>\n"
+ . " <td class=\"blank\" align=\"left\" valign=\"top\" "
+ . "colspan=\"";
+ $html .= ($this->moveItemID) ? "1" : "1";
+ $html .= "\""
+ . ">\n";
+
+ if (!$this->startItemID != ROOT_BLOCK) {
+ $html .= "<a name=\"anchor\"></a>\n";
+ }
+
+ $html .= $this->showTree($this->startItemID, 1)
+ . " </td>\n"
+ . " </tr>\n"
+ . "</table>\n";
+
+ return $html;
+ }
+
+# ###################################################### end: public functions #
+
+
+################################################################################
+# #
+# show tree functions #
+# #
+################################################################################
+
+ /**
+ * prints out the tree beginning at the parent-item
+ *
+ * @access public
+ * @param string $itemID the item to display
+ * @param string $start YES if its the basecall
+ * @return string the tree (html)
+ */
+ function showTree($itemID = ROOT_BLOCK, $start = NULL)
+ {
+
+ $items = [];
+ if (!is_array($itemID)) {
+ $items[0] = $itemID;
+
+ $mode = $this->getInstance($itemID);
+
+ switch ($mode) {
+
+ case ROOT_BLOCK:
+ $this->startItemID = $itemID;
+ break;
+
+ case ARRANGMENT_BLOCK:
+
+ case QUESTION_BLOCK:
+ $parentgroup = &$this->tree->getGroupObject($itemID);
+ $this->startItemID = $parentgroup->getObjectID();
+ break;
+ }
+
+ $this->startItemID = $itemID;
+ } else {
+ $items = $itemID;
+ }
+ $num_items = count($items);
+
+ $html = "";
+
+ // this is the first / the opened item
+ if ($start) {
+
+ $mode = $this->getInstance($itemID);
+
+ switch ($mode) {
+
+ case ROOT_BLOCK:
+
+ break;
+
+ case ARRANGMENT_BLOCK:
+
+ case QUESTION_BLOCK:
+
+ $group = &$this->tree->getGroupObject($itemID);
+ $parentID = $group->getParentID();
+
+ $mode = $this->getInstance($parentID);
+
+ if ($mode == ROOT_BLOCK) {
+
+ $eval = new Evaluation ($this->evalID, NULL, EVAL_LOAD_FIRST_CHILDREN);
+ while ($child = $eval->getNextChild())
+ $items2[] = $child->getObjectID();
+ } else {
+
+ $parentgroup = &$this->tree->getGroupObject($parentID, NULL, EVAL_LOAD_FIRST_CHILDREN);
+ while ($child = $parentgroup->getNextChild())
+ $items2[] = $child->getObjectID();
+ }
+
+ $num_items2 = count($items2);
+
+ $num_items = $num_items2;
+ $items = $items2;
+ break;
+
+ }
+
+ }
+
+ for ($j = 0; $j < $num_items; ++$j) {
+
+ $html .= $this->createTreeLevelOutput($items[$j]);
+ $html .= $this->createTreeItemOutput($items[$j]);
+
+ if ($this->tree->hasKids($items[$j]) &&
+ $this->itemID == $items[$j])
+ $html .= $this->showTree($this->tree->tree_childs[$items[$j]]);
+ }
+
+ return $html;
+ }
+
+
+ /**
+ * creates the parentslinks
+ *
+ * @access private
+ * @return string the eval path as html-links
+ */
+ function getEvalPath()
+ {
+
+ $path = "<a name=\"anchor\">&nbsp;</a>\n"
+ . _("Sie sind hier:")
+ . "&nbsp;";
+ if (0 && $this->startItemID != ROOT_ITEM) {
+
+
+ $path .= "<a class=\"tree\" href=\""
+ . URLHelper::getLink($this->getSelf("itemID=root"))
+ . "\">"
+# . Icon::create('arr_1right', 'attention')->asImg()
+# . "width=\"10\" hight=\"20\">"
+# . "&nbsp;"
+ . _("Evaluation")
+ . "</a>";
+ }
+ $path .= "<a class=\"tree\" href=\""
+ . URLHelper::getLink($this->getSelf("itemID=" . ROOT_BLOCK, false))
+ . "\">"
+ . htmlready(my_substr(
+ $this->tree->tree_data[ROOT_BLOCK]["name"], 0, 60))
+ . "</a>";
+
+ # collecting the parent blocks =========================================== #
+
+ if ($parents = $this->tree->getParents($this->startItemID)) {
+ for ($i = count($parents) - 1; $i >= 0; --$i) {
+ if ($parents[$i] != ROOT_BLOCK)
+ $path .= "&nbsp;&gt;&nbsp;"
+ . "<a class=\"tree\" href=\""
+ . URLHelper::getLink($this->getSelf("itemID={$parents[$i]}", false))
+ . "\">"
+ . htmlready(my_substr(
+ $this->tree->tree_data[$parents[$i]]["name"], 0, 60))
+ . "</a>";
+ }
+ }
+ # ====================================== END: collecting the parent blocks #
+ return $path;
+ }
+
+
+ /**
+ * returns html for the icons in front of the name of the item
+ *
+ * @access private
+ * @param string $itemID the item-heas id
+ * @return string the item head (html)
+ */
+ function getItemHeadPics($itemID)
+ {
+
+ $mode = $this->getInstance($itemID);
+
+ if ($this->itemID == $itemID) {
+
+ $img = new HTMLempty ("img");
+ $img->addAttr("src", EVAL_PIC_TREE_ARROW_ACTIVE);
+ $img->addAttr("border", "0");
+ $img->addAttr("align", "baseline");
+ $img->addAttr("hspace", "2");
+ $img->addString(tooltip(_("Dieser Block ist geöffnet."), true));
+ $head = $img->createContent();
+
+ } else {
+
+ $a = new HTML ("a");
+ $a->addAttr("href", URLHelper::getLink($this->getSelf("itemID={$itemID}")));
+
+ $img = new HTMLempty ("img");
+ $img->addAttr("src", EVAL_PIC_TREE_ARROW);
+ $img->addAttr("border", "0");
+ $img->addAttr("align", "baseline");
+ $img->addAttr("hspace", "2");
+ $img->addString(tooltip(_("Diesen Block öffnen."), true));
+
+ $a->addContent($img);
+
+ $head = $a->createContent();
+
+ }
+
+ # collecting the image and tooltip for this item ========================== #
+
+ switch ($mode) {
+
+ case ROOT_BLOCK:
+
+ $tooltip = _("Dies ist Ihre Evaluation.");
+ $image = EVAL_PIC_ICON;
+ break;
+
+ case ARRANGMENT_BLOCK:
+
+ $group = &$this->tree->getGroupObject($itemID);
+
+ $tooltip = ($group->getNumberChildren() == 0)
+ ? _("Dieser Gruppierungsblock enthält keine Blöcke.")
+ : sprintf(_("Dieser Grupppierungsblock enthält %s Blöcke."),
+ $group->getNumberChildren());
+
+ $image = ($group->getNumberChildren() == 0)
+ ? EVAL_PIC_TREE_GROUP
+ : EVAL_PIC_TREE_GROUP_FILLED;
+
+ break;
+
+ case QUESTION_BLOCK:
+
+ $group = &$this->tree->getGroupObject($itemID);
+
+ $tooltip = ($group->getNumberChildren() == 0)
+ ? _("Dieser Fragenblock enthält keine Fragen.")
+ : sprintf(_("Dieser Fragenblock enthält %s Fragen."),
+ $group->getNumberChildren());
+
+ $image = ($group->getNumberChildren() == 0)
+ ? EVAL_PIC_TREE_QUESTIONGROUP
+ : EVAL_PIC_TREE_QUESTIONGROUP_FILLED;
+
+ break;
+
+ default:
+
+ $tooltip = _("Kein Blocktyp.");
+ $image = EVAL_PIC_TREE_GROUP;
+
+ break;
+ }
+
+ # ===================== END: collecting the image and toolpi for this item #
+
+ $img = new HTMLempty ("img");
+ $img->addAttr("border", "0");
+ $img->addAttr("align", "baseline");
+ $img->addAttr("src", $image);
+ $img->addString(tooltip($tooltip, true));
+
+ $head .= $img->createContent();
+
+ return $head;
+ }
+
+
+ /**
+ * creates the content for all item-types
+ *
+ * @access private
+ * @param string $itemID the item-heas id
+ * @return string the item content (html)
+ */
+ function getItemContent($itemID)
+ {
+
+ $content = "";
+
+ if ($this->getItemMessage($itemID)) {
+
+ $table = new HTML ("table");
+ $table->addAttr("width", "99%");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("cellspacing", "2");
+ $table->addAttr("style", "font-size:10pt;");
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addHTMLContent($this->getItemMessage($itemID));
+
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ $content .= "<br>" . $table->createContent();
+ }
+
+
+ $content .= "<form class=\"default\" action=\"" . URLHelper::getLink($this->getSelf("item_id={$itemID}", 1))
+ . "\" method=\"POST\" style=\"display:inline;\">\n";
+ $content .= CSRFProtection::tokenTag();
+
+ $content .= "<br>";
+
+ $mode = $this->getInstance($itemID);
+
+ switch ($mode) {
+ case ROOT_BLOCK:
+
+ $content .= $this->createTitleInput(ROOT_BLOCK)
+ . $this->createGlobalFeatures()
+
+ . $this->createButtonbar(ROOT_BLOCK);
+ break;
+
+ case ARRANGMENT_BLOCK:
+
+ $content .= $this->createTitleInput(ARRANGMENT_BLOCK);
+
+ $group = &$this->tree->getGroupObject($itemID);
+ if ($children = $group->getChildren()) {
+ if ($this->getInstance($children[0]->getObjectID()) == ARRANGMENT_BLOCK)
+ $show = ARRANGMENT_BLOCK;
+ else
+ $show = QUESTION_BLOCK;
+ } else
+ $show = "both";
+ $content .= $this->createButtonbar($show);
+ break;
+
+ case QUESTION_BLOCK:
+
+ $content .= $this->createTitleInput(QUESTION_BLOCK)
+ . $this->createQuestionFeatures()
+ . $this->createQuestionForm()
+ . $this->createButtonbar(NULL);
+ break;
+ }
+
+ $content .= "</form>\n";
+
+ return $content;
+ }
+
+
+ /**
+ * prints out the lines before an item ("Strichlogik" (c) rstockm)
+ *
+ * @access private
+ * @param string $item_id the current item
+ * @param string $start_itemID the start item
+ * @return string the level output (html)
+ */
+ function createTreeLevelOutput($item_id, $start_itemID = NULL)
+ {
+
+ $level_output = "";
+
+ // without the first strichcode
+ $item_parent = $this->tree->tree_data[$item_id]['parent_id'];
+ $startitem_parent = $this->tree->tree_data[$this->startItemID]['parent_id'];
+
+ if (($item_parent != $startitem_parent) && ($item_parent != NULL)
+ && (
+ ($item_id != ROOT_BLOCK) ||
+ ($item_id != $this->tree->tree_data[$this->startItemID]['parent_id']))) {
+ if ($this->tree->isLastKid($item_id) || $item_id == ROOT_BLOCK)
+ $level_output = "<td class=\"blank tree-indent\" valign=\"top\" "
+ . "nowrap>"
+ . Assets::img('forumstrich2.gif')
+ . "</td>"; //last
+ else
+ $level_output = " <td class=\"blank tree-indent\" valign=\"top\" "
+ . "nowrap>"
+ . Assets::img('forumstrich3.gif')
+ . "</td>"; //crossing
+
+ $parent_id = $item_id;
+ $counter = 0;
+ while (
+ (0) &&
+ ($this->tree->tree_data[$parent_id]['parent_id'] != $this->tree->tree_data[$this->startItemID]['parent_id']) &&
+ ($this->tree->tree_data[$parent_id]['parent_id'] != $start_itemID) &&
+ ($this->tree->tree_data[$parent_id]['parent_id'] != ROOT_BLOCK)) {
+ $parent_id = $this->tree->tree_data[$parent_id]['parent_id'];
+ $counter++;
+
+ if ($this->tree->isLastKid($parent_id)) {
+ $level_output = "<td class=\"blank\" valign=\"top\" "
+ . "width=\"10\" nowrap>"
+ . Assets::img('forumleer.gif')
+ . "</td>"
+ . $level_output; //nothing
+ } else {
+ $level_output = " <td class=\"blank tree-indent\" valign=\"top\" "
+ . "nowrap>"
+ . Assets::img('forumstrich.gif')
+ . "</td>"
+ . $level_output; //vertical line
+ }
+
+ }
+
+ // the root-item
+ if ((0) &&
+ ($this->startItemID == ROOT_BLOCK) &&
+ ($this->tree->tree_data[$item_id]['parent_id'] == ROOT_BLOCK)) {
+ $level_output = "<td class=\"blank\" valign=\"top\" "
+ . "width=\"10\" nowrap>"
+ . Assets::img('forumleer.gif')
+ . "</td>"
+ . $level_output; //nothing
+ }
+
+ }
+
+ $html = "<table border=\"0\" width=\"100%\" cellspacing=\"0\" "
+ . "cellpadding=\"0\">"
+ . " <tr>$level_output";
+ return $html;
+ }
+
+
+ /**
+ * prints out one item
+ *
+ * @access private
+ * @param string $item_id the items id
+ * @return string one item (html)
+ */
+ function createTreeItemOutput($item_id)
+ {
+
+ $html = " <td class=\"printhead\" nowrap align=\"left\" "
+ . "valign=\"bottom\">\n"
+ . $this->getItemHeadPics($item_id) . "\n"
+ . " </td>\n"
+ . " <td class=\"printhead\" nowrap width=\"1\" valign=\"middle\">\n";
+ if ($this->anchor == $item_id)
+ $html .= "<a name=\"anchor\">";
+ $html .= Assets::img('forumleer.gif');
+ if ($this->anchor == $item_id)
+ $html .= "</a>";
+ $html .= "\n"
+ . " </td>\n"
+ . " <td class=\"printhead\" align=\"left\" width=\"99%\" "
+ . "nowrap valign=\"bottom\">"
+ . $this->getItemHead($item_id)
+ . " </td>\n"
+ . " </tr>\n"
+ . "</table>\n";
+ if ($this->itemID == $item_id)
+ $html .= $this->createTreeItemDetails($item_id);
+ return $html;
+ }
+
+
+ /**
+ * prints out the item details
+ *
+ * @access private
+ * @param string $item_id the current item
+ * @return string the item details (html)
+ */
+ 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;
+ $isLastKid = YES;
+ break;
+ break;
+
+ case ARRANGMENT_BLOCK:
+ $group = &$this->tree->getGroupObject($item_id);
+ $hasKids = ($group->getNumberChildren() == 0)
+ ? NO
+ : YES;
+
+ $par = $this->getInstance($group->getParentID());
+
+ if ($par == ROOT_BLOCK)
+ $parent = new Evaluation ($group->getParentID(), NULL, EVAL_LOAD_FIRST_CHILDREN);
+ else
+ $parent =& $this->tree->getGroupObject($group->getParentID());
+
+ $isLastKid = ($parent->getNumberChildren()
+ == $group->getPosition() + 1)
+ ? YES
+ : NO;
+ break;
+
+ case QUESTION_BLOCK:
+
+ $hasKids = NO;
+
+ $group =& $this->tree->getGroupObject($item_id);
+ $par = $this->getInstance($group->getParentID());
+
+ if ($par == ROOT_BLOCK) $parent = new Evaluation ($group->getParentID(), NULL, EVAL_LOAD_FIRST_CHILDREN);
+ else $parent = &$this->tree->getGroupObject($group->getParentID);
+ $isLastKid = ($parent->getNumberChildren()
+ == $group->getPosition() + 1)
+ ? YES
+ : NO;
+ break;
+
+ default:
+ $hasKids = NO;
+ $isLastKid = NO;
+ break;
+ }
+
+ if (!$hasKids || (!$this->itemID == $item_id))
+ $level_output = $this->createLevelOutputTD("forumleer.gif") . $level_output;
+ else
+ $level_output = $this->createLevelOutputTD("forumstrich.gif") . $level_output;#
+
+
+ if ($item_id != $this->startItemID) {
+ $parent_id = $item_id;
+
+ while (($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'];
+ }
+ }
+
+ $table = new HTML ("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "0");
+ $table->addAttr("width", "100%");
+
+ $tr = new HTML ("tr");
+
+ if ($level_output) ;
+ $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 = "&nbsp;";
+ if ($this->tree->tree_data[$itemID]['name'] == "" && $mode == QUESTION_BLOCK)
+ $head .= NO_QUESTION_GROUP_TITLE;
+ else
+ $head .= htmlready(my_substr(
+ $this->tree->tree_data[$itemID]['name'], 0, 60));
+
+ } else {
+
+ if ($mode == QUESTION_BLOCK) {
+
+ $group = &$this->tree->getGroupObject($itemID);
+ $templateID = $group->getTemplateID();
+ if ($templateID) {
+ $template = new EvaluationQuestion($templateID);
+ $templateTitle = htmlReady($template->getText());
+ } else
+ $templateTitle = NO_TEMPLATE_GROUP;
+
+ if ($templateTitle == "")
+ $templateTitle = NO_TEMPLATE;
+
+ $template = " </td>\n"
+ . " <td align=\"right\" valign=\"bottom\" "
+ . "class=\"printhead\" nowrap=\"nowrap\">\n"
+ . "<b>"
+ . _("Vorlage") . ": "
+ . $templateTitle
+ . "</b>&nbsp;";
+
+ }
+
+ $head = "&nbsp;<a class=\"tree\" href=\""
+ . URLHelper::getLink($this->getSelf("itemID={$itemID}", false)) . "\"" . tooltip(_("Diesen Block öffnen"), true) . ">";
+
+ if ($this->tree->tree_data[$itemID]['name'] == "" && $mode == QUESTION_BLOCK)
+ $head .= NO_QUESTION_GROUP_TITLE;
+ else
+ $head .= htmlready(my_substr(
+ $this->tree->tree_data[$itemID]['name'], 0, 60));
+ $head .= "</a>";
+
+ if ($template)
+ $head .= $template;
+ }
+
+ if ($itemID == ROOT_BLOCK)
+ $itemID2 = $this->evalID;
+ else
+ $itemID2 = $itemID;
+
+ // the "verschiebäfinger"
+ if ($this->moveItemID &&
+ ($this->tree->tree_data[$itemID]['parent_id'] != $this->moveItemID) &&
+ ($mode == ARRANGMENT_BLOCK || $itemID == ROOT_BLOCK) &&
+ $this->moveItemID != $itemID2) {
+
+ $parentID = $this->tree->tree_data[$itemID]['parent_id'];
+ if (!$parentID) $parentID = ROOT_BLOCK;
+ while ($parentID != ROOT_BLOCK && $parentID != $this->moveItemID) {
+ $parentID = $this->tree->tree_data[$parentID]['parent_id'];
+ if ($parentID == $this->moveItemID)
+ $moveItemIsParent = 1;
+ }
+
+ $moveItem = " </td>\n"
+ . " <td align=\"right\" valign=\"middle\" class=\"printhead\" nowrap=\"nowrap\">\n"
+ . $this->createLinkImage(EVAL_PIC_MOVE_GROUP,
+ _("Den ausgwählten Block in diesen Block verschieben"),
+ "&itemID=$itemID&cmd=MoveGroup",
+ NO, NULL, NO)
+ . "&nbsp;";
+ }
+
+ if ($moveItem && !$moveItemIsParent) {
+ $move_mode = $this->getInstance($this->moveItemID);
+
+ if ($mode == ARRANGMENT_BLOCK) {
+ $group = &$this->tree->getGroupObject($itemID);
+ if ($children = $group->getChildren()) {
+ if ($this->getInstance($children[0]->getObjectID()) == ARRANGMENT_BLOCK)
+ $move_type = ARRANGMENT_BLOCK;
+ else
+ $move_type = QUESTION_BLOCK;
+ } else
+ $move_type = "both";
+ } elseif ($mode == ROOT_BLOCK)
+ $move_type = ARRANGMENT_BLOCK;
+ else
+ $move_type = "no";
+
+
+ if (($move_type == "both") ||
+ ($move_mode == $move_type)) {
+ $head .= $moveItem;
+ }
+ }
+
+ if (!($this->tree->isFirstKid($itemID) && $this->tree->isLastKid($itemID)) &&
+ ($itemID != $this->startItemID) &&
+ ($this->tree->tree_data[$itemID]['parent_id'] == $this->startItemID)) {
+ $head .= " </td>\n"
+ . " <td align=\"right\" valign=\"bottom\" class=\"printhead\" nowrap=\"nowrap\">\n"
+ . $this->createLinkImage(EVAL_PIC_MOVE_UP,
+ _("Block nach oben verschieben"),
+ "cmd=Move&direction=up&groupID=$itemID",
+ NO)
+ . $this->createLinkImage(EVAL_PIC_MOVE_DOWN,
+ _("Block nach unten verschieben"),
+ "cmd=Move&direction=down&groupID=$itemID",
+ NO)
+ . "&nbsp;";
+ }
+ 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 ($this->msg[$itemID]) {
+ $msg = explode("§", $this->msg[$itemID]);
+
+ if ($msg[0] == 'msg') {
+ $msg[0] = 'success';
+ }
+ if (mb_strpos($msg[1], '<br>')) {
+ $details = explode("<br>", $msg[1]);
+ $msg[1] = array_shift($details);
+ }
+
+ return (string)MessageBox::{$msg[0]}($msg[1], $details);
+ } else {
+ return NULL;
+ }
+ }
+
+
+ /**
+ * creates a self-url with add. items
+ *
+ * @access private
+ * @param string $param params (optional)
+ * @param boolean $with_start_item startItem needed? (optional)
+ * @return string the self url
+ */
+ function getSelf($param = "", $with_start_item = true)
+ {
+
+ $url = "?page=edit";
+
+ if ($this->evalID)
+ $url .= "&evalID=" . $this->evalID;
+ else
+ $url .= "&evalID=" . Request::option("evalID");
+
+ if ($param) {
+ $url .= (($with_start_item)
+ ? "&itemID=" . $this->startItemID . "&"
+ : "&") . $param;
+ } else {
+ $url .= (($with_start_item)
+ ? "&itemID=" . $this->startItemID
+ : "");
+ }
+
+ if ($this->moveItemID)
+ $url .= "&moveItemID=" . $this->moveItemID;
+
+ $url .= "#anchor";
+
+ return $url;
+ }
+
+# ################################################### end: show tree functions #
+
+
+################################################################################
+# #
+# command functions #
+# #
+################################################################################
+
+ /**
+ * parses the _Request-commands and calls the avaible functions
+ *
+ * @access private
+ */
+ function parseCommand()
+ {
+
+ 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 {
+
+ # 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 ($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 ($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 ($group->isError) {
+ return MessageBox::error(_("Fehler beim Einlesen (Block)"));
+ }
+ $this->msg[$this->itemID] = "msg§"
+ . _("Veränderungen wurden gespeichert.");
+ $group = null;
+ break;
+ case QUESTION_BLOCK:
+
+ $group = &$this->tree->getGroupObject($this->itemID, true);
+ $group->setTitle($title);
+ $group->setText($text);
+ $group->setMandatory(Request::get('mandatory'));
+ $group->save();
+
+ // update the questions
+ $msg = $this->execCommandUpdateQuestions();
+
+ $no_answers = 0;
+ $group = &$this->tree->getGroupObject($this->itemID, true);
+ // info about missing answers
+ if ($group->getChildren() && $group->getTemplateID() == NULL) {
+ foreach ($group->getChildren() as $question) {
+ if ($question->getChildren() == NULL)
+ $no_answers++;
+ }
+ if ($no_answers == 1) {
+ if ($this->msg[$this->itemID])
+ $this->msg[$this->itemID] .= "<br>" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen.");
+ else
+ $this->msg[$this->itemID] .= "info§" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen.");
+ } elseif ($no_answers > 1) {
+ if ($this->msg[$this->itemID])
+ $this->msg[$this->itemID] .= "<br>" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers);
+ else
+ $this->msg[$this->itemID] .= "info§" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers);
+ }
+
+ }
+
+ if ($group->isError) {
+ return MessageBox::error("Fehler beim Einlesen (Fragenblock)");
+ }
+ if ($this->msg[$this->itemID])
+ $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert.");
+ else
+ $this->msg[$this->itemID] .= "msg§"
+ . _("Veränderungen wurden gespeichert.");
+
+ if ($msg) {
+ $this->msg[$this->itemID] = $this->msg[$this->itemID] . "<br>" . $msg;
+ }
+ break;
+ default:
+ $this->msg[$this->itemID] .= "info§"
+ . _("Falscher Blocktyp. Es wurden keine Veränderungen vorgenommen.");
+ break;
+ }
+
+ $this->changed = true;
+
+ return true;
+ }
+
+
+ /**
+ * Creates a delete-request
+ *
+ * @access public
+ * @return boolean false
+ */
+ function execCommandAssertDeleteItem()
+ {
+
+
+ $group = &$this->tree->getGroupObject($this->itemID);
+ if ($group->getChildType() == "EvaluationQuestion")
+ $numberofchildren = $group->getNumberChildren();
+ else
+ $numberofchildren = $this->tree->getNumKidsKids($this->itemID);
+
+ $title = htmlready($group->getTitle());
+
+ // constructing the message
+ $this->msg[$this->itemID] = "info§";
+
+ if ($group->getChildType() == "EvaluationQuestion") {
+ if ($numberofchildren) {
+ $this->msg[$this->itemID] .= ""
+ . sprintf(
+ _("Sie beabsichtigen den Fragenblock <b>%s</b> inklusive aller Fragen zu löschen. "),
+ $title)
+ . sprintf(_("Es werden insgesamt %s Fragen gelöscht!"), $numberofchildren);
+ } else {
+ $this->msg[$this->itemID] .= ""
+ . sprintf(
+ _("Sie beabsichtigen den Fragenblock <b>%s</b> inklusive aller Fragen zu löschen. "),
+ $title);
+ }
+ $this->msg[$this->itemID] .= "<br>"
+ . _("Wollen Sie diesen Fragenblock wirklich löschen?");
+ } else {
+ if ($numberofchildren) {
+ $this->msg[$this->itemID] .= ""
+ . sprintf(
+ _("Sie beabsichtigen den Gruppierungsblock <b>%s</b> inklusive aller Unterblöcke zu löschen. "),
+ $title)
+ . sprintf(_("Es werden insgesamt %s Unterblöcke gelöscht!"), $numberofchildren);
+ } else {
+ $this->msg[$this->itemID] .= ""
+ . sprintf(
+ _("Sie beabsichtigen den Gruppierungsblock <b>%s</b> inklusive aller Unterblöcke zu löschen. "),
+ $title);
+ }
+ $this->msg[$this->itemID] .= "<br>"
+ . _("Wollen Sie diesen Gruppierungsblock wirklich löschen?");
+ }
+
+ $this->msg[$this->itemID] .= "<br><br>"
+ . LinkButton::createAccept(_('JA!'),
+ $this->getSelf('cmd[DeleteItem]=1'),
+ ['title' => _('Löschen')])
+ . "&nbsp;"
+ . 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 ($group->isError) {
+ return MessageBox::error(_("Fehler beim Löschen eines Block."));
+ }
+
+ if ($group->getChildType() == "EvaluationQuestion") {
+ if ($numberofchildren) {
+ $this->msg[$parentID] = "msg§" . sprintf(_("Der Fragenblock <b>%s</b> und alle darin enthaltenen Fragen (insgesamt %s) wurden gelöscht. "), $title, $numberofchildren);
+ } else {
+ $this->msg[$parentID] = "msg§" . sprintf(_("Der Fragenblock <b>%s</b> wurde gelöscht. "), $title);
+ }
+ } else {
+ if ($numberofchildren) {
+ $this->msg[$parentID] = "msg§" . sprintf(_("Der Gruppierungsblock <b>%s</b> und alle Unterblöcke (insgesamt %s) wurden gelöscht. "), $title, $numberofchildren);
+ } else {
+ $this->msg[$parentID] = "msg§" . sprintf(_("Der Gruppierungsblock <b>%s</b> wurde gelöscht. "), $title);
+ }
+ }
+
+ $this->changed = true;
+
+ $this->startItemID = $parentID;
+ $this->itemID = $parentID;
+
+ return true;
+ }
+
+ /**
+ * Creates a new Group and adds it to the tree
+ *
+ * @access public
+ * @return boolean true (reinits the tree)
+ */
+ function execCommandAddGroup()
+ {
+
+
+ $group = new EvaluationGroup();
+ $group->setTitle(NEW_ARRANGMENT_BLOCK_TITLE);
+ $group->setText("");
+
+ $mode = $this->getInstance($this->itemID);
+
+ if ($mode == ROOT_BLOCK) {
+ $this->tree->eval->addChild($group);
+ $this->tree->eval->save();
+ if ($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 ($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 ($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 ($parentgroup->isError) {
+ return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks."));
+ }
+ if (Request::option("templateID") != "")
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Ein neuer Fragenblock mit der Antwortenvorlage <b>%s</b> wurde angelegt."),
+ htmlReady($template->getText()));
+ else
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Ein neuer Fragenblock mit keiner Antwortenvorlage wurde angelegt."),
+ 1);
+ }
+ $this->execCommandUpdateItem();
+
+ return true;
+ }
+
+ /**
+ * Updates the templateID of a group
+ *
+ * @access private
+ * @return boolean true (reinits the tree)
+ */
+ function execCommandChangeTemplate()
+ {
+
+
+ $this->execCommandUpdateItem();
+
+ $group = &$this->tree->getGroupObject($this->itemID);
+ $group->setTemplateID(Request::option("templateID"));
+ $group->save();
+
+ if ($group->isError) {
+ return MessageBox::error(_("Fehler beim Zuordnen eines Templates."));
+ }
+
+ $templateID = $group->getTemplateID();
+ if ($templateID) {
+
+ $template = new EvaluationQuestion($templateID);
+ $templateTitle = htmlReady($template->getText());
+
+ } else
+ $templateTitle = NO_TEMPLATE_GROUP;
+
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Die Vorlage <b>%s</b> wurde dem Fragenblock zugeordnet."),
+ $templateTitle);
+
+ return true;
+ }
+
+ /**
+ * Update the Question content
+ *
+ * @access private
+ * @param boolean $no_delete YES/NO (optional)
+ * @return string the udpatemessage
+ */
+ function execCommandUpdateQuestions($no_delete = false)
+ {
+
+ $questions = Request::getArray('questions');
+ $deleteQuestions = Request::getArray('DeleteQuestions');
+
+ // remove any empty questions
+ $deletecount = 0;
+
+ $qgroup = &$this->tree->getGroupObject($this->itemID);
+ $questionsDB = $qgroup->getChildren();
+ $cmd = Request::optionArray('cmd');
+ if (!empty($cmd))
+ if (key($cmd) == "UpdateItem")
+ $delete_empty_questions = 1;
+
+ for ($i = 0; $i < count($questions); $i++) {
+
+ if (!isset($deleteQuestions[$i])) {
+ $question = new EvaluationQuestion($questions[$i]['questionID'], NULL,
+ EVAL_LOAD_FIRST_CHILDREN);
+
+ // remove any empty questions
+ if ((empty($questions[$i]['text'])) && $delete_empty_questions) {
+
+ $question->delete();
+ $deletecount++;
+
+ // upadate the questiontext to the db
+ } else {
+
+ $question->setText($questions[$i]['text']);
+ $question->save();
+ }
+ }
+ }
+ $msg = NULL;
+ if ($deletecount == 1)
+ $msg = _("Es wurde eine leere Frage entfernt.");
+ elseif ($deletecount > 1)
+ $msg = sprintf(_("Es wurden %s leere Fragen entfernt."), $deletecount);
+
+ return $msg;
+ }
+
+ /**
+ * Adds Questions
+ *
+ * @access private
+ * @return boolean true (reinits the tree)
+ */
+ function execCommandAddQuestions()
+ {
+
+ $addquestions = Request::get('newQuestionFields');
+
+ $qgroup = &$this->tree->getGroupObject($this->itemID);
+ $templateID = $qgroup->getTemplateID();
+
+ for ($i = 1; $i <= $addquestions; $i++) {
+ $template = new EvaluationQuestion ($templateID, NULL, EVAL_LOAD_FIRST_CHILDREN);
+ $newquestion = $template->duplicate();
+ $newquestion->setText("");
+ $qgroup->addChild($newquestion);
+ $qgroup->save();
+ if ($qgroup->isError) {
+ return MessageBox::error(_("Fehler beim Anlegen neuer Fragen."));
+ }
+ }
+
+ if ($addquestions == "1")
+ $this->msg[$this->itemID] = "msg§"
+ . _("Es wurde eine neue Frage hinzugefügt.");
+ else
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Es wurden %s neue Fragen hinzugefügt."), $addquestions);
+
+ $this->execCommandUpdateItem(NO);
+
+ return true;
+ }
+
+ /**
+ * deletes questions
+ *
+ * @access private
+ * @return boolean true (reinits the tree)
+ */
+ function execCommandDeleteQuestions()
+ {
+
+ $questions = Request::getArray('questions');
+ $deleteQuestions = Request::getArray('DeleteQuestions');
+
+ $deletecount = 0;
+ for ($i = 0; $i < count($questions); $i++) {
+
+ $question = new EvaluationQuestion($questions[$i]['questionID'], NULL,
+ EVAL_LOAD_ALL_CHILDREN);
+
+ // remove any empty questions
+ if ($deleteQuestions[$i]) {
+ $question->delete();
+ $deletecount++;
+ }
+ }
+
+ if ($deletecount == "1")
+ $this->msg[$this->itemID] = "msg§"
+ . _("Es wurde eine Frage gelöscht.");
+ elseif ($deletecount > 1)
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Es wurden %s Fragen gelöscht."), $deletecount);
+ else
+ $this->msg[$this->itemID] = "msg§"
+ . _("Es wurde keine Frage gelöscht.");
+
+ $this->execCommandUpdateItem();
+
+ return true;
+ }
+
+ /**
+ * creates an info-message and updates the item
+ *
+ * @access private
+ * @return boolean true (reinits the tree)
+ */
+ function execCommandQuestionAnswersCreate()
+ {
+
+ $this->execCommandUpdateItem();
+
+ // extract the questionID from the command
+ foreach ($_REQUEST as $key => $value) {
+ if (preg_match("/template_(.*)_button?/", $key, $command))
+ break;
+ }
+ if (preg_match("/(.*)_#(.*)/", $command[1], $command_parts))
+ $questionID = $command_parts[2];
+
+ $question = new EvaluationQuestion($questionID);
+ $questiontitle = htmlReady($question->getText());
+
+ $this->msg[$this->itemID] = "msg§"
+# . sprintf(_("Sie können nun der Frage <b>%s</b> im rechten Bereich Antworten zuweisen.")
+# , $questiontitle)
+# . "<br>"
+ . _("Veränderungen wurden gespeichert.");
+
+ return true;
+ }
+
+ /**
+ * creates an confirm-message if answers were created
+ *
+ * @access private
+ * @return boolean false
+ */
+ function execCommandQuestionAnswersCreated()
+ {
+
+ $id = $this->itemID;
+
+ $question = new EvaluationQuestion(Request::get("questionID"));
+ $title = htmlready($question->getTitle());
+
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Der Frage <b>%s</b> wurden Antwortenmöglichkeiten zugewiesen."), $title);
+
+ $this->changed = true;
+
+ return false;
+ }
+
+ /**
+ * Moves a Questions
+ *
+ * @access private
+ * @return boolean true (reinits the tree)
+ */
+ function execCommandMoveQuestionUp()
+ {
+
+ $this->execCommandUpdateItem();
+
+ foreach ($_REQUEST as $key => $value) {
+ if (preg_match("/cmd_(.*)_#(.*)_§(.*)_button(_x)?/", $key, $command))
+ break;
+ }
+
+ $questionID = $command[2];
+ $oldposition = $command[3];
+
+ $this->swapPosition($this->itemID, $questionID, $oldposition,
+ "up");
+
+ if ($oldposition == 0)
+ $this->msg[$this->itemID] = "msg§"
+ . _("Die Frage wurde von Position 1 an die letzte Stelle verschoben.");
+ else
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Die Frage wurde von Position %s nach oben verschoben."), $oldposition + 1);
+
+ $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert.");
+ return true;
+ }
+
+ /**
+ * Moves a Questions
+ *
+ * @access private
+ * @return boolean true (reinits the tree)
+ */
+ function execCommandMoveQuestionDown()
+ {
+
+ $this->execCommandUpdateItem();
+
+ foreach ($_REQUEST as $key => $value) {
+ if (preg_match("/cmd_(.*)_#(.*)_§(.*)_button(_x)?/", $key, $command))
+ break;
+ }
+
+ $questionID = $command[2];
+ $oldposition = $command[3];
+
+ $this->swapPosition($this->itemID, $questionID, $oldposition,
+ "down");
+
+ if ($oldposition == $numberchild - 1)
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Die Frage wurde von Position %s an die erste Stelle verschoben.")
+ , $oldposition + 1);
+ else
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Die Frage wurde von Position %s nach oben verschoben."), $oldposition + 1);
+
+ $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert.");
+ return true;
+ }
+
+
+ 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 ($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 ($this->tree->eval->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($move_group->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($newgroup->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($grouptodelete->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Der Block <b>%s</b> wurde in die Hauptebene verschoben."),
+ $move_group_title);
+ break;
+
+ case ARRANGMENT_BLOCK:
+
+ $group = &$this->tree->getGroupObject($this->itemID);
+ if ($children = $group->getChildren()) {
+ if ($this->getInstance($children[0]->getObjectID()) != $move_mode) {
+ $this->msg[$this->itemID] = "msg§"
+ . _("Fehler beim Verschieben eines Blocks. Der ausgewählte Block und der Zielblock besitzen verschiedene Typen.");
+ return false;
+ }
+ }
+ if ($oldparentID == $this->evalID) {
+ $grouptodelete = $this->tree->eval->getChild($move_group->getObjectID());
+ $grouptodelete->delete();
+ $this->tree->eval->save();
+ if ($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 ($oldparentgroup->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ }
+ $newgroup = $move_group->duplicate();
+
+ $group->addChild($newgroup);
+ $group->save();
+
+
+ if ($group->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($move_group->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($newgroup->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($grouptodelete->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+
+
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Der Block <b>%s</b> wurde in diesen Gruppierungsblock verschoben."),
+ $move_group_title);
+ break;
+
+ case QUESTION_BLOCK:
+
+ $group = &$this->tree->getGroupObject($this->itemID);
+
+ if ($children = $group->getChildren()) {
+ if ($this->getInstance($children[0]->getObjectID()) != $move_mode) {
+ $this->msg[$this->itemID] = "msg§"
+ . _("Fehler beim Verschieben eines Blocks. Der ausgewählte Block und der Zielblock besitzen verschiedene Typen.");
+ return false;
+ }
+ }
+
+ $oldparentID = $move_group->getParentID();
+ if ($oldparentID == ROOT_BLOCK) {
+
+ $this->msg[$this->itemID] = "msg§"
+ . _("Fehler beim Verschieben eines Blocks. Ein Fragenblock kann nicht auf die oberste Ebene verschoben werden.");
+ return false;
+ } elseif ($oldparentID == $this->evalID) {
+
+ $this->msg[$this->itemID] = "msg§"
+ . _("Fehler beim Verschieben eines Blocks. Ein Fragenblock kann nicht auf die oberste Ebene verschoben werden.");
+ return false;
+ } else {
+
+ $oldparent = &$this->tree->getGroupObject($oldparentID);
+ }
+
+ $newgroup = $move_group->duplicate();
+
+ $group->addChild($newgroup);
+ $group->save();
+
+ $grouptodelete = $oldparent->getChild($move_group->getObjectID());
+ $grouptodelete->delete();
+ $oldparent->save();
+
+
+ if ($group->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($move_group->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($newgroup->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($grouptodelete->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+ if ($oldparent->isError)
+ return MessageBox::error(_("Fehler beim Verschieben eines Blocks."));
+
+ $this->msg[$this->itemID] = "msg§"
+ . sprintf(_("Der Block <b>%s</b> wurde in diesen Fragenblock verschoben."),
+ $move_group_title);
+
+ break;
+ }
+
+ $this->moveItemID = NULL;
+
+ $this->changed = true;
+
+ return true;
+ }
+
+# ##################################################### end: command functions #
+
+
+################################################################################
+# #
+# HTML functions #
+# #
+################################################################################
+
+ /**
+ * creates the html for the create new group options
+ *
+ * @access private
+ *
+ * @param string $show the blocktyp to display
+ * @return string the buttons (html)
+ */
+ function createButtonbar($show = ARRANGMENT_BLOCK)
+ {
+
+ $infotext = _("Sie können ...") . "\n";
+
+ $table = new HTML ("table");
+ $table->addAttr("width", "100%");
+ $table->addAttr("class", "blank");
+ $table->addAttr("border", "0");
+ $table->addAttr("cellpadding", "6");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("div", "left");
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addAttr("class", "steelgrau");
+ $td->addAttr("align", "center");
+
+ $seperator = "&nbsp;|&nbsp;&nbsp;";
+
+ // the update-button
+ $buttons = "&nbsp;"
+ . 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)
+ ? "&nbsp;"
+ : $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 &&
+ $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")
+ . "&nbsp;"
+ . Button::create(_('Erstellen'),
+ 'cmd[AddGroup]',
+ ['title' => _('Einen neuen Gruppierungsblock erstellen')]);
+
+ $qgroup_selection = _("Fragenblock mit")
+ . "&nbsp;"
+ . $this->createTemplateSelection()
+ . Button::create(_('Erstellen'),
+ 'cmd[AddQGroup]',
+ ['title' => _('Einen neuen Fragenblock erstellen')]);
+
+ $seperator = "&nbsp;|&nbsp;";
+
+ 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 . "&nbsp;";
+
+ $a_content = LinkButton::createCancel(_('Abbrechen'),
+ URLHelper::getURL(EVAL_FILE_ADMIN . "?evalID=" . $this->tree->eval->getObjectID() . "&abort_creation_button=1"),
+ ['title' => _("Erstellung einer Evaluation abbrechen")]);
+
+ $cancel .= $a_content;
+
+ $td->addHTMLContent($cancel);
+
+ }
+
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+
+ return $table->createContent();
+ }
+
+ /**
+ * creates the html for the title and text input
+ *
+ * @access private
+ * @param string $mode
+ * @return string the html
+ */
+ function createTitleInput($mode = ROOT_BLOCK)
+ {
+
+ switch ($mode) {
+
+ case ROOT_BLOCK:
+ $title_label = _("Titel der Evaluation");
+ $title = htmlReady($this->tree->eval->getTitle());
+ $text_label = _("Zusätzlicher Text");
+ $text = wysiwygReady($this->tree->eval->getText());
+ break;
+
+ case ARRANGMENT_BLOCK:
+ $title_label = _("Titel des Gruppierungsblocks");
+ $group = &$this->tree->getGroupObject($this->itemID);
+ $title = htmlReady($group->getTitle());
+ $text_label = _("Zusätzlicher Text");
+ $text = wysiwygReady($group->getText());
+ break;
+
+ case QUESTION_BLOCK:
+ $title_label = _("Titel des Fragenblocks");
+ $title_info = _("Die Angabe des Titels ist bei einem Fragenblock optional.");
+ $group = &$this->tree->getGroupObject($this->itemID);
+ $title = htmlReady($group->getTitle());
+ $text_label = _("Zusätzlicher Text");
+ $text = wysiwygReady($group->getText());
+ break;
+ }
+ $text_info = _("Die Angabe des zusätzlichen Textes ist optional.");
+
+ $table = new HTML ("table");
+ $table->addAttr("width", "98%");
+ $table->addAttr("border", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("cellpadding", "0");
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addAttr('colspan', '2');
+ $label = new HTML('label');
+ $label->addContent($title_label);
+ if ($mode == QUESTION_BLOCK)
+ $label->addHTMLContent($this->createImage(EVAL_PIC_HELP, $title_info));
+
+
+ $input = new HTMLempty ("input");
+ $input->addAttr("type", "text");
+ $input->addAttr("name", "title");
+ $input->addString("value=\"" . $title . "\"");
+ $input->addAttr("size", "60");
+ $input->addAttr("style", "vertical-align:middle; width: 100%;");
+
+ $label->addContent($input);
+
+ $td->addContent($label);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addAttr('colspan', '2');
+
+ $label = new HTML('label');
+ $label->addContent($text_label);
+ $label->addHTMLContent($this->createImage(EVAL_PIC_HELP, $text_info));
+
+ $textarea = "<br><textarea class=\"add_toolbar wysiwyg\" name=\"text\" rows=\"4\" "
+ . "style=\"vertical-align:top; width: 100%;\">";
+ $textarea .= ($text)
+ ? $text
+ : "";
+ $textarea .= "</textarea>";
+
+ $label->addHTMLContent($textarea);
+ $label->setTextareaCheck();
+
+ $td->addContent($label);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ return $table->createContent();
+ }
+
+ /**
+ * creates the html for the update button
+ *
+ * @access private
+ * @param string $mode
+ * @return string the html
+ */
+ function createUpdateButton($mode = NULL)
+ {
+
+ $button = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" "
+ . "cellspacing=\"2\">\n"
+ . " <tr>\n"
+ . " <td align=center>\n"
+// . " <input type=hidden name=\"cmd\" value=\"UpdateItem\">\n"
+ . Button::create(_('Übernehmen'),
+ 'cmd[UpdateItem]',
+ ['title' => _('Änderungen übernehmen.')]);
+
+ if ($mode == NULL) {
+ $button .= "&nbsp;&nbsp;|&nbsp;&nbsp;" . _("Diesen Block") . "&nbsp;"
+ . Button::create(_('Löschen'),
+ 'cmd[AssertDeleteItem]',
+ ['title', _('Diesen Block und alle seine Unterblöcke löschen.')]);
+ }
+
+ $button .= " </td>\n"
+ . " </tr>\n"
+// . " </form></tr>\n"
+ . "</table>\n";
+ return $button;
+ }
+
+ /**
+ * creates the html for the global features-input
+ *
+ * @access private
+ * @return string the html
+ */
+ function createGlobalFeatures()
+ {
+
+ $table = new HTML ("table");
+ $table->addAttr("width", "99%");
+ $table->addAttr("border", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("cellspacing", "2");
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addAttr("class", "table_row_odd");
+ $td->addAttr("colspan", "2");
+
+ $b = new HTML ("b");
+ $b->addContent(_("Globale Eigenschaften"));
+
+ $td->addContent($b);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addAttr('colspan', '2');
+
+ $div = new HTML('div');
+ $div->addContent(_("Die Auswertung der Evaluation läuft"));
+
+ $td->addContent($div);
+
+ $section = new HTML('section');
+ $section->addAttr('class', 'hgroup');
+
+ $l1 = new HTML('label');
+ $input = new HTMLempty ("input");
+ $input->addAttr("type", "radio");
+ $input->addAttr("value", "1");
+ $input->addAttr("name", "anonymous");
+ if ($this->tree->eval->isAnonymous())
+ $input->addAttr("checked", "checked");
+ $l1->addContent($input);
+ $l1->addContent(_("anonym"));
+
+ $l2 = new HTML('label');
+ $input2 = new HTMLempty ("input");
+ $input2->addAttr("type", "radio");
+ $input2->addAttr("value", "0");
+ $input2->addAttr("name", "anonymous");
+ if (!$this->tree->eval->isAnonymous())
+ $input2->addAttr("checked", "checked");
+ $l2->addContent($input2);
+ $l2->addContent(_("personalisiert"));
+
+ $section->addContent($l1);
+ $section->addContent($l2);
+
+ $td->addContent($section);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ return $table->createContent();
+ }
+
+ /**
+ * creates the html for the global features-input
+ *
+ * @access private
+ * @return string the html
+ */
+ function createQuestionFeatures()
+ {
+
+ $group = &$this->tree->getGroupObject($this->itemID);
+ $templateID = $group->getTemplateID();
+
+ if ($templateID) {
+ $template = new EvaluationQuestion($templateID);
+ $templateTitle = htmlReady($template->getText());
+ } else
+ $templateTitle = NO_TEMPLATE_GROUP;//_("keine Vorlage");
+
+ if ($templateTitle == "")
+ $templateTitle = NO_TEMPLATE;
+
+ $table = new HTML ("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "0");
+ $table->addAttr("width", "98%");
+// $table->addAttr ("style", "border:5px solid white;");
+
+ $tr = new HTML ("tr");
+
+ $td = new HTMl ("td");
+ $td->addAttr("class", "table_row_odd");
+ $td->addAttr("colspan", "2");
+
+ $b = new HTML ("b");
+ $b->addContent(_("Eigenschaften"));
+ $b->addContent(":");
+
+ $td->addContent($b);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ $tr = new HTML ("tr");
+
+ $td = new HTMl ("td");
+ $td->addAttr("style", "border-bottom:0px dotted black;");
+ $td->addContent(_("Die Fragen dieses Blocks müssen beantwortet werden (Pflichtfelder):"));
+
+ $tr->addContent($td);
+
+ $td = new HTMl ("td");
+ $td->addAttr("style", "border-bottom:0px dotted black;");
+
+ $input = new HTMLempty ("input");
+ $input->addAttr("type", "radio");
+ $input->addAttr("value", "0");
+ $input->addAttr("name", "mandatory");
+ if (!$group->isMandatory()) $input->addAttr("checked", "checked");
+
+ $td->addContent($input);
+ $td->addContent(_("nein"));
+ $td->addContent(new HTMLempty ("br"));
+
+ $input = new HTMLempty ("input");
+ $input->addAttr("type", "radio");
+ $input->addAttr("value", "1");
+ $input->addAttr("name", "mandatory");
+ if ($group->isMandatory()) $input->addAttr("checked", "checked");
+
+ $td->addContent($input);
+ $td->addContent(_("ja"));
+
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addAttr("style", "border-bottom:0px dotted black;");
+ $td->addHTMLContent(sprintf(_("Diesem Fragenblock ist die Antwortenvorlage <b>%s</b> zugewiesen."),
+ $templateTitle));
+ $text = _("Das Zuweisen einer Antwortenvorlage ändert alle Antwortenmöglichkeiten der Fragen dieses Fragenblocks.");
+ if ($templateTitle == NO_TEMPLATE_GROUP)
+ $text .= " " . _("Da dieser Fragenblock keine Antwortenvorlage benutzt, würde ein Zuweisen einer Antwortenvorlage zum Verlust aller eingegebenen Antworten führen.");
+
+ $td->addHTMLContent($this->createImage(EVAL_PIC_HELP,
+ $text));
+
+ $tr->addContent($td);
+
+ $td = new HTML ("td");
+ $td->addAttr("style", "border-bottom:0px dotted black;");
+ $td->addAttr("nowrap", "nowrap");
+ $td->addHTMLContent($this->createTemplateSelection($templateID));
+ $td->addContent(" ");
+ $td->addHTMLContent(Button::create(_('Zuweisen'),
+ 'cmd[ChangeTemplate]',
+ ['title' => _('Eine andere Antwortenvorlage für diesen Fragenblock auswählen')]));
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ return $table->createContent();
+ }
+
+ /**
+ * creates the html for the question-input
+ *
+ * @access private
+ * @return string the html
+ */
+ function createQuestionForm()
+ {
+
+ $qgroup = &$this->tree->getGroupObject($this->itemID);
+ $questions = $qgroup->getChildren();
+ $templateID = $qgroup->getTemplateID();
+
+ $table = new HTML ("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("width", "98%");
+
+ $tr = new HTML ("tr");
+
+ $td = new HTML ("td");
+ $td->addAttr("align", "center");
+
+ $table2 = new HTML ("table");
+ $table2->addAttr("border", "0");
+ $table2->addAttr("class", "blank");
+ $table2->addAttr("cellspacing", "0");
+ $table2->addAttr("cellpadding", "0");
+ $table2->addAttr("width", "100%");
+
+ // captions
+ $tr2 = new HTML ("tr");
+
+ $showclass = "table_row_odd";
+
+ $td2 = new HTML ("td");
+ $td2->addAttr("class", $showclass);
+ $td2->addAttr("align", "center");
+ $td2->addAttr("width", "15");
+
+ $b = new HTML ("b");
+ $b->addContent("#");
+
+ $td2->addContent($b);
+ $tr2->addContent($td2);
+
+ $td2 = new HTML ("td");
+ $td2->addAttr("class", $showclass);
+
+ $b = new HTML ("b");
+ $b->addContent(_("Frage"));
+
+ $td2->addContent($b);
+ $tr2->addContent($td2);
+
+ $td2 = new HTML ("td");
+ $td2->addAttr("class", $showclass);
+
+ if (count($questions) > 1) {
+ $b = new HTML ("b");
+ $b->addContent(_("Position"));
+
+ $td2->addContent($b);
+
+ } else {
+
+ $td2->addContent("");
+
+ }
+
+ $tr2->addContent($td2);
+
+ $td2 = new HTML ("td");
+ $td2->addAttr("class", $showclass);
+
+ $b = new HTML ("b");
+ $b->addContent(_("Löschen"));
+
+ $td2->addContent($b);
+ $tr2->addContent($td2);
+
+ // only if template is NO_TEMPLATE_GROUP
+ if ($templateID == NULL) {
+ $td2 = new HTML ("td");
+ $td2->addAttr("class", $showclass);
+
+ $b = new HTML ("b");
+ $b->addContent(_("Antworten"));
+
+ $td2->addContent($b);
+ $tr2->addContent($td2);
+ }
+
+ $table2->addContent($tr2);
+
+ $i = 0;
+ foreach ($questions as $question) {
+ $tr2 = new HTML ("tr");
+
+ // brrr :)
+ // extract the questionID from the command
+ foreach ($_REQUEST as $key => $value) {
+ if (preg_match("/template_(.*)_button?/", $key, $command))
+ break;
+ }
+ if (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();
+ $instance = $group->x_instanceof();
+
+ 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 ($swapitem->isError) {
+ return MessageBox::error(_("Fehler beim verschieben."));
+ }
+ if ($object->isError) {
+ return MessageBox::error(_("Fehler beim verschieben."));
+ }
+ }
+}
diff --git a/lib/evaluation/classes/EvaluationTreeShowUser.class.php b/lib/evaluation/classes/EvaluationTreeShowUser.class.php
new file mode 100644
index 0000000..f266ccd
--- /dev/null
+++ b/lib/evaluation/classes/EvaluationTreeShowUser.class.php
@@ -0,0 +1,536 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +---------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +---------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +---------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +---------------------------------------------------------------------------+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once HTML;
+# ====================================================== end: including files #
+
+# Define constants ========================================================== #
+
+/**
+ * The number of pixels by which each sub-group is indented.
+ * @const INDENT_PIXELS
+ * @access private
+ */
+define("INDENT_PIXELS", 5);
+
+# ===================================================== end: define constants #
+
+
+/**
+ * Class to print out html representation of an evaluation's tree
+ * for the participation page
+ * (based on /lib/classes/TreeView.class)
+ *
+ * @author mcohrs <michael A7 cohrs D07 de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ */
+class EvaluationTreeShowUser
+{
+
+ /**
+ * Reference to the tree structure
+ *
+ * @access private
+ * @var object EvaluationTree $tree
+ */
+ var $tree;
+
+ /**
+ * contains the item with the current html anchor (currently unused)
+ *
+ * @access public
+ * @var string $anchor
+ */
+ var $anchor;
+
+ /**
+ * the item to start with
+ *
+ * @access private
+ * @var string $start_item_id
+ */
+ var $start_item_id;
+
+
+ /**
+ * constructor
+ * @access public
+ * @param string the eval's ID
+ */
+ public function __construct($evalID)
+ {
+
+ $this->tree = TreeAbstract::GetInstance("EvaluationTree", ['evalID' => $evalID,
+ 'load_mode' => EVAL_LOAD_ALL_CHILDREN]);
+
+ }
+
+
+ /**
+ * prints out the tree beginning with a given item
+ *
+ * @access public
+ * @param string ID of the start item, shouldnt be needed.
+ */
+ public function showTree($item_id = "root")
+ {
+ $items = [];
+
+ if (!is_array($item_id)) {
+ $items[0] = $item_id;
+ $this->start_item_id = $item_id;
+ } else {
+ $items = $item_id;
+ }
+
+ $num_items = count($items);
+ for ($j = 0; $j < $num_items; ++$j) {
+
+ $this->printLevelOutput($items[$j]);
+ $this->printItemOutput($items[$j]);
+
+ if ($this->tree->hasKids($items[$j])) {
+ $this->showTree($this->tree->tree_childs[$items[$j]]);
+ }
+ }
+ return;
+ }
+
+
+ /**
+ * prints out ... hmm ... the group's level indentation space, and a table start
+ *
+ * @access private
+ * @param string ID of the item (which is an EvaluationGroup) to print the space for.
+ */
+ public function printLevelOutput($group_id)
+ {
+ if ($group_id == "root")
+ return;
+
+ $level_output = "";
+
+ $parent_id = $group_id;
+ while ($this->tree->tree_data[$parent_id]['parent_id'] != $this->start_item_id) {
+ $parent_id = $this->tree->tree_data[$parent_id]['parent_id'];
+
+ /* a little space to indent subgroups */
+ $level_output .=
+ "<td valign=\"top\" width=\"" . INDENT_PIXELS . "\" height=\"1\" nowrap>" .
+ Assets::img('forumleer.gif', ['size' => INDENT_PIXELS . '@1']) .
+ "</td>";
+ }
+
+ echo "<!-- printLevelOutput ----------------- -->\n";
+ echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n";
+ echo "<tr>\n";
+ echo $level_output;
+ return;
+ }
+
+
+ /**
+ * prints out one group
+ *
+ * @access private
+ * @param string ID of the item to print (which is an EvaluationGroup).
+ */
+ public function printItemOutput($group_id)
+ {
+ if ($group_id == "root")
+ return;
+ $group = &$this->tree->getGroupObject($group_id);
+
+ echo "<td width=\"1\">\n";
+ echo "</td>\n";
+
+ /* show group headline, if it's not a question group */
+ if ($group->getChildType() != "EvaluationQuestion") {
+
+ /* add space after a top-level group */
+ $parent = $group->getParentObject();
+ if ($parent->x_instanceof() == "Evaluation" && $group->getPosition() != 0)
+ echo "<td colspan=\"2\" width=\"100%\"><br></td><tr>";
+
+ echo "<td align=\"left\" width=\"100%\" valign=\"bottom\" class=\"content_body\" style=\"padding:1px;\">\n";
+ $parent_id = $group_id;
+ 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 "&nbsp;" . $chapter_num . " ";
+ echo "<b>";
+ echo htmlReady($this->tree->tree_data[$group_id]['name']);
+ echo "</b>";
+ echo "</td>";
+
+ echo "<td width=\"1\">\n";
+ echo Assets::img('forumleer.gif', ['size' => '2@1']);
+ echo "</td>\n";
+
+ } else {
+ echo "<td width=\"100%\"></td>";
+ }
+
+ echo "</tr>\n";
+ echo "</table>\n";
+
+ $this->printItemDetails($group);
+
+ return;
+ }
+
+
+ /**
+ * prints out the details for a group
+ *
+ * @access private
+ * @param object EvaluationGroup the group object.
+ */
+ public function printItemDetails($group)
+ {
+ $group_id = $group->getObjectID();
+
+ $parent_id = $group_id;
+ while ($this->tree->tree_data[$parent_id]['parent_id'] != $this->start_item_id) {
+ $parent_id = $this->tree->tree_data[$parent_id]['parent_id'];
+
+ /* a little space to indent subgroups */
+ $level_output = "<td width=\"" . INDENT_PIXELS . "\">" .
+ Assets::img('forumleer.gif', ['size' => INDENT_PIXELS . '@1']) .
+ "</td>" .
+ $level_output;
+ }
+
+ /* print table */
+ echo "<!-- printItemDetails ----------------- -->\n";
+ echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n";
+ echo "<tr>\n" . $level_output;
+ echo "<td class=\"printcontent\" width=\"100%\" " .
+ ($group->getChildType() == "EvaluationQuestion"
+ ? ">"
+ : ">");
+ echo $this->getGroupContent($group);
+ echo "</td></tr>\n";
+ echo "</table>\n";
+ return;
+ }
+
+
+ /**
+ * returns html for the content of a group
+ *
+ * @access private
+ * @param object EvaluationGroup the group object.
+ * @return string
+ */
+ public function getGroupContent($group)
+ {
+ $closeTable = NO;
+ $html = "";
+ $content = "";
+
+ /* get title */
+ $content .= $group->getChildType() == "EvaluationQuestion" && $group->getTitle()
+ ? "<b>" . formatReady($group->getTitle()) . "</b><br>\n"
+ : "";
+
+ /* get text */
+ $content .= $group->getText()
+ ? formatReady($group->getText()) . "<br>\n"
+ : "";
+
+ /* get the content of questions under this group, if any */
+ foreach ($group->getChildren() as $question) {
+ if ($question->x_instanceof() == INSTANCEOF_EVALQUESTION) {
+
+ if ($question->getPosition() == 0) {
+ $content .= "\n<table width=\"100%\" cellpadding=\"3\" cellspacing=\"0\" " .
+ "align=\"center\" style=\"margin-top:3px;\">\n";
+ }
+
+ $content .= $this->getQuestionContent($question, $group);
+ $closeTable = YES;
+ }
+ }
+ if ($closeTable)
+ $content .= "</table>\n";
+
+ /* return if there is nothing to show */
+ if (empty($content))
+ return "";
+
+ /* build table of content */
+ $style = $group->getChildType() != "EvaluationQuestion"
+ ? ""
+ : "";
+
+ $class = $group->getChildType() != "EvaluationQuestion"
+ ? "eval_gray"
+ : "steelgroup7";
+ $html .= "\n<!-- getGroupContent ----------------- -->\n";
+ $html .= "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" " . $style . ">\n";
+ $html .= "<tr>\n";
+ $html .= "<td align=\"left\" class=\"" . $class . "\">\n";
+ $html .= $content;
+ $html .= "</td></tr>\n";
+ $html .= "</table>\n";
+
+ return $html;
+ }
+
+
+ /**
+ * returns html for a question and its answers
+ *
+ * @access private
+ * @param object EvaluationQuestion the question object.
+ * @param object EvaluationGroup the question's parent-group object.
+ * @return string
+ */
+ public function getQuestionContent($question, $group)
+ {
+
+ $type = $question->isMultipleChoice() ? "checkbox" : "radio";
+ $answerBorder = "1px dotted #909090";
+ $residualBorder = "1px dotted #909090";
+ $answerArray = $question->getChildren();
+ $hasResidual = NO;
+ $leftOutStyle = ($group->isMandatory() &&
+ Request::submitted('voteButton') &&
+ is_array($GLOBALS["mandatories"]) &&
+ in_array($question->getObjectID(), $GLOBALS["mandatories"]))
+ ? "background-image:url(" . Assets::image_path("steelgroup1.gif") . "); border-left:3px solid red; border-right:3px solid red;"
+ : "";
+
+ /* Skala (one row question) ---------------------------------------- */
+ if ($question->getType() == EVALQUESTION_TYPE_LIKERT || $question->getType() == EVALQUESTION_TYPE_POL) {
+
+ if (($numAnswers = $question->getNumberChildren()) > 0)
+ $cellWidth = (int)(40 / $numAnswers);
+
+ if ($numAnswers > 0 && $answerArray[$numAnswers - 1]->isResidual())
+ $hasResidual = YES;
+
+ $lastTextAnswer = $hasResidual ? ($numAnswers - 3) : ($numAnswers - 2);
+
+ /* Headline, only shown for first question */
+ if ($question->getPosition() == 0) {
+ $html .= " <tr>\n";
+ $html .= " <td width=\"60%\" style=\"border-bottom: $answerBorder; border-top: $answerBorder;\">";
+# $html .= mb_strlen( $group->getText() ) < 100 ? formatReady( $group->getText() ) : "&nbsp;";
+ $html .= "&nbsp;";
+ $html .= "</td>\n";
+ foreach ($answerArray as $answer) {
+ $noWrap = NO;
+
+ if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) {
+ if (!$answer->getText()) {
+ /* answer has NO text ------------ */
+ if ($answer->getPosition() <= $lastTextAnswer / 2) //&& $numAnswers > 4 )
+ $headCell = "&lt;--";
+ elseif ($answer->getPosition() >= round($lastTextAnswer / 2) + $lastTextAnswer % 2) //&& $numAnswers > 4 )
+ $headCell = "--&gt;";
+ else
+ $headCell = "&lt;- -&gt;";
+
+ $noWrap = YES;
+ } else {
+ /* answer has its own text ------ */
+ $headCell = formatReady($answer->getText());
+ }
+
+ $extraStyle = "";
+ if ($answer->isResidual()) {
+ $extraStyle = "border-left: $residualBorder;";
+ $html .=
+ "<td align=\"center\" style=\"$extraStyle\" " .
+ "width=\"1\">&nbsp;</td>";
+ }
+
+ $html .=
+ " <td align=\"center\" class=\"steelgroup6\" " .
+ "style=\"border-bottom: $answerBorder; " .
+ "border-left: $answerBorder; border-top: $answerBorder; $extraStyle;\" " .
+ "width=\"" . $cellWidth . "%\" " . ($noWrap ? "nowrap" : "") . ">";
+ $html .= $headCell;
+ $html .= "</td>\n";
+ }
+ }
+ $html .= " </tr>\n";
+ }
+ $class = $question->getPosition() % 2 ? "table_row_even" : "table_row_odd";
+ $extraStyle = ($question->getPosition() == $group->getNumberChildren() - 1
+ ? "border-bottom: $answerBorder"
+ : "");
+ $html .= " <tr class=\"" . $class . "\">\n";
+ $html .= " <td align=\"left\" width=\"60%\" style=\"$extraStyle; $leftOutStyle;\">";
+ $html .= formatReady($question->getText());
+ $html .= ($group->isMandatory() ? "<span class=\"eval_error\"><b>**</b></span>" : "");
+ $html .= "</td>\n";
+
+ foreach ($answerArray as $answer) {
+ $number = $question->isMultipleChoice() ? "[" . $answer->getPosition() . "]" : "";
+
+ if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) {
+ $extraStyle = "";
+ if ($answer->isResidual()) {
+ $extraStyle = "border-left: $residualBorder;";
+ $html .=
+ "<td align=\"center\" class=\"steelgroup7\" style=\"$extraStyle\" " .
+ "width=\"1%\">&nbsp;</td>";
+ }
+
+ $extraStyle .= ($question->getPosition() == $group->getNumberChildren() - 1
+ ? " border-bottom: $answerBorder;"
+ : "");
+ $answers = Request::getArray('answers');
+ $checked = $answers[$question->getObjectID()] == $answer->getObjectID() ? "checked" : "";
+
+ $html .= " <td align=\"center\" style=\"border-left: $answerBorder; $extraStyle;\" " .
+ "width=\"" . $cellWidth . "%\">";
+ $html .= "<input type=\"" . $type . "\" name=\"answers[" . $question->getObjectID() . "]" . $number . "\" " .
+ "value=\"" . $answer->getObjectID() . "\" " . $checked . ">";
+ $html .= "</td>\n";
+ }
+ }
+ $html .= " </tr>\n";
+ /* -------------------------------------------- */
+ } /* Normal (question with long answers) ----------------------------- */
+ else {
+ $class = $question->getPosition() % 2 ? "table_row_even" : "table_row_odd";
+
+ /* Question ----------------------------------- */
+ $html .=
+ "<tr class=\"" . $class . "\">" .
+ "<td align=\"left\" style=\"$leftOutStyle;\">" .
+ formatReady($question->getText()) .
+ ($group->isMandatory() ? "<span class=\"eval_error\"><b>**</b></span>" : "") .
+ "</td>" .
+ "</tr>\n";
+
+ $html .= "<tr class=\"" . $class . "\">";
+ $html .= "<td>";
+ $html .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\">\n";
+ /* -------------------------------------------- */
+
+ $numberOfVisibleAnswers = 0;
+ foreach ($answerArray as $answer)
+ if (!($answer->isFreetext() && $answer->getText() != ''))
+ $numberOfVisibleAnswers++;
+
+ if ($numberOfVisibleAnswers == 0) {
+ $html .= "<tr valign=\"middle\">\n";
+ $html .=
+ "<td class=\"eval_error\">" .
+ _("Dieser Frage wurden keine Antworten zugeordnet!") .
+ "</td>\n";
+ $html .= "</tr>\n";
+ }
+
+ /* Answers ------------------------------------ */
+ foreach ($answerArray as $answer) {
+ if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) {
+ $number = $question->isMultipleChoice() ? "[" . $answer->getPosition() . "]" : "";
+
+ /* if not a user's answer */
+ if (!($answer->isFreetext() && $answer->getText() != '')) {
+ $html .= "<tr valign=\"middle\">\n";
+
+ /* show text input field ---------- */
+ if ($answer->isFreetext()) {
+
+ // not really needed anymore
+ if ($numberOfVisibleAnswers > 1)
+ /* show a check/radio-box */
+ $html .=
+ "<td width=\"2%\">" .
+ "<input type=\"" . $type . "\"" .
+ " name=\"answers[" . $question->getObjectID() . "]" . $number . "\"" .
+ " value=\"" . $answer->getObjectID() . "\">" .
+ "</td>\n";
+
+ /* one row input field */
+ $freetexts = Request::getArray('freetexts');
+ if ($answer->getRows() == 1)
+ $html .=
+ "<td colspan=\"2\">" .
+ "<input type=\"text\"" .
+ " name=\"freetexts[" . $question->getObjectID() . "]\"" .
+ " value=\"" . htmlReady($freetexts[$question->getObjectID()]) . "\" size=\"60\">" .
+ "</td>\n";
+
+ /* multiple row input field (textarea) */
+ else
+ $html .=
+ "<td colspan=\"2\">" .
+ "<textarea" .
+ " name=\"freetexts[" . $question->getObjectID() . "]\"" .
+ " cols=\"60\" rows=\"" . $answer->getRows() . "\">" .
+ htmlReady($freetexts[$question->getObjectID()]) .
+ "</textarea>" .
+ "</td>\n";
+ } /* show normal answer ------------- */
+ else {
+ $answers = Request::getArray('answers');
+ /* see if it must be checked */
+ if ($type == "radio")
+ $checked = $answers[$question->getObjectID()] == $answer->getObjectID()
+ ? "checked"
+ : "";
+ else
+ $checked = (is_array($answers[$question->getObjectID()]) &&
+ in_array($answer->getObjectID(), $answers[$question->getObjectID()]))
+ ? "checked"
+ : "";
+
+ /* show a check/radio-box */
+ $html .=
+ "<td width=\"2%\">" .
+ "<input type=\"" . $type . "\"" .
+ " name=\"answers[" . $question->getObjectID() . "]" . $number . "\"" .
+ " value=\"" . $answer->getObjectID() . "\" " . $checked . ">" .
+ "</td>\n";
+ $html .=
+ "<td align=\"left\" width=\"98%\">" .
+ formatReady($answer->getText()) .
+ "</td>\n";
+ }
+ $html .= "</tr>\n";
+ }
+ }
+ /* ------------------------------- End: Answers */
+ }
+
+ $html .= "</table>\n";
+ $html .= "</td></tr>";
+ }
+
+ return $html;
+ }
+}
diff --git a/lib/evaluation/classes/HTML.class.php b/lib/evaluation/classes/HTML.class.php
new file mode 100644
index 0000000..50b01eb
--- /dev/null
+++ b/lib/evaluation/classes/HTML.class.php
@@ -0,0 +1,185 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * HTML-class for the Stud.IP-project.
+ * Based on scripts from "http://tut.php-q.net/".
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+require_once 'HTMLempty.class.php';
+
+class HTML extends HTMLempty
+{
+ /**
+ * Holds the content.
+ *
+ * @access private
+ * @var object $_content
+ */
+ var $_content;
+
+ /**
+ */
+ var $has_textarea = false;
+
+ public function addHTMLContent($_content)
+ {
+ if (is_object($_content)) {
+ $classname = mb_strtolower(get_class($_content));
+ $valid_classes = ['htmlempty', 'html', 'htm', 'htmpty', 'studip\button', 'studip\linkbutton', 'messagebox'];
+ if (in_array($classname, $valid_classes)) {
+ $this->_content[] = $_content;
+ } else {
+ trigger_error('Ungültiges Objekt: "' . $classname . '"', E_USER_ERROR);
+ }
+ } elseif (is_scalar($_content)) {
+ $this->_content[] = (string)$_content;
+ } else {
+ echo "Fehler in HTML.class.php: Es fehlt ein addHTMLContent-Element für ein Element des Typs \"&lt;" . $this->getName() . "&gt;\"<br>";
+ }
+ }
+
+ public function addContent($_content)
+ {
+ if (is_object($_content)) {
+ $this->addHTMLContent($_content);
+ } elseif (is_scalar($_content)) {
+ $this->addHTMLContent(htmlReady(((string)$_content)));
+ } else {
+ $this->addHTMLContent("");
+ }
+ }
+
+ /**
+ *
+ */
+ public function getContent()
+ {
+ return $this->_content;
+ }
+
+ /**
+ * avoid indentation of <textarea>...
+ */
+ public function setTextareaCheck()
+ {
+ $this->has_textarea = true;
+ }
+
+ /**
+ *
+ */
+ public function printContent($indent = 0)
+ {
+ echo $this->createContent($indent);
+ }
+
+ /**
+ *
+ */
+ public function createContent($indent = 0)
+ {
+ $output = "";
+
+ $str_indent = str_repeat(' ', $indent);
+
+ $_content = $this->getContent();
+ $output .= ($str_indent . "<" . $this->getName());
+
+ $attribute = $this->getAttr();
+ foreach ($attribute as $name => $value) {
+ $output .= (' ' . $name . '="' . $value . '"');
+ }
+
+ $output .= $this->_string;
+ $output .= (">\n");
+ if (!is_array($_content)) {
+ $attributes = "";
+ foreach ($attribute as $name => $value) {
+ $attributes .= ($name . '=&gt;"' . $value . '"; ');
+ }
+ print "Fehler in HTML.class.php: Es fehlt ein Content-Element für ein Element des Typs \"&lt;" . $this->getName() . "&gt;\" (Attribute: $attributes).";
+
+ return;
+ }
+
+ foreach ($_content as $content) {
+ if (is_object($content)) {
+ // der aktuelle Content ist ein Object
+ // also ein HTML-Element. Also geben
+ // wir es aus
+ $classname = mb_strtolower(get_class($content));
+ $valid_classes = ['studip\button', 'studip\linkbutton', 'messagebox'];
+ if (in_array($classname, $valid_classes)) {
+ $output .= $content;
+ } else {
+ $output .= $content->createContent($indent + 4);
+ }
+ // Rekursion lässt grüßen ...
+ } else {
+ // Content ist ein String. Jeden Zeile
+ // geben wir getrennt aus
+ $zeilen = explode("\n", $content);
+ $echo = "";
+
+ if ($this->has_textarea) {
+
+ // look for textarea in content
+ $text_area = false;
+ foreach ($zeilen as $zeile) {
+
+ if (mb_strstr($zeile, "<textarea"))
+ $text_area = true;
+
+ if ($text_area)
+ $echo .= $zeile . "\n";
+ else
+ $echo .= $str_indent . " " . $zeile . "\n";
+
+ if (mb_strstr($zeile, "</textarea"))
+ $text_area = false;
+ }
+ } else {
+ // standard
+ foreach ($zeilen as $zeile) {
+ $echo .= $str_indent . " " . $zeile . "\n";
+ }
+ }
+ $output .= $echo;
+ }
+ }
+ $output .= ($str_indent . "</" . $this->getName() . ">\n");
+
+ return $output;
+ }
+}
+
+include_once("LazyHTML.class.php");
+
diff --git a/lib/evaluation/classes/HTMLempty.class.php b/lib/evaluation/classes/HTMLempty.class.php
new file mode 100644
index 0000000..a3dfdae
--- /dev/null
+++ b/lib/evaluation/classes/HTMLempty.class.php
@@ -0,0 +1,181 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * HTML-class for the Stud.IP-project.
+ * Based on scripts from "http://tut.php-q.net/".
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+class HTMLempty
+{
+
+# Define all required variables ============================================= #
+ /**
+ * Holds the name of the element.
+ *
+ * @access private
+ * @var string $_name
+ */
+ var $_name = "";
+
+ /**
+ * Holds the attributes of the element.
+ *
+ * @access private
+ * @var array $_attribute
+ */
+ var $_attribute = [];
+
+ /**
+ * Holds additional attributes (strings generated from studip functions)
+ *
+ * @access private
+ * @var array $_string
+ */
+ var $_string = "";
+# ============================================================ end: variables #
+
+
+# Define constructor and destructor ========================================= #
+ public function __construct($name)
+ {
+ if (preg_match('/^[a-zA-Z.:][\w\-_\.:]*$/i', $name)) {
+ $this->_name = $name;
+ } else {
+ trigger_error("Unerlaubter Name für ein HTML-Element : '" . $name . "'", E_USER_ERROR);
+ }
+ }
+
+ /**
+ *
+ */
+ public function addAttr($name, $wert = null)
+ {
+ if (isset ($wert)) {
+ $name = (string)$name;
+ if (preg_match('/^[a-zA-Z.:][\w\-_\.:]*$/i', $name)) {
+ $this->_attribute[$name] = $wert;
+ } else {
+ trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . $name . "'", E_USER_ERROR);
+ }
+ } else {
+ if (is_scalar($name)) {
+ // Dies braucht man, falls man Attribute hinzufügen
+ // will, die keinen Wert haben, wie man es bei
+ // <option selected> kennt
+ if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $name)) {
+ $this->_attribute[$name] = $name;
+ // Da wir gültiges HTML bzw XML schreiben
+ // muss jedes Attribut auch einen Wert haben
+ // selected wird dann zu selected="selected"
+ } else {
+ trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . $name . "'", E_USER_ERROR);
+ }
+ } elseif (is_array($name)) {
+ // Jedes Arrayelement durchgehen
+ foreach ($name as $key => $wert) {
+ if (is_int($key)) {
+ // Arrayelement wurde mit $foo[] hinzugefügt
+ // also ohne Schlüssel. Ich nehme dann an
+ // das es sich um ein Attribut wie
+ // 'selected' oder 'readonly' handelt
+ if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $wert)) {
+ $this->_attribute[$wert] = $wert;
+ } else {
+ trigger_error("Unerlaubter Name für ein HTML-Attribut : '" .
+ $wert . "'", E_USER_ERROR);
+ }
+ } else {
+ $key = (string)$key;
+ if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $key)) {
+ $this->_attribute[$key] = $wert;
+ } else {
+ trigger_error("Unerlaubter Name für ein HTML-Attribut : '" .
+ $key . "'", E_USER_ERROR);
+ }
+ }
+ }
+ } else {
+ trigger_error("Erster Parameter muss ein Scalar oder ein Array sein",
+ E_USER_ERROR);
+ }
+ }
+ }
+
+ /**
+ * to support Stud.IP legacy functions like makeButton...
+ */
+ public function addString($string)
+ {
+ $this->_string .= " " . $string;
+ }
+
+ /**
+ *
+ */
+ public function getName()
+ {
+ return $this->_name;
+ }
+
+ /**
+ *
+ */
+ public function getAttr()
+ {
+ return $this->_attribute;
+ }
+
+ /**
+ *
+ */
+ public function printContent($indent = 0)
+ {
+ echo $this->createContent($str);
+ }
+
+ /**
+ *
+ */
+ public function createContent($indent = 0)
+ {
+ $str = str_repeat(' ', $indent);
+ $str .= "<" . $this->getName();
+ $attrib = $this->getAttr();
+ foreach ($attrib as $name => $value) {
+ $str .= ' ' . $name . '="' . htmlReady($value) . '"';
+ }
+ $str .= $this->_string;
+ $str .= ">\n";
+
+ return ($str);
+ }
+}
diff --git a/lib/evaluation/classes/LazyHTML.class.php b/lib/evaluation/classes/LazyHTML.class.php
new file mode 100644
index 0000000..98f2f5e
--- /dev/null
+++ b/lib/evaluation/classes/LazyHTML.class.php
@@ -0,0 +1,71 @@
+<?php
+/**
+ * HTML-class for the Stud.IP-project.
+ * Based on scripts from "http://tut.php-q.net/".
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+require_once 'HTML.class.php';
+
+class HTMpty extends HTMLempty
+{
+
+ public function attr($name, $wert = null)
+ {
+ parent::addAttr($name, $wert);
+ }
+
+ public function stri($string)
+ {
+ parent::addString($string);
+ }
+
+}
+
+class HTM extends HTML
+{
+
+ public function stri($string)
+ {
+ parent::addString($string);
+ }
+
+ public function attr($name, $wert = null)
+ {
+ parent::addAttr($name, $wert);
+ }
+
+ public function html($_content)
+ {
+ parent::addHTMLContent($_content);
+ }
+
+ public function cont($_content)
+ {
+ parent::addContent($_content);
+ }
+}
diff --git a/lib/evaluation/classes/db/EvaluationAnswerDB.class.php b/lib/evaluation/classes/db/EvaluationAnswerDB.class.php
new file mode 100644
index 0000000..d69ac77
--- /dev/null
+++ b/lib/evaluation/classes/db/EvaluationAnswerDB.class.php
@@ -0,0 +1,284 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * Beschreibung
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_OBJECTDB;
+
+
+class EvaluationAnswerDB extends EvaluationObjectDB
+{
+ /**
+ * Constructor
+ * @access public
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->instanceof = 'EvalANSWERDB';
+ }
+
+ /**
+ * Loads answers of a group from the DB
+ * @access public
+ * @param EvaluationAnswer &&$answerObject The answer object
+ */
+ public function load(&$answerObject)
+ {
+ /* load answer --------------------------------------------------------- */
+ $row = DBManager::get()->fetchOne(
+ "SELECT * FROM evalanswer WHERE evalanswer_id= ?", [$answerObject->getObjectID()]
+ );
+ if (!count($row)) {
+ return $this->throwError(2, _("Keine Antwort mit dieser ID gefunden."));
+ }
+
+ $answerObject->setObjectID($row['evalanswer_id']);
+ $answerObject->setParentID($row['parent_id']);
+ $answerObject->setPosition($row['position']);
+ $answerObject->setText($row['text']);
+ $answerObject->setValue($row['value']);
+ $answerObject->setRows($row['rows']);
+ $answerObject->setResidual($row['residual']);
+ }
+
+
+ /**
+ * Loads the votes from the users for this answer
+ * @access public
+ * @param EvaluationAnswer &$answerObject The answer object
+ */
+ function loadVotes(&$answerObject)
+ {
+ /* load users -------------------------------------------------------- */
+ $result = DBManager::get()->fetchFirst("SELECT user_id FROM evalanswer_user
+ WHERE evalanswer_id= ?", [$answerObject->getObjectID()]);
+ foreach ($result as $row) {
+ $answerObject->addUserID($row, NO);
+ }
+ }
+ /* ----------------------------------------------------------- end: users */
+
+ /**
+ * Writes answers into the DB
+ * @access public
+ * @param EvaluationAnswer &$answerObject The answerobject
+ * @throws error
+ */
+ function save(&$answerObject)
+ {
+ /* save answers -------------------------------------------------------- */
+ DBManager::get()->execute(
+ "REPLACE INTO evalanswer SET
+ `evalanswer_id` = ?,
+ `parent_id` = ?,
+ `position` = ?,
+ `text` = ?,
+ `value` = ?,
+ `rows` = ?,
+ `residual` = ?
+ ",
+ [$answerObject->getObjectID(),
+ $answerObject->getParentID(),
+ $answerObject->getPosition(),
+ $answerObject->getText(),
+ $answerObject->getValue(),
+ $answerObject->getRows(),
+ $answerObject->isResidual()]);
+ /* ----------------------------------------------------- end: answersave */
+
+ /* connect answer to users --------------------------------------------- */
+ while ($userID = $answerObject->getNextUserID()) {
+ DBManager::get()->execute(
+ "INSERT INTO evalanswer_user SET
+ evalanswer_id = ?,
+ user_id = ?,
+ evaldate = UNIX_TIMESTAMP()",
+ [$answerObject->getObjectID(), $userID]);
+ }
+ /* ----------------------------------------------------- end: connecting */
+
+ } // saved
+
+ /**
+ * Deletes all votes from the users for this answers
+ * @access public
+ * @param EvaluationAnswer &$answerObject The answer object
+ */
+ function resetVotes(&$answerObject)
+ {
+ /* delete userconnects ------------------------------------------------- */
+ DBManager::get()->execute("
+ DELETE FROM evalanswer_user
+ WHERE evalanswer_id = ?",
+ [$answerObject->getObjectID()]);
+ /* ------------------------------------------------------- end: deleting */
+ }
+
+ /**
+ * Deletes a answer
+ * @access public
+ * @param EvaluationAnswer &$answerObject The answer to delete
+ * @throws error
+ */
+ function delete(&$answerObject)
+ {
+ /* delete answer ----------------------------------------------------- */
+ DBManager::get()->execute("
+ DELETE FROM evalanswer
+ WHERE evalanswer_id = ?",
+ [$answerObject->getObjectID()]);
+ /* ------------------------------------------------------- end: deleting */
+ $this->resetVotes($answerObject);
+ } // deleted
+
+
+ /**
+ * Checks if answer with this ID exists
+ * @access public
+ * @param string $answerID The answerID
+ * @return bool YES if exists
+ */
+ function exists($answerID)
+ {
+ $result = DBManager::get()->fetchOne("SELECT 1 FROM evalanswer
+ WHERE evalanswer_id= ?", [$answerID]);
+ if (count($result) > 0)
+ return true;
+ return false;
+ }
+
+
+ /**
+ * Adds the children to a parent object
+ * @access public
+ * @param EvaluationObject &$parentObject The parent object
+ */
+ function addChildren(&$parentObject)
+ {
+ $result = DBManager::get()->fetchFirst("SELECT evalanswer_id FROM evalanswer
+ WHERE parent_id= ? ORDER by position",
+ [$parentObject->getObjectID()]);
+
+ $loadChildren =
+ $parentObject->loadChildren == EVAL_LOAD_ALL_CHILDREN ? EVAL_LOAD_ALL_CHILDREN : EVAL_LOAD_NO_CHILDREN;
+
+ foreach ($result as $row) {
+ $parentObject->addChild(new EvaluationAnswer
+ ($row, $parentObject, $loadChildren));
+ }
+ }
+
+ /**
+ * Returns the type of an objectID
+ * @access public
+ * @param string $objectID The objectID
+ * @return string INSTANCEOF_x, else NO
+ */
+ function getType($objectID)
+ {
+ if ($this->exists($objectID)) {
+ return INSTANCEOF_EVALANSWER;
+ } else {
+ return NO;
+ }
+ }
+
+ /**
+ * Returns the id from the parent object
+ * @access public
+ * @param string $objectID The object id
+ * @return string The id from the parent object
+ */
+ function getParentID($objectID)
+ {
+ return DBManager::get()->fetchColumn("SELECT parent_id FROM evalanswer
+ WHERE evalanswer_id = ?",
+ [$objectID()]);
+ }
+
+ /**
+ * Give all textanswers for a user and question for the export
+ * @access public
+ * @param string $questionID The question id
+ * @param string $userID The user id
+ */
+ function getUserAnwerIDs($questionID, $userID)
+ {
+ /* ask database ------------------------------------------------------- */
+ $sql = "SELECT a.evalanswer_id as ttt FROM evalanswer a, evalanswer_user b
+ WHERE a.parent_id = ? AND a.evalanswer_id = b.evalanswer_id";
+ if (empty ($userID))
+ $answer_ids = DBManager::get()->fetchFirst($sql, [$questionID]);
+ else
+ $answer_ids = DBManager::get()->fetchFirst($sql . " AND b.user_id = ?", [$questionID, $userID]);
+ /* -------------------------------------------------------- end: asking */
+ return $answer_ids;
+ }
+
+ /**
+ * Checks whether a user has voted for an answer
+ * @access public
+ * @param string $answerID The answer id
+ * @param string $userID The user id
+ * @return boolean YES if user has voted for the answer
+ */
+ function hasVoted($answerID, $userID)
+ {
+ $result = DBManager::get()->fetchOne("SELECT 1 FROM evalanswer_user
+ WHERE evalanswer_id= ? AND user_id", [$answerID, $userID]);
+ if (count($result) > 0)
+ return true;
+ return false;
+ }
+
+ function getAllAnswers($question_id, $userID, $only_user_answered = false)
+ {
+ if ($only_user_answered)
+ return DBManager::get()->fetchAll("
+ SELECT evalanswer.*, COUNT(IF(user_id=?,1,NULL)) AS has_voted
+ FROM evalanswer LEFT JOIN evalanswer_user USING(evalanswer_id)
+ WHERE parent_id = ? AND user_id = ?
+ GROUP BY evalanswer.evalanswer_id ORDER BY position",
+ [$userID, $question_id, $userID]);
+ else
+ return DBManager::get()->fetchAll("
+ SELECT evalanswer.*, COUNT(IF(user_id=?,1,NULL)) AS has_voted
+ FROM evalanswer LEFT JOIN evalanswer_user USING(evalanswer_id)
+ WHERE parent_id = ?
+ GROUP BY evalanswer.evalanswer_id ORDER BY position",
+ [$userID, $question_id]);
+ }
+}
+
+?>
diff --git a/lib/evaluation/classes/db/EvaluationDB.class.php b/lib/evaluation/classes/db/EvaluationDB.class.php
new file mode 100644
index 0000000..991e26c
--- /dev/null
+++ b/lib/evaluation/classes/db/EvaluationDB.class.php
@@ -0,0 +1,291 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_OBJECTDB;
+require_once EVAL_FILE_GROUPDB;
+
+
+/**
+ * @const EVAL_STATE_NEW Beschreibung
+ * @access public
+ */
+define("EVAL_STATE_NEW", "new");
+
+/**
+ * @const EVAL_STATE_ACTIVE Beschreibung
+ * @access public
+ */
+define("EVAL_STATE_ACTIVE", "active");
+
+/**
+ * @const EVAL_STATE_STOPPED Beschreibung
+ * @access public
+ */
+define("EVAL_STATE_STOPPED", "stopped");
+# =========================================================================== #
+
+
+/**
+ * Databaseclass for all evaluations
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class EvaluationDB extends EvaluationObjectDB
+{
+
+ public function __construct()
+ {
+ parent::__construct();
+ $this->instanceof = 'EvalDB';
+ }
+
+ /**
+ * Loads an evaluation from DB into an object
+ *
+ * @access public
+ * @param object EvaluationObject &$evalObject The evaluation to load
+ * @throws error
+ */
+ public function load(&$evalObject)
+ {
+ $row = DBManager::get()->fetchOne("SELECT * FROM eval WHERE eval_id = ?", [$evalObject->getObjectID()]);
+
+ if (!count($row)) {
+ return $this->throwError(1, _("Keine Evaluation mit dieser ID gefunden."));
+ }
+
+ $evalObject->setAuthorID($row['author_id']);
+ $evalObject->setTitle($row['title']);
+ $evalObject->setText($row['text']);
+ $evalObject->setStartdate($row['startdate']);
+ $evalObject->setStopdate($row['stopdate']);
+ $evalObject->setTimespan($row['timespan']);
+ $evalObject->setCreationdate($row['mkdate']);
+ $evalObject->setChangedate($row['chdate']);
+ $evalObject->setAnonymous($row['anonymous']);
+ $evalObject->setVisible($row['visible']);
+ $evalObject->setShared($row['shared']);
+
+ $range_ids = DBManager::get()->fetchFirst("SELECT range_id FROM eval_range WHERE eval_id = ?",
+ [$evalObject->getObjectID()]);
+
+ foreach ($range_ids as $range_id) {
+ $evalObject->addRangeID($range_id);
+ }
+ if ($evalObject->loadChildren != EVAL_LOAD_NO_CHILDREN) {
+ EvaluationGroupDB::addChildren($evalObject);
+ }
+ }
+
+ /**
+ * Saves an evaluation
+ * @access public
+ * @param object Evaluation &$evalObject The evaluation to save
+ * @throws error
+ */
+ public function save(&$evalObject)
+ {
+ $startdate = $evalObject->getStartdate();
+ $stopdate = $evalObject->getStopdate();
+ $timespan = $evalObject->getTimespan();
+
+ $evalObject->setChangedate(time());
+ if ($this->exists($evalObject->getObjectID())) {
+ DBManager::get()->execute(
+ "UPDATE eval SET title = ?, text = ?, startdate = ?,
+ stopdate = ?, timespan = ?, mkdate = ?,
+ chdate = ?, anonymous = ?, visible = ?, shared = ?
+ WHERE eval_id = ?",
+ [$evalObject->getTitle(), $evalObject->getText(),
+ $startdate, $stopdate, $timespan, $evalObject->getCreationdate(),
+ $evalObject->getChangedate(), $evalObject->isAnonymous(),
+ $evalObject->isVisible(), $evalObject->isShared(), $evalObject->getObjectID()]);
+ } else {
+ DBManager::get()->execute(
+ "INSERT INTO eval SET eval_id = ?,
+ author_id = ?, title = ?, text = ?, startdate = ?,
+ stopdate = ?, timespan = ?, mkdate = ?, chdate = ?,
+ anonymous = ?, visible = ?, shared = ?",
+ [$evalObject->getObjectID(), $evalObject->getAuthorID(),
+ $evalObject->getTitle(), $evalObject->getText(),
+ $startdate, $stopdate, $timespan, $evalObject->getCreationdate(),
+ $evalObject->getChangedate(), $evalObject->isAnonymous(),
+ $evalObject->isVisible(), $evalObject->isShared()]);
+ }
+ DBManager::get()->execute("DELETE FROM eval_range WHERE eval_id = ?", [$evalObject->getObjectID()]);
+
+ while ($rangeID = $evalObject->getNextRangeID()) {
+ DBManager::get()->execute("INSERT INTO eval_range SET eval_id = ?, range_id = ?",
+ [$evalObject->getObjectID(), $rangeID]);
+ }
+ }
+
+ /**
+ * Deletes an evaluation
+ * @access public
+ * @param object Evaluation &$evalObject The evaluation to delete
+ * @throws error
+ */
+ public function delete(&$evalObject)
+ {
+ DBManager::get()->execute("DELETE FROM eval WHERE eval_id = ?", [$evalObject->getObjectID()]);
+
+ DBManager::get()->execute("DELETE FROM eval_range WHERE eval_id = ?", [$evalObject->getObjectID()]);
+ DBManager::get()->execute("DELETE FROM eval_user WHERE eval_id = ?", [$evalObject->getObjectID()]);
+
+ }
+
+ /**
+ * Checks if evaluation with this ID exists
+ * @access public
+ * @param string $evalID The evalID
+ * @return bool YES if exists
+ */
+ public function exists($evalID)
+ {
+ $entry = DBManager::get()->fetchOne("SELECT 1 FROM eval WHERE eval_id = ?", [$evalID]);
+ if (count($entry) > 0)
+ return true;
+ return false;
+ }
+
+ /**
+ * Checks if someone used the evaluation
+ * @access public
+ * @param string $evalID The eval id
+ * @param string $userID The user id
+ * @return bool YES if evaluation was used
+ */
+ public function hasVoted($evalID, $userID = "")
+ {
+ /* ask database ------------------------------------------------------- */
+ $sql = "SELECT 1 FROM eval_user WHERE eval_id = ?";
+ if (empty($userID))
+ $entry = DBManager::get()->fetchOne($sql, [$evalID]);
+ else
+ $entry = DBManager::get()->fetchOne($sql . " AND user_id = ?", [$evalID, $userID]);
+ /* --------------------------------------------------------- end: asking */
+ if (count($entry) > 0)
+ return true;
+ return false;
+ }
+
+ /**
+ * Returns the type of an objectID
+ * @access public
+ * @param string $objectID The objectID
+ * @return string INSTANCEOF_x, else NO
+ */
+ public function getType($objectID)
+ {
+ if ($this->exists($objectID)) {
+ return INSTANCEOF_EVAL;
+ } else {
+ $dbObject = new EvaluationGroupDB();
+ return $dbObject->getType($objectID);
+ }
+ }
+
+ /**
+ * Connect a user with an evaluation
+ * @access public
+ * @param string $evalID The evaluation id
+ * @param string $userID The user id
+ */
+ public function connectWithUser($evalID, $userID)
+ {
+ if (empty($userID))
+ die ("EvaluationDB::connectWithUser: UserID leer!!");
+ DBManager::get()->execute("INSERT IGNORE INTO eval_user SET eval_id = ?, user_id = ?", [$evalID, $userID]);
+ }
+
+ /**
+ * Removes the connection of an evaluation with a user or all users
+ * @access public
+ * @param string $evalID The evaluation id
+ * @param string $userID The user id
+ */
+ public function removeUser($evalID, $userID = "")
+ {
+ $sql = "DELETE FROM eval_user WHERE eval_id = ?";
+
+ if (empty($userID))
+ DBManager::get()->execute($sql, [$evalID]);
+ else
+ DBManager::get()->execute($sql . " AND user_id = ?", [$evalID, $userID]);
+ }
+
+ /**
+ * Get number of users who participated in the eval
+ * @access public
+ * @param string $evalID The eval id
+ * @return integer The number of users
+ */
+ public static function getNumberOfVotes($evalID)
+ {
+ return DBManager::get()->fetchColumn("SELECT count(DISTINCT user_id) AS number FROM eval_user WHERE eval_id = ?", [$evalID]);
+ }
+
+ /**
+ * Get users who participated in the eval
+ * @access public
+ * @param string $evalID The eval id
+ * @param array $answerIDs The answerIDs to get the pseudonym users
+ * @return integer The number of users
+ */
+ public function getUserVoted($evalID, $answerIDs = [], $questionIDs = [])
+ {
+ $sql = "SELECT DISTINCT user_id FROM ";
+
+ if (empty($answerIDs) && empty($questionIDs)) {
+ $sql .= "eval_user WHERE eval_id = ?";
+ $search_criteria = $evalID;
+ } elseif (empty ($questionIDs)) {
+ $sql .= "evalanswer_user WHERE evalanswer_id IN (?)";
+ $search_criteria = $answerIDs;
+ } else {
+ $sql .= "evalanswer INNER JOIN evalanswer_user USING(evalanswer_id) WHERE parent_id IN (?)";
+ $search_criteria = $questionIDs;
+ }
+
+ return DBManager::get()->fetchFirst($sql, [$search_criteria]);
+ }
+
+ /**
+ *
+ * @access public
+ * @param string $search_str
+ * @return array
+ */
+ public function search_range($search_str)
+ {
+ return search_range($search_str, true);
+ }
+}
diff --git a/lib/evaluation/classes/db/EvaluationGroupDB.class.php b/lib/evaluation/classes/db/EvaluationGroupDB.class.php
new file mode 100644
index 0000000..557a52d
--- /dev/null
+++ b/lib/evaluation/classes/db/EvaluationGroupDB.class.php
@@ -0,0 +1,226 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_OBJECTDB;
+require_once EVAL_FILE_ANSWERDB;
+
+/**
+ * Databaseclass for all evaluationgroups
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class EvaluationGroupDB extends EvaluationObjectDB
+{
+
+ /**
+ * Constructor
+ * @access public
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->instanceof = 'EvalGroupDB';
+ }
+
+ /**
+ * Loads an evaluationgroup from DB into an object
+ *
+ * @access private
+ * @param object EvaluationGroup &$groupObject The group to load
+ * @throws error
+ */
+ public function load(&$groupObject)
+ {
+ /* load group ---------------------------------------------------------- */
+ $row = DBManager::get()->fetchOne("
+ SELECT * FROM evalgroup
+ WHERE evalgroup_id = ?
+ ORDER BY position ", [$groupObject->getObjectID()]);
+
+ if (count($row) === 0) {
+ return $this->throwError(1, _("Keine Gruppe mit dieser ID gefunden."));
+ }
+
+ $groupObject->setParentID($row['parent_id']);
+ $groupObject->setTitle($row['title']);
+ $groupObject->setText($row['text']);
+ $groupObject->setPosition($row['position']);
+ $groupObject->setChildType($row['child_type']);
+ $groupObject->setMandatory($row['mandatory']);
+ $groupObject->setTemplateID($row['template_id']);
+ if ($groupObject->loadChildren != EVAL_LOAD_NO_CHILDREN) {
+ if ($groupObject->loadChildren == EVAL_LOAD_ONLY_EVALGROUP) {
+ EvaluationGroupDB::addChildren($groupObject);
+ } else {
+ EvaluationGroupDB::addChildren($groupObject);
+ EvaluationQuestionDB::addChildren($groupObject);
+ }
+ }
+ }
+
+
+ /**
+ * Saves a group
+ * @access public
+ * @param object EvaluationGroup &$groupObject The group to save
+ * @throws error
+ */
+ public function save(&$groupObject)
+ {
+ if ($this->exists($groupObject->getObjectID())) {
+ DBManager::get()->execute("
+ UPDATE evalgroup SET
+ title = ?,
+ text = ?,
+ child_type = ?,
+ position = ?,
+ template_id = ?,
+ mandatory = ?
+ WHERE
+ evalgroup_id = ?
+ ", [(string)$groupObject->getTitle(),
+ (string)$groupObject->getText(),
+ (string)$groupObject->getChildType(),
+ (int)$groupObject->getPosition(),
+ (string)$groupObject->getTemplateID(),
+ (int)$groupObject->isMandatory(),
+ (string)$groupObject->getObjectID()
+ ]);
+ } else {
+ DBManager::get()->execute("
+ INSERT INTO evalgroup SET
+ evalgroup_id = ?,
+ parent_id = ?,
+ title = ?,
+ text = ?,
+ child_type = ?,
+ mandatory = ?,
+ template_id = ?,
+ position = ?
+ ", [
+ (string)$groupObject->getObjectID(),
+ (string)$groupObject->getParentID(),
+ (string)$groupObject->getTitle(),
+ (string)$groupObject->getText(),
+ (string)$groupObject->getChildType(),
+ (int)$groupObject->isMandatory(),
+ (string)$groupObject->getTemplateID(),
+ (int)$groupObject->getPosition()
+ ]);
+ }
+ }
+
+ /**
+ * Deletes a group
+ * @access public
+ * @param object EvaluationGroup &$groupObject The group to delete
+ * @throws error
+ */
+ public function delete(&$groupObject)
+ {
+ DBManager::get()->execute("DELETE FROM evalgroup WHERE evalgroup_id = ?", [$groupObject->getObjectID()]);
+ }
+
+ /**
+ * Checks if group with this ID exists
+ * @access public
+ * @param string $groupID The groupID
+ * @return bool YES if exists
+ */
+ public function exists($groupID)
+ {
+ $result = DBManager::get()->fetchColumn("SELECT 1 FROM evalgroup WHERE evalgroup_id = ?", [$groupID]);
+ return (bool)$result;
+ }
+
+ /**
+ * Adds the children to a parent object
+ * @access public
+ * @param EvaluationObject &$parentObject The parent object
+ */
+ public function addChildren(&$parentObject)
+ {
+ $result = DBManager::get()->fetchFirst("
+ SELECT evalgroup_id FROM evalgroup
+ WHERE parent_id = ?
+ ORDER BY position", [$parentObject->getObjectID()]);
+
+ if (($loadChildren = $parentObject->loadChildren) == EVAL_LOAD_NO_CHILDREN)
+ $loadChildren = EVAL_LOAD_NO_CHILDREN;
+
+ foreach ($result as $groupID) {
+ $parentObject->addChild(
+ new EvaluationGroup ($groupID, $parentObject, $loadChildren)
+ );
+ }
+ }
+
+ /**
+ * Returns the type of an objectID
+ * @access public
+ * @param string $objectID The objectID
+ * @return string INSTANCEOF_x, else NO
+ */
+ public function getType($objectID)
+ {
+ if ($this->exists($objectID)) {
+ return INSTANCEOF_EVALGROUP;
+ } else {
+ $dbObject = new EvaluationQuestionDB ();
+ return $dbObject->getType($objectID);
+ }
+ }
+
+
+ /**
+ * Returns whether the childs are groups or questions
+ * @access public
+ * @param string $objectID The object id
+ */
+ public function getChildType($objectID)
+ {
+ $result = DBManager::get()->fetchColumn("
+ SELECT child_type FROM evalgroup WHERE evalgroup_id = ?", [$objectID]);
+ if ($result) return $result;
+ return NULL;
+ }
+
+ /**
+ * Returns the id from the parent object
+ * @access public
+ * @param string $objectID The object id
+ * @return string The id from the parent object
+ */
+ public function getParentID($objectID)
+ {
+ return DBManager::get()->fetchColumn("
+ SELECT parent_id FROM evalgroup WHERE evalgroup_id = ?", [$objectID]);
+ }
+}
diff --git a/lib/evaluation/classes/db/EvaluationObjectDB.class.php b/lib/evaluation/classes/db/EvaluationObjectDB.class.php
new file mode 100644
index 0000000..d9e476c
--- /dev/null
+++ b/lib/evaluation/classes/db/EvaluationObjectDB.class.php
@@ -0,0 +1,368 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once 'lib/evaluation/evaluation.config.php';
+
+/**
+ * Databaseclass for all evaluationobjects
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class EvaluationObjectDB extends DatabaseObject
+{
+ /**
+ * Constructor
+ * @access public
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->instanceof = 'EvalDBObject';
+ }
+
+ /**
+ * Gets the name of the range. Copied somewhere from Stud.IP...
+ * @access public
+ * @param string $rangeID the rangeID
+ * @param boolean $html_decode (optional)
+ * @return string The name of the range
+ */
+ public function getRangename($rangeID, $html_decode = true)
+ {
+ if ($rangeID == "studip") {
+ return _('Systemweite Evaluationen');
+ }
+ $o_type = get_object_type($rangeID, ['sem', 'user', 'inst']);
+ if (in_array($o_type, ['sem', 'inst', 'fak'])) {
+ $name = Context::getHeaderLine();
+ if ($name != NULL) {
+ if ($html_decode)
+ $rangename = decodeHTML($name);
+ else
+ $rangename = $name;
+ } else {
+ $rangename = _('Kein Titel gefunden.');
+ }
+ return $rangename;
+ }
+ if ($o_type != 'user') {
+ $user_id = get_userid($rangeID);
+ } else {
+ $user_id = $rangeID;
+ }
+
+ if ($user_id != $GLOBALS['user']->id) {
+ $rangename = _('Profil') . ': '
+ . get_fullname($user_id, 'full', true)
+ . ' (' . get_username($user_id) . ')';
+ } else {
+ $rangename = _('Profil');
+ }
+ return $rangename;
+ }
+
+ /**
+ * Gets the global Studi.IP perm
+ * @access public
+ * @param boolean $as_value If YES return as value
+ * @return string the perm or NULL
+ */
+ public function getGlobalPerm($as_value = false)
+ {
+ if ($GLOBALS['perm']->have_perm("root")) {
+ return ($as_value) ? 63 : "root";
+ } elseif ($GLOBALS['perm']->have_perm("admin")) {
+ return ($as_value) ? 31 : "admin";
+ } elseif ($GLOBALS['perm']->have_perm("dozent")) {
+ return ($as_value) ? 15 : "dozent";
+ } elseif ($GLOBALS['perm']->have_perm("tutor")) {
+ return ($as_value) ? 7 : "dozent";
+ } elseif ($GLOBALS['perm']->have_perm("autor")) {
+ return ($as_value) ? 3 : "autor";
+ } elseif ($GLOBALS['perm']->have_perm("user")) {
+ return ($as_value) ? 1 : "user";
+ } else {
+ return ($as_value) ? 0 : NULL;
+ }
+ }
+
+ /**
+ * Get the Stud.IP-Perm for a range
+ * @param string $rangeID The range id
+ * @param string $userID The user id
+ * @param boolean $as_value If YES return as value
+ * @access public
+ * @return string
+ */
+ public function getRangePerm($rangeID, $userID = NULL, $as_value = false)
+ {
+ if (!$rangeID) {
+ print "no rangeID!<br>";
+ return NULL;
+ }
+ $userID = ($userID) ? $userID : $GLOBALS['user']->id;
+ $range_perm = $GLOBALS['perm']->get_studip_perm($rangeID, $userID);
+
+ if ($rangeID == $userID) {
+ return ($as_value) ? 63 : "root";
+ }
+
+ if (($rangeID == "studip") && ($GLOBALS['perm']->have_perm("root"))) {
+ return ($as_value) ? 63 : "root";
+ }
+
+ switch ($range_perm) {
+ case "root":
+ return ($as_value) ? 63 : "root";
+ case "admin":
+ return ($as_value) ? 31 : "admin";
+ case "dozent":
+ return ($as_value) ? 15 : "dozent";
+ case "tutor":
+ return ($as_value) ? 7 : "dozent";
+ case "autor":
+ return ($as_value) ? 3 : "autor";
+ case "user":
+ return ($as_value) ? 1 : "user";
+ default:
+ return 0;
+ }
+
+ }
+
+ /**
+ * Look for all rangeIDs for my permissions
+ * @param object Perm &$permObj PHP-LIB-Perm-Object
+ * @param object User &$userObj PHP-LIB-User-Object
+ * @param string $rangeID RangeID of actual page
+ */
+ public function getValidRangeIDs(&$permObj, &$userObj, $rangeID)
+ {
+ $range_ids = [];
+ $username = $userObj->username;
+
+ $range_ids += [
+ $username => ["name" => _("Profil")]
+ ];
+
+ if ($permObj->have_perm("root")) {
+ $range_ids += ["studip" => ["name" => _("Stud.IP-System")]];
+ if (($adminRange = $this->getRangename($rangeID)) &&
+ $rangeID != $userObj->id)
+ $range_ids += [$rangeID => ["name" =>
+ $adminRange]];
+ } else if ($permObj->have_perm("admin")) {
+ if (($adminRange = $this->getRangename($rangeID)) &&
+ $rangeID != $userObj->id) {
+ $range_ids += [$rangeID => ["name" =>
+ $adminRange]];
+ }
+ } else if ($permObj->have_perm("dozent") || $permObj->have_perm("tutor")) {
+ if ($ranges = search_range("")) {
+ $range_ids += $ranges;
+ }
+ }
+ return $range_ids;
+ }
+
+ /**
+ * Returns the number of ranges with no permission
+ * @access public
+ * @param EvaluationObject &$eval The evaluation
+ * @param boolean $return_ids If YES return the ids
+ * @return integer Number of ranges with no permission
+ */
+ public function getEvalUserRangesWithNoPermission(&$eval, $return_ids = false)
+ {
+ $no_permisson = 0;
+ $rangeIDs = $eval->getRangeIDs();
+
+ if (!is_array($rangeIDs)) {
+ $rangeIDs = [$rangeIDs];
+ }
+
+ foreach ($eval->getRangeIDs() as $rangeID) {
+ $user_perm = EvaluationObjectDB::getRangePerm($rangeID, $GLOBALS['user']->id, YES);
+ // every range with a lower perm than Tutor
+ if ($user_perm < 7) {
+ $no_permisson++;
+ $no_permisson_ranges[] = $rangeID;
+ }
+ }
+ if ($return_ids == YES) {
+ return $no_permisson_ranges;
+ }
+ return ($no_permisson > 0) ? $no_permisson : NO;
+ }
+
+ /**
+ * Gets the public template ids
+ * @access public
+ * @param string $searchString The name of the template
+ * @return array The public template ids
+ */
+ public function getPublicTemplateIDs($searchString)
+ {
+ $sql = "
+ SELECT eval_id FROM eval
+ LEFT JOIN auth_user_md5 ON user_id = author_id
+ WHERE shared = 1
+ AND author_id <> :current_user
+ AND (title LIKE :search_string
+ OR text LIKE :search_string
+ OR Vorname LIKE :search_string
+ OR Nachname LIKE :search_string
+ OR username LIKE :search_string
+ )
+ ORDER BY title";
+
+ return DBManager::get()->fetchFirst(
+ $sql, [':current_user' => $GLOBALS['user']->id, ':search_string' => '%' . $searchString . '%']
+ );
+ }
+
+ /**
+ * Return all evaluationIDs in a specific range
+ *
+ * @access public
+ * @param string $rangeID Specific rangeID or it is a template
+ * @param string $state Specific state
+ * @return array All evaluations in this range and this state
+ */
+ public function getEvaluationIDs($rangeID = "", $state = "")
+ {
+ if (!empty ($rangeID) && !is_scalar($rangeID)) {
+ return $this->throwError(1, _("Übergebene RangeID ist ungültig."));
+ }
+ if ($state != "" &&
+ $state != EVAL_STATE_NEW &&
+ $state != EVAL_STATE_ACTIVE &&
+ $state != EVAL_STATE_STOPPED) {
+ return $this->throwError(2, _("Übergebener Status ist ungültig."));
+ }
+
+ if (get_userid($rangeID) != NULL && $rangeID != NULL) {
+ $rangeID = get_userid($rangeID);
+ }
+
+ if (!empty ($rangeID)) {
+ $sql =
+ "SELECT" .
+ " a.eval_id " .
+ "FROM" .
+ " eval_range a, eval b " .
+ "WHERE" .
+ " a.eval_id = b.eval_id" .
+ " AND " .
+ " a.range_id = ?";
+ $param = $rangeID;
+ } else {
+ $sql =
+ "SELECT" .
+ " b.eval_id " .
+ "FROM" .
+ " eval b " .
+ "LEFT JOIN" .
+ " eval_range " .
+ "ON" .
+ " b.eval_id = eval_range.eval_id " .
+ "WHERE" .
+ " eval_range.eval_id IS NULL" .
+ " AND" .
+ " b.author_id = ?";
+ $param = $GLOBALS['user']->id;
+ }
+
+ if ($state == EVAL_STATE_NEW)
+ $sql .= " AND (b.startdate IS NULL OR b.startdate > " . time() . ")";
+
+ elseif ($state == EVAL_STATE_ACTIVE)
+ $sql .=
+ " AND b.startdate < " . time() . "" .
+ " AND (" .
+ " (b.timespan IS NULL AND b.stopdate > " . time() . ")" .
+ " OR" .
+ " (b.stopdate IS NULL AND (b.startdate+b.timespan) > " . time() . ")" .
+ " OR" .
+ " (b.timespan IS NULL AND b.stopdate IS NULL)" .
+ " )";
+
+ elseif ($state == EVAL_STATE_STOPPED)
+ $sql .=
+ " AND b.startdate < " . time() . "" .
+ " AND (" .
+ " (b.timespan IS NULL AND b.stopdate <= " . time() . ")" .
+ " OR" .
+ " (b.stopdate IS NULL AND (b.startdate+b.timespan) <= " . time() . ")" .
+ " )";
+
+ $sql .= " ORDER BY chdate DESC";
+
+ return DBManager::get()->fetchFirst($sql, [$param]);
+ }
+
+ /**
+ * Gets the evaluation id for a object id
+ * @access public
+ * @param string $objectID The object id
+ * @return string The evaluation id or nothing
+ */
+ public function getEvalID($objectID)
+ {
+ if (empty ($objectID)) {
+ throw new Exception("FATAL ERROR in getEvalID ;)");
+ }
+
+ $type = EvaluationObjectDB::getType($objectID);
+
+ switch ($type) {
+ case INSTANCEOF_EVALANSWER:
+ $parentID = EvaluationAnswerDB::getParentID($objectID);
+ break;
+ case INSTANCEOF_EVALQUESTION:
+ $parentID = EvaluationQuestionDB::getParentID($objectID);
+ break;
+ case INSTANCEOF_EVALGROUP:
+ $parentID = EvaluationGroupDB::getParentID($objectID);
+ break;
+ default:
+ return $objectID;
+ }
+ return EvaluationObjectDB::getEvalID($parentID);
+ }
+
+ /**
+ * Returns the type of an objectID
+ * @access public
+ * @param string $objectID The objectID
+ * @return string INSTANCEOF_x, else NO
+ */
+ public function getType($objectID)
+ {
+ return (new EvaluationDB ())->getType($objectID);
+ }
+}
diff --git a/lib/evaluation/classes/db/EvaluationQuestionDB.class.php b/lib/evaluation/classes/db/EvaluationQuestionDB.class.php
new file mode 100644
index 0000000..fb3b42f
--- /dev/null
+++ b/lib/evaluation/classes/db/EvaluationQuestionDB.class.php
@@ -0,0 +1,307 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * Beschreibung
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_FILE_OBJECTDB;
+require_once EVAL_FILE_ANSWERDB;
+# ====================================================== end: including files #
+
+# Define all required constants ============================================= #
+/**
+ * @const INSTANCEOF_EVALQUESTIONDB Instance of an evaluationQuestionDB object
+ * @access public
+ */
+define("INSTANCEOF_EVALQUESTIONDB", "EvalQuestionDB");
+
+# =========================================================================== #
+
+
+class EvaluationQuestionDB extends EvaluationObjectDB
+{
+
+ /**
+ * Constructor
+ * @access public
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->instanceof = 'EvalQuestionDB';
+ }
+
+ /**
+ * Loads a question from the DB
+ * @access public
+ * @param EvaluationQuestion &$questionObject The question object
+ */
+ public function load(&$questionObject)
+ {
+ $db = DBManager::get();
+ $query =
+ "SELECT" .
+ " * " .
+ "FROM" .
+ " evalquestion " .
+ "WHERE" .
+ " evalquestion_id = ? " .
+ "ORDER BY" .
+ " position ";
+ $row = $db->fetchOne($query, [$questionObject->getObjectID()]);
+
+ if (!count($row)) {
+ return $this->throwError(1, _("Keine Frage mit dieser ID gefunden."));
+ }
+
+ $questionObject->setParentID($row['parent_id']);
+ $questionObject->setType($row['type']);
+ $questionObject->setPosition($row['position']);
+ $questionObject->setText($row['text']);
+ $questionObject->setMultiplechoice($row['multiplechoice']);
+
+ if ($questionObject->loadChildren != EVAL_LOAD_NO_CHILDREN) {
+ EvaluationAnswerDB::addChildren($questionObject);
+ }
+ }
+
+
+ /**
+ * Writes or updates a question into the DB
+ * @access public
+ * @param EvaluationQuestion &$questionObject The question object
+ */
+ public function save(&$questionObject)
+ {
+ $db = DBManager::get();
+
+ if ($this->exists($questionObject->getObjectID())) {
+ $sql =
+ "UPDATE" .
+ " evalquestion " .
+ "SET" .
+ " parent_id = ?," .
+ " type = ?," .
+ " position = ?," .
+ " text = ?," .
+ " multiplechoice = ? " .
+ "WHERE" .
+ " evalquestion_id = ?";
+ } else {
+ $sql =
+ "INSERT INTO" .
+ " evalquestion " .
+ "SET" .
+ " parent_id = ?," .
+ " type = ?," .
+ " position = ?," .
+ " text = ?," .
+ " multiplechoice = ?," .
+ " evalquestion_id = ?";;
+ }
+ $db->execute($sql, [
+ (string)$questionObject->getParentID(),
+ (string)$questionObject->getType(),
+ (int)$questionObject->getPosition(),
+ (string)$questionObject->getText(),
+ (int)$questionObject->isMultiplechoice(),
+ $questionObject->getObjectID()
+ ]);
+ }
+
+ /**
+ * Deletes a question
+ * @access public
+ * @param object EvaluationQuestion &$questionObject The question to delete
+ * @throws error
+ */
+ public function delete(&$questionObject)
+ {
+ $db = DBManager::get();
+
+ $sql = "DELETE FROM evalquestion WHERE evalquestion_id = ?";
+ $db->execute($sql, [$questionObject->getObjectID()]);
+ }
+
+ /**
+ * Checks if question with this ID exists
+ * @access public
+ * @param string $questionID The questionID
+ * @return bool YES if exists
+ */
+ public function exists($questionID)
+ {
+ $db = DBManager::get();
+
+ $sql =
+ "SELECT" .
+ " 1 " .
+ "FROM" .
+ " evalquestion " .
+ "WHERE" .
+ " evalquestion_id = ?";
+ $result = $db->fetchColumn($sql, [$questionID]);
+
+ return (bool)$result;
+ }
+
+ /**
+ * Checks if a template exists with this title
+ * @access public
+ * @param string $questionTitle The title of the question
+ * @param string $userID The user id
+ * @return bool YES if exists
+ */
+ public function titleExists($questionTitle, $userID)
+ {
+ $db = DBManager::get();
+
+ $sql =
+ "SELECT" .
+ " 1 " .
+ "FROM" .
+ " evalquestion " .
+ "WHERE" .
+ " text = ? " .
+ " AND " .
+ " parent_id = ?";
+
+ $result = $db->fetchColumn($sql, [$questionTitle, $userID]);
+
+ return (bool)$result;
+ }
+
+
+ /**
+ * Adds the children to a parent object
+ * @access public
+ * @param EvaluationObject &$parentObject The parent object
+ */
+ public function addChildren(&$parentObject)
+ {
+ $db = DBManager::get();
+
+ $sql =
+ "SELECT" .
+ " evalquestion_id " .
+ "FROM" .
+ " evalquestion " .
+ "WHERE" .
+ " parent_id = ? " .
+ "ORDER BY" .
+ " position";
+ $result = $db->fetchFirst($sql, [$parentObject->getObjectID()]);
+
+ $loadChildren = $parentObject->loadChildren == EVAL_LOAD_ALL_CHILDREN
+ ? EVAL_LOAD_ALL_CHILDREN
+ : EVAL_LOAD_NO_CHILDREN;
+
+ foreach ($result as $evalquestion_id) {
+ $parentObject->addChild(new EvaluationQuestion
+ ($evalquestion_id,
+ $parentObject, $loadChildren));
+ }
+ }
+
+ /**
+ * Returns the type of an objectID
+ * @access public
+ * @param string $objectID The objectID
+ * @return string INSTANCEOF_x, else NO
+ */
+ public function getType($objectID)
+ {
+ if ($this->exists($objectID)) {
+ return INSTANCEOF_EVALQUESTION;
+ } else {
+ $dbObject = new EvaluationAnswerDB ();
+ return $dbObject->getType($objectID);
+ }
+ }
+
+ /**
+ * Returns the id from the parent object
+ * @access public
+ * @param string $objectID The object id
+ * @return string The id from the parent object
+ */
+ public function getParentID($objectID)
+ {
+ $db = DBManager::get();
+
+ $sql =
+ "SELECT" .
+ " parent_id " .
+ "FROM" .
+ " evalquestion " .
+ "WHERE" .
+ " evalquestion_id = ?";
+ $result = $db->fetchColumn($sql, [$objectID]);
+ return $result;
+ }
+
+ /**
+ * Returns the ids of the Answertemplates of a user
+ * @access public
+ * @param string $userID The user id
+ * @return array The ids of the answertemplates
+ */
+ public function getTemplateID($userID)
+ {
+ $db = DBManager::get();
+
+ if (EvaluationObjectDB::getGlobalPerm() == "root") {
+ $sql =
+ "SELECT" .
+ " evalquestion_id " .
+ "FROM" .
+ " evalquestion " .
+ "WHERE" .
+ " parent_id = '0' ORDER BY text";
+ return $db->fetchFirst($sql);
+ } else {
+ $sql =
+ "SELECT" .
+ " evalquestion_id " .
+ "FROM" .
+ " evalquestion " .
+ "WHERE" .
+ " parent_id = '" . $userID . "' " .
+ "OR " .
+ " parent_id = '0' ORDER BY text";
+ $sql .= " ";
+ return $db->fetchFirst($sql, [$userID]);
+ }
+ }
+}
diff --git a/lib/evaluation/evaluation.config.php b/lib/evaluation/evaluation.config.php
new file mode 100644
index 0000000..63b1aab
--- /dev/null
+++ b/lib/evaluation/evaluation.config.php
@@ -0,0 +1,154 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * Configurationfile for the evaluation module
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Include all required files ================================================ #
+
+# ====================================================== end: including files #
+
+
+# Define public constants =================================================== #
+
+/* General constants ------------------------------------------------------- */
+define ("YES", 1);
+define ("NO", 0);
+define ("DEBUG", 1);
+define ("QUOTED", 1);
+define ("UNQUOTED", 0);
+define ("EVAL_MIN_SEARCHLEN", 3);
+define ("EVAL_MAX_TEMPLATENAMELEN", 22);
+/* -------------------------------------------------- end: general constants */
+
+/* Path constants ---------------------------------------------------------- */
+define ("EVAL_PATH_RELATIV", "lib/evaluation/");
+define ("EVAL_PATH", EVAL_PATH_RELATIV);
+define ("EVAL_PATH_CLASSES", EVAL_PATH."classes/");
+define ("EVAL_PATH_DBCLASSES", EVAL_PATH_CLASSES."db/");
+/* ----------------------------------------------------- end: path constatns */
+
+/* Class constants --------------------------------------------------------- */
+define ("EVAL_FILE_EDIT", "evaluation_admin_edit.inc.php");
+define ("EVAL_FILE_TEMPLATE", "evaluation_admin_template.inc.php");
+define ("EVAL_FILE_OVERVIEW", "evaluation_admin_overview.inc.php");
+define ("EVAL_FILE_SHOW", "show_evaluation.php");
+define ("EVAL_FILE_ADMIN", "admin_evaluation.php");
+
+define ("EVAL_FILE_OBJECT", EVAL_PATH_CLASSES."EvaluationObject.class.php");
+define ("EVAL_FILE_OBJECTDB", EVAL_PATH_DBCLASSES."EvaluationObjectDB.class.php");
+define ("EVAL_FILE_EVAL", EVAL_PATH_CLASSES."Evaluation.class.php");
+define ("EVAL_FILE_EVALDB", EVAL_PATH_DBCLASSES."EvaluationDB.class.php");
+define ("EVAL_FILE_GROUP", EVAL_PATH_CLASSES."EvaluationGroup.class.php");
+define ("EVAL_FILE_GROUPDB", EVAL_PATH_DBCLASSES."EvaluationGroupDB.class.php");
+define ("EVAL_FILE_QUESTION", EVAL_PATH_CLASSES."EvaluationQuestion.class.php");
+define ("EVAL_FILE_QUESTIONDB", EVAL_PATH_DBCLASSES."EvaluationQuestionDB.class.php");
+define ("EVAL_FILE_ANSWER", EVAL_PATH_CLASSES."EvaluationAnswer.class.php");
+define ("EVAL_FILE_ANSWERDB", EVAL_PATH_DBCLASSES."EvaluationAnswerDB.class.php");
+define ("EVAL_FILE_EXPORTMANAGER", EVAL_PATH_CLASSES."EvaluationExportManager.class.php");
+define ("EVAL_FILE_EXPORTMANAGERCSV", EVAL_PATH_CLASSES."EvaluationExportManagerCSV.class.php");
+define ("EVAL_FILE_EVALTREE", EVAL_PATH_CLASSES."EvaluationTree.class.php");
+define ("EVAL_FILE_EDIT_TREEVIEW", EVAL_PATH_CLASSES."EvaluationTreeEditView.class.php");
+define ("EVAL_FILE_SHOW_TREEVIEW", EVAL_PATH_CLASSES."EvaluationTreeShowUser.class.php");
+
+define ("HTML", EVAL_PATH_CLASSES."HTML.class.php");
+define ("HTMLempty", EVAL_PATH_CLASSES."HTMLempty.class.php");
+/* --------------------------------------------------- end: class constants */
+
+/* Library constants ------------------------------------------------------- */
+define ("EVAL_LIB_COMMON", EVAL_PATH."evaluation.lib.php");
+define ("EVAL_LIB_OVERVIEW", EVAL_PATH."evaluation_admin_overview.lib.php");
+define ("EVAL_LIB_EDIT", EVAL_PATH."evaluation_admin_edit.lib.php");
+define ("EVAL_LIB_TEMPLATE", EVAL_PATH."evaluation_admin_template.lib.php");
+define ("EVAL_LIB_SHOW", EVAL_PATH."evaluation_show.lib.php");
+/* -------------------------------------------------- end: library constants */
+
+/* Picture constants ------------------------------------------------------- */
+define ("EVAL_PIC_ICON", Icon::create('test', 'inactive')->asImagePath());
+define ("EVAL_PIC_PREVIEW", Icon::create('question-circle', 'clickable')->asImagePath());
+define ("EVAL_PIC_ADMIN", Icon::create('admin', 'clickable')->asImagePath());
+define ("EVAL_PIC_LOGO", Assets::image_path('sidebar/evaluation-sidebar.png'));
+define ("EVAL_PIC_ARROW", Icon::create('arr_1right', 'accept')->asImagePath());
+define ("EVAL_PIC_ARROW_ACTIVE", Icon::create('arr_1down', 'accept')->asImagePath());
+define ("EVAL_PIC_SUCCESS", Icon::create('accept', 'accept')->asImagePath());
+define ("EVAL_PIC_ERROR", Icon::create('decline', 'attention')->asImagePath());
+define ("EVAL_PIC_INFO", Icon::create('exclaim', 'inactive')->asImagePath());
+define ("EVAL_PIC_INFO_SMALL", Icon::create('info', 'info')->asImagePath());
+define ("EVAL_PIC_HELP", Icon::create('info-circle', 'inactive')->asImagePath());
+define ("EVAL_PIC_MOVE_GROUP", Icon::create('arr_2left', 'sort')->asImagePath());
+define ("EVAL_PIC_MOVE_UP", Icon::create('arr_2up', 'sort')->asImagePath());
+define ("EVAL_PIC_MOVE_DOWN", Icon::create('arr_2down', 'sort')->asImagePath());
+define ("EVAL_PIC_MOVE_RIGHT", Icon::create('arr_2right', 'sort')->asImagePath());
+define ("EVAL_PIC_MOVE_LEFT", Icon::create('arr_2left', 'sort')->asImagePath());
+define ("EVAL_PIC_CREATE_ANSWERS", Assets::image_path('eval_create_answers.gif'));
+define ("EVAL_PIC_EDIT_ANSWERS", Assets::image_path('eval_edit_answers.gif'));
+define ("EVAL_PIC_TIME", Icon::create('date', 'info')->asImagePath());
+define ("EVAL_PIC_EXCLAIM", Icon::create('info', 'info')->asImagePath());
+define ("EVAL_PIC_DELETE_GROUP", Icon::create('trash', 'clickable')->asImagePath());
+define ("EVAL_PIC_MOVE_BUTTON", Icon::create('arr_2right', 'sort')->asImagePath());
+define ("EVAL_PIC_ADD", Icon::create('add', 'clickable')->asImagePath());
+define ("EVAL_PIC_ADD_TEMPLATE", Icon::create('add', 'clickable')->asImagePath());
+define ("EVAL_PIC_REMOVE", Icon::create('trash', 'clickable')->asImagePath());
+define ("EVAL_PIC_EDIT", Icon::create('edit', 'clickable')->asImagePath());
+define ("EVAL_PIC_BACK", Icon::create('link-intern', 'clickable')->asImagePath());
+define ("EVAL_PIC_ARROW_TEMPLATE", Icon::create('arr_1right', 'clickable')->asImagePath());
+define ("EVAL_PIC_ARROW_TEMPLATE_OPEN", Icon::create('arr_1down', 'clickable')->asImagePath());
+define ("EVAL_PIC_ARROW_NEW", Icon::create('arr_1right', 'sort')->asImagePath());
+define ("EVAL_PIC_ARROW_NEW_OPEN", Icon::create('arr_1down', 'sort')->asImagePath());
+define ("EVAL_PIC_ARROW_RUNNING", Icon::create('arr_1right', 'accept')->asImagePath());
+define ("EVAL_PIC_ARROW_RUNNING_OPEN", Icon::create('arr_1down', 'accept')->asImagePath());
+define ("EVAL_PIC_ARROW_STOPPED", Icon::create('arr_1right', 'attention')->asImagePath());
+define ("EVAL_PIC_ARROW_STOPPED_OPEN", Icon::create('arr_1down', 'attention')->asImagePath());
+define ("EVAL_PIC_TREE_ARROW", Icon::create('arr_1right', 'clickable')->asImagePath());
+define ("EVAL_PIC_TREE_ARROW_ACTIVE", Icon::create('arr_1down', 'clickable')->asImagePath());
+define ("EVAL_PIC_TREE_BLANC", Assets::image_path('forumleer.gif'));
+define ("EVAL_PIC_TREE_ROOT", Icon::create('vote', 'inactive')->asImagePath());
+define ("EVAL_PIC_TREE_GROUP", Icon::create('test', 'info')->asImagePath());
+define ("EVAL_PIC_TREE_GROUP_FILLED", Assets::image_path('eval_group_filled.gif'));
+define ("EVAL_PIC_TREE_QUESTIONGROUP", Icon::create('test', 'info')->asImagePath());
+define ("EVAL_PIC_TREE_QUESTIONGROUP_FILLED", Assets::image_path('eval_qgroup_filled.gif'));
+define ("EVAL_PIC_EXPORT_FILE", Icon::create('file-xls', 'clickable')->asImagePath());
+define ("EVAL_PIC_YES", Icon::create('accept', 'accept')->asImagePath());
+define ("EVAL_PIC_NO", Icon::create('decline', 'attention')->asImagePath());
+define ("EVAL_PIC_SHARED", Icon::create('checkbox-checked', 'clickable')->asImagePath());
+define ("EVAL_PIC_NOTSHARED", Icon::create('checkbox-unchecked', 'clickable')->asImagePath());
+/* -------------------------------------------------- end: picture constants */
+
+/* CSS constants ----------------------------------------------------------- */
+define ("EVAL_CSS_SUCCESS", "eval_success");
+define ("EVAL_CSS_ERROR", "eval_error");
+define ("EVAL_CSS_INFO", "eval_info");
+/* ------------------------------------------------------ end: css constants */
+
+# ===================================================== end: define constants #
+?>
diff --git a/lib/evaluation/evaluation.lib.php b/lib/evaluation/evaluation.lib.php
new file mode 100644
index 0000000..6314454
--- /dev/null
+++ b/lib/evaluation/evaluation.lib.php
@@ -0,0 +1,263 @@
+<?php
+# Lifter002: TODO
+# Lifter005: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+
+# Define constants ========================================================== #
+# ===================================================== end: define constants #
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once HTML;
+# ====================================================== end: including files #
+
+
+/**
+ * Library with common static functions for the evaluation module
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class EvalCommon
+{
+ /**
+ * Creates this funny blue title bar
+ * @param string $title The title
+ * @param string $iconURL The URL for the icon
+ */
+ public static function createTitle($title, $iconURL = "", $padding = 0)
+ {
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("class", "blank");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", $padding);
+ $table->addAttr("width", "100%");
+
+ $trTitle = new HTML("tr");
+ $trTitle->AddAttr("valign", "top");
+ $trTitle->AddAttr("align", "center");
+
+ $tdTitle = new HTML("td");
+ if ($iconURL) {
+ $tdTitle->addAttr("class", "table_header_bold");
+ } else {
+ $tdTitle->addAttr("class", "content_body");
+ }
+ $tdTitle->addAttr("colspan", "2");
+ $tdTitle->addAttr("align", "left");
+ $tdTitle->addAttr("valign", "middle");
+
+ if ($iconURL) {
+ $imgTitle = new HTMLempty ("img");
+ $imgTitle->addAttr("src", $iconURL);
+ $imgTitle->addAttr("alt", $title);
+ $imgTitle->addAttr("align", "bottom");
+ $tdTitle->addContent($imgTitle);
+ }
+
+ $bTitle = new HTML ("b");
+ $bTitle->addContent($title);
+ $tdTitle->addContent($bTitle);
+
+ $trTitle->addContent($tdTitle);
+ $table->addContent($trTitle);
+
+ return $table;
+ }
+
+ /**
+ * Creates a simple image for the normal top of an modulepage
+ * @param string $imgURL The URL for the icon
+ * @param string $imgALT The description for the icon
+ */
+ public static function createImage($imgURL, $imgALT, $extra = "")
+ {
+ $img = new HTMLempty ("img");
+ $img->addAttr("border", "0");
+ $img->addAttr("valign", "middle");
+ $img->addAttr("src", $imgURL);
+ if (empty($extra)) {
+ $img->addAttr("alt", $imgALT);
+ $img->addAttr("title", $imgALT);
+ } else {
+ $img->addString($extra);
+ }
+
+ return $img;
+ }
+
+ /**
+ * Creates the Javascript static function, which will open an evaluation popup
+ */
+ static function createEvalShowJS($isPreview = NO, $as_object = YES)
+ {
+ $html = "";
+ $html .=
+ "<script type=\"text/javascript\" language=\"JavaScript\">" .
+ " function openEval( evalID ) {" .
+ " evalwin = window.open(STUDIP.URLHelper.getURL('show_evaluation.php?evalID=' + evalID + '&isPreview=" . $isPreview . "'), " .
+ " evalID, 'width=790,height=500,scrollbars=yes,resizable=yes');" .
+ " evalwin.focus();" .
+ " }\n" .
+ "</script>\n";
+
+ $div = new HTML ("div");
+ $div->addHTMLContent($html);
+
+ if ($as_object) {
+ return $div;
+ }
+ return $html;
+ }
+
+ /**
+ * Creates a link, which will open an evaluation popup
+ */
+ static function createEvalShowLink($evalID, $content, $isPreview = NO, $as_object = YES)
+ {
+ $html = "";
+
+ $html .=
+ "<a " .
+ "href=\"" . URLHelper::getLink('show_evaluation.php?evalID=' . $evalID . '&isPreview=' . $isPreview) . "\" " .
+ "target=\"" . $evalID . "\" " .
+ "onClick=\"openEval('" . $evalID . "'); return false;\">" .
+ (is_object($content) ? str_replace("\n", "", $content->createContent()) : $content) .
+ "</a>";
+
+ $div = new HTML ("div");
+ $div->addHTMLContent($html);
+
+ if ($as_object) {
+ return $div;
+ }
+ return $html;
+ }
+
+
+ /**
+ * Creates an errormessage from an object
+ * @param object StudipObejct $object A Stud.IP-object
+ */
+ public static function showErsrorReport(&$object, $errortitle = "")
+ {
+ $errors = $object->getErrors();
+ if (empty ($errortitle)) {
+ if ($errors && count($errors) > 1) {
+ $errortitle = _("Es sind Fehler aufgetreten.");
+ } else {
+ $errortitle = _("Es ist ein Fehler aufgetreten.");
+ }
+ }
+
+ if (!$object->isError()) {
+ return MessageBox::success(_("Es ist kein Fehler aufgetreten"));
+ } else {
+ $details = [];
+ if (!empty($errors)) {
+ foreach ($errors as $error) {
+ $string = $error['string'];
+ if ($error["type"] == ERROR_CRITICAL) {
+ $string .= _("Datei: ") . $error["file"] . '<br>';
+ $string .= _("Zeile: ") . $error["line"] . '<br>';
+
+ }
+ $details[] = $string;
+ }
+ }
+ return MessageBox::error($errortitle, $details);
+ }
+ }
+
+ /**
+ * @param $object
+ * @param string $errortitle
+ * @return MessageBox|object
+ * @deprecated
+ */
+ public static function createErrorReport(&$object, $errortitle = "")
+ {
+ return MessageBox::error($errortitle);
+ }
+
+ /**
+ * Returns the rangeID
+ */
+ public static function getRangeID()
+ {
+ $rangeID = Request::option('range_id') ?: Context::getId();
+
+ if (empty ($rangeID) || ($rangeID == get_username($GLOBALS['user']->id)))
+ $rangeID = $GLOBALS['user']->id;
+
+ return $rangeID;
+ }
+
+
+ /**
+ * Checks and transforms a date into a UNIX (r)(tm) timestamp
+ * @access public
+ * @static
+ * @param integer $day The day
+ * @param integer $month The month
+ * @param integer $year The year
+ * @param integer $hour The hour (optional)
+ * @param integer $minute The minute (optional)
+ * @param integer $second The second (optional)
+ * @return integer If an error occurs -> -1. Otherwise the UNIX-timestamp
+ */
+ public static function date2timestamp(
+ $day,
+ $month,
+ $year,
+ $hour = 0,
+ $minute = 0,
+ $second = 0
+ )
+ {
+ if (!checkdate((int)$month, (int)$day, (int)$year) ||
+ $hour < 0 || $hour > 24 ||
+ $minute < 0 || $minute > 59 ||
+ $second < 0 || $second > 59) {
+ return -1;
+ }
+
+ // windows cant count that mutch
+ if ($year < 1971) {
+ $year = 1971;
+ } elseif ($year > 2037) {
+ $year = 2037;
+ }
+
+ return mktime($hour, $minute, $second, $month, $day, $year);
+ }
+}
+
+?>
diff --git a/lib/evaluation/evaluation_admin_edit.inc.php b/lib/evaluation/evaluation_admin_edit.inc.php
new file mode 100644
index 0000000..5785368
--- /dev/null
+++ b/lib/evaluation/evaluation_admin_edit.inc.php
@@ -0,0 +1,229 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * Beschreibung
+ *
+ * @author Christian Bauer <alfredhitchcock@gmx.net>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +---------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +---------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +---------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +---------------------------------------------------------------------------+
+
+# PHP-LIB: open session ===================================================== #
+/*page_open (array ("sess" => "Seminar_Session",
+ "auth" => "Seminar_Auth",
+ "perm" => "Seminar_Perm",
+ "user" => "Seminar_User"));
+$auth->login_if ($auth->auth["uid"] == "nobody");
+$perm->check ("autor");*/
+# ============================================================== end: PHP-LIB #
+
+# Include all required files ================================================ #
+
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_LIB_EDIT;
+require_once EVAL_FILE_EDIT_TREEVIEW;
+
+# ====================================================== end: including files #
+
+# define constancs ========================================================== #
+
+/**
+ * @const NEW_EVALUATION_TITLE title of a new question block
+ * @access public
+ */
+define("NEW_EVALUATION_TITLE", _("Neue Evaluation"));
+
+/**
+ * @const FIRST_ARRANGMENT_BLOCK_TITLE title of a new arrangment block
+ * @access public
+ */
+define("FIRST_ARRANGMENT_BLOCK_TITLE", _("Erster Gruppierungsblock"));
+
+# ====================================================== end: define constancs #
+
+$debug = "<pre class=\"steelgroup6\" style=\"font-size:10pt\">"
+ . "<pre class=\"steelgroup3\" style=\"font-size:10pt\">"
+ . "Welcome to BugReport 1.02 "
+ . "[Sharewareversion]"
+ . "</pre>";
+
+# check the evalID ========================================================= #
+
+global $user;
+
+if (Request::submitted('newButton')) {
+ $debug .= "neue Eval!<br>";
+ // create the first group
+ $group = new EvaluationGroup();
+ $group->setTitle(FIRST_ARRANGMENT_BLOCK_TITLE, QUOTED);
+ $group->setText("");
+ if ($group->isError()) {
+ return MessageBox::error(_("Fehler beim Anlegen einer Gruppe"));
+ }
+ // create a new eval
+ $eval = new Evaluation ();
+ $rangeID = Request::option("rangeID");
+ if ($rangeID == $user->username) {
+ $rangeID = $user->id;
+ }
+
+ $eval->setAuthorID($user->id);
+ $eval->setTitle(NEW_EVALUATION_TITLE);
+ $eval->setAnonymous(YES);
+ $evalID = $eval->getObjectID();
+ $eval->addChild($group);
+ $eval->save();
+
+ if ($eval->isError()) {
+ return MessageBox::error(_("Fehler beim Anlegen einer Evaluation"));
+ }
+
+ $groupID = $group->getObjectID();
+ $evalID = $eval->getObjectID();
+
+} elseif (Request::option("evalID") && (Request::option("evalID") != NULL)) {
+ $debug .= "isset _REQUTEST[evalID]!<br>";
+ $evalID = Request::option("evalID");
+ $eval = new Evaluation ($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
+ if ($eval->isError()) {
+ PageLayout::postError(_("Es wurde eine ungültige Evaluations-ID übergeben."));
+ } elseif ($evalID == NULL) {
+ PageLayout::postError(_("Es wurde keine Evaluations-ID übergeben"));
+ }
+
+} else {
+ PageLayout::postError(_("Es wurde keine Evaluations-ID übergeben"));
+}
+
+# ===================================================== END: check the evalID #
+
+# check the itemID ========================================================= #
+$itemID = Request::option('itemID');
+if ($itemID) {
+ $_SESSION['itemID'] = $itemID;
+} elseif (Request::submitted('newButton')) {
+ $_SESSION['itemID'] = "root";
+}
+# ===================================================== END: check the itemID #
+
+# check the rangeID ======================================================== #
+
+if (Request::option("rangeID")) {
+ $_SESSION['rangeID'] = Request::option("rangeID");
+
+}
+
+# ==================================================== END: check the rangeID #
+
+# EVTAU: employees of the vote-team against urlhacking ====================== #
+
+$eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
+
+// someone has voted
+if ($eval->hasVoted()) {
+ $error = MessageBox::error(
+ _("An dieser Evaluation hat bereits jemand teilgenommen. Sie darf nicht mehr verändert werden.")
+ );
+}
+
+
+// only the author or user with tutor perm in all evalRangeIDs should edit an eval
+$authorID = $eval->getAuthorID();
+$db = new EvaluationObjectDB();
+
+if ($authorID != $user->id) {
+
+ $no_permisson = 0;
+
+ if (is_array($eval->getRangeIDs())) {
+
+ foreach ($eval->getRangeIDs() as $rangeID) {
+
+ $user_perm = $db->getRangePerm($rangeID, $user->id, YES);
+
+ // every range with a lower perm than Tutor
+ if ($user_perm < 7)
+ $no_permisson++;
+ }
+
+ if ($no_permisson > 0) {
+ if ($no_permisson == 1) {
+ $no_permisson_msg = _("Sie haben in einem Bereich, in welchem diese Evaluation hängt, nicht aussreichene Rechte, um diese Eval zu bearbeiten.");
+ } else {
+ $no_permisson_msg = sprintf(_("Sie haben in %s Bereichen, in denen diese Evaluation hängt, nicht aussreichene Rechte, um diese Eval zu bearbeiten."), $no_permisson);
+ }
+ $error_msgs[] = MessageBox::error($no_permisson_msg);
+ }
+ }
+}
+
+
+# ============================================ end: Collection post/get-vars #
+
+# Print Error MSG and end Site ============================================= #
+
+if ($error_msgs) {
+
+ $back_button = ("&nbsp;&nbsp;&nbsp;")
+ . "<a href=\"" . URLHelper::getLink('admin_evaluation.php?page=overview&rangeID=' . Request::option('rangeID')) . "\">"
+ . _("Zur Evaluations-Verwaltung")
+ . "</a>";
+
+ if (is_array($error_msgs)) {
+ foreach ($error_msgs as $error_msg) {
+ $errors .= $error_msg . "<br>";
+ }
+
+ }
+ echo EvalEdit::createSite($errors . $back_button, " ");
+ include_once('lib/include/html_end.inc.php');
+ page_close();
+ exit ();
+
+}
+
+
+# ======================================== end: Print Error MSG and end Site #
+
+/* Do first all actions for templates -------------------------------------- */
+$templateSite = include(EVAL_FILE_TEMPLATE);
+/* --------------------------------- end: do first all actions for templates */
+
+
+# Creating the Tree ======================================================== #
+$EditTree = new EvaluationTreeEditView($itemID, $evalID);
+
+# Send messages to the tree ================================================ #
+
+if (Request::submitted('newButton')) {
+ $EditTree->msg["root"] = "msg§"
+ . _("Erstellen Sie nun eine Evaluation.<br> Der erste Gruppierungsblock ist bereits angelegt worden. Wenn Sie ihn öffnen, können Sie dort weitere Gruppierungsblöcke oder Fragenblöcke anlegen.");
+}
+$editSite = $EditTree->showEvalTree($itemID, 1);
+echo EvalEdit::createSite($editSite, $templateSite);
+
+?>
diff --git a/lib/evaluation/evaluation_admin_edit.lib.php b/lib/evaluation/evaluation_admin_edit.lib.php
new file mode 100644
index 0000000..a79bb78
--- /dev/null
+++ b/lib/evaluation/evaluation_admin_edit.lib.php
@@ -0,0 +1,99 @@
+<?php
+/**
+ * Beschreibung
+ *
+ * @author Christian Bauer <alfredhitchcock@gmx.net>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +---------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +---------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +---------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +---------------------------------------------------------------------------+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once HTML;
+//require_once (HTMLempty);
+# ====================================================== end: including files #
+class EvalEdit
+{
+
+ /**
+ * creates the main-table
+ * @access public
+ * @param string $title the title
+ * @param string $left the left site of the table
+ * @param string $rigt the right site of the table
+ * @return string the html-table
+ */
+ public function createSite($left = "", $right = "")
+ {
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("class", "blank");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("width", "100%");
+
+ $tr = new HTML("tr");
+
+ $td = new HTML("td");
+ $td->addAttr("class", "blank");
+ $td->addAttr("width", "100%");
+ $td->addAttr("align", "left");
+ $td->addAttr("valign", "top");
+ $td->setTextareaCheck(YES);
+ $td->addHTMLContent($left);
+
+ $tr->addContent($td);
+
+ $td = new HTML("td");
+ $td->addAttr("class", "blank");
+ $td->addAttr("align", "right");
+ $td->addAttr("valign", "top");
+ $td->addHTMLContent($right);
+
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ return $table->createContent();
+ }
+
+ public function createHiddenIDs()
+ {
+ $input = new HTML ("input");
+ $input->addAttr("type", "hidden");
+ $input->addAttr("evalID", Request::option('evalID'));
+
+ $input = new HTML ("input");
+ $input->addAttr("type", "hidden");
+ $input->addAttr("itemID", Request::option('itemID'));
+
+ $input = new HTML ("input");
+ $input->addAttr("type", "hidden");
+ $input->addAttr("rangeID", Request::option("rangeID"));
+
+ return;
+ }
+}
+
+?>
diff --git a/lib/evaluation/evaluation_admin_overview.inc.php b/lib/evaluation/evaluation_admin_overview.inc.php
new file mode 100644
index 0000000..a670e2f
--- /dev/null
+++ b/lib/evaluation/evaluation_admin_overview.inc.php
@@ -0,0 +1,390 @@
+<?php
+/**
+ * Overview of all existing evaluations
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+# PHP-LIB: open session ===================================================== #
+// page_open (array ("sess" => "Seminar_Session",
+// "auth" => "Seminar_Auth",
+// "perm" => "Seminar_Perm",
+// "user" => "Seminar_User"));
+// $auth->login_if ($auth->auth["uid"] == "nobody");
+// $GLOBALS['perm']->check ("autor");
+# ============================================================== end: PHP-LIB #
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once EVAL_LIB_COMMON;
+require_once EVAL_LIB_OVERVIEW;
+require_once EVAL_FILE_EVAL;
+require_once EVAL_FILE_EVALDB;
+# ====================================================== end: including files #
+
+define("DISCARD_OPENID", "discard_openid");
+
+/* Create objects ---------------------------------------------------------- */
+$db = new EvaluationObjectDB ();
+if ($db->isError) {
+ return MessageBox::error(_("Datenbankfehler"));
+}
+$lib = new EvalOverview ($db, $GLOBALS['perm'], $GLOBALS['user']);
+/* ------------------------------------------------------------ end: objects */
+
+
+/* Set variables ----------------------------------------------------------- */
+if ($_SESSION['evalID']) {
+ unset($_SESSION['evalID']);
+}
+if ($_SESSION['rangeID']) {
+ unset($_SESSION['rangeID']);
+}
+
+if (!empty($the_range)) {
+ $rangeID = $the_range;
+}
+
+$rangeID = ($rangeID) ? $rangeID : Context::getId();
+
+if (empty ($rangeID) || ($rangeID == $GLOBALS['user']->username)) {
+ $rangeID = $GLOBALS['user']->id;
+}
+$_SESSION['rangeID'] = $rangeID;
+$debug = 0;
+
+$evalAction = $lib->getPageCommand();
+
+$openID = Request::option("openID");
+$evalID = Request::option("evalID");
+$search = Request::get("search"); // range
+$templates_search = Request::get("templates_search");
+$search = $templates_search;
+/* ---------------------------------------------------------- end: variables */
+
+/* Javascript function ----------------------------------------------------- */
+$js = EvalCommon::createEvalShowJS(YES);
+echo $js->createContent();
+
+/* Maintable with white border --------------------------------------------- */
+$table = $lib->createMainTable();
+/* -----------------------------------------------------------end: maintable */
+
+/* Check permissions and call safeguard ------------------------------------ */
+if (!$GLOBALS['perm']->have_studip_perm("tutor", $rangeID) && $GLOBALS['user']->id != $rangeID) {
+ echo MessageBox::error(_("Sie haben keinen Zugriff auf diesen Bereich."));
+ return;
+}
+
+$safeguard = $lib->callSafeguard($evalAction, $evalID, $rangeID, $search, $referer);
+/* ---------------------------------------------------------- end: safeguard */
+
+/* found public templates -------------------------------------------------- */
+if ($templates_search) {
+ $search = trim($search);
+ $evalIDArray = $db->getPublicTemplateIDs($search);
+ if (mb_strlen($search) >= EVAL_MIN_SEARCHLEN && !empty ($evalIDArray)) {
+ $foundTable = new HTML ("table");
+ $foundTable->addAttr("border", "0");
+ $foundTable->addAttr("align", "center");
+ $foundTable->addAttr("cellspacing", "0");
+ $foundTable->addAttr("cellpadding", "0");
+ $foundTable->addAttr("width", "100%");
+ $foundTr = new HTML ("tr");
+ $foundTd = new HTML ("td");
+ $foundTd->addAttr("align", "left");
+ $foundTd->addAttr("colspan", "10");
+ $foundTd->addContent(new HTMLempty ("br"));
+
+ $b = new HTML ("b");
+ $b->addContent(_("Gefundene öffentliche Evaluationsvorlagen:"));
+ $foundTd->addContent($b);
+ $foundTr->addContent($foundTd);
+ $foundTable->addContent($foundTr);
+
+ $foundTable->addContent($lib->createGroupTitle([
+ " ",
+ _("Titel"),
+# " ",
+ _("Autor"),
+ _("Letzte Änderung"),
+ _("Anonym"),
+ "",
+ _("Ansehen"),
+ _("Kopieren"),
+ " "
+ ], YES, "public_template"));
+ foreach ($evalIDArray as $number => $evalID) {
+ $eval = new Evaluation ($evalID);
+ $foundTable->addContent($lib->createEvalRow($eval, $number, "public_template", NO, YES));
+ }
+ }
+}
+/* --------------------------------------------- end: found public templates */
+
+/* Own templates ----------------------------------------------------------- */
+$evalIDArray = $db->getEvaluationIDs();
+$templateTable = new HTML ("table");
+$templateTable->addAttr("border", "0");
+#$templateTable->addAttr ("style","border:1px solid black");
+$templateTable->addAttr("align", "center");
+$templateTable->addAttr("cellspacing", "0");
+$templateTable->addAttr("cellpadding", "2");
+$templateTable->addAttr("width", "100%");
+$templateTr = new HTML ("tr");
+$templateTd = new HTML ("td");
+$templateTd->addAttr("colspan", "7");
+
+$b = new HTML ("h2");
+$b->addContent(_("Eigene Evaluationsvorlagen:"));
+$templateTd->addContent($b);
+$templateTr->addContent($templateTd);
+$templateTable->addContent($templateTr);
+
+if (!empty ($evalIDArray)) {
+ $templateTable->addContent($lib->createGroupTitle([
+ " ",
+ _("Titel"),
+ _("Freigeben"),
+ " ",
+ " ",
+ " ",
+ _("Bearbeiten"),
+ _("Löschen")], YES, "user_template"));
+ foreach ($evalIDArray as $number => $evalID) {
+ $eval = new Evaluation ($evalID);
+ $open = ($openID == $evalID);
+ $templateTable->addContent($lib->createEvalRow($eval, $number, "user_template", $open, YES));
+ if ($open) {
+ $tr = new HTML ("tr");
+ $td = new HTML ("td");
+ $td->addAttr("colspan", "10");
+ $td->addContent($lib->createEvalContent($eval, $number, "user_template", $safeguard));
+ $tr->addContent($td);
+ $templateTable->addContent($tr);
+ }
+ }
+} else {
+ $tr = new HTML ("tr");
+ $td = new HTML ("td");
+ $td->addAttr("colspan", "10");
+ $td->addContent($lib->createInfoCol(_("Keine eigenen Evaluationsvorlagen vorhanden.")));
+ $tr->addContent($td);
+ $templateTable->addContent($tr);
+}
+
+/* ------------------------------------------------------ end: own templates */
+
+
+/* Create header with logo and safeguard messages -------------------------- */
+if (is_array($safeguard)) {
+ if ($safeguard["option"] == DISCARD_OPENID)
+ $openID = NULL;
+ $safeguard = $safeguard["msg"];
+}
+
+if (empty($openID)) {
+ $table->addContent($lib->createHeader($safeguard, $templateTable, $foundTable));
+} else {
+ $table->addContent($lib->createHeader(" ", $templateTable, $foundTable));
+}
+/* ------------------------------------------------------------- end: header */
+
+$table->addContent($lib->createClosingRow());
+/* ---------------------------------------------------------- end: templates */
+
+
+/* Create line with informations ------------------------------------------- */
+$tr = new HTML ("tr");
+$td = new HTML ("td");
+$td->addAttr("class", "blank");
+
+
+if ($lib->db->getGlobalPerm() != "autor") {
+ $td->addContent($lib->createShowRangeForm());
+} else {
+ $td->addHTMLContent("Evaluationen aus dem Bereich \"" .
+ htmlReady($db->getRangename($rangeID)) . "\":");
+ $td->addContent(new HTMLempty ("br"));
+}
+$td->addContent(new HTMLempty ("br"));
+
+
+$tr->addContent($td);
+$table->addContent($tr);
+/* ----------------------------------------------------------- end: infoline */
+
+/* Show showrange search results ------------------------------------------- */
+if ($evalAction == "search_showrange" && Request::get("search")) {
+ $tr = new HTML ("tr");
+ $td = new HTML ("td");
+ $td->addAttr("class", "blank");
+ $td->addAttr("align", "left");
+ $td->addContent(new HTMLempty ("br"));
+ $b = new HTML ("b");
+ $line = new HTMLempty ("hr");
+ $line->addAttr("size", "1");
+ $line->addAttr("noshade", "noshade");
+#$td->addContent ($line);
+ $b->addContent(_('Suchergebnisse') . ':');
+ $td->addContent($b);
+
+ $td->addHTMLContent($lib->createDomainLinks(Request::get("search")));
+ $tr->addContent($td);
+ $table->addContent($tr);
+ $table->addContent($lib->createClosingRow());
+ echo $table->createContent();
+ return;
+}
+/* -------------------------------------- end: Show showrange search results */
+
+/* Show not started evaluations -------------------------------------------- */
+$evalIDArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_NEW);
+
+$tr = new HTML ("tr");
+$td = new HTML ("td");
+$td->addAttr("class", "blank");
+$b = new HTML ("b");
+$b->addContent(_("Noch nicht gestartete Evaluationen: "));
+$td->addContent($b);
+
+if (!empty ($evalIDArray)) {
+ $td->addContent($lib->createGroupTitle([_("Titel"),
+ _("Autor"),
+ _("Startdatum"),
+ _("Status"),
+ "",
+ _("Bearbeiten"),
+ _("Löschen"),
+ ""]));
+ foreach ($evalIDArray as $number => $evalID) {
+ $eval = new Evaluation ($evalID);
+ $open = ($openID == $evalID);
+ $td->addContent($lib->createEvalRow($eval, $number, EVAL_STATE_NEW, $open));
+ if ($open)
+ $td->addContent($lib->createEvalContent($eval, $number, EVAL_STATE_NEW, $safeguard));
+ }
+
+} else {
+ $td->addContent($lib->createInfoCol(_("Keine neuen Evaluationen vorhanden.")));
+}
+$tr->addContent($td);
+$table->addContent($tr);
+$table->addContent($lib->createClosingRow());
+/* -------------------------------------------------------- end: not started */
+
+
+/* Show running evaluations ------------------------------------------------ */
+$evalIDArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_ACTIVE);
+
+$tr = new HTML ("tr");
+$td = new HTML ("td");
+$td->addAttr("class", "blank");
+$td->addContent(new HTMLEmpty("br"));
+$b = new HTML ("b");
+$b->addContent(_("Laufende Evaluationen:"));
+$td->addContent($b);
+if (!empty ($evalIDArray)) {
+ $td->addContent($lib->createGroupTitle([_("Titel"),
+ _("Autor"),
+ _("Ablaufdatum"),
+ _("Status"),
+ "",
+ _("Exportieren"),
+ _("Löschen"),
+ _("Auswertung")]));
+ foreach ($evalIDArray as $number => $evalID) {
+ $eval = new Evaluation ($evalID);
+ $open = ($openID == $evalID);
+ $td->addContent($lib->createEvalRow($eval, $number, EVAL_STATE_ACTIVE, $open));
+ if ($open)
+ $td->addContent($lib->createEvalContent($eval, $number, EVAL_STATE_ACTIVE, $safeguard));
+ }
+} else {
+ $td->addContent($lib->createInfoCol(_("Keine laufenden Evaluationen vorhanden.")));
+}
+$tr->addContent($td);
+$table->addContent($tr);
+$table->addContent($lib->createClosingRow());
+/* ------------------------------------------------------------ end: running */
+
+
+/* Show stopped evaluations ------------------------------------------------ */
+$evalIDArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_STOPPED);
+$tr = new HTML ("tr");
+$td = new HTML ("td");
+$td->addAttr("class", "blank");
+$td->addContent(new HTMLEmpty("br"));
+$b = new HTML ("b");
+$b->addContent(_("Beendete Evaluationen:"));
+$td->addContent($b);
+
+if (!empty ($evalIDArray)) {
+ $td->addContent($lib->createGroupTitle([_("Titel"),
+ _("Autor"),
+ "",
+ _("Status"),
+ "",
+ _("Exportieren"),
+ _("Löschen"),
+ _("Auswertung")]));
+ foreach ($evalIDArray as $number => $evalID) {
+ $eval = new Evaluation ($evalID);
+ $open = ($openID == $evalID);
+ $td->addContent($lib->createEvalRow($eval, $number, EVAL_STATE_STOPPED, $open));
+ if ($open)
+ $td->addContent($lib->createEvalContent($eval, $number, EVAL_STATE_STOPPED, $safeguard));
+ }
+} else {
+ $td->addContent($lib->createInfoCol(_("Keine gestoppten Evaluationen vorhanden.")));
+}
+$tr->addContent($td);
+$table->addContent($tr);
+$table->addContent($lib->createClosingRow());
+/* ------------------------------------------------------------ end: stopped */
+
+echo $table->createContent();
+
+
+if ($debug) {
+ echo "<pre>";
+ echo "rangeid = $rangeID\n";
+ echo "<font color=red>Nach Evaluationen suchen...</font><br>";
+ $evalArray = $db->getEvaluationIDs($rangeID);
+ echo "ed(n) " . count($evalArray) . " Evaluation(en) gefunden...</font><br>";
+ $evalArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_NEW);
+ echo "Es wurde(n) " . count($evalArray) . " neue Evaluation(en) gefunden...</font><br>";
+ $evalArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_ACTIVE);
+ echo "Es wurde(n) " . count($evalArray) . " laufende Evaluation(en) gefunden...</font><br>";
+ $evalArray = $db->getEvaluationIDs($rangeID, EVAL_STATE_STOPPED);
+ echo "Es wurde(n) " . count($evalArray) . " gestoppte Evaluation(en) gefunden...</font><br>";
+
+ echo EvalCommon::createErrorReport($db);
+
+ print_r($_POST);
+}
diff --git a/lib/evaluation/evaluation_admin_overview.lib.php b/lib/evaluation/evaluation_admin_overview.lib.php
new file mode 100644
index 0000000..9ad6f56
--- /dev/null
+++ b/lib/evaluation/evaluation_admin_overview.lib.php
@@ -0,0 +1,2222 @@
+<?php
+
+# Lifter002: TODO
+# Lifter005: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+use Studip\Button,
+ Studip\LinkButton;
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once HTML;
+require_once EVAL_LIB_COMMON;
+require_once EVAL_LIB_SHOW;
+require_once EVAL_FILE_EXPORTMANAGERCSV;
+# ====================================================== end: including files #
+# Define constants ========================================================== #
+/**
+ * @const EVAL_TITLE Blah...
+ */
+define("EVAL_TITLE", _("Evaluations-Verwaltung"));
+# ===================================================== end: define constants #
+
+/**
+ * Library for the overview of all existing evaluations
+ *
+ * @author Alexander Willner <mail@AlexanderWillner.de>
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ *
+ */
+class EvalOverview
+{
+# Define all required variables ============================================= #
+ /**
+ * Databaseobject
+ * @access private
+ * @var object DatabaseObject $db
+ */
+
+ var $db;
+
+ /**
+ * Permobject
+ * @access private
+ * @var object Perm $perm
+ */
+ var $perm;
+
+ /**
+ * Userobject
+ * @access private
+ * @var object User $user
+ */
+ var $user;
+# ============================================================ end: variables #
+# Define constructor and destructor ========================================= #
+ /**
+ * Constructor
+ * @access public
+ * @param object DatabaseObject $db The database object
+ * @param object Perm $perm The permission object
+ * @param object User $user The user object
+ */
+
+ function __construct($db, $perm, $user)
+ {
+ /* Set default values ------------------------------------------------- */
+ $this->db = $db;
+ $this->perm = $perm;
+ $this->user = $user;
+ /* -------------------------------------------------------------------- */
+ }
+
+# =========================================== end: constructor and destructor #
+# Define public functions =================================================== #
+ /**
+ *
+ */
+
+ function createMainTable()
+ {
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "0");
+ $table->addAttr("width", "100%");
+ $table->addAttr("style", "border:5px solid white;");
+ return $table;
+ }
+
+ /**
+ * Creates the funny blue small titlerows
+ * @access public
+ * @param array $rowTitles An array with all col-titles
+ * @param boolean $returnRow If YES it returns the row not the table
+ * @param string $state
+ */
+ function createGroupTitle($rowTitles, $returnRow = false, $state = false)
+ {
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("width", "100%");
+
+ $tr = new HTML("tr");
+
+ if ($state == "user_template")
+ $style = "steel_with_table_row_even_bg";
+ elseif ($state == "public_template")
+ $style = "eval_grey_border";
+ else
+ $style = "table_header";
+
+ for ($i = 0; $rowTitles != NULL; $i++) {
+
+ $td = new HTML("td");
+ $td->addAttr("style", "vertical-align:bottom; font-weight:bold; white-space:nowrap");
+ $td->addAttr("nowrap", "nowrap");
+ $td->addAttr("height", "22");
+ $td->addAttr("class", $style);
+
+ if ($i == 0) {
+ $td->addAttr("width", $state == "public_template" ? "1" : "10");
+ $td->addHTMLContent("&nbsp;");
+ } else {
+ if ($i == 2 && $state == "user_template") {
+ // the title
+ $td->addAttr("width", "100%");
+ $td->addAttr("align", "left");
+ } elseif ($i == 2 && $state == "public_template") {
+ // the title
+ $td->addAttr("width", "100%");
+ $td->addAttr("align", "left");
+ } elseif ($i > 1) {
+ $td->addAttr("width", "96");
+ $td->addAttr("align", "center");
+ } elseif ($i == 1 && $state == "public_template") {
+ // the preview
+ $td->addAttr("width", "20");
+ $td->addAttr("align", "left");
+ $td->addHTMLContent("&nbsp;");
+ } else {
+ $td->addAttr("align", "left");
+ }
+ $title = array_shift($rowTitles);
+ $title = empty($title) ? "&nbsp;" : $title;
+ $td->addHTMLContent($title);
+ }
+
+ # filter out not needed headlines
+ if ($state == "user_template" &&
+ (($i == 4) || ($i == 5))) {
+ //nothing
+ } elseif ($state == "public_template" &&
+ (($i == 6) || ($i == 7) || ($i == 9))) {
+ //nothing
+ } else
+ $tr->addContent($td);
+ } // for
+
+ $table->addContent($tr);
+
+ return $returnRow ? $tr : $table;
+ }
+
+ /**
+ * Test...
+ * @access public
+ * @param object Evaluation $eval The evaluation
+ * @param string $number
+ * @param string $state
+ * @param string $open
+ * @param boolean $returnRow
+ */
+ function createEvalRow($eval, $number, $state, $open, $returnRow = false)
+ {
+
+ /* initialize variables -------- */
+ $evalID = $eval->getObjectID();
+ $numberOfVotes = EvaluationDB::getNumberOfVotes($evalID);
+
+ $no_permissons = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
+
+ if ($eval->getAuthor() != $GLOBALS['user']->id && $no_permissons)
+ $no_buttons = 1;
+
+ $style = ($number % 2) ? "table_row_odd" : ($number == 0 ? "content_body" : "table_row_even");
+
+ $startDate = $eval->getStartdate() == NULL ? " " : date("d.m.Y", $eval->getStartdate());
+
+ $stopDate = $eval->getRealStopdate() == NULL ? " " : date("d.m.Y", $eval->getRealStopdate());
+
+ $link = "?rangeID=" . $_SESSION["rangeID"];
+ if ($open == NO)
+ $link .= '&openID=' . $evalID . '#open';
+
+ $titleLink = new HTML('a');
+ $titleLink->addAttr('href', URLHelper::getLink($link));
+ $arrowLink = new HTML('a');
+ $arrowLink->addAttr('href', URLHelper::getLink($link));
+
+ $titleLink->addContent(($eval->getTitle()) ? $eval->getTitle() : ' ');
+
+ switch ($state) {
+
+ case "public_template":
+ $arrowLink = "&nbsp;";
+ $titleLink = $eval->getTitle() ? $eval->getTitle() : " ";
+ $content[0] = $eval->getFullname() ? $eval->getFullname() : " ";
+ $content[1] = $eval->getChangedate() == NULL ? " " : date("d.m.Y", $eval->getChangedate());
+
+ $button = LinkButton::create(_('Vorschau'), URLHelper::getURL('show_evaluation.php?evalID=' . $evalID . '&isPreview=' . YES), ['title' => _('Vorschau dieser öffentlichen Evaluationsvorlage.'),
+ 'onClick' => 'openEval(\'' . $evalID . '\'); return false;']);
+ $div = new HTML("div");
+ $div->addHTMLContent($button);
+ $content[4] = $div;
+
+ $content[2] = $eval->isAnonymous() ? EvalCommon::createImage(EVAL_PIC_YES, _("ja")) : EvalCommon::createImage(EVAL_PIC_NO, _("nein"));
+
+ $copyButton = new HTMLempty("input");
+ $copyButton->addAttr("style", "vertical-align:middle;");
+ $copyButton->addAttr("type", "image");
+ $copyButton->addAttr("name", "copy_public_template_button");
+ $copyButton->addAttr("src", Icon::create('arr_2down', 'sort')->asImagePath());
+ $copyButton->addAttr("border", "0");
+ $copyButton->addAttr("alt", _("Kopieren"));
+ $copyButton->addAttr("title", _("Diese öffentliche Evaluationsvorlagen zu den eigenen Evaluationsvorlagen kopieren"));
+ $content[5] = $copyButton;
+
+ break;
+
+ case "user_template":
+ $arrowLink->addContent(EvalCommon::createImage(($open ? EVAL_PIC_ARROW_TEMPLATE_OPEN : EVAL_PIC_ARROW_TEMPLATE), _("Aufklappen")));
+ $isShared = $eval->isShared() ? YES : NO;
+ $shareButton = new HTMLempty("input");
+ $shareButton->addAttr("style", "vertical-align:middle;");
+ $shareButton->addAttr("type", "image");
+ $shareButton->addAttr("name", "share_template_button");
+ $shareButton->addAttr("src", $isShared ? EVAL_PIC_SHARED : EVAL_PIC_NOTSHARED);
+ $shareButton->addAttr("border", "0");
+ $shareButton->addAttr("alt", $isShared ? _("als öffentliche Evaluationsvorlage Freigeben") : _("Freigabe entziehen"));
+ $shareButton->addAttr("title", $isShared ? _("Die Freigabe für diese Evaluationsvorlage entziehen") : _("Diese Evaluationsvorlage öffentlich freigeben"));
+
+ $content[0] = $shareButton;
+ $content[3] = Button::create(_('Kopie erstellen'), 'copy_own_template_button', ['title' => _('Evaluationsvorlage kopieren')]);
+
+ $content[4] = LinkButton::create(_('Bearbeiten'), URLHelper::getURL("admin_evaluation.php?page=edit&evalID=" . $evalID), ['title' => _('Evaluation bearbeiten')]);
+
+ $content[5] = Button::create(_('Löschen'), 'delete_request_button', ['title' => _('Evaluation löschen')]);
+ break;
+
+ case EVAL_STATE_NEW:
+ $arrowLink->addContent(EvalCommon::createImage(($open ? EVAL_PIC_ARROW_NEW_OPEN : EVAL_PIC_ARROW_NEW), _("Aufklappen")));
+ $content[0] = $eval->getFullname() ? $eval->getFullname() : " ";
+ $content[1] = $startDate;
+ if (!$no_buttons) {
+ $content[2] = Button::create(_('Start'), 'start_button', ['title' => _('Evaluation starten')]);
+
+ $content[4] = LinkButton::create(_('Bearbeiten'), URLHelper::getURL("admin_evaluation.php?page=edit&evalID=" . $evalID), ['title' => _('Evaluation bearbeiten')]);
+
+ $content[5] = Button::create(_('Löschen'), 'delete_request_button', ['title' => _('Evaluation löschen')]);
+ }
+ break;
+
+ case EVAL_STATE_ACTIVE:
+ $arrowLink->addContent(EvalCommon::createImage(($open ? EVAL_PIC_ARROW_RUNNING_OPEN : EVAL_PIC_ARROW_RUNNING), _("Aufklappen")));
+ $content[0] = $eval->getFullname() ? $eval->getFullname() : " ";
+ $content[1] = $stopDate;
+ if (!$no_buttons) {
+ $content[2] = Button::createCancel(_('Stop'), 'stop_button', ['title' => _('Evaluation stoppen')]);;
+ // Kann hier noch optimiert werden, da hasVoted () immer einen DB-Aufruf startet
+ $content[3] = ($eval->hasVoted()) ? Button::create(_('Zurücksetzen'), 'restart_request_button', ['title' => _('Evaluation zurücksetzen')]) : Button::create(_('Zurücksetzen'), 'restart_confirmed_button', ['title' => _('Evaluation zurücksetzen')]);
+ $content[4] = Button::create(_('Export'), 'export_request_button', ['title' => _('Evaluation exportieren')]);
+ $content[5] = Button::create(_('Löschen'), 'delete_request_button', ['title' => _('Evaluation löschen')]);
+ //$content[6] = EvalCommon::createSubmitButton ("auswertung", _("Auswertung"), "export_gfx_request_button");
+ $content[6] = LinkButton::create(_('Auswertung'), URLHelper::getURL("eval_summary.php?eval_id=" . $evalID), ['title' => _('Auswertung')]);
+ }
+ break;
+
+ case EVAL_STATE_STOPPED:
+ $arrowLink->addContent(EvalCommon::createImage(($open ? EVAL_PIC_ARROW_STOPPED_OPEN : EVAL_PIC_ARROW_STOPPED), _("Aufklappen")));
+ $content[0] = $eval->getFullname() ? $eval->getFullname() : " ";
+ //$content[1] = $eval->isVisible() ? "yes" : "no";
+ if (!$no_buttons) {
+ $content[2] = Button::create(_('Fortsetzen'), 'continue_button', ['title' => _('Evaluation fortsetzen')]);
+ $content[3] = ($eval->hasVoted()) ? Button::create(_('Zurücksetzen'), 'restart_request_button', ['title' => _('Evaluation zurücksetzen')]) : Button::create(_('Zurücksetzen'), 'restart_confirmed_button', ['title' => _('Evaluation zurücksetzen')]);
+ $content[4] = Button::create(_('Export'), 'export_request_button', ['title' => _('Evaluation exportieren')]);
+ $content[5] = Button::create(_('Löschen'), 'delete_request_button', ['title' => _('Evaluation löschen')]);
+ //$content[6] = EvalCommon::createSubmitButton ("auswertung", _("Auswertung"), "export_gfx_request_button");
+ $content[6] = LinkButton::create(_('Auswertung'), URLHelper::getURL("eval_summary.php?eval_id=" . $evalID), ['title' => _('Auswertung')]);
+ }
+ break;
+ }
+
+ $form = new HTML("form");
+ $form->addAttr("action", URLHelper::getLink("?rangeID=" . $_SESSION["rangeID"]));
+ $form->addAttr("method", "post");
+ $form->addAttr("style", "display:inline;");
+ $form->addHTMLContent(CSRFProtection::tokenTag());
+
+ $input = new HTMLEmpty("input");
+ $input->addAttr("type", "hidden");
+ $input->addAttr("name", "evalID");
+ $input->addAttr("value", $evalID);
+
+ $form->addContent($input);
+
+
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("width", "100%");
+
+ $tr = new HTML("tr");
+ $tr->addAttr("align", "center");
+
+ /* opening arrow */
+ $td = new HTML("td");
+ $td->addAttr("class", $style);
+ $td->addAttr("width", "10");
+ if ($open) {
+ $anchor = new HTML("a");
+ $anchor->addAttr("name", "open");
+ $anchor->addContent($arrowLink);
+ $td->addContent($anchor);
+ } else {
+ $td->addHTMLContent($arrowLink);
+ }
+
+ if ($state != "public_template")
+ $tr->addContent($td);
+ else {
+ $td = new HTML("td");
+ $td->addAttr("class", $style);
+ $td->addAttr("width", "1");
+
+ // create a blindgif
+ $blingif = new HTMLempty("img");
+ $blingif->addAttr("border", "0");
+ $blingif->addAttr("valign", "middle");
+ $blingif->addAttr("width", "1");
+ $blingif->addAttr("height", "24");
+ $blingif->addAttr("alt", " ");
+ $blingif->addAttr("src", Assets::image_path('forumleer.gif'));
+ $td->addContent($blingif);
+ $tr->addContent($td);
+ }
+
+ /* preview icon */
+ $td = new HTML("td");
+ $td->addAttr("width", $state == "public_template" ? "20" : "1%");
+ $td->addAttr("class", $style);
+ $td->addAttr("align", "left");
+ $icon = EvalCommon::createImage(EVAL_PIC_PREVIEW, _("Vorschau"));
+ $td->addContent(EvalCommon::createEvalShowLink($evalID, $icon, YES));
+ $tr->addContent($td);
+
+ /* title */
+ $td = new HTML("td");
+ $td->addAttr("class", $style);
+ $td->addAttr("align", "left");
+ if ($returnRow)
+ $td->addAttr("width", "100%");
+
+ $td->addContent($titleLink);
+
+ if ($state == EVAL_STATE_ACTIVE || $state == EVAL_STATE_STOPPED) {
+ $td->addContent("|");
+ $font = new HTML("font");
+ $font->addAttr("color", "#005500");
+ $font->addContent($numberOfVotes);
+ $td->addContent($font);
+ $td->addContent("|");
+ }
+ $tr->addContent($td);
+ /* the content fields */
+ //for( $i = 0; $i < 6; $i++ ) {
+ for ($i = 0; $i < 7; $i++) {
+ $td = new HTML("td");
+ $td->addAttr("width", "96");
+ $td->addAttr("class", $style);
+ $td->addAttr("nowrap", "nowrap");
+ $td->addAttr("style", "white-space:nowrap");
+ #if (is_object($content[$i]))
+ $td->addContent(($content[$i] ? $content[$i] : " "));
+ #$td->addHTMLContent ( ($content[$i] ? $content[$i] : "-") );
+ # filter out not needed datacells
+ if ($state == "user_template" &&
+ (($i == 1) || ($i == 2))) {
+ //nothing
+ } elseif ($state == "public_template" &&
+ (($i == 3) || ($i == 4))) {
+ //nothing
+ } else {
+ $tr->addContent($td);
+ }
+ } // end: for
+
+ $table->addContent($tr);
+ if ($returnRow)
+ $form->addContent($tr);
+ else
+ $form->addContent($table);
+
+ return $form;
+ }
+
+ /**
+ * Test...
+ * @access public
+ * @param object Evaluation $eval The evaluation
+ */
+ function createEvalContent($eval, $number, $state, $safeguard)
+ {
+
+ /* initialize variables -------- */
+ $evalID = $eval->getObjectID();
+
+ $style = ($number % 2) ? "table_row_odd" : "table_row_even";
+
+ $startDate = $eval->getStartdate() == NULL ? " " : date("d.m.Y", $eval->getStartdate());
+
+ $stopDate = $eval->getRealStopdate() == NULL ? " " : date("d.m.Y", $eval->getRealStopdate());
+
+ switch ($state) {
+
+ case EVAL_STATE_NEW:
+ break;
+
+ case EVAL_STATE_ACTIVE:
+ break;
+
+ case EVAL_STATE_STOPPED:
+ break;
+ }
+
+ $form = new HTML("form");
+ $form->addAttr("name", "settingsForm");
+ $form->addAttr("action", URLHelper::getLink("?rangeID=" .
+ $_SESSION["rangeID"] . "&openID=" . $evalID . "#open"));
+ $form->addAttr("method", "post");
+ $form->addAttr("style", "display:inline;");
+ $form->addHTMLContent(CSRFProtection::tokenTag());
+
+ $input = new HTMLEmpty("input");
+ $input->addAttr("type", "hidden");
+ $input->addAttr("name", "evalID");
+ $input->addAttr("value", $evalID);
+
+ $form->addContent($input);
+
+ $a = new HTMLEmpty("a");
+ $a->addAttr("name", "open");
+
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("width", "100%");
+
+ $tr = new HTML("tr");
+ $tr->addAttr("align", "center");
+
+ $td = new HTML("td");
+ $td->addAttr("class", $style);
+
+
+ $table2 = new HTML("table");
+ $table2->addAttr("align", "center");
+ $table2->addAttr("cellspacing", "0");
+ $table2->addAttr("cellpadding", "3");
+ $table2->addAttr("width", "90%");
+
+ $tr2 = new HTML("tr");
+ $td2 = new HTML("td");
+ $td2->addAttr("colspan", "2");
+#$td2->addAttr ("style", "padding-bottom:0; border-top:1px solid black;");
+ $td2->addAttr("align", "center");
+ $td2->addAttr("class", ($number % 2 ? "table_row_odd" : "table_row_even"));
+
+ $td2->addHTMLContent($safeguard);
+
+ $globalperm = EvaluationObjectDB::getGlobalPerm();
+
+ $no_permission = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
+
+ if (($globalperm == "root" || $globalperm == "admin") &&
+ !Request::get("search") && $eval->isTemplate()) {
+ // no RuntimeSettings and Save-Button for Template if there are no ranges
+ $td2->addHTMLContent($this->createDomainSettings($eval, $state, $number % 2 ? "eval_grey_border" : "eval_light_border"));
+ } elseif ($no_permission) {
+ // no RuntimeSettings if there are ranges with no permission
+ $td2->addHTMLContent($this->createDomainSettings($eval, $state, $number % 2 ? "eval_grey_border" : "eval_light_border"));
+
+ $td2->addContent(new HTMLEmpty("br"));
+
+ $saveButton = Button::create(_('Übernehmen'), 'save_button', ['title' => _('Einstellungen speichern')]);
+ $td2->addContent($saveButton);
+ } else {
+ $td2->addHTMLContent($this->createRuntimeSettings($eval, $state, $number % 2 ? "eval_grey_border" : "eval_light_border"));
+
+ $td2->addHTMLContent($this->createDomainSettings($eval, $state, $number % 2 ? "eval_grey_border" : "eval_light_border"));
+ $td2->addContent(new HTMLEmpty("br"));
+
+ $saveButton = Button::create(_('Übernehmen'), 'save_button', ['title' => _('Einstellungen speichern')]);
+
+ $td2->addContent($saveButton);
+ }
+
+ if (!$eval->isTemplate()) {
+ /* No Infotext for templates, it makes no sense */
+ $show = new EvalShow ();
+ $td2->addContent($show->createEvalMetaInfo($eval, NO, NO));
+ }
+
+ $tr2->addContent($td2);
+ $table2->addContent($tr2);
+
+ $td->addContent($table2);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+# $form->addContent ($a);
+ $form->addContent($table);
+
+ return $form;
+ }
+
+
+ /**
+ *
+ */
+ function createHeader($safeguard, $templates = NULL, $foundTable = "")
+ {
+ Helpbar::Get()->addPlainText(_('Übersicht'), _('Auf dieser Seite haben Sie eine Übersicht aller in dem ausgewählten Bereich existierenden Evaluationen sowie Ihrer eigenen Evaluationsvorlagen.'));
+ Helpbar::Get()->addPlainText(_('Ansicht'), _("Sie können eine Evaluation aufklappen und dann Bereichen zuordnen und ihre Laufzeit bestimmen."));
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "5");
+ $table->addAttr("width", "100%");
+
+ /* create new ---------------------------------------------------------- */
+ $actions = new ActionsWidget();
+ $actions->addLink(_('Neue Evaluationsvorlage'),
+ URLHelper::getURL('?rangeID=' . $_SESSION['rangeID'] . '&page=edit&newButton=1'),
+ Icon::create('add', 'clickable'));
+ Sidebar::get()->addWidget($actions);
+ /* ----------------------------------------------------- end: create new */
+
+ /* search template ----------------------------------------------------- */
+ $tr = new HTML("tr");
+ $td = new HTML("td");
+ $td->addAttr("class", "table_row_odd");
+ $td->addAttr("valign", "top");
+ $td->addContent(EvalOverview::createSearchTemplateForm());
+ $tr->addContent($td);
+ $table->addContent($tr);
+ /* --------------------------------------------------------- end: search */
+
+ /* Show found templates ------------------------------------------------ */
+ if ($foundTable) {
+ $tr = new HTML("tr");
+ $td = new HTML("td");
+ $td->addAttr("class", "table_row_odd");
+ $td->addContent($foundTable);
+ $tr->addContent($td);
+ $table->addContent($tr);
+ }
+ /* ------------------------------------------------- end: show templates */
+
+ /* Show templates ------------------------------------------------------ */
+ $tr = new HTML("tr");
+ $td = new HTML("td");
+ $td->addAttr("class", "content_body");
+ $td->addContent(" ");
+ $tr->addContent($td);
+ $table->addContent($tr);
+ $tr = new HTML("tr");
+ $td = new HTML("td");
+ $td->addAttr("valign", "top");
+ $td->addAttr("class", "table_row_even");
+ $td->addContent($templates ? $templates : " ");
+ $tr->addContent($td);
+ $table->addContent($tr);
+ /* -------------------------------------------------- end: show templates */
+
+ /* Create result ------------------------------------------------------- */
+ $tr = new HTML("tr");
+ $td = new HTML("td");
+ $td->addAttr("class", "blank");
+
+ $tr->addHTMLContent($safeguard);
+
+ $td->addContent($table);
+ $tr->addContent($td);
+ /* --------------------------------------------------------- end: result */
+
+ return $tr;
+ }
+
+ /**
+ *
+ */
+ function createShowRangeForm()
+ {
+
+ $currentRangeID = $_SESSION['rangeID'];
+
+ $form = new HTML("form");
+ $form->addAttr('class', 'default');
+ $form->addAttr("method", "post");
+ $form->addAttr("action", URLHelper::getLink());
+ $form->addHTMLContent(CSRFProtection::tokenTag());
+
+ $form->addHTMLContent('<fieldset>');
+
+ $headline = new HTML ("legend");
+ $headline->addAttr("class", "eval");
+ $headline->addContent(_("Evaluationen"));
+ $form->addContent($headline);
+
+ $select = new HTML("select");
+ $select->addAttr("name", "rangeID");
+ $select->addAttr("style", "vertical-align:middle;");
+
+ /* get allowed range id's for user */
+ $rangeIDs = $this->db->getValidRangeIDs($this->perm, $this->user, $currentRangeID);
+ /* add the currently shown range if neccessary */
+ if (is_array($rangeIDs) && !in_array($currentRangeID, array_keys($rangeIDs))) {
+ $rangeIDs[$currentRangeID] = ["name" => $this->db->getRangename($currentRangeID)];
+ }
+
+ foreach ($rangeIDs as $rangeID => $object) {
+ $option = new HTML("option");
+ if ($currentRangeID == $rangeID)
+ $option->addAttr("selected", "selected");
+
+ $option->addAttr("value", $rangeID);
+ if (empty($object["name"]))
+ $object["name"] = " ";
+ $option->addHTMLContent(htmlReady($object["name"]));
+ $select->addContent($option);
+ }
+ /* --------------------------------------------------------------------- */
+
+ $form->addHTMLContent('<label>');
+ $form->addContent(_("Evaluationen aus folgendem Bereich anzeigen"));
+ $form->addContent($select);
+ $form->addHTMLContent('</label>');
+ $form->addContent(" ");
+ $form->addContent(Button::create(_('Anzeigen'), ['title' => _('Evaluationen aus gewähltem Bereich anzeigen')]));
+ $form->addContent(new HTMLempty("br"));
+
+ /* search field for showing ranges (admin/root) */
+ if ($GLOBALS["perm"]->have_perm("admin")) {
+ $form->addHTMLContent('<label>');
+ $form->addContent(_("Nach weiteren Bereichen suchen"));
+ $input = new HTMLEmpty("input");
+ $input->addAttr("type", "text");
+ $input->addAttr("name", "search");
+ $input->addAttr("size", "30");
+ $form->addContent($input);
+ $form->addHTMLContent('</label>');
+ $form->addContent(Button::create(_('Suchen'), 'search_showrange_button', ['title' => _('Weitere Bereiche suchen')]));
+ }
+
+ $form->addHTMLContent('</fieldset>');
+
+ return $form;
+ }
+
+ /**
+ *
+ */
+ function createSearchTemplateForm()
+ {
+ $form = new HTML("form");
+ $form->addAttr('class', 'default');
+ $form->addAttr("method", "post");
+ $form->addAttr("action", URLHelper::getLink("?rangeID=" . $_SESSION["rangeID"]));
+ $form->addHTMLContent(CSRFProtection::tokenTag());
+
+ $form->addHTMLContent('<fieldset><legend>');
+ $form->addContent(_("Öffentliche Evaluationsvorlage suchen"));
+ $form->addHTMLContent('</legend>');
+
+ $form->addHTMLContent('<label>');
+ $form->addContent(_("Name der Vorlage"));
+
+ $input = new HTMLempty("input");
+ $input->addAttr("type", "text");
+ $input->addAttr("name", "templates_search");
+ $input->addAttr("value", stripslashes($GLOBALS['templates_search']));
+ $input->addAttr("style", "vertical-align:middle;");
+
+ $form->addContent($input);
+ $form->addHTMLContent('</label>');
+
+ $form->addHTMLContent('</fieldset><footer>');
+ $form->addContent(Button::create(_('Suchen'), 'search_template_button', ['title' => _('Öffentliche Vorlage suchen')]));
+ $form->addHTMLContent('</footer>');
+
+ return $form;
+ }
+
+ /**
+ * Creates a gray col with text
+ * @access public
+ * @param string $text The information
+ */
+ function createInfoCol($text)
+ {
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("width", "100%");
+
+ $tr = new HTML("tr");
+
+ $td = new HTML("td");
+ $td->addAttr("class", "content_body");
+ $td->addContent($text);
+
+ $tr->addContent($td);
+
+ $table->addContent($tr);
+ return $table;
+ }
+
+ /**
+ * Creates a row with black line above (and "open all evals" link...?)
+ * @access public
+ */
+ function createClosingRow()
+ {
+ $tr = new HTML("tr");
+ $tr->addAttr("height", "2");
+ $td = new HTML("td");
+ $td->addAttr("class", "content_body");
+ $td->addContent("");
+ $tr->addContent($td);
+
+ return $tr;
+ }
+
+ /*
+ * modifies the eval and calls createSafeguard
+ *
+ * @access private
+ * @param evalAction string comprised the action
+ */
+
+ public function callSafeguard($evalAction, $evalID = "", $showrangeID = NULL, $search = NULL, $referer = NULL)
+ {
+ if (!($evalAction || $evalAction == "search")) {
+ return " ";
+ }
+
+ if (!($GLOBALS['perm']->have_studip_perm("tutor", $showrangeID)) && $GLOBALS['user']->id != $showrangeID &&
+ !(Deputy::isEditActivated()() && Deputy::isDeputy($GLOBALS['user']->id, $showrangeID, true))) {
+ return $this->createSafeguard("ausruf", sprintf(_("Sie haben keinen Zugriff auf diesen Bereich.")));
+ }
+
+ $evalDB = new EvaluationDB;
+ $evalChanged = NULL;
+ $safeguard = " ";
+
+ /* Actions without any permissions ---------------------------------- */
+ switch ($evalAction) {
+ case "search_template":
+ $search = trim($search);
+ $templates = $evalDB->getPublicTemplateIDs($search);
+ if (mb_strlen($search) < EVAL_MIN_SEARCHLEN) {
+ return MessageBox::error(sprintf(_("Bitte einen Suchbegriff mit mindestens %d Buchstaben eingeben."), EVAL_MIN_SEARCHLEN));
+ } elseif (count($templates) == 0) {
+ return MessageBox::error(_("Es wurden keine passenden öffentlichen Evaluationsvorlagen gefunden."));
+ } else {
+ return MessageBox::error(sprintf(_("Es wurde(n) %d passende öffentliche Evaluationsvorlagen gefunden."), count($templates)));
+ }
+ case "export_request":
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
+ $haveNoPerm = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
+ if ($haveNoPerm == YES) {
+ return MessageBox::error(_("Sie haben nicht die Berechtigung diese Evaluation zu exportieren."));
+ }
+ /* -------------------------------------- end: check permissions */
+
+
+ /* Export evaluation ------------------------------------------- */
+ $exportManager = new EvaluationExportManagerCSV($evalID);
+ $exportManager->export();
+ /* -------------------------------------- end: export evaluation */
+
+
+ /* Create report ----------------------------------------------- */
+ if ($exportManager->isError()) {
+ return MessageBox::error(_("Fehler beim Exportieren"));
+ } else {
+ return MessageBox::success(
+ _("Die Daten wurden erfolgreich exportiert. Sie können die Ausgabedatei jetzt herunterladen."),
+ [
+ sprintf(_("Bitte klicken Sie %s um die Datei herunter zu laden.") . "<br><br>", '<a href="' . FileManager::getDownloadLinkForTemporaryFile($exportManager->getTempFilename(), $exportManager->getFilename()) . '">' . _("auf diese Verknüpfung") . '</a>')
+ ]
+ );
+ }
+ }
+ /* ----------------------------------- end: actions without permissions */
+
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
+ $evalName = htmlready($eval->getTitle());
+
+ /* Check for errors while loading ------------------------------------- */
+ if ($eval->isError()) {
+ EvalCommon::createErrorReport($eval);
+ return $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ }
+ /* -------------------------------------- end: errorcheck while loading */
+
+ /* Check for permissions in all ranges of the evaluation -------------- */
+ if (!$eval->isTemplate() && ($GLOBALS['user']->id != $eval->getAuthorID())) {
+
+ $no_permisson = (int)EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
+ $no_permission_msg = '';
+ if ($no_permisson > 0) {
+ if ($no_permisson === 1) {
+ $no_permission_msg .= sprintf(_("Die Evaluation %s ist einem Bereich zugeordnet, für den Sie keine Veränderungsrechte besitzen."), $evalName);
+ } else {
+ $no_permission_msg .= sprintf(_("Die Evaluation %s ist %s Bereichen zugeordnet, für die Sie keine Veränderungsrechte besitzen."), $evalName, $no_permisson);
+ }
+
+ if ($evalAction != "save") {
+ $no_permission_msg .= " " . _("Der Besitzer wurde durch eine systeminterne Nachricht informiert.");
+ $author = User::find($eval->getAuthorID());
+ $sms = new messaging();
+ $sms->insert_message(
+ sprintf(_("Benutzer **%s** hat versucht eine unzulässige Änderung an Ihrer Evaluation **%s** vorzunehmen."),
+ $GLOBALS['user']->username,
+ $eval->getTitle()
+ ),
+ $author->username,
+ "____%system%____",
+ false,
+ false,
+ "1",
+ false,
+ _("Versuchte Änderung an Ihrer Evaluation")
+ );
+ }
+ }
+ } else if ($eval->isTemplate() &&
+ $GLOBALS['user']->id != $eval->getAuthorID() &&
+ $evalAction != "copy_public_template" &&
+ $evalAction != "search_showrange") {
+ $author = User::find($eval->getAuthorID());
+ $sms = new messaging();
+ $sms->insert_message(
+ sprintf(
+ _("Benutzer **%s** hat versucht eine unzulässige Änderung an Ihrem Template **%s** vorzunehmen."),
+ $GLOBALS['user']->username,
+ $eval->getTitle()
+ ), $author->username,
+ "____%system%____",
+ false,
+ false,
+ "1",
+ false,
+ _("Versuchte Änderung an Ihrem Template")
+ );
+ return MessageBox::error(sprintf(_("Sie besitzen keine Rechte für das Tempate <b>%s</b>. Der Besitzer wurde durch eine systeminterne Nachricht informiert."), $evalName));
+ }
+ /* ----------------------------------------- end: check for permissions */
+ switch ($evalAction) {
+ case "share_template":
+ if ($eval->isShared()) {
+ $eval->setShared(NO);
+ $eval->save();
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage %s kann jetzt nicht mehr von anderen Benutzern gefunden werden."), $evalName));
+ } else {
+ $eval->setShared(YES);
+ $eval->save();
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage %s kann jetzt von anderen Benutzern gefunden werden."), $evalName));
+ }
+ break;
+
+ case "copy_public_template":
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
+ $newEval = $eval->duplicate();
+ $newEval->setAuthorID($GLOBALS['user']->id);
+ $newEval->setShared(NO);
+ $newEval->setStartdate(NULL);
+ $newEval->setStopdate(NULL);
+ $newEval->setTimespan(NULL);
+ $newEval->removeRangeIDs();
+ $newEval->save();
+ if ($newEval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval));
+ return $safeguard;
+ }
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die öffentliche Evaluationsvorlage <b>%s</b> wurde zu den eigenen Evaluationsvorlagen kopiert."), $evalName));
+ break;
+
+ case "start":
+
+ if ($no_permission_msg)
+ return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gestartet."));
+
+ $eval->setStartdate(time() - 500);
+ $eval->save();
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde gestartet."), $evalName));
+ $evalChanged = YES;
+ break;
+
+ case "stop":
+ if ($no_permission_msg)
+ return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht beendet."));
+
+ $eval->setStopdate(time());
+ $eval->save();
+ if ($eval->isError()) {
+ EvalCommon::createErrorReport($eval);
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde beendet."), $evalName));
+ $evalChanged = YES;
+ break;
+
+ case "continue":
+
+ if ($no_permission_msg)
+ return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht fortgesetzt."));
+
+ $eval->setStopdate(NULL);
+ $eval->setStartdate(time() - 500);
+ $eval->save();
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde fortgesetzt."), $evalName));
+ $evalChanged = YES;
+ break;
+
+ case "restart_request":
+
+ if ($no_permission_msg)
+ return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht zurücksetzen."));
+
+ $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Die Evaluation %s wirklich zurücksetzen? Dabei werden alle bisher abgegebenen Antworten gelöscht!"), $evalName), "restart_request", $evalID, $showrangeID, $referer);
+ break;
+
+ case "restart_confirmed":
+
+ if ($no_permission_msg)
+ return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht zurücksetzen."));
+
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
+ $eval->resetAnswers();
+
+ $evalDB->removeUser($eval->getObjectID());
+ $eval->setStartdate(NULL);
+ $eval->setStopdate(NULL);
+ $eval->save();
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde zurückgesetzt."), $evalName));
+ $evalChanged = YES;
+ break;
+
+ case "restart_aborted":
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde nicht zurückgesetzt."), $evalName), "", "", "", $referer);
+ break;
+
+ case "copy_own_template":
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
+ $newEval = $eval->duplicate();
+ $newEval->setShared(NO);
+ $newEval->save();
+ if ($newEval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval));
+ return $safeguard;
+ }
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluationsvorlage %s wurde kopiert."), $evalName));
+ break;
+
+ case "delete_request":
+
+ if ($no_permission_msg) {
+ return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gelöscht."));
+ }
+
+ $text = $eval->isTemplate() ? sprintf(_("Die Evaluationsvorlage %s wirklich löschen?"), $evalName) : sprintf(_("Die Evaluation %s wirklich löschen?"), $evalName);
+ $safeguard .= $this->createSafeguard("ausruf", $text, "delete_request", $evalID, $showrangeID, $referer);
+ break;
+
+ case "delete_confirmed":
+
+ if ($no_permission_msg)
+ return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht gelöscht."));
+
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
+ $eval->delete();
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+
+ $text = $eval->isTemplate() ? _("Die Evaluationsvorlage %s wurde gelöscht.") : _("Die Evaluation %s wurde gelöscht.");
+ $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer);
+ $evalChanged = YES;
+ break;
+
+ case "delete_aborted":
+ $text = $eval->isTemplate() ? _("Die Evaluationsvorlage %s wurde nicht gelöscht.") : _("Die Evaluation %s wurde nicht gelöscht.");
+ $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer);
+ break;
+
+ case "unlink_delete_aborted":
+ $text = _("Die Evaluation %s wurde nicht verändert.");
+ $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer);
+ break;
+
+ case "unlink_and_move":
+
+ if ($no_permission_msg)
+ return $this->createSafeguard("ausruf", $no_permission_msg . "<br>" . _("Die Evaluation wurde nicht ausgehängt und zu den eigenen Evaluationsvorlagen verschoben."));
+
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
+ $eval->removeRangeIDs();
+ $eval->setAuthorID($GLOBALS['user']->id);
+ $eval->resetAnswers();
+ $evalDB->removeUser($eval->getObjectID());
+ $eval->setStartdate(NULL);
+ $eval->setStopdate(NULL);
+ $eval->save();
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+ $text = _("Die Evaluation %s wurde aus allen Bereichen ausgehängt und zu den eigenen Evaluationsvorlagen verschoben.");
+ $safeguard .= $this->createSafeguard("ok", sprintf($text, $evalName), "", "", "", $referer);
+ break;
+
+ case "created":
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Die Evaluation %s wurde angelegt."), $evalName));
+ break;
+
+
+ case "save2":
+ case "save":
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
+ $update_message = sprintf(_("Die Evaluation %s wurde mit den Veränderungen gespeichert."), $evalName);
+ /* Timesettings ---------------------------------------------------- */
+ if (Request::option("startMode")) {
+ switch (Request::option("startMode")) {
+ case "manual":
+ $startDate = NULL;
+ break;
+ case "timeBased":
+ $startDate = EvalCommon::date2timestamp(Request::int("startDay"), Request::int("startMonth"), Request::int("startYear"), Request::int("startHour"), Request::int("startMinute"));
+ break;
+ case "immediate":
+ $startDate = time() - 1;
+ break;
+ }
+ if ($no_permission_msg && ($eval->getStartdate != $startDate)) {
+ $time_msg = $no_permission_msg . "<br>" . _("Die Einstellungen zur Startzeit wurden nicht verändert.");
+ }
+ }
+
+ if (Request::option("stopMode")) {
+ switch (Request::option("stopMode")) {
+ case "manual":
+ $stopDate = NULL;
+ $timeSpan = NULL;
+ break;
+ case "timeBased":
+ $stopDate = EvalCommon::date2timestamp(Request::int("stopDay"), Request::int("stopMonth"), Request::int("stopYear"), Request::int("stopHour"), Request::int("stopMinute"));
+ $timeSpan = NULL;
+ break;
+ case "timeSpanBased":
+ $stopDate = NULL;
+ $timeSpan = Request::get("timeSpan");
+ break;
+ }
+
+ if ($no_permission_msg &&
+ ($eval->getStopdate != $stopDate &&
+ $eval->getTimespan != $timeSpan)) {
+ $time_msg = ($time_msg) ? $time_msg . "<br>" : $no_permission_msg;
+ $time_msg .= _("Die Einstellungen zur Endzeit wurden nicht verändert.");
+ }
+ }
+ /* ----------------------------------------------- end: timesettings */
+
+
+ /* link eval to ranges --------------------------------------------- */
+ $link_range_Array = Request::optionArray("link_range");
+ if ($link_range_Array) {
+ $isTemplate = $eval->isTemplate();
+ if ($isTemplate) {
+ $newEval = $eval->duplicate();
+ if ($newEval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($newEval));
+ return $safeguard;
+ }
+ $update_message = sprintf(_("Die Evaluationsvorlage %s wurde als Evaluation angelegt."), $evalName);
+ $newEval->setStartdate($startDate);
+ $newEval->setStopdate($stopDate);
+ $newEval->setTimespan($timeSpan);
+ $newEval->setShared(NO);
+ } else {
+ $newEval = &$eval;
+ }
+
+ $counter_linked = 0;
+ foreach ($link_range_Array as $link_rangeID => $v) {
+ if ($userid = get_userid($link_rangeID))
+ $link_rangeID = $userid;
+ $newEval->addRangeID($link_rangeID);
+ $counter_linked++;
+ }
+
+ if ($isTemplate)
+ $newEval->save();
+
+ if ($newEval->isError()) {
+ $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Einhängen von Bereichen.") . EvalCommon::createErrorReport($newEval));
+ return $safeguard;
+ }
+
+ $message .= $message ? "<br>" : " ";
+ $message .= ($counter_linked > 1) ? sprintf(_("Die Evaluation wurde in %s Bereiche eingehängt."), $counter_linked) : sprintf(_("Die Evaluation wurde in einen Bereich eingehängt."), $counter_linked);
+ }
+ /* ---------------------------------------- end: link eval to ranges */
+
+
+ /* copy eval to ranges --------------------------------------------- */
+ $copy_range_Array = Request::optionArray("copy_range");
+ if (!empty($copy_range_Array)) {
+ $counter_copy = 0;
+ foreach ($copy_range_Array as $copy_rangeID => $v) {
+ if ($userid = get_userid($copy_rangeID))
+ $copy_rangeID = $userid;
+ $newEval = $eval->duplicate();
+ if (Request::option("startMode"))
+ $newEval->setStartdate($startDate);
+ if (Request::get("stopMode")) {
+ $newEval->setStopdate($stopDate);
+ $newEval->setTimespan($timeSpan);
+ }
+ $newEval->setShared(NO);
+ $newEval->removeRangeIDs();
+ $evalDB->removeUser($newEval->getObjectID());
+ $newEval->addRangeID($copy_rangeID);
+ $newEval->save();
+ $counter_copy++;
+
+ if ($newEval->isError()) {
+ $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Kopieren von Evaluationen in Bereiche.") . EvalCommon::createErrorReport($newEval));
+ return $safeguard;
+ }
+ }
+
+ $message .= $message ? "<br>" : " ";
+ $message .= ($counter_copy > 1) ? sprintf(_("Die Evaluation wurde in %s Bereiche kopiert."), $counter_copy) : sprintf(_("Die Evaluation wurde in einen Bereich kopiert."), $counter_copy);
+ }
+ /* ------------------------------------------- end: copy eval to ranges */
+
+ /* unlink ranges ------------------------------------------------------- */
+ $remove_range_Array = Request::optionArray("remove_range");
+ if (!empty($remove_range_Array)) {
+
+ /* if all rangeIDs will be removed, so ask if it should be deleted -- */
+ if (is_array($remove_range_Array) && count($remove_range_Array) == $eval->getNumberRanges()) {
+ $text = _("Sie wollen die Evaluation <b>%s</b> aus allen ihr zugeordneten Bereichen aushängen.<br>Soll die Evaluation gelöscht oder zu Ihren eigenen Evaluationsvorlagen verschoben werden?");
+ $safeguard .= $this->createSafeguard("ausruf", sprintf($text, $evalName), "unlink_delete_request", $evalID, $showrangeID, $referer);
+ $update_message = NULL;
+ return $safeguard;
+ }
+ /* -------------------------------- end: ask if it should be deleted */
+ $no_permission_ranges = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval, YES);
+ $counter_no_permisson = 0;
+ if (is_array($no_permission_ranges)) {
+ foreach ($remove_range_Array as $remove_rangeID => $v) {
+
+ if ($userid = get_userid($remove_rangeID))
+ $remove_rangeID = $userid;
+
+ // no permisson to unlink this range
+ if (in_array($remove_rangeID, $no_permission_ranges))
+ $counter_no_permisson++;
+ }
+ }
+
+ // if there are no_permisson_ranges to unlink, return
+ if ($counter_no_permisson > 0) {
+
+ if ($counter_no_permisson == 1)
+ $safeguard .= $this->createSafeguard("ausruf", _("Sie wollen die Evaluation aus einem Bereich aushängen, für den Sie keine Berechtigung besitzten.<br> Die Aktion wurde nicht ausgeführt."));
+ else
+ $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Sie wollen die Evaluation aus %d Bereichen aushängen, für die Sie keine Berechtigung besitzten.<br> Die Aktion wurde nicht ausgeführt."), $counter_no_permisson));
+ return $safeguard;
+ }
+
+ reset($remove_range_Array);
+ $counter_copy = 0;
+ foreach ($remove_range_Array as $remove_rangeID => $v) {
+
+ if ($userid = get_userid($remove_rangeID))
+ $remove_rangeID = $userid;
+
+ // the current range will be removed
+ if ($showrangeID == $remove_rangeID)
+ $current_range_removed = 1;
+
+ $eval->removeRangeID($remove_rangeID);
+ $counter_copy++;
+ }
+
+
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Aushängen von Bereichen.") . EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+
+ $message .= $message ? "<br>" : " ";
+ $message .= ($counter_copy > 1) ? sprintf(_("Die Evaluation wurde aus %s Bereichen ausgehängt."), $counter_copy) : sprintf(_("Die Evaluation wurde aus einem Bereich ausgehängt."), $counter_copy);
+
+ if ($eval->getNumberRanges() == 0) {
+ $message .= $message ? "<br>" : "";
+ $message .= _("Sie ist nun keinem Bereich mehr zugeordnet und wurde zu den eigenen Evaluationsvorlagen verschoben.");
+ $eval->setStartdate(NULL);
+ $eval->setStopdate(NULL);
+ $evalDB->removeUser($eval->getObjectID());
+
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("ausruf", _("Fehler beim Kopieren von Evaluationen in Bereiche.") . EvalCommon::createErrorReport($newEval));
+ return $safeguard;
+ }
+ } else {
+
+ $no_permission_ranges = EvaluationObjectDB::getEvalUserRangesWithNoPermission($eval);
+ $number_of_ranges = $eval->getNumberRanges();
+
+ if ($number_of_ranges == $no_permission_ranges) {
+ $return["msg"] = $this->createSafeguard("ausruf", $message . "<br>" . sprintf(_("Sie haben die Evaluation <b>%s</b> aus allen ihren Bereichen ausgehängt."), $evalName));
+ $return["option"] = DISCARD_OPENID;
+ $eval->save();
+ if ($eval->isError()) {
+ $safeguard = $this->createSafeguard("ausruf", _("Fehler beim Aushängen einer Evaluationen aus allen Bereichen auf die Sie Zugriff haben.") . EvalCommon::createErrorReport($newEval));
+ return $safeguard;
+ }
+ return $return;
+ }
+ }
+ }
+
+ if ($eval->isTemplate()) {
+ if (empty($link_range) && empty($copy_range) && empty($remove_range)) {
+ $update_message = sprintf(_("Es wurden keine Veränderungen an der Evaluationsvorlage <b>%s</b> gespeichert."), $evalName);
+ }
+ } else {
+ // nothing changed
+ if (!Request::option('startMode') && !Request::option('stopMode') &&
+ empty($link_range) && empty($copy_range) && empty($remove_range))
+ $update_message = _("Es wurden keine Veränderungen gespeichert.");
+
+ // set new start date
+ if (Request::option("startMode") && !$time_msg) {
+ $eval->setStartDate($startDate);
+
+ if ($startDate != NULL && $startDate <= time() - 1) {
+ $message .= $message ? "<br>" : " ";
+ $message .= _("Die Evaluation wurde gestartet.");
+ }
+ }
+
+ // set new stop date
+ if (Request::get("stopMode") && !$time_msg) {
+ $eval->setStopDate($stopDate);
+ $eval->setTimeSpan($timeSpan);
+
+ if (($stopDate != NULL && $stopDate <= time() - 1) ||
+ ($timeSpan != NULL && $eval->getStartdate() != NULL && $eval->getStartdate() + $timeSpan <= time() - 1)) {
+ $message .= $message ? "<br>" : " ";
+ $message .= _("Die Evaluation wurde beendet.");
+ }
+ }
+
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+
+ $eval->save();
+ }
+
+ $evalChanged = YES;
+
+ // start/endtime aren't saved, because of ranges with no permisson
+ if ($time_msg)
+ $safeguard .= $this->createSafeguard(
+ "ausruf", $time_msg);
+
+ // everything is just fine so print the all messages
+ if ($update_message && !$time_msg)
+ $safeguard .= $this->createSafeguard(
+ "ok", $update_message . "<br>" . $message);
+ // messages from un/linking an making copys
+ elseif ($time_msg && $message)
+ $safeguard .= $this->createSafeguard(
+ "ok", $message);
+
+ break;
+
+ case "search_showrange":
+ case "search_range":
+ $search = Request::get("search");
+
+ if (EvaluationObjectDB::getGlobalPerm(YES) < 31) {
+ $safeguard = $this->createSafeguard("ausruf", _("Sie besitzen keine Berechtigung eine Suche durchzuführen."));
+ return $safeguard;
+ }
+
+ $results = $evalDB->search_range($search);
+ if (empty($search))
+ $safeguard .= $this->createSafeguard("ausruf", _("Bitte einen Suchbegriff eingeben."), $search);
+ elseif (empty($results))
+ $safeguard .= $this->createSafeguard("ausruf", sprintf(_("Es wurde kein Bereich gefunden, der den Suchbegriff <b>%s</b> enthält."), htmlReady($search)), $search);
+ else
+ $safeguard .= $this->createSafeguard("ok", sprintf(_("Es wurden %s Bereiche gefunden, die den Suchbegriff <b>%s</b> enthalten."), count($results), htmlReady($search)), $search);
+ break;
+
+ case "check_abort_creation":
+
+ # check if the evaluation is new and not yet edited
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
+ $abort_creation = false;
+ if ($eval->getTitle() == _("Neue Evaluation") &&
+ $eval->getText() == "") {
+ # the evaluationen may be not edited yet ... so continue checking
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
+ $number_of_childs = $eval->getNumberChildren();
+ $child = $eval->getNextChild();
+ if ($number_of_childs == 1 &&
+ $child &&
+ $child->getTitle() == _("Erster Gruppierungsblock") &&
+ $child->getChildren() == NULL &&
+ $child->getText() == "") {
+ $abort_creation = true;
+ }
+ }
+
+ if ($abort_creation != true)
+ break;
+ # continue abort_creation
+
+ case "abort_creation":
+ $eval = new Evaluation($evalID, NULL, EVAL_LOAD_ALL_CHILDREN);
+ $eval->delete();
+ // error_ausgabe
+ if ($eval->isError()) {
+ $safeguard .= $this->createSafeguard("", EvalCommon::createErrorReport($eval));
+ return $safeguard;
+ }
+
+ $safeguard .= $this->createSafeguard("ok", _("Die Erstellung einer Evaluation wurde abgebrochen."), "", "", "", $referer);
+ break;
+
+ case "nothing":
+ break;
+
+ default:
+ $safeguard .= $this->createSafeguard("ausruf", _("Fehler! Es wurde versucht, eine nicht vorhandene Aktion auszuführen."));
+ break;
+ }
+
+ /* Send SMS when eval has been modified by admin/root ----------------- */
+ if (($evalChanged) && ($eval->getAuthorID() != $GLOBALS['user']->id)) {
+ $sms = new messaging();
+ $sms->insert_message(sprintf(_("An Ihrer Evaluation \"%s\" wurden von %s Änderungen vorgenommen."), $eval->getTitle(), $GLOBALS['user']->username), get_username($eval->getAuthorID()), "____%system%____", FALSE, FALSE, "1");
+ }
+ /* ------------------------------------------------------ end: send SMS */
+
+ // the current range has been removed from the eval
+ if ($current_range_removed) {
+ $return["msg"] = $safeguard;
+ $return["option"] = DISCARD_OPENID;
+ return $return;
+ } else {
+ return $safeguard;
+ }
+ }
+
+// callSafeguard
+
+ /**
+ * creates the 'Safeguard'
+ *
+ * @access private
+ * @param sign string Sign to draw (must be "ok" or "ausruf")
+ * @param text string The Text to draw
+ * @param evalID string needed if you want to delete an evaluation (not needed)
+ */
+ public function createSafeguard($sign, $text, $mode = NULL, $evalID = NULL, $showrangeID = NULL, $referer = NULL)
+ {
+ //TODO: auf messagebox bzw. createQuestion umstellen!!!
+
+ if (mb_stripos($mode, 'request') === false && $sign != '') {
+ if($sign === 'ok') {
+ return MessageBox::success($text);
+ } else {
+ return MessageBox::error($text);
+ }
+ }
+ $label = [
+ "referer" => _("Zum vorherigen Bereich zurückkehren."),
+ "yes" => _("Ja!"),
+ "no" => _("Nein!"),
+ "delete" => _("Löschen."),
+ "template" => _("Zu den eigenen Evaluationsvorlagen verschieben."),
+ "cancel" => _("Abbrechen")
+ ];
+
+ if ($referer) {
+ $linkreferer = "&referer=" . $referer;
+ }
+
+ if ($mode == "delete_request") {
+ $value1 = "delete_confirmed";
+ $value2 = "delete_aborted";
+ $request = YES;
+ }
+ if ($mode == "restart_request") {
+ $value1 = "restart_confirmed";
+ $value2 = "restart_aborted";
+ $request = YES;
+ }
+
+ if ($referer) {
+ URLHelper::bindLinkParam('referer', $referer);
+ }
+
+ if ($request) {
+ return QuestionBox::create(
+ $text,
+ URLHelper::getURL('admin_evaluation.php?evalAction=' . $value1 . '&evalID=' . $evalID . '&rangeID=' . $showrangeID),
+ URLHelper::getURL('admin_evaluation.php?evalAction=' . $value2 . '&evalID=' . $evalID . '&rangeID=' . $showrangeID)
+ );
+ }
+
+ if ($mode == "unlink_delete_request") {
+ $add_cancel = !$referer ?: "&referer=" . $referer;
+ $links = [
+ URLHelper::getURL('admin_evaluation.php?evalAction=delete_confirmed&evalID=' . $evalID . '&rangeID=' . $showrangeID),
+ URLHelper::getURL('admin_evaluation.php?evalAction=unlink_delete_aborted&evalID=' . $evalID . '&rangeID=' . $showrangeID),
+ URLHelper::getURL('admin_evaluation.php?evalAction=unlink_and_move&evalID=' . $evalID . '&rangeID=' . $showrangeID . $add_cancel)
+ ];
+ $details[] = LinkButton::create(_('Löschen'), $links[0], ['title' => $label["delete"]]);
+ $details[] = LinkButton::create(_('Verschieben'), $links[1], ['title' => $label["template"]]);
+ $details[] = LinkButton::createCancel(_('Abbrechen'), $links[2], ['title' => $label["cancel"]]);
+
+ return MessageBox::info($text, $details);
+ }
+
+ if ($referer) {
+ return LinkButton::create($label["referer"], URLHelper::getLink($referer));
+ }
+ }
+
+ /**
+ * prints the tables for the runtime settings (start date, stop date...)
+ *
+ * @access private
+ * @param $eval the eval object
+ * @param $state the eval's state (EVAL_STATE_NEW, EVAL_STATE_ACTIVE, ...)
+ * @param $style the background style
+ * @return string the runtime settings (html)
+ */
+ function createRuntimeSettings($eval, $state, $style)
+ {
+ $html = "";
+ $startDate = $eval->getStartdate();
+ $stopDate = $eval->getStopdate();
+ $timeSpan = $eval->getTimespan();
+
+ if ($startDate == NULL)
+ $startMode = "manual";
+ else
+ $startMode = "timeBased";
+
+ if ($stopDate == NULL)
+ $stopMode = "manual";
+ else
+ $stopMode = "timeBased";
+
+ if ($timeSpan != NULL)
+ $stopMode = "timeSpanBased";
+
+ if (!$startDate || $startDate == -1)
+ $startDate = time();
+
+ $startDay = date("d", $startDate);
+ $startMonth = date("m", $startDate);
+ $startYear = date("Y", $startDate);
+ $startHour = date("H", $startDate);
+ $startMinute = date("i", $startDate);
+
+ if (!$stopDate || $stopDate == -1)
+ $stopDate = mktime(0, 0, 0, date("m") + 1, date("d"), date("Y"));
+
+ $stopDay = date("d", $stopDate);
+ $stopMonth = date("m", $stopDate);
+ $stopYear = date("Y", $stopDate);
+ $stopHour = date("H", $stopDate);
+ $stopMinute = date("i", $stopDate);
+
+ if (!$timeSpan)
+ $timeSpan = 1209600; // default: 2 weeks
+
+ $html .= "<table border=0 align=center cellspacing=0 cellpadding=4 width=\"100%\">\n";
+ $html .= "<tr><td colspan=\"2\">\n";
+ $html .= "<b>" . _("Einstellungen zur Start- und Endzeit:") . "</b>";
+ $tooltip = $eval->isTemplate()
+ ? _('Legen Sie fest, von wann bis wann alle eingehängten und kopierten Instanzen dieser Evaluationsvorlage in Stud.IP öffentlich sichtbar sein sollen.')
+ : _('Legen Sie fest, von wann bis wann die Evaluation in Stud.IP öffentlich sichtbar sein soll.');
+ $html .= " ";
+ $html .= Icon::create('info-circle', 'inactive', ['title' => $tooltip])->asImg(['class' => 'middle']);
+ $html .= "</td></tr>";
+ $html .= "<tr>";
+
+ /* START TIME settings ------------------------------------------------- */
+ $html .= "<td width=\"50%\" valign=\"top\">"
+ . "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0>\n"
+ . "<tr>"
+ . "<td class=\"$style\" height=\"22\" align=\"left\" "
+ . "style=\"vertical-align:bottom;\">"
+ . "<b>"
+ . "&nbsp;"
+ . _("Anfang")
+ . "</b>"
+ . "</td>"
+ . "</tr>\n";
+
+ /* Eval has NOT started yet --- */
+ if ($state == EVAL_STATE_NEW || $eval->isTemplate()) {
+ $html .= "<tr><td class=\"table_row_even\">";
+ $html .= "<input type=radio name=\"startMode\" value=\"manual\" " . ($startMode == "manual" ? "checked" : "") . ">&nbsp;";
+ $html .= _("später manuell starten");
+ $html .= "</td></tr>";
+
+ $html .= "<tr><td class=table_row_odd>";
+ $html .= "<input type=radio name=\"startMode\" value=\"timeBased\" " . ($startMode == "timeBased" ? "checked" : "") . ">&nbsp;";
+ $html .= _("Startzeitpunkt:");
+ $html .= "&nbsp;&nbsp;<input type=text name=\"startDay\" size=3 maxlength=2 value=\"" . $startDay . "\">&nbsp;.&nbsp;"
+ . "<input type=text name=\"startMonth\" size=3 maxlength=2 value=\"" . $startMonth . "\">&nbsp;.&nbsp;"
+ . "<input type=text name=\"startYear\" size=5 maxlength=4 value=\"" . $startYear . "\">&nbsp;"
+ . sprintf(_("um %s Uhr"), "&nbsp;<input type=text name=\"startHour\" size=3 maxlength=2 value=\"" . $startHour . "\">&nbsp;:" .
+ "&nbsp;<input type=text name=\"startMinute\" size=3 maxlength=2 value=\"" . $startMinute . "\">&nbsp;");
+ $html .= "</td></tr>";
+
+ $html .= "<tr><td class=table_row_even valign=middle>";
+ $html .= "<input type=radio name=\"startMode\" value=\"immediate\">&nbsp;";
+ $html .= _("sofort");
+ $html .= "</td></tr>";
+ } /* Eval is already running or finished --- */ else {
+ $html .= "<tr><td><font size=\"+2\">&nbsp;</font></td></tr>";
+ $html .= "<tr><td valign=\"middle\" align=\"center\">";
+ $html .= sprintf(_("Startzeitpunkt war der <b>%s</b> um <b>%s</b> Uhr."), date("d.m.Y", $startDate), date("H:i", $startDate));
+ $html .= "</td></tr>";
+ $html .= "<tr><td><font size=\"+2\">&nbsp;</font></td></tr>";
+ }
+ $html .= "</table></td>";
+
+
+ /* END TIME settings --------------------------------------------------- */
+ $html .= "<td width=\"50%\" valign=\"top\">"
+ . "<table width=\"100%\" cellpadding=0 cellspacing=0 border=0>\n"
+ . "<tr>"
+ . "<td class=\"$style\" height=\"22\" align=\"left\" "
+ . "style=\"vertical-align:bottom;\">"
+ . "<b>"
+ . "&nbsp;"
+ . _("Ende")
+ . "</b>"
+ . "</td>"
+ . "</tr>\n";
+
+ /* Eval has NOT finished yet --- */
+ if ($state != EVAL_STATE_STOPPED) {
+ $html .= "<tr><td class=table_row_even>\n"
+ . "<input type=radio name=\"stopMode\" value=\"manual\" " . ($stopMode == "manual" ? "checked" : "") . ">&nbsp;"
+ . _("manuell beenden")
+ . "</td></tr>"
+ . "<tr><td class=table_row_odd>\n"
+ . "<input type=radio name=\"stopMode\" value=\"timeBased\" " . ($stopMode == "timeBased" ? "checked" : "") . ">&nbsp;"
+ . _("Endzeitpunkt:");
+
+ $html .= "&nbsp;&nbsp;"
+ . "<input type=text name=\"stopDay\" size=3 maxlength=2 value=\"" . $stopDay . "\">&nbsp;.&nbsp;"
+ . "<input type=text name=\"stopMonth\" size=3 maxlength=2 value=\"" . $stopMonth . "\">&nbsp;.&nbsp;"
+ . "<input type=text name=\"stopYear\" size=5 maxlength=4 value=\"" . $stopYear . "\">&nbsp;"
+ . sprintf(_("um %s Uhr"), "&nbsp;<input type=text name=\"stopHour\" size=3 maxlength=2 value=\"" . $stopHour . "\">&nbsp;:" .
+ "&nbsp;<input type=text name=\"stopMinute\" size=3 maxlength=2 value=\"" . $stopMinute . "\">&nbsp;");
+ $html .= "&nbsp;"
+ . "</td></tr>"
+ . "<tr><td class=table_row_even valign=middle>"
+ . "<input type=radio name=\"stopMode\" value=\"timeSpanBased\" " . ($stopMode == "timeSpanBased" ? "checked" : "")
+ . ">&nbsp;"
+ . _("Zeitspanne")
+ . "&nbsp;&nbsp;"
+ . "<select name=\"timeSpan\" style=\"vertical-align:middle\" size=1 "
+ . ">";
+
+ for ($i = 1; $i <= 12; $i++) {
+ $secs = $i * 604800; // == weeks * seconds per week
+
+ $html .= "\n<option value=\"" . $secs . "\" ";
+ if ($timeSpan == $secs)
+ $html .= "selected";
+ $html .= ">";
+ $html .= sprintf(
+ ngettext(
+ '%d Woche',
+ '%d Wochen',
+ $i
+ ),
+ $i
+ );
+ $html .= "</option>";
+ }
+ $html .= "</select>";
+
+ if ($stopMode == "timeSpanBased" && $startMode != "manual") {
+
+ $startDate = ($startMode == "immediate") ? time() : $startDate;
+
+ $html .= "&nbsp;";
+ $html .= Icon::create('refresh', 'clickable', ['title' => _('Endzeitpunkt neu berechnen')])->asInput(['name' => 'save2_button', 'align' => 'middle',]);
+ $html .= sprintf(_(" (<b>%s</b> um <b>%s</b> Uhr)"), strftime("%d.%m.%Y", $startDate + $timeSpan), strftime("%H:%M", $startDate + $timeSpan));
+ }
+ $html .= "</td></tr>";
+ } else {
+ $html .= "<tr><td><font size=\"+2\">&nbsp;</font></td></tr>";
+ $html .= "<tr><td valign=\"middle\" align=\"center\">";
+ $html .= sprintf(_("Endzeitpunkt war der <b>%s</b> um <b>%s</b> Uhr."), date("d.m.Y", $stopDate), date("H:i", $stopDate));
+ $html .= "</td></tr>";
+ $html .= "<tr><td><font size=\"+2\">&nbsp;</font></td></tr>";
+ }
+ $html .= "</table>";
+
+ $html .= "</td></tr>";
+ $html .= "</table>";
+
+ return $html;
+ }
+
+ /**
+ * the current eval-ranges and the options to copy and link ranges
+ *
+ * @access private
+ * @param $eval the eval object
+ * @param $state the eval's state (EVAL_STATE_NEW, EVAL_STATE_ACTIVE, ...)
+ * @param $style the background style
+ * @return string the domain settings (html)
+ */
+ public function createDomainSettings($eval, $state, $style)
+ {
+ $db = new EvaluationObjectDB ();
+ $evalDB = new EvaluationDB ();
+ $evalID = $eval->getObjectID();
+ $globalperm = $db->getGlobalPerm();
+
+ // linked ranges
+ $rangeIDs = $eval->getRangeIDs();
+
+ // search results
+ if (Request::get("search"))
+ $results = $evalDB->search_range(Request::get("search"));
+ else
+ $results = $evalDB->search_range("");
+
+ if ($globalperm == "root") {
+ $results["studip"] = ["type" => "system", "name" => _("Systemweite Evaluationen")];
+ } elseif ($globalperm == "dozent" || $globalperm == "autor" || $globalperm == "admin") {
+ $results[$GLOBALS['user']->id] = ["type" => "user", "name" => _("Profil")];
+ }
+
+ if ($globalperm == "dozent" || $globalperm == "autor" || Request::get("search"))
+ $showsearchresults = 1;
+
+
+ if ($globalperm == "autor")
+ $range_types = [
+ "user" => _("Benutzer"),
+ "sem" => _("Veranstaltung")];
+ elseif ($globalperm == "dozent")
+ $range_types = [
+ "user" => _("Benutzer"),
+ "sem" => _("Veranstaltung"),
+ "inst" => _("Einrichtung")];
+ elseif ($globalperm == "admin")
+ $range_types = [
+ "user" => _("Benutzer"),
+ "sem" => _("Veranstaltung"),
+ "inst" => _("Einrichtung"),
+ "fak" => _("Fakultät")];
+ elseif ($globalperm == "root")
+ $range_types = [
+ "user" => _("Benutzer"),
+ "sem" => _("Veranstaltung"),
+ "inst" => _("Einrichtung"),
+ "fak" => _("Fakultät"),
+ "system" => _("System")];
+
+
+ // zugewiesene Bereiche
+ $table_r = new HTML("table");
+# $table_r->addAttr ("class","white");
+ $table_r->addAttr("border", "0");
+ $table_r->addAttr("align", "center");
+ $table_r->addAttr("cellspacing", "0");
+ $table_r->addAttr("cellpadding", "0");
+ $table_r->addAttr("width", "100%");
+ $table_r->addAttr('class', 'default');
+
+ // Überschriften
+ $tr_r = new HTML("tr");
+
+ $td_r = new HTML("td");
+ $td_r->addAttr("class", "$style");
+ $td_r->addAttr("style", "vertical-align:bottom;");
+ $td_r->addAttr("height", "22");
+ $b_r = new HTML("b");
+ $b_r->addHTMLContent("&nbsp;");
+ $b_r->addContent(_("Bereich"));
+ $td_r->addContent($b_r);
+ $tr_r->addContent($td_r);
+
+ $td_r = new HTML("td");
+ $td_r->addAttr("class", "$style");
+ $td_r->addAttr("height", "22");
+ $td_r->addAttr("align", "center");
+ $td_r->addAttr("style", "vertical-align:bottom;");
+ $b_r = new HTML("b");
+ $b_r->addContent(_("aushängen"));
+ $td_r->addContent($b_r);
+ $tr_r->addContent($td_r);
+
+ $table_r->addContent($tr_r);
+
+ if ($rangeIDs) {
+
+ // die verknüpften bereiche
+ foreach ($rangeIDs as $k => $assigned_rangeID) {
+ $tr_r = new HTML("tr");
+
+ // title
+ $td_r = new HTML("td");
+ $td_r->addHTMLContent("&nbsp;");
+ $td_r->addContent($db->getRangename($assigned_rangeID, NO));
+# $td_r->addContent ($db->getRangename($assigned_rangeID));
+ $tr_r->addContent($td_r);
+
+ if (($this->perm->have_studip_perm("tutor", $assigned_rangeID)) ||
+ $assigned_rangeID == $GLOBALS['user']->id) {
+ // link
+ $td_r = new HTML("td");
+ $td_r->addAttr("align", "center");
+ $input = new HTMLempty("input");
+ $input->addAttr("type", "checkbox");
+ $input->addAttr("name", "remove_range[$assigned_rangeID]");
+ $input->addAttr("value", "1");
+ $td_r->addContent($input);
+ } else {
+ // no permission
+ $td_r = new HTML("td");
+ $td_r->addAttr("align", "center");
+ $td_r->addContent(_("Sie haben keine Berechtigung die Evaluation aus diesem Bereich auszuhängen."));
+ }
+ $tr_r->addContent($td_r);
+ $table_r->addContent($tr_r);
+ }
+ } else {
+ $td_r = new HTML("td");
+ $td_r->addAttr("class", "content_body");
+ $td_r->addAttr("width", "40");
+ $td_r->addAttr("align", "center");
+ $td_r->addAttr("style", "vertical-align:bottom;");
+ $td_r->addAttr("colspan", "2");
+ $b_r = new HTML("b");
+ $b_r->addHTMLContent("&nbsp;");
+ $b_r->addContent(_("Diese Evaluation wurde keinem Bereich zugeordnet."));
+ $td_r->addContent($b_r);
+ $tr_r->addContent($td_r);
+
+ $table_r->addContent($tr_r);
+ }
+
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "4");
+ $table->addAttr("width", "100%");
+
+ $tr = new HTML("tr");
+
+ $td = new HTML("td");
+ $td->addAttr("colspan", "2");
+ $td->addAttr("style", "padding-bottom:0; border-top:1px solid black;");
+ $b = new HTML("b");
+ $b->addContent(_("Diese Evaluation ist folgenden Bereichen zugeordnet:"));
+ $td->addContent($b);
+ $td->addContent(EvalCommon::createImage(EVAL_PIC_HELP, "", tooltip(_(" können Sie Ihre Evaluation aus den verknüpften Bereichen entfernen."), TRUE, TRUE)));
+ $tr->addContent($td);
+ if (!$eval->isTemplate())
+ $table->addContent($tr);
+
+ $tr = new HTML("tr");
+
+ $td = new HTML("td");
+ $td->addAttr("colspan", "2");
+ $td->addContent($table_r);
+ $tr->addContent($td);
+ if (!$eval->isTemplate())
+ $table->addContent($tr);
+
+ // display search_results
+ if ($results) {
+ foreach ($results as $k => $v) {
+ foreach ($range_types as $type_key => $type_value) {
+ if ($v["type"] == $type_key) {
+ $ranges["$type_key"][] = ["id" => $k, "name" => $v["name"]];
+ }
+ }
+ reset($range_types);
+ }
+
+ $table_s = new HTML("table");
+ $table_s->addAttr("border", "0");
+ $table_s->addAttr("align", "center");
+ $table_s->addAttr("cellspacing", "0");
+ $table_s->addAttr("cellpadding", "0");
+ $table_s->addAttr("width", "100%");
+
+ foreach ($range_types as $type_key => $type_value) {
+
+ // Überschriften
+ $tr_s = new HTML("tr");
+
+ // Typ
+ $td_s = new HTML("td");
+ $td_s->addAttr("colspan", "1");
+ $td_s->addAttr("class", "$style");
+ $td_s->addAttr("height", "22");
+ $td_s->addAttr("style", "vertical-align:bottom;");
+ $b_s = new HTML("b");
+ $b_s->addHTMLContent("&nbsp;");
+ $b_s->addContent($type_value . ":");
+ $td_s->addContent($b_s);
+ $tr_s->addContent($td_s);
+
+ // link
+ $td_s = new HTML("td");
+ $td_s->addAttr("class", "$style");
+ $td_s->addAttr("height", "22");
+ $td_s->addAttr("align", "center");
+ $td_s->addAttr("style", "vertical-align:bottom;");
+ $b_s = new HTML("b");
+ $b_s->addContent(_("einhängen"));
+ $td_s->addContent($b_s);
+ $tr_s->addContent($td_s);
+
+ // kopie
+ $td_s = new HTML("td");
+ $td_s->addAttr("class", "$style");
+ $td_s->addAttr("height", "22");
+ $td_s->addAttr("align", "center");
+ $td_s->addAttr("style", "vertical-align:bottom;");
+ $b_s = new HTML("b");
+ $b_s->addContent(_("kopieren"));
+ $td_s->addContent($b_s);
+ $tr_s->addContent($td_s);
+
+ $table_s->addContent($tr_s);
+
+ $counter = 0;
+
+ if ($ranges["$type_key"]) {
+ foreach ($ranges["$type_key"] as $range) {
+
+ if ($counter == 0)
+ $displayclass = "content_body";
+ elseif (($counter % 2) == 0)
+ $displayclass = "table_row_even";
+ else
+ $displayclass = "table_row_odd";
+
+ $tr_s = new HTML("tr");
+
+ // name
+ $td_s = new HTML("td");
+ $td_s->addHTMLContent("&nbsp;");
+ $td_s->addHTMLContent(htmlready($range["name"]));
+ $tr_s->addContent($td_s);
+
+ // if the rangeID is a username, convert it to the userID
+ $new_rangeID = (get_userid($range['id'])) ? get_userid($range['id']) : $range['id'];
+
+ if (!in_array($new_rangeID, $rangeIDs)) {
+
+ // link
+ $td_s = new HTML("td");
+ $td_s->addAttr("align", "center");
+ $input = new HTMLempty("input");
+ $input->addAttr("type", "checkbox");
+ $input->addAttr("name", "link_range[{$range['id']}]");
+ $input->addAttr("value", "1");
+ $td_s->addContent($input);
+ $tr_s->addContent($td_s);
+ } else {
+
+ // no link
+ $td_s = new HTML("td");
+ $td_s->addAttr("align", "center");
+ $td_s->addAttr("colspan", "1");
+ $input = new HTMLempty("input");
+ $td_s->addContent(_("Die Evaluation ist bereits diesem Bereich zugeordnet."));
+ $tr_s->addContent($td_s);
+ }
+
+ // copy
+ $td_s = new HTML("td");
+ $td_s->addAttr("align", "center");
+ $input = new HTMLempty("input");
+ $input->addAttr("type", "checkbox");
+ $input->addAttr("name", "copy_range[{$range['id']}]");
+ $input->addAttr("value", "1");
+ $td_s->addContent($input);
+ $tr_s->addContent($td_s);
+
+ $table_s->addContent($tr_s);
+ $counter++;
+ }
+ } elseif ($globalperm == "root" || $globalperm == "admin") {
+ $tr_s = new HTML("tr");
+ $td_s = new HTML("td");
+ $td_s->addAttr("class", "content_body");
+ $td_s->addAttr("colspan", "4");
+ $td_s->addHTMLContent("&nbsp;");
+ $td_s->addContent(_("Es wurden keine Ergebnisse aus diesem Bereich gefunden."));
+ $tr_s->addContent($td_s);
+ $table_s->addContent($tr_s);
+ }
+ reset($ranges);
+ }
+ }
+ if ($showsearchresults) {
+ $tr = new HTML("tr");
+ $td = new HTML("td");
+ $td->addAttr("colspan", "2");
+// $td->addContent(new HTMLempty("hr"));
+ $b = new HTML("b");
+# $b->addContent (_('Suchergebnisse') . ':');
+ if (Request::get("search"))
+ $b->addContent(_("Sie können die Evaluation folgenden Bereichen zuordnen (Suchergebnisse):"));
+ else
+ $b->addContent(_("Sie können die Evaluation folgenden Bereichen zuordnen:"));
+ $td->addContent($b);
+ $td->addContent(EvalCommon::createImage(EVAL_PIC_HELP, "", tooltip(_("Hängen Sie die Evaluation in die gewünschten Bereiche ein (abhängige Kopie mit gemeinsamer Auswertung) oder kopieren Sie sie in Bereiche (unabhängige Kopie mit getrennter Auswertung)."), TRUE, TRUE)));
+ $td->addContent(($results) ? $table_s : _("Die Suche ergab keine Treffer."));
+ $tr->addContent($td);
+ $table->addContent($tr);
+ }
+
+ // the seach-button
+ if ($globalperm == "root" || $globalperm == "admin") {
+ $tr = new HTML("tr");
+
+ $td = new HTML("td");
+ $td->addAttr("colspan", "2");
+ $td->addAttr("style", "padding-bottom:0; border-top:1px solid black;");
+ $td->addContent(_("Nach Bereichen suchen:"));
+ $td->addContent(" ");
+
+ $input = new HTMLempty("input");
+ $input->addAttr("type", "text");
+ $input->addAttr("name", "search");
+ $input->addAttr("style", "vertical-align:middle;");
+ $input->addAttr("value", "" . Request::get("search") . "");
+ $td->addContent($input);
+
+ $td->addContent(Button::create(_('Suchen'), 'search_range_button', ['title' => _('Bereiche suchen')]));
+ $tr->addContent($td);
+
+ $table->addContent($tr);
+ }
+
+ return $table->createContent();
+ }
+
+ function createDomainLinks($search)
+ {
+ $db = new EvaluationObjectDB ();
+ $evalDB = new EvaluationDB ();
+ $globalperm = $db->getGlobalPerm();
+
+ // search results
+ $results = $evalDB->search_range($search);
+
+ if ($globalperm == "root") {
+ $results["studip"] = ["type" => "system", "name" => _("Systemweite Evaluationen")];
+ } else {
+ $results[$GLOBALS['user']->id] = ["type" => "user", "name" => _("Profil")];
+ }
+
+ if ($globalperm == "dozent" || $globalperm == "autor" || $search)
+ $showsearchresults = 1;
+
+ if ($globalperm == "admin")
+ $range_types = [
+ "user" => _("Benutzer"),
+ "sem" => _("Veranstaltung"),
+ "inst" => _("Einrichtung"),
+ "fak" => _("Fakultät")];
+
+ elseif ($globalperm == "root")
+ $range_types = [
+ "user" => _("Benutzer"),
+ "sem" => _("Veranstaltung"),
+ "inst" => _("Einrichtung"),
+ "fak" => _("Fakultät"),
+ "system" => _("System")];
+
+ // display search_results
+ if ($results) {
+ foreach ($results as $k => $v) {
+ foreach ($range_types as $type_key => $type_value) {
+ if ($v["type"] == $type_key) {
+ $ranges["$type_key"][] = ["id" => $k, "name" => $v["name"]];
+ }
+ }
+ reset($range_types);
+ }
+
+ $table = new HTML("table");
+ $table->addAttr("class", "default");
+ $table->addAttr("border", "0");
+ $table->addAttr("align", "center");
+ $table->addAttr("cellspacing", "0");
+ $table->addAttr("cellpadding", "0");
+ $table->addAttr("width", "100%");
+
+ foreach ($range_types as $type_key => $type_value) {
+ // Überschriften
+ $tr = new HTML("tr");
+
+ // Typ
+ $td = new HTML("td");
+ $td->addAttr("colspan", "1");
+ $td->addAttr("class", "table_header");
+ $td->addAttr("height", "22");
+ $td->addAttr("width", "50%");
+ $td->addAttr("style", "vertical-align:bottom;");
+ $b = new HTML("b");
+ $b->addHTMLContent("&nbsp;");
+ $b->addContent($type_value . ":");
+ $td->addContent($b);
+ $tr->addContent($td);
+
+ // Typ
+ $td = new HTML("td");
+ $td->addAttr("class", "table_header");
+ $td->addAttr("height", "22");
+ $td->addAttr("align", "center");
+ $td->addAttr("style", "vertical-align:bottom;");
+ $b = new HTML("b");
+ $b->addContent(" ");
+ $td->addContent($b);
+ $tr->addContent($td);
+
+ // Typ
+ $td = new HTML("td");
+ $td->addAttr("class", "table_header");
+ $td->addAttr("height", "22");
+ $td->addAttr("align", "center");
+ $td->addAttr("style", "vertical-align:bottom;");
+ $b = new HTML("b");
+ $b->addContent(" ");
+ $td->addContent($b);
+ $tr->addContent($td);
+
+ $table->addContent($tr);
+
+ $counter = 0;
+
+ if ($ranges["$type_key"]) {
+ foreach ($ranges["$type_key"] as $range) {
+
+ if ($counter == 0)
+ $displayclass = "content_body";
+ elseif (($counter % 2) == 0)
+ $displayclass = "table_row_even";
+ else
+ $displayclass = "table_row_odd";
+
+ $tr = new HTML("tr");
+
+ // name
+ $td = new HTML("td");
+ $td->addHTMLContent("&nbsp;");
+ $td->addContent($range["name"]);
+ $tr->addContent($td);
+
+ // if the rangeID is a username, convert it to the userID
+ $new_rangeID = (get_userid($range['id'])) ? get_userid($range['id']) : $range['id'];
+
+
+ // link
+ $td = new HTML("td");
+ $td->addAttr("align", "center");
+ $link = new HTML("a");
+ $link->addAttr("href", URLHelper::getLink(EVAL_FILE_ADMIN . "?rangeID=" . $range['id']));
+ $link->addContent(_("Diesen Bereich anzeigen."));
+ $td->addContent($link);
+ $tr->addContent($td);
+
+ // copy
+ $td = new HTML("td");
+ $td->addAttr("align", "center");
+ $td->addContent(" ");
+ $tr->addContent($td);
+
+ $table->addContent($tr);
+ $counter++;
+ }
+ } elseif ($globalperm == "root" || $globalperm == "admin") {
+ $tr = new HTML("tr");
+ $td = new HTML("td");
+ $td->addAttr("class", "content_body");
+ $td->addAttr("colspan", "4");
+ $td->addHTMLContent("&nbsp;");
+ $td->addContent(_("Es wurden keine Ergebnisse aus diesem Bereich gefunden."));
+ $tr->addContent($td);
+ $table->addContent($tr);
+ }
+ reset($ranges);
+ }
+ }
+
+ return $table->createContent();
+ }
+
+ /**
+ * checks which button was pressed
+ *
+ * @access public
+ * @returns string the command
+ *
+ */
+ function getPageCommand()
+ {
+ if (Request::option("evalAction"))
+ return Request::option("evalAction");
+
+ foreach ($_REQUEST as $key => $value) {
+ if (preg_match("/(.*)_button(_x)?/", $key, $command))
+ break;
+ }
+ return $command[1];
+ }
+
+# ===================================================== end: public functions #
+}
diff --git a/lib/evaluation/evaluation_admin_template.inc.php b/lib/evaluation/evaluation_admin_template.inc.php
new file mode 100644
index 0000000..f7a96c6
--- /dev/null
+++ b/lib/evaluation/evaluation_admin_template.inc.php
@@ -0,0 +1,672 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * the form to create/edit templates for answers
+ *
+ * @author JPWowra
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+use Studip\Button, Studip\LinkButton;
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once 'lib/evaluation/classes/db/EvaluationQuestionDB.class.php';
+require_once 'lib/evaluation/classes/EvaluationQuestion.class.php';
+require_once EVAL_LIB_COMMON;
+require_once EVAL_LIB_OVERVIEW;
+require_once EVAL_LIB_TEMPLATE;
+require_once EVAL_FILE_EVAL;
+require_once EVAL_FILE_EVALDB;
+require_once EVAL_FILE_QUESTION;
+require_once EVAL_FILE_QUESTIONDB;
+require_once EVAL_FILE_OBJECTDB;
+# ====================================================== end: including files #
+
+
+/* Create objects ---------------------------------------------------------- */
+$db = new EvaluationQuestionDB();
+$lib = new EvalTemplateGUI();
+/* ------------------------------------------------------------ end: objects */
+
+#error_reporting( E_ALL );
+
+/* Set variables ----------------------------------------------------------- */
+$rangeID = ($rangeID) ? $rangeID : Context::getId();
+
+if (empty ($rangeID)) {
+ $rangeID = $user->id;
+}
+
+$command = $lib->getPageCommand();
+$odb = new EvaluationObjectDB();
+if ($odb->getGlobalPerm() == "root") {
+ $myuserid = 0;
+} else {
+ $myuserid = $user->id;
+
+}
+if (!$parentID) {
+ $parentID = Request::option('parentID');
+}
+$template_name = Request::get('template_name', $template_name);
+$template_type = Request::get('template_type') ? Request::get('template_type') : $template_type;
+$template_multiple = Request::get('template_multiple', $template_multiple);
+$template_answers = Request::getArray('template_answers');
+$template_add_num_answers = Request::get('template_add_num_answers') ? Request::get('template_add_num_answers') : $template_add_num_answers;
+if (empty($template_answers)) {
+ if (mb_strstr($command, "edit"))
+ for ($i = 0; $i < 5; $i++)
+ $template_answers[$i] = $lib->makeNewAnswer();
+ else
+ $template_answers = [];
+}
+if (!$template_id) {
+ $template_id = Request::option('template_id');
+}
+
+/* ---------------------------------------------------------- end: variables */
+
+if (Request::option('onthefly') && ($command == "delete" || $command == "add_answers"
+ || $command == "delete_answers" || $command == "save2")) {
+ $question = new EvaluationQuestion ($template_id,
+ NULL, EVAL_LOAD_ALL_CHILDREN);
+ $question->setMultiplechoice($template_multiple);
+ $question->setText(trim($template_name), YES);
+ $question->setType($template_type);
+ $question->setParentID($parentID);
+ $question->setPosition($template_position);
+ while ($answerrem = $question->getChild()) {
+ $id = $answerrem->getObjectID();
+ $answerrem->delete();
+ $question->removeChildID($id);
+ }
+ $controlnumber = count($template_answers);
+ for ($i = 0; $i < $controlnumber; $i++) {
+ $text = $template_answers[$i]['text'];
+ $answerID = $template_answers[$i]['answer_id'];
+ $answer = new EvaluationAnswer();
+ $answer->setObjectID($answerID);
+ $answer->setText(trim($text), YES);
+ $answer->setParentID($template_id);
+ $question->addChild($answer);
+ }
+
+}
+
+switch ($command) {
+ /* -------------------------------------------------------------------- */
+ case "savefree":
+ $qdb = new EvaluationQuestionDB();
+ if ($qdb->exists($template_id)) {
+ $question = new EvaluationQuestion ($template_id, NULL,
+ EVAL_LOAD_ALL_CHILDREN);
+ if ($question->getParentID() != $myuserid) {
+ $question = new EvaluationQuestion();
+ $question->setParentID($myuserid);
+ } else {
+ $question->delete();
+ $question = new EvaluationQuestion();
+ }
+ } else {
+ $question = new EvaluationQuestion();
+ }
+ /*wenn root, dann id = 0 setzen ---und Text Brandmarken!!--------------*/
+ $question->setParentID($myuserid);
+ $question->setText(trim($template_name), YES);
+ while ($answerrem = $question->getChild()) {
+ $id = $answerrem->getObjectID();
+ $answerrem->delete();
+ $question->removeChildID($id);
+ }
+ $answer = new EvaluationAnswer();
+ $answer->setRows(Request::option('template_add_num_answers'));
+ $question->addChild($answer);
+ $lib->setUniqueName($question, $db, $myuserid);
+ $question->save();
+ $command = "";
+
+ break;
+ /* -------------------------------------------------------------------- */
+ case "delete":
+ $question = new EvaluationQuestion ($template_id, null, EVAL_LOAD_ALL_CHILDREN);
+ if ($question->getParentID() == $myuserid) {
+ $question->delete();
+ } elseif (get_username($question->getParentID()) == "") {
+ while ($answer = $question->getChild()) {
+ $answer->delete();
+ }
+ } else {
+ $report = MessageBox::error(_("Keine Berechtigung zum Löschen."));
+ }
+ $command = "";
+ break;
+
+ /* -------------------------------------------------------------------- */
+ case "add_answers":
+ // Bevor etwas hinzugefügt wird nochmal die Speicherungsroutine laufen lassen
+ if (!Request::option('onthefly')) {
+ $question = save1($myuserid);
+ } else {
+ $question->save();
+ }
+ //$question->setMultiplechoice($template_multiple);
+ //$question->setText(trim($template_name), YES);
+ //$question->setType($template_type);
+ $command = "continue_edit";
+ if ($question->getType() == EVALQUESTION_TYPE_MC ||
+ $question->getType() == EVALQUESTION_TYPE_LIKERT) {
+ while ($template_add_num_answers--) {
+ $answer = new EvaluationAnswer();
+ $answer->setText("");
+ $question->addChild($answer);
+ }
+ #echo "Nummer: ".$question->getNumberChildren()."<br>";
+ break;
+
+ } elseif ($question->getType() == EVALQUESTION_TYPE_POL) {
+ echo(_("Diese Option gibt es nicht"));
+ } else {
+ echo(_("Unbekanntes Objekt"));
+ }
+ $command = "continue_edit";
+
+ break;
+
+
+ /* delete answers ----------------------------------------------------- */
+ case "delete_answers":
+ if (!Request::option('onthefly')) {
+ $question = save1($myuserid);
+ $question->setParentID($myuserid);
+ } else
+ $question->save();
+ $template_delete_answers = Request::getArray("template_delete_answers");
+ if (!empty($template_delete_answers))
+ foreach ($template_delete_answers as $answerID) {
+ $question->removeChildID($answerID);
+ $answer = new EvaluationAnswer ($answerID);
+ $answer->delete();
+ }
+ $command = "continue_edit";
+
+ break;
+ /* ------------------------------------------------ end: delete answers */
+
+
+ /* -------------------------------------------------------------------- */
+ case "save":
+ $question = save1($myuserid);
+ /* Check userinput ----------------------------------------------------- */
+ if ($question->getType() == EVALQUESTION_TYPE_MC ||
+ $question->getType() == EVALQUESTION_TYPE_LIKERT) {
+ $nummer = $question->getNumberChildren();
+ for ($i = 0; $i < count($template_answers); $i++) {
+ $text = $template_answers[$i]['text'];
+ if ($text == "") {
+ $question->removeChildID($template_answers[$i]['answer_id']);
+ $nummer--;
+ }
+ }
+
+ if ($nummer == 0) {
+ $report = MessageBox::error(_("Dem Template wurden keine Antworten zugewiesen oder keine der Antworten enthielt einen Text. Fügen Sie Antworten an, oder löschen Sie das Template."));
+ $command = "continue_edit";
+ break;
+ }
+ }
+
+ if ($question->getType() == EVALQUESTION_TYPE_POL) {
+ for ($i = 0; $i < count($template_answers); $i++) {
+ $text = $template_answers[$i]['text'];
+ if ($text == "") {
+ $report = MessageBox::error(_("Leere Antworten sind nicht zulässig, löschen Sie betreffende Felder oder geben Sie einen Text ein."));
+ $command = "continue_edit";
+ break;
+ }
+ }
+ if ($command == "continue_edit") {
+ break;
+ }
+ }
+ if ($template_residual && empty ($template_residual_text)) {
+ $report = MessageBox::error(_("Geben Sie eine Ausweichantwort ein oder deaktivieren Sie diese."));
+ $command = "continue_edit";
+ break;
+ }
+ if (!Request::option('onthefly') && !$question->getText()) {
+ $report = MessageBox::error(_("Geben Sie einen Namen für die Vorlage ein."));
+ $command = "continue_edit";
+ break;
+ }
+ $question->save();
+ if ($question->isError()) {
+ $report = MessageBox::error(_("Fehler beim Speichern."));
+ }
+ $command = "";
+ $template_answers = "";
+ break;
+ case "save2":
+ $question->save();
+ if ($question->isError()) {
+ $report = MessageBox::error(_("Fehler beim Speichern."));
+ }
+ $command = "";
+ $template_answers = "";
+ break;
+}
+
+/* Surrounding Table ------------------------------------------------------- */
+$br = new HTMpty("br");
+
+$tableA = new HTM ("table");
+$tableA->attr("border", "0");
+$tableA->attr("align", "center");
+$tableA->attr("cellspacing", "0");
+$tableA->attr("cellpadding", "2");
+$tableA->attr("width", "250");
+
+$lib->createInfoBox();
+
+$trA = new HTM("tr");
+$tdA = new HTM("td");
+$tdA->cont(EvalCommon::createTitle(_("Antwortenvorlagen"), NULL, 2));
+$trA->cont($tdA);
+$tableA->cont($trA);
+
+$trA = new HTM("tr");
+$tdA = new HTM("td");
+
+$table = new HTM ("table");
+$table->attr("border", "0");
+$table->attr("align", "center");
+$table->attr("cellspacing", "0");
+$table->attr("cellpadding", "3");
+$table->attr("width", "100%");
+
+$tr = new HTM("tr");
+$td = new HTM("td");
+$td->attr("class", "table_row_even");
+
+if (!$command || $command == "back") {
+ /* the template selection lists --------------------------------------- */
+
+ $question_show = new EvaluationQuestionDB();
+ $arrayOfTemplateIDs = $question_show->getTemplateID($myuserid);
+ $arrayOfPolTemplates = [];
+ $arrayOfSkalaTemplates = [];
+ $arrayOfNormalTemplates = [];
+ $arrayOfFreeTemplates = [];
+
+ foreach ($arrayOfTemplateIDs as $templateID) {
+ $questionload = new EvaluationQuestion ($templateID,
+ NULL, EVAL_LOAD_FIRST_CHILDREN);
+ $typ = $questionload->getType();
+ $text = my_substr($questionload->getText(), 0, EVAL_MAX_TEMPLATENAMELEN);
+ /*Root kennzeichnung hier entfernen!!*/
+ //if($questionload->getParentID()==0)
+ // $text="<b>".$text."</b>";
+ if ($questionload->getParentID() == '0') {
+ $text = $questionload->getText() . " " . EVAL_ROOT_TAG;
+ }
+ if (($answer = $questionload->getChild()) == NULL)
+ $answer = new EvaluationAnswer ();
+ /* --------------------------------------------------------------- */
+ switch ($typ) {
+
+ case EVALQUESTION_TYPE_POL:
+ array_push($arrayOfPolTemplates,
+ [$questionload->getObjectID(), $text]);
+ break;
+ case EVALQUESTION_TYPE_LIKERT:
+ array_push($arrayOfSkalaTemplates,
+ [$questionload->getObjectID(), $text]);
+ break;
+ case EVALQUESTION_TYPE_MC:
+ if ($answer->isFreetext()) {
+ array_push($arrayOfFreeTemplates,
+ [$questionload->getObjectID(), $text]);
+ } else {
+ array_push($arrayOfNormalTemplates,
+ [$questionload->getObjectID(), $text]);
+ }
+ break;
+ }
+ /* -------------------------------------------------------- */
+ }
+
+ /* report messages ---------------------------------------------------- */
+ $td->cont($report);
+
+ $td->cont($lib->createSelections($arrayOfPolTemplates,
+ $arrayOfSkalaTemplates,
+ $arrayOfNormalTemplates,
+ $arrayOfFreeTemplates,
+ $myuserid));
+
+} else {
+ $form = new HTM("form");
+ $form->attr("action", URLHelper::getLink("?page=edit&evalID=" . $evalID));
+ $form->attr("method", "post");
+ $form->html(CSRFProtection::tokenTag());
+ $form->cont(Button::create(_('zurück'), 'template_back_button', ['title' => _('Zurück zur Auswahl')]));
+ $td->cont($form);
+
+ /* on the fly info message -------------------------------------------- */
+ if ($command == "create_question_answers" || Request::option('onthefly')) {
+ $report = MessageBox::info(sprintf(_("Weisen Sie der links %sausgewählten%s Frage hier Antworten zu:"),
+ "<span class=\"eval_highlight\">", "</span>"));
+ }
+ /* report messages ---------------------------------------------------- */
+ $td->cont($report);
+}
+
+
+$tr->cont($td);
+$table->cont($tr);
+$tdA->cont($table);
+$trA->cont($tdA);
+$tableA->cont($trA);
+
+
+if ($command) {
+ /* the template editing fields */
+ $trA = new HTM("tr");
+ $tdA = new HTM("td");
+
+ $table = new HTM ("table");
+ $table->attr("border", "0");
+ $table->attr("align", "center");
+ $table->attr("cellspacing", "0");
+ $table->attr("cellpadding", "0");
+ $table->attr("width", "100%");
+
+ $tr = new HTM("tr");
+ $td = new HTM("td");
+ $td->attr("class", "table_row_odd");
+
+ /*übergebe an create Form das template, dass verändert werden soll*/
+
+ switch ($command) {
+ case "editpol_scale":
+ $question = new EvaluationQuestion (Request::option('template_editpol_scale'), NULL, EVAL_LOAD_ALL_CHILDREN);
+ $td->cont($lib->createTemplateForm($question));
+ break;
+ case "createpol_scale":
+ $question = new EvaluationQuestion();
+ $question->setObjectID(md5(uniqid(rand())));
+ $question->setType(EVALQUESTION_TYPE_POL);
+ $question->setText("");
+ for ($i = 0; $i < 2; $i++) {
+ $answer = new EvaluationAnswer();
+ $answer->setParentID($question->getObjectID());
+ if ($i == 0)
+ $answer->setText(_("Anfang"));
+ else
+ $answer->setText(_("Ende"));
+ $question->addChild($answer);
+ }
+ // $td->cont( $lib->createTemplateFormPol( $question ) );
+ $td->cont($lib->createTemplateForm($question));
+ break;
+ case "editlikert_scale":
+ $question = new EvaluationQuestion (Request::option('template_editlikert_scale'),
+ NULL, EVAL_LOAD_ALL_CHILDREN);
+ $question->setType(EVALQUESTION_TYPE_LIKERT);
+ //$td->cont( $lib->createTemplateFormLikert( $question ) );
+ $td->cont($lib->createTemplateForm($question));
+ break;
+ case "createlikert_scale":
+ $question = new EvaluationQuestion();
+ $question->setObjectID(md5(uniqid(rand())));
+ $question->setType(EVALQUESTION_TYPE_LIKERT);
+ $question->setText("");
+ for ($i = 0; $i < 4; $i++) {
+ $answer = new EvaluationAnswer();
+ $answer->setParentID($question->getObjectID());
+ $answer->setText("");
+ $answer->setPosition(1);
+ $question->addChild($answer);
+ }
+ $td->cont($lib->createTemplateForm($question));
+ break;
+ case "editnormal_scale":
+ $question = new EvaluationQuestion (Request::option('template_editnormal_scale'),
+ NULL, EVAL_LOAD_ALL_CHILDREN);
+ $question->setType(EVALQUESTION_TYPE_MC);
+ $td->cont($lib->createTemplateForm($question));
+ break;
+ case "createnormal_scale":
+ $question = new EvaluationQuestion();
+ $question->setObjectID(md5(uniqid(rand())));
+ $question->setType(EVALQUESTION_TYPE_MC);
+ $question->setText("");
+ for ($i = 0; $i < 4; $i++) {
+ $answer = new EvaluationAnswer();
+ $answer->setParentID($question->getObjectID());
+ $answer->setText("");
+ $answer->setPosition(1);
+ $question->addChild($answer);
+ }
+ $td->cont($lib->createTemplateForm($question));
+ //$td->cont( $lib->createTemplateFormMul( $question ) );
+ break;
+ case "continue_edit":
+ /*Im Fall direkt question->answers flag mitübergeben*/
+ /*$template_type überprüfen------------------------------------------*/
+ switch (Request::option('template_type')) {
+ /* --------------------------------------------------------------- */
+ case EVALQUESTION_TYPE_POL:
+ $td->cont($lib->createTemplateForm($question));
+ break;
+ case EVALQUESTION_TYPE_LIKERT:
+ $td->cont($lib->createTemplateForm($question));
+ break;
+ case EVALQUESTION_TYPE_MC:
+ $td->cont($lib->createTemplateForm($question, Request::int('onthefly')));
+ break;
+ }
+ break;
+
+ case "create_question_answers":
+ $onthefly = 1;
+ // extract the questionID from the command
+ foreach ($_REQUEST as $key => $value) {
+ if (preg_match("/template_(.*)_button?/", $key, $command))
+ break;
+ }
+ if (preg_match("/(.*)_#(.*)/", $command[1], $command_parts))
+ $questionID = $command_parts[2];
+ $question = new EvaluationQuestion ($questionID,
+ NULL, EVAL_LOAD_ALL_CHILDREN);
+
+ if ($question->getNumberChildren() == 0) {
+ $question->setType(EVALQUESTION_TYPE_MC);
+ for ($i = 0; $i < 4; $i++) {
+ $answer = new EvaluationAnswer();
+ $answer->setParentID($question->getObjectID());
+ $answer->setText((""));
+ $answer->setPosition(1);
+ $question->addChild($answer);
+ }
+ }
+ $td->cont($lib->createTemplateForm($question, $onthefly));
+ break;
+ case "createfree_scale":
+ $question = new EvaluationQuestion();
+ $question->setObjectID(md5(uniqid(rand())));
+ $question->setType(EVALQUESTION_TYPE_MC);
+ $question->setText(_("Freitext"));
+ $answer = new EvaluationAnswer();
+ $answer->setParentID($question->getObjectID());
+ $answer->setText("");
+ $answer->setRows(1);
+ $question->addChild($answer);
+ $td->cont($lib->createTemplateFormFree($question));
+ break;
+ case "editfree_scale":
+ $question = new EvaluationQuestion (Request::option('template_editfree_scale'),
+ NULL, EVAL_LOAD_ALL_CHILDREN);
+ $td->cont($lib->createTemplateFormFree($question));
+ break;
+
+ case "back":
+ $td->cont(" ");
+ break;
+
+ }
+
+ $tr->cont($td);
+ $table->cont($tr);
+ $tdA->cont($table);
+ $trA->cont($tdA);
+ $tableA->cont($trA);
+
+}
+
+/* Javascript function for preview-link */
+$js = EvalCommon::createEvalShowJS(YES);
+
+/* --------------------------------------------------------------------- */
+return $js->createContent() . $tableA->createContent();
+/* --------------------------------------------------------------------- */
+
+
+/* --------------------------------------------------------------------- */
+function save1($myuserid)
+{
+ $mineexists = 0;
+ /*Existiert Question/Template schon?*/
+ $qdb = new EvaluationQuestionDB();
+ if (!$template_id) {
+ $template_id = Request::option("template_id");
+ }
+ if ($qdb->exists($template_id)) {
+ $question = new EvaluationQuestion ($template_id,
+ NULL, EVAL_LOAD_ALL_CHILDREN);
+ if ($question->getParentID() != $myuserid) {
+ $foreign = TRUE;
+ $question = new EvaluationQuestion();
+ $question->setParentID($myuserid);
+ } else {
+ $overwrite = 1;
+ //$question->delete();
+ //$question = new EvaluationQuestion();
+ //$template_id=$question->getObjectID();
+ }
+ } else {
+ $question = new EvaluationQuestion();
+ }
+
+ /*Get Vars ----------------------------------------------------*/
+ $template_name = Request::get("template_name");
+ $template_type = Request::get("template_type");
+ $template_multiple = Request::get("template_multiple");
+ $template_add_num_answers = Request::option("template_add_num_answers");
+ $template_residual = Request::get("template_residual");
+ $template_residual_text = Request::get("template_residual_text");
+ $template_answers = Request::getArray("template_answers");
+ /*end: Get Vars -----------------------------------------------*/
+
+ $question->setParentID($myuserid);
+ $question->setMultiplechoice($template_multiple);
+ $question->setText(trim($template_name), YES);
+ $question->setType($template_type);
+
+ while ($answerrem = $question->getChild()) {
+ $id = $answerrem->getObjectID();
+ $answerrem->delete();
+ $question->removeChildID($id);
+ }
+
+ $controlnumber = count($template_answers);
+ $ausgleich = 0;
+
+ for ($i = 0; $i < $controlnumber; $i++) {
+ $text = $template_answers[$i]['text'];
+ $answerID = $template_answers[$i]['answer_id'];
+ $answer = new EvaluationAnswer();
+ if (!$foreign)
+ $answer->setObjectID($answerID);
+ $answer->setText(trim($text), YES);
+ $question->addChild($answer);
+
+ if ($template_type == EVALQUESTION_TYPE_POL && $i == 0) {
+ $answerdiff = $controlnumber - $template_add_num_answers;
+
+ if ($answerdiff > 0) {
+ $i = $i + $answerdiff;
+ $ausgleich = $ausgleich - $answerdiff;
+ }
+ while ($answerdiff < 0) {
+ $ausgleich = $ausgleich + 1;
+ $answer = new EvaluationAnswer();
+ $answer->setText("");
+ $answer->setParentID($question->getObjectID());
+ $answer->setPosition($i + $ausgleich);
+ $answer->setValue($i + 1 + $ausgleich);
+ $question->addChild($answer);
+ $answerdiff++;
+ }
+ }
+ }
+
+ if ($template_residual) {
+ $answer = new EvaluationAnswer();
+ $answer->setResidual($template_residual);
+ $answer->setText(trim($template_residual_text), QUOTED);
+ $answer->setParentID($question->getObjectID());
+ $answer->setPosition($i + $ausgleich + 1);
+ $answer->setValue(-1);
+ $question->addChild($answer);
+ }
+
+ if (!$overwrite) {
+ $db = new EvaluationQuestionDB();
+ $lib = new EvalTemplateGUI();
+ $lib->setUniqueName($question, $db, $myuserid, YES);
+ }
+
+ if ($question->isError()) {
+ return MessageBox::error(_("Fehler beim Speichern."));
+ }
+ return $question;
+
+}
+
+# Define constants ========================================================== #
+/**
+ * @const EVAL_ROOT_TAG Specifies the string for taging root templates
+ * @access public
+ */
+define('EVAL_ROOT_TAG', "[R]");
+# ===================================================== end: define constants #
+
+
+?>
diff --git a/lib/evaluation/evaluation_admin_template.lib.php b/lib/evaluation/evaluation_admin_template.lib.php
new file mode 100644
index 0000000..e5e5f9f
--- /dev/null
+++ b/lib/evaluation/evaluation_admin_template.lib.php
@@ -0,0 +1,1115 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * Library for template gui
+ *
+ * @author JPWowra
+ *
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +--------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +--------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +--------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +--------------------------------------------------------------------------+
+
+use Studip\Button, Studip\LinkButton;
+
+class EvalTemplateGUI
+{
+ public function __construct()
+ {
+ $this->BR = new HTMpty("br");
+ $this->command = $this->getPageCommand();
+ }
+
+ /**
+ * Creates the two (?) template selection lists
+ * @param
+ */
+ public function createSelections(
+ $polTemplates,
+ $skalaTemplates,
+ $normalTemplates,
+ $freeTemplates,
+ $myuserid
+ )
+ {
+
+ global $evalID;
+
+ $form = new HTM("form");
+
+ $form->attr("action", URLHelper::getLink("?page=edit&evalID=" . $evalID));
+ $form->attr("method", "post");
+ $form->html(CSRFProtection::tokenTag());
+
+ $table = new HTML("table");
+ $table->addAttr("border", "0");
+ $table->addAttr("cellpadding", "2");
+ $table->addAttr("cellspacing", "0");
+
+ $table->addAttr("width", "100%");
+ $tr = new HTML ("tr");
+ $td = new HTML ("td");
+ $td->addAttr("align", "right");
+
+ /* Polskalen ------------------------------------------------ */
+ $b = new HTM("b");
+ $b->cont(_("Polskala"));
+ $td->addContent($b);
+ $tr->addContent($td);
+
+ $td = new HTML ("td");
+
+ /* create button ------------------------------------ */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_createpol_scale_button");
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $input->stri(tooltip(_("Neue Vorlage erstellen."), TRUE));
+ $input->attr("src", EVAL_PIC_ADD_TEMPLATE);
+
+ $td->addContent($input);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ if (!empty($polTemplates)) {
+ $tr = new HTML ("tr");
+ $td = new HTML ("td");
+ $td->addAttr("align", "right");
+
+ $select = new HTM("select");
+ $select->attr("name", "template");
+ $select->attr("size", "1");
+ foreach ($polTemplates as $templatearray) {
+ $option = new HTM("option");
+ $select->attr("name", "template_editpol_scale");
+ $option->attr("value", $templatearray[0]);
+ $option->cont("$templatearray[1]");
+ $select->cont($option);
+ }
+ $td->addContent($select);
+ $tr->addContent($td);
+ $td = new HTML ("td");
+
+ /* edit button ----------------------------------- */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_editpol_scale_button");
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $input->stri(tooltip(_("Ausgewählte Vorlage bearbeiten."), TRUE));
+ $input->attr("src", EVAL_PIC_EDIT);
+
+ $td->addContent($input);
+ $tr->addContent($td);
+ $table->addContent($tr);
+ }
+ /* end: Polskalen ----------------------------------------------- */
+
+
+ /* Likertskalen ------------------------------------------------- */
+ $td = new HTML ("td");
+ $td->addAttr("align", "right");
+ $td->addAttr("class", "content_body");
+ $tr = new HTML ("tr");
+
+ $b = new HTM("b");
+ $b->cont(_("Likertskala"));
+ $td->addContent($b);
+ $tr->addContent($td);
+
+ $td = new HTML ("td");
+ $td->addAttr("class", "content_body");
+
+ /* create button ------------------------------------ */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_createlikert_scale_button");
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $input->stri(tooltip(_("Neue Vorlage erstellen."), TRUE));
+ $input->attr("src", EVAL_PIC_ADD_TEMPLATE);
+
+ $td->addContent($input);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ if (!empty($skalaTemplates)) {
+ $td = new HTML ("td");
+ $tr = new HTML ("tr");
+ $td->addAttr("align", "right");
+ $select = new HTM("select");
+ $select->attr("name", "template");
+ $select->attr("size", "1");
+
+ foreach ($skalaTemplates as $templatearray) {
+ $option = new HTM("option");
+ $select->attr("name", "template_editlikert_scale");
+ $option->attr("value", $templatearray[0]);
+ $option->cont("$templatearray[1]");
+ $select->cont($option);
+ }
+ $td->addContent($select);
+ $tr->addContent($td);
+
+ $td = new HTML ("td");
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_editlikert_scale_button");
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $input->stri(tooltip(_("Ausgewählte Vorlage bearbeiten."), TRUE));
+ $input->attr("src", EVAL_PIC_EDIT);
+
+ $td->addContent($input);
+ $tr->addContent($td);
+ $table->addContent($tr);
+ }
+ /* end: Likertskalen ----------------------------------------------- */
+
+
+ /* Normale / Multiplechoice ---------------------------------------- */
+ $td = new HTML ("td");
+ $td->addAttr("class", "content_body");
+ $tr = new HTML ("tr");
+ $td->addAttr("align", "right");
+
+ $b = new HTM("b");
+ $b->cont(_("Multiple Choice"));
+ $td->addContent($b);
+ $tr->addContent($td);
+
+ $td = new HTML ("td");
+ $td->addAttr("class", "content_body");
+
+ /* create button ------------------------------------ */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_createnormal_scale_button");
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $input->stri(tooltip(_("Neue Vorlage erstellen."), TRUE));
+ $input->attr("src", EVAL_PIC_ADD_TEMPLATE);
+
+ $td->addContent($input);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ if (!empty($normalTemplates)) {
+ $td = new HTML ("td");
+ $tr = new HTML ("tr");
+ $td->addAttr("align", "right");
+ $select = new HTM("select");
+ $select->attr("name", "template");
+ $select->attr("size", "1");
+
+ foreach ($normalTemplates as $templatearray) {
+ $option = new HTM("option");
+ $select->attr("name", "template_editnormal_scale");
+ $option->attr("value", $templatearray[0]);
+ $option->cont("$templatearray[1]");
+ $select->cont($option);
+ }
+ $td->addContent($select);
+ $tr->addContent($td);
+ $td = new HTML ("td");
+
+ /* edit button */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_editnormal_scale_button");
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $input->stri(tooltip(_("Ausgewählte Vorlage bearbeiten."), TRUE));
+ $input->attr("src", EVAL_PIC_EDIT);
+
+ $td->addContent($input);
+ $tr->addContent($td);
+ $table->addContent($tr);
+ }
+ /* end: Normale / Multiplechoice-------------------------------------- */
+
+
+ /* Freitext ----------------------------------------------------- */
+
+ $td = new HTML ("td");
+ $td->addAttr("class", "content_body");
+ $tr = new HTML ("tr");
+ $td->addAttr("align", "right");
+
+ $b = new HTM("b");
+ $b->cont(_("Freitext-Antwort"));
+ $td->addContent($b);
+ $tr->addContent($td);
+
+ $td = new HTML ("td");
+ $td->addAttr("class", "content_body");
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_createfree_scale_button");
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $input->stri(tooltip(_("Neue Vorlage erstellen."), TRUE));
+ $input->attr("src", EVAL_PIC_ADD_TEMPLATE);
+ $td->addContent($input);
+ $tr->addContent($td);
+ $table->addContent($tr);
+
+ if (!empty($freeTemplates)) {
+ $td = new HTML ("td");
+ $tr = new HTML ("tr");
+ $td->addAttr("align", "right");
+
+ $select = new HTM("select");
+ $select->attr("name", "template");
+ $select->attr("size", "1");
+
+ foreach ($freeTemplates as $templatearray) {
+ $option = new HTM("option");
+ $select->attr("name", "template_editfree_scale");
+ $option->attr("value", $templatearray[0]);
+ $option->cont("$templatearray[1]");
+ $select->cont($option);
+ }
+ $td->addContent($select);
+ $tr->addContent($td);
+ $td = new HTML ("td");
+
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_editfree_scale_button");
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $input->stri(tooltip(_("Ausgewählte Vorlage bearbeiten."), TRUE));
+ $input->attr("src", EVAL_PIC_EDIT);
+ $td->addContent($input);
+ $tr->addContent($td);
+ $table->addContent($tr);
+ }
+ /* end: Freitext -------------------------------------- */
+
+ $form->cont($table);
+
+ return $form;
+ }
+
+ /**
+ * Creates the form for the template
+ * @param
+ */
+ public function createTemplateForm(&$question, $onthefly = "")
+ {
+ global $evalID, $itemID;
+
+ $type = $question->getType();
+ $tableA = new HTM("table");
+ $tableA->attr("border", "0");
+ $tableA->attr("cellpadding", "2");
+ $tableA->attr("cellspacing", "0");
+ $tableA->attr("width", "100%");
+
+ $trA = new HTM("tr");
+ $tdA = new HTM("td");
+ $tdA->attr("class", "table_header_bold");
+ $tdA->attr("align", "left");
+ if ($onthefly) {
+ $tdA->html(_("<b>Freie Antworten definieren</b>"));
+ } else {
+ $isCreate = mb_strstr($this->getPageCommand(), "create");
+ $tdA->html("<b>");
+ switch ($type) {
+ case EVALQUESTION_TYPE_MC:
+ //$answer = $question->getChild();
+ //if ($answer->isFreetext ()) {}
+ //else
+ $tdA->html($isCreate
+ ? _("Multiple Choice erstellen")
+ : _("Multiple Choice bearbeiten"));
+ break;
+ case EVALQUESTION_TYPE_LIKERT:
+ $tdA->html($isCreate
+ ? _("Likertskala erstellen")
+ : _("Likertskala bearbeiten"));
+ break;
+ case EVALQUESTION_TYPE_POL:
+ $tdA->html($isCreate
+ ? _("Polskala erstellen")
+ : _("Polskala bearbeiten"));
+ break;
+ }
+ $tdA->html("</b>");
+ }
+ $trA->cont($tdA);
+ $tableA->cont($trA);
+
+ $trA = new HTM("tr");
+ $tdA = new HTM("td");
+
+ $form = new HTM("form");
+ $form->attr("action", URLHelper::getLink('', ['page' => 'edit', 'evalID' => $evalID, 'itemID' => $itemID]));
+
+ $form->attr("method", "post");
+ $form->html(CSRFProtection::tokenTag());
+ /* template name --------------------------------- */
+ if ($onthefly != 1) {
+ $b = new HTM("b");
+ $b->cont(_("Name") . ": ");
+ $form->cont($b);
+ $input = new HTMpty("input");
+ $input->attr("type", "text");
+ $input->attr("name", "template_name");
+ $input->attr("value", $question->getText());
+ $input->attr("style", "vertical-align:middle;");
+ $input->attr("size", 22);
+ $input->attr("maxlength", 22);
+ $input->attr("tabindex", 1);
+ $form->cont($input);
+ } else {
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_name");
+ $input->attr("value", $question->getText());
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "onthefly");
+ $input->attr("value", $onthefly);
+ $form->cont($input);
+ }
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_id");
+ $input->attr("value", $question->getObjectID());
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_type");
+ $input->attr("value", $question->getType());
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_residual");
+ $input->attr("value", NO);
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_position");
+ $input->attr("value", $question->getPosition());
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "parentID");
+ $input->attr("value", $question->getParentID());
+ $form->cont($input);
+
+ if ($onthefly != 1) {
+ $img = new HTMpty("img");
+ $img->attr("src", Icon::create('info-circle', 'inactive')->asImagePath(16));
+ $img->attr("class", "middle");
+ $img->stri(tooltip(_("Geben Sie hier einen Namen für Ihre Vorlage ein. Wenn Sie eine systemweite Vorlage bearbeiten, und speichern, wird eine neue Vorlage für Sie persönlich angelegt."),
+ FALSE, TRUE));
+ $form->cont($img);
+ $form->cont($this->BR);
+ }
+ if ($type == EVALQUESTION_TYPE_MC) {
+ /* multiple - radiobuttons ----------------------- */
+ $form->cont($this->createSubHeadline
+ (_("Mehrfachantwort erlaubt") . ": "));
+ $radio = new HTMpty("input");
+ $radio->attr("type", "radio");
+ $radio->attr("name", "template_multiple");
+ $radio->attr("value", YES);
+ $question->isMultiplechoice()
+ ? $radio->attr("checked") : 0;
+ $form->cont($radio);
+ $form->cont(_("ja"));
+
+ $radio = new HTMpty("input");
+ $radio->attr("type", "radio");
+ $radio->attr("name", "template_multiple");
+ $radio->attr("value", NO);
+ $question->isMultiplechoice()
+ ? 0 : $radio->attr("checked");
+ $form->cont($radio);
+ $form->cont(_("nein"));
+ $form->cont($this->BR);
+ /*end: multiple - radiobuttons -------------------- */
+
+ /* show multiple choice checkboxes & answers------------------------- */
+ $form->cont($this->createSubHeadline(_("Antworten") . ": "));
+ for ($i = 0; $answer = $question->getNextChild(); $i++) {
+ $form->cont(($i < 9 ? "0" : "") . ($i + 1) . ". ");
+ $input = new HTMpty("input");
+ $input->attr("type", "text");
+ $input->attr("name", "template_answers[" . $i . "][text]");
+ $input->attr("value", $answer->getText());
+ $input->attr("size", 23);
+ $input->attr("tabindex", $i + 2);
+ $form->cont($input);
+ $input = new HTMpty("input");
+ $input->attr("type", "checkbox");
+ $input->attr("name", "template_delete_answers[" . $i . "]");
+ $input->attr("value", $answer->getObjectID());
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_answers[" . $i . "][answer_id]");
+ $input->attr("value", $answer->getObjectID());
+ $form->cont($input);
+ $form->cont($this->BR);
+ }
+ /* ------------------------- end: multiple choice checkboxes &answers */
+
+ /* add button ------------------------------------ */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_add_answers_button");
+ $input->addAttr("src", EVAL_PIC_ADD);
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $form->html("&nbsp;");
+ $form->cont($input);
+
+ /* add number of answers - list ------------------ */
+ $select = new HTM("select");
+ $select->attr("name", "template_add_num_answers");
+ $select->attr("size", "1");
+ $select->attr("style", "vertical-align:middle;");
+ for ($i = 1; $i <= 10; $i++) {
+ $option = new HTM("option");
+ $option->attr("value", $i);
+ $option->cont($i);
+ $select->cont($option);
+ }
+ $form->cont($select);
+
+ /* delete button --------------------------------- */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_delete_answers_button");
+ $input->addAttr("src", EVAL_PIC_REMOVE);
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $form->html("&nbsp;");
+ $form->cont($input);
+ $form->cont($this->BR);
+ } else {
+ if ($type == EVALQUESTION_TYPE_POL) {
+ $form->cont($this->createSubHeadline(_("Antworten") . ": "));
+ /* answers --------------------------------------- */
+ $isResidual = NO;
+ for ($i = 0; $answer = $question->getNextChild(); $i++) {
+ /*Einbau der Residualkategorie hier komplizierter*/
+ $residualAnswer = $answer;
+ if (!$answer->isResidual()) {
+ if ($i == 0 || $i >= ($question->getNumberChildren() - 2)) {
+ if ($i == 0) {
+ $form->cont(_("Beschriftung erste Antwort"));
+ $input = new HTMpty("input");
+ $input->attr("type", "text");
+ $input->attr("name", "template_answers[0][text]");
+ $input->attr("value", $answer->getText());
+ $input->attr("size", 29);
+ $form->cont($input);
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_answers[0][answer_id]");
+ $input->attr("value", $answer->getObjectID());
+ $form->cont($input);
+ $form->cont($this->BR);
+ } else {
+
+ if ($answer->getText() == "") {
+ $oldid = $answer->getObjectID();
+ //continue;
+ } else {
+ $form->cont(_("Beschriftung letzte Antwort"));
+ $lastone = -1;
+ $input = new HTMpty("input");
+ $input->attr("type", "text");
+ $input->attr("name", "template_answers[1][text]");
+ $input->attr("value", $answer->getText());
+ $input->attr("size", 29);
+ $form->cont($input);
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_answers[1][answer_id]");
+ $input->attr("value", $answer->getObjectID());
+ $form->cont($input);
+ }
+
+ }
+
+ }
+
+ } else {
+ $isResidual = YES;
+
+ }
+ if ($lastone != -1 && $i == ($question->getNumberChildren() - 1)) {
+ $form->cont(_("Beschriftung letzte Antwort"));
+ $lastone = YES;
+ $input = new HTMpty("input");
+ $input->attr("type", "text");
+ $input->attr("name", "template_answers[1][text]");
+ $input->attr("value", "");
+ $input->attr("size", 29);
+ $form->cont($input);
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_answers[1][answer_id]");
+ $input->attr("value", $oldid);
+ $form->cont($input);
+ }
+ }
+ $form->cont($this->BR);
+ $form->cont($this->
+ createSubHeadline(_("Anzahl Abstufungen") . ": "));
+ /* NUMBER OF ANSWERS------------------------------------------ */
+ $select = new HTM("select");
+ $select->attr("name", "template_add_num_answers");
+ $select->attr("size", "1");
+ $select->attr("style", "vertical-align:middle;");
+ if ($isResidual == YES) {
+ $res = 1;
+ }
+ for ($i = 4; $i <= 20; $i++) {
+ $option = new HTM("option");
+ $option->attr("value", $i);
+ $option->cont($i);
+ if ($i == $question->getNumberChildren() - $res)
+ $option->addAttr("selected", "selected");
+ $select->cont($option);
+ }
+ $form->cont($select);
+ $form->cont($this->BR);
+
+
+ }
+ if ($type == EVALQUESTION_TYPE_LIKERT) {
+ $form->cont($this->createSubHeadline(_("Antworten") . ": "));
+ $residualAnswer = NULL;
+ $isResidual = NO;
+ for ($i = 0; $answer = $question->getNextChild(); $i++) {
+ if (!$answer->isResidual()) {
+ $form->cont(($i < 9 ? "0" : "") . ($i + 1) . ". ");
+ $input = new HTMpty("input");
+ $input->attr("type", "text");
+ $input->attr("name", "template_answers[" . $i . "][text]");
+ $input->attr("value", $answer->getText());
+ $input->attr("size", 23);
+ $input->attr("tabindex", $i + 2);
+ $form->cont($input);
+ $input = new HTMpty("input");
+ $input->attr("type", "checkbox");
+ $input->attr("name", "template_delete_answers[" . $i . "]");
+ $input->attr("value", $answer->getObjectID());
+ $form->cont($input);
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_answers[" . $i . "][answer_id]");
+ $input->attr("value", $answer->getObjectID());
+ $form->cont($input);
+ $form->cont($this->BR);
+ if (!$residualAnswer)
+ $residualAnswer = $answer;
+ } else {
+ $i--;
+ $isResidual = YES;
+ $residualAnswer = $answer;
+ }
+ }
+
+ /* add button ------------------------------------ */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_add_answers_button");
+ $input->addAttr("src", EVAL_PIC_ADD);
+
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $form->html("&nbsp;");
+ $form->cont($input);
+
+ /* add number of answers - list ------------------ */
+ $select = new HTM("select");
+ $select->attr("name", "template_add_num_answers");
+ $select->attr("size", "1");
+ $select->attr("style", "vertical-align:middle;");
+ for ($i = 1; $i <= 10; $i++) {
+ $option = new HTM("option");
+ $option->attr("value", $i);
+ $option->cont($i);
+ $select->cont($option);
+ }
+ $form->cont($select);
+
+ /* delete answers button --------------------------------- */
+ $input = new HTMpty("input");
+ $input->attr("type", "image");
+ $input->attr("name", "template_delete_answers_button");
+ $input->addAttr("src", EVAL_PIC_REMOVE);
+ $input->attr("border", "0");
+ $input->attr("style", "vertical-align:middle;");
+ $form->html("&nbsp;");
+ $form->cont($input);
+ $form->cont($this->BR);
+
+
+ }
+
+ }
+ if ($type == EVALQUESTION_TYPE_LIKERT || $type == EVALQUESTION_TYPE_POL) {
+ /* residual category ------------------------------------ */
+ $form->cont($this->createSubHeadline(_("Ausweichantwort") . ": "));
+
+ /* residual - radiobuttons ------------------------------ */
+ $radio = new HTMpty("input");
+ $radio->attr("type", "radio");
+ $radio->attr("name", "template_residual");
+ $radio->attr("value", YES);
+
+ $value = $isResidual ? "checked" : "unchecked";
+ $radio->attr($value);
+
+ $form->cont($radio);
+ $form->cont(_("ja") . ":");
+
+ /* residual text field -------------> */
+ $input = new HTMpty("input");
+ $input->attr("type", "text");
+ $input->attr("name", "template_residual_text");
+ if ($isResidual)
+ $input->attr("value", $residualAnswer->getText());
+ else
+ $input->attr("value", "");
+ $input->attr("size", 22);
+ $form->cont($input);
+ /* <------------- residual text field */
+ $form->cont($this->BR);
+ $radio = new HTMpty("input");
+ $radio->attr("type", "radio");
+ $radio->attr("name", "template_residual");
+ $radio->attr("value", NO);
+
+ $value = $value == "unchecked" ? "checked" : "unchecked";
+ $radio->attr($value);
+
+ $form->cont($radio);
+ $form->cont(_("nein"));
+ /*end: residual - radiobuttons -------------------- */
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_residual_id");
+ $input->attr("value", $residualAnswer->getObjectID);
+ $form->cont($input);
+ /*end: residual - kategorie -------------------- */
+ }
+ /* uebernehmen button ---------------------------- */
+ if ($onthefly == 1) {
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "cmd");
+ $input->attr("value", "QuestionAnswersCreated");
+ $form->cont($input);
+
+ $input = Button::create(_('Übernehmen'),
+ 'template_save2_button');
+ } else {
+ $input = Button::create(_('Übernehmen'),
+ 'template_save_button');
+ }
+
+ if (!mb_strstr($this->command, "create")) {
+ $showDelete = YES;
+ $input2 = Button::createAccept(_('Löschen'),
+ 'template_delete_button');
+ }
+
+ $table = new HTM("table");
+ $table->attr("border", "0");
+ $table->attr("align", "center");
+ $table->attr("cellspacing", "0");
+ $table->attr("cellpadding", "3");
+ $table->attr("width", "100%");
+ $tr = new HTM("tr");
+ $td = new HTM("td");
+ $td->attr("class", "content_body");
+ $td->attr("align", "center");
+ $td->cont($input);
+ $tr->cont($td);
+
+ if ($showDelete) {
+ $td = new HTM("td");
+ $td->attr("class", "content_body");
+ $td->attr("align", "center");
+ $td->cont($input2);
+ $tr->cont($td);
+ }
+
+ $table->cont($tr);
+ $form->cont($table);
+
+ /* ----------------------------------------------- */
+ $tdA->cont($form);
+ $trA->cont($tdA);
+ $tableA->cont($trA);
+ return $tableA;
+
+ }
+
+
+ /**
+ * Creates the form for the Polskala templates
+ * @param
+ */
+ public function createTemplateFormFree(&$question)
+ {
+ global $evalID;
+ $answer = $question->getNextChild();
+
+ $tableA = new HTM("table");
+ $tableA->attr("border", "0");
+ $tableA->attr("cellpadding", "2");
+ $tableA->attr("cellspacing", "0");
+ $tableA->attr("width", "100%");
+
+ $trA = new HTM("tr");
+ $tdA = new HTM("td");
+ $tdA->attr("class", "table_header_bold");
+ $tdA->attr("align", "left");
+ $tdA->html("<b>" . (mb_strstr($this->getPageCommand(), "create")
+ ? _("Freitextvorlage erstellen")
+ : _("Freitextvorlage bearbeiten")) . "</b>");
+ $trA->cont($tdA);
+ $tableA->cont($trA);
+
+ $trA = new HTM("tr");
+ $tdA = new HTM("td");
+ $form = new HTM("form");
+ $form->attr("action", URLHelper::getLink("?page=edit&evalID=" . $evalID));
+ $form->attr("method", "post");
+ $form->html(CSRFProtection::tokenTag());
+
+ $b = new HTM("b");
+ $b->cont(_("Name") . ": ");
+ $form->cont($b);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "text");
+ $input->attr("name", "template_name");
+ $name = $question->getText();
+ $input->attr("value", $question->getText());
+ // $input->attr( "value", $name );
+ $input->attr("style", "vertical-align:middle;");
+ $input->attr("size", 22);
+ $input->attr("maxlength", 22);
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_id");
+ $input->attr("value", $question->getObjectID());
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_type");
+ $input->attr("value", $question->getType());
+ $form->cont($input);
+
+ $input = new HTMpty("input");
+ $input->attr("type", "hidden");
+ $input->attr("name", "template_multiple");
+ $input->attr("value", NO);
+ $form->cont($input);
+
+ $img = new HTMpty("img");
+ $img->attr("src", Icon::create('info-circle', 'inactive')->asImagePath(16));
+ $img->attr("class", "middle");
+ $img->stri(tooltip(_("Geben Sie hier einen Namen für Ihre Vorlage ein. Ändern Sie den Namen, um eine neue Vorlage anzulegen."),
+ FALSE, TRUE));
+ $form->cont($img);
+ $form->cont($this->BR);
+
+ //$answer = $question->getNextChild();
+ //$answer->toString();
+ /* Anzahl Zeilen------------------------------------------------------ */
+ $form->cont($this->createSubHeadline(_("Anzahl Zeilen") . ": "));
+
+ $select = new HTM("select");
+ $select->attr("name", "template_add_num_answers");
+ $select->attr("size", "1");
+ $select->attr("style", "vertical-align:middle;");
+ for ($i = 1; $i <= 25; $i++) {
+ $option = new HTM("option");
+ $option->attr("value", $i);
+ $option->cont($i);
+ if ($i == $answer->getRows())
+ $option->addAttr("selected", "selected");
+ $select->cont($option);
+ }
+ $form->cont($select);
+ $form->cont($this->BR);
+
+ /* uebernehmen / loeschen Button ---------------------------- */
+ $input = Button::create(_('Übernehmen'),
+ 'template_savefree_button');
+ $odb = new EvaluationObjectDB();
+ //if($odb->getGlobalPerm()=="root"){
+ // $myuserid = 0;
+ //}
+ //else{
+ // $myuserid = $user->id;
+ //}
+ //if($question->getParentID()==$myuserid){
+ // $loesch=1;
+ if (!mb_strstr($this->command, "create")) {
+ $showDelete = YES;
+ $input2 = Button::createAccept(_('Löschen'),
+ 'template_delete_button');
+ }
+
+ $table = new HTM("table");
+ $table->attr("border", "0");
+ $table->attr("align", "center");
+ $table->attr("cellspacing", "0");
+ $table->attr("cellpadding", "3");
+ $table->attr("width", "100%");
+ $tr = new HTM("tr");
+ $td = new HTM("td");
+ $td->attr("class", "content_body");
+ $td->attr("align", "center");
+ $td->cont($input);
+ $tr->cont($td);
+
+ if ($showDelete) {
+ $td = new HTM("td");
+ $td->attr("class", "content_body");
+ $td->attr("align", "center");
+ $td->cont($input2);
+ $tr->cont($td);
+ }
+ $table->cont($tr);
+ $form->cont($table);
+
+ $tdA->cont($form);
+ $trA->cont($tdA);
+ $tableA->cont($trA);
+ return $tableA;
+ }
+
+
+ /**
+ * create a blue headline
+ */
+ public function createHeadline($text)
+ {
+ $div = new HTM("div");
+ $div->attr("class", "eval_title");
+ $div->attr("style", "margin-bottom:4px; margin-top:4px;");
+ $div->cont($text);
+ return $div;
+ }
+
+ /**
+ * create a fat-printed sub headline with some space
+ */
+ public function createSubHeadline($text)
+ {
+ $div = new HTM("div");
+ $div->attr("style", "margin-bottom:4px; margin-top:4px;");
+ $b = new HTM("b");
+ $b->cont($text);
+ $div->cont($b);
+ return $div;
+ }
+
+
+ /**
+ * creates the infobox
+ *
+ */
+ public function createInfoBox()
+ {
+ global $evalID, $rangeID;
+
+ if (get_Username($rangeID)) {
+ $rangeID = get_Username($rangeID);
+ }
+
+ if (empty($rangeID)) {
+ $rangeID = get_Username($user->id);
+ }
+
+ $actions = new ActionsWidget();
+ $actions->addLink(_('Vorschau der Evaluation'),
+ URLHelper::getURL('show_evaluation.php',
+ ['evalID' => $evalID,
+ 'isPreview' => YES]), Icon::create('question-circle', 'clickable'),
+ ['target' => $evalID,
+ 'onClick' => "openEval('" . $evalID . "'); return false;"]);
+ $actions->addLink(_('Zurück zur Evaluations-Verwaltung'), URLHelper::getURL('admin_evaluation.php',
+ ['page' => 'overview',
+ 'check_abort_creation_button' => '1',
+ 'evalID' => $evalID,
+ 'rangeID' => $rangeID]),
+ Icon::create('link-intern', 'clickable'));
+ Sidebar::Get()->addWidget($actions);
+ }
+
+
+# Define private functions ================================================== #
+
+ /**
+ * creates a new answer
+ *
+ * @access private
+ * @return array the created answer as an array with keys 'answer_id' => new md5 id,
+ * 'text' => "",
+ * 'counter' => 0,
+ * 'correct' => NO
+ */
+ public function makeNewAnswer()
+ {
+ return ['answer_id' => md5(uniqid(rand())),
+ 'text' => rand()
+ ];
+ }
+
+
+ /**
+ * deletes the answer at position 'pos' from the array 'answers'
+ * and modifies the array 'deleteAnswers' respectively
+ *
+ * @access public
+ * @param array &$answers the answerarray
+ * @param array &$deleteAnswers the array containing the deleteCheckbox-bool-value for each answer
+ * @param int $pos the position of the answer to be deleted
+ *
+ */
+ public function deleteAnswer($pos, &$answers, &$deleteAnswers)
+ {
+
+ unset($answers[$pos]);
+ if (is_array($deleteAnswers))
+ unset($deleteAnswers[$pos]);
+
+ for ($i = $pos; $i < count($answers); $i++) {
+
+ if (!isset($answers[$i])) {
+ $answers[$i] = $answers[$i + 1];
+ unset($answers[$i + 1]);
+ if (is_array($deleteAnswers)) {
+ $deleteAnswers[$i] = $deleteAnswers[$i + 1];
+ unset($deleteAnswers[$i + 1]);
+ }
+ }
+ }
+ return;
+ }
+
+ /**
+ * checks which button was pressed
+ *
+ * @access public
+ * @returns string the command "add_answers", "delete_answers", etc.
+ *
+ */
+ public function getPageCommand()
+ {
+ foreach ($_REQUEST as $key => $value) {
+ if (preg_match("/template_(.*)_button?/", $key, $command))
+ break;
+ }
+
+ $return_command = $command[1];
+
+ // extract the command if theres a questionID in the commandname
+ if (preg_match("/(.*)_#(.*)/", $return_command, $new_command))
+ $return_command = $new_command[1];
+
+
+ return $return_command;
+ }
+
+
+ /**
+ * Checks if a template with the same name already exists and modifies the
+ * text of the template if necessary.
+ * @param object $template The template
+ * @param object $db The EvaluationQuestionDB
+ * @param string $myuserid My userid
+ * @param boolean $rootTag If yes, add the root tag if necessary
+ * @access private
+ */
+ public function setUniqueName(&$question, $db, $myuserid, $rootTag = NO)
+ {
+ $text = $question->getText();
+
+ /* Add root tag if necessary ----------------------------------------- */
+ //if ($rootTag && $myuserid == "0" && !mb_strstr ($text, EVAL_ROOT_TAG))
+ // $question->setText ($text." ".EVAL_ROOT_TAG);
+ /* ------------------------------------------------- end: add root tag */
+
+ /* Remove root tag if necessary -------------------------------------- */
+ if ($myuserid != "0" && mb_strstr($text, EVAL_ROOT_TAG)) {
+ $question->setText(trim(implode("", explode(EVAL_ROOT_TAG, $text))));
+ }
+ /* ---------------------------------------------- end: remove root tag */
+
+ /* Change text if necessary with increasing number ------------------- */
+ $originalName = $question->getText();
+ for ($i = 1; $db->titleExists($question->getText(), $myuserid); $i++) {
+ $question->setText($originalName . " (" . $i . ")");
+ }
+ /* -------------------------------------------------- end: change text */
+ }
+
+# ==================================================== end: private functions #
+
+}
+
+# Define constants ========================================================== #
+/**
+ * @const EVAL_ROOT_TAG Specifies the string for taging root templates
+ * @access public
+ */
+define('EVAL_ROOT_TAG', "[R]");
+# ===================================================== end: define constants #
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once HTML;
+# ====================================================== end: including files #
diff --git a/lib/evaluation/evaluation_show.lib.php b/lib/evaluation/evaluation_show.lib.php
new file mode 100644
index 0000000..164ad11
--- /dev/null
+++ b/lib/evaluation/evaluation_show.lib.php
@@ -0,0 +1,424 @@
+<?php
+# Lifter002: TODO
+# Lifter007: TODO
+# Lifter003: TODO
+# Lifter010: TODO
+/**
+ * Library for evaluation participation page
+ *
+ * @author mcohrs <michael A7 cohrs D07 de>
+ * @copyright 2004 Stud.IP-Project
+ * @access public
+ * @package evaluation
+ * @modulegroup evaluation_modules
+ *
+ */
+
+// +---------------------------------------------------------------------------+
+// This file is part of Stud.IP
+// Copyright (C) 2001-2004 Stud.IP
+// +---------------------------------------------------------------------------+
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or any later version.
+// +---------------------------------------------------------------------------+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+// +---------------------------------------------------------------------------+
+
+use Studip\Button, Studip\LinkButton;
+
+class EvalShow
+{
+
+ /**
+ * createEvaluationHeader: generate the head of an evaluation (title and base text)
+ * @param the evaluation
+ * @returns a table row
+ */
+ function createEvaluationHeader( $eval, $votedNow, $votedEarlier )
+ {
+ $br = new HTMpty( "br" );
+
+ $tr = new HTM( "tr" );
+ $td = new HTM( "td" );
+ $td->attr( "class", "table_row_even" );
+
+ $table2 = new HTM( "table" );
+ $table2->attr( "width", "100%" );
+ $tr2 = new HTM( "tr" );
+ $td2 = new HTM( "td" );
+ $td2->attr( "width", "90%" );
+ $td2->attr( "valign", "top" );
+
+ if( $eval->isError() ) {
+ $td2->html( EvalCommon::createErrorReport ($eval, _("Fehler")) );
+ $td2->html( $br );
+ }
+
+ $span = new HTM( "span" );
+ $span->attr( "class", "eval_title" );
+ $span->html( htmlReady($eval->getTitle()) );
+ $td2->cont( $span );
+ $td2->cont( $br );
+
+ $td2->cont( $br );
+ if( $votedNow ) {
+ $message = new HTML('div');
+ $message->_content = [(string) MessageBox::success(_("Vielen Dank für Ihre Teilnahme."))];
+ $td2->cont($message);
+ } elseif( $votedEarlier ) {
+ $message = new HTML('div');
+ $message->_content = [(string) MessageBox::info(_("Sie haben an dieser Evaluation bereits teilgenommen."))];
+ $td2->cont($message);
+ } else {
+ $td2->html( formatReady($eval->getText()) );
+ $td2->cont( $br );
+ }
+ $tr2->cont( $td2 );
+ $voted = $votedNow || $votedEarlier;
+ $message = new HTML('div');
+ $message->_content = [(string)MessageBox::info(EvalShow::getAnonymousText($eval, $voted))];
+ $table2->cont($message);
+ $message = new HTML('div');
+ $message->_content = [(string)EvalShow::getStopdateText( $eval, $voted)];
+ $table2->cont($message);
+
+ if(!$voted && $GLOBALS["mandatories"] != 0) {
+ $message = new HTML('div');
+ $message->_content = [(string)sprintf(_("Mit %s gekennzeichnete Fragen müssen beantwortet werden."),
+ "<b><span class=\"eval_error\">**</span></b>")];
+ $table2->cont($message);
+ }
+
+
+
+ $td->cont( $table2 );
+ $tr->cont( $td );
+
+ return $tr;
+ }
+
+
+ /**
+ * createEvaluation: generate the evaluation itself (questions and answers)
+ * @param the evaluation
+ * @returns a table row
+ */
+ function createEvaluation( $tree ) {
+ $tr = new HTM( "tr" );
+ $td = new HTM( "td" );
+ $td->attr( "class", "table_row_even" );
+ $td->html( "<hr noshade=\"noshade\" size=\"1\">\n" );
+
+ ob_start();
+ $tree->showTree();
+ $html = ob_get_contents();
+ ob_end_clean();
+
+ $td->html( $html );
+ $td->setTextareaCheck();
+ $tr->cont( $td );
+
+ return $tr;
+ }
+
+
+
+ /**
+ * create html for the meta-information about an evaluation.
+ * @param Object $eval The evaluation
+ * @param bool $isAssociated whether the current user has used the eval
+ * @returns String a table row
+ */
+ function createEvalMetaInfo( $eval, $votedNow = NO, $votedEarlier = NO ) {
+ $html = "";
+ $stopdate = $eval->getRealStopdate();
+ $number = EvaluationDB::getNumberOfVotes( $eval->getObjectID() );
+ $voted = $votedNow || $votedEarlier;
+
+ $html .= "<div align=\"left\" style=\"margin-left:3px; margin-right:3px;\">\n";
+ $html .= "<hr noshade=\"noshade\" size=\"1\">\n";
+
+# $html .= $votedEarlier ? _("Sie haben an dieser Evaluation bereits teilgenommen.") : "";
+# $html .= $votedNow ? _("Vielen Dank für Ihre Teilnahme.") : "";
+# $html .= $voted ? "<hr noshade=\"noshade\" size=\"1\">\n" : "";
+
+ /* multiple choice? ----------------------------------------------------- */
+# if ($eval->isMultipleChoice()) {
+# $html .= ($voted || $eval->isStopped())
+# ? _("Sie konnten mehrere Antworten auswählen.")
+# : _("Sie können mehrere Antworten auswählen.");
+# $html .= " \n";
+# }
+ /* ---------------------------------------------------------------------- */
+
+ $html .= EvalShow::getNumberOfVotesText( $eval, $voted );
+ $html .= "<br>";
+ $html .= EvalShow::getAnonymousText( $eval, $voted );
+ $html .= "<br>";
+ $html .= EvalShow::getStopdateText( $eval, $voted );
+
+ $html .= "<br>\n";
+ $html .= "</div>\n";
+ /* ---------------------------------------------------------------------- */
+
+ /* create html tr object ------------------------------------------------ */
+ $tr = new HTM( "tr" );
+ $td = new HTM( "td" );
+ $td->attr( "align", "left" );
+ $td->attr( "style", "font-size:0.8em;" );
+ $td->html( $html );
+ $tr->cont( $td );
+ return $tr;
+ }
+
+
+ function getNumberOfVotesText( $eval, $voted ) {
+ $stopdate = $eval->getRealStopdate();
+ $number = EvaluationDB::getNumberOfVotes( $eval->getObjectID() );
+ $html = "";
+
+ /* Get number of participants ------------------------------------------- */
+ if( $stopdate < time() && $stopdate > 0 ) {
+ if ($number != 1)
+ $html .= sprintf (_("Es haben insgesamt <b>%s</b> Personen teilgenommen"), $number);
+ else
+ $html .= $voted
+ ? sprintf (_("Sie waren die einzige Person die teilgenommen hat"))
+ : sprintf (_("Es hat insgesamt <b>eine</b> Person teilgenommen"));
+ }
+ else {
+ if ($number != 1)
+ $html .= sprintf (_("Es haben bisher <b>%s</b> Personen teilgenommen"), $number);
+ else
+ $html .= $voted
+ ? sprintf (_("Sie waren bisher der/die einzige Person die teilgenommen hat"))
+ : sprintf (_("Es hat bisher <b>eine</b> Person teilgenommen"));
+ }
+ /* ---------------------------------------------------------------------- */
+
+ if ($voted && $number > 1)
+ $html .= _(", Sie ebenfalls");
+
+ $html .= ".\n";
+ return $html;
+ }
+
+ function getStopdateText( $eval, $voted ) {
+ $stopdate = $eval->getRealStopdate();
+ $html = "";
+
+ /* stopdate ------------------------------------------------------------- */
+ if (!empty ($stopdate)) {
+ if( $stopdate < time() ) {
+ $html .= sprintf (_("Die Evaluation wurde beendet am <b>%s</b> um <b>%s</b> Uhr."),
+ date ("d.m.Y", $stopdate),
+ date ("H:i", $stopdate));
+ }
+ else {
+ if( $voted ) {
+ $html .= sprintf (_("Die Evaluation wird voraussichtlich beendet am <b>%s</b> um <b>%s</b> Uhr."),
+ date ("d.m.Y", $stopdate),
+ date ("H:i", $stopdate));
+ }
+ else {
+ $html .= sprintf (_("Sie können teilnehmen bis zum <b>%s</b> um <b>%s</b> Uhr."),
+ date ("d.m.Y", $stopdate),
+ date ("H:i", $stopdate));
+ }
+ }
+ }
+ else {
+ $html .= _("Der Endzeitpunkt dieser Evaluation steht noch nicht fest.");
+ }
+ $html .= " \n";
+
+ return $html;
+ }
+
+ function getAnonymousText( $eval, $voted ) {
+ $stopdate = $eval->getRealStopdate();
+ $html = "";
+
+ /* Is anonymous --------------------------------------------------------- */
+ if( ($stopdate < time() && $stopdate > 0) ||
+ $voted )
+ $html .= ($eval->isAnonymous())
+ ? _("Die Teilnahme war anonym.")
+ : _("Die Teilnahme war <b>nicht</b> anonym.");
+ else
+ $html .= ($eval->isAnonymous())
+ ? _("Die Teilnahme ist anonym.")
+# : _("Die Teilnahme ist <b>nicht</b> anonym.");
+ : ("<span style=\"color:red;\">" .
+ _("Dies ist eine personalisierte Evaluation. Ihre Angaben werden verknüpft mit Ihrem Namen gespeichert.") .
+ "</span>");
+
+ return $html;
+ }
+
+
+ /**
+ * createEvaluationFooter: generate the foot of an evaluation (buttons etc.)
+ * @param the evaluation
+ * @returns a table row
+ */
+ function createEvaluationFooter( $eval, $voted, $isPreview ) {
+ global $auth;
+ if( $isPreview )
+ $voted = YES;
+
+ $br = new HTMpty( "br" );
+
+ $tr = new HTM( "tr" );
+ $td = new HTM( "td" );
+ $td->attr( "class", "content_body" );
+ $td->attr( "align", "center" );
+ $td->attr( "data-dialog-button","");
+ $td->cont( $br );
+
+ /* vote button */
+ if( ! $voted ) {
+ $button = Button::createAccept(_('Abschicken'),
+ 'voteButton',
+ ['title' => _('Senden Sie Ihre Antworten hiermit ab.'), 'data-dialog' => '']);
+ $td->cont( $button );
+ }
+
+ /* close button */
+ if (!Request::isXHR()) {
+ $button = new HTM( "p" );
+ $button->cont( _("Sie können dieses Fenster jetzt schließen.") );
+ $td->cont( $button );
+ }
+
+
+ /* reload button */
+ if( $isPreview ) {
+ $button = LinkButton::create(_('Aktualisieren'),
+ URLHelper::getURL('show_evaluation.php?evalID='.$eval->getObjectID().'&isPreview=1'),
+ ['title' => _('Vorschau aktualisieren.')]);
+ $td->cont( $button );
+ }
+
+ $td->cont( $br );
+ $td->cont( $br );
+
+ $tr->cont( $td );
+
+ return $tr;
+ }
+
+ function createVoteButton ($eval) {
+ $button = LinkButton::create(_('Anzeigen'),
+ URLHelper::getURL('show_evaluation.php?evalID=' .$eval->getObjectID().'&isPreview=' . NO),
+ ['title' => _('Evaluation anzeigen.'),
+ 'onClick' => 'openEval(\''.$eval->getObjectID().'\'); return false;']);
+ $div = new HTML ("div");
+ $div->addHTMLContent( $button );
+ return $div;
+
+ // keine Ahnung warum das hier nicht funktioniert, bekomme eine JS-Fehlermeldung :(
+
+ // <grusel> das da oben reicht ja auch :)
+
+ /*
+ $script = new HTML ("script");
+ $script->addAttr ("type", "text/javascript");
+ $script->addAttr ("language", "JavaScript");
+
+ $aScript = new HTML ("a");
+ $aScript->addAttr ("href", "javascript:void();");
+ $aScript->addAttr ("onClick",
+ "window.open(\'show_evaluation.php?evalID=".$eval->getObjectID ()."\', ".
+ "\'_blank\', ".
+ "\'width=790,height=500,scrollbars=yes,resizable=yes\');");
+ $aScript->addContent ("Teilnehmen"); // Eigentlich kommt hier ein button hin
+ $script->addContent ("document.write ('");
+ $script->addContent ($aScript);
+ $script->addContent ("');");
+
+ $noscript = new HTML ("noscript");
+ $aNoScript = new HTML ("a");
+ $aNoScript->addAttr ("href", "show_evaluation.php?evalID=".$eval->getObjectID ());
+ $aNoScript->addAttr ("target", "_blank");
+ $aNoScript->addContent ("Teilnehmen"); // Eigentlich kommt hier ein button hin
+ $noscript->addContent ($aNoScript);
+
+ $div = new HTML ("div");
+ $div->addContent ($script);
+ $div->addContent ($noscript);
+ $tr = new HTML ("tr");
+ $td = new HTML ("td");
+ $td->addContent($script);
+ $td->addContent($noscript);
+ $tr->addContent($td);
+ return $tr;
+ */
+ }
+
+ function createEditButton ($eval) {
+ $button = LinkButton::create(_('Bearbeiten'),
+ URLHelper::getURL(EVAL_FILE_ADMIN."?page=edit&evalID=".$eval->getObjectID()),
+ ['title' => _('Evaluation bearbeiten.')]);
+ return $button;
+ }
+
+ function createOverviewButton ($rangeID, $evalID) {
+ $button = LinkButton::create(_('Bearbeiten'),
+ URLHelper::getURL(EVAL_FILE_ADMIN."?rangeID=".$rangeID."&openID=".$evalID."#open"),
+ ['title' => _('Evaluationsverwaltung.')]);
+ return $button;
+ }
+
+ function createDeleteButton ($eval) {
+ $button = LinkButton::create(_('Löschen'),
+ URLHelper::getURL(EVAL_FILE_ADMIN."?evalAction=delete_request&evalID=".$eval->getObjectID ()),
+ ['title' => _('Evaluation löschen.')]);
+ return $button;
+ }
+
+ function createStopButton ($eval) {
+ $button = LinkButton::createCancel(_('Stop'),
+ URLHelper::getURL(EVAL_FILE_ADMIN."?evalAction=stop&evalID=".$eval->getObjectID ()),
+ ['title' => _('Evaluation stoppen.')]);
+ return $button;
+ }
+
+ function createContinueButton ($eval) {
+ $button = LinkButton::create(_('Fortsetzen'),
+ URLHelper::getURL(EVAL_FILE_ADMIN."?evalAction=continue&evalID=".$eval->getObjectID ()),
+ ['title' => _('Evaluation fortsetzen')]);
+ return $button;
+ }
+
+ function createExportButton ($eval) {
+ $button = LinkButton::create(_('Export'),
+ URLHelper::getURL(EVAL_FILE_ADMIN."?evalAction=export_request&evalID=".$eval->getObjectID ()),
+ ['title' => _('Evaluation exportieren.')]);
+ return $button;
+ }
+
+ function createReportButton($eval) {
+ return LinkButton::create(_('Auswertung'), URLHelper::getURL("eval_summary.php?eval_id=" . $eval->getObjectID()), ['title' => _('Auswertung')]);
+ }
+
+ /* ----------------------------------------------------------------------- */
+}
+
+# Define constants ========================================================== #
+# ===================================================== end: define constants #
+
+
+# Include all required files ================================================ #
+require_once 'lib/evaluation/evaluation.config.php';
+require_once HTML;
+require_once EVAL_LIB_COMMON;
+# ====================================================== end: including files #