diff --git a/application/controllers/QuestionsController.php b/application/controllers/QuestionsController.php index b996a790c09..a41dd2c7c7f 100644 --- a/application/controllers/QuestionsController.php +++ b/application/controllers/QuestionsController.php @@ -43,12 +43,12 @@ public function actionCreate($gid, $questiontype = 'd58fa4752cf173a50411b19a0243 public function actionPreview($id, $language = 'en') { - $question = Questions::model()->findByPk($qid); + $question = Questions::model()->findByPk($id); if (isset($question)) { - $questionObject = App()->getPluginManager()->constructQuestionFromGUID($question->questiontype, $qid); - $questionObject->render("preview$qid", $language); + $questionObject = App()->getPluginManager()->constructQuestionFromGUID($question->questiontype, $id); + $questionObject->render("preview$id", $language); } } public function actionUpdate($id, $questiontype = null) @@ -74,7 +74,7 @@ public function actionUpdate($id, $questiontype = null) } // Always redirect to prevent reloading from resubmitting. - $this->redirect(array($this->route, 'qid' => $id)); + $this->redirect(array($this->route, 'id' => $id)); } diff --git a/application/controllers/SurveysController.php b/application/controllers/SurveysController.php index 9bdceadb864..d001804ba18 100644 --- a/application/controllers/SurveysController.php +++ b/application/controllers/SurveysController.php @@ -59,6 +59,24 @@ public function actionIndex() $this->render('/surveys/index', compact('overview')); } + /** + * Previews a survey. + * @param type $id + */ + public function actionPreview($id, $language = 'en') + { + $survey = Survey::model()->findByPk($id); + $format = $survey->attributes['format']; + var_dump($format); + switch ($format) + { + case 'G': + + + case 'Q': + default: + } + } /** * Survey overview. diff --git a/application/controllers/admin/surveyadmin.php b/application/controllers/admin/surveyadmin.php index 7ef67cef512..789b5cb690e 100644 --- a/application/controllers/admin/surveyadmin.php +++ b/application/controllers/admin/surveyadmin.php @@ -183,46 +183,6 @@ function editsurveysettings($iSurveyID) $aData = array_merge($aData, $this->_tabTokens($esrow)); $aData = array_merge($aData, $this->_tabPanelIntegration($esrow)); $aData = array_merge($aData, $this->_tabResourceManagement($iSurveyID)); - - - - - - $oResult = Questions::model()->with('groups')->with('question_types')->with('parents')->findAllByAttributes(array('sid' => $iSurveyID, 'language' => $esrow['language']), array('index' => 'qid', 'order' => 'group_order, t.question_order')); - $questions=array(); - foreach ($oResult as $result) - { - if (isset($result->questiontype_id)) - { - $questions[] = array( - 'qid' => $result['qid'], - 'title' => $result['title'], - /** - * @todo Remove dependency on optional property "question". - * In the future this column will be removed from the database. - */ - 'question' => $result['question'] - ); - - /** - * @todo Add support for subquestions. - */ - } - else - { - $q = createQuestion(empty($result->question_types['class']) ? $oResult[$result['parent_qid']]->question_types['class'] : $result->question_types['class']); - if ($q->questionProperties('subquestions') && $result['parent_qid']) - { - $questions[] = array('qid' => $result['parent_qid'], 'sqid' => $result['qid'], 'title' => $result->parents['title'], 'question' => $result->parents['question'], 'sqquestion' => $result['question']); - } - else if ($q->questionProperties('hasdefaultvalues') && !$q->questionProperties('subquestions')) - { - $questions[] = array('qid' => $result['qid'], 'title' => $result['title'], 'question' => $result['question']); - } - } - } - $aData['questions'] = $questions; - $aData['display']['menu_bars']['surveysummary'] = "editsurveysettings"; $tempData = $aData; $aData['data'] = $tempData; diff --git a/application/extensions/Menu/MenuWidget.php b/application/extensions/Menu/MenuWidget.php index cf6f88c0e13..b7280f8e1fd 100644 --- a/application/extensions/Menu/MenuWidget.php +++ b/application/extensions/Menu/MenuWidget.php @@ -2,17 +2,11 @@ class MenuWidget extends CWidget { - /** - * @var Limesurvey_lang - */ - public $clang = null; - public $menu = array(); public function __construct($owner = null) { parent::__construct($owner); Yii::import('application.helpers.surveytranslator_helper', true); - $this->clang = App()->lang; } public $defaults = array( 'title' => '', @@ -35,6 +29,10 @@ public function run() { $this->render('adminmenu', array('menu' => $this->menuGroup($this->groupId))); } + if (isset($this->questionId)) + { + $this->render('adminmenu', array('menu' => $this->menuQuestion($this->questionId))); + } } @@ -127,6 +125,26 @@ protected function menuMain() return $menu; } + protected function menuQuestion($questionId) + { + $question = Questions::model()->findByPk($questionId); + + $menu['title'] = "Question {$question->code} (id: {$questionId})"; + $menu['role'] = 'question'; + $menu['imageUrl'] = App()->getConfig('adminimageurl'); + + $menu['items']['left'][] = array( + 'alt' => gT('Preview this question'), + 'type' => 'link', + 'image' => 'preview.png', + 'target' => '_blank', + 'href' => array('questions/preview/', 'id' => $questionId) + ); + $menu['items']['left'][] = 'separator'; + + return $menu; + } + protected function menuSurvey($surveyId) { /** @@ -193,6 +211,104 @@ protected function menuSurvey($surveyId) ) ) ); + + $menu['items']['left'][] = array( + 'type' => 'sub', + 'href' => array('surveys/view', 'id' => $surveyId), + 'image' => 'edit.png', + 'items' => array( + array( + 'type' => 'link', + 'title' => gT('Edit text elements'), + 'image' => 'edit_30.png', + 'href' => array('admin/survey', 'sa' => 'editlocalsettings', 'surveyid' => $surveyId) + ), + array( + 'type' => 'link', + 'title' => gT('General settings'), + 'image' => 'survey_settings_30.png', + 'href' => array('admin/survey', 'sa' => 'editsurveysettings', 'surveyid' => $surveyId) + ), + array( + 'type' => 'link', + 'title' => gT('Survey permissions'), + 'image' => 'survey_security_30.png', + 'href' => array('admin/surveypermission', 'sa' => 'view', 'surveyid' => $surveyId) + ), + array( + 'type' => 'link', + 'title' => gT('Quotas'), + 'image' => 'quota_30.png', + 'href' => array('admin/quotas', 'sa' => 'index', 'surveyid' => $surveyId) + ), + array( + 'type' => 'link', + 'title' => gT('Assessments'), + 'image' => 'assessments_30.png', + 'href' => array('admin/assessments', 'sa' => 'index', 'surveyid' => $surveyId) + ), + array( + 'type' => 'link', + 'title' => gT('Email templates'), + 'image' => 'emailtemplates_30.png', + 'href' => array('admin/emailtemplates', 'sa' => 'index', 'surveyid' => $surveyId) + ), + array( + 'type' => 'link', + 'title' => gT('Survey logic file'), + 'image' => 'quality_assurance_30.png', + 'href' => array('admin/expressions', 'sa' => 'survey_logic_file', 'sid' => $surveyId) + ), + + ) + ); + $menu['items']['left'][] = array( + 'type' => 'sub', + 'href' => array('surveys/view', 'id' => $surveyId), + 'image' => 'tools.png', + 'items' => array( + array( + 'type' => 'link', + 'title' => gT('Delete survey'), + 'image' => 'delete_30.png', + 'href' => array('admin/survey', 'sa' => 'delete', 'surveyid' => $surveyId) + ), + array( + 'type' => 'link', + 'title' => gT('Quick-translation'), + 'image' => 'translate_30.png', + 'href' => array('admin/translate', 'sa' => 'index', 'surveyid' => $surveyId) + ), + array( + 'type' => 'link', + 'title' => gT('Expression manager'), + 'image' => 'expressionmanager_30.png', + 'href' => array('admin/expressions') + ), + array( + 'type' => 'link', + 'title' => gT('Reset conditions'), + 'image' => 'resetsurveylogic_30.png' + ), + array( + 'type' => 'sub', + 'title' => gT('Regenerate question codes'), + 'image' => 'resetsurveylogic_30.png', + 'items' => array( + array( + 'title' => gT('Straight'), + 'image' => 'resetsurveylogic_30.png', + 'href' => array('admin/survey', 'sa' => 'regenquestioncodes', 'surveyid' => $surveyId, 'subaction' => 'straight') + ), + array( + 'title' => gT('By group'), + 'image' => 'resetsurveylogic_30.png', + 'href' => array('admin/survey', 'sa' => 'regenquestioncodes', 'surveyid' => $surveyId, 'subaction' => 'bygroup') + ) + ) + ), + ) + ); $menu['items']['right'][] = array( 'title' => 'Groups:', 'type' => 'select', @@ -223,6 +339,7 @@ protected function menuGroup($groupId) 'alt' => gT('Preview this group'), 'type' => 'link', 'image' => 'preview.png', + 'target' => '_blank', 'href' => array('survey/index/', 'action' => 'previewgroup', 'sid' => $group->sid, 'gid' => $groupId) ); $menu['items']['left'][] = 'separator'; @@ -267,16 +384,23 @@ protected function renderItem($item, &$allowSeparator, $imageUrl, $level = 0) $result = $this->renderSelect($item); } + if (isset($item['href'])) + { + $options = array(); + if (isset($item['target'])) + { + $options['target'] = $item['target']; + } + $result = CHtml::link($result, $item['href'], $options); + } + if(isset($item['items'])) { $result = $this->renderSub($item, $imageUrl, $level + 1); } - if (isset($item['href'])) - { - $result = CHtml::link($result, $item['href']); - } + } elseif (is_string($item) && $item == 'separator' && $allowSeparator) { diff --git a/application/extensions/Menu/assets/nav.css b/application/extensions/Menu/assets/nav.css index 46053c7b7b8..b0bba2f71ff 100644 --- a/application/extensions/Menu/assets/nav.css +++ b/application/extensions/Menu/assets/nav.css @@ -7,10 +7,12 @@ nav { } nav ol { + background-color: white; list-style: none; padding: 0px; margin: 0px; display: inline-block; + box-shadow: 7px 7px 5px rgba(50, 50, 50, 0.75); } nav > ol.menubar-left { @@ -21,17 +23,23 @@ nav > ol.menubar-right { float: right; } + nav li { - padding: 2px; -moz-box-sizing: border-box; box-sizing: border-box; white-space:nowrap; + padding: 5px; +} + +nav ol.level0 > li { + padding: 2px !important; } - nav a { display: inline-block; + + width: 100%; } nav img { @@ -39,6 +47,9 @@ nav img { vertical-align: middle; } +nav ol.level0 { + box-shadow: none !important; +} nav ol.level0 > li { display: inline-block; } @@ -54,6 +65,11 @@ nav ol.level1 { nav ol.level1 > li { position: relative; } + +nav ol.level1 img { + margin-right: 10px; +} + nav ol.level2 { top: 0px; visibility: hidden;