From: SourceForge.net <no...@so...> - 2009-03-23 20:31:44
|
Bugs item #2672129, was opened at 2009-03-08 06:21 Message generated for change (Comment added) made by liedekef You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2672129&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: Admin Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: kswartz (kswartz) Assigned to: bishop (bishopb) Summary: Copy survey reorders positions starting with 1 instead of 0 Initial Comment: When you initialize $pos before looping through the calls to survey_copy_questions, you set it to 1, so the first copied question has position=1. However, when you define questions for a survey, the first question's position is set to 0. The application works fine with this bug in place UNTIL you go to copy conditions. That requires matching the questions from the new survey and the old survey, and the only way to do that is to match on the columns position and deleted. With this bug, however, the position columns do not correspond, so the question that was in position 1 in the old survey is in position 2 in the new survey. The fix requires changing only two lines in survey_aggregate.inc: $ diff survey_aggregate_old.inc survey_aggregate.inc 74c74 < $pos = 1; --- > $pos = 0; 85c85 < function survey_copy_questions($sid, $new_sid, $pos = 1) { --- > function survey_copy_questions($sid, $new_sid, $pos = 0) { ---------------------------------------------------------------------- Comment By: Franky Van Liedekerke (liedekef) Date: 2009-03-23 21:31 Message: Well, I don't think it matters :-) Or more: to fix the ones starting at "1" would be very troublesome ... the damage there is already done (if you have conditions in place). But after the fix is in place, it wouldn't matter: you start at position 0 in source and destination, even if position 0 is not defined it should still be ok, no? Franky ---------------------------------------------------------------------- Comment By: kswartz (kswartz) Date: 2009-03-09 04:45 Message: I haven't looked through the code yet for the initial "0" position, but I can say that every survey I've created has 0 as the value of position for the first question. I would expect that this gets set when using the section to reorder the questions in creating a new survey. One question (no pun intended) is whether or not it starts with "0" if you do NOT reorder the questions; i.e.: if you only create a question and exit. However, I think it doesn't really matter, and here's why... As soon as we introduce the code to copy conditions (which is dependent on this change), it's going to rely on the fact that positions between original and copied surveys always start with the same value. Today, some surveys will start with 0 and some start with 1. So the next release will have to include an upgrade script that cleans this up, by updating the position column so that ALL surveys start with the same value. I'm inclined to say that value should be 0, based on what I'm seeing from the surveys I've created from scratch and your last comment, bishopb. ---------------------------------------------------------------------- Comment By: bishop (bishopb) Date: 2009-03-08 20:50 Message: I am inclined to think that 0 is the correct position, and since I was the most recent to work in that area of the (really old) code, I'll take on this issue. kswartz: are you seeing the initial definition of 0 somewhere specifically in the code, or only as a post facto artifact in the generated rows? ---------------------------------------------------------------------- Comment By: Franky Van Liedekerke (liedekef) Date: 2009-03-08 18:27 Message: Hmmm ... I don't remember as well, probably the oldest programmer for that part was way before me ... Franky ---------------------------------------------------------------------- Comment By: bishop (bishopb) Date: 2009-03-08 13:15 Message: survey_aggregate() is a generalization of the original survey_copy() code, and in fact the survey_copy_questions() helper function is a direct descendant of the original survey_copy(). In the original survey_copy(), $pos was initialized to 1: 65 $pos=1; 66 array_shift($question_fields); 67 while($question = fetch_row($result)) { 68 $result->MoveNext(); 69 $tid = $question['type_id']; 70 $qid = $question['id']; 71 // fix some fields first 72 $question['survey_id'] = $new_sid; 73 $question['position'] = $pos++; So, I can say that if this is a bug, it's existed for a while. Is anyone here familiar with the older code from survey_copy() that can comment on this? ---------------------------------------------------------------------- Comment By: kswartz (kswartz) Date: 2009-03-08 06:22 Message: File Added: survey_aggregate.inc ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=108956&aid=2672129&group_id=8956 |