From: SourceForge.net <no...@so...> - 2009-04-10 07:13:41
|
Bugs item #2669428, was opened at 2009-03-06 21:45 Message generated for change (Comment added) made by liedekef You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2669428&group_id=8956 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: kswartz (kswartz) Assigned to: bishop (bishopb) Summary: Copying an existing survey does not copy conditions Initial Comment: I'm working with version 2.0.2 of phpESP, and noticed that if you copy an existing survey, it copies everything BUT the conditions. If this isn't fixed in the latest version, please consider it for the next update. (If this IS fixed in 2.1.2, it will probably speed up my upgrade. Only reason I haven't so far is because I made a lot of changes and fixed some bugs in 2.0.2, and wasn't sure how long it would take to copy the changes over.) ---------------------------------------------------------------------- >Comment By: Franky Van Liedekerke (liedekef) Date: 2009-04-10 09:13 Message: That would be great! Thanks, Bishop. Don't let it ruin the holidays though :-) ---------------------------------------------------------------------- Comment By: bishop (bishopb) Date: 2009-04-10 01:58 Message: Franky, I'll try and get to them before Monday, 13-April-09. ---------------------------------------------------------------------- Comment By: Franky Van Liedekerke (liedekef) Date: 2009-04-09 23:33 Message: I'm assigning this to Bishop as well, but I'm really planning on releasing a new version after this fix (seems good enough reasons/bugfixes exist now). So Bishop, I don't know if you have the time to look at this and 2672129 any time soon? Franky ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2009-04-09 23:20 Message: Crap, another typo! Man, I wish I could edit these posts. One more time: INSERT INTO conditions (id,survey_id,q1_id,q2_id,cond,cond_value) SELECT NULL, 11, qnew1.id, qnew2.id, cond, cond_value FROM question qold1, question qold2, question qnew1, question qnew2, conditions c WHERE qold1.id=c.q1_id AND qold2.id=c.q2_id AND qold1.survey_id=$old_survey_id and qold2.survey_id=$old_survey_id AND qnew1.survey_id=$new_survey_id AND qnew1.position=qold1.position AND qnew1.deleted=qold1.deleted AND qnew2.survey_id=$new_survey_id AND qnew2.position=qold2.position AND qnew2.deleted=qold2.deleted; ---------------------------------------------------------------------- Comment By: Nobody/Anonymous (nobody) Date: 2009-04-09 23:18 Message: Sorry, the SQL in the last update was missing a line. It should read: INSERT INTO conditions (id,survey_id,q1_id,q2_id,cond,cond_value) SELECT NULL, $new_survey_id, qnew1.id, qnew2.id, cond, cond_value FROM question qold1, question qold2, question qnew1, question qnew2, conditions c WHERE qold1.id=c.q1_id AND qold2.id=c.q2_id AND qold1.survey_id=3 and qold2.survey_id=3 AND qnew1.survey_id=$new_survey_id AND qnew1.position=qold1.position AND qnew1.deleted=qold1.deleted AND qnew2.survey_id=$new_survey_id AND qnew2.position=qold2.position AND qnew2.deleted=qold2.deleted; Just a reminder, too, this enhancement REQUIRES the fix to 2672129 also (which makes copied surveys start with the same position as the original). This SQL cannot be manually applied to previously copied surveys unless the positions between the original and copy are re-aligned by hand, which may or may not be part of the fix to 2672129. (Probably not.) ---------------------------------------------------------------------- Comment By: kswartz (kswartz) Date: 2009-03-08 06:23 Message: (Sorry for the double post before.) Okay, I've looked at survey_aggregate.inc, and I think what I described previously is actually a bug. I've logged a separate bug for this. With that fix in place, this is the SQL I used to copy the conditions from the old survey to the new survey: INSERT INTO conditions (id,survey_id,q1_id,q2_id,cond,cond_value) SELECT NULL, $new_survey_id, qnew1.id, qnew2.id, cond, cond_value FROM question qold1, question qold2, question qnew1, question qnew2, conditions c WHERE qold1.id=c.q1_id AND qold2.id=c.q2_id AND qnew1.survey_id=$new_survey_id AND qnew1.position=qold1.position AND qnew1.deleted=qold1.deleted AND qnew2.survey_id=$new_survey_id AND qnew2.position=qold2.position AND qnew2.deleted=qold2.deleted; I'll work on producing a patch that incorporates this into survey_aggregate.inc Incidentally, I'm not sure why you chose to insert the questions one at a time while cycling through the results of a select. I think all the changes you made to the old data could have been made in SQL. I elected to do an INSERT INTO ... SELECT FROM ... instead, as you can see, as it's much faster. ---------------------------------------------------------------------- Comment By: kswartz (kswartz) Date: 2009-03-08 05:24 Message: Okay, I've set up 2.1.2, and I may have a patch for this coming, but I've discovered a weird quirk that's affecting the SQL. The starting position for all my surveys (in the question table) is 0. However, when I copy a survey, the starting position is 1. Is that intended behavior? Can I always assume that the value of "position" for a question in a copied survey is always one greater than its counterpart in the original survey? ---------------------------------------------------------------------- Comment By: kswartz (kswartz) Date: 2009-03-07 20:45 Message: Okay, I've set up 2.1.2, and I may have a patch for this coming, but I've discovered a weird quirk that's affecting the SQL. The starting position for all my surveys (in the question table) is 0. However, when I copy a survey, the starting position is 1. Is that intended behavior? Can I always assume that the value of "position" for a question in a copied survey is always one greater than its counterpart in the original survey? ---------------------------------------------------------------------- Comment By: kswartz (kswartz) Date: 2009-03-07 01:01 Message: That's cool - it's not a feature I use very often, which is why it took so long to say anything. Next time I go to do this, I'll add a comment to the request with the SQL necessary to do the copy (which is the hard part). If I have time to actually fix the code, I'll gladly supply a patch. (And yes, I'll upgrade to 2.1.2 first. :) ) ---------------------------------------------------------------------- Comment By: Franky Van Liedekerke (liedekef) Date: 2009-03-07 00:40 Message: Hi, sorry, but I don't think it is fixed in 2.1.2 (it was known to me though, and I'm pretty sure I documented it somewhere...) But feel free to make any contribution, be it patches, bug fixes, etc ... Franky ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2669428&group_id=8956 |