Code Duplication    Length = 11-17 lines in 3 locations

main/survey/fillsurvey.php 1 location

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

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/survey.lib.php 1 location

@@ 2061-2071 (lines=11) @@
2058
                        survey_question.c_id = $course_id
2059
					ORDER BY survey_question.sort, survey_question_option.sort ASC";
2060
            $result = Database::query($sql);
2061
            while ($row = Database::fetch_array($result, 'ASSOC')) {
2062
                if ($row['type'] != 'pagebreak') {
2063
                    $questions[$row['sort']]['question_id'] = $row['question_id'];
2064
                    $questions[$row['sort']]['survey_id'] = $row['survey_id'];
2065
                    $questions[$row['sort']]['survey_question'] = $row['survey_question'];
2066
                    $questions[$row['sort']]['display'] = $row['display'];
2067
                    $questions[$row['sort']]['type'] = $row['type'];
2068
                    $questions[$row['sort']]['maximum_score'] = $row['max_value'];
2069
                    $questions[$row['sort']]['options'][$row['question_option_id']] = $row['option_text'];
2070
                }
2071
            }
2072
2073
            // Getting all the answers of the user
2074
            $sql = "SELECT * FROM $table_survey_answer