Code Duplication    Length = 15-20 lines in 3 locations

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

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

main/survey/survey.lib.php 2 locations

@@ 1523-1540 (lines=18) @@
1520
     * @author Patrick Cool <[email protected]>, Ghent University
1521
     * @version January 2007
1522
     */
1523
    public static function delete_all_survey_questions_options($survey_id, $shared = false)
1524
    {
1525
        // Table definitions
1526
        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
1527
        $course_id = api_get_course_int_id();
1528
        $course_condition = " c_id = $course_id AND ";
1529
        if ($shared) {
1530
            $course_condition = "";
1531
            $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION);
1532
        }
1533
1534
        $sql = "DELETE FROM $table_survey_question_option
1535
                WHERE $course_condition survey_id='".intval($survey_id)."'";
1536
1537
        // Deleting the options of the survey questions
1538
        Database::query($sql);
1539
        return true;
1540
    }
1541
1542
    /**
1543
     * This function deletes the options of a given question
@@ 1555-1574 (lines=20) @@
1552
     * @author Julio Montoya
1553
     * @version March 2007
1554
     */
1555
    public static function delete_survey_question_option($survey_id, $question_id, $shared = false)
1556
    {
1557
        $course_id = api_get_course_int_id();
1558
        $course_condition = " c_id = $course_id AND ";
1559
1560
        // Table definitions
1561
        $table_survey_question_option = Database :: get_course_table(TABLE_SURVEY_QUESTION_OPTION);
1562
        if ($shared) {
1563
            $course_condition = "";
1564
            $table_survey_question_option = Database :: get_main_table(TABLE_MAIN_SHARED_SURVEY_QUESTION_OPTION);
1565
        }
1566
1567
        // Deleting the options of the survey questions
1568
        $sql = "DELETE from $table_survey_question_option
1569
		        WHERE
1570
		            $course_condition survey_id='".intval($survey_id)."' AND
1571
		            question_id='".intval($question_id)."'";
1572
        Database::query($sql);
1573
        return true;
1574
    }
1575
1576
    /**
1577
     * SURVEY ANSWERS FUNCTIONS