From eaec0034a9f49af5e8eb0032d0757e42a42d9106 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Wed, 17 Dec 2014 14:13:56 -0500 Subject: [PATCH] Add skills report to Boss Student role - refs BT#9084 --- main/mySpace/student.php | 4 ++ main/mySpace/team_skills.php | 72 +++++++++++++++++++ .../template/default/my_space/team_skills.tpl | 57 +++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 main/mySpace/team_skills.php create mode 100644 main/template/default/my_space/team_skills.tpl diff --git a/main/mySpace/student.php b/main/mySpace/student.php index eb7f474fc9..e8556e6804 100755 --- a/main/mySpace/student.php +++ b/main/mySpace/student.php @@ -210,6 +210,10 @@ if (api_is_drh()) { Display::return_icon('user_na.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), '#' ); + $actions .= Display::url( + Display::return_icon('skills.png', get_lang('Skills'), array(), ICON_SIZE_MEDIUM), + api_get_path(WEB_CODE_PATH) . 'mySpace/team_skills.php' + ); } $actions .= ''; diff --git a/main/mySpace/team_skills.php b/main/mySpace/team_skills.php new file mode 100644 index 0000000000..6babd8fdee --- /dev/null +++ b/main/mySpace/team_skills.php @@ -0,0 +1,72 @@ + "index.php", "name" => get_lang('MySpace')); + +$toolName = get_lang('Skills'); + +$userId = api_get_user_id(); +$selectedStudent = isset($_REQUEST['student']) ? intval($_REQUEST['student']) : 0; + +$tableRows = array(); + +$followedStudents = UserManager::getUsersFollowedByStudentBoss($userId); + +$skillTable = Database::get_main_table(TABLE_MAIN_SKILL); +$skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER); +$userTable = Database::get_main_table(TABLE_MAIN_USER); +$courseTable = Database::get_main_table(TABLE_MAIN_COURSE); + +foreach ($followedStudents as &$student) { + $student['completeName'] = api_get_person_name($student['firstname'], $student['lastname']); +} + +if ($selectedStudent > 0) { + $sql = "SELECT s.name, sru.acquired_skill_at, c.title c_name, c.directory c_directory " + . "FROM $skillTable s " + . "INNER JOIN $skillRelUserTable sru ON s.id = sru.skill_id " + . "INNER JOIN $courseTable c ON sru.course_id = c.id " + . "WHERE sru.user_id = $selectedStudent"; + + $result = Database::query($sql); + + while ($resultData = Database::fetch_assoc($result)) { + $row = array( + 'completeName' => $followedStudents[$selectedStudent]['completeName'], + 'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER) + ); + + if (file_exists(api_get_path(SYS_COURSE_PATH) . "{$resultData['c_directory']}/course-pic85x85.png")) { + $row['courseImage'] = api_get_path(WEB_COURSE_PATH) . "{$resultData['c_directory']}/course-pic85x85.png"; + } else { + $row['courseImage'] = Display::return_icon('course.png', null, null, ICON_SIZE_BIG, null, true); + } + + $tableRows[] = array_merge($resultData, $row); + } +} + +/* + * View + */ +$tpl = new Template($toolName); + +$tpl->assign('followedStudents', $followedStudents); +$tpl->assign('selectedStudent', $selectedStudent); + +$tpl->assign('rows', $tableRows); + +$contentTemplate = $tpl->get_template('my_space/team_skills.tpl'); + +$tpl->display($contentTemplate); diff --git a/main/template/default/my_space/team_skills.tpl b/main/template/default/my_space/team_skills.tpl new file mode 100644 index 0000000000..504c3ecf78 --- /dev/null +++ b/main/template/default/my_space/team_skills.tpl @@ -0,0 +1,57 @@ +{% extends "default/layout/main.tpl" %} + +{% block body %} +
+ + +

{{ 'SkillsAcquired' | get_lang }}

+ +
+ + + +
+ + {% if rows %} + + + + + + + + + + + {% for row in rows %} + + + + + + + {% endfor %} + +
{{ 'Student' | get_lang }}{{ 'SkillsAcquired' | get_lang }}{{ 'Date' | get_lang }}{{ 'Course' | get_lang }}
{{ row.completeName }}{{ row.name }}{{ row.achievedAt }}{{ row.c_name }} {{ row.c_name }}
+ {% else %} +
+ {{ 'NoResults' | get_lang }} +
+ {% endif %} +
+{% endblock %} \ No newline at end of file