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

survey/classes/class.SurveyOrdinalQuestionGUI.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 SurveyOrdinalQuestionGUI extends SurveyQuestionGUI 
00039 {
00040 
00049   function SurveyOrdinalQuestionGUI(
00050                 $id = -1
00051   )
00052 
00053   {
00054                 $this->SurveyQuestionGUI();
00055                 include_once "./survey/classes/class.SurveyOrdinalQuestion.php";
00056                 $this->object = new SurveyOrdinalQuestion();
00057                 if ($id >= 0)
00058                 {
00059                         $this->object->loadFromDb($id);
00060                 }
00061         }
00062         
00071         function getQuestionType()
00072         {
00073                 return "SurveyOrdinalQuestion";
00074         }
00075 
00083   function editQuestion() 
00084         {
00085                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_ordinal.html", true);
00086           $this->tpl->addBlockFile("OTHER_QUESTION_DATA", "other_question_data", "tpl.il_svy_qpl_other_question_data.html", true);
00087                 $internallinks = array(
00088                         "lm" => $this->lng->txt("obj_lm"),
00089                         "st" => $this->lng->txt("obj_st"),
00090                         "pg" => $this->lng->txt("obj_pg"),
00091                         "glo" => $this->lng->txt("glossary_term")
00092                 );
00093                 foreach ($internallinks as $key => $value)
00094                 {
00095                         $this->tpl->setCurrentBlock("internallink");
00096                         $this->tpl->setVariable("TYPE_INTERNAL_LINK", $key);
00097                         $this->tpl->setVariable("TEXT_INTERNAL_LINK", $value);
00098                         $this->tpl->parseCurrentBlock();
00099                 }
00100                 
00101                 $this->tpl->setCurrentBlock("adm_content");
00102                 $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material"));
00103                 if (count($this->object->material))
00104                 {
00105                         include_once "./survey/classes/class.SurveyQuestion.php";
00106                         $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00107                         $this->tpl->setVariable("TEXT_VALUE_MATERIAL", " <a href=\"$href\" target=\"content\">" . $this->lng->txt("material"). "</a> ");
00108                         $this->tpl->setVariable("BUTTON_REMOVE_MATERIAL", $this->lng->txt("remove"));
00109                         $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("change"));
00110                         $this->tpl->setVariable("VALUE_MATERIAL", $this->object->material["internal_link"]);
00111                         $this->tpl->setVariable("VALUE_MATERIAL_TITLE", $this->object->material["title"]);
00112                         $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00113                 }
00114                 else
00115                 {
00116                         $this->tpl->setVariable("BUTTON_ADD_MATERIAL", $this->lng->txt("add"));
00117                 }
00118                 $this->tpl->setVariable("TEXT_ORIENTATION", $this->lng->txt("orientation"));
00119                 switch ($this->object->getOrientation())
00120                 {
00121                         case 0:
00122                                 $this->tpl->setVariable("SELECTED_VERTICAL", " selected=\"selected\"");
00123                                 break;
00124                         case 1:
00125                                 $this->tpl->setVariable("SELECTED_HORIZONTAL", " selected=\"selected\"");
00126                                 break;
00127                         case 2:
00128                                 $this->tpl->setVariable("SELECTED_COMBOBOX", " selected=\"selected\"");
00129                                 break;
00130                 }
00131                 $this->tpl->setVariable("TXT_VERTICAL", $this->lng->txt("vertical"));
00132                 $this->tpl->setVariable("TXT_HORIZONTAL", $this->lng->txt("horizontal"));
00133                 $this->tpl->setVariable("TXT_COMBOBOX", $this->lng->txt("combobox"));
00134                 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00135                 $this->tpl->setVariable("VALUE_TITLE", $this->object->getTitle());
00136                 $this->tpl->setVariable("VALUE_DESCRIPTION", $this->object->getDescription());
00137                 $this->tpl->setVariable("VALUE_AUTHOR", $this->object->getAuthor());
00138                 $questiontext = $this->object->getQuestiontext();
00139                 $this->tpl->setVariable("VALUE_QUESTION", ilUtil::prepareFormOutput($this->object->prepareTextareaOutput($questiontext)));
00140                 $this->tpl->setVariable("TEXT_TITLE", $this->lng->txt("title"));
00141                 $this->tpl->setVariable("TEXT_AUTHOR", $this->lng->txt("author"));
00142                 $this->tpl->setVariable("TEXT_DESCRIPTION", $this->lng->txt("description"));
00143                 $this->tpl->setVariable("TEXT_QUESTION", $this->lng->txt("question"));
00144                 $this->tpl->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt("questiontype"));
00145                 $this->tpl->setVariable("TEXT_OBLIGATORY", $this->lng->txt("obligatory"));
00146                 if ($this->object->getObligatory())
00147                 {
00148                         $this->tpl->setVariable("CHECKED_OBLIGATORY", " checked=\"checked\"");
00149                 }
00150                 $this->tpl->setVariable("SAVE",$this->lng->txt("save"));
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->setVariable("TEXT_QUESTION_TYPE", $this->lng->txt($this->getQuestionType()));
00154                 $this->tpl->parseCurrentBlock();
00155                 include_once "./Services/RTE/classes/class.ilRTE.php";
00156                 $rtestring = ilRTE::_getRTEClassname();
00157                 include_once "./Services/RTE/classes/class.$rtestring.php";
00158                 $rte = new $rtestring();
00159                 $rte->addPlugin("latex");               
00160                 $rte->addButton("latex");
00161                 $rte->removePlugin("ibrowser");
00162                 include_once "./classes/class.ilObject.php";
00163                 $obj_id = $_GET["q_id"];
00164                 $obj_type = ilObject::_lookupType($_GET["ref_id"], TRUE);
00165                 $rte->addRTESupport($obj_id, $obj_type, "survey");
00166 
00167   }
00168 
00176         function outWorkingForm($working_data = "", $question_title = 1, $error_message = "")
00177         {
00178                 if (count($this->object->material))
00179                 {
00180                         $this->tpl->setCurrentBlock("material_ordinal");
00181                         include_once "./survey/classes/class.SurveyQuestion.php";
00182                         $href = SurveyQuestion::_getInternalLinkHref($this->object->material["internal_link"]);
00183                         $this->tpl->setVariable("TEXT_MATERIAL", $this->lng->txt("material") . ": <a href=\"$href\" target=\"content\">" . $this->object->material["title"]. "</a> ");
00184                         $this->tpl->parseCurrentBlock();
00185                 }
00186                 switch ($this->object->orientation)
00187                 {
00188                         case 0:
00189                                 // vertical orientation
00190                                 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) 
00191                                 {
00192                                         $category = $this->object->categories->getCategory($i);
00193                                         $this->tpl->setCurrentBlock("ordinal_row");
00194                                         $this->tpl->setVariable("TEXT_ORDINAL", $category);
00195                                         $this->tpl->setVariable("VALUE_ORDINAL", $i);
00196                                         $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00197                                         if (is_array($working_data))
00198                                         {
00199                                                 if (strcmp($working_data[0]["value"], "") != 0)
00200                                                 {
00201                                                         if ($working_data[0]["value"] == $i)
00202                                                         {
00203                                                                 $this->tpl->setVariable("CHECKED_ORDINAL", " checked=\"checked\"");
00204                                                         }
00205                                                 }
00206                                         }
00207                                         $this->tpl->parseCurrentBlock();
00208                                 }
00209                                 break;
00210                         case 1:
00211                                 // horizontal orientation
00212                                 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) 
00213                                 {
00214                                         $category = $this->object->categories->getCategory($i);
00215                                         $this->tpl->setCurrentBlock("radio_col_ordinal");
00216                                         $this->tpl->setVariable("VALUE_ORDINAL", $i);
00217                                         $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00218                                         if (is_array($working_data))
00219                                         {
00220                                                 if (strcmp($working_data[0]["value"], "") != 0)
00221                                                 {
00222                                                         if ($working_data[0]["value"] == $i)
00223                                                         {
00224                                                                 $this->tpl->setVariable("CHECKED_ORDINAL", " checked=\"checked\"");
00225                                                         }
00226                                                 }
00227                                         }
00228                                         $this->tpl->parseCurrentBlock();
00229                                 }
00230                                 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) 
00231                                 {
00232                                         $category = $this->object->categories->getCategory($i);
00233                                         $this->tpl->setCurrentBlock("text_col_ordinal");
00234                                         $this->tpl->setVariable("VALUE_ORDINAL", $i);
00235                                         $this->tpl->setVariable("TEXT_ORDINAL", $category);
00236                                         $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00237                                         $this->tpl->parseCurrentBlock();
00238                                 }
00239                                 break;
00240                         case 2:
00241                                 // combobox output
00242                                 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) 
00243                                 {
00244                                         $category = $this->object->categories->getCategory($i);
00245                                         $this->tpl->setCurrentBlock("comborow");
00246                                         $this->tpl->setVariable("TEXT_ORDINAL", $category);
00247                                         $this->tpl->setVariable("VALUE_ORDINAL", $i);
00248                                         if (is_array($working_data))
00249                                         {
00250                                                 if (strcmp($working_data[0]["value"], "") != 0)
00251                                                 {
00252                                                         if ($working_data[0]["value"] == $i)
00253                                                         {
00254                                                                 $this->tpl->setVariable("SELECTED_ORDINAL", " selected=\"selected\"");
00255                                                         }
00256                                                 }
00257                                         }
00258                                         $this->tpl->parseCurrentBlock();
00259                                 }
00260                                 $this->tpl->setCurrentBlock("combooutput");
00261                                 $this->tpl->setVariable("QUESTION_ID", $this->object->getId());
00262                                 $this->tpl->setVariable("SELECT_OPTION", $this->lng->txt("select_option"));
00263                                 $this->tpl->setVariable("TEXT_SELECTION", $this->lng->txt("selection"));
00264                                 $this->tpl->parseCurrentBlock();
00265                                 break;
00266                 }
00267                 if ($question_title)
00268                 {
00269                         $this->tpl->setVariable("QUESTION_TITLE", $this->object->getTitle());
00270                 }
00271                 $this->tpl->setCurrentBlock("question_data_ordinal");
00272                 if (strcmp($error_message, "") != 0)
00273                 {
00274                         $this->tpl->setVariable("ERROR_MESSAGE", "<p class=\"warning\">$error_message</p>");
00275                 }
00276                 $questiontext = $this->object->getQuestiontext();
00277                 $this->tpl->setVariable("QUESTIONTEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00278                 if (! $this->object->getObligatory())
00279                 {
00280                         $this->tpl->setVariable("OBLIGATORY_TEXT", $this->lng->txt("survey_question_optional"));
00281                 }
00282                 $this->tpl->parseCurrentBlock();
00283         }
00284 
00292         function preview()
00293         {
00294                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_preview.html", true);
00295                 $this->tpl->addBlockFile("ORDINAL", "ordinal", "tpl.il_svy_out_ordinal.html", true);
00296                 $this->outWorkingForm();
00297                 $this->tpl->parseCurrentBlock();
00298         }
00299         
00308   function writePostData() 
00309         {
00310     $result = 0;
00311     if ((!$_POST["title"]) or (!$_POST["author"]) or (!$_POST["question"]))
00312       $result = 1;
00313 
00314     // Set the question id from a hidden form parameter
00315     if ($_POST["id"] > 0)
00316       $this->object->setId($_POST["id"]);
00317                 include_once "./classes/class.ilUtil.php";
00318     $this->object->setTitle(ilUtil::stripSlashes($_POST["title"]));
00319     $this->object->setAuthor(ilUtil::stripSlashes($_POST["author"]));
00320     $this->object->setDescription(ilUtil::stripSlashes($_POST["description"]));
00321                 $this->object->setOrientation($_POST["orientation"]);
00322                 if (strlen($_POST["material"]))
00323                 {
00324                         $this->object->setMaterial($_POST["material"], 0, ilUtil::stripSlashes($_POST["material_title"]));
00325                 }
00326                 include_once "./classes/class.ilObjAdvancedEditing.php";
00327                 $questiontext = ilUtil::stripSlashes($_POST["question"], true, ilObjAdvancedEditing::_getUsedHTMLTagsAsString("survey"));
00328                 $this->object->setQuestiontext($questiontext);
00329                 if ($_POST["obligatory"])
00330                 {
00331                         $this->object->setObligatory(1);
00332                 }
00333                 else
00334                 {
00335                         $this->object->setObligatory(0);
00336                 }
00337 
00338                 if ($saved) {
00339                         // If the question was saved automatically before an upload, we have to make
00340                         // sure, that the state after the upload is saved. Otherwise the user could be
00341                         // irritated, if he presses cancel, because he only has the question state before
00342                         // the upload process.
00343                         $this->object->saveToDb();
00344                 }
00345     return $result;
00346   }
00347 
00355         function categories($add = false)
00356         {
00357                 if ($this->object->getId() < 1) 
00358                 {
00359                         sendInfo($this->lng->txt("fill_out_all_required_fields_add_category"), true);
00360                         $this->ctrl->redirect($this, "editQuestion");
00361                 }
00362                 if (strcmp($this->ctrl->getCmd(), "categories") == 0) $_SESSION["spl_modified"] = false;
00363                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_ordinal_answers.html", true);
00364     // output of existing single response answers
00365                 for ($i = 0; $i < $this->object->categories->getCategoryCount(); $i++) 
00366                 {
00367                         $this->tpl->setCurrentBlock("cat_selector");
00368                         $this->tpl->setVariable("CATEGORY_ORDER", $i);
00369                         $this->tpl->parseCurrentBlock();
00370                         $this->tpl->setCurrentBlock("categories");
00371                         $category = $this->object->categories->getCategory($i);
00372                         $this->tpl->setVariable("CATEGORY_ORDER", $i);
00373                         $this->tpl->setVariable("CATEGORY_NUMBER", $i+1);
00374                         $this->tpl->setVariable("VALUE_CATEGORY", $category);
00375                         $this->tpl->setVariable("TEXT_CATEGORY", $this->lng->txt("category"));
00376                         $this->tpl->parseCurrentBlock();
00377                 }
00378                 
00379                 if ($add)
00380                 {
00381                         $nrOfCategories = $_POST["nrOfCategories"];
00382                         if ($nrOfCategories < 1) $nrOfCategories = 1;
00383                         // Create template for a new category
00384                         for ($i = 1; $i <= $nrOfCategories; $i++)
00385                         {
00386                                 $this->tpl->setCurrentBlock("categories");
00387                                 $this->tpl->setVariable("CATEGORY_ORDER", $this->object->categories->getCategoryCount() + $i - 1);
00388                                 $this->tpl->setVariable("TEXT_CATEGORY", $this->lng->txt("category"));
00389                                 $this->tpl->parseCurrentBlock();
00390                         }
00391                 }
00392 
00393                 if (is_array($_SESSION["spl_move"]))
00394                 {
00395                         if (count($_SESSION["spl_move"]))
00396                         {
00397                                 $this->tpl->setCurrentBlock("move_buttons");
00398                                 $this->tpl->setVariable("INSERT_BEFORE", $this->lng->txt("insert_before"));
00399                                 $this->tpl->setVariable("INSERT_AFTER", $this->lng->txt("insert_after"));
00400                                 $this->tpl->parseCurrentBlock();
00401                         }
00402                 }
00403                 
00404                 include_once "./classes/class.ilUtil.php";
00405                 if ($this->object->categories->getCategoryCount() == 0)
00406                 {
00407                         if (!$add)
00408                         {
00409                                 $this->tpl->setCurrentBlock("nocategories");
00410                                 $this->tpl->setVariable("NO_CATEGORIES", $this->lng->txt("question_contains_no_categories"));
00411                                 $this->tpl->parseCurrentBlock();
00412                         }
00413                 }
00414                 else
00415                 {
00416                         $this->tpl->setCurrentBlock("selectall");
00417                         $this->tpl->setVariable("SELECT_ALL", $this->lng->txt("select_all"));
00418                         $this->tpl->parseCurrentBlock();
00419                         $this->tpl->setCurrentBlock("existingcategories");
00420                         $this->tpl->setVariable("DELETE", $this->lng->txt("delete"));
00421                         $this->tpl->setVariable("MOVE", $this->lng->txt("move"));
00422                         $this->tpl->setVariable("VALUE_SAVE_PHRASE", $this->lng->txt("save_phrase"));
00423                         $this->tpl->setVariable("ARROW", "<img src=\"" . ilUtil::getImagePath("arrow_downright.gif") . "\" alt=\"".$this->lng->txt("arrow_downright")."\">");
00424                         $this->tpl->parseCurrentBlock();
00425                 }
00426                 
00427                 for ($i = 1; $i < 10; $i++)
00428                 {
00429                         $this->tpl->setCurrentBlock("numbers");
00430                         $this->tpl->setVariable("VALUE_NUMBER", $i);
00431                         if ($i == 1)
00432                         {
00433                                 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("category"));
00434                         }
00435                         else
00436                         {
00437                                 $this->tpl->setVariable("TEXT_NUMBER", $i . " " . $this->lng->txt("categories"));
00438                         }
00439                         $this->tpl->parseCurrentBlock();
00440                 }
00441                 
00442                 $this->tpl->setCurrentBlock("adm_content");
00443                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00444                 $this->tpl->setVariable("VALUE_ADD_CATEGORY", $this->lng->txt("add"));
00445                 $this->tpl->setVariable("VALUE_ADD_PHRASE", $this->lng->txt("add_phrase"));
00446                 $this->tpl->setVariable("SAVE", $this->lng->txt("save"));
00447                 if ($_SESSION["spl_modified"])
00448                 {
00449                         $this->tpl->setVariable("FORM_DATA_MODIFIED_PRESS_SAVE", $this->lng->txt("form_data_modified_press_save"));
00450                 }
00451                 $questiontext = $this->object->getQuestiontext();
00452                 $this->tpl->setVariable("QUESTION_TEXT", $this->object->prepareTextareaOutput($questiontext, TRUE));
00453                 $this->tpl->parseCurrentBlock();
00454         }
00455         
00456         function setQuestionTabs()
00457         {
00458                 $this->setQuestionTabsForClass("surveyordinalquestiongui");
00459         }
00460 
00468   function addPhrase() 
00469         {
00470                 $this->writeCategoryData(true);
00471                 $this->ctrl->setParameterByClass(get_class($this), "q_id", $this->object->getId());
00472                 $this->ctrl->setParameterByClass("ilobjsurveyquestionpoolgui", "q_id", $this->object->getId());
00473 
00474                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_addphrase.html", true);
00475 
00476                 // set the id to return to the selected question
00477                 $this->tpl->setCurrentBlock("hidden");
00478                 $this->tpl->setVariable("HIDDEN_NAME", "id");
00479                 $this->tpl->setVariable("HIDDEN_VALUE", $this->object->getId());
00480                 $this->tpl->parseCurrentBlock();
00481 
00482                 $phrases =& $this->object->getAvailablePhrases();
00483                 $colors = array("tblrow1", "tblrow2");
00484                 $counter = 0;
00485                 foreach ($phrases as $phrase_id => $phrase_array)
00486                 {
00487                         $this->tpl->setCurrentBlock("phraserow");
00488                         $this->tpl->setVariable("COLOR_CLASS", $colors[$counter++ % 2]);
00489                         $this->tpl->setVariable("PHRASE_VALUE", $phrase_id);
00490                         $this->tpl->setVariable("PHRASE_NAME", $phrase_array["title"]);
00491                         $categories =& $this->object->getCategoriesForPhrase($phrase_id);
00492                         $this->tpl->setVariable("PHRASE_CONTENT", join($categories, ","));
00493                         $this->tpl->parseCurrentBlock();
00494                 }
00495                 
00496                 $this->tpl->setCurrentBlock("adm_content");
00497                 $this->tpl->setVariable("TEXT_CANCEL", $this->lng->txt("cancel"));
00498                 $this->tpl->setVariable("TEXT_PHRASE", $this->lng->txt("phrase"));
00499                 $this->tpl->setVariable("TEXT_CONTENT", $this->lng->txt("categories"));
00500                 $this->tpl->setVariable("TEXT_ADD_PHRASE", $this->lng->txt("add_phrase"));
00501                 $this->tpl->setVariable("TEXT_INTRODUCTION",$this->lng->txt("add_phrase_introduction"));
00502                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00503                 $this->tpl->parseCurrentBlock();
00504         }
00505 
00513         function cancelViewPhrase() 
00514         {
00515                 $this->ctrl->redirect($this, "categories");
00516         }
00517 
00525         function addSelectedPhrase() 
00526         {
00527                 if (strcmp($_POST["phrases"], "") == 0)
00528                 {
00529                         sendInfo($this->lng->txt("select_phrase_to_add"));
00530                         $this->addPhrase();
00531                 }
00532                 else
00533                 {
00534                         if (strcmp($this->object->getPhrase($_POST["phrases"]), "dp_standard_numbers") != 0)
00535                         {
00536                                 $this->object->addPhrase($_POST["phrases"]);
00537                                 $this->object->saveCategoriesToDb();
00538                         }
00539                         else
00540                         {
00541                                 $this->addStandardNumbers();
00542                                 return;
00543                         }
00544                         $this->ctrl->redirect($this, "categories");
00545                 }
00546         }
00547         
00555   function addStandardNumbers() 
00556         {
00557                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_addphrase_standard_numbers.html", true);
00558 
00559                 // set the id to return to the selected question
00560                 $this->tpl->setCurrentBlock("hidden");
00561                 $this->tpl->setVariable("HIDDEN_NAME", "id");
00562                 $this->tpl->setVariable("HIDDEN_VALUE", $this->object->getId());
00563                 $this->tpl->parseCurrentBlock();
00564 
00565                 $this->tpl->setCurrentBlock("adm_content");
00566                 $this->tpl->setVariable("ADD_STANDARD_NUMBERS", $this->lng->txt("add_standard_numbers"));
00567                 $this->tpl->setVariable("TEXT_ADD_LIMITS", $this->lng->txt("add_limits_for_standard_numbers"));
00568                 $this->tpl->setVariable("TEXT_LOWER_LIMIT",$this->lng->txt("lower_limit"));
00569                 $this->tpl->setVariable("TEXT_UPPER_LIMIT",$this->lng->txt("upper_limit"));
00570                 $this->tpl->setVariable("VALUE_LOWER_LIMIT", $_POST["lower_limit"]);
00571                 $this->tpl->setVariable("VALUE_UPPER_LIMIT", $_POST["upper_limit"]);
00572                 $this->tpl->setVariable("BTN_ADD",$this->lng->txt("add_phrase"));
00573                 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
00574                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00575                 $this->tpl->parseCurrentBlock();
00576         }
00577         
00585         function cancelStandardNumbers() 
00586         {
00587                 $this->ctrl->redirect($this, "categories");
00588         }
00589 
00597         function insertStandardNumbers() 
00598         {
00599                 if ((strcmp($_POST["lower_limit"], "") == 0) or (strcmp($_POST["upper_limit"], "") == 0))
00600                 {
00601                         sendInfo($this->lng->txt("missing_upper_or_lower_limit"));
00602                         $this->addStandardNumbers();
00603                 }
00604                 else if ((int)$_POST["upper_limit"] <= (int)$_POST["lower_limit"])
00605                 {
00606                         sendInfo($this->lng->txt("upper_limit_must_be_greater"));
00607                         $this->addStandardNumbers();
00608                 }
00609                 else
00610                 {
00611                         $this->object->addStandardNumbers($_POST["lower_limit"], $_POST["upper_limit"]);
00612                         $this->object->saveCategoriesToDb();
00613                         $this->ctrl->redirect($this, "categories");
00614                 }
00615         }
00616 
00624   function savePhrase() 
00625         {
00626                 $this->writeCategoryData(true);
00627                 $nothing_selected = true;
00628                 if (array_key_exists("chb_category", $_POST))
00629                 {
00630                         if (count($_POST["chb_category"]))
00631                         {
00632                                 $nothing_selected = false;
00633                                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_qpl_savephrase.html", true);
00634                                 $rowclass = array("tblrow1", "tblrow2");
00635                                 $counter = 0;
00636                                 foreach ($_POST["chb_category"] as $category)
00637                                 {
00638                                         $this->tpl->setCurrentBlock("row");
00639                                         $this->tpl->setVariable("TXT_TITLE", $this->object->categories->getCategory($category));
00640                                         $this->tpl->setVariable("COLOR_CLASS", $rowclass[$counter % 2]);
00641                                         $this->tpl->parseCurrentBlock();
00642                                         $this->tpl->setCurrentBlock("hidden");
00643                                         $this->tpl->setVariable("HIDDEN_NAME", "chb_category[]");
00644                                         $this->tpl->setVariable("HIDDEN_VALUE", $category);
00645                                         $this->tpl->parseCurrentBlock();
00646                                 }
00647                         
00648                                 $this->tpl->setCurrentBlock("adm_content");
00649                                 $this->tpl->setVariable("SAVE_PHRASE_INTRODUCTION", $this->lng->txt("save_phrase_introduction"));
00650                                 $this->tpl->setVariable("TEXT_PHRASE_TITLE", $this->lng->txt("enter_phrase_title"));
00651                                 $this->tpl->setVariable("TXT_TITLE", $this->lng->txt("category"));
00652                                 $this->tpl->setVariable("VALUE_PHRASE_TITLE", $_POST["phrase_title"]);
00653                                 $this->tpl->setVariable("BTN_CANCEL",$this->lng->txt("cancel"));
00654                                 $this->tpl->setVariable("BTN_CONFIRM",$this->lng->txt("confirm"));
00655                                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00656                                 $this->tpl->parseCurrentBlock();
00657                         }
00658                 }
00659                 if ($nothing_selected)
00660                 {
00661                         sendInfo($this->lng->txt("check_category_to_save_phrase"), true);
00662                         $this->ctrl->redirect($this, "categories");
00663                 }
00664         }
00665 
00673         function cancelSavePhrase() 
00674         {
00675                 $this->ctrl->redirect($this, "categories");
00676         }
00677 
00685         function confirmSavePhrase() 
00686         {
00687                 if (!$_POST["phrase_title"])
00688                 {
00689                         sendInfo($this->lng->txt("qpl_savephrase_empty"));
00690                         $this->savePhrase();
00691                         return;
00692                 }
00693                 
00694                 if ($this->object->phraseExists($_POST["phrase_title"]))
00695                 {
00696                         sendInfo($this->lng->txt("qpl_savephrase_exists"));
00697                         $this->savePhrase();
00698                         return;
00699                 }
00700 
00701                 $this->object->savePhrase($_POST["chb_category"], $_POST["phrase_title"]);
00702                 sendInfo($this->lng->txt("phrase_saved"), true);
00703                 $this->ctrl->redirect($this, "categories");
00704         }
00705 
00706         function outCumulatedResultsDetails(&$cumulated_results, $counter)
00707         {
00708                 $this->tpl->setCurrentBlock("detail_row");
00709                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("question"));
00710                 $questiontext = $this->object->getQuestiontext();
00711                 $this->tpl->setVariable("TEXT_OPTION_VALUE", $this->object->prepareTextareaOutput($questiontext, TRUE));
00712                 $this->tpl->parseCurrentBlock();
00713                 $this->tpl->setCurrentBlock("detail_row");
00714                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("question_type"));
00715                 $this->tpl->setVariable("TEXT_OPTION_VALUE", $this->lng->txt($this->getQuestionType()));
00716                 $this->tpl->parseCurrentBlock();
00717                 $this->tpl->setCurrentBlock("detail_row");
00718                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("users_answered"));
00719                 $this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["USERS_ANSWERED"]);
00720                 $this->tpl->parseCurrentBlock();
00721                 $this->tpl->setCurrentBlock("detail_row");
00722                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("users_skipped"));
00723                 $this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["USERS_SKIPPED"]);
00724                 $this->tpl->parseCurrentBlock();
00725                 
00726                 $this->tpl->setCurrentBlock("detail_row");
00727                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("mode"));
00728                 $this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["MODE"]);
00729                 $this->tpl->parseCurrentBlock();
00730                 $this->tpl->setCurrentBlock("detail_row");
00731                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("mode_nr_of_selections"));
00732                 $this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["MODE_NR_OF_SELECTIONS"]);
00733                 $this->tpl->parseCurrentBlock();
00734                 $this->tpl->setCurrentBlock("detail_row");
00735                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("median"));
00736                 $this->tpl->setVariable("TEXT_OPTION_VALUE", $cumulated_results["MEDIAN"]);
00737                 $this->tpl->parseCurrentBlock();
00738                 
00739                 $this->tpl->setCurrentBlock("detail_row");
00740                 $this->tpl->setVariable("TEXT_OPTION", $this->lng->txt("categories"));
00741                 $categories = "";
00742                 foreach ($cumulated_results["variables"] as $key => $value)
00743                 {
00744                         $categories .= "<li>" . $this->lng->txt("title") . ":" . "<span class=\"bold\">" . $value["title"] . "</span><br />" .
00745                                 $this->lng->txt("category_nr_selected") . ": " . "<span class=\"bold\">" . $value["selected"] . "</span><br />" .
00746                                 $this->lng->txt("percentage_of_selections") . ": " . "<span class=\"bold\">" . sprintf("%.2f", 100*$value["percentage"]) . "</span></li>";
00747                 }
00748                 $categories = "<ol>$categories</ol>";
00749                 $this->tpl->setVariable("TEXT_OPTION_VALUE", $categories);
00750                 $this->tpl->parseCurrentBlock();
00751                 
00752                 // display chart for ordinal question for array $eval["variables"]
00753                 $this->tpl->setVariable("TEXT_CHART", $this->lng->txt("chart"));
00754                 $this->tpl->setVariable("ALT_CHART", $data["title"] . "( " . $this->lng->txt("chart") . ")");
00755                 $this->tpl->setVariable("CHART","./survey/displaychart.php?grName=" . urlencode($this->object->getTitle()) . 
00756                         "&type=bars" . 
00757                         "&x=" . urlencode($this->lng->txt("answers")) . 
00758                         "&y=" . urlencode($this->lng->txt("users_answered")) . 
00759                         "&arr=".base64_encode(serialize($cumulated_results["variables"])));
00760                 
00761                 $this->tpl->setCurrentBlock("detail");
00762                 $this->tpl->setVariable("QUESTION_TITLE", "$counter. ".$this->object->getTitle());
00763                 $this->tpl->parseCurrentBlock();
00764         }
00765 }
00766 ?>

Generated on Fri Dec 13 2013 13:52:15 for ILIAS Release_3_7_x_branch .rev 46817 by  doxygen 1.7.1