Skip to content

Commit

Permalink
Dev: in survey summary, quick action, the switch to display questions…
Browse files Browse the repository at this point in the history
… group by group is now working
  • Loading branch information
louis committed Sep 23, 2015
1 parent 45be452 commit c0b76d5
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 19 deletions.
16 changes: 16 additions & 0 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -1177,6 +1177,22 @@ public function organize($iSurveyID)
}
}


/**
* Called via ajax request from survey summary quick action "Show questions group by group"
*
*/
public function changeFormat($iSurveyID)
{
if ( Permission::model()->hasSurveyPermission($iSurveyID, 'surveycontent', 'update') )
{
$survey = Survey::model()->findByPk($iSurveyID);
$survey->format = ($survey->format == 'G')? 'S' : 'G';
$survey->save();
echo $survey->format;
}
}

private function _showReorderForm($iSurveyID)
{
// Prepare data for the view
Expand Down
17 changes: 17 additions & 0 deletions application/views/admin/super/header.php
Expand Up @@ -1466,6 +1466,23 @@
$('#questionTypeContainer').css("overflow","hidden")
})


/* Switch format group */
$('#switchchangeformat').on('switchChange.bootstrapSwitch', function(event, state) {
$.ajax({
url : '<?php echo $this->createUrl("admin/survey/sa/changeFormat/surveyid/23627".$surveyinfo['sid']); ?>',
type : 'GET',
dataType : 'html',

// html contains the buttons
success : function(html, statut){
},
error : function(html, statut){
alert('error');
}
});

});

});

Expand Down
58 changes: 39 additions & 19 deletions application/views/admin/survey/surveySummary_view.php
@@ -1,44 +1,67 @@
<?php
/**
* Survey default view
*
*/
?>
<div class="side-body">


<!-- Quick Actions -->
<h3><?php eT('Survey quick actions'); ?></h3>
<div class="row welcome survey-action">
<div class="col-lg-12 content-right">

<!-- Alerts, infos... -->
<div class="row">
<div class="col-lg-12">

<!-- While survey is activated, you can't add or remove group or question -->
<?php if ($activated == "Y"): ?>
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong><?php eT('Warning!');?></strong> <?php eT('While survey is activated, you can\'t add or remove group or question');?>
</div>
</div>

<?php elseif(!$groups_count > 0):?>

<!-- To add questions, first, you must add a question group -->
<div class="alert alert-warning alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<strong><?php eT('Warning!');?></strong> <?php eT('To add questions, first, you must add a question group.');?>
</div>


<!-- If you want a single page survey, just add a single group, and switch on "Show questions group by group -->
<div class="alert alert-info alert-dismissible" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>&nbsp;&nbsp;&nbsp;
<?php eT('If you want a single page survey, just add a single group, and switch on "Show questions group by group"');?>
</div>
<?php endif;?>

</div>
</div>

<!-- Switch : Show questions group by group -->
<?php $switchvalue = ($surveyinfo['format']=='G') ? 1 : 0 ; ?>
<div class="row">
<div class="col-lg-4">
<label for="groupbygroup"><?php eT('Show questions group by group :');?></label>
<?php $this->widget('yiiwheels.widgets.switch.WhSwitch', array(
'name' => 'groupbygroup'
'name' => 'groupbygroup',
'id'=>'switchchangeformat',
'value'=>$switchvalue,
));?>
<br/><br/>
</div>
</div>


<!-- Add group / questions -->
<div class="row">

<!-- Survey active, so it's impossible to add new group/question -->
<?php if ($activated == "Y"): ?>


<!-- Can't add new group to survey -->
<div class="col-lg-2">
<div class="panel panel-primary disabled" id="pannel-1">
<div class="panel-heading">
Expand All @@ -48,11 +71,12 @@
<a href="#" data-toggle="tooltip" data-placement="bottom" title="<?php eT("This survey is currently active."); ?>" style="display: inline-block" data-toggle="tooltip">
<img src="<?php echo Yii::app()->getBaseUrl(true);?>/images/lime-icons/big/328637/add.png" class="responsive"/>
</a>
<p><a href="#"><?php eT('Add new group to survey');?></a></p>
<p><a href="#"><?php eT('Add new group');?></a></p>
</div>
</div>
</div>

<!-- Can't add a new question -->
<div class="col-lg-2" >
<div class="panel panel-primary disabled" id="pannel-2">
<div class="panel-heading">
Expand All @@ -70,9 +94,11 @@
</div>
</div>
</div>


<!-- survey is not active, and user has permissions, so buttons are shown and active -->
<?php elseif(Permission::model()->hasSurveyPermission($surveyinfo['sid'],'surveycontent','create')): ?>

<!-- Add group -->
<div class="col-lg-2">
<div class="panel panel-primary panel-clickable" id="pannel-1" aria-data-url="<?php echo $this->createUrl("admin/questiongroups/sa/add/surveyid/".$surveyinfo['sid']); ?>">
<div class="panel-heading">
Expand All @@ -82,13 +108,13 @@
<a href="<?php echo $this->createUrl("admin/questiongroups/sa/add/surveyid/".$surveyinfo['sid']); ?>" >
<img src="<?php echo Yii::app()->getBaseUrl(true);?>/images/lime-icons/big/328637/add.png" class="responsive"/>
</a>
<p><a href="<?php echo $this->createUrl("admin/questiongroups/sa/add/surveyid/".$surveyinfo['sid']); ?>"><?php eT('Add new group to survey');?></a></p>
<p><a href="<?php echo $this->createUrl("admin/questiongroups/sa/add/surveyid/".$surveyinfo['sid']); ?>"><?php eT('Add new group');?></a></p>
</div>
</div>
</div>


<!-- Survey has no group, so can't add a question -->
<?php if(!$groups_count > 0): ?>

<div class="col-lg-2" >
<div class="panel panel-primary disabled" id="pannel-2">
<div class="panel-heading">
Expand All @@ -107,7 +133,7 @@
</div>
</div>


<!-- Survey has a group, so can add a question -->
<?php else:?>
<div class="col-lg-2">
<div class="panel panel-primary panel-clickable" id="pannel-2" aria-data-url="<?php echo $this->createUrl("admin/questions/sa/newquestion/surveyid/".$surveyinfo['sid']); ?>">
Expand All @@ -122,19 +148,13 @@
</div>
</div>
</div>

<?php endif; ?>

<?php endif; ?>
</div>




</div>
</div>


<!-- Survey summary -->
<h3><?php eT('Survey summary'); ?></h3>
<div class="row">
<div class="col-lg-12 content-right">
Expand Down

0 comments on commit c0b76d5

Please sign in to comment.