示例#1
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();
         }
     }
 }
示例#2
0
 function __construct($suid, $primkey, $phpid, $version, $seid, $doState = true, $doContext = true)
 {
     $this->primkey = $primkey;
     $this->phpid = $phpid;
     $this->setSuid($suid);
     if (isset($_SESSION['URID']) && $_SESSION['URID'] != '') {
         $user = new User($_SESSION['URID']);
         if (isTestmode() && inArray($user->getUserType(), array(USER_SYSADMIN, USER_TRANSLATOR, USER_TESTER))) {
             $this->display = new DisplayQuestionTest($this->primkey, $this);
         } else {
             if ($user->getUserType() == USER_NURSE) {
                 $this->display = new DisplayQuestionNurse($this->primkey, $this);
             } else {
                 $this->display = new DisplayQuestionSms($this->primkey, $this);
             }
         }
     } else {
         $this->display = new DisplayQuestion($this->primkey, $this);
     }
     global $survey;
     $this->survey = $survey;
     $this->version = $version;
     /* get context */
     if ($doContext == true) {
         $this->loadContext();
     }
     /* data record */
     $this->datarecord = new DataRecord($suid, $primkey);
     $this->datarecord->loadRecord();
     /* do state */
     if ($doState == true) {
         /* get main section and current section */
         $this->mainseid = getSurveyMainSection($suid, $primkey);
         $this->seid = getSurveySection($suid, $primkey);
         /* check for existing state */
         $this->state = new State($this->primkey, $this->survey->getSuid());
         if ($this->loadLastState() == true) {
             $this->previousrgid = $this->getRgid();
             $this->previousloopaction = $this->getForLoopLastAction();
             $this->previousloopstring = $this->getLoopString();
             $this->previouslooprgid = $this->getLoopRgid();
             $this->previouswhilergid = $this->getWhileRgid();
             $this->previouswhileaction = $this->getWhileLastAction();
         } else {
             $this->state->setSuid($suid);
             $this->setMainSeid($this->mainseid);
             $this->setSeid($this->seid);
             $this->setPrefix("");
             $this->setParentPrefix("");
             $this->setParentSeid(0);
             $this->setParentRgid(0);
             /* set loop string, loop rgid and loop left off to empty by default */
             $this->setLoopString("");
             $this->setLoopRgid("");
             $this->setForLoopLastAction("");
             $this->setWhileRgid("");
             $this->setWhileLastAction("");
         }
     } else {
         $this->seid = $seid;
         // set for loadSetFillClasses
     }
     $this->flooding = false;
     $this->stop = false;
     $this->startatbegin = false;
     $this->redofills = false;
     $this->forward = false;
     $this->firstform = false;
     $this->updateaction = false;
     $this->reset = array();
     $this->dk = array();
     $this->rf = array();
     $this->na = array();
     $this->processedfills = array();
     $this->justassigned = array();
     $this->currentaction = ACTION_DYNAMIC;
     /* load any set fill classes */
     //$this->loadSetFillClasses();
 }
示例#3
0
 function __construct()
 {
     $primkey = getFromSessionParams('watchprimkey');
     $seid = getSurveySection(getFromSessionParams('watchsuid'), $primkey);
     $this->engine = loadEngine(getFromSessionParams('watchsuid'), $primkey, "", getSurveyVersion(), $seid);
 }