$html = '<div id="wrapper"><p id="optoutmessage">';
if ($thissurvey == false || !tableExists("tokens_{$surveyid}")) {
    $html .= $clang->gT('This survey does not seem to exist.');
} else {
    $usquery = "SELECT emailstatus from " . db_table_name("tokens_{$surveyid}") . " where token=" . db_quoteall($token, true);
    $usresult = $connect->GetOne($usquery);
    if ($usresult == false) {
        $html .= $clang->gT('You are not a participant in this survey.');
    } elseif ($usresult == 'OK') {
        $usquery = "Update " . db_table_name("tokens_{$surveyid}") . " set emailstatus='OptOut', usesleft=0 where token=" . db_quoteall($token, true);
        $usresult = $connect->Execute($usquery);
        $html .= $clang->gT('You have been successfully removed from this survey.');
    } else {
        $html .= $clang->gT('You have been already removed from this survey.');
    }
}
$html .= '</p></div>';
//PRINT COMPLETED PAGE
if (!$thissurvey['templatedir']) {
    $thistpl = sGetTemplatePath($defaulttemplate);
} else {
    $thistpl = sGetTemplatePath($thissurvey['templatedir']);
}
sendcacheheaders();
doHeader();
echo templatereplace(file_get_contents("{$thistpl}/startpage.pstpl"));
echo templatereplace(file_get_contents("{$thistpl}/survey.pstpl"));
echo $html;
echo templatereplace(file_get_contents("{$thistpl}/endpage.pstpl"));
doFooter();
// Closing PHP tag is intentially left out (yes, it's fine!)
Example #2
0
    $html=ReplaceFields($html, $fieldsarray);
    $html .= "<br /><br /></center>\n";
}
else
{
    $html="Email Error";
}

//PRINT COMPLETED PAGE
if (!$thissurvey['template'])
{
    $thistpl=sGetTemplatePath(validate_templatedir('default'));
} 
else 
{
    $thistpl=sGetTemplatePath(validate_templatedir($thissurvey['template']));
}

sendcacheheaders();
doHeader();

foreach(file("$thistpl/startpage.pstpl") as $op)
{
    echo templatereplace($op);
}
foreach(file("$thistpl/survey.pstpl") as $op)
{
    echo "\t".templatereplace($op);
}
echo $html;
foreach(file("$thistpl/endpage.pstpl") as $op)
Example #3
0
/**
 * This function returns an array containing the "question/answer" html display
 * and a list of the question/answer fieldnames associated. It is called from
 * question.php, group.php or survey.php
 *
 * @param mixed $ia
 * @param mixed $notanswered
 * @param mixed $notvalidated
 * @param mixed $filenotvalidated
 * @return mixed
 */
function retrieveAnswers($ia, $notanswered=null, $notvalidated=null, $filenotvalidated=null)
{
    //globalise required config variables
    global $dbprefix, $clang; //These are from the config-defaults.php file
    global $thissurvey, $gl; //These are set by index.php
    global $connect;

    //DISPLAY
    $display = $ia[7];

    //QUESTION NAME
    $name = $ia[0];

    $qtitle=$ia[3];
    //Replace INSERTANS statements with previously provided answers;
    $qtitle=dTexts::run($qtitle);


    //GET HELP
    $hquery="SELECT help FROM {$dbprefix}questions WHERE qid=$ia[0] AND language='".$_SESSION['s_lang']."'";
    $hresult=db_execute_num($hquery) or safe_die($connect->ErrorMsg());       //Checked
    $help="";
    while ($hrow=$hresult->FetchRow()) {$help=$hrow[0];}

    //A bit of housekeeping to stop PHP Notices
    $answer = "";
    if (!isset($_SESSION[$ia[1]])) {$_SESSION[$ia[1]] = "";}
    $qidattributes=getQuestionAttributes($ia[0],$ia[4]);
    //echo "<pre>";print_r($qidattributes);echo "</pre>";
    //Create the question/answer html

    // Previously in limesurvey, it was virtually impossible to control how the start of questions were formatted.
    // this is an attempt to allow users (or rather system admins) some control over how the starting text is formatted.
    $number = isset($ia[9]) ? $ia[9] : '';

    $question_text = array(
				 'all' => '' // All has been added for backwards compatibility with templates that use question_start.pstpl (now redundant)
    ,'text' => $qtitle
    ,'code' => $ia[2]
    ,'number' => $number
    ,'help' => ''
    ,'mandatory' => ''
    ,'man_message' => ''
    ,'valid_message' => ''
    ,'file_valid_message' => ''
    ,'class' => ''
    ,'man_class' => ''
    ,'input_error_class' => ''// provides a class.
    ,'essentials' => ''
    );

    switch ($ia[4])
    {
        case 'X': //BOILERPLATE QUESTION
            $values = do_boilerplate($ia);
            break;
        case '5': //5 POINT CHOICE radio-buttons
            $values = do_5pointchoice($ia);
            break;
        case 'D': //DATE
            $values = do_date($ia);
            break;
        case 'L': //LIST drop-down/radio-button list
            $values = do_list_radio($ia);
            if ($qidattributes['hide_tip']==0)
            {
                $qtitle .= "<br />\n<span class=\"questionhelp\">"
                . $clang->gT('Choose one of the following answers').'</span>';
                $question_text['help'] = $clang->gT('Choose one of the following answers');
            }
            break;
        case '!': //List - dropdown
            $values=do_list_dropdown($ia);
            if ($qidattributes['hide_tip']==0)
            {
                $qtitle .= "<br />\n<span class=\"questionhelp\">"
                . $clang->gT('Choose one of the following answers').'</span>';
                $question_text['help'] = $clang->gT('Choose one of the following answers');
            }
            break;
        case 'O': //LIST WITH COMMENT drop-down/radio-button list + textarea
            $values=do_listwithcomment($ia);
            if (count($values[1]) > 1 && $qidattributes['hide_tip']==0)
            {
                $qtitle .= "<br />\n<span class=\"questionhelp\">"
                . $clang->gT('Choose one of the following answers').'</span>';
                $question_text['help'] = $clang->gT('Choose one of the following answers');
            }
            break;
        case 'R': //RANKING STYLE
            $values=do_ranking($ia);
            if (count($values[1]) > 1 && $qidattributes['hide_tip']==0)
            {
                $question_text['help'] = $clang->gT("Click on an item in the list on the left, starting with your highest ranking item, moving through to your lowest ranking item.");
                if (trim($qidattributes['min_answers'])!='')
                {
                    $qtitle .= "<br />\n<span class=\"questionhelp\">"
                    . sprintf($clang->ngT("Check at least %d item","Check at least %d items",$qidattributes['min_answers']),$qidattributes['min_answers'])."</span>";
                    $question_text['help'] .=' '.sprintf($clang->ngT("Check at least %d item","Check at least %d items",$qidattributes['min_answers']),$qidattributes['min_answers']);
                }
            }
            break;
        case 'M': //Multiple choice checkbox
            $values=do_multiplechoice($ia);
            if (count($values[1]) > 1 && $qidattributes['hide_tip']==0)
            {
                $maxansw=trim($qidattributes['max_answers']);
                $minansw=trim($qidattributes['min_answers']);
                if (!($maxansw || $minansw))
                {
                    $qtitle .= "<br />\n<span class=\"questionhelp\">"
                    . $clang->gT('Check any that apply').'</span>';
                    $question_text['help'] = $clang->gT('Check any that apply');
                }
                else
                {
                    if ($maxansw && $minansw)
                    {
                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                        . sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw)."</span>";
                        $question_text['help'] = sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw);
                    } elseif ($maxansw)
                    {
                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                        . sprintf($clang->gT("Check at most %d answers"), $maxansw)."</span>";
                        $question_text['help'] = sprintf($clang->gT("Check at most %d answers"), $maxansw);
                    } else
                    {
                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                        . sprintf($clang->ngT("Check at least %d answer","Check at least %d answers",$minansw),$minansw)."</span>";
                        $question_text['help'] = sprintf($clang->ngT("Check at least %d answer","Check at least %d answers",$minansw),$minansw);
                    }
                }
            }
            break;

        case 'I': //Language Question
            $values=do_language($ia);
            if (count($values[1]) > 1)
            {
                $qtitle .= "<br />\n<span class=\"questionhelp\">"
                . $clang->gT('Choose your language').'</span>';
                $question_text['help'] = $clang->gT('Choose your language');
            }
            break;
        case 'P': //Multiple choice with comments checkbox + text
            $values=do_multiplechoice_withcomments($ia);
            if (count($values[1]) > 1 && $qidattributes['hide_tip']==0)
            {
                $maxansw=trim($qidattributes["max_answers"]);
                $minansw=trim($qidattributes["min_answers"]);
                if (!($maxansw || $minansw))
                {
                    $qtitle .= "<br />\n<span class=\"questionhelp\">"
                    . $clang->gT('Check any that apply').'</span>';
                    $question_text['help'] = $clang->gT('Check any that apply');
                }
                else
                {
                    if ($maxansw && $minansw)
                    {
                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                        . sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw)."</span>";
                        $question_text['help'] = sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw);
                    } elseif ($maxansw)
                    {
                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                        . sprintf($clang->gT("Check at most %d answers"), $maxansw)."</span>";
                        $question_text['help'] = sprintf($clang->gT("Check at most %d answers"), $maxansw);
                    } else
                    {
                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                        . sprintf($clang->gT("Check at least %d answers"), $minansw)."</span>";
                        $question_text['help'] = sprintf($clang->gT("Check at least %d answers"), $minansw);
                    }
                }
            }
            break;
        case '|': //File Upload
            $values=do_file_upload($ia);
            if ($qidattributes['min_num_of_files'] != 0)
            {
                if (trim($qidattributes['min_num_of_files']) != 0)
                {
                    $qtitle .= "<br />\n<span class = \"questionhelp\">"
                    .sprintf($clang->gT("At least %d files must be uploaded for this question"), $qidattributes['min_num_of_files'])."<span>";
                    $question_text['help'] .= ' '.sprintf($clang->gT("At least %d files must be uploaded for this question"), $qidattributes['min_num_of_files']);
                }
            }
            break;
        case 'Q': //MULTIPLE SHORT TEXT
            $values=do_multipleshorttext($ia);
            break;
        case 'K': //MULTIPLE NUMERICAL QUESTION
            $values=do_multiplenumeric($ia);
            break;
        case 'N': //NUMERICAL QUESTION TYPE
            $values=do_numerical($ia);
            break;
        case 'S': //SHORT FREE TEXT
            $values=do_shortfreetext($ia);
            break;
        case 'T': //LONG FREE TEXT
            $values=do_longfreetext($ia);
            break;
        case 'U': //HUGE FREE TEXT
            $values=do_hugefreetext($ia);
            break;
        case 'Y': //YES/NO radio-buttons
            $values=do_yesno($ia);
            break;
        case 'G': //GENDER drop-down list
            $values=do_gender($ia);
            break;
        case 'A': //ARRAY (5 POINT CHOICE) radio-buttons
            $values=do_array_5point($ia);
            break;
        case 'B': //ARRAY (10 POINT CHOICE) radio-buttons
            $values=do_array_10point($ia);
            break;
        case 'C': //ARRAY (YES/UNCERTAIN/NO) radio-buttons
            $values=do_array_yesnouncertain($ia);
            break;
        case 'E': //ARRAY (Increase/Same/Decrease) radio-buttons
            $values=do_array_increasesamedecrease($ia);
            break;
        case 'F': //ARRAY (Flexible) - Row Format
            $values=do_array($ia);
            break;
        case 'H': //ARRAY (Flexible) - Column Format
            $values=do_arraycolumns($ia);
            break;
        case ':': //ARRAY (Multi Flexi) 1 to 10
            $values=do_array_multiflexi($ia);
            break;
        case ';': //ARRAY (Multi Flexi) Text
            $values=do_array_multitext($ia);  //It's like the "5th element" movie, come to life
            break;
        case '1': //Array (Flexible Labels) dual scale
            $values=do_array_dual($ia);
            break;
    } //End Switch

    if (isset($values)) //Break apart $values array returned from switch
    {
        //$answer is the html code to be printed
        //$inputnames is an array containing the names of each input field
        list($answer, $inputnames)=$values;
    }

    $answer .= "\n\t<input type='hidden' name='display$ia[1]' id='display$ia[0]' value='";
    $answer .= 'on'; //If this is single format, then it must be showing. Needed for checking conditional mandatories
    $answer .= "' />\n"; //for conditional mandatory questions

    if ($ia[6] == 'Y')
    {
        $qtitle = '<span class="asterisk">'.$clang->gT('*').'</span>'.$qtitle;
        $question_text['mandatory'] = $clang->gT('*');
    }
    //If this question is mandatory but wasn't answered in the last page
    //add a message HIGHLIGHTING the question
    $qtitle .= mandatory_message($ia);
    $question_text['man_message'] = mandatory_message($ia);

    $qtitle .= validation_message($ia);
    $question_text['valid_message'] = validation_message($ia);

    $qtitle .= $ia[4] == "|" ? file_validation_message($ia) : "";
    $question_text['file_valid_message'] = $ia[4] == "|" ? file_validation_message($ia) : "";

    if(!empty($question_text['man_message']) || !empty($question_text['valid_message']) || !empty($question_text['file_valid_message']))
    {
        $question_text['input_error_class'] = ' input-error';// provides a class to style question wrapper differently if there is some kind of user input error;
    }

    // =====================================================
    // START: legacy question_start.pstpl code
    // The following section adds to the templating system by allowing
    // templaters to control where the various parts of the question text
    // are put.

    if(is_file('templates/'.validate_templatedir($thissurvey['template']).'/question_start.pstpl'))
    {
        $qtitle_custom = '';

        $replace=array();
        foreach($question_text as $key => $value)
        {
            $find[] = '{QUESTION_'.strtoupper($key).'}'; // Match key words from template
            $replace[] = $value; // substitue text
        };
        if(!defined('QUESTION_START'))
        {
            define('QUESTION_START' , file_get_contents(sGetTemplatePath($thissurvey['template']).'/question_start.pstpl' , true));
        };
        $qtitle_custom = str_replace( $find , $replace , QUESTION_START);

        $c = 1;
        // START: <EMBED> work-around step 1
        $qtitle_custom = preg_replace( '/(<embed[^>]+>)(<\/embed>)/i' , '\1NOT_EMPTY\2' , $qtitle_custom );
        // END <EMBED> work-around step 1
        while($c > 0) // This recursively strips any empty tags to minimise rendering bugs.
        {
            $matches = 0;
            $oldtitle=$qtitle_custom;
            $qtitle_custom = preg_replace( '/<([^ >]+)[^>]*>[\r\n\t ]*<\/\1>[\r\n\t ]*/isU' , '' , $qtitle_custom , -1); // I removed the $count param because it is PHP 5.1 only.

            $c = ($qtitle_custom!=$oldtitle)?1:0;
        };
        // START <EMBED> work-around step 2
        $qtitle_custom = preg_replace( '/(<embed[^>]+>)NOT_EMPTY(<\/embed>)/i' , '\1\2' , $qtitle_custom );
        // END <EMBED> work-around step 2
        while($c > 0) // This recursively strips any empty tags to minimise rendering bugs.
        {
            $matches = 0;
            $oldtitle=$qtitle_custom;
            $qtitle_custom = preg_replace( '/(<br(?: ?\/)?>(?:&nbsp;|\r\n|\n\r|\r|\n| )*)+$/i' , '' , $qtitle_custom , -1 ); // I removed the $count param because it is PHP 5.1 only.
            $c = ($qtitle_custom!=$oldtitle)?1:0;
        };

        //		$qtitle = $qtitle_custom;
        $question_text['all'] = $qtitle_custom;
    }
    else
    {
        $question_text['all'] = $qtitle;
    };
    // END: legacy question_start.pstpl code
    //===================================================================
    //	echo '<pre>[qanda.php] line '.__LINE__.": $question_text =\n".htmlspecialchars(print_r($question_text,true)).'</pre>';
    $qtitle = $question_text;
    // =====================================================

    $qanda=array($qtitle, $answer, $help, $display, $name, $ia[2], $gl[0], $ia[1] );
    //New Return
    return array($qanda, $inputnames);
}
        if (isset($_POST['printableexport'])) {
            $pdf->intopdf(FlattenText($fname[0] . $fname[1], true) . ": " . $fname[2]);
            $pdf->ln(2);
        } else {
            $printoutput .= "\t<tr class='printanswersquestionhead'><td  colspan='2'>{$fname[0]}</td></tr>\n";
        }
    } else {
        if (isset($_POST['printableexport'])) {
            $pdf->intopdf(FlattenText($fname[0] . $fname[1], true) . ": " . $fname[2]);
            $pdf->ln(2);
        } else {
            $printoutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
        }
    }
}
$printoutput .= "</table>\n";
if (isset($_POST['printableexport'])) {
    header("Pragma: public");
    header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
    $sExportFileName = sanitize_filename($surveyname);
    $pdf->Output($sExportFileName . "-" . $surveyid . ".pdf", "D");
}
//Display the page with user answers
if (!isset($_POST['printableexport'])) {
    sendcacheheaders();
    doHeader();
    echo templatereplace(file_get_contents(sGetTemplatePath($thistpl) . '/startpage.pstpl'));
    echo templatereplace(file_get_contents(sGetTemplatePath($thistpl) . '/printanswers.pstpl'), array('ANSWERTABLE' => $printoutput));
    echo templatereplace(file_get_contents(sGetTemplatePath($thistpl) . '/endpage.pstpl'));
    echo "</body></html>";
}
Example #5
0
/**
* This function returns an array containing the "question/answer" html display
* and a list of the question/answer fieldnames associated. It is called from
* question.php, group.php or survey.php
*
* @param mixed $ia
* @param mixed $notanswered
* @param mixed $notvalidated
* @param mixed $filenotvalidated
* @return mixed
*/
function retrieveAnswers($ia)
{
    //globalise required config variables
    global $dbprefix, $clang;
    //These are from the config-defaults.php file
    global $thissurvey, $gl;
    //These are set by index.php
    global $connect;
    //DISPLAY
    $display = $ia[7];
    //QUESTION NAME
    $name = $ia[0];
    $qtitle = $ia[3];
    $inputnames = array();
    // TMSW - eliminate this - get from LEM
    //A bit of housekeeping to stop PHP Notices
    $answer = "";
    if (!isset($_SESSION[$ia[1]])) {
        $_SESSION[$ia[1]] = "";
    }
    $qidattributes = getQuestionAttributes($ia[0], $ia[4]);
    //Create the question/answer html
    // Previously in limesurvey, it was virtually impossible to control how the start of questions were formatted.
    // this is an attempt to allow users (or rather system admins) some control over how the starting text is formatted.
    $number = isset($ia[9]) ? $ia[9] : '';
    // TMSW - populate this directly from LEM? - this this is global
    $question_text = array('all' => '', 'text' => $qtitle, 'code' => $ia[2], 'number' => $number, 'help' => '', 'mandatory' => '', 'man_message' => '', 'valid_message' => '', 'file_valid_message' => '', 'class' => '', 'man_class' => '', 'input_error_class' => '', 'essentials' => '');
    switch ($ia[4]) {
        case 'X':
            //BOILERPLATE QUESTION
            $values = do_boilerplate($ia);
            break;
        case '5':
            //5 POINT CHOICE radio-buttons
            $values = do_5pointchoice($ia);
            break;
        case 'D':
            //DATE
            $values = do_date($ia);
            break;
        case 'L':
            //LIST drop-down/radio-button list
            $values = do_list_radio($ia);
            if ($qidattributes['hide_tip'] == 0) {
                $qtitle .= "<br />\n<span class=\"questionhelp\">" . $clang->gT('Choose one of the following answers') . '</span>';
                $question_text['help'] = $clang->gT('Choose one of the following answers');
            }
            break;
        case '!':
            //List - dropdown
            $values = do_list_dropdown($ia);
            if ($qidattributes['hide_tip'] == 0) {
                $qtitle .= "<br />\n<span class=\"questionhelp\">" . $clang->gT('Choose one of the following answers') . '</span>';
                $question_text['help'] = $clang->gT('Choose one of the following answers');
            }
            break;
        case 'O':
            //LIST WITH COMMENT drop-down/radio-button list + textarea
            $values = do_listwithcomment($ia);
            if (count($values[1]) > 1 && $qidattributes['hide_tip'] == 0) {
                $qtitle .= "<br />\n<span class=\"questionhelp\">" . $clang->gT('Choose one of the following answers') . '</span>';
                $question_text['help'] = $clang->gT('Choose one of the following answers');
            }
            break;
        case 'R':
            //RANKING STYLE
            $values = do_ranking($ia);
            if (count($values[1]) > 1 && $qidattributes['hide_tip'] == 0) {
                $question_text['help'] = $clang->gT("Click on an item in the list on the left, starting with your highest ranking item, moving through to your lowest ranking item.");
                if (trim($qidattributes['min_answers']) != '') {
                    $qtitle .= "<br />\n<span class=\"questionhelp\">" . sprintf($clang->ngT("Check at least %d item", "Check at least %d items", $qidattributes['min_answers']), $qidattributes['min_answers']) . "</span>";
                    $question_text['help'] .= ' ' . sprintf($clang->ngT("Check at least %d item", "Check at least %d items", $qidattributes['min_answers']), $qidattributes['min_answers']);
                }
            }
            break;
        case 'M':
            //Multiple choice checkbox
            $values = do_multiplechoice($ia);
            if (count($values[1]) > 1 && $qidattributes['hide_tip'] == 0) {
                $maxansw = trim($qidattributes['max_answers']);
                $minansw = trim($qidattributes['min_answers']);
                if (!($maxansw || $minansw)) {
                    $qtitle .= "<br />\n<span class=\"questionhelp\">" . $clang->gT('Check any that apply') . '</span>';
                    $question_text['help'] = $clang->gT('Check any that apply');
                }
                //                else
                //                {
                //                    if ($maxansw && $minansw)
                //                    {
                //                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                //                        . sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw)."</span>";
                //                        $question_text['help'] = sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw);
                //                    } elseif ($maxansw)
                //                    {
                //                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                //                        . sprintf($clang->gT("Check at most %d answers"), $maxansw)."</span>";
                //                        $question_text['help'] = sprintf($clang->gT("Check at most %d answers"), $maxansw);
                //                    } else
                //                    {
                //                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                //                        . sprintf($clang->ngT("Check at least %d answer","Check at least %d answers",$minansw),$minansw)."</span>";
                //                        $question_text['help'] = sprintf($clang->ngT("Check at least %d answer","Check at least %d answers",$minansw),$minansw);
                //                    }
                //                }
            }
            break;
        case 'I':
            //Language Question
            $values = do_language($ia);
            if (count($values[1]) > 1) {
                $qtitle .= "<br />\n<span class=\"questionhelp\">" . $clang->gT('Choose your language') . '</span>';
                $question_text['help'] = $clang->gT('Choose your language');
            }
            break;
        case 'P':
            //Multiple choice with comments checkbox + text
            $values = do_multiplechoice_withcomments($ia);
            if (count($values[1]) > 1 && $qidattributes['hide_tip'] == 0) {
                $maxansw = trim($qidattributes["max_answers"]);
                $minansw = trim($qidattributes["min_answers"]);
                if (!($maxansw || $minansw)) {
                    $qtitle .= "<br />\n<span class=\"questionhelp\">" . $clang->gT('Check any that apply') . '</span>';
                    $question_text['help'] = $clang->gT('Check any that apply');
                }
                //                else
                //                {
                //                    if ($maxansw && $minansw)
                //                    {
                //                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                //                        . sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw)."</span>";
                //                        $question_text['help'] = sprintf($clang->gT("Check between %d and %d answers"), $minansw, $maxansw);
                //                    } elseif ($maxansw)
                //                    {
                //                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                //                        . sprintf($clang->gT("Check at most %d answers"), $maxansw)."</span>";
                //                        $question_text['help'] = sprintf($clang->gT("Check at most %d answers"), $maxansw);
                //                    } else
                //                    {
                //                        $qtitle .= "<br />\n<span class=\"questionhelp\">"
                //                        . sprintf($clang->gT("Check at least %d answers"), $minansw)."</span>";
                //                        $question_text['help'] = sprintf($clang->gT("Check at least %d answers"), $minansw);
                //                    }
                //                }
            }
            break;
        case '|':
            //File Upload
            $values = do_file_upload($ia);
            if ($qidattributes['min_num_of_files'] != 0) {
                if (trim($qidattributes['min_num_of_files']) != 0) {
                    $qtitle .= "<br />\n<span class = \"questionhelp\">" . sprintf($clang->gT("At least %d files must be uploaded for this question"), $qidattributes['min_num_of_files']) . "<span>";
                    $question_text['help'] .= ' ' . sprintf($clang->gT("At least %d files must be uploaded for this question"), $qidattributes['min_num_of_files']);
                }
            }
            break;
        case 'Q':
            //MULTIPLE SHORT TEXT
            $values = do_multipleshorttext($ia);
            break;
        case 'K':
            //MULTIPLE NUMERICAL QUESTION
            $values = do_multiplenumeric($ia);
            break;
        case 'N':
            //NUMERICAL QUESTION TYPE
            $values = do_numerical($ia);
            break;
        case 'S':
            //SHORT FREE TEXT
            $values = do_shortfreetext($ia);
            break;
        case 'T':
            //LONG FREE TEXT
            $values = do_longfreetext($ia);
            break;
        case 'U':
            //HUGE FREE TEXT
            $values = do_hugefreetext($ia);
            break;
        case 'Y':
            //YES/NO radio-buttons
            $values = do_yesno($ia);
            break;
        case 'G':
            //GENDER drop-down list
            $values = do_gender($ia);
            break;
        case 'A':
            //ARRAY (5 POINT CHOICE) radio-buttons
            $values = do_array_5point($ia);
            break;
        case 'B':
            //ARRAY (10 POINT CHOICE) radio-buttons
            $values = do_array_10point($ia);
            break;
        case 'C':
            //ARRAY (YES/UNCERTAIN/NO) radio-buttons
            $values = do_array_yesnouncertain($ia);
            break;
        case 'E':
            //ARRAY (Increase/Same/Decrease) radio-buttons
            $values = do_array_increasesamedecrease($ia);
            break;
        case 'F':
            //ARRAY (Flexible) - Row Format
            $values = do_array($ia);
            break;
        case 'H':
            //ARRAY (Flexible) - Column Format
            $values = do_arraycolumns($ia);
            break;
        case ':':
            //ARRAY (Multi Flexi) 1 to 10
            $values = do_array_multiflexi($ia);
            break;
        case ';':
            //ARRAY (Multi Flexi) Text
            $values = do_array_multitext($ia);
            //It's like the "5th element" movie, come to life
            break;
        case '1':
            //Array (Flexible Labels) dual scale
            $values = do_array_dual($ia);
            break;
        case '*':
            // Equation
            $values = do_equation($ia);
            break;
    }
    //End Switch
    if (isset($values)) {
        //$answer is the html code to be printed
        //$inputnames is an array containing the names of each input field
        list($answer, $inputnames) = $values;
    }
    if ($ia[6] == 'Y') {
        $qtitle = '<span class="asterisk">' . $clang->gT('*') . '</span>' . $qtitle;
        $question_text['mandatory'] = $clang->gT('*');
    }
    //If this question is mandatory but wasn't answered in the last page
    //add a message HIGHLIGHTING the question
    if ($_SESSION['step'] != $_SESSION['maxstep'] || $_SESSION['step'] == $_SESSION['prevstep']) {
        $mandatory_msg = mandatory_message($ia);
    } else {
        $mandatory_msg = '';
    }
    $qtitle .= $mandatory_msg;
    $question_text['man_message'] = $mandatory_msg;
    //    if (($_SESSION['step'] != $_SESSION['maxstep']) || ($_SESSION['step'] == $_SESSION['prevstep'])) {
    if (!isset($qidattributes['hide_tip']) || $qidattributes['hide_tip'] == 0) {
        $_vshow = true;
        // whether should initially be visible - TODO should also depend upon 'hidetip'?
    } else {
        $_vshow = false;
    }
    list($validation_msg, $isValid) = validation_message($ia, $_vshow);
    $qtitle .= $validation_msg;
    $question_text['valid_message'] = $validation_msg;
    if ($_SESSION['step'] != $_SESSION['maxstep'] || $_SESSION['step'] == $_SESSION['prevstep']) {
        $file_validation_msg = file_validation_message($ia);
    } else {
        $file_validation_msg = '';
        $isValid = true;
        // don't want to show any validation messages.
    }
    $qtitle .= $ia[4] == "|" ? $file_validation_msg : "";
    $question_text['file_valid_message'] = $ia[4] == "|" ? $file_validation_msg : "";
    if (!empty($question_text['man_message']) || !$isValid || !empty($question_text['file_valid_message'])) {
        $question_text['input_error_class'] = ' input-error';
        // provides a class to style question wrapper differently if there is some kind of user input error;
    }
    // =====================================================
    // START: legacy question_start.pstpl code
    // The following section adds to the templating system by allowing
    // templaters to control where the various parts of the question text
    // are put.
    if (is_file('templates/' . validate_templatedir($thissurvey['template']) . '/question_start.pstpl')) {
        $qtitle_custom = '';
        $replace = array();
        foreach ($question_text as $key => $value) {
            $find[] = '{QUESTION_' . strtoupper($key) . '}';
            // Match key words from template
            $replace[] = $value;
            // substitue text
        }
        if (!defined('QUESTION_START')) {
            define('QUESTION_START', file_get_contents(sGetTemplatePath($thissurvey['template']) . '/question_start.pstpl', true));
        }
        $qtitle_custom = str_replace($find, $replace, QUESTION_START);
        $c = 1;
        // START: <EMBED> work-around step 1
        $qtitle_custom = preg_replace('/(<embed[^>]+>)(<\\/embed>)/i', '\\1NOT_EMPTY\\2', $qtitle_custom);
        // END <EMBED> work-around step 1
        while ($c > 0) {
            $matches = 0;
            $oldtitle = $qtitle_custom;
            $qtitle_custom = preg_replace('/<([^ >]+)[^>]*>[\\r\\n\\t ]*<\\/\\1>[\\r\\n\\t ]*/isU', '', $qtitle_custom, -1);
            // I removed the $count param because it is PHP 5.1 only.
            $c = $qtitle_custom != $oldtitle ? 1 : 0;
        }
        // START <EMBED> work-around step 2
        $qtitle_custom = preg_replace('/(<embed[^>]+>)NOT_EMPTY(<\\/embed>)/i', '\\1\\2', $qtitle_custom);
        // END <EMBED> work-around step 2
        while ($c > 0) {
            $matches = 0;
            $oldtitle = $qtitle_custom;
            $qtitle_custom = preg_replace('/(<br(?: ?\\/)?>(?:&nbsp;|\\r\\n|\\n\\r|\\r|\\n| )*)+$/i', '', $qtitle_custom, -1);
            // I removed the $count param because it is PHP 5.1 only.
            $c = $qtitle_custom != $oldtitle ? 1 : 0;
        }
        $question_text['all'] = $qtitle_custom;
    } else {
        $question_text['all'] = $qtitle;
    }
    // END: legacy question_start.pstpl code
    //===================================================================
    $qtitle = $question_text;
    // =====================================================
    $qanda = array($qtitle, $answer, 'help', $display, $name, $ia[2], $gl[0], $ia[1]);
    //New Return
    return array($qanda, $inputnames);
}
Example #6
0
         $myoutput[] = templatereplace($op);
     }
     foreach (file("{$templatedir}/clearall.pstpl") as $op) {
         $myoutput[] = templatereplace($op);
     }
     foreach (file("{$templatedir}/endpage.pstpl") as $op) {
         $myoutput[] = templatereplace($op);
     }
     $myoutput[] = "\n";
     break;
 case 'completed':
     unset($files);
     $myoutput[] = "";
     foreach ($CompletedTemplate as $qs) {
         $files[] = array("name" => $qs);
         $myoutput = array_merge($myoutput, doreplacement(sGetTemplatePath($templatename) . "/{$qs}"));
     }
     break;
 case 'printablesurvey':
     unset($files);
     foreach ($printablesurveytemplate as $qs) {
         $files[] = array("name" => $qs);
     }
     $questionoutput = array();
     foreach (file("{$templatedir}/print_question.pstpl") as $op) {
         // echo '<pre>line '.__LINE__.'$op = '.htmlspecialchars(print_r($op)).'</pre>';
         $questionoutput[] = templatereplace($op, array('QUESTION_NUMBER' => '1', 'QUESTION_CODE' => 'Q1', 'QUESTION_MANDATORY' => $clang->gT('*'), 'QUESTION_SCENARIO' => 'Only answer this if certain conditions are met.', 'QUESTION_CLASS' => ' mandatory list-radio', 'QUESTION_TYPE_HELP' => $clang->gT('Please choose *only one* of the following:'), 'QUESTION_MAN_MESSAGE' => '', 'QUESTION_VALID_MESSAGE' => '', 'QUESTION_FILE_VALID_MESSAGE' => '', 'QUESTION_TEXT' => 'This is a sample question text. The user was asked to pick an entry.', 'QUESTIONHELP' => 'This is some help text for this question.', 'ANSWER' => '<ul>
                             <li>
                                 <img src="' . $templateurl . '/print_img_radio.png" alt="First choice" class="input-radio" height="14" width="14">First choice
                             </li>
                             <li>
Example #7
0
    $tokensexist = 0;
    unset($_POST['token']);
    unset($_GET['token']);
    unset($token);
    unset($clienttoken);
}
if ($interviewer) {
    //SET THE TEMPLATE DIRECTORY
    if (!$thissurvey['templatedir']) {
        $thistpl = sGetTemplatePath($defaulttemplate);
    } else {
        $thistpl = sGetTemplatePath($thissurvey['templatedir']);
    }
} else {
    $thissurvey['templatedir'] = quexs_get_template($clienttoken);
    $thistpl = sGetTemplatePath(quexs_get_template($clienttoken));
}
//MAKE SURE SURVEY HASN'T EXPIRED
if ($thissurvey['expiry'] != '' and date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust) > $thissurvey['expiry'] && $thissurvey['active'] != 'N') {
    sendcacheheaders();
    doHeader();
    echo templatereplace(file_get_contents("{$thistpl}/startpage.pstpl"));
    echo "\t<div id='wrapper'>\n" . "\t<p id='tokenmessage'>\n" . "\t" . $clang->gT("This survey is no longer available.") . "<br /><br />\n" . "\t" . sprintf($clang->gT("Please contact %s ( %s ) for further assistance."), $thissurvey['adminname'], $thissurvey['adminemail']) . ".<br /><br />\n" . "\t</p>\n" . "\t</div>\n";
    echo templatereplace(file_get_contents("{$thistpl}/endpage.pstpl"));
    doFooter();
    exit;
}
//MAKE SURE SURVEY IS ALREADY VALID
if ($thissurvey['startdate'] != '' and date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $timeadjust) < $thissurvey['startdate'] && $thissurvey['active'] != 'N') {
    sendcacheheaders();
    doHeader();