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/forum/forumfunction.inc.php 1 location

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

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

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