Skip to content

Commit

Permalink
Merge branch 'master' into 192_dev
Browse files Browse the repository at this point in the history
  • Loading branch information
TMSWhite committed Jul 20, 2012
2 parents d635ad1 + a28788a commit 9cc921b
Show file tree
Hide file tree
Showing 21 changed files with 1,300 additions and 225 deletions.
1 change: 1 addition & 0 deletions admin/admin.php
Expand Up @@ -275,6 +275,7 @@
$_POST['surveyMode'] = 'survey';
$_POST['LEMcalledFromAdmin'] = 'Y';
$_POST['assessments'] = $thissurvey['assessments'];
LimeExpressionManager::SetDirtyFlag();
if (isset($_GET['gid'])) { $_POST['gid'] = $_GET['gid']; }
if (isset($_GET['qid'])) { $_POST['qid'] = $_GET['qid']; }
include($rootdir . '/classes/expressions/test/survey_logic_file.php');
Expand Down
2 changes: 1 addition & 1 deletion admin/statistics.php
Expand Up @@ -282,7 +282,7 @@
foreach ($survlangs as $survlang)
{
$language_options .= "\t<option value=\"{$survlang}\"";
if ($_SESSION['adminlang'] == $survlang)
if ($statlang == $survlang)
{
$language_options .= "selected=\"selected\" " ;
}
Expand Down
72 changes: 71 additions & 1 deletion classes/expressions/ExpressionManager.php
Expand Up @@ -151,7 +151,8 @@ function __construct()
'checkdate' => array('checkdate', 'checkdate', $this->gT('Returns true(1) if it is a valid date in gregorian calendar'), 'bool checkdate(month,day,year)', 'http://www.php.net/manual/en/function.checkdate.php', 3),
'cos' => array('cos', 'Math.cos', $this->gT('Cosine'), 'number cos(number)', 'http://www.php.net/manual/en/function.cos.php', 1),
'count' => array('exprmgr_count', 'LEMcount', $this->gT('Count the number of answered questions in the list'), 'number count(arg1, arg2, ... argN)', '', -1),
'countif' => array('exprmgr_countif', 'LEMcountif', $this->gT('Count the number of answered questions in the list equal the first argument'), 'number count(matches, arg1, arg2, ... argN)', '', -2),
'countif' => array('exprmgr_countif', 'LEMcountif', $this->gT('Count the number of answered questions in the list equal the first argument'), 'number countif(matches, arg1, arg2, ... argN)', '', -2),
'countifop' => array('exprmgr_countifop', 'LEMcountifop', $this->gT('Count the number of answered questions in the list which pass the critiera (arg op value)'), 'number countifop(op, value, arg1, arg2, ... argN)', '', -3),
'date' => array('date', 'date', $this->gT('Format a local date/time'), 'string date(format [, timestamp=time()])', 'http://www.php.net/manual/en/function.date.php', 1,2),
'exp' => array('exp', 'Math.exp', $this->gT('Calculates the exponent of e'), 'number exp(number)', 'http://www.php.net/manual/en/function.exp.php', 1),
'fixnum' => array('exprmgr_fixnum', 'LEMfixnum', $this->gT('Display numbers with comma as radix separator, if needed'), 'string fixnum(number)', '', 1),
Expand Down Expand Up @@ -211,6 +212,7 @@ function __construct()
'strtoupper' => array('strtoupper', 'LEMstrtoupper', $this->gT('Make a string uppercase'), 'string strtoupper(string)', 'http://www.php.net/manual/en/function.strtoupper.php', 1),
'substr' => array('substr', 'substr', $this->gT('Return part of a string'), 'string substr(string, start [, length])', 'http://www.php.net/manual/en/function.substr.php', 2,3),
'sum' => array('array_sum', 'LEMsum', $this->gT('Calculate the sum of values in an array'), 'number sum(arg1, arg2, ... argN)', '', -2),
'sumifop' => array('exprmgr_sumifop', 'LEMsumifop', $this->gT('Sum the values of answered questions in the list which pass the critiera (arg op value)'), 'number sumifop(op, value, arg1, arg2, ... argN)', '', -3),
'tan' => array('tan', 'Math.tan', $this->gT('Tangent'), 'number tan(arg)', 'http://www.php.net/manual/en/function.tan.php', 1),
'time' => array('time', 'time', $this->gT('Return current UNIX timestamp'), 'number time()', 'http://www.php.net/manual/en/function.time.php', 0),
'trim' => array('trim', 'trim', $this->gT('Strip whitespace (or other characters) from the beginning and end of a string'), 'string trim(string [, charlist])', 'http://www.php.net/manual/en/function.trim.php', 1,2),
Expand Down Expand Up @@ -3240,6 +3242,74 @@ function exprmgr_countif($args)
return $j;
}

/**
* Count the number of answered questions (non-empty) which meet the criteria (arg op value)
* @param <type> $args
* @return int
*/
function exprmgr_countifop($args)
{
$j=0;
$op = array_shift($args);
$value = array_shift($args);
foreach ($args as $arg)
{
switch($op)
{
case '==': case 'eq': if ($arg == $value) { ++$j; } break;
case '>=': case 'ge': if ($arg >= $value) { ++$j; } break;
case '>': case 'gt': if ($arg > $value) { ++$j; } break;
case '<=': case 'le': if ($arg <= $value) { ++$j; } break;
case '<': case 'lt': if ($arg < $value) { ++$j; } break;
case '!=': case 'ne': if ($arg != $value) { ++$j; } break;
case 'RX':
try {
if (@preg_match($value, $arg))
{
++$j;
}
}
catch (Exception $e) { }
break;
}
}
return $j;
}

/**
* Sum of values of answered questions which meet the criteria (arg op value)
* @param <type> $args
* @return int
*/
function exprmgr_sumifop($args)
{
$result=0;
$op = array_shift($args);
$value = array_shift($args);
foreach ($args as $arg)
{
switch($op)
{
case '==': case 'eq': if ($arg == $value) { $result += $arg; } break;
case '>=': case 'ge': if ($arg >= $value) { $result += $arg; } break;
case '>': case 'gt': if ($arg > $value) { $result += $arg; } break;
case '<=': case 'le': if ($arg <= $value) { $result += $arg; } break;
case '<': case 'lt': if ($arg < $value) { $result += $arg; } break;
case '!=': case 'ne': if ($arg != $value) { $result += $arg; } break;
case 'RX':
try {
if (@preg_match($value, $arg))
{
$result += $arg;
}
}
catch (Exception $e) { }
break;
}
}
return $result;
}

/**
* If $test is true, return $ok, else return $error
* @param <type> $test
Expand Down
8 changes: 5 additions & 3 deletions classes/expressions/LimeExpressionManager.php
Expand Up @@ -4803,8 +4803,10 @@ static function JumpTo($seq,$preview=false,$processPOST=true,$force=false,$chang
else
{
// display new group
$message .= $LEM->_UpdateValuesInDatabase($updatedValues,false,$setSubmitDate);
$LEM->runtimeTimings[] = array(__METHOD__,(microtime(true) - $now));
if(!$preview){ // Save only if not in preview mode
$message .= $LEM->_UpdateValuesInDatabase($updatedValues,false,$setSubmitDate);
$LEM->runtimeTimings[] = array(__METHOD__,(microtime(true) - $now));
}
$LEM->lastMoveResult = array(
'finished'=>false,
'message'=>$message,
Expand Down Expand Up @@ -7338,7 +7340,7 @@ private function getQuestionAttributesForEM($surveyid=NULL,$qid=NULL, $lang=NULL
global $databasetype;
if ($databasetype == 'odbc_mssql' || $databasetype == 'odbtp' || $databasetype == 'mssql_n' || $databasetype =='mssqlnative')
{
$query = "select distinct a.qid, a.attribute, CAST(a.value as varchar) as value";
$query = "select distinct a.qid, a.attribute, CAST(a.value as varchar(4000)) as value";
}
else
{
Expand Down
20 changes: 12 additions & 8 deletions common_functions.php
Expand Up @@ -2239,15 +2239,19 @@ function strip_comments($comment, $email, $replace=''){

function validate_templatedir($templatename)
{
global $usertemplaterootdir, $standardtemplaterootdir, $defaulttemplate;
if (is_dir("$usertemplaterootdir/{$templatename}/"))
global $usertemplaterootdir, $defaulttemplate;
if (isStandardTemplate($templatename))
{
return $templatename;
}
elseif (is_dir("$standardtemplaterootdir/{$templatename}/"))
elseif (is_dir("$usertemplaterootdir/{$templatename}/"))
{
return $templatename;
}
elseif (isStandardTemplate($defaulttemplate))
{
return $defaulttemplate;
}
elseif (is_dir("$usertemplaterootdir/{$defaulttemplate}/"))
{
return $defaulttemplate;
Expand Down Expand Up @@ -4799,7 +4803,7 @@ function createPassword()

for ($i=0; $i<$password_length; $i++)
{
$passwd .= $pwchars[floor(rand(0,strlen($pwchars)-1))];
$passwd .= $pwchars[(int)floor(rand(0,strlen($pwchars)-1))];
}
return $passwd;
}
Expand Down Expand Up @@ -6535,15 +6539,15 @@ function sGetTemplatePath($sTemplateName)
}
else
{
if (file_exists($usertemplaterootdir.'/'.$sTemplateName))
if (is_dir($usertemplaterootdir.'/'.$sTemplateName))
{
return $usertemplaterootdir.'/'.$sTemplateName;
}
elseif (file_exists($usertemplaterootdir.'/'.$defaulttemplate))
elseif (is_dir($usertemplaterootdir.'/'.$defaulttemplate))
{
return $usertemplaterootdir.'/'.$defaulttemplate;
}
elseif (file_exists($standardtemplaterootdir.'/'.$defaulttemplate))
elseif (isStandardTemplate($defaulttemplate))
{
return $standardtemplaterootdir.'/'.$defaulttemplate;
}
Expand Down Expand Up @@ -6576,7 +6580,7 @@ function sGetTemplateURL($sTemplateName)
{
return $usertemplaterooturl.'/'.$defaulttemplate;
}
elseif (file_exists($standardtemplaterootdir.'/'.$defaulttemplate))
elseif (isStandardTemplate($defaulttemplate))
{
return $standardtemplaterooturl.'/'.$defaulttemplate;
}
Expand Down

0 comments on commit 9cc921b

Please sign in to comment.