View Issue Details

This bug affects 1 person(s).
 2
IDProjectCategoryView StatusLast Update
04295Bug reportsOtherpublic2010-05-05 10:28
Reporterjooghe Assigned Tomdekker  
PrioritynormalSeverityminor 
Status closedResolutionfixed 
Product Version1.87+ 
Target Version1.90bFixed in Version1.90b 
Summary04295: SPSS export of labels for dual scale questions is incorrect
Description

Hi,

We are writing a module to export survey results to SAS (statistical analysis software). We're using the same logic as the SPSS export and re-using SPSS code.
While doing this we found an error in the Export of SPSS. Our production environment is 1.85+, but I could reproduce it in 1.87.

The problem is the dual scale question (LSTYPE=1). For this question type you must give 2 answers for 1 question. These answers are selected from 2 different labelsets. When exporting such a question to SPSS you see that there correctly 2 variables created, but only 1 labelset is used to retrieve the answer codes. Only lableset LID is selected, the second labelset in the question definition is (LID1) is not used for the second answer.

I think it can be solved by a minor change in export_data_functions.php. In the function spss_getvalues around line 190 there is the contion :

} elseif (strpos("FWZWH1",$field['LStype']) !== false) {

I think this is best change to :
} elseif (strpos("FWZWH",$field['LStype']) !== false) {
so not including LSTYPE=1
then a new test can be done for LSTYPE=1 and then retrieving LID for the first answer of the dual-scale question and retrieving LID1 for the second answer. This could be something like :

} elseif (strpos("1",$field['LStype']) !== false) {
    if ($field["code"] == "1#0"){

//build query for LID
$query = "SELECT {$dbprefix}questions.lid, {$dbprefix}labels.code, {$dbprefix}labels.title from
{$dbprefix}questions, {$dbprefix}labels WHERE {$dbprefix}labels.language='".$language."' and
{$dbprefix}questions.language='".$language."' and
{$dbprefix}questions.qid ='".$field["qid"]."' and {$dbprefix}questions.lid={$dbprefix}labels.lid ORDER BY sortorder ASC";
} elseif ($field["code"] == "1#1"){
//build query for LID1
$query = "SELECT {$dbprefix}questions.lid1, {$dbprefix}labels.code, {$dbprefix}labels.title from
{$dbprefix}questions, {$dbprefix}labels WHERE {$dbprefix}labels.language='".$language."' and
{$dbprefix}questions.language='".$language."' and
{$dbprefix}questions.qid ='".$field["qid"]."' and {$dbprefix}questions.lid1={$dbprefix}labels.lid ORDER BY sortorder ASC";
}
$result=db_execute_assoc($query) or safe_die("Couldn't get labels<br />$query<br />".$connect->ErrorMsg()); //Checked
$num_results = $result->RecordCount();
if ($num_results > 0)
{
for ($i=0; $i < $num_results; $i++)
{
$row = $result->FetchRow();
$answers[] = array('code'=>$row['code'], 'value'=>strip_tags_full(mb_substr($row["title"],0,$length_vallabel)));
}
}

I hope this makes sense. Please give some feedback if this is the good way to solve the problem.

Cheers,
Jan.

Steps To Reproduce

Create a survey with only 1 group and 1 dual-scale question.
use 2 different labelsets in the question definition.
Activate the survey.
Fill out the survey 1 time.
View the responses.
Export the results to SPSS.
Check the SPSS syntax that is generated, yous see that for both question variable, the same labelset is used.

TagsNo tags attached.
Bug heat2
Complete LimeSurvey version number (& build)1.87
I will donate to the project if issue is resolved
Browser
Database type & versionMYSQL
Server OS (if known)Linux
Webserver software & version (if known)Apache
PHP Version4.

Users monitoring this issue

There are no users monitoring this issue.

Activities

mdekker

mdekker

2010-04-28 10:05

reporter   ~11668

Thanks for the report! Will be fixed in the new 1.90 release which will go beta in the coming weeks. As a lot has changed on the labelsets, please test the beta when released.

Also take a look at http://quanti.hypotheses.org/348/ they have a macro to convert spss export to sas export. Not really sure if it works, but it could be a good start.

mdekker

mdekker

2010-04-28 10:07

reporter   ~11669

Committed a fix in svn 8645

Issue History

Date Modified Username Field Change
2010-04-26 00:43 jooghe New Issue
2010-04-26 15:43 user372 Assigned To => mdekker
2010-04-26 15:43 user372 Status new => assigned
2010-04-28 10:02 mdekker Fixed in Version => 1.90b
2010-04-28 10:02 mdekker Target Version => 1.90b
2010-04-28 10:05 mdekker Note Added: 11668
2010-04-28 10:07 mdekker Note Added: 11669
2010-04-28 10:07 mdekker Status assigned => resolved
2010-04-28 10:07 mdekker Resolution open => fixed
2010-05-05 10:28 c_schmitz Status resolved => closed
2010-05-06 10:27 c_schmitz Category Import / Export => (No Category)