61                 $this->
object =& $a_object;
 
   64                 $this->external_rater_360 = 
false;
 
   65                 if($this->object->get360Mode() &&
 
   66                         $_SESSION[
"anonymous_id"][$this->
object->getId()] && 
 
   68                                         $_SESSION[
"anonymous_id"][$this->
object->getId()]))
 
   70                         $this->external_rater_360 = 
true;
 
   75                 $this->ctrl->saveParameter($this, 
"prvw");
 
   76                 $this->ctrl->saveParameter($this, 
"pgov");
 
   84                 $cmd = $this->ctrl->getCmd();
 
   85                 $next_class = $this->ctrl->getNextClass($this);
 
   88                 if (strlen(
$cmd) == 0)
 
   90                         $this->ctrl->setParameter($this, 
"qid", 
$_GET[
"qid"]);
 
   91                         $this->ctrl->redirect($this, 
"gotoPage");
 
  108                         if(!$rbacsystem->checkAccess(
"write", $this->object->ref_id))
 
  111                                 $this->ilias->raiseError($this->lng->txt(
"survey_cannot_preview_survey"),$this->ilias->error_obj->MESSAGE);     
 
  117                 if (!$this->external_rater_360 &&
 
  118                         !$rbacsystem->checkAccess(
"read", $this->object->ref_id)) 
 
  121                         $this->ilias->raiseError($this->lng->txt(
"cannot_read_survey"),$this->ilias->error_obj->MESSAGE);
 
  124                 $user_id = $ilUser->getId();
 
  128                 $anonymous_id = $anonymous_code = null;
 
  129                 if ($this->object->getAnonymize() || !$this->
object->isAccessibleWithoutCode())
 
  131                         $anonymous_code = 
$_SESSION[
"anonymous_id"][$this->
object->getId()];            
 
  132                         $anonymous_id = $this->
object->getAnonymousIdByCode($anonymous_code);                   
 
  135                                 ilUtil::sendFailure(sprintf($this->lng->txt(
"error_retrieving_anonymous_survey"), $anonymous_code, 
true));
 
  136                                 $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  142                 if($this->object->get360Mode())
 
  147                                 $appr_id = 
$_SESSION[
"appr_id"][$this->
object->getId()];
 
  152                                 $appraisees = $this->
object->getAppraiseesToRate(0, $anonymous_id);
 
  154                         if(!$appraisees && $user_id != ANONYMOUS_USER_ID)
 
  156                                 $appraisees = $this->
object->getAppraiseesToRate($user_id);
 
  158                         if(!in_array($appr_id, $appraisees))
 
  161                                 $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  164                 $_SESSION[
"appr_id"][$this->
object->getId()] = $appr_id;
 
  166                 $status = $this->
object->isSurveyStarted($user_id, $anonymous_code, $appr_id);          
 
  171                         $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  174                 else if ($status === 
false)
 
  178                                 $_SESSION[
"finished_id"][$this->
object->getId()] = 
 
  179                                         $this->
object->startSurvey($user_id, $anonymous_code, $appr_id);                                
 
  184                                 $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  194                 if($this->object->getActiveID($user_id, $anonymous_code, $appr_id) != 
 
  195                         $_SESSION[
"finished_id"][$this->
object->getId()])
 
  198                         $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");                   
 
  246                         $activepage = $this->
object->getLastActivePage(
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  249                 if (strlen($activepage)) 
 
  251                         $this->ctrl->setParameter($this, 
"qid", $activepage);
 
  253                 $this->ctrl->setParameter($this, 
"activecommand", 
"default");
 
  254                 $this->ctrl->redirect($this, 
"redirectQuestion");
 
  265                 switch (
$_GET[
"activecommand"])
 
  297                 $this->ctrl->setParameter($this, 
"activecommand", 
"previous");
 
  298                 $this->ctrl->setParameter($this, 
"qid", 
$_GET[
"qid"]);
 
  301                         $this->ctrl->setParameter($this, 
"direction", 
"0");
 
  305                         $this->ctrl->setParameter($this, 
"direction", 
"-1");
 
  307                 $this->ctrl->redirect($this, 
"redirectQuestion");
 
  318                 $this->ctrl->setParameter($this, 
"activecommand", 
"next");
 
  319                 $this->ctrl->setParameter($this, 
"qid", 
$_GET[
"qid"]);
 
  322                         $this->ctrl->setParameter($this, 
"direction", 
"0");
 
  326                         $this->ctrl->setParameter($this, 
"direction", 
"1");
 
  328                 $this->ctrl->redirect($this, 
"redirectQuestion");
 
  338                 $this->ctrl->setParameter($this, 
"activecommand", 
"gotoPage");
 
  339                 $this->ctrl->setParameter($this, 
"qid", 
$_GET[
"qid"]);
 
  340                 $this->ctrl->setParameter($this, 
"direction", 
"0");
 
  341                 $this->ctrl->redirect($this, 
"redirectQuestion");
 
  357                 $page = $this->
object->getNextPage($activepage, $direction);
 
  358                 $constraint_true = 0;
 
  361                 if (count($page[0][
"constraints"]))
 
  363                         while (is_array($page) and ($constraint_true == 0) and (count($page[0][
"constraints"])))
 
  365                                 $constraint_true = ($page[0][
'constraints'][0][
'conjunction'] == 0) ? 
true : 
false;
 
  366                                 foreach ($page[0][
"constraints"] as $constraint)
 
  370                                                 $working_data = $this->
object->loadWorkingData($constraint[
"question"], 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  374                                                 $working_data = 
$_SESSION[
"preview_data"][$this->
object->getId()][$constraint[
"question"]];
 
  376                                         if ($constraint[
'conjunction'] == 0)
 
  379                                                 $constraint_true = $constraint_true & $this->
object->checkConstraint($constraint, $working_data);
 
  384                                                 $constraint_true = $constraint_true | $this->
object->checkConstraint($constraint, $working_data);
 
  387                                 if ($constraint_true == 0)
 
  390                                         foreach($page as $page_question)
 
  392                                                 $qid = $page_question[
"question_id"];
 
  397                                                         $this->
object->deleteWorkingData($qid, 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  401                                                         $_SESSION[
"preview_data"][$this->
object->getId()][$qid] = null;
 
  405                                         $page = $this->
object->getNextPage($page[0][
"question_id"], $direction);
 
  410                 $first_question = -1;
 
  413                         $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  415                 else if ($page === 1)
 
  417                         $this->
object->finishSurvey(
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  419                         if ($this->object->getMailNotification())
 
  421                                 $this->
object->sendNotificationMail($ilUser->getId(), 
 
  422                                         $_SESSION[
"anonymous_id"][$this->
object->getId()],
 
  423                                         $_SESSION[
"appr_id"][$this->
object->getId()]);
 
  438                         $ilHelp->setScreenIdComponent(
"svy");
 
  439                         $ilHelp->setScreenId(
"quest_presentation");
 
  442                         $this->tpl->addBlockFile(
"ADM_CONTENT", 
"adm_content", 
"tpl.il_svy_svy_content.html", 
"Modules/Survey");
 
  444                         if($this->object->get360Mode())
 
  446                                 $appr_id = 
$_SESSION[
"appr_id"][$this->
object->getId()];
 
  448                                 include_once 
"Services/User/classes/class.ilUserUtil.php";
 
  449                                 $this->tpl->setTitle($this->object->getTitle().
" (".
 
  450                                         $this->lng->txt(
"survey_360_appraisee").
": ".
 
  454                         if (!($this->object->getAnonymize() && $this->
object->isAccessibleWithoutCode() && ($ilUser->getId() == ANONYMOUS_USER_ID)))
 
  456                                 $this->tpl->setCurrentBlock(
"suspend_survey");
 
  460                                         $this->tpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"cancel_survey"));
 
  461                                         $this->tpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI", 
"infoScreen"));
 
  462                                         $this->tpl->setVariable(
"HREF_IMG_SUSPEND", $this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI", 
"infoScreen"));
 
  466                                         $this->ctrl->setParameterByClass(
"ilObjSurveyGUI", 
"pgov", 
$_REQUEST[
"pgov"]);
 
  467                                         $this->tpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"survey_cancel_preview"));
 
  468                                         $this->tpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array(
"ilObjSurveyGUI", 
"ilSurveyEditorGUI"), 
"questions"));
 
  469                                         $this->tpl->setVariable(
"HREF_IMG_SUSPEND", $this->ctrl->getLinkTargetByClass(array(
"ilObjSurveyGUI", 
"ilSurveyEditorGUI"), 
"questions"));
 
  472                                 $this->tpl->setVariable(
"ALT_IMG_SUSPEND", $this->lng->txt(
"cancel_survey"));
 
  473                                 $this->tpl->setVariable(
"TITLE_IMG_SUSPEND", $this->lng->txt(
"cancel_survey"));
 
  475                                 $this->tpl->parseCurrentBlock();
 
  478                         $this->tpl->setCurrentBlock(
"percentage");
 
  479                         $percentage = (int)(($page[0][
"position"])*100);
 
  484                         $this->tpl->setVariable(
"PERCENTAGE_ALT", $this->lng->txt(
"percentage"));
 
  485                         $this->tpl->setVariable(
"PERCENTAGE_VALUE", $percentage);
 
  486                         $this->tpl->setVariable(
"PERCENTAGE_UNFINISHED", 100-$percentage);
 
  487                         $this->tpl->parseCurrentBlock();
 
  488                         if (count($page) > 1 && $page[0][
"questionblock_show_blocktitle"])
 
  490                                 $this->tpl->setCurrentBlock(
"questionblock_title");
 
  491                                 $this->tpl->setVariable(
"TEXT_QUESTIONBLOCK_TITLE", $page[0][
"questionblock_title"]);
 
  492                                 $this->tpl->parseCurrentBlock();
 
  494                         foreach ($page as $data)
 
  496                                 $this->tpl->setCurrentBlock(
"survey_content");
 
  497                                 if ($data[
"heading"])
 
  499                                         $this->tpl->setVariable(
"QUESTION_HEADING", $data[
"heading"]);
 
  501                                 if ($first_question == -1) $first_question = $data[
"question_id"];
 
  502                                 $question_gui = $this->
object->getQuestionGUI($data[
"type_tag"], $data[
"question_id"]);
 
  505                                         $working_data =& $question_gui->object->getWorkingDataFromUserInput(
$_SESSION[
"postdata"]);
 
  509                                         $working_data = $this->
object->loadWorkingData($data[
"question_id"], 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  511                                 $question_gui->object->setObligatory($data[
"obligatory"]);
 
  517                                 $show_questiontext = ($data[
"questionblock_show_questiontext"]) ? 1 : 0;
 
  518                                 $question_output = $question_gui->getWorkingForm($working_data, $this->object->getShowQuestionTitles(), $show_questiontext, 
$error_messages[$data[
"question_id"]], $this->
object->getSurveyId());
 
  519                                 $this->tpl->setVariable(
"QUESTION_OUTPUT", $question_output);
 
  520                                 $this->ctrl->setParameter($this, 
"qid", $data[
"question_id"]);
 
  521                                 $this->tpl->parse(
"survey_content");
 
  522                                 if ($data[
"obligatory"]) $required = 
true;
 
  526                                 $this->tpl->setCurrentBlock(
"required");
 
  527                                 $this->tpl->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
 
  528                                 $this->tpl->parseCurrentBlock();
 
  533                         $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this, 
"redirectQuestion"));
 
  538                         $this->
object->setPage(
$_SESSION[
"finished_id"][$this->object->getId()], $page[0][
'question_id']);
 
  539                         $this->
object->setStartTime(
$_SESSION[
"finished_id"][$this->object->getId()], $first_question);
 
  552                         $this->
object->setEndTime(
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  559                 $page = $this->
object->getNextPage(
$_GET[
"qid"], 0);
 
  560                 foreach ($page as $data)
 
  564                 if ($page_error && (strcmp($navigationDirection, 
"previous") != 0))
 
  566                         if ($page_error == 1)
 
  652                 include_once 
"./Modules/SurveyQuestionPool/classes/class.SurveyQuestion.php";
 
  654                 $error = $question->checkUserInput(
$_POST, $this->object->getSurveyId());
 
  655                 if (strlen($error) == 0)
 
  660                                 $this->
object->deleteWorkingData($data[
"question_id"], 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  662                                 $question->saveUserInput(
$_POST, 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  666                                 $_SESSION[
"preview_data"][$this->
object->getId()][$data[
"question_id"]] = 
 
  667                                         $question->saveUserInput(
$_POST, 
$_SESSION[
"finished_id"][$this->object->getId()], 
true);
 
  673                         $_SESSION[
"svy_errors"][$question->getId()] = $error;
 
  687                 $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  699                 if (strlen($this->object->getOutro()) == 0)
 
  705                         $this->tpl->addBlockFile(
"ADM_CONTENT", 
"adm_content", 
"tpl.il_svy_svy_finished.html", 
"Modules/Survey");
 
  706                         $this->tpl->setVariable(
"TEXT_FINISHED", $this->object->prepareTextareaOutput($this->object->getOutro()));
 
  707                         $this->tpl->setVariable(
"BTN_EXIT", $this->lng->txt(
"exit"));
 
  708                         $this->tpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this, 
"runShowFinishedPage"));
 
  717                 if($this->object->get360Mode())
 
  719                         $target_ref_id = $this->
object->getRefId();
 
  724                         $target_ref_id = $tree->getParentId($this->object->getRefId());
 
  727                 include_once 
"Services/Link/classes/class.ilLink.php";
 
  747                         $this->ctrl->setParameterByClass(
"ilsurveyeditorgui", 
"pgov", 
$_REQUEST[
"pgov"]);
 
  748                         $this->ctrl->redirectByClass(array(
"ilobjsurveygui", 
"ilsurveyeditorgui"), 
"questions");
 
  763                 $prevpage = $this->
object->getNextPage($page[0][
"question_id"], -1);
 
  764                 $this->tpl->setCurrentBlock($navigationblock . 
"_prev");
 
  767                         $this->tpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_start"));
 
  771                         $this->tpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_previous"));
 
  773                 $this->tpl->parseCurrentBlock();
 
  774                 $nextpage = $this->
object->getNextPage($page[0][
"question_id"], 1);
 
  775                 $this->tpl->setCurrentBlock($navigationblock . 
"_next");
 
  778                         $this->tpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_finish"));
 
  782                         $this->tpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_next"));
 
  784                 $this->tpl->parseCurrentBlock();