View Issue Details

This bug affects 1 person(s).
 8
IDProjectCategoryView StatusLast Update
08718Bug reportsSurvey editingpublic2014-02-16 18:32
Reporteradamzammit Assigned Toc_schmitz  
PrioritynormalSeveritypartial_block 
Status closedResolutionfixed 
Product Version2.05+ 
Fixed in Version2.05+ 
Summary08718: Adding subquestions to multilingual survey causes database inconsistency
Description

In a survey that is already multilingual, it appears that adding subquestions creates a unique qid (instead of a unique qid,language pair). For example, adding subquestions where 4 languages are selected creates the following in the database:

qid,lang,parent_qid
2,lang1,1
3,lang2,1
4,lang3,1
5,lang4,1

Instead of:

qid,lang,parent_qid
2,lang1,1
2,lang2,1
2,lang3,1
2,lang4,1

As expected. This then causes problems when deleting a subquestion as the code for deleting a subquestion deletes by qid, expecting them all languages to contain the same qid. The database then becomes inconsistent with stray subquestions for other languages besides the main one deleted.

I think the code for adding subquestions where multiple languages exist needs to be updated to make sure the qid is the same.

Steps To Reproduce
  1. Create a survey with multiple languages
  2. Create a question that has subquestions (i.e. multiple numeric)
  3. Add subquestions and save
  4. Delete a subquestion and save
TagsNo tags attached.
Attached Files
fix8718.patch (707 bytes)   
--- /tmp/limesurvey/application/controllers/admin/database.php	2014-02-12 21:15:20.000000000 +1100
+++ application/controllers/admin/database.php	2014-02-14 14:08:51.000000000 +1100
@@ -288,6 +288,7 @@
                                 if(!$oSubQuestion)
                                     $oSubQuestion=new Question;
                                 $oSubQuestion->sid=$iSurveyID;
+                                $oSubQuestion->qid = $aInsertQID[$iScaleID][$iPosition];
                                 $oSubQuestion->gid=$iQuestionGroupID;
                                 $oSubQuestion->question_order=$iPosition+1;
                                 $oSubQuestion->title=$aCodes[$iScaleID][$iPosition];
fix8718.patch (707 bytes)   
Bug heat8
Complete LimeSurvey version number (& build)140212
I will donate to the project if issue is resolvedNo
BrowserFirefox
Database type & versionMySQL 5.5.35
Server OS (if known)Ubuntu 12.04
Webserver software & version (if known)Apache 2
PHP Version5.3.10

Users monitoring this issue

adamzammit, mfaber

Activities

c_schmitz

c_schmitz

2014-02-14 00:56

administrator   ~28728

Adam, are you sure that this issue still exists in the current build? This was already resolved a couple weeks ago. Maybe it is a remain of a previous version?

adamzammit

adamzammit

2014-02-14 01:04

developer   ~28730

Hi Carsten,

I just double checked by clearing browser cache, and checked via a directory diff with the download of build 140212 so there isn't any remnants of a previous version. Problem persists. Can you point me to the fix and I'll check if it is applied?

Adam

c_schmitz

c_schmitz

2014-02-14 01:07

administrator   ~28731

Have a look at https://github.com/LimeSurvey/LimeSurvey/commit/390642a2e168754f776cf4720418230f5859a5ae

c_schmitz

c_schmitz

2014-02-14 01:08

administrator   ~28732

Please check with a clean newly created survey.

adamzammit

adamzammit

2014-02-14 01:21

developer   ~28733

With a newly created survey the same issue occurs.

I notice for the first subquestion added, the qid stays the same for all languages, but for the second and subsequent subquestions, the qid becomes sequential and unique for each.

adamzammit

adamzammit

2014-02-14 04:17

developer   ~28734

Hi Carsten,

The fix you referred to appears to be for a separate issue.

I have attached a patch which fixes the problem for me. I didn't commit it as I would prefer someone else confirms the issue for them before proceeding to patch the mainline.

Adam

c_schmitz

c_schmitz

2014-02-14 13:20

administrator   ~28738

Thank you very much - looks great!

c_schmitz

c_schmitz

2014-02-14 13:21

administrator   ~28739

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=13889

c_schmitz

c_schmitz

2014-02-16 18:32

administrator   ~28773

2.05+ Build 140216 released

Related Changesets

LimeSurvey: master 691e3cd8

2014-02-14 12:20:25

c_schmitz

Details Diff
Fixed 08718: Adding subquestions to multilingual survey causes database inconsistency - patch by Adam Zammit Affected Issues
08718
mod - application/controllers/admin/database.php Diff File

Issue History

Date Modified Username Field Change
2014-02-14 00:53 adamzammit New Issue
2014-02-14 00:56 c_schmitz Note Added: 28728
2014-02-14 00:56 c_schmitz Assigned To => c_schmitz
2014-02-14 00:56 c_schmitz Status new => feedback
2014-02-14 01:04 adamzammit Note Added: 28730
2014-02-14 01:04 adamzammit Status feedback => assigned
2014-02-14 01:07 c_schmitz Note Added: 28731
2014-02-14 01:08 c_schmitz Note Added: 28732
2014-02-14 01:18 c_schmitz Status assigned => feedback
2014-02-14 01:21 adamzammit Note Added: 28733
2014-02-14 01:21 adamzammit Status feedback => assigned
2014-02-14 04:15 adamzammit File Added: fix8718.patch
2014-02-14 04:17 adamzammit Note Added: 28734
2014-02-14 04:17 adamzammit Status assigned => feedback
2014-02-14 05:16 adamzammit Issue Monitored: adamzammit
2014-02-14 12:46 mfaber Issue Monitored: mfaber
2014-02-14 13:20 c_schmitz Note Added: 28738
2014-02-14 13:20 c_schmitz Status feedback => resolved
2014-02-14 13:20 c_schmitz Fixed in Version => 2.05+
2014-02-14 13:20 c_schmitz Resolution open => fixed
2014-02-14 13:21 c_schmitz Changeset attached => LimeSurvey master 691e3cd8
2014-02-14 13:21 c_schmitz Note Added: 28739
2014-02-16 18:32 c_schmitz Note Added: 28773
2014-02-16 18:32 c_schmitz Status resolved => closed
2019-11-01 17:25 c_schmitz Category Survey design => Survey editing
2021-08-02 20:20 guest Bug heat 4 => 8