Skip to content

Commit

Permalink
Dev: working Draft
Browse files Browse the repository at this point in the history
Not all Links are thoroughly tested, but updating the survey should work without issues.
The sidebar now renders bound to localStorage, as does the questiontree
Refactored the Database-Class to only uptdate actually present post variables.
  • Loading branch information
lacrioque committed Jul 3, 2017
1 parent b7644cf commit 5a44439
Show file tree
Hide file tree
Showing 22 changed files with 682 additions and 387 deletions.
25 changes: 21 additions & 4 deletions application/controllers/admin/assessments.php
Expand Up @@ -34,7 +34,6 @@ public function index($iSurveyID)
{
$iSurveyID = sanitize_int($iSurveyID);
$sAction = Yii::app()->request->getParam('action');

if (Permission::model()->hasSurveyPermission($iSurveyID, 'assessments', 'read'))
{
$languages = Survey::model()->findByPk($iSurveyID)->additionalLanguages;
Expand All @@ -56,6 +55,9 @@ public function index($iSurveyID)
if ($sAction == "assessmentdelete")
$this->_delete($iSurveyID, $_POST['id']);

if($sAction == "asessementactivate")
$this->_activateAsessement($iSurveyID);


$this->_showAssessments($iSurveyID, $sAction, $surveyLanguage);
}
Expand All @@ -66,6 +68,7 @@ public function index($iSurveyID)
}
}


/**
* Renders template(s) wrapped in header and footer
*
Expand Down Expand Up @@ -117,16 +120,30 @@ private function _showAssessments($iSurveyID, $action)
$urls['output'] = '<div class="side-body ' . getSideBodyClass(false) . '">';
$urls['output'] .= App()->getController()->renderPartial('/admin/survey/breadcrumb', array('oSurvey'=>$oSurvey, 'active'=>gT("Assessments")), true, false);
$urls['output'] .= '<h3>'.gT("Assessments").'</h3>';

$aData['asessementNotActivated'] = false;
if ($surveyinfo['assessments']!='Y')
{

$urls['message'] = array('title' => gT("Assessments mode not activated"), 'message' => sprintf(gT("Assessment mode for this survey is not activated. You can activate it in the %s survey settings %s (tab 'Notification & data management')."),'<a href="'.$this->getController()->createUrl('admin/survey/sa/editlocalsettings/surveyid/'.$iSurveyID).'">','</a>'), 'class'=> 'warningheader');
$aData['asessementNotActivated'] = array(
'title' => gT("Assessments mode not activated"),
'message' => gT("Assessment mode for this survey is not activated.").'<br/>'
. gt("If you want to activate it click here:").'<br/>'
. '<a type="submit" class="btn btn-primary" href="'
. App()->getController()->createUrl('admin/assessments', ['action'=> 'asessementactivate','surveyid'=> $iSurveyID])
.'">'.gT('Activate asessements').'</a>',
'class'=> 'warningheader col-sm-12 col-md-6 col-md-offset-3');
}
$urls['assessments_view'][]= $aData;
$this->_renderWrappedTemplate('', $urls, $aData);
}

private function _activateAsessement($iSurveyID)
{
$oSurvey=Survey::model()->findByPk($iSurveyID);
$oSurvey->assessments = "Y";
$oSurvey->save();
return ['success' => true];
}

private function _collectGroupData($iSurveyID)
{
$aData = array();
Expand Down
261 changes: 195 additions & 66 deletions application/controllers/admin/database.php

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions application/controllers/admin/expressions.php
Expand Up @@ -61,6 +61,7 @@ function index()
$aData['questiongroupbar']['closebutton']['url'] = $this->getController()->createUrl(
'admin/questiongroups/sa/view/',
['surveyid'=> $surveyid, 'gid'=> sanitize_int(Yii::app()->request->getQuery('gid')), 'qid'=> sanitize_int(Yii::app()->request->getQuery('qid'))]);

$aData['gid'] = sanitize_int(Yii::app()->request->getQuery('gid'));
}
}
Expand Down
2 changes: 2 additions & 0 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -440,13 +440,15 @@ public function getAjaxQuestionGroupArray($surveyid){
foreach($aGroups as $group)
{
$curGroup = $group->attributes;
$curGroup['link'] = $this->getController()->createUrl("admin/questiongroups/sa/view", ['surveyid' => $surveyid, 'gid' => $group->gid]);
$group->aQuestions = Question::model()->findAllByAttributes(array("sid"=>$iSurveyID, "gid"=>$group['gid'],"language"=>$baselang), array('order'=>'question_order ASC'));
$curGroup['questions'] = array();
foreach($group->aQuestions as $question)
{
if(is_object($question))
{
$curQuestion = $question->attributes;
$curGroup['link'] = $this->getController()->createUrl("admin/questiongroups/sa/view", ['surveyid' => $surveyid, 'gid' => $group->gid, 'qid', $question->qid]);
$curQuestion['name_short'] = viewHelper::flatEllipsizeText($question->question,true,60,'[...]',0.5);
$curGroup['questions'][] = $curQuestion;
}
Expand Down
4 changes: 4 additions & 0 deletions application/models/Survey.php
Expand Up @@ -546,6 +546,10 @@ private function _getDefaultSurveyMenu(){
$defaultMenuEntries = $oDefaultMenu->surveymenuEntries;
foreach($defaultMenuEntries as $menuEntry){
$aEntry = $menuEntry->attributes;
if((!empty($entry['permission']) && !empty($entry['permission_grade']) && !Permission::model()->hasSurveyPermission($this->sid,$entry['permission'],$entry['permission_grade'])))
continue;


$aEntry['link'] = $aEntry['menu_link']
? App()->getController()->createUrl($aEntry['menu_link'],['surveyid' => $this->sid])
: App()->getController()->createUrl("admin/survey/sa/rendersidemenulink",['surveyid' => $this->sid, 'subaction' => $aEntry['name'] ]);
Expand Down
13 changes: 13 additions & 0 deletions application/views/admin/assessments_view.php
Expand Up @@ -10,6 +10,17 @@
var strnogroup='<?php eT("There are no groups available.", "js");?>';
-->
</script>
<div class="container-fluid">
<?php if($asessementNotActivated):?>

<div class="row text-center">
<div class="jumbotron message-box <?php echo isset($asessementNotActivated['class']) ? $asessementNotActivated['class'] : ""; ?>">
<h2 ><?php echo $asessementNotActivated['title'];?></h2>
<?php echo $asessementNotActivated['message'];?>
</div>
</div>
</form>
<?php else:?>

<h4><?php eT("Assessment rules");?></h4>

Expand Down Expand Up @@ -252,3 +263,5 @@
</form>
<?php endif; ?>
</div></div></div><!-- opened in controller -->
<?php endif;?>
</div>
Expand Up @@ -5,6 +5,7 @@
<?php if(!$fullPage):?>
<div id='edit-survey-text-element' class='side-body <?php echo getSideBodyClass(false); ?>'>
<?php endif;?>

<h3><?php eT("Edit survey settings");?></h3>

<div class="row">
Expand Down
2 changes: 1 addition & 1 deletion application/views/admin/super/_renderJson.php
Expand Up @@ -4,5 +4,5 @@
$this->layout=false;

echo CJavaScript::jsonEncode($data);

Yii::app()->end()
?>
Expand Up @@ -5,8 +5,9 @@
?>

<script type="text/javascript">
standardtemplaterooturl='<?php echo Yii::app()->getConfig('standardtemplaterooturl');?>';
templaterooturl='<?php echo Yii::app()->getConfig('usertemplaterooturl');?>';
var standardtemplaterooturl='<?php echo Yii::app()->getConfig('standardtemplaterooturl');?>';
var templaterooturl='<?php echo Yii::app()->getConfig('usertemplaterooturl');?>';
var formId = '<?=$entryData['name']?>';
</script>

<?php
Expand Down Expand Up @@ -43,10 +44,9 @@
<input type="hidden" name="action" value="<?=$entryData['action']?>" />
<input type="hidden" name="sid" value="<?php echo $surveyid; ?>" />
<input type="hidden" name="language" value="<?php echo $surveyls_language; ?>" />
<input type="hidden" name="responsejson" value="1" />
<input type='submit' class="hide" id="globalsetting_submit" />
</form>
</div>

<?php //$this->renderPartial('/admin/survey/subview/import_ressources_modal', $settings_data); ?>
</div>
</div>
Expand Up @@ -3,6 +3,16 @@
* General options
*/
?>
<script type="text/javascript">
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '<?php eT("If you are using token functions or notifications emails you need to set an administrator email address.",'js'); ?>'
var sURLParameters = '';
var sAddParam = '';
</script>
<!-- General options -->
<?php
$yii = Yii::app();
Expand Down
Expand Up @@ -6,10 +6,9 @@
$yii = Yii::app();
$controller = $yii->getController();
?>

<!-- Datatable translation-data -->
<script type="text/javascript">
var jsonUrl = "<?php echo App()->createUrl('admin/survey', array('sa' => 'getUrlParamsJson', 'surveyid' => $surveyid))?>";
var jsonUrl = "<?php echo App()->createUrl('admin/survey/sa/getUrlParamsJson', array('surveyid' => $surveyid))?>";
var imageUrl = "<?php echo $yii->getConfig("adminimageurl");?>";
var sProgress = "<?php eT('Showing _START_ to _END_ of _TOTAL_ entries','js');?>";
var sAction = "<?php eT('Action','js');?>";
Expand Down
Expand Up @@ -3,6 +3,16 @@
* Notificatin panel
*/
?>
<script type="text/javascript">
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '<?php eT("If you are using token functions or notifications emails you need to set an administrator email address.",'js'); ?>'
var sURLParameters = '';
var sAddParam = '';
</script>
<!-- Notification panel -->
<div id='notification' class="container-fluid">

Expand Down
10 changes: 10 additions & 0 deletions application/views/admin/survey/subview/accordion/_plugin_panel.php
Expand Up @@ -3,6 +3,16 @@
* Plugin options panel
*/
?>
<script type="text/javascript">
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '<?php eT("If you are using token functions or notifications emails you need to set an administrator email address.",'js'); ?>'
var sURLParameters = '';
var sAddParam = '';
</script>
<?php if (!empty($plugin['settings'])): ?>
<div class="panel panel-default">
<div class="panel-heading" role="tab" id="heading-plugin<?php echo $id; ?>">
Expand Down
Expand Up @@ -3,6 +3,16 @@
* Optionnal plugins options panels
*/
?>
<script type="text/javascript">
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '<?php eT("If you are using token functions or notifications emails you need to set an administrator email address.",'js'); ?>'
var sURLParameters = '';
var sAddParam = '';
</script>
<?php if (isset($pluginSettings)):
foreach ($pluginSettings as $id => $plugin)
{
Expand Down
Expand Up @@ -3,7 +3,16 @@
* Presentation panel
*/
?>

<script type="text/javascript">
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '<?php eT("If you are using token functions or notifications emails you need to set an administrator email address.",'js'); ?>'
var sURLParameters = '';
var sAddParam = '';
</script>
<!-- Presentation panel -->
<div id='presentation' class="container-fluid">
<div class="col-sm-12 col-md-6">
Expand Down
Expand Up @@ -3,6 +3,16 @@
* Publication Panel
*/
?>
<script type="text/javascript">
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '<?php eT("If you are using token functions or notifications emails you need to set an administrator email address.",'js'); ?>'
var sURLParameters = '';
var sAddParam = '';
</script>
<!-- Publication panel -->
<div id='publication' class="container-fluid">
<div class="row">
Expand Down
Expand Up @@ -3,37 +3,60 @@
* ressources panel tab
*/
?>

<script type="text/javascript">
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '<?php eT("If you are using token functions or notifications emails you need to set an administrator email address.",'js'); ?>'
var sURLParameters = '';
var sAddParam = '';
</script>
<!-- ressources panel -->
<div id='resources' class="tab-pane fade in">
<ul class="list-unstyled">
<div id='resources' >
<div class="row">
<div class="col-sm-12 col-md-4">
<ul class="list-unstyled">

<!-- Browse -->
<li>
<label>&nbsp;</label>
<?php echo CHtml::dropDownList('type', 'files', array('files' => gT('Files','unescaped'), 'flash' => gT('Flash','unescaped'), 'images' => gT('Images','unescaped')), array('class'=>'btn btn-default')); ?>
<a class="btn btn-default" href="<?php echo Yii::app()->request->getBaseUrl() ; ?>/third_party/kcfinder/browse.php?language='<?php echo sTranslateLangCode2CK( App()->language); ?>'" target='_blank'>
<?php eT("Browse uploaded resources") ?>
</a>
</li>
<!-- Browse -->
<li>
<label>&nbsp;</label>
<?php echo CHtml::dropDownList('type', 'files', array('files' => gT('Files','unescaped'), 'flash' => gT('Flash','unescaped'), 'images' => gT('Images','unescaped')), array('class'=>'btn btn-default')); ?>
<a id="loadiframe" class="btn btn-default" href="<?php echo Yii::app()->request->getBaseUrl() ; ?>/third_party/kcfinder/browse.php?language='<?php echo sTranslateLangCode2CK( App()->language); ?>'" target='_blank'>
<?php eT("Browse uploaded resources") ?>
</a>
</li>

<!-- Export -->
<li>
<br/>
<label>&nbsp;</label>
<a href="<?php echo $this->createUrl('admin/export/sa/resources/export/survey/surveyid/'.$surveyid); ?>" target="_blank" class="btn btn-default">
<?php eT("Export resources as ZIP archive") ?>
</a>
</li>
<!-- Export -->
<li>
<br/>
<label>&nbsp;</label>
<a href="<?php echo $this->createUrl('admin/export/sa/resources/export/survey/surveyid/'.$surveyid); ?>" target="_blank" class="btn btn-default">
<?php eT("Export resources as ZIP archive") ?>
</a>
</li>

<!-- Export -->
<li>
<br/>
<label>&nbsp;</label>
<a class="btn btn-default" href="" target='_blank' data-toggle="modal" data-target="#importRessourcesModal">
<span class="fa fa-download"></span>
<?php eT("Import resources ZIP archive"); ?>
</a>
</li>
</ul>
<!-- Export -->
<li>
<br/>
<label>&nbsp;</label>
<a class="btn btn-default" href="" target='_blank' data-toggle="modal" data-target="#importRessourcesModal">
<span class="fa fa-download"></span>
<?php eT("Import resources ZIP archive"); ?>
</a>
</li>
</ul>
</div>
<div class="col-sm-12 col-md-8">
<iframe id="browseiframe" src="<?php echo Yii::app()->request->getBaseUrl() ; ?>/third_party/kcfinder/browse.php?language='<?php echo sTranslateLangCode2CK( App()->language); ?>'" width="100%" height="600px"></iframe>
</div>
</div>
</div>
<script>
$('#loadiframe').on('click', function(e){
e.preventDefault();
$('#browseiframe').attr('src', $(this).attr('href'));
})
</script>
<?php $this->renderPartial('/admin/survey/subview/import_ressources_modal', ['surveyid'=>$surveyid, 'ZIPimportAction' => $ZIPimportAction]); ?>
10 changes: 10 additions & 0 deletions application/views/admin/survey/subview/accordion/_tokens_panel.php
Expand Up @@ -3,6 +3,16 @@
* Tokens panel
*/
?>
<script type="text/javascript">
var jsonUrl = '';
var sAction = '';
var sParameter = '';
var sTargetQuestion = '';
var sNoParametersDefined = '';
var sAdminEmailAddressNeeded = '<?php eT("If you are using token functions or notifications emails you need to set an administrator email address.",'js'); ?>'
var sURLParameters = '';
var sAddParam = '';
</script>
<!-- tokens panel -->
<div id='tokens' class="container-fluid">
<div class="row">
Expand Down
Expand Up @@ -9,7 +9,7 @@

?>

<div id='dlgEditParameter###'>
<div id='dlgEditParameter'>
<div id='dlgForm' class='form-horizontal'>
<div class='row'>
<div class='form-group'>
Expand Down

0 comments on commit 5a44439

Please sign in to comment.