Esempio n. 1
0
        return EvalCommon::showErrorReport($group, _("Fehler beim Anlegen einer Gruppe"));
    }
    // create a new eval
    $eval = new Evaluation();
    $rangeID = Request::option("rangeID");
    if ($rangeID == get_username($user->id)) {
        $rangeID = $user->id;
    }
    $eval->setAuthorID($user->id);
    $eval->setTitle(NEW_EVALUATION_TITLE);
    $eval->setAnonymous(YES);
    $evalID = $eval->getObjectID();
    $eval->addChild($group);
    $eval->save();
    if ($eval->isError()) {
        return EvalCommon::showErrorReport($eval, _("Fehler beim Anlegen einer Evaluation"));
    }
    $groupID = $group->getObjectID();
    $evalID = $eval->getObjectID();
} elseif (Request::option("evalID") && Request::option("evalID") != NULL) {
    $debug .= "isset _REQUTEST[evalID]!<br>";
    $evalID = Request::option("evalID");
    $eval = new Evaluation($evalID, NULL, EVAL_LOAD_NO_CHILDREN);
    if ($eval->isError()) {
        $error = EvalCommon::createReportMessage(_("Es wurde eine ungültige Evaluations-ID übergeben."), EVAL_PIC_ERROR, EVAL_CSS_ERROR);
        $error_msgs[] = $error->createContent();
    } elseif ($evalID == NULL) {
        $error = EvalCommon::createReportMessage(_("Es wurde keine Evaluations-ID übergeben"), EVAL_PIC_ERROR, EVAL_CSS_ERROR);
        $error_msgs[] = $error->createContent();
    }
} else {
 /**
 * swaps positions of two objects
 *
 * @access  private
 * @param   string  $parentID     the parentID
 * @param   string  $objectID     the object to swap
 * @param   string  $oldposition  the old position
 * @param   string  $direction    the direction to swap
 */
 function swapPosition($parentID, $objectID, $oldposition, $direction)
 {
     if ($parentID == ROOT_BLOCK) {
         $group = $this->tree->eval;
     } else {
         $group =& $this->tree->getGroupObject($parentID);
     }
     $numberchildren = $group->getNumberChildren();
     $instance = $group->x_instanceof();
     if ($direction == "up") {
         if ($oldposition == 0) {
             $newposition = $numberchildren - 1;
         } else {
             $newposition = $oldposition - 1;
         }
     } else {
         if ($oldposition == $numberchildren - 1) {
             $newposition = 0;
         } else {
             $newposition = $oldposition + 1;
         }
     }
     while ($swapitem = $group->getNextChild()) {
         if ($swapitem->getPosition() == $newposition) {
             $swapitem->setPosition($oldposition);
             $swapitem->save();
         }
     }
     if ($parentID != ROOT_BLOCK && $group->getChildType() == "EvaluationQuestion") {
         $object = new EvaluationQuestion($objectID);
     } else {
         $object =& $this->tree->getGroupObject($objectID);
     }
     $object->setPosition($newposition);
     $object->save();
     if ($swapitem->isError) {
         return EvalCommon::showErrorReport($swapitem, _("Fehler beim verschieben."));
     }
     if ($object->isError) {
         return EvalCommon::showErrorReport($object, _("Fehler beim verschieben."));
     }
 }
Esempio n. 3
0
 static function createErrorReport(&$object, $errortitle = "")
 {
     ob_start();
     EvalCommon::showErrorReport($object, $errortitle);
     $html = ob_get_contents();
     ob_end_clean();
     return $html;
 }
function save1($myuserid)
{
    $mineexists = 0;
    /*Existiert Question/Template schon?*/
    $qdb = new EvaluationQuestionDB();
    if (!$template_id) {
        $template_id = Request::option("template_id");
    }
    if ($qdb->exists($template_id)) {
        $question = new EvaluationQuestion($template_id, NULL, EVAL_LOAD_ALL_CHILDREN);
        if ($question->getParentID() != $myuserid) {
            $foreign = TRUE;
            $question = new EvaluationQuestion();
            $question->setParentID($myuserid);
        } else {
            $overwrite = 1;
            //$question->delete();
            //$question = new EvaluationQuestion();
            //$template_id=$question->getObjectID();
        }
    } else {
        $question = new EvaluationQuestion();
    }
    /*Get Vars ----------------------------------------------------*/
    $template_name = Request::get("template_name");
    $template_type = Request::get("template_type");
    $template_multiple = Request::get("template_multiple");
    $template_add_num_answers = Request::option("template_add_num_answers");
    $template_residual = Request::get("template_residual");
    $template_residual_text = Request::get("template_residual_text");
    $template_answers = Request::getArray("template_answers");
    /*end: Get Vars -----------------------------------------------*/
    $question->setParentID($myuserid);
    $question->setMultiplechoice($template_multiple);
    $question->setText(trim($template_name), YES);
    $question->setType($template_type);
    while ($answerrem = $question->getChild()) {
        $id = $answerrem->getObjectID();
        $answerrem->delete();
        $question->removeChildID($id);
    }
    $controlnumber = count($template_answers);
    $ausgleich = 0;
    for ($i = 0; $i < $controlnumber; $i++) {
        $text = $template_answers[$i]['text'];
        $answerID = $template_answers[$i]['answer_id'];
        $answer = new EvaluationAnswer();
        if (!$foreign) {
            $answer->setObjectID($answerID);
        }
        $answer->setText(trim($text), YES);
        $question->addChild($answer);
        /*Anzahl der Antworten bei Polskalen anpassen ------------------------*/
        if ($template_type == EVALQUESTION_TYPE_POL && $i == 0) {
            $answerdiff = $controlnumber - $template_add_num_answers;
            if ($template_residual) {
                //echo "Hust<br>";
                //$answerdiff;
            }
            if ($answerdiff > 0) {
                /*differenz abziehen => answers überspringen*/
                $i = $i + $answerdiff;
                $ausgleich = $ausgleich - $answerdiff;
            }
            while ($answerdiff < 0) {
                $ausgleich = $ausgleich + 1;
                $answer = new EvaluationAnswer();
                $answer->setText("");
                $answer->setParentID($question->getObjectID());
                $answer->setPosition($i + $ausgleich);
                $answer->setValue($i + 1 + $ausgleich);
                $question->addChild($answer);
                $answerdiff++;
            }
        }
        /*end: Polskala antworten angleichen ----------------------------------*/
    }
    /*create residual category-----------------------------------------------*/
    if ($template_residual) {
        $answer = new EvaluationAnswer();
        $answer->setResidual($template_residual);
        $answer->setText(trim($template_residual_text), QUOTED);
        $answer->setParentID($question->getObjectID());
        $answer->setPosition($i + $ausgleich + 1);
        $answer->setValue(-1);
        $question->addChild($answer);
    }
    /*object HIER NOCH NICHT in db speichern!      */
    // $question->save();
    if (!$overwrite) {
        $db = new EvaluationQuestionDB();
        $lib = new EvalTemplateGUI();
        $lib->setUniqueName($question, $db, $myuserid, YES);
    }
    if ($question->isError()) {
        EvalCommon::showErrorReport($question, _("Fehler beim Speichern."));
    }
    return $question;
}
//         "user" => "Seminar_User"));
// $auth->login_if ($auth->auth["uid"] == "nobody");
// $perm->check ("autor");
# ============================================================== end: PHP-LIB #
# Include all required files ================================================ #
require_once 'lib/evaluation/evaluation.config.php';
require_once EVAL_LIB_COMMON;
require_once EVAL_LIB_OVERVIEW;
require_once EVAL_FILE_EVAL;
require_once EVAL_FILE_EVALDB;
# ====================================================== end: including files #
define("DISCARD_OPENID", "discard_openid");
/* Create objects ---------------------------------------------------------- */
$db = new EvaluationObjectDB();
if ($db->isError) {
    return EvalCommon::showErrorReport($db, _("Datenbankfehler"));
}
$lib = new EvalOverview($db, $perm, $user);
/* ------------------------------------------------------------ end: objects */
/* Set variables ----------------------------------------------------------- */
if ($_SESSION['evalID']) {
    unset($_SESSION['evalID']);
}
if ($_SESSION['rangeID']) {
    unset($_SESSION['rangeID']);
}
if (!empty($the_range)) {
    $rangeID = $the_range;
}
$rangeID = $rangeID ? $rangeID : $SessSemName[1];
if (empty($rangeID) || $rangeID == get_username($user->id)) {