本文整理汇总了PHP中getqtypelist函数的典型用法代码示例。如果您正苦于以下问题:PHP getqtypelist函数的具体用法?PHP getqtypelist怎么用?PHP getqtypelist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getqtypelist函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testExporting
function testExporting() {
$exportHtml .= "<select id='question_type' style='margin-bottom:5px' name='type' "
. ">\n"
. getqtypelist($eqrow['type'],'group')
. "</select>\n";
echo $exportHtml;
}
示例2: alert
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"" . $clang->gT("Answers with a code of 0 (zero) or blank code are not allowed, and will not be saved", "js") . "\")\n //-->\n</script>\n";
}
if ($duplicateCode == 1) {
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"" . $clang->gT("Duplicate codes found, these entries won't be updated", "js") . "\")\n //-->\n</script>\n";
}
$sortorderid--;
$_SESSION['flashmessage'] = $clang->gT("Answer options were successfully saved.");
$action = 'editansweroptions';
} elseif ($action == "updatesubquestions" && bHasSurveyPermission($surveyid, 'surveycontent', 'update')) {
$anslangs = GetAdditionalLanguagesFromSurveyID($surveyid);
$baselang = GetBaseLanguageFromSurveyID($surveyid);
array_unshift($anslangs, $baselang);
$query = "select type from " . db_table_name('questions') . " where qid={$qid}";
$questiontype = $connect->GetOne($query);
// Checked
$qtypes = getqtypelist('', 'array');
$scalecount = $qtypes[$questiontype]['subquestions'];
// First delete any deleted ids
$deletedqids = explode(' ', trim($_POST['deletedqids']));
LimeExpressionManager::RevertUpgradeConditionsToRelevance($surveyid);
foreach ($deletedqids as $deletedqid) {
$deletedqid = (int) $deletedqid;
if ($deletedqid > 0) {
// don't remove undefined
$query = "DELETE FROM " . db_table_name('questions') . " WHERE qid='{$deletedqid}'";
// Checked
if (!($result = $connect->Execute($query))) {
$databaseoutput .= "<script type=\"text/javascript\">\n<!--\n alert(\"" . $clang->gT("Failed to delete answer", "js") . " - " . $query . " - " . $connect->ErrorMsg() . "\")\n //-->\n</script>\n";
}
}
}
示例3: getqtypelist
if ($qrrow['type'] != "X") {
if ($qrrow['mandatory'] == "Y") {
$questionsummary .= ": (<i>" . $clang->gT("Mandatory Question") . "</i>)";
} else {
$questionsummary .= ": (<i>" . $clang->gT("Optional Question") . "</i>)";
}
}
$questionsummary .= "</td></tr>\n" . "<tr><td align='right' valign='top'><strong>" . $clang->gT("Question:") . "</strong></td>\n<td align='left'>" . $qrrow['question'] . "</td></tr>\n" . "<tr><td align='right' valign='top'><strong>" . $clang->gT("Help:") . "</strong></td>\n<td align='left'>";
if (trim($qrrow['help']) != '') {
$questionsummary .= $qrrow['help'];
}
$questionsummary .= "</td></tr>\n";
if ($qrrow['preg']) {
$questionsummary .= "<tr ><td align='right' valign='top'><strong>" . $clang->gT("Validation:") . "</strong></td>\n<td align='left'>{$qrrow['preg']}" . "</td></tr>\n";
}
$qtypes = getqtypelist("", "array");
//qtypes = array(type code=>type description)
$questionsummary .= "<tr><td align='right' valign='top'><strong>" . $clang->gT("Type:") . "</strong></td>\n<td align='left'>{$qtypes[$qrrow['type']]['description']}";
$questionsummary .= "</td></tr>\n";
if ($qct == 0 && $qtypes[$qrrow['type']]['answerscales'] > 0) {
$questionsummary .= "<tr ><td></td><td align='left'>" . "<span class='statusentryhighlight'>" . $clang->gT("Warning") . ": <a href='{$scriptname}?sid={$surveyid}&gid={$gid}&qid={$qid}&action=editansweroptions'>" . $clang->gT("You need to add answer options to this question") . " " . "<img src='{$imageurl}/answers_20.png' title='" . $clang->gT("Edit answer options for this question") . "' name='EditThisQuestionAnswers'/></span></td></tr>\n";
}
// EDIT SUBQUESTIONS FOR THIS QUESTION BUTTON
if ($sqct == 0 && $qtypes[$qrrow['type']]['subquestions'] > 0) {
$questionsummary .= "<tr ><td></td><td align='left'>" . "<span class='statusentryhighlight'>" . $clang->gT("Warning") . ": <a href='{$scriptname}?sid={$surveyid}&gid={$gid}&qid={$qid}&action=editsubquestions'>" . $clang->gT("You need to add subquestions to this question") . " " . "<img src='{$imageurl}/subquestions_20.png' title='" . $clang->gT("Edit subquestions for this question") . "' name='EditThisQuestionAnswers' /></span></td></tr>\n";
}
if ($qrrow['type'] == "M" or $qrrow['type'] == "P") {
$questionsummary .= "<tr>" . "<td align='right' valign='top'><strong>" . $clang->gT("Option 'Other':") . "</strong></td>\n" . "<td align='left'>";
$questionsummary .= $qrrow['other'] == "Y" ? $clang->gT("Yes") : $clang->gT("No");
$questionsummary .= "</td></tr>\n";
}
示例4: CSVImportSurvey
//.........这里部分代码省略.........
$surveylsrowdata=array_map('convertCsvreturn2return', $surveylsrowdata);
// Convert the \n return char from welcometext to <br />
// translate internal links
$surveylsrowdata['surveyls_title']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_title']);
$surveylsrowdata['surveyls_description']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_description']);
$surveylsrowdata['surveyls_welcometext']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_welcometext']);
$surveylsrowdata['surveyls_urldescription']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_urldescription']);
$surveylsrowdata['surveyls_email_invite']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_invite']);
$surveylsrowdata['surveyls_email_remind']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_remind']);
$surveylsrowdata['surveyls_email_register']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_register']);
$surveylsrowdata['surveyls_email_confirm']=translink('survey', $oldsid, $newsid, $surveylsrowdata['surveyls_email_confirm']);
unset($surveylsrowdata['lastpage']);
$surveylsrowdata['surveyls_survey_id']=$newsid;
$newvalues=array_values($surveylsrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lsainsert = "INSERT INTO {$dbprefix}surveys_languagesettings (".implode(',',array_keys($surveylsrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$lsiresult=$connect->Execute($lsainsert) or safe_die("<br />".$clang->gT("Import of this survey file failed")."<br />\n[$lsainsert]<br />\n" . $connect->ErrorMsg() );
}
// The survey languagesettings are imported now
$aLanguagesSupported = array(); // this array will keep all the languages supported for the survey
$sBaseLanguage = GetBaseLanguageFromSurveyID($newsid);
$aLanguagesSupported[]=$sBaseLanguage; // adds the base language to the list of supported languages
$aLanguagesSupported=array_merge($aLanguagesSupported,GetAdditionalLanguagesFromSurveyID($newsid));
// DO SURVEY_RIGHTS
GiveAllSurveyPermissions($_SESSION['loginID'],$newsid);
$importresults['deniedcountls'] =0;
$qtypes = getqtypelist("" ,"array");
$results['labels']=0;
$results['labelsets']=0;
$results['answers']=0;
$results['subquestions']=0;
//Do label sets
if (isset($labelsetsarray) && $labelsetsarray)
{
$csarray=buildLabelSetCheckSumArray(); // build checksums over all existing labelsets
$count=0;
foreach ($labelsetsarray as $lsa) {
$fieldorders =convertCSVRowToArray($labelsetsarray[0],',','"');
$fieldcontents=convertCSVRowToArray($lsa,',','"');
if ($count==0) {$count++; continue;}
$labelsetrowdata=array_combine($fieldorders,$fieldcontents);
// Save old labelid
$oldlid=$labelsetrowdata['lid'];
unset($labelsetrowdata['lid']);
$newvalues=array_values($labelsetrowdata);
$newvalues=array_map(array(&$connect, "qstr"),$newvalues); // quote everything accordingly
$lsainsert = "INSERT INTO {$dbprefix}labelsets (".implode(',',array_keys($labelsetrowdata)).") VALUES (".implode(',',$newvalues).")"; //handle db prefix
$lsiresult=$connect->Execute($lsainsert);
$results['labelsets']++;
// Get the new insert id for the labels inside this labelset
$newlid=$connect->Insert_ID("{$dbprefix}labelsets",'lid');
if ($labelsarray) {
$count=0;
foreach ($labelsarray as $la) {
示例5: 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 = 'short', $force_refresh = false, $questionid = false, $sQuestionLanguage = null)
{
global $dbprefix, $connect, $globalfieldmap, $clang, $aDuplicateQIDs;
$surveyid = sanitize_int($surveyid);
//checks to see if fieldmap has already been built for this page.
if (isset($globalfieldmap[$surveyid][$style][$clang->langcode]) && $force_refresh == false) {
return $globalfieldmap[$surveyid][$style][$clang->langcode];
}
$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'] = "";
}
}
}
//Get list of questions
if (is_null($sQuestionLanguage)) {
$s_lang = GetBaseLanguageFromSurveyID($surveyid);
} else {
$s_lang = $sQuestionLanguage;
}
$qtypes = getqtypelist('', 'array');
$aquery = "SELECT *, " . " (SELECT count(1) FROM " . db_table_name('conditions') . " c\n" . " WHERE questions.qid = c.qid) AS hasconditions,\n" . " (SELECT count(1) FROM " . db_table_name('conditions') . " c\n" . " WHERE questions.qid = c.cqid) AS usedinconditions\n" . " FROM " . db_table_name('questions') . " as questions, " . db_table_name('groups') . " as groups" . " WHERE questions.gid=groups.gid AND " . " questions.sid={$surveyid} AND " . " questions.language='{$s_lang}' AND " . " questions.parent_qid=0 AND " . " groups.language='{$s_lang}' ";
if ($questionid !== false) {
$aquery .= " and questions.qid={$questionid} ";
}
$aquery .= " ORDER BY group_order, question_order";
$aresult = db_execute_assoc($aquery) or safe_die("Couldn't get list of questions in createFieldMap function.<br />{$query}<br />" . $connect->ErrorMsg());
//Checked
//.........这里部分代码省略.........
示例6: CSVImportGroup
//.........这里部分代码省略.........
$langfieldnum = array_search("language", $questionfieldnames);
$qidfieldnum = array_search("qid", $questionfieldnames);
$questionssupportbaselang = bDoesImportarraySupportsLanguage($questionarray, array($qidfieldnum), $langfieldnum, $sBaseLanguage, true);
if (!$questionssupportbaselang) {
$results['fatalerror'] = $clang->gT("You can't import a question which doesn't support at least the survey base language.");
return $results;
}
}
if ($countanswers > 0) {
$langfieldnum = array_search("language", $answerfieldnames);
$answercodefilednum1 = array_search("qid", $answerfieldnames);
$answercodefilednum2 = array_search("code", $answerfieldnames);
$answercodekeysarr = array($answercodefilednum1, $answercodefilednum2);
$answerssupportbaselang = bDoesImportarraySupportsLanguage($answerarray, $answercodekeysarr, $langfieldnum, $sBaseLanguage);
if (!$answerssupportbaselang) {
$results['fatalerror'] = $clang->gT("You can't import answers which doesn't support at least the survey base language.");
return $results;
}
}
if (count($labelsetsarray) > 1) {
$labelsetfieldname = convertCSVRowToArray($labelsetsarray[0], ',', '"');
$langfieldnum = array_search("languages", $labelsetfieldname);
$lidfilednum = array_search("lid", $labelsetfieldname);
$labelsetssupportbaselang = bDoesImportarraySupportsLanguage($labelsetsarray, array($lidfilednum), $langfieldnum, $sBaseLanguage, true);
if (!$labelsetssupportbaselang) {
$results['fatalerror'] = $clang->gT("You can't import label sets which don't support the current survey's base language");
return $results;
}
}
// I assume that if a labelset supports the survey's baselang,
// then it's labels do support it as well
//DO ANY LABELSETS FIRST, SO WE CAN KNOW WHAT THEIR NEW LID IS FOR THE QUESTIONS
$results['labelsets'] = 0;
$qtypes = getqtypelist("", "array");
$results['labels'] = 0;
$results['labelsets'] = 0;
$results['answers'] = 0;
$results['subquestions'] = 0;
//Do label sets
if (isset($labelsetsarray) && $labelsetsarray) {
$csarray = buildLabelSetCheckSumArray();
// build checksums over all existing labelsets
$count = 0;
foreach ($labelsetsarray as $lsa) {
$fieldorders = convertCSVRowToArray($labelsetsarray[0], ',', '"');
$fieldcontents = convertCSVRowToArray($lsa, ',', '"');
if ($count == 0) {
$count++;
continue;
}
$labelsetrowdata = array_combine($fieldorders, $fieldcontents);
// Save old labelid
$oldlid = $labelsetrowdata['lid'];
unset($labelsetrowdata['lid']);
$newvalues = array_values($labelsetrowdata);
$newvalues = array_map(array(&$connect, "qstr"), $newvalues);
// quote everything accordingly
$lsainsert = "INSERT INTO {$dbprefix}labelsets (" . implode(',', array_keys($labelsetrowdata)) . ") VALUES (" . implode(',', $newvalues) . ")";
//handle db prefix
$lsiresult = $connect->Execute($lsainsert);
$results['labelsets']++;
// Get the new insert id for the labels inside this labelset
$newlid = $connect->Insert_ID("{$dbprefix}labelsets", 'lid');
if ($labelsarray) {
$count = 0;
foreach ($labelsarray as $la) {
示例7: createFieldMap
//.........这里部分代码省略.........
if ($style == "full") {
$fieldmap["refurl"]['title'] = "";
$fieldmap["refurl"]['question'] = $clang->gT("Referrer URL");
$fieldmap["refurl"]['group_name'] = "";
}
}
}
// Collect all default values once so don't need separate query for each question with defaults
// First collect language specific defaults
$defaultsQuery = "SELECT a.qid, a.sqid, a.scale_id, a.specialtype, a.defaultvalue" . " FROM " . db_table_name('defaultvalues') . " as a, " . db_table_name('questions') . " as b" . " WHERE a.qid = b.qid" . " AND a.language = b.language" . " AND a.language = '{$s_lang}'" . " AND b.same_default=0" . " AND b.sid = " . $surveyid;
$defaultResults = db_execute_assoc($defaultsQuery) or safe_die("Couldn't get list of default values in createFieldMap.<br/>{$defaultsQuery}<br/>" . $conect->ErrorMsg());
$defaultValues = array();
// indexed by question then subquestion
foreach ($defaultResults as $dv) {
if ($dv['specialtype'] != '') {
$sq = $dv['specialtype'];
} else {
$sq = $dv['sqid'];
}
$defaultValues[$dv['qid'] . '~' . $sq] = $dv['defaultvalue'];
}
// Now overwrite language-specific defaults (if any) base language values for each question that uses same_defaults=1
$baseLanguage = GetBaseLanguageFromSurveyID($surveyid);
$defaultsQuery = "SELECT a.qid, a.sqid, a.scale_id, a.specialtype, a.defaultvalue" . " FROM " . db_table_name('defaultvalues') . " as a, " . db_table_name('questions') . " as b" . " WHERE a.qid = b.qid" . " AND a.language = b.language" . " AND a.language = '{$baseLanguage}'" . " AND b.same_default=1" . " AND b.sid = " . $surveyid;
$defaultResults = db_execute_assoc($defaultsQuery) or safe_die("Couldn't get list of default values in createFieldMap.<br/>{$defaultsQuery}<br/>" . $conect->ErrorMsg());
foreach ($defaultResults as $dv) {
if ($dv['specialtype'] != '') {
$sq = $dv['specialtype'];
} else {
$sq = $dv['sqid'];
}
$defaultValues[$dv['qid'] . '~' . $sq] = $dv['defaultvalue'];
}
$qtypes = getqtypelist('', 'array');
$aquery = "SELECT * " . " FROM " . db_table_name('questions') . " as questions, " . db_table_name('groups') . " as groups" . " WHERE questions.gid=groups.gid AND " . " questions.sid={$surveyid} AND " . " questions.language='{$s_lang}' AND " . " questions.parent_qid=0 AND " . " groups.language='{$s_lang}' ";
if ($questionid !== false) {
$aquery .= " and questions.qid={$questionid} ";
}
$aquery .= " ORDER BY group_order, question_order";
$aresult = db_execute_assoc($aquery) or safe_die("Couldn't get list of questions in createFieldMap function.<br />{$query}<br />" . $connect->ErrorMsg());
//Checked
$questionSeq = -1;
// this is incremental question sequence across all groups
$groupSeq = -1;
$_groupOrder = -1;
while ($arow = $aresult->FetchRow()) {
++$questionSeq;
// fix fact taht group_order may have gaps
if ($_groupOrder != $arow['group_order']) {
$_groupOrder = $arow['group_order'];
++$groupSeq;
}
// Conditions indicators are obsolete with EM. However, they are so tightly coupled into LS code that easider to just set values to 'N' for now and refactor later.
$conditions = 'N';
$usedinconditions = 'N';
// Field identifier
// GXQXSXA
// G=Group Q=Question S=Subquestion A=Answer Option
// If S or A don't exist then set it to 0
// Implicit (subqestion intermal to a question type ) or explicit qubquestions/answer count starts at 1
// Types "L", "!" , "O", "D", "G", "N", "X", "Y", "5","S","T","U","*"
$fieldname = "{$arow['sid']}X{$arow['gid']}X{$arow['qid']}";
if ($qtypes[$arow['type']]['subquestions'] == 0 && $arow['type'] != "R" && $arow['type'] != "|") {
if (isset($fieldmap[$fieldname])) {
$aDuplicateQIDs[$arow['qid']] = array('fieldname' => $fieldname, 'question' => $arow['question'], 'gid' => $arow['gid']);
}
示例8: buildsurveysession
//.........这里部分代码省略.........
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"));
doFooter();
exit;
}
//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..
$_SESSION['token'] = $clienttoken;
if ($thissurvey['anonymized'] == "N") {
$_SESSION['insertarray'][] = "token";
}
if ($tokensexist == 1 && $thissurvey['anonymized'] == "N" && db_tables_exist($dbprefix . 'tokens_' . $surveyid)) {
//Gather survey data for "non anonymous" surveys, for use in presenting questions
$_SESSION['thistoken'] = getTokenData($surveyid, $clienttoken);
}
$qtypes = getqtypelist('', 'array');
$fieldmap = createFieldMap($surveyid, 'full', false, false, $_SESSION['s_lang']);
// Randomization Groups
// Find all defined randomization groups through question attribute values
$randomGroups = array();
if ($databasetype == 'odbc_mssql' || $databasetype == 'odbtp' || $databasetype == 'mssql_n' || $databasetype == 'mssqlnative') {
$rgquery = "SELECT attr.qid, CAST(value as varchar(255)) FROM " . db_table_name('question_attributes') . " as attr right join " . db_table_name('questions') . " as quests on attr.qid=quests.qid WHERE attribute='random_group' and CAST(value as varchar(255)) <> '' and sid={$surveyid} GROUP BY attr.qid, CAST(value as varchar(255))";
} else {
$rgquery = "SELECT attr.qid, value FROM " . db_table_name('question_attributes') . " as attr right join " . db_table_name('questions') . " as quests on attr.qid=quests.qid WHERE attribute='random_group' and value <> '' and sid={$surveyid} GROUP BY attr.qid, value";
}
$rgresult = db_execute_assoc($rgquery);
while ($rgrow = $rgresult->FetchRow()) {
// Get the question IDs for each randomization group
$randomGroups[$rgrow['value']][] = $rgrow['qid'];
}
// If we have randomization groups set, then lets cycle through each group and
// replace questions in the group with a randomly chosen one from the same group
if (count($randomGroups) > 0) {
$copyFieldMap = array();
$oldQuestOrder = array();
$newQuestOrder = array();
$randGroupNames = array();
foreach ($randomGroups as $key => $value) {
$oldQuestOrder[$key] = $randomGroups[$key];
$newQuestOrder[$key] = $oldQuestOrder[$key];
// We shuffle the question list to get a random key->qid which will be used to swap from the old key
shuffle($newQuestOrder[$key]);
$randGroupNames[] = $key;
}
// Loop through the fieldmap and swap each question as they come up
while (list($fieldkey, $fieldval) = each($fieldmap)) {
$found = 0;
foreach ($randomGroups as $gkey => $gval) {
示例9: CSVImportQuestion
//.........这里部分代码省略.........
if ((int) $questionrowdata['lid'] > 0) {
$oldquestion['lid1'] = (int) $questionrowdata['lid'];
}
if ((int) $questionrowdata['lid1'] > 0) {
$oldquestion['lid2'] = (int) $questionrowdata['lid1'];
}
$oldquestion['oldtype'] = $questionrowdata['type'];
// Unset label set IDs and convert question types
unset($questionrowdata['lid']);
unset($questionrowdata['lid1']);
if ($questionrowdata['type'] == 'W') {
$questionrowdata['type'] = '!';
} elseif ($questionrowdata['type'] == 'Z') {
$questionrowdata['type'] = 'L';
}
$oldquestion['newtype'] = $questionrowdata['type'];
$questionrowdata = array_map('convertCsvreturn2return', $questionrowdata);
// translate internal links
$questionrowdata['title'] = translink('survey', $oldsid, $newsid, $questionrowdata['title']);
$questionrowdata['question'] = translink('survey', $oldsid, $newsid, $questionrowdata['question']);
$questionrowdata['help'] = translink('survey', $oldsid, $newsid, $questionrowdata['help']);
$newvalues = array_values($questionrowdata);
$newvalues = array_map(array(&$connect, "qstr"), $newvalues);
// quote everything accordingly
$qinsert = "INSERT INTO {$dbprefix}questions (" . implode(',', array_keys($questionrowdata)) . ") VALUES (" . implode(',', $newvalues) . ")";
$qres = $connect->Execute($qinsert) or safe_die("Error: Failed to insert question<br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
// set the newqid only if is not set
if (!isset($newqid)) {
$newqid = $connect->Insert_ID("{$dbprefix}questions", "qid");
} else {
db_switchIDInsert('questions', false);
}
}
$qtypes = getqtypelist("", "array");
$results['answers'] = 0;
$results['subquestions'] = 0;
// Now we will fix up old label sets where they are used as answers
if ((isset($oldquestion['lid1']) || isset($oldquestion['lid2'])) && ($qtypes[$oldquestion['newtype']]['answerscales'] > 0 || $qtypes[$oldquestion['newtype']]['subquestions'] > 1)) {
$query = "select * from " . db_table_name('labels') . " where lid={$aLIDReplacements[$oldquestion['lid1']]} ";
$oldlabelsresult = db_execute_assoc($query);
while ($labelrow = $oldlabelsresult->FetchRow()) {
if (in_array($labelrow['language'], $aLanguagesSupported)) {
if ($qtypes[$oldquestion['newtype']]['subquestions'] < 2) {
$qinsert = "insert INTO " . db_table_name('answers') . " (qid,code,answer,sortorder,language,assessment_value,scale_id)\n VALUES ({$newqid}," . db_quoteall($labelrow['code']) . "," . db_quoteall($labelrow['title']) . "," . db_quoteall($labelrow['sortorder']) . "," . db_quoteall($labelrow['language']) . "," . db_quoteall($labelrow['assessment_value']) . ",0)";
$qres = $connect->Execute($qinsert) or safe_die("Error: Failed to insert answer <br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
$results['answers']++;
} else {
if (isset($aSQIDReplacements[$labelrow['code']])) {
$fieldname = 'qid,';
$data = $aSQIDReplacements[$labelrow['code']] . ',';
db_switchIDInsert('questions', true);
} else {
$fieldname = '';
$data = '';
}
$qinsert = "insert INTO " . db_table_name('questions') . " ({$fieldname} sid,gid,parent_qid,title,question,question_order,language,scale_id,type)\n VALUES ({$data} {$newsid},{$newgid},{$newqid}," . db_quoteall($labelrow['code']) . "," . db_quoteall($labelrow['title']) . "," . db_quoteall($labelrow['sortorder']) . "," . db_quoteall($labelrow['language']) . ",1," . db_quoteall($oldquestion['newtype']) . ")";
$qres = $connect->Execute($qinsert) or safe_die("Error: Failed to insert subquestion <br />\n{$qinsert}<br />\n" . $connect->ErrorMsg());
if ($fieldname == '') {
$aSQIDReplacements[$labelrow['code']] = $connect->Insert_ID("{$dbprefix}questions", "qid");
} else {
db_switchIDInsert('questions', false);
}
}
}
}
if (isset($oldquestion['lid2']) && $qtypes[$oldquestion['newtype']]['answerscales'] > 1) {
示例10: ShowSurveyLogicFile
/**
* Create HTML view of the survey, showing everything that uses EM
* @param <type> $sid
* @param <type> $gid
* @param <type> $qid
*/
public static function ShowSurveyLogicFile($sid, $gid = NULL, $qid = NULL, $LEMdebugLevel = 0, $assessments = false)
{
// Title
// Welcome
// G1, name, relevance, text
// *Q1, name [type], relevance [validation], text, help, default, help_msg
// SQ1, name [scale], relevance [validation], text
// A1, code, assessment_value, text
// End Message
global $rooturl;
$LEM =& LimeExpressionManager::singleton();
$allErrors = array();
$warnings = 0;
$surveyOptions = array('assessments' => $assessments, 'hyperlinkSyntaxHighlighting' => true, 'rooturl' => $rooturl);
$varNamesUsed = array();
// keeps track of whether variables have been declared
if (!is_null($qid)) {
$surveyMode = 'question';
LimeExpressionManager::StartSurvey($sid, 'question', $surveyOptions, false, $LEMdebugLevel);
$qseq = LimeExpressionManager::GetQuestionSeq($qid);
$moveResult = LimeExpressionManager::JumpTo($qseq + 1, true, false, true);
} else {
if (!is_null($gid)) {
$surveyMode = 'group';
LimeExpressionManager::StartSurvey($sid, 'group', $surveyOptions, false, $LEMdebugLevel);
$gseq = LimeExpressionManager::GetGroupSeq($gid);
$moveResult = LimeExpressionManager::JumpTo($gseq + 1, true, false, true);
} else {
$surveyMode = 'survey';
LimeExpressionManager::StartSurvey($sid, 'survey', $surveyOptions, false, $LEMdebugLevel);
$moveResult = LimeExpressionManager::NavigateForwards();
}
}
$qtypes = getqtypelist('', 'array');
if (is_null($moveResult) || is_null($LEM->currentQset) || count($LEM->currentQset) == 0) {
return array('errors' => 1, 'html' => $LEM->gT('Invalid question - probably missing sub-questions or language-specific settings for language ') . $_SESSION['LEMlang']);
}
$surveyname = templatereplace('{SURVEYNAME}');
$out = '<H3>' . $LEM->gT('Logic File for Survey # ') . '[' . $LEM->sid . "]: {$surveyname}</H3>\n";
$out .= "<table border='1'>";
if (is_null($gid) && is_null($qid)) {
$description = templatereplace('{SURVEYDESCRIPTION}');
$errClass = $LEM->em->HasErrors() ? 'LEMerror' : '';
if ($description != '') {
$out .= "<tr class='LEMgroup {$errClass}'><td colspan=2>" . $LEM->gT("Description:") . "</td><td colspan=2>" . $description . "</td></tr>";
}
$welcome = templatereplace('{WELCOME}');
$errClass = $LEM->em->HasErrors() ? 'LEMerror' : '';
if ($welcome != '') {
$out .= "<tr class='LEMgroup {$errClass}'><td colspan=2>" . $LEM->gT("Welcome:") . "</td><td colspan=2>" . $welcome . "</td></tr>";
}
$endmsg = templatereplace('{ENDTEXT}');
$errClass = $LEM->em->HasErrors() ? 'LEMerror' : '';
if ($endmsg != '') {
$out .= "<tr class='LEMgroup {$errClass}'><td colspan=2>" . $LEM->gT("End message:") . "</td><td colspan=2>" . $endmsg . "</td></tr>";
}
$_linkreplace = templatereplace('{URL}');
$errClass = $LEM->em->HasErrors() ? 'LEMerror' : '';
if ($_linkreplace != '') {
$out .= "<tr class='LEMgroup {$errClass}'><td colspan=2>" . $LEM->gT("End URL") . ":</td><td colspan=2>" . $_linkreplace . "</td></tr>";
}
}
$out .= "<tr><th>#</th><th>" . $LEM->gT('Name [ID]') . "</th><th>" . $LEM->gT('Relevance [Validation] (Default)') . "</th><th>" . $LEM->gT('Text [Help] (Tip)') . "</th></tr>\n";
$_gseq = -1;
foreach ($LEM->currentQset as $q) {
$gseq = $q['info']['gseq'];
$gid = $q['info']['gid'];
$qid = $q['info']['qid'];
$qseq = $q['info']['qseq'];
$errorCount = 0;
//////
// SHOW GROUP-LEVEL INFO
//////
if ($gseq != $_gseq) {
$LEM->ParseResultCache = array();
// reset for each group so get proper color coding?
$_gseq = $gseq;
$ginfo = $LEM->gseq2info[$gseq];
$grelevance = '{' . ($ginfo['grelevance'] == '' ? 1 : $ginfo['grelevance']) . '}';
$gtext = trim($ginfo['description']) == '' ? ' ' : $ginfo['description'];
$groupRow = "<tr class='LEMgroup'>" . "<td>G-{$gseq}</td>" . "<td><b>" . $ginfo['group_name'] . "</b><br/>[<a target='_blank' href='{$rooturl}/admin/admin.php?action=orderquestions&sid={$sid}&gid={$gid}'>GID " . $gid . "</a>]</td>" . "<td>" . $grelevance . "</td>" . "<td>" . $gtext . "</td>" . "</tr>\n";
$LEM->ProcessString($groupRow, $qid, NULL, false, 1, 1, false, false);
$out .= $LEM->GetLastPrettyPrintExpression();
if ($LEM->em->HasErrors()) {
++$errorCount;
}
}
//////
// SHOW QUESTION-LEVEL INFO
//////
$mandatory = $q['info']['mandatory'] == 'Y' ? "<span style='color:red'>*</span>" : '';
$type = $q['info']['type'];
$typedesc = $qtypes[$type]['description'];
$sgqas = explode('|', $q['sgqa']);
//.........这里部分代码省略.........
示例11: getqtypelist
else {$questionsummary .= ": (<i>".$clang->gT("Optional Question")."</i>)";}
}
$questionsummary .= "</td></tr>\n"
. "<tr><td align='right' valign='top'><strong>"
. $clang->gT("Question:")."</strong></td>\n<td align='left'>".$qrrow['question']."</td></tr>\n"
. "<tr><td align='right' valign='top'><strong>"
. $clang->gT("Help:")."</strong></td>\n<td align='left'>";
if (trim($qrrow['help'])!=''){$questionsummary .= $qrrow['help'];}
$questionsummary .= "</td></tr>\n";
if ($qrrow['preg'])
{
$questionsummary .= "<tr ><td align='right' valign='top'><strong>"
. $clang->gT("Validation:")."</strong></td>\n<td align='left'>{$qrrow['preg']}"
. "</td></tr>\n";
}
$qtypes = getqtypelist("", "array"); //qtypes = array(type code=>type description)
$questionsummary .= "<tr><td align='right' valign='top'><strong>"
.$clang->gT("Type:")."</strong></td>\n<td align='left'>{$qtypes[$qrrow['type']]['description']}";
$questionsummary .="</td></tr>\n";
if ($qct == 0 && $qtypes[$qrrow['type']]['answerscales'] >0)
{
$questionsummary .= "<tr ><td></td><td align='left'>"
. "<span class='statusentryhighlight'>"
. $clang->gT("Warning").": <a href='{$scriptname}?sid={$surveyid}&gid={$gid}&qid={$qid}&action=editansweroptions'>". $clang->gT("You need to add answer options to this question")." "
. "<img src='$imageurl/answers_20.png' title='"
. $clang->gT("Edit answer options for this question")."' name='EditThisQuestionAnswers'/></span></td></tr>\n";
}
// EDIT SUBQUESTIONS FOR THIS QUESTION BUTTON
if($sqct == 0 && $qtypes[$qrrow['type']]['subquestions'] >0)
{
示例12: scriptadvance
function scriptadvance()
{
$this->commonhelper->checkpermission("modify_scripts");
$go_ErrorPassingemptydatacontactyoursupport = $this->lang->line('go_ErrorPassingemptydatacontactyoursupport');
// check if $_POST has value
if (!empty($_POST)) {
global $dbprefix, $connect, $clang, $databasetype, $databasetabletype, $uploaddir, $limedb, $link;
$rootdir = $this->config->item('lime_path') . "/limesurvey";
require $rootdir . '/common_functions_ci.php';
require $rootdir . '/admin/admin_functions_ci.php';
require $rootdir . '/classes/core/sanitize.php';
require $rootdir . '/classes/core/language.php';
require $rootdir . '/admin/classes/core/sha256.php';
$clang = new limesurvey_lang('en');
require $rootdir . '/classes/core/surveytranslator_ci.php';
include $rootdir . '/admin/activate_functions.php';
require $rootdir . '/limesurvey_functions_ce.php';
// get asterisk dbname
$database = $this->go_script->asteriskDB->database;
// vicidial_script table
$data['fields'] = array('fullname' => 'Agent Name', 'vendor_lead_code' => 'vendor_lead_code', 'source_id' => 'source_id', 'list_id' => 'list_id', 'gmt_offset_now' => 'gmt_offset_now', 'called_since_last_reset' => 'called_since_last_reset', 'phone_code' => 'phone_code', 'phone_number' => 'phone_number', 'title' => 'title', 'first_name' => 'first_name', 'middle_initial' => 'middle_initial', 'last_name' => 'last_name', 'address1' => 'address1', 'address2' => 'address2', 'address3' => 'address3', 'city' => 'city', 'state' => 'state', 'province' => 'province', 'postal_code' => 'postal_code', 'country_code' => 'country_code', 'gender' => 'gender', 'date_of_birth' => 'date_of_birth', 'alt_phone' => 'alt_phone', 'email' => 'email', 'security_phrase' => 'security_phrase', 'comments' => 'comments', 'lead_id' => 'lead_id', 'campaign' => 'campaign', 'phone_login' => 'phone_login', 'group' => 'group', 'channel_group' => 'channel_group', 'SQLdate' => 'SQLdate', 'epoch' => 'epoch', 'uniqueid' => 'uniqueid', 'customer_zap_channel' => 'customer_zap_channel', 'server_ip' => 'server_ip', 'SIPexten' => 'SIPexten', 'session_id' => 'session_id', 'dialed_number' => 'dialed_number', 'dialed_label' => 'dialed_label', 'rank' => 'rank', 'owner' => 'owner', 'camp_script' => 'camp_script', 'in_script' => 'in_script', 'script_width' => 'script_width', 'script_height' => 'script_height', 'recording_filename' => 'recording_filename', 'recording_id' => 'recording_id', 'user_custom_one' => 'user_custom_one', 'user_custom_two' => 'user_custom_two', 'user_custom_three' => 'user_custom_three', 'user_custom_four' => 'user_custom_four', 'user_custom_five' => 'user_custom_five', 'preset_number_a' => 'preset_number_a', 'preset_number_b' => 'preset_number_b', 'preset_number_c' => 'preset_number_c', 'preset_number_d' => 'preset_number_d', 'preset_number_e' => 'preset_number_e', 'preset_number_f' => 'preset_number_f', 'preset_dtmf_a' => 'preset_dtmf_a', 'preset_dtmf_b' => 'preset_dtmf_b', 'did_id' => 'did_id', 'did_extension' => 'did_extension', 'did_pattern' => 'did_pattern', 'did_description' => 'did_description', 'closecallid' => 'closecallid', 'xfercallid' => 'xfercallid', 'agent_log_id' => 'agent_log_id', 'entry_list_id' => 'entry_list_id');
$info = $this->commonhelper->simpleretrievedata('vicidial_scripts', "script_id,script_name,script_comments,script_text,active", null, array(array('script_id' => $_POST['script_id'])));
$data['vicidial_script'] = $info->result();
// get the data from limesurvey
$this->go_script->limesurveyDB->select("surveyls_survey_id,surveyls_title,surveyls_description,ls.active,surveyls_welcometext,\n surveyls_endtext,surveyls_language,surveyls_url,surveyls_urldescription,surveyls_dateformat,\n admin,adminemail,format,showwelcome,navigationdelay,allowprev,allowjumps,nokeyboard,showprogress,\n\t printanswers,publicstatistics,publicgraphs,autoredirect,showXquestions,showgroupinfo,showqnumcode,\n\t ls.template,surveyls_numberformat,ls.sid,vs.script_name,vs.script_comments,vs.script_id");
$this->go_script->limesurveyDB->from("lime_surveys_languagesettings as lsl");
$this->go_script->limesurveyDB->join("lime_surveys as ls", "lsl.surveyls_survey_id=ls.sid", "left");
$this->go_script->limesurveyDB->join("{$database}.go_scripts as gs", "ls.sid={$database}.gs.surveyid", "right");
$this->go_script->limesurveyDB->join("{$database}.vicidial_scripts as vs", "gs.script_id={$database}.vs.script_id", "right");
$this->go_script->limesurveyDB->where("gs.script_id = '" . $_POST['script_id'] . "'");
$data['script'] = $this->go_script->limesurveyDB->get()->result();
//get the questions
$this->go_script->limesurveyDB->select("qid,title,question,type,mandatory,question_order,language,help,preg");
$this->go_script->limesurveyDB->where("sid", $data['script'][0]->sid);
$this->go_script->limesurveyDB->order_by("question_order", "asc");
$data['questions'] = $this->go_script->limesurveyDB->get("lime_questions")->result();
$data['script'][0]->surveyls_language = getLanguageNameFromCode($data['script'][0]->surveyls_language, false, $clang);
foreach (getRadixPointData(-1, $clang) as $index => $val) {
$data['radixpoint'][$index] = $val['desc'];
}
$templaterootDir = $rootdir . "/templates";
$standardtemplate = $rootdir . "/templates";
$standardtemplaterootDir = $rootdir . "/templates";
foreach (gettemplatelist($templaterootDir, $standardtemplate, $standardtemplaterootDir) as $template => $templateval) {
$data['template'][$template] = $template;
}
$data['type'] = getqtypelist($data['questions'][0]->type, 'group');
$data['preview'] = sGetTemplateURL($data['script'][0]->template);
$this->load->view('go_script/go_script_advance_ce', $data);
} else {
//die ($go_ErrorPassingemptydatacontactyoursupport);
die("" . $this->lang->line("go_error_passing_empty_data") . "");
}
}
示例13: returnglobal
//insert new question!
$loid_list = returnglobal('loid_list');
$loid_list = explode("~", $loid_list);
foreach($loid_list as $item) {
$loid = $item;
$question = returnglobal("txtQuestion_".$item);
$questiontype = returnglobal("slQuestionType_".$item);
$parent_id = "";
}
}
else {
$lo_tree = get_lo_subtree($loid);
//print_r($lo_tree);
//$qt = GetAllQuestionType();
$qt = getqtypelist();
$lo_id_list = array();
$html = genRawQuestionOnInitialize($lo_tree, $qt, $lo_id_list);
//print_r($qt);
//print_r($lo_id_list);
$rs_output .= $html;
$rs_output .= "<input name='loid' type='hidden' value='$loid' />";
$lo_id_list = implode("~", $lo_id_list);
$rs_output .= "<input name='loid_list' type='hidden' value='$lo_id_list' />";
}
}
}