00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 require_once "./survey/classes/class.SurveyTextQuestion.php";
00025 require_once "./survey/classes/class.SurveyQuestionGUI.php";
00026
00038 class SurveyTextQuestionGUI extends SurveyQuestionGUI {
00039
00048 function SurveyTextQuestionGUI(
00049 $id = -1
00050 )
00051
00052 {
00053 $this->SurveyQuestionGUI();
00054 $this->object = new SurveyTextQuestion();
00055 if ($id >= 0)
00056 {
00057 $this->object->loadFromDb($id);
00058 }
00059 }
00060
00069 function getQuestionType()
00070 {
00071 return "qt_text";
00072 }
00073
00081 function editQuestion() {
00082 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_text.html", true);
00083 $this->tpl->addBlockFile("OTHER_QUESTION_DATA", "other_question_data", "tpl.il_svy_qpl_other_question_data.html", true);
00084
00085 $internallinks = array(
00086 "lm" => $this->lng->txt("obj_lm"),
00087 "st" => $this->lng->txt("obj_st"),
00088 "pg" => $this->lng->txt("obj_pg"),
00089 "glo" => $this->lng->txt("glossary_term")
00090 );
00091 foreach ($internallinks as $key => $value)
00092 {
00093 $this->tpl->setCurrentBlock("internallink");
00094 $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00095 $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00096 $this->tpl->parseCurrentBlock();
00097 }
00098
00099 $this->tpl->setCurrentBlock("adm_content");
00100 $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material"));
00101 if (count($this->object->material))
00102 {
00103 $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00104 $this->tpl->setVariable("TEXT_VALUE_MATERIAL", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("material"). "</a> ");
00105 $this->tpl->setVariable("BUTTON_REMOVE_MATERIAL", $this->lng->txt("remove"));
00106 $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("change"));
00107 $this->tpl->setVariable("VALUE_MATERIAL", $this->object->material["internal_link"]);
00108 $this->tpl->setVariable("VALUE_MATERIAL_TITLE", $this->object->material["title"]);
00109 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00110 }
00111 else
00112 {
00113 $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("add"));
00114 }
00115 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00116 $this->tpl->setVariable("VALUE_TITLE", $this->object->getTitle());
00117 $this->tpl->setVariable("VALUE_DESCRIPTION", $this->object->getDescription());
00118 $this->tpl->setVariable("VALUE_AUTHOR", $this->object->getAuthor());
00119 if ($this->object->getMaxChars() > 0)
00120 {
00121 $this->tpl->setVariable("VALUE_MAXCHARS", $this->object->getMaxChars());
00122 }
00123 $questiontext = $this->object->getQuestiontext();
00124 $questiontext = str_replace("<br />", "\n", $questiontext);
00125 $this->tpl->setVariable("VALUE_QUESTION", htmlspecialchars($questiontext));
00126 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00127 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00128 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00129 $this->tpl->setVariable("TEXT_MAXCHARS", $this->lng->txt("maxchars"));
00130 $this->tpl->setVariable("DESCRIPTION_MAXCHARS", $this->lng->txt("description_maxchars"));
00131 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00132 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00133 if ($this->object->getObligatory())
00134 {
00135 $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00136 }
00137 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00138 $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
00139 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00140 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00141 $this->tpl->parseCurrentBlock();
00142 }
00143
00151 function outWorkingForm($working_data = "", $question_title = 1, $error_message = "")
00152 {
00153 if (count($this->object->material))
00154 {
00155 $this->tpl->setCurrentBlock("material_text");
00156 $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00157 $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
00158 $this->tpl->parseCurrentBlock();
00159 }
00160 $this->tpl->setCurrentBlock("question_data_text");
00161 $this->tpl->setVariable("QUESTIONTEXT", $this->object->getQuestiontext());
00162 if ($this->object->getObligatory())
00163 {
00164 $this->tpl->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_obligatory"));
00165 }
00166 if ($question_title)
00167 {
00168 $this->tpl->setVariable("QUESTION_TITLE", $this->object->getTitle());
00169 }
00170 $this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
00171 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00172 if (is_array($working_data))
00173 {
00174 $this->tpl->setVariable("VALUE_ANSWER", $working_data[0]["textanswer"]);
00175 }
00176 if (strcmp($error_message, "") != 0)
00177 {
00178 $this->tpl->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
00179 }
00180 if ($this->object->getMaxChars())
00181 {
00182 $this->tpl->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
00183 }
00184 $this->tpl->parseCurrentBlock();
00185 }
00186
00194 function preview()
00195 {
00196 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", true);
00197 $this->tpl->addBlockFile("TEXT", "text", "tpl.il_svy_out_text.html", true);
00198 $this->outWorkingForm();
00199 $this->tpl->parseCurrentBlock();
00200 }
00201
00210 function writePostData() {
00211 $result = 0;
00212 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00213 $result = 1;
00214
00215
00216 if ($_POST["id"] > 0)
00217 $this->object->setId($_POST["id"]);
00218
00219 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00220 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00221 $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
00222 $this->object->setMaxChars(ilUtil::stripSlashes($_POST["maxchars"]));
00223 if (strlen($_POST["material"]))
00224 {
00225 $this->object->setMaterial($_POST["material"], 0, ilUtil::stripSlashes($_POST["material_title"]));
00226 }
00227 $questiontext = ilUtil::stripSlashes($_POST["question"]);
00228 $questiontext = str_replace("\n", "<br />", $questiontext);
00229 $this->object->setQuestiontext($questiontext);
00230 if ($_POST["obligatory"])
00231 {
00232 $this->object->setObligatory(1);
00233 }
00234 else
00235 {
00236 $this->object->setObligatory(0);
00237 }
00238
00239 if ($saved) {
00240
00241
00242
00243
00244 $this->object->saveToDb();
00245 }
00246 return $result;
00247 }
00248
00249 function setQuestionTabs()
00250 {
00251 $this->setQuestionTabsForClass("surveytextquestiongui");
00252 }
00253 }
00254 ?>