示例#1
0
文件: quexs.php 项目: ddrmoscow/queXS
/**
 * Get start interviewer URL
 *
 * @return string The URL to start the interview
 */
function get_start_interview_url()
{
    $db = newADOConnection(DB_TYPE);
    $db->Connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
    $db->SetFetchMode(ADODB_FETCH_ASSOC);
    $operator_id = get_operator_id();
    $url = QUEXS_URL . "nocaseavailable.php";
    $case_id = get_case_id($operator_id);
    if ($case_id) {
        $sql = "SELECT token\r\n\t\t\tFROM `case`\r\n\t\t\tWHERE case_id = {$case_id}";
        $token = $db->GetOne($sql);
        $sid = get_limesurvey_id($operator_id);
        $url = LIME_URL . "index.php?interviewer=interviewer&loadall=reload&sid={$sid}&token={$token}&lang=" . DEFAULT_LOCALE;
        $questionnaire_id = get_questionnaire_id($operator_id);
        //get prefills
        $sql = "SELECT lime_sgqa,value\r\n                        FROM questionnaire_prefill\r\n                        WHERE questionnaire_id = '{$questionnaire_id}'";
        $pf = $db->GetAll($sql);
        if (!empty($pf)) {
            foreach ($pf as $p) {
                $url .= "&" . $p['lime_sgqa'] . "=" . quexs_template_replace($p['value']);
            }
        }
    }
    return $url;
}
示例#2
0
文件: qanda.php 项目: ddrmoscow/queXS
function do_listwithcomment($ia)
{
    global $maxoptionsize, $dbprefix, $dropdownthreshold, $lwcdropdowns, $thissurvey;
    global $clang;
    if ($thissurvey['nokeyboard'] == 'Y') {
        vIncludeKeypad();
        $kpclass = "text-keypad";
    } else {
        $kpclass = "";
    }
    $checkconditionFunction = "checkconditions";
    $answer = '';
    $qidattributes = getQuestionAttributes($ia[0], $ia[4]);
    if (!isset($maxoptionsize)) {
        $maxoptionsize = 35;
    }
    //question attribute random order set?
    if ($qidattributes['random_order'] == 1) {
        $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid={$ia['0']} AND language='" . $_SESSION['s_lang'] . "' and scale_id=0 ORDER BY " . db_random();
    } elseif ($qidattributes['alphasort'] == 1) {
        $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid={$ia['0']} AND language='" . $_SESSION['s_lang'] . "' and scale_id=0 ORDER BY answer";
    } else {
        $ansquery = "SELECT * FROM {$dbprefix}answers WHERE qid={$ia['0']} AND language='" . $_SESSION['s_lang'] . "' and scale_id=0 ORDER BY sortorder, answer";
    }
    $ansresult = db_execute_assoc($ansquery);
    //Checked
    $anscount = $ansresult->RecordCount();
    $hint_comment = $clang->gT('Please enter your comment here');
    if ($lwcdropdowns == 'R' && $anscount <= $dropdownthreshold) {
        $answer .= '<div class="list">
	                    <ul>
                    ';
        while ($ansrow = $ansresult->FetchRow()) {
            $check_ans = '';
            if ($_SESSION[$ia[1]] == $ansrow['code']) {
                $check_ans = CHECKED;
            }
            //queXS check if this is designed to set an outcome:
            $quexs_outcome = false;
            $quexs_outcome_code = 0;
            if (strncasecmp($ansrow['answer'], "{OUTCOME:", 9) == 0) {
                $quexs_pos = strrpos($ansrow['answer'], "}", 8);
                if ($quexs_pos != false) {
                    $quexs_outcome_code = substr($ansrow['answer'], 9, $quexs_pos - 9);
                    $quexs_outcome = true;
                    include_once dirname(__FILE__) . '/quexs.php';
                    $ansrow['answer'] = quexs_template_replace($ansrow['answer']);
                }
            }
            //queXS check if this is designed to schedule an appointment:
            $quexs_appointment = false;
            if (strncasecmp($ansrow['answer'], "{SCHEDULEAPPOINTMENT}", 21) == 0) {
                include_once dirname(__FILE__) . '/quexs.php';
                $ansrow['answer'] = T_("Schedule Appointment");
                $quexs_appointment = true;
            }
            $answer .= '		<li>
			<input type="radio" name="' . $ia[1] . '" id="answer' . $ia[1] . $ansrow['code'] . '" value="' . $ansrow['code'] . '" class="radio" ' . $check_ans . ' onclick="' . $checkconditionFunction . '(this.value, this.name, this.type)' . quexs_submit_on_click(!$quexs_outcome && !$quexs_appointment) . quexs_outcome($quexs_outcome_code) . quexs_appointment($quexs_appointment) . '" />
			<label for="answer' . $ia[1] . $ansrow['code'] . '" class="answertext">' . $ansrow['answer'] . '</label>
		</li>
            ';
        }
        if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) {
            if (!isset($_SESSION[$ia[1]]) || $_SESSION[$ia[1]] == '' || $_SESSION[$ia[1]] == ' ') {
                $check_ans = CHECKED;
            } elseif (isset($_SESSION[$ia[1]]) || $_SESSION[$ia[1]] != '') {
                $check_ans = '';
            }
            $answer .= '		<li>
			<input class="radio" type="radio" name="' . $ia[1] . '" id="answer' . $ia[1] . '" value=" " onclick="' . $checkconditionFunction . '(this.value, this.name, this.type)"' . $check_ans . ' />
			<label for="answer' . $ia[1] . '" class="answertext">' . $clang->gT('No answer') . '</label>
		</li>
            ';
        }
        $fname2 = $ia[1] . 'comment';
        if ($anscount > 8) {
            $tarows = $anscount / 1.2;
        } else {
            $tarows = 4;
        }
        $answer .= '	</ul>
        </div>

        <p class="comment">
	<label for="answer' . $ia[1] . 'comment">' . $hint_comment . ':</label>

	<textarea class="textarea ' . $kpclass . '" name="' . $ia[1] . 'comment" id="answer' . $ia[1] . 'comment" rows="' . floor($tarows) . '" cols="30" >';
        if (isset($_SESSION[$fname2]) && $_SESSION[$fname2]) {
            $answer .= htmlspecialchars(htmlspecialchars(str_replace("\\", "", $_SESSION[$fname2])));
        }
        $answer .= '</textarea>
        </p>

        <input class="radio" type="hidden" name="java' . $ia[1] . '" id="java' . $ia[1] . "\" value=\"{$_SESSION[$ia[1]]}\" />\n        ";
        $inputnames[] = $ia[1];
        $inputnames[] = $ia[1] . 'comment';
    } else {
        $answer .= '<p class="select">
        <select class="select" name="' . $ia[1] . '" id="answer' . $ia[1] . '" onchange="' . $checkconditionFunction . '(this.value, this.name, this.type)" >
        ';
        while ($ansrow = $ansresult->FetchRow()) {
            $check_ans = '';
            if ($_SESSION[$ia[1]] == $ansrow['code']) {
                $check_ans = SELECTED;
            }
            $answer .= '		<option value="' . $ansrow['code'] . '"' . $check_ans . '>' . $ansrow['answer'] . "</option>\n";
            if (strlen($ansrow['answer']) > $maxoptionsize) {
                $maxoptionsize = strlen($ansrow['answer']);
            }
        }
        if ($ia[6] != 'Y' && SHOW_NO_ANSWER == 1) {
            if (!isset($_SESSION[$ia[1]]) || $_SESSION[$ia[1]] == '' || $_SESSION[$ia[1]] == ' ') {
                $check_ans = SELECTED;
            } elseif (isset($_SESSION[$ia[1]]) || $_SESSION[$ia[1]] != '') {
                $check_ans = '';
            }
            $answer .= '<option value=""' . $check_ans . '>' . $clang->gT('No answer') . "</option>\n";
        }
        $answer .= '	</select>
        </p>
        ';
        $fname2 = $ia[1] . 'comment';
        if ($anscount > 8) {
            $tarows = $anscount / 1.2;
        } else {
            $tarows = 4;
        }
        if ($tarows > 15) {
            $tarows = 15;
        }
        $maxoptionsize = $maxoptionsize * 0.72;
        if ($maxoptionsize < 33) {
            $maxoptionsize = 33;
        }
        if ($maxoptionsize > 70) {
            $maxoptionsize = 70;
        }
        $answer .= '<p class="comment">
	' . $hint_comment . '
	<textarea class="textarea ' . $kpclass . '" name="' . $ia[1] . 'comment" id="answer' . $ia[1] . 'comment" rows="' . $tarows . '" cols="' . $maxoptionsize . '" >';
        if (isset($_SESSION[$fname2]) && $_SESSION[$fname2]) {
            $answer .= htmlspecialchars(htmlspecialchars(str_replace("\\", "", $_SESSION[$fname2])));
        }
        $answer .= '</textarea>
	<input class="radio" type="hidden" name="java' . $ia[1] . '" id="java' . $ia[1] . " value=\"{$_SESSION[$ia[1]]}\" />\n</p>\n";
        $inputnames[] = $ia[1];
        $inputnames[] = $ia[1] . 'comment';
    }
    return array($answer, $inputnames);
}