Ejemplo n.º 1
0
$table->attr("width", "100%");
$tr = new HTM("tr");
$td = new HTM("td");
$td->attr("class", "table_row_even");
if (!$command || $command == "back") {
    /* the template selection lists --------------------------------------- */
    $question_show = new EvaluationQuestionDB();
    $arrayOfTemplateIDs = $question_show->getTemplateID($myuserid);
    $arrayOfPolTemplates = array();
    $arrayOfSkalaTemplates = array();
    $arrayOfNormalTemplates = array();
    $arrayOfFreeTemplates = array();
    foreach ($arrayOfTemplateIDs as $templateID) {
        $questionload = new EvaluationQuestion($templateID, NULL, EVAL_LOAD_FIRST_CHILDREN);
        $typ = $questionload->getType();
        $text = my_substr($questionload->getText(), 0, EVAL_MAX_TEMPLATENAMELEN);
        /*Root kennzeichnung hier entfernen!!*/
        //if($questionload->getParentID()==0)
        //  $text="<b>".$text."</b>";
        if ($questionload->getParentID() == '0') {
            $text = $questionload->getText() . " " . EVAL_ROOT_TAG;
        }
        if (($answer = $questionload->getChild()) == NULL) {
            $answer = new EvaluationAnswer();
        }
        /* --------------------------------------------------------------- */
        switch ($typ) {
            case EVALQUESTION_TYPE_POL:
                array_push($arrayOfPolTemplates, array($questionload->getObjectID(), $text));
                break;
            case EVALQUESTION_TYPE_LIKERT:
Ejemplo n.º 2
0
 /**
 * 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 = array();
     $arrayOfSkalaTemplates = array();
     $arrayOfNormalTemplates = array();
     $arrayOfFreetextTemplates = array();
     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, array($question->getObjectID(), $questiontext));
                     break;
                 case EVALQUESTION_TYPE_LIKERT:
                     array_push($arrayOfSkalaTemplates, array($question->getObjectID(), $questiontext));
                     break;
                 case EVALQUESTION_TYPE_MC:
                     $answer = $question->getNextChild();
                     if ($answer && $answer->isFreetext()) {
                         array_push($arrayOfFreetextTemplates, array($question->getObjectID(), $questiontext));
                     } else {
                         array_push($arrayOfNormalTemplates, array($question->getObjectID(), $questiontext));
                     }
                     break;
             }
         }
     }
     // End:  if (is_array ($arrayOfTemplateIDs))
     $select = new HTML("select");
     $select->addAttr("name", "templateID");
     $select->addAttr("style", "vertical-align:middle;");
     $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();
 }
Ejemplo n.º 3
0
            }
        }
    }
    /* 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 ------ */
    $table->cont($lib->createEvaluation($tree));