Exemplo n.º 1
0
if ($survey = new SC_Survey_Flow($surveyID, FOLDER_SURVEYS, $langCode)) {
    //Config
    $survey->bool_store_bwd = TRUE;
    //Process answers to questions
    if (isset($_POST['sc_page_id'])) {
        // Languages
        if (isset($_POST['q_language'])) {
            $langCode = $_POST['q_language'];
            if (!is_null($langCode) && !empty($langCode)) {
                $_SESSION['wrapper']['language'] = $langCode;
            }
        }
        $next_id = $survey->go();
    } else {
        $first_id = $survey->obj_page_generator->get_first_page_id();
        SC_Survey_Flow::reset_survey($first_id);
        throw new Exception('no page id posted');
    }
    //Load next page or submit response
    if ($next_id === SC_Page_Generator::SUBMIT_RESPONSE) {
        //Submit survey response
        header('Location:process_response.php?sid=' . rawurlencode($surveyID) . '&did=' . rawurlencode($deviceID));
        exit;
    } elseif ($next_id === SC_Page_Generator::START) {
        //Back to intro
        header('Location:../?pagetype=intro');
        exit;
    } else {
        //Load next page
        header('Location:../?pagetype=survey&pid=' . rawurlencode($next_id));
        //header('Refresh:4;../?pagetype=survey&pid='.rawurlencode($next_id));
Exemplo n.º 2
0
    }
}
## Get required content
switch ($pageType) {
    case 'date':
        break;
    case 'survey':
        $page->bool_ignore_defaults = config_var_exists($config, 'settings', 'ignoreDefaults') ? $config['settings']['ignoreDefaults'] : TRUE;
        ### Check for page id and reset survey if none exists
        $firstPageID = $page->get_first_page_id();
        if (isset($_GET['pid']) && strlen($_GET['pid']) > 0) {
            $pageID = $_GET['pid'];
        } else {
            ### Start survey
            $pageID = $firstPageID;
            SC_Survey_Flow::reset_survey($pageID, $initialAnswers);
        }
        break;
    case 'thankyou':
        ### Forget device ID if web or data-entry, to allow staff to switch between the two
        if ($_SESSION['deviceID'] === 'web' || $_SESSION['deviceID'] === 'data-entry') {
            unset($_SESSION['deviceID']);
        }
        ### Load outro into string
        if (is_null($outroPath)) {
            #### No outro - start survey
            header('Location:' . $url_menu);
        } elseif (isset($_SESSION['wrapper']['data'][$surveyID][$langCode]['outro.md'])) {
            #### Load outro from session
            $content = $_SESSION['wrapper']['data'][$surveyID][$langCode]['outro.md'];
        } else {