Code Duplication    Length = 11-17 lines in 3 locations

main/survey/preview.php 1 location

@@ 171-186 (lines=16) @@
168
            $result = Database::query($sql);
169
            $question_counter_max = Database::num_rows($result);
170
            $limit = 0;
171
            while ($row = Database::fetch_array($result)) {
172
                // If the type is not a pagebreak we store it in the $questions array
173
                if ($row['type'] != 'pagebreak') {
174
                    $questions[$row['sort']]['question_id'] = $row['question_id'];
175
                    $questions[$row['sort']]['survey_id'] = $row['survey_id'];
176
                    $questions[$row['sort']]['survey_question'] = $row['survey_question'];
177
                    $questions[$row['sort']]['display'] = $row['display'];
178
                    $questions[$row['sort']]['type'] = $row['type'];
179
                    $questions[$row['sort']]['options'][intval($row['option_sort'])] = $row['option_text'];
180
                    $questions[$row['sort']]['maximum_score'] = $row['max_value'];
181
                } else {
182
                    // If the type is a pagebreak we are finished loading the questions for this page
183
                    break;
184
                }
185
                $counter_question++;
186
            }
187
        }
188
    }
189

main/survey/survey.lib.php 1 location

@@ 2135-2145 (lines=11) @@
2132
                        survey_question.c_id = $course_id
2133
					ORDER BY survey_question.sort, survey_question_option.sort ASC";
2134
            $result = Database::query($sql);
2135
            while ($row = Database::fetch_array($result, 'ASSOC')) {
2136
                if ($row['type'] != 'pagebreak') {
2137
                    $questions[$row['sort']]['question_id'] = $row['question_id'];
2138
                    $questions[$row['sort']]['survey_id'] = $row['survey_id'];
2139
                    $questions[$row['sort']]['survey_question'] = $row['survey_question'];
2140
                    $questions[$row['sort']]['display'] = $row['display'];
2141
                    $questions[$row['sort']]['type'] = $row['type'];
2142
                    $questions[$row['sort']]['maximum_score'] = $row['max_value'];
2143
                    $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text'];
2144
                }
2145
            }
2146
2147
            // Getting all the answers of the user
2148
            $sql = "SELECT * FROM $table_survey_answer

main/survey/fillsurvey.php 1 location

@@ 713-729 (lines=17) @@
710
            $limit = 0;
711
            $questions = array();
712
713
            while ($row = Database :: fetch_array($result, 'ASSOC')) {
714
715
                // If the type is not a pagebreak we store it in the $questions array
716
                if ($row['type'] != 'pagebreak') {
717
                    $questions[$row['sort']]['question_id'] = $row['question_id'];
718
                    $questions[$row['sort']]['survey_id'] = $row['survey_id'];
719
                    $questions[$row['sort']]['survey_question'] = $row['survey_question'];
720
                    $questions[$row['sort']]['display'] = $row['display'];
721
                    $questions[$row['sort']]['type'] = $row['type'];
722
                    $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text'];
723
                    $questions[$row['sort']]['maximum_score'] = $row['max_value'];
724
                } else {
725
                    // If the type is a pagebreak we are finished loading the questions for this page
726
                    break;
727
                }
728
                $counter++;
729
            }
730
        }
731
    } elseif ($survey_data['survey_type'] === '1') {
732
        $my_survey_id = intval($survey_invitation['survey_id']);