Check out the LimeSurvey source code on GitHub!
Welcome, Guest
Username: Password:
  • Page:
  • 1
  • 2

TOPIC: Copy Survey Not Working - Question Codes

Copy Survey Not Working - Question Codes 1 year 11 months ago #111980

  • Mike1985_2
  • Mike1985_2's Avatar
  • Offline
  • Junior Lime
  • Posts: 25
  • Karma: 0
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: 1 year 11 months ago by Mike1985_2. Reason: Added another question
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 11 months ago #111990

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5063
  • Thank you received: 749
  • Karma: 227
Never had a problem like this.

What version do you work with?

Do you have the same question code for more than one question?
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 11 months ago #111994

  • Mike1985_2
  • Mike1985_2's Avatar
  • Offline
  • Junior Lime
  • Posts: 25
  • Karma: 0
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?
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 11 months ago #111996

  • fransmarcelissen
  • fransmarcelissen's Avatar
  • Offline
  • Gold Lime
  • Posts: 241
  • Thank you received: 53
  • Karma: 13
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
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 11 months ago #112009

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5063
  • Thank you received: 749
  • Karma: 227
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.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 11 months ago #112010

  • holch
  • holch's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5063
  • Thank you received: 749
  • Karma: 227
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.
Have a look at the manual! It is a really valuable source for information. Here some helpful links:
Manual (EN) | Question Types | Question Attributes | Workarounds

If you found this answer helpful and it saved you some time please consider a donation to the project to keep Limesurvey going!
Last Edit: 1 year 11 months ago by holch.
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 7 months ago #115381

  • ohvelma
  • ohvelma's Avatar
  • Offline
  • Senior Lime
  • Posts: 62
  • Thank you received: 5
  • Karma: 4
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
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 7 months ago #115397

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9293
  • Thank you received: 1327
  • Karma: 384
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 developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 7 months ago #115400

  • fransmarcelissen
  • fransmarcelissen's Avatar
  • Offline
  • Gold Lime
  • Posts: 241
  • Thank you received: 53
  • Karma: 13
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 administrator has disabled public write access.
The following user(s) said Thank You: ohvelma

Copy Survey Not Working - Question Codes 1 year 7 months ago #115433

  • ohvelma
  • ohvelma's Avatar
  • Offline
  • Senior Lime
  • Posts: 62
  • Thank you received: 5
  • Karma: 4
Ah, great tip!
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 7 months ago #115439

  • ohvelma
  • ohvelma's Avatar
  • Offline
  • Senior Lime
  • Posts: 62
  • Thank you received: 5
  • Karma: 4
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. :)
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 7 months ago #115461

  • Mazi
  • Mazi's Avatar
  • Offline
  • LimeSurvey Team
  • Posts: 5974
  • Thank you received: 366
  • Karma: 260
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)limesurvey.org'"
The administrator has disabled public write access.
The following user(s) said Thank You: ohvelma

Copy Survey Not Working - Question Codes 1 year 7 months ago #115473

  • ohvelma
  • ohvelma's Avatar
  • Offline
  • Senior Lime
  • Posts: 62
  • Thank you received: 5
  • Karma: 4
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: 1 year 7 months ago by ohvelma. Reason: grammar
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 7 months ago #115479

  • ohvelma
  • ohvelma's Avatar
  • Offline
  • Senior Lime
  • Posts: 62
  • Thank you received: 5
  • Karma: 4
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!
The administrator has disabled public write access.

Copy Survey Not Working - Question Codes 1 year 7 months ago #115486

  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • Moderator Lime
  • Posts: 9293
  • Thank you received: 1327
  • Karma: 384
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 developpement are on my free time (Say thanks ?).
A bug not reported is a bug not corrected. | Please, read the documentation | La doc en français à besoin de vous
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Moderators: ITEd
Time to create page: 0.277 seconds
Imprint                   Data Protection Statement                  Revocation information and revocation form