Code Duplication    Length = 11-17 lines in 3 locations

main/survey/preview.php 1 location

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

main/survey/fillsurvey.php 1 location

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

main/survey/survey.lib.php 1 location

@@ 2100-2110 (lines=11) @@
2097
                        survey_question.c_id = $course_id
2098
					ORDER BY survey_question.sort, survey_question_option.sort ASC";
2099
            $result = Database::query($sql);
2100
            while ($row = Database::fetch_array($result, 'ASSOC')) {
2101
                if ($row['type'] != 'pagebreak') {
2102
                    $questions[$row['sort']]['question_id'] = $row['question_id'];
2103
                    $questions[$row['sort']]['survey_id'] = $row['survey_id'];
2104
                    $questions[$row['sort']]['survey_question'] = $row['survey_question'];
2105
                    $questions[$row['sort']]['display'] = $row['display'];
2106
                    $questions[$row['sort']]['type'] = $row['type'];
2107
                    $questions[$row['sort']]['maximum_score'] = $row['max_value'];
2108
                    $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text'];
2109
                }
2110
            }
2111
2112
            // Getting all the answers of the user
2113
            $sql = "SELECT * FROM $table_survey_answer