예제 #1
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();
 }
$table->attr("cellpadding", "3");
$table->attr("width", "100%");
$tr = new HTM("tr");
$td = new HTM("td");
$td->attr("class", "table_row_even");
if (!$command || $command == "back") {
    /* the template selection lists --------------------------------------- */
    $question_show = new EvaluationQuestionDB();
    $arrayOfTemplateIDs = $question_show->getTemplateID($myuserid);
    $arrayOfPolTemplates = 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;