Пример #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();
 }