本文整理汇总了PHP中LimeExpressionManager类的典型用法代码示例。如果您正苦于以下问题:PHP LimeExpressionManager类的具体用法?PHP LimeExpressionManager怎么用?PHP LimeExpressionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LimeExpressionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fixNumbering
/**
* fixes the numbering of questions
* This can happen if question 1 have subquestion code 1 and have question 11 in same survey and group (then same SGQA)
* @param int $fixnumbering
* @todo can call this function (no $_GET, but getParam) AND do it with Yii
*/
function fixNumbering($iQuestionID, $iSurveyID)
{
Yii::app()->loadHelper("database");
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
//Fix a question id - requires renumbering a question
$iQuestionID = (int) $iQuestionID;
$iMaxQID = Question::model()->getMaxId('qid', true);
// Always refresh as we insert new qid's
$iNewQID = $iMaxQID + 1;
// Not sure we can do this in MSSQL ?
$sQuery = "UPDATE {{questions}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
// Update subquestions
$sQuery = "UPDATE {{questions}} SET parent_qid={$iNewQID} WHERE parent_qid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
//Update conditions.. firstly conditions FOR this question
$sQuery = "UPDATE {{conditions}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
//Update default values
$sQuery = "UPDATE {{defaultvalues}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
$sQuery = "UPDATE {{defaultvalues}} SET sqid={$iNewQID} WHERE sqid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
//Update quotas
$sQuery = "UPDATE {{quota_members}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
//Update url params
$sQuery = "UPDATE {{survey_url_parameters}} SET targetqid={$iNewQID} WHERE targetqid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
$sQuery = "UPDATE {{survey_url_parameters}} SET targetsqid={$iNewQID} WHERE targetsqid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
//Now conditions based upon this question
$sQuery = "SELECT cqid, cfieldname FROM {{conditions}} WHERE cqid={$iQuestionID}";
$sResult = Yii::app()->db->createCommand($sQuery)->query();
foreach ($sResult->readAll() as $row) {
$aSwitcher[] = array("cqid" => $row['cqid'], "cfieldname" => $row['cfieldname']);
}
if (isset($aSwitcher)) {
foreach ($aSwitcher as $aSwitch) {
$sQuery = "UPDATE {{conditions}}\n SET cqid={$iNewQID},\n cfieldname='" . str_replace("X" . $iQuestionID, "X" . $iNewQID, $aSwitch['cfieldname']) . "'\n WHERE cqid={$iQuestionID}";
$sResult = db_execute_assosc($sQuery);
}
}
//Now question_attributes
$sQuery = "UPDATE {{question_attributes}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
//Now answers
$sQuery = "UPDATE {{answers}} SET qid={$iNewQID} WHERE qid={$iQuestionID}";
Yii::app()->db->createCommand($sQuery)->query();
LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
}
示例2: actiontokens
function actiontokens($surveyid, $token, $langcode = '')
{
Yii::app()->loadHelper('database');
Yii::app()->loadHelper('sanitize');
$sLanguageCode = $langcode;
$iSurveyID = $surveyid;
$sToken = $token;
$sToken = sanitize_token($sToken);
if (!$iSurveyID) {
$this->redirect(array('/'));
}
$iSurveyID = (int) $iSurveyID;
//Check that there is a SID
// Get passed language from form, so that we dont loose this!
if (!isset($sLanguageCode) || $sLanguageCode == "" || !$sLanguageCode) {
$sBaseLanguage = Survey::model()->findByPk($iSurveyID)->language;
} else {
$sBaseLanguage = sanitize_languagecode($sLanguageCode);
}
Yii::app()->setLanguage($sBaseLanguage);
$aSurveyInfo = getSurveyInfo($iSurveyID, $sBaseLanguage);
if ($aSurveyInfo == false || !tableExists("{{tokens_{$iSurveyID}}}")) {
throw new CHttpException(404, "This survey does not seem to exist. It may have been deleted or the link you were given is outdated or incorrect.");
} else {
LimeExpressionManager::singleton()->loadTokenInformation($iSurveyID, $token, false);
$oToken = Token::model($iSurveyID)->findByAttributes(array('token' => $token));
if (!isset($oToken)) {
$sMessage = gT('You are not a participant in this survey.');
} else {
if ($oToken->emailstatus == 'OptOut') {
$oToken->emailstatus = 'OK';
$oToken->save();
$sMessage = gT('You have been successfully added back to this survey.');
} elseif ($oToken->emailstatus == 'OK') {
$sMessage = gT('You are already a part of this survey.');
} else {
$sMessage = gT('You have been already removed from this survey.');
}
}
}
//PRINT COMPLETED PAGE
if (!$aSurveyInfo['templatedir']) {
$sTemplate = getTemplatePath(Yii::app()->getConfig("defaulttemplate"));
} else {
$sTemplate = getTemplatePath($aSurveyInfo['templatedir']);
}
$this->_renderHtml($sMessage, $sTemplate, $aSurveyInfo);
}
示例3: fixNumbering
/**
* fixes the numbering of questions
* @param <type> $fixnumbering
*/
function fixNumbering($fixnumbering, $iSurveyID)
{
Yii::app()->loadHelper("database");
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyID);
//Fix a question id - requires renumbering a question
$oldqid = $fixnumbering;
$query = "SELECT qid FROM {{questions}} ORDER BY qid DESC";
$result = dbSelectLimitAssoc($query, 1);
foreach ($result->readAll() as $row) {
$lastqid = $row['qid'];
}
$newqid = $lastqid + 1;
$query = "UPDATE {{questions}} SET qid={$newqid} WHERE qid={$oldqid}";
$result = db_execute_assosc($query);
// Update subquestions
$query = "UPDATE {{questions}} SET parent_qid={$newqid} WHERE parent_qid={$oldqid}";
$result = db_execute_assosc($query);
//Update conditions.. firstly conditions FOR this question
$query = "UPDATE {{conditions}} SET qid={$newqid} WHERE qid={$oldqid}";
$result = db_execute_assosc($query);
//Now conditions based upon this question
$query = "SELECT cqid, cfieldname FROM {{conditions}} WHERE cqid={$oldqid}";
$result = dbExecuteAssoc($query);
foreach ($result->readAll() as $row) {
$switcher[] = array("cqid" => $row['cqid'], "cfieldname" => $row['cfieldname']);
}
if (isset($switcher)) {
foreach ($switcher as $switch) {
$query = "UPDATE {{conditions}}\n SET cqid={$newqid},\n cfieldname='" . str_replace("X" . $oldqid, "X" . $newqid, $switch['cfieldname']) . "'\n WHERE cqid={$oldqid}";
$result = db_execute_assosc($query);
}
}
// TMSW Conditions->Relevance: (1) Call LEM->ConvertConditionsToRelevance()when done. (2) Should relevance for old conditions be removed first?
//Now question_attributes
$query = "UPDATE {{question_attributes}} SET qid={$newqid} WHERE qid={$oldqid}";
$result = db_execute_assosc($query);
//Now answers
$query = "UPDATE {{answers}} SET qid={$newqid} WHERE qid={$oldqid}";
$result = db_execute_assosc($query);
LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyID);
}
示例4: fixNumbering
/**
* fixes the numbering of questions
* @global $dbprefix $dbprefix
* @global $connect $connect
* @global $clang $clang
* @param <type> $fixnumbering
*/
function fixNumbering($fixnumbering)
{
global $dbprefix, $connect, $clang, $surveyid;
LimeExpressionManager::RevertUpgradeConditionsToRelevance($surveyid);
//Fix a question id - requires renumbering a question
$oldqid = sanitize_int($fixnumbering);
$query = "SELECT qid FROM {$dbprefix}questions ORDER BY qid DESC";
$result = db_select_limit_assoc($query, 1) or safe_die($query . "<br />" . $connect->ErrorMsg());
while ($row = $result->FetchRow()) {
$lastqid = $row['qid'];
}
$newqid = $lastqid + 1;
$query = "UPDATE {$dbprefix}questions SET qid={$newqid} WHERE qid={$oldqid}";
$result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
// Update subquestions
$query = "UPDATE {$dbprefix}questions SET parent_qid={$newqid} WHERE parent_qid={$oldqid}";
$result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
//Update conditions.. firstly conditions FOR this question
$query = "UPDATE {$dbprefix}conditions SET qid={$newqid} WHERE qid={$oldqid}";
$result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
//Now conditions based upon this question
$query = "SELECT cqid, cfieldname FROM {$dbprefix}conditions WHERE cqid={$oldqid}";
$result = db_execute_assoc($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
while ($row = $result->FetchRow()) {
$switcher[] = array("cqid" => $row['cqid'], "cfieldname" => $row['cfieldname']);
}
if (isset($switcher)) {
foreach ($switcher as $switch) {
$query = "UPDATE {$dbprefix}conditions\n SET cqid={$newqid},\n cfieldname='" . str_replace("X" . $oldqid, "X" . $newqid, $switch['cfieldname']) . "'\n WHERE cqid={$oldqid}";
$result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
}
}
//Now question_attributes
$query = "UPDATE {$dbprefix}question_attributes SET qid={$newqid} WHERE qid={$oldqid}";
$result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
//Now answers
$query = "UPDATE {$dbprefix}answers SET qid={$newqid} WHERE qid={$oldqid}";
$result = $connect->Execute($query) or safe_die($query . "<br />" . $connect->ErrorMsg());
LimeExpressionManager::UpgradeConditionsToRelevance($surveyid);
}
示例5: count
<?php
$data = LimeExpressionManager::UpgradeConditionsToRelevance();
if (is_null($data)) {
echo "No conditions found in database";
} else {
echo "Found and converted conditions for " . count($data) . " question(s)<br/>";
echo "<pre>";
print_r($data);
echo "</pre>";
}
示例6: limesurvey_lang
$clang = new limesurvey_lang("en");
$surveyInfo = explode('|', $_POST['sid']);
$surveyid = $surveyInfo[0];
$assessments = $surveyInfo[1] == 'Y';
$surveyMode = $_POST['surveyMode'];
$LEMdebugLevel = (isset($_POST['LEM_DEBUG_TIMING']) && $_POST['LEM_DEBUG_TIMING'] == 'Y' ? LEM_DEBUG_TIMING : 0) + (isset($_POST['LEM_DEBUG_VALIDATION_SUMMARY']) && $_POST['LEM_DEBUG_VALIDATION_SUMMARY'] == 'Y' ? LEM_DEBUG_VALIDATION_SUMMARY : 0) + (isset($_POST['LEM_DEBUG_VALIDATION_DETAIL']) && $_POST['LEM_DEBUG_VALIDATION_DETAIL'] == 'Y' ? LEM_DEBUG_VALIDATION_DETAIL : 0) + (isset($_POST['LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB']) && $_POST['LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB'] == 'Y' ? LEM_DEBUG_LOG_SYNTAX_ERRORS_TO_DB : 0) + (isset($_POST['LEM_PRETTY_PRINT_ALL_SYNTAX']) && $_POST['LEM_PRETTY_PRINT_ALL_SYNTAX'] == 'Y' ? LEM_PRETTY_PRINT_ALL_SYNTAX : 0);
$surveyOptions = array('active' => false, 'allowsave' => true, 'anonymized' => false, 'assessments' => $assessments, 'datestamp' => true, 'hyperlinkSyntaxHighlighting' => true, 'ipaddr' => true, 'rooturl' => '../../..');
print '<h3>Starting survey ' . $surveyid . " using Survey Mode '" . $surveyMode . ($assessments ? "' [Uses Assessments]" : "'") . "</h3>";
$now = microtime(true);
LimeExpressionManager::StartSurvey($surveyid, $surveyMode, $surveyOptions, true, $LEMdebugLevel);
print '<b>[StartSurvey() took ' . (microtime(true) - $now) . ' seconds]</b><br/>';
while (true) {
$now = microtime(true);
$result = LimeExpressionManager::NavigateForwards(true);
print $result['message'] . "<br/>";
LimeExpressionManager::FinishProcessingPage();
// print LimeExpressionManager::GetRelevanceAndTailoringJavaScript();
if (($LEMdebugLevel & LEM_DEBUG_TIMING) == LEM_DEBUG_TIMING) {
print LimeExpressionManager::GetDebugTimingMessage();
}
print '<b>[NavigateForwards() took ' . (microtime(true) - $now) . ' seconds]</b><br/>';
if (is_null($result) || $result['finished'] == true) {
break;
}
}
print "<h3>Finished survey " . $surveyid . "</h3>";
}
?>
</body>
</html>
示例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)
{
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");
}
$clang = SetSurveyLanguage($iSurveyID, $sLanguage);
$aSurveyInfo = getSurveyInfo($iSurveyID, $sLanguage);
//SET THE TEMPLATE DIRECTORY
if (!isset($aSurveyInfo['templatedir']) || !$aSurveyInfo['templatedir']) {
$aSurveyInfo['templatedir'] = Yii::app()->getConfig('defaulttemplate');
}
$sTemplate = validateTemplateDir($aSurveyInfo['templatedir']);
//Survey is not finished or don't exist
if (!isset($_SESSION['survey_' . $iSurveyID]['finished']) || !isset($_SESSION['survey_' . $iSurveyID]['srid'])) {
sendCacheHeaders();
doHeader();
echo templatereplace(file_get_contents(getTemplatePath($sTemplate) . '/startpage.pstpl'), 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."), Yii::app()->getConfig("siteadminname"), Yii::app()->getConfig("siteadminemail")) . "\n" . "</center><br />\n";
echo templatereplace(file_get_contents(getTemplatePath($sTemplate) . '/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");}
if ($aSurveyInfo['printanswers'] == 'N') {
die;
//Die quietly if print answers is not permitted
}
//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
$sOutput = CHtml::form(array("printanswers/view/surveyid/{$iSurveyID}/printableexport/pdf"), 'post') . "<center><input type='submit' value='" . $clang->gT("PDF export") . "'id=\"exportbutton\"/><input type='hidden' name='printableexport' /></center></form>";
if ($sExportType == 'pdf') {
//require (Yii::app()->getConfig('rootdir').'/application/config/tcpdf.php');
Yii::import('application.libraries.admin.pdf', true);
Yii::import('application.helpers.pdfHelper');
$aPdfLanguageSettings = pdfHelper::getPdfLanguageSettings($clang->langcode);
$oPDF = new pdf();
$oPDF->SetTitle($clang->gT("Survey name (ID)", 'unescaped') . ": {$sSurveyName} ({$iSurveyID})");
$oPDF->SetSubject($sSurveyName);
$oPDF->SetDisplayMode('fullpage', 'two');
$oPDF->setLanguageArray($aPdfLanguageSettings['lg']);
$oPDF->setHeaderFont(array($aPdfLanguageSettings['pdffont'], '', PDF_FONT_SIZE_MAIN));
$oPDF->setFooterFont(array($aPdfLanguageSettings['pdffont'], '', PDF_FONT_SIZE_DATA));
$oPDF->SetFont($aPdfLanguageSettings['pdffont'], '', $aPdfLanguageSettings['pdffontsize']);
$oPDF->AddPage();
$oPDF->titleintopdf($clang->gT("Survey name (ID)", 'unescaped') . ": {$sSurveyName} ({$iSurveyID})");
}
$sOutput .= "\t<div class='printouttitle'><strong>" . $clang->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";
} elseif (substr($sFieldname, 0, 4) == 'qid_') {
//.........这里部分代码省略.........
示例8: ReplaceFields
function ReplaceFields($text, $fieldsarray, $bReplaceInsertans = true, $staticReplace = true)
{
if ($bReplaceInsertans) {
$replacements = array();
foreach ($fieldsarray as $key => $value) {
$replacements[substr($key, 1, -1)] = $value;
}
$text = LimeExpressionManager::ProcessString($text, NULL, $replacements, false, 2, 1, false, false, $staticReplace);
} else {
foreach ($fieldsarray as $key => $value) {
$text = str_replace($key, $value, $text);
}
}
return $text;
}
示例9: view
/**
* dataentry::view()
* view a dataentry
* @param mixed $surveyid
* @param mixed $lang
* @return
*/
public function view($surveyid, $lang = NULL)
{
$surveyid = sanitize_int($surveyid);
$lang = isset($_GET['lang']) ? $_GET['lang'] : NULL;
if (isset($lang)) {
$lang = sanitize_languagecode($lang);
}
$aViewUrls = array();
if (hasSurveyPermission($surveyid, 'responses', 'read')) {
$clang = Yii::app()->lang;
$sDataEntryLanguage = Survey::model()->findByPk($surveyid)->language;
$surveyinfo = getSurveyInfo($surveyid);
$slangs = Survey::model()->findByPk($surveyid)->additionalLanguages;
$baselang = Survey::model()->findByPk($surveyid)->language;
array_unshift($slangs, $baselang);
if (is_null($lang) || !in_array($lang, $slangs)) {
$sDataEntryLanguage = $baselang;
$blang = $clang;
} else {
Yii::app()->loadLibrary('Limesurvey_lang', array($lang));
$blang = new Limesurvey_lang($lang);
$sDataEntryLanguage = $lang;
}
$langlistbox = languageDropdown($surveyid, $sDataEntryLanguage);
$thissurvey = getSurveyInfo($surveyid);
//This is the default, presenting a blank dataentry form
LimeExpressionManager::StartSurvey($surveyid, 'survey', NULL, false, LEM_PRETTY_PRINT_ALL_SYNTAX);
$moveResult = LimeExpressionManager::NavigateForwards();
$aData['thissurvey'] = $thissurvey;
$aData['langlistbox'] = $langlistbox;
$aData['surveyid'] = $surveyid;
$aData['blang'] = $blang;
$aData['site_url'] = Yii::app()->homeUrl;
LimeExpressionManager::StartProcessingPage(true, Yii::app()->baseUrl);
// means that all variables are on the same page
$aViewUrls[] = 'caption_view';
Yii::app()->loadHelper('database');
// SURVEY NAME AND DESCRIPTION TO GO HERE
$degquery = "SELECT * FROM {{groups}} WHERE sid={$surveyid} AND language='{$sDataEntryLanguage}' ORDER BY {{groups}}.group_order";
$degresult = dbExecuteAssoc($degquery);
// GROUP NAME
$aDataentryoutput = '';
foreach ($degresult->readAll() as $degrow) {
LimeExpressionManager::StartProcessingGroup($degrow['gid'], $thissurvey['anonymized'] != "N", $surveyid);
$deqquery = "SELECT * FROM {{questions}} WHERE sid={$surveyid} AND parent_qid=0 AND gid={$degrow['gid']} AND language='{$sDataEntryLanguage}'";
$deqrows = (array) dbExecuteAssoc($deqquery)->readAll();
$aDataentryoutput .= "\t<tr>\n" . "<td colspan='3' align='center'><strong>" . flattenText($degrow['group_name'], true) . "</strong></td>\n" . "\t</tr>\n";
$gid = $degrow['gid'];
$aDataentryoutput .= "\t<tr class='data-entry-separator'><td colspan='3'></td></tr>\n";
// Perform a case insensitive natural sort on group name then question title of a multidimensional array
usort($deqrows, 'groupOrderThenQuestionOrder');
$bgc = 'odd';
foreach ($deqrows as $deqrow) {
$qidattributes = getQuestionAttributeValues($deqrow['qid'], $deqrow['type']);
$cdata['qidattributes'] = $qidattributes;
$hidden = isset($qidattributes['hidden']) ? $qidattributes['hidden'] : 0;
// TODO - can questions be hidden? Are JavaScript variables names used? Consistently with everywhere else?
// LimeExpressionManager::ProcessRelevance($qidattributes['relevance'],$deqrow['qid'],NULL,$deqrow['type'],$hidden);
// TMSW Conditions->Relevance: Show relevance equation instead of conditions here - better yet, have data entry use survey-at-a-time but with different view
$qinfo = LimeExpressionManager::GetQuestionStatus($deqrow['qid']);
$relevance = trim($qinfo['info']['relevance']);
$explanation = trim($qinfo['relEqn']);
$validation = trim($qinfo['prettyValidTip']);
$qidattributes = getQuestionAttributeValues($deqrow['qid']);
$array_filter_help = flattenText($this->_array_filter_help($qidattributes, $sDataEntryLanguage, $surveyid));
if ($relevance != '' && $relevance != '1' || $validation != '' || $array_filter_help != '') {
$showme = '';
if ($bgc == "even") {
$bgc = "odd";
} else {
$bgc = "even";
}
//Do no alternate on explanation row
if ($relevance != '' && $relevance != '1') {
$showme = "[" . $blang->gT("Only answer this if the following conditions are met:") . "]<br />{$explanation}\n";
}
if ($showme != '' && $validation != '') {
$showme .= '<br/>';
}
if ($validation != '') {
$showme .= "[" . $blang->gT("The answer(s) must meet these validation criteria:") . "]<br />{$validation}\n";
}
if ($showme != '' && $array_filter_help != '') {
$showme .= '<br/>';
}
if ($array_filter_help != '') {
$showme .= "[" . $blang->gT("The answer(s) must meet these array_filter criteria:") . "]<br />{$array_filter_help}\n";
}
$cdata['explanation'] = "<tr class ='data-entry-explanation'><td class='data-entry-small-text' colspan='3' align='left'>{$showme}</td></tr>\n";
}
//END OF GETTING CONDITIONS
//Alternate bgcolor for different groups
if (!isset($bgc)) {
//.........这里部分代码省略.........
示例10: getQuestionReplacement
/**
* Construction of replacement array, actually doing it with redata
*
* @param $aQuestionQanda : array from qanda helper
* @return aray of replacement for question.psptl
**/
public static function getQuestionReplacement($aQuestionQanda)
{
// Get the default replacement and set empty value by default
$aReplacement = array("QID" => "", "SGQ" => "", "AID" => "", "QUESTION_CODE" => "", "QUESTION_NUMBER" => "", "QUESTION" => "", "QUESTION_TEXT" => "", "QUESTIONHELP" => "", "QUESTIONHELPPLAINTEXT" => "", "QUESTION_CLASS" => "", "QUESTION_MAN_CLASS" => "", "QUESTION_INPUT_ERROR_CLASS" => "", "ANSWER" => "", "QUESTION_HELP" => "", "QUESTION_VALID_MESSAGE" => "", "QUESTION_FILE_VALID_MESSAGE" => "", "QUESTION_MAN_MESSAGE" => "", "QUESTION_MANDATORY" => "", "QUESTION_ESSENTIALS" => "");
if (!is_array($aQuestionQanda) || empty($aQuestionQanda[0])) {
return $aReplacement;
}
$iQid = $aQuestionQanda[4];
$lemQuestionInfo = LimeExpressionManager::GetQuestionStatus($iQid);
$iSurveyId = Yii::app()->getConfig('surveyID');
// Or : by SGQA of question ? by Question::model($iQid)->sid;
$oSurveyId = Survey::model()->findByPk($iSurveyId);
$sType = $lemQuestionInfo['info']['type'];
// Core value : not replaced
$aReplacement['QID'] = $iQid;
$aReplacement['GID'] = $aQuestionQanda[6];
// Not sure for aleatory : it's the real gid or the updated gid ? We need original gid or updated gid ?
$aReplacement['SGQ'] = $aQuestionQanda[7];
$aReplacement['AID'] = isset($aQuestionQanda[0]['aid']) ? $aQuestionQanda[0]['aid'] : "";
$aReplacement['QUESTION_CODE'] = $aReplacement['QUESTION_NUMBER'] = "";
$sCode = $aQuestionQanda[5];
$iNumber = $aQuestionQanda[0]['number'];
switch (Yii::app()->getConfig('showqnumcode')) {
case 'both':
$aReplacement['QUESTION_CODE'] = $sCode;
$aReplacement['QUESTION_NUMBER'] = $iNumber;
break;
case 'number':
$aReplacement['QUESTION_NUMBER'] = $iNumber;
break;
case 'number':
$aReplacement['QUESTION_CODE'] = $sCode;
break;
case 'choose':
default:
switch ($oSurveyId->showqnumcode) {
case 'B':
// Both
$aReplacement['QUESTION_CODE'] = $sCode;
$aReplacement['QUESTION_NUMBER'] = $iNumber;
break;
case 'N':
$aReplacement['QUESTION_NUMBER'] = $iNumber;
break;
case 'C':
$aReplacement['QUESTION_CODE'] = $sCode;
break;
case 'X':
default:
break;
}
break;
}
$aReplacement['QUESTION'] = $aQuestionQanda[0]['all'];
// Deprecated : only used in old template (very old)
// Core value : user text
$aReplacement['QUESTION_TEXT'] = $aQuestionQanda[0]['text'];
$aReplacement['QUESTIONHELP'] = $lemQuestionInfo['info']['help'];
// User help
// To be moved in a extra plugin : QUESTIONHELP img adding
$sTemplateDir = Template::model()->getTemplatePath($oSurveyId->template);
$sTemplateUrl = Template::model()->getTemplateURL($oSurveyId->template);
if (flattenText($aReplacement['QUESTIONHELP'], true, true) != '') {
$aReplacement['QUESTIONHELP'] = Yii::app()->getController()->renderPartial('/survey/system/questionhelp/questionhelp', array('questionHelp' => $aReplacement['QUESTIONHELP']), true);
}
// Core value :the classes
$aReplacement['QUESTION_CLASS'] = Question::getQuestionClass($sType);
//get additional question classes from question attribute
$aQuestionAttributes = getQuestionAttributeValues($aQuestionQanda[4]);
//add additional classes
if (isset($aQuestionAttributes['cssclass'])) {
$aReplacement['QUESTION_CLASS'] .= " " . $aQuestionAttributes['cssclass'];
}
$aMandatoryClass = array();
if ($lemQuestionInfo['info']['mandatory'] == 'Y') {
$aMandatoryClass[] = 'mandatory';
}
if ($lemQuestionInfo['anyUnanswered'] && $_SESSION['survey_' . $iSurveyId]['maxstep'] != $_SESSION['survey_' . $iSurveyId]['step']) {
$aMandatoryClass[] = 'missing';
}
$aReplacement['QUESTION_MAN_CLASS'] = !empty($aMandatoryClass) ? " " . implode(" ", $aMandatoryClass) : "";
$aReplacement['QUESTION_INPUT_ERROR_CLASS'] = $aQuestionQanda[0]['input_error_class'];
// Core value : LS text : EM and not
$aReplacement['ANSWER'] = $aQuestionQanda[1];
$aReplacement['QUESTION_HELP'] = $aQuestionQanda[0]['help'];
// Core help only, not EM
$aReplacement['QUESTION_VALID_MESSAGE'] = $aQuestionQanda[0]['valid_message'];
// $lemQuestionInfo['validTip']
$aReplacement['QUESTION_FILE_VALID_MESSAGE'] = $aQuestionQanda[0]['file_valid_message'];
// $lemQuestionInfo['??']
$aReplacement['QUESTION_MAN_MESSAGE'] = $aQuestionQanda[0]['man_message'];
$aReplacement['QUESTION_MANDATORY'] = $aQuestionQanda[0]['mandatory'];
// For QUESTION_ESSENTIALS
$aHtmlOptions = array();
//.........这里部分代码省略.........
示例11: copied
} else {
$conditionDuplicated = true;
}
}
}
if (isset($conditionCopied) && $conditionCopied === true) {
if (isset($conditionDuplicated) && $conditionDuplicated == true) {
$CopyConditionsMessage = "<div class='partialheader'>(" . $clang->gT("Conditions successfully copied (some were skipped because they were duplicates)") . ")</div>";
} else {
$CopyConditionsMessage = "<div class='successheader'>(" . $clang->gT("Conditions successfully copied") . ")</div>";
}
} else {
$CopyConditionsMessage = "<div class='warningheader'>(" . $clang->gT("No conditions could be copied (due to duplicates)") . ")</div>";
}
}
LimeExpressionManager::UpgradeConditionsToRelevance($surveyid);
// do for whole survey, since don't know which questions affected.
}
//END PROCESS ACTIONS
$cquestions = array();
$canswers = array();
//BEGIN: GATHER INFORMATION
// 1: Get information for this question
if (!isset($qid)) {
$qid = returnglobal('qid');
}
if (!isset($surveyid)) {
$surveyid = returnglobal('sid');
}
$thissurvey = getSurveyInfo($surveyid);
$query = "SELECT * " . "FROM {$dbprefix}questions, " . "{$dbprefix}groups " . "WHERE {$dbprefix}questions.gid={$dbprefix}groups.gid " . "AND qid={$qid} " . "AND parent_qid=0 " . "AND {$dbprefix}questions.language='" . GetBaseLanguageFromSurveyID($surveyid) . "'";
示例12: translate_google_api
private function translate_google_api()
{
$sBaselang = Yii::app()->getRequest()->getPost('baselang');
$sTolang = Yii::app()->getRequest()->getPost('tolang');
$sToconvert = Yii::app()->getRequest()->getPost('text');
$aSearch = array('zh-Hans', 'zh-Hant-HK', 'zh-Hant-TW', 'nl-informal', 'de-informal', 'it-formal', 'pt-BR', 'es-MX', 'nb', 'nn');
$aReplace = array('zh-CN', 'zh-TW', 'zh-TW', 'nl', 'de', 'it', 'pt', 'es', 'no', 'no');
$sBaselang = str_replace($aSearch, $aReplace, $sBaselang);
$sTolang = str_replace($aSearch, $aReplace, $sTolang);
$error = false;
try {
require_once APPPATH . '/third_party/gtranslate-api/GTranslate.php';
$gtranslate = new Gtranslate();
$objGt = $gtranslate;
// Gtranslate requires you to run function named XXLANG_to_XXLANG
$sProcedure = $sBaselang . "_to_" . $sTolang;
$parts = LimeExpressionManager::SplitStringOnExpressions($sToconvert);
$sparts = array();
foreach ($parts as $part) {
if ($part[2] == 'EXPRESSION') {
$sparts[] = $part[0];
} else {
$convertedPart = $objGt->{$sProcedure}($part[0]);
$convertedPart = str_replace("<br>", "\r\n", $convertedPart);
$convertedPart = html_entity_decode(stripcslashes($convertedPart));
$sparts[] = $convertedPart;
}
}
$sOutput = implode(' ', $sparts);
} catch (GTranslateException $ge) {
// Get the error message and build the ouput array
$error = TRUE;
$sOutput = $ge->getMessage();
}
$aOutput = array('error' => $error, 'baselang' => $sBaselang, 'tolang' => $sTolang, 'converted' => $sOutput);
header('Content-type: application/json');
return ls_json_encode($aOutput);
Yii::app()->end();
}
示例13: TSVImportSurvey
//.........这里部分代码省略.........
} elseif ($sqname == 'other' && $lastother == "Y") {
if ($qtype == "!" || $qtype == "L") {
// only used to set default value for 'other' in these cases
if (isset($row['default'])) {
$insertdata = array();
$insertdata['qid'] = $qid;
$insertdata['specialtype'] = 'other';
$insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
$insertdata['defaultvalue'] = $row['default'];
$result = DefaultValue::model()->insertRecords($insertdata);
if (!$result) {
$results['importwarnings'][] = $clang->gT("Warning") . " : " . $clang->gT("Failed to insert default value") . ". " . $clang->gT("Text file row number ") . $rownumber;
break;
}
$results['defaultvalues']++;
}
}
} else {
$insertdata = array();
$scale_id = isset($row['type/scale']) ? $row['type/scale'] : 0;
$insertdata['sid'] = $iNewSID;
$insertdata['gid'] = $gid;
$insertdata['parent_qid'] = $qid;
$insertdata['type'] = $qtype;
$insertdata['title'] = $sqname;
$insertdata['question'] = isset($row['text']) ? $row['text'] : '';
$insertdata['relevance'] = isset($row['relevance']) ? $row['relevance'] : '';
$insertdata['preg'] = isset($row['validation']) ? $row['validation'] : '';
$insertdata['help'] = isset($row['help']) ? $row['help'] : '';
$insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
$insertdata['mandatory'] = isset($row['mandatory']) ? $row['mandatory'] : '';
$insertdata['scale_id'] = $scale_id;
// For multi nueric language, qid is needed, why not gid. name is not unique.
$fullsqname = "G{$gid}Q{$qid}_{$scale_id}_{$sqname}";
if (isset($sqinfo[$fullsqname])) {
$qseq = $sqinfo[$fullsqname]['question_order'];
$sqid = $sqinfo[$fullsqname]['sqid'];
$insertdata['question_order'] = $qseq;
$insertdata['qid'] = $sqid;
} else {
$insertdata['question_order'] = $qseq;
}
// Insert sub question and keep the sqid for multi language survey
$newsqid = Question::model()->insertRecords($insertdata);
if (!$newsqid) {
$results['error'][] = $clang->gT("Error") . " : " . $clang->gT("Could not insert subquestion") . ". " . $clang->gT("Text file row number ") . $rownumber . " (" . $qname . ")";
break;
}
if (!isset($sqinfo[$fullsqname])) {
$sqinfo[$fullsqname]['question_order'] = $qseq++;
$sqid = $newsqid;
// save this for later
$sqinfo[$fullsqname]['sqid'] = $sqid;
$results['subquestions']++;
}
// insert default value
if (isset($row['default'])) {
$insertdata = array();
$insertdata['qid'] = $qid;
$insertdata['sqid'] = $sqid;
$insertdata['scale_id'] = $scale_id;
$insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
$insertdata['defaultvalue'] = $row['default'];
$result = DefaultValue::model()->insertRecords($insertdata);
if (!$result) {
$results['importwarnings'][] = $clang->gT("Warning") . " : " . $clang->gT("Failed to insert default value") . ". " . $clang->gT("Text file row number ") . $rownumber;
break;
}
$results['defaultvalues']++;
}
}
break;
case 'A':
$insertdata = array();
$insertdata['qid'] = $qid;
$insertdata['code'] = isset($row['name']) ? $row['name'] : 'A' . $aseq;
$insertdata['answer'] = isset($row['text']) ? $row['text'] : '';
$insertdata['scale_id'] = isset($row['type/scale']) ? $row['type/scale'] : 0;
$insertdata['language'] = isset($row['language']) ? $row['language'] : $baselang;
$insertdata['assessment_value'] = (int) (isset($row['relevance']) ? $row['relevance'] : '');
$insertdata['sortorder'] = ++$aseq;
$result = Answer::model()->insertRecords($insertdata);
// or safeDie("Error: Failed to insert answer<br />");
if (!$result) {
$results['error'][] = $clang->gT("Error") . " : " . $clang->gT("Could not insert answer") . ". " . $clang->gT("Text file row number ") . $rownumber;
}
$results['answers']++;
break;
}
}
// Delete the survey if error found
if (is_array($results['error'])) {
$result = Survey::model()->deleteSurvey($iNewSID);
} else {
LimeExpressionManager::SetSurveyId($iNewSID);
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iNewSID);
LimeExpressionManager::UpgradeConditionsToRelevance($iNewSID);
}
return $results;
}
示例14: count
<?php
$data = LimeExpressionManager::UnitTestConvertConditionsToRelevance();
echo count($data) . " question(s) in your database contain conditions. Below is the mapping of question ID number to generated relevance equation<br/>";
echo "<pre>";
print_r($data);
echo "</pre>";
示例15: delete
/**
* Action to delete a question group.
*
* @access public
* @return void
*/
public function delete($iSurveyId, $iGroupId)
{
$iSurveyId = sanitize_int($iSurveyId);
if (Permission::model()->hasSurveyPermission($iSurveyId, 'surveycontent', 'delete')) {
LimeExpressionManager::RevertUpgradeConditionsToRelevance($iSurveyId);
$iGroupId = sanitize_int($iGroupId);
$iGroupsDeleted = QuestionGroup::deleteWithDependency($iGroupId, $iSurveyId);
if ($iGroupsDeleted > 0) {
fixSortOrderGroups($iSurveyId);
Yii::app()->setFlashMessage(gT('The question group was deleted.'));
} else {
Yii::app()->setFlashMessage(gT('Group could not be deleted'), 'error');
}
LimeExpressionManager::UpgradeConditionsToRelevance($iSurveyId);
$this->getController()->redirect(array('admin/survey/sa/view/surveyid/' . $iSurveyId));
}
}