Exemplo n.º 1
0
 /**
 * 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."));
     }
 }
Exemplo n.º 2
0
                voteFor($answer);
            }
        }
    }
    /* process the user's typed-in answers --------------------------------- */
    $freetexts = Request::quotedArray('freetexts');
    if (is_array($freetexts)) {
        foreach ($freetexts as $question_id => $text) {
            if (trim($text) != '') {
                $question = new EvaluationQuestion($question_id);
                $answer = new EvaluationAnswer();
                $answer->setText($text);
                $answer->setRows(1);
                $answer->vote($GLOBALS["userID"]);
                $question->addChild($answer);
                $question->save();
                $debug .= "added answer text <b>" . $answer->getText() . "</b> for question <b>" . $question->getText() . "</b>\n";
            }
        }
    }
    /* connect user with eval */
    $evalDB->connectWithUser($evalID, $auth->auth["uid"]);
    /* header ------ */
    $table->cont($lib->createEvaluationHeader($eval, $votedNow, $votedEarlier));
} elseif ($votedEarlier) {
    /* header ------ */
    $table->cont($lib->createEvaluationHeader($eval, $votedNow, $votedEarlier));
} else {
    /* header ------ */
    $table->cont($lib->createEvaluationHeader($eval, $votedNow, $votedEarlier));
    /* the whole evaluation ------ */