Skip to content

Commit

Permalink
Dev Editsurveysettings no longer instantiates each question in the su…
Browse files Browse the repository at this point in the history
…rvey.

Dev Added more submenus to the menuwidget.
  • Loading branch information
Sam committed Feb 26, 2013
1 parent 979da67 commit f4f886a
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 56 deletions.
8 changes: 4 additions & 4 deletions application/controllers/QuestionsController.php
Expand Up @@ -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)
Expand All @@ -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));

}

Expand Down
18 changes: 18 additions & 0 deletions application/controllers/SurveysController.php
Expand Up @@ -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.
Expand Down
40 changes: 0 additions & 40 deletions application/controllers/admin/surveyadmin.php
Expand Up @@ -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;
Expand Down
144 changes: 134 additions & 10 deletions application/extensions/Menu/MenuWidget.php
Expand Up @@ -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' => '',
Expand All @@ -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)));
}
}


Expand Down Expand Up @@ -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)
{
/**
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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)
{
Expand Down
20 changes: 18 additions & 2 deletions application/extensions/Menu/assets/nav.css
Expand Up @@ -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 {
Expand All @@ -21,24 +23,33 @@ 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 {
float: none !important;
vertical-align: middle;
}

nav ol.level0 {
box-shadow: none !important;
}
nav ol.level0 > li {
display: inline-block;
}
Expand All @@ -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;
Expand Down

0 comments on commit f4f886a

Please sign in to comment.