Integrate Advanced Skills plugin in the core - refs BT#9084

1.10.x
Angel Fernando Quiroz Campos 11 years ago
parent bb90300f23
commit 3cf13a775d
  1. 44
      main/inc/lib/skill.lib.php
  2. 2
      main/inc/lib/userportal.lib.php
  3. 3
      main/install/db_main.sql
  4. 3
      main/install/migrate-db-1.9.0-1.10.0-pre.sql
  5. 25
      main/social/home.php
  6. 14
      main/social/my_skills_report.php
  7. 4
      main/template/default/skill/drh_report.tpl
  8. 4
      main/template/default/skill/student_boss_report.tpl
  9. 2
      main/template/default/skill/student_report.tpl
  10. 4
      plugin/advancedskills/README.md
  11. 12
      plugin/advancedskills/config.php
  12. 8
      plugin/advancedskills/index.php
  13. 10
      plugin/advancedskills/install.php
  14. 9
      plugin/advancedskills/lang/spanish.php
  15. 10
      plugin/advancedskills/plugin.php
  16. 3
      plugin/advancedskills/readme.txt
  17. 149
      plugin/advancedskills/src/AdvancedSkills.php
  18. 10
      plugin/advancedskills/uninstall.php

@ -335,24 +335,12 @@ class SkillRelGradebook extends Model
*/
class SkillRelUser extends Model
{
public $columns = array('id', 'user_id', 'skill_id', 'acquired_skill_at', 'assigned_by');
public $columns = array('id', 'user_id', 'skill_id', 'acquired_skill_at', 'assigned_by', 'course_id', 'session_id');
public function __construct()
{
$this->table = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
//$this->table_user = Database::get_main_table(TABLE_MAIN_USER);
if (!class_exists('AdvancedSkills')) {
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once api_get_path(PLUGIN_PATH) . 'advancedskills/src/AdvancedSkills.php';
}
if (class_exists('AdvancedSkills')) {
if (AdvancedSkills::extraColumnsExists()) {
$this->columns[] = 'course_id';
$this->columns[] = 'session_id';
}
}
}
public function get_user_by_skills($skill_list)
@ -624,11 +612,6 @@ class Skill extends Model
$skill_gradebooks = $skill_gradebook->get_all(array('where' => array('gradebook_id = ?' => $gradebook_id)));
if (!empty($skill_gradebooks)) {
if (!class_exists('AdvancedSkills')) {
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once api_get_path(PLUGIN_PATH) . 'advancedskills/src/AdvancedSkills.php';
}
foreach ($skill_gradebooks as $skill_gradebook) {
$user_has_skill = $this->user_has_skill($user_id, $skill_gradebook['skill_id'], $courseId, $sessionId);
if (!$user_has_skill) {
@ -636,15 +619,10 @@ class Skill extends Model
'user_id' => $user_id,
'skill_id' => $skill_gradebook['skill_id'],
'acquired_skill_at' => api_get_utc_datetime(),
'course_id' => $courseId,
'session_id' => $sessionId
);
if (class_exists('AdvancedSkills')) {
if (AdvancedSkills::extraColumnsExists()) {
$params['course_id'] = $courseId;
$params['session_id'] = $sessionId;
}
}
$skill_rel_user->save($params);
}
}
@ -1013,21 +991,11 @@ class Skill extends Model
$whereConditions = array(
'user_id = ? ' => $user_id,
'AND skill_id = ? ' => $skill_id
'AND skill_id = ? ' => $skill_id,
'AND course_id = ? ' => $courseId,
'AND session_id = ? ' => $sessionId
);
if (!class_exists('AdvancedSkills')) {
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once api_get_path(PLUGIN_PATH) . 'advancedskills/src/AdvancedSkills.php';
}
if (class_exists('AdvancedSkills')) {
if (AdvancedSkills::extraColumnsExists()) {
$whereConditions['AND course_id = ? '] = $courseId;
$whereConditions['AND session_id = ? '] = $sessionId;
}
}
$result = Database::select('COUNT(1) AS qty', $this->table_skill_rel_user, array(
'where' => $whereConditions
), 'first');

@ -324,7 +324,7 @@ class IndexManager
if (api_get_setting('allow_skills_tool') == 'true') {
$content = '<ul class="nav nav-list">';
$content .= Display::tag('li', Display::url(get_lang('MySkills'), api_get_path(WEB_CODE_PATH).'social/skills_wheel.php'));
$content .= Display::tag('li', Display::url(get_lang('MySkills'), api_get_path(WEB_CODE_PATH).'social/my_skills_report.php'));
$allowSkillsManagement = api_get_setting('allow_hr_skills_management') == 'true';

@ -2878,8 +2878,11 @@ CREATE TABLE IF NOT EXISTS skill_rel_user (
skill_id int NOT NULL,
acquired_skill_at datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
assigned_by int NOT NULL,
course_id INT NOT NULL DEFAULT 0,
session_id INT NOT NULL DEFAULT 0
PRIMARY KEY (id)
);
ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id);
DROP TABLE IF EXISTS skill_profile;
CREATE TABLE IF NOT EXISTS skill_profile (

@ -13,6 +13,9 @@
-- This first part is for the main database
-- xxMAINxx
ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id;
ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id;
ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id);

@ -133,12 +133,6 @@ if (api_get_setting('allow_skills_tool') == 'true') {
$socialRightInformation .= '<div class="well_border">';
$skill = new Skill();
$ranking = $skill->get_user_skill_ranking(api_get_user_id());
$url = api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php';
$ranking_url = Display::url(
sprintf(get_lang('YourSkillRankingX'), $ranking),
$url,
array('class' => 'btn')
);
$skills = $skill->get_user_skills(api_get_user_id(), true);
@ -156,13 +150,24 @@ if (api_get_setting('allow_skills_tool') == 'true') {
}
$socialRightInformation .= Display::tag('ul', $lis);
}
$url = api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php';
$skill_wheel_url = Display::url(
$socialRightInformation .= "<div class=\"btn-group\">";
if (api_is_student() || api_is_student_boss() || api_is_drh()) {
$socialRightInformation .= Display::url(
get_lang('SkillsReport'),
api_get_path(WEB_CODE_PATH) . 'social/my_skills_report.php',
array('class' => 'btn')
);
}
$socialRightInformation .= Display::url(
get_lang('ViewSkillsWheel'),
$url,
api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php',
array('class' => 'btn')
);
$socialRightInformation .= Display::url(
sprintf(get_lang('YourSkillRankingX'), $ranking),
api_get_path(WEB_CODE_PATH) . 'social/skills_ranking.php',
array('class' => 'btn')
);
$socialRightInformation .= '<div class="btn-group">' . $skill_wheel_url . $ranking_url . '</div>';
$socialRightInformation .= '</div>';
}

@ -3,11 +3,9 @@
/**
* Show the skills report
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.advancedskills
* @package chamilo.social.skill
*/
require_once '../../main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once api_get_path(PLUGIN_PATH) . 'advancedskills/src/AdvancedSkills.php';
require_once '../inc/global.inc.php';
$isStudent = api_is_student();
$isStudentBosss = api_is_student_boss();
@ -56,7 +54,7 @@ if ($isStudent) {
$tableRows[] = $tableRow;
}
$tplPath = 'advancedskills/tpl/student.tpl';
$tplPath = 'skill/student_report.tpl';
} else if ($isStudentBosss) {
$selectedStudent = isset($_REQUEST['student']) ? intval($_REQUEST['student']) : 0;
@ -94,7 +92,7 @@ if ($isStudent) {
}
}
$tplPath = 'advancedskills/tpl/student_boss.tpl';
$tplPath = 'skill/student_boss_report.tpl';
$tpl->assign('followedStudents', $followedStudents);
$tpl->assign('selectedStudent', $selectedStudent);
@ -157,7 +155,7 @@ if ($isStudent) {
}
}
$tplPath = 'advancedskills/tpl/drh.tpl';
$tplPath = 'skill/drh_report.tpl';
$tpl->assign('action', $action);
@ -172,7 +170,7 @@ if ($isStudent) {
$tpl->assign('rows', $tableRows);
$contentTemplate = $tpl->fetch($tplPath);
$contentTemplate = $tpl->fetch("default/" . $tplPath);
$tpl->assign('content', $contentTemplate);
$tpl->display_one_col_template();

@ -1,6 +1,6 @@
{% if allowSkillsTool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'MySkills' | get_lang }}</a>
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a>
{% if allowDrhSkillsManagement %}
<a class="btn btn-default" href="{{ _p.web_main }}admin/skills_wheel.php">{{ 'ManageSkills' | get_lang }}</a>
{% endif %}
@ -77,4 +77,4 @@
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% endif %}
{% endif %}

@ -1,6 +1,6 @@
{% if allowSkillsTool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'MySkills' | get_lang }}</a>
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a>
</div>
{% endif %}
@ -42,4 +42,4 @@
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% endif %}
{% endif %}

@ -1,6 +1,6 @@
{% if allowSkillsTool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'MySkills' | get_lang }}</a>
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a>
</div>
{% endif %}

@ -1,4 +0,0 @@
Advanced Skills Plugin
======================
Alter the skill_rel_user table adding the course_id and session_id columns

@ -1,12 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Config the plugin
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.advancedskills
*/
//require_once '../../main/inc/global.inc.php';
require_once api_get_path(SYS_PATH) . 'main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH) . 'plugin.class.php';
require_once api_get_path(PLUGIN_PATH) . 'advancedskills/src/AdvancedSkills.php';

@ -1,8 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Index
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.advancedskills
*/
require_once __DIR__ . '/config.php';

@ -1,10 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Initialization install
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.advancedskills
*/
require_once __DIR__ . '/config.php';
AdvancedSkills::create()->install();

@ -1,9 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Strings to spanish L10n
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.advancedskills
*/
$strings['plugin_title'] = 'Advanced Skills';
$strings['plugin_comment'] = 'Altera la tabla skill_rel_user agregando las columnas course_id y session_id';

@ -1,10 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Init the plugin
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.advancedskills
*/
require_once __DIR__.'/config.php';
$plugin_info = AdvancedSkills::create()->get_info();

@ -1,3 +0,0 @@
<h1>Advanced Skills Plugin</h1>
<p>Alter the skill_rel_user table adding the course_id and session_id columns</p>

@ -1,149 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Plugin to add extra columns to skill_rel_user tablee
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.advancedskills
*/
class AdvancedSkills extends Plugin
{
/**
* Class constructor
*/
protected function __construct()
{
parent::__construct('1.0', 'Angel Fernando Quiroz Campos');
}
/**
* Instance the plugin
* @staticvar null $result
* @return Tour
*/
static function create()
{
static $result = null;
return $result ? $result : $result = new self();
}
/**
* Install the plugin
*/
public function install()
{
$this->addTableColumns();
$this->addIndex();
$this->addTab(get_lang('Skills'), 'plugin/advancedskills/report.php');
}
/**
* Uninstall the plugin
*/
public function uninstall()
{
$this->removeTableColumns();
$this->removeIndex();
$this->removeTab();
}
/**
* Add the course_id and session_id columns on skill_rel_user table
*/
private function addTableColumns()
{
$skillUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$sql = "ALTER TABLE $skillUserTable "
. "ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id";
Database::query($sql);
$sql = "ALTER TABLE $skillUserTable "
. "ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id";
Database::query($sql);
}
/**
* Remove the course_id and session_id columns on skill_rel_user table
*/
private function removeTableColumns()
{
$skillUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$sql = "ALTER TABLE $skillUserTable "
. "DROP course_id";
Database::query($sql);
$sql = "ALTER TABLE $skillUserTable "
. "DROP session_id";
Database::query($sql);
}
/**
* Add a index to course_id and session_id on skill_rel_user table
*/
private function addIndex()
{
$skillUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$sql = "ALTER TABLE $skillUserTable "
. "ADD INDEX idx_select_cs (course_id, session_id)";
Database::query($sql);
}
/**
* Remove a index to course_id and session_id on skill_rel_user table
*/
private function removeIndex()
{
$skillUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$sql = "DROP INDEX idx_select_cs ON $skillUserTable";
Database::query($sql);
}
/**
*
* @return boolean
*/
public static function extraColumnsExists()
{
$skillUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$sql = "SHOW COLUMNS FROM $skillUserTable";
$result = Database::query($sql);
while ($resultData = Database::fetch_assoc($result)) {
if ($resultData['Field'] == 'course_id' || $resultData['Field'] == 'session_id') {
return true;
}
}
return false;
}
/**
* Remove the plugin tab
*/
private function removeTab() {
$data = Database::select('comment', Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT), array(
'where' => array(
"variable = '?' AND title = '?'" => array('status', 'advancedskills')
)
), 'first');
if (!empty($data)) {
$this->deleteTab($data['comment']);
}
}
}

@ -1,10 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Initialization uninstall
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.plugin.advancedskills
*/
require_once __DIR__ . '/config.php';
AdvancedSkills::create()->uninstall();
Loading…
Cancel
Save