Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/Yii' into Yii
Browse files Browse the repository at this point in the history
Conflicts:
	application/helpers/update/updatedb_helper.php
  • Loading branch information
c-schmitz committed Jun 7, 2012
2 parents 39ee741 + 7baa8a2 commit 72cb8e5
Show file tree
Hide file tree
Showing 11 changed files with 4,291 additions and 3,907 deletions.
2 changes: 1 addition & 1 deletion application/config/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*/

$config['versionnumber'] = "2.0RC2";
$config['dbversionnumber'] = 157;
$config['dbversionnumber'] = 158;
$config['buildnumber'] = '';
$config['updatable'] = false;

Expand Down
15 changes: 15 additions & 0 deletions application/helpers/common_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4110,6 +4110,21 @@ function questionAttributes($returnByName=false)
"help"=>$clang->gT("Place questions into a specified randomization group, all questions included in the specified group will appear in a random order"),
"caption"=>$clang->gT("Randomization group name"));

// This is added to support historical behavior. Early versions of 1.92 used a value of "No", so if there was a min_sum_value or equals_sum_value, the question was not valid
// unless those criteria were met. In later releases of 1.92, the default was changed so that missing values were allowed even if those attributes were set
// This attribute lets authors control whether missing values should be allowed in those cases without needing to set min_answers
// Existing surveys will use the old behavior, but if the author edits the question, the default will be the new behavior.
$qattributes["value_range_allows_missing"]=array(
"types"=>"K",
'category'=>$clang->gT('Input'),
'sortorder'=>100,
"inputtype"=>"singleselect",
'options'=>array(0=>$clang->gT('No'),
1=>$clang->gT('Yes')),
'default'=>1,
"help"=>$clang->gT("Is no answer (missing) allowed when either 'Equals sum value' or 'Minimum sum value' are set?"),
"caption"=>$clang->gT("Value range allows missing"));

//This builds a more useful array (don't modify)
if ($returnByName==false)
{
Expand Down
109 changes: 109 additions & 0 deletions application/helpers/expressions/em_core_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2515,6 +2515,115 @@ static function UnitTestEvaluator()
// expectedResult~expression
// if the expected result is an error, use NULL for the expected result
$tests = <<<EOD
<B>Empty Vs. Empty</B>~"<B>Empty Vs. Empty</B>"
1~'' == ''
0~'' != ''
0~'' > ''
1~'' >= ''
0~'' < ''
1~'' <= ''
1~!''
~('' and '')
~('' or '')
<B>Empty Vs. Zero</B>~"<B>Empty Vs. Zero</B>"
0~'' == 0
1~'' != 0
0~'' > 0
0~'' >= 0
0~'' < 0
0~'' <= 0
1~!''
1~!0
0~('' and 0)
0~('' or 0)
<B>Empty Vs. Constant</B>~"<B>Empty Vs. Constant</B>"
0~'' == 3
1~'' != 3
0~'' > 3
0~'' >= 3
0~'' < 3
0~'' <= 3
1~!''
0~!3
0~('' and 3)
1~('' or 3)
<B>Empty Vs. Empty_Var</B>~"<B>Empty Vs. Empty_Var</B>"
1~'' == empty
0~'' != empty
0~'' > empty
1~'' >= empty
0~'' < empty
1~'' <= empty
1~!''
1~!empty
~('' and empty)
~('' or empty)
<B>Empty_Var Vs. Zero</B>~"<B>Empty_Var Vs. Zero</B>"
0~empty == 0
1~empty != 0
0~empty > 0
0~empty >= 0
0~empty < 0
0~empty <= 0
1~!empty
1~!0
0~(empty and 0)
0~(empty or 0)
<B>Empty_Var Vs. Zero</B>~"<B>Empty_Var Vs. Zero</B>"
0~empty == zero
1~empty != zero
0~empty > zero
0~empty >= zero
0~empty < zero
0~empty <= zero
1~!empty
1~!zero
0~(empty and zero)
0~(empty or zero)
<B>Empty_Var Vs. Constant</B>~"<B>Empty_Var Vs. Constant</B>"
0~empty == 3
1~empty != 3
0~empty > 3
0~empty >= 3
0~empty < 3
0~empty <= 3
1~!empty
0~!3
0~(empty and 3)
1~(empty or 3)
<B>Solution: Empty_Var Vs. Zero</B>~"<B>Solution: Empty_Var Vs. Zero</B>"
0~!is_empty(empty) && (empty == 0)
0~!is_empty(five) && (five == 0)
1~!is_empty(zero) && (zero == 0)
0~!is_empty(empty) && (empty > 0)
0~!is_empty(empty) && (empty >= 0)
0~!is_empty(empty) && (empty < 0)
0~!is_empty(empty) && (empty <= 0)
0~!is_empty(empty) && ((empty and 0))
0~!is_empty(empty) && ((empty or 0))
<B>Solution: Empty_Var Vs. Zero</B>~"<B>Solution: Empty_Var Vs. Zero</B>"
0~!is_empty(empty) && (empty == zero)
0~!is_empty(five) && (five == zero)
1~!is_empty(zero) && (zero == zero)
0~!is_empty(empty) && (empty > zero)
0~!is_empty(empty) && (empty >= zero)
0~!is_empty(empty) && (empty < zero)
0~!is_empty(empty) && (empty <= zero)
0~!is_empty(empty) && ((empty and zero))
0~!is_empty(empty) && ((empty or zero))
<B>Solution: Empty_Var Vs. Constant</B>~"<B>Solution: Empty_Var Vs. Constant</B>"
0~!is_empty(empty) && (empty < 3)
0~!is_empty(empty) && (empty <= 3)
<B>Solution: Empty_Var Vs. Variable</B>~"<B>Solution: Empty_Var Vs. Variable</B>"
0~!is_empty(empty) && (empty < five)
0~!is_empty(empty) && (empty <= five)
<B>Solution: The Hard One is Empty_Var != 0</B>~"<B>Solution: The Hard One is Empty_Var != 0</B>"
1~(empty != 0)
1~!is_empty(empty) && (empty != 0)
1~is_empty(empty) || (empty != 0)
1~is_empty(empty) || (empty != zero)
0~is_empty(zero) || (zero != 0)
1~is_empty(five) || (five != 0)
<b>SETUP</b>~'<b>SETUP</b>'
&quot;Can strings contain embedded \&quot;quoted passages\&quot; (and parentheses + other characters?)?&quot;~a=htmlspecialchars(ASSESSMENT_HEADING)
&quot;can single quoted strings&quot; . &#039;contain nested &#039;quoted sections&#039;?~b=htmlspecialchars(QUESTIONHELP)
Expand Down
108 changes: 94 additions & 14 deletions application/helpers/expressions/em_manager_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ class LimeExpressionManager {
* 'type' => 'M' // the one-letter question type
* 'fieldname' => '26626X34X702sq1' // the fieldname (used as JavaScript variable name, and also as database column name
* 'rootVarName' => 'afDS' // the root variable name
* 'preg' => '/[A-Z]+/' // regular expression validation equation, if any
* 'subqs' => array() of sub-questions, where each contains:
* 'rowdivid' => '26626X34X702sq1' // the javascript id identifying the question row (so array_filter can hide rows)
* 'varName' => 'afSrcFilter_sq1' // the full variable name for the sub-question
Expand Down Expand Up @@ -791,6 +792,7 @@ public static function ConvertConditionsToRelevance($surveyId=NULL, $qid=NULL)
$relOrList = array();
foreach($query->readAll() as $row)
{
$row['method']=trim($row['method']); //For Postgres
if ($row['qid'] != $_qid)
{
// output the values for prior question is there was one
Expand Down Expand Up @@ -884,18 +886,52 @@ public static function ConvertConditionsToRelevance($surveyId=NULL, $qid=NULL)
{
// Conditions uses ' ' to mean not answered, but internally it is really stored as ''. Fix this
if ($value === '" "') {
if ($row['method'] == '==') {
if ($row['method'] == '==')
{
$relOrList[] = "is_empty(" . $fieldname . ")";
}
else if ($row['method'] == '!=') {
$relOrList[] = "!is_empty(" . $fieldname . ")";
}
else {
$relOrList[] = $fieldname . " " . $row['method'] . " " . $value;
else if ($row['method'] == '!=')
{
$relOrList[] = "!is_empty(" . $fieldname . ")";
}
else
{
$relOrList[] = $fieldname . " " . $row['method'] . " " . $value;
}
}
else {
$relOrList[] = $fieldname . " " . $row['method'] . " " . $value;
else
{
if ($value == '"0"' || !preg_match('/^".+"$/',$value))
{
switch ($row['method'])
{
case '==':
case '<':
case '<=':
case '>=':
$relOrList[] = '(!is_empty(' . $fieldname . ') && (' . $fieldname . " " . $row['method'] . " " . $value . '))';
break;
case '!=':
$relOrList[] = '(is_empty(' . $fieldname . ') || (' . $fieldname . " != " . $value . '))';
break;
default:
$relOrList[] = $fieldname . " " . $row['method'] . " " . $value;
break;
}
}
else
{
switch ($row['method'])
{
case '<':
case '<=':
$relOrList[] = '(!is_empty(' . $fieldname . ') && (' . $fieldname . " " . $row['method'] . " " . $value . '))';
break;
default:
$relOrList[] = $fieldname . " " . $row['method'] . " " . $value;
break;
}
}
}
}

Expand Down Expand Up @@ -982,6 +1018,15 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
$input_boxes='';
}

if (isset($qattr['value_range_allows_missing']) && $qattr['value_range_allows_missing'] == '1')
{
$value_range_allows_missing = true;
}
else
{
$value_range_allows_missing = false;
}

// array_filter
// If want to filter question Q2 on Q1, where each have subquestions SQ1-SQ3, this is equivalent to relevance equations of:
// relevance for Q2_SQ1 is Q1_SQ1!=''
Expand Down Expand Up @@ -1170,11 +1215,18 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
$sumRemainingEqn = 'round(' . $sumRemainingEqn . ', ' . $precision . ')';
$mainEqn = 'round(' . $mainEqn . ', ' . $precision . ')';
}

$noanswer_option = '';
if ($value_range_allows_missing)
{
$noanswer_option = ' || count(' . implode(', ', $sq_names) . ') == 0';
}

$validationEqn[$questionNum][] = array(
'qtype' => $type,
'type' => 'equals_num_value',
'class' => 'sum_range',
'eqn' => ($qinfo['mandatory']=='Y')?'(' . $mainEqn . ' == (' . $equals_num_value . '))':'(' . $mainEqn . ' == (' . $equals_num_value . ') || count(' . implode(', ', $sq_names) . ') == 0)',
'eqn' => ($qinfo['mandatory']=='Y')?'(' . $mainEqn . ' == (' . $equals_num_value . '))':'(' . $mainEqn . ' == (' . $equals_num_value . ')' . $noanswer_option . ')',
'qid' => $questionNum,
'sumEqn' => $sumEqn,
'sumRemainingEqn' => $sumRemainingEqn,
Expand Down Expand Up @@ -1683,11 +1735,17 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
$sumEqn = 'round(' . $sumEqn . ', ' . $precision . ')';
}

$noanswer_option = '';
if ($value_range_allows_missing)
{
$noanswer_option = ' || count(' . implode(', ', $sq_names) . ') == 0';
}

$validationEqn[$questionNum][] = array(
'qtype' => $type,
'type' => 'min_num_value',
'class' => 'sum_range',
'eqn' => '(sum(' . implode(', ', $sq_names) . ') >= (' . $min_num_value . ') || count(' . implode(', ', $sq_names) . ') == 0)',
'eqn' => '(sum(' . implode(', ', $sq_names) . ') >= (' . $min_num_value . ')' . $noanswer_option . ')',
'qid' => $questionNum,
'sumEqn' => $sumEqn,
);
Expand Down Expand Up @@ -1741,11 +1799,17 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
$sumEqn = 'round(' . $sumEqn . ', ' . $precision . ')';
}

$noanswer_option = '';
if ($value_range_allows_missing)
{
$noanswer_option = ' || count(' . implode(', ', $sq_names) . ') == 0';
}

$validationEqn[$questionNum][] = array(
'qtype' => $type,
'type' => 'max_num_value',
'class' => 'sum_range',
'eqn' => '(sum(' . implode(', ', $sq_names) . ') <= (' . $max_num_value . ') || count(' . implode(', ', $sq_names) . ') == 0)',
'eqn' => '(sum(' . implode(', ', $sq_names) . ') <= (' . $max_num_value . ')' . $noanswer_option . ')',
'qid' => $questionNum,
'sumEqn' => $sumEqn,
);
Expand Down Expand Up @@ -7644,10 +7708,20 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL
// SHOW QUESTION ATTRIBUTES THAT ARE PROCESSED BY EM
//////
$attrTable = '';
if (isset($LEM->qattr[$qid]) && count($LEM->qattr[$qid]) > 0) {
$attrTable = "<hr/><table border='1'><tr><th>" . $LEM->gT("Question attribute") . "</th><th>" . $LEM->gT("Value"). "</th></tr>\n";

$attrs = (isset($LEM->qattr[$qid]) ? $LEM->qattr[$qid] : array());
if (isset($LEM->q2subqInfo[$qid]['preg']))
{
$attrs['regex_validation'] = $LEM->q2subqInfo[$qid]['preg'];
}
if (isset($LEM->questionSeq2relevance[$qseq]['other']))
{
$attrs['other'] = $LEM->questionSeq2relevance[$qseq]['other'];
}
if (count($attrs) > 0) {
$attrTable = "<hr/><table border='1'><tr><th>" . $LEM->gT("Question Attribute") . "</th><th>" . $LEM->gT("Value"). "</th></tr>\n";
$count=0;
foreach ($LEM->qattr[$qid] as $key=>$value) {
foreach ($attrs as $key=>$value) {
if (is_null($value) || trim($value) == '') {
continue;
}
Expand Down Expand Up @@ -7687,6 +7761,12 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL
break;
case 'other_replace_text':
case 'show_totals':
case 'regex_validation':
break;
case 'other':
if ($value == 'N') {
$value = NULL; // so can skip this one
}
break;
}
if (is_null($value)) {
Expand Down
20 changes: 17 additions & 3 deletions application/helpers/qanda_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -899,12 +899,26 @@ function return_array_filter_strings($ia, $aQuestionAttributes, $thissurvey, $an
}
else
{
$htmltbody2 .= " style='display: none'";
if (!isset($aQuestionAttributes['array_filter_style']) || $aQuestionAttributes['array_filter_style'] == '0')
{
$htmltbody2 .= " style='display: none'";
}
else
{
$htmltbody2 .= " disabled='disabled'";
}
}
}
else
{
$htmltbody2 .= " style='display: none'";
if (!isset($aQuestionAttributes['array_filter_style']) || $aQuestionAttributes['array_filter_style'] == '0')
{
$htmltbody2 .= " style='display: none'";
}
else
{
$htmltbody2 .= " disabled='disabled'";
}
}
}
$htmltbody2 .= ">\n";
Expand Down Expand Up @@ -2529,7 +2543,7 @@ function do_multiplechoice($ia)
{
$dispVal = str_replace('.',$sSeperator,$dispVal);
}
$answer .= ' value="'.htmlspecialchars($dispVal,ENT_QUOTES).'"';
$answer .= htmlspecialchars($dispVal,ENT_QUOTES);
}

$answer .= "\" />\n{$wrapper['item-end']}";
Expand Down

0 comments on commit 72cb8e5

Please sign in to comment.