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