Merge branch 'AngelFQC-9084' into 1.10.x

1.10.x
Yannick Warnier 10 years ago
commit ea6311ca62
  1. 89
      main/admin/dashboard_add_users_to_user.php
  2. 1
      main/admin/user_add.php
  3. 1
      main/admin/user_edit.php
  4. 36
      main/admin/user_list.php
  5. 13
      main/auth/my_progress.php
  6. 4
      main/exercice/exercise.class.php
  7. 6
      main/exercice/exercise.lib.php
  8. 2
      main/exercice/exercise_report.php
  9. 6
      main/exercice/exercise_show.php
  10. 30
      main/gradebook/lib/be/category.class.php
  11. 16
      main/gradebook/lib/be/evallink.class.php
  12. 2
      main/gradebook/lib/be/exerciselink.class.php
  13. 19
      main/gradebook/lib/fe/flatviewtable.class.php
  14. 25
      main/gradebook/lib/flatview_data_generator.class.php
  15. 2
      main/gradebook/lib/scoredisplay.class.php
  16. 2
      main/inc/ajax/model.ajax.php
  17. 10
      main/inc/lib/banner.lib.php
  18. 5
      main/inc/lib/certificate.lib.php
  19. 19
      main/inc/lib/main_api.lib.php
  20. 2
      main/inc/lib/sessionmanager.lib.php
  21. 105
      main/inc/lib/skill.lib.php
  22. 6
      main/inc/lib/sortable_table.class.php
  23. 120
      main/inc/lib/usermanager.lib.php
  24. 2
      main/inc/lib/userportal.lib.php
  25. 10
      main/install/db_main.sql
  26. 5
      main/install/migrate-db-1.9.0-1.10.0-pre.sql
  27. 6
      main/lang/english/trad4all.inc.php
  28. 4
      main/lang/french/trad4all.inc.php
  29. 9
      main/lang/spanish/trad4all.inc.php
  30. 4
      main/mySpace/myStudents.php
  31. 27
      main/mySpace/student.php
  32. 2
      main/mySpace/teachers.php
  33. 25
      main/social/home.php
  34. 176
      main/social/my_skills_report.php
  35. 134
      main/template/default/layout/footer.tpl
  36. 80
      main/template/default/skill/drh_report.tpl
  37. 45
      main/template/default/skill/student_boss_report.tpl
  38. 32
      main/template/default/skill/student_report.tpl

@ -40,6 +40,8 @@ $user_info = api_get_user_info($user_id);
$user_anonymous = api_get_anonymous_id();
$current_user_id = api_get_user_id();
$userStatus = api_get_user_status($user_id);
$firstLetterUser = isset($_POST['firstLetterUser']) ? $_POST['firstLetterUser'] : null;
// setting the name of the tool
@ -47,6 +49,8 @@ if (UserManager::is_admin($user_id)) {
$tool_name= get_lang('AssignUsersToPlatformAdministrator');
} else if ($user_info['status'] == SESSIONADMIN) {
$tool_name= get_lang('AssignUsersToSessionsAdministrator');
} else if ($user_info['status'] == STUDENT_BOSS) {
$tool_name= get_lang('AssignUsersToBoss');
} else {
$tool_name= get_lang('AssignUsersToHumanResourcesManager');
}
@ -62,7 +66,7 @@ if (!api_is_platform_admin()) {
function search_users($needle,$type)
{
global $tbl_access_url_rel_user, $tbl_user, $user_anonymous, $current_user_id, $user_id;
global $tbl_access_url_rel_user, $tbl_user, $user_anonymous, $current_user_id, $user_id, $userStatus;
$xajax_response = new XajaxResponse();
$return = '';
@ -70,8 +74,17 @@ function search_users($needle,$type)
// xajax send utf8 datas... datas in db can be non-utf8 datas
$charset = api_get_system_encoding();
$needle = api_convert_encoding($needle, $charset, 'utf-8');
$assigned_users_to_hrm = array();
switch ($userStatus) {
case DRH:
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
break;
case STUDENT_BOSS:
$assigned_users_to_hrm = UserManager::getUsersFollowedByStudentBoss($user_id);
break;
}
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
$assigned_users_id = array_keys($assigned_users_to_hrm);
$without_assigned_users = '';
@ -92,7 +105,7 @@ function search_users($needle,$type)
LEFT JOIN $tbl_access_url_rel_user au ON (au.user_id = user.user_id)
WHERE
".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
status NOT IN(".DRH.", ".SESSIONADMIN.") AND
status NOT IN(".DRH.", ".SESSIONADMIN.", " . STUDENT_BOSS . ") AND
user.user_id NOT IN ($user_anonymous, $current_user_id, $user_id)
$without_assigned_users AND
access_url_id = ".api_get_current_access_url_id()."
@ -104,7 +117,7 @@ function search_users($needle,$type)
FROM $tbl_user user
WHERE
".(api_sort_by_first_name() ? 'firstname' : 'lastname')." LIKE '$needle%' AND
status NOT IN(".DRH.", ".SESSIONADMIN.") AND
status NOT IN(".DRH.", ".SESSIONADMIN.", " . STUDENT_BOSS . ") AND
user_id NOT IN ($user_anonymous, $current_user_id, $user_id)
$without_assigned_users
$order_clause
@ -127,10 +140,19 @@ function search_users($needle,$type)
username LIKE "'.$needle.'%" OR
firstname LIKE "'.$needle.'%" OR
lastname LIKE "'.$needle.'%"
) AND
user.status<>6 AND user.status<>'.DRH.' '.
$order_clause.
' LIMIT 11';
) AND ';
switch ($userStatus) {
case DRH:
$sql .= " user.status <> 6 AND user.status <> " . DRH;
break;
case STUDENT_BOSS:
$sql .= " user.status <> 6 AND user.status <> " . STUDENT_BOSS;
break;
}
$sql .= " $order_clause LIMIT 11";
$rs = Database::query($sql);
$i = 0;
while ($user = Database :: fetch_array($rs)) {
@ -267,7 +289,18 @@ if (!empty($filters) && !empty($filterData)) {
$msg = '';
if (isset($_POST['formSent']) && intval($_POST['formSent']) == 1) {
$user_list = $_POST['UsersList'];
$affected_rows = UserManager::suscribe_users_to_hr_manager($user_id, $user_list);
switch ($userStatus) {
case DRH:
$affected_rows = UserManager::suscribe_users_to_hr_manager($user_id, $user_list);
break;
case STUDENT_BOSS;
$affected_rows = UserManager::subscribeUsersToBoss($user_id, $user_list);
break;
default:
$affected_rows = 0;
}
if ($affected_rows) {
$msg = get_lang('AssignedUsersHaveBeenUpdatedSuccessfully');
}
@ -278,11 +311,27 @@ Display::display_header($tool_name);
// actions
echo '<div class="actions">';
echo '<span style="float: right;margin:0px;padding:0px;">
<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.
Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignCourses').'</a>
<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.
Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'), array('style'=>'vertical-align:middle')).' '.get_lang('AssignSessions').'</a></span>';
if ($userStatus != STUDENT_BOSS) {
$actions = Display::url(
Display::return_icon('course_add.gif', get_lang('AssignCourses'),
array(
'style' => 'vertical-align:middle'
)) . get_lang('AssignCourses'), "dashboard_add_courses_to_user.php?user=$user_id"
);
$actions .= Display::url(
Display::return_icon('view_more_stats.gif', get_lang('AssignSessions'),
array(
'style' => 'vertical-align:middle'
)) . get_lang('AssignSessions'), "dashboard_add_sessions_to_user.php?user=$user_id"
);
echo Display::span($actions, array(
'style' => 'float: right; margin: 0; paddingg: 0;'
));
}
echo Display::url(get_lang('AdvancedSearch'), '#', array('class' => 'advanced_options', 'id' => 'advanced_search'));
echo '</div>';
@ -294,7 +343,15 @@ echo Display::page_header(
sprintf(get_lang('AssignUsersToX'), api_get_person_name($user_info['firstname'], $user_info['lastname']))
);
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
switch ($userStatus) {
case DRH:
$assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id);
break;
case STUDENT_BOSS;
$assigned_users_to_hrm = UserManager::getUsersFollowedByStudentBoss($user_id);
break;
}
$assigned_users_id = array_keys($assigned_users_to_hrm);
$without_assigned_users = '';
if (count($assigned_users_id) > 0) {
@ -368,6 +425,8 @@ if(!empty($msg)) {
echo get_lang('AssignedUsersListToPlatformAdministrator');
} else if ($user_info['status'] == SESSIONADMIN) {
echo get_lang('AssignedUsersListToSessionsAdministrator');
} else if ($user_info['status'] == STUDENT_BOSS) {
echo get_lang('AssignedUsersListToStudentBoss');
} else {
echo get_lang('AssignedUsersListToHumanResourcesManager');
}

@ -198,6 +198,7 @@ $status[COURSEMANAGER] = get_lang('Teacher');
$status[STUDENT] = get_lang('Learner');
$status[DRH] = get_lang('Drh');
$status[SESSIONADMIN] = get_lang('SessionsAdmin');
$status[STUDENT_BOSS] = get_lang('RoleStudentBoss');
$form->addElement('select', 'status', get_lang('Profile'), $status, array('id' => 'status_select', 'class'=>'chzn-select', 'onchange' => 'javascript: display_drh_list();'));

@ -211,6 +211,7 @@ $status[COURSEMANAGER] = get_lang('Teacher');
$status[STUDENT] = get_lang('Learner');
$status[DRH] = get_lang('Drh');
$status[SESSIONADMIN] = get_lang('SessionsAdmin');
$status[STUDENT_BOSS] = get_lang('RoleStudentBoss');
$form->addElement('select', 'status', get_lang('Profile'), $status, array('id' => 'status_select', 'onchange' => 'javascript: display_drh_list();','class'=>'chzn-select'));

@ -579,13 +579,35 @@ function modify_filter($user_id, $url_params, $row) {
$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
}*/
} else {
if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id)) {
$result .= '<a href="dashboard_add_users_to_user.php?user='.$user_id.'">'.Display::return_icon('user_subscribe_course.png', get_lang('AssignUsers'),'',ICON_SIZE_SMALL).'</a>';
$result .= '<a href="dashboard_add_courses_to_user.php?user='.$user_id.'">'.Display::return_icon('course_add.gif', get_lang('AssignCourses')).'</a>&nbsp;&nbsp;';
$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
} else if ($current_user_status_label == $statusname[SESSIONADMIN]) {
$result .= '<a href="dashboard_add_sessions_to_user.php?user='.$user_id.'">'.Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')).'</a>&nbsp;&nbsp;';
}
if ($current_user_status_label == $statusname[SESSIONADMIN]) {
$result .= Display::url(
Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')),
"dashboard_add_sessions_to_user.php?user={$user_id}"
);
} else {
if (
$current_user_status_label == $statusname[DRH] ||
UserManager::is_admin($user_id) ||
$current_user_status_label == $statusname[STUDENT_BOSS]
) {
$result .= Display::url(
Display::return_icon('user_subscribe_course.png', get_lang('AssignUsers'), '', ICON_SIZE_SMALL),
"dashboard_add_users_to_user.php?user={$user_id}"
);
}
if ($current_user_status_label == $statusname[DRH] || UserManager::is_admin($user_id)) {
$result .= Display::url(
Display::return_icon('course_add.gif', get_lang('AssignCourses')),
"dashboard_add_courses_to_user.php?user={$user_id}"
);
$result .= Display::url(
Display::return_icon('view_more_stats.gif', get_lang('AssignSessions')),
"dashboard_add_sessions_to_user.php?user={$user_id}"
);
}
}
}
if (api_is_platform_admin()) {

@ -50,6 +50,9 @@ $user_id = api_get_user_id();
$course_user_list = CourseManager::get_courses_list_by_user_id($user_id);
$dates = $issues = '';
$sessionId = isset($_GET['session_id']) ? intval($_GET['session_id']) : 0;
$courseCode = isset($_GET['course']) ? Security::remove_XSS($_GET['course']) : null;
if (!empty($course_user_list)) {
$items = MySpace::get_connections_from_course_list($user_id, $course_user_list);
@ -82,8 +85,10 @@ if (!empty($course_user_list)) {
}
}
$content .= Tracking::show_user_progress(api_get_user_id(), $_GET['session_id']);
$content .= Tracking::show_course_detail(api_get_user_id(), $_GET['course'], $_GET['session_id']);
$content = '';
$content .= Tracking::show_user_progress(api_get_user_id(), $sessionId);
$content .= Tracking::show_course_detail(api_get_user_id(), $courseCode, $sessionId);
if (!empty($dates)) {
if (!empty($content)) {
@ -104,11 +109,13 @@ if (!empty($dates)) {
</div></div>';
}
$message = null;
if (empty($content)) {
$message = Display::return_message(get_lang('NoDataAvailable'), 'warning');
}
$tpl = new Template($tool_name);
$tpl = new Template($nameTools);
$tpl->assign('message', $message);
$tpl->assign('content', $content);

@ -2341,14 +2341,14 @@ class Exercise
$choice[$ind] = 1;
}
$studentChoice = $choice[$numAnswer];
$studentChoice = isset($choice[$numAnswer]) ? $choice[$numAnswer] : null;
$real_answers[$answerId] = (bool)$studentChoice;
if ($studentChoice) {
$questionScore +=$answerWeighting;
}
} else {
$studentChoice = $choice[$numAnswer];
$studentChoice = isset($choice[$numAnswer]) ? $choice[$numAnswer] : null;
$real_answers[$answerId] = (bool)$studentChoice;
if (isset($studentChoice)) {

@ -1198,7 +1198,7 @@ function get_exam_results_data(
$course_code = api_get_course_id();
$sessionId = api_get_session_id();
$is_allowedToEdit = api_is_allowed_to_edit(null,true) || api_is_allowed_to_edit(true) || api_is_drh();
$is_allowedToEdit = api_is_allowed_to_edit(null,true) || api_is_allowed_to_edit(true) || api_is_drh() || api_is_student_boss();
$TBL_USER = Database :: get_main_table(TABLE_MAIN_USER);
$TBL_EXERCICES = Database :: get_course_table(TABLE_QUIZ_TEST);
@ -1506,8 +1506,8 @@ function get_exam_results_data(
Display :: return_icon('history.gif', get_lang('ViewHistoryChange')).'</a>';
}
// Admin can always delete the attempt
if ($locked == false || api_is_platform_admin()) {
//Admin can always delete the attempt
if (($locked == false || api_is_platform_admin()) && !api_is_student_boss()) {
$ip = TrackingUserLog::get_ip_from_user_event($results[$i]['exe_user_id'], date('Y-m-d h:i:s'), false);
$actions .= '<a href="http://www.whatsmyip.org/ip-geo-location/?ip='.$ip.'" target="_blank"><img src="'.api_get_path(WEB_CODE_PATH).'img/icons/22/info.png" title="'.$ip.'" /></a>';

@ -46,7 +46,7 @@ $gradebook = isset($gradebook) ? $gradebook : null;
$path = isset($_GET['path']) ? Security::remove_XSS($_GET['path']) : null;
/* Constants and variables */
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_drh();
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || api_is_drh() || api_is_student_boss();
$is_tutor = api_is_allowed_to_edit(true);
$TBL_QUESTIONS = Database :: get_course_table(TABLE_QUIZ_QUESTION);

@ -73,7 +73,7 @@ if (api_is_course_session_coach(
}
$maxEditors = isset($_configuration['exercise_max_fckeditors_in_page']) ? $_configuration['exercise_max_fckeditors_in_page'] : 0;
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor || api_is_session_admin() || api_is_drh();
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor || api_is_session_admin() || api_is_drh() || api_is_student_boss();
//Getting results from the exe_id. This variable also contain all the information about the exercise
$track_exercise_info = get_exercise_track_exercise_info($id);
@ -512,7 +512,7 @@ foreach ($questionList as $questionId) {
$comnt = null;
if ($show_results) {
if ($is_allowedToEdit && $locked == false && !api_is_drh()) {
if ($is_allowedToEdit && $locked == false && !api_is_drh() && !api_is_student_boss()) {
$name = "fckdiv".$questionId;
$marksname = "marksName".$questionId;
if (in_array($answerType, array(FREE_ANSWER, ORAL_EXPRESSION))) {
@ -712,7 +712,7 @@ if (is_array($arrid) && is_array($arrmarks)) {
$marksid = implode(",",$arrmarks);
}
if ($is_allowedToEdit && $locked == false && !api_is_drh()) {
if ($is_allowedToEdit && $locked == false && !api_is_drh() && !api_is_student_boss()) {
if (in_array($origin, array('tracking_course','user_course','correct_exercise_in_lp'))) {
echo ' <form name="myform" id="myform" action="exercise_report.php?exerciseId='.$exercise_id.'&filter=2&comments=update&exeid='.$id.'&origin='.$origin.'&details=true&course='.Security::remove_XSS($_GET['cidReq']).$fromlink.'" method="post">';
echo '<input type = "hidden" name="lp_item_id" value="'.$learnpath_id.'">';

@ -292,7 +292,6 @@ class Category implements GradebookItem
// otherwise a special parameter is given to ask explicitely
$sql .= " AND (session_id IS NULL OR session_id = 0) ";
} else {*/
if (empty($session_id)) {
$sql .= ' AND (session_id IS NULL OR session_id = 0) ';
} else {
@ -326,14 +325,15 @@ class Category implements GradebookItem
$sql .= ' '.$order_by;
}
}
$result = Database::query($sql);
$allcat = array();
$categories = array();
if (Database::num_rows($result) > 0) {
$allcat = Category::create_category_objects_from_sql_result($result);
$categories = Category::create_category_objects_from_sql_result($result);
}
return $allcat;
return $categories;
}
/**
@ -731,7 +731,7 @@ class Category implements GradebookItem
*/
public function calc_score($stud_id = null, $course_code = '', $session_id = null)
{
// get appropriate subcategories, evaluations and links
// Get appropriate subcategories, evaluations and links
if (!empty($course_code)) {
$cats = $this->get_subcategories($stud_id, $course_code, $session_id);
$evals = $this->get_evaluations($stud_id, false, $course_code);
@ -782,10 +782,9 @@ class Category implements GradebookItem
}
if (!empty($links)) {
/** @var EvalLink $link */
/** @var EvalLink|ExerciseLink $link */
foreach ($links as $link) {
$linkres = $link->calc_score($stud_id);
if (!empty($linkres) && $link->get_weight() != 0) {
$linkweight = $link->get_weight();
$link_res_denom = $linkres[1] == 0 ? 1 : $linkres[1];
@ -1296,14 +1295,23 @@ class Category implements GradebookItem
// 1 student
if (isset($stud_id)) {
// special case: this is the root
// Special case: this is the root
if ($this->id == 0) {
return Category::get_root_categories_for_student($stud_id, $course_code, $session_id);
} else {
return Category::load(null,null, $course_code, $this->id, api_is_allowed_to_edit() ? null : 1, $session_id, $order);
return Category::load(
null,
null,
$course_code,
$this->id,
api_is_allowed_to_edit() ? null : 1,
$session_id,
$order
);
}
} else {// all students
// course admin
} else {
// All students
// Course admin
if (api_is_allowed_to_edit() && !api_is_platform_admin()) {
// root
if ($this->id == 0) {

@ -19,18 +19,26 @@ abstract class EvalLink extends AbstractLink
parent::__construct();
}
// Functions implementing AbstractLink
/**
* @return bool
*/
public function has_results()
{
$eval = $this->get_evaluation();
return $eval->has_results();
}
public function calc_score($stud_id = null)
/**
* @param int $userId
*
* @return array
*/
public function calc_score($userId = null)
{
$eval = $this->get_evaluation();
return $eval->calc_score($stud_id);
return $eval->calc_score($userId);
}
public function get_link()

@ -221,7 +221,7 @@ class ExerciseLink extends AbstractLink
if ($student_count == 0) {
return null;
} else {
return array ($sum , $student_count);
return array($sum, $student_count);
}
}
}

@ -47,6 +47,7 @@ class FlatViewTable extends SortableTable
$mainCourseCategory = null
) {
parent :: __construct('flatviewlist', null, null, (api_is_western_name_order() xor api_sort_by_first_name()) ? 1 : 0);
$this->selectcat = $selectcat;
$this->datagen = new FlatViewDataGenerator(
@ -368,10 +369,13 @@ class FlatViewTable extends SortableTable
}
// retrieve sorting type
if ($is_western_name_order) {
$users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME : FlatViewDataGenerator :: FVDG_SORT_LASTNAME);
//$users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME : FlatViewDataGenerator :: FVDG_SORT_LASTNAME);
$users_sorting = FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME;
} else {
$users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_LASTNAME : FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME);
//$users_sorting = ($this->column == 0 ? FlatViewDataGenerator :: FVDG_SORT_LASTNAME : FlatViewDataGenerator :: FVDG_SORT_FIRSTNAME);
$users_sorting = FlatViewDataGenerator :: FVDG_SORT_LASTNAME;
}
if ($this->direction == 'DESC') {
$users_sorting |= FlatViewDataGenerator :: FVDG_SORT_DESC;
@ -382,16 +386,15 @@ class FlatViewTable extends SortableTable
$header_names = $this->datagen->get_header_names($this->offset, $selectlimit);
$column = 0;
if ($is_western_name_order) {
$this->set_header($column++, $header_names[1]);
$this->set_header($column++, $header_names[0]);
$this->set_header(0, $header_names[1]);
$this->set_header(1, $header_names[0]);
} else {
$this->set_header($column++, $header_names[0]);
$this->set_header($column++, $header_names[1]);
$this->set_header(0, $header_names[0]);
$this->set_header(1, $header_names[1]);
}
$column = 2;
while ($column < count($header_names)) {
$this->set_header($column, $header_names[$column], false);
$column++;

@ -157,9 +157,11 @@ class FlatViewDataGenerator
$session_id,
'ORDER BY id'
);
$evaluationsAdded = array();
if ($parent_id == 0 && !empty($allcat)) {
// Means there are any subcategory
foreach ($allcat as $sub_cat) {
$sub_cat_weight = round(100 * $sub_cat->get_weight() / $main_weight, 1);
$add_weight = " $sub_cat_weight %";
@ -216,7 +218,8 @@ class FlatViewDataGenerator
$max = $score[0];
}
}
return $max ;
return $max;
}
/**
@ -389,7 +392,12 @@ class FlatViewDataGenerator
$course_code = api_get_course_id();
$session_id = api_get_session_id();
$allcat = $this->category->get_subcategories(null, $course_code, $session_id, 'ORDER BY id');
$allcat = $this->category->get_subcategories(
null,
$course_code,
$session_id,
'ORDER BY id'
);
$evaluationsAdded = array();
@ -400,7 +408,7 @@ class FlatViewDataGenerator
$real_score = $score;
$divide = ( ($score[1])==0 ) ? 1 : $score[1];
$divide = $score[1] == 0 ? 1 : $score[1];
$sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()];
$item_value = $score[0]/$divide*$main_weight;
@ -410,10 +418,10 @@ class FlatViewDataGenerator
$item_value = $percentage*$item_value;
$item_total += $sub_cat->get_weight();
/*
if ($convert_using_the_global_weight) {
$score[0] = $score[0]/$main_weight*$sub_cat->get_weight();
$score[1] = $main_weight ;
}
if ($convert_using_the_global_weight) {
$score[0] = $score[0]/$main_weight*$sub_cat->get_weight();
$score[1] = $main_weight ;
}
*/
if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') {
//if (true)
@ -427,8 +435,7 @@ class FlatViewDataGenerator
}
if (!isset($this->params['only_total_category']) ||
(isset($this->params['only_total_category']) &&
$this->params['only_total_category'] == false)
(isset($this->params['only_total_category']) && $this->params['only_total_category'] == false)
) {
if (!$show_all) {
$row[] = $temp_score.' ';

@ -364,9 +364,11 @@ class ScoreDisplay
return $this->display_as_div($score).' (' . $this->display_as_percent($score) . ')'.$custom;
case SCORE_DIV_SIMPLE_WITH_CUSTOM : // X - Good!
$custom = $this->display_custom($score);
if (!empty($custom)) {
$custom = ' - '.$custom;
}
return $this->display_simple_score($score).$custom;
break;
case SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS:

@ -658,7 +658,7 @@ switch ($action) {
$course = api_get_course_info();
// Used inside get_exam_results_data()
$documentPath = api_get_path(SYS_COURSE_PATH) . $course['path'] . "/document";
if ($is_allowedToEdit) {
if ($is_allowedToEdit || api_is_student_boss()) {
$columns = array(
'firstname', 'lastname', 'username', 'group_name', 'exe_duration', 'start_date', 'exe_date', 'score', 'status', 'lp', 'actions'
);

@ -59,7 +59,11 @@ function get_tabs() {
$navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'.(api_is_drh()?'session.php':'');
$navigation['session_my_space']['title'] = get_lang('MySpace');
$navigation['session_my_space']['key'] = 'my-space';
} else {
} else if (api_is_student_boss()) {
$navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH) . 'mySpace/student.php';
$navigation['session_my_space']['title'] = get_lang('MySpace');
$navigation['session_my_space']['key'] = 'my-space';
} else {
// Link to my progress
$navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php';
$navigation['session_my_progress']['title'] = get_lang('MyProgress');
@ -303,13 +307,13 @@ function return_navigation_array() {
// Reporting
if (api_get_setting('show_tabs', 'reporting') == 'true') {
if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) {
$navigation['session_my_space'] = $possible_tabs['session_my_space'];
} else {
$navigation['session_my_space'] = $possible_tabs['session_my_progress'];
}
} else {
if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) {
if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin() || api_is_student_boss()) {
$menu_navigation['session_my_space'] = $possible_tabs['session_my_space'];
} else {
$menu_navigation['session_my_space'] = $possible_tabs['session_my_progress'];

@ -167,8 +167,11 @@ class Certificate extends Model
//If the gradebook is related to skills we added the skills to the user
$courseId = api_get_real_course_id();
$sessionId = api_get_session_id();
$skill = new Skill();
$skill->add_skill_to_user($this->user_id, $this->certificate_data['cat_id']);
$skill->add_skill_to_user($this->user_id, $this->certificate_data['cat_id'], $courseId, $sessionId);
if (is_dir($this->certification_user_path)) {
if (!empty($this->certificate_data)) {

@ -43,6 +43,7 @@ define('SESSION_GENERAL_COACH', 13);
define('COURSE_STUDENT', 14); //student subscribed in a course
define('SESSION_STUDENT', 15); //student subscribed in a session course
define('COURSE_TUTOR', 16); // student is tutor of a course (NOT in session)
define('STUDENT_BOSS', 17); // student is boss
// Table of status
$_status_list[COURSEMANAGER] = 'teacher'; // 1
@ -325,6 +326,7 @@ define('USER_RELATION_TYPE_GOODFRIEND', 4); // should be deprecated is useless
define('USER_RELATION_TYPE_ENEMY', 5); // should be deprecated is useless
define('USER_RELATION_TYPE_DELETED', 6);
define('USER_RELATION_TYPE_RRHH', 7);
define('USER_RELATION_TYPE_BOSS', 8);
//Gradebook link constants
//Please do not change existing values, they are used in the database !
@ -1312,6 +1314,8 @@ function api_get_user_info_from_username($username = '')
if (empty($username)) {
return false;
}
$username = trim($username);
$sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)."
WHERE username='".Database::escape_string($username)."'";
$result = Database::query($sql);
@ -4669,7 +4673,8 @@ function api_get_status_langvars() {
SESSIONADMIN => get_lang('SessionsAdmin', ''),
DRH => get_lang('Drh', ''),
STUDENT => get_lang('Student', ''),
ANONYMOUS => get_lang('Anonymous', '')
ANONYMOUS => get_lang('Anonymous', ''),
STUDENT_BOSS => get_lang('RoleStudentBoss', '')
);
}
@ -7504,6 +7509,18 @@ function api_register_campus($listCampus = true) {
// Reload the settings.
}
/**
* Checks whether current user is a student boss
* @global array $_user
* @return boolean
*/
function api_is_student_boss ()
{
global $_user;
return isset($_user['status']) && $_user['status'] == STUDENT_BOSS;
}
/**
* Set the Site Use Cookie Warning for 1 year
*/

@ -4763,7 +4763,7 @@ class SessionManager
null,
$active,
$lastConnectionDate,
COURSEMANAGER,
api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER,
$keyword
);
}

@ -335,7 +335,7 @@ 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()
{
@ -602,21 +602,27 @@ class Skill extends Model
return null;
}
public function add_skill_to_user($user_id, $gradebook_id)
public function add_skill_to_user($user_id, $gradebook_id, $courseId = 0, $sessionId = 0)
{
$courseId = intval($courseId);
$sessionId = intval($sessionId);
$skill_gradebook = new SkillRelGradebook();
$skill_rel_user = new SkillRelUser();
$skill_gradebooks = $skill_gradebook->get_all(array('where' => array('gradebook_id = ?' => $gradebook_id)));
if (!empty($skill_gradebooks)) {
foreach ($skill_gradebooks as $skill_gradebook) {
$user_has_skill = $this->user_has_skill($user_id, $skill_gradebook['skill_id']);
$user_has_skill = $this->user_has_skill($user_id, $skill_gradebook['skill_id'], $courseId, $sessionId);
if (!$user_has_skill) {
$params = array(
'user_id' => $user_id,
'skill_id' => $skill_gradebook['skill_id'],
'acquired_skill_at' => api_get_utc_datetime(),
'course_id' => $courseId,
'session_id' => $sessionId
);
$skill_rel_user->save($params);
}
}
@ -978,11 +984,24 @@ class Skill extends Model
*
* @return bool
*/
public function user_has_skill($user_id, $skill_id)
{
$skills = $this->get_user_skills($user_id);
foreach ($skills as $my_skill_id) {
if ($my_skill_id == $skill_id) {
public function user_has_skill($user_id, $skill_id, $courseId = 0, $sessionId = 0)
{
$courseId = intval($courseId);
$sessionId = intval($sessionId);
$whereConditions = array(
'user_id = ? ' => $user_id,
'AND skill_id = ? ' => $skill_id,
'AND course_id = ? ' => $courseId,
'AND session_id = ? ' => $sessionId
);
$result = Database::select('COUNT(1) AS qty', $this->table_skill_rel_user, array(
'where' => $whereConditions
), 'first');
if ($result != false) {
if ($result['qty'] > 0) {
return true;
}
}
@ -1026,4 +1045,74 @@ class Skill extends Model
return false;
}
/**
* Get the achieved skills by course
* @param int $courseId The course id
* @return array The skills list
*/
public function listAchievedByCourse($courseId)
{
$courseId = intval($courseId);
if ($courseId == 0) {
return array();
}
$list = array();
$sql = "SELECT course.id c_id, course.title c_name, course.directory c_directory, 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;
}
/**
* Get the users list who achieved a skill
* @param int $skillId The skill id
* @return array The users 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, course.directory c_directory, 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;
}
}

@ -244,7 +244,7 @@ class SortableTable extends HTML_Table
public function return_table()
{
$empty_table = false;
$this->processHeaders();
$content = $this->get_table_html();
if ($this->get_total_number_of_items() == 0) {
@ -574,6 +574,8 @@ class SortableTable extends HTML_Table
$table_data = $this->get_table_data($from);
$this->processHeaders();
if (is_array($table_data)) {
$count = 1;
foreach ($table_data as & $row) {
@ -697,6 +699,7 @@ class SortableTable extends HTML_Table
public function processHeaders()
{
$counter = 0;
foreach ($this->headers as $column => $columnInfo) {
$label = $columnInfo['label'];
$sortable = $columnInfo['sortable'];
@ -743,7 +746,6 @@ class SortableTable extends HTML_Table
$counter++;
}
}
/**

@ -4216,6 +4216,10 @@ class UserManager
)"
;
break;
case STUDENT_BOSS :
$drhConditions = " AND friend_user_id = $userId AND "
. "relation_type = " . USER_RELATION_TYPE_BOSS;
break;
}
$join = null;
@ -4282,51 +4286,65 @@ class UserManager
* */
public static function suscribe_users_to_hr_manager($hr_dept_id, $users_id)
{
// Database Table Definitions
$tbl_user_rel_user = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
return self::subscribeUsersToUser($hr_dept_id, $users_id, USER_RELATION_TYPE_RRHH);
}
$hr_dept_id = intval($hr_dept_id);
$affected_rows = 0;
/**
* Add subscribed users to a user by relation type
* @param int $userId The user id
* @param array $subscribedUsersId The id of suscribed users
* @param action $relationType The relation type
*/
public static function subscribeUsersToUser($userId, $subscribedUsersId, $relationType)
{
$userRelUserTable = Database::get_main_table(TABLE_MAIN_USER_REL_USER);
$userRelAccessUrlTable = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER);
$userId = intval($userId);
$relationType = intval($relationType);
$affectedRows = 0;
if (api_get_multiple_access_url()) {
//Deleting assigned users to hrm_id
$sql = "SELECT s.user_id FROM $tbl_user_rel_user s
INNER JOIN $tbl_user_rel_access_url a
ON (a.user_id = s.user_id)
WHERE
friend_user_id = $hr_dept_id AND
relation_type = '".USER_RELATION_TYPE_RRHH."' AND
access_url_id = ".api_get_current_access_url_id()."";
$sql = "SELECT s.user_id FROM $userRelUserTable s "
. "INNER JOIN $userRelAccessUrlTable a ON (a.user_id = s.user_id) "
. "WHERE friend_user_id = $userId "
. "AND relation_type = $relationType "
. "AND access_url_id = " . api_get_current_access_url_id() . "";
} else {
$sql = "SELECT user_id FROM $tbl_user_rel_user
WHERE
friend_user_id = $hr_dept_id AND
relation_type = '".USER_RELATION_TYPE_RRHH."' ";
$sql = "SELECT user_id FROM $userRelUserTable "
. "WHERE friend_user_id = $userId "
. "AND relation_type = $relationType";
}
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result)) {
$sql = "DELETE FROM $tbl_user_rel_user
WHERE
user_id = '{$row['user_id']}' AND
friend_user_id = $hr_dept_id AND
relation_type = '".USER_RELATION_TYPE_RRHH."' ";
$sql = "DELETE FROM $userRelUserTable "
. "WHERE user_id = {$row['user_id']} "
. "AND friend_user_id = $userId "
. "AND relation_type = $relationType";
Database::query($sql);
}
}
// Inserting new user list
if (is_array($users_id)) {
foreach ($users_id as $user_id) {
$user_id = intval($user_id);
$sql = "INSERT IGNORE INTO $tbl_user_rel_user(user_id, friend_user_id, relation_type)
VALUES ('$user_id', $hr_dept_id, '".USER_RELATION_TYPE_RRHH."')";
if (is_array($subscribedUsersId)) {
foreach ($subscribedUsersId as $subscribedUserId) {
$subscribedUserId = intval($subscribedUserId);
$sql = "INSERT IGNORE INTO $userRelUserTable(user_id, friend_user_id, relation_type) "
. "VALUES ($subscribedUserId, $userId, $relationType)";
Database::query($sql);
$affected_rows = Database::affected_rows();
$affectedRows = Database::affected_rows();
}
}
return $affected_rows;
return $affectedRows;
}
/**
@ -4943,6 +4961,51 @@ EOF;
}
}
/**
* Subscribe users to student boss
* @param int $bossId The boss id
* @param array $usersId The users array
* @return int Affected rows
*/
public static function subscribeUsersToBoss($bossId, $usersId)
{
return self::subscribeUsersToUser($bossId, $usersId, USER_RELATION_TYPE_BOSS);
}
/**
* Get users followed by student boss
* @param int $userId
* @param int $userStatus (STUDENT, COURSEMANAGER, etc)
* @param bool $getOnlyUserId
* @param bool $getSql
* @param bool $getCount
* @param int $from
* @param int $numberItems
* @param int $column
* @param string $direction
* @param int $active
* @param string $lastConnectionDate
* @return array users
*/
public static function getUsersFollowedByStudentBoss(
$userId,
$userStatus = 0,
$getOnlyUserId = false,
$getSql = false,
$getCount = false,
$from = null,
$numberItems = null,
$column = null,
$direction = null,
$active = null,
$lastConnectionDate = null
){
return self::getUsersFollowedByUser(
$userId, $userStatus, $getOnlyUserId, $getSql, $getCount, $from, $numberItems, $column, $direction,
$active, $lastConnectionDate, STUDENT_BOSS
);
}
/**
* Get the teacher (users with COURSEMANGER status) list
* @return array The list
@ -5005,4 +5068,5 @@ EOF;
}
return $users;
}
}

@ -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';

@ -877,7 +877,7 @@ VALUES
('tool_visible_by_default_at_creation','forums','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Forums', 1),
('tool_visible_by_default_at_creation','quiz','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Quiz', 1),
('tool_visible_by_default_at_creation','gradebook','checkbox','Tools','true','ToolVisibleByDefaultAtCreationTitle','ToolVisibleByDefaultAtCreationComment',NULL,'Gradebook', 1),
('chamilo_database_version', NULL, 'textfield',NULL, '1.9.0.18715','DatabaseVersion','', NULL, NULL, 0);
('chamilo_database_version', NULL, 'textfield',NULL, '1.10.0.1','DatabaseVersion','', NULL, NULL, 0);
UNLOCK TABLES;
/*!40000 ALTER TABLE settings_current ENABLE KEYS */;
@ -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 (
@ -3026,4 +3029,7 @@ CREATE TABLE usergroup_rel_question (
coefficient float(6,2)
);
-- 1.10.x-specific, non-course-related, database changes
-- 1.10.x-specific, non-course-related, database changes
-- some changes to previous structure might have been applied to the tables
-- creation statements above to increase efficiency

@ -13,11 +13,14 @@
-- 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);
-- Do not move this query
UPDATE settings_current SET selected_value = '1.9.0.18716' WHERE variable = 'chamilo_database_version';
UPDATE settings_current SET selected_value = '1.10.0.1' WHERE variable = 'chamilo_database_version';
-- xxCOURSExx

@ -2,6 +2,12 @@
/*
for more information: see languages.txt in the lang folder.
*/
$StudentsWhoAchievedTheSkillX = "Students who acquired skill %s";
$AchievedSkillInCourseX = "Skills acquired in course %s";
$SkillsReport = "Skills report";
$AssignedUsersListToStudentBoss = "Users assigned to their superior";
$AssignUsersToBoss = "Assign users to superior";
$RoleStudentBoss = "Student's superior";
$CosecantCsc = "Cosecant:\t\t\t\tcsc(x)";
$HyperbolicCosecantCsch = "Hyperbolic cosecant:\t\tcsch(x)";
$ArccosecantArccsc = "Arccosecant:\t\t\tarccsc(x)";

@ -2,6 +2,7 @@
/*
for more information: see languages.txt in the lang folder.
*/
$RoleStudentBoss = "Chef d'apprenant(s)";
$CosecantCsc = "Cosécante:\t\t\t\tcsc(x)";
$HyperbolicCosecantCsch = "Cosécante hyperbolique:\t\tcsch(x)";
$ArccosecantArccsc = "Arccosécante:\t\t\tarccsc(x)";
@ -53,11 +54,14 @@ $BuyCourses = "Achat de cours";
$MySessions = "Mes sessions";
$ActivateAudioRecorder = "Activer l'enregistreur audio";
$StartSpeaking = "Parlez maintenant";
$SessionDurationDescription = "La durée de la session vous permet d'établir une durée en nombre de jours d'accès depuis le premier accès de l'étudiant à cette session. Tant que l'étudiant n'y entre pas, la durée n'est pas entamée. De cette manière, il vous est possible de définir une session qui durera '15 jours' au lieu de démarrer ou de terminer à une date spécifique.";
$HyperbolicArctangentArctanh = "Arctangente hyperbolique:\t\tarctanh(x)";
$SessionDurationTitle = "Durée de session";
$ArctangentArctan = "Arctangente:\t\t\tarctan(x)";
$HyperbolicTangentTanh = "Tangente hyperbolique:\t\ttanh(x)";
$TangentTan = "Tangente:\t\t\ttan(x)";
$CoachAndStudent = "Coach et apprenant";
$Serie = "Série";
$HyperbolicArccosineArccosh = "Arcosinus hyperbolique:\t\tarccosh(x)";
$ArccosineArccos = "Arccosinus:\t\t\tarccos(x)";
$HyperbolicCosineCosh = "Cosinus hyperbolique:\t\tcosh(x)";

@ -2,6 +2,12 @@
/*
for more information: see languages.txt in the lang folder.
*/
$StudentsWhoAchievedTheSkillX = "Estudiantes que adquirieron la competencia %s";
$AchievedSkillInCourseX = "Competencias adquiridas en curso %s";
$SkillsReport = "Reporte de competencias";
$AssignedUsersListToStudentBoss = "Lista de usuarios asignados al superior";
$AssignUsersToBoss = "Asignar usuarios a superior";
$RoleStudentBoss = "Superior de estudiante(s)";
$CosecantCsc = "Cosecante:\t\t\t\tcsc(x)";
$HyperbolicCosecantCsch = "Cosecante hiperbólico:\t\tcsch(x)";
$ArccosecantArccsc = "Arccosecante:\t\t\tarccsc(x)";
@ -55,11 +61,14 @@ $BuyCourses = "Comprar cursos";
$MySessions = "Mis sesiones";
$ActivateAudioRecorder = "Activar la grabación de voz";
$StartSpeaking = "Hable ahora";
$SessionDurationDescription = "La duración de sesiones le permite configurar un número de días de acceso a una sesión que inician desde el primer acceso del estudiante a la misma sesión. Mientras no entre, no inicia el conteo de estos días. De esta manera, puede poner una sesión con acceso 'por 15 días' en lugar de una fecha específica de inicio y de fin, y así tener estudiantes que puedan iniciar con mayor flexibilidad.";
$HyperbolicArctangentArctanh = "Arcotangente hiperbólica:\tarctanh(x)";
$SessionDurationTitle = "Duración de sesión";
$ArctangentArctan = "Arcotangente:\t\t\tarctan(x)";
$HyperbolicTangentTanh = "Tangente hiperbólica:\t\ttanh(x)";
$TangentTan = "Tangente:\t\t\ttan(x)";
$CoachAndStudent = "Tutor y estudiante";
$Serie = "Serie";
$HyperbolicArccosineArccosh = "Arcocoseno hiperbólico:\t\tarccosh(x)";
$ArccosineArccos = "Arcocoseno:\t\t\tarccos(x)";
$HyperbolicCosineCosh = "Coseno hiperbólico:\t\tcosh(x)";

@ -33,7 +33,7 @@ require_once api_get_path(SYS_CODE_PATH).'survey/survey.lib.php';
api_block_anonymous_users();
if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh()) {
if (!api_is_allowed_to_create_course() && !api_is_session_admin() && !api_is_drh() && !api_is_student_boss()) {
// Check if the user is tutor of the course
$user_course_status = CourseManager::get_tutor_in_course_status(
api_get_user_id(),
@ -230,7 +230,7 @@ $courses_in_session = array();
//See #4676
$drh_can_access_all_courses = false;
if (api_is_drh() || api_is_platform_admin()) {
if (api_is_drh() || api_is_platform_admin() || api_is_student_boss()) {
$drh_can_access_all_courses = true;
}

@ -14,6 +14,8 @@ $cidReset = true;
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'export.lib.inc.php';
$nameTools = get_lang('Students');
$export_csv = isset($_GET['export']) && $_GET['export'] == 'csv' ? true : false;
$keyword = isset($_GET['keyword']) ? Security::remove_XSS($_GET['keyword']) : null;
$active = isset($_GET['active']) ? intval($_GET['active']) : 1;
@ -49,7 +51,7 @@ function get_count_users()
$lastConnectionDate,
null,
null,
STUDENT
api_is_student_boss() ? null : STUDENT
);
return $count;
}
@ -85,7 +87,7 @@ function get_users($from, $limit, $column, $direction)
$lastConnectionDate,
null,
null,
STUDENT
api_is_student_boss() ? null : STUDENT
);
$drhLoaded = true;
}
@ -94,7 +96,7 @@ function get_users($from, $limit, $column, $direction)
if ($drhLoaded == false) {
$students = UserManager::getUsersFollowedByUser(
api_get_user_id(),
STUDENT,
api_is_student_boss() ? null : STUDENT,
false,
false,
false,
@ -104,7 +106,7 @@ function get_users($from, $limit, $column, $direction)
$direction,
$active,
$lastConnectionDate,
COURSEMANAGER,
api_is_student_boss() ? STUDENT_BOSS : COURSEMANAGER,
$keyword
);
}
@ -178,7 +180,7 @@ if ($export_csv) {
}
$sort_by_first_name = api_sort_by_first_name();
$actions .= '<div class="actions">';
$actions = '<div class="actions">';
if (api_is_drh()) {
$menu_items = array(
@ -186,7 +188,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);
@ -195,6 +201,15 @@ if (api_is_drh()) {
$actions .= $item;
}
}
} else if (api_is_student_boss()) {
$actions .= Display::url(
Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH)."auth/my_progress.php"
);
$actions .= Display::url(
Display::return_icon('user_na.png', get_lang('Students'), array(), ICON_SIZE_MEDIUM),
'#'
);
}
$actions .= '<span style="float:right">';

@ -186,7 +186,7 @@ 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'),
);
$nb_menu_items = count($menu_items);

@ -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>';
}

@ -0,0 +1,176 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Show the skills report
* @author Angel Fernando Quiroz Campos <angel.quiroz@beeznest.com>
* @package chamilo.social.skill
*/
require_once '../inc/global.inc.php';
$isStudent = api_is_student();
$isStudentBosss = api_is_student_boss();
$isDRH = api_is_drh();
if (!$isStudent && !$isStudentBosss && !$isDRH) {
header('Location: ' . api_get_path(WEB_CODE_PATH) . 'social/skills_wheel.php');
die;
}
$userId = api_get_user_id();
$skillTable = Database::get_main_table(TABLE_MAIN_SKILL);
$skillRelUserTable = Database::get_main_table(TABLE_MAIN_SKILL_REL_USER);
$courseTable = Database::get_main_table(TABLE_MAIN_COURSE);
$tableRows = array();
$tpl = new Template(get_lang('Skills'));
$tplPath = null;
$tpl->assign('allowSkillsTool', api_get_setting('allow_skills_tool') == 'true');
$tpl->assign('allowDrhSkillsManagement', api_get_setting('allow_hr_skills_management') == 'true');
if ($isStudent) {
$sql = "SELECT s.name, sru.acquired_skill_at, c.title, 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 = $userId";
$result = Database::query($sql);
while ($resultData = Database::fetch_assoc($result)) {
$tableRow = array(
'skillName' => $resultData['name'],
'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'courseImage' => Display::return_icon('course.png', null, null, ICON_SIZE_BIG, null, true),
'courseName' => $resultData['title']
);
if (file_exists(api_get_path(SYS_COURSE_PATH) . "{$resultData['directory']}/course-pic85x85.png")) {
$tableRow['courseImage'] = api_get_path(WEB_COURSE_PATH) . "{$resultData['directory']}/course-pic85x85.png";
}
$tableRows[] = $tableRow;
}
$tplPath = 'skill/student_report.tpl';
} else if ($isStudentBosss) {
$selectedStudent = isset($_REQUEST['student']) ? intval($_REQUEST['student']) : 0;
$tableRows = array();
$followedStudents = UserManager::getUsersFollowedByStudentBoss($userId);
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.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)) {
$tableRow = array(
'completeName' => $followedStudents[$selectedStudent]['completeName'],
'skillName' => $resultData['name'],
'achievedAt' => api_format_date($resultData['acquired_skill_at'], DATE_FORMAT_NUMBER),
'courseImage' => Display::return_icon('course.png', null, null, ICON_SIZE_BIG, null, true),
'courseName' => $resultData['title']
);
if (file_exists(api_get_path(SYS_COURSE_PATH) . "{$resultData['directory']}/course-pic85x85.png")) {
$tableRow['courseImage'] = api_get_path(WEB_COURSE_PATH) . "{$resultData['directory']}/course-pic85x85.png";
}
$tableRows[] = $tableRow;
}
}
$tplPath = 'skill/student_boss_report.tpl';
$tpl->assign('followedStudents', $followedStudents);
$tpl->assign('selectedStudent', $selectedStudent);
} else if ($isDRH) {
$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';
}
$courses = CourseManager::get_courses_list();
$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('AchievedSkillInCourseX'), $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
);
$coursesFilter = array();
foreach ($courses as $course) {
$coursesFilter[] = $course['id'];
}
$tableRows = $objSkill->listUsersWhoAchieved($selectedSkill, $coursesFilter);
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);
if (file_exists(api_get_path(SYS_COURSE_PATH) . $row['c_directory'] . '/course-pic85x85.png')) {
$row['courseImage'] = api_get_path(WEB_COURSE_PATH) . $row['c_directory'] . '/course-pic85x85.png';
} else {
$row['courseImage'] = Display::return_icon('course.png', null, null, ICON_SIZE_BIG, null, true);
}
}
$tplPath = 'skill/drh_report.tpl';
$tpl->assign('action', $action);
$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->fetch("default/" . $tplPath);
$tpl->assign('content', $contentTemplate);
$tpl->display_one_col_template();

@ -20,7 +20,7 @@
{{ plugin_footer_left }}
</div>
{% endif %}
&nbsp;
&nbsp;
</div>
<div id="footer_center" class="span4">
@ -30,7 +30,7 @@
{{ plugin_footer_center }}
</div>
{% endif %}
&nbsp;
&nbsp;
</div>
<div id="footer_right" class="span4">
@ -62,27 +62,7 @@
{% raw %}
<script>
$("form").on("click", ' .advanced_parameters', function() {
var id = $(this).attr('id') + '_options';
var button = $(this);
$("#"+id).toggle(function() {
button.toggleClass('active');
});
});
/* Makes row highlighting possible */
$(document).ready( function() {
/**
* Advanced options
* Usage
* <a id="link" href="url">Advanced</a>
* <div id="link_options">
* hidden content :)
* </div>
* */
$(".advanced_options").on("click", function(event) {
event.preventDefault();
$("form").on("click", ' .advanced_parameters', function() {
var id = $(this).attr('id') + '_options';
var button = $(this);
$("#"+id).toggle(function() {
@ -90,58 +70,78 @@ $(document).ready( function() {
});
});
/**
* <a class="advanced_options_open" href="http://" rel="div_id">Open</a>
* <a class="advanced_options_close" href="http://" rel="div_id">Close</a>
* <div id="div_id">Div content</div>
* */
$(".advanced_options_open").on("click", function(event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#"+id).show();
});
$(".advanced_options_close").on("click", function(event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#"+id).hide();
});
/* Makes row highlighting possible */
$(document).ready( function() {
/**
* Advanced options
* Usage
* <a id="link" href="url">Advanced</a>
* <div id="link_options">
* hidden content :)
* </div>
* */
$(".advanced_options").on("click", function(event) {
event.preventDefault();
var id = $(this).attr('id') + '_options';
var button = $(this);
$("#"+id).toggle(function() {
button.toggleClass('active');
});
});
// Chosen select
$(".chzn-select").chosen({
disable_search_threshold: 10
});
/**
* <a class="advanced_options_open" href="http://" rel="div_id">Open</a>
* <a class="advanced_options_close" href="http://" rel="div_id">Close</a>
* <div id="div_id">Div content</div>
* */
$(".advanced_options_open").on("click", function(event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#"+id).show();
});
$(".jp-jplayer audio").addClass('skip');
$(".advanced_options_close").on("click", function(event) {
event.preventDefault();
var id = $(this).attr('rel');
$("#"+id).hide();
});
// Mediaelement
jQuery('video:not(.skip), audio:not(.skip)').mediaelementplayer(/* Options */);
// Chosen select
$(".chzn-select").chosen({
disable_search_threshold: 10
});
$(".jp-jplayer audio").addClass('skip');
// Mediaelement
jQuery('video:not(.skip), audio:not(.skip)').mediaelementplayer(/* Options */);
// Table highlight.
$("form .data_table input:checkbox").click(function() {
if ($(this).is(":checked")) {
$(this).parentsUntil("tr").parent().addClass("row_selected");
// Table highlight.
$("form .data_table input:checkbox").click(function() {
if ($(this).is(":checked")) {
$(this).parentsUntil("tr").parent().addClass("row_selected");
} else {
$(this).parentsUntil("tr").parent().removeClass("row_selected");
}
});
} else {
$(this).parentsUntil("tr").parent().removeClass("row_selected");
/* For non HTML5 browsers */
if ($("#formLogin".length > 1)) {
$("input[name=login]").focus();
}
});
/* For non HTML5 browsers */
if ($("#formLogin".length > 1)) {
$("input[name=login]").focus();
}
/* For IOS users */
$('.autocapitalize_off').attr('autocapitalize', 'off');
//Tool tip (in exercises)
var tip_options = {
placement : 'right'
}
$('.boot-tooltip').tooltip(tip_options);
});
{% endraw %}
/* For IOS users */
$('.autocapitalize_off').attr('autocapitalize', 'off');
//Tool tip (in exercises)
var tip_options = {
placement : 'right'
};
$('.boot-tooltip').tooltip(tip_options);
});
{% endraw %}
</script>

@ -0,0 +1,80 @@
{% if allowSkillsTool %}
<div class="btn-group">
<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 %}
</div>
{% endif %}
<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>
{% if action == 'filterByCourse' %}
<th>{{ 'Course' | get_lang }}</th>
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
{% elseif action == 'filterBySkill' %}
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
{% if action == 'filterByCourse' %}
<td><img src="{{ row.courseImage }}" alt="{{ row.c_name }}" width="64"> {{ row.c_name }}</td>
<td>{{ row.skill_name }}</td>
<td>{{ row.completeName }}</td>
<td>{{ row.achievedAt }}</td>
{% elseif action == 'filterBySkill' %}
<td>{{ row.skill_name }}</td>
<td>{{ row.completeName }}</td>
<td>{{ row.achievedAt }}</td>
<td><img src="{{ row.courseImage }}" alt="{{ row.c_name }}" width="64"> {{ row.c_name }}</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% endif %}

@ -0,0 +1,45 @@
{% if allowSkillsTool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a>
</div>
{% endif %}
<h1 class="page-header">{{ 'SkillsAcquired' | get_lang }}</h1>
<form class="form-inline" method="post" action="{{ _p.web_self }}">
<label>{{ 'Students' | get_lang }}</label>
<select name="student" id="student">
<option value="0">{{ 'Select' | get_lang }}</option>
{% for student in followedStudents %}
<option value="{{ student.user_id }}" {{ (student.user_id == selectedStudent) ? 'selected' : '' }}>{{ student.completeName }}</option>
{% endfor %}
</select>
<button type="submit" class="btn btn-primary">{{ 'Search' | get_lang }}</button>
</form>
{% if rows %}
<table class="table">
<thead>
<tr>
<th>{{ 'Student' | get_lang }}</th>
<th>{{ 'SkillsAcquired' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.completeName }}</td>
<td>{{ row.skillName }}</td>
<td>{{ row.achievedAt }}</td>
<td><img src="{{ row.courseImage }}" alt="{{ row.courseName }}" width="64"> {{ row.courseName }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% endif %}

@ -0,0 +1,32 @@
{% if allowSkillsTool %}
<div class="btn-group">
<a class="btn btn-default" href="{{ _p.web_main }}social/skills_wheel.php">{{ 'SkillsWheel' | get_lang }}</a>
</div>
{% endif %}
<h1 class="page-header">{{ 'SkillsAcquired' | get_lang }}</h1>
{% if rows %}
<table class="table">
<thead>
<tr>
<th>{{ 'Skill' | get_lang }}</th>
<th>{{ 'Date' | get_lang }}</th>
<th>{{ 'Course' | get_lang }}</th>
</tr>
</thead>
<tbody>
{% for row in rows %}
<tr>
<td>{{ row.skillName }}</td>
<td>{{ row.achievedAt }}</td>
<td><img src="{{ row.courseImage }}" alt="{{ row.courseName }}" width="64"> {{ row.courseName }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<div class="alert alert-info">
{{ 'NoResults' | get_lang }}
</div>
{% endif %}
Loading…
Cancel
Save