本文整理汇总了PHP中retrieveAnswers函数的典型用法代码示例。如果您正苦于以下问题:PHP retrieveAnswers函数的具体用法?PHP retrieveAnswers怎么用?PHP retrieveAnswers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了retrieveAnswers函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
//.........这里部分代码省略.........
//PRESENT SURVEY
//******************************************************************************************************
$okToShowErrors = !$previewgrp && (isset($invalidLastPage) || $_SESSION[$LEMsessid]['prevstep'] == $_SESSION[$LEMsessid]['step']);
Yii::app()->getController()->loadHelper('qanda');
setNoAnswerMode($thissurvey);
//Iterate through the questions about to be displayed:
$inputnames = array();
foreach ($_SESSION[$LEMsessid]['grouplist'] as $gl) {
$gid = $gl['gid'];
$qnumber = 0;
if ($surveyMode != 'survey') {
$onlyThisGID = $stepInfo['gid'];
if ($onlyThisGID != $gid) {
continue;
}
}
// TMSW - could iterate through LEM::currentQset instead
//// To diplay one question, all the questions are processed ?
foreach ($_SESSION[$LEMsessid]['fieldarray'] as $key => $ia) {
++$qnumber;
$ia[9] = $qnumber;
// incremental question count;
if (isset($ia[10]) && $ia[10] == $gid || !isset($ia[10]) && $ia[5] == $gid) {
if ($surveyMode == 'question' && $ia[0] != $stepInfo['qid']) {
continue;
}
$qidattributes = getQuestionAttributeValues($ia[0]);
if ($ia[4] != '*' && ($qidattributes === false || !isset($qidattributes['hidden']) || $qidattributes['hidden'] == 1)) {
continue;
}
//Get the answers/inputnames
// TMSW - can content of retrieveAnswers() be provided by LEM? Review scope of what it provides.
// TODO - retrieveAnswers is slow - queries database separately for each question. May be fixed in _CI or _YII ports, so ignore for now
list($plus_qanda, $plus_inputnames) = retrieveAnswers($ia, $surveyid);
if ($plus_qanda) {
$plus_qanda[] = $ia[4];
$plus_qanda[] = $ia[6];
// adds madatory identifyer for adding mandatory class to question wrapping div
// Add a finalgroup in qa array , needed for random attribute : TODO: find a way to have it in new quanda_helper in 2.1
if (isset($ia[10])) {
$plus_qanda['finalgroup'] = $ia[10];
} else {
$plus_qanda['finalgroup'] = $ia[5];
}
$qanda[] = $plus_qanda;
}
if ($plus_inputnames) {
$inputnames = addtoarray_single($inputnames, $plus_inputnames);
}
//Display the "mandatory" popup if necessary
// TMSW - get question-level error messages - don't call **_popup() directly
if ($okToShowErrors && $stepInfo['mandViolation']) {
list($mandatorypopup, $popup) = mandatory_popup($ia, $notanswered);
}
//Display the "validation" popup if necessary
if ($okToShowErrors && !$stepInfo['valid']) {
list($validationpopup, $vpopup) = validation_popup($ia, $notvalidated);
}
// Display the "file validation" popup if necessary
if ($okToShowErrors && isset($filenotvalidated)) {
list($filevalidationpopup, $fpopup) = file_validation_popup($ia, $filenotvalidated);
}
}
if ($ia[4] == "|") {
$upload_file = TRUE;
}
示例2: preview
/**
* Load preview of a question screen.
*
* @access public
* @param int $surveyid
* @param int $qid
* @param string $lang
* @return void
*/
public function preview($surveyid, $qid, $lang = null)
{
$surveyid = sanitize_int($surveyid);
$qid = sanitize_int($qid);
$LEMdebugLevel = 0;
Yii::app()->loadHelper("qanda");
Yii::app()->loadHelper("surveytranslator");
if (empty($surveyid)) {
$this->getController()->error('No Survey ID provided');
}
if (empty($qid)) {
$this->getController()->error('No Question ID provided');
}
if (empty($lang)) {
$language = Survey::model()->findByPk($surveyid)->language;
} else {
$language = $lang;
}
if (!isset(Yii::app()->session['step'])) {
Yii::app()->session['step'] = 0;
}
if (!isset(Yii::app()->session['prevstep'])) {
Yii::app()->session['prevstep'] = 0;
}
if (!isset(Yii::app()->session['maxstep'])) {
Yii::app()->session['maxstep'] = 0;
}
// Use $_SESSION instead of $this->session for frontend features.
$_SESSION['survey_' . $surveyid]['s_lang'] = $language;
$_SESSION['survey_' . $surveyid]['fieldmap'] = createFieldMap($surveyid, 'full', true, $qid, $language);
// Prefill question/answer from defaultvalues
foreach ($_SESSION['survey_' . $surveyid]['fieldmap'] as $field) {
if (isset($field['defaultvalue'])) {
$_SESSION['survey_' . $surveyid][$field['fieldname']] = $field['defaultvalue'];
}
}
$clang = new limesurvey_lang($language);
$thissurvey = getSurveyInfo($surveyid);
setNoAnswerMode($thissurvey);
Yii::app()->session['dateformats'] = getDateFormatData($thissurvey['surveyls_dateformat']);
$qrows = Questions::model()->findByAttributes(array('sid' => $surveyid, 'qid' => $qid, 'language' => $language))->getAttributes();
$ia = array(0 => $qid, 1 => $surveyid . 'X' . $qrows['gid'] . 'X' . $qid, 2 => $qrows['title'], 3 => $qrows['question'], 4 => $qrows['type'], 5 => $qrows['gid'], 6 => $qrows['mandatory'], 7 => 'N', 8 => 'N');
$radix = getRadixPointData($thissurvey['surveyls_numberformat']);
$radix = $radix['seperator'];
$surveyOptions = array('radix' => $radix, 'tempdir' => Yii::app()->getConfig('tempdir'));
LimeExpressionManager::StartSurvey($surveyid, 'question', $surveyOptions, false, $LEMdebugLevel);
$qseq = LimeExpressionManager::GetQuestionSeq($qid);
$moveResult = LimeExpressionManager::JumpTo($qseq + 1, true, false, true);
$answers = retrieveAnswers($ia, $surveyid);
if (!$thissurvey['template']) {
$thistpl = getTemplatePath(Yii::app()->getConfig('defaulttemplate'));
} else {
$thistpl = getTemplatePath(validateTemplateDir($thissurvey['template']));
}
doHeader();
$showQuestion = "\$('#question{$qid}').show();";
$dummy_js = <<<EOD
<script type='text/javascript'>
<!--
LEMradix='{$radix}';
var numRegex = new RegExp('[^-' + LEMradix + '0-9]','g');
var intRegex = new RegExp('[^-0-9]','g');
function fixnum_checkconditions(value, name, type, evt_type, intonly)
{
newval = new String(value);
if (typeof intonly !=='undefined' && intonly==1) {
newval = newval.replace(intRegex,'');
}
else {
newval = newval.replace(numRegex,'');
}
if (LEMradix === ',') {
newval = newval.split(',').join('.');
}
if (newval != '-' && newval != '.' && newval != '-.' && newval != parseFloat(newval)) {
newval = '';
}
displayVal = newval;
if (LEMradix === ',') {
displayVal = displayVal.split('.').join(',');
}
if (name.match(/other\$/)) {
\$('#answer'+name+'text').val(displayVal);
}
\$('#answer'+name).val(displayVal);
if (typeof evt_type === 'undefined')
{
evt_type = 'onchange';
}
checkconditions(newval, name, type, evt_type);
//.........这里部分代码省略.........
示例3: run
//.........这里部分代码省略.........
//******************************************************************************************************
//PRESENT SURVEY
//******************************************************************************************************
$okToShowErrors = !$previewgrp && (isset($invalidLastPage) || $_SESSION[$LEMsessid]['prevstep'] == $_SESSION[$LEMsessid]['step']);
Yii::app()->getController()->loadHelper('qanda');
setNoAnswerMode($thissurvey);
//Iterate through the questions about to be displayed:
$inputnames = array();
foreach ($_SESSION[$LEMsessid]['grouplist'] as $gl) {
$gid = $gl[0];
$qnumber = 0;
if ($surveyMode != 'survey') {
$onlyThisGID = $stepInfo['gid'];
if ($onlyThisGID != $gid) {
continue;
}
}
// TMSW - could iterate through LEM::currentQset instead
foreach ($_SESSION[$LEMsessid]['fieldarray'] as $key => $ia) {
++$qnumber;
$ia[9] = $qnumber;
// incremental question count;
if (isset($ia[10]) && $ia[10] == $gid || !isset($ia[10]) && $ia[5] == $gid) {
if ($surveyMode == 'question' && $ia[0] != $stepInfo['qid']) {
continue;
}
$qidattributes = getQuestionAttributeValues($ia[0], $ia[4]);
if ($ia[4] != '*' && ($qidattributes === false || !isset($qidattributes['hidden']) || $qidattributes['hidden'] == 1)) {
continue;
}
//Get the answers/inputnames
// TMSW - can content of retrieveAnswers() be provided by LEM? Review scope of what it provides.
// TODO - retrieveAnswers is slow - queries database separately for each question. May be fixed in _CI or _YII ports, so ignore for now
list($plus_qanda, $plus_inputnames) = retrieveAnswers($ia, $surveyid);
if ($plus_qanda) {
$plus_qanda[] = $ia[4];
$plus_qanda[] = $ia[6];
// adds madatory identifyer for adding mandatory class to question wrapping div
$qanda[] = $plus_qanda;
}
if ($plus_inputnames) {
$inputnames = addtoarray_single($inputnames, $plus_inputnames);
}
//Display the "mandatory" popup if necessary
// TMSW - get question-level error messages - don't call **_popup() directly
if ($okToShowErrors && $stepInfo['mandViolation']) {
list($mandatorypopup, $popup) = mandatory_popup($ia, $notanswered);
}
//Display the "validation" popup if necessary
if ($okToShowErrors && !$stepInfo['valid']) {
list($validationpopup, $vpopup) = validation_popup($ia, $notvalidated);
}
// Display the "file validation" popup if necessary
if ($okToShowErrors && isset($filenotvalidated)) {
list($filevalidationpopup, $fpopup) = file_validation_popup($ia, $filenotvalidated);
}
}
if ($ia[4] == "|") {
$upload_file = TRUE;
}
}
//end iteration
}
if ($surveyMode != 'survey' && isset($thissurvey['showprogress']) && $thissurvey['showprogress'] == 'Y') {
if ($show_empty_group) {
$percentcomplete = makegraph($_SESSION[$LEMsessid]['totalsteps'] + 1, $_SESSION[$LEMsessid]['totalsteps']);
示例4: foreach
$gid=$gl[0];
$groupUnconditionnalQuestionsCount[$gid]=0;
$qnumber = 0;
foreach ($_SESSION['fieldarray'] as $ia)
{
++$qnumber;
$ia[9] = $qnumber; // incremental question count;
if ($ia[5] == $gid)
{
$qidattributes=getQuestionAttributes($ia[0]);
if ($qidattributes===false || $qidattributes['hidden']==1) {
continue;
}
$qtypesarray[$ia[1]] = $ia[4];
list($plus_qanda, $plus_inputnames)=retrieveAnswers($ia);
if ($plus_qanda)
{
$plus_qanda[] = $ia[4];
$plus_qanda[] = $ia[6]; // adds madatory identifyer for adding mandatory class to question wrapping div
$qanda[]=$plus_qanda;
}
if ($plus_inputnames)
{
$inputnames = addtoarray_single($inputnames, $plus_inputnames);
}
//Display the "mandatory" popup if necessary
if (isset($notanswered))
{
list($mandatorypopup, $popup)=mandatory_popup($ia, $notanswered);
示例5: limesurvey_lang
$clang = new limesurvey_lang($language);
$thissurvey = getSurveyInfo($surveyid);
$_SESSION['dateformats'] = getDateFormatData($thissurvey['surveyls_dateformat']);
require_once dirname(__FILE__) . '/../qanda.php';
$qquery = 'SELECT * FROM ' . db_table_name('questions') . " WHERE sid='{$surveyid}' AND qid='{$qid}' AND language='{$language}'";
$qresult = db_execute_assoc($qquery);
$qrows = $qresult->FetchRow();
$ia = array(0 => $qid, 1 => $surveyid . 'X' . $qrows['gid'] . 'X' . $qid, 2 => $qrows['title'], 3 => $qrows['question'], 4 => $qrows['type'], 5 => $qrows['gid'], 6 => $qrows['mandatory'], 7 => 'N', 8 => 'N');
// ia[8] is usedinconditions
$radix = getRadixPointData($thissurvey['surveyls_numberformat']);
$radix = $radix['seperator'];
$surveyOptions = array('radix' => $radix);
LimeExpressionManager::StartSurvey($thissurvey['sid'], 'question', $surveyOptions, false, $LEMdebugLevel);
$qseq = LimeExpressionManager::GetQuestionSeq($qid);
$moveResult = LimeExpressionManager::JumpTo($qseq + 1, true, false, true);
$answers = retrieveAnswers($ia);
if (!$thissurvey['template']) {
$thistpl = sGetTemplatePath($defaulttemplate);
} else {
$thistpl = sGetTemplatePath(validate_templatedir($thissurvey['template']));
}
doHeader();
$showQuestion = "\$('#question{$qid}').show();";
$dummy_js = <<<EOD
<script type='text/javascript'>
<!--
LEMradix='{$radix}';
var numRegex = new RegExp('[^-' + LEMradix + '0-9]','g');
var intRegex = new RegExp('[^-0-9]','g');
\tfunction fixnum_checkconditions(value, name, type, evt_type, intonly)
\t{
示例6: retrieveOneQuestion
<?php
require_once "./mysql/retrieve_qa.php";
$questions = retrieveOneQuestion($_GET['id']);
$answers = retrieveAnswers($_GET['id']);
foreach ($questions as $question) {
$name = $question['name'];
$email = $question['email'];
$topic = $question['topic'];
$content = $question['content'];
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Edit question - Bukan StackExchange</title>
<script src="./js/form_validation.js"></script>
<link rel="stylesheet" type="text/css" href="./css/style.css">
</head>
<body>
<a href="index.php"><h1>Bukan StackExchange</h1></a>
<div id="form">
<h2>Edit your question</h2>
<hr>
<form name="edit_q" action="./mysql/edit_question.php" onsubmit="return validateQuestionForm('edit_q')" method="post">
<input type="text" name="Name" value="<?php
echo $name;
?>
"><br>
<input type="text" name="Email" value="<?php
echo $email;