Skip to content

Commit

Permalink
Dev (1) Fix question preview. Note, requires call to full createField…
Browse files Browse the repository at this point in the history
…Map(), so may take a while in large survey until createFieldMap is refactored

Dev (2) Bugfix to bCheckQuestionForAnswer()
Dev (3) Hack bugfix to getRadixPointData().  Core problem is passed null since $thissurvey is undefined at time of call.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_ci@11200 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
TMSWhite committed Oct 19, 2011
1 parent d987a83 commit 04f06ad
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
12 changes: 6 additions & 6 deletions application/controllers/admin/question.php
Expand Up @@ -1032,7 +1032,7 @@ function preview($surveyid, $qid, $lang = null)

// This is needed to properly detect and color code EM syntax errors
LimeExpressionManager::StartProcessingPage();
LimeExpressionManager::StartProcessingGroup($qrows['gid'],false,$surveyid); // loads list of replacement values available for this group
LimeExpressionManager::StartProcessingGroup($qrows['gid'],false,$surveyid,true); // loads list of replacement values available for this group

$answers = retrieveAnswers($ia);

Expand Down Expand Up @@ -1098,12 +1098,12 @@ function noop_checkconditions(value, name, type)
$question_template = file_get_contents("$thistpl/question.pstpl");
if(substr_count($question_template , '{QUESTION_ESSENTIALS}') > 0 ) // the following has been added for backwards compatiblity.
{// LS 1.87 and newer templates
$content .= "\n".templatereplace($question_template,array(),$redata,'question[1319]')."\n";
$content .= "\n".templatereplace($question_template,array(),$redata,'question[1319]',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,array(),$redata,'question[1324]')."\n";
$content .= "\n".templatereplace($question_template,array(),$redata,'question[1324]',false,$qid)."\n";
$content .= "\n\t</div>\n";
};

Expand All @@ -1112,9 +1112,9 @@ function noop_checkconditions(value, name, type)
$content .= templatereplace(file_get_contents("$thistpl/endpage.pstpl"),array(),$redata,'question[1330]');

// if want to include Javascript in question preview, uncomment these. However, Group level preview is probably adequate
// LimeExpressionManager::FinishProcessingGroup();
// LimeExpressionManager::FinishProcessingPage();
// echo LimeExpressionManager::GetRelevanceAndTailoringJavaScript();
LimeExpressionManager::FinishProcessingGroup();
$content .= LimeExpressionManager::GetRelevanceAndTailoringJavaScript();
LimeExpressionManager::FinishProcessingPage();

echo $content;
echo "</html>\n";
Expand Down
6 changes: 4 additions & 2 deletions application/helpers/common_helper.php
Expand Up @@ -6233,6 +6233,8 @@ function aArrayInvert($aArr)
*/
function bCheckQuestionForAnswer($q, $aFieldnamesInfoInv)
{
$CI =& get_instance();

$qtype = $_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['type'];

if ($qtype == 'X')
Expand Down Expand Up @@ -6260,9 +6262,9 @@ function bCheckQuestionForAnswer($q, $aFieldnamesInfoInv)

$qid=$_SESSION['fieldmap'][$aFieldnamesInfoInv[$q][0]]['qid'];

$gquery = "SELECT * FROM ".db_table_name('question_attributes')." WHERE qid={$qid} AND attribute ='array_filter'";
$gquery = "SELECT * FROM ".$CI->db->dbprefix('question_attributes')." WHERE qid={$qid} AND attribute ='array_filter'";
$qresult = db_execute_assoc($gquery); //checked
$qrows = $qresult->GetRows();
$qrows = $qresult->result_array();

$filter=$qrows[0]['value'];

Expand Down
4 changes: 2 additions & 2 deletions application/helpers/expressions/em_manager_helper.php
Expand Up @@ -997,7 +997,7 @@ static function StartProcessingPage($navigationIndex=false,$allOnOnePage=false,$
}
}

static function StartProcessingGroup($groupNum=NULL,$anonymized=false,$surveyid=NULL)
static function StartProcessingGroup($groupNum=NULL,$anonymized=false,$surveyid=NULL,$forceRefresh=false)
{
$LEM =& LimeExpressionManager::singleton();
$LEM->em->StartProcessingGroup();
Expand All @@ -1011,7 +1011,7 @@ static function StartProcessingGroup($groupNum=NULL,$anonymized=false,$surveyid=
$LEM->qid2code = array(); // List of codes for each question - needed to know which to NULL if a question is irrelevant
$LEM->jsVar2qid = array();

if (!is_null($surveyid) && $LEM->setVariableAndTokenMappingsForExpressionManager($surveyid,false,$anonymized,$LEM->allOnOnePage))
if (!is_null($surveyid) && $LEM->setVariableAndTokenMappingsForExpressionManager($surveyid,$forceRefresh,$anonymized,$LEM->allOnOnePage))
{
// means that some values changed, so need to update what was registered to ExpressionManager
$LEM->em->RegisterVarnamesUsingMerge($LEM->knownVars);
Expand Down
5 changes: 5 additions & 0 deletions application/helpers/surveytranslator_helper.php
Expand Up @@ -526,6 +526,11 @@ function getRadixPointData($format=-1)
1=>array('seperator'=> ',', 'desc'=> $clang->gT('Comma (,)'))
);

// hack for fact that null sometimes sent to this function
if (is_null($format)) {
$format = 0;
}

if ($format >= 0)
return $aRadixFormats[$format];
else
Expand Down

0 comments on commit 04f06ad

Please sign in to comment.