Code Duplication    Length = 3-8 lines in 4 locations

main/survey/preview.php 1 location

@@ 127-133 (lines=7) @@
124
		$result = Database::query($sql);
125
        $questions_exists = true;
126
        if (Database::num_rows($result)) {
127
    		while ($row = Database::fetch_array($result)) {
128
    			if ($row['type'] == 'pagebreak') {
129
    				$counter++;
130
    			} else {
131
    				$paged_questions[$counter][] = $row['question_id'];
132
    			}
133
    		}
134
        } else {
135
            $questions_exists = false;
136
        }

main/survey/fillsurvey.php 1 location

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

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

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

main/forum/forumfunction.inc.php 1 location

@@ 1878-1884 (lines=7) @@
1875
    $result = Database::query($sql);
1876
    $list = array();
1877
    $alreadyAdded = array();
1878
    while ($row = Database::fetch_array($result, 'ASSOC')) {
1879
        if (in_array($row['thread_id'], $alreadyAdded)) {
1880
            continue;
1881
        }
1882
        $list[] = $row;
1883
        $alreadyAdded[] = $row['thread_id'];
1884
    }
1885
1886
    return $list;
1887
}