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

survey/classes/class.ilSurveyExecutionGUI.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/inc.SurveyConstants.php";
00025 
00038 class ilSurveyExecutionGUI
00039 {
00040         var $object;
00041         var $lng;
00042         var $tpl;
00043         var $ctrl;
00044         var $ilias;
00045         var $tree;
00046         
00055   function ilSurveyExecutionGUI($a_object)
00056   {
00057                 global $lng, $tpl, $ilCtrl, $ilias, $tree;
00058 
00059     $this->lng =& $lng;
00060     $this->tpl =& $tpl;
00061                 $this->ctrl =& $ilCtrl;
00062                 $this->ilias =& $ilias;
00063                 $this->object =& $a_object;
00064                 $this->tree =& $tree;
00065         }
00066         
00070         function &executeCommand()
00071         {
00072                 $cmd = $this->ctrl->getCmd();
00073                 $next_class = $this->ctrl->getNextClass($this);
00074 
00075                 $cmd = $this->getCommand($cmd);
00076                 switch($next_class)
00077                 {
00078                         default:
00079                                 $ret =& $this->$cmd();
00080                                 break;
00081                 }
00082                 return $ret;
00083         }
00084 
00092         function getCommand($cmd)
00093         {
00094                 return $cmd;
00095         }
00096 
00104         function resume()
00105         {
00106                 $this->start(true);
00107         }
00108         
00116         function start($resume = false)
00117         {
00118                 global $ilUser;
00119                 global $rbacsystem;
00120 
00121                 unset($_SESSION["svy_errors"]);
00122                 if (!$rbacsystem->checkAccess("read", $this->object->ref_id)) 
00123                 {
00124                         // only with read access it is possible to run the test
00125                         $this->ilias->raiseError($this->lng->txt("cannot_read_survey"),$this->ilias->error_obj->MESSAGE);
00126                 }
00127 
00128                 if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
00129                 {
00130                         if ($resume)
00131                         {
00132                                 $anonymize_key = $this->object->getAnonymousId($_POST["anonymous_id"]);
00133                                 if ($anonymize_key)
00134                                 {
00135                                         $_SESSION["anonymous_id"] = $anonymize_key;
00136                                 }
00137                                 else
00138                                 {
00139                                         unset($_POST["cmd"]["resume"]);
00140                                         sendInfo(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $_POST["anonymous_id"]));
00141                                 }
00142                                 if (strlen($_SESSION["anonymous_id"]) == 0)
00143                                 {
00144                                         sendInfo(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), ""), true);
00145                                         $this->ctrl->redirect($this, "run");
00146                                 }
00147                         }
00148                 }
00149                 
00150                 $direction = 0;
00151 
00152                 if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
00153                 {
00154                         if ($this->object->checkSurveyCode($_POST["anonymous_id"]))
00155                         {
00156                                 $_SESSION["anonymous_id"] = $_POST["anonymous_id"];
00157                         }
00158                         else
00159                         {
00160                                 sendInfo(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), $_POST["anonymous_id"]), true);
00161                                 $this->ctrl->redirect($this, "run");
00162                         }
00163                         if (strlen($_SESSION["anonymous_id"]) == 0)
00164                         {
00165                                 sendInfo(sprintf($this->lng->txt("error_retrieving_anonymous_survey"), ""), true);
00166                                 $this->ctrl->redirect($this, "run");
00167                         }
00168                 }
00169                 if ($this->object->isAccessibleWithoutCode())
00170                 {
00171                         $_SESSION["anonymous_id"] = $this->object->getRandomSurveyCode();
00172                 }
00173                 
00174                 $activepage = "";
00175                 if ($resume)
00176                 {
00177                         $activepage = $this->object->getLastActivePage($ilUser->id);
00178                         $direction = 0;
00179                 }
00180                 // explicitly set the survey started!
00181                 if ($this->object->isSurveyStarted($ilUser->getId(), $_SESSION["anonymous_id"]) === FALSE)
00182                 {
00183                         $this->object->startSurvey($ilUser->getId(), $_SESSION["anonymous_id"]);
00184                 }
00185                 $this->outSurveyPage($activepage, $direction);
00186         }
00187 
00195         function previous()
00196         {
00197                 $this->navigate("previous");
00198         }
00199         
00207         function next()
00208         {
00209                 $this->navigate("next");
00210         }
00211         
00219         function outSurveyPage($activepage, $direction)
00220         {
00221                 global $ilUser;
00222                 
00223                 // security check if someone tries to go into a survey using an URL to one of the questions
00224                 $canStart = $this->object->canStartSurvey();
00225                 if (!$canStart["result"])
00226                 {
00227                         sendInfo(implode("<br />", $canStart["messages"]), TRUE);
00228                         $this->ctrl->redirectByClass("ilobjsurveygui", "run");
00229                 }
00230                 $survey_started = $this->object->isSurveyStarted($ilUser->getId(), $_SESSION["anonymous_id"]);
00231                 if ($survey_started === FALSE)
00232                 {
00233                         sendInfo($this->lng->txt("survey_use_start_button"), TRUE);
00234                         $this->ctrl->redirectByClass("ilobjsurveygui", "run");
00235                 }
00236 
00237                 $page = $this->object->getNextPage($activepage, $direction);
00238                 $constraint_true = 0;
00239 
00240                 // check for constraints
00241                 if (count($page[0]["constraints"]))
00242                 {
00243                         while (is_array($page) and ($constraint_true == 0) and (count($page[0]["constraints"])))
00244                         {
00245                                 $constraint_true = 1;
00246                                 foreach ($page[0]["constraints"] as $constraint)
00247                                 {
00248                                         $working_data = $this->object->loadWorkingData($constraint["question"], $ilUser->id);
00249                                         $constraint_true = $constraint_true & $this->object->checkConstraint($constraint, $working_data);
00250                                 }
00251                                 if ($constraint_true == 0)
00252                                 {
00253                                         $page = $this->object->getNextPage($page[0]["question_id"], $direction);
00254                                 }
00255                         }
00256                 }
00257 
00258                 $qid = "";
00259                 if ($page === 0)
00260                 {
00261                         $this->runShowIntroductionPage();
00262                         return;
00263                 }
00264                 else if ($page === 1)
00265                 {
00266                         $this->object->finishSurvey($ilUser->id, $_SESSION["anonymous_id"]);
00267                         $this->runShowFinishedPage();
00268                         return;
00269                 }
00270                 else
00271                 {
00272                         $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_content.html", true);
00273                         $this->outNavigationButtons("top", $page);
00274                         $this->tpl->addBlockFile("NOMINAL_QUESTION", "nominal_question", "tpl.il_svy_out_nominal.html", true);
00275                         $this->tpl->addBlockFile("ORDINAL_QUESTION", "ordinal_question", "tpl.il_svy_out_ordinal.html", true);
00276                         $this->tpl->addBlockFile("METRIC_QUESTION", "metric_question", "tpl.il_svy_out_metric.html", true);
00277                         $this->tpl->addBlockFile("TEXT_QUESTION", "text_question", "tpl.il_svy_out_text.html", true);
00278                         $this->tpl->setCurrentBlock("percentage");
00279                         $this->tpl->setVariable("PERCENTAGE", (int)(($page[0]["position"])*200));
00280                         $this->tpl->setVariable("PERCENTAGE_VALUE", (int)(($page[0]["position"])*100));
00281                         $this->tpl->setVariable("HUNDRED_PERCENT", "200");
00282                         $this->tpl->setVariable("TEXT_COMPLETED", $this->lng->txt("completed") . ": ");
00283                         $this->tpl->parseCurrentBlock();
00284                         if (count($page) > 1)
00285                         {
00286                                 $this->tpl->setCurrentBlock("questionblock_title");
00287                                 $this->tpl->setVariable("TEXT_QUESTIONBLOCK_TITLE", $page[0]["questionblock_title"]);
00288                                 $this->tpl->parseCurrentBlock();
00289                         }
00290                         foreach ($page as $data)
00291                         {
00292                                 $this->tpl->setCurrentBlock("survey_content");
00293                                 if ($data["heading"])
00294                                 {
00295                                         $this->tpl->setVariable("QUESTION_HEADING", $data["heading"]);
00296                                 }
00297                                 $question_gui = $this->object->getQuestionGUI($data["type_tag"], $data["question_id"]);
00298                                 $working_data = $this->object->loadWorkingData($data["question_id"], $ilUser->id);
00299                                 $question_gui->object->setObligatory($data["obligatory"]);
00300                                 $error_messages = array();
00301                                 if (is_array($_SESSION["svy_errors"]))
00302                                 {
00303                                         $error_messages = $_SESSION["svy_errors"];
00304                                 }
00305                                 $question_gui->outWorkingForm($working_data, $this->object->getShowQuestionTitles(), $error_messages[$data["question_id"]]);
00306                                 $qid = "&qid=" . $data["question_id"];
00307                                 $this->tpl->parse("survey_content");
00308                         }
00309                         $this->outNavigationButtons("bottom", $page);
00310                         $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this) . $qid);
00311                 }
00312         }
00313         
00321         function navigate($navigationDirection = "next") 
00322         {
00323                 global $ilUser;
00324                 global $rbacsystem;
00325                 unset($_SESSION["svy_errors"]);
00326                 if (!$rbacsystem->checkAccess("read", $this->object->ref_id)) 
00327                 {
00328                         // only with read access it is possible to run the test
00329                         $this->ilias->raiseError($this->lng->txt("cannot_read_survey"),$this->ilias->error_obj->MESSAGE);
00330                 }
00331 
00332                 // check users input when it is a metric question
00333                 $page_error = 0;
00334                 $page = $this->object->getNextPage($_GET["qid"], 0);
00335                 foreach ($page as $data)
00336                 {
00337                         $page_error += $this->saveActiveQuestionData($data);
00338                 }
00339 
00340                 if ($page_error)
00341                 {
00342                         if ($page_error == 1)
00343                         {
00344                                 sendInfo($this->lng->txt("svy_page_error"));
00345                         }
00346                         else
00347                         {
00348                                 sendInfo($this->lng->txt("svy_page_errors"));
00349                         }
00350                 }
00351 
00352                 $direction = 0;
00353                 switch ($navigationDirection)
00354                 {
00355                         case "next":
00356                         default:
00357                                 $activepage = $_GET["qid"];
00358                                 if (!$page_error)
00359                                 {
00360                                         $direction = 1;
00361                                 }
00362                                 break;
00363                         case "previous":
00364                                 $activepage = $_GET["qid"];
00365                                 if (!$page_error)
00366                                 {
00367                                         $direction = -1;
00368                                 }
00369                                 break;
00370                 }
00371                 $this->outSurveyPage($activepage, $direction);
00372         }
00373 
00381         function saveActiveQuestionData(&$data)
00382         {
00383                 global $ilUser;
00384                 $page_error = 0;
00385                 $save_answer = 0;
00386                 $error = 0;
00387                 $error_messages = array();
00388                 if (is_array($_SESSION["svy_errors"])) $error_messages = $_SESSION["svy_errors"];
00389                 
00390                 if (strcmp($data["type_tag"], "qt_metric") == 0)
00391                 {
00392                         // there is a metric question -> check input
00393                         $variables =& $this->object->getVariables($data["question_id"]);
00394                         $entered_value = $_POST[$data["question_id"] . "_metric_question"];
00395                         // replace german notation with international notation
00396                         $entered_value = str_replace(",", ".", $entered_value);
00397                         $_POST[$data["question_id"] . "_metric_question"] = $entered_value;
00398                         if (strlen($entered_value) != 0)
00399                         { 
00400                                 if (($variables[0]->value2 < $variables[0]->value1) && ($variables[0]->value2 == -1))
00401                                 {
00402                                         // old &infty; value was written as -1
00403                                         $variables[0]->value2 = "";
00404                                 }
00405                                 if (($data["subtype"] > 3) && ($variables[0]->value1 < 0)) $variables[0]->value1 = 0;
00406                                 if (strlen($variables[0]->value1))
00407                                 {
00408                                         if ($entered_value < $variables[0]->value1)
00409                                         {
00410                                                 $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_out_of_bounds");
00411                                                 $error = 1;
00412                                         }
00413                                 }
00414                                 if (strlen($variables[0]->value2))
00415                                 {
00416                                         if ($entered_value > $variables[0]->value2)
00417                                         {
00418                                                 $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_out_of_bounds");
00419                                                 $error = 1;
00420                                         }
00421                                 }
00422 
00423                                 if (!is_numeric($entered_value))
00424                                 {
00425                                         $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_not_a_value");
00426                                         $error = 1;
00427                                 }
00428                                 if (strcmp($entered_value, "") == 0)
00429                                 {
00430                                         // there is an error: value is not in bounds
00431                                         $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_out_of_bounds");
00432                                         $error = 1;
00433                                 }
00434 
00435                                 include_once "./survey/classes/class.SurveyMetricQuestion.php";
00436                                 if (($data["subtype"] == SUBTYPE_RATIO_ABSOLUTE) && (intval($entered_value) != doubleval($entered_value)))
00437                                 {
00438                                         $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_floating_point");
00439                                         $error = 1;
00440                                 }
00441                                 if (($error == 0) && (strcmp($entered_value, "") != 0))
00442                                 {
00443                                         $save_answer = 1;
00444                                 }
00445                         }
00446                         else if ($data["obligatory"] && (strlen($entered_value) == 0))
00447                         {
00448                                 $error_messages[$data["question_id"]] = $this->lng->txt("metric_question_not_a_value");
00449                                 $error = 1;
00450                         }
00451                 }
00452                 if (strcmp($data["type_tag"], "qt_nominal") == 0)
00453                 {
00454                         $variables =& $this->object->getVariables($data["question_id"]);
00455                         include_once "./survey/classes/class.SurveyNominalQuestion.php";
00456                         $save_answer = 1;
00457                         $entered_value = $_POST[$data["question_id"] . "_value"];
00458                         if ($data["subtype"] == SUBTYPE_MCSR)
00459                         {
00460                                 if ($data["obligatory"])
00461                                 {
00462                                         if (strcmp($entered_value, "") == 0)
00463                                         {
00464                                                 $error_messages[$data["question_id"]] = $this->lng->txt("nominal_question_not_checked");
00465                                                 $error = 1;
00466                                                 $save_answer = 0;
00467                                         }
00468                                 }
00469                         }
00470                         else
00471                         {
00472                                 if ($data["obligatory"])
00473                                 {
00474                                         if (!is_array($entered_value))
00475                                         {
00476                                                 $error_messages[$data["question_id"]] = $this->lng->txt("nominal_question_mr_not_checked");
00477                                                 $error = 1;
00478                                                 $save_answer = 0;
00479                                         }
00480                                 }
00481                         }
00482                 }
00483                 if (strcmp($data["type_tag"], "qt_ordinal") == 0)
00484                 {
00485                         $variables =& $this->object->getVariables($data["question_id"]);
00486                         if ((strcmp($_POST[$data["question_id"] . "_value"], "") == 0) && ($data["obligatory"]))
00487                         {
00488                                 // none of the radio buttons was checked
00489                                 $error_messages[$data["question_id"]] = $this->lng->txt("ordinal_question_not_checked");
00490                                 $error = 1;
00491                         }
00492                         if ((strcmp($_POST[$data["question_id"] . "_value"], "") == 0) && !$error)
00493                         {
00494                                 $save_answer = 0;
00495                         }
00496                         else
00497                         {
00498                                 $save_answer = 1;
00499                         }
00500                 }
00501                 if (strcmp($data["type_tag"], "qt_text") == 0)
00502                 {
00503                         $variables =& $this->object->getVariables($data["question_id"]);
00504                         if ((strcmp($_POST[$data["question_id"] . "_text_question"], "") == 0) && ($data["obligatory"]))
00505                         {
00506                                 // none of the radio buttons was checked
00507                                 $error_messages[$data["question_id"]] = $this->lng->txt("text_question_not_filled_out");
00508                                 $error = 1;
00509                         }
00510                         if ((strcmp($_POST[$data["question_id"] . "_text_question"], "") == 0) && (!$data["obligatory"]))
00511                         {
00512                                 $save_answer = 0;
00513                         }
00514                         else
00515                         {
00516                                 $save_answer = 1;
00517                                 include_once "./survey/classes/class.SurveyTextQuestion.php";
00518                                 $maxchars = SurveyTextQuestion::_getMaxChars($data["question_id"]);
00519                                 if ($maxchars)
00520                                 {
00521                                         $_POST[$data["question_id"] . "_text_question"] = substr($_POST[$data["question_id"] . "_text_question"], 0, $maxchars);
00522                                 }
00523                         }
00524                 }
00525 
00526                 $page_error += $error;
00527                 if ((!$error) && ($save_answer))
00528                 {
00529                         // save user input
00530                         $this->object->deleteWorkingData($data["question_id"], $ilUser->id);
00531                         switch ($data["type_tag"])
00532                         {
00533                                 case "qt_nominal":
00534                                         include_once "./survey/classes/class.SurveyNominalQuestion.php";
00535                                         if ($data["subtype"] == SUBTYPE_MCSR)
00536                                         {
00537                                                 $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], $_POST[$data["question_id"] . "_value"]);
00538                                         }
00539                                         else
00540                                         {
00541                                                 if (is_array($_POST[$data["question_id"] . "_value"]))
00542                                                 {
00543                                                         foreach ($_POST[$data["question_id"] . "_value"] as $value)
00544                                                         {
00545                                                                 $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], $value);
00546                                                         }
00547                                                 }
00548                                                 else
00549                                                 {
00550                                                         $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"]);
00551                                                 }
00552                                         }
00553                                         break;
00554                                 case "qt_ordinal":
00555                                         $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], $_POST[$data["question_id"] . "_value"]);
00556                                         break;
00557                                 case "qt_metric":
00558                                         $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], $_POST[$data["question_id"] . "_metric_question"]);
00559                                         break;
00560                                 case "qt_text":
00561                                         include_once("./classes/class.ilUtil.php");
00562                                         $this->object->saveWorkingData($data["question_id"], $ilUser->id, $_SESSION["anonymous_id"], 0, ilUtil::stripSlashes($_POST[$data["question_id"] . "_text_question"]));
00563                                         break;
00564                         }
00565                 }
00566                 else
00567                 {
00568                         $_SESSION["svy_errors"] = $error_messages;
00569                 }
00570                 return $page_error;
00571         }
00572         
00580         function run() {
00581                 global $ilUser;
00582                 global $rbacsystem;
00583 
00584                 if (!$rbacsystem->checkAccess("read", $this->object->ref_id)) 
00585                 {
00586                         // only with read access it is possible to run the test
00587                         $this->ilias->raiseError($this->lng->txt("cannot_read_survey"),$this->ilias->error_obj->MESSAGE);
00588                 }
00589 
00590                 $this->runShowIntroductionPage();
00591         }
00592 
00600         function cancel()
00601         {
00602                 $this->ctrl->redirectByClass("ilobjsurveygui", "backToRepository");
00603         }
00604         
00612         function runShowIntroductionPage()
00613         {
00614                 global $ilUser;
00615                 global $rbacsystem;
00616                 
00617                 if (($this->object->getAnonymize()) && (strcmp($ilUser->login, "anonymous") == 0))
00618                 {
00619                         $survey_started = false;
00620                 }
00621                 else
00622                 {
00623                         $survey_started = $this->object->isSurveyStarted($ilUser->id, $this->object->getUserSurveyCode());
00624                 }
00625                 // show introduction page
00626                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_introduction.html", true);
00627                 if ((strcmp($ilUser->login, "anonymous") == 0) && (!$this->object->getAnonymize()))
00628                 {
00629                         $this->tpl->setCurrentBlock("back");
00630                         $this->tpl->setVariable("BTN_BACK", $this->lng->txt("back"));
00631                         $this->tpl->parseCurrentBlock();
00632                         $this->tpl->setCurrentBlock("adm_content");
00633                         $this->tpl->setVariable("TEXT_INTRODUCTION", $this->lng->txt("anonymous_with_personalized_survey"));
00634                         $this->tpl->parseCurrentBlock();
00635                         return;
00636                 }
00637                 if ($this->object->getAnonymize() && !$this->object->isAccessibleWithoutCode())
00638                 {
00639                         $this->tpl->setCurrentBlock("start");
00640                         $anonymize_key = $this->object->getUserSurveyCode();
00641                         if (strcmp($ilUser->login, "anonymous") == 0)
00642                         {
00643                                 $this->tpl->setVariable("TEXT_ANONYMIZE", $this->lng->txt("anonymize_anonymous_introduction"));
00644                         }
00645                         else
00646                         if ($survey_started === 0)
00647                         {
00648                                 $this->tpl->setVariable("TEXT_ANONYMIZE", $this->lng->txt("anonymize_resume_introduction"));
00649                         }
00650                         elseif ($survey_started === false)
00651                         {
00652                                 $this->tpl->setVariable("TEXT_ANONYMIZE", sprintf($this->lng->txt("anonymize_key_introduction"), $anonymize_key));
00653                         }
00654                         $this->tpl->setVariable("ENTER_ANONYMOUS_ID", $this->lng->txt("enter_anonymous_id"));
00655                         if (strlen($_SESSION["accesscode"]))
00656                         {
00657                                 $this->tpl->setVariable("ANONYMOUS_ID_VALUE", $_SESSION["accesscode"]);
00658                                 unset($_SESSION["accesscode"]);
00659                         }
00660                         if ($_SESSION["AccountId"] != ANONYMOUS_USER_ID)
00661                         {
00662                                 $this->tpl->setVariable("ANONYMOUS_ID_VALUE", $anonymize_key);
00663                         }
00664                         $this->tpl->parseCurrentBlock();
00665                 }
00666                 $this->tpl->setCurrentBlock("start");
00667                 $canStart = $this->object->canStartSurvey();
00668                 if ($survey_started === 1)
00669                 {
00670                         sendInfo($this->lng->txt("already_completed_survey"));
00671                         $this->tpl->setCurrentBlock("start");
00672                         $this->tpl->setVariable("BTN_START", $this->lng->txt("start_survey"));
00673                         $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00674                         $this->tpl->parseCurrentBlock();
00675                 }
00676                 if ($survey_started === 0)
00677                 {
00678                         $this->tpl->setCurrentBlock("resume");
00679                         $this->tpl->setVariable("BTN_RESUME", $this->lng->txt("resume_survey"));
00680                         if (!$canStart["result"])
00681                         {
00682                                 sendInfo($canStart["message"]);
00683                                 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00684                         }
00685                         $this->tpl->parseCurrentBlock();
00686                 }
00687                 if ($survey_started === false)
00688                 {
00689                         $this->tpl->setCurrentBlock("start");
00690                         $this->tpl->setVariable("BTN_START", $this->lng->txt("start_survey"));
00691                         if (!$rbacsystem->checkAccess('participate', $this->object->getRefId()))
00692                         {
00693                                 sendInfo($this->lng->txt("cannot_participate_survey"));
00694                                 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00695                         }
00696                         if (!$canStart["result"])
00697                         {
00698                                 sendInfo($canStart["message"]);
00699                                 $this->tpl->setVariable("DISABLED", " disabled=\"disabled\"");
00700                         }
00701                         $this->tpl->parseCurrentBlock();
00702                 }
00703                 $this->tpl->parseCurrentBlock();
00704                 $this->tpl->setCurrentBlock("adm_content");
00705                 $introduction = $this->object->getIntroduction();
00706                 $introduction = preg_replace("/\n/i", "<br />", $introduction);
00707                 $this->tpl->setVariable("TEXT_INTRODUCTION", $introduction);
00708                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00709                 $this->tpl->parseCurrentBlock();
00710         }
00711 
00719         function runShowFinishedPage()
00720         {
00721                 // show introduction page
00722                 unset($_SESSION["anonymous_id"]);
00723                 $this->tpl->addBlockFile("ADM_CONTENT", "adm_content", "tpl.il_svy_svy_finished.html", true);
00724                 $this->tpl->setVariable("TEXT_FINISHED", $this->lng->txt("survey_finished"));
00725                 $this->tpl->setVariable("BTN_EXIT", $this->lng->txt("exit"));
00726                 $this->tpl->setVariable("FORM_ACTION", $this->ctrl->getFormAction($this));
00727                 $this->tpl->parseCurrentBlock();
00728         }
00729 
00737         function exitSurvey()
00738         {
00739                 $this->ctrl->redirectByClass("ilobjsurveygui", "backToRepository");
00740         }
00741         
00751         function outNavigationButtons($navigationblock = "top", $page)
00752         {
00753                 $prevpage = $this->object->getNextPage($page[0]["question_id"], -1);
00754                 $this->tpl->setCurrentBlock($navigationblock . "_prev");
00755                 if ($prevpage === 0)
00756                 {
00757                         $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_start"));
00758                 }
00759                 else
00760                 {
00761                         $this->tpl->setVariable("BTN_PREV", $this->lng->txt("survey_previous"));
00762                 }
00763                 $this->tpl->parseCurrentBlock();
00764                 $nextpage = $this->object->getNextPage($page[0]["question_id"], 1);
00765                 $this->tpl->setCurrentBlock($navigationblock . "_next");
00766                 if ($nextpage === 1)
00767                 {
00768                         $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_finish"));
00769                 }
00770                 else
00771                 {
00772                         $this->tpl->setVariable("BTN_NEXT", $this->lng->txt("survey_next"));
00773                 }
00774                 $this->tpl->parseCurrentBlock();
00775         }
00776 }
00777 ?>

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