Code Duplication    Length = 8-12 lines in 2 locations

main/exercise/question.class.php 1 location

@@ 534-545 (lines=12) @@
531
                        c_id = ".$courseId;
532
            $res = Database::query($sql);
533
            $row = Database::fetch_array($res);
534
            if ($row['nb'] > 0) {
535
                $sql = "UPDATE $table
536
                        SET category_id = $categoryId
537
                        WHERE
538
                            question_id = $question_id AND
539
                            c_id = ".$courseId;
540
                Database::query($sql);
541
            } else {
542
                $sql = "INSERT INTO $table (c_id, question_id, category_id)
543
                        VALUES (".$courseId.", $question_id, $categoryId)";
544
                Database::query($sql);
545
            }
546
547
            return true;
548
        }

main/lp/learnpath.class.php 1 location

@@ 3928-3935 (lines=8) @@
3925
        }
3926
        if ($num > 1) { // If there's only one element, no need to sort.
3927
            $order = $lps[$lp_id]['display_order'];
3928
            if ($order > 1) { // If it's the first element, no need to move up.
3929
                $sql = "UPDATE $lp_table SET display_order = $order
3930
                        WHERE c_id = $courseId AND id = ".$lp_order[$order - 1];
3931
                Database::query($sql);
3932
                $sql = "UPDATE $lp_table SET display_order = ".($order - 1)."
3933
                        WHERE c_id = $courseId AND id = ".$lp_id;
3934
                Database::query($sql);
3935
            }
3936
        }
3937
3938
        return true;