Skip to content

Commit

Permalink
Dev: fixed save subquestions :goberserk:
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisGac committed Jan 12, 2016
1 parent b914559 commit c948e92
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 9 deletions.
25 changes: 25 additions & 0 deletions application/controllers/admin/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,34 @@ function index($sa = null)
$iPosition=0;
foreach ($aRows[$iScaleID][$sLanguage] as $subquestionkey=>$subquestionvalue)
{

if (substr($subquestionkey,0,3)!='new') //update record
{
$oSubQuestion=Question::model()->find("qid=:qid AND language=:language",array(":qid"=>$subquestionkey,':language'=>$sLanguage));

if(!is_object($oSubQuestion)) // For new rows
{
$oSubQuestion=new Question;
$oSubQuestion->sid=$iSurveyID;
$oSubQuestion->gid=$iQuestionGroupID;
$oSubQuestion->question_order=$iPosition+1;
$oSubQuestion->title=$aCodes[$iScaleID][$iPosition];
$oSubQuestion->question=$subquestionvalue;
$oSubQuestion->parent_qid=$iQuestionID;
$oSubQuestion->language=$sLanguage;
$oSubQuestion->scale_id=$iScaleID;
if(isset($aRelevance[0][$iPosition]))
{
$oSubQuestion->relevance=$aRelevance[0][$iPosition];
}
else
{
$oSubQuestion->relevance='';
}


}

$oSubQuestion->question_order=$iPosition+1;
$oSubQuestion->title=$aCodes[$iScaleID][$iPosition];
$oSubQuestion->question=$subquestionvalue;
Expand Down
1 change: 1 addition & 0 deletions application/controllers/admin/questions.php
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ public function _editansweroptions($surveyid, $gid, $qid)

$aData['activated'] = $activated = $surveyinfo['active'];

$results = array();
foreach ($anslangs as $anslang)
{
for ($scale_id = 0; $scale_id < $scalecount; $scale_id++)
Expand Down
10 changes: 8 additions & 2 deletions application/views/admin/survey/Question/answerOptions_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
<input type='hidden' name='sid' value='<?php echo $surveyid; ?>' />
<input type='hidden' name='gid' value='<?php echo $gid; ?>' />
<input type='hidden' name='qid' value='<?php echo $qid; ?>' />
<input type='hidden' name='action' value='updateansweroptions' />

<?php if($viewType=='subQuestions'): ?>
<input type='hidden' id='action' name='action' value='updatesubquestions' />
<?php elseif($viewType=='answerOptions'): ?>
<input type='hidden' name='action' value='updateansweroptions' />
<?php endif; ?>

<input type='hidden' name='sortorder' value='' />
<input type='hidden' id='deletedqids' name='deletedqids' value='' />

Expand Down Expand Up @@ -148,7 +154,7 @@
</thead>

<!-- Body -->
<tbody>
<tbody id="rowcontainer">
<?php foreach ($result as $row): ?>

<!-- Line tag -->
Expand Down
17 changes: 10 additions & 7 deletions scripts/admin/subquestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,10 +279,18 @@ function updaterowproperties()
info=$(this).closest('table').attr('id').split("_");
language=info[1];
scale_id=info[2];
var rownumber=1;

//alert($(this).attr('id'));
var $firstrow = $(this).children('tr').first();
//alert($firstrow.attr('id'));
//var rownumber=$(this).;
var datas=$firstrow.attr('id').split('_');
var rownumber=datas[2];


$(this).children('tr').each(function()
{

$(this).addClass('row_'+rownumber);
$(this).find('.oldcode').attr('name','oldcode_'+rownumber+'_'+scale_id);
$(this).find('.code').attr('id','code_'+rownumber+'_'+scale_id);
Expand Down Expand Up @@ -408,11 +416,6 @@ function code_duplicates_check()
$notifycontainer.notify("create", 'error-notify', { message:duplicatesubquestioncode});
cansubmit= false;
}
if (otherisreserved && $.inArray('other', codearray)!=-1)
{
$notifycontainer.notify("create", 'error-notify', { message:otherisreserved});
cansubmit= false;
}
});
return cansubmit;
}
Expand Down Expand Up @@ -834,7 +837,7 @@ function quickaddlabels()
' <span class="btneditanswerena glyphicon glyphicon-pencil text-success"></span>'+
' <span class="btneditanswerdis glyphicon glyphicon-pencil text-success" title="Give focus to the HTML editor popup window" style="display: none;"></span>'+
' </a>'+

' <span class="btnaddanswer icon-add text-success"></span>'+
' <span class="btndelanswer glyphicon glyphicon-trash text-warning"></span>'+
' </td>'+
Expand Down
1 change: 1 addition & 0 deletions styles/Black_Pearl/scripts/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ var getForm = function (that) {
if ($('#save-button').length > 0){
$('#save-button').on('click', function()
{
console.log('ok');
var $form = getForm(this);
closeAfterSaveInput.val("false");
$form.append(closeAfterSaveInput);
Expand Down

0 comments on commit c948e92

Please sign in to comment.