• 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 include_once "./survey/classes/class.SurveyQuestionGUI.php";
00025 include_once "./survey/classes/inc.SurveyConstants.php";
00026 
00038 class SurveyMetricQuestionGUI extends SurveyQuestionGUI 
00039 {
00048   function SurveyMetricQuestionGUI(
00049                 $id = -1
00050   )
00051 
00052   {
00053                 $this->SurveyQuestionGUI();
00054                 include_once "./survey/classes/class.SurveyMetricQuestion.php";
00055                 $this->object = new SurveyMetricQuestion();
00056                 if ($id >= 0)
00057                 {
00058                         $this->object->loadFromDb($id);
00059                 }
00060         }
00061 
00070         function getQuestionType()
00071         {
00072                 return "qt_metric";
00073         }
00074 
00082   function editQuestion() {
00083                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_metric.html", true);
00084           $this->tpl->addBlockFile("OTHER_QUESTION_DATA", "other_question_data", "tpl.il_svy_qpl_other_question_data.html", true);
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                         include_once "./survey/classes/class.SurveyQuestion.php";
00104                         $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00105                         $this->tpl->setVariable("TEXT_VALUE_MATERIAL", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("material"). "</a> ");
00106                         $this->tpl->setVariable("BUTTON_REMOVE_MATERIAL", $this->lng->txt("remove"));
00107                         $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("change"));
00108                         $this->tpl->setVariable("VALUE_MATERIAL", $this->object->material["internal_link"]);
00109                         $this->tpl->setVariable("VALUE_MATERIAL_TITLE", $this->object->material["title"]);
00110                         $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00111                 }
00112                 else
00113                 {
00114                         $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("add"));
00115                 }
00116                 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00117                 $this->tpl->setVariable("VALUE_TITLE", $this->object->getTitle());
00118                 $this->tpl->setVariable("VALUE_DESCRIPTION", $this->object->getDescription());
00119                 $this->tpl->setVariable("VALUE_AUTHOR", $this->object->getAuthor());
00120                 $questiontext = $this->object->getQuestiontext();
00121                 $questiontext = str_replace("<br />", "\n", $questiontext);
00122                 $this->tpl->setVariable("VALUE_QUESTION", htmlspecialchars($questiontext));
00123                 $this->tpl->setVariable("VALUE_MINIMUM", $this->object->getMinimum());
00124                 $this->tpl->setVariable("VALUE_MAXIMUM", $this->object->getMaximum());
00125                 $this->tpl->setVariable("TEXT_MINIMUM", $this->lng->txt("minimum"));
00126                 $this->tpl->setVariable("TEXT_MAXIMUM", $this->lng->txt("maximum"));
00127                 $this->tpl->setVariable("TEXT_NONRATIO", $this->lng->txt("non_ratio"));
00128                 $this->tpl->setVariable("TEXT_RATIONONABSOLUTE", $this->lng->txt("ratio_non_absolute"));
00129                 $this->tpl->setVariable("TEXT_RATIOABSOLUTE", $this->lng->txt("ratio_absolute"));
00130                 if ($this->object->getSubtype() == SUBTYPE_NON_RATIO)
00131                 {
00132                         $this->tpl->setVariable("SELECTED_NONRATIO", " selected=\"selected\"");
00133                 }
00134                 else if ($this->object->getSubtype() == SUBTYPE_RATIO_NON_ABSOLUTE)
00135                 {
00136                         $this->tpl->setVariable("SELECTED_RATIONONABSOLUTE", " selected=\"selected\"");
00137                 }
00138                 else if ($this->object->getSubtype() == SUBTYPE_RATIO_ABSOLUTE)
00139                 {
00140                         $this->tpl->setVariable("SELECTED_RATIOABSOLUTE", " selected=\"selected\"");
00141                 }
00142                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00143                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00144                 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00145                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00146                 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00147                 if ($this->object->getObligatory())
00148                 {
00149                         $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00150                 }
00151                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("questiontype"));
00152                 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
00153                 $this->tpl->setVariable("TXT_REQUIRED_FLD", $this->lng->txt("required_field"));
00154                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00155                 $this->tpl->parseCurrentBlock();
00156   }
00157 
00166   function writePostData() {
00167     $result = 0;
00168     if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00169       $result = 1;
00170 
00171     // Set the question id from a hidden form parameter
00172     if ($_POST["id"] > 0)
00173       $this->object->setId($_POST["id"]);
00174 
00175                 include_once "./classes/class.ilUtil.php";      
00176                 $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00177     $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00178     $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
00179                 if (strlen($_POST["material"]))
00180                 {
00181                         $this->object->setMaterial($_POST["material"], 0, ilUtil::stripSlashes($_POST["material_title"]));
00182                 }
00183                 $questiontext = ilUtil::stripSlashes($_POST["question"]);
00184                 $questiontext = str_replace("\n", "<br />", $questiontext);
00185     $this->object->setQuestiontext($questiontext);
00186                 if ($_POST["obligatory"])
00187                 {
00188                         $this->object->setObligatory(1);
00189                 }
00190                 else
00191                 {
00192                         $this->object->setObligatory(0);
00193                 }
00194                 $this->object->setSubtype($_POST["type"]);
00195                 $minimum = $_POST["minimum"];
00196                 if ($this->object->getSubtype() > 3)
00197                 {
00198                         if ($minimum < 0)
00199                         {
00200                                 $this->errormessage = $this->lng->txt("ratio_scale_ge_zero");
00201                                 $result = 1;
00202                         }
00203                 }
00204                 $this->object->setMinimum($minimum);
00205                 $this->object->setMaximum($_POST["maximum"]);
00206 
00207                 if ($saved) {
00208                         // If the question was saved automatically before an upload, we have to make
00209                         // sure, that the state after the upload is saved. Otherwise the user could be
00210                         // irritated, if he presses cancel, because he only has the question state before
00211                         // the upload process.
00212                         $this->object->saveToDb();
00213                 }
00214     return $result;
00215   }
00216 
00224         function outWorkingForm($working_data = "", $question_title = 1, $error_message = "")
00225         {
00226                 if (count($this->object->material))
00227                 {
00228                         $this->tpl->setCurrentBlock("material_metric");
00229                         include_once "./survey/classes/class.SurveyQuestion.php";
00230                         $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00231                         $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
00232                         $this->tpl->parseCurrentBlock();
00233                 }
00234 
00235                 if (strlen($this->object->getMinimum()))
00236                 {
00237                         $this->tpl->setCurrentBlock("minimum");
00238                         $this->tpl->setVariable("TEXT_MINIMUM", $this->lng->txt("minimum"));
00239                         $this->tpl->setVariable("VALUE_MINIMUM", $this->object->getMinimum());
00240                         $this->tpl->parseCurrentBlock();
00241                 }
00242                 if (strlen($this->object->getMaximum()))
00243                 {
00244                         $this->tpl->setCurrentBlock("maximum");
00245                         $this->tpl->setVariable("TEXT_MAXIMUM", $this->lng->txt("maximum"));
00246                         $this->tpl->setVariable("VALUE_MAXIMUM", $this->object->getMaximum());
00247                         $this->tpl->parseCurrentBlock();
00248                 }
00249 
00250                 $this->tpl->setCurrentBlock("question_data_metric");
00251                 $this->tpl->setVariable("QUESTIONTEXT", $this->object->getQuestiontext());
00252                 if (! $this->object->getObligatory())
00253                 {
00254                         $this->tpl->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_optional"));
00255                 }
00256                 if ($question_title)
00257                 {
00258                         $this->tpl->setVariable("QUESTION_TITLE", $this->object->getTitle());
00259                 }
00260                 $this->tpl->setVariable("TEXT_ANSWER", $this->lng->txt("answer"));
00261                 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00262                 if (is_array($working_data))
00263                 {
00264                         $this->tpl->setVariable("VALUE_METRIC", $working_data[0]["value"]);
00265                 }
00266 
00267                 if (strlen($this->object->getMaximum())>1) {
00268                         $len = strlen($this->object->getMaximum()) + 2;
00269                         $this->tpl->setVariable("INPUT_SIZE", $len);
00270                 }
00271                 else {
00272                         $this->tpl->setVariable("INPUT_SIZE", 10);
00273                 }
00274 
00275                 if (strcmp($error_message, "") != 0)
00276                 {
00277                         $this->tpl->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
00278                 }
00279                 $this->tpl->parseCurrentBlock();
00280         }
00281 
00289         function preview()
00290         {
00291                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", true);
00292                 $this->tpl->addBlockFile("METRIC", "metric", "tpl.il_svy_out_metric.html", true);
00293                 $this->outWorkingForm();
00294                 $this->tpl->parseCurrentBlock();
00295         }
00296 
00297         function setQuestionTabs()
00298         {
00299                 $this->setQuestionTabsForClass("surveymetricquestiongui");
00300         }
00301 }
00302 ?>

Generated on Fri Dec 13 2013 11:58:02 for ILIAS Release_3_6_x_branch .rev 46809 by  doxygen 1.7.1