Code Duplication    Length = 15-20 lines in 3 locations

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

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

main/survey/survey.lib.php 2 locations

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