Code Duplication    Length = 38-38 lines in 2 locations

main/inc/lib/skill.lib.php 2 locations

@@ 1363-1400 (lines=38) @@
1360
     * @param int $courseId The course id
1361
     * @return array The skills list
1362
     */
1363
    public function listAchievedByCourse($courseId)
1364
    {
1365
        $courseId = intval($courseId);
1366
1367
        if ($courseId == 0) {
1368
            return array();
1369
        }
1370
1371
        $list = array();
1372
1373
        $sql = "SELECT
1374
                    course.id c_id,
1375
                    course.title c_name,
1376
                    course.directory c_directory,
1377
                    user.user_id,
1378
                    user.lastname,
1379
                    user.firstname,
1380
                    user.username,
1381
                    skill.id skill_id,
1382
                    skill.name skill_name,
1383
                    sru.acquired_skill_at
1384
                FROM {$this->table_skill_rel_user} AS sru
1385
                INNER JOIN {$this->table_course}
1386
                ON sru.course_id = course.id
1387
                INNER JOIN {$this->table_user}
1388
                ON sru.user_id = user.user_id
1389
                INNER JOIN {$this->table}
1390
                ON sru.skill_id = skill.id
1391
                WHERE course.id = $courseId";
1392
1393
        $result = Database::query($sql);
1394
1395
        while ($row = Database::fetch_assoc($result)) {
1396
            $list[] = $row;
1397
        }
1398
1399
        return $list;
1400
    }
1401
1402
    /**
1403
     * Get the users list who achieved a skill
@@ 1408-1445 (lines=38) @@
1405
     *
1406
     * @return array The users list
1407
     */
1408
    public function listUsersWhoAchieved($skillId)
1409
    {
1410
        $skillId = intval($skillId);
1411
1412
        if ($skillId == 0) {
1413
            return array();
1414
        }
1415
1416
        $list = array();
1417
1418
        $sql = "SELECT
1419
                    course.id c_id,
1420
                    course.title c_name,
1421
                    course.directory c_directory,
1422
                    user.user_id,
1423
                    user.lastname,
1424
                    user.firstname,
1425
                    user.username,
1426
                    skill.id skill_id,
1427
                    skill.name skill_name,
1428
                    sru.acquired_skill_at
1429
                FROM {$this->table_skill_rel_user} AS sru
1430
                INNER JOIN {$this->table_course}
1431
                ON sru.course_id = course.id
1432
                INNER JOIN {$this->table_user}
1433
                ON sru.user_id = user.user_id
1434
                INNER JOIN {$this->table}
1435
                ON sru.skill_id = skill.id
1436
                WHERE skill.id = $skillId ";
1437
1438
        $result = Database::query($sql);
1439
1440
        while ($row = Database::fetch_assoc($result)) {
1441
            $list[] = $row;
1442
        }
1443
1444
        return $list;
1445
    }
1446
1447
    /**
1448
     * Get the session list where the user can achieve a skill