/** * Adds Questions * * @access private * @return boolean true (reinits the tree) */ function execCommandAddQuestions() { $addquestions = Request::get('newQuestionFields'); $qgroup =& $this->tree->getGroupObject($this->itemID); $templateID = $qgroup->getTemplateID(); for ($i = 1; $i <= $addquestions; $i++) { $template = new EvaluationQuestion($templateID, NULL, EVAL_LOAD_FIRST_CHILDREN); $newquestion = $template->duplicate(); $newquestion->setText(""); $qgroup->addChild($newquestion); $qgroup->save(); if ($qgroup->isError) { return EvalCommon::showErrorReport($this->tree->eval, _("Fehler beim Anlegen neuer Fragen.")); } } if ($addquestions == "1") { $this->msg[$this->itemID] = "msg§" . _("Es wurde eine neue Frage hinzugefügt."); } else { $this->msg[$this->itemID] = "msg§" . sprintf(_("Es wurden %s neue Fragen hinzugefügt."), $addquestions); } $this->execCommandUpdateItem(NO); return true; }
/** * Sets the template id * @access public * @param string $templateID The template id */ function setTemplateID($templateID) { $newQuestionTexts = array(); # if ($templateID == $this->templateID) # return; // for performance reasons $this->templateID = $templateID; while ($child =& $this->getChild()) { array_push($newQuestionTexts, $child->getText()); $child->delete(); } while ($text = array_pop($newQuestionTexts)) { $template = new EvaluationQuestion($templateID, NULL, EVAL_LOAD_ALL_CHILDREN); $child =& $template->duplicate(); $child->setText($text); $this->addChild($child); } }