81        $this->rbacsystem = 
$DIC->rbac()->system();
 
   82        $this->
user = $DIC->user();
 
   83        $this->
help = $DIC[
"ilHelp"];
 
   84        $this->toolbar = 
$DIC->toolbar();
 
   87        $ilCtrl = 
$DIC->ctrl();
 
   92        $this->ctrl = $ilCtrl;
 
   93        $this->
object = $a_object;
 
   96        $this->external_rater_360 = 
false;
 
   97        if ($this->object->get360Mode() &&
 
   98            $_SESSION[
"anonymous_id"][$this->object->getId()] &&
 
  100                $this->object->getRefId(),
 
  101                $_SESSION[
"anonymous_id"][$this->object->getId()]
 
  103            $this->external_rater_360 = 
true;
 
  107        $this->
preview = (bool) $_REQUEST[
"prvw"];
 
  108        $this->ctrl->saveParameter($this, 
"prvw");
 
  109        $this->ctrl->saveParameter($this, 
"pgov");
 
  122            $this->object->getRefId(),
 
  123            $this->object->getId(),
 
  127        $cmd = $this->ctrl->getCmd();
 
  128        $next_class = $this->ctrl->getNextClass($this);
 
  132        $this->log->debug(
"- cmd= " . $cmd);
 
  134        if (strlen($cmd) == 0) {
 
  135            $this->ctrl->setParameter($this, 
"qid", 
$_GET[
"qid"]);
 
  136            $this->ctrl->redirect($this, 
"gotoPage");
 
  138        switch ($next_class) {
 
  140                $ret = &$this->$cmd();
 
  146    protected function checkAuth($a_may_start = 
false, $a_ignore_status = 
false)
 
  152            if (!
$rbacsystem->checkAccess(
"write", $this->object->ref_id)) {
 
  160        if (!$this->external_rater_360 &&
 
  161            !
$rbacsystem->checkAccess(
"read", $this->object->ref_id)) {
 
  170        $anonymous_id = $anonymous_code = 
null;
 
  171        if ($this->object->getAnonymize() || !$this->object->isAccessibleWithoutCode()) {
 
  172            $anonymous_code = 
$_SESSION[
"anonymous_id"][$this->
object->getId()];
 
  173            $anonymous_id = $this->
object->getAnonymousIdByCode($anonymous_code);
 
  174            if (!$anonymous_id) {
 
  175                ilUtil::sendFailure(sprintf($this->lng->txt(
"error_retrieving_anonymous_survey"), $anonymous_code, 
true));
 
  176                $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  182        if ($this->object->get360Mode()) {
 
  183            $appr_id = $_REQUEST[
"appr_id"];
 
  185                $appr_id = 
$_SESSION[
"appr_id"][$this->
object->getId()];
 
  189                $appraisees = $this->
object->getAppraiseesToRate(0, $anonymous_id);
 
  192                $appraisees = $this->
object->getAppraiseesToRate($user_id);
 
  194            if (!in_array($appr_id, $appraisees)) {
 
  196                $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  200        #23575 in self eval the appraisee is the current user. 
  205        $_SESSION[
"appr_id"][$this->
object->getId()] = $appr_id;
 
  207        if (!$a_ignore_status) {
 
  208            $status = $this->
object->isSurveyStarted($user_id, $anonymous_code, $appr_id);
 
  212                $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  215            elseif ($status === 
false) {
 
  217                    $_SESSION[
"finished_id"][$this->
object->getId()] =
 
  218                        $this->
object->startSurvey($user_id, $anonymous_code, $appr_id);
 
  221                    $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  231        if ($this->object->getActiveID($user_id, $anonymous_code, $appr_id) !=
 
  232            $_SESSION[
"finished_id"][$this->object->getId()]) {
 
  234            $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  269    public function start($resume = 
false)
 
  280            $activepage = $this->
object->getLastActivePage(
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  283        if (strlen($activepage)) {
 
  284            $this->ctrl->setParameter($this, 
"qid", $activepage);
 
  286        $this->ctrl->setParameter($this, 
"activecommand", 
"default");
 
  287        $this->ctrl->redirect($this, 
"redirectQuestion");
 
  298        switch (
$_GET[
"activecommand"]) {
 
  336        $this->ctrl->setParameter($this, 
"activecommand", 
"previous");
 
  337        $this->ctrl->setParameter($this, 
"qid", 
$_GET[
"qid"]);
 
  338        if (strlen($has_error)) {
 
  339            $this->ctrl->setParameter($this, 
"direction", 
"0");
 
  341            $this->ctrl->setParameter($this, 
"direction", 
"-1");
 
  343        $this->ctrl->redirect($this, 
"redirectQuestion");
 
  354        $this->ctrl->setParameter($this, 
"activecommand", 
"next");
 
  355        $this->ctrl->setParameter($this, 
"qid", 
$_GET[
"qid"]);
 
  357            $this->ctrl->setParameter($this, 
"direction", 
"0");
 
  359            $this->ctrl->setParameter($this, 
"direction", 
"1");
 
  361        $this->ctrl->redirect($this, 
"redirectQuestion");
 
  371        $this->ctrl->setParameter($this, 
"activecommand", 
"gotoPage");
 
  372        $this->ctrl->setParameter($this, 
"qid", 
$_GET[
"qid"]);
 
  373        $this->ctrl->setParameter($this, 
"direction", 
"0");
 
  374        $this->ctrl->redirect($this, 
"redirectQuestion");
 
  390        $page = $this->
object->getNextPage($activepage, $direction);
 
  391        $constraint_true = 0;
 
  394        if (is_array($page[0][
"constraints"]) && count($page[0][
"constraints"])) {
 
  395            $this->log->debug(
"Page constraints= ", $page[0][
"constraints"]);
 
  397            while (is_array($page) and ($constraint_true == 0) and (count($page[0][
"constraints"]))) {
 
  398                $constraint_true = ($page[0][
'constraints'][0][
'conjunction'] == 0) ? 
true : 
false;
 
  399                foreach ($page[0][
"constraints"] as $constraint) {
 
  401                        $working_data = $this->
object->loadWorkingData($constraint[
"question"], 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  403                        $working_data = 
$_SESSION[
"preview_data"][$this->
object->getId()][$constraint[
"question"]];
 
  405                    if ($constraint[
'conjunction'] == 0) {
 
  407                        $constraint_true = $constraint_true & $this->
object->checkConstraint($constraint, $working_data);
 
  410                        $constraint_true = $constraint_true | $this->
object->checkConstraint($constraint, $working_data);
 
  413                if ($constraint_true == 0) {
 
  415                    foreach ($page as $page_question) {
 
  416                        $qid = $page_question[
"question_id"];
 
  420                            $this->
object->deleteWorkingData($qid, 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  422                            $_SESSION[
"preview_data"][$this->
object->getId()][$qid] = 
null;
 
  426                    $page = $this->
object->getNextPage($page[0][
"question_id"], $direction);
 
  431        $first_question = -1;
 
  433            $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  434        } elseif ($page === 1) {
 
  435            $state = $this->
object->getUserSurveyExecutionStatus();
 
  437                !$state[
"runs"][
$_SESSION[
"finished_id"][$this->object->getId()]][
"finished"]) {
 
  445            $ilHelp->setScreenIdComponent(
"svy");
 
  446            $ilHelp->setScreenId(
"quest_presentation");
 
  454            $stpl = 
new ilTemplate(
"tpl.il_svy_svy_content.html", 
true, 
true, 
"Modules/Survey");
 
  456            if ($this->object->get360Mode()) {
 
  457                $appr_id = 
$_SESSION[
"appr_id"][$this->
object->getId()];
 
  459                $this->tpl->setTitle($this->object->getTitle() . 
" (" .
 
  460                    $this->lng->txt(
"survey_360_appraisee") . 
": " .
 
  464            if (!($this->object->getAnonymize() && $this->object->isAccessibleWithoutCode() && (
$ilUser->getId() == 
ANONYMOUS_USER_ID))) {
 
  465                $stpl->setCurrentBlock(
"suspend_survey");
 
  468                    $stpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"cancel_survey"));
 
  469                    $stpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI", 
"infoScreen"));
 
  471                    $this->ctrl->setParameterByClass(
"ilObjSurveyGUI", 
"pgov", $_REQUEST[
"pgov"]);
 
  472                    $stpl->setVariable(
"TEXT_SUSPEND", $this->lng->txt(
"survey_cancel_preview"));
 
  473                    $stpl->setVariable(
"HREF_SUSPEND", $this->ctrl->getLinkTargetByClass(array(
"ilObjSurveyGUI", 
"ilSurveyEditorGUI"), 
"questions"));
 
  476                $stpl->setVariable(
"ALT_IMG_SUSPEND", $this->lng->txt(
"cancel_survey"));
 
  477                $stpl->setVariable(
"TITLE_IMG_SUSPEND", $this->lng->txt(
"cancel_survey"));
 
  478                $stpl->parseCurrentBlock();
 
  483            $stpl->setCurrentBlock(
"percentage");
 
  485            $percentage = (int) (($page[0][
"position"]) * 100);
 
  488            $pbar->setCurrent($percentage);
 
  489            $stpl->setVariable(
"NEW_PBAR", $pbar->render());
 
  491            $stpl->parseCurrentBlock();
 
  494            if (count($page) > 1 && $page[0][
"questionblock_show_blocktitle"]) {
 
  495                $stpl->setCurrentBlock(
"questionblock_title");
 
  496                $stpl->setVariable(
"TEXT_QUESTIONBLOCK_TITLE", $page[0][
"questionblock_title"]);
 
  497                $stpl->parseCurrentBlock();
 
  499            $compress_view = 
false;
 
  500            if (count($page) > 1) {
 
  501                $compress_view = $page[0][
"questionblock_compress_view"];
 
  503            $previous_page = 
null;
 
  506            $previous_key = 
null;
 
  507            foreach ($page as $k => 
$data) {
 
  508                $page[$k][
"compressed"] = 
false;
 
  509                $page[$k][
"compressed_first"] = 
false;
 
  511                    $page[$k][
"compressed"] = 
true;
 
  512                    if ($previous_key !== 
null && $page[$previous_key][
"compressed"] == 
false) {
 
  513                        $page[$previous_key][
"compressed_first"] = 
true;
 
  517                $previous_page = 
$data;
 
  519            foreach ($page as 
$data) {
 
  520                if (
$data[
"heading"]) {
 
  521                    $stpl->setCurrentBlock(
"heading");
 
  522                    $stpl->setVariable(
"QUESTION_HEADING", 
$data[
"heading"]);
 
  523                    $stpl->parseCurrentBlock();
 
  525                $stpl->setCurrentBlock(
"survey_content");
 
  526                if ($first_question == -1) {
 
  527                    $first_question = 
$data[
"question_id"];
 
  529                $question_gui = $this->
object->getQuestionGUI($data[
"type_tag"], 
$data[
"question_id"]);
 
  531                    $working_data = &$question_gui->object->getWorkingDataFromUserInput(
$_SESSION[
"postdata"]);
 
  533                    $working_data = $this->
object->loadWorkingData($data[
"question_id"], 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  535                $question_gui->object->setObligatory(
$data[
"obligatory"]);
 
  536                $error_messages = array();
 
  538                    $error_messages = 
$_SESSION[
"svy_errors"];
 
  540                $show_questiontext = (
$data[
"questionblock_show_questiontext"]) ? 1 : 0;
 
  541                $show_title = ($this->
object->getShowQuestionTitles() && !$data[
"compressed_first"]);
 
  542                $question_output = $question_gui->getWorkingForm($working_data, $show_title, $show_questiontext, $error_messages[
$data[
"question_id"]], $this->object->getSurveyId(), $compress_view);
 
  543                if (
$data[
"compressed"]) {
 
  544                    $question_output = 
'<div class="il-svy-qst-compressed">' . $question_output . 
'</div>';
 
  546                $stpl->setVariable(
"QUESTION_OUTPUT", $question_output);
 
  547                $this->ctrl->setParameter($this, 
"qid", 
$data[
"question_id"]);
 
  549                if (
$data[
"obligatory"]) {
 
  552                $stpl->parseCurrentBlock();
 
  555                $stpl->setCurrentBlock(
"required");
 
  556                $stpl->setVariable(
"TEXT_REQUIRED", $this->lng->txt(
"required_field"));
 
  557                $stpl->parseCurrentBlock();
 
  562            $stpl->setVariable(
"FORM_ACTION", $this->ctrl->getFormAction($this, 
"redirectQuestion"));
 
  564        $this->tpl->setContent($stpl->get());
 
  567            $this->
object->setPage(
$_SESSION[
"finished_id"][$this->object->getId()], $page[0][
'question_id']);
 
  568            $this->
object->setStartTime(
$_SESSION[
"finished_id"][$this->object->getId()], $first_question);
 
  580        if (!$previous_page) {
 
  584        if ($previous_page[
"type_tag"] === $page[
"type_tag"] &&
 
  585            $page[
"type_tag"] === 
"SurveySingleChoiceQuestion") {
 
  602            $this->
object->setEndTime(
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  609        $page = $this->
object->getNextPage(
$_GET[
"qid"], 0);
 
  610        foreach ($page as 
$data) {
 
  613        if ($page_error && (strcmp($navigationDirection, 
"previous") != 0)) {
 
  614            if ($page_error == 1) {
 
  696        $error = $question->checkUserInput(
$_POST, $this->object->getSurveyId());
 
  697        if (strlen($error) == 0) {
 
  700                $this->
object->deleteWorkingData(
$data[
"question_id"], 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  702                $question->saveUserInput(
$_POST, 
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  704                $_SESSION[
"preview_data"][$this->
object->getId()][
$data[
"question_id"]] =
 
  705                    $question->saveUserInput(
$_POST, 
$_SESSION[
"finished_id"][$this->object->getId()], 
true);
 
  709            $_SESSION[
"svy_errors"][$question->getId()] = $error;
 
  723        $this->ctrl->redirectByClass(
"ilobjsurveygui", 
"infoScreen");
 
  742            if ($this->object->hasViewOwnResults()) {
 
  744                $button->setCaption(
"svy_view_own_results");
 
  745                $button->setUrl($this->ctrl->getLinkTarget($this, 
"viewUserResults"));
 
  746                $ilToolbar->addButtonInstance($button);
 
  751            if ($this->object->hasMailConfirmation()) {
 
  753                    $ilToolbar->addSeparator();
 
  758                    require_once 
"Services/Form/classes/class.ilTextInputGUI.php";
 
  761                    $ilToolbar->addInputItem($mail, 
true);
 
  764                $ilToolbar->setFormAction($this->ctrl->getFormAction($this, 
"mailUserResults"));
 
  767                $button->setCaption(
"svy_mail_send_confirmation");
 
  768                $button->setCommand(
"mailUserResults");
 
  769                $ilToolbar->addButtonInstance($button);
 
  777                $button->setCaption(
"svy_results");
 
  778                $button->setUrl($this->ctrl->getLinkTargetByClass(
"ilObjSurveyGUI", 
"evaluation"));
 
  779                $ilToolbar->addButtonInstance($button);
 
  786            strlen($this->object->getOutro()) == 0) {
 
  790                $ilToolbar->addSeparator();
 
  794            $button->setCaption(
"survey_execution_exit");
 
  795            $button->setUrl($this->ctrl->getLinkTarget($this, 
"exitSurvey"));
 
  796            $ilToolbar->addButtonInstance($button);
 
  798            if (strlen($this->object->getOutro())) {
 
  800                $panel->setBody($this->object->prepareTextareaOutput($this->object->getOutro()));
 
  801                $this->tpl->setContent(
$panel->getHTML());
 
  811        if ($this->object->get360Mode()) {
 
  812            $target_ref_id = $this->
object->getRefId();
 
  815            $target_ref_id = 
$tree->getParentId($this->object->getRefId());
 
  834            $this->ctrl->setParameterByClass(
"ilsurveyeditorgui", 
"pgov", $_REQUEST[
"pgov"]);
 
  835            $this->ctrl->redirectByClass(array(
"ilobjsurveygui", 
"ilsurveyeditorgui"), 
"questions");
 
  850        $prevpage = $this->
object->getNextPage($page[0][
"question_id"], -1);
 
  851        $stpl->setCurrentBlock($navigationblock . 
"_prev");
 
  852        if ($prevpage === 0) {
 
  853            $stpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_start"));
 
  855            $stpl->setVariable(
"BTN_PREV", $this->lng->txt(
"survey_previous"));
 
  857        $stpl->parseCurrentBlock();
 
  858        $nextpage = $this->
object->getNextPage($page[0][
"question_id"], 1);
 
  859        $stpl->setCurrentBlock($navigationblock . 
"_next");
 
  860        if ($nextpage === 1) {
 
  861            $stpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_finish"));
 
  863            $stpl->setVariable(
"BTN_NEXT", $this->lng->txt(
"survey_next"));
 
  865        $stpl->parseCurrentBlock();
 
  877        if (!$this->object->hasViewOwnResults()) {
 
  884        $button->setCaption(
"btn_back");
 
  885        $button->setUrl($this->ctrl->getLinkTarget($this, 
"runShowFinishedPage"));
 
  886        $ilToolbar->addButtonInstance($button);
 
  889        $html = $survey_gui->getUserResultsTable(
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  890        $this->tpl->setContent($html);
 
  897        if (!$this->object->hasMailConfirmation()) {
 
  903        $recipient = 
$_POST[
"mail"];
 
  905            $recipient = 
$ilUser->getEmail();
 
  908            $this->ctrl->redirect($this, 
"runShowFinishedPage");
 
  912        $survey_gui->sendUserResultsMail(
 
  913            $_SESSION[
"finished_id"][$this->object->getId()],
 
  917        ilUtil::sendSuccess($this->lng->txt(
"mail_sent"), 
true);
 
  918        $this->ctrl->redirect($this, 
"runShowFinishedPage");
 
  926        $cgui->setHeaderText($this->lng->txt(
"survey_execution_sure_finish"));
 
  928        $cgui->setFormAction($this->ctrl->getFormAction($this, 
"confirmedFinish"));
 
  929        $cgui->setCancel($this->lng->txt(
"cancel"), 
"previousNoSave");
 
  930        $cgui->setConfirm($this->lng->txt(
"confirm"), 
"confirmedFinish");
 
  932        $tpl->setContent($cgui->getHTML());
 
  940            $this->
object->finishSurvey(
$_SESSION[
"finished_id"][$this->object->getId()]);
 
  946            if ($this->object->getMailNotification()) {
 
  947                $this->
object->sendNotificationMail(
 
  949                    $_SESSION[
"anonymous_id"][$this->object->getId()],
 
  950                    $_SESSION[
"appr_id"][$this->object->getId()]
 
  955        $this->ctrl->redirect($this, 
"runShowFinishedPage");
 
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
An exception for terminatinating execution or to throw for unit testing.
static _instanciateQuestion($question_id)
Creates an instance of a question with a given question id.
static compressable($id1, $id2)
static _recordReadEvent( $a_type, $a_ref_id, $obj_id, $usr_id, $isCatchupWriteEvents=true, $a_ext_rc=false, $a_ext_time=false)
Records a read event and catches up with write events.
Confirmation screen class.
static _updateStatus($a_obj_id, $a_usr_id, $a_obj=null, $a_percentage=false, $a_force_raise=false)
Update status.
static _tracProgress($a_user_id, $a_obj_id, $a_ref_id, $a_obj_type='')
static _getLink($a_ref_id, $a_type='', $a_params=array(), $append="")
static getLogger($a_component_id)
Get component logger.
static _hasEvaluationAccess($a_obj_id, $user_id)
static validateExternalRaterCode($a_ref_id, $a_code)
static getInstance()
Get instance.
static getInstance()
Factory.
Survey execution graphical output.
previous($a_save_input=true)
Navigates to the previous pages.
getCommand($cmd)
Retrieves the ilCtrl command.
exitSurvey()
Exits the survey after finishing it.
saveUserInput($navigationDirection="next")
Save the user's input.
outNavigationButtons($navigationblock="top", $page, $stpl)
Creates the navigation buttons for a survey.
resume()
Resumes the survey.
cancel()
Called on cancel.
outSurveyPage($activepage=null, $direction=null)
Output of the active survey question to the screen.
redirectQuestion()
Called when a user answered a page to perform a redirect after POST.
saveActiveQuestionData(&$data)
Survey navigation.
next()
Navigates to the next pages.
checkAuth($a_may_start=false, $a_ignore_status=false)
gotoPage()
Go to a specific page without saving.
compressQuestion($previous_page, $page)
__construct($a_object)
ilSurveyExecutionGUI constructor
runShowFinishedPage()
Creates the finished page for a running survey.
executeCommand()
execute command
start($resume=false)
Starts the survey.
special template class to simplify handling of ITX/PEAR
This class represents a text property in a property form.
static getNamePresentation( $a_user_id, $a_user_image=false, $a_profile_link=false, $a_profile_back_link="", $a_force_first_lastname=false, $a_omit_login=false, $a_sortable=true, $a_return_data_array=false, $a_ctrl_path="ilpublicuserprofilegui")
Default behaviour is:
static redirect($a_script)
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static is_email($a_email, ilMailRfc822AddressParserFactory $mailAddressParserFactory=null)
This preg-based function checks whether an e-mail address is formally valid.
if(isset($_FILES['img_file']) &&is_array($_FILES['img_file'])) $panel