Skip to content

Commit

Permalink
Fixed issue Show Survey Logic File does not show survey title, descri…
Browse files Browse the repository at this point in the history
…ption, welcome, endmsg, endurl, nor any errors within them

Dev added {ENDTEXT} replacement
Dev fixed EM error detection - was losing track of errors in nested replacements.
  • Loading branch information
TMSWhite committed Jun 22, 2012
1 parent 070d255 commit 7b5d2e4
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 6 deletions.
3 changes: 3 additions & 0 deletions classes/expressions/ExpressionManager.php
Expand Up @@ -1811,6 +1811,7 @@ public function sProcessStringContainingExpressions($src, $questionNum=0, $numRe
$this->groupSeq = $groupSeq;
$result = $src;
$prettyPrint = '';
$errors = array();

for($i=1;$i<=$numRecursionLevels;++$i)
{
Expand All @@ -1820,8 +1821,10 @@ public function sProcessStringContainingExpressions($src, $questionNum=0, $numRe
{
$prettyPrint = $this->prettyPrintSource;
}
$errors = array_merge($errors, $this->RDP_errs);
}
$this->prettyPrintSource = $prettyPrint; // ensure that if doing recursive substition, can get original source to pretty print
$this->RDP_errs = $errors;
return $result;
}

Expand Down
46 changes: 42 additions & 4 deletions classes/expressions/LimeExpressionManager.php
Expand Up @@ -7784,6 +7784,7 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL
$LEM =& LimeExpressionManager::singleton();

$allErrors = array();
$warnings=0;

$surveyOptions = array(
'assessments'=>$assessments,
Expand Down Expand Up @@ -7816,17 +7817,50 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL

$qtypes=getqtypelist('','array');

templatereplace('{SITENAME}'); // to ensure that lime replacement fields loaded

if (is_null($moveResult) || is_null($LEM->currentQset) || count($LEM->currentQset) == 0) {
return array(
'errors'=>1,
'html'=>$LEM->gT('Invalid question - probably missing sub-questions or language-specific settings for language ') . $_SESSION['LEMlang'],
);
}

$out = "<table border='1'>"
. "<tr><th>#</th><th>".$LEM->gT('Name [ID]')."</th><th>".$LEM->gT('Relevance [Validation] (Default)')."</th><th>".$LEM->gT('Text [Help] (Tip)')."</th></tr>\n";
$surveyname = templatereplace('{SURVEYNAME}');

$out = '<H3>' . $LEM->gT('Logic File for Survey # ') . '[' . $LEM->sid . "]: $surveyname</H3>\n";
$out .= "<table border='1'>";

if (is_null($gid) && is_null($qid))
{
$description = templatereplace('{SURVEYDESCRIPTION}');
$errClass = ($LEM->em->HasErrors() ? 'LEMerror' : '');
if ($description != '')
{
$out .= "<tr class='LEMgroup $errClass'><td colspan=2>" . $LEM->gT("Description:") . "</td><td colspan=2>" . $description . "</td></tr>";
}

$welcome = templatereplace('{WELCOME}');
$errClass = ($LEM->em->HasErrors() ? 'LEMerror' : '');
if ($welcome != '')
{
$out .= "<tr class='LEMgroup $errClass'><td colspan=2>" . $LEM->gT("Welcome:") . "</td><td colspan=2>" . $welcome . "</td></tr>";
}

$endmsg = templatereplace('{ENDTEXT}');
$errClass = ($LEM->em->HasErrors() ? 'LEMerror' : '');
if ($endmsg != '')
{
$out .= "<tr class='LEMgroup $errClass'><td colspan=2>" . $LEM->gT("End message:") . "</td><td colspan=2>" . $endmsg . "</td></tr>";
}

$_linkreplace = templatereplace('{URL}');
$errClass = ($LEM->em->HasErrors() ? 'LEMerror' : '');
if ($_linkreplace != '')
{
$out .= "<tr class='LEMgroup $errClass'><td colspan=2>" . $LEM->gT("End URL") . ":</td><td colspan=2>" . $_linkreplace . "</td></tr>";
}
}

$out .= "<tr><th>#</th><th>".$LEM->gT('Name [ID]')."</th><th>".$LEM->gT('Relevance [Validation] (Default)')."</th><th>".$LEM->gT('Text [Help] (Tip)')."</th></tr>\n";

$_gseq=-1;
foreach ($LEM->currentQset as $q) {
Expand Down Expand Up @@ -8050,6 +8084,10 @@ static public function ShowSurveyLogicFile($sid, $gid=NULL, $qid=NULL,$LEMdebugL
{
++$errorCount;
}
else
{
++$warnings;
}
}

//////
Expand Down
2 changes: 0 additions & 2 deletions classes/expressions/test/survey_logic_file.php
Expand Up @@ -135,8 +135,6 @@

SetSurveyLanguage($surveyid, $language);

echo '<H3>' . $clang->gT('Logic File for Survey # ') . $surveyid . "</H3>\n";

$result = LimeExpressionManager::ShowSurveyLogicFile($surveyid, $gid, $qid,$LEMdebugLevel,$assessments);
print $result['html'];

Expand Down
7 changes: 7 additions & 0 deletions replacements.php
Expand Up @@ -639,6 +639,12 @@ function templatereplace($line, $replacements=array(), $anonymized=false, $quest
}
}

$_endtext = '';
if (isset($thissurvey['surveyls_endtext']) && trim($thissurvey['surveyls_endtext'])!='')
{
$_endtext = $thissurvey['surveyls_endtext'];
}

// Set the array of replacement variables here - don't include curly braces
// Please put any conditional logic above this section. Here below should just be an alphabetical list of replacement values with no embedded logic.

Expand All @@ -654,6 +660,7 @@ function templatereplace($line, $replacements=array(), $anonymized=false, $quest
$coreReplacements['CLOSEWINDOW'] = "<a href='javascript:%20self.close()'>".$clang->gT("Close this window")."</a>";
$coreReplacements['COMPLETED'] = $completed; // global
$coreReplacements['DATESTAMP'] = $_datestamp;
$coreReplacements['ENDTEXT'] = $_endtext;
$coreReplacements['EXPIRY'] = $_dateoutput;
$coreReplacements['GID'] = $_question_gid;
$coreReplacements['GOOGLE_ANALYTICS_API_KEY'] = $_googleAnalyticsAPIKey;
Expand Down

0 comments on commit 7b5d2e4

Please sign in to comment.