2
0
mirror of https://github.com/ACSPRI/queXS synced 2024-04-02 12:12:16 +00:00

Merging the updated Limesurvey 1.92+ branch of queXS to trunk

This commit is contained in:
azammitdcarf
2012-11-21 04:04:39 +00:00
parent 153fc8ca0d
commit c569559964
856 changed files with 254260 additions and 819988 deletions

View File

@@ -0,0 +1,19 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($subaction) && $subaction == 'conditions2relevance'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LimeExpressionManager: Preview Conditions to Relevance</title>
</head>
<body>
<?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>";
?>
</body>
</html>

View File

@@ -0,0 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($subaction) && $subaction == 'functions'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ExpressionManager: Available Functions</title>
</head>
<body>
<?php
echo ExpressionManager::ShowAllowableFunctions();
?>
</body>
</html>

View File

@@ -0,0 +1,112 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (count($_POST)==0 && !((isset($subaction) && $subaction == 'navigation_test'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LEM Navigation Test</title>
</head>
<body>
<?php
if (count($_POST) == 0) {
$clang = new limesurvey_lang("en");
$query = "select a.surveyls_survey_id as sid, a.surveyls_title as title, b.datecreated, b.assessments "
. "from " . db_table_name('surveys_languagesettings') . " as a join ". db_table_name('surveys') . " as b on a.surveyls_survey_id = b.sid"
. " where a.surveyls_language='en' order by a.surveyls_title, b.datecreated";
$data = db_execute_assoc($query);
$surveyList='';
foreach($data->GetRows() as $row) {
$surveyList .= "<option value='" . $row['sid'] .'|' . $row['assessments'] . "'>#" . $row['sid'] . " [" . $row['datecreated'] . '] ' . FlattenText($row['title']) . "</option>\n";
}
$form = <<< EOD
<form method='post' action='../classes/expressions/test/navigation_test.php'>
<h3>Enter the following variables to test navigation for a survey using different styles</h3>
<table border='1'>
<tr><th>Parameter</th><th>Value</th></tr>
<tr><td>Survey ID (SID)</td>
<td><select name='sid' id='sid'>
$surveyList
</select></td></tr>
<tr><td>Navigation Style</td>
<td><select name='surveyMode' id='surveyMode'>
<option value='question'>Question (One-at-a-time)</option>
<option value='group' selected='selected'>Group (Group-at-a-time)</option>
<option value='survey'>Survey (All-in-one)</option>
</select></td></tr>
<tr><td>Debug Log Level</td>
<td>
Specify which debugging features to use
<ul>
<li><input type='checkbox' name='LEM_DEBUG_TIMING' id='LEM_DEBUG_TIMING' value='Y'/>Detailed Timing</li>
<li><input type='checkbox' name='LEM_DEBUG_VALIDATION_SUMMARY' id='LEM_DEBUG_VALIDATION_SUMMARY' value='Y' checked="checked"/>Validation Summary</li>
<li><input type='checkbox' name='LEM_DEBUG_VALIDATION_DETAIL' id='LEM_DEBUG_VALIDATION_DETAIL' value='Y' checked="checked"/>Validation Detail (Validation Summary must also be checked to see detail)</li>
<li><input type='checkbox' name='LEM_PRETTY_PRINT_ALL_SYNTAX' id='LEM_PRETTY_PRINT_ALL_SYNTAX' value='Y' checked="checked"/>Pretty Print Syntax</li>
<li><input type='checkbox' name='deletenonvalues' id='deletenonvalues' value='Y' checked="checked"/>Delete Non-Values</li>
</ul></td>
</tr>
<tr><td colspan='2'><input type='submit'/></td></tr>
</table>
</form>
EOD;
echo $form;
}
else {
include_once('../LimeExpressionManager.php');
require_once('../../../classes/core/startup.php');
require_once('../../../config-defaults.php');
require_once('../../../common.php');
require_once('../../../classes/core/language.php');
$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_PRETTY_PRINT_ALL_SYNTAX']) && $_POST['LEM_PRETTY_PRINT_ALL_SYNTAX'] == 'Y') ? LEM_PRETTY_PRINT_ALL_SYNTAX : 0)
);
$deletenonvalues = ((isset($_POST['deletenonvalues']) && $_POST['deletenonvalues']=='Y') ? 1 : 0);
$surveyOptions = array(
'active'=>false,
'allowsave'=>true,
'anonymized'=>false,
'assessments'=>$assessments,
'datestamp'=>true,
'deletenonvalues'=>$deletenonvalues,
'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>

View File

@@ -0,0 +1,19 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($subaction) && $subaction == 'relevance'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ExpressionManager: Unit Test Relevance</title>
<script type="text/javascript" src="../scripts/jquery/jquery.js"></script>
<script type="text/javascript" src="../scripts/em_javascript.js"></script>
<script type="text/javascript" src="../scripts/survey_runtime.js"></script>
</head>
<body id="limesurvey">
<?php
// include_once('../LimeExpressionManager.php');
LimeExpressionManager::UnitTestRelevance();
?>
</body>
</html>

View File

@@ -0,0 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($subaction) && $subaction == 'strings_with_expressions'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ExpressionManager: Test Evaluation of Strings Containing Expressions</title>
</head>
<body>
<?php
LimeExpressionManager::UnitTestProcessStringContainingExpressions();
?>
</body>
</html>

View File

@@ -0,0 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($subaction) && $subaction == 'stringsplit'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ExpressionManager: Unit Test String Splitter</title>
</head>
<body>
<?php
ExpressionManager::UnitTestStringSplitter();
?>
</body>
</html>

View File

@@ -0,0 +1,146 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<?php
if (count($_POST) == 0 && !((isset($subaction) && $subaction == 'survey_logic_file'))) {die("Cannot run this script directly");}
?>
<?php
if (count($_GET) > 0) {
foreach ($_GET as $key=>$val) {
if ($key == 'sid') {
$val = $val . '|N'; // hack to pretend this is not an assessment
}
$_POST[$key] = $val;
}
}
if ((isset($subaction) && $subaction == 'survey_logic_file') || $_POST['LEMcalledFromAdmin']=='Y') {
$rootpath = $rootdir;
}
else {
$rootpath = '../../..';
}
include_once($rootpath . '/classes/expressions/LimeExpressionManager.php');
require_once($rootpath . '/classes/core/startup.php');
require_once($rootpath . '/config-defaults.php');
require_once($rootpath . '/common.php');
require_once($rootpath . '/classes/core/language.php');
$clang = new limesurvey_lang("en");
if ((isset($subaction) && $subaction == 'survey_logic_file')) // || count($_POST) == 0) {
{
$query = "select a.surveyls_survey_id as sid, a.surveyls_title as title, b.datecreated, b.assessments "
. "from " . db_table_name('surveys_languagesettings') . " as a join ". db_table_name('surveys') . " as b on a.surveyls_survey_id = b.sid"
. " where a.surveyls_language='en' order by a.surveyls_title, b.datecreated";
$data = db_execute_assoc($query);
$surveyList='';
foreach($data->GetRows() as $row) {
$surveyList .= "<option value='" . $row['sid'] .'|' . $row['assessments'] . "'>#" . $row['sid'] . " [" . $row['datecreated'] . '] ' . FlattenText($row['title']) . "</option>\n";
}
$form = <<< EOD
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Survey Logic File</title>
</head>
<body>
<form method='post' action='../classes/expressions/test/survey_logic_file.php'>
<h3>Generate a logic file for the survey</h3>
<table border='1'>
<tr><th>Parameter</th><th>Value</th></tr>
<tr><td>Survey ID (SID)</td>
<td><select name='sid' id='sid'>
$surveyList
</select></td></tr>
<tr><td>Navigation Style</td>
<td><select name='surveyMode' id='surveyMode'>
<option value='question'>Question (One-at-a-time)</option>
<option value='group'>Group (Group-at-a-time)</option>
<option value='survey' selected='selected'>Survey (All-in-one)</option>
</select></td></tr>
<tr><td>Debug Log Level</td>
<td>
Specify which debugging features to use
<ul>
<li><input type='checkbox' name='LEM_DEBUG_TIMING' id='LEM_DEBUG_TIMING' value='Y'/>Detailed Timing</li>
<li><input type='checkbox' name='LEM_DEBUG_VALIDATION_SUMMARY' id='LEM_DEBUG_VALIDATION_SUMMARY' value='Y'/>Validation Summary</li>
<li><input type='checkbox' name='LEM_DEBUG_VALIDATION_DETAIL' id='LEM_DEBUG_VALIDATION_DETAIL' value='Y'/>Validation Detail (Validation Summary must also be checked to see detail)</li>
<li><input type='checkbox' name='LEM_PRETTY_PRINT_ALL_SYNTAX' id='LEM_PRETTY_PRINT_ALL_SYNTAX' value='Y' checked="checked"/>Pretty Print Syntax</li>
</ul></td>
</tr>
<tr><td colspan='2'><input type='submit'/></td></tr>
</table>
</form>
</body>
EOD;
echo $form;
}
else {
$surveyInfo = explode('|',$_POST['sid']);
$surveyid = $surveyInfo[0];
if (isset($_POST['assessments']))
{
$assessments = ($_POST['assessments'] == 'Y');
}
else
{
$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_PRETTY_PRINT_ALL_SYNTAX']) && $_POST['LEM_PRETTY_PRINT_ALL_SYNTAX'] == 'Y') ? LEM_PRETTY_PRINT_ALL_SYNTAX : 0)
);
$language = (isset($_POST['lang']) ? sanitize_languagecode($_POST['lang']) : NULL);
$gid = (isset($_POST['gid']) ? sanitize_int($_POST['gid']) : NULL);
$qid = (isset($_POST['qid']) ? sanitize_int($_POST['qid']) : NULL);
print <<< EOD
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Logic File - Survey #$surveyid</title>
<style type="text/css">
tr.LEMgroup td
{
background-color:lightgrey;
}
tr.LEMquestion
{
background-color:#EAF2D3;
}
tr.LEManswer td
{
background-color:white;
}
.LEMerror
{
color:red;
font-weight:bold;
}
tr.LEMsubq td
{
background-color:lightyellow;
}
</style>
</head>
<body>
EOD;
SetSurveyLanguage($surveyid, $language);
$result = LimeExpressionManager::ShowSurveyLogicFile($surveyid, $gid, $qid,$LEMdebugLevel,$assessments);
print $result['html'];
print <<< EOD
</body>
EOD;
}
?>
</html>

View File

@@ -0,0 +1,56 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($action) && $action == 'EMtest'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Suite for Expression Manager</title>
</head>
<body>
<h1>Test Suite for Expression Manager</h1>
<table border="1">
<tr><th>Test</th><th>Description</th></tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=functions">Available Functions</a></td>
<td>Show the list of functions available within Expression Manager.</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=stringsplit">String Splitter</a></td>
<td>Unit test of String Splitter to ensure splits source into Strings vs. Expressions. Expressions are surrounded by un-escaped curly braces</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=tokenizer">Tokenizer</a></td>
<td>Demonstrates that Expression Manager properly detects and categorizes tokens (e.g. variables, string, functions, operators)</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=unit">Unit Tests of Isolated Expressions</a></td>
<td>Unit tests of each of Expression Manager's features (e.g. all operators and functions). Color coding shows whether any tests fail. Syntax highlighting shows cases where Expression Manager properly detects bad syntax.</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=strings_with_expressions">Unit Tests of Expressions Within Strings</a></td>
<td>Test how Expression Manager can process strings containing one or more variable, token, or expression replacements surrounded by curly braces.</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=relevance">Unit Test Dynamic Relevance Processing</a></td>
<td>Questions and substitutions should dynamically change based upon values entered.</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=conditions2relevance">Preview Conversion of Conditions to Relevance</a></td>
<td>Shows Relevance equations for all conditions in the database, grouped by question id (and not pretty-printed)</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=upgrade_conditions2relevance">Bulk Convert Conditions to Relevance</a></td>
<td>Convert conditions to relevance for entire database</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=navigation_test">Test Navigation</a></td>
<td>Tests whether navigation properly handles relevant and irrelevant groups</td>
</tr>
<tr>
<td><a href="admin.php?action=EMtest&subaction=survey_logic_file">Show Survey Logic File</a></td>
<td>Shows the logic for the survey (e.g. relevance, validation), and all tailoring</td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,15 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($subaction) && $subaction == 'tokenizer'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ExpressionManager: Unit Test Tokenizer</title>
</head>
<body>
<?php
ExpressionManager::UnitTestTokenizer();
?>
</body>
</html>

View File

@@ -0,0 +1,27 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($subaction) && $subaction == 'unit'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
<!--
.error {
background-color: #ff0000;
}
.ok {
background-color: #00ff00
}
-->
</style>
<title>ExpressionManager: Unit Test Core Evaluator</title>
</head>
<body onload="recompute()">
<script type="text/javascript" src="../scripts/em_javascript.js"></script>
<?php
// include_once('../ExpressionManager.php');
ExpressionManager::UnitTestEvaluator();
?>
</body>
</html>

View File

@@ -0,0 +1,24 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<?php
if (!((isset($subaction) && $subaction == 'upgrade_conditions2relevance'))) {die("Cannot run this script directly");}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LimeExpressionManager: Upgrade Conditions to Relevance</title>
</head>
<body>
<?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>";
}
?>
</body>
</html>