View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
06139Bug reportsConditionspublic2012-06-07 11:04
ReporterMazi Assigned Toc_schmitz  
PrioritynormalSeveritypartial_block 
Status closedResolutionfixed 
Product Version1.92+ 
Target Version1.92+ 
Summary06139: EM doesn't convert condition correctly, AND becomes OR
Description

When creating a condition using the condition editor like "Show question X IF question Y = Yes AND equestion_question == '0' (constant value)" EM doesn't convbert the condition correctly and shows an OR connector between the two questions. See attached screen shots.

Steps To Reproduce
  1. Have a look at the attached screens.

  2. Import the sample survey for testing

Additional Information

Additional note: All pages having questions which are having a condition based on the equation question (first question of group "Demographics 2") don't show the progress bar correctly. Can you reproduce this?

TagsNo tags attached.
Attached Files
condition editor.PNG (17,489 bytes)   
condition editor.PNG (17,489 bytes)   
em_syntax.PNG (33,429 bytes)   
em_syntax.PNG (33,429 bytes)   
sgqa_conversion_equation.png (13,428 bytes)   
sgqa_conversion_equation.png (13,428 bytes)   
sgqa_admin_interface.png (51,402 bytes)   
sgqa_admin_interface.png (51,402 bytes)   
progres_bar.png (5,464 bytes)   
progres_bar.png (5,464 bytes)   
Bug heat8
Complete LimeSurvey version number (& build)120525
I will donate to the project if issue is resolvedNo
BrowserFirefox 12
Database type & versionMySQL
Server OS (if known)?
Webserver software & version (if known)?
PHP Version?

Users monitoring this issue

TMSWhite

Activities

Mazi

Mazi

2012-05-27 15:33

updater   ~18920

I'm not sure if this is related: When using EMs rand() function to create a random integer number and then applying conditions to it, do i have to use
((equationQuestionCode == "1"))
...or does that compare the rand number with a string value so hat I should better use
((equationQuestionCode == 1))

?!?

TMSWhite

TMSWhite

2012-05-27 15:41

reporter   ~18921

(equationQuestionCode == "1") should be fine (but you can also use the number). Strings that are numbers are automatically cast to numeric.

TMSWhite

TMSWhite

2012-05-27 16:27

reporter   ~18922

Mazi-

When I import this survey, it shows an error for the relevance. The first randnumber.NAOK is shown as the SGQA code (e.g. it isn't recognized on import).

When I manually edit the condition to fix that problem, the generated equation is correct:

((car_owner.NAOK == "A1") and (randnumber.NAOK == "0")) or ((home_owner.NAOK == "A1") and (car_owner.NAOK == "A1") and (randnumber.NAOK == "1"))

So, I can't reproduce this yet.

However, oddly, I do see the problem relevance equation within the .lss file. Perhaps there is also an import problem since the variable is declared within the same group that the condition is used. Although, I haven't seen that problem before either.

Mazi

Mazi

2012-05-28 14:13

updater   ~18939

Hi Tom,

I have tried to reproduce the problem but whatever I tried, it now shows up correctly. I wonder how I managed to get this done so it convert from, maybe it was just my fault.

nevertheless you are right, there is a problem at import. The GSQA value for the question question isn't converted correctly, see attached screenshot.

c_schmitz

c_schmitz

2012-05-28 14:21

administrator   ~18940

The import is working correctly.

There seems to be an error in the source database:

<row>
<cid><![CDATA[763]]></cid>
<qid><![CDATA[3627]]></qid>
<scenario><![CDATA[1]]></scenario>
<cqid><![CDATA[3626]]></cqid>
<cfieldname><![CDATA[19966X84X3633]]></cfieldname>
<method><![CDATA[==]]></method>
<value><![CDATA[0]]></value>
</row>

Note the invalid cfieldname, if should end with 3626. Question is how that happened in the first place? How old is that database, which versions were used to edit it? Why are there duplicate question codes at all? (randnumber?)

c_schmitz

c_schmitz

2012-05-28 14:24

administrator   ~18941

Last edited: 2012-05-28 14:25

You can see the error in the first of Mazis screenshots, too.
'randnumber' has two different question IDs if you look closely.

Since this is so hard to reproduce, I suggest we close this matter until someone finds how how exactly to reproduce it.

Mazi

Mazi

2012-05-28 14:59

updater   ~18942

Carsten, this survey was created on Limeservice (account: http://actions.limequery.com/admin). The database is pretty fresh. There is just one test survey and this one.

Tom/Carsten: Since this is an important survey that should go live soon, do you recommend to delete the equation question and re-create it?
If so, can I leave the conditions? They were not created using the condition editor but using the relevance field and if I use the same question code, should it all work fine?

@Tom, using the attached survey, can you reproduce the error that the progress bar doesn't work correctly on some pages?
I couldn't always reproduce the problem for every page, seems to be related to conditions. I attached another screenshot.

c_schmitz

c_schmitz

2012-05-28 15:02

administrator   ~18943

Last edited: 2012-05-28 15:03

I remember there was an error in the conditions editor a little time ago.
Maybe this is/was an after-effect.
Just dropping and creating the conditions again should do the trick, no need to delete the equation question.

Mazi

Mazi

2012-05-28 15:14

updater   ~18962

Do I have to re-create the conditions at all for technical reason or to be sure that it all works well?

Because I thought that when using question codes and relevance only (no condition editor), there is no reference to any question ID anymore but only the code is used?
If so, there would be no use to re-create all the conditions I would say?!

TMSWhite

TMSWhite

2012-05-28 15:20

reporter   ~18963

Mazi-

To recreate the relevance from conditions, you can either re-import the survey, or use the EM menu tool to convert conditions to relevance for the entire survey. Then check the Show Logic file for any errors. As long as there are no errors, the survey should be fine.

c_schmitz

c_schmitz

2012-05-28 15:20

administrator   ~18964

I mean only the conditions where you are using the conditions editor and that don't work as intended.

Mazi

Mazi

2012-05-28 20:10

updater   ~18976

Tom, one more general question since I'm trying to debug some other odd behavior: if there is a question with some customized JS at the first question of a group at a survey run in group by group mode, when does EM process that JS?

  • Only if there are any conditions at one of those questions?
  • Only if an equation question exists at this group?
  • Always?

Different topic (but I wanted to ask before creating a bug report): Did you notice any odd/different behavior when using the rand() function inside an IF statement which refers to previous questions at an equation question if you run it in group by group or all in one mode?
Should EM be able to check the previous questions in all in one mode and then apply the rand function to generate a random number, or does the equation question need to be placed on a following page?

TMSWhite

TMSWhite

2012-05-28 20:32

reporter   ~18977

Mazi-

Custom JS will probably run regardless of when EM does it processing. EM gets called (via checkconditions) at load time, and then every time a value is changed. When custom JS gets called depends on when it gets loaded relative to document.ready(). I'm not an expert on that stuff. So, I recommend you pick some sample use cases and use FireBug to step through the code and see when the custom JS is called. Bottom line is that EM doesn't try to encapsulate custom JS to prevent it from being called except for situations where the question is relevant.

I didn't try your custom rand() functions. However, if they are part of relevance or EM in general, rand() will be called multiple times, which often isn't what you want. So, see this example, which ensures that rand() is only called once. http://docs.limesurvey.org/Expression+Manager+Sample+Surveys#Randomly_Ask_One_Question_Per_Group

/Tom

Issue History

Date Modified Username Field Change
2012-05-27 15:21 Mazi New Issue
2012-05-27 15:21 Mazi Status new => assigned
2012-05-27 15:21 Mazi Assigned To => c_schmitz
2012-05-27 15:21 Mazi File Added: limesurvey_survey_19966 - EM condition conversion bug.lss
2012-05-27 15:21 Mazi File Added: condition editor.PNG
2012-05-27 15:21 Mazi File Added: em_syntax.PNG
2012-05-27 15:31 Mazi Issue Monitored: Mazi
2012-05-27 15:31 Mazi Issue End Monitor: Mazi
2012-05-27 15:31 Mazi Issue Monitored: TMSWhite
2012-05-27 15:33 Mazi Note Added: 18920
2012-05-27 15:41 TMSWhite Note Added: 18921
2012-05-27 16:27 TMSWhite Note Added: 18922
2012-05-28 14:13 Mazi Note Added: 18939
2012-05-28 14:13 Mazi File Added: sgqa_conversion_equation.png
2012-05-28 14:14 Mazi File Added: sgqa_admin_interface.png
2012-05-28 14:21 c_schmitz Note Added: 18940
2012-05-28 14:21 c_schmitz Status assigned => feedback
2012-05-28 14:24 c_schmitz Note Added: 18941
2012-05-28 14:25 c_schmitz Note Edited: 18941
2012-05-28 14:59 Mazi Note Added: 18942
2012-05-28 14:59 Mazi Status feedback => assigned
2012-05-28 14:59 Mazi File Added: progres_bar.png
2012-05-28 15:02 c_schmitz Note Added: 18943
2012-05-28 15:03 c_schmitz Note Edited: 18943
2012-05-28 15:10 c_schmitz Status assigned => closed
2012-05-28 15:10 c_schmitz Resolution open => unable to reproduce
2012-05-28 15:12 Mazi Status closed => feedback
2012-05-28 15:12 Mazi Resolution unable to reproduce => reopened
2012-05-28 15:14 Mazi Note Added: 18962
2012-05-28 15:14 Mazi Status feedback => assigned
2012-05-28 15:14 Mazi Status assigned => resolved
2012-05-28 15:14 Mazi Resolution reopened => fixed
2012-05-28 15:20 TMSWhite Note Added: 18963
2012-05-28 15:20 c_schmitz Note Added: 18964
2012-05-28 20:10 Mazi Note Added: 18976
2012-05-28 20:32 TMSWhite Note Added: 18977
2012-06-07 11:04 c_schmitz Status resolved => closed