Code Duplication    Length = 15-20 lines in 3 locations

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

@@ 2369-2383 (lines=15) @@
2366
     * @param int $courseId
2367
     * @return bool Returns TRUE if the session and the course are related, FALSE otherwise.
2368
     * */
2369
    public static function relation_session_course_exist($session_id, $courseId)
2370
    {
2371
        $tbl_session_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE);
2372
        $return_value = false;
2373
        $sql = "SELECT c_id FROM $tbl_session_course
2374
                WHERE
2375
                  session_id = " . intval($session_id) . " AND
2376
                  c_id = " . intval($courseId) . "";
2377
        $result = Database::query($sql);
2378
        $num = Database::num_rows($result);
2379
        if ($num > 0) {
2380
            $return_value = true;
2381
        }
2382
        return $return_value;
2383
    }
2384
2385
    /**
2386
     * Get the session information by name

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
        return true;
1520
    }
1521
1522
    /**
1523
     * This function deletes the options of a given question
@@ 1535-1554 (lines=20) @@
1532
     * @author Julio Montoya
1533
     * @version March 2007
1534
     */
1535
    public static function delete_survey_question_option($survey_id, $question_id, $shared = false)
1536
    {
1537
        $course_id = api_get_course_int_id();
1538
        $course_condition = " c_id = $course_id AND ";
1539
1540
        // Table definitions
1541
        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
1542
        if ($shared) {
1543
            $course_condition = "";
1544
            $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION);
1545
        }
1546
1547
        // Deleting the options of the survey questions
1548
        $sql = "DELETE from $table_survey_question_option
1549
		        WHERE
1550
		            $course_condition survey_id='".intval($survey_id)."' AND
1551
		            question_id='".intval($question_id)."'";
1552
        Database::query($sql);
1553
        return true;
1554
    }
1555
1556
    /**
1557
     * SURVEY ANSWERS FUNCTIONS