Skip to content

Commit

Permalink
Fixed issue #06221: Array filtering does not work when trigger questi…
Browse files Browse the repository at this point in the history
…on has multiple inputs per row
  • Loading branch information
TMSWhite committed Jun 15, 2012
1 parent d943dd6 commit 195b305
Showing 1 changed file with 52 additions and 28 deletions.
80 changes: 52 additions & 28 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -1069,7 +1069,13 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
$cascadedAFE = array_reverse($cascadedAFE);

$subqs = $qinfo['subqs'];
$last_rowdivid = '--';
foreach ($subqs as $sq) {
if ($sq['rowdivid'] == $last_rowdivid)
{
continue;
}
$last_rowdivid = $sq['rowdivid'];
$af_names = array();
$afe_names = array();
switch ($type)
Expand All @@ -1087,46 +1093,64 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
case 'P': //Multiple choice with comments checkbox + text
case 'K': //MULTIPLE NUMERICAL QUESTION
case 'Q': //MULTIPLE SHORT TEXT
if ($this->sgqaNaming)
{
// if ($this->sgqaNaming)
// {
foreach ($cascadedAF as $_caf)
{
$sgq = ((isset($this->qcode2sgq[$_caf])) ? $this->qcode2sgq[$_caf] : $_caf);
$sgq .= substr($sq['sqsuffix'],1);
if (isset($this->knownVars[$sgq]))
$fqid = explode('X',$sgq);
$fqid = $fqid[2];
$fsqs = array();
foreach ($this->q2subqInfo[$fqid]['subqs'] as $fsq)
{
$af_names[] = $sgq . '.NAOK';
if ($fsq['sqsuffix'] == $sq['sqsuffix'])
{
$fsqs[] = $sgq . $fsq['csuffix'] . '.NAOK';
}
}
}
foreach ($cascadedAFE as $_cafe)
{
$sgq = ((isset($this->qcode2sgq[$_cafe])) ? $this->qcode2sgq[$_cafe] : $_cafe);
$sgq .= substr($sq['sqsuffix'],1);
if (isset($this->knownVars[$sgq]))
if (count($fsqs) > 0)
{
$afe_names[] = $sgq . '.NAOK';
$af_names[] = '(' . implode(' != "" or ', $fsqs) . ' != "")';
}
}
}
else
{
foreach ($cascadedAF as $_caf)
foreach ($cascadedAFE as $_cafe)
{
$sgq = $_caf . $sq['sqsuffix'];
if (isset($this->knownVars[$sgq]))
$sgq = ((isset($this->qcode2sgq[$_cafe])) ? $this->qcode2sgq[$_cafe] : $_cafe);
$fqid = explode('X',$sgq);
$fqid = $fqid[2];
$fsqs = array();
foreach ($this->q2subqInfo[$fqid]['subqs'] as $fsq)
{
$af_names[] = $sgq . '.NAOK';
if ($fsq['sqsuffix'] == $sq['sqsuffix'])
{
$fsqs[] = $sgq . $fsq['csuffix'] . '.NAOK';
}
}
}
foreach ($cascadedAFE as $_cafe)
{
$sgq = $_cafe . $sq['sqsuffix'];
if (isset($this->knownVars[$sgq]))
if (count($fsqs) > 0)
{
$afe_names[] = $sgq . '.NAOK';
$afe_names[] = '(' . implode(' == "" and ', $fsqs) . ' == "")';
}
}
}
// }
// else // TODO - implement qcode naming for this
// {
// foreach ($cascadedAF as $_caf)
// {
// $sgq = $_caf . $sq['sqsuffix'];
// if (isset($this->knownVars[$sgq]))
// {
// $af_names[] = $sgq . '.NAOK';
// }
// }
// foreach ($cascadedAFE as $_cafe)
// {
// $sgq = $_cafe . $sq['sqsuffix'];
// if (isset($this->knownVars[$sgq]))
// {
// $afe_names[] = $sgq . '.NAOK';
// }
// }
// }
break;
default:
break;
Expand All @@ -1138,15 +1162,15 @@ public function _CreateSubQLevelRelevanceAndValidationEqns($onlyThisQseq=NULL)
$afs_eqn = '';
if (count($af_names) > 0)
{
$afs_eqn .= implode(' != "" && ', $af_names) . ' != ""';
$afs_eqn .= implode(' && ', $af_names);
}
if (count($afe_names) > 0)
{
if ($afs_eqn != '')
{
$afs_eqn .= ' && ';
}
$afs_eqn .= implode(' == "" && ', array_unique($afe_names)) . ' == ""';
$afs_eqn .= implode(' && ', $afe_names);
}

$subQrels[] = array(
Expand Down

0 comments on commit 195b305

Please sign in to comment.