Code Duplication    Length = 3-9 lines in 5 locations

main/survey/preview.php 1 location

@@ 133-139 (lines=7) @@
130
        $result = Database::query($sql);
131
        $questions_exists = true;
132
        if (Database::num_rows($result)) {
133
            while ($row = Database::fetch_array($result)) {
134
                if ($row['type'] == 'pagebreak') {
135
                    $counter++;
136
                } else {
137
                    $paged_questions[$counter][] = $row['question_id'];
138
                }
139
            }
140
        } else {
141
            $questions_exists = false;
142
        }

main/forum/forumfunction.inc.php 1 location

@@ 1892-1898 (lines=7) @@
1889
    $result = Database::query($sql);
1890
    $list = array();
1891
    $alreadyAdded = array();
1892
    while ($row = Database::fetch_array($result, 'ASSOC')) {
1893
        if (in_array($row['thread_id'], $alreadyAdded)) {
1894
            continue;
1895
        }
1896
        $list[] = $row;
1897
        $alreadyAdded[] = $row['thread_id'];
1898
    }
1899
1900
    return $list;
1901
}

main/inc/lib/course.lib.php 1 location

@@ 2843-2851 (lines=9) @@
2840
        $result = Database::query($sql);
2841
2842
        if (Database::num_rows($result)) {
2843
            while ($row = Database::fetch_array($result, 'ASSOC')) {
2844
                if (!empty($skipCourseList)) {
2845
                    if (in_array($row['real_id'], $skipCourseList)) {
2846
                        continue;
2847
                    }
2848
                }
2849
                $course_list[] = $row;
2850
                $codes[] = $row['real_id'];
2851
            }
2852
        }
2853
2854
        if ($include_sessions === true) {

main/inc/lib/events.lib.php 1 location

@@ 1368-1370 (lines=3) @@
1365
            $sql = "SELECT * FROM $table_track_attempt
1366
                    WHERE exe_id = {$row['exe_id']}";
1367
            $res_question = Database::query($sql);
1368
            while ($row_q = Database::fetch_array($res_question, 'ASSOC')) {
1369
                $list[$row['exe_id']]['question_list'][$row_q['question_id']][] = $row_q;
1370
            }
1371
        }
1372
        return $list;
1373
    }

main/survey/fillsurvey.php 1 location

@@ 620-627 (lines=8) @@
617
                    WHERE c_id = $course_id AND survey_id = '".intval($survey_invitation['survey_id'])."'
618
                    ORDER BY sort ASC";
619
            $result = Database::query($sql);
620
            while ($row = Database::fetch_array($result, 'ASSOC')) {
621
                if ($row['type'] == 'pagebreak') {
622
                    $counter++;
623
                } else {
624
                    // ids from question of the current survey
625
                    $paged_questions[$counter][] = $row['question_id'];
626
                }
627
            }
628
            $_SESSION['paged_questions'] = $paged_questions;
629
        } else {
630
            $paged_questions = $_SESSION['paged_questions'];