Code Duplication    Length = 5-6 lines in 3 locations

main/lp/learnpath.class.php 3 locations

@@ 3891-3895 (lines=5) @@
3888
        if ($num > 0) {
3889
            $i = 1;
3890
            while ($row = Database::fetch_array($res)) {
3891
                if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it.
3892
                    $sql = "UPDATE $lp_table SET display_order = $i
3893
                            WHERE c_id = $courseId AND id = ".$row['id'];
3894
                    Database::query($sql);
3895
                }
3896
                $row['display_order'] = $i;
3897
                $lps[$row['id']] = $row;
3898
                $lp_order[$i] = $row['id'];
@@ 3952-3957 (lines=6) @@
3949
            $i = 1;
3950
            while ($row = Database::fetch_array($res)) {
3951
                $max = $i;
3952
                if ($row['display_order'] != $i) { // If we find a gap in the order, we need to fix it.
3953
                    $need_fix = true;
3954
                    $sql_u = "UPDATE $lp_table SET display_order = $i
3955
                              WHERE c_id = ".$courseId." AND id = ".$row['id'];
3956
                    Database::query($sql_u);
3957
                }
3958
                $row['display_order'] = $i;
3959
                $lps[$row['id']] = $row;
3960
                $lp_order[$i] = $row['id'];
@@ 5341-5346 (lines=6) @@
5338
        if ($num > 0) {
5339
            $i = 1;
5340
            while ($row = Database::fetch_array($res)) {
5341
                if ($row['display_order'] != $i) {
5342
                    // If we find a gap in the order, we need to fix it.
5343
                    $sql = "UPDATE $lp_table SET display_order = $i
5344
                            WHERE c_id = ".$course_id." AND id = ".$row['id'];
5345
                    Database::query($sql);
5346
                }
5347
                $i++;
5348
            }
5349
        }