Code Duplication    Length = 15-20 lines in 4 locations

main/survey/survey.lib.php 2 locations

@@ 1503-1520 (lines=18) @@
1500
     * @author Patrick Cool <[email protected]>, Ghent University
1501
     * @version January 2007
1502
     */
1503
    public static function delete_all_survey_questions_options($survey_id, $shared = false)
1504
    {
1505
        // Table definitions
1506
        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
1507
        $course_id = api_get_course_int_id();
1508
        $course_condition = " c_id = $course_id AND ";
1509
        if ($shared) {
1510
            $course_condition = "";
1511
            $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION);
1512
        }
1513
1514
        $sql = "DELETE FROM $table_survey_question_option
1515
                WHERE $course_condition survey_id='".intval($survey_id)."'";
1516
1517
        // Deleting the options of the survey questions
1518
        Database::query($sql);
1519
1520
        return true;
1521
    }
1522
1523
    /**
@@ 1536-1555 (lines=20) @@
1533
     * @author Julio Montoya
1534
     * @version March 2007
1535
     */
1536
    public static function delete_survey_question_option($survey_id, $question_id, $shared = false)
1537
    {
1538
        $course_id = api_get_course_int_id();
1539
        $course_condition = " c_id = $course_id AND ";
1540
1541
        // Table definitions
1542
        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
1543
        if ($shared) {
1544
            $course_condition = "";
1545
            $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION);
1546
        }
1547
1548
        // Deleting the options of the survey questions
1549
        $sql = "DELETE from $table_survey_question_option
1550
		        WHERE
1551
		            $course_condition survey_id='".intval($survey_id)."' AND
1552
		            question_id='".intval($question_id)."'";
1553
        Database::query($sql);
1554
        return true;
1555
    }
1556
1557
    /**
1558
     * SURVEY ANSWERS FUNCTIONS

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

@@ 2487-2501 (lines=15) @@
2484
     * @param int $courseId
2485
     * @return bool Returns TRUE if the session and the course are related, FALSE otherwise.
2486
     * */
2487
    public static function relation_session_course_exist($session_id, $courseId)
2488
    {
2489
        $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
2490
        $return_value = false;
2491
        $sql = "SELECT c_id FROM $tbl_session_course
2492
                WHERE
2493
                  session_id = " . intval($session_id) . " AND
2494
                  c_id = " . intval($courseId);
2495
        $result = Database::query($sql);
2496
        $num = Database::num_rows($result);
2497
        if ($num > 0) {
2498
            $return_value = true;
2499
        }
2500
        return $return_value;
2501
    }
2502
2503
    /**
2504
     * Get the session information by name

main/forum/forumfunction.inc.php 1 location

@@ 2060-2075 (lines=16) @@
2057
 * @author Patrick Cool <[email protected]>, Ghent University
2058
 * @version february 2006, dokeos 1.8
2059
 */
2060
function get_post_information($post_id)
2061
{
2062
    $table_posts = Database :: get_course_table(TABLE_FORUM_POST);
2063
    $table_users = Database :: get_main_table(TABLE_MAIN_USER);
2064
    $course_id = api_get_course_int_id();
2065
2066
    $sql = "SELECT posts.*, email FROM ".$table_posts." posts, ".$table_users." users
2067
            WHERE
2068
                c_id = $course_id AND
2069
                posts.poster_id=users.user_id AND
2070
                posts.post_id = ".intval($post_id);
2071
    $result = Database::query($sql);
2072
    $row = Database::fetch_array($result, 'ASSOC');
2073
2074
    return $row;
2075
}
2076
2077
/**
2078
 * This function retrieves all the information of a thread