View Issue Details

This bug affects 1 person(s).
 4
IDProjectCategoryView StatusLast Update
07061Bug reportsExpression Managerpublic2012-12-11 11:02
Reporterfrederickjayne Assigned Tosammousa  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Fixed in Version2.00+ 
Summary07061: expression not resolving correctly in javascript
Description

I am trying to use the Qcode.qid field to pass the qid as part of the selector in a call to the jquery autocomplete fn, If you look at the attached small survey, you will see that the case of one text entry field works flawlessly. However, this approach fails for the multiple text entry case. There, if the qid is entered as a constant (as in the commented out section of that script code), everything works.

I need to be able to export and reimport surveys with this functionality intact. The use of the Qcode.qid field would be a perfect solution as I wouldn't need to worry about LS resetting the IDs upon import. It works beautifully in the single text entry case; would love to see it work with the multiple entry case as well.

TagsNo tags attached.
Attached Files
limesurvey_survey_465199.lss (18,215 bytes)   
<?xml version="1.0" encoding="UTF-8"?>
<document>
 <LimeSurveyDocType>Survey</LimeSurveyDocType>
 <DBVersion>164</DBVersion>
 <languages>
  <language>en</language>
 </languages>
 <groups>
  <fields>
   <fieldname>gid</fieldname>
   <fieldname>sid</fieldname>
   <fieldname>group_name</fieldname>
   <fieldname>group_order</fieldname>
   <fieldname>description</fieldname>
   <fieldname>language</fieldname>
   <fieldname>randomization_group</fieldname>
   <fieldname>grelevance</fieldname>
  </fields>
  <rows>
   <row>
    <gid><![CDATA[2]]></gid>
    <sid><![CDATA[465199]]></sid>
    <group_name><![CDATA[test questions]]></group_name>
    <group_order><![CDATA[0]]></group_order>
    <description/>
    <language><![CDATA[en]]></language>
    <randomization_group/>
    <grelevance/>
   </row>
  </rows>
 </groups>
 <questions>
  <fields>
   <fieldname>qid</fieldname>
   <fieldname>parent_qid</fieldname>
   <fieldname>sid</fieldname>
   <fieldname>gid</fieldname>
   <fieldname>type</fieldname>
   <fieldname>title</fieldname>
   <fieldname>question</fieldname>
   <fieldname>preg</fieldname>
   <fieldname>help</fieldname>
   <fieldname>other</fieldname>
   <fieldname>mandatory</fieldname>
   <fieldname>question_order</fieldname>
   <fieldname>language</fieldname>
   <fieldname>scale_id</fieldname>
   <fieldname>same_default</fieldname>
   <fieldname>relevance</fieldname>
  </fields>
  <rows>
   <row>
    <qid><![CDATA[7]]></qid>
    <parent_qid><![CDATA[0]]></parent_qid>
    <sid><![CDATA[465199]]></sid>
    <gid><![CDATA[2]]></gid>
    <type><![CDATA[Q]]></type>
    <title><![CDATA[potus]]></title>
    <question><![CDATA[Who were the last three presidents? {potus.qid} {QID}<script type="text/javascript" charset="utf-8">

    $(document).ready(function() {
							   
        var choices = "Barack Obama,George W. Bush,Bill Clinton,Thomas Jefferson,Ronald Reagan,Richard Nixon".split(',');
		
/*        $('#question'+{potus.qid}+' input.text').autocomplete({
                source: choices
        }); */

        $('#question929 input.text').autocomplete({
                source: choices
        });
	
    });
</script>]]></question>
    <preg/>
    <help><![CDATA[<br />
]]></help>
    <other><![CDATA[N]]></other>
    <mandatory><![CDATA[N]]></mandatory>
    <question_order><![CDATA[2]]></question_order>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
    <same_default><![CDATA[0]]></same_default>
    <relevance><![CDATA[1]]></relevance>
   </row>
  </rows>
 </questions>
 <subquestions>
  <fields>
   <fieldname>qid</fieldname>
   <fieldname>parent_qid</fieldname>
   <fieldname>sid</fieldname>
   <fieldname>gid</fieldname>
   <fieldname>type</fieldname>
   <fieldname>title</fieldname>
   <fieldname>question</fieldname>
   <fieldname>preg</fieldname>
   <fieldname>help</fieldname>
   <fieldname>other</fieldname>
   <fieldname>mandatory</fieldname>
   <fieldname>question_order</fieldname>
   <fieldname>language</fieldname>
   <fieldname>scale_id</fieldname>
   <fieldname>same_default</fieldname>
   <fieldname>relevance</fieldname>
  </fields>
  <rows>
   <row>
    <qid><![CDATA[8]]></qid>
    <parent_qid><![CDATA[7]]></parent_qid>
    <sid><![CDATA[465199]]></sid>
    <gid><![CDATA[2]]></gid>
    <type><![CDATA[T]]></type>
    <title><![CDATA[curr]]></title>
    <question><![CDATA[Current:]]></question>
    <preg/>
    <help/>
    <other><![CDATA[N]]></other>
    <mandatory><![CDATA[N]]></mandatory>
    <question_order><![CDATA[1]]></question_order>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
    <same_default><![CDATA[0]]></same_default>
    <relevance/>
   </row>
   <row>
    <qid><![CDATA[9]]></qid>
    <parent_qid><![CDATA[7]]></parent_qid>
    <sid><![CDATA[465199]]></sid>
    <gid><![CDATA[2]]></gid>
    <type><![CDATA[T]]></type>
    <title><![CDATA[prev]]></title>
    <question><![CDATA[Previous:]]></question>
    <preg/>
    <help/>
    <other><![CDATA[N]]></other>
    <mandatory><![CDATA[N]]></mandatory>
    <question_order><![CDATA[3]]></question_order>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
    <same_default><![CDATA[0]]></same_default>
    <relevance/>
   </row>
   <row>
    <qid><![CDATA[10]]></qid>
    <parent_qid><![CDATA[7]]></parent_qid>
    <sid><![CDATA[465199]]></sid>
    <gid><![CDATA[2]]></gid>
    <type><![CDATA[T]]></type>
    <title><![CDATA[earlier]]></title>
    <question><![CDATA[One before that:]]></question>
    <preg/>
    <help/>
    <other><![CDATA[N]]></other>
    <mandatory><![CDATA[N]]></mandatory>
    <question_order><![CDATA[4]]></question_order>
    <language><![CDATA[en]]></language>
    <scale_id><![CDATA[0]]></scale_id>
    <same_default><![CDATA[0]]></same_default>
    <relevance/>
   </row>
  </rows>
 </subquestions>
 <question_attributes>
  <fields>
   <fieldname>qid</fieldname>
   <fieldname>attribute</fieldname>
   <fieldname>value</fieldname>
   <fieldname>language</fieldname>
  </fields>
  <rows>
   <row>
    <qid><![CDATA[7]]></qid>
    <attribute><![CDATA[text_input_width]]></attribute>
    <value><![CDATA[30]]></value>
   </row>
  </rows>
 </question_attributes>
 <surveys>
  <fields>
   <fieldname>sid</fieldname>
   <fieldname>admin</fieldname>
   <fieldname>expires</fieldname>
   <fieldname>startdate</fieldname>
   <fieldname>adminemail</fieldname>
   <fieldname>anonymized</fieldname>
   <fieldname>faxto</fieldname>
   <fieldname>format</fieldname>
   <fieldname>savetimings</fieldname>
   <fieldname>template</fieldname>
   <fieldname>language</fieldname>
   <fieldname>additional_languages</fieldname>
   <fieldname>datestamp</fieldname>
   <fieldname>usecookie</fieldname>
   <fieldname>allowregister</fieldname>
   <fieldname>allowsave</fieldname>
   <fieldname>autonumber_start</fieldname>
   <fieldname>autoredirect</fieldname>
   <fieldname>allowprev</fieldname>
   <fieldname>printanswers</fieldname>
   <fieldname>ipaddr</fieldname>
   <fieldname>refurl</fieldname>
   <fieldname>publicstatistics</fieldname>
   <fieldname>publicgraphs</fieldname>
   <fieldname>listpublic</fieldname>
   <fieldname>htmlemail</fieldname>
   <fieldname>sendconfirmation</fieldname>
   <fieldname>tokenanswerspersistence</fieldname>
   <fieldname>assessments</fieldname>
   <fieldname>usecaptcha</fieldname>
   <fieldname>usetokens</fieldname>
   <fieldname>bounce_email</fieldname>
   <fieldname>attributedescriptions</fieldname>
   <fieldname>emailresponseto</fieldname>
   <fieldname>emailnotificationto</fieldname>
   <fieldname>tokenlength</fieldname>
   <fieldname>showxquestions</fieldname>
   <fieldname>showgroupinfo</fieldname>
   <fieldname>shownoanswer</fieldname>
   <fieldname>showqnumcode</fieldname>
   <fieldname>bouncetime</fieldname>
   <fieldname>bounceprocessing</fieldname>
   <fieldname>bounceaccounttype</fieldname>
   <fieldname>bounceaccounthost</fieldname>
   <fieldname>bounceaccountpass</fieldname>
   <fieldname>bounceaccountencryption</fieldname>
   <fieldname>bounceaccountuser</fieldname>
   <fieldname>showwelcome</fieldname>
   <fieldname>showprogress</fieldname>
   <fieldname>allowjumps</fieldname>
   <fieldname>navigationdelay</fieldname>
   <fieldname>nokeyboard</fieldname>
   <fieldname>alloweditaftercompletion</fieldname>
   <fieldname>googleanalyticsstyle</fieldname>
   <fieldname>googleanalyticsapikey</fieldname>
  </fields>
  <rows>
   <row>
    <sid><![CDATA[465199]]></sid>
    <admin><![CDATA[Wizard]]></admin>
    <adminemail><![CDATA[wizard@frederickjayne.com]]></adminemail>
    <anonymized><![CDATA[N]]></anonymized>
    <faxto/>
    <format><![CDATA[A]]></format>
    <savetimings><![CDATA[N]]></savetimings>
    <template><![CDATA[default]]></template>
    <language><![CDATA[en]]></language>
    <additional_languages/>
    <datestamp><![CDATA[N]]></datestamp>
    <usecookie><![CDATA[N]]></usecookie>
    <allowregister><![CDATA[N]]></allowregister>
    <allowsave><![CDATA[Y]]></allowsave>
    <autonumber_start><![CDATA[9]]></autonumber_start>
    <autoredirect><![CDATA[N]]></autoredirect>
    <allowprev><![CDATA[N]]></allowprev>
    <printanswers><![CDATA[N]]></printanswers>
    <ipaddr><![CDATA[N]]></ipaddr>
    <refurl><![CDATA[N]]></refurl>
    <publicstatistics><![CDATA[N]]></publicstatistics>
    <publicgraphs><![CDATA[N]]></publicgraphs>
    <listpublic><![CDATA[N]]></listpublic>
    <htmlemail><![CDATA[Y]]></htmlemail>
    <sendconfirmation><![CDATA[Y]]></sendconfirmation>
    <tokenanswerspersistence><![CDATA[Y]]></tokenanswerspersistence>
    <assessments><![CDATA[N]]></assessments>
    <usecaptcha><![CDATA[D]]></usecaptcha>
    <usetokens><![CDATA[N]]></usetokens>
    <bounce_email><![CDATA[wizard@frederickjayne.com]]></bounce_email>
    <attributedescriptions><![CDATA[a:0:{}]]></attributedescriptions>
    <emailresponseto/>
    <emailnotificationto/>
    <tokenlength><![CDATA[15]]></tokenlength>
    <showxquestions><![CDATA[Y]]></showxquestions>
    <showgroupinfo><![CDATA[B]]></showgroupinfo>
    <shownoanswer><![CDATA[Y]]></shownoanswer>
    <showqnumcode><![CDATA[X]]></showqnumcode>
    <bounceprocessing><![CDATA[N]]></bounceprocessing>
    <bounceaccounttype/>
    <bounceaccounthost/>
    <bounceaccountpass/>
    <bounceaccountencryption/>
    <bounceaccountuser/>
    <showwelcome><![CDATA[N]]></showwelcome>
    <showprogress><![CDATA[Y]]></showprogress>
    <allowjumps><![CDATA[N]]></allowjumps>
    <navigationdelay><![CDATA[0]]></navigationdelay>
    <nokeyboard><![CDATA[N]]></nokeyboard>
    <alloweditaftercompletion><![CDATA[N]]></alloweditaftercompletion>
    <googleanalyticsstyle><![CDATA[0]]></googleanalyticsstyle>
    <googleanalyticsapikey/>
   </row>
  </rows>
 </surveys>
 <surveys_languagesettings>
  <fields>
   <fieldname>surveyls_survey_id</fieldname>
   <fieldname>surveyls_language</fieldname>
   <fieldname>surveyls_title</fieldname>
   <fieldname>surveyls_description</fieldname>
   <fieldname>surveyls_welcometext</fieldname>
   <fieldname>surveyls_endtext</fieldname>
   <fieldname>surveyls_url</fieldname>
   <fieldname>surveyls_urldescription</fieldname>
   <fieldname>surveyls_email_invite_subj</fieldname>
   <fieldname>surveyls_email_invite</fieldname>
   <fieldname>surveyls_email_remind_subj</fieldname>
   <fieldname>surveyls_email_remind</fieldname>
   <fieldname>surveyls_email_register_subj</fieldname>
   <fieldname>surveyls_email_register</fieldname>
   <fieldname>surveyls_email_confirm_subj</fieldname>
   <fieldname>surveyls_email_confirm</fieldname>
   <fieldname>surveyls_dateformat</fieldname>
   <fieldname>surveyls_attributecaptions</fieldname>
   <fieldname>email_admin_notification_subj</fieldname>
   <fieldname>email_admin_notification</fieldname>
   <fieldname>email_admin_responses_subj</fieldname>
   <fieldname>email_admin_responses</fieldname>
   <fieldname>surveyls_numberformat</fieldname>
  </fields>
  <rows>
   <row>
    <surveyls_survey_id><![CDATA[465199]]></surveyls_survey_id>
    <surveyls_language><![CDATA[en]]></surveyls_language>
    <surveyls_title><![CDATA[Autocomplete test]]></surveyls_title>
    <surveyls_description><![CDATA[This is a test of the Limesurvey system for our needs.]]></surveyls_description>
    <surveyls_welcometext/>
    <surveyls_endtext><![CDATA[Thanks, sucka!]]></surveyls_endtext>
    <surveyls_url><![CDATA[http://www.frederickjayne.com/]]></surveyls_url>
    <surveyls_urldescription/>
    <surveyls_email_invite_subj><![CDATA[Invitation to participate in a Frederick Jayne questionnaire]]></surveyls_email_invite_subj>
    <surveyls_email_invite><![CDATA[<html><head><title></title></head><body>Dear {FIRSTNAME},<br />
<br />
You have been invited to participate in a questionnaire to discover whether you have a brain.<br />
<br />
The questionnaire is titled:<br />
&quot;{SURVEYNAME}&quot;<br />
<br />
&quot;{SURVEYDESCRIPTION}&quot;<br />
<br />
To participate, please click on the link below.<br />
<br />
Sincerely,<br />
<br />
{ADMINNAME} ({ADMINEMAIL})<br />
<br />
----------------------------------------------<br />
Click here to do the survey:<br />
{SURVEYURL}<br />
</body></html>]]></surveyls_email_invite>
    <surveyls_email_remind_subj><![CDATA[Reminder to participate in a survey]]></surveyls_email_remind_subj>
    <surveyls_email_remind><![CDATA[<html><head><title></title></head><body>Dear {FIRSTNAME},<br />
<br />
Recently we invited you to participate in a survey.<br />
<br />
We note that you have not yet completed the survey, and wish to remind you that the survey is still available should you wish to take part.<br />
<br />
The survey is titled:<br />
&quot;{SURVEYNAME}&quot;<br />
<br />
&quot;{SURVEYDESCRIPTION}&quot;<br />
<br />
To participate, please click on the link below.<br />
<br />
Sincerely,<br />
<br />
{ADMINNAME} ({ADMINEMAIL})<br />
<br />
----------------------------------------------<br />
Click here to do the survey:<br />
{SURVEYURL}<br />
<br />
If you do not want to participate in this survey and don&#39;t want to receive any more invitations please click the following link:<br />
{OPTOUTURL}</body></html>]]></surveyls_email_remind>
    <surveyls_email_register_subj><![CDATA[Survey registration confirmation]]></surveyls_email_register_subj>
    <surveyls_email_register><![CDATA[<html><head><title></title></head><body>Dear {FIRSTNAME},<br />
<br />
You, or someone using your email address, have registered to participate in an online survey titled {SURVEYNAME}.<br />
<br />
To complete this survey, click on the following URL:<br />
<br />
{SURVEYURL}<br />
<br />
If you have any questions about this survey, or if you did not register to participate and believe this email is in error, please contact {ADMINNAME} at {ADMINEMAIL}.</body></html>]]></surveyls_email_register>
    <surveyls_email_confirm_subj><![CDATA[Confirmation of your participation in our questionnaire]]></surveyls_email_confirm_subj>
    <surveyls_email_confirm><![CDATA[<html><head><title></title></head><body>
<p>Dear {FIRSTNAME},<br />
<br />
This email is to confirm that you have completed the questionnaire titled {SURVEYNAME} and your response has been saved. Thank you for participating. Since you were able to complete the questionnaire, you indeed must have a brain.<br />
<br />
If you have any further questions about this email, please contact {ADMINEMAIL}.<br />
<br />
Sincerely,
</p>
<p>The Wizard of Frederick Jayne
</p>
</body></html>]]></surveyls_email_confirm>
    <surveyls_dateformat><![CDATA[6]]></surveyls_dateformat>
    <surveyls_attributecaptions><![CDATA[a:0:{}]]></surveyls_attributecaptions>
    <email_admin_notification_subj><![CDATA[Response submission for survey {SURVEYNAME}]]></email_admin_notification_subj>
    <email_admin_notification><![CDATA[<html><head><title></title></head><body>Hello,<br />
<br />
A new response was submitted for your survey &#39;{SURVEYNAME}&#39;.<br />
<br />
Click the following link to reload the survey:<br />
{RELOADURL}<br />
<br />
Click the following link to see the individual response:<br />
{VIEWRESPONSEURL}<br />
<br />
Click the following link to edit the individual response:<br />
{EDITRESPONSEURL}<br />
<br />
View statistics by clicking here:<br />
{STATISTICSURL}</body></html>]]></email_admin_notification>
    <email_admin_responses_subj><![CDATA[Response submission for survey {SURVEYNAME} with results]]></email_admin_responses_subj>
    <email_admin_responses><![CDATA[<html><head><title></title></head><body><style type="text/css">.printouttable {
                                                  margin:1em auto;
                                                }
                                                .printouttable th {
                                                  text-align: center;
                                                }
                                                .printouttable td {
                                                  border-color: #ddf #ddf #ddf #ddf;
                                                  border-style: solid;
                                                  border-width: 1px;
                                                  padding:0.1em 1em 0.1em 0.5em;
                                                }

                                                .printouttable td:first-child {
                                                  font-weight: 700;
                                                  text-align: right;
                                                  padding-right: 5px;
                                                  padding-left: 5px;

                                                }
                                                .printouttable .printanswersquestion td{
                                                  background-color:#F7F8FF;
                                                }

                                                .printouttable .printanswersquestionhead td{
                                                  text-align: left;
                                                  background-color:#ddf;
                                                }

                                                .printouttable .printanswersgroup td{
                                                  text-align: center;        
                                                  font-weight:bold;
                                                  padding-top:1em;
                                                }</style>Hello,<br />
<br />
A new response was submitted for your survey &#39;{SURVEYNAME}&#39;.<br />
<br />
Click the following link to reload the survey:<br />
{RELOADURL}<br />
<br />
Click the following link to see the individual response:<br />
{VIEWRESPONSEURL}<br />
<br />
Click the following link to edit the individual response:<br />
{EDITRESPONSEURL}<br />
<br />
View statistics by clicking here:<br />
{STATISTICSURL}<br />
<br />
<br />
The following answers were given by the participant:<br />
{ANSWERTABLE}</body></html>]]></email_admin_responses>
    <surveyls_numberformat><![CDATA[0]]></surveyls_numberformat>
   </row>
  </rows>
 </surveys_languagesettings>
</document>
limesurvey_survey_465199.lss (18,215 bytes)   
Bug heat4
Complete LimeSurvey version number (& build)120919
I will donate to the project if issue is resolvedYes
BrowserFirefox, Chrome
Database type & versionmysql, 5.5.28
Server OS (if known)unix
Webserver software & version (if known)Apache, version ?
PHP Version3.4.11.1

Users monitoring this issue

There are no users monitoring this issue.

Activities

c_schmitz

c_schmitz

2012-12-11 09:53

administrator   ~23104

As a workaround you can use {QID} but you are right. Qcode.qid should work, too.
I attached an even more simple example to reproduce.

sammousa

sammousa

2012-12-11 10:51

reporter   ~23109

Try using self.qid or that.qcode.qid.

Basically a question with subquestions has several valid variables (one for each subquestion) but the question code for the "main" question itself is not one of them.

For MST question Q1 with subquestions sq1 and sq2 the valid codes are Q1_sq1 and Q1_sq2. No matter if the suffix, .qid, yields the same results the variable Q1 simply doesnt exist.

sammousa

sammousa

2012-12-11 11:02

reporter   ~23110

Try using self.qid or that.qcode.qid.

Basically a question with subquestions has several valid variables (one for each subquestion) but the question code for the "main" question itself is not one of them.

For MST question Q1 with subquestions sq1 and sq2 the valid codes are Q1_sq1 and Q1_sq2. No matter if the suffix, .qid, yields the same results the variable Q1 simply doesnt exist.

Issue History

Date Modified Username Field Change
2012-12-11 04:37 frederickjayne New Issue
2012-12-11 04:37 frederickjayne File Added: limesurvey_survey_65729.lss
2012-12-11 09:52 c_schmitz File Added: limesurvey_survey_465199.lss
2012-12-11 09:53 c_schmitz Note Added: 23104
2012-12-11 09:57 c_schmitz Assigned To => sammousa
2012-12-11 09:57 c_schmitz Status new => assigned
2012-12-11 10:51 sammousa Note Added: 23109
2012-12-11 11:02 sammousa Note Added: 23110
2012-12-11 11:02 sammousa Status assigned => closed
2012-12-11 11:02 sammousa Resolution open => fixed
2012-12-11 11:02 sammousa Fixed in Version => 2.00+