diff options
| author | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
|---|---|---|
| committer | Philipp Schüttlöffel <schuettloeffel@zqs.uni-hannover.de> | 2024-09-24 10:53:31 +0200 |
| commit | 4459dd7917f4d1c34f40bb68f0e991e9c3d53e4c (patch) | |
| tree | 5c07151ae61276d334e88f6309c30d439a85c12e /lib/evaluation/classes | |
| parent | da0022e5c1abbf9825ae76debaabdff7e8623bb4 (diff) | |
| parent | 97a188592c679890a25c37ab78463add76a52ff7 (diff) | |
Merge branch 'main' into issue-3911issue-3911
Diffstat (limited to 'lib/evaluation/classes')
18 files changed, 0 insertions, 8179 deletions
diff --git a/lib/evaluation/classes/Evaluation.class.php b/lib/evaluation/classes/Evaluation.class.php deleted file mode 100644 index 5f269a7..0000000 --- a/lib/evaluation/classes/Evaluation.class.php +++ /dev/null @@ -1,539 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EVALDB; -require_once EVAL_FILE_OBJECT; -require_once EVAL_FILE_GROUP; -# ====================================================== end: including files # - - -# Define all required constants ============================================= # -/** - * @const INSTANCEOF_EVAL Is instance of an evaluation object - * @access public - */ -define("INSTANCEOF_EVAL", "Evaluation"); -# ===================================================== end: define constants # - - -/** - * The mainclass for an evaluation for the Stud.IP-project. - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class Evaluation extends EvaluationObject implements PrivacyObject -{ -# Define all required variables ============================================= # - /** - * Startdate - * @access private - * @var integer $startdate - */ - var $startdate; - - /** - * Stopdate - * @access private - * @var integer $stopdate - */ - var $stopdate; - - /** - * Timespan - * @access private - * @var integer $timespan - */ - var $timespan; - - /** - * Time of creation. Is set automatically. - * @access private - * @var integer $mkdate - */ - var $mkdate; - - /** - * Time of last change. Is set automatically. - * @access private - * @var integer $chdate - */ - var $chdate; - - /** - * Defines wheter the evaluation is anonymous - * @access private - * @var boolean $anonymous - */ - var $anonymous; - - /** - * Defines whether the evaluation is visible - * @access private - * @var boolean $visible - */ - var $visible; - - /** - * Defines whether the evaluation template is shared - * @access private - * @var boolean $shared - */ - var $shared; - - /** - * Counts the number of connected ranges - * @access private - * @var integer $numberRanges - */ - var $numberRanges; - - /** - * Counts the number of connected ranges - * @access private - * @var integer $rangeNum - */ - var $rangeNum; - - /** - * Constructor - * @access public - * @param string $objectID The ID of an existing evaluation - * @param object $parentObject The parent object if exists - * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN - */ - public function __construct($objectID = "", $parentObject = null, $loadChildren = EVAL_LOAD_NO_CHILDREN) - { - parent::__construct($objectID, $parentObject, $loadChildren); - $this->instanceof = INSTANCEOF_EVAL; - - $this->rangeID = []; - $this->startdate = NULL; - $this->stopdate = NULL; - $this->timespan = NULL; - $this->mkdate = time(); - $this->chdate = time(); - $this->anonymous = NO; - $this->visible = NO; - $this->shared = NO; - $this->rangeNum = 0; - $this->db = new EvaluationDB (); - if ($this->db->isError()) { - return $this->throwErrorFromClass($this->db); - } - $this->init($objectID); - } - - /** - * Sets the startdate - * @access public - * @param integer $startdate The startdate. - * @throws error - */ - public function setStartdate($startdate) - { - if (!empty ($startdate)) { - if (!empty ($this->stopdate) && $startdate > $this->stopdate) { - return $this->throwError(1, _("Das Startdatum ist nach dem Stoppdatum.")); - } - if ($startdate <= 0) { - return $this->throwError(1, _("Das Startdatum ist leider ungültig.")); - } - } - $this->startdate = $startdate; - } - - /** - * Gets the startdate - * @access public - * @return integer The startdate - */ - public function getStartdate() - { - return $this->startdate; - } - - /** - * Sets the stopdate - * @access public - * @param integer $stopdate The stopdate. - * @throws error - */ - public function setStopdate($stopdate) - { - if (!empty ($stopdate)) { - if ($stopdate <= 0) - return $this->throwError(1, _("Das Stoppdatum ist leider ungültig.")); - if ($stopdate < $this->startdate) - return $this->throwError(1, _("Das Stoppdatum ist vor dem Startdatum.")); - if (!empty ($this->timespan)) - $this->timespan = NULL; - } - $this->stopdate = $stopdate; - } - - /** - * Gets the stopdate - * @access public - * @return string The stopdate - */ - public function getStopdate() - { - return $this->stopdate; - } - - /** - * Gets the real stop date as a UNIX-timestamp (e.g. startdate + timespan) - * @access public - * @return integer The UNIX-timestamp with the real stopdate - */ - public function getRealStopdate() - { - $stopdate = $this->getStopdate(); - - if ($this->getTimespan() != NULL) - $stopdate = $this->getStartdate() + $this->getTimespan(); - - return $stopdate; - } - - /** - * Sets the timespan - * @access public - * @param string $timespan The timespan. - * @throws error - */ - public function setTimespan($timespan) - { - if (!empty ($timespan) && !empty ($this->stopdate)) - $this->stopdate = NULL; - $this->timespan = $timespan; - } - - /** - * Gets the timespan - * @access public - * @return string The timespan - */ - public function getTimespan() - { - return $this->timespan; - } - - /** - * Gets the creationdate - * @access public - * @return integer The creationdate - */ - public function getCreationdate() - { - return $this->mkdate; - } - - /** - * Gets the changedate - * @access public - * @return integer The changedate - */ - public function getChangedate() - { - return $this->chdate; - } - - /** - * Sets anonymous - * @access public - * @param string $anonymous The anonymous. - * @throws error - */ - public function setAnonymous($anonymous) - { - $this->anonymous = $anonymous == YES ? YES : NO; - } - - /** - * Gets anonymous - * @access public - * @return string The anonymous - */ - public function isAnonymous() - { - return $this->anonymous == YES ? YES : NO; - } - - /** - * Sets visible - * @access public - * @param string $visible The visible. - * @throws error - */ - public function setVisible($visible) - { - $this->visible = $visible == YES ? YES : NO; - } - - /** - * Gets visible - * @access public - * @return string The visible - */ - public function isVisible() - { - return $this->visible == YES ? YES : NO; - } - - /** - * Set shared for a public search - * @access public - * @param boolean $shared if true it is shared - */ - public function setShared($shared) - { - if ($shared == YES && $this->isTemplate() == NO) - return $this->throwError(1, _("Nur ein Template kann freigegeben werden")); - $this->shared = $shared == YES ? YES : NO; - } - - /** - * Is shared for a public search? - * @access public - * @return boolen true if it is shared template - */ - public function isShared() - { - return $this->shared == YES ? YES : NO; - } - - /** - * Is this evaluation a template? - * @access public - * @return boolen true if it is a template - */ - public function isTemplate() - { - return empty ($this->rangeID) ? YES : NO; - } - - /** - * Has a user used this evaluation? - * @access public - * @param string $userID Optional an user id - * @return string YES if a user used this evaluation - */ - public function hasVoted($userID = "") - { - return $this->db->hasVoted($this->getObjectID(), $userID); - } - - /** - * Removes a range from the object (not from the DB!) - * @access public - * @param string $rangeID The range id - */ - public function removeRangeID($rangeID) - { - $temp = []; - while ($oldRangeID = $this->getNextRangeID()) { - if ($oldRangeID != $rangeID) { - $temp[] = $oldRangeID; - } - } - $this->rangeID = $temp; - $this->numberRanges = count($temp); - } - - /** - * Removes all rangeIDs - * @access public - */ - public function removeRangeIDs() - { - while ($this->getRangeID()) ; - } - - /** - * Adds a rangeID - * @access public - * @param string $rangeID The rangeID - * @throws error - */ - public function addRangeID($rangeID) - { - $this->rangeID[] = $rangeID; - $this->numberRanges++; - } - - /** - * Gets the first rangeID and removes it - * @access public - * @return string The first object - */ - public function getRangeID() - { - if ($this->numberRanges) - $this->numberRanges--; - return array_pop($this->rangeID); - } - - /** - * Gets the next rangeID - * @access public - * @return string The rangeID - */ - public function getNextRangeID() - { - if ($this->rangeNum >= $this->numberRanges) { - $this->rangeNum = 0; - return NULL; - } - return $this->rangeID[$this->rangeNum++]; - } - - /** - * Gets all the rangeIDs from the evaluation - * @access public - * @return array An array full of rangeIDs - */ - public function getRangeIDs() - { - return $this->rangeID; - } - - /** - * Gets the number of ranges - * @access public - * @return integer Number of ranges - */ - public function getNumberRanges() - { - return $this->numberRanges; - } - - /** - * Resets all answers for this evaluation - * @access public - */ - public function resetAnswers() - { - // Für diesen Mist habe ich jetzt ca. 3 Stunden gebraucht :( - $answers = $this->getSpecialChildobjects($this, INSTANCEOF_EVALANSWER); - - $number = count($answers); - for ($i = 0; $i < $number; $i++) { - $answer = &$answers[$i]; -#while ($answer->getUserID ()); // delete users... - $answer->db->resetVotes($answer); - } - - } - - /** - * Export available data of a given user into a storage object - * (an instance of the StoredUserData class) for that user. - * - * @param StoredUserData $storage object to store data into - */ - public static function exportUserData(StoredUserData $storage) - { - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval WHERE author_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('Evaluation'), 'eval', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM evalanswer_user WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationAnswerUser'), 'evalanswer_user', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval_group_template WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationGroupTemplate'), 'eval_group_template', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval_templates WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationTemplates'), 'eval_templates', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval_templates_user WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationTemplatesUser'), 'eval_templates_user', $field_data); - } - - $field_data = DBManager::get()->fetchAll("SELECT * FROM eval_user WHERE user_id = ?", [$storage->user_id]); - if ($field_data) { - $storage->addTabularData(_('EvaluationUser'), 'eval_user', $field_data); - } - - } - - /** - * Sets the creationdate - * @access private - * @param integer $creationdate The creationdate. - * @throws error - */ - public function setCreationdate($creationdate) - { - $this->mkdate = $creationdate; - } - - /** - * Sets the changedate - * @access private - * @param integer $changedate The changedate. - * @throws error - */ - public function setChangedate($changedate) - { - $this->chdate = $changedate; - } - - /** - * Checks if object is in a valid state - * @access private - */ - public function check() - { - parent::check(); - if (empty ($this->title)) { - $this->throwError(1, _("Der Titel darf nicht leer sein.")); - } - - if ($this->isTemplate() && $this->hasVoted()) { - $this->throwError(2, _("Ungültiges Objekt: Bei einer Vorlage wurde abgestimmt.")); - } - - if (!$this->isTemplate() && $this->isShared()) { - $this->throwError(3, _("Ungültiges Objekt: Eine aktive Evaluation wurde freigegeben.")); - } - - } -} diff --git a/lib/evaluation/classes/EvaluationAnswer.class.php b/lib/evaluation/classes/EvaluationAnswer.class.php deleted file mode 100644 index 0116e3b..0000000 --- a/lib/evaluation/classes/EvaluationAnswer.class.php +++ /dev/null @@ -1,277 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * - */ - -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_ANSWERDB; -require_once EVAL_FILE_OBJECT; - -/** - * @const INSTANCEOF_EVALANSWER Is instance of an evaluationanswer object - * @access public - */ -define("INSTANCEOF_EVALANSWER", "EvaluationAnswer"); - -class EvaluationAnswer extends EvaluationObject -{ - - /** - * The value for an answer - * @access private - * @var integer $value ; - */ - var $value; - - /** - * If >0 the answer is a freetext with $rows rows - * @access private - * @var integer $rows - */ - var $rows; - - /** - * The userIDs of users who voted for this answer - * @access private - * @var array $users - */ - var $users; - - /** - * The number of users voted for this answer - * @access private - * @var integer $userNum - */ - var $userNum; - - /** - * For internal use (getNextUserID) - * @access private - * @var integer $userNumIterator - */ - var $userNumIterator; - - /** - * If true this is the residual answer for a question - * @access private - * @var boolean $residual - */ - var $residual; - - /** - * Constructor - * @access public - * @param string $objectID The ID of an existing answer - * @param object $parentObject The parent object if exists - * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN - */ - public function __construct($objectID = "", $parentObject = null, $loadChildren = EVAL_LOAD_NO_CHILDREN) - { - /* Set default values ------------------------------------------------- */ - parent::__construct($objectID, $parentObject, $loadChildren); - $this->instanceof = INSTANCEOF_EVALANSWER; - - $this->value = 0; - $this->rows = 0; - $this->users = []; - $this->userNum = 0; - $this->userNumIterator = 0; - $this->residual = NO; - - $this->db = new EvaluationAnswerDB (); - if ($this->db->isError()) { - return $this->throwErrorFromClass($this->db); - } - $this->init($objectID); - - } - - /** - * Gets the number of votes for this answer - * @access public - * @return string The counter of the answer - */ - public function getNumberOfVotes() - { - return $this->userNum; - } - - /** - * Gets the number of rows from freetext answers - * @access public - * @return integer The number of rows - */ - public function getRows() - { - return $this->rows; - } - - /** - * Gets the number of rows for freetext answers - * @access public - * @param integer $rows The number of rows - */ - public function setRows($rows) - { - $this->rows = $rows; - } - - /** - * Gets the value of an answer - * @access public - * @return integer The value - */ - public function getValue() - { - return $this->value;; - } - - /** - * Sets the value of an answer - * @access public - * @param integer $value The value - */ - public function setValue($value) - { - $this->value = $value; - } - - /** - * Checks whether the answer is a residual answer - * @access public - * @return boolean YES if it is a residual answer - */ - public function isResidual() - { - return $this->residual == YES ? YES : NO; - } - - /** - * Sets the answers as an residual answer - * @access public - * @param boolean $boolean YES to set it as a residual answer - */ - public function setResidual($boolean) - { - $this->residual = $boolean == YES ? YES : NO; - } - - /** - * Vote for this answer - * @access public - * @param string $userID The user id - */ - public function vote($userID) - { - $this->addUserID($userID); - } - - /** - * Non-Anonymous vote for this answer - * @access public - * @param string $userID The user id - */ - public function addUserID($userID) - { - if (empty ($userID)) { - return $this->throwError(1, _("Nur pseudonyme Abstimmung erlaubt! Neue ID mit StudipObject::createNewID () erzeugen")); - } - - $this->userNum++; - array_push($this->users, $userID); - } - - /** - * Gets the first user and removes it - * @access public - * @return string The first user id - */ - public function getUserID() - { - if ($this->userNum > 0) - $this->userNum--; - return array_pop($this->users); - } - - /** - * Gets the next user - * @access public - * @return string The next user id, otherwise NULL - */ - public function getNextUserID() - { - if ($this->userNumIterator >= $this->userNum) { - $this->userNumIterator = 0; - return NULL; - } - return $this->users[$this->userNumIterator++]; - } - - /** - * Gets all the user ids - * @access public - * @return array An array full of user ids - */ - public function getUserIDs() - { - return $this->users; - } - - /** - * @access public - * @return integer YES, if the Answer is a textfield - */ - public function isFreetext() - { - return ($this->rows == 0) ? NO : YES; - } - - /** - * Checks if object is in a valid state - * @access private - */ - public function check() - { - parent::check(); - } - - /** - * Debugfunction - * @access private - */ - public function toString() - { - parent::toString(); - echo "Anzahl der Stimmen: " . $this->getNumberOfVotes() . "<br>\n"; - } -} diff --git a/lib/evaluation/classes/EvaluationExportManager.class.php b/lib/evaluation/classes/EvaluationExportManager.class.php deleted file mode 100644 index 0c88e7f..0000000 --- a/lib/evaluation/classes/EvaluationExportManager.class.php +++ /dev/null @@ -1,267 +0,0 @@ -<?php -# Lifter002: TEST -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EVALDB; -require_once EVAL_FILE_ANSWERDB; -require_once EVAL_FILE_OBJECT; -require_once EVAL_FILE_GROUP; - -/** - * @const INSTANCEOF_EVALEXPORTMANAGER Is instance of an export manager - * @access public - */ -define("INSTANCEOF_EVALEXPORTMANAGER", "EvaluationExportManager"); - -/** - * @const EVALEXPORT_PREFIX The prefix for temporary filenames - * @access public - */ -define("EVALEXPORT_PREFIX", "evaluation"); - -/** - * @const EVALEXPORT_LIFETIME The lifetime in seconds for temporary files - * @access public - */ -define("EVALEXPORT_LIFETIME", 1800); - - -/** - * The mainclass for the evaluation export manager - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationExportManager extends AuthorObject -{ - - /** - * The temporary filename - * @access private - * @var string $filename - */ - public $filename; - - /** - * The filehandle for the temporary filename - * @access private - * @public integer $filehandle - */ - public $filehandle; - - /** - * The ID for the evaluation to export - * @access private - * @var string $evalID - */ - public $evalID; - - /** - * The evaluation to export - * @access private - * @var object Evaluation $eval - */ - public $eval; - - /** - * Array full of questionobjects - * @access private - * @var array $evalquestions - */ - public $evalquestions; - - /** - * The extension for the FILENAME - * @access private - * @var string $extension - */ - public $extension; - - /** - * UserIDs of all persons which used the evaluation - * @access private - * @var array $users - */ - public $users; - - /** - * Constructor - * @access public - * @param string $evalID The ID of the evaluation for export - */ - public function __construct($evalID) - { - register_shutdown_function([&$this, "_EvaluationExportManager"]); - - parent::__construct(); - $this->instanceof = INSTANCEOF_EVALEXPORTMANAGER; - - $this->filename = ""; - $this->filehandle = ""; - $this->evalID = $evalID; - $this->eval = new Evaluation ($evalID, NULL, EVAL_LOAD_FIRST_CHILDREN); - $this->evalquestions = []; - $this->extension = EVALEXPORT_EXTENSION; - - $this->createNewFile(); - $this->getQuestionobjects($this->eval); - /* -------------------------------------------------------------------- */ - } - - /** - * Destructor. Closes all files and removes old temp files - * @access public - */ - public function _EvaluationExportManager() - { - $this->closeFile(); - $this->cleanUp(); - } - - /** - * Returns the temnporary filename - * @access public - * @returns string The temporary filename - */ - public function getTempFilename() - { - return $this->filename; - } - - /** - * Exports the evaluation - * @access public - */ - public function export() - { - if (empty ($this->filehandle)) { - return $this->throwError(1, _("ExportManager::Konnte temporäre Datei nicht öffnen.")); - } - - if (!$this->eval->isAnonymous()) { - $this->users = EvaluationDB::getUserVoted($this->eval->getObjectID()); - } else { - $questions = $this->eval->getSpecialChildobjects($this->eval, INSTANCEOF_EVALQUESTION); - $questionIDs = []; - foreach ($questions as $question) { - array_push($questionIDs, $question->getObjectID()); - } - $this->users = EvaluationDB::getUserVoted($this->eval->getObjectID(), null, $questionIDs); - } - - if (empty ($this->users)) { - return $this->throwError(1, _("ExportManager::Es haben noch keine Benutzer abgestimmt oder angegebene Evaluation existiert nicht.")); - } - } - - /** - * Gets the filname for the user - * @access public - */ - public function getFilename() - { - return (rawurlencode($this->eval->getTitle()) . "." . $this->extension); - } - - /** - * Gets all questionobjects of the evaluation - * @access private - * @param EvaluationObject &$object An evaluationobject object - */ - public function getQuestionobjects(&$object) - { - if ($object->x_instanceof() == INSTANCEOF_EVALQUESTION) { - array_push($this->evalquestions, $object); - } else { - while ($child = $object->getNextChild()) { - $this->getQuestionobjects($child); - } - } - } - - /** - * Closes all opened files - * @access public - */ - public function closeFile() - { - if (empty($this->filehandle)) { - return $this->throwError(1, _("ExportManager::Konnte temporäre Datei nicht schließen.")); - } - - fclose($this->filehandle); - } - - /** - * Removes old temporary files - * @access private - */ - public function cleanUp() - { - if (empty ($this->filehandle)) { - return $this->throwError(1, _("ExportManager::Konnte temporäre Datei nicht öffnen.")); - } - - $dirhandle = dir($GLOBALS['TMP_PATH']); - while (($file = $dirhandle->read()) != false) { - $file = $GLOBALS['TMP_PATH'] . "/" . $file; - $part = pathinfo($file); - - if (filemtime($file) < (time() - EVALEXPORT_LIFETIME) && - $part["extension"] == $this->extension && - mb_substr($part["basename"], 0, mb_strlen(EVALEXPORT_PREFIX)) == EVALEXPORT_PREFIX) - unlink($file); - } - $dirhandle->close(); - } - - /** - * Creates a new temporary file - * @access public - */ - public function createNewFile() - { - $randomID = StudipObject::createNewID(); - $this->filename = $randomID . "." . $this->extension; - if (!is_dir($GLOBALS['TMP_PATH'])) { - return $this->throwError(1, sprintf(_("ExportManager::Das Verzeichnis %s existiert nicht."), $GLOBALS['TMP_PATH'])); - } - if (!is_writable($GLOBALS['TMP_PATH'])) { - return $this->throwError(2, sprintf(_("ExportManager::Das Verzeichnis %s ist nicht schreibbar nicht."), $GLOBALS['TMP_PATH'])); - } - - $this->filehandle = @fopen($GLOBALS['TMP_PATH'] . "/" . $this->filename, "w"); - - if (empty ($this->filehandle)) { - return $this->throwError(3, _("ExportManager::Konnte temporäre Datei nicht erstellen.")); - } - } - -} - diff --git a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php b/lib/evaluation/classes/EvaluationExportManagerCSV.class.php deleted file mode 100644 index 4baa3f8..0000000 --- a/lib/evaluation/classes/EvaluationExportManagerCSV.class.php +++ /dev/null @@ -1,341 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EXPORTMANAGER; -# ====================================================== end: including files # - - -# Define all required constants ============================================= # -/** - * @const INSTANCEOF_EVALEXPORTMANAGER Is instance of an export manager - * @access public - */ -define ("INSTANCEOF_EVALEXPORTMANAGERCSV", "EvaluationExportManagerCSV"); - -/** - * @const EVALEXPORT_SEPERATOR The seperator for values - * @access public - */ -define ("EVALEXPORT_SEPERATOR", ";"); - -/** - * @const EVALEXPORT_DELIMITER The delimiter for values - * @access public - */ -define ("EVALEXPORT_DELIMITER", "\""); - -/** - * @const EVALEXPORT_NODELIMITER Character to substitute the delimiter in a text - * @access public - */ -define ("EVALEXPORT_NODELIMITER", "'"); - -/** - * @const EVALEXPORT_ENDROW The characters to end a row - * @access public - */ -define ("EVALEXPORT_ENDROW", EVALEXPORT_DELIMITER.EVALEXPORT_DELIMITER."\n"); - -/** - * @const EVALEXPORT_EXTENSION The extension for the filenames - * @access public - */ -define ("EVALEXPORT_EXTENSION", "csv"); -# ===================================================== end: define constants # - - -/** - * The mainclass for the evaluation export manager - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationExportManagerCSV extends EvaluationExportManager { -# Define all required variables ============================================= # - var $evalquestions_residual = []; -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param string $evalID The ID of the evaluation for export - */ - function __construct($evalID) { - /* Set default values ------------------------------------------------- */ - register_shutdown_function([&$this, "_EvaluationExportManagerCSV"]); - ini_set('memory_limit', '256M'); - parent::__construct($evalID); - $this->instanceof = INSTANCEOF_EVALEXPORTMANAGERCSV; - - $this->extension = EVALEXPORT_EXTENSION; - /* -------------------------------------------------------------------- */ - } - - /** - * Destructor. Closes all files and removes old temp files - * @access public - */ - function _EvaluationExportManagerCSV () { - - } -# =========================================== end: constructor and destructor # - - -# Define public functions =================================================== # - /** - * Exports the evaluation - * @access public - */ - function export () { - parent::export (); - if ($this->isError ()) - return; - $this->exportHeader (); - $this->exportContent(); - } - - /** - * Exports the headline - * @access public - */ - function exportHeader () { - if (empty ($this->filehandle)) - return $this->throwError (1, _("ExportManager::Konnte temporäre Datei nicht öffnen.")); - fputs ($this->filehandle, "\xEF\xBB\xBF"); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Nummer") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Datum") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Benutzername") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Nachname") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("Vorname") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . _("E-Mail") . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - - /* for each question -------------------------------------------------- */ - foreach ($this->evalquestions as $evalquestion) { - $type = $evalquestion->getType (); - $residual = ""; - - /* Questiontype: likert scale -------------------------------------- */ - if ($type == EVALQUESTION_TYPE_LIKERT) { - EvaluationAnswerDB::addChildren($evalquestion); - $header = $evalquestion->getText ().":"; - while ($answer = &$evalquestion->getNextChild ()) { - if ($answer->isResidual ()) { - $residual = $evalquestion->getText ().":".$answer->getText (); - } else { - $header .= $answer->getText (); - $header .= "(".$answer->getPosition ().")"; - $header .= ","; - } - } - $header = mb_substr ($header, 0, mb_strlen ($header) - 1); - - $this->addCol ($header); - - if (!empty ($residual)) { - $this->addCol ($residual); - $this->evalquestions_residual[$evalquestion->getObjectID()] = true; - } - /* ----------------------------------------------------- end: likert */ - - - /* Questiontype: pol scale ----------------------------------------- */ - } elseif ($type == EVALQUESTION_TYPE_POL) { - EvaluationAnswerDB::addChildren($evalquestion); - $header = $evalquestion->getText ().":"; - $answer = $evalquestion->getNextChild (); - $header .= $answer->getText (); - $header .= "(".$answer->getPosition ().")"; - $header .= "-"; - while ($answer = &$evalquestion->getNextChild ()) { - if ($answer->isResidual ()) - $residual = $evalquestion->getText ().":".$answer->getText (); - else - $last = $answer->getText ()."(".$answer->getPosition ().")"; - } - $header .= $last; - $this->addCol ($header); - if (!empty ($residual)) { - $this->addCol ($residual); - $this->evalquestions_residual[$evalquestion->getObjectID()] = true; - } - /* -------------------------------------------------------- end: pol */ - - - /* Questiontype: multiple chioice ---------------------------------- */ - } elseif ($type == EVALQUESTION_TYPE_MC) { - if ($evalquestion->isMultiplechoice ()) { - EvaluationAnswerDB::addChildren($evalquestion); - while ($answer = &$evalquestion->getNextChild ()) { - $header = $evalquestion->getText (); - $header .= ":".$answer->getText (); - $this->addCol ($header); - } - } else { - $header = $evalquestion->getText (); - $this->addCol ($header); - } - /* --------------------------------------------------------- end: mc */ - - - /* Questiontype: undefined ----------------------------------------- */ - } else { - return $this->throwError (2, _("ExportManager::Ungültiger Typ.")); - } - /* -------------------------------------------------- end: undefined */ - } - /* ---------------------------------------------- end: foreach question */ - - fputs ($this->filehandle, EVALEXPORT_ENDROW); - } - - /** - * Exports the content - * @access public - */ - function exportContent () { - $counter = 0; - $answers = []; - $db = DBManager::get(); - $stmt = $db->prepare("SELECT user_id,text,value,position,residual, - MAX(evaldate) as evaldate, - GROUP_CONCAT(evalanswer_id) as evalanswer_id - FROM evalanswer - INNER JOIN evalanswer_user - USING ( evalanswer_id ) - WHERE parent_id = ? GROUP BY user_id"); - foreach ($this->evalquestions as $evalquestion) { - $stmt->execute([$evalquestion->getObjectID()]); - $answers[$evalquestion->getObjectID()] = $stmt->fetchGrouped(); - } - - /* One row for each user --------------------------------------------- */ - foreach ($this->users as $userID) { - - /* Userinformation if available ----------------------------------- */ - $username = ""; - $name = ""; - $surname = ""; - $email = ""; - $evaldate = ""; - if (!$this->eval->isAnonymous ()) { - $data = DBManager::get()->query("SELECT username, Vorname, Nachname, Email " - . "FROM auth_user_md5 WHERE user_id = " - . DBManager::get()->quote($userID))->fetchAll(PDO::FETCH_NUM); - if (is_array($data[0])) { - list($username, $name, $surname, $email) = $data[0]; - } - } - if ($timestamp = $answers[$this->evalquestions[0]->getObjectID()][$userID]['evaldate']) { - $evaldate = date('Y-m-d H:i:s', $timestamp); - } - fputs ($this->filehandle, EVALEXPORT_DELIMITER . ++$counter . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $evaldate . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $username . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $surname . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $name . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - fputs ($this->filehandle, EVALEXPORT_DELIMITER . $email . EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - - /* ------------------------------------------------- end: user info */ - - /* One colum for each question ------------------------------------ */ - foreach ($this->evalquestions as $evalquestion) { - $type = $evalquestion->getType (); - - /* Questiontype: pol or likert scale --------------------------- */ - if ($type == EVALQUESTION_TYPE_LIKERT || - $type == EVALQUESTION_TYPE_POL) { - $hasResidual = $this->evalquestions_residual[$evalquestion->getObjectID()]; - $entry = ""; - $residual = 0; - if ($answer = $answers[$evalquestion->getObjectID()][$userID]) { - if ($answer['residual']) { - $residual = 1; - } else { - $entry = $answer['position']; - } - } - $this->addCol ($entry); - - if ($hasResidual) { - $this->addCol ($residual); - } - } - /* ------------------------------------------------- end: likert */ - - - /* Questiontype: multiple chioice ------------------------------ */ - elseif ($type == EVALQUESTION_TYPE_MC) { - if ($evalquestion->isMultiplechoice ()) { - $mc_answers = explode(',', $answers[$evalquestion->getObjectID()][$userID]['evalanswer_id']); - while ($answer = &$evalquestion->getNextChild ()) { - $this->addCol ((int)in_array($answer->getObjectID(), $mc_answers)); - } - } else { - $entry = ""; - if ($answer = $answers[$evalquestion->getObjectID()][$userID]) { - $entry = preg_replace ("(\r\n|\n|\r)", " ", $answer['text']); - } - $this->addCol ($entry); - } - } - /* ------------------------------------------------------ end: mc */ - - - /* Questiontype: undefined -------------------------------------- */ - else { - return $this->throwError (1, _("ExportManager::Ungültiger Fragetyp.")); - } - /* ----------------------------------------------- end: undefined */ - } - /* ------------------------------------------ end: col for question */ - - fputs ($this->filehandle, EVALEXPORT_ENDROW); - } - /* -------------------------------------------- end: row for each user */ - } -# ===================================================== end: public functions # - -# Define private functions ================================================== # - /** - * Adds a row for the text - * @param string $text The text for the row - * @access private - */ - function addCol ($text) { - $col = str_replace (EVALEXPORT_DELIMITER, EVALEXPORT_NODELIMITER, $text); - fputs ($this->filehandle, EVALEXPORT_DELIMITER.$col.EVALEXPORT_DELIMITER.EVALEXPORT_SEPERATOR); - } -# ==================================================== end: private functions # - -} - -?> diff --git a/lib/evaluation/classes/EvaluationGroup.class.php b/lib/evaluation/classes/EvaluationGroup.class.php deleted file mode 100644 index fbe84af..0000000 --- a/lib/evaluation/classes/EvaluationGroup.class.php +++ /dev/null @@ -1,193 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_GROUPDB; -require_once EVAL_FILE_OBJECT; -require_once EVAL_FILE_QUESTION; -# ====================================================== end: including files # - - -# Define constants ========================================================== # -/** - * @const INSTANCEOF_EVALGROUP Is instance of an evaluationgroup object - * @access public - */ -define ("INSTANCEOF_EVALGROUP", "EvaluationGroup"); -# ===================================================== end: define constants # - - -/** - * This class provides a group for an evaluation for the Stud.IP-project. - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ - -class EvaluationGroup extends EvaluationObject { - -#Define all required variables ============================================= # - /** - * Possible Type of thechildren - * @access private - * @var string $childType - */ - var $childType; - - /** - * Is it mandatory to answer sub questions - * @access private - * @var boolean $mandatory - */ - var $mandatory; - - /** - * ID of the templateID for the childs - * @access private - * @var string $templateID - */ - var $templateID; -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param string $objectID The ID of an existing group - * @param EvaluationObject $parentObject The parent object if exists - * @param string $loadChildren See const EVAL_LOAD_*_CHILDREN - */ - function __construct($objectID = "", $parentObject = null, - $loadChildren = EVAL_LOAD_NO_CHILDREN) { - /* Set default values ------------------------------------------------- */ - parent::__construct($objectID, $parentObject, $loadChildren); - $this->instanceof = INSTANCEOF_EVALGROUP; - - $this->childType = NULL; - $this->mandatory = NO; - /* --------------------------------------------------------------------- */ - - /* Connect to database ------------------------------------------------- */ - $this->db = new EvaluationGroupDB (); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - $this->init ($objectID); - /* --------------------------------------------------------------------- */ - } -# =========================================== end: constructor and destructor # - -# Define public functions =================================================== # - /** - * Returns wheter the childs are groups or questions - * @access public - */ - function getChildType () { - return $this->childType; - } - - /** - * Adds a child - * @access public - * @param object EvaluationObject &$child The child object - */ - function addChild (&$child) { - parent::addChild ($child); - $this->childType = $child->x_instanceof (); - } - - /** - * Defines which type of childs the group have - * @access public - * @param string $childType The child type - */ - function setChildType ($childType) { - $this->childType = $childType; - } - - /** - * Is it mandatory to answer sub questions - * @access public - * @param boolean $boolean true if it is mandatory - */ - function setMandatory ($boolean) { - $this->mandatory = $boolean == YES ? YES : NO; - } - - /** - * Is it mandatory to answer sub questions? - * @access public - * @return boolean YES if it is true, else NO - */ - function isMandatory () { - return $this->mandatory == YES ? YES : NO; - } - - /** - * Gets the template id - * @access public - * @return string The template id - */ - function getTemplateID () { - return $this->templateID; - } - - /** - * Sets the template id - * @access public - * @param string $templateID The template id - */ - function setTemplateID ($templateID) { - $newQuestionTexts = []; - -# if ($templateID == $this->templateID) -# return; // for performance reasons - - $this->templateID = $templateID; - - while ($child = &$this->getChild ()) { - array_push ($newQuestionTexts, $child->getText ()); - $child->delete (); - } - - while ($text = array_pop ($newQuestionTexts)) { - $template = new EvaluationQuestion ($templateID, NULL, - EVAL_LOAD_ALL_CHILDREN); - $child = &$template->duplicate (); - $child->setText ($text); - $this->addChild ($child); - } - } -# ======================================================= end: public nctions # - - -# Define private functions ================================================== # -# ==================================================== end: private functions # -} - -?> diff --git a/lib/evaluation/classes/EvaluationObject.class.php b/lib/evaluation/classes/EvaluationObject.class.php deleted file mode 100644 index e42dfb0..0000000 --- a/lib/evaluation/classes/EvaluationObject.class.php +++ /dev/null @@ -1,530 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -# ====================================================== end: including files # - - -# Define constants ========================================================== # -/** - * @const INSTANCEOF_EVALOBJECT Is instance of an abstrakt evaluation object - * @access public - */ -define ("INSTANCEOF_EVALOBJECT", "EvaluationObject"); - -/** - * @const EVAL_LOAD_NO_CHILDREN Load no children from DB - * @access public - */ -define ("EVAL_LOAD_NO_CHILDREN", 0); - -/** - * @const EVAL_LOAD_FIRST_CHILDREN Load just the direct children from DB - * @access public - */ -define ("EVAL_LOAD_FIRST_CHILDREN", 1); - -/** - * @const EVAL_LOAD_ALL_CHILDREN Load all children from DB - * @access public - */ -define ("EVAL_LOAD_ALL_CHILDREN", 2); - -/** - * @const EVAL_LOAD_ONLY_EVALGROUP Load just the groups for performance reasons - * @access public - */ -define ("EVAL_LOAD_ONLY_EVALGROUP", 3); -# ===================================================== end: define constants # - - -/** - * This abstract class provides functions for evaluation objects - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationObject extends StudipObject { -# Define all required variables ============================================= # - /** - * The parent object - * @access private - * @var string $parentObject - */ - var $parentObject; - - /** - * The parent object id - * @access private - * @var string $parentObjectCD - */ - var $parentObjectID; - - /** - * Array with all linked childobjects - * @access private - * @var array $childObjects - */ - var $childObjects; - - /** - * Counts the number of childs - * @access private - * @var integer $numberChildren - */ - var $numberChildren; - - /** - * Title of the group - * @access private - * @var integer $title - */ - var $title; - - /** - * Text of the group - * @access private - * @var integer $text - */ - var $text; - - /** - * Position of this group in parent object - * @access private - * @var integer $position - */ - var $position; - - /** - * Holds the DB object - * @access private - * @var object DatabaseObject $db - */ - var $db; - - /** - * Is used as a counter for getNextChild ) - * @access private - * @var integer $childNum - */ - var $childNum; - - /** - * Defines how many children to load. See EVAL_LOAD_*_CHILDREN - * @access private - * @var integer $loadChildren - */ - var $loadChildren; -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @param string $objectID The ID of an existing object - * @param EvaluationObject $parentObject The parent object - * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN - * @access public - */ - function __construct($objectID = "", $parentObject = NULL, - $loadChildren = EVAL_LOAD_NO_CHILDREN) { - - /* Set default values -------------------------------------------------- */ - parent::__construct($objectID); - $this->instanceof = INSTANCEOF_EVALOBJECT; - - $this->parentObject = $parentObject; - $this->loadChildren = $loadChildren; - $this->db = NULL; - $this->childObjects = []; - $this->numberChildren = 0; - $this->title = ""; - $this->text = ""; - $this->position = 0; - $this->childNum = 0; - /* --------------------------------------------------------------------- */ - } -# =========================================== end: constructor and destructor # - - -# Define public functions =================================================== # - /** - * Sets the title - * @access public - * @param string $title The title. - * @throws error - */ - function setTitle ($title) { - $this->title = $title; - } - - /** - * Gets the title - * @access public - * @return string The title - */ - function getTitle () { - return $this->title; - } - - /** - * Sets the text - * @access public - * @param string $text The text. - * @throws error - */ - function setText ($text) { - $this->text = $text; - } - - /** - * Gets the text - * @access public - * @return string The text - */ - function getText () { - return $this->text; - } - - - /** - * Sets the position - * @access public - * @param string $position The position. - */ - function setPosition ($position) { - $this->position = $position; - } - - /** - * Gets the position - * @access public - * @return string The position - */ - function getPosition () { - return $this->position; - } - - /** - * Sets the parentObject - * @access public - * @param string &$parentObject The parentObject. - */ - function setParentObject (&$parentObject) { - $this->parentObject = &$parentObject; - $this->parentObjectID = $this->parentObject->getObjectID (); - } - - /** - * Gets the parentObject - * @access public - * @returns object The parentObject. - */ - function getParentObject () { - return $this->parentObject; - } - - /** - * Gets the parentObjectID - * @access public - * @returns string The parentObjectID - */ - function getParentID () { - return $this->parentObjectID; - } - - - /** - * Sets the parentObjectID - * @access public - * @param string $parentID The parent id - */ - function setParentID ($parentID) { - $this->parentObjectID = $parentID; - } - - /** - * Removes a child from the object (not from the DB!) - * @access public - * @param string $childID The child id - */ - function removeChildID ($childID) { - $temp = []; - $childRemoved = NO; - - while ($child = &$this->getNextChild ()) { - if ($childRemoved) - $child->setPosition ($child->getPosition () - 1); - - if ($child->getObjectID () != $childID) { - array_push ($temp, $child); - } else { - $childRemoved = YES; - } - } - - $this->childObjects = $temp; - - if ($childRemoved) - $this->numberChildren--; - } - - /** - * Adds a child - * @access public - * @param object EvaluationObject &$child The child object - */ - function addChild (&$child) { - $child->setPosition ($this->numberChildren++); - $child->setParentObject ($this); - array_push ($this->childObjects, $child); - } - - /** - * Gets the first child and removes it (if no id is given) - * @access public - * @param string $childID The child id - * @return object The first object - */ - function &getChild ($childID = "") { - if (!empty ($childID)) { - while ($child = $this->getNextChild ()) - if ($child->getObjectID () == $childID) { - $this->childNum = 0; - return $child; - } - $ret = null; - return $ret; - } else { - if ($this->numberChildren > 0) - $this->numberChildren--; - $ret = array_pop ($this->childObjects); - return $ret; - } - } - - /** - * Gets the next child - * @access public - * @return object The next object, otherwise NULL - */ - function &getNextChild () { - if ($this->childNum >= $this->numberChildren) { - $this->childNum = 0; - $ret = null; - return $ret; - } - return $this->childObjects[$this->childNum++]; - } - - /** - * Gets all the childs in the object - * @access public - * @return array An array full of childObjects - */ - function getChildren () { - return $this->childObjects; - } - - /** - * Gets the number of children - * @access public - * @return integer Number of children - */ - function getNumberChildren () { - return $this->numberChildren; - } - - /** - * Saves the object into the database - * @access public - */ - function save () { - /* Check own object --------------------------------------------------- */ - $this->check (); - if ($this->isError ()) - return; - /* --------------------------------------------------------- end: check */ - - /* save own object ---------------------------------------------------- */ - $this->db->save ($this); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - /* ----------------------------------------------- end: save own object */ - - /* save children ------------------------------------------------------ */ - while ($childObject = $this->getNextChild ()) { - $childObject->save (); - if ($childObject->isError ()) - return $this->throwErrorFromClass ($childObject); - } - /* ------------------------------------------------- end: save children */ - } - - /** - * Deletes the object from the database - * @access public - */ - function delete () { - /* remove id from parentobject if exists ------------------------------ */ - if (!empty ($this->parentObject)) { - $this->parentObject->removeChildID ($this->getObjectID ()); - } - /* ----------------------------------------- end: remove id from parent */ - - /* delete own object -------------------------------------------------- */ - $this->db->delete ($this); - /* --------------------------------------------- end: delete own object */ - - /* delete children ---------------------------------------------------- */ - while ($childObject = $this->getChild ()) { - $childObject->delete (); - if ($childObject->isError ()) - $this->throwErrorFromClass ($childObject); - } - /* ----------------------------------------------- end: delete children */ - } - - /** - * Duplicates the evaluation object. WARNING: Stored childs will be - * modified :( - * @access public - */ - function &duplicate () { - $newObject = $this; - $newObject->duplicate_init (); - return $newObject; - } -# ===================================================== end: public functions # - - -# Define private functions ================================================== # - /** - * Initialisation for duplicated objects - * @access private - */ - function duplicate_init () { - $this->init (); - while ($childObject =& $this->getNextChild ()) { - $childObject->setParentID ($this->getObjectID ()); - $childObject->duplicate_init (); - } - } - - /** - * Initialisation for objects - * @access private - * @param string $objectID The object id - */ - function init ($objectID = "") { - /* Load an evaluationobject or create a new one ----------------------- */ - if (empty ($objectID)) { - $this->setObjectID(self::createNewID()); - } else { - $this->setObjectID ($objectID); - $this->load (); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - } - /* -------------------------------------------------------------------- */ - - } - - /** - * Loads the Object from the database - * @access private - */ - function load () { - $this->db->load ($this); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - } - - /** - * Checks if object is in a valid state - * @access private - */ - function check () { - if (empty ($this->db)) - $this->throwError (1, _("Es existiert kein DB-Objekt")); - } - - /** - * Gets all children of a special kind - * @param EvaluationObject &$object the parent object - * @param string $instanceof instance of the searched child - * @param boolean $reset for internal use - * @access public - */ - function getSpecialChildobjects (&$object, $instanceof, $reset = false) { - static $specialchildobjects = []; - if ($reset == YES) { - $specialchildobjects = []; - } - - if ($object->x_instanceof () == $instanceof) { - array_push ($specialchildobjects, $object); - } else { - while ($child = &$object->getNextChild ()) { - $this->getSpecialChildobjects ($child, $instanceof, NO); - } - } - return $specialchildobjects; - } - - /** - * Debugfunction - * @access public - */ - function toString () { - echo "<table border=1 cellpadding=5><tr><td>"; - echo "Typ: ".$this->x_instanceof ()."<br>"; - echo "ObjectID: ".$this->getObjectID ()."<br>"; - echo "ParentID: ".$this->getParentID ()."<br>"; - echo "ParentObject: ".$this->getParentObject ()."<br>"; - echo "Author: ".$this->getAuthorID ()."<br>"; - echo "Titel: ".$this->getTitle ()."<br>"; - echo "Text: ".$this->getText ()."<br>"; - echo "Position: ".$this->getPosition ()."<br>"; - echo "Untergruppen: ".$this->getNumberChildren ()."<br>"; - echo "</td></tr>"; - $i = 0; - while ($child = $this->getNextChild ()) { - echo "<tr><td>"; - $i++; - echo "<b>Kind $i</b>"."<br>"; - $child->toString (); - echo "</td></tr>"; - } - echo "</table>"; - } -# ==================================================== end: private functions # - -} - -?> diff --git a/lib/evaluation/classes/EvaluationQuestion.class.php b/lib/evaluation/classes/EvaluationQuestion.class.php deleted file mode 100644 index c3c1da3..0000000 --- a/lib/evaluation/classes/EvaluationQuestion.class.php +++ /dev/null @@ -1,179 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * -*/ - -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_QUESTIONDB; -require_once EVAL_FILE_OBJECT; -require_once EVAL_FILE_ANSWER; -# ====================================================== end: including files # - - -# Define constants ========================================================== # -/** - * @const INSTANCEOF_EVALGROUP Is instance of an evaluationquestion object - * @access public - */ -define ("INSTANCEOF_EVALQUESTION", "EvaluationQuestion"); - -/** - * @const EVALQUESTION_TYPE_LIKERT Type of question is skala - * @access public - */ -define ("EVALQUESTION_TYPE_LIKERT", "likertskala"); - -/** - * @const EVALQUESTION_TYPE_MC Type of question is normal - * @access public - */ -define ("EVALQUESTION_TYPE_MC", "multiplechoice"); - -/** - * @const EVALQUESTION_TYPE_POL Type of question is pol - * @access public - */ -define ("EVALQUESTION_TYPE_POL", "polskala"); -# ===================================================== end: define constants # - - -class EvaluationQuestion extends EvaluationObject { - -# Define all required variables ============================================= # - /** - * Type of question (skala/normal) => see EVALQUESTION_TYPE_* - * @access private - * @var string $type - */ - var $type; - - /** - * If set YES it is allowed to choose more than one answer - * @access private - * @var string $isMultiplechoice - */ - var $isMultiplechoice; - - var $templateID; - -# ============================================================ end: variables # - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param string $objectID The ID of an existing question - * @param object $parentObject The parent object if exists - * @param integer $loadChildren See const EVAL_LOAD_*_CHILDREN - */ - function __construct($objectID = "", $parentObject = NULL, - $loadChildren = EVAL_LOAD_NO_CHILDREN) { - /* Set default values ------------------------------------------------- */ - parent::__construct($objectID, $parentObject, $loadChildren); - $this->instanceof = INSTANCEOF_EVALQUESTION; - - $this->type = EVALQUESTION_TYPE_MC; - $this->isMultiplechoice = NO; - $this->templateID = YES; - /* ------------------------------------------------------------------- */ - - /* Connect to database ------------------------------------------------- */ - $this->db = new EvaluationQuestionDB (); - if ($this->db->isError ()) - return $this->throwErrorFromClass ($this->db); - $this->init ($objectID); - /* --------------------------------------------------------------------- */ - } -# =========================================== end: constructor and destructor # - - -# Define public functions =================================================== # - /** - * Sets the type of a question - * @access public - * @param string $type The type of the question. ('skala','normal','pol') - */ - function setType ($type) { - $this->type = $type; - } - - /** - * Sets the type of a question - * @access public - * @return string The type of the question.('likert','multiplechoice','pol') - */ - function getType () { - return $this->type; - } - - - /** - * Sets multiplechoice value of a question - * @access public - * @param $tinyint The multiplechoice Value. - */ - function setMultiplechoice ($multiplechoice) { - $this->isMultiplechoice = $multiplechoice == YES ? YES : NO; - } - - /** - * Checks for multiplechoice - * @access public - * @return boolean YES if it is an multiplechoice question - */ - function isMultiplechoice () { - return $this->isMultiplechoice == YES ? YES : NO; - } - - - /** - * Adds a child and sets the value to pos+1 - * @access public - * @param object EvaluationObject &$child The child object - * @throws error - */ - function addChild (&$child) { - parent::addChild ($child); - if ($child->getValue () == 0) - $child->setValue ($child->getPosition () + 1); - } -# ===================================================== end: public functions # - - -# Define private functions ================================================== # -# ==================================================== end: private functions # - -} - -?> diff --git a/lib/evaluation/classes/EvaluationTree.class.php b/lib/evaluation/classes/EvaluationTree.class.php deleted file mode 100644 index a369d69..0000000 --- a/lib/evaluation/classes/EvaluationTree.class.php +++ /dev/null @@ -1,166 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * The treeclass for an evaluation. - * - * @author mcohrs - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * - */ - -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_EVAL; -require_once EVAL_FILE_GROUP; -# ====================================================== end: including files # - - -class EvaluationTree extends TreeAbstract { -# Define all required variables ============================================= # - - /** - * Holds the Evaluation object - * @access public - * @var object Evaluation $eval - */ - var $eval; - - /** - * Holds the Evaluation ID - * @access public - * @var string $evalID - */ - var $evalID; - - /** - * Holds the eval constructor load mode - * @access public - * @var integer $load_mode - */ - var $load_mode; - - var $root_content; - -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - /** - * Constructor - * @access public - * @param array the eval's ID (optional - if not given, it must be in $_REQUEST). - */ - function __construct( $args ) { - - - if (isset($args['evalID'])) - $this->evalID = $args['evalID']; - else - $this->evalID = Request::option("evalID"); - - $this->load_mode = ($args['load_mode'] ? $args['load_mode'] : EVAL_LOAD_NO_CHILDREN); - if (empty($this->evalID)){ - print _("Fehler in EvaluationTree: Es wurde keine evalID übergeben"); - exit (); - } - - /* ------------------------------------------------------------------- */ - parent::__construct(); - } -# =========================================== end: constructor and destructor # - - -# Define public functions =================================================== # - - /** - * initializes the tree - * store rows from evaluation tables in array $tree_data - * @access public - */ - function init() { - /* create the evaluation -------------------> */ - $this->eval = new Evaluation( $this->evalID, NULL, $this->load_mode ); - $this->root_name = $this->eval->getTitle(); - $this->root_content = $this->eval->getText(); - - /* create the tree structure ---------------> */ - parent::init(); - - foreach( $this->eval->getChildren() as $group ) { - $this->recursiveInit( $group ); - - $this->tree_data[$group->getObjectID()]["text"] = $group->getText(); - $this->tree_data[$group->getObjectID()]["object"] = $group; - $this->storeItem( $group->getObjectID(), "root", - $group->getTitle(), $group->getPosition() ); - } - /* <---------------------------------------- */ - } - - - /** - * initialize the sub-groups. - * - * @access private - * @param object EvaluationGroup the current group to be initialized. - */ - function recursiveInit( $group ) { - // only groups are interesting here. - if( $group->x_instanceof() != INSTANCEOF_EVALGROUP ) - return; - - if( $children = $group->getChildren() ) { - foreach( $children as $child ) { - $this->recursiveInit( $child ); - } - } - - // store current object itself - $this->tree_data[$group->getObjectID()]["object"] = $group; - - $this->storeItem( $group->getObjectID(), $group->getParentID(), - $group->getTitle(), $group->getPosition() ); - - } - - function &getGroupObject($item_id, $renew = false){ - if (isset($this->tree_data[$item_id]['object']) && is_object($this->tree_data[$item_id]['object'])) { - if ($renew) $this->recursiveInit(new EvaluationGroup($item_id,null,$this->load_mode)); - return $this->tree_data[$item_id]['object']; - } else { - $evalGroup = new EvaluationGroup($item_id, null, $this->load_mode); - return $evalGroup; - } - } - -# ===================================================== end: public functions # - - -} - -?> diff --git a/lib/evaluation/classes/EvaluationTreeEditView.class.php b/lib/evaluation/classes/EvaluationTreeEditView.class.php deleted file mode 100644 index 3bfe92a..0000000 --- a/lib/evaluation/classes/EvaluationTreeEditView.class.php +++ /dev/null @@ -1,3245 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter005: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - -use Studip\Button, Studip\LinkButton; - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_LIB_COMMON; -require_once EVAL_FILE_EVALTREE; -require_once EVAL_FILE_EVAL; -# ====================================================== end: including files # - -/** - * Class to print out the an evaluation's admin-tree - * - * @author Christian Bauer <alfredhitchcock@gmx.net> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - */ - - -# defines ==================================================================== # - -/** - * @const NO_TEMPLATE_GROUP title of the template without temtplateID - * @access private - */ -define('NO_TEMPLATE_GROUP', _('keine Vorlage')); - -/** - * @const NO_TEMPLATE_GROUP_TITLE title of questiongroup without title - * @access private - */ -define('NO_QUESTION_GROUP_TITLE', _('*Fragenblock*')); - -/** - * @const NO_TEMPLATE title of a template without title - * @access private - */ -define('NO_TEMPLATE', _('*unbekannt*')); -/** - * @const NEW_ARRANGMENT_BLOCK_TITLE title of a new arrangment block - * @access private - */ -define('NEW_ARRANGMENT_BLOCK_TITLE', _('Neuer Gruppierungsblock')); - -/** - * @const NEW_QUESTION_BLOCK_BLOCK_TITLE title of a new question block - * @access private - */ -define('NEW_QUESTION_BLOCK_BLOCK_TITLE', _('Neuer Fragenblock')); - -/** - * @const ROOT_BLOCK the root item - * @access private - */ -define('ROOT_BLOCK', 'root'); - -/** - * @const ARRANGMENT_BLOCK the arrangment block item - * @access private - */ -define('ARRANGMENT_BLOCK', 'ARRANGMENT_BLOCK'); - -/** - * @const QUESTION_BLOCK the question block item - * @access private - */ -define('QUESTION_BLOCK', 'QUESTION_BLOCK'); - -# =============================================================== end: defines # - - -# classes ==================================================================== # - -class EvaluationTreeEditView -{ - - /** - * Reference to the tree structure - * - * @access public - * @var object EvaluationTree $tree - */ - var $tree; - - /** - * contains the item with the current html anchor - * - * @access public - * @var string $anchor - */ - var $anchor; - - /** - * the item to start with - * - * @access public - * @var string $startItemID - */ - var $startItemID; - - /** - * true if changedate should be set - * - * @access private - * @var boolean $changed - */ - var $changed; - - /** - * Holds the Evaluation object - * @access private - * @var object Evaluation $eval - */ - var $eval; - - /** - * Holds the current Item-ID - * @access private - * @var string $itemID - */ - var $itemID; - - /** - * Holds the currently moved Item-ID - * @var string $moveItemID - */ - var $moveItemID; - - /** - * Holds the current evalID - * @access private - * @var integer $evalID - */ - var $evalID; - - /** - * The itemID instance - * @access private - * @var string $itemInstance - */ - var $itemInstance; - - /** - * Possible messages - * - * @var array $msg - */ - var $msg = []; - - /** - * constructor - * - * @access public - * @param string $itemID the item to display - * @param string $evalID the evaluation of the item - */ - function __construct($itemID = ROOT_BLOCK, $evalID = NULL) - { - global $sess; - - $this->itemID = ($itemID) ? $itemID : ROOT_BLOCK; - $this->startItemID = ($itemID) ? $itemID : ROOT_BLOCK; - $this->evalID = $evalID; - $this->itemInstance = $this->getInstance($this->itemID); - $this->changed = false; - - $this->tree = TreeAbstract::GetInstance("EvaluationTree", ['evalID' => $this->evalID, - 'load_mode' => EVAL_LOAD_ALL_CHILDREN]); - - # filter out an old session itemID ======================================= # - if (is_array($this->tree->tree_data) && !is_null($itemID)) { - if (!array_key_exists($itemID, $this->tree->tree_data)) { - $this->itemID = ROOT_BLOCK; - $this->startItemID = ROOT_BLOCK; - $this->tree->init(); - } - } else { - $this->itemID = ROOT_BLOCK; - $this->startItemID = ROOT_BLOCK; - $this->tree->init(); - } - - # handling the moveItemID =============================================== # - if (Request::submitted('create_moveItemID')) - $this->moveItemID = Request::option("itemID"); - elseif (Request::option("moveItemID")) - $this->moveItemID = Request::get("moveItemID"); - - if (Request::submitted("abbort_move")) - $this->moveItemID = NULL; - - if ($this->moveItemID != NULL) { - if (is_array($this->tree->tree_data)) { - if (!array_key_exists($this->moveItemID, $this->tree->tree_data)) { - $this->moveItemID = NULL; - } - } else { - $this->moveItemID = NULL; - } - } - - - # execute the comand ==================================================== # - $this->parseCommand(); - - # set the new changedate ================================================ # - if ($this->changed) { - $this->tree->eval->setChangedate(time()); - $this->tree->eval->save(); - } - - } - - -################################################################################ -# # -# public functions # -# # -################################################################################ - - /** - * displays the EvaluationTree - * - * @access public - * @return string the eval-tree (html) - */ - function showEvalTree() - { - - $html = "<table width=\"99%\" border=\"0\" cellpadding=\"0\" " - . "cellspacing=\"0\">\n"; - - if ($this->startItemID != ROOT_BLOCK) { - - $html .= " <tr>\n" - . " <td class=\"table_row_odd\" align=\"left\" valign=\"top\" " - . "colspan=\""; - $html .= ($this->moveItemID) ? "1" : "1"; - $html .= "\"" - . ">\n" - . $this->getEvalPath() -# . "<img src=\"". -# . "/forumleer.gif\" border=\"0\" height=\"20\" width=\"1\">\n" - . " </td>\n" - . " </tr>\n"; - } - # display the infos when moving a block =================================== # - - if ($this->moveItemID) { - - $html .= " <tr>\n"; -# . " <td width=\"10\"class=\"blank tree-indent\" " -# . "background=\"".."forumstrich.gif\">" -# . "<img src=\"" -# . ."forumstrich.gif\" width=\"10\" border=\"0\" >" -# . "</td>\n" - $html .= " <td class=\"graulight\" align=\"left\" valign=\"top\" width=\"100%\">\n"; - - - $mode = $this->getInstance($this->moveItemID); - - switch ($mode) { - - case ARRANGMENT_BLOCK: - $group =& $this->tree->getGroupObject($this->moveItemID); - $title = htmlready($group->getTitle()); - $msg = sprintf(_("Sie haben den Gruppierungsblock <b>%s</b> zum Verschieben ausgewählt. Sie können ihn nun in einen leeren Gruppierungsblock, einen Gruppierungsblock ohne Frageblöcke oder in die oberste Ebene verschieben."), $title); - - break; - - case QUESTION_BLOCK: - $group = &$this->tree->getGroupObject($this->moveItemID); - $title = htmlready($group->getTitle()); - if (!$title) - $title = NO_QUESTION_GROUP_TITLE; - $msg = sprintf(_("Sie haben den Fragenblock <b>%s</b> zum Verschieben ausgewählt. Sie können ihn nun in einen leeren Gruppierungsblock oder einen Gruppierungsblock mit Frageblöcke verschieben."), $title); - break; - - default: - - $msg = _("Es wurde ein ungültiger Block zum verschieben ausgewählt."); - break; - } - - - $table = new HTML ("table"); - $table->addAttr("border", "0"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "100%"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("align", "center"); - $td->addAttr("class", "graulight"); - $td->addAttr("width", "25"); - - $img = new HTMLempty ("img"); - $img->addAttr("width", "32"); - $img->addAttr("height", "32"); - $img->addAttr("src", EVAL_PIC_INFO); - - $td->addContent($img); - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("align", "left"); - - $font = new HTML ("font"); - $font->addAttr("color", "black"); - $font->addHTMLContent($msg); - $font->addHTMLContent(" " . sprintf( - _("Benutzen Sie dieses %s Symbol, um den Block zu verschieben."), - $this->createImage(EVAL_PIC_MOVE_GROUP, _("Block verschieben Symbol")))); - $font->addHTMLContent("<br><br>" - . _("Oder wollen Sie die Aktion abbrechen?") - . " " - . LinkButton::createCancel(_('Abbrechen'), - $this->getSelf('abbort_move=1'))); - - $td->addContent($font); - $tr->addContent($td); - $table->addContent($tr); - - $html .= "<br>" . $table->createContent() . "<br>"; - - $html .= "</td></tr>\n"; - } - # ============================= END: display the infos when moving a block # - - $html .= " <tr>\n" - . " <td class=\"blank\" align=\"left\" valign=\"top\" " - . "colspan=\""; - $html .= ($this->moveItemID) ? "1" : "1"; - $html .= "\"" - . ">\n"; - - if (!$this->startItemID != ROOT_BLOCK) { - $html .= "<a name=\"anchor\"></a>\n"; - } - - $html .= $this->showTree($this->startItemID, 1) - . " </td>\n" - . " </tr>\n" - . "</table>\n"; - - return $html; - } - -# ###################################################### end: public functions # - - -################################################################################ -# # -# show tree functions # -# # -################################################################################ - - /** - * prints out the tree beginning at the parent-item - * - * @access public - * @param string $itemID the item to display - * @param string $start YES if its the basecall - * @return string the tree (html) - */ - function showTree($itemID = ROOT_BLOCK, $start = NULL) - { - - $items = []; - if (!is_array($itemID)) { - $items[0] = $itemID; - - $mode = $this->getInstance($itemID); - - switch ($mode) { - - case ROOT_BLOCK: - $this->startItemID = $itemID; - break; - - case ARRANGMENT_BLOCK: - - case QUESTION_BLOCK: - $parentgroup = &$this->tree->getGroupObject($itemID); - $this->startItemID = $parentgroup->getObjectID(); - break; - } - - $this->startItemID = $itemID; - } else { - $items = $itemID; - } - $num_items = count($items); - - $html = ""; - - // this is the first / the opened item - if ($start) { - - $mode = $this->getInstance($itemID); - - switch ($mode) { - - case ROOT_BLOCK: - - break; - - case ARRANGMENT_BLOCK: - - case QUESTION_BLOCK: - - $group = &$this->tree->getGroupObject($itemID); - $parentID = $group->getParentID(); - - $mode = $this->getInstance($parentID); - $items2 = []; - if ($mode == ROOT_BLOCK) { - - $eval = new Evaluation ($this->evalID, NULL, EVAL_LOAD_FIRST_CHILDREN); - while ($child = $eval->getNextChild()) - $items2[] = $child->getObjectID(); - } else { - - $parentgroup = &$this->tree->getGroupObject($parentID, NULL, EVAL_LOAD_FIRST_CHILDREN); - while ($child = $parentgroup->getNextChild()) - $items2[] = $child->getObjectID(); - } - - $num_items2 = count($items2); - - $num_items = $num_items2; - $items = $items2; - break; - - } - - } - - for ($j = 0; $j < $num_items; ++$j) { - - $html .= $this->createTreeLevelOutput($items[$j]); - $html .= $this->createTreeItemOutput($items[$j]); - - if ($this->tree->hasKids($items[$j]) && - $this->itemID == $items[$j]) - $html .= $this->showTree($this->tree->tree_childs[$items[$j]]); - } - - return $html; - } - - - /** - * creates the parentslinks - * - * @access private - * @return string the eval path as html-links - */ - function getEvalPath() - { - - $path = "<a name=\"anchor\"> </a>\n" - . _("Sie sind hier:") - . " "; - $path .= "<a class=\"tree\" href=\"" - . URLHelper::getLink($this->getSelf("itemID=" . ROOT_BLOCK, false)) - . "\">" - . htmlready(my_substr( - $this->tree->tree_data[ROOT_BLOCK]["name"], 0, 60)) - . "</a>"; - - # collecting the parent blocks =========================================== # - - if ($parents = $this->tree->getParents($this->startItemID)) { - for ($i = count($parents) - 1; $i >= 0; --$i) { - if ($parents[$i] != ROOT_BLOCK) - $path .= " > " - . "<a class=\"tree\" href=\"" - . URLHelper::getLink($this->getSelf("itemID={$parents[$i]}", false)) - . "\">" - . htmlready(my_substr( - $this->tree->tree_data[$parents[$i]]["name"], 0, 60)) - . "</a>"; - } - } - # ====================================== END: collecting the parent blocks # - return $path; - } - - - /** - * returns html for the icons in front of the name of the item - * - * @access private - * @param string $itemID the item-heas id - * @return string the item head (html) - */ - function getItemHeadPics($itemID) - { - - $mode = $this->getInstance($itemID); - - if ($this->itemID == $itemID) { - - $img = new HTMLempty ("img"); - $img->addAttr("src", EVAL_PIC_TREE_ARROW_ACTIVE); - $img->addAttr("border", "0"); - $img->addAttr("align", "baseline"); - $img->addAttr("hspace", "2"); - $img->addString(tooltip(_("Dieser Block ist geöffnet."), true)); - $head = $img->createContent(); - - } else { - - $a = new HTML ("a"); - $a->addAttr("href", URLHelper::getLink($this->getSelf("itemID={$itemID}"))); - - $img = new HTMLempty ("img"); - $img->addAttr("src", EVAL_PIC_TREE_ARROW); - $img->addAttr("border", "0"); - $img->addAttr("align", "baseline"); - $img->addAttr("hspace", "2"); - $img->addString(tooltip(_("Diesen Block öffnen."), true)); - - $a->addContent($img); - - $head = $a->createContent(); - - } - - # collecting the image and tooltip for this item ========================== # - - switch ($mode) { - - case ROOT_BLOCK: - - $tooltip = _("Dies ist Ihre Evaluation."); - $image = EVAL_PIC_ICON; - break; - - case ARRANGMENT_BLOCK: - - $group = &$this->tree->getGroupObject($itemID); - - $tooltip = ($group->getNumberChildren() == 0) - ? _("Dieser Gruppierungsblock enthält keine Blöcke.") - : sprintf(_("Dieser Grupppierungsblock enthält %s Blöcke."), - $group->getNumberChildren()); - - $image = ($group->getNumberChildren() == 0) - ? EVAL_PIC_TREE_GROUP - : EVAL_PIC_TREE_GROUP_FILLED; - - break; - - case QUESTION_BLOCK: - - $group = &$this->tree->getGroupObject($itemID); - - $tooltip = ($group->getNumberChildren() == 0) - ? _("Dieser Fragenblock enthält keine Fragen.") - : sprintf(_("Dieser Fragenblock enthält %s Fragen."), - $group->getNumberChildren()); - - $image = ($group->getNumberChildren() == 0) - ? EVAL_PIC_TREE_QUESTIONGROUP - : EVAL_PIC_TREE_QUESTIONGROUP_FILLED; - - break; - - default: - - $tooltip = _("Kein Blocktyp."); - $image = EVAL_PIC_TREE_GROUP; - - break; - } - - # ===================== END: collecting the image and toolpi for this item # - - $img = new HTMLempty ("img"); - $img->addAttr("border", "0"); - $img->addAttr("align", "baseline"); - $img->addAttr("src", $image); - $img->addString(tooltip($tooltip, true)); - - $head .= $img->createContent(); - - return $head; - } - - - /** - * creates the content for all item-types - * - * @access private - * @param string $itemID the item-heas id - * @return string the item content (html) - */ - function getItemContent($itemID) - { - - $content = ""; - - if ($this->getItemMessage($itemID)) { - - $table = new HTML ("table"); - $table->addAttr("width", "99%"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("cellspacing", "2"); - $table->addAttr("style", "font-size:10pt;"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addHTMLContent($this->getItemMessage($itemID)); - - $tr->addContent($td); - $table->addContent($tr); - - $content .= "<br>" . $table->createContent(); - } - - - $content .= "<form class=\"default\" action=\"" . URLHelper::getLink($this->getSelf("item_id={$itemID}", 1)) - . "\" method=\"POST\" style=\"display:inline;\">\n"; - $content .= CSRFProtection::tokenTag(); - - $content .= "<br>"; - - $mode = $this->getInstance($itemID); - - switch ($mode) { - case ROOT_BLOCK: - - $content .= $this->createTitleInput(ROOT_BLOCK) - . $this->createGlobalFeatures() - - . $this->createButtonbar(ROOT_BLOCK); - break; - - case ARRANGMENT_BLOCK: - - $content .= $this->createTitleInput(ARRANGMENT_BLOCK); - - $group = &$this->tree->getGroupObject($itemID); - if ($children = $group->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) == ARRANGMENT_BLOCK) - $show = ARRANGMENT_BLOCK; - else - $show = QUESTION_BLOCK; - } else - $show = "both"; - $content .= $this->createButtonbar($show); - break; - - case QUESTION_BLOCK: - - $content .= $this->createTitleInput(QUESTION_BLOCK) - . $this->createQuestionFeatures() - . $this->createQuestionForm() - . $this->createButtonbar(NULL); - break; - } - - $content .= "</form>\n"; - - return $content; - } - - - /** - * prints out the lines before an item ("Strichlogik" (c) rstockm) - * - * @access private - * @param string $item_id the current item - * @param string $start_itemID the start item - * @return string the level output (html) - */ - function createTreeLevelOutput($item_id, $start_itemID = NULL) - { - - $level_output = ""; - - // without the first strichcode - $item_parent = $this->tree->tree_data[$item_id]['parent_id']; - $startitem_parent = $this->tree->tree_data[$this->startItemID]['parent_id']; - - if (($item_parent != $startitem_parent) && ($item_parent != NULL) - && ( - ($item_id != ROOT_BLOCK) || - ($item_id != $this->tree->tree_data[$this->startItemID]['parent_id']))) { - if ($this->tree->isLastKid($item_id) || $item_id == ROOT_BLOCK) - $level_output = "<td class=\"blank tree-indent\" valign=\"top\" " - . "nowrap>" - . Assets::img('forumstrich2.gif') - . "</td>"; //last - else - $level_output = " <td class=\"blank tree-indent\" valign=\"top\" " - . "nowrap>" - . Assets::img('forumstrich3.gif') - . "</td>"; //crossing - - $parent_id = $item_id; - $counter = 0; - while ( - (0) && - ($this->tree->tree_data[$parent_id]['parent_id'] != $this->tree->tree_data[$this->startItemID]['parent_id']) && - ($this->tree->tree_data[$parent_id]['parent_id'] != $start_itemID) && - ($this->tree->tree_data[$parent_id]['parent_id'] != ROOT_BLOCK)) { - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - $counter++; - - if ($this->tree->isLastKid($parent_id)) { - $level_output = "<td class=\"blank\" valign=\"top\" " - . "width=\"10\" nowrap>" - . Assets::img('forumleer.gif') - . "</td>" - . $level_output; //nothing - } else { - $level_output = " <td class=\"blank tree-indent\" valign=\"top\" " - . "nowrap>" - . Assets::img('forumstrich.gif') - . "</td>" - . $level_output; //vertical line - } - - } - - // the root-item - if ((0) && - ($this->startItemID == ROOT_BLOCK) && - ($this->tree->tree_data[$item_id]['parent_id'] == ROOT_BLOCK)) { - $level_output = "<td class=\"blank\" valign=\"top\" " - . "width=\"10\" nowrap>" - . Assets::img('forumleer.gif') - . "</td>" - . $level_output; //nothing - } - - } - - $html = "<table border=\"0\" width=\"100%\" cellspacing=\"0\" " - . "cellpadding=\"0\">" - . " <tr>$level_output"; - return $html; - } - - - /** - * prints out one item - * - * @access private - * @param string $item_id the items id - * @return string one item (html) - */ - function createTreeItemOutput($item_id) - { - - $html = " <td class=\"printhead\" nowrap align=\"left\" " - . "valign=\"bottom\">\n" - . $this->getItemHeadPics($item_id) . "\n" - . " </td>\n" - . " <td class=\"printhead\" nowrap width=\"1\" valign=\"middle\">\n"; - if ($this->anchor == $item_id) - $html .= "<a name=\"anchor\">"; - $html .= Assets::img('forumleer.gif'); - if ($this->anchor == $item_id) - $html .= "</a>"; - $html .= "\n" - . " </td>\n" - . " <td class=\"printhead\" align=\"left\" width=\"99%\" " - . "nowrap valign=\"bottom\">" - . $this->getItemHead($item_id) - . " </td>\n" - . " </tr>\n" - . "</table>\n"; - if ($this->itemID == $item_id) - $html .= $this->createTreeItemDetails($item_id); - return $html; - } - - - /** - * prints out the item details - * - * @access private - * @param string $item_id the current item - * @return string the item details (html) - */ - private function createTreeItemDetails($item_id) - { - $mode = $this->getInstance($item_id); - - switch ($mode) { - case ROOT_BLOCK: - $eval = new Evaluation($this->evalID, NULL, EVAL_LOAD_FIRST_CHILDREN); - $hasKids = $eval->getNumberChildren() == 0 ? NO : YES; - break; - case ARRANGMENT_BLOCK: - $group = $this->tree->getGroupObject($item_id); - $hasKids = $group->getNumberChildren() == 0 ? NO : YES; - break; - default: - $hasKids = NO; - break; - } - - if (!$hasKids || $this->itemID != $item_id) { - $level_output = $this->createLevelOutputTD(); - } else { - $level_output = $this->createLevelOutputTD("forumstrich.gif"); - } - - $table = new HTML ("table"); - $table->addAttr("border", "0"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "0"); - $table->addAttr("width", "100%"); - - $tr = new HTML ("tr"); - $tr->addHTMLContent($level_output); - - $td = new HTML ("td"); - $td->addAttr("class", "printcontent"); - $td->addAttr("width", "100%"); - - $div = new HTML ("div"); - $div->addAttr("align", "center"); - $div->setTextareaCheck(); - $div->addHTMLContent($this->getItemContent($item_id)); - - $td->addContent($div); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - - /** - * creates the items head - * - * @access private - * @param string $itemID the current item - * @return string the item head (html) - */ - function getItemHead($itemID) - { - - $mode = $this->getInstance($itemID); - - if ($this->itemID == $itemID) { - -# $group = new EvaluationGroup($itemID); - $head = " "; - if ($this->tree->tree_data[$itemID]['name'] == "" && $mode == QUESTION_BLOCK) - $head .= NO_QUESTION_GROUP_TITLE; - else - $head .= htmlready(my_substr( - $this->tree->tree_data[$itemID]['name'], 0, 60)); - - } else { - - if ($mode == QUESTION_BLOCK) { - - $group = &$this->tree->getGroupObject($itemID); - $templateID = $group->getTemplateID(); - if ($templateID) { - $template = new EvaluationQuestion($templateID); - $templateTitle = htmlReady($template->getText()); - } else - $templateTitle = NO_TEMPLATE_GROUP; - - if ($templateTitle == "") - $templateTitle = NO_TEMPLATE; - - $template = " </td>\n" - . " <td align=\"right\" valign=\"bottom\" " - . "class=\"printhead\" nowrap=\"nowrap\">\n" - . "<b>" - . _("Vorlage") . ": " - . $templateTitle - . "</b> "; - - } - - $head = " <a class=\"tree\" href=\"" - . URLHelper::getLink($this->getSelf("itemID={$itemID}", false)) . "\"" . tooltip(_("Diesen Block öffnen"), true) . ">"; - - if ($this->tree->tree_data[$itemID]['name'] == "" && $mode == QUESTION_BLOCK) - $head .= NO_QUESTION_GROUP_TITLE; - else - $head .= htmlready(my_substr( - $this->tree->tree_data[$itemID]['name'], 0, 60)); - $head .= "</a>"; - - if (!empty($template)) - $head .= $template; - } - $moveItem = []; - $moveItemIsParent = 0; - if ($itemID == ROOT_BLOCK) - $itemID2 = $this->evalID; - else - $itemID2 = $itemID; - - // the "verschiebäfinger" - if ($this->moveItemID && - ($this->tree->tree_data[$itemID]['parent_id'] != $this->moveItemID) && - ($mode == ARRANGMENT_BLOCK || $itemID == ROOT_BLOCK) && - $this->moveItemID != $itemID2) { - - $parentID = $this->tree->tree_data[$itemID]['parent_id']; - if (!$parentID) $parentID = ROOT_BLOCK; - while ($parentID != ROOT_BLOCK && $parentID != $this->moveItemID) { - $parentID = $this->tree->tree_data[$parentID]['parent_id']; - if ($parentID == $this->moveItemID) - $moveItemIsParent = 1; - } - - $moveItem = " </td>\n" - . " <td align=\"right\" valign=\"middle\" class=\"printhead\" nowrap=\"nowrap\">\n" - . $this->createLinkImage(EVAL_PIC_MOVE_GROUP, - _("Den ausgwählten Block in diesen Block verschieben"), - "&itemID=$itemID&cmd=MoveGroup", - NO, NULL, NO) - . " "; - } - - if ($moveItem && !$moveItemIsParent) { - $move_mode = $this->getInstance($this->moveItemID); - - if ($mode == ARRANGMENT_BLOCK) { - $group = &$this->tree->getGroupObject($itemID); - if ($children = $group->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) == ARRANGMENT_BLOCK) - $move_type = ARRANGMENT_BLOCK; - else - $move_type = QUESTION_BLOCK; - } else - $move_type = "both"; - } elseif ($mode == ROOT_BLOCK) - $move_type = ARRANGMENT_BLOCK; - else - $move_type = "no"; - - - if (($move_type == "both") || - ($move_mode == $move_type)) { - $head .= $moveItem; - } - } - - if (!($this->tree->isFirstKid($itemID) && $this->tree->isLastKid($itemID)) && - ($itemID != $this->startItemID) && - ($this->tree->tree_data[$itemID]['parent_id'] == $this->startItemID)) { - $head .= " </td>\n" - . " <td align=\"right\" valign=\"bottom\" class=\"printhead\" nowrap=\"nowrap\">\n" - . $this->createLinkImage(EVAL_PIC_MOVE_UP, - _("Block nach oben verschieben"), - "cmd=Move&direction=up&groupID=$itemID", - NO) - . $this->createLinkImage(EVAL_PIC_MOVE_DOWN, - _("Block nach unten verschieben"), - "cmd=Move&direction=down&groupID=$itemID", - NO) - . " "; - } - return $head; - } - - - /** - * creates a table and calls the ItemMessages - * - * @access private - * @param string $itemID the current item - * @param integer $colspan the needed colspan (optional) - * @return string the item message (html) - */ - function getItemMessage($itemID, $colspan = 1) - { - if (!empty($this->msg[$itemID])) { - $msg = explode("§", $this->msg[$itemID]); - $details = []; - if ($msg[0] == 'msg') { - $msg[0] = 'success'; - } - if (mb_strpos($msg[1], '<br>')) { - $details = explode("<br>", $msg[1]); - $msg[1] = array_shift($details); - } - - return (string)MessageBox::{$msg[0]}($msg[1], $details); - } else { - return NULL; - } - } - - - /** - * creates a self-url with add. items - * - * @access private - * @param string $param params (optional) - * @param boolean $with_start_item startItem needed? (optional) - * @return string the self url - */ - function getSelf($param = "", $with_start_item = true) - { - - $url = "?page=edit"; - - if ($this->evalID) - $url .= "&evalID=" . $this->evalID; - else - $url .= "&evalID=" . Request::option("evalID"); - - if ($param) { - $url .= (($with_start_item) - ? "&itemID=" . $this->startItemID . "&" - : "&") . $param; - } else { - $url .= (($with_start_item) - ? "&itemID=" . $this->startItemID - : ""); - } - - if ($this->moveItemID) - $url .= "&moveItemID=" . $this->moveItemID; - - $url .= "#anchor"; - - return $url; - } - -# ################################################### end: show tree functions # - - -################################################################################ -# # -# command functions # -# # -################################################################################ - - /** - * parses the _Request-commands and calls the avaible functions - * - * @access private - */ - function parseCommand() - { - $exec_func = ''; - if (Request::option('cmd') || Request::optionArray('cmd')) { - # extract the command from Request (array) =========================== # - - if (Request::optionArray('cmd')) - $exec_func = "execCommand" . key(Request::optionArray('cmd')); - else - $exec_func = "execCommand" . Request::option('cmd'); - - } else { - $found = 0; - # extract the command from the template-site ========================= # - foreach ($_REQUEST as $key => $value) { - if (preg_match("/template_(.*)_#(.*)_button?/", $key, $command)) { - $found = 1; - break; - } - } - - if (!$found) { - foreach ($_REQUEST as $key => $value) { - if (preg_match("/cmd_(.*)_#(.*)_§(.*)_button?/", $key, $command)) - break; - } - } - - - if (isset($command[1])) { - if ($command[1] == "create_question_answers") - $exec_func = "execCommandQuestionAnswersCreate"; - else - $exec_func = "execCommand" . $command[1]; - } - # ==================== END: extract the command from the template-site # - } - - if (method_exists($this, $exec_func)) { - if ($this->$exec_func()) { - $this->tree->init(); - $this->tree->eval->save(); - } - } - } - - - /** - * Creates cancel-message - * @access public - * @return boolean true (reinits the tree) - */ - function execCommandCancel() - { - - - $itemID = Request::option('startItemID'); - - $this->anchor = $itemID; - $this->msg[$this->startItemID] .= "info§" - . sprintf(_("Die Aktion wurde abgebrochen.")); - return false; - } - - /** - * Updates the item content of any kind - * - * @access private - * @param boolean $no_delete YES/NO (optional) - * @return boolean true (reinits the tree) - */ - function execCommandUpdateItem($no_delete = false) - { - - - $mode = $this->getInstance($this->itemID); - - $title = Request::get('title'); - if ($title == "" && $mode != QUESTION_BLOCK) - $title = _("Kein Titel angegeben."); - $text = Studip\Markup::purifyHtml(trim(Request::get('text'))); - - switch ($mode) { - case ROOT_BLOCK: - - $this->tree->eval->setTitle($title); - $this->tree->eval->setText($text); - - //global features - $this->tree->eval->setAnonymous(Request::get('anonymous')); - - $this->tree->eval->save(); - - if (!empty($this->tree->eval->isError)) { - return MessageBox::error(_("Fehler beim Einlesen (root-item)")); - } - $this->msg[$this->itemID] = "msg§" - . _("Veränderungen wurden gespeichert."); - - break; - case ARRANGMENT_BLOCK: - - $group = &$this->tree->getGroupObject($this->itemID, true); - - $group->setTitle($title); - $group->setText($text); - $group->save(); - if (!empty($group->isError)) { - return MessageBox::error(_("Fehler beim Einlesen (Block)")); - } - $this->msg[$this->itemID] = "msg§" - . _("Veränderungen wurden gespeichert."); - $group = null; - break; - case QUESTION_BLOCK: - - $group = &$this->tree->getGroupObject($this->itemID, true); - $group->setTitle($title); - $group->setText($text); - $group->setMandatory(Request::get('mandatory')); - $group->save(); - - // update the questions - $msg = $this->execCommandUpdateQuestions(); - - $no_answers = 0; - $group = &$this->tree->getGroupObject($this->itemID, true); - // info about missing answers - if ($group->getChildren() && $group->getTemplateID() == NULL) { - foreach ($group->getChildren() as $question) { - if ($question->getChildren() == NULL) - $no_answers++; - } - if ($no_answers == 1) { - if ($this->msg[$this->itemID]) - $this->msg[$this->itemID] .= "<br>" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); - else - $this->msg[$this->itemID] .= "info§" . _("Einer Frage wurden noch keine Antwortenmöglichkeiten zugewiesen."); - } elseif ($no_answers > 1) { - if ($this->msg[$this->itemID]) - $this->msg[$this->itemID] .= "<br>" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); - else - $this->msg[$this->itemID] .= "info§" . sprintf(_("%s Fragen wurden noch keine Antwortenmöglichkeiten zugewiesen."), $no_answers); - } - - } - - if (!empty($group->isError)) { - return MessageBox::error("Fehler beim Einlesen (Fragenblock)"); - } - if (!isset($this->msg[$this->itemID])) { - $this->msg[$this->itemID] = ''; - } - if (!empty($this->msg[$this->itemID])) - $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert."); - else - $this->msg[$this->itemID] .= "msg§" - . _("Veränderungen wurden gespeichert."); - - if (!empty($msg)) { - if (!isset($this->msg[$this->itemID])) { - $this->msg[$this->itemID] = ''; - } - $this->msg[$this->itemID] = $this->msg[$this->itemID] . "<br>" . $msg; - } - break; - default: - $this->msg[$this->itemID] .= "info§" - . _("Falscher Blocktyp. Es wurden keine Veränderungen vorgenommen."); - break; - } - - $this->changed = true; - - return true; - } - - - /** - * Creates a delete-request - * - * @access public - * @return boolean false - */ - function execCommandAssertDeleteItem() - { - $group = &$this->tree->getGroupObject($this->itemID); - if ($group->getChildType() == "EvaluationQuestion") - $numberofchildren = $group->getNumberChildren(); - else - $numberofchildren = $this->tree->getNumKidsKids($this->itemID); - - $title = htmlready($group->getTitle()); - - // constructing the message - $this->msg[$this->itemID] = "info§"; - - if ($group->getChildType() == "EvaluationQuestion") { - if ($numberofchildren) { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Fragenblock <b>%s</b> inklusive aller Fragen zu löschen. "), - $title) - . sprintf(_("Es werden insgesamt %s Fragen gelöscht!"), $numberofchildren); - } else { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Fragenblock <b>%s</b> inklusive aller Fragen zu löschen. "), - $title); - } - $this->msg[$this->itemID] .= "<br>" - . _("Wollen Sie diesen Fragenblock wirklich löschen?"); - } else { - if ($numberofchildren) { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Gruppierungsblock <b>%s</b> inklusive aller Unterblöcke zu löschen. "), - $title) - . sprintf(_("Es werden insgesamt %s Unterblöcke gelöscht!"), $numberofchildren); - } else { - $this->msg[$this->itemID] .= "" - . sprintf( - _("Sie beabsichtigen den Gruppierungsblock <b>%s</b> inklusive aller Unterblöcke zu löschen. "), - $title); - } - $this->msg[$this->itemID] .= "<br>" - . _("Wollen Sie diesen Gruppierungsblock wirklich löschen?"); - } - - $this->msg[$this->itemID] .= "<br><br>" - . LinkButton::createAccept(_('JA!'), - $this->getSelf('cmd[DeleteItem]=1'), - ['title' => _('Löschen')]) - . " " - . LinkButton::createCancel(_('NEIN!'), - $this->getSelf('cmd[Cancel]=1')) - . "\n"; - - return false; - } - - /** - * Deletes an Item and its kids - * @access public - * @return boolean true (reinits the tree) - */ - function execCommandDeleteItem() - { - - $title = $this->tree->tree_data[$this->itemID]['name']; - $parentID = $this->tree->tree_data[$this->itemID]['parent_id']; - - $group = &$this->tree->getGroupObject($this->startItemID); - if ($group->getChildType() == "EvaluationQuestion") - $numberofchildren = $group->getNumberChildren(); - else - $numberofchildren = $this->tree->getNumKidsKids($this->itemID); - - $group->delete(); - - if (!empty($group->isError)) { - return MessageBox::error(_("Fehler beim Löschen eines Block.")); - } - - if ($group->getChildType() == "EvaluationQuestion") { - if ($numberofchildren) { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Fragenblock <b>%s</b> und alle darin enthaltenen Fragen (insgesamt %s) wurden gelöscht. "), $title, $numberofchildren); - } else { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Fragenblock <b>%s</b> wurde gelöscht. "), $title); - } - } else { - if ($numberofchildren) { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Gruppierungsblock <b>%s</b> und alle Unterblöcke (insgesamt %s) wurden gelöscht. "), $title, $numberofchildren); - } else { - $this->msg[$parentID] = "msg§" . sprintf(_("Der Gruppierungsblock <b>%s</b> wurde gelöscht. "), $title); - } - } - - $this->changed = true; - - $this->startItemID = $parentID; - $this->itemID = $parentID; - - return true; - } - - /** - * Creates a new Group and adds it to the tree - * - * @access public - * @return boolean true (reinits the tree) - */ - function execCommandAddGroup() - { - - - $group = new EvaluationGroup(); - $group->setTitle(NEW_ARRANGMENT_BLOCK_TITLE); - $group->setText(""); - - $mode = $this->getInstance($this->itemID); - - if ($mode == ROOT_BLOCK) { - $this->tree->eval->addChild($group); - $this->tree->eval->save(); - if (!empty($this->tree->eval->isError)) { - return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks.")); - } - $this->msg[$this->itemID] = "msg§" - . _("Ein neuer Gruppierungsblock wurde angelegt."); - } elseif ($mode == ARRANGMENT_BLOCK) { - $parentgroup = &$this->tree->getGroupObject($this->itemID); - $parentgroup->addChild($group); - $parentgroup->save(); - if (!empty($parentgroup->isError)) { - return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks.")); - } - $this->msg[$this->itemID] = "msg§" - . _("Ein neuer Gruppierungsblock wurde angelegt."); - } - - $this->execCommandUpdateItem(); - - return true; - } - - /** - * adds a questions-group - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandAddQGroup() - { - - - $group = new EvaluationGroup(); - $group->setTitle(NEW_QUESTION_BLOCK_BLOCK_TITLE); - $group->setText(""); - $group->setChildType("EvaluationQuestion"); - $group->setTemplateID(Request::option("templateID")); - $template = new EvaluationQuestion (Request::option("templateID"), - NULL, EVAL_LOAD_FIRST_CHILDREN); - - $mode = $this->getInstance($this->itemID); - - if ($mode == ROOT_BLOCK) { - $this->tree->eval->addChild($group); - $this->tree->eval->save(); - if (!empty($this->tree->eval->isError)) { - return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks.")); - } - $this->msg[$this->itemID] = "msg§" - . _("Ein neuer Fragenblock wurde angelegt."); - }// group - elseif ($mode == ARRANGMENT_BLOCK) { - $parentgroup =& $this->tree->getGroupObject($this->itemID); - $parentgroup->addChild($group); - $parentgroup->save(); - if (!empty($parentgroup->isError)) { - return MessageBox::error(_("Fehler beim Anlegen eines neuen Blocks.")); - } - if (Request::option("templateID") != "") - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Ein neuer Fragenblock mit der Antwortenvorlage <b>%s</b> wurde angelegt."), - htmlReady($template->getText())); - else - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Ein neuer Fragenblock mit keiner Antwortenvorlage wurde angelegt."), - 1); - } - $this->execCommandUpdateItem(); - - return true; - } - - /** - * Updates the templateID of a group - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandChangeTemplate() - { - - - $this->execCommandUpdateItem(); - - $group = &$this->tree->getGroupObject($this->itemID); - $group->setTemplateID(Request::option("templateID")); - $group->save(); - - if (!empty($group->isError)) { - return MessageBox::error(_("Fehler beim Zuordnen eines Templates.")); - } - - $templateID = $group->getTemplateID(); - if ($templateID) { - - $template = new EvaluationQuestion($templateID); - $templateTitle = htmlReady($template->getText()); - - } else - $templateTitle = NO_TEMPLATE_GROUP; - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Die Vorlage <b>%s</b> wurde dem Fragenblock zugeordnet."), - $templateTitle); - - return true; - } - - /** - * Update the Question content - * - * @access private - * @param boolean $no_delete YES/NO (optional) - * @return string the udpatemessage - */ - function execCommandUpdateQuestions($no_delete = false) - { - - $questions = Request::getArray('questions'); - $deleteQuestions = Request::getArray('DeleteQuestions'); - - // remove any empty questions - $deletecount = 0; - - $qgroup = &$this->tree->getGroupObject($this->itemID); - $questionsDB = $qgroup->getChildren(); - $cmd = Request::optionArray('cmd'); - if (!empty($cmd)) - if (key($cmd) == "UpdateItem") - $delete_empty_questions = 1; - - for ($i = 0; $i < count($questions); $i++) { - - if (!isset($deleteQuestions[$i])) { - $question = new EvaluationQuestion($questions[$i]['questionID'], NULL, - EVAL_LOAD_FIRST_CHILDREN); - - // remove any empty questions - if ((empty($questions[$i]['text'])) && $delete_empty_questions) { - - $question->delete(); - $deletecount++; - - // upadate the questiontext to the db - } else { - - $question->setText($questions[$i]['text']); - $question->save(); - } - } - } - $msg = NULL; - if ($deletecount == 1) - $msg = _("Es wurde eine leere Frage entfernt."); - elseif ($deletecount > 1) - $msg = sprintf(_("Es wurden %s leere Fragen entfernt."), $deletecount); - - return $msg; - } - - /** - * Adds Questions - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandAddQuestions() - { - - $addquestions = Request::get('newQuestionFields'); - - $qgroup = &$this->tree->getGroupObject($this->itemID); - $templateID = $qgroup->getTemplateID(); - - for ($i = 1; $i <= $addquestions; $i++) { - $template = new EvaluationQuestion ($templateID, NULL, EVAL_LOAD_FIRST_CHILDREN); - $newquestion = $template->duplicate(); - $newquestion->setText(""); - $qgroup->addChild($newquestion); - $qgroup->save(); - if (!empty($qgroup->isError)) { - return MessageBox::error(_("Fehler beim Anlegen neuer Fragen.")); - } - } - - if ($addquestions == "1") - $this->msg[$this->itemID] = "msg§" - . _("Es wurde eine neue Frage hinzugefügt."); - else - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Es wurden %s neue Fragen hinzugefügt."), $addquestions); - - $this->execCommandUpdateItem(NO); - - return true; - } - - /** - * deletes questions - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandDeleteQuestions() - { - - $questions = Request::getArray('questions'); - $deleteQuestions = Request::getArray('DeleteQuestions'); - - $deletecount = 0; - for ($i = 0; $i < count($questions); $i++) { - - $question = new EvaluationQuestion($questions[$i]['questionID'], NULL, - EVAL_LOAD_ALL_CHILDREN); - - // remove any empty questions - if ($deleteQuestions[$i]) { - $question->delete(); - $deletecount++; - } - } - - if ($deletecount == "1") - $this->msg[$this->itemID] = "msg§" - . _("Es wurde eine Frage gelöscht."); - elseif ($deletecount > 1) - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Es wurden %s Fragen gelöscht."), $deletecount); - else - $this->msg[$this->itemID] = "msg§" - . _("Es wurde keine Frage gelöscht."); - - $this->execCommandUpdateItem(); - - return true; - } - - /** - * creates an info-message and updates the item - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandQuestionAnswersCreate() - { - - $this->execCommandUpdateItem(); - - // extract the questionID from the command - foreach ($_REQUEST as $key => $value) { - if (preg_match("/template_(.*)_button?/", $key, $command)) - break; - } - if (preg_match("/(.*)_#(.*)/", $command[1], $command_parts)) - $questionID = $command_parts[2]; - - $question = new EvaluationQuestion($questionID); - $questiontitle = htmlReady($question->getText()); - - $this->msg[$this->itemID] = "msg§" -# . sprintf(_("Sie können nun der Frage <b>%s</b> im rechten Bereich Antworten zuweisen.") -# , $questiontitle) -# . "<br>" - . _("Veränderungen wurden gespeichert."); - - return true; - } - - /** - * creates an confirm-message if answers were created - * - * @access private - * @return boolean false - */ - function execCommandQuestionAnswersCreated() - { - - $id = $this->itemID; - - $question = new EvaluationQuestion(Request::get("questionID")); - $title = htmlready($question->getTitle()); - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Der Frage <b>%s</b> wurden Antwortenmöglichkeiten zugewiesen."), $title); - - $this->changed = true; - - return false; - } - - /** - * Moves a Questions - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandMoveQuestionUp() - { - - $this->execCommandUpdateItem(); - - foreach ($_REQUEST as $key => $value) { - if (preg_match("/cmd_(.*)_#(.*)_§(.*)_button(_x)?/", $key, $command)) - break; - } - - $questionID = $command[2]; - $oldposition = $command[3]; - - $this->swapPosition($this->itemID, $questionID, $oldposition, - "up"); - - if ($oldposition == 0) - $this->msg[$this->itemID] = "msg§" - . _("Die Frage wurde von Position 1 an die letzte Stelle verschoben."); - else - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Die Frage wurde von Position %s nach oben verschoben."), $oldposition + 1); - - $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert."); - return true; - } - - /** - * Moves a Questions - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandMoveQuestionDown() - { - - $this->execCommandUpdateItem(); - - foreach ($_REQUEST as $key => $value) { - if (preg_match("/cmd_(.*)_#(.*)_§(.*)_button(_x)?/", $key, $command)) - break; - } - - $questionID = $command[2]; - $oldposition = $command[3]; - - $this->swapPosition($this->itemID, $questionID, $oldposition, - "down"); - - $this->msg[$this->itemID] = "msg§" . sprintf( - _("Die Frage wurde von Position %s nach unten verschoben."), - $oldposition + 1 - ); - - $this->msg[$this->itemID] .= "<br>" . _("Veränderungen wurden gespeichert."); - return true; - } - - - public function execCommandMove() - { - $direction = Request::option('direction'); - - $group = &$this->tree->getGroupObject(Request::option('groupID')); - $oldposition = $group->getPosition(); - - $this->swapPosition($this->itemID, $group->objectID, $oldposition, $direction); - - $this->msg[$this->itemID] = "msg§ "; - if (($this->itemID != ROOT_BLOCK) - && ($group->getChildType() == "EvaluationQuestion")) - $this->msg[$this->itemID] .= _("Fragenblock"); - else - $this->msg[$this->itemID] .= _("Gruppierungsblock"); - - if (($oldposition == 0) && ($direction == "up")) - $this->msg[$this->itemID] .= - _(" wurde von Position 1 an die letzte Stelle verschoben."); - elseif (($oldposition == $group->getNumberChildren() - 1) - && ($direction == "down")) - $this->msg[$this->itemID] .= - sprintf(_(" wurde von Position %s an die erste Stelle verschoben.") - , $oldposition + 1); - else - $this->msg[$this->itemID] .= (($direction == "up") - ? sprintf(_(" wurde von Position %s nach oben verschoben."), $oldposition + 1) - : sprintf(_(" wurde von Position %s nach unten verschoben."), $oldposition + 1)); - - $this->changed = true; - - return true; - } - - /** - * Moves a Group from one parent to another - * - * @access private - * @return boolean true (reinits the tree) - */ - function execCommandMoveGroup() - { - - - $moveGroupeID = Request::option('moveGroupeID'); - - if (!$this->moveItemID) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Es wurde kein Block zum verschieben ausgewählt."); - return false; - } - - $mode = $this->getInstance($this->itemID); - - if (!$mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der Zielblock besitzt keinen Typ."); - return false; - } - - $move_mode = $this->getInstance($this->moveItemID); - - if (!$move_mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der Zielblock besitzt keinen Typ."); - return false; - } - - $move_group =& $this->tree->getGroupObject($this->moveItemID); - $move_group_title = htmlready($move_group->getTitle()); - $oldparentID = $move_group->getParentID(); - - switch ($mode) { - - case ROOT_BLOCK: - - if ($children = $this->tree->eval->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) != $move_mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der ausgewählte Block und der Zielblock besitzen verschiedene Typen."); - return false; - } - } - - $newgroup = $move_group->duplicate(); - - $this->tree->eval->addChild($newgroup); - $this->tree->eval->save(); - - if (($oldparentID == $this->evalID) || $oldparentID == "root") { - - $grouptodelete = $this->tree->eval->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $this->tree->eval->save(); - if (!empty($this->tree->eval->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - } else { - - $oldparentgroup = &$this->tree->getGroupObject($oldparentID); - $grouptodelete = $oldparentgroup->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $oldparentgroup->save(); - } - - if (!empty($this->tree->eval->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($move_group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($newgroup->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($grouptodelete->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Der Block <b>%s</b> wurde in die Hauptebene verschoben."), - $move_group_title); - break; - - case ARRANGMENT_BLOCK: - - $group = &$this->tree->getGroupObject($this->itemID); - if ($children = $group->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) != $move_mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der ausgewählte Block und der Zielblock besitzen verschiedene Typen."); - return false; - } - } - if ($oldparentID == $this->evalID) { - $grouptodelete = $this->tree->eval->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $this->tree->eval->save(); - if (!empty($this->tree->eval->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - } else { - - $oldparentgroup = &$this->tree->getGroupObject($oldparentID); - $grouptodelete = $oldparentgroup->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $oldparentgroup->save(); - if (!empty($oldparentgroup->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - } - $newgroup = $move_group->duplicate(); - - $group->addChild($newgroup); - $group->save(); - - - if (!empty($group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($move_group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($newgroup->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($grouptodelete->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Der Block <b>%s</b> wurde in diesen Gruppierungsblock verschoben."), - $move_group_title); - break; - - case QUESTION_BLOCK: - - $group = &$this->tree->getGroupObject($this->itemID); - - if ($children = $group->getChildren()) { - if ($this->getInstance($children[0]->getObjectID()) != $move_mode) { - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Der ausgewählte Block und der Zielblock besitzen verschiedene Typen."); - return false; - } - } - - $oldparentID = $move_group->getParentID(); - if ($oldparentID == ROOT_BLOCK) { - - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Ein Fragenblock kann nicht auf die oberste Ebene verschoben werden."); - return false; - } elseif ($oldparentID == $this->evalID) { - - $this->msg[$this->itemID] = "msg§" - . _("Fehler beim Verschieben eines Blocks. Ein Fragenblock kann nicht auf die oberste Ebene verschoben werden."); - return false; - } else { - - $oldparent = &$this->tree->getGroupObject($oldparentID); - } - - $newgroup = $move_group->duplicate(); - - $group->addChild($newgroup); - $group->save(); - - $grouptodelete = $oldparent->getChild($move_group->getObjectID()); - $grouptodelete->delete(); - $oldparent->save(); - - - if (!empty($group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($move_group->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($newgroup->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($grouptodelete->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - if (!empty($oldparent->isError)) - return MessageBox::error(_("Fehler beim Verschieben eines Blocks.")); - - $this->msg[$this->itemID] = "msg§" - . sprintf(_("Der Block <b>%s</b> wurde in diesen Fragenblock verschoben."), - $move_group_title); - - break; - } - - $this->moveItemID = NULL; - - $this->changed = true; - - return true; - } - -# ##################################################### end: command functions # - - -################################################################################ -# # -# HTML functions # -# # -################################################################################ - - /** - * creates the html for the create new group options - * - * @access private - * - * @param string $show the blocktyp to display - * @return string the buttons (html) - */ - function createButtonbar($show = ARRANGMENT_BLOCK) - { - - $infotext = _("Sie können ...") . "\n"; - - $table = new HTML ("table"); - $table->addAttr("width", "100%"); - $table->addAttr("class", "blank"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "6"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("div", "left"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "steelgrau"); - $td->addAttr("align", "center"); - - $seperator = " | "; - - // the update-button - $buttons = " " - . Button::create(_('Übernehmen'), - 'cmd[UpdateItem]', - ['title' => _('Die Veränderungen innerhalb des Blockes speichern.')]); - - $infotext .= "\n" - . _("- die Veränderungen dieses Blocks speichern."); - - // the new group-button - if ($show == "both" || $show == ARRANGMENT_BLOCK || $show == ROOT_BLOCK) { - $buttons .= $seperator - . Button::create(_('Erstellen'), - 'cmd[AddGroup]', - ['title' => _('Einen neuen Gruppierungsblock erstellen.')]); - $infotext .= "\n" - . _("- einen neuen Gruppierungsblock innerhalb dieses Blockes erstellen, in welchem Sie weitere Gruppierungs- oder Fragenblöcke anlegen können."); - } - - // the new question-group-button - if ($show == "both" || $show == QUESTION_BLOCK) { - - $buttons .= $seperator - . $this->createTemplateSelection() - . Button::create(_('Erstellen'), - 'cmd[AddQGroup]', - ['title' => _('Einen neuen Fragenblock mit der ausgewählten Antwortenvorlage erstellen.')]); - $infotext .= "\n" - . _("- einen neuen Fragenblock innherhalb dieses Blockes erstellen. Geben Sie dazu bitte eine Antwortenvorlage an, welche für alle Fragen des neuen Fragenblockes verwendet wird."); - } - - // the move-button - if ($this->itemID != ROOT_BLOCK && !$this->moveItemID) { - - $a = new HTML ("a"); - $a->addAttr("href", - URLHelper::getLink($this->getSelf("&moveItemID=" . $this->itemID))); - - $img = new HTMLempty ("img"); - $img->addAttr("border", "0"); - $img->addAttr("style", "vertical-align:middle;"); - $img->addAttr("src", EVAL_PIC_MOVE_BUTTON); - $img->addAttr("style", "vertical-align:middle;"); - $img->addString(tooltip(_("Diesen Block verschieben."))); - - $a->addContent($img); - - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "&moveItemID=" . $this->itemID); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", EVAL_PIC_MOVE_BUTTON); - $button->addString(Tooltip(_("Diesen Block verschieben."))); - - $buttons .= $seperator - . Button::create(_('verschieben'), - 'create_moveItemID', - ['title' => _('Diesen Block verschieben.')]); -# . $a->createContent (); - $infotext .= "\n" - . _("- diesen Block zum Verschieben markieren."); - - $movebutton = 1; - } - - - // the delete-button - if ($this->itemID != ROOT_BLOCK) { - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "cmd[AssertDeleteItem]"); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", EVAL_PIC_DELETE_GROUP); - $button->addString(Tooltip(_("Diesen Block und alle seine Unterblöcke löschen."))); - - $buttons .= ($movebutton) - ? " " - : $seperator; - $buttons .= Button::create(_('Löschen'), - 'cmd[AssertDeleteItem]', - ['title' => _('Diesen Block (und alle seine Unterblöcke) löschen..')]); -# $buttons .= $button->createContent (); - - $infotext .= "\n" - . _("- diesen Block und seine Unterblöcke löschen."); - } - - // the abort-button - $child = $this->tree->eval->getNextChild(); - $number_of_childs = $this->tree->eval->getNumberChildren(); - if ($number_of_childs == 1 && - $this->itemID == ROOT_BLOCK && - $this->tree->eval->getTitle() == NEW_EVALUATION_TITLE && - $this->tree->eval->getText() == "" && - $child && - $child->getTitle() == FIRST_ARRANGMENT_BLOCK_TITLE && - $child->getChildren() == NULL && - isset($child->getText) && $child->getText == "") { - - $a_content = LinkButton::createCancel(_('Abbrechen'), - URLHelper::getURL(EVAL_FILE_ADMIN . "?evalID=") . $this->tree->eval->getObjectID() . "&abort_creation_button=1", - ['title' => _("Erstellung einer Evaluation abbrechen")]); - - $buttons .= $seperator - . $a_content; - $infotext .= "\n" - . _("Die Erstellung dieser Evaluation abbrechen."); - } - - $td->addHTMLContent( - $this->createImage(EVAL_PIC_HELP, $infotext)); - $td->addHTMLContent($buttons); - $tr->addContent($td); - $table->addContent($tr); - - - return $table->createContent(); - } - - /** - * creates the html for the create new group options - * - * @access private - * @param string $show - * @return string the html - */ - function createFormNew($show = ARRANGMENT_BLOCK) - { - - $table = new HTML ("table"); - $table->addAttr("width", "100%"); - $table->addAttr("class", "blank"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "6"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("div", "left"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "blank"); - $td->addAttr("align", "center"); - $td->addContent(new HTMLempty ("br")); - -# $tr->addContent ($td); -# $table->addContent ($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "content_body"); -# $td->addAttr ("class","steelgrau"); - $td->addAttr("align", "center"); - - $img = new HTMLempty ("img"); - $img->addAttr("src", Assets::image_path("blank.gif")); - $img->addAttr("width", "30"); - $img->addAttr("height", "1"); - $img->addAttr("alt", ""); - -# $td->addContent ($img); -# $td->addContent (new HTMLempty ("br")); - - - $group_selection = _("Gruppierungsblock") - . " " - . Button::create(_('Erstellen'), - 'cmd[AddGroup]', - ['title' => _('Einen neuen Gruppierungsblock erstellen')]); - - $qgroup_selection = _("Fragenblock mit") - . " " - . $this->createTemplateSelection() - . Button::create(_('Erstellen'), - 'cmd[AddQGroup]', - ['title' => _('Einen neuen Fragenblock erstellen')]); - - $seperator = " | "; - - switch ($show) { - case ARRANGMENT_BLOCK: - $td->addHTMLContent($group_selection); - break; - case QUESTION_BLOCK: - $td->addHTMLContent($qgroup_selection); - break; - case "both": - $td->addHTMLContent( - $group_selection - . $seperator - . $qgroup_selection); - break; - } - - // abort-button - $child = $this->tree->eval->getNextChild(); - $number_of_childs = $this->tree->eval->getNumberChildren(); - if ($number_of_childs == 1 && - $this->itemID == ROOT_BLOCK && - $this->tree->eval->getTitle() == _("Neue Evaluation") && - $this->tree->eval->getText() == "" && - $child && - $child->getTitle() == _("Erster Gruppierungsblock") && - $child->getChildren() == NULL && - $child->getText == "") { - - - $cancel = $seperator . " "; - - $a_content = LinkButton::createCancel(_('Abbrechen'), - URLHelper::getURL(EVAL_FILE_ADMIN . "?evalID=" . $this->tree->eval->getObjectID() . "&abort_creation_button=1"), - ['title' => _("Erstellung einer Evaluation abbrechen")]); - - $cancel .= $a_content; - - $td->addHTMLContent($cancel); - - } - - $tr->addContent($td); - $table->addContent($tr); - - - return $table->createContent(); - } - - /** - * creates the html for the title and text input - * - * @access private - * @param string $mode - * @return string the html - */ - function createTitleInput($mode = ROOT_BLOCK) - { - - switch ($mode) { - - case ROOT_BLOCK: - $title_label = _("Titel der Evaluation"); - $title = htmlReady($this->tree->eval->getTitle()); - $text_label = _("Zusätzlicher Text"); - $text = wysiwygReady($this->tree->eval->getText()); - break; - - case ARRANGMENT_BLOCK: - $title_label = _("Titel des Gruppierungsblocks"); - $group = &$this->tree->getGroupObject($this->itemID); - $title = htmlReady($group->getTitle()); - $text_label = _("Zusätzlicher Text"); - $text = wysiwygReady($group->getText()); - break; - - case QUESTION_BLOCK: - $title_label = _("Titel des Fragenblocks"); - $title_info = _("Die Angabe des Titels ist bei einem Fragenblock optional."); - $group = &$this->tree->getGroupObject($this->itemID); - $title = htmlReady($group->getTitle()); - $text_label = _("Zusätzlicher Text"); - $text = wysiwygReady($group->getText()); - break; - } - $text_info = _("Die Angabe des zusätzlichen Textes ist optional."); - - $table = new HTML ("table"); - $table->addAttr("width", "98%"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("cellpadding", "0"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr('colspan', '2'); - $label = new HTML('label'); - $label->addContent($title_label); - if ($mode == QUESTION_BLOCK) - $label->addHTMLContent($this->createImage(EVAL_PIC_HELP, $title_info)); - - - $input = new HTMLempty ("input"); - $input->addAttr("type", "text"); - $input->addAttr("name", "title"); - $input->addString("value=\"" . $title . "\""); - $input->addAttr("size", "60"); - $input->addAttr("style", "vertical-align:middle; width: 100%;"); - - $label->addContent($input); - - $td->addContent($label); - $tr->addContent($td); - $table->addContent($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr('colspan', '2'); - - $label = new HTML('label'); - $label->addContent($text_label); - $label->addHTMLContent($this->createImage(EVAL_PIC_HELP, $text_info)); - - $textarea = "<br><textarea class=\"wysiwyg\" name=\"text\" rows=\"4\" " - . "style=\"vertical-align:top; width: 100%;\">"; - $textarea .= ($text) - ? $text - : ""; - $textarea .= "</textarea>"; - - $label->addHTMLContent($textarea); - $label->setTextareaCheck(); - - $td->addContent($label); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - /** - * creates the html for the update button - * - * @access private - * @param string $mode - * @return string the html - */ - function createUpdateButton($mode = NULL) - { - - $button = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" " - . "cellspacing=\"2\">\n" - . " <tr>\n" - . " <td align=center>\n" -// . " <input type=hidden name=\"cmd\" value=\"UpdateItem\">\n" - . Button::create(_('Übernehmen'), - 'cmd[UpdateItem]', - ['title' => _('Änderungen übernehmen.')]); - - if ($mode == NULL) { - $button .= " | " . _("Diesen Block") . " " - . Button::create(_('Löschen'), - 'cmd[AssertDeleteItem]', - ['title', _('Diesen Block und alle seine Unterblöcke löschen.')]); - } - - $button .= " </td>\n" - . " </tr>\n" -// . " </form></tr>\n" - . "</table>\n"; - return $button; - } - - /** - * creates the html for the global features-input - * - * @access private - * @return string the html - */ - function createGlobalFeatures() - { - - $table = new HTML ("table"); - $table->addAttr("width", "99%"); - $table->addAttr("border", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("cellspacing", "2"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "table_row_odd"); - $td->addAttr("colspan", "2"); - - $b = new HTML ("b"); - $b->addContent(_("Globale Eigenschaften")); - - $td->addContent($b); - $tr->addContent($td); - $table->addContent($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr('colspan', '2'); - - $div = new HTML('div'); - $div->addContent(_("Die Auswertung der Evaluation läuft")); - - $td->addContent($div); - - $section = new HTML('section'); - $section->addAttr('class', 'hgroup'); - - $l1 = new HTML('label'); - $input = new HTMLempty ("input"); - $input->addAttr("type", "radio"); - $input->addAttr("value", "1"); - $input->addAttr("name", "anonymous"); - if ($this->tree->eval->isAnonymous()) - $input->addAttr("checked", "checked"); - $l1->addContent($input); - $l1->addContent(_("anonym")); - - $l2 = new HTML('label'); - $input2 = new HTMLempty ("input"); - $input2->addAttr("type", "radio"); - $input2->addAttr("value", "0"); - $input2->addAttr("name", "anonymous"); - if (!$this->tree->eval->isAnonymous()) - $input2->addAttr("checked", "checked"); - $l2->addContent($input2); - $l2->addContent(_("personalisiert")); - - $section->addContent($l1); - $section->addContent($l2); - - $td->addContent($section); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - /** - * creates the html for the global features-input - * - * @access private - * @return string the html - */ - function createQuestionFeatures() - { - - $group = &$this->tree->getGroupObject($this->itemID); - $templateID = $group->getTemplateID(); - - if ($templateID) { - $template = new EvaluationQuestion($templateID); - $templateTitle = htmlReady($template->getText()); - } else - $templateTitle = NO_TEMPLATE_GROUP;//_("keine Vorlage"); - - if ($templateTitle == "") - $templateTitle = NO_TEMPLATE; - - $table = new HTML ("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "0"); - $table->addAttr("width", "98%"); -// $table->addAttr ("style", "border:5px solid white;"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("class", "table_row_odd"); - $td->addAttr("colspan", "2"); - - $b = new HTML ("b"); - $b->addContent(_("Eigenschaften")); - $b->addContent(":"); - - $td->addContent($b); - $tr->addContent($td); - $table->addContent($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("style", "border-bottom:0px dotted black;"); - $td->addContent(_("Die Fragen dieses Blocks müssen beantwortet werden (Pflichtfelder):")); - - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("style", "border-bottom:0px dotted black;"); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "radio"); - $input->addAttr("value", "0"); - $input->addAttr("name", "mandatory"); - if (!$group->isMandatory()) $input->addAttr("checked", "checked"); - - $td->addContent($input); - $td->addContent(_("nein")); - $td->addContent(new HTMLempty ("br")); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "radio"); - $input->addAttr("value", "1"); - $input->addAttr("name", "mandatory"); - if ($group->isMandatory()) $input->addAttr("checked", "checked"); - - $td->addContent($input); - $td->addContent(_("ja")); - - $tr->addContent($td); - $table->addContent($tr); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("style", "border-bottom:0px dotted black;"); - $td->addHTMLContent(sprintf(_("Diesem Fragenblock ist die Antwortenvorlage <b>%s</b> zugewiesen."), - $templateTitle)); - $text = _("Das Zuweisen einer Antwortenvorlage ändert alle Antwortenmöglichkeiten der Fragen dieses Fragenblocks."); - if ($templateTitle == NO_TEMPLATE_GROUP) - $text .= " " . _("Da dieser Fragenblock keine Antwortenvorlage benutzt, würde ein Zuweisen einer Antwortenvorlage zum Verlust aller eingegebenen Antworten führen."); - - $td->addHTMLContent($this->createImage(EVAL_PIC_HELP, - $text)); - - $tr->addContent($td); - - $td = new HTML ("td"); - $td->addAttr("style", "border-bottom:0px dotted black;"); - $td->addAttr("nowrap", "nowrap"); - $td->addHTMLContent($this->createTemplateSelection($templateID)); - $td->addContent(" "); - $td->addHTMLContent(Button::create(_('Zuweisen'), - 'cmd[ChangeTemplate]', - ['title' => _('Eine andere Antwortenvorlage für diesen Fragenblock auswählen')])); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } - - /** - * creates the html for the question-input - * - * @access private - * @return string the html - */ - function createQuestionForm() - { - - $qgroup = &$this->tree->getGroupObject($this->itemID); - $questions = $qgroup->getChildren(); - $templateID = $qgroup->getTemplateID(); - - $table = new HTML ("table"); - $table->addAttr("border", "0"); - $table->addAttr("align", "center"); - $table->addAttr("cellspacing", "0"); - $table->addAttr("cellpadding", "2"); - $table->addAttr("width", "98%"); - - $tr = new HTML ("tr"); - - $td = new HTML ("td"); - $td->addAttr("align", "center"); - - $table2 = new HTML ("table"); - $table2->addAttr("border", "0"); - $table2->addAttr("class", "blank"); - $table2->addAttr("cellspacing", "0"); - $table2->addAttr("cellpadding", "0"); - $table2->addAttr("width", "100%"); - - // captions - $tr2 = new HTML ("tr"); - - $showclass = "table_row_odd"; - - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - $td2->addAttr("align", "center"); - $td2->addAttr("width", "15"); - - $b = new HTML ("b"); - $b->addContent("#"); - - $td2->addContent($b); - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - - $b = new HTML ("b"); - $b->addContent(_("Frage")); - - $td2->addContent($b); - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - - if (count($questions) > 1) { - $b = new HTML ("b"); - $b->addContent(_("Position")); - - $td2->addContent($b); - - } else { - - $td2->addContent(""); - - } - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - - $b = new HTML ("b"); - $b->addContent(_("Löschen")); - - $td2->addContent($b); - $tr2->addContent($td2); - - // only if template is NO_TEMPLATE_GROUP - if ($templateID == NULL) { - $td2 = new HTML ("td"); - $td2->addAttr("class", $showclass); - - $b = new HTML ("b"); - $b->addContent(_("Antworten")); - - $td2->addContent($b); - $tr2->addContent($td2); - } - - $table2->addContent($tr2); - - $i = 0; - foreach ($questions as $question) { - $tr2 = new HTML ("tr"); - - // brrr :) - // extract the questionID from the command - foreach ($_REQUEST as $key => $value) { - if (preg_match("/template_(.*)_button?/", $key, $command)) - break; - } - if (isset($command[1]) && preg_match("/(.*)_#(.*)/", $command[1], $command_parts)) - $questionID = $command_parts[2]; - else - $questionID = Request::submitted('template_save2_button') ? "" : Request::get("template_id"); - - if ($question->getObjectID() == $questionID) - $tr2->addAttr("class", "eval_highlight"); - else - $tr2->addAttr("class", ($i % 2 == 1 ? "table_row_odd" : "table_row_even")); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - - $font = new HTML ("font"); - $font->addAttr("size", "-1"); - $font->addContent(($i + 1) . "."); - - $td2->addContent($font); - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "left"); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "tex"); - $input->addAttr("size", "70"); - $input->addAttr("name", "questions[$i][text]"); - $input->addAttr("value", $question->getText()); - $input->addAttr("tabindex", 3 + $i); - - $td2->addContent($input); -# $td2->addHTMLContent ("POST: -".$question->getPosition()."-!"); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("name", "questions[$i][questionID]"); - $input->addAttr("value", $question->getObjectID()); - - $td2->addContent($input); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("name", "questions[$i][position]"); - $input->addAttr("value", $question->getPosition()); - - $td2->addContent($input); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "hidden"); - $input->addAttr("name", "questions[$i][counter]"); - $input->addAttr("value", $question->getPosition()); - - $td2->addContent($input); - - $tr2->addContent($td2); - - // move-up/down arrows and counter - if (count($questions) > 1) { - - $numberchildren = $qgroup->getNumberChildren(); - - if ($question->getPosition() == 0) - $tooltipup = _("Diese Frage mit der letzten Frage vertauschen."); - else - $tooltipup = _("Diese Frage eine Position nach oben verschieben."); - - if ($question->getPosition() == $numberchildren - 1) - $tooltipdown = _("Diese Frage mit der ersten Frage vertauschen."); - else - $tooltipdown = _("Diese Frage eine Position nach unten verschieben."); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "cmd_MoveQuestionUp_#" . $question->getObjectID() . "_§" . $question->getPosition() . "_button"); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", EVAL_PIC_MOVE_UP); - $button->addString(Tooltip($tooltipup)); - - $td2->addContent($button); - - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "cmd_MoveQuestionDown_#" . $question->getObjectID() . "_§" . $question->getPosition() . "_button"); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", EVAL_PIC_MOVE_DOWN); - $button->addString(Tooltip($tooltipdown)); - - $td2->addContent($button); - - } else { - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - $td2->addContent(" "); - } - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - - $input = new HTMLempty ("input"); - $input->addAttr("type", "checkbox"); - $input->addAttr("id", "deleteCheckboxes"); - $input->addAttr("name", "DeleteQuestions[" . $question->getPosition() . "]"); - - $td2->addContent($input); - $tr2->addContent($td2); - - // if template is NO_TEMPLATE_GROUP - if ($templateID == NULL) { - - // hat noch keine antworten - if ($question->getChildren() == NULL) { - $image = EVAL_PIC_CREATE_ANSWERS; - $text = _("Dieser Frage wurden noch keine Antwortenmöglichkeiten zugewiesen. Drücken Sie auf den Doppelfpeil, um dies jetzt zu tun."); - $tooltip = tooltip(_("Dieser Frage Antwortenmöglichkeiten zuweisen.")); - } else { - $image = EVAL_PIC_EDIT_ANSWERS; - $text = _("Dieser Frage wurden bereits folgende Antwortenmöglichkeiten zugewiesen:") - . " "; - $tooltip = tooltip(_("Die zugewiesenen Antwortenmöglichkeiten bearbeiten.")); - $text .= "\n"; - while ($answer = $question->getNextChild()) { - $text .= "\"" . $answer->getText() . "\"\n "; - } - $text .= ""; - } - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - $td2->addAttr("valign", "middle"); - $td2->addHTMLContent( - $this->createImage(EVAL_PIC_HELP, $text)); - - $questionID = $question->getObjectID(); - - $button = new HTMLempty ("input"); - $button->addAttr("type", "image"); - $button->addAttr("name", "template_create_question_answers_#" . $questionID . "_button"); - $button->addAttr("style", "vertical-align:middle;"); - $button->addAttr("border", "0"); - $button->addAttr("src", $image); - $button->addString($tooltip); - - $td2->addContent($button); - - - $tr2->addContent($td2); - } - - $table2->addContent($tr2); - $i++; - } - - if (sizeof($questions) == 0) { - - $tr2 = new HTML ("tr"); - $td2->addAttr("class", "table_row_even"); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "center"); - $td2->addContent(" "); - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addContent(_("Dieser Block besitzt keine Fragen.")); - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addContent(" "); - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addContent(" "); - - $tr2->addContent($td2); - $table2->addContent($tr2); - } - - $td->addContent($table2); - - // the new questions und delete questions buttons - $table2 = new HTML ("table"); - $table2->addAttr("width", "100%"); - $table2->addAttr("border", "0"); - $table2->addAttr("class", - ($i % 2 == 6) - ? "content_body" - : "content_body"); - $table2->addAttr("cellspacing", "0"); - $table2->addAttr("cellpadding", "2"); - - // buttons - $tr2 = new HTML ("tr"); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "left"); - - $select = new HTML ("select"); - $select->addAttr("style", "vertical-align:middle;"); - $select->addAttr("name", "newQuestionFields"); - $select->addAttr("size", "1"); - - for ($i = 1; $i <= 10; $i++) { - - $option = new HTML ("option"); - $option->addAttr("value", $i); - $option->addContent($i); - - $select->addContent($option); - } - - $td2->addContent($select); - $td2->addContent(_("Frage/en")); - $td2->addContent(" "); - $td2->addHTMLContent( - Button::create(_('Hinzufügen'), - 'cmd[AddQuestions]', - ['title' => _('Fragen hinzufügen')]) - ); - - $tr2->addContent($td2); - - $td2 = new HTML ("td"); - $td2->addAttr("align", "right"); - - $font = new HTML ("font"); - $font->addAttr("size", "-1"); - $font->addContent(_("markierte Fragen ")); - - $td2->addContent($font); - $td2->addHTMLContent( - Button::create(_('Löschen'), - 'cmd[DeleteQuestions]', - ['title' => _('Markierte Fragen löschen')]) - ); - - $tr2->addContent($td2); - $table2->addContent($tr2); - - $td->addContent($table2); - $tr->addContent($td); - $table->addContent($tr); - - return $table->createContent(); - } -# ######################################################## end: HTML functions # - - -################################################################################ -# # -# additional HTML functions # -# # -################################################################################ - - /** - * creates a link-image - * - * @access private - * @param string $pic the image - * @param string $alt the alt-text (optional) - * @param string $value the value (optional) - * @param boolean $tooltip display as tooltip? (optional) - * @param string $args additional options (optional) - * @param boolean $self get self? (optional) - * @return string the image with a link (html) - */ - function createLinkImage($pic, - $alt = "", - $value = "", - $tooltip = true, - $args = NULL, - $self = true) - { - - $a = new HTML ("a"); - $a->addAttr("href", URLHelper::getLink($this->getSelf($value))); - - $img = new HTMLempty ("img"); - $img->addAttr("src", $pic); - $img->addAttr("border", "0"); - $img->addAttr("style", "vertical-align:middle;"); - if ($tooltip) - $img->addString(tooltip($alt, TRUE, TRUE)); - else - $img->addAttr("alt", $alt); - if ($args) - $img->addString($args); - - $a->addContent($img); - - return $a->createContent(); - } - - - /** - * creates an image - * - * @access private - * @param string $pic the image - * @param string $alt the alt-text (optional) - * @param string $args additional options (optional) - * @return string the image (html) - */ - function createImage($pic, - $alt = "", - $args = NULL) - { - - if (!isset($args['alt'])) { - $args['alt'] = $alt; - $args['title'] = $alt; - } - - $args['border'] = 0; - $args['style'] = "vertical-align:middle;"; - - $img = new HTMLempty ("img"); - $img->addString(tooltip($alt, TRUE, TRUE)); - $img->addAttr("src", $pic); - $img->addAttr("border", "0"); - $img->addAttr("style", "vertical-align:middle;"); - if (empty($args)) { - $img->addAttr("alt", $alt); - $img->addAttr("title", $alt); - } else - $img->addString($alt); - if ($args) ; - $img->addString($args); - - return $img->createContent(); - } - - - /** - * creates an td with an image - * - * @access private - * @param string $pic the image - * @return string the image - */ - function createLevelOutputTD($pic = "forumleer.gif") - { - $td = new HTML ("td"); - $td->addAttr("class", "blank"); - $td->addAttr("background", Assets::image_path($pic)); - - $img = new HTMLempty ("img"); - $img->addAttr("width", "10"); - $img->addAttr("height", "20"); - $img->addAttr("src", Assets::image_path($pic)); - - $td->addContent($img); - - return $td->createContent(); - } - - - /** - * creates the template selection - * - * @access private - * @param string $selected the entry to be preselected (optional) - * @return string the html - */ - function createTemplateSelection($selected = NULL) - { - global $user; - - $question_show = new EvaluationQuestionDB(); - $arrayOfTemplateIDs = $question_show->getTemplateID($user->id); - $arrayOfPolTemplates = []; - $arrayOfSkalaTemplates = []; - $arrayOfNormalTemplates = []; - $arrayOfFreetextTemplates = []; - - if (is_array($arrayOfTemplateIDs)) { - foreach ($arrayOfTemplateIDs as $templateID) { - $question = new EvaluationQuestion ($templateID, NULL, - EVAL_LOAD_FIRST_CHILDREN); - $question->load(); - $questiontyp = $question->getType(); - - $questiontext = $question->getText(); - - if ($question->getParentID() == '0') - $questiontext .= " " . EVAL_ROOT_TAG; - - - switch ($questiontyp) { - - case EVALQUESTION_TYPE_POL: - array_push($arrayOfPolTemplates, [$question->getObjectID(), - ($questiontext)]); - break; - - case EVALQUESTION_TYPE_LIKERT: - array_push($arrayOfSkalaTemplates, [$question->getObjectID(), - ($questiontext)]); - break; - - case EVALQUESTION_TYPE_MC: - $answer = $question->getNextChild(); - if ($answer && $answer->isFreetext()) - array_push($arrayOfFreetextTemplates, [ - $question->getObjectID(), - ($questiontext)]); - else - array_push($arrayOfNormalTemplates, [ - $question->getObjectID(), - ($questiontext)]); - break; - } - } - - } // End: if (is_array ($arrayOfTemplateIDs)) - - - $select = new HTML ("select"); - $select->addAttr("name", "templateID"); - $select->addAttr("style", "vertical-align:middle; max-width: 250px;"); - - $option = new HTML ("option"); - $option->addAttr("value", ""); - $option->addContent(NO_TEMPLATE_GROUP); - - $select->addContent($option); - - - if (!empty($arrayOfPolTemplates) && is_array($arrayOfPolTemplates)) { - - $optgroup = new HTML ("optgroup"); - $optgroup->addAttr("label", _("Polskalen:")); - - foreach ($arrayOfPolTemplates as $template) { - $option = new HTML ("option"); - $option->addAttr("value", $template[0]); - if ($template[0] == $selected) - $option->addAttr("selected", "selected"); - $option->addHTMLContent($template[1]); - $optgroup->addContent($option); - } - - $select->addContent($optgroup); - - } - - - if (!empty($arrayOfSkalaTemplates) && is_array($arrayOfSkalaTemplates)) { - - $optgroup = new HTML ("optgroup"); - $optgroup->addAttr("label", _("Likertskalen:")); - - foreach ($arrayOfSkalaTemplates as $template) { - $option = new HTML ("option"); - $option->addAttr("value", $template[0]); - if ($template[0] == $selected) - $option->addAttr("selected", "selected"); - $option->addContent($template[1]); - $optgroup->addContent($option); - } - - $select->addContent($optgroup); - - } - - - if (!empty($arrayOfNormalTemplates) && is_array($arrayOfNormalTemplates)) { - - $optgroup = new HTML ("optgroup"); - $optgroup->addAttr("label", _("Multiple Choice:")); - - foreach ($arrayOfNormalTemplates as $template) { - $option = new HTML ("option"); - $option->addAttr("value", $template[0]); - if ($template[0] == $selected) - $option->addAttr("selected", "selected"); - $option->addContent($template[1]); - $optgroup->addContent($option); - } - - $select->addContent($optgroup); - - } - - - if (!empty($arrayOfFreetextTemplates) && is_array($arrayOfFreetextTemplates)) { - - $optgroup = new HTML ("optgroup"); - $optgroup->addAttr("label", _("Freitextantworten:")); - - foreach ($arrayOfFreetextTemplates as $template) { - $option = new HTML ("option"); - $option->addAttr("value", $template[0]); - if ($template[0] == $selected) - $option->addAttr("selected", "selected"); - $option->addContent($template[1]); - $optgroup->addContent($option); - } - - $select->addContent($optgroup); - - } - - return $select->createContent(); - - } - -# ############################################# end: additional HTML functions # - - -################################################################################ -# # -# additional functions # -# # -################################################################################ - - /** - * detects the type of an object by its itemID - * - * @access private - * @param string $itemID - * @return string the insctance of an object - */ - function getInstance($itemID) - { - - if ($itemID == ROOT_BLOCK || $itemID == $this->evalID) - return ROOT_BLOCK; - else { - $tree = TreeAbstract::GetInstance("EvaluationTree", ['evalID' => $this->evalID, - 'load_mode' => EVAL_LOAD_FIRST_CHILDREN]); - $group = &$tree->getGroupObject($itemID); - $childtype = $group->getChildType(); - - if ($childtype == "EvaluationQuestion") - return QUESTION_BLOCK; - else - return ARRANGMENT_BLOCK; - } - } - - - /** - * swaps positions of two objects - * - * @access private - * @param string $parentID the parentID - * @param string $objectID the object to swap - * @param string $oldposition the old position - * @param string $direction the direction to swap - */ - function swapPosition($parentID, - $objectID, - $oldposition, - $direction) - { - - if ($parentID == ROOT_BLOCK) $group = $this->tree->eval; - else $group = &$this->tree->getGroupObject($parentID); - - $numberchildren = $group->getNumberChildren(); - - if ($direction == "up") { - if ($oldposition == 0) - $newposition = $numberchildren - 1; - else - $newposition = $oldposition - 1; - } else { - if ($oldposition == $numberchildren - 1) - $newposition = 0; - else - $newposition = $oldposition + 1; - } - - while ($swapitem = $group->getNextChild()) { - if ($swapitem->getPosition() == $newposition) { - $swapitem->setPosition($oldposition); - $swapitem->save(); - } - } - if (($parentID != ROOT_BLOCK) && - $group->getChildType() == "EvaluationQuestion") - $object = new EvaluationQuestion ($objectID); - else - $object = &$this->tree->getGroupObject($objectID); - $object->setPosition($newposition); - $object->save(); - - if (!empty($swapitem->isError)) { - return MessageBox::error(_("Fehler beim verschieben.")); - } - if (!empty($object->isError)) { - return MessageBox::error(_("Fehler beim verschieben.")); - } - } -} diff --git a/lib/evaluation/classes/EvaluationTreeShowUser.class.php b/lib/evaluation/classes/EvaluationTreeShowUser.class.php deleted file mode 100644 index e999cb5..0000000 --- a/lib/evaluation/classes/EvaluationTreeShowUser.class.php +++ /dev/null @@ -1,539 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +---------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +---------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +---------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +---------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once HTML; -# ====================================================== end: including files # - -# Define constants ========================================================== # - -/** - * The number of pixels by which each sub-group is indented. - * @const INDENT_PIXELS - * @access private - */ -define("INDENT_PIXELS", 5); - -# ===================================================== end: define constants # - - -/** - * Class to print out html representation of an evaluation's tree - * for the participation page - * (based on /lib/classes/TreeView.class) - * - * @author mcohrs <michael A7 cohrs D07 de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - */ -class EvaluationTreeShowUser -{ - - /** - * Reference to the tree structure - * - * @access private - * @var object EvaluationTree $tree - */ - var $tree; - - /** - * contains the item with the current html anchor (currently unused) - * - * @access public - * @var string $anchor - */ - var $anchor; - - /** - * the item to start with - * - * @access private - * @var string $start_item_id - */ - var $start_item_id; - - - /** - * constructor - * @access public - * @param string the eval's ID - */ - public function __construct($evalID) - { - - $this->tree = TreeAbstract::GetInstance("EvaluationTree", ['evalID' => $evalID, - 'load_mode' => EVAL_LOAD_ALL_CHILDREN]); - - } - - - /** - * prints out the tree beginning with a given item - * - * @access public - * @param string ID of the start item, shouldnt be needed. - */ - public function showTree($item_id = "root") - { - $items = []; - - if (!is_array($item_id)) { - $items[0] = $item_id; - $this->start_item_id = $item_id; - } else { - $items = $item_id; - } - - $num_items = count($items); - for ($j = 0; $j < $num_items; ++$j) { - - $this->printLevelOutput($items[$j]); - $this->printItemOutput($items[$j]); - - if ($this->tree->hasKids($items[$j])) { - $this->showTree($this->tree->tree_childs[$items[$j]]); - } - } - return; - } - - - /** - * prints out ... hmm ... the group's level indentation space, and a table start - * - * @access private - * @param string ID of the item (which is an EvaluationGroup) to print the space for. - */ - public function printLevelOutput($group_id) - { - if ($group_id == "root") - return; - - $level_output = ""; - - $parent_id = $group_id; - while ($this->tree->tree_data[$parent_id]['parent_id'] != $this->start_item_id) { - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - - /* a little space to indent subgroups */ - $level_output .= - "<td valign=\"top\" width=\"" . INDENT_PIXELS . "\" height=\"1\" nowrap>" . - Assets::img('forumleer.gif', ['size' => INDENT_PIXELS . '@1']) . - "</td>"; - } - - echo "<!-- printLevelOutput ----------------- -->\n"; - echo "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"0\">\n"; - echo "<tr>\n"; - echo $level_output; - return; - } - - - /** - * prints out one group - * - * @access private - * @param string ID of the item to print (which is an EvaluationGroup). - */ - public function printItemOutput($group_id) - { - if ($group_id == "root") - return; - $group = &$this->tree->getGroupObject($group_id); - - echo "<td width=\"1\">\n"; - echo "</td>\n"; - - /* show group headline, if it's not a question group */ - if ($group->getChildType() != "EvaluationQuestion") { - - /* add space after a top-level group */ - $parent = $group->getParentObject(); - if ($parent->x_instanceof() == "Evaluation" && $group->getPosition() != 0) - echo "<td colspan=\"2\" width=\"100%\"><br></td><tr>"; - - echo "<td align=\"left\" width=\"100%\" valign=\"bottom\" class=\"content_body\" style=\"padding:1px;\">\n"; - $parent_id = $group_id; - $chapter_num = ''; - while ($parent_id != "root") { - $chapter_num = ($this->tree->tree_data[$parent_id]['priority'] + 1) . "." . $chapter_num; - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - } - echo " " . $chapter_num . " "; - echo "<b>"; - echo htmlReady($this->tree->tree_data[$group_id]['name']); - echo "</b>"; - echo "</td>"; - - echo "<td width=\"1\">\n"; - echo Assets::img('forumleer.gif', ['size' => '2@1']); - echo "</td>\n"; - - } else { - echo "<td width=\"100%\"></td>"; - } - - echo "</tr>\n"; - echo "</table>\n"; - - $this->printItemDetails($group); - - return; - } - - - /** - * prints out the details for a group - * - * @access private - * @param object EvaluationGroup the group object. - */ - public function printItemDetails($group) - { - $group_id = $group->getObjectID(); - - $parent_id = $group_id; - $level_output = ''; - while ($this->tree->tree_data[$parent_id]['parent_id'] != $this->start_item_id) { - $parent_id = $this->tree->tree_data[$parent_id]['parent_id']; - - /* a little space to indent subgroups */ - $level_output = "<td width=\"" . INDENT_PIXELS . "\">" . - Assets::img('forumleer.gif', ['size' => INDENT_PIXELS . '@1']) . - "</td>" . - $level_output; - } - - /* print table */ - echo "<!-- printItemDetails ----------------- -->\n"; - echo "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"100%\">\n"; - echo "<tr>\n" . $level_output; - echo "<td class=\"printcontent\" width=\"100%\" " . - ($group->getChildType() == "EvaluationQuestion" - ? ">" - : ">"); - echo $this->getGroupContent($group); - echo "</td></tr>\n"; - echo "</table>\n"; - return; - } - - - /** - * returns html for the content of a group - * - * @access private - * @param object EvaluationGroup the group object. - * @return string - */ - public function getGroupContent($group) - { - $closeTable = NO; - $html = ""; - $content = ""; - - /* get title */ - $content .= $group->getChildType() == "EvaluationQuestion" && $group->getTitle() - ? "<b>" . formatReady($group->getTitle()) . "</b><br>\n" - : ""; - - /* get text */ - $content .= $group->getText() - ? formatReady($group->getText()) . "<br>\n" - : ""; - - /* get the content of questions under this group, if any */ - foreach ($group->getChildren() as $question) { - if ($question->x_instanceof() == INSTANCEOF_EVALQUESTION) { - - if ($question->getPosition() == 0) { - $content .= "\n<table width=\"100%\" cellpadding=\"3\" cellspacing=\"0\" " . - "align=\"center\" style=\"margin-top:3px;\">\n"; - } - - $content .= $this->getQuestionContent($question, $group); - $closeTable = YES; - } - } - if ($closeTable) - $content .= "</table>\n"; - - /* return if there is nothing to show */ - if (empty($content)) - return ""; - - /* build table of content */ - $style = $group->getChildType() != "EvaluationQuestion" - ? "" - : ""; - - $class = $group->getChildType() != "EvaluationQuestion" - ? "eval_gray" - : "steelgroup7"; - $html .= "\n<!-- getGroupContent ----------------- -->\n"; - $html .= "<table width=\"100%\" cellpadding=\"2\" cellspacing=\"2\" align=\"center\" " . $style . ">\n"; - $html .= "<tr>\n"; - $html .= "<td align=\"left\" class=\"" . $class . "\">\n"; - $html .= $content; - $html .= "</td></tr>\n"; - $html .= "</table>\n"; - - return $html; - } - - - /** - * returns html for a question and its answers - * - * @access private - * @param object EvaluationQuestion the question object. - * @param object EvaluationGroup the question's parent-group object. - * @return string - */ - public function getQuestionContent($question, $group) - { - $type = $question->isMultipleChoice() ? "checkbox" : "radio"; - $answerBorder = "1px dotted #909090"; - $residualBorder = "1px dotted #909090"; - $answerArray = $question->getChildren(); - $hasResidual = NO; - $leftOutStyle = ($group->isMandatory() && - Request::submitted('voteButton') && - is_array($GLOBALS["mandatories"]) && - in_array($question->getObjectID(), $GLOBALS["mandatories"])) - ? "background-image:url(" . Assets::image_path("steelgroup1.gif") . "); border-left:3px solid red; border-right:3px solid red;" - : ""; - - $html = ''; - $cellWidth = null; - /* Skala (one row question) ---------------------------------------- */ - if ($question->getType() == EVALQUESTION_TYPE_LIKERT || $question->getType() == EVALQUESTION_TYPE_POL) { - - if (($numAnswers = $question->getNumberChildren()) > 0) - $cellWidth = (int)(40 / $numAnswers); - - if ($numAnswers > 0 && $answerArray[$numAnswers - 1]->isResidual()) - $hasResidual = YES; - - $lastTextAnswer = $hasResidual ? ($numAnswers - 3) : ($numAnswers - 2); - - /* Headline, only shown for first question */ - if ($question->getPosition() == 0) { - $html .= " <tr>\n"; - $html .= " <td width=\"60%\" style=\"border-bottom: $answerBorder; border-top: $answerBorder;\">"; -# $html .= mb_strlen( $group->getText() ) < 100 ? formatReady( $group->getText() ) : " "; - $html .= " "; - $html .= "</td>\n"; - foreach ($answerArray as $answer) { - $noWrap = NO; - - if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) { - if (!$answer->getText()) { - /* answer has NO text ------------ */ - if ($answer->getPosition() <= $lastTextAnswer / 2) //&& $numAnswers > 4 ) - $headCell = "<--"; - elseif ($answer->getPosition() >= round($lastTextAnswer / 2) + $lastTextAnswer % 2) //&& $numAnswers > 4 ) - $headCell = "-->"; - else - $headCell = "<- ->"; - - $noWrap = YES; - } else { - /* answer has its own text ------ */ - $headCell = formatReady($answer->getText()); - } - - $extraStyle = ""; - if ($answer->isResidual()) { - $extraStyle = "border-left: $residualBorder;"; - $html .= - "<td align=\"center\" style=\"$extraStyle\" " . - "width=\"1\"> </td>"; - } - - $html .= - " <td align=\"center\" class=\"steelgroup6\" " . - "style=\"border-bottom: $answerBorder; " . - "border-left: $answerBorder; border-top: $answerBorder; $extraStyle;\" " . - "width=\"" . $cellWidth . "%\" " . ($noWrap ? "nowrap" : "") . ">"; - $html .= $headCell; - $html .= "</td>\n"; - } - } - $html .= " </tr>\n"; - } - $class = $question->getPosition() % 2 ? "table_row_even" : "table_row_odd"; - $extraStyle = ($question->getPosition() == $group->getNumberChildren() - 1 - ? "border-bottom: $answerBorder" - : ""); - $html .= " <tr class=\"" . $class . "\">\n"; - $html .= " <td align=\"left\" width=\"60%\" style=\"$extraStyle; $leftOutStyle;\">"; - $html .= formatReady($question->getText()); - $html .= ($group->isMandatory() ? "<span class=\"eval_error\"><b>**</b></span>" : ""); - $html .= "</td>\n"; - - foreach ($answerArray as $answer) { - $number = $question->isMultipleChoice() ? "[" . $answer->getPosition() . "]" : ""; - - if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) { - $extraStyle = ""; - if ($answer->isResidual()) { - $extraStyle = "border-left: $residualBorder;"; - $html .= - "<td align=\"center\" class=\"steelgroup7\" style=\"$extraStyle\" " . - "width=\"1%\"> </td>"; - } - - $extraStyle .= ($question->getPosition() == $group->getNumberChildren() - 1 - ? " border-bottom: $answerBorder;" - : ""); - $answers = Request::getArray('answers'); - $checked = isset($answers[$question->getObjectID()]) && $answers[$question->getObjectID()] == $answer->getObjectID() ? "checked" : ""; - - $html .= " <td align=\"center\" style=\"border-left: $answerBorder; $extraStyle;\" " . - "width=\"" . $cellWidth . "%\">"; - $html .= "<input type=\"" . $type . "\" name=\"answers[" . $question->getObjectID() . "]" . $number . "\" " . - "value=\"" . $answer->getObjectID() . "\" " . $checked . ">"; - $html .= "</td>\n"; - } - } - $html .= " </tr>\n"; - /* -------------------------------------------- */ - } /* Normal (question with long answers) ----------------------------- */ - else { - $class = $question->getPosition() % 2 ? "table_row_even" : "table_row_odd"; - - /* Question ----------------------------------- */ - $html .= - "<tr class=\"" . $class . "\">" . - "<td align=\"left\" style=\"$leftOutStyle;\">" . - formatReady($question->getText()) . - ($group->isMandatory() ? "<span class=\"eval_error\"><b>**</b></span>" : "") . - "</td>" . - "</tr>\n"; - - $html .= "<tr class=\"" . $class . "\">"; - $html .= "<td>"; - $html .= "<table border=\"0\" cellspacing=\"0\" cellpadding=\"3\">\n"; - /* -------------------------------------------- */ - - $numberOfVisibleAnswers = 0; - foreach ($answerArray as $answer) - if (!($answer->isFreetext() && $answer->getText() != '')) - $numberOfVisibleAnswers++; - - if ($numberOfVisibleAnswers == 0) { - $html .= "<tr valign=\"middle\">\n"; - $html .= - "<td class=\"eval_error\">" . - _("Dieser Frage wurden keine Antworten zugeordnet!") . - "</td>\n"; - $html .= "</tr>\n"; - } - - /* Answers ------------------------------------ */ - foreach ($answerArray as $answer) { - if ($answer->x_instanceof() == INSTANCEOF_EVALANSWER) { - $number = $question->isMultipleChoice() ? "[" . $answer->getPosition() . "]" : ""; - - /* if not a user's answer */ - if (!($answer->isFreetext() && $answer->getText() != '')) { - $html .= "<tr valign=\"middle\">\n"; - - /* show text input field ---------- */ - if ($answer->isFreetext()) { - - // not really needed anymore - if ($numberOfVisibleAnswers > 1) - /* show a check/radio-box */ - $html .= - "<td width=\"2%\">" . - "<input type=\"" . $type . "\"" . - " name=\"answers[" . $question->getObjectID() . "]" . $number . "\"" . - " value=\"" . $answer->getObjectID() . "\">" . - "</td>\n"; - - /* one row input field */ - $freetexts = Request::getArray('freetexts'); - if ($answer->getRows() == 1) - $html .= - "<td colspan=\"2\">" . - "<input type=\"text\"" . - " name=\"freetexts[" . $question->getObjectID() . "]\"" . - " value=\"" . htmlReady(isset($freetexts[$question->getObjectID()]) ? $freetexts[$question->getObjectID()] : '') . "\" size=\"60\">" . - "</td>\n"; - - /* multiple row input field (textarea) */ - else - $html .= - "<td colspan=\"2\">" . - "<textarea" . - " name=\"freetexts[" . $question->getObjectID() . "]\"" . - " cols=\"60\" rows=\"" . $answer->getRows() . "\">" . - htmlReady(isset($freetexts[$question->getObjectID()]) ? $freetexts[$question->getObjectID()] : '') . - "</textarea>" . - "</td>\n"; - } /* show normal answer ------------- */ - else { - $answers = Request::getArray('answers'); - /* see if it must be checked */ - if ($type == "radio") - $checked = isset($answers[$question->getObjectID()]) && $answers[$question->getObjectID()] == $answer->getObjectID() - ? "checked" - : ""; - else - $checked = (is_array($answers[$question->getObjectID()]) && - in_array($answer->getObjectID(), $answers[$question->getObjectID()])) - ? "checked" - : ""; - - /* show a check/radio-box */ - $html .= - "<td width=\"2%\">" . - "<input type=\"" . $type . "\"" . - " name=\"answers[" . $question->getObjectID() . "]" . $number . "\"" . - " value=\"" . $answer->getObjectID() . "\" " . $checked . ">" . - "</td>\n"; - $html .= - "<td align=\"left\" width=\"98%\">" . - formatReady($answer->getText()) . - "</td>\n"; - } - $html .= "</tr>\n"; - } - } - /* ------------------------------- End: Answers */ - } - - $html .= "</table>\n"; - $html .= "</td></tr>"; - } - - return $html; - } -} diff --git a/lib/evaluation/classes/HTML.class.php b/lib/evaluation/classes/HTML.class.php deleted file mode 100644 index 50b01eb..0000000 --- a/lib/evaluation/classes/HTML.class.php +++ /dev/null @@ -1,185 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * HTML-class for the Stud.IP-project. - * Based on scripts from "http://tut.php-q.net/". - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * - */ - -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ -require_once 'HTMLempty.class.php'; - -class HTML extends HTMLempty -{ - /** - * Holds the content. - * - * @access private - * @var object $_content - */ - var $_content; - - /** - */ - var $has_textarea = false; - - public function addHTMLContent($_content) - { - if (is_object($_content)) { - $classname = mb_strtolower(get_class($_content)); - $valid_classes = ['htmlempty', 'html', 'htm', 'htmpty', 'studip\button', 'studip\linkbutton', 'messagebox']; - if (in_array($classname, $valid_classes)) { - $this->_content[] = $_content; - } else { - trigger_error('Ungültiges Objekt: "' . $classname . '"', E_USER_ERROR); - } - } elseif (is_scalar($_content)) { - $this->_content[] = (string)$_content; - } else { - echo "Fehler in HTML.class.php: Es fehlt ein addHTMLContent-Element für ein Element des Typs \"<" . $this->getName() . ">\"<br>"; - } - } - - public function addContent($_content) - { - if (is_object($_content)) { - $this->addHTMLContent($_content); - } elseif (is_scalar($_content)) { - $this->addHTMLContent(htmlReady(((string)$_content))); - } else { - $this->addHTMLContent(""); - } - } - - /** - * - */ - public function getContent() - { - return $this->_content; - } - - /** - * avoid indentation of <textarea>... - */ - public function setTextareaCheck() - { - $this->has_textarea = true; - } - - /** - * - */ - public function printContent($indent = 0) - { - echo $this->createContent($indent); - } - - /** - * - */ - public function createContent($indent = 0) - { - $output = ""; - - $str_indent = str_repeat(' ', $indent); - - $_content = $this->getContent(); - $output .= ($str_indent . "<" . $this->getName()); - - $attribute = $this->getAttr(); - foreach ($attribute as $name => $value) { - $output .= (' ' . $name . '="' . $value . '"'); - } - - $output .= $this->_string; - $output .= (">\n"); - if (!is_array($_content)) { - $attributes = ""; - foreach ($attribute as $name => $value) { - $attributes .= ($name . '=>"' . $value . '"; '); - } - print "Fehler in HTML.class.php: Es fehlt ein Content-Element für ein Element des Typs \"<" . $this->getName() . ">\" (Attribute: $attributes)."; - - return; - } - - foreach ($_content as $content) { - if (is_object($content)) { - // der aktuelle Content ist ein Object - // also ein HTML-Element. Also geben - // wir es aus - $classname = mb_strtolower(get_class($content)); - $valid_classes = ['studip\button', 'studip\linkbutton', 'messagebox']; - if (in_array($classname, $valid_classes)) { - $output .= $content; - } else { - $output .= $content->createContent($indent + 4); - } - // Rekursion lässt grüßen ... - } else { - // Content ist ein String. Jeden Zeile - // geben wir getrennt aus - $zeilen = explode("\n", $content); - $echo = ""; - - if ($this->has_textarea) { - - // look for textarea in content - $text_area = false; - foreach ($zeilen as $zeile) { - - if (mb_strstr($zeile, "<textarea")) - $text_area = true; - - if ($text_area) - $echo .= $zeile . "\n"; - else - $echo .= $str_indent . " " . $zeile . "\n"; - - if (mb_strstr($zeile, "</textarea")) - $text_area = false; - } - } else { - // standard - foreach ($zeilen as $zeile) { - $echo .= $str_indent . " " . $zeile . "\n"; - } - } - $output .= $echo; - } - } - $output .= ($str_indent . "</" . $this->getName() . ">\n"); - - return $output; - } -} - -include_once("LazyHTML.class.php"); - diff --git a/lib/evaluation/classes/HTMLempty.class.php b/lib/evaluation/classes/HTMLempty.class.php deleted file mode 100644 index 574816f..0000000 --- a/lib/evaluation/classes/HTMLempty.class.php +++ /dev/null @@ -1,184 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * HTML-class for the Stud.IP-project. - * Based on scripts from "http://tut.php-q.net/". - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * - */ - -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - -class HTMLempty -{ - -# Define all required variables ============================================= # - /** - * Holds the name of the element. - * - * @access private - * @var string $_name - */ - var $_name = ""; - - /** - * Holds the attributes of the element. - * - * @access private - * @var array $_attribute - */ - var $_attribute = []; - - /** - * Holds additional attributes (strings generated from studip functions) - * - * @access private - * @var array $_string - */ - var $_string = ""; -# ============================================================ end: variables # - - -# Define constructor and destructor ========================================= # - public function __construct($name) - { - if (preg_match('/^[a-zA-Z.:][\w\-_\.:]*$/i', $name)) { - $this->_name = $name; - } else { - trigger_error("Unerlaubter Name für ein HTML-Element : '" . $name . "'", E_USER_ERROR); - } - } - - /** - * - */ - public function addAttr($name, $wert = null) - { - if (isset ($wert)) { - $name = (string)$name; - if (preg_match('/^[a-zA-Z.:][\w\-_\.:]*$/i', $name)) { - $this->_attribute[$name] = $wert; - } else { - trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . $name . "'", E_USER_ERROR); - } - } else { - if (is_scalar($name)) { - // Dies braucht man, falls man Attribute hinzufügen - // will, die keinen Wert haben, wie man es bei - // <option selected> kennt - if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $name)) { - $this->_attribute[$name] = $name; - // Da wir gültiges HTML bzw XML schreiben - // muss jedes Attribut auch einen Wert haben - // selected wird dann zu selected="selected" - } else { - trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . $name . "'", E_USER_ERROR); - } - } elseif (is_array($name)) { - // Jedes Arrayelement durchgehen - foreach ($name as $key => $wert) { - if (is_int($key)) { - // Arrayelement wurde mit $foo[] hinzugefügt - // also ohne Schlüssel. Ich nehme dann an - // das es sich um ein Attribut wie - // 'selected' oder 'readonly' handelt - if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $wert)) { - $this->_attribute[$wert] = $wert; - } else { - trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . - $wert . "'", E_USER_ERROR); - } - } else { - $key = (string)$key; - if (preg_match('/^[a-zA-Z\.:][\w\-_\.:]*$/i', $key)) { - $this->_attribute[$key] = $wert; - } else { - trigger_error("Unerlaubter Name für ein HTML-Attribut : '" . - $key . "'", E_USER_ERROR); - } - } - } - } else { - trigger_error("Erster Parameter muss ein Scalar oder ein Array sein", - E_USER_ERROR); - } - } - } - - /** - * to support Stud.IP legacy functions like makeButton... - */ - public function addString($string) - { - if (is_array($string)) { - $string = implode(' ', $string); - } - $this->_string .= " " . $string; - } - - /** - * - */ - public function getName() - { - return $this->_name; - } - - /** - * - */ - public function getAttr() - { - return $this->_attribute; - } - - /** - * - */ - public function printContent($indent = 0) - { - echo $this->createContent($indent); - } - - /** - * - */ - public function createContent($indent = 0) - { - $str = str_repeat(' ', $indent); - $str .= "<" . $this->getName(); - $attrib = $this->getAttr(); - foreach ($attrib as $name => $value) { - $str .= ' ' . $name . '="' . htmlReady($value) . '"'; - } - $str .= $this->_string; - $str .= ">\n"; - - return ($str); - } -} diff --git a/lib/evaluation/classes/LazyHTML.class.php b/lib/evaluation/classes/LazyHTML.class.php deleted file mode 100644 index 98f2f5e..0000000 --- a/lib/evaluation/classes/LazyHTML.class.php +++ /dev/null @@ -1,71 +0,0 @@ -<?php -/** - * HTML-class for the Stud.IP-project. - * Based on scripts from "http://tut.php-q.net/". - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * - */ - -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ -require_once 'HTML.class.php'; - -class HTMpty extends HTMLempty -{ - - public function attr($name, $wert = null) - { - parent::addAttr($name, $wert); - } - - public function stri($string) - { - parent::addString($string); - } - -} - -class HTM extends HTML -{ - - public function stri($string) - { - parent::addString($string); - } - - public function attr($name, $wert = null) - { - parent::addAttr($name, $wert); - } - - public function html($_content) - { - parent::addHTMLContent($_content); - } - - public function cont($_content) - { - parent::addContent($_content); - } -} diff --git a/lib/evaluation/classes/db/EvaluationAnswerDB.class.php b/lib/evaluation/classes/db/EvaluationAnswerDB.class.php deleted file mode 100644 index 54bdb7d..0000000 --- a/lib/evaluation/classes/db/EvaluationAnswerDB.class.php +++ /dev/null @@ -1,284 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * - */ - -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_OBJECTDB; - - -class EvaluationAnswerDB extends EvaluationObjectDB -{ - /** - * Constructor - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalANSWERDB'; - } - - /** - * Loads answers of a group from the DB - * @access public - * @param EvaluationAnswer &&$answerObject The answer object - */ - public function load(&$answerObject) - { - /* load answer --------------------------------------------------------- */ - $row = DBManager::get()->fetchOne( - "SELECT * FROM evalanswer WHERE evalanswer_id= ?", [$answerObject->getObjectID()] - ); - if (!count($row)) { - return $this->throwError(2, _("Keine Antwort mit dieser ID gefunden.")); - } - - $answerObject->setObjectID($row['evalanswer_id']); - $answerObject->setParentID($row['parent_id']); - $answerObject->setPosition($row['position']); - $answerObject->setText($row['text']); - $answerObject->setValue($row['value']); - $answerObject->setRows($row['rows']); - $answerObject->setResidual($row['residual']); - } - - - /** - * Loads the votes from the users for this answer - * @access public - * @param EvaluationAnswer &$answerObject The answer object - */ - function loadVotes(&$answerObject) - { - /* load users -------------------------------------------------------- */ - $result = DBManager::get()->fetchFirst("SELECT user_id FROM evalanswer_user - WHERE evalanswer_id= ?", [$answerObject->getObjectID()]); - foreach ($result as $row) { - $answerObject->addUserID($row, NO); - } - } - /* ----------------------------------------------------------- end: users */ - - /** - * Writes answers into the DB - * @access public - * @param EvaluationAnswer &$answerObject The answerobject - * @throws error - */ - function save(&$answerObject) - { - /* save answers -------------------------------------------------------- */ - DBManager::get()->execute( - "REPLACE INTO evalanswer SET - `evalanswer_id` = ?, - `parent_id` = ?, - `position` = ?, - `text` = ?, - `value` = ?, - `rows` = ?, - `residual` = ? - ", - [$answerObject->getObjectID(), - $answerObject->getParentID(), - $answerObject->getPosition(), - $answerObject->getText(), - $answerObject->getValue(), - $answerObject->getRows(), - $answerObject->isResidual()]); - /* ----------------------------------------------------- end: answersave */ - - /* connect answer to users --------------------------------------------- */ - while ($userID = $answerObject->getNextUserID()) { - DBManager::get()->execute( - "INSERT INTO evalanswer_user SET - evalanswer_id = ?, - user_id = ?, - evaldate = UNIX_TIMESTAMP()", - [$answerObject->getObjectID(), $userID]); - } - /* ----------------------------------------------------- end: connecting */ - - } // saved - - /** - * Deletes all votes from the users for this answers - * @access public - * @param EvaluationAnswer &$answerObject The answer object - */ - function resetVotes(&$answerObject) - { - /* delete userconnects ------------------------------------------------- */ - DBManager::get()->execute(" - DELETE FROM evalanswer_user - WHERE evalanswer_id = ?", - [$answerObject->getObjectID()]); - /* ------------------------------------------------------- end: deleting */ - } - - /** - * Deletes a answer - * @access public - * @param EvaluationAnswer &$answerObject The answer to delete - * @throws error - */ - function delete(&$answerObject) - { - /* delete answer ----------------------------------------------------- */ - DBManager::get()->execute(" - DELETE FROM evalanswer - WHERE evalanswer_id = ?", - [$answerObject->getObjectID()]); - /* ------------------------------------------------------- end: deleting */ - $this->resetVotes($answerObject); - } // deleted - - - /** - * Checks if answer with this ID exists - * @access public - * @param string $answerID The answerID - * @return bool YES if exists - */ - function exists($answerID) - { - $result = DBManager::get()->fetchOne("SELECT 1 FROM evalanswer - WHERE evalanswer_id= ?", [$answerID]); - if (count($result) > 0) - return true; - return false; - } - - - /** - * Adds the children to a parent object - * @access public - * @param EvaluationObject &$parentObject The parent object - */ - public static function addChildren(&$parentObject) - { - $result = DBManager::get()->fetchFirst("SELECT evalanswer_id FROM evalanswer - WHERE parent_id= ? ORDER by position", - [$parentObject->getObjectID()]); - - $loadChildren = - $parentObject->loadChildren == EVAL_LOAD_ALL_CHILDREN ? EVAL_LOAD_ALL_CHILDREN : EVAL_LOAD_NO_CHILDREN; - - foreach ($result as $row) { - $child = new EvaluationAnswer($row, $parentObject, $loadChildren); - $parentObject->addChild($child); - } - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - function getType($objectID) - { - if ($this->exists($objectID)) { - return INSTANCEOF_EVALANSWER; - } else { - return NO; - } - } - - /** - * Returns the id from the parent object - * @access public - * @param string $objectID The object id - * @return string The id from the parent object - */ - public static function getParentID($objectID) - { - return DBManager::get()->fetchColumn("SELECT parent_id FROM evalanswer - WHERE evalanswer_id = ?", - [$objectID]); - } - - /** - * Give all textanswers for a user and question for the export - * @access public - * @param string $questionID The question id - * @param string $userID The user id - */ - function getUserAnwerIDs($questionID, $userID) - { - /* ask database ------------------------------------------------------- */ - $sql = "SELECT a.evalanswer_id as ttt FROM evalanswer a, evalanswer_user b - WHERE a.parent_id = ? AND a.evalanswer_id = b.evalanswer_id"; - if (empty ($userID)) - $answer_ids = DBManager::get()->fetchFirst($sql, [$questionID]); - else - $answer_ids = DBManager::get()->fetchFirst($sql . " AND b.user_id = ?", [$questionID, $userID]); - /* -------------------------------------------------------- end: asking */ - return $answer_ids; - } - - /** - * Checks whether a user has voted for an answer - * @access public - * @param string $answerID The answer id - * @param string $userID The user id - * @return boolean YES if user has voted for the answer - */ - function hasVoted($answerID, $userID) - { - $result = DBManager::get()->fetchOne("SELECT 1 FROM evalanswer_user - WHERE evalanswer_id= ? AND user_id", [$answerID, $userID]); - if (count($result) > 0) - return true; - return false; - } - - function getAllAnswers($question_id, $userID, $only_user_answered = false) - { - if ($only_user_answered) - return DBManager::get()->fetchAll(" - SELECT evalanswer.*, COUNT(IF(user_id=?,1,NULL)) AS has_voted - FROM evalanswer LEFT JOIN evalanswer_user USING(evalanswer_id) - WHERE parent_id = ? AND user_id = ? - GROUP BY evalanswer.evalanswer_id ORDER BY position", - [$userID, $question_id, $userID]); - else - return DBManager::get()->fetchAll(" - SELECT evalanswer.*, COUNT(IF(user_id=?,1,NULL)) AS has_voted - FROM evalanswer LEFT JOIN evalanswer_user USING(evalanswer_id) - WHERE parent_id = ? - GROUP BY evalanswer.evalanswer_id ORDER BY position", - [$userID, $question_id]); - } -} - -?> diff --git a/lib/evaluation/classes/db/EvaluationDB.class.php b/lib/evaluation/classes/db/EvaluationDB.class.php deleted file mode 100644 index fd1c2b6..0000000 --- a/lib/evaluation/classes/db/EvaluationDB.class.php +++ /dev/null @@ -1,291 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_OBJECTDB; -require_once EVAL_FILE_GROUPDB; - - -/** - * @const EVAL_STATE_NEW Beschreibung - * @access public - */ -define("EVAL_STATE_NEW", "new"); - -/** - * @const EVAL_STATE_ACTIVE Beschreibung - * @access public - */ -define("EVAL_STATE_ACTIVE", "active"); - -/** - * @const EVAL_STATE_STOPPED Beschreibung - * @access public - */ -define("EVAL_STATE_STOPPED", "stopped"); -# =========================================================================== # - - -/** - * Databaseclass for all evaluations - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationDB extends EvaluationObjectDB -{ - - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalDB'; - } - - /** - * Loads an evaluation from DB into an object - * - * @access public - * @param object EvaluationObject &$evalObject The evaluation to load - * @throws error - */ - public function load(&$evalObject) - { - $row = DBManager::get()->fetchOne("SELECT * FROM eval WHERE eval_id = ?", [$evalObject->getObjectID()]); - - if (!count($row)) { - return $this->throwError(1, _("Keine Evaluation mit dieser ID gefunden.")); - } - - $evalObject->setAuthorID($row['author_id']); - $evalObject->setTitle($row['title']); - $evalObject->setText($row['text']); - $evalObject->setStartdate($row['startdate']); - $evalObject->setStopdate($row['stopdate']); - $evalObject->setTimespan($row['timespan']); - $evalObject->setCreationdate($row['mkdate']); - $evalObject->setChangedate($row['chdate']); - $evalObject->setAnonymous($row['anonymous']); - $evalObject->setVisible($row['visible']); - $evalObject->setShared($row['shared']); - - $range_ids = DBManager::get()->fetchFirst("SELECT range_id FROM eval_range WHERE eval_id = ?", - [$evalObject->getObjectID()]); - - foreach ($range_ids as $range_id) { - $evalObject->addRangeID($range_id); - } - if ($evalObject->loadChildren != EVAL_LOAD_NO_CHILDREN) { - EvaluationGroupDB::addChildren($evalObject); - } - } - - /** - * Saves an evaluation - * @access public - * @param object Evaluation &$evalObject The evaluation to save - * @throws error - */ - public function save(&$evalObject) - { - $startdate = $evalObject->getStartdate(); - $stopdate = $evalObject->getStopdate(); - $timespan = $evalObject->getTimespan(); - - $evalObject->setChangedate(time()); - if ($this->exists($evalObject->getObjectID())) { - DBManager::get()->execute( - "UPDATE eval SET title = ?, text = ?, startdate = ?, - stopdate = ?, timespan = ?, mkdate = ?, - chdate = ?, anonymous = ?, visible = ?, shared = ? - WHERE eval_id = ?", - [$evalObject->getTitle(), $evalObject->getText(), - $startdate, $stopdate, $timespan, $evalObject->getCreationdate(), - $evalObject->getChangedate(), $evalObject->isAnonymous(), - $evalObject->isVisible(), $evalObject->isShared(), $evalObject->getObjectID()]); - } else { - DBManager::get()->execute( - "INSERT INTO eval SET eval_id = ?, - author_id = ?, title = ?, text = ?, startdate = ?, - stopdate = ?, timespan = ?, mkdate = ?, chdate = ?, - anonymous = ?, visible = ?, shared = ?", - [$evalObject->getObjectID(), $evalObject->getAuthorID(), - $evalObject->getTitle(), $evalObject->getText(), - $startdate, $stopdate, $timespan, $evalObject->getCreationdate(), - $evalObject->getChangedate(), $evalObject->isAnonymous(), - $evalObject->isVisible(), $evalObject->isShared()]); - } - DBManager::get()->execute("DELETE FROM eval_range WHERE eval_id = ?", [$evalObject->getObjectID()]); - - while ($rangeID = $evalObject->getNextRangeID()) { - DBManager::get()->execute("INSERT INTO eval_range SET eval_id = ?, range_id = ?", - [$evalObject->getObjectID(), $rangeID]); - } - } - - /** - * Deletes an evaluation - * @access public - * @param object Evaluation &$evalObject The evaluation to delete - * @throws error - */ - public function delete(&$evalObject) - { - DBManager::get()->execute("DELETE FROM eval WHERE eval_id = ?", [$evalObject->getObjectID()]); - - DBManager::get()->execute("DELETE FROM eval_range WHERE eval_id = ?", [$evalObject->getObjectID()]); - DBManager::get()->execute("DELETE FROM eval_user WHERE eval_id = ?", [$evalObject->getObjectID()]); - - } - - /** - * Checks if evaluation with this ID exists - * @access public - * @param string $evalID The evalID - * @return bool YES if exists - */ - public function exists($evalID) - { - $entry = DBManager::get()->fetchOne("SELECT 1 FROM eval WHERE eval_id = ?", [$evalID]); - if (count($entry) > 0) - return true; - return false; - } - - /** - * Checks if someone used the evaluation - * @access public - * @param string $evalID The eval id - * @param string $userID The user id - * @return bool YES if evaluation was used - */ - public function hasVoted($evalID, $userID = "") - { - /* ask database ------------------------------------------------------- */ - $sql = "SELECT 1 FROM eval_user WHERE eval_id = ?"; - if (empty($userID)) - $entry = DBManager::get()->fetchOne($sql, [$evalID]); - else - $entry = DBManager::get()->fetchOne($sql . " AND user_id = ?", [$evalID, $userID]); - /* --------------------------------------------------------- end: asking */ - if (count($entry) > 0) - return true; - return false; - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - public function getType($objectID) - { - if ($this->exists($objectID)) { - return INSTANCEOF_EVAL; - } else { - $dbObject = new EvaluationGroupDB(); - return $dbObject->getType($objectID); - } - } - - /** - * Connect a user with an evaluation - * @access public - * @param string $evalID The evaluation id - * @param string $userID The user id - */ - public function connectWithUser($evalID, $userID) - { - if (empty($userID)) - die ("EvaluationDB::connectWithUser: UserID leer!!"); - DBManager::get()->execute("INSERT IGNORE INTO eval_user SET eval_id = ?, user_id = ?", [$evalID, $userID]); - } - - /** - * Removes the connection of an evaluation with a user or all users - * @access public - * @param string $evalID The evaluation id - * @param string $userID The user id - */ - public function removeUser($evalID, $userID = "") - { - $sql = "DELETE FROM eval_user WHERE eval_id = ?"; - - if (empty($userID)) - DBManager::get()->execute($sql, [$evalID]); - else - DBManager::get()->execute($sql . " AND user_id = ?", [$evalID, $userID]); - } - - /** - * Get number of users who participated in the eval - * @access public - * @param string $evalID The eval id - * @return integer The number of users - */ - public static function getNumberOfVotes($evalID) - { - return DBManager::get()->fetchColumn("SELECT count(DISTINCT user_id) AS number FROM eval_user WHERE eval_id = ?", [$evalID]); - } - - /** - * Get users who participated in the eval - * @access public - * @param string $evalID The eval id - * @param array $answerIDs The answerIDs to get the pseudonym users - * @return string[] Ids of the users who voted - */ - public static function getUserVoted($evalID, $answerIDs = [], $questionIDs = []) - { - $sql = "SELECT DISTINCT user_id FROM "; - - if (empty($answerIDs) && empty($questionIDs)) { - $sql .= "eval_user WHERE eval_id = ?"; - $search_criteria = $evalID; - } elseif (empty ($questionIDs)) { - $sql .= "evalanswer_user WHERE evalanswer_id IN (?)"; - $search_criteria = $answerIDs; - } else { - $sql .= "evalanswer INNER JOIN evalanswer_user USING(evalanswer_id) WHERE parent_id IN (?)"; - $search_criteria = $questionIDs; - } - - return DBManager::get()->fetchFirst($sql, [$search_criteria]); - } - - /** - * - * @access public - * @param string $search_str - * @return array - */ - public function search_range($search_str) - { - return search_range($search_str, true); - } -} diff --git a/lib/evaluation/classes/db/EvaluationGroupDB.class.php b/lib/evaluation/classes/db/EvaluationGroupDB.class.php deleted file mode 100644 index 60842ad..0000000 --- a/lib/evaluation/classes/db/EvaluationGroupDB.class.php +++ /dev/null @@ -1,225 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_OBJECTDB; -require_once EVAL_FILE_ANSWERDB; - -/** - * Databaseclass for all evaluationgroups - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationGroupDB extends EvaluationObjectDB -{ - - /** - * Constructor - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalGroupDB'; - } - - /** - * Loads an evaluationgroup from DB into an object - * - * @access private - * @param object EvaluationGroup &$groupObject The group to load - * @throws error - */ - public function load(&$groupObject) - { - /* load group ---------------------------------------------------------- */ - $row = DBManager::get()->fetchOne(" - SELECT * FROM evalgroup - WHERE evalgroup_id = ? - ORDER BY position ", [$groupObject->getObjectID()]); - - if (count($row) === 0) { - return $this->throwError(1, _("Keine Gruppe mit dieser ID gefunden.")); - } - - $groupObject->setParentID($row['parent_id']); - $groupObject->setTitle($row['title']); - $groupObject->setText($row['text']); - $groupObject->setPosition($row['position']); - $groupObject->setChildType($row['child_type']); - $groupObject->setMandatory($row['mandatory']); - $groupObject->setTemplateID($row['template_id']); - if ($groupObject->loadChildren != EVAL_LOAD_NO_CHILDREN) { - if ($groupObject->loadChildren == EVAL_LOAD_ONLY_EVALGROUP) { - EvaluationGroupDB::addChildren($groupObject); - } else { - EvaluationGroupDB::addChildren($groupObject); - EvaluationQuestionDB::addChildren($groupObject); - } - } - } - - - /** - * Saves a group - * @access public - * @param object EvaluationGroup &$groupObject The group to save - * @throws error - */ - public function save(&$groupObject) - { - if ($this->exists($groupObject->getObjectID())) { - DBManager::get()->execute(" - UPDATE evalgroup SET - title = ?, - text = ?, - child_type = ?, - position = ?, - template_id = ?, - mandatory = ? - WHERE - evalgroup_id = ? - ", [(string)$groupObject->getTitle(), - (string)$groupObject->getText(), - (string)$groupObject->getChildType(), - (int)$groupObject->getPosition(), - (string)$groupObject->getTemplateID(), - (int)$groupObject->isMandatory(), - (string)$groupObject->getObjectID() - ]); - } else { - DBManager::get()->execute(" - INSERT INTO evalgroup SET - evalgroup_id = ?, - parent_id = ?, - title = ?, - text = ?, - child_type = ?, - mandatory = ?, - template_id = ?, - position = ? - ", [ - (string)$groupObject->getObjectID(), - (string)$groupObject->getParentID(), - (string)$groupObject->getTitle(), - (string)$groupObject->getText(), - (string)$groupObject->getChildType(), - (int)$groupObject->isMandatory(), - (string)$groupObject->getTemplateID(), - (int)$groupObject->getPosition() - ]); - } - } - - /** - * Deletes a group - * @access public - * @param object EvaluationGroup &$groupObject The group to delete - * @throws error - */ - public function delete(&$groupObject) - { - DBManager::get()->execute("DELETE FROM evalgroup WHERE evalgroup_id = ?", [$groupObject->getObjectID()]); - } - - /** - * Checks if group with this ID exists - * @access public - * @param string $groupID The groupID - * @return bool YES if exists - */ - public function exists($groupID) - { - $result = DBManager::get()->fetchColumn("SELECT 1 FROM evalgroup WHERE evalgroup_id = ?", [$groupID]); - return (bool)$result; - } - - /** - * Adds the children to a parent object - * @access public - * @param EvaluationObject &$parentObject The parent object - */ - public static function addChildren(&$parentObject) - { - $result = DBManager::get()->fetchFirst(" - SELECT evalgroup_id FROM evalgroup - WHERE parent_id = ? - ORDER BY position", [$parentObject->getObjectID()]); - - if (($loadChildren = $parentObject->loadChildren) == EVAL_LOAD_NO_CHILDREN) - $loadChildren = EVAL_LOAD_NO_CHILDREN; - - foreach ($result as $groupID) { - $child = new EvaluationGroup ($groupID, $parentObject, $loadChildren); - $parentObject->addChild($child); - } - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - public function getType($objectID) - { - if ($this->exists($objectID)) { - return INSTANCEOF_EVALGROUP; - } else { - $dbObject = new EvaluationQuestionDB (); - return $dbObject->getType($objectID); - } - } - - - /** - * Returns whether the childs are groups or questions - * @access public - * @param string $objectID The object id - */ - public function getChildType($objectID) - { - $result = DBManager::get()->fetchColumn(" - SELECT child_type FROM evalgroup WHERE evalgroup_id = ?", [$objectID]); - if ($result) return $result; - return NULL; - } - - /** - * Returns the id from the parent object - * @access public - * @param string $objectID The object id - * @return string The id from the parent object - */ - public static function getParentID($objectID) - { - return DBManager::get()->fetchColumn(" - SELECT parent_id FROM evalgroup WHERE evalgroup_id = ?", [$objectID]); - } -} diff --git a/lib/evaluation/classes/db/EvaluationObjectDB.class.php b/lib/evaluation/classes/db/EvaluationObjectDB.class.php deleted file mode 100644 index fd5728d..0000000 --- a/lib/evaluation/classes/db/EvaluationObjectDB.class.php +++ /dev/null @@ -1,365 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -require_once 'lib/evaluation/evaluation.config.php'; - -/** - * Databaseclass for all evaluationobjects - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * - */ -class EvaluationObjectDB extends DatabaseObject -{ - /** - * Constructor - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalDBObject'; - } - - /** - * Gets the name of the range. Copied somewhere from Stud.IP... - * @access public - * @param string $rangeID the rangeID - * @param boolean $html_decode (optional) - * @return string The name of the range - */ - public function getRangename($rangeID, $html_decode = true) - { - if ($rangeID == "studip") { - return _('Systemweite Evaluationen'); - } - $o_type = get_object_type($rangeID, ['sem', 'user', 'inst']); - if (in_array($o_type, ['sem','inst','fak'])) { - $range = get_object_by_range_id($rangeID); - if ($range) { - $rangename = $range->getFullName('number-name-semester'); - } else { - $rangename = _('Kein Titel gefunden.'); - } - return $rangename; - } - if ($o_type != 'user') { - $user_id = get_userid($rangeID); - } else { - $user_id = $rangeID; - } - - if ($user_id != $GLOBALS['user']->id) { - $rangename = _('Profil') . ': ' - . get_fullname($user_id, 'full', true) - . ' (' . get_username($user_id) . ')'; - } else { - $rangename = _('Profil'); - } - return $rangename; - } - - /** - * Gets the global Studi.IP perm - * @access public - * @param boolean $as_value If YES return as value - * @return string the perm or NULL - */ - public static function getGlobalPerm($as_value = false) - { - if ($GLOBALS['perm']->have_perm("root")) { - return $as_value ? 63 : "root"; - } elseif ($GLOBALS['perm']->have_perm("admin")) { - return $as_value ? 31 : "admin"; - } elseif ($GLOBALS['perm']->have_perm("dozent")) { - return $as_value ? 15 : "dozent"; - } elseif ($GLOBALS['perm']->have_perm("tutor")) { - return $as_value ? 7 : "dozent"; - } elseif ($GLOBALS['perm']->have_perm("autor")) { - return $as_value ? 3 : "autor"; - } elseif ($GLOBALS['perm']->have_perm("user")) { - return $as_value ? 1 : "user"; - } else { - return $as_value ? 0 : NULL; - } - } - - /** - * Get the Stud.IP-Perm for a range - * @param string $rangeID The range id - * @param string $userID The user id - * @param boolean $as_value If YES return as value - * @access public - * @return string - */ - public static function getRangePerm($rangeID, $userID = NULL, $as_value = false) - { - if (!$rangeID) { - print "no rangeID!<br>"; - return NULL; - } - $userID = ($userID) ? $userID : $GLOBALS['user']->id; - $range_perm = $GLOBALS['perm']->get_studip_perm($rangeID, $userID); - - if ($rangeID == $userID) { - return ($as_value) ? 63 : "root"; - } - - if (($rangeID == "studip") && ($GLOBALS['perm']->have_perm("root"))) { - return ($as_value) ? 63 : "root"; - } - - switch ($range_perm) { - case "root": - return ($as_value) ? 63 : "root"; - case "admin": - return ($as_value) ? 31 : "admin"; - case "dozent": - return ($as_value) ? 15 : "dozent"; - case "tutor": - return ($as_value) ? 7 : "dozent"; - case "autor": - return ($as_value) ? 3 : "autor"; - case "user": - return ($as_value) ? 1 : "user"; - default: - return 0; - } - - } - - /** - * Look for all rangeIDs for my permissions - * @param object Perm &$permObj PHP-LIB-Perm-Object - * @param object User &$userObj PHP-LIB-User-Object - * @param string $rangeID RangeID of actual page - */ - public function getValidRangeIDs(&$permObj, &$userObj, $rangeID) - { - $range_ids = []; - $username = $userObj->username; - - $range_ids += [ - $username => ["name" => _("Profil")] - ]; - - if ($permObj->have_perm("root")) { - $range_ids += ["studip" => ["name" => _("Stud.IP-System")]]; - if (($adminRange = $this->getRangename($rangeID)) && - $rangeID != $userObj->id) - $range_ids += [$rangeID => ["name" => - $adminRange]]; - } else if ($permObj->have_perm("admin")) { - if (($adminRange = $this->getRangename($rangeID)) && - $rangeID != $userObj->id) { - $range_ids += [$rangeID => ["name" => - $adminRange]]; - } - } else if ($permObj->have_perm("dozent") || $permObj->have_perm("tutor")) { - if ($ranges = search_range("")) { - $range_ids += $ranges; - } - } - return $range_ids; - } - - /** - * Returns the number of ranges with no permission - * @access public - * @param EvaluationObject &$eval The evaluation - * @param boolean $return_ids If YES return the ids - * @return array|integer Number of ranges with no permission or array of ids - */ - public static function getEvalUserRangesWithNoPermission(&$eval, $return_ids = false) - { - $no_permisson = 0; - $rangeIDs = $eval->getRangeIDs(); - $no_permisson_ranges = []; - if (!is_array($rangeIDs)) { - $rangeIDs = [$rangeIDs]; - } - - foreach ($eval->getRangeIDs() as $rangeID) { - $user_perm = EvaluationObjectDB::getRangePerm($rangeID, $GLOBALS['user']->id, YES); - // every range with a lower perm than Tutor - if ($user_perm < 7) { - $no_permisson++; - $no_permisson_ranges[] = $rangeID; - } - } - if ($return_ids == YES) { - return $no_permisson_ranges; - } - return ($no_permisson > 0) ? $no_permisson : NO; - } - - /** - * Gets the public template ids - * @access public - * @param string $searchString The name of the template - * @return array The public template ids - */ - public function getPublicTemplateIDs($searchString) - { - $sql = " - SELECT eval_id FROM eval - LEFT JOIN auth_user_md5 ON user_id = author_id - WHERE shared = 1 - AND author_id <> :current_user - AND (title LIKE :search_string - OR text LIKE :search_string - OR Vorname LIKE :search_string - OR Nachname LIKE :search_string - OR username LIKE :search_string - ) - ORDER BY title"; - - return DBManager::get()->fetchFirst( - $sql, [':current_user' => $GLOBALS['user']->id, ':search_string' => '%' . $searchString . '%'] - ); - } - - /** - * Return all evaluationIDs in a specific range - * - * @access public - * @param string $rangeID Specific rangeID or it is a template - * @param string $state Specific state - * @return array All evaluations in this range and this state - */ - public function getEvaluationIDs($rangeID = "", $state = "") - { - if (!empty ($rangeID) && !is_scalar($rangeID)) { - return $this->throwError(1, _("Übergebene RangeID ist ungültig.")); - } - if ($state != "" && - $state != EVAL_STATE_NEW && - $state != EVAL_STATE_ACTIVE && - $state != EVAL_STATE_STOPPED) { - return $this->throwError(2, _("Übergebener Status ist ungültig.")); - } - - if (get_userid($rangeID) != NULL && $rangeID != NULL) { - $rangeID = get_userid($rangeID); - } - - if (!empty ($rangeID)) { - $sql = - "SELECT" . - " a.eval_id " . - "FROM" . - " eval_range a, eval b " . - "WHERE" . - " a.eval_id = b.eval_id" . - " AND " . - " a.range_id = ?"; - $param = $rangeID; - } else { - $sql = - "SELECT" . - " b.eval_id " . - "FROM" . - " eval b " . - "LEFT JOIN" . - " eval_range " . - "ON" . - " b.eval_id = eval_range.eval_id " . - "WHERE" . - " eval_range.eval_id IS NULL" . - " AND" . - " b.author_id = ?"; - $param = $GLOBALS['user']->id; - } - - if ($state == EVAL_STATE_NEW) - $sql .= " AND (b.startdate IS NULL OR b.startdate > " . time() . ")"; - - elseif ($state == EVAL_STATE_ACTIVE) - $sql .= - " AND b.startdate < " . time() . "" . - " AND (" . - " (b.timespan IS NULL AND b.stopdate > " . time() . ")" . - " OR" . - " (b.stopdate IS NULL AND (b.startdate+b.timespan) > " . time() . ")" . - " OR" . - " (b.timespan IS NULL AND b.stopdate IS NULL)" . - " )"; - - elseif ($state == EVAL_STATE_STOPPED) - $sql .= - " AND b.startdate < " . time() . "" . - " AND (" . - " (b.timespan IS NULL AND b.stopdate <= " . time() . ")" . - " OR" . - " (b.stopdate IS NULL AND (b.startdate+b.timespan) <= " . time() . ")" . - " )"; - - $sql .= " ORDER BY chdate DESC"; - - return DBManager::get()->fetchFirst($sql, [$param]); - } - - /** - * Gets the evaluation id for a object id - * @access public - * @param string $objectID The object id - * @return string The evaluation id or nothing - */ - public function getEvalID($objectID) - { - if (empty ($objectID)) { - throw new Exception("FATAL ERROR in getEvalID ;)"); - } - - $type = EvaluationObjectDB::getType($objectID); - - switch ($type) { - case INSTANCEOF_EVALANSWER: - $parentID = EvaluationAnswerDB::getParentID($objectID); - break; - case INSTANCEOF_EVALQUESTION: - $parentID = EvaluationQuestionDB::getParentID($objectID); - break; - case INSTANCEOF_EVALGROUP: - $parentID = EvaluationGroupDB::getParentID($objectID); - break; - default: - return $objectID; - } - return EvaluationObjectDB::getEvalID($parentID); - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - public function getType($objectID) - { - return (new EvaluationDB ())->getType($objectID); - } -} diff --git a/lib/evaluation/classes/db/EvaluationQuestionDB.class.php b/lib/evaluation/classes/db/EvaluationQuestionDB.class.php deleted file mode 100644 index b6cea24..0000000 --- a/lib/evaluation/classes/db/EvaluationQuestionDB.class.php +++ /dev/null @@ -1,298 +0,0 @@ -<?php -# Lifter002: TODO -# Lifter007: TODO -# Lifter003: TODO -# Lifter010: TODO -/** - * Beschreibung - * - * @author Alexander Willner <mail@AlexanderWillner.de> - * @copyright 2004 Stud.IP-Project - * @access public - * @package evaluation - * @modulegroup evaluation_modules - * - */ - - -// +--------------------------------------------------------------------------+ -// This file is part of Stud.IP -// Copyright (C) 2001-2004 Stud.IP -// +--------------------------------------------------------------------------+ -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License -// as published by the Free Software Foundation; either version 2 -// of the License, or any later version. -// +--------------------------------------------------------------------------+ -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -// +--------------------------------------------------------------------------+ - -# Include all required files ================================================ # -require_once 'lib/evaluation/evaluation.config.php'; -require_once EVAL_FILE_OBJECTDB; -require_once EVAL_FILE_ANSWERDB; -# ====================================================== end: including files # - -# Define all required constants ============================================= # -/** - * @const INSTANCEOF_EVALQUESTIONDB Instance of an evaluationQuestionDB object - * @access public - */ -define("INSTANCEOF_EVALQUESTIONDB", "EvalQuestionDB"); - -# =========================================================================== # - - -class EvaluationQuestionDB extends EvaluationObjectDB -{ - - /** - * Constructor - * @access public - */ - public function __construct() - { - parent::__construct(); - $this->instanceof = 'EvalQuestionDB'; - } - - /** - * Loads a question from the DB - * @access public - * @param EvaluationQuestion &$questionObject The question object - */ - public function load(&$questionObject) - { - $db = DBManager::get(); - $query = - "SELECT" . - " * " . - "FROM" . - " evalquestion " . - "WHERE" . - " evalquestion_id = ? " . - "ORDER BY" . - " position "; - $row = $db->fetchOne($query, [$questionObject->getObjectID()]); - - if (!count($row)) { - return $this->throwError(1, _("Keine Frage mit dieser ID gefunden.")); - } - - $questionObject->setParentID($row['parent_id']); - $questionObject->setType($row['type']); - $questionObject->setPosition($row['position']); - $questionObject->setText($row['text']); - $questionObject->setMultiplechoice($row['multiplechoice']); - - if ($questionObject->loadChildren != EVAL_LOAD_NO_CHILDREN) { - EvaluationAnswerDB::addChildren($questionObject); - } - } - - - /** - * Writes or updates a question into the DB - * @access public - * @param EvaluationQuestion &$questionObject The question object - */ - public function save(&$questionObject) - { - $db = DBManager::get(); - - if ($this->exists($questionObject->getObjectID())) { - $sql = - "UPDATE" . - " evalquestion " . - "SET" . - " parent_id = ?," . - " type = ?," . - " position = ?," . - " text = ?," . - " multiplechoice = ? " . - "WHERE" . - " evalquestion_id = ?"; - } else { - $sql = - "INSERT INTO" . - " evalquestion " . - "SET" . - " parent_id = ?," . - " type = ?," . - " position = ?," . - " text = ?," . - " multiplechoice = ?," . - " evalquestion_id = ?";; - } - $db->execute($sql, [ - (string)$questionObject->getParentID(), - (string)$questionObject->getType(), - (int)$questionObject->getPosition(), - (string)$questionObject->getText(), - (int)$questionObject->isMultiplechoice(), - $questionObject->getObjectID() - ]); - } - - /** - * Deletes a question - * @access public - * @param object EvaluationQuestion &$questionObject The question to delete - * @throws error - */ - public function delete(&$questionObject) - { - $db = DBManager::get(); - - $sql = "DELETE FROM evalquestion WHERE evalquestion_id = ?"; - $db->execute($sql, [$questionObject->getObjectID()]); - } - - /** - * Checks if question with this ID exists - * @access public - * @param string $questionID The questionID - * @return bool YES if exists - */ - public function exists($questionID) - { - $db = DBManager::get(); - - $sql = - "SELECT" . - " 1 " . - "FROM" . - " evalquestion " . - "WHERE" . - " evalquestion_id = ?"; - $result = $db->fetchColumn($sql, [$questionID]); - - return (bool)$result; - } - - /** - * Checks if a template exists with this title - * @access public - * @param string $questionTitle The title of the question - * @param string $userID The user id - * @return bool YES if exists - */ - public function titleExists($questionTitle, $userID) - { - $db = DBManager::get(); - - $sql = - "SELECT" . - " 1 " . - "FROM" . - " evalquestion " . - "WHERE" . - " text = ? " . - " AND " . - " parent_id = ?"; - - $result = $db->fetchColumn($sql, [$questionTitle, $userID]); - - return (bool)$result; - } - - - /** - * Adds the children to a parent object - * @access public - * @param EvaluationObject &$parentObject The parent object - */ - public static function addChildren(&$parentObject) - { - $db = DBManager::get(); - - $sql = - "SELECT" . - " evalquestion_id " . - "FROM" . - " evalquestion " . - "WHERE" . - " parent_id = ? " . - "ORDER BY" . - " position"; - $result = $db->fetchFirst($sql, [$parentObject->getObjectID()]); - - $loadChildren = $parentObject->loadChildren == EVAL_LOAD_ALL_CHILDREN - ? EVAL_LOAD_ALL_CHILDREN - : EVAL_LOAD_NO_CHILDREN; - - foreach ($result as $evalquestion_id) { - $child = new EvaluationQuestion($evalquestion_id, $parentObject, $loadChildren); - $parentObject->addChild($child); - } - } - - /** - * Returns the type of an objectID - * @access public - * @param string $objectID The objectID - * @return string INSTANCEOF_x, else NO - */ - public function getType($objectID) - { - if ($this->exists($objectID)) { - return INSTANCEOF_EVALQUESTION; - } else { - $dbObject = new EvaluationAnswerDB (); - return $dbObject->getType($objectID); - } - } - - /** - * Returns the id from the parent object - * @access public - * @param string $objectID The object id - * @return string The id from the parent object - */ - public static function getParentID($objectID) - { - $db = DBManager::get(); - - $sql = - "SELECT" . - " parent_id " . - "FROM" . - " evalquestion " . - "WHERE" . - " evalquestion_id = ?"; - $result = $db->fetchColumn($sql, [$objectID]); - return $result; - } - - /** - * Returns the ids of the Answertemplates of a user - * @access public - * @param string $userID The user id - * @return array The ids of the answertemplates - */ - public function getTemplateID($userID) - { - $db = DBManager::get(); - - if (EvaluationObjectDB::getGlobalPerm() === 'root') { - $sql = "SELECT evalquestion_id - FROM evalquestion - WHERE parent_id = '0' - ORDER BY text"; - return $db->fetchFirst($sql); - } else { - $sql = "SELECT evalquestion_id - FROM evalquestion - WHERE parent_id = ? - OR parent_id = '0' - ORDER BY text"; - return $db->fetchFirst($sql, [$userID]); - } - } -} |
