Add skills report for DRH role - refs BT#9084

1.10.x
Angel Fernando Quiroz Campos 11 years ago
parent 990fdf1a97
commit 41380c91c3
  1. 60
      main/inc/lib/skill.lib.php
  2. 7
      main/mySpace/course.php
  3. 4
      main/mySpace/index.php
  4. 7
      main/mySpace/session.php
  5. 82
      main/mySpace/skills.php
  6. 6
      main/mySpace/student.php
  7. 6
      main/mySpace/teachers.php
  8. 84
      main/template/default/my_space/skills.tpl

@ -1028,4 +1028,64 @@ class Skill extends Model
return false;
}
public function listAchievedByCourse($courseId)
{
$courseId = intval($courseId);
if ($courseId == 0) {
return array();
}
$list = array();
$sql = "SELECT course.id c_id, course.title c_name, user.user_id, user.lastname, "
. "user.firstname, user.username, skill.id skill_id, skill.name skill_name, sru.acquired_skill_at "
. "FROM {$this->table_skill_rel_user} AS sru "
. "INNER JOIN {$this->table_course} "
. "ON sru.course_id = course.id "
. "INNER JOIN {$this->table_user} "
. "ON sru.user_id = user.user_id "
. "INNER JOIN {$this->table} "
. "ON sru.skill_id = skill.id "
. "WHERE course.id = $courseId";
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) {
$list[] = $row;
}
return $list;
}
public function listUsersWhoAchieved($skillId)
{
$skillId = intval($skillId);
if ($skillId == 0) {
return array();
}
$list = array();
$sql = "SELECT course.id c_id, course.title c_name, user.user_id, user.lastname, "
. "user.firstname, user.username, skill.id skill_id, skill.name skill_name, sru.acquired_skill_at "
. "FROM {$this->table_skill_rel_user} AS sru "
. "INNER JOIN {$this->table_course} "
. "ON sru.course_id = course.id "
. "INNER JOIN {$this->table_user} "
. "ON sru.user_id = user.user_id "
. "INNER JOIN {$this->table} "
. "ON sru.skill_id = skill.id "
. "WHERE skill.id = $skillId";
$result = Database::query($sql);
while ($row = Database::fetch_assoc($result)) {
$list[] = $row;
}
return $list;
}
}

@ -113,6 +113,13 @@ if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
}
}
if (api_is_drh()) {
$menu_items[] = Display::url(
Display::return_icon('skills.png', get_lang('Skills'), array(), ICON_SIZE_MEDIUM),
'skills.php'
);
}
echo '<div class="actions">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {

@ -107,6 +107,10 @@ if ($is_drh) {
$menu_items[] = Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php');
$menu_items[] = Display::url(Display::return_icon('empty_evaluation.png', get_lang('CompanyReport'), array(), ICON_SIZE_MEDIUM), 'company_reports.php');
$menu_items[] = Display::url(Display::return_icon('evaluation_rate.png', get_lang('CompanyReportResumed'), array(), ICON_SIZE_MEDIUM), 'company_reports_resumed.php');
$menu_items[] = Display::url(
Display::return_icon('skills.png', get_lang('Skills'), array(), ICON_SIZE_MEDIUM),
'skills.php'
);
}
echo '<div id="actions" class="actions">';

@ -60,6 +60,13 @@ if (api_is_drh() || api_is_session_admin() || api_is_platform_admin()) {
);
}
if (api_is_drh()) {
$menu_items[] = Display::url(
Display::return_icon('skills.png', get_lang('Skills'), array(), ICON_SIZE_MEDIUM),
'skills.php'
);
}
echo '<div class="actions">';
$nb_menu_items = count($menu_items);
if ($nb_menu_items > 1) {

@ -0,0 +1,82 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Skills reporting
* @package chamilo.reporting
*/
require_once '../inc/global.inc.php';
$this_section = SECTION_TRACKING;
$interbreadcrumb[] = array("url" => "index.php", "name" => get_lang('MySpace'));
$toolName = get_lang('Skills');
$selectedCourse = isset($_REQUEST['course']) ? intval($_REQUEST['course']) : null;
$selectedSkill = isset($_REQUEST['skill']) ? intval($_REQUEST['skill']) : 0;
$action = null;
if (!empty($selectedCourse)) {
$action = 'filterByCourse';
} else if (!empty($selectedSkill)) {
$action = 'filterBySkill';
}
$userId = api_get_user_id();
$courses = CourseManager::getCoursesFollowedByUser(
$userId, DRH, null, null, null, null, false
);
$tableRows = array();
$reportTitle = null;
$objSkill = new Skill();
$skills = $objSkill->get_all();
switch ($action) {
case 'filterByCourse':
$course = api_get_course_info_by_id($selectedCourse);
$reportTitle = sprintf(get_lang('AchievedSkillByCourseX'), $course['name']);
$tableRows = $objSkill->listAchievedByCourse($selectedCourse);
break;
case 'filterBySkill':
$skill = $objSkill->get($selectedSkill);
$reportTitle = sprintf(get_lang('StudentsWhoAchievedTheSkillX'), $skill['name']);
$students = UserManager::getUsersFollowedByUser($userId, STUDENT, false, false, false, null, null, null, null,
null, null, DRH);
foreach ($students as $student) {
$tableRows = $objSkill->listUsersWhoAchieved($selectedSkill, $student['user_id']);
}
break;
}
foreach ($tableRows as &$row) {
$row['completeName'] = api_get_person_name($row['firstname'], $row['lastname']);
$row['achievedAt'] = api_format_date($row['acquired_skill_at'], DATE_FORMAT_NUMBER);
}
/*
* View
*/
$tpl = new Template($toolName);
$tpl->assign('courses', $courses);
$tpl->assign('skills', $skills);
$tpl->assign('selectedCourse', $selectedCourse);
$tpl->assign('selectedSkill', $selectedSkill);
$tpl->assign('reportTitle', $reportTitle);
$tpl->assign('rows', $tableRows);
$contentTemplate = $tpl->get_template('my_space/skills.tpl');
$tpl->display($contentTemplate);

@ -186,7 +186,11 @@ if (api_is_drh()) {
Display::url(Display::return_icon('user_na.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), '#'),
Display::url(Display::return_icon('teacher.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php'),
Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php'),
Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php')
Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php'),
Display::url(
Display::return_icon('skills.png', get_lang('Skills'), array(), ICON_SIZE_MEDIUM),
'skills.php'
)
);
$nb_menu_items = count($menu_items);

@ -186,7 +186,11 @@ if (api_is_drh()) {
Display::url(Display::return_icon('user.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM), 'student.php'),
Display::url(Display::return_icon('teacher_na.png', get_lang('Trainers'), array(), ICON_SIZE_MEDIUM), 'teachers.php'),
Display::url(Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_MEDIUM), 'course.php'),
Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php')
Display::url(Display::return_icon('session.png', get_lang('Sessions'), array(), ICON_SIZE_MEDIUM), 'session.php'),
Display::url(
Display::return_icon('skills.png', get_lang('Skills'), array(), ICON_SIZE_MEDIUM),
'skills.php'
)
);
$nb_menu_items = count($menu_items);

@ -0,0 +1,84 @@
{% extends "default/layout/main.tpl" %}
{% block body %}
<div class="span12">
<div class="actions">
<a href="{{ _p.web_main }}auth/my_progress.php">
<img src="{{ _p.web_img }}icons/32/stats.png" alt="Ver mis estadísticas" title="Ver mis estadísticas">
</a>
<a href="{{ _p.web_main }}mySpace/student.php">
<img src="{{ _p.web_img }}icons/32/user.png" alt="Estudiantes" title="Estudiantes">
</a>
<a href="{{ _p.web_main }}mySpace/teachers.php">
<img src="{{ _p.web_img }}icons/32/teacher.png" alt="Profesores" title="Profesores">
</a>
<a href="{{ _p.web_main }}mySpace/course.php">
<img src="{{ _p.web_img }}icons/32/course.png" alt="Cursos" title="Cursos">
</a>
<a href="{{ _p.web_main }}mySpace/session.php">
<img src="{{ _p.web_img }}icons/32/session.png" alt="Sesiones de formación" title="Sesiones de formación">
</a>
<a href="{{ _p.web_main }}mySpace/skills.php">
<img src="{{ _p.web_img }}icons/32/skills.png" alt="Competencias" title="Competencias">
</a>
</div>
<h1 class="page-header">{{ 'Skills' | get_lang }}</h1>
<div class="row">
<div class="span6">
<form class="form-inline" method="post" action="{{ _p.web_self }}">
<label for="course">{{ 'Courses' | get_lang }}</label>
<select name="course" id="course">
<option value="0">{{ 'Select' | get_lang }}</option>
{% for course in courses %}
<option value="{{ course.id }}" {{ (course.id == selectedCourse) ? 'selected' : '' }}>{{ course.title }}</option>
{% endfor %}
</select>
<button type="submit" class="btn">{{ 'Filter' | get_lang }}</button>
</form>
</div>
<div class="span6">
<form class="form-inline" method="post" action="{{ _p.web_self }}">
<label for="skill">{{ 'Skills' | get_lang }}</label>
<select name="skill" id="skill">
<option value="0">{{ 'Select' | get_lang }}</option>
{% for skill in skills %}
<option value="{{ skill.id }}" {{ (skill.id == selectedSkill) ? 'selected' : '' }}>{{ skill.name }}</option>
{% endfor %}
</select>
<button type="submit" class="btn">{{ 'Filter' | get_lang }}</button>
</form>
</div>
</div>
<h2 class="page-header">{{ reportTitle }} <small>{{ reportSubTitle }}</small></h2>
{% if rows %}
<table class="table">
<thead>
<tr>
<th>{{ 'Course' | get_lang }}</th>
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.c_name }}</td>
<td>{{ row.skill_name }}</td>
<td>{{ row.completeName }}</td>
<td>{{ row.achievedAt }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% endif %}
</div>
{% endblock %}
Loading…
Cancel
Save