View Issue Details

This bug affects 1 person(s).
 2
IDProjectCategoryView StatusLast Update
05055Bug reportsSurvey takingpublic2011-03-26 11:55
Reporteruser12634Assigned Toc_schmitz  
PrioritynormalSeverityminor 
Status closedResolutionduplicate 
Product Version1.91RC4 
Summary05055: SGQA identifier with "ohter" answer in multiple select questions works bad
Description

I could address "other" reponse form multiple select question using (assuming SGQ of thi question is 1X2X3) SGQA identifier 1X2X3other, but the dynamic text wich is displayed then is "no answer" instead of the answer given by the user in the textbox next to "other" response.

TagsNo tags attached.
Bug heat2
Complete LimeSurvey version number (& build)9797
I will donate to the project if issue is resolvedNo
Browser
Database type & versionMysql 5.1
Server OS (if known)Ubuntu server 9.04
Webserver software & version (if known)Apache 2.2.12
PHP Version5.2.10

Relationships

duplicate of 05057 closedlemeur using only "other" subquestion as a dynamic text (through SGQA) doesn't work 

Users monitoring this issue

There are no users monitoring this issue.

Activities

user12634

2011-03-25 22:57

  ~14541

This quick and dirty modyfications of insertansReplace() and retrieve_Answer() functions in common_functions.php let me use only QID instead of SGQ.
The loop through the $_SESSION keys is not a preaty sollution but the number of keys in $_SESSION table seems to be about 40+number_od_questions_given, so it is not a really big overhead to iterate through it.

function insertansReplace($line)
{
if (!isset($_SESSION['dateformats']['phpdate'])) $_SESSION['dateformats']['phpdate']='';
//<-- MATEUSZ 25.03.2011
// dirty patch implementing using only QID for retrieving answers that were already given, eg. {INSERTANS:1234} instead of {INSERTANS:1234X5678X9012}
while (($pos=strpos($line, "{INSERTANS:")) !== false)
{
$len=strpos($line, "}", $pos)-$pos+1;
$answreplace=substr($line, $pos, $len);
$answreplace2=substr($answreplace, 11, -1);
/
$answreplace=substr($line, strpos($line, "{INSERTANS:"), strpos($line, "}", strpos($line, "{INSERTANS:"))-strpos($line, "{INSERTANS:")+1);
$answreplace2=substr($answreplace, 11, strpos($answreplace, "}", strpos($answreplace, "{INSERTANS:"))-11);
/
$answreplace3=strip_tags(retrieve_Answer($answreplace2, $_SESSION['dateformats']['phpdate']));
$line=str_replace($answreplace, $answreplace3, $line);

}
//-->
return $line;

}

function retrieve_Answer($code, $phpdateformat=null)
{
//This function checks to see if there is an answer saved in the survey session
//data that matches the $code. If it does, it returns that data.
//It is used when building a questions text to allow incorporating the answer
//to an earlier question into the text of a later question.
//IE: Q1: What is your name? [Jason]
// Q2: Hi [Jason] how are you ?
//This function is called from the retriveAnswers function.
global $dbprefix, $connect, $clang;
//Find question details
//<-- MATEUSZ 25.03.2011
// dirty patch implementing using only QID for retrieving answers that were already given, eg. {INSERTANS:1234} instead of {INSERTANS:1234X5678X9012}
if (!isset($_SESSION[$code]))
{
foreach(array_keys($_SESSION) as $i)
{
$itmp=explode('X', $i);
if(count($itmp) < 3 ) continue;
$itmp=implode('X', array_slice($itmp, 2));
if($itmp == $code)
{
$code=$i;
break;
}
}
}
//-->
if (isset($_SESSION[$code]))
{
$questiondetails=getsidgidqidaidtype($code);
//the getsidgidqidaidtype function is in common.php and returns
//a SurveyID, GroupID, QuestionID and an Answer code
//extracted from a "fieldname" - ie: 1X2X3a
// also returns question type

    if ($questiondetails['type'] == &quot;M&quot; ||
    $questiondetails['type'] == &quot;P&quot;)
    {
        $query=&quot;SELECT * FROM {$dbprefix}questions WHERE parent_qid='&quot;.$questiondetails['qid'].&quot;' AND language='&quot;.$_SESSION['s_lang'].&quot;'&quot;;
        $result=db_execute_assoc($query) or safe_die(&quot;Error getting answer<br />$query<br />&quot;.$connect->ErrorMsg());  //Checked
        while($row=$result->FetchRow())
        {
            if (isset($_SESSION[$code.$row['title']]) && $_SESSION[$code.$row['title']] == &quot;Y&quot;)
            {
                $returns[] = $row['question'];
            }
            elseif (isset($_SESSION[$code]) && $_SESSION[$code] == &quot;Y&quot; && $questiondetails['aid']==$row['title'])
            {
                return $row['question'];
            }
        }
        if (isset($_SESSION[$code.&quot;other&quot;]) && $_SESSION[$code.&quot;other&quot;])
        {
            $returns[]=$_SESSION[$code.&quot;other&quot;];
        }
        if (isset($returns))
        {
            $return=implode(&quot;, &quot;, $returns);
            if (strpos($return, &quot;,&quot;))
            {
                $return=substr_replace($return, &quot; &&quot;, strrpos($return, &quot;,&quot;), 1);
            }
        }
        else
        {
            $return=$clang->gT(&quot;No answer&quot;);
        }
    }
    elseif (!$_SESSION[$code] && $_SESSION[$code] !=0)
    {
        $return=$clang->gT(&quot;No answer&quot;);
    }
    else
    {
        $return=getextendedanswer($code, $_SESSION[$code], 'INSERTANS',$phpdateformat);
    }
}
else
{
    $return=$clang->gT(&quot;Error&quot;) . &quot;($code)&quot;;
}
return html_escape($return);

}

Issue History

Date Modified Username Field Change
2011-03-25 14:10 user12634 New Issue
2011-03-25 22:57 user12634 Note Added: 14541
2011-03-25 23:54 user12634 Issue Monitored: user12634
2011-03-26 11:55 c_schmitz Relationship added duplicate of 05057
2011-03-26 11:55 c_schmitz Status new => closed
2011-03-26 11:55 c_schmitz Assigned To => c_schmitz
2011-03-26 11:55 c_schmitz Resolution open => duplicate