Code Duplication    Length = 25-33 lines in 2 locations

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

@@ 3541-3573 (lines=33) @@
3538
     * @param int $session_id
3539
     * @return int
3540
     */
3541
    public static function get_number_students_finish_exercise(
3542
        $exercise_id,
3543
        $course_code,
3544
        $session_id
3545
    ) {
3546
        $track_exercises = Database::get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES);
3547
        $track_attempt = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
3548
3549
        $exercise_id = intval($exercise_id);
3550
        $course_code = Database::escape_string($course_code);
3551
        $session_id = intval($session_id);
3552
3553
        $sql = "SELECT DISTINCT exe_user_id
3554
                FROM $track_exercises e
3555
                INNER JOIN $track_attempt a 
3556
                ON (a.exe_id = e.exe_id)
3557
                WHERE
3558
                    exe_exo_id 	 = $exercise_id AND
3559
                    course_code  = '$course_code' AND
3560
                    e.session_id = $session_id AND
3561
                    status = ''";
3562
        $result = Database::query($sql);
3563
        $return = 0;
3564
        if ($result) {
3565
            $return = Database::num_rows($result);
3566
3567
        }
3568
        return $return;
3569
    }
3570
3571
    /**
3572
     * @param string $in_name is the name and the id of the <select>
3573
     * @param string $in_default default value for option
3574
     * @param string $in_onchange
3575
     * @return string the html code of the <select>
3576
     */

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

@@ 1372-1396 (lines=25) @@
1369
     * @param int $user_id
1370
     * @return int The number of groups the user is subscribed in.
1371
     */
1372
    public static function user_in_number_of_groups($user_id, $cat_id = null)
1373
    {
1374
        $table_group_user = Database::get_course_table(TABLE_GROUP_USER);
1375
        $table_group = Database::get_course_table(TABLE_GROUP);
1376
        $user_id = intval($user_id);
1377
        $cat_id = intval($cat_id);
1378
1379
        $course_id = api_get_course_int_id();
1380
        $cat_condition = '';
1381
        if (!empty($cat_id)) {
1382
            $cat_condition = " AND g.category_id =  $cat_id ";
1383
        }
1384
1385
        $sql = "SELECT  COUNT(*) AS number_of_groups
1386
                FROM $table_group_user gu, $table_group g
1387
                WHERE
1388
                    gu.c_id = $course_id AND
1389
                    g.c_id = $course_id AND
1390
                    gu.user_id = $user_id AND
1391
                    g.iid = gu.group_id  
1392
                    $cat_condition";
1393
        $result = Database::query($sql);
1394
        $db_object = Database::fetch_object($result);
1395
1396
        return $db_object->number_of_groups;
1397
    }
1398
1399
    /**