Skip to content

Commit

Permalink
Fixed issue #05943: exclusive option in multiple choice hide all othe…
Browse files Browse the repository at this point in the history
…r answer options

Dev Author can choose between having array_filter(_exclude) hide vs. disable the filtered values
  • Loading branch information
TMSWhite committed Jun 5, 2012
1 parent bb897f4 commit 33de973
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
11 changes: 11 additions & 0 deletions application/helpers/common_helper.php
Expand Up @@ -3088,6 +3088,17 @@ function questionAttributes($returnByName=false)
"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",
'category'=>$clang->gT('Logic'),
'sortorder'=>100,
'inputtype'=>'singleselect',
'options'=>array(0=>$clang->gT('Hidden'),
1=>$clang->gT('Disabled')),
'default'=>0,
"help"=>$clang->gT("Specify how array-filtered sub-questions should be displayed"),
"caption"=>$clang->gT('Array filter style'));

$qattributes["assessment_value"]=array(
"types"=>"MP",
'category'=>$clang->gT('Logic'),
Expand Down
31 changes: 28 additions & 3 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -5831,12 +5831,23 @@ 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 = (isset($LEM->qattr[$arg['qid']]['array_filter_style']) ? ($LEM->qattr[$arg['qid']]['array_filter_style'] == '0') : true);
foreach ($subqParts as $sq)
{
$rowdividList[$sq['rowdivid']] = $sq['result'];

$relParts[] = " if ( " . $sq['relevancejs'] . " ) {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').show();\n";
if ($afHide)
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').show();\n";
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').removeAttr('disabled');\n";
}
if ($sq['isExclusiveJS'] != '')
{
$relParts[] = " if ( " . $sq['isExclusiveJS'] . " ) {\n";
Expand All @@ -5858,7 +5869,14 @@ static function GetRelevanceAndTailoringJavaScript()
$relParts[] = " }\n";
$relParts[] = " else {\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').removeAttr('disabled');\n";
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n";
if ($afHide)
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n";
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
}
$relParts[] = " }\n";
}
else
Expand All @@ -5868,7 +5886,14 @@ static function GetRelevanceAndTailoringJavaScript()
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n";
if ($afHide)
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . "').hide();\n";
}
else
{
$relParts[] = " $('#javatbd" . $sq['rowdivid'] . " :input:not(:hidden)').attr('disabled','disabled');\n";
}
}
$relParts[] = " relChange" . $arg['qid'] . "=true;\n";
$relParts[] = " $('#relevance" . $sq['rowdivid'] . "').val('');\n";
Expand Down

0 comments on commit 33de973

Please sign in to comment.