• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

survey/classes/class.SurveyMetricQuestionGUI.php

Go to the documentation of this file.
00001 <?php
00002  /*
00003    +----------------------------------------------------------------------------+
00004    | ILIAS open source                                                          |
00005    +----------------------------------------------------------------------------+
00006    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne           |
00007    |                                                                            |
00008    | This program is free software; you can redistribute it and/or              |
00009    | modify it under the terms of the GNU General Public License                |
00010    | as published by the Free Software Foundation; either version 2             |
00011    | of the License, or (at your option) any later version.                     |
00012    |                                                                            |
00013    | This program is distributed in the hope that it will be useful,            |
00014    | but WITHOUT ANY WARRANTY; without even the implied warranty of             |
00015    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              |
00016    | GNU General Public License for more details.                               |
00017    |                                                                            |
00018    | You should have received a copy of the GNU General Public License          |
00019    | along with this program; if not, write to the Free Software                |
00020    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
00021    +----------------------------------------------------------------------------+
00022 */
00023 
00024 require_once "./survey/classes/class.SurveyMetricQuestion.php";
00025 require_once "./survey/classes/class.SurveyQuestionGUI.php";
00026 
00038 class SurveyMetricQuestionGUI extends SurveyQuestionGUI {
00047   function SurveyMetricQuestionGUI(
00048                 $id = -1
00049   )
00050 
00051   {
00052                 $this->SurveyQuestionGUI();
00053                 $this->object = new SurveyMetricQuestion();
00054                 if ($id >= 0)
00055                 {
00056                         $this->object->loadFromDb($id);
00057                 }
00058         }
00059 
00068         function getQuestionType()
00069         {
00070                 return "qt_metric";
00071         }
00072 
00080   function editQuestion() {
00081                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_metric.html", true);
00082           $this->tpl->addBlockFile("OTHER_QUESTION_DATA", "other_question_data", "tpl.il_svy_qpl_other_question_data.html", true);
00083                 $internallinks = array(
00084                         "lm" => $this->lng->txt("obj_lm"),
00085                         "st" => $this->lng->txt("obj_st"),
00086                         "pg" => $this->lng->txt("obj_pg"),
00087                         "glo" => $this->lng->txt("glossary_term")
00088                 );
00089                 foreach ($internallinks as $key => $value)
00090                 {
00091                         $this->tpl->setCurrentBlock("internallink");
00092                         $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00093                         $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00094                         $this->tpl->parseCurrentBlock();
00095                 }
00096                 
00097                 $this->tpl->setCurrentBlock("adm_content");
00098                 $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material"));
00099                 if (count($this->object->material))
00100                 {
00101                         $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00102                         $this->tpl->setVariable("TEXT_VALUE_MATERIAL", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("material"). "</a> ");
00103                         $this->tpl->setVariable("BUTTON_REMOVE_MATERIAL", $this->lng->txt("remove"));
00104                         $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("change"));
00105                         $this->tpl->setVariable("VALUE_MATERIAL", $this->object->material["internal_link"]);
00106                         $this->tpl->setVariable("VALUE_MATERIAL_TITLE", $this->object->material["title"]);
00107                         $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00108                 }
00109                 else
00110                 {
00111                         $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("add"));
00112                 }
00113                 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00114                 $this->tpl->setVariable("VALUE_TITLE", $this->object->getTitle());
00115                 $this->tpl->setVariable("VALUE_DESCRIPTION", $this->object->getDescription());
00116                 $this->tpl->setVariable("VALUE_AUTHOR", $this->object->getAuthor());
00117                 $questiontext = $this->object->getQuestiontext();
00118                 $questiontext = str_replace("<br />", "\n", $questiontext);
00119                 $this->tpl->setVariable("VALUE_QUESTION", htmlspecialchars($questiontext));
00120                 $this->tpl->setVariable("VALUE_MINIMUM", $this->object->getMinimum());
00121                 $this->tpl->setVariable("VALUE_MAXIMUM", $this->object->getMaximum());
00122                 $this->tpl->setVariable("TEXT_MINIMUM", $this->lng->txt("minimum"));
00123                 $this->tpl->setVariable("TEXT_MAXIMUM", $this->lng->txt("maximum"));
00124                 $this->tpl->setVariable("TEXT_NONRATIO", $this->lng->txt("non_ratio"));
00125                 $this->tpl->setVariable("TEXT_RATIONONABSOLUTE", $this->lng->txt("ratio_non_absolute"));
00126                 $this->tpl->setVariable("TEXT_RATIOABSOLUTE", $this->lng->txt("ratio_absolute"));
00127                 if ($this->object->getSubtype() == SUBTYPE_NON_RATIO)
00128                 {
00129                         $this->tpl->setVariable("SELECTED_NONRATIO", " selected=\"selected\"");
00130                 }
00131                 else if ($this->object->getSubtype() == SUBTYPE_RATIO_NON_ABSOLUTE)
00132                 {
00133                         $this->tpl->setVariable("SELECTED_RATIONONABSOLUTE", " selected=\"selected\"");
00134                 }
00135                 else if ($this->object->getSubtype() == SUBTYPE_RATIO_ABSOLUTE)
00136                 {
00137                         $this->tpl->setVariable("SELECTED_RATIOABSOLUTE", " selected=\"selected\"");
00138                 }
00139                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00140                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00141                 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00142                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00143                 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00144                 if ($this->object->getObligatory())
00145                 {
00146                         $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00147                 }
00148                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("questiontype"));
00149                 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00150                 $this->tpl->setVariable("CANCEL",$this->lng->txt("cancel"));
00151                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00152                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00153                 $this->tpl->parseCurrentBlock();
00154   }
00155 
00164   function writePostData() {
00165     $result = 0;
00166     if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00167       $result = 1;
00168 
00169     // Set the question id from a hidden form parameter
00170     if ($_POST["id"] > 0)
00171       $this->object->setId($_POST["id"]);
00172 
00173     $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00174     $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00175     $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
00176                 if (strlen($_POST["material"]))
00177                 {
00178                         $this->object->setMaterial($_POST["material"], 0, ilUtil::stripSlashes($_POST["material_title"]));
00179                 }
00180                 $questiontext = ilUtil::stripSlashes($_POST["question"]);
00181                 $questiontext = str_replace("\n", "<br />", $questiontext);
00182     $this->object->setQuestiontext($questiontext);
00183                 if ($_POST["obligatory"])
00184                 {
00185                         $this->object->setObligatory(1);
00186                 }
00187                 else
00188                 {
00189                         $this->object->setObligatory(0);
00190                 }
00191                 $this->object->setSubtype($_POST["type"]);
00192                 $this->object->setMinimum($_POST["minimum"]);
00193                 $this->object->setMaximum($_POST["maximum"]);
00194 
00195                 if ($saved) {
00196                         // If the question was saved automatically before an upload, we have to make
00197                         // sure, that the state after the upload is saved. Otherwise the user could be
00198                         // irritated, if he presses cancel, because he only has the question state before
00199                         // the upload process.
00200                         $this->object->saveToDb();
00201                 }
00202     return $result;
00203   }
00204 
00212         function outWorkingForm($working_data = "", $question_title = 1, $error_message = "")
00213         {
00214                 if (count($this->object->material))
00215                 {
00216                         $this->tpl->setCurrentBlock("material_metric");
00217                         $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00218                         $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
00219                         $this->tpl->parseCurrentBlock();
00220                 }
00221                 $this->tpl->setCurrentBlock("question_data_metric");
00222                 $this->tpl->setVariable("QUESTIONTEXT", $this->object->getQuestiontext());
00223                 if ($this->object->getObligatory())
00224                 {
00225                         $this->tpl->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_obligatory"));
00226                 }
00227                 if ($question_title)
00228                 {
00229                         $this->tpl->setVariable("QUESTION_TITLE", $this->object->getTitle());
00230                 }
00231                 $this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
00232                 $this->tpl->setVariable("TEXT_MINIMUM", $this->lng->txt("minimum"));
00233                 $this->tpl->setVariable("VALUE_MINIMUM", $this->object->getMinimum());
00234                 $this->tpl->setVariable("TEXT_MAXIMUM", $this->lng->txt("maximum"));
00235                 $this->tpl->setVariable("VALUE_MAXIMUM", $this->object->getMaximum());
00236                 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00237                 if (is_array($working_data))
00238                 {
00239                         $this->tpl->setVariable("VALUE_METRIC", $working_data[0]["value"]);
00240                 }
00241 
00242                 if (strlen($this->object->getMaximum())>1) {
00243                         $len = strlen($this->object->getMaximum()) + 2;
00244                         $this->tpl->setVariable("INPUT_SIZE", $len);
00245                 }
00246                 else {
00247                         $this->tpl->setVariable("INPUT_SIZE", 10);
00248                 }
00249 
00250                 if (strcmp($error_message, "") != 0)
00251                 {
00252                         $this->tpl->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
00253                 }
00254                 $this->tpl->parseCurrentBlock();
00255         }
00256 
00264         function preview()
00265         {
00266                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", true);
00267                 $this->tpl->addBlockFile("METRIC", "metric", "tpl.il_svy_out_metric.html", true);
00268                 $this->outWorkingForm();
00269                 $this->tpl->parseCurrentBlock();
00270         }
00271 
00272         function setQuestionTabs()
00273         {
00274                 $this->setQuestionTabsForClass("surveymetricquestiongui");
00275         }
00276 }
00277 ?>

Generated on Fri Dec 13 2013 09:06:38 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1