Skip to content

Commit

Permalink
Reintroduce setNoAnswerMode(). Fix question/questiongroup preview.
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_yii@12052 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
GautamGupta committed Jan 14, 2012
1 parent 943d3d5 commit 05d119f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
29 changes: 12 additions & 17 deletions application/controllers/admin/question.php
Expand Up @@ -939,26 +939,22 @@ public function preview($surveyid, $qid, $lang = null)
$LEMdebugLevel=0;

Yii::app()->loadHelper("qanda");

Yii::app()->loadHelper("surveytranslator");

if (!isset($surveyid))
$surveyid = returnglobal('sid');

$surveyid = (int) $surveyid;
if (!isset($qid))
$qid = returnglobal('qid');

if (empty($surveyid))
$this->getController()->error('No Survey ID provided');
if (empty($qid))
$this->getController()->error('No Question ID provided');

if (!isset($lang) || $lang == "")
if (empty($lang))
$language = Survey::model()->findByPk($surveyid)->language;
else
$language = $lang;

if (!isset($_SESSION['step'])) { $_SESSION['step'] = 0; }
if (!isset($_SESSION['prevstep'])) { $_SESSION['prevstep'] = 0; }
if (!isset($_SESSION['maxstep'])) { $_SESSION['maxstep'] = 0; }

// Use $_SESSION instead of $this->session for frontend features.
$_SESSION['s_lang'] = $language;
$_SESSION['fieldmap'] = createFieldMap($surveyid, 'full', true, $qid);
Expand All @@ -976,9 +972,8 @@ public function preview($surveyid, $qid, $lang = null)

$_SESSION['dateformats'] = getDateFormatData($thissurvey['surveyls_dateformat']);

$qresult = Questions::model()->findByAttributes(array('sid' => $surveyid, 'qid' => $qid, 'language' => $language));
$qrows = Questions::model()->findByAttributes(array('sid' => $surveyid, 'qid' => $qid, 'language' => $language))->getAttributes();

$qrows = $qresult->attributes;
$ia = array(
0 => $qid,
1 => $surveyid . 'X' . $qrows['gid'] . 'X' . $qid,
Expand Down Expand Up @@ -1046,28 +1041,28 @@ function noop_checkconditions(value, name, type)
$question['man_class'] = '';

$redata = compact(array_keys(get_defined_vars()));
$content = templatereplace(file_get_contents("$thistpl/startpage.pstpl"));
$content = templatereplace(file_get_contents("$thistpl/startpage.pstpl"), array(), $redata);
$content .='<form method="post" action="index.php" id="limesurvey" name="limesurvey" autocomplete="off">';
$content .= templatereplace(file_get_contents("$thistpl/startgroup.pstpl"));
$content .= templatereplace(file_get_contents("$thistpl/startgroup.pstpl"), array(), $redata);

$question_template = file_get_contents("$thistpl/question.pstpl");
// the following has been added for backwards compatiblity.
if (substr_count($question_template, '{QUESTION_ESSENTIALS}') > 0)
{
// LS 1.87 and newer templates
$content .= "\n" . templatereplace($question_template, false, $qid) . "\n";
$content .= "\n" . templatereplace($question_template, array(), $redata, 'Unspecified', false, $qid) . "\n";
}
else
{
// LS 1.86 and older templates
$content .= '<div ' . $question['essentials'] . ' class="' . $question['class'] . $question['man_class'] . '">';
$content .= "\n" . templatereplace($question_template, false, $qid) . "\n";
$content .= "\n" . templatereplace($question_template, array(), $redata, 'Unspecified', false, $qid) . "\n";
$content .= "\n\t</div>\n";
};

$content .= templatereplace(file_get_contents("$thistpl/endgroup.pstpl")) . $dummy_js;
$content .= templatereplace(file_get_contents("$thistpl/endgroup.pstpl"), array(), $redata) . $dummy_js;
$content .= '<p>&nbsp;</form>';
$content .= templatereplace(file_get_contents("$thistpl/endpage.pstpl"));
$content .= templatereplace(file_get_contents("$thistpl/endpage.pstpl"), array(), $redata);

LimeExpressionManager::FinishProcessingPage();

Expand Down
1 change: 1 addition & 0 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -556,6 +556,7 @@ function run($args) {
$okToShowErrors = (!$previewgrp && (isset($invalidLastPage) || $_SESSION['prevstep'] == $_SESSION['step']));

Yii::app()->getController()->loadHelper('qanda');
setNoAnswerMode($thissurvey);

//Iterate through the questions about to be displayed:
$inputnames = array();
Expand Down
15 changes: 5 additions & 10 deletions application/helpers/globalsettings_helper.php
Expand Up @@ -40,20 +40,17 @@ function injectglobalsettings()

function getGlobalSetting($settingname)
{
if (Yii::app()->getRegistry($settingname) === false) {
//$usquery = "SELECT stg_value FfROM ".db_table_name("settings_global")." where stg_name='$settingname'";
$dbvalue = Yii::app()->getRegistry($settingname);

$dbvalue = Settings_global::model()->findByPk($settingname);
//$dbvalue = $dbvalue['stg_value'];
//var_dump($dbvalue);
if ($dbvalue === false)
{
$dbvalue = Settings_global::model()->findByPk($settingname)->getAttribute('stg_value');

if (empty($dbvalue))
{
Yii::app()->setRegistry($settingname, null);
$dbvalue="";
$dbvalue = '';
}
else
$dbvalue = $dbvalue->getAttribute('stg_value');

if (Yii::app()->getConfig($settingname) !== false)
{
Expand All @@ -63,8 +60,6 @@ function getGlobalSetting($settingname)
$dbvalue = Yii::app()->getConfig($settingname);
}
}
else
$dbvalue = Yii::app()->getRegistry($settingname);

return $dbvalue;
}
Expand Down
18 changes: 12 additions & 6 deletions application/helpers/qanda_helper.php
Expand Up @@ -46,13 +46,19 @@
* $condition[n][7] => scenario *NEW BY R.L.J. van den Burg*
*/

if(!empty($shownoanswer) && $shownoanswer > 0 && !empty($thissurvey['shownoanswer']) && $thissurvey['shownoanswer'] != 'N')
{
define('SHOW_NO_ANSWER', 1);
}
else
/**
* setNoAnswerMode
*/
function setNoAnswerMode($thissurvey)
{
define('SHOW_NO_ANSWER', 0);
if (getGlobalSetting('shownoanswer') > 0 && $thissurvey['shownoanswer'] != 'N')
{
define('SHOW_NO_ANSWER', 1);
}
else
{
define('SHOW_NO_ANSWER', 0);
}
}

/**
Expand Down
Expand Up @@ -9,7 +9,7 @@
<?php if(bHasSurveyPermission($surveyid,'surveycontent','update'))
{ ?>
<img src='<?php echo Yii::app()->getConfig('imageurl'); ?>/seperator.gif' alt='' />
<a href="#" onclick="window.open('<?php echo $this->createUrl("survey/action/previewgroup/surveyid/$surveyid/gid/$gid/");?>','_blank')"
<a href="#" onclick="window.open('<?php echo $this->createUrl("survey/index/sid/$surveyid/gid/$gid/");?>','_blank')"
title="<?php $clang->eTview("Preview current question group"); ?>">
<img src='<?php echo Yii::app()->getConfig('imageurl'); ?>/preview.png' alt='<?php $clang->eT("Preview current question group"); ?>' width="40" height="40"/></a>
<?php }
Expand Down

0 comments on commit 05d119f

Please sign in to comment.