Code Duplication    Length = 38-38 lines in 2 locations

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

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