Code Duplication    Length = 11-17 lines in 3 locations

main/survey/preview.php 1 location

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

main/survey/fillsurvey.php 1 location

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

main/survey/survey.lib.php 1 location

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