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 Jun 19, 2012
2 parents 3a3e2b8 + f8e80f8 commit 3556984
Show file tree
Hide file tree
Showing 8 changed files with 123 additions and 108 deletions.
5 changes: 4 additions & 1 deletion admin/install/createdb.php
Expand Up @@ -41,7 +41,10 @@
if ($createdbtype=='mssql_n' || $createdbtype=='odbc_mssql' || $createdbtype=='odbtp') $createdbtype='mssql';
if($createdbtype=='postgres' && version_compare($connect->pgVersion, '9') >= 0)
{
$connect->execute("ALTER DATABASE {$dbname} SET bytea_output='escape';");
$result=$connect->execute("ALTER DATABASE {$dbname} SET bytea_output='escape';");
if ($result==false){
die ('Database creation failed. Some database settings could not be set.<br>You need to be owner of the Postgres database. Please adjust your permissions and try again.');
}
}
if($createdbtype=='mssqlnative') $createdbtype='mssqlnative';
if (modify_database(dirname(__FILE__).'/create-'.$createdbtype.'.sql'))
Expand Down
2 changes: 1 addition & 1 deletion admin/install/resetadminpw.php
Expand Up @@ -32,7 +32,7 @@
case 'odbc_mssql':modify_database("",'UPDATE [prefix_users] set password=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
case 'postgres':modify_database("",'UPDATE prefix_users set \"password\"=\'$defaultpass\' where uid=1;');
case 'postgres':modify_database("",'UPDATE prefix_users set "password"=\'$defaultpass\' where uid=1;');
echo $modifyoutput; flush();
break;
}
Expand Down
2 changes: 1 addition & 1 deletion admin/update/updater.php
Expand Up @@ -12,7 +12,7 @@
*
* $Id: updater.php 8987 2010-07-27 12:59:34Z c_schmitz $
*/
list(,$updaterversion)=explode(' ','$Rev: 11664 $'); // this is updated by subversion so don't change this string
$updaterversion='120614';

if (isset($_REQUEST['update'])) die();

Expand Down
73 changes: 47 additions & 26 deletions classes/expressions/LimeExpressionManager.php
Expand Up @@ -1059,6 +1059,17 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
$cascadedAFE = array_reverse($cascadedAFE);

$subqs = $qinfo['subqs'];
if ($type == 'R') {
$subqs = array();
foreach ($this->qans[$qinfo['qid']] as $k=>$v)
{
$_code = explode('~',$k);
$subqs[] = array(
'rowdivid'=>$qinfo['sgqa'] . $_code[1],
'sqsuffix'=>'_' . $_code[1],
);
}
}
$last_rowdivid = '--';
foreach ($subqs as $sq) {
if ($sq['rowdivid'] == $last_rowdivid)
Expand All @@ -1083,6 +1094,7 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
case 'P': //Multiple choice with comments checkbox + text
case 'K': //MULTIPLE NUMERICAL QUESTION
case 'Q': //MULTIPLE SHORT TEXT
case 'R': //Ranking
// if ($this->sgqaNaming)
// {
foreach ($cascadedAF as $_caf)
Expand Down Expand Up @@ -1443,6 +1455,7 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
case 'K': //MULTIPLE NUMERICAL QUESTION
case 'Q': //MULTIPLE SHORT TEXT
case 'M': //Multiple choice checkbox
case 'R': //RANKING STYLE
if ($this->sgqaNaming)
{
$sq_name = substr($sq['jsVarName'],4) . '.NAOK';
Expand All @@ -1464,10 +1477,6 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
}
}
break;
case 'R': //RANKING STYLE
// TODO - does not have sub-questions, so how should this be done?
// Current JavaScript works fine, but can't use expression value
break;
default:
break;
}
Expand All @@ -1484,7 +1493,7 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
'qtype' => $type,
'type' => 'min_answers',
'class' => 'num_answers',
'eqn' => '(count(' . implode(', ', $sq_names) . ') >= (' . $min_answers . '))',
'eqn' => 'if(is_empty('.$min_answers.'),1,(count(' . implode(', ', $sq_names) . ') >= (' . $min_answers . ')))',
'qid' => $questionNum,
);
}
Expand Down Expand Up @@ -1532,6 +1541,7 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
case 'K': //MULTIPLE NUMERICAL QUESTION
case 'Q': //MULTIPLE SHORT TEXT
case 'M': //Multiple choice checkbox
case 'R': //RANKING STYLE
if ($this->sgqaNaming)
{
$sq_name = substr($sq['jsVarName'],4) . '.NAOK';
Expand All @@ -1553,10 +1563,6 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
}
}
break;
case 'R': //RANKING STYLE
// TODO - does not have sub-questions, so how should this be done?
// Current JavaScript works fine, but can't use expression value
break;
default:
break;
}
Expand All @@ -1573,7 +1579,7 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
'qtype' => $type,
'type' => 'max_answers',
'class' => 'num_answers',
'eqn' => '(count(' . implode(', ', $sq_names) . ') <= (' . $max_answers . '))',
'eqn' => '(if(is_empty('.$max_answers.'),1,count(' . implode(', ', $sq_names) . ') <= (' . $max_answers . ')))',
'qid' => $questionNum,
);
}
Expand Down Expand Up @@ -2984,7 +2990,7 @@ private function setVariableAndTokenMappingsForExpressionManager($surveyid,$forc
$varName = $fielddata['title'] . '_' . $fielddata['aid'];
$question = $fielddata['subquestion'];
// $question = $fielddata['question'] . ': ' . $fielddata['subquestion'];
if ($type != 'H' && $type != 'R') {
if ($type != 'H') {
if ($type == 'P' && preg_match("/comment$/", $sgqa)) {
// $rowdivid = substr($sgqa,0,-7);
}
Expand Down Expand Up @@ -4272,7 +4278,7 @@ private function _UpdateValuesInDatabase($updatedValues, $finished=false,$setSub
}
else
{
// Otherwise, use the real date/time, it will only be saved when the table holds a
// Otherwise, use the real date/time, it will only be saved when the table holds a
// datestamp field
$datestamp=date_shift(date("Y-m-d H:i:s"), "Y-m-d H:i:s", $this->surveyOptions['timeadjust']);
}
Expand Down Expand Up @@ -6009,9 +6015,10 @@ static function GetRelevanceAndTailoringJavaScript()

// Do all sub-question filtering (e..g array_filter)
/**
* $afHide - if true, then use jQuery.show(). If false, then disable/enable the row
* $afHide - if true, then use jQuery.show(). If false, then disable/enable the row
*/
$afHide = (isset($LEM->qattr[$arg['qid']]['array_filter_style']) ? ($LEM->qattr[$arg['qid']]['array_filter_style'] == '0') : true);
$inputSelector = (($arg['type'] == 'R') ? '' : ' :input:not(:hidden)');
foreach ($subqParts as $sq)
{
$rowdividList[$sq['rowdivid']] = $sq['result'];
Expand All @@ -6023,15 +6030,15 @@ static function GetRelevanceAndTailoringJavaScript()
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').removeAttr('disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').removeAttr('disabled');\n";
}
if ($sq['isExclusiveJS'] != '')
{
$relParts[] = " if ( " . $sq['isExclusiveJS'] . " ) {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n";
$relParts[] = " }\n";
$relParts[] = " else {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').removeAttr('disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').removeAttr('disabled');\n";
$relParts[] = " }\n";
}
$relParts[] = " relChange" . $arg['qid'] . "=true;\n";
Expand All @@ -6042,23 +6049,23 @@ static function GetRelevanceAndTailoringJavaScript()
if ($sq['irrelevantAndExclusiveJS'] != '')
{
$relParts[] = " if ( " . $sq['irrelevantAndExclusiveJS'] . " ) {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n";
$relParts[] = " }\n";
$relParts[] = " else {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').removeAttr('disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').removeAttr('disabled');\n";
if ($afHide)
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n";
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n";
}
$relParts[] = " }\n";
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n";
}
}
else
Expand All @@ -6069,7 +6076,7 @@ static function GetRelevanceAndTailoringJavaScript()
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "$inputSelector').attr('disabled','disabled');\n";
}
}
$relParts[] = " relChange" . $arg['qid'] . "=true;\n";
Expand Down Expand Up @@ -7001,6 +7008,8 @@ public static function usingCommaAsRadix()

private static function getConditionsForEM($surveyid=NULL, $qid=NULL)
{
global $databasetype;

if (!is_null($qid)) {
$where = " c.qid = ".$qid." and ";
}
Expand All @@ -7022,8 +7031,18 @@ private static function getConditionsForEM($surveyid=NULL, $qid=NULL)
." from ".db_table_name('conditions')." as c"
.", ".db_table_name('questions')." as q"
." where ". $where
." c.cqid = 0 and c.qid = q.qid"
." order by sid, qid, scenario, cqid, cfieldname, value";
." c.cqid = 0 and c.qid = q.qid";

if ($databasetype == 'mssql')
{
$query .= " order by sid, c.qid, scenario, cqid, cfieldname, value";

}
else
{
$query .= " order by sid, qid, scenario, cqid, cfieldname, value";

}

$data = db_execute_assoc($query);

Expand Down Expand Up @@ -7888,7 +7907,7 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL
break;
case 'other':
if ($value == 'N') {
$value = NULL; // so can skip this one
$value = NULL; // so can skip this one
}
break;
}
Expand Down Expand Up @@ -8032,8 +8051,6 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL
$sgqa_len = strlen($sid . 'X'. $gid . 'X' . $qid);
$varName = $rootVarName . '_' . substr($_rowdivid,$sgqa_len);
}
case 'L':
// TODO - need to show array filters applied to lists
break;
}
if (is_null($rowdivid)) {
Expand Down Expand Up @@ -8102,6 +8119,10 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL

$subQeqn = '';
$rowdivid = $sgqas[0] . $ansInfo[1];
if ($q['info']['type'] == 'R')
{
$rowdivid = $LEM->sid . 'X' . $gid . 'X' . $qid . $ansInfo[1];
}
if (isset($LEM->subQrelInfo[$qid][$rowdivid]))
{
$sq = $LEM->subQrelInfo[$qid][$rowdivid];
Expand Down
6 changes: 3 additions & 3 deletions common_functions.php
Expand Up @@ -3215,23 +3215,23 @@ function questionAttributes($returnByName=false)
"caption"=>$clang->gT('Answer width'));

$qattributes["array_filter"]=array(
"types"=>"1ABCEF:;MPLKQ",
"types"=>"1ABCEF:;MPLKQR",
'category'=>$clang->gT('Logic'),
'sortorder'=>100,
'inputtype'=>'text',
"help"=>$clang->gT("Enter the code(s) of Multiple choice question(s) (separated by semicolons) to only show the matching answer options in this question."),
"caption"=>$clang->gT('Array filter'));

$qattributes["array_filter_exclude"]=array(
"types"=>"1ABCEF:;MPLKQ",
"types"=>"1ABCEF:;MPLKQR",
'category'=>$clang->gT('Logic'),
'sortorder'=>100,
'inputtype'=>'text',
"help"=>$clang->gT("Enter the code(s) of Multiple choice question(s) (separated by semicolons) to exclude the matching answer options in this question."),
"caption"=>$clang->gT('Array filter exclusion'));

$qattributes["array_filter_style"]=array(
"types"=>"1ABCEF:;MPLKQ",
"types"=>"1ABCEF:;MPLKQR",
'category'=>$clang->gT('Logic'),
'sortorder'=>100,
'inputtype'=>'singleselect',
Expand Down

0 comments on commit 3556984

Please sign in to comment.