Survey duplicate lost all questions if original survey has answers

Hi, team.
Survey duplicate lost all questions if original survey has answers. :oops:
System. RedHat Enterprise. CRM 7.0.15 and 7.0.16.

Problem - it is impossible to repeat servey with at least one answer
Problem description:
In this case you need repeat the survey manually again or keep drafts for all surveys probably will be needed in the future.

Status of servey.
The same problem for draft and public status.
The same problem for answered.

Possible reson. :slight_smile:
Module blocks the ability to edit questions. It doesnt generate questions with holded (disabled to edit) fields.
Instead it shows simple table similar to preview mode of the survey.

Reason:
This can be a reason cause the problem to duplicate the survey which has at least one answer.

Possible solution: B-)
Instead the table with questions description generate questions with disabled fields and buttons.

To repeat.

  1. Create any survey with 1 or more quesions.
  2. Answer 1 or more times.
  3. Duplicate it.

Result - All questions in the new survey will be lost.

Image uploaded:
[CRM_survey_block_questions_to_duplicate.PNG]

UPDATE: here are 2 different problems, so I changed description

  1. This post - Can’t duplicate survey with any answer
  2. New post - duplicate survey with Draft or Public status is ok but original servey lost all questions
    Survey duplicate but delete all questions in original survey https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/26588-survey-duplicate-but-delete-all-questions-in-original-survey

Hi, team.
Survey duplicate lost all questions if original survey has answers. :oops:
System. RedHat Enterprise. CRM 7.0.15 and 7.0.17 (updated: was 7.0.16).

Problem - it is impossible to repeat servey with at least one answer
Problem description:
In this case you need repeat the survey manually again or keep drafts for all surveys probably will be needed in the future.

Status of servey.
The same problem for answered.

Possible reson. :slight_smile:
Module blocks the ability to edit questions. It doesnt generate questions with holded (disabled to edit) fields.
Instead it shows simple table similar to preview mode of the survey.

Reason:
This can be a reason cause the problem to duplicate the survey which has at least one answer.

Possible solution: B-)
Instead the table with questions description generate questions with disabled fields and buttons.

To repeat.

  1. Create any survey with 1 or more quesions.
  2. Answer 1 or more times.
  3. Duplicate it.

Result - All questions in the new survey will be lost.

There was a bug with the surveys entry point, I am not sure if it affects your version.

Does this change improve anything in the problem you describe here?

https://github.com/salesagility/SuiteCRM/pull/7516/files

Hi, Prg.
This fix is nice. I did it with more direct code - $isValidator = new \SuiteCRM\Utility\SuiteValidator();
Thus my problem appear after my fix.

But merged fix much better with coding style and crystal readness :slight_smile:

Anyway I retest it again and publish the result.

Hi Prg, here is the more complexity problem.
I had a doubt with Survey duplicate behavior and test again.

System. RedHat Enterprise. CRM 7.0.15

The problem gives 2 different situation.(at least).
A) original Survey lost quiestions, duplicate has
B) duplicate Survey lost quiestions, original has

How to replicate the problem:

  1. New Survey in Draft duplicated. = Situation 1
    1a) Create new one with one question. Status Draft. > Duplicate it. => 1b) Original has no questions, duplicate has questions.

  2. New Survey in Pubilc without an answer duplicated. = Situation 1
    2a) Create new one with one question. Status Public. > Duplicate it. => 2b) Original has no questions, duplicate has questions.

  3. New Survey in Pubilc with an answer duplicated. = Situation 2
    3a) Create new one with one question. Status Public. > Duplicate it. => 3b) Original has questions, duplicate has no questions.

** 1a, 1b, 2a, 2b, 3a, 3b - attached files have similar markers with number in thier names to check how it looks
*** the list with 6 surveys with dates to insure order of steps

Here is new behavior for different 2 situations.

Thanks. Alex

Are you using an IDE (like PHpStorm or Eclipse)? Can you debug through the Survey duplication code to see where it’s going wrong?

Hi. I don’t use something like that, sorry.
Last years I’m working in BI area. CRM it is just another one task for me. I try to use all SuiteCRM power without coding. So I’m a little bit far from debuging now.

I just use my past experience to find out and locate a problem. Sometimes I can find and fix a bug myself :slight_smile:

Alex

Hi, Prg.
With data analysis without debugging I can find where problem is in a logic.
But not exact place in the code for sure.

Problem = The CRM renew Survey_ID field in DB for current original questions instead to copy them to new records and attach to the new. survey.

Explanation how it was detected.

Here are 2 syrveys 1a and 1b.(2nd and 3rd attached images).

  1. For the 2nd new duplicated Survey “Dup test original 2 from Draft” here the question with Deleted = 0.

  2. The most important data about 1st survey is Date and ID
    ID 9e0855e9-84bc-d19e-754d-5d2879862237
    Date_entered and Date_modified are similar and it is 2019-07-12 12:12:19

  3. The quiestion is not deleted and it is OLD record, created with 1st Survey.
    The quiestion belongs to the original “Dup test original” according to Date_entered and Date_modified.
    The 2nd survey was created later.

4 No another question in DB for the 1st Suvrey. No questions with Survey_ID 9e0855e9-84bc-d19e-754d-5d2879862237
But the DB has to have 2 identical questions related to different surveys.

  1. It means that the issue is - the CRM logic changes Survey_ID data to new Survey.
    But has to create a new record for each question ralated to original survey (which duplicated) with survey_id for new the survey…

Details:

2nd Survey:DB record (partly)

ID 9e0855e9-84bc-d19e-754d-5d2879862237
Date_entered 2019-07-12 12:12:19
Date_modified 2019-07-12 12:12:19

2nd Survey:DB record ““Dup test original 2 from Draft”” is:

ID 9ce9faa2-f785-e862-553a-5d28799093c6
Name Dup test original 2 from Draft
Date_entered 2019-07-12 12:13:05
Date_modified 2019-07-12 12:13:05
Modified user ID 1
Created by1
Description Dup test original
Deleted 0
Assigned_user_id 1
Status Draft

The question:from the original survey “Dup test original” with ID 9e0855e9-84bc-d19e-754d-5d2879862237

ID abd8d536-7e61-a90d-3ef5-5d28796e0662
Duplicate
2019-07-12 12:12:19
2019-07-12 12:13:05
1
1
NULL
Deleted = 0
0
Rating
0
Survey_id = 9ce9faa2-f785-e862-553a-5d28799093c6

Maybe it helps a little bit. I surprised with DB analysis.

Alex

Alex can you please open an Issue for this on Github? I think we should duplicate Surveys correctly, with all dependent information (questions etc).

Hi Pgr. Will try next week. Thanks.