Skip to content

Commit

Permalink
Fixed issue #10411: Option 'Other' always visible
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Feb 15, 2016
1 parent a820c70 commit aaaee75
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 92 deletions.
31 changes: 6 additions & 25 deletions application/controllers/admin/database.php
Expand Up @@ -276,7 +276,6 @@ function index($sa = null)

if (substr($subquestionkey,0,3)!='new') //update record
{
//var_dump($subquestionkey); die();
$oSubQuestion=Question::model()->find("qid=:qid AND language=:language",array(":qid"=>$subquestionkey,':language'=>$sLanguage));
if(!is_object($oSubQuestion))
{
Expand Down Expand Up @@ -421,14 +420,8 @@ function index($sa = null)
{

// For Bootstrap Version usin YiiWheels switch :
if( Yii::app()->request->getPost('mandatory') == '1' || Yii::app()->request->getPost('mandatory') == '0' )
{
$_POST['mandatory'] = ( Yii::app()->request->getPost('mandatory') == '1' ) ? 'Y' : 'N' ;
}
else
{
$_POST['mandatory'] = Yii::app()->request->getPost('mandatory');
}
$_POST['mandatory'] = ( Yii::app()->request->getPost('mandatory') == '1' ) ? 'Y' : 'N' ;
$_POST['other'] = ( Yii::app()->request->getPost('other') == '1' ) ? 'Y' : 'N' ;

if (Yii::app()->request->getPost('questionposition',"")!="")
{
Expand Down Expand Up @@ -458,14 +451,8 @@ function index($sa = null)
$oQuestion->other = Yii::app()->request->getPost('other');

// For Bootstrap Version usin YiiWheels switch :
if( Yii::app()->request->getPost('mandatory') == '1' || Yii::app()->request->getPost('mandatory') == '0' )
{
$oQuestion->mandatory = ( Yii::app()->request->getPost('mandatory') == '1' ) ? 'Y' : 'N' ;
}
else
{
$oQuestion->mandatory = Yii::app()->request->getPost('mandatory');
}
$oQuestion->mandatory = ( Yii::app()->request->getPost('mandatory') == '1' ) ? 'Y' : 'N' ;
$oQuestion->other = ( Yii::app()->request->getPost('other') == '1' ) ? 'Y' : 'N' ;


$oQuestion->relevance = Yii::app()->request->getPost('relevance');
Expand Down Expand Up @@ -878,14 +865,8 @@ function index($sa = null)


// For Bootstrap Version usin YiiWheels switch :
if( Yii::app()->request->getPost('mandatory') == '1' || Yii::app()->request->getPost('mandatory') == '0' )
{
$_POST['mandatory'] = ( Yii::app()->request->getPost('mandatory') == '1' ) ? 'Y' : 'N' ;
}
else
{
$_POST['mandatory'] = Yii::app()->request->getPost('mandatory');
}
$_POST['mandatory'] = ( Yii::app()->request->getPost('mandatory') == '1' ) ? 'Y' : 'N' ;
$_POST['other'] = ( Yii::app()->request->getPost('other') == '1' ) ? 'Y' : 'N' ;

// These are the questions types that have no mandatory property - so zap it accordingly
if (Yii::app()->request->getPost('type')== "X" || Yii::app()->request->getPost('type')== "|")
Expand Down
134 changes: 67 additions & 67 deletions application/views/admin/survey/Question/questionJavascript_view.php
@@ -1,7 +1,4 @@
<script type='text/javascript'>
if (navigator.userAgent.indexOf("Gecko") != -1)
window.addEventListener("load", init_gecko_select_hack, false);

var qtypes = new Array();
var qnames = new Array();
var qhelp = new Array();
Expand All @@ -10,71 +7,74 @@

function OtherSelection(QuestionType)
{
if(typeof QuestionType != 'undefined')
if (QuestionType == undefined)
{
//console.log('Error: OtherSelection: QuestionType must not be undefined');
return;
}

if (QuestionType == '') { QuestionType=document.getElementById('question_type').value;}
if (QuestionType == 'M' || QuestionType == 'P' || QuestionType == 'L' || QuestionType == '!')
{
document.getElementById('OtherSelection').style.display = '';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == 'W' || QuestionType == 'Z')
{
document.getElementById('OtherSelection').style.display = '';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == '|')
{
document.getElementById('OtherSelection').style.display = 'none';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='none';
}
else if (QuestionType == 'F' || QuestionType == 'H')
{
document.getElementById('OtherSelection').style.display = 'none';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == ':' || QuestionType == ';')
{
document.getElementById('OtherSelection').style.display = 'none';
document.getElementById('Validation').style.display = '';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == '1')
{
document.getElementById('OtherSelection').style.display = 'none';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == 'S' || QuestionType == 'T' || QuestionType == 'U' || QuestionType == 'N' || QuestionType=='' || QuestionType=='K')
{
document.getElementById('Validation').style.display = '';
document.getElementById('OtherSelection').style.display ='none';
if (document.getElementById('ON')) { document.getElementById('ON').checked = true;}
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == 'X')
{
document.getElementById('Validation').style.display = 'none';
document.getElementById('OtherSelection').style.display ='none';
document.getElementById('MandatorySelection').style.display='none';
}
else if (QuestionType == 'Q')
{
document.getElementById('Validation').style.display = '';
document.getElementById('OtherSelection').style.display ='none';
document.getElementById('MandatorySelection').style.display='';
}
else
{
if (QuestionType == '') { QuestionType=document.getElementById('question_type').value;}
if (QuestionType == 'M' || QuestionType == 'P' || QuestionType == 'L' || QuestionType == '!')
{
document.getElementById('OtherSelection').style.display = '';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == 'W' || QuestionType == 'Z')
{
document.getElementById('OtherSelection').style.display = '';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == '|')
{
document.getElementById('OtherSelection').style.display = 'none';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='none';
}
else if (QuestionType == 'F' || QuestionType == 'H')
{
document.getElementById('OtherSelection').style.display = 'none';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == ':' || QuestionType == ';')
{
document.getElementById('OtherSelection').style.display = 'none';
document.getElementById('Validation').style.display = '';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == '1')
{
document.getElementById('OtherSelection').style.display = 'none';
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == 'S' || QuestionType == 'T' || QuestionType == 'U' || QuestionType == 'N' || QuestionType=='' || QuestionType=='K')
{
document.getElementById('Validation').style.display = '';
document.getElementById('OtherSelection').style.display ='none';
if (document.getElementById('ON')) { document.getElementById('ON').checked = true;}
document.getElementById('MandatorySelection').style.display='';
}
else if (QuestionType == 'X')
{
document.getElementById('Validation').style.display = 'none';
document.getElementById('OtherSelection').style.display ='none';
document.getElementById('MandatorySelection').style.display='none';
}
else if (QuestionType == 'Q')
{
document.getElementById('Validation').style.display = '';
document.getElementById('OtherSelection').style.display ='none';
document.getElementById('MandatorySelection').style.display='';
}
else
{
document.getElementById('OtherSelection').style.display = 'none';
if (document.getElementById('ON')) { document.getElementById('ON').checked = true;}
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
document.getElementById('OtherSelection').style.display = 'none';
if (document.getElementById('ON')) { document.getElementById('ON').checked = true;}
document.getElementById('Validation').style.display = 'none';
document.getElementById('MandatorySelection').style.display='';
}
}
OtherSelection('<?php echo $type; ?>');
Expand Down
3 changes: 3 additions & 0 deletions scripts/admin/admin_core.js
Expand Up @@ -269,6 +269,9 @@ function getToolTip(type){

function updatequestionattributes()
{
var type = $('#question_type').val();
OtherSelection(type);

$('.loader').show();
$('#advancedquestionsettings').html('');
var selected_value = qDescToCode[''+$("#question_type_child .selected").text()];
Expand Down

0 comments on commit aaaee75

Please sign in to comment.