Copy Survey Not Working - Question Codes

More
2 years 10 months ago - 2 years 10 months ago #111980 by Mike1985_2
Mike1985_2 created the topic: Copy Survey Not Working - Question Codes
Hi,

I'm having a problem understanding the way LimeSurvey handles copying of surveys/groups/questions.

I have tried to copy an entire survey (having the same issue with importing as well). Although the copy is technically successful, all my subquestions from array type questions have not copied over.

So, as a different approach, I tried to import just a question (an array type with subquestions) on it's own from one survey to another and I get the following error message;
LimeSurvey
Error
 
The question could not be imported for the following reasons:
 
Question codes must be unique.

Why can't the codes be made unique for me? Do I have to do something differently to get it to work?

Can I turn debugging on and see the SQL query that is being submitted for this?
Attachments:
Last Edit: 2 years 10 months ago by Mike1985_2. Reason: Added another question

Please Log in to join the conversation.

More
2 years 10 months ago #111990 by holch
holch replied the topic: Copy Survey Not Working - Question Codes
Never had a problem like this.

What version do you work with?

Do you have the same question code for more than one question?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
2 years 10 months ago #111994 by Mike1985_2
Mike1985_2 replied the topic: Copy Survey Not Working - Question Codes
Version 2.05+ Build 140811

The question codes are unique - but obviously once I try to import, it is importing an exact duplicate and therefore there will be duplicate codes.

Am I supposed to go through the .lss files first and change all the codes?

Please Log in to join the conversation.

More
2 years 10 months ago #111996 by fransmarcelissen
fransmarcelissen replied the topic: Copy Survey Not Working - Question Codes
I do not know whether this is intended behaviour, but indeed, if you import the same question twice, the codes are the same.
What I would do: do not import the question the second time, but copy the (first) question. Then you can/must change the code. Or before import change the code of the first question.
Frans

Please Log in to join the conversation.

More
2 years 10 months ago #112009 by holch
holch replied the topic: Copy Survey Not Working - Question Codes
Let us be clear here what you are trying: You try to export a whole survey and import it as a whole new survey, correct? In this case, as long as within the same survey you don't have the same question code twice this should be not a problem. The new survey should receive a new survey code and you should be fine.

I will make a test later.

However, when exporting and importing questions (like fransmacelissen is saying), you need to make sure to give the imported question a different question code to any other question within the survey you are importing to.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in to join the conversation.

More
2 years 10 months ago - 2 years 10 months ago #112010 by holch
holch replied the topic: Copy Survey Not Working - Question Codes
Just exported and then imported a survey with the same LS version as you and there are no error messages.

I would assume that there is something wrong with the survey you are trying to import and export.

Can you provide the survey as a download here or is it confidential?

Ahhh, I just had another look at your orginal post, and your export is a question file.

Of course there can't be two questions with the same name. So when you import the question to a survey where there is already a question with this code, you will need to change the code for one of them.

Just tested it and the question is imported without asking for a new question code. This wasn't a problem, because 'q4' did not exist in my test survey. I tried to import it again, which is when I got your error message.

So you have two quick solutions: If you want to have the same question twice in the same survey, don't export/import it, but copy it. Or you need to change the question code for the one that already exists after exporting, so you can import it. Ideally there would be a dialog when importing, so that you can change the question code of the imported question. I think a bug report would be good. But for now you can solve it with the above aproaches.

For importing Surveys this doesn't happen. Might be also a problem for importing groups.

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds
Last Edit: 2 years 10 months ago by holch.

Please Log in to join the conversation.

More
2 years 7 months ago #115381 by cshaw
cshaw replied the topic: Copy Survey Not Working - Question Codes
Yep, this is an issue for importing groups.

I have the situation where I am asking respondents to enter family health information for my group's research study, so we are asking the same questions over and over again with each family member.

I created a group with health info questions for a family member, thinking I could export and import the group again for the second family member. I can export/import to .lss files, BUT all the references get broken since we are referencing ONLY the question name. It would be really great if LimeSurvey namespaced the questions. That is what we used to do when with had SGQA names. We lost some flexibility going to a user defined name.

It is very tedious to go through and rename EVERY question, so I thought I'd export the whole survey to Excel make the modifications and then upload again. BUT no that doesn't work anymore either. I can't get a survey saved as txt to upload again. Maybe someone else knows a trick I don't.

IT's a little frustrating because I know we used to have that functionality.

I am playing around with different approaches ... but if anyone else has crossed this bridge and KNOWS how to get to the other side I'd appreciate a head's up.

What I am thinking I will try:
- Playing around with different types of export/import
- Try using SGQA names for questions and doing export/import of the group

Carole

Please Log in to join the conversation.

More
2 years 7 months ago #115397 by DenisChenu
DenisChenu replied the topic: Copy Survey Not Working - Question Codes
Hi,

I update directly the lsg file for this, for example adding G1 at start of each question. Open with gedit and replace all G1 by G2.

It work, but it's not cool, then you can pit a feature request.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

More
2 years 7 months ago #115400 by fransmarcelissen
fransmarcelissen replied the topic: Copy Survey Not Working - Question Codes
Extra advice: always make a backup of the db first, before doing this kind of things.
Even more naughty: you can also change the names of the questions and the references also directly in the mysql database. Again: never do this without making a backup first!
Succes!
frans
The following user(s) said Thank You: cshaw

Please Log in to join the conversation.

More
2 years 7 months ago #115433 by cshaw
cshaw replied the topic: Copy Survey Not Working - Question Codes
Ah, great tip!

Please Log in to join the conversation.

More
2 years 7 months ago #115439 by cshaw
cshaw replied the topic: Copy Survey Not Working - Question Codes

Hi,

I update directly the lsg file for this, for example adding G1 at start of each question. Open with gedit and replace all G1 by G2.

It work, but it's not cool, then you can pit a feature request.


Hey I did what you suggest here and it works really slick. I still think the questions should be name-spaced, but this does the trick nicely. I hadn't attempted to modify the lsg file directly before, but that was a synch. LOVE being able to just search/replace. :)

Please Log in to join the conversation.

More
2 years 7 months ago #115461 by Mazi
Mazi replied the topic: Copy Survey Not Working - Question Codes
Guys, please do such changes with care, it could really break your survey so always created backups!

Best tools for using search/replace are Notepad++ (if you want to edit the raw file) and - since the export format is XML based - XML Notepad.


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"
The following user(s) said Thank You: cshaw

Please Log in to join the conversation.

More
2 years 7 months ago - 2 years 7 months ago #115473 by cshaw
cshaw replied the topic: Copy Survey Not Working - Question Codes
Thanks Mazi, point well taken. I am only working on a proof-of-concept survey at the moment so I am not too worried about it. I would never attempt such a thing on a production survey. IMO a production survey shouldn't ever NEED to be changed like that. I would make a copy of the existing survey, modify the copy and make it the new production survey preserving the old one. I seldom even move responses from an old version to a new version, I feel that obscures the history for the responses ... and in a research setting that can make a big difference ... the exception is when the modification is VERY minor such as a tweak to the look or correction of a typo.

I did use Notepad++ for searching and replacing in the raw XML (.lsg)

For example I have a whole group of questions that need to be asked for each of the respondent's female relatives to get a health history. I prefaced each question in the group with fr1, exported the group, opened the .lsg file in Notepad++ (Love that program) did a search and replace of fr1 with fr2, so for instance fr1cancerdx became fr2cancerdx, changed the name of the group from FemaleRelative1 to FemaleRelative2 and saved. Then back in the survey I imported the revised group. Worked like a charm and all the questions now have their unique fr2 preface and anywhere they were referenced in a relevance equation or elsewhere is also updated.

This wouldn't work for places I referenced the variables outside of the group, but since my goal was just to save myself the tedium of copying each question one at a time, this was a great time saver!

PLUS: I figured the worst thing that could happen is that the group wouldn't import as I had hoped, but it actually went really smoothly.
Last Edit: 2 years 7 months ago by cshaw. Reason: grammar

Please Log in to join the conversation.

More
2 years 7 months ago #115479 by cshaw
cshaw replied the topic: Copy Survey Not Working - Question Codes
BTW: In Notepad++ I recorded a macro to do the modifications to the first relative to make them the second relative group. THEN I opened the Notepad++ file "shortcuts.xls" and copied the macro to make a third, fourth, fifth and sixth relative macro with a little tweaking. Now converting a group for the first relative is as easy as opening the lsg file in Notepad++, running the appropriate macro, saving the revisions, and then importing the revised lsg into the survey. Slick and Quick!

Please Log in to join the conversation.

More
2 years 7 months ago #115486 by DenisChenu
DenisChenu replied the topic: Copy Survey Not Working - Question Codes

Mazi wrote: Guys, please do such changes with care, it could really break your survey so always created backups!

Hi,

We don't update the DB directly, but it's done by LimeSurvey. If we make error : LS don't accept the lsg file.

I don't see any real reason to do a backup before. It's like we try to add a group + question manually.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
An error happen ? Before make a new topic : remind the Debug mode .

Please Log in to join the conversation.

Did you already participate in our customer survey?

Don't miss your chance for great prices.

Please click here to participate:

Start now

Start now!

Just create your account and start using Limesurvey today.

Register now