Code Duplication    Length = 8-12 lines in 2 locations

main/exercise/question.class.php 1 location

@@ 519-530 (lines=12) @@
516
                        c_id = ".$courseId;
517
            $res = Database::query($sql);
518
            $row = Database::fetch_array($res);
519
            if ($row['nb'] > 0) {
520
                $sql = "UPDATE $table
521
                        SET category_id = $categoryId
522
                        WHERE
523
                            question_id = $question_id AND
524
                            c_id = ".$courseId;
525
                Database::query($sql);
526
            } else {
527
                $sql = "INSERT INTO $table (c_id, question_id, category_id)
528
                        VALUES (".$courseId.", $question_id, $categoryId)";
529
                Database::query($sql);
530
            }
531
532
            return true;
533
        }

main/lp/learnpath.class.php 1 location

@@ 3904-3911 (lines=8) @@
3901
        }
3902
        if ($num > 1) { // If there's only one element, no need to sort.
3903
            $order = $lps[$lp_id]['display_order'];
3904
            if ($order > 1) { // If it's the first element, no need to move up.
3905
                $sql = "UPDATE $lp_table SET display_order = $order
3906
                        WHERE c_id = $courseId AND id = ".$lp_order[$order - 1];
3907
                Database::query($sql);
3908
                $sql = "UPDATE $lp_table SET display_order = ".($order - 1)."
3909
                        WHERE c_id = $courseId AND id = ".$lp_id;
3910
                Database::query($sql);
3911
            }
3912
        }
3913
3914
        return true;