From: SourceForge.net <no...@so...> - 2009-03-08 17:28:01
|
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: Nobody/Anonymous (nobody) 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-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 |