本文整理汇总了PHP中SetSurveyLanguage函数的典型用法代码示例。如果您正苦于以下问题:PHP SetSurveyLanguage函数的具体用法?PHP SetSurveyLanguage怎么用?PHP SetSurveyLanguage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetSurveyLanguage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionAction
function actionAction($surveyid, $language = null)
{
$sLanguage = $language;
ob_start(function ($buffer, $phase) {
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
ob_implicit_flush(false);
$iSurveyID = (int) $surveyid;
//$postlang = returnglobal('lang');
Yii::import('application.libraries.admin.progressbar', true);
Yii::app()->loadHelper("admin/statistics");
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('surveytranslator');
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerPackage('jquery-touch-punch');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
$data = array();
if (!isset($iSurveyID)) {
$iSurveyID = returnGlobal('sid');
} else {
$iSurveyID = (int) $iSurveyID;
}
if (!$iSurveyID) {
//This next line ensures that the $iSurveyID value is never anything but a number.
safeDie('You have to provide a valid survey ID.');
}
if ($iSurveyID) {
$actresult = Survey::model()->findAll('sid = :sid AND active = :active', array(':sid' => $iSurveyID, ':active' => 'Y'));
//Checked
if (count($actresult) == 0) {
safeDie('You have to provide a valid survey ID.');
} else {
$surveyinfo = getSurveyInfo($iSurveyID);
// CHANGE JSW_NZ - let's get the survey title for display
$thisSurveyTitle = $surveyinfo["name"];
// CHANGE JSW_NZ - let's get css from individual template.css - so define path
$thisSurveyCssPath = getTemplateURL($surveyinfo["template"]);
if ($surveyinfo['publicstatistics'] != 'Y') {
safeDie('The public statistics for this survey are deactivated.');
}
//check if graphs should be shown for this survey
if ($surveyinfo['publicgraphs'] == 'Y') {
$publicgraphs = 1;
} else {
$publicgraphs = 0;
}
}
}
//we collect all the output within this variable
$statisticsoutput = '';
//for creating graphs we need some more scripts which are included here
//True -> include
//False -> forget about charts
if (isset($publicgraphs) && $publicgraphs == 1) {
require_once APPPATH . 'third_party/pchart/pchart/pChart.class';
require_once APPPATH . 'third_party/pchart/pchart/pData.class';
require_once APPPATH . 'third_party/pchart/pchart/pCache.class';
$MyCache = new pCache(Yii::app()->getConfig("tempdir") . DIRECTORY_SEPARATOR);
//$currentuser is created as prefix for pchart files
if (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
$currentuser = $_SERVER['REDIRECT_REMOTE_USER'];
} else {
if (session_id()) {
$currentuser = substr(session_id(), 0, 15);
} else {
$currentuser = "standard";
}
}
}
// Set language for questions and labels to base language of this survey
if ($sLanguage == null || !in_array($sLanguage, Survey::model()->findByPk($iSurveyID)->getAllLanguages())) {
$sLanguage = Survey::model()->findByPk($iSurveyID)->language;
} else {
$sLanguage = sanitize_languagecode($sLanguage);
}
//set survey language for translations
SetSurveyLanguage($iSurveyID, $sLanguage);
//Create header
sendCacheHeaders();
$condition = false;
$sitename = Yii::app()->getConfig("sitename");
$data['surveylanguage'] = $sLanguage;
$data['sitename'] = $sitename;
$data['condition'] = $condition;
$data['thisSurveyCssPath'] = $thisSurveyCssPath;
/*
* only show questions where question attribute "public_statistics" is set to "1"
*/
$query = "SELECT q.* , group_name, group_order FROM {{questions}} q, {{groups}} g, {{question_attributes}} qa\n WHERE g.gid = q.gid AND g.language = :lang1 AND q.language = :lang2 AND q.sid = :surveyid AND q.qid = qa.qid AND q.parent_qid = 0 AND qa.attribute = 'public_statistics'";
$databasetype = Yii::app()->db->getDriverName();
if ($databasetype == 'mssql' || $databasetype == "sqlsrv" || $databasetype == "dblib") {
$query .= " AND CAST(CAST(qa.value as varchar) as int)='1'\n";
} else {
$query .= " AND qa.value='1'\n";
}
//execute query
$result = Yii::app()->db->createCommand($query)->bindParam(":lang1", $sLanguage, PDO::PARAM_STR)->bindParam(":lang2", $sLanguage, PDO::PARAM_STR)->bindParam(":surveyid", $iSurveyID, PDO::PARAM_INT)->queryAll();
//store all the data in $rows
//.........这里部分代码省略.........
示例2: action
//.........这里部分代码省略.........
}
}
// TODO can this be moved to the top?
// (Used to be global, used in ExpressionManager, merged into amVars. If not filled in === '')
// can this be added in the first computation of $redata?
if (isset($_SESSION['survey_' . $surveyid]['srid'])) {
$saved_id = $_SESSION['survey_' . $surveyid]['srid'];
}
// recompute $redata since $saved_id used to be a global
$redata = compact(array_keys(get_defined_vars()));
if ($this->_didSessionTimeOut($surveyid)) {
// @TODO is this still required ?
$asMessage = array(gT("Error"), gT("We are sorry but your session has expired."), gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection."), sprintf(gT("Please contact %s ( %s ) for further assistance."), $thissurvey['adminname'], $thissurvey['adminemail']));
$this->_niceExit($redata, __LINE__, null, $asMessage);
}
// Set the language of the survey, either from POST, GET parameter of session var
// Keep the old value, because SetSurveyLanguage update $_SESSION
$sOldLang = isset($_SESSION['survey_' . $surveyid]['s_lang']) ? $_SESSION['survey_' . $surveyid]['s_lang'] : "";
// Keep the old value, because SetSurveyLanguage update $_SESSION
if (!empty($param['lang'])) {
$sDisplayLanguage = $param['lang'];
// $param take lang from returnGlobal and returnGlobal sanitize langagecode
} elseif (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
$sDisplayLanguage = $_SESSION['survey_' . $surveyid]['s_lang'];
} elseif (Survey::model()->findByPk($surveyid)) {
$sDisplayLanguage = Survey::model()->findByPk($surveyid)->language;
} else {
$sDisplayLanguage = Yii::app()->getConfig('defaultlang');
}
//CHECK FOR REQUIRED INFORMATION (sid)
if ($surveyid && $surveyExists) {
LimeExpressionManager::SetSurveyId($surveyid);
// must be called early - it clears internal cache if a new survey is being used
SetSurveyLanguage($surveyid, $sDisplayLanguage);
if ($previewmode) {
LimeExpressionManager::SetPreviewMode($previewmode);
}
if (App()->language != $sOldLang) {
UpdateGroupList($surveyid, App()->language);
// to refresh the language strings in the group list session variable
UpdateFieldArray();
// to refresh question titles and question text
}
} else {
throw new CHttpException(404, "The survey in which you are trying to participate does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
}
// Get token
if (!isset($token)) {
$token = $clienttoken;
}
//GET BASIC INFORMATION ABOUT THIS SURVEY
$thissurvey = getSurveyInfo($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
$event = new PluginEvent('beforeSurveyPage');
$event->set('surveyId', $surveyid);
App()->getPluginManager()->dispatchEvent($event);
if (!is_null($event->get('template'))) {
$thissurvey['templatedir'] = $event->get('template');
}
//SEE IF SURVEY USES TOKENS
if ($surveyExists == 1 && tableExists('{{tokens_' . $thissurvey['sid'] . '}}')) {
$tokensexist = 1;
} else {
$tokensexist = 0;
unset($_POST['token']);
unset($param['token']);
unset($token);
示例3: buildsurveysession
//.........这里部分代码省略.........
}
echo '<label for="token">' . $clang->gT("Token:") . "</label><span id='token'>{$gettoken}</span>" . "<input type='hidden' name='token' value='{$gettoken}'></li>";
}
if (function_exists("ImageCreate") && isCaptchaEnabled('surveyaccessscreen', $thissurvey['usecaptcha'])) {
echo "<li>\n <label for='captchaimage'>" . $clang->gT("Security Question") . "</label><img id='captchaimage' src='" . Yii::app()->getController()->createUrl('/verification/image/sid/' . $surveyid) . "' alt='captcha' /><input type='text' size='5' maxlength='3' name='loadsecurity' value='' />\n </li>";
}
echo "<li><input class='submit' type='submit' value='" . $clang->gT("Continue") . "' /></li>\n </ul>\n </form>\n </id>";
}
echo '</div>' . templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata, 'frontend_helper[1817]');
doFooter();
exit;
}
}
}
//RESET ALL THE SESSION VARIABLES AND START AGAIN
unset($_SESSION['survey_' . $surveyid]['grouplist']);
unset($_SESSION['survey_' . $surveyid]['fieldarray']);
unset($_SESSION['survey_' . $surveyid]['insertarray']);
unset($_SESSION['survey_' . $surveyid]['fieldnamesInfo']);
unset($_SESSION['survey_' . $surveyid]['fieldmap-' . $surveyid . '-randMaster']);
unset($_SESSION['survey_' . $surveyid]['groupReMap']);
$_SESSION['survey_' . $surveyid]['fieldnamesInfo'] = array();
// Multi lingual support order : by REQUEST, if not by Token->language else by survey default language
if (returnGlobal('lang', true)) {
$language_to_set = returnGlobal('lang', true);
} elseif (isset($oTokenEntry) && $oTokenEntry) {
// If survey have token : we have a $oTokenEntry
// Can use $oTokenEntry = Token::model($surveyid)->findByAttributes(array('token'=>$clienttoken)); if we move on another function : this par don't validate the token validity
$language_to_set = $oTokenEntry->language;
} else {
$language_to_set = $thissurvey['language'];
}
if (!isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
SetSurveyLanguage($surveyid, $language_to_set);
}
UpdateGroupList($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
$sQuery = "SELECT count(*)\n" . " FROM {{groups}} INNER JOIN {{questions}} ON {{groups}}.gid = {{questions}}.gid\n" . " WHERE {{questions}}.sid=" . $surveyid . "\n" . " AND {{groups}}.language='" . $_SESSION['survey_' . $surveyid]['s_lang'] . "'\n" . " AND {{questions}}.language='" . $_SESSION['survey_' . $surveyid]['s_lang'] . "'\n" . " AND {{questions}}.parent_qid=0\n";
$totalquestions = Yii::app()->db->createCommand($sQuery)->queryScalar();
// Fix totalquestions by substracting Test Display questions
$iNumberofQuestions = dbExecuteAssoc("SELECT count(*)\n" . " FROM {{questions}}" . " WHERE type in ('X','*')\n" . " AND sid={$surveyid}" . " AND language='" . $_SESSION['survey_' . $surveyid]['s_lang'] . "'" . " AND parent_qid=0")->read();
$_SESSION['survey_' . $surveyid]['totalquestions'] = $totalquestions - (int) reset($iNumberofQuestions);
//2. SESSION VARIABLE: totalsteps
//The number of "pages" that will be presented in this survey
//The number of pages to be presented will differ depending on the survey format
switch ($thissurvey['format']) {
case "A":
$_SESSION['survey_' . $surveyid]['totalsteps'] = 1;
break;
case "G":
if (isset($_SESSION['survey_' . $surveyid]['grouplist'])) {
$_SESSION['survey_' . $surveyid]['totalsteps'] = count($_SESSION['survey_' . $surveyid]['grouplist']);
}
break;
case "S":
$_SESSION['survey_' . $surveyid]['totalsteps'] = $totalquestions;
}
if ($totalquestions == 0) {
sendCacheHeaders();
doHeader();
$redata = compact(array_keys(get_defined_vars()));
echo templatereplace(file_get_contents($sTemplatePath . "startpage.pstpl"), array(), $redata, 'frontend_helper[1914]');
echo templatereplace(file_get_contents($sTemplatePath . "survey.pstpl"), array(), $redata, 'frontend_helper[1915]');
echo "\t<div id='wrapper'>\n" . "\t<p id='tokenmessage'>\n" . "\t" . $clang->gT("This survey does not yet have any questions and cannot be tested or completed.") . "<br /><br />\n" . "\t" . sprintf($clang->gT("For further information please contact %s"), $thissurvey['adminname']) . " (<a href='mailto:{$thissurvey['adminemail']}'>" . "{$thissurvey['adminemail']}</a>)<br /><br />\n" . "\t</p>\n" . "\t</div>\n";
echo templatereplace(file_get_contents($sTemplatePath . "endpage.pstpl"), array(), $redata, 'frontend_helper[1925]');
doFooter();
exit;
示例4: array
/**
* TSV survey definition in format readable by TSVSurveyImport
* one line each per group, question, sub-question, and answer
* does not use SGQA naming at all.
* @param type $sid
* @return type
*/
public static function &TSVSurveyExport($sid)
{
$fields = array('class', 'type/scale', 'name', 'relevance', 'text', 'help', 'language', 'validation', 'mandatory', 'other', 'default', 'same_default', 'allowed_filetypes', 'alphasort', 'answer_width', 'array_filter', 'array_filter_exclude', 'array_filter_style', 'assessment_value', 'category_separator', 'choice_title', 'code_filter', 'commented_checkbox', 'commented_checkbox_auto', 'date_format', 'date_max', 'date_min', 'display_columns', 'display_rows', 'dropdown_dates', 'dropdown_dates_minute_step', 'dropdown_dates_month_style', 'dropdown_prefix', 'dropdown_prepostfix', 'dropdown_separators', 'dropdown_size', 'dualscale_headerA', 'dualscale_headerB', 'em_validation_q', 'em_validation_q_tip', 'em_validation_sq', 'em_validation_sq_tip', 'equals_num_value', 'exclude_all_others', 'exclude_all_others_auto', 'hidden', 'hide_tip', 'input_boxes', 'location_city', 'location_country', 'location_defaultcoordinates', 'location_mapheight', 'location_mapservice', 'location_mapwidth', 'location_mapzoom', 'location_nodefaultfromip', 'location_postal', 'location_state', 'max_answers', 'max_filesize', 'max_num_of_files', 'max_num_value', 'max_num_value_n', 'maximum_chars', 'min_answers', 'min_num_of_files', 'min_num_value', 'min_num_value_n', 'multiflexible_checkbox', 'multiflexible_max', 'multiflexible_min', 'multiflexible_step', 'num_value_int_only', 'numbers_only', 'other_comment_mandatory', 'other_numbers_only', 'other_replace_text', 'page_break', 'parent_order', 'prefix', 'printable_help', 'public_statistics', 'random_group', 'random_order', 'rank_title', 'repeat_headings', 'reverse', 'samechoiceheight', 'samelistheight', 'scale_export', 'show_comment', 'show_grand_total', 'show_title', 'show_totals', 'showpopups', 'slider_accuracy', 'slider_default', 'slider_layout', 'slider_max', 'slider_middlestart', 'slider_min', 'slider_rating', 'slider_reset', 'slider_separator', 'slider_showminmax', 'statistics_graphtype', 'statistics_showgraph', 'statistics_showmap', 'suffix', 'text_input_width', 'time_limit', 'time_limit_action', 'time_limit_countdown_message', 'time_limit_disable_next', 'time_limit_disable_prev', 'time_limit_message', 'time_limit_message_delay', 'time_limit_message_style', 'time_limit_timer_style', 'time_limit_warning', 'time_limit_warning_2', 'time_limit_warning_2_display_time', 'time_limit_warning_2_message', 'time_limit_warning_2_style', 'time_limit_warning_display_time', 'time_limit_warning_message', 'time_limit_warning_style', 'thousands_separator', 'use_dropdown');
$rows = array();
$primarylang = 'en';
$otherlangs = '';
$langs = array();
// Export survey-level information
$query = "select * from {{surveys}} where sid = " . $sid;
$data = dbExecuteAssoc($query);
foreach ($data->readAll() as $r) {
foreach ($r as $key => $value) {
if ($value != '') {
$row['class'] = 'S';
$row['name'] = $key;
$row['text'] = $value;
$rows[] = $row;
}
if ($key == 'language') {
$primarylang = $value;
}
if ($key == 'additional_languages') {
$otherlangs = $value;
}
}
}
$langs = explode(' ', $primarylang . ' ' . $otherlangs);
$langs = array_unique($langs);
// Export survey language settings
$query = "select * from {{surveys_languagesettings}} where surveyls_survey_id = " . $sid;
$data = dbExecuteAssoc($query);
foreach ($data->readAll() as $r) {
$_lang = $r['surveyls_language'];
foreach ($r as $key => $value) {
if ($value != '' && $key != 'surveyls_language' && $key != 'surveyls_survey_id') {
$row['class'] = 'SL';
$row['name'] = $key;
$row['text'] = $value;
$row['language'] = $_lang;
$rows[] = $row;
}
}
}
$surveyinfo = getSurveyInfo($sid);
$assessments = false;
if (isset($surveyinfo['assessments']) && $surveyinfo['assessments'] == 'Y') {
$assessments = true;
}
foreach ($langs as $lang) {
if (trim($lang) == '') {
continue;
}
SetSurveyLanguage($sid, $lang);
LimeExpressionManager::StartSurvey($sid, 'survey', array('sgqaNaming' => 'N', 'assessments' => $assessments), true);
$moveResult = LimeExpressionManager::NavigateForwards();
$LEM =& LimeExpressionManager::singleton();
if (is_null($moveResult) || is_null($LEM->currentQset) || count($LEM->currentQset) == 0) {
continue;
}
$_gseq = -1;
foreach ($LEM->currentQset as $q) {
$gseq = $q['info']['gseq'];
$gid = $q['info']['gid'];
$qid = $q['info']['qid'];
//////
// SHOW GROUP-LEVEL INFO
//////
if ($gseq != $_gseq) {
$_gseq = $gseq;
$ginfo = $LEM->gseq2info[$gseq];
// if relevance equation is using SGQA coding, convert to qcoding
$grelevance = $ginfo['grelevance'] == '' ? 1 : $ginfo['grelevance'];
$LEM->em->ProcessBooleanExpression($grelevance, $gseq, 0);
// $qseq
$grelevance = trim(strip_tags($LEM->em->GetPrettyPrintString()));
$gtext = trim($ginfo['description']) == '' ? '' : $ginfo['description'];
$row = array();
$row['class'] = 'G';
//create a group code to allow proper importing of multi-lang survey TSVs
$row['type/scale'] = 'G' . $gseq;
$row['name'] = $ginfo['group_name'];
$row['relevance'] = $grelevance;
$row['text'] = $gtext;
$row['language'] = $lang;
$row['random_group'] = $ginfo['randomization_group'];
$rows[] = $row;
}
//////
// SHOW QUESTION-LEVEL INFO
//////
$row = array();
$mandatory = $q['info']['mandatory'] == 'Y' ? 'Y' : '';
$type = $q['info']['type'];
//.........这里部分代码省略.........
示例5: index
/**
* Show printable survey
*/
function index($surveyid, $lang = null)
{
$surveyid = sanitize_int($surveyid);
if (!Permission::model()->hasSurveyPermission($surveyid, 'surveycontent', 'read')) {
$aData['surveyid'] = $surveyid;
App()->getClientScript()->registerPackage('jquery-superfish');
$message['title'] = gT('Access denied!');
$message['message'] = gT('You do not have sufficient rights to access this page.');
$message['class'] = "error";
$this->_renderWrappedTemplate('survey', array("message" => $message), $aData);
} else {
$aSurveyInfo = getSurveyInfo($surveyid, $lang);
if (!$aSurveyInfo) {
$this->getController()->error('Invalid survey ID');
}
SetSurveyLanguage($surveyid, $lang);
$sLanguageCode = App()->language;
$templatename = $aSurveyInfo['template'];
$welcome = $aSurveyInfo['surveyls_welcometext'];
$end = $aSurveyInfo['surveyls_endtext'];
$surveyname = $aSurveyInfo['surveyls_title'];
$surveydesc = $aSurveyInfo['surveyls_description'];
$surveyactive = $aSurveyInfo['active'];
$surveytable = "{{survey_" . $aSurveyInfo['sid'] . "}}";
$surveyexpirydate = $aSurveyInfo['expires'];
$surveyfaxto = $aSurveyInfo['faxto'];
$dateformattype = $aSurveyInfo['surveyls_dateformat'];
Yii::app()->loadHelper('surveytranslator');
if (!is_null($surveyexpirydate)) {
$dformat = getDateFormatData($dateformattype);
$dformat = $dformat['phpdate'];
$expirytimestamp = strtotime($surveyexpirydate);
$expirytimeofday_h = date('H', $expirytimestamp);
$expirytimeofday_m = date('i', $expirytimestamp);
$surveyexpirydate = date($dformat, $expirytimestamp);
if (!empty($expirytimeofday_h) || !empty($expirytimeofday_m)) {
$surveyexpirydate .= ' – ' . $expirytimeofday_h . ':' . $expirytimeofday_m;
}
sprintf(gT("Please submit by %s"), $surveyexpirydate);
} else {
$surveyexpirydate = '';
}
//Fix $templatename : control if print_survey.pstpl exist
if (is_file(getTemplatePath($templatename) . DIRECTORY_SEPARATOR . 'print_survey.pstpl')) {
$templatename = $templatename;
// Change nothing
} elseif (is_file(getTemplatePath(Yii::app()->getConfig("defaulttemplate")) . DIRECTORY_SEPARATOR . 'print_survey.pstpl')) {
$templatename = Yii::app()->getConfig("defaulttemplate");
} else {
$templatename = "default";
}
$sFullTemplatePath = getTemplatePath($templatename) . DIRECTORY_SEPARATOR;
$sFullTemplateUrl = getTemplateURL($templatename) . "/";
define('PRINT_TEMPLATE_DIR', $sFullTemplatePath, true);
define('PRINT_TEMPLATE_URL', $sFullTemplateUrl, true);
LimeExpressionManager::StartSurvey($surveyid, 'survey', NULL, false, LEM_PRETTY_PRINT_ALL_SYNTAX);
$moveResult = LimeExpressionManager::NavigateForwards();
$condition = "sid = '{$surveyid}' AND language = '{$sLanguageCode}'";
$degresult = QuestionGroup::model()->getAllGroups($condition, array('group_order'));
//xiao,
if (!isset($surveyfaxto) || !$surveyfaxto and isset($surveyfaxnumber)) {
$surveyfaxto = $surveyfaxnumber;
//Use system fax number if none is set in survey.
}
$headelements = getPrintableHeader();
//if $showsgqacode is enabled at config.php show table name for reference
$showsgqacode = Yii::app()->getConfig("showsgqacode");
if (isset($showsgqacode) && $showsgqacode == true) {
$surveyname = $surveyname . "<br />[" . gT('Database') . " " . gT('table') . ": {$surveytable}]";
} else {
$surveyname = $surveyname;
}
$survey_output = array('SITENAME' => Yii::app()->getConfig("sitename"), 'SURVEYNAME' => $surveyname, 'SURVEYDESCRIPTION' => $surveydesc, 'WELCOME' => $welcome, 'END' => $end, 'THEREAREXQUESTIONS' => 0, 'SUBMIT_TEXT' => gT("Submit Your Survey."), 'SUBMIT_BY' => $surveyexpirydate, 'THANKS' => gT("Thank you for completing this survey."), 'HEADELEMENTS' => $headelements, 'TEMPLATEURL' => PRINT_TEMPLATE_URL, 'FAXTO' => $surveyfaxto, 'PRIVACY' => '', 'GROUPS' => '');
$survey_output['FAX_TO'] = '';
if (!empty($surveyfaxto) && $surveyfaxto != '000-00000000') {
$survey_output['FAX_TO'] = gT("Please fax your completed survey to:") . " {$surveyfaxto}";
}
$total_questions = 0;
$mapquestionsNumbers = array();
$answertext = '';
// otherwise can throw an error on line 1617
$fieldmap = createFieldMap($surveyid, 'full', false, false, $sLanguageCode);
// =========================================================
// START doin the business:
foreach ($degresult->readAll() as $degrow) {
// ---------------------------------------------------
// START doing groups
$deqresult = Question::model()->getQuestions($surveyid, $degrow['gid'], $sLanguageCode, 0, '"I"');
$deqrows = array();
//Create an empty array in case FetchRow does not return any rows
foreach ($deqresult->readAll() as $deqrow) {
$deqrows[] = $deqrow;
}
// Get table output into array
// Perform a case insensitive natural sort on group name then question title of a multidimensional array
usort($deqrows, 'groupOrderThenQuestionOrder');
if ($degrow['description']) {
//.........这里部分代码省略.........
示例6: actionAction
/**
* @param int $surveyid
* @param string $language
*/
public function actionAction($surveyid, $language = null)
{
$sLanguage = $language;
$this->sLanguage = $language;
ob_start(function ($buffer) {
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
ob_implicit_flush(false);
$iSurveyID = (int) $surveyid;
$this->iSurveyID = (int) $surveyid;
//$postlang = returnglobal('lang');
Yii::import('application.libraries.admin.progressbar', true);
Yii::app()->loadHelper("userstatistics");
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('surveytranslator');
App()->getClientScript()->registerPackage('jqueryui');
App()->getClientScript()->registerPackage('jquery-touch-punch');
App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('generalscripts') . "survey_runtime.js");
$data = array();
if (!isset($iSurveyID)) {
$iSurveyID = returnGlobal('sid');
} else {
$iSurveyID = (int) $iSurveyID;
}
if (!$iSurveyID) {
//This next line ensures that the $iSurveyID value is never anything but a number.
safeDie('You have to provide a valid survey ID.');
}
$actresult = Survey::model()->findAll('sid = :sid AND active = :active', array(':sid' => $iSurveyID, ':active' => 'Y'));
//Checked
if (count($actresult) == 0) {
safeDie('You have to provide a valid survey ID.');
} else {
$surveyinfo = getSurveyInfo($iSurveyID);
// CHANGE JSW_NZ - let's get the survey title for display
$thisSurveyTitle = $surveyinfo["name"];
// CHANGE JSW_NZ - let's get css from individual template.css - so define path
$thisSurveyCssPath = getTemplateURL($surveyinfo["template"]);
if ($surveyinfo['publicstatistics'] != 'Y') {
safeDie('The public statistics for this survey are deactivated.');
}
//check if graphs should be shown for this survey
if ($surveyinfo['publicgraphs'] == 'Y') {
$publicgraphs = 1;
} else {
$publicgraphs = 0;
}
}
//we collect all the output within this variable
$statisticsoutput = '';
//for creating graphs we need some more scripts which are included here
//True -> include
//False -> forget about charts
if (isset($publicgraphs) && $publicgraphs == 1) {
require_once APPPATH . 'third_party/pchart/pchart/pChart.class';
require_once APPPATH . 'third_party/pchart/pchart/pData.class';
require_once APPPATH . 'third_party/pchart/pchart/pCache.class';
$MyCache = new pCache(Yii::app()->getConfig("tempdir") . DIRECTORY_SEPARATOR);
//$currentuser is created as prefix for pchart files
if (isset($_SERVER['REDIRECT_REMOTE_USER'])) {
$currentuser = $_SERVER['REDIRECT_REMOTE_USER'];
} else {
if (session_id()) {
$currentuser = substr(session_id(), 0, 15);
} else {
$currentuser = "standard";
}
}
}
// Set language for questions and labels to base language of this survey
if ($sLanguage == null || !in_array($sLanguage, Survey::model()->findByPk($iSurveyID)->getAllLanguages())) {
$sLanguage = Survey::model()->findByPk($iSurveyID)->language;
} else {
$sLanguage = sanitize_languagecode($sLanguage);
}
//set survey language for translations
SetSurveyLanguage($iSurveyID, $sLanguage);
//Create header
sendCacheHeaders();
$condition = false;
$sitename = Yii::app()->getConfig("sitename");
$data['surveylanguage'] = $sLanguage;
$data['sitename'] = $sitename;
$data['condition'] = $condition;
$data['thisSurveyCssPath'] = $thisSurveyCssPath;
/*
* only show questions where question attribute "public_statistics" is set to "1"
*/
$query = "SELECT q.* , group_name, group_order FROM {{questions}} q, {{groups}} g, {{question_attributes}} qa\n WHERE g.gid = q.gid AND g.language = :lang1 AND q.language = :lang2 AND q.sid = :surveyid AND q.qid = qa.qid AND q.parent_qid = 0 AND qa.attribute = 'public_statistics'";
$databasetype = Yii::app()->db->getDriverName();
if ($databasetype == 'mssql' || $databasetype == "sqlsrv" || $databasetype == "dblib") {
$query .= " AND CAST(CAST(qa.value as varchar) as int)='1'\n";
} else {
$query .= " AND qa.value='1'\n";
//.........这里部分代码省略.........
示例7: actionView
/**
* printanswers::view()
* View answers at the end of a survey in one place. To export as pdf, set 'usepdfexport' = 1 in lsconfig.php and $printableexport='pdf'.
* @param mixed $surveyid
* @param bool $printableexport
* @return
*/
function actionView($surveyid, $printableexport = FALSE)
{
global $siteadminname, $siteadminemail;
Yii::app()->loadHelper("frontend");
Yii::import('application.libraries.admin.pdf');
$surveyid = (int) $surveyid;
Yii::app()->loadHelper('database');
if (isset($_SESSION['survey_' . $surveyid]['sid'])) {
$surveyid = $_SESSION['survey_' . $surveyid]['sid'];
} else {
die('Invalid survey/session');
}
//Debut session time out
if (!isset($_SESSION['survey_' . $surveyid]['finished']) || !isset($_SESSION['survey_' . $surveyid]['srid'])) {
//require_once($rootdir.'/classes/core/language.php');
$baselang = Survey::model()->findByPk($surveyid)->language;
Yii::import('application.libraries.Limesurvey_lang', true);
$clang = new Limesurvey_lang($baselang);
//A nice exit
sendCacheHeaders();
doHeader();
echo templatereplace(file_get_contents(getTemplatePath(validateTemplateDir("default")) . "/startpage.pstpl"), array(), array());
echo "<center><br />\n" . "\t<font color='RED'><strong>" . $clang->gT("Error") . "</strong></font><br />\n" . "\t" . $clang->gT("We are sorry but your session has expired.") . "<br />" . $clang->gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection.") . "<br />\n" . "\t" . sprintf($clang->gT("Please contact %s ( %s ) for further assistance."), $siteadminname, $siteadminemail) . "\n" . "</center><br />\n";
echo templatereplace(file_get_contents(getTemplatePath(validateTemplateDir("default")) . "/endpage.pstpl"), array(), array());
doFooter();
exit;
}
//Fin session time out
$id = $_SESSION['survey_' . $surveyid]['srid'];
//I want to see the answers with this id
$clang = $_SESSION['survey_' . $surveyid]['s_lang'];
//Ensure script is not run directly, avoid path disclosure
//if (!isset($rootdir) || isset($_REQUEST['$rootdir'])) {die( "browse - Cannot run this script directly");}
// Set the language for dispay
//require_once($rootdir.'/classes/core/language.php'); // has been secured
if (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
$clang = SetSurveyLanguage($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
$language = $_SESSION['survey_' . $surveyid]['s_lang'];
} else {
$language = Survey::model()->findByPk($surveyid)->language;
$clang = SetSurveyLanguage($surveyid, $language);
}
// Get the survey inforamtion
$thissurvey = getSurveyInfo($surveyid, $language);
//SET THE TEMPLATE DIRECTORY
if (!isset($thissurvey['templatedir']) || !$thissurvey['templatedir']) {
$thistpl = validateTemplateDir("default");
} else {
$thistpl = validateTemplateDir($thissurvey['templatedir']);
}
if ($thissurvey['printanswers'] == 'N') {
die;
//Die quietly if print answers is not permitted
}
//CHECK IF SURVEY IS ACTIVATED AND EXISTS
$surveytable = "{{survey_{$surveyid}}}";
$surveyname = $thissurvey['surveyls_title'];
$anonymized = $thissurvey['anonymized'];
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
$printoutput = '';
$printoutput .= "<form action='" . Yii::app()->getController()->createUrl('printanswers/view/surveyid/' . $surveyid . '/printableexport/pdf') . "' method='post'>\n<center><input type='submit' value='" . $clang->gT("PDF export") . "'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
if ($printableexport == 'pdf') {
require Yii::app()->getConfig('rootdir') . '/application/config/tcpdf.php';
Yii::import('application.libraries.admin.pdf', true);
$pdf = new pdf();
$pdf->setConfig($tcpdf);
//$pdf->SetFont($pdfdefaultfont,'',$pdffontsize);
$pdf->AddPage();
//$pdf->titleintopdf($clang->gT("Survey name (ID)",'unescaped').": {$surveyname} ({$surveyid})");
$pdf->SetTitle($clang->gT("Survey name (ID)", 'unescaped') . ": {$surveyname} ({$surveyid})");
}
$printoutput .= "\t<div class='printouttitle'><strong>" . $clang->gT("Survey name (ID):") . "</strong> {$surveyname} ({$surveyid})</div><p> \n";
LimeExpressionManager::StartProcessingPage(true);
// means that all variables are on the same page
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
LimeExpressionManager::StartProcessingGroup(1, $thissurvey['anonymized'] != "N", $surveyid);
$aFullResponseTable = getFullResponseTable($surveyid, $id, $language, true);
//Get the fieldmap @TODO: do we need to filter out some fields?
unset($aFullResponseTable['id']);
unset($aFullResponseTable['token']);
unset($aFullResponseTable['lastpage']);
unset($aFullResponseTable['startlanguage']);
unset($aFullResponseTable['datestamp']);
unset($aFullResponseTable['startdate']);
$printoutput .= "<table class='printouttable' >\n";
if ($printableexport == 'pdf') {
$pdf->intopdf($clang->gT("Question", 'unescaped') . ": " . $clang->gT("Your answer", 'unescaped'));
}
$oldgid = 0;
$oldqid = 0;
foreach ($aFullResponseTable as $sFieldname => $fname) {
if (substr($sFieldname, 0, 4) == 'gid_') {
//.........这里部分代码省略.........
示例8: actionView
/**
* printanswers::view()
* View answers at the end of a survey in one place. To export as pdf, set 'usepdfexport' = 1 in lsconfig.php and $printableexport='pdf'.
* @param mixed $surveyid
* @param bool $printableexport
* @return
*/
function actionView($surveyid, $printableexport = FALSE)
{
Yii::app()->loadHelper("frontend");
Yii::import('application.libraries.admin.pdf');
$iSurveyID = (int) $surveyid;
$sExportType = $printableexport;
Yii::app()->loadHelper('database');
if (isset($_SESSION['survey_' . $iSurveyID]['sid'])) {
$iSurveyID = $_SESSION['survey_' . $iSurveyID]['sid'];
} else {
//die('Invalid survey/session');
}
// Get the survey inforamtion
// Set the language for dispay
if (isset($_SESSION['survey_' . $iSurveyID]['s_lang'])) {
$sLanguage = $_SESSION['survey_' . $iSurveyID]['s_lang'];
} elseif (Survey::model()->findByPk($iSurveyID)) {
$sLanguage = Survey::model()->findByPk($iSurveyID)->language;
} else {
$iSurveyID = 0;
$sLanguage = Yii::app()->getConfig("defaultlang");
}
SetSurveyLanguage($iSurveyID, $sLanguage);
$aSurveyInfo = getSurveyInfo($iSurveyID, $sLanguage);
$oTemplate = Template::model()->getInstance(null, $iSurveyID);
//Survey is not finished or don't exist
if (!isset($_SESSION['survey_' . $iSurveyID]['finished']) || !isset($_SESSION['survey_' . $iSurveyID]['srid'])) {
sendCacheHeaders();
doHeader();
/// $oTemplate is a global variable defined in controller/survey/index
echo templatereplace(file_get_contents($oTemplate->viewPath . '/startpage.pstpl'), array());
echo "<center><br />\n" . "\t<font color='RED'><strong>" . gT("Error") . "</strong></font><br />\n" . "\t" . gT("We are sorry but your session has expired.") . "<br />" . gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection.") . "<br />\n" . "\t" . sprintf(gT("Please contact %s ( %s ) for further assistance."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")) . "\n" . "</center><br />\n";
echo templatereplace(file_get_contents($oTemplate->viewPath . '/endpage.pstpl'), array());
doFooter();
exit;
}
//Fin session time out
$sSRID = $_SESSION['survey_' . $iSurveyID]['srid'];
//I want to see the answers with this id
//Ensure script is not run directly, avoid path disclosure
//if (!isset($rootdir) || isset($_REQUEST['$rootdir'])) {die( "browse - Cannot run this script directly");}
//Ensure Participants printAnswer setting is set to true or that the logged user have read permissions over the responses.
if ($aSurveyInfo['printanswers'] == 'N' && !Permission::model()->hasSurveyPermission($iSurveyID, 'responses', 'read')) {
throw new CHttpException(401, 'You are not allowed to print answers.');
}
//CHECK IF SURVEY IS ACTIVATED AND EXISTS
$sSurveyName = $aSurveyInfo['surveyls_title'];
$sAnonymized = $aSurveyInfo['anonymized'];
//OK. IF WE GOT THIS FAR, THEN THE SURVEY EXISTS AND IT IS ACTIVE, SO LETS GET TO WORK.
//SHOW HEADER
if ($sExportType != 'pdf') {
$sOutput = CHtml::form(array("printanswers/view/surveyid/{$iSurveyID}/printableexport/pdf"), 'post') . "<center><input class='btn btn-default' type='submit' value='" . gT("PDF export") . "'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
$sOutput .= "\t<div class='printouttitle'><strong>" . gT("Survey name (ID):") . "</strong> {$sSurveyName} ({$iSurveyID})</div><p> \n";
LimeExpressionManager::StartProcessingPage(true);
// means that all variables are on the same page
// Since all data are loaded, and don't need JavaScript, pretend all from Group 1
LimeExpressionManager::StartProcessingGroup(1, $aSurveyInfo['anonymized'] != "N", $iSurveyID);
$printanswershonorsconditions = Yii::app()->getConfig('printanswershonorsconditions');
$aFullResponseTable = getFullResponseTable($iSurveyID, $sSRID, $sLanguage, $printanswershonorsconditions);
//Get the fieldmap @TODO: do we need to filter out some fields?
if ($aSurveyInfo['datestamp'] != "Y" || $sAnonymized == 'Y') {
unset($aFullResponseTable['submitdate']);
} else {
unset($aFullResponseTable['id']);
}
unset($aFullResponseTable['token']);
unset($aFullResponseTable['lastpage']);
unset($aFullResponseTable['startlanguage']);
unset($aFullResponseTable['datestamp']);
unset($aFullResponseTable['startdate']);
$sOutput .= "<table class='printouttable' >\n";
foreach ($aFullResponseTable as $sFieldname => $fname) {
if (substr($sFieldname, 0, 4) == 'gid_') {
$sOutput .= "\t<tr class='printanswersgroup'><td colspan='2'>{$fname[0]}</td></tr>\n";
$sOutput .= "\t<tr class='printanswersgroupdesc'><td colspan='2'>{$fname[1]}</td></tr>\n";
} elseif ($sFieldname == 'submitdate') {
if ($sAnonymized != 'Y') {
$sOutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]} {$sFieldname}</td><td class='printanswersanswertext'>{$fname[2]}</td></tr>";
}
} elseif (substr($sFieldname, 0, 4) != 'qid_') {
$sOutput .= "\t<tr class='printanswersquestion'><td>{$fname[0]} {$fname[1]}</td><td class='printanswersanswertext'>" . flattenText($fname[2]) . "</td></tr>";
}
}
$sOutput .= "</table>\n";
$sData['thissurvey'] = $aSurveyInfo;
$sOutput = templatereplace($sOutput, array(), $sData, '', $aSurveyInfo['anonymized'] == "Y", NULL, array(), true);
// Do a static replacement
ob_start(function ($buffer, $phase) {
App()->getClientScript()->render($buffer);
App()->getClientScript()->reset();
return $buffer;
});
ob_implicit_flush(false);
//.........这里部分代码省略.........
示例9: action
function action()
{
global $surveyid;
global $thissurvey, $thisstep;
global $clienttoken, $tokensexist, $token;
global $clang;
$clang = Yii::app()->lang;
@ini_set('session.gc_maxlifetime', Yii::app()->getConfig('iSessionExpirationTime'));
$this->_loadRequiredHelpersAndLibraries();
$param = $this->_getParameters(func_get_args(), $_POST);
$surveyid = $param['sid'];
Yii::app()->setConfig('surveyID', $surveyid);
$thisstep = $param['thisstep'];
$move = $param['move'];
$clienttoken = $param['token'];
$standardtemplaterootdir = Yii::app()->getConfig('standardtemplaterootdir');
// unused vars in this method (used in methods using compacted method vars)
@($loadname = $param['loadname']);
@($loadpass = $param['loadpass']);
$sitename = Yii::app()->getConfig('sitename');
if (isset($param['newtest']) && $param['newtest'] == "Y") {
killSurveySession($surveyid);
}
list($surveyExists, $isSurveyActive) = $this->_surveyExistsAndIsActive($surveyid);
// collect all data in this method to pass on later
$redata = compact(array_keys(get_defined_vars()));
$clang = $this->_loadLimesurveyLang($surveyid);
if ($this->_isClientTokenDifferentFromSessionToken($clienttoken, $surveyid)) {
$asMessage = array($clang->gT('Token mismatch'), $clang->gT('The token you provided doesn\'t match the one in your session.'), $clang->gT('Please wait to begin with a new session.'));
$this->_createNewUserSessionAndRedirect($surveyid, $redata, __LINE__, $asMessage);
}
if ($this->_isSurveyFinished($surveyid)) {
$asMessage = array($clang->gT('Previous session is set to be finished.'), $clang->gT('Your browser reports that it was used previously to answer this survey. We are resetting the session so that you can start from the beginning.'), $clang->gT('Please wait to begin with a new session.'));
$this->_createNewUserSessionAndRedirect($surveyid, $redata, __LINE__, $asMessage);
}
if ($this->_isPreviewAction($param) && !$this->_canUserPreviewSurvey($surveyid)) {
$asMessage = array($clang->gT('Error'), $clang->gT('We are sorry but you don\'t have permissions to do this.'));
$this->_niceExit($redata, __LINE__, null, $asMessage);
}
if ($this->_surveyCantBeViewedWithCurrentPreviewAccess($surveyid, $isSurveyActive, $surveyExists)) {
$bPreviewRight = $this->_userHasPreviewAccessSession($surveyid);
if ($bPreviewRight === false) {
$asMessage = array($clang->gT("Error"), $clang->gT("We are sorry but you don't have permissions to do this."), sprintf($clang->gT("Please contact %s ( %s ) for further assistance."), $thissurvey['adminname'], $thissurvey['adminemail']));
$this->_niceExit($redata, __LINE__, null, $asMessage);
}
}
// TODO can this be moved to the top?
// (Used to be global, used in ExpressionManager, merged into amVars. If not filled in === '')
// can this be added in the first computation of $redata?
if (isset($_SESSION['survey_' . $surveyid]['srid'])) {
$saved_id = $_SESSION['survey_' . $surveyid]['srid'];
}
// recompute $redata since $saved_id used to be a global
$redata = compact(array_keys(get_defined_vars()));
/*if ( $this->_didSessionTimeOut() )
{
// @TODO is this still required ?
$asMessage = array(
$clang->gT("Error"),
$clang->gT("We are sorry but your session has expired."),
$clang->gT("Either you have been inactive for too long, you have cookies disabled for your browser, or there were problems with your connection."),
sprintf($clang->gT("Please contact %s ( %s ) for further assistance."),$thissurvey['adminname'],$thissurvey['adminemail'])
);
$this->_niceExit($redata, __LINE__, null, $asMessage);
};*/
// Set the language of the survey, either from POST, GET parameter of session var
if (!empty($_REQUEST['lang'])) {
$sTempLanguage = sanitize_languagecode($_REQUEST['lang']);
} elseif (!empty($param['lang'])) {
$sTempLanguage = sanitize_languagecode($param['lang']);
} elseif (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
$sTempLanguage = $_SESSION['survey_' . $surveyid]['s_lang'];
} else {
$sTempLanguage = '';
}
//CHECK FOR REQUIRED INFORMATION (sid)
if ($surveyid && $surveyExists) {
LimeExpressionManager::SetSurveyId($surveyid);
// must be called early - it clears internal cache if a new survey is being used
$clang = SetSurveyLanguage($surveyid, $sTempLanguage);
UpdateSessionGroupList($surveyid, $sTempLanguage);
// to refresh the language strings in the group list session variable
UpdateFieldArray();
// to refresh question titles and question text
} else {
if (!is_null($param['lang'])) {
$sDisplayLanguage = $param['lang'];
} else {
$sDisplayLanguage = Yii::app()->getConfig('defaultlang');
}
$clang = $this->_loadLimesurveyLang($sDisplayLanguage);
$languagechanger = makeLanguageChanger($sDisplayLanguage);
//Find out if there are any publicly available surveys
$query = "SELECT sid, surveyls_title, publicstatistics, language\n FROM {{surveys}}\n INNER JOIN {{surveys_languagesettings}}\n ON ( surveyls_survey_id = sid )\n AND (surveyls_language=language)\n WHERE\n active='Y'\n AND listpublic='Y'\n AND ((expires >= '" . date("Y-m-d H:i") . "') OR (expires is null))\n AND ((startdate <= '" . date("Y-m-d H:i") . "') OR (startdate is null))\n ORDER BY surveyls_title";
$result = dbExecuteAssoc($query, false, true) or safeDie("Could not connect to database. If you try to install LimeSurvey please refer to the <a href='http://docs.limesurvey.org'>installation docs</a> and/or contact the system administrator of this webpage.");
//Checked
$list = array();
foreach ($result->readAll() as $rows) {
$querylang = "SELECT surveyls_title\n FROM {{surveys_languagesettings}}\n WHERE surveyls_survey_id={$rows['sid']}\n AND surveyls_language='{$sDisplayLanguage}'";
$resultlang = Yii::app()->db->createCommand($querylang)->queryRow();
//.........这里部分代码省略.........
示例10: createFieldMap
/**
* This function generates an array containing the fieldcode, and matching data in the same order as the activate script
*
* @param string $surveyid The Survey ID
* @param mixed $style 'short' (default) or 'full' - full creates extra information like default values
* @param mixed $force_refresh - Forces to really refresh the array, not just take the session copy
* @param int $questionid Limit to a certain qid only (for question preview) - default is false
* @return array
*/
function createFieldMap($surveyid, $style = 'full', $force_refresh = false, $questionid = false, $sQuestionLanguage = null)
{
global $dbprefix, $connect, $clang, $aDuplicateQIDs;
$surveyid = sanitize_int($surveyid);
//Get list of questions
if (is_null($sQuestionLanguage)) {
if (isset($_SESSION['s_lang']) && in_array($_SESSION['s_lang'], GetAdditionalLanguagesFromSurveyID($surveyid))) {
$sQuestionLanguage = $_SESSION['s_lang'];
} else {
$sQuestionLanguage = GetBaseLanguageFromSurveyID($surveyid);
}
}
$sQuestionLanguage = sanitize_languagecode($sQuestionLanguage);
if ($clang->langcode != $sQuestionLanguage) {
SetSurveyLanguage($surveyid, $sQuestionLanguage);
}
$s_lang = $clang->langcode;
//checks to see if fieldmap has already been built for this page.
if (isset($_SESSION['fieldmap-' . $surveyid . $s_lang]) && !$force_refresh && $questionid == false) {
if (isset($_SESSION['adminlang']) && $clang->langcode != $_SESSION['adminlang']) {
$clang = new limesurvey_lang($_SESSION['adminlang']);
}
return $_SESSION['fieldmap-' . $surveyid . $s_lang];
}
$fieldmap["id"] = array("fieldname" => "id", 'sid' => $surveyid, 'type' => "id", "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["id"]['title'] = "";
$fieldmap["id"]['question'] = $clang->gT("Response ID");
$fieldmap["id"]['group_name'] = "";
}
$fieldmap["submitdate"] = array("fieldname" => "submitdate", 'type' => "submitdate", 'sid' => $surveyid, "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["submitdate"]['title'] = "";
$fieldmap["submitdate"]['question'] = $clang->gT("Date submitted");
$fieldmap["submitdate"]['group_name'] = "";
}
$fieldmap["lastpage"] = array("fieldname" => "lastpage", 'sid' => $surveyid, 'type' => "lastpage", "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["lastpage"]['title'] = "";
$fieldmap["lastpage"]['question'] = $clang->gT("Last page");
$fieldmap["lastpage"]['group_name'] = "";
}
$fieldmap["startlanguage"] = array("fieldname" => "startlanguage", 'sid' => $surveyid, 'type' => "startlanguage", "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["startlanguage"]['title'] = "";
$fieldmap["startlanguage"]['question'] = $clang->gT("Start language");
$fieldmap["startlanguage"]['group_name'] = "";
}
//Check for any additional fields for this survey and create necessary fields (token and datestamp and ipaddr)
$pquery = "SELECT anonymized, datestamp, ipaddr, refurl FROM " . db_table_name('surveys') . " WHERE sid={$surveyid}";
$presult = db_execute_assoc($pquery);
//Checked
while ($prow = $presult->FetchRow()) {
if ($prow['anonymized'] == "N") {
$fieldmap["token"] = array("fieldname" => "token", 'sid' => $surveyid, 'type' => "token", "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["token"]['title'] = "";
$fieldmap["token"]['question'] = $clang->gT("Token");
$fieldmap["token"]['group_name'] = "";
}
}
if ($prow['datestamp'] == "Y") {
$fieldmap["datestamp"] = array("fieldname" => "datestamp", 'type' => "datestamp", 'sid' => $surveyid, "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["datestamp"]['title'] = "";
$fieldmap["datestamp"]['question'] = $clang->gT("Date last action");
$fieldmap["datestamp"]['group_name'] = "";
}
$fieldmap["startdate"] = array("fieldname" => "startdate", 'type' => "startdate", 'sid' => $surveyid, "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["startdate"]['title'] = "";
$fieldmap["startdate"]['question'] = $clang->gT("Date started");
$fieldmap["startdate"]['group_name'] = "";
}
}
if ($prow['ipaddr'] == "Y") {
$fieldmap["ipaddr"] = array("fieldname" => "ipaddr", 'type' => "ipaddress", 'sid' => $surveyid, "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["ipaddr"]['title'] = "";
$fieldmap["ipaddr"]['question'] = $clang->gT("IP address");
$fieldmap["ipaddr"]['group_name'] = "";
}
}
// Add 'refurl' to fieldmap.
if ($prow['refurl'] == "Y") {
$fieldmap["refurl"] = array("fieldname" => "refurl", 'type' => "url", 'sid' => $surveyid, "gid" => "", "qid" => "", "aid" => "");
if ($style == "full") {
$fieldmap["refurl"]['title'] = "";
$fieldmap["refurl"]['question'] = $clang->gT("Referrer URL");
$fieldmap["refurl"]['group_name'] = "";
}
//.........这里部分代码省略.........
示例11: buildsurveysession
//.........这里部分代码省略.........
echo '</div>' . templatereplace(file_get_contents("{$thistpl}/endpage.pstpl"));
doFooter();
unset($_SESSION['srid']);
exit;
}
}
}
//RESET ALL THE SESSION VARIABLES AND START AGAIN
unset($_SESSION['grouplist']);
unset($_SESSION['fieldarray']);
unset($_SESSION['insertarray']);
unset($_SESSION['thistoken']);
unset($_SESSION['fieldnamesInfo']);
$_SESSION['fieldnamesInfo'] = array();
//RL: multilingual support
if (isset($_GET['token']) && db_tables_exist($dbprefix . 'tokens_' . $surveyid)) {
//get language from token (if one exists)
$tkquery2 = "SELECT * FROM " . db_table_name('tokens_' . $surveyid) . " WHERE token='" . db_quote($clienttoken) . "' AND (completed = 'N' or completed='')";
//echo $tkquery2;
$result = db_execute_assoc($tkquery2) or safe_die("Couldn't get tokens<br />{$tkquery}<br />" . $connect->ErrorMsg());
//Checked
while ($rw = $result->FetchRow()) {
$tklanguage = $rw['language'];
}
}
if (returnglobal('lang')) {
$language_to_set = returnglobal('lang');
} elseif (isset($tklanguage)) {
$language_to_set = $tklanguage;
} else {
$language_to_set = $thissurvey['language'];
}
if (!isset($_SESSION['s_lang'])) {
SetSurveyLanguage($surveyid, $language_to_set);
}
UpdateSessionGroupList($_SESSION['s_lang']);
// Optimized Query
// Change query to use sub-select to see if conditions exist.
$query = "SELECT " . db_table_name('questions') . ".*, " . db_table_name('groups') . ".*,\n" . " (SELECT count(1) FROM " . db_table_name('conditions') . "\n" . " WHERE " . db_table_name('questions') . ".qid = " . db_table_name('conditions') . ".qid) AS hasconditions,\n" . " (SELECT count(1) FROM " . db_table_name('conditions') . "\n" . " WHERE " . db_table_name('questions') . ".qid = " . db_table_name('conditions') . ".cqid) AS usedinconditions\n" . " FROM " . db_table_name('groups') . " INNER JOIN " . db_table_name('questions') . " ON " . db_table_name('groups') . ".gid = " . db_table_name('questions') . ".gid\n" . " WHERE " . db_table_name('questions') . ".sid=" . $surveyid . "\n" . " AND " . db_table_name('groups') . ".language='" . $_SESSION['s_lang'] . "'\n" . " AND " . db_table_name('questions') . ".language='" . $_SESSION['s_lang'] . "'\n" . " AND " . db_table_name('questions') . ".parent_qid=0\n" . " ORDER BY " . db_table_name('groups') . ".group_order," . db_table_name('questions') . ".question_order";
//var_dump($_SESSION);
$result = db_execute_assoc($query);
//Checked
$arows = $result->GetRows();
$totalquestions = $result->RecordCount();
//2. SESSION VARIABLE: totalsteps
//The number of "pages" that will be presented in this survey
//The number of pages to be presented will differ depending on the survey format
switch ($thissurvey['format']) {
case "A":
$_SESSION['totalsteps'] = 1;
break;
case "G":
if (isset($_SESSION['grouplist'])) {
$_SESSION['totalsteps'] = count($_SESSION['grouplist']);
}
break;
case "S":
$_SESSION['totalsteps'] = $totalquestions;
}
if ($totalquestions == "0") {
sendcacheheaders();
doHeader();
echo templatereplace(file_get_contents("{$thistpl}/startpage.pstpl"));
echo templatereplace(file_get_contents("{$thistpl}/survey.pstpl"));
echo "\t<div id='wrapper'>\n" . "\t<p id='tokenmessage'>\n" . "\t" . $clang->gT("This survey does not yet have any questions and cannot be tested or completed.") . "<br /><br />\n" . "\t" . sprintf($clang->gT("For further information please contact %s"), $thissurvey['adminname']) . " (<a href='mailto:{$thissurvey['adminemail']}'>" . "{$thissurvey['adminemail']}</a>)<br /><br />\n" . "\t</p>\n" . "\t</div>\n";
echo templatereplace(file_get_contents("{$thistpl}/endpage.pstpl"));
示例12: array
/**
* TSV survey definition in format readable by TSVSurveyImport
* one line each per group, question, sub-question, and answer
* does not use SGQA naming at all.
* @param type $sid
* @return type
*/
public static function &TSVSurveyExport($sid)
{
$aBaseFields = array('class', 'type/scale', 'name', 'relevance', 'text', 'help', 'language', 'validation', 'mandatory', 'other', 'default', 'same_default');
// Advanced question attributes : @todo get used question attribute by question in survey ?
$aQuestionAttributes = array_keys(\ls\helpers\questionHelper::getAttributesDefinitions());
sort($aQuestionAttributes);
$fields = array_merge($aBaseFields, $aQuestionAttributes);
$rows = array();
$primarylang = 'en';
$otherlangs = '';
$langs = array();
// Export survey-level information
$query = "select * from {{surveys}} where sid = " . $sid;
$data = dbExecuteAssoc($query);
foreach ($data->readAll() as $r) {
foreach ($r as $key => $value) {
if ($value != '') {
$row['class'] = 'S';
$row['name'] = $key;
$row['text'] = $value;
$rows[] = $row;
}
if ($key == 'language') {
$primarylang = $value;
}
if ($key == 'additional_languages') {
$otherlangs = $value;
}
}
}
$langs = explode(' ', $primarylang . ' ' . $otherlangs);
$langs = array_unique($langs);
// Export survey language settings
$query = "select * from {{surveys_languagesettings}} where surveyls_survey_id = " . $sid;
$data = dbExecuteAssoc($query);
foreach ($data->readAll() as $r) {
$_lang = $r['surveyls_language'];
foreach ($r as $key => $value) {
if ($value != '' && $key != 'surveyls_language' && $key != 'surveyls_survey_id') {
$row['class'] = 'SL';
$row['name'] = $key;
$row['text'] = $value;
$row['language'] = $_lang;
$rows[] = $row;
}
}
}
$surveyinfo = getSurveyInfo($sid);
$assessments = false;
if (isset($surveyinfo['assessments']) && $surveyinfo['assessments'] == 'Y') {
$assessments = true;
}
foreach ($langs as $lang) {
if (trim($lang) == '') {
continue;
}
SetSurveyLanguage($sid, $lang);
LimeExpressionManager::StartSurvey($sid, 'survey', array('sgqaNaming' => 'N', 'assessments' => $assessments), true);
$moveResult = LimeExpressionManager::NavigateForwards();
$LEM =& LimeExpressionManager::singleton();
if (is_null($moveResult) || is_null($LEM->currentQset) || count($LEM->currentQset) == 0) {
continue;
}
$_gseq = -1;
foreach ($LEM->currentQset as $q) {
$gseq = $q['info']['gseq'];
$gid = $q['info']['gid'];
$qid = $q['info']['qid'];
//////
// SHOW GROUP-LEVEL INFO
//////
if ($gseq != $_gseq) {
$_gseq = $gseq;
$ginfo = $LEM->gseq2info[$gseq];
// if relevance equation is using SGQA coding, convert to qcoding
$grelevance = $ginfo['grelevance'] == '' ? 1 : $ginfo['grelevance'];
$LEM->em->ProcessBooleanExpression($grelevance, $gseq, 0);
// $qseq
$grelevance = trim(strip_tags($LEM->em->GetPrettyPrintString()));
$gtext = trim($ginfo['description']) == '' ? '' : $ginfo['description'];
$row = array();
$row['class'] = 'G';
//create a group code to allow proper importing of multi-lang survey TSVs
$row['type/scale'] = 'G' . $gseq;
$row['name'] = $ginfo['group_name'];
$row['relevance'] = $grelevance;
$row['text'] = $gtext;
$row['language'] = $lang;
$row['random_group'] = $ginfo['randomization_group'];
$rows[] = $row;
}
//////
// SHOW QUESTION-LEVEL INFO
//.........这里部分代码省略.........
示例13: buildsurveysession
//.........这里部分代码省略.........
$aEnterTokenData = array();
$aEnterTokenData['bNewTest'] = false;
$aEnterTokenData['bDirectReload'] = false;
$aEnterTokenData['error'] = $secerror;
$aEnterTokenData['iSurveyId'] = $surveyid;
$aEnterTokenData['sKpClass'] = $kpclass;
// ???
$aEnterTokenData['sLangCode'] = $sLangCode;
if (isset($_GET['bNewTest']) && $_GET['newtest'] == "Y") {
$aEnterTokenData['bNewTest'] = true;
}
// If this is a direct Reload previous answers URL, then add hidden fields
if (isset($loadall) && isset($scid) && isset($loadname) && isset($loadpass)) {
$aEnterTokenData['bDirectReload'] = true;
$aEnterTokenData['sCid'] = $scid;
$aEnterTokenData['sLoadname'] = htmlspecialchars($loadname);
$aEnterTokenData['sLoadpass'] = htmlspecialchars($loadpass);
}
$FlashError = "";
// Scenario => Captcha required
if ($scenarios['captchaRequired'] && !$preview) {
list($renderCaptcha, $FlashError) = testCaptcha($aEnterTokenData, $subscenarios, $surveyid, $loadsecurity);
}
// Scenario => Token required
if ($scenarios['tokenRequired'] && !$preview) {
//Test if token is valid
list($renderToken, $FlashError) = testIfTokenIsValid($subscenarios, $thissurvey, $aEnterTokenData, $clienttoken);
}
//If there were errors, display through yii->FlashMessage
if ($FlashError !== "") {
$aEnterTokenData['errorMessage'] = $FlashError;
}
$renderWay = getRenderWay($renderToken, $renderCaptcha);
$redata = compact(array_keys(get_defined_vars()));
renderRenderWayForm($renderWay, $redata, $scenarios, $sTemplateViewPath, $aEnterTokenData, $surveyid);
// Reset all the session variables and start again
resetAllSessionVariables($surveyid);
// Multi lingual support order : by REQUEST, if not by Token->language else by survey default language
if (returnGlobal('lang', true)) {
$language_to_set = returnGlobal('lang', true);
} elseif (isset($oTokenEntry) && $oTokenEntry) {
// If survey have token : we have a $oTokenEntry
// Can use $oTokenEntry = Token::model($surveyid)->findByAttributes(array('token'=>$clienttoken)); if we move on another function : this par don't validate the token validity
$language_to_set = $oTokenEntry->language;
} else {
$language_to_set = $thissurvey['language'];
}
// Always SetSurveyLanguage : surveys controller SetSurveyLanguage too, if different : broke survey (#09769)
SetSurveyLanguage($surveyid, $language_to_set);
UpdateGroupList($surveyid, $_SESSION['survey_' . $surveyid]['s_lang']);
$totalquestions = Question::model()->getTotalQuestions($surveyid);
$iTotalGroupsWithoutQuestions = QuestionGroup::model()->getTotalGroupsWithoutQuestions($surveyid);
// Fix totalquestions by substracting Test Display questions
$iNumberofQuestions = Question::model()->getNumberOfQuestions($surveyid);
$_SESSION['survey_' . $surveyid]['totalquestions'] = $totalquestions - (int) reset($iNumberofQuestions);
// 2. SESSION VARIABLE: totalsteps
setTotalSteps($surveyid, $thissurvey, $totalquestions);
// Break out and crash if there are no questions!
if ($totalquestions == 0 || $iTotalGroupsWithoutQuestions > 0) {
$redata = compact(array_keys(get_defined_vars()));
breakOutAndCrash($redata, $sTemplateViewPath, $totalquestions, $iTotalGroupsWithoutQuestions, $thissurvey);
}
//Perform a case insensitive natural sort on group name then question title of a multidimensional array
// usort($arows, 'groupOrderThenQuestionOrder');
//3. SESSION VARIABLE - insertarray
//An array containing information about used to insert the data into the db at the submit stage
//4. SESSION VARIABLE - fieldarray
//See rem at end..
if ($tokensexist == 1 && $clienttoken) {
$_SESSION['survey_' . $surveyid]['token'] = $clienttoken;
}
if ($thissurvey['anonymized'] == "N") {
$_SESSION['survey_' . $surveyid]['insertarray'][] = "token";
}
$qtypes = getQuestionTypeList('', 'array');
$fieldmap = createFieldMap($surveyid, 'full', true, false, $_SESSION['survey_' . $surveyid]['s_lang']);
//$seed = ls\mersenne\getSeed($surveyid, $preview);
// Randomization groups for groups
list($fieldmap, $randomized1) = randomizationGroup($surveyid, $fieldmap, $preview);
// Randomization groups for questions
list($fieldmap, $randomized2) = randomizationQuestion($surveyid, $fieldmap, $preview);
$randomized = $randomized1 || $randomized2;
if ($randomized === true) {
$fieldmap = finalizeRandomization($fieldmap);
$_SESSION['survey_' . $surveyid]['fieldmap-' . $surveyid . $_SESSION['survey_' . $surveyid]['s_lang']] = $fieldmap;
$_SESSION['survey_' . $surveyid]['fieldmap-' . $surveyid . '-randMaster'] = 'fieldmap-' . $surveyid . $_SESSION['survey_' . $surveyid]['s_lang'];
}
// TMSW Condition->Relevance: don't need hasconditions, or usedinconditions
$_SESSION['survey_' . $surveyid]['fieldmap'] = $fieldmap;
initFieldArray($surveyid, $fieldmap);
// Prefill questions/answers from command line params
prefillFromCommandLine($surveyid);
if (isset($_SESSION['survey_' . $surveyid]['fieldarray'])) {
$_SESSION['survey_' . $surveyid]['fieldarray'] = array_values($_SESSION['survey_' . $surveyid]['fieldarray']);
}
//Check if a passthru label and value have been included in the query url
checkPassthruLabel($surveyid, $preview, $fieldmap);
Yii::trace('end', 'survey.buildsurveysession');
//traceVar($_SESSION['survey_' . $surveyid]);
}
示例14: SetSurveyLanguage
background-color:white;
}
.LEMerror
{
color:red;
font-weight:bold;
}
tr.LEMsubq td
{
background-color:lightyellow;
}
</style>
</head>
<body>
EOD;
SetSurveyLanguage($surveyid, $language);
LimeExpressionManager::SetDirtyFlag();
$result = LimeExpressionManager::ShowSurveyLogicFile($surveyid, $gid, $qid,$LEMdebugLevel,$assessments);
print $result['html'];
print <<< EOD
</body>
</html>
EOD;
}
?>
示例15: run
function run($actionID)
{
if (isset($_SESSION['LEMsid']) && ($oSurvey = Survey::model()->findByPk($_SESSION['LEMsid']))) {
$surveyid = $_SESSION['LEMsid'];
} else {
throw new CHttpException(400);
// See for debug > 1
}
if (isset($_SESSION['survey_' . $surveyid]['s_lang'])) {
$sLanguage = $_SESSION['survey_' . $surveyid]['s_lang'];
} else {
$sLanguage = '';
}
$clang = SetSurveyLanguage($surveyid, $sLanguage);
$uploaddir = Yii::app()->getConfig("uploaddir");
$tempdir = Yii::app()->getConfig("tempdir");
Yii::app()->loadHelper("database");
// Fill needed var
$sFileGetContent = Yii::app()->request->getParam('filegetcontents', '');
// The file to view fu_ or fu_tmp
$bDelete = Yii::app()->request->getParam('delete');
$sFieldName = Yii::app()->request->getParam('fieldname');
$sFileName = Yii::app()->request->getParam('filename', '');
// The file to delete fu_ or fu_tmp
$sOriginalFileName = Yii::app()->request->getParam('name', '');
// Used for javascript return only
$sMode = Yii::app()->request->getParam('mode');
$sPreview = Yii::app()->request->getParam('preview', 0);
// Validate and filter and throw error if problems
// Using 'futmp_'.randomChars(15).'_'.$pathinfo['extension'] for filename, then remove all other characters
$sFileGetContentFiltered = preg_replace('/[^a-zA-Z0-9_]/', '', $sFileGetContent);
$sFileNameFiltered = preg_replace('/[^a-zA-Z0-9_]/', '', $sFileName);
$sFieldNameFiltered = preg_replace('/[^X0-9]/', '', $sFieldName);
if ($sFileGetContent != $sFileGetContentFiltered || $sFileName != $sFileNameFiltered || $sFieldName != $sFieldNameFiltered) {
// If one seems to be a hack: Bad request
throw new CHttpException(400);
// See for debug > 1
}
if ($sFileGetContent) {
if (substr($sFileGetContent, 0, 6) == 'futmp_') {
$sFileDir = $tempdir . '/upload/';
} elseif (substr($sFileGetContent, 0, 3) == 'fu_') {
// Need to validate $_SESSION['srid'], and this file is from this srid !
$sFileDir = "{$uploaddir}/surveys/{$surveyid}/files/";
} else {
throw new CHttpException(400);
// See for debug > 1
}
if (is_file($sFileDir . $sFileGetContent)) {
header('Content-Type: ' . CFileHelper::getMimeType($sFileDir . $sFileGetContent));
readfile($sFileDir . $sFileGetContent);
Yii::app()->end();
} else {
Yii::app()->end();
}
} elseif ($bDelete) {
if (substr($sFileName, 0, 6) == 'futmp_') {
$sFileDir = $tempdir . '/upload/';
} elseif (substr($sFileName, 0, 3) == 'fu_') {
// Need to validate $_SESSION['srid'], and this file is from this srid !
$sFileDir = "{$uploaddir}/surveys/{$surveyid}/files/";
} else {
throw new CHttpException(400);
// See for debug > 1
}
if (isset($_SESSION[$sFieldName])) {
// We already have $sFieldName ?
$sJSON = $_SESSION[$sFieldName];
$aFiles = json_decode(stripslashes($sJSON), true);
if (substr($sFileName, 0, 3) == 'fu_') {
$iFileIndex = 0;
$found = false;
foreach ($aFiles as $aFile) {
if ($aFile['filename'] == $sFileName) {
$found = true;
break;
}
$iFileIndex++;
}
if ($found == true) {
unset($aFiles[$iFileIndex]);
}
$_SESSION[$sFieldName] = ls_json_encode($aFiles);
}
}
//var_dump($sFileDir.$sFilename);
// Return some json to do a beautiful text
if (@unlink($sFileDir . $sFileName)) {
echo sprintf($clang->gT('File %s deleted'), $sOriginalFileName);
} else {
echo $clang->gT('Oops, There was an error deleting the file');
}
Yii::app()->end();
}
if ($sMode == "upload") {
$clang = Yii::app()->lang;
$sTempUploadDir = $tempdir . '/upload/';
// Check if exists and is writable
if (!file_exists($sTempUploadDir)) {
// Try to create
//.........这里部分代码省略.........