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 "SurveyTextQuestion";
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 $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
00129 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00130 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00131 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00132 $this->tpl->setVariable("TEXT_MAXCHARS", $this->lng->txt("maxchars"));
00133 $this->tpl->setVariable("DESCRIPTION_MAXCHARS", $this->lng->txt("description_maxchars"));
00134 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00135 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00136 if ($this->object->getObligatory())
00137 {
00138 $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00139 }
00140 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00141 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00142 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00143 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($this->getQuestionType()));
00144 $this->tpl->parseCurrentBlock();
00145 include_once "./Services/RTE/classes/class.ilRTE.php";
00146 $rtestring = ilRTE::_getRTEClassname();
00147 include_once "./Services/RTE/classes/class.$rtestring.php";
00148 $rte = new $rtestring();
00149 $rte->addPlugin("latex");
00150 $rte->addButton("latex");
00151 $rte->removePlugin("ibrowser");
00152 include_once "./classes/class.ilObject.php";
00153 $obj_id = $_GET["q_id"];
00154 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00155 $rte->addRTESupport($obj_id, $obj_type, "survey");
00156 }
00157
00165 function outWorkingForm($working_data = "", $question_title = 1, $error_message = "")
00166 {
00167 if (count($this->object->material))
00168 {
00169 $this->tpl->setCurrentBlock("material_text");
00170 include_once "./survey/classes/class.SurveyQuestion.php";
00171 $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00172 $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
00173 $this->tpl->parseCurrentBlock();
00174 }
00175 $this->tpl->setCurrentBlock("question_data_text");
00176 $questiontext = $this->object->getQuestiontext();
00177 $this->tpl->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00178 if (! $this->object->getObligatory())
00179 {
00180 $this->tpl->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_optional"));
00181 }
00182 if ($question_title)
00183 {
00184 $this->tpl->setVariable("QUESTION_TITLE", $this->object->getTitle());
00185 }
00186 $this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
00187 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00188 if (is_array($working_data))
00189 {
00190 $this->tpl->setVariable("VALUE_ANSWER", $working_data[0]["textanswer"]);
00191 }
00192 if (strcmp($error_message, "") != 0)
00193 {
00194 $this->tpl->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
00195 }
00196 if ($this->object->getMaxChars())
00197 {
00198 $this->tpl->setVariable("TEXT_MAXCHARS", sprintf($this->lng->txt("text_maximum_chars_allowed"), $this->object->getMaxChars()));
00199 }
00200 $this->tpl->parseCurrentBlock();
00201 }
00202
00210 function preview()
00211 {
00212 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", true);
00213 $this->tpl->addBlockFile("TEXT", "text", "tpl.il_svy_out_text.html", true);
00214 $this->outWorkingForm();
00215 $this->tpl->parseCurrentBlock();
00216 }
00217
00226 function writePostData()
00227 {
00228 $result = 0;
00229 if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00230 $result = 1;
00231
00232
00233 if ($_POST["id"] > 0)
00234 $this->object->setId($_POST["id"]);
00235 include_once "./classes/class.ilUtil.php";
00236 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00237 $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00238 $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
00239 $this->object->setMaxChars(ilUtil::stripSlashes($_POST["maxchars"]));
00240 if (strlen($_POST["material"]))
00241 {
00242 $this->object->setMaterial($_POST["material"], 0, ilUtil::stripSlashes($_POST["material_title"]));
00243 }
00244 include_once "./classes/class.ilObjAdvancedEditing.php";
00245 $questiontext = ilUtil::stripSlashes($_POST["question"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
00246 $this->object->setQuestiontext($questiontext);
00247 if ($_POST["obligatory"])
00248 {
00249 $this->object->setObligatory(1);
00250 }
00251 else
00252 {
00253 $this->object->setObligatory(0);
00254 }
00255
00256 if ($saved)
00257 {
00258
00259
00260
00261
00262 $this->object->saveToDb();
00263 }
00264 return $result;
00265 }
00266
00267 function setQuestionTabs()
00268 {
00269 $this->setQuestionTabsForClass("surveytextquestiongui");
00270 }
00271
00272 function outCumulatedResultsDetails(&$cumulated_results, $counter)
00273 {
00274 $this->tpl->setCurrentBlock("detail_row");
00275 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("question"));
00276 $questiontext = $this->object->getQuestiontext();
00277 $this->tpl->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
00278 $this->tpl->parseCurrentBlock();
00279 $this->tpl->setCurrentBlock("detail_row");
00280 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
00281 $this->tpl->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
00282 $this->tpl->parseCurrentBlock();
00283 $this->tpl->setCurrentBlock("detail_row");
00284 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
00285 $this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["USERS_ANSWERED"]);
00286 $this->tpl->parseCurrentBlock();
00287 $this->tpl->setCurrentBlock("detail_row");
00288 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
00289 $this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["USERS_SKIPPED"]);
00290 $this->tpl->parseCurrentBlock();
00291
00292 $this->tpl->setCurrentBlock("detail_row");
00293 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("given_answers"));
00294 $textvalues = "";
00295 if (is_array($cumulated_results["textvalues"]))
00296 {
00297 foreach ($cumulated_results["textvalues"] as $textvalue)
00298 {
00299 $textvalues .= "<li>" . preg_replace("/\n/", "<br>", $textvalue) . "</li>";
00300 }
00301 }
00302 $textvalues = "<ul>$textvalues</ul>";
00303 $this->tpl->setVariable("TEXT_OPTION_VALUE", $textvalues);
00304 $this->tpl->parseCurrentBlock();
00305
00306 $this->tpl->setCurrentBlock("detail");
00307 $this->tpl->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
00308 $this->tpl->parseCurrentBlock();
00309 }
00310 }
00311 ?>