Skip to content

Commit

Permalink
Fixed issue #05731: Randomization group name seems to block "Test thi…
Browse files Browse the repository at this point in the history
…s survey"

Dev the randomization itself isn't working properly in Yii, but testing is no longer blocked, and the rest of the refactoring needed to get randomization working has been completed.
  • Loading branch information
TMSWhite committed Apr 4, 2012
1 parent 3ed8d54 commit ee2b6b4
Show file tree
Hide file tree
Showing 10 changed files with 3,048 additions and 180 deletions.
3 changes: 1 addition & 2 deletions application/controllers/admin/question.php
Expand Up @@ -723,8 +723,7 @@ public function index($sa, $surveyid, $gid, $qid=null)
else
{
// This is needed to properly color-code content if it contains replacements
LimeExpressionManager::StartProcessingPage(false,Yii::app()->baseUrl); // so can click on syntax highlighting to edit questions
LimeExpressionManager::StartProcessingGroup($gid, ($surveyinfo['anonymized']!="N"), $surveyinfo['sid']); // loads list of replacement values available for this group
LimeExpressionManager::StartProcessingPage(false,Yii::app()->baseUrl,true); // so can click on syntax highlighting to edit questions
}

$qtypelist = getQuestionTypeList('', 'array');
Expand Down
3 changes: 1 addition & 2 deletions application/core/Survey_Common_Action.php
Expand Up @@ -205,8 +205,7 @@ protected function _renderWrappedTemplate($sAction = '', $aViewUrls = array(), $
if (!empty($aData['surveyid']))
{

LimeExpressionManager::StartProcessingPage(false, Yii::app()->baseUrl); // so can click on syntax highlighting to edit questions
LimeExpressionManager::StartProcessingGroup(!empty($aData['gid']) ? $aData['gid'] : null, false, $aData['surveyid']); // loads list of replacement values available for this group
LimeExpressionManager::StartProcessingPage(false, Yii::app()->baseUrl,true); // so can click on syntax highlighting to edit questions

$this->_surveybar($aData['surveyid'], !empty($aData['gid']) ? $aData['gid'] : null);

Expand Down
34 changes: 25 additions & 9 deletions application/helpers/SurveyRuntimeHelper.php
Expand Up @@ -847,16 +847,16 @@ function checkconditions(value, name, type, evt_type)
{
// force the group to be visible, even if irrelevant - will not always work
print <<<END
$('#relevanceG' + LEMgid).val(1);
$('#relevanceG' + LEMgseq).val(1);
$(document).ready(function() {
$('#group-' + LEMgid).show();
$('#group-' + LEMgseq).show();
});
$(document).change(function() {
$('#group-' + LEMgid).show();
$('#group-' + LEMgseq).show();
});
$(document).bind('keydown',function(e) {
if (e.keyCode == 9) {
$('#group-' + LEMgid).show();
$('#group-' + LEMgseq).show();
return true;
}
return true;
Expand Down Expand Up @@ -889,9 +889,11 @@ function checkconditions(value, name, type, evt_type)
echo "<p><span class='errormandatory'>" . $clang->gT("One or more uploaded files are not in proper format/size. You cannot proceed until these files are valid.") . "</span></p>";
}

$_gseq = -1;
foreach ($_SESSION[$LEMsessid]['grouplist'] as $gl)
{
$gid = $gl[0];
++$_gseq;
$groupname = $gl[1];
$groupdescription = $gl[2];

Expand All @@ -903,8 +905,8 @@ function checkconditions(value, name, type, evt_type)
$redata = compact(array_keys(get_defined_vars()));

echo "\n\n<!-- START THE GROUP -->\n";
echo "\n\n<div id='group-$gid'";
$gnoshow = LimeExpressionManager::GroupIsIrrelevantOrHidden($gid);
echo "\n\n<div id='group-$_gseq'";
$gnoshow = LimeExpressionManager::GroupIsIrrelevantOrHidden($_gseq);
if ($gnoshow && !$previewgrp)
{
echo " style='display: none;'";
Expand All @@ -923,6 +925,10 @@ function checkconditions(value, name, type, evt_type)

foreach ($qanda as $qa) // one entry per QID
{
if ($gid != $qa[6]) {
continue;
}

$qid = $qa[4];
$qinfo = LimeExpressionManager::GetQuestionStatus($qid);
$lastgrouparray = explode("X", $qa[7]);
Expand Down Expand Up @@ -1045,10 +1051,11 @@ function checkconditions(value, name, type, evt_type)
// show the group label
++$gseq;
$g = $_SESSION[$LEMsessid]['grouplist'][$gseq];
$grel = !LimeExpressionManager::GroupIsIrrelevantOrHidden($stepInfo['gid']);
$grel = !LimeExpressionManager::GroupIsIrrelevantOrHidden($gseq);
if ($grel)
{
echo '<h3>' . flattenText($g[1]) . "</h3>";
$gtitle = LimeExpressionManager::ProcessString($g[1]);
echo '<h3>' . flattenText($gtitle) . "</h3>";
}
$lastGseq = $stepInfo['gseq'];
}
Expand All @@ -1068,7 +1075,16 @@ function checkconditions(value, name, type, evt_type)
$g = $_SESSION[$LEMsessid]['grouplist'][$gseq];
}

$sText = (($surveyMode == 'group') ? flattenText($g[1]) : flattenText($q[3]));
if ($surveyMode == 'group')
{
$indexlabel = LimeExpressionManager::ProcessString($g[1]);
}
else
{
$indexlabel = LimeExpressionManager::ProcessString($q[3]);
}

$sText = (($surveyMode == 'group') ? flattenText($indexlabel) : flattenText($indexlabel));
$bGAnsw = !$stepInfo['anyUnanswered'];

++$v;
Expand Down
55 changes: 53 additions & 2 deletions application/helpers/common_helper.php
Expand Up @@ -2188,7 +2188,7 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
$clang = new Limesurvey_lang($sLanguage); ;

//checks to see if fieldmap has already been built for this page.
if (isset(Yii::app()->session['fieldmap-' . $surveyid . $sLanguage]) && !$force_refresh) {
if (isset(Yii::app()->session['fieldmap-' . $surveyid . $sLanguage]) && !$force_refresh && $questionid == false) {
return Yii::app()->session['fieldmap-' . $surveyid . $sLanguage];
}

Expand Down Expand Up @@ -2733,7 +2733,58 @@ function createFieldMap($surveyid, $style='short', $force_refresh=false, $questi
}

if (isset($fieldmap)) {
Yii::app()->session['fieldmap-' . $surveyid . $sLanguage]=$fieldmap;
if ($questionid == false)
{
// If the fieldmap was randomized, the master will contain the proper order. Copy that fieldmap with the new language settings.
if (isset(Yii::app()->session['fieldmap-' . $surveyid . '-randMaster']))
{
$masterFieldmap = Yii::app()->session['fieldmap-' . $surveyid . '-randMaster'];
$mfieldmap = Yii::app()->session[$masterFieldmap];

foreach ($mfieldmap as $fieldname => $mf)
{
if (isset($fieldmap[$fieldname]))
{
$f = $fieldmap[$fieldname];
if (isset($f['question']))
{
$mf['question'] = $f['question'];
}
if (isset($f['subquestion']))
{
$mf['subquestion'] = $f['subquestion'];
}
if (isset($f['subquestion1']))
{
$mf['subquestion1'] = $f['subquestion1'];
}
if (isset($f['subquestion2']))
{
$mf['subquestion2'] = $f['subquestion2'];
}
if (isset($f['group_name']))
{
$mf['group_name'] = $f['group_name'];
}
if (isset($f['answerList']))
{
$mf['answerList'] = $f['answerList'];
}
if (isset($f['defaultvalue']))
{
$mf['defaultvalue'] = $f['defaultvalue'];
}
if (isset($f['help']))
{
$mf['help'] = $f['help'];
}
}
$mfieldmap[$fieldname] = $mf;
}
$fieldmap = $mfieldmap;
}
Yii::app()->session['fieldmap-' . $surveyid . $sLanguage]=$fieldmap;
}
return $fieldmap;
}
}
Expand Down
2 changes: 1 addition & 1 deletion application/helpers/expressions/em_core_helper.php
Expand Up @@ -2942,7 +2942,7 @@ static function UnitTestEvaluator()
$body .= '</table>';
$body .= "<script type='text/javascript'>\n";
$body .= "<!--\n";
$body .= "var LEMgid=2;\n";
$body .= "var LEMgseq=2;\n";
$body .= "var LEMmode='group';\n";
$body .= "function recompute() {\n";
$body .= implode("\n",$javaScript);
Expand Down

0 comments on commit ee2b6b4

Please sign in to comment.