Example #1
0
    function watch()
    {
        $returnStr = $this->showHeader(Language::messageSMSTitle());
        $returnStr .= $this->displayComboBox();
        $returnStr .= "<form method='post'>";
        $params = getSessionParams();
        //$params['reportpage'] = 'reportRes';
        $returnStr .= setSessionParamsPost($params);
        $returnStr .= '<div id="wrap">';
        $returnStr .= '<div class="container"><p>';
        $returnStr .= '<div class="panel panel-default">
                <div class="panel-heading">';
        $returnStr .= '<h4>' . Language::linkWatch() . '</h4>';
        $returnStr .= '                </div>
                <div class="panel-body">';
        require_once 'data.php';
        require_once 'display.php';
        $data = new Data();
        $values = $data->getRespondentData(getFromSessionParams('watchsuid'), getFromSessionParams('watchprimkey'));
        $returnStr .= '</div>
    <div role="panel" class="panel">';
        if (sizeof($values) == 0) {
            $returnStr .= "<br/>" . '<div class="alert alert-warning">' . Language::labelWatchNoData() . '</div>';
        } else {
            $returnStr .= $this->displayDataTablesScripts(array("colvis", "rowreorder"));
            $returnStr .= "<script type='text/javascript'>\n                        \$(document).ready(function(){\n                            \$('#issuetable').dataTable(\n                                {\n                                    \"iDisplayLength\": 5,\n                                    dom: 'C<\"clear\">lfrtip',\n                                    searching: false,\n                                    paging: true\n                                    }    \n                                );\n                                         \n                       });</script>\n\n                        ";
            //
            $returnStr .= "<br/><table id='issuetable' class='table table-bordered table-striped'><thead>";
            $returnStr .= "<th>" . Language::labelWatchVariable() . "</th><th>" . Language::labelWatchValue() . "</th><th>" . Language::labelWatchClean() . "</th><th>" . Language::labelWatchMode() . "</th><th>" . Language::labelWatchLanguage() . "</th><th>" . Language::labelWatchTime() . "</th></tr>";
            $returnStr .= "</thead><tbody>";
            $modes = Common::surveyModes();
            $languages = Language::getLanguagesArray();
            $sesid = session_id();
            require_once 'object.php';
            require_once 'component.php';
            require_once 'setting.php';
            require_once 'type.php';
            require_once 'variabledescriptive.php';
            $survey = new Survey(getFromSessionParams('watchsuid'));
            foreach ($values as $is) {
                $returnStr .= "<tr>";
                $returnStr .= "<td>" . $is["variablename"] . "</td>";
                $returnStr .= "<td>" . $this->getDisplayValue($survey->getVariableDescriptiveByName($is["variablename"]), $is["answer_dec"]) . "</td>";
                $returnStr .= "<td>" . $this->displayDirty([$is["dirty"]]) . "</td>";
                $returnStr .= "<td>" . $modes[$is["mode"]] . "</td>";
                $returnStr .= "<td>" . $languages[str_replace("_", "", getSurveyLanguagePostFix($is["language"]))]['name'] . "</td>";
                $returnStr .= "<td>" . $is["ts"] . "</td>";
                $returnStr .= "</tr>";
            }
            $returnStr .= "</tbody></table>";
        }
        $returnStr .= '</div>
  </div>
</div>';
        $returnStr .= '                </div></div>';
        $returnStr .= '</p></div>    </div>';
        //container and wrap
        $returnStr .= $this->showFooter(false);
        echo $returnStr;
    }
Example #2
0
 function getNextQuestion()
 {
     global $db;
     /* get language */
     $language = getSurveyLanguage();
     // include language
     if (file_exists("language/language" . getSurveyLanguagePostFix($language) . ".php")) {
         require_once 'language' . getSurveyLanguagePostFix($language) . '.php';
         // language
     } else {
         require_once 'language_en.php';
         // fall back on english language  file
     }
     // check if session request already in progress
     if (isset($_SESSION['PREVIOUS_REQUEST_IN_PROGRESS']) && $_SESSION['PREVIOUS_REQUEST_IN_PROGRESS'] == 1) {
         doCommit();
         echo $this->display->showInProgressSurvey();
         doExit();
     } else {
         if ($this->isLocked()) {
             doCommit();
             echo $this->display->showLockedSurvey();
             doExit();
         }
     }
     // lock (we unlock in showQuestion OR doEnd if end of survey
     $this->lock();
     // we are starting/returning to the survey/section OR submit of old form
     $oldform = $this->isOldFormSubmit();
     //echo 'rgid: ' . getFromSessionParams(SESSION_PARAM_RGID) . '----';
     if (getFromSessionParams(SESSION_PARAM_RGID) == '' || $oldform) {
         // returning to the survey
         if ($this->getDisplayed() != "") {
             // completed interview
             if ($this->getDataRecord()->isCompleted()) {
                 /* see what to do on reentry after completion
                  * based on settings of last displayed variable/group
                  */
                 $reentry = AFTER_COMPLETION_NO_REENTRY;
                 $reentry_preload = PRELOAD_REDO_NO;
                 $groupname = $this->getTemplate();
                 $rgid = $this->getRgid();
                 $variablenames = $this->getDisplayed();
                 if ($groupname != "") {
                     $group = $this->getGroup($groupname);
                     $reentry = $group->getAccessReturnAfterCompletionAction();
                     $reentry_preload = $group->getAccessReturnAfterCompletionRedoPreload();
                 } else {
                     $variables = explode("~", $variablenames);
                     $realvariables = explode("~", $this->display->getRealVariables($variables));
                     if (sizeof($realvariables) > 0) {
                         $var = $this->getVariableDescriptive($realvariables[0]);
                         //echo $var->getName();
                         $reentry = $var->getAccessReturnAfterCompletionAction();
                         $reentry_preload = $var->getAccessReturnAfterCompletionRedoPreload();
                     }
                 }
                 if ($reentry == AFTER_COMPLETION_NO_REENTRY) {
                     $this->unlock();
                     doCommit();
                     echo $this->display->showCompletedSurvey();
                     doExit();
                 } else {
                     // set current action to reentry
                     $this->currentaction = ACTION_SURVEY_REENTRY;
                     /* update language, mode and version */
                     $this->setAnswer(VARIABLE_LANGUAGE, $language);
                     $this->setAnswer(VARIABLE_VERSION, getSurveyVersion());
                     $this->setAnswer(VARIABLE_MODE, getSurveyMode());
                     $this->setAnswer(VARIABLE_PLATFORM, $_SERVER['HTTP_USER_AGENT']);
                     $this->setAnswer(VARIABLE_EXECUTION_MODE, getSurveyExecutionMode());
                     $this->setAnswer(VARIABLE_TEMPLATE, getSurveyTemplate());
                     $this->setAnswer(VARIABLE_END, null);
                     /* set interview data as incompleted */
                     $this->getDataRecord()->setToIncomplete();
                     // redoing preloads
                     if ($reentry_preload == PRELOAD_REDO_YES) {
                         //echo 'preloading again';
                         $pd = loadvarSurvey('pd');
                         if ($pd != '') {
                             getSessionParamsPost(loadvarSurvey('pd'), 'PD');
                             foreach ($_SESSION['PD'] as $field => $answer) {
                                 //echo $field . ' set with ' . $answer . '<br/>';
                                 $this->setAnswer($field, $answer);
                             }
                         }
                     }
                     // where are we entering
                     $where = $reentry;
                     //$this->survey->getAccessReturnAfterCompletionAction();
                     // show first question(s) of survey
                     if ($where == AFTER_COMPLETION_FIRST_SCREEN) {
                         /* save data record */
                         $this->getDataRecord()->saveRecord();
                         // get data of current state, which is the last one (with updated preloads if we re-did the preloads)
                         $data = $this->state->getAllData();
                         // remove all states except first one with displayed != "" and anything before that state
                         $this->removeAllStatesExceptFirst();
                         // load the first state
                         $this->loadLastState();
                         // set data from last state to first state
                         $this->state->setAllData($data);
                         //unset($data);
                         // save updated state
                         $this->saveState(false);
                         /* if (language different from state AND not using last known language) OR (mode different from state AND not using last known language) OR (version different from state), then wipe fill texts */
                         if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getReentryLanguage() == LANGUAGE_REENTRY_NO || $this->state->getMode() != getSurveyMode() && $this->survey->getReentryMode() == MODE_REENTRY_NO || $this->state->getVersion() != getSurveyVersion()) {
                             $this->setFillTexts(array());
                             /* indicate to redo any fills */
                             $this->setRedoFills(true);
                         }
                         // show question(s)
                         $groupname = $this->getTemplate();
                         $rgid = $this->getRgid();
                         $variablenames = $this->getDisplayed();
                         $this->showQuestion($variablenames, $rgid, $groupname);
                         doExit();
                     } else {
                         if ($where == AFTER_COMPLETION_FROM_START) {
                             // get data of current state, which is the last one (with updated preloads if we re-did the preloads)
                             $data = $this->state->getAllData();
                             // remove all states
                             $this->removeAllStates();
                             // initialize new state
                             $this->reinitializeState();
                             // set data
                             $this->state->setAllData($data);
                             // start main section
                             $this->doSection("", 0, $this->getMainSeid(), true);
                             /* stop */
                             doExit();
                         } else {
                             if (inArray($where, array(AFTER_COMPLETION_LAST_SCREEN, AFTER_COMPLETION_LAST_SCREEN_REDO))) {
                                 /* if (language different from state AND not using last known language) OR (mode different from state AND not using last known language) OR (version different from state), then wipe fill texts */
                                 if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getReentryLanguage() == LANGUAGE_REENTRY_NO || $this->state->getMode() != getSurveyMode() && $this->survey->getReentryMode() == MODE_REENTRY_NO || $this->state->getVersion() != getSurveyVersion()) {
                                     $this->setFillTexts(array());
                                     /* indicate to redo any fills */
                                     $this->setRedoFills(true);
                                 }
                                 $groupname = $this->getTemplate();
                                 $rgid = $this->getRgid();
                                 $variablenames = $this->getDisplayed();
                                 // not redoing anything
                                 if ($where == AFTER_COMPLETION_LAST_SCREEN) {
                                     $this->showQuestion($variablenames, $rgid, $groupname);
                                     doExit();
                                 } else {
                                     // in group, then we redo
                                     if ($groupname != "") {
                                         /* indicate update action */
                                         $this->updateaction = true;
                                         /* clear inline fields and sub displays */
                                         $this->setInlineFields(array());
                                         $this->setSubDisplays(array());
                                         /* remove assignments within action */
                                         $this->removeAssignmentsAfterRgid($rgid);
                                         /* re-do action */
                                         $this->doAction($rgid);
                                         /* save data record */
                                         $this->getDataRecord()->saveRecord();
                                         /* we finished everything and are showing a question if all went well 
                                          * so this is the moment to update the state
                                          */
                                         $this->saveState(false);
                                         /* stop */
                                         return;
                                     }
                                 }
                                 doExit();
                             }
                         }
                     }
                 }
             } else {
                 /* see what to do on reentry
                  * based on settings of last 
                  * displayed variable/group
                  */
                 $action = REENTRY_SAME_SCREEN;
                 $reentry_preload = PRELOAD_REDO_NO;
                 $groupname = $this->getTemplate();
                 $rgid = $this->getRgid();
                 $variablenames = $this->getDisplayed();
                 if ($groupname != "") {
                     $group = $this->getGroup($groupname);
                     $action = $group->getAccessReentryAction();
                     $reentry_preload = $group->getAccessReentryRedoPreload();
                 } else {
                     $variables = explode("~", $variablenames);
                     $realvariables = explode("~", $this->display->getRealVariables($variables));
                     if (sizeof($realvariables) > 0) {
                         $var = $this->getVariableDescriptive($realvariables[0]);
                         $action = $var->getAccessReentryAction();
                         $reentry_preload = $var->getAccessReentryRedoPreload();
                     }
                 }
                 /* no re-entry allowed */
                 if ($action == REENTRY_NO_REENTRY) {
                     $this->unlock();
                     doCommit();
                     echo $this->display->showCompletedSurvey();
                     doExit();
                 } else {
                     // set current action to reentry
                     $this->currentaction = ACTION_SURVEY_RETURN;
                     /* update language, mode and version */
                     $this->setAnswer(VARIABLE_LANGUAGE, $language);
                     $this->setAnswer(VARIABLE_VERSION, getSurveyVersion());
                     $this->setAnswer(VARIABLE_MODE, getSurveyMode());
                     $this->setAnswer(VARIABLE_PLATFORM, $_SERVER['HTTP_USER_AGENT']);
                     $this->setAnswer(VARIABLE_EXECUTION_MODE, getSurveyExecutionMode());
                     $this->setAnswer(VARIABLE_TEMPLATE, getSurveyTemplate());
                     // redoing preloads
                     if ($reentry_preload == PRELOAD_REDO_YES) {
                         //echo 'preloading again';
                         $pd = loadvarSurvey('pd');
                         if ($pd != '') {
                             getSessionParamsPost(loadvarSurvey('pd'), 'PD');
                             foreach ($_SESSION['PD'] as $field => $answer) {
                                 //echo $field . ' set with ' . $answer . '<br/>';
                                 $this->setAnswer($field, $answer);
                             }
                         }
                     }
                     // show first question(s) of survey
                     if ($action == REENTRY_FIRST_SCREEN) {
                         /* save data record */
                         $this->getDataRecord()->saveRecord();
                         // get data of current state, which is the last one (with updated preloads if we re-did the preloads)
                         $data = $this->state->getAllData();
                         // remove all states except first one with displayed != "" and anything before that state
                         $this->removeAllStatesExceptFirst();
                         // load the first state
                         $this->loadLastState();
                         // set data from last state to first state
                         $this->state->setAllData($data);
                         //unset($data);
                         // save updated state
                         $this->saveState(false);
                         /* if (language different from state AND not using last known language) OR (mode different from state AND not using last known language) OR (version different from state), then wipe fill texts */
                         if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getReentryLanguage() == LANGUAGE_REENTRY_NO || $this->state->getMode() != getSurveyMode() && $this->survey->getReentryMode() == MODE_REENTRY_NO || $this->state->getVersion() != getSurveyVersion()) {
                             $this->setFillTexts(array());
                             /* indicate to redo any fills */
                             $this->setRedoFills(true);
                         }
                         // show question(s)
                         $groupname = $this->getTemplate();
                         $rgid = $this->getRgid();
                         $variablenames = $this->getDisplayed();
                         $this->showQuestion($variablenames, $rgid, $groupname);
                         doExit();
                     } else {
                         if ($action == REENTRY_FROM_START) {
                             // get data of current state, which is the last one (with updated preloads if we re-did the preloads)
                             $data = $this->state->getAllData();
                             // remove all states
                             $this->removeAllStates();
                             // initialize new state
                             $this->reinitializeState();
                             // set data
                             $this->state->setAllData($data);
                             // start main section
                             $this->doSection("", 0, $this->getMainSeid(), true);
                             /* stop */
                             doExit();
                         } else {
                             if (inArray($action, array(REENTRY_SAME_SCREEN, REENTRY_SAME_SCREEN_REDO_ACTION))) {
                                 /* if (language different from state AND not using last known language) OR (mode different from state AND not using last known language) OR (version different from state), then wipe fill texts */
                                 if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getReentryLanguage() == LANGUAGE_REENTRY_NO || $this->state->getMode() != getSurveyMode() && $this->survey->getReentryMode() == MODE_REENTRY_NO || $this->state->getVersion() != getSurveyVersion()) {
                                     $this->setFillTexts(array());
                                     /* indicate to redo any fills */
                                     $this->setRedoFills(true);
                                 }
                                 // not redoing anything
                                 if ($action == REENTRY_SAME_SCREEN) {
                                     $this->showQuestion($variablenames, $rgid, $groupname);
                                     doExit();
                                 } else {
                                     // in group, then we redo
                                     if ($groupname != "") {
                                         /* indicate update action */
                                         $this->updateaction = true;
                                         /* clear inline fields and sub displays */
                                         $this->setInlineFields(array());
                                         $this->setSubDisplays(array());
                                         /* clear any assignments part of the action */
                                         $this->removeAssignmentsAfterRgid($rgid);
                                         /* re-do action */
                                         $this->doAction($rgid);
                                         /* save data record */
                                         $this->getDataRecord()->saveRecord();
                                         /* we finished everything and are showing a question if all went well 
                                          * so this is the moment to update the state
                                          */
                                         $this->saveState(false);
                                         /* stop */
                                         return;
                                     }
                                 }
                             } else {
                                 $torgid = 0;
                                 $result = $db->selectQuery('select torgid from ' . Config::dbSurvey() . '_next where suid=' . prepareDatabaseString($this->getSuid()) . ' and seid=' . prepareDatabaseString($this->seid) . ' and fromrgid = ' . prepareDatabaseString($rgid));
                                 if ($row = $db->getRow($result)) {
                                     $torgid = $row["torgid"];
                                 }
                                 /* indicate we are going forward */
                                 $this->setForward(true);
                                 /* log action */
                                 $this->currentaction = ACTION_EXIT_NEXT;
                                 $this->logAction($rgid, ACTION_EXIT_NEXT);
                                 // action to do
                                 if ($torgid > 0) {
                                     /* reset any assignments */
                                     $this->setAssignments(array());
                                     /* reset inline fields */
                                     $this->setInlineFields(array());
                                     /* reset sub displays */
                                     $this->setSubDisplays(array());
                                     /* reset fill texts */
                                     $this->setFillTexts(array());
                                     /* do action */
                                     $this->doAction($torgid);
                                     /* we finished everything and are showing a question if 
                                      * all went well so this is the moment to save the state
                                      */
                                     if ($this->endofsurvey == false) {
                                         /* save data record */
                                         $this->getDataRecord()->saveRecord();
                                         $this->saveState();
                                     }
                                 } else {
                                     /* do end */
                                     $this->doEnd(true);
                                 }
                             }
                         }
                     }
                 }
                 /* stop */
                 doExit();
             }
         } else {
             $this->currentaction = ACTION_SURVEY_ENTRY;
             /* store basic fields */
             $this->setAnswer(VARIABLE_PRIMKEY, $this->primkey);
             $this->setAnswer(VARIABLE_BEGIN, date("Y-m-d H:i:s", time()));
             $this->setAnswer(VARIABLE_LANGUAGE, $language);
             $this->setAnswer(VARIABLE_VERSION, getSurveyVersion());
             $this->setAnswer(VARIABLE_MODE, getSurveyMode());
             $this->setAnswer(VARIABLE_PLATFORM, $_SERVER['HTTP_USER_AGENT']);
             $this->setAnswer(VARIABLE_EXECUTION_MODE, getSurveyExecutionMode());
             $this->setAnswer(VARIABLE_TEMPLATE, getSurveyTemplate());
             /* preload */
             $pd = loadvarSurvey('pd');
             if ($pd != '') {
                 getSessionParamsPost(loadvarSurvey('pd'), 'PD');
                 foreach ($_SESSION['PD'] as $field => $answer) {
                     //echo $field . ' set with ' . $answer . '<br/>';
                     $this->setAnswer($field, $answer);
                 }
             }
             /* save data record */
             $this->getDataRecord()->saveRecord();
             /* do first action */
             $this->doAction($this->getFirstAction());
             /* we finished everything and are showing a question if 
              * went well so this is the moment to save the state
              */
             $this->saveState();
             if ($this->getFlooding()) {
                 if ($this->stop != true) {
                     $this->doFakeSubmit($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
                     $this->getNextQuestion();
                 }
             }
             /* stop */
             $this->stop = true;
             return;
         }
     } else {
         /* get the rgid */
         $lastrgid = getFromSessionParams(SESSION_PARAM_RGID);
         //echo 'dsdsdsdsdsdsd' . $lastrgid . '----' . $this->getPreviousRgid();
         /* check if rgid matches the one from the state AND no posted navigation
          * if not, then this is a browser resubmit
          */
         if ($lastrgid != $this->getPreviousRgid() && !isset($_POST['navigation'])) {
             /* show last question(s) and stop */
             $this->showQuestion($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
             doExit();
         }
         /* handle timings */
         $this->addTimings($lastrgid, $this->getStateId());
         /* get query display object for button labels */
         //echo getFromSessionParams(SESSION_PARAM_VARIABLES) . '====';
         $vars = splitString("/~/", getFromSessionParams(SESSION_PARAM_VARIABLES));
         $dkrfnacheck = false;
         $queryobject = null;
         $screendumps = false;
         $paradata = false;
         if (sizeof($vars) == 1) {
             $var = $this->getVariableDescriptive($vars[0]);
             $queryobject = $var;
             $backlabel = $var->getLabelBackButton();
             $updatelabel = $var->getLabelUpdateButton();
             $nextlabel = $var->getLabelNextButton();
             $dklabel = $var->getLabelDKButton();
             $rflabel = $var->getLabelRFButton();
             $nalabel = $var->getLabelNAButton();
             $remarks = $var->getShowRemarkButton();
             $dkrfnacheck = $var->isIndividualDKRFNA();
             $screendumps = $var->isScreendumpStorage();
             $paradata = $var->isParadata();
         } else {
             $group = $this->getGroup(getFromSessionParams(SESSION_PARAM_GROUP));
             $queryobject = $group;
             $backlabel = $group->getLabelBackButton();
             $updatelabel = $group->getLabelUpdateButton();
             $nextlabel = $group->getLabelNextButton();
             $dklabel = $group->getLabelDKButton();
             $rflabel = $group->getLabelRFButton();
             $nalabel = $group->getLabelNAButton();
             $remarks = $group->getShowRemarkButton();
             $dkrfnacheck = $group->isIndividualDKRFNA();
             $screendumps = $group->isScreendumpStorage();
             $paradata = $group->isParadata();
         }
         /* handle screenshot */
         if ($screendumps == true) {
             $this->addScreenshot();
         }
         /* handle paradata */
         if ($paradata == true) {
             $this->addParadata($lastrgid);
         }
         /* handle action */
         // back
         if (isset($_POST['navigation']) && $_POST['navigation'] == $backlabel) {
             $this->currentaction = ACTION_EXIT_BACK;
             /* update remark status from clean to dirty */
             if ($remarks == BUTTON_YES && loadvarSurvey(POST_PARAM_REMARK_INDICATOR) == 1) {
                 $this->updateRemarkStatus(DATA_DIRTY);
             }
             $this->doBackState($lastrgid, $dkrfnacheck);
             $cnt = 0;
             $currentseid = $this->getSeid();
             // this was a section call, so we need to go back one more state
             while ($this->getDisplayed() == "") {
                 $this->setSeid($this->getParentSeid());
                 $this->setPrefix($this->getParentPrefix());
                 $this->doBackState($this->getRgid(), $dkrfnacheck, false);
                 // dont save answers again!
                 $cnt++;
                 if ($cnt > 100) {
                     break;
                 }
             }
             /* if (language different from state AND update) OR (mode different from state AND update) OR (version different from state), then wipe fill texts */
             $redo = false;
             if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getBackLanguage() == LANGUAGE_BACK_YES || $this->state->getMode() != getSurveyMode() && $this->survey->getBackMode() == MODE_BACK_YES || $this->state->getVersion() != getSurveyVersion()) {
                 $this->setFillTexts(array());
                 /* indicate to redo any fills */
                 $this->setRedoFills(true);
                 $redo = true;
             }
             /* if language different, but keeping from state, then update language */
             if ($this->state->getLanguage() != getSurveyLanguage() && $this->survey->getBackLanguage() != LANGUAGE_BACK_YES) {
                 setSurveyLanguage($this->state->getLanguage());
             }
             if ($this->state->getMode() != getSurveyMode() && $this->survey->getBackMode() != MODE_BACK_YES) {
                 setSurveyMode($this->state->getMode());
             }
             if ($this->state->getVersion() != getSurveyVersion()) {
                 setSurveyVersion($this->state->getVersion());
             }
             /* check for on submit function */
             $onsubmit = $queryobject->getOnBack();
             $tocall = $this->replaceFills($onsubmit);
             $parameters = array();
             if (stripos($tocall, '(') !== false) {
                 $parameters = rtrim(substr($tocall, stripos($tocall, '(') + 1), ')');
                 $parameters = preg_split("/[\\s,]+/", $parameters);
                 $tocall = substr($tocall, 0, stripos($tocall, '('));
             }
             if (function_exists($tocall)) {
                 try {
                     $f = new ReflectionFunction($tocall);
                     $returnStr .= $f->invoke($parameters);
                 } catch (Exception $e) {
                 }
             }
             /* no need to reset inline fields array in state --> they are based on the routing
              * if we went back after a language change, then any routing related change resulting from
              * that are not effectuated until after going forward again.
              */
             /* show previous question(s) from the stored state */
             if ($this->getRgid() != "") {
                 // no language/mode/version change, so no need to redo anything
                 if ($redo == false) {
                     $this->showQuestion($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
                 } else {
                     /* we have a rgid */
                     if ($this->getRgid() > 0) {
                         //$this->updateaction = true;
                         // we are going back to different section, so we need to load another engine
                         if ($currentseid != $this->getSeid()) {
                             global $engine;
                             $engine = loadEngine($this->getSuid(), $this->primkey, $this->phpid, $this->version, $this->getSeid(), false, true);
                             /* set state as current state */
                             $engine->setState($this->state);
                             /* update state properties */
                             $engine->setSeid($this->getSeid());
                             $engine->setMainSeid($this->getMainSeid());
                             $engine->setPrefix($this->getPrefix());
                             $engine->setParentSeid($this->getParentSeid());
                             $engine->setParentRgid($this->getParentRgid());
                             $engine->setParentPrefix($this->getParentPrefix());
                             $engine->setForward($this->getForward());
                             $engine->setFlooding($this->getFlooding());
                             // do the action in the correct engine
                             $engine->doAction($this->getRgid());
                             // stop
                             return;
                         } else {
                             $this->doAction($this->getRgid());
                             /* we finished everything and are showing a question if all went well 
                              * so this is the moment to update the state
                              */
                             $this->saveState(false);
                         }
                     } else {
                         $this->showQuestion($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
                     }
                 }
             } else {
                 // this should not happen
                 $this->showQuestion(VARIABLE_INTRODUCTION, "");
                 //echo Language::messageSurveyStart();
             }
             /* save data record */
             $this->getDataRecord()->saveRecord();
             /* stop */
             return;
         } else {
             if (isset($_POST['navigation']) && ($_POST['navigation'] == $updatelabel || $_POST['navigation'] == NAVIGATION_LANGUAGE_CHANGE || $_POST['navigation'] == NAVIGATION_MODE_CHANGE || $_POST['navigation'] == PROGRAMMATIC_UPDATE)) {
                 $torgid = getFromSessionParams(SESSION_PARAM_RGID);
                 /* log action */
                 if ($_POST['navigation'] == $updatelabel) {
                     $this->currentaction = ACTION_EXIT_UPDATE;
                     $this->logAction($lastrgid, ACTION_EXIT_UPDATE);
                 } else {
                     if ($_POST['navigation'] == NAVIGATION_LANGUAGE_CHANGE) {
                         $this->currentaction = ACTION_EXIT_LANGUAGE_CHANGE;
                         $this->logAction($lastrgid, ACTION_EXIT_LANGUAGE_CHANGE);
                         $this->setAnswer(VARIABLE_LANGUAGE, getSurveyLanguage());
                     } else {
                         if ($_POST['navigation'] == NAVIGATION_MODE_CHANGE) {
                             $this->currentaction = ACTION_EXIT_MODE_CHANGE;
                             $this->logAction($lastrgid, ACTION_EXIT_MODE_CHANGE);
                             $this->setAnswer(VARIABLE_MODE, getSurveyMode());
                         } else {
                             if ($_POST['navigation'] == NAVIGATION_VERSION_CHANGE) {
                                 $this->currentaction = ACTION_EXIT_VERSION_CHANGE;
                                 $this->logAction($lastrgid, ACTION_EXIT_VERSION_CHANGE);
                                 $this->setAnswer(VARIABLE_VERSION, getSurveyVersion());
                             } else {
                                 if ($_POST['navigation'] == PROGRAMMATIC_UPDATE) {
                                     $this->currentaction = ACTION_EXIT_PROGRAMMATIC_UPDATE;
                                     $this->logAction($lastrgid, ACTION_EXIT_PROGRAMMATIC_UPDATE);
                                 }
                             }
                         }
                     }
                 }
                 /* store answers in db and previous state */
                 $cnt = 1;
                 foreach ($vars as $var) {
                     $vd = $this->getVariableDescriptive($var);
                     if ($vd->getAnswerType() == ANSWER_TYPE_SETOFENUMERATED) {
                         $answer = "";
                         if ($dkrfnacheck == true) {
                             /* dk/rf/na */
                             $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt . "_dkrfna");
                             if (!inArray($answer, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
                                 $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                             }
                         } else {
                             $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                         }
                         if (is_array($answer)) {
                             $answer = implode(SEPARATOR_SETOFENUMERATED, $answer);
                         }
                         $this->setAnswer($var, $answer, DATA_DIRTY);
                     } else {
                         if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                             $answer = "";
                             if ($dkrfnacheck == true) {
                                 /* dk/rf/na */
                                 $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt . "_dkrfna");
                                 if (!inArray($answer, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
                                     $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                 }
                             } else {
                                 $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                             }
                             $this->setAnswer($var, $answer, DATA_DIRTY);
                         }
                     }
                     $cnt++;
                 }
                 /* if update button OR language OR mode OR version now different from state, then wipe fill texts */
                 if ($this->currentaction == ACTION_EXIT_UPDATE || $_POST['navigation'] == NAVIGATION_LANGUAGE_CHANGE && $this->state->getLanguage() != getSurveyLanguage() || $_POST['navigation'] == NAVIGATION_MODE_CHANGE && $this->state->getMode() != getSurveyMode() || $_POST['navigation'] == NAVIGATION_VERSION_CHANGE && $this->state->getVersion() != getSurveyVersion()) {
                     $this->setFillTexts(array());
                     /* indicate to redo any fills */
                     $this->setRedoFills(true);
                 }
                 /* indicate update action */
                 $this->updateaction = true;
                 /* clear inline fields and sub displays */
                 $this->setInlineFields(array());
                 $this->setSubDisplays(array());
                 /* update remark status to clean */
                 if ($remarks == BUTTON_YES && loadvarSurvey(POST_PARAM_REMARK_INDICATOR) == 1) {
                     $this->updateRemarkStatus(DATA_DIRTY);
                 }
                 /* check for on submit function */
                 $onsubmit = "";
                 if ($_POST['navigation'] == $updatelabel) {
                     $onsubmit = $queryobject->getOnUpdate();
                 } else {
                     if ($_POST['navigation'] == NAVIGATION_LANGUAGE_CHANGE) {
                         $onsubmit = $queryobject->getOnLanguageChange();
                     } else {
                         if ($_POST['navigation'] == NAVIGATION_MODE_CHANGE) {
                             $onsubmit = $queryobject->getOnModeChange();
                         } else {
                             if ($_POST['navigation'] == NAVIGATION_VERSION_CHANGE) {
                                 $onsubmit = $queryobject->getOnVersionChange();
                             }
                         }
                     }
                 }
                 $tocall = $this->replaceFills($onsubmit);
                 $parameters = array();
                 if (stripos($tocall, '(') !== false) {
                     $parameters = rtrim(substr($tocall, stripos($tocall, '(') + 1), ')');
                     $parameters = preg_split("/[\\s,]+/", $parameters);
                     $tocall = substr($tocall, 0, stripos($tocall, '('));
                 }
                 if (function_exists($tocall)) {
                     try {
                         $f = new ReflectionFunction($tocall);
                         $returnStr .= $f->invoke($parameters);
                     } catch (Exception $e) {
                     }
                 }
                 /* re-do action */
                 $this->doAction($this->getRgid());
                 /* save data record */
                 $this->getDataRecord()->saveRecord();
                 /* we finished everything and are showing a question if all went well 
                  * so this is the moment to update the state
                  */
                 $this->saveState(false);
                 /* stop */
                 return;
             } else {
                 if (isset($_POST['navigation']) && inArray($_POST['navigation'], array($nextlabel, $dklabel, $rflabel, $nalabel))) {
                     $torgid = 0;
                     $result = $db->selectQuery('select torgid from ' . Config::dbSurvey() . '_next where suid=' . prepareDatabaseString($this->getSuid()) . ' and seid=' . prepareDatabaseString($this->seid) . ' and fromrgid = ' . prepareDatabaseString($lastrgid));
                     //echo 'select * from ' . Config::dbSurvey() . '_next where suid=' . prepareDatabaseString($this->getSuid()) . ' and seid=' . prepareDatabaseString($this->seid) . ' and fromrgid = ' . prepareDatabaseString($lastrgid);
                     if ($row = $db->getRow($result)) {
                         $torgid = $row["torgid"];
                     }
                     /* indicate we are going forward */
                     $this->setForward(true);
                     /* log action */
                     if ($_POST['navigation'] == $nextlabel) {
                         $this->currentaction = ACTION_EXIT_NEXT;
                         $this->logAction($lastrgid, ACTION_EXIT_NEXT);
                     } else {
                         if ($_POST['navigation'] == $dklabel) {
                             $this->currentaction = ACTION_EXIT_DK;
                             $this->logAction($lastrgid, ACTION_EXIT_DK);
                         } else {
                             if ($_POST['navigation'] == $rflabel) {
                                 $this->currentaction = ACTION_EXIT_RF;
                                 $this->logAction($lastrgid, ACTION_EXIT_RF);
                             } else {
                                 if ($_POST['navigation'] == $nalabel) {
                                     $this->currentaction = ACTION_EXIT_NA;
                                     $this->logAction($lastrgid, ACTION_EXIT_NA);
                                 }
                             }
                         }
                     }
                     /* store answers in db and previous state */
                     $cnt = 1;
                     //echo $torgid . '---';
                     foreach ($vars as $var) {
                         //echo 'answer for ' . $var . ' at ' . $cnt . ' is: ' .  loadvar("answer" . $cnt) . '---<br/>';
                         // next button
                         if ($_POST['navigation'] == $nextlabel) {
                             $vd = $this->getVariableDescriptive($var);
                             if ($vd->getAnswerType() == ANSWER_TYPE_SETOFENUMERATED || $vd->getAnswerType() == ANSWER_TYPE_MULTIDROPDOWN) {
                                 $answer = "";
                                 if ($dkrfnacheck == true) {
                                     /* dk/rf/na */
                                     $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt . "_dkrfna");
                                     if (!inArray($answer, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
                                         $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                     }
                                 } else {
                                     $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                 }
                                 if (is_array($answer)) {
                                     $answer = implode(SEPARATOR_SETOFENUMERATED, $answer);
                                 }
                                 $this->setAnswer($var, $answer, DATA_CLEAN);
                             } else {
                                 if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                                     $answer = "";
                                     if ($dkrfnacheck == true) {
                                         /* dk/rf/na */
                                         $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt . "_dkrfna");
                                         if (!inArray($answer, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
                                             $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                         }
                                     } else {
                                         $answer = loadvarSurvey(SESSION_PARAMS_ANSWER . $cnt);
                                     }
                                     $this->setAnswer($var, $answer, DATA_CLEAN);
                                 }
                             }
                         } else {
                             if ($_POST['navigation'] == $dklabel) {
                                 $vd = $this->getVariableDescriptive($var);
                                 if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                                     $this->setAnswer($var, ANSWER_DK, DATA_CLEAN);
                                 }
                             } else {
                                 if ($_POST['navigation'] == $rflabel) {
                                     $vd = $this->getVariableDescriptive($var);
                                     if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                                         $this->setAnswer($var, ANSWER_RF, DATA_CLEAN);
                                     }
                                 } else {
                                     if ($_POST['navigation'] == $nalabel) {
                                         $vd = $this->getVariableDescriptive($var);
                                         if ($vd->getAnswerType() != ANSWER_TYPE_NONE) {
                                             $this->setAnswer($var, ANSWER_NA, DATA_CLEAN);
                                         }
                                     }
                                 }
                             }
                         }
                         $cnt++;
                     }
                     /* update remark status to clean */
                     if ($remarks == BUTTON_YES && loadvarSurvey(POST_PARAM_REMARK_INDICATOR) == 1) {
                         $this->updateRemarkStatus(DATA_CLEAN);
                     }
                     $onsubmit = "";
                     if ($_POST['navigation'] == $nextlabel) {
                         $onsubmit = $queryobject->getOnNext();
                     } else {
                         if ($_POST['navigation'] == $dklabel) {
                             $onsubmit = $queryobject->getOnDK();
                         } else {
                             if ($_POST['navigation'] == $rflabel) {
                                 $onsubmit = $queryobject->getOnRF();
                             } else {
                                 if ($_POST['navigation'] == $nalabel) {
                                     $onsubmit = $queryobject->getOnNA();
                                 }
                             }
                         }
                     }
                     $tocall = $this->replaceFills($onsubmit);
                     $parameters = array();
                     if (stripos($tocall, '(') !== false) {
                         $parameters = rtrim(substr($tocall, stripos($tocall, '(') + 1), ')');
                         $parameters = preg_split("/[\\s,]+/", $parameters);
                         $tocall = substr($tocall, 0, stripos($tocall, '('));
                     }
                     if (function_exists($tocall)) {
                         try {
                             $f = new ReflectionFunction($tocall);
                             $returnStr .= $f->invoke($parameters);
                         } catch (Exception $e) {
                         }
                     }
                     // action to do
                     if ($torgid > 0) {
                         /* reset any assignments */
                         $this->setAssignments(array());
                         /* reset inline fields */
                         $this->setInlineFields(array());
                         /* reset sub displays */
                         $this->setSubDisplays(array());
                         /* reset fill texts */
                         $this->setFillTexts(array());
                         /* do action */
                         $this->doAction($torgid);
                         /* we finished everything and are showing a question if 
                          * went well so this is the moment to save the state
                          */
                         if ($this->endofsurvey == false) {
                             if ($this->getFlooding()) {
                                 if ($this->stop != true) {
                                     $this->getDataRecord()->saveRecord();
                                     $this->saveState();
                                 }
                             } else {
                                 /* save data record */
                                 $this->getDataRecord()->saveRecord();
                                 $this->saveState();
                             }
                         }
                     } else {
                         /* not end of survey, then clear any assignments and so on */
                         if ($this->isMainSection() == false) {
                             /* reset any assignments */
                             $this->setAssignments(array());
                             /* reset inline fields */
                             $this->setInlineFields(array());
                             /* reset sub displays */
                             $this->setSubDisplays(array());
                             /* reset fill texts */
                             $this->setFillTexts(array());
                         }
                         /* do end */
                         $this->doEnd(true);
                     }
                     /* stop */
                     if ($this->getFlooding()) {
                         if ($this->stop != true) {
                             $this->doFakeSubmit($this->getDisplayed(), $this->getRgid(), $this->getTemplate());
                             $this->getNextQuestion();
                         }
                         $this->stop = true;
                         return;
                     }
                     doExit();
                 }
             }
         }
     }
 }
 function showTranslateGroupAssistance($group)
 {
     $returnStr = '<form id="editform" method="post">';
     $returnStr .= setSessionParamsPost(array('page' => 'translator.survey.translategroupassistanceres', 'gid' => $group->getGid()));
     $returnStr .= $this->getGroupTopTab(3);
     $returnStr .= '<div class="well" style="background-color:white;">';
     $helpstart = '<div class="input-group">';
     $message = Language::helpFollowSurvey();
     $survey = new Survey($_SESSION['SUID']);
     $language = getSurveyLanguage();
     $returnStr .= "<div id='accordion' class='panel-group' role='tablist' aria-expanded='true'>";
     $l = $survey->getDefaultLanguage(getSurveyMode());
     $arr = Language::getLanguagesArray();
     $helpend = '<span class="input-group-addon"><i>' . $message . '</i></span></div>';
     if ($l != $language) {
         switchSurveyLanguageTranslator($l);
         $langlabel = $arr[str_replace("_", "", getSurveyLanguagePostFix($l))]['name'];
         $returnStr .= "<div class='panel panel-default'>";
         $returnStr .= "<div class='panel panel-heading' role='tab' id='headingOne'>";
         $returnStr .= '<a role="button" data-toggle="collapse" aria-expanded="true" aria-controls="collapseOne" href="#collapseOne">' . $langlabel . '</a>';
         $returnStr .= "</div>";
         $returnStr .= '<div class="panel-collapse collapse in" id="collapseOne" role="tabpanel" labelledby="headingOne">';
         $returnStr .= "<div class='panel-body'>";
         $returnStr .= '<table width=100%>';
         $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceExclusive() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" readonly rows=2 class="form-control">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageExclusive(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
         $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceInclusive() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" readonly rows=2 class="form-control">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageInclusive(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
         $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceMinimumRequired() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" readonly rows=2 class="form-control">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageMinimumRequired(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
         $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceMaximumRequired() . '</td><td>' . $helpstart . '<textarea style="width: 100%;;" readonly rows=2 class="form-control">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageMaximumRequired(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
         $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceExactRequired() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" readonly rows=2 class="form-control">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageExactRequired(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
         $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceUniqueRequired() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" readonly rows=2 class="form-control">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageUniqueRequired(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
         $returnStr .= '</table></div></div></div>';
         switchSurveyLanguageTranslator($language);
     }
     $langlabel = $arr[str_replace("_", "", getSurveyLanguagePostFix($language))]['name'];
     $returnStr .= "<div class='panel panel-default'>";
     $returnStr .= "<div class='panel panel-heading' role='tab' id='headingTwo'>";
     $returnStr .= '<a role="button" data-toggle="collapse" aria-expanded="true" aria-controls="collapseTwo" href="#collapseTwo">' . $langlabel . '</a>';
     $returnStr .= "</div>";
     $returnStr .= '<div class="panel-collapse collapse in" id="collapseTwo" role="tabpanel" labelledby="headingTwo">';
     $returnStr .= "<div class='panel-body'>";
     $returnStr .= '<table width=100%>';
     $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceExclusive() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" rows=2 class="form-control" name="' . SETTING_ERROR_MESSAGE_EXCLUSIVE . '">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageExclusive(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
     $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceInclusive() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" rows=2 class="form-control" name="' . SETTING_ERROR_MESSAGE_INCLUSIVE . '">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageInclusive(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
     $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceMinimumRequired() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" rows=2 class="form-control" name="' . SETTING_ERROR_MESSAGE_MINIMUM_REQUIRED . '">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageMinimumRequired(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
     $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceMaximumRequired() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" rows=2 class="form-control" name="' . SETTING_ERROR_MESSAGE_MAXIMUM_REQUIRED . '">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageMaximumRequired(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
     $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceExactRequired() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" rows=2 class="form-control" name="' . SETTING_ERROR_MESSAGE_EXACT_REQUIRED . '">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageExactRequired(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
     $returnStr .= '<tr><td valign=top style="width: 15%;">' . Language::labelGroupEditAssistanceUniqueRequired() . '</td><td>' . $helpstart . '<textarea style="width: 100%;" rows=2 class="form-control" name="' . SETTING_ERROR_MESSAGE_UNIQUE_REQUIRED . '">' . $this->displayTextSettingValue(convertHTLMEntities($group->getErrorMessageUniqueRequired(), ENT_QUOTES)) . '</textarea>' . $helpend . '</td></tr>';
     $returnStr .= '</table></div></div></div></div></div>';
     $survey = new Survey($_SESSION['SUID']);
     $user = new User($_SESSION['URID']);
     $langs = explode("~", $user->getLanguages(getSurvey(), getSurveyMode()));
     if (getSurveyLanguage() != $survey->getDefaultLanguage(getSurveyMode())) {
         $returnStr .= '<input type="submit" class="btn btn-default" value="' . Language::buttonTranslate() . '"/>';
     } else {
         if (inArray(getSurveyLanguage(), $langs)) {
             $returnStr .= '<input type="submit" class="btn btn-default" value="' . Language::buttonEdit() . '"/>';
         }
     }
     $returnStr .= '</form>';
     return $returnStr;
 }
Example #4
0
 function showAnswer($number, $variable, $var, $previousdata, $inline = false, $enumid = "")
 {
     //echo '<br/>showing: ' . $variable;
     /* if inline field, then don't show it UNLESS it is inline display */
     if ($this->engine->isInlineField($variable) && $inline == false) {
         return "";
     }
     $inlineclass = "";
     $hovertext = $this->engine->getFill($variable, $var, SETTING_HOVERTEXT);
     if ($hovertext != "") {
         $returnStr = "<div title='" . str_replace("'", "", $hovertext) . "' class='uscic-answer'>";
     } else {
         $returnStr = "<div class='uscic-answer'>";
     }
     if ($inline) {
         $inlineclass = "-inline";
         $returnStr = "";
     }
     $language = getSurveyLanguage();
     $varname = SESSION_PARAMS_ANSWER . $number;
     $id = $this->engine->getFill($variable, $var, SETTING_ID);
     if (trim($id) == "") {
         $id = $varname;
     }
     $answertype = $var->getAnswerType();
     if (inArray($answertype, array(ANSWER_TYPE_SETOFENUMERATED, ANSWER_TYPE_MULTIDROPDOWN))) {
         $varname .= "[]";
     }
     /* add required error check */
     if ($var->getIfEmpty() != IF_EMPTY_ALLOW) {
         /* if not inline OR inline but not in enumerated/set of enumerated */
         if ($inline == false || $inline == true && trim($enumid) == "") {
             if (inArray($var->getAnswerType(), array(ANSWER_TYPE_SETOFENUMERATED))) {
                 // custom name for set of enumerated question, since we use a hidden field/textbox to track the real answer(s); we just use this custom name for referencing in the error checking
                 $this->addErrorCheck(SESSION_PARAMS_ANSWER . $number . "_name[]", new ErrorCheck(ERROR_CHECK_REQUIRED, "true"), $this->engine->getFill($variable, $var, SETTING_EMPTY_MESSAGE));
             } else {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_REQUIRED, "true"), $this->engine->getFill($variable, $var, SETTING_EMPTY_MESSAGE));
             }
         }
     }
     $align = $var->getAnswerAlignment();
     $qa = "";
     switch ($align) {
         case ALIGN_LEFT:
             $qa = "text-left";
             break;
         case ALIGN_RIGHT:
             $qa = "text-right";
             break;
         case ALIGN_JUSTIFIED:
             $qa = "text-justify";
             break;
         case ALIGN_CENTER:
             $qa = "text-center";
             break;
         default:
             break;
     }
     /* hide dk/rf/na */
     if (inArray($previousdata, array(ANSWER_DK, ANSWER_RF, ANSWER_NA))) {
         $previousdata = "";
     }
     $pretext = "";
     $posttext = "";
     $inputgroupstart = '';
     $inputgroupend = "";
     if (inArray($answertype, array(ANSWER_TYPE_STRING, ANSWER_TYPE_INTEGER, ANSWER_TYPE_RANGE, ANSWER_TYPE_DOUBLE))) {
         $pretext = $this->engine->getFill($variable, $var, SETTING_PRETEXT);
         $posttext = $this->engine->getFill($variable, $var, SETTING_POSTTEXT);
         $answerformat = "";
         if ($pretext != "") {
             $answerformat = $var->getAnswerFormatting();
             $pretext = '<span id="vsid_' . $var->getVsid() . '" uscic-texttype="' . SETTING_PRETEXT . '" class="input-group-addon uscic-inputaddon-pretext' . $this->inlineeditable . '">' . $this->applyFormatting($pretext, $answerformat) . '</span>';
             $inputgroupstart = '<div class="input-group uscic-inputgroup-pretext">';
             $inputgroupend = "</div>";
         }
         if ($posttext != "") {
             if ($answerformat == "") {
                 $answerformat = $var->getAnswerFormatting();
             }
             $posttext = '<div id="vsid_' . $var->getVsid() . '" uscic-texttype="' . SETTING_POSTTEXT . '" class="input-group-addon uscic-inputaddon-posttext' . $this->inlineeditable . '">' . $this->applyFormatting($posttext, $answerformat) . '</div>';
             $inputgroupstart = '<div class="input-group uscic-inputgroup-posttext">';
             $inputgroupend = "</div>";
         }
     }
     $inlinejavascript = $this->engine->getFill($variable, $var, SETTING_JAVASCRIPT_WITHIN_ELEMENT);
     $inlinestyle = $this->engine->getFill($variable, $var, SETTING_STYLE_WITHIN_ELEMENT);
     $placeholder = $this->engine->getFill($variable, $var, SETTING_PLACEHOLDER);
     if (trim($placeholder) != "") {
         $placeholder = " placeholder='" . $placeholder . "' ";
     }
     $linkedto = "";
     if ($inline == true && trim($enumid) != "") {
         $linkedto = ' linkedto="' . $enumid . '" ';
     }
     /* add any comparison checks */
     $this->addComparisonChecks($var, $variable, $varname);
     /* any individual dk/rf/na */
     $dkrfna = $this->addDKRFNAButton($varname, $var, $variable, $inline, $enumid);
     $dkrfnaclass = "";
     if ($dkrfna != "") {
         if ($this->engine->isDKAnswer($variable)) {
             $dkrfnaclass = "dkrfna";
         } else {
             if ($this->engine->isRFAnswer($variable)) {
                 $dkrfnaclass = "dkrfna";
             } else {
                 if ($this->engine->isNAAnswer($variable)) {
                     $dkrfnaclass = "dkrfna";
                 }
             }
         }
     }
     /* add answer display */
     switch ($answertype) {
         case ANSWER_TYPE_STRING:
             //string
             $minimumlength = $this->engine->getFill($variable, $var, SETTING_MINIMUM_LENGTH);
             $maximumlength = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_LENGTH);
             if ($minimumlength > 0) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MINLENGTH, $minimumlength), replacePlaceHolders(array(PLACEHOLDER_MINIMUM_LENGTH => $minimumlength), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MINIMUM_LENGTH)));
             }
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MAXLENGTH, $maximumlength), replacePlaceHolders(array(PLACEHOLDER_MAXIMUM_LENGTH => $maximumlength), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MAXIMUM_LENGTH)));
             $minwords = $this->engine->getFill($variable, $var, SETTING_MINIMUM_WORDS);
             $maxwords = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_WORDS);
             if ($minwords > 0) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MINWORDS, $minwords), replacePlaceHolders(array(PLACEHOLDER_MINIMUM_WORDS => $minwords), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MINIMUM_WORDS)));
             }
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MAXWORDS, $maxwords), replacePlaceHolders(array(PLACEHOLDER_MAXIMUM_WORDS => $maxwords), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MAXIMUM_WORDS)));
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             // placeholder: , "placeholder": "*"
             $pattern = $this->engine->getFill($variable, $var, SETTING_PATTERN);
             if (trim($pattern) != "") {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_PATTERN, $pattern), replacePlaceHolders(array(PLACEHOLDER_PATTERN => $pattern), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_PATTERN)));
             }
             if ($inline) {
                 $returnStr .= '<label>
                             <div class="uscic-string ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input class="form-control uscic-form-control-inline ' . $dkrfnaclass . '" spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $linkedto . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="uscic-string' . $inlineclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label>';
             } else {
                 $returnStr .= $this->displayZipScripts();
                 $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <label>
                                 <div class="uscic-string ' . $qa . '">' . $inputgroupstart . $pretext . '                                    
                                 <input spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                     ' . $posttext . $inputgroupend . $dkrfna . '
                                 </div>    
                             </label>                                
                             </div>
                             ';
             }
             break;
         case ANSWER_TYPE_ENUMERATED:
             //enumerated
             $dis = $var->getEnumeratedDisplay();
             if ($dis == ORIENTATION_HORIZONTAL) {
                 $returnStr .= $this->showEnumeratedHorizontal($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
             } else {
                 if ($dis == ORIENTATION_VERTICAL) {
                     $returnStr .= $this->showEnumeratedVertical($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
                 } else {
                     $returnStr .= $this->showEnumeratedCustom($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
                 }
             }
             break;
         case ANSWER_TYPE_SETOFENUMERATED:
             //set of enumerated
             $dis = $var->getEnumeratedDisplay();
             if ($dis == ORIENTATION_HORIZONTAL) {
                 $returnStr .= $this->showsetOfEnumeratedHorizontal($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
             } else {
                 if ($dis == ORIENTATION_VERTICAL) {
                     $returnStr .= $this->showSetOfEnumeratedVertical($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
                 } else {
                     $returnStr .= $this->showSetOfEnumeratedCustom($id, $varname, $variable, $var, $previousdata, $inlineclass, $inlinestyle, $inlinejavascript);
                 }
             }
             break;
         case ANSWER_TYPE_DROPDOWN:
             //drop down
             $options = $this->engine->getFill($variable, $var, SETTING_OPTIONS);
             $returnStr .= $this->showComboBox($variable, $var, $varname, $id, $options, $previousdata, $inline, "", $linkedto);
             break;
         case ANSWER_TYPE_MULTIDROPDOWN:
             //multiple selection dropdown
             $this->addSetOfEnumeratedChecks($varname, $variable, $var, ANSWER_TYPE_MULTIDROPDOWN);
             $options = $this->engine->getFill($variable, $var, SETTING_OPTIONS);
             $returnStr .= $this->showComboBox($variable, $var, $varname, $id, $options, $previousdata, $inline, "multiple", $linkedto);
             break;
         case ANSWER_TYPE_INTEGER:
             //integer
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_INTEGER, "true"), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_INTEGER));
             if ($inline) {
                 $returnStr .= '<div class="form-group uscic-formgroup-inline"><label>
                             <div class="uscic-integer ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input class="form-control uscic-form-control-inline ' . $dkrfnaclass . '" spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $linkedto . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="uscic-integer' . $inlineclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label></div>';
             } else {
                 $returnStr .= '<div class="form-group uscic-formgroup">
                             <label>
                             <div class="uscic-integer ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label>
                             </div>';
             }
             break;
         case ANSWER_TYPE_DOUBLE:
             //double
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_NUMBER, "true"), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_DOUBLE));
             if ($inline) {
                 $returnStr .= '<div class="form-group uscic-formgroup-inline"><label>
                             <div class="uscic-double ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input class="form-control uscic-form-control-inline ' . $dkrfnaclass . '" spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $linkedto . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="uscic-double' . $inlineclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label></div>';
             } else {
                 $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <label>
                             <div class="uscic-double ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                             ' . $posttext . $inputgroupend . $dkrfna . '</div>
                             </label>
                             </div>';
             }
             break;
         case ANSWER_TYPE_RANGE:
             //range
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             $minimum = $this->engine->getFill($variable, $var, SETTING_MINIMUM_RANGE);
             if ($minimum == "" || !is_numeric($minimum)) {
                 $minimum = ANSWER_RANGE_MINIMUM;
             }
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_RANGE);
             if ($maximum == "" || !is_numeric($maximum)) {
                 $maximum = ANSWER_RANGE_MAXIMUM;
             }
             $others = $this->engine->getFill($variable, $var, SETTING_OTHER_RANGE);
             if (trim($others) == "") {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_RANGE, "[" . $minimum . "," . $maximum . "]"), replacePlaceHolders(array(PLACEHOLDER_MINIMUM => $minimum, PLACEHOLDER_MAXIMUM => $maximum), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_RANGE)));
             } else {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_RANGE_CUSTOM, "'" . $minimum . "," . $maximum . ";" . $others . "'"), replacePlaceHolders(array(PLACEHOLDER_MINIMUM => $minimum, PLACEHOLDER_MAXIMUM => $maximum), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_RANGE)));
             }
             if (!(contains($minimum, ".") || contains($maximum, "."))) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_INTEGER, "true"), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_INTEGER));
             }
             if ($inline) {
                 $returnStr .= '<div class="form-group uscic-formgroup-inline"><label>
                             <div class="uscic-range ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input class="form-control uscic-form-control-inline ' . $dkrfnaclass . '" spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $linkedto . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="uscic-range' . $inlineclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '
                             </div>
                             </label></div>';
             } else {
                 $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">                                
                             <label>
                             <div class="uscic-range ' . $qa . '">' . $inputgroupstart . $pretext . '
                             <input spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $textmask . ' ' . $inlinestyle . ' ' . $inlinejavascript . ' ' . $this->getErrorTextString($varname) . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" type=text id=' . $id . ' name=' . $varname . ' value="' . convertHTLMEntities($previousdata, ENT_QUOTES) . '">
                                 ' . $posttext . $inputgroupend . $dkrfna . '</div>
                             </label>
                             </div>';
             }
             break;
         case ANSWER_TYPE_SLIDER:
             //slider
             $minimum = $this->engine->getFill($variable, $var, SETTING_MINIMUM_RANGE);
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_RANGE);
             if ($minimum == "" || !is_numeric($minimum)) {
                 $minimum = ANSWER_RANGE_MINIMUM;
             }
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_RANGE);
             if ($maximum == "" || !is_numeric($maximum)) {
                 $maximum = ANSWER_RANGE_MAXIMUM;
             }
             $orientation = "horizontal";
             if ($var->getSliderOrientation() == ORIENTATION_VERTICAL) {
                 $orientation = "vertical";
             }
             $step = $this->engine->replaceFills($var->getIncrement());
             $tooltip = "show";
             if ($var->getTooltip() == TOOLTIP_NO) {
                 $tooltip = "hide";
             }
             $returnStr .= $this->displaySlider($variable, $var, $varname, $id, $previousdata, $minimum, $maximum, $this->getErrorTextString($varname), $qa, $inlineclass, $step, $tooltip, $orientation, $dkrfna, $linkedto);
             break;
         case ANSWER_TYPE_DATE:
             //date
             $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                           <div class="uscic-date' . $inlineclass . ' ' . $qa . '">
                             <label>
                             ' . $this->displayDateTimePicker($varname, $id, $previousdata, getSurveyLanguagePostFix(getSurveyLanguage()), "true", "false", Config::usFormatSurvey(), Config::secondsSurvey(), Config::minutesSurvey(), $inlineclass, $inlinestyle, $inlinejavascript, $this->engine->replaceFills($var->getDateFormat()), $this->getErrorTextString($varname), $dkrfna, $variable, $linkedto) . '
                             </label>
                             </div>
                             </div>';
             break;
         case ANSWER_TYPE_TIME:
             //time
             $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <div class="uscic-time' . $inlineclass . ' ' . $qa . '">
                             <label>
                             ' . $this->displayDateTimePicker($varname, $id, $previousdata, getSurveyLanguagePostFix(getSurveyLanguage()), "false", "true", Config::usFormatSurvey(), Config::secondsSurvey(), Config::minutesSurvey(), $inlineclass, $inlinestyle, $inlinejavascript, $this->engine->replaceFills($var->getTimeFormat()), $this->getErrorTextString($varname), $dkrfna, $variable, $linkedto) . '
                             </label>
                             </div>
                             </div>';
             break;
         case ANSWER_TYPE_DATETIME:
             //date/time
             $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <div class="uscic-datetime' . $inlineclass . ' ' . $qa . '">
                             <label>
                             ' . $this->displayDateTimePicker($varname, $id, $previousdata, getSurveyLanguagePostFix(getSurveyLanguage()), "true", "true", Config::usFormatSurvey(), Config::secondsSurvey(), Config::minutesSurvey(), $inlineclass, $inlinestyle, $inlinejavascript, $this->engine->replaceFills($var->getDateTimeFormat()), $this->getErrorTextString($varname), $dkrfna, $variable, $linkedto) . '
                             </label>
                             </div>
                             </div>';
             break;
         case ANSWER_TYPE_OPEN:
             //open
             $minimumlength = $this->engine->getFill($variable, $var, SETTING_MINIMUM_LENGTH);
             $maximumlength = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_LENGTH);
             if ($minimumlength > 0) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MINLENGTH, $minimumlength), replacePlaceHolders(array(PLACEHOLDER_MINIMUM_LENGTH => $minimumlength), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MINIMUM_LENGTH)));
             }
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MAXLENGTH, $maximumlength), replacePlaceHolders(array(PLACEHOLDER_MAXIMUM_LENGTH => $maximumlength), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MAXIMUM_LENGTH)));
             $minwords = $this->engine->getFill($variable, $var, SETTING_MINIMUM_WORDS);
             $maxwords = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_WORDS);
             if ($minwords > 0) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MINWORDS, $minwords), replacePlaceHolders(array(PLACEHOLDER_MINIMUM_WORDS => $minimumwords), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MINIMUM_WORDS)));
             }
             $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_MAXWORDS, $maxwords), replacePlaceHolders(array(PLACEHOLDER_MAXIMUM_WORDS => $maximumwords), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_MAXIMUM_WORDS)));
             $pattern = $this->engine->getFill($variable, $var, SETTING_PATTERN);
             if (trim($pattern) != "") {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_PATTERN, $pattern), replacePlaceHolders(array(PLACEHOLDER_PATTERN => $pattern), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_PATTERN)));
             }
             if ($inline) {
                 $returnStr .= '<div class="form-group uscic-formgroup-inline"><label>
                             <textarea spellcheck="false" autocorrect="off" autocapitalize="off" ' . $placeholder . $linkedto . $inlinestyle . ' ' . $inlinejavascript . ' ' . $qa . ' ' . $this->getErrorTextString($varname) . ' id=' . $id . ' class="uscic-open-inline' . $inlineclass . ' ' . $dkrfnaclass . '" name=' . $varname . '>' . convertHTLMEntities($previousdata, ENT_QUOTES) . '</textarea>' . $dkrfna . '
                             </label></div>';
             } else {
                 $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                             <label>
                             <div class="uscic-open">
                             <textarea spellcheck="false" autocorrect="off" autocapitalize="off" autocomplete="off" ' . $placeholder . $inlinestyle . ' ' . $inlinejavascript . ' ' . $qa . ' ' . $this->getErrorTextString($varname) . ' id=' . $id . ' class="form-control uscic-form-control ' . $dkrfnaclass . '" name=' . $varname . '>' . convertHTLMEntities($previousdata, ENT_QUOTES) . '</textarea>
                                 </div>' . $dkrfna . '
                             </label>                                
                             </div>';
             }
             break;
         case ANSWER_TYPE_CALENDAR:
             //calendar
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_CALENDAR);
             $returnStr .= '<div class="form-group uscic-formgroup' . $inlineclass . '">
                         <div class="uscic-calendar' . $inlineclass . '">' . $this->showCalendar($varname, $id, $previousdata, $maximum, "en", true) . '
                         <p style="display:none" id="' . $id . '_help" class="help-block">You can only select a maximum of ' . $maximum . ' days.</p>
                          </div>
                          </div>';
             break;
         case ANSWER_TYPE_CUSTOM:
             //custom
             /* input masking */
             $textmask = $this->addInputMasking($varname, $variable, $var);
             $minimum = $this->engine->getFill($variable, $var, SETTING_MINIMUM_RANGE);
             if ($minimum == "" || !is_numeric($minimum)) {
                 $minimum = ANSWER_RANGE_MINIMUM;
             }
             $maximum = $this->engine->getFill($variable, $var, SETTING_MAXIMUM_RANGE);
             if ($maximum == "" || !is_numeric($maximum)) {
                 $maximum = ANSWER_RANGE_MAXIMUM;
             }
             $others = $this->engine->getFill($variable, $var, SETTING_OTHER_RANGE);
             if (trim($others) == "") {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_RANGE, "[" . $minimum . "," . $maximum . "]"), replacePlaceHolders(array(PLACEHOLDER_MINIMUM => $minimum, PLACEHOLDER_MAXIMUM => $maximum), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_RANGE)));
             } else {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_RANGE_CUSTOM, "'" . $minimum . "," . $maximum . ";" . $others . "'"), replacePlaceHolders(array(PLACEHOLDER_MINIMUM => $minimum, PLACEHOLDER_MAXIMUM => $maximum), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_RANGE)));
             }
             if (!(contains($minimum, ".") || contains($maximum, "."))) {
                 $this->addErrorCheck($varname, new ErrorCheck(ERROR_CHECK_INTEGER, "true"), $this->engine->getFill($variable, $var, SETTING_ERROR_MESSAGE_INTEGER));
             }
             $tocall = $this->engine->getFill($variable, $var, SETTING_ANSWERTYPE_CUSTOM);
             $parameters = array();
             if (stripos($tocall, '(') !== false) {
                 $parameters = rtrim(substr($tocall, stripos($tocall, '(') + 1), ')');
                 $parameters = preg_split("/[\\s,]+/", $parameters);
                 $tocall = substr($tocall, 0, stripos($tocall, '('));
             }
             // add error string as parameter if we need it
             $parameters[] = $this->getErrorTextString($varname);
             //echo $tocall . '----';
             if (function_exists($tocall)) {
                 try {
                     $f = new ReflectionFunction($tocall);
                     $returnStr .= $f->invoke($variable, $parameters);
                 } catch (Exception $e) {
                 }
             }
     }
     if (!$inline) {
         $returnStr .= "</div>";
     }
     return $returnStr;
 }
Example #5
0
 function surveyEntry()
 {
     global $engine;
     if ($this->checkDateTime() == false) {
         /* get whatever the language is (either post or default) and use it */
         $l = getSurveyLanguage();
         if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
             require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
             // language
         } else {
             require_once 'language_en.php';
             // fall back on english language file
         }
         $login = new Login(session_id());
         return $login->getClosedScreen();
     }
     $logactions = new LogActions();
     $nosessionactions = $logactions->getNumberOfSurveyActionsBySession($this->phpid, USCIC_SURVEY);
     /* no entry yet, then ask for prim_key in login screen */
     if ($nosessionactions == 0 || loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') {
         //no entry yet: ask for prim_key!
         if (loadvarSurvey(POST_PARAM_NEW_PRIMKEY) == '1') {
             $logactions->deleteLoggedInSurveySession($this->phpid);
         }
         /* get whatever the language is (either post or default) and use it */
         $l = getSurveyLanguage();
         if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
             require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
             // language
         } else {
             require_once 'language_en.php';
             // fall back on english language file
         }
         $logactions->addAction('', '', "loginstart", USCIC_SURVEY, 1);
         $login = new Login($this->phpid);
         return $login->getLoginScreen();
     } else {
         //entry: is this person logged in?
         $loggedin = $logactions->getLoggedInSurveySession($this->phpid);
         // gets the last logged in action
         /* no prim_key assigned to this sessionid. Assign if given (and check for pwd etc??)! */
         if ($loggedin["count"] == 0) {
             /* we don't have active session, so take the template we can get */
             global $survey;
             require_once "display/templates/displayquestion_" . getSurveyTemplate() . ".php";
             // we don't have an active session, so fall back to whatever was passed along as language in post OR is the default language
             $l = getSurveyLanguage();
             if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
                 //echo 'well done';
                 require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
                 // language
             } else {
                 require_once 'language_en.php';
                 // fall back on english language file
             }
             $primkey = loadvarSurvey(POST_PARAM_PRIMKEY);
             $_SESSION['PRIMKEY'] = $primkey;
             if ($primkey != '' && strlen($primkey) < 20) {
                 // make sure primkey is not encrypted!
                 //check!!!!!!
                 $login = new Login($this->phpid);
                 if ($login->checkAccess()) {
                     $primkey = $_SESSION['PRIMKEY'];
                     $logactions->addAction($primkey, '', "loggedin", USCIC_SURVEY, 1);
                     // pass along primkey to load correct engine!
                     $engine = loadEngine(getSurvey(), $primkey, $this->phpid, getSurveyVersion(), getSurveySection(getSurvey(), $primkey));
                     $engine->setFirstForm(true);
                     return $engine->getNextQuestion();
                 } else {
                     // incorrect login..start new session
                     endSession();
                     session_start();
                     session_regenerate_id(true);
                     $logactions->addAction('', '', "loginempty", USCIC_SURVEY, 1);
                     $login = new Login(session_id());
                     global $survey;
                     return $login->getLoginScreen($survey->getLoginError());
                 }
             } else {
                 $logactions->addAction('', '', "loginempty", USCIC_SURVEY, 1);
                 $login = new Login($this->phpid);
                 global $survey;
                 if ($survey->getAccessType() == LOGIN_ANONYMOUS) {
                     return $login->getLoginScreen(Language::messageEnterPrimKey());
                 } else {
                     if ($survey->getAccessType() == LOGIN_LOGINCODE) {
                         return $login->getLoginScreen($survey->getLoginError());
                     } else {
                         return $login->getLoginScreen(Language::messageEnterPrimKeyDirectAccess());
                     }
                 }
             }
         } else {
             //continue interview! EXTRA CHECK!!!
             /* update survey info with what we know from the last session action */
             setSurvey($loggedin["suid"]);
             /* include survey template now that we know which survey we are in */
             global $survey;
             require_once "display/templates/displayquestion_" . getSurveyTemplate() . ".php";
             /* update interview mode with what we know from the last session action
              * IF we are not changing the interview mode right now
              */
             if (isset($_POST['navigation']) && $_POST['navigation'] != NAVIGATION_MODE_CHANGE && $survey->getReentryMode() == MODE_REENTRY_YES) {
                 setSurveyMode($loggedin["mode"]);
             }
             /* update language with what we know from the last session action 
              * IF we are not changing the language right now
              */
             if (isset($_POST['navigation']) && $_POST['navigation'] != NAVIGATION_LANGUAGE_CHANGE && $survey->getReentryLanguage(getSurveyMode()) == LANGUAGE_REENTRY_YES) {
                 setSurveyLanguage($loggedin["language"]);
             }
             /* update version with what we know from the last session action */
             setSurveyVersion($loggedin["version"]);
             // include language file
             $l = getSurveyLanguage();
             //echo 'NOW: ' . $l;
             if (file_exists("language/language" . getSurveyLanguagePostFix($l) . ".php")) {
                 //echo 'well done';
                 require_once 'language' . getSurveyLanguagePostFix($l) . '.php';
                 // language
             } else {
                 require_once 'language_en.php';
                 // fall back on english language file
             }
             // pass along primkey to load correct engine!
             $engine = loadEngine(getSurvey(), $loggedin["primkey"], $this->phpid, getSurveyVersion(), getSurveySection(getSurvey(), $loggedin["primkey"]));
             /* handle button click */
             return $engine->getNextQuestion();
         }
     }
 }
Example #6
0
    function reportSub($message = '')
    {
        $returnStr = $this->displayComboBox();
        $returnStr .= '<div class="panel panel-default">
                <div class="panel-heading">';
        $returnStr .= '<h4>' . Language::reportProblem() . '</h4>';
        $returnStr .= '                </div>
                <div class="panel-body">';
        $returnStr .= $message;
        global $survey;
        $issues = $survey->getReportedIssues();
        $returnStr .= '<div>
  <!-- Nav tabs -->
  <ul class="nav nav-tabs" role="tablist">
    <li role="presentation" class="active"><a href="#newissue" aria-controls="home" role="tab" data-toggle="tab">New problem</a></li>
    <li role="presentation"><a href="#reportedissues" aria-controls="home" role="tab" data-toggle="tab">Reported problems (' . sizeof($issues) . ')</a></li>
  </ul>
<div class="tab-content">
    <div role="tabpanel" class="tab-pane active" id="newissue">';
        $returnStr .= "<br/><table>";
        $returnStr .= "<tr><td>" . Language::reportProblemCategory() . "</td><td>";
        $returnStr .= "<select class='selectpicker show-tick' name='reportcategory'>";
        $options = Language::reportProblemCategories();
        foreach ($options as $k => $option) {
            $returnStr .= "<option value=" . $k . ">" . $option . "</option>";
        }
        $returnStr .= "</select></td></tr>";
        $returnStr .= "<tr><td valign=top>" . Language::reportProblemDescription() . "</td><td>";
        $returnStr .= "<textarea name='reportcomment' class='form-control' style='min-width: 400px;' rows=6></textarea>";
        $returnStr .= "</td></tr>";
        $returnStr .= '</table><br/>';
        $returnStr .= '<button type="submit" class="btn btn-success" style="min-width:100px">' . Language::buttonReport() . '</button>';
        $returnStr .= '<button onclick="window.close();" type="cancel" class="btn btn-default" style="min-width:100px">' . Language::buttonClose() . '</button>';
        $returnStr .= "</form>";
        $returnStr .= '</div>
    <div role="tabpanel" class="tab-pane" id="reportedissues">';
        if (sizeof($issues) == 0) {
            $returnStr .= "<br/>" . '<div class="alert alert-warning">' . Language::labelNoProblemsReported() . '</div>';
        } else {
            $returnStr .= $this->displayDataTablesScripts(array("colvis", "rowreorder"));
            $returnStr .= "<script type='text/javascript'>\n                        \$(document).ready(function(){\n                            \$('#issuetable').dataTable(\n                                {\n                                    \"iDisplayLength\": " . sizeof($issues) . ",\n                                    dom: 'C<\"clear\">lfrtip',\n                                    searching: false,\n                                    paging: false\n                                    }    \n                                );\n                                         \n                       });</script>\n\n                        ";
            //
            $returnStr .= "<br/><table id='issuetable' class='table table-bordered table-striped'><thead>";
            $returnStr .= "<th>Reported by</th><th>" . Language::labelReportedOn() . "</th><th>" . Language::labelReportedCategory() . "</th><th>" . Language::labelReportedDescription() . "</th><th>" . Language::labelReportedMode() . "</th><th>" . Language::labelReportedLanguage() . "</th>";
            $returnStr .= "</thead><tbody>";
            $modes = Common::surveyModes();
            $languages = Language::getLanguagesArray();
            $cats = Language::reportProblemCategories();
            foreach ($issues as $is) {
                $us = new User($is['urid']);
                $returnStr .= "<tr>";
                $returnStr .= "<td>" . $us->getUsername() . "</td>";
                $returnStr .= "<td>" . $is["ts"] . "</td>";
                $returnStr .= "<td>" . $cats[$is["category"]] . "</td>";
                $returnStr .= "<td>" . $is["comment"] . "</td>";
                $returnStr .= "<td>" . $modes[$is["mode"]] . "</td>";
                $returnStr .= "<td>" . $languages[str_replace("_", "", getSurveyLanguagePostFix($is["language"]))]['name'] . "</td>";
                $returnStr .= "</tr>";
            }
            $returnStr .= "</tbody></table>";
        }
        $returnStr .= '</div>
  </div>
</div>';
        return $returnStr;
    }
Example #7
0
 function showIssues($content = "")
 {
     $returnStr = $this->showToolsHeader(Language::linkReported());
     $returnStr .= $content;
     $surveys = new Surveys();
     $surveys = $surveys->getSurveys();
     if (sizeof($surveys) > 0) {
         $returnStr .= "<form id=refreshform method=post>";
         $returnStr .= '<input type=hidden name=page value="sysadmin.tools.issues">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_SURVEY . '" id="' . SMS_POST_SURVEY . '_hidden" value="' . getSurvey() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_MODE . '" id="' . SMS_POST_MODE . '_hidden" value="' . getSurveyMode() . '">';
         $returnStr .= '<input type=hidden name="' . SMS_POST_LANGUAGE . '" id="' . SMS_POST_LANGUAGE . '_hidden" value="' . getSurveyLanguage() . '">';
         $returnStr .= "</form>";
         // get reported issues for survey
         global $survey;
         $issues = $survey->getReportedIssues();
         // no problems reported
         if (sizeof($issues) == 0) {
             $returnStr .= "<br/>" . '<div class="alert alert-warning">' . 'No reported problems found' . '</div>';
         } else {
             $returnStr .= $this->displayComboBox();
             $returnStr .= '<span class="label label-default">Filter by</span>';
             $returnStr .= '<div class="well well-sm">';
             $returnStr .= '<table>';
             $returnStr .= '<tr><td>' . Language::labelTestSurvey() . "</td><td><select onchange='document.getElementById(\"" . SMS_POST_SURVEY . "_hidden\").value=this.value; document.getElementById(\"refreshform\").submit();' name=" . POST_PARAM_SUID . " class='selectpicker show-tick'>";
             $current = new Survey(getSurvey());
             foreach ($surveys as $survey) {
                 $selected = "";
                 if ($survey->getSuid() == $current->getSuid()) {
                     $selected = "SELECTED";
                 }
                 $returnStr .= "<option {$selected} value=" . $survey->getSuid() . '>' . $survey->getName() . '</option>';
             }
             $returnStr .= "</select></td></tr></table></div>";
             $returnStr .= $this->displayDataTablesScripts(array("colvis", "rowreorder"));
             $returnStr .= "<script type='text/javascript'>\n                        \$(document).ready(function(){\n                            \$('#issuetable').dataTable(\n                                {\n                                    \"iDisplayLength\": " . sizeof($issues) . ",\n                                    dom: 'C<\"clear\">lfrtip',\n                                    searching: false,\n                                    paging: false\n                                    }    \n                                );\n                                         \n                       });</script>\n\n                        ";
             //
             $returnStr .= "<br/><table id='issuetable' class='table table-bordered table-striped'><thead>";
             $returnStr .= "<th>Reported by</th><th>Reported on</th><th>Category</th><th>Description</th><th>Primary key</th><th>Interview mode</th><th>Language</th>";
             $returnStr .= "</thead><tbody>";
             $modes = Common::surveyModes();
             $languages = Language::getLanguagesArray();
             $cats = Language::reportProblemCategories();
             foreach ($issues as $is) {
                 $us = new User($is['urid']);
                 $returnStr .= "<tr>";
                 $returnStr .= "<td>" . $us->getUsername() . "</td>";
                 $returnStr .= "<td>" . $is["ts"] . "</td>";
                 $returnStr .= "<td>" . $cats[$is["category"]] . "</td>";
                 $returnStr .= "<td>" . $is["comment"] . "</td>";
                 $returnStr .= "<td>" . $is["primkey"] . "</td>";
                 $returnStr .= "<td>" . $modes[$is["mode"]] . "</td>";
                 $returnStr .= "<td>" . $languages[str_replace("_", "", getSurveyLanguagePostFix($is["language"]))]['name'] . "</td>";
                 $returnStr .= "</tr>";
             }
             $returnStr .= "</tbody></table>";
         }
     } else {
         $returnStr .= $this->displayInfo(Language::messageNoSurveysAvailable());
     }
     $returnStr .= '</p></div></div>';
     //container and wrap
     $returnStr .= $this->showBottomBar();
     $returnStr .= $this->showFooter(false);
     return $returnStr;
 }