Skip to content

Commit

Permalink
Fixed issue #5013: GSOC - Filter settings based on token information …
Browse files Browse the repository at this point in the history
…not properly displayed in printable version. Patch kindly provided by user pasmaill.

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/source/limesurvey_dev@9934 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
Thibault Le Meur committed Mar 29, 2011
1 parent d90dc9f commit c51f51d
Showing 1 changed file with 80 additions and 32 deletions.
112 changes: 80 additions & 32 deletions admin/printablesurvey.php
Expand Up @@ -401,6 +401,7 @@ function star_replace($input)
$group['ODD_EVEN'] = ' g-row-even';
}

//Loop through questions
foreach ($deqrows as $deqrow)
{
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand All @@ -419,6 +420,7 @@ function star_replace($input)
$scenarioquery="SELECT DISTINCT ".db_table_name("conditions").".scenario FROM ".db_table_name("conditions")." WHERE ".db_table_name("conditions").".qid={$deqrow['qid']} ORDER BY scenario";
$scenarioresult=db_execute_assoc($scenarioquery);

//Loop through distinct scenarios, thus grouping them together.
while ($scenariorow=$scenarioresult->FetchRow())
{
if($s == 0 && $scenarioresult->RecordCount() > 1)
Expand All @@ -431,13 +433,14 @@ function star_replace($input)
}

$x=0;
$distinctquery="SELECT cqid, method
$distinctquery="SELECT cqid, method, cfieldname, value
FROM ".db_table_name("conditions")."
WHERE ".db_table_name("conditions").".qid={$deqrow['qid']}
AND ".db_table_name("conditions").".scenario={$scenariorow['scenario']}
group by cqid, method
ORDER BY cqid";
$distinctresult=db_execute_assoc($distinctquery);
//Loop through each condition for a particular scenario.
while ($distinctrow=$distinctresult->FetchRow())
{
$subquery='select title, question from '.db_table_name("questions")." where qid={$distinctrow['cqid']} AND parent_qid=0 AND language='{$surveyprintlang}'";
Expand All @@ -452,37 +455,77 @@ function star_replace($input)
$distinctrow['method']='==';
}

if($distinctrow['method']=='==')
{
$explanation .= $clang->gT("Answer was")." ";
}
elseif($distinctrow['method']=='!=')
{
$explanation .= $clang->gT("Answer was NOT")." ";
}
elseif($distinctrow['method']=='<')
{
$explanation .= $clang->gT("Answer was less than")." ";
}
elseif($distinctrow['method']=='<=')
{
$explanation .= $clang->gT("Answer was less than or equal to")." ";
}
elseif($distinctrow['method']=='>=')
{
$explanation .= $clang->gT("Answer was greater than or equal to")." ";
}
elseif($distinctrow['method']=='>')
{
$explanation .= $clang->gT("Answer was greater than")." ";
}
elseif($distinctrow['method']=='RX')
{
$explanation .= $clang->gT("Answer matched (regexp)")." ";
if($distinctrow['cqid']){ // cqid != 0 ==> previous answer match
if($distinctrow['method']=='==')
{
$explanation .= $clang->gT("Answer was")." ";
}
elseif($distinctrow['method']=='!=')
{
$explanation .= $clang->gT("Answer was NOT")." ";
}
elseif($distinctrow['method']=='<')
{
$explanation .= $clang->gT("Answer was less than")." ";
}
elseif($distinctrow['method']=='<=')
{
$explanation .= $clang->gT("Answer was less than or equal to")." ";
}
elseif($distinctrow['method']=='>=')
{
$explanation .= $clang->gT("Answer was greater than or equal to")." ";
}
elseif($distinctrow['method']=='>')
{
$explanation .= $clang->gT("Answer was greater than")." ";
}
elseif($distinctrow['method']=='RX')
{
$explanation .= $clang->gT("Answer matched (regexp)")." ";
}
else
{
$explanation .= $clang->gT("Answer was")." ";
}
}
else
{
$explanation .= $clang->gT("Answer was")." ";
if(!$distinctrow['cqid']){ // cqid == 0 ==> token attribute match
$tokenData = GetTokenFieldsAndNames($surveyid);
preg_match('/^{TOKEN:([^}]*)}$/',$distinctrow['cfieldname'],$extractedTokenAttr);
$explanation .= "Your ".$tokenData[strtolower($extractedTokenAttr[1])]." ";
if($distinctrow['method']=='==')
{
$explanation .= $clang->gT("is")." ";
}
elseif($distinctrow['method']=='!=')
{
$explanation .= $clang->gT("is NOT")." ";
}
elseif($distinctrow['method']=='<')
{
$explanation .= $clang->gT("is less than")." ";
}
elseif($distinctrow['method']=='<=')
{
$explanation .= $clang->gT("is less than or equal to")." ";
}
elseif($distinctrow['method']=='>=')
{
$explanation .= $clang->gT("is greater than or equal to")." ";
}
elseif($distinctrow['method']=='>')
{
$explanation .= $clang->gT("is greater than")." ";
}
elseif($distinctrow['method']=='RX')
{
$explanation .= $clang->gT("is matched (regexp)")." ";
}
else
{
$explanation .= $clang->gT("is")." ";
}
$answer_section = $distinctrow['value'];
}

$conquery="SELECT cid, cqid, q.title,\n"
Expand Down Expand Up @@ -690,7 +733,12 @@ function star_replace($input)
unset($conditions);
// Following line commented out because answer_section was lost, but is required for some question types
//$explanation .= " ".$clang->gT("to question")." '".$mapquestionsNumbers[$distinctrow['cqid']]."' $answer_section ";
$explanation .= " ".$clang->gT("at question")." '".$mapquestionsNumbers[$distinctrow['cqid']]." [".$subresult['title']."]' (".strip_tags($subresult['question'])."$answer_section)" ;
if($distinctrow['cqid']){
$explanation .= " ".$clang->gT("at question")." '".$mapquestionsNumbers[$distinctrow['cqid']]." [".$subresult['title']."]' (".strip_tags($subresult['question'])."$answer_section)" ;
}
else{
$explanation .= " ".$distinctrow['value'] ;
}
//$distinctrow
$x++;
}
Expand Down

0 comments on commit c51f51d

Please sign in to comment.