Learning Calendar WIP - See BT#14608

Ui changes, several fixes
pull/2588/merge
Julio Montoya 7 years ago
parent 89ac2f824f
commit f645280e30
  1. 18
      main/admin/add_users_to_usergroup.php
  2. 4
      main/inc/lib/usergroup.lib.php
  3. 27
      main/inc/lib/userportal.lib.php
  4. 13
      plugin/learning_calendar/LearningCalendarPlugin.php
  5. 2
      plugin/learning_calendar/lang/english.php

@ -238,19 +238,7 @@ if (!empty($filters) && !empty($filterData)) {
}
$elements_not_in = $elements_in = [];
$onlyThisUserList = [];
if ($usergroup->allowTeachers()) {
$userId = api_get_user_id();
$courseList = CourseManager::getCoursesFollowedByUser($userId, COURSEMANAGER);
foreach ($courseList as $course) {
$userList = CourseManager::get_user_list_from_course_code($course['code'], 0, null, null, STUDENT);
$userList = array_column($userList, 'user_id');
$onlyThisUserList = array_merge($onlyThisUserList, $userList);
}
}
$complete_user_list = UserManager::getUserListLike([], $order, false, 'AND', $onlyThisUserList);
$complete_user_list = UserManager::getUserListLike([], $order, false, 'AND');
if (!empty($complete_user_list)) {
foreach ($complete_user_list as $item) {
@ -288,7 +276,7 @@ if (!empty($complete_user_list)) {
$user_with_any_group = isset($_REQUEST['user_with_any_group']) && !empty($_REQUEST['user_with_any_group']) ? true : false;
if ($user_with_any_group) {
$user_list = UserManager::getUserListLike($conditions, $order, true, 'AND', $onlyThisUserList);
$user_list = UserManager::getUserListLike($conditions, $order, true, 'AND');
$new_user_list = [];
foreach ($user_list as $item) {
if (!in_array($item['user_id'], $list_all)) {
@ -297,7 +285,7 @@ if ($user_with_any_group) {
}
$user_list = $new_user_list;
} else {
$user_list = UserManager::getUserListLike($conditions, $order, true, 'AND', $onlyThisUserList);
$user_list = UserManager::getUserListLike($conditions, $order, true, 'AND');
}
if (!empty($user_list)) {

@ -151,8 +151,8 @@ class UserGroup extends Model
}
$data['time_spent'] = api_time_to_hms($totalTime);
$data['lp_day_completed'] = $stats['completed'];
$data['days_diff'] = $stats['diff'];
$data['lp_day_completed'] = $stats['user_event_count'];
$data['days_diff'] = $stats['completed'];
}
$data['id'] = $data['user_id'];
$list[] = $data;

@ -781,19 +781,9 @@ class IndexManager
return '';
}
$usergroup = new UserGroup();
$usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id());
$items = [];
if (!empty($usergroup_list)) {
foreach ($usergroup_list as $group_id) {
$data = $usergroup->get($group_id);
$items[] = [
'link' => api_get_path(WEB_CODE_PATH).'user/classes.php?id='.$data['id'],
'title' => $data['name'],
];
}
}
$usergroup = new UserGroup();
if (api_is_platform_admin()) {
$items[] = [
'link' => api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add',
@ -802,8 +792,19 @@ class IndexManager
} else {
if (api_is_teacher() && $usergroup->allowTeachers()) {
$items[] = [
'link' => api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add',
'title' => get_lang('AddClasses'),
'link' => api_get_path(WEB_CODE_PATH).'admin/usergroups.php',
'title' => get_lang('ClassList'),
];
}
}
$usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id());
if (!empty($usergroup_list)) {
foreach ($usergroup_list as $group_id) {
$data = $usergroup->get($group_id);
$items[] = [
'link' => api_get_path(WEB_CODE_PATH).'user/classes.php?id='.$data['id'],
'title' => $data['name'],
];
}
}

@ -121,7 +121,7 @@ class LearningCalendarPlugin extends Plugin
$extraField = new ExtraField('course');
$params = [
'display_text' => get_lang('Duration'),
'display_text' => $this->get_lang('CourseHoursDuration'),
'variable' => 'course_hours_duration',
'visible_to_self' => 1,
'changeable' => 1,
@ -570,12 +570,13 @@ class LearningCalendarPlugin extends Plugin
}
/**
* @param int $start
* @param int $end
* @param Agenda $agenda
* @param int $start
* @param int $end
*
* @return array
*/
public function getPersonalEvents($calendar, $start, $end)
public function getPersonalEvents($agenda, $start, $end)
{
$userId = api_get_user_id();
$events = $this->getUserEvents($userId, $start, $end);
@ -603,12 +604,12 @@ class LearningCalendarPlugin extends Plugin
$event['type'] = 'personal';
if (!empty($row['start_date'])) {
$event['start'] = $calendar->formatEventDate($row['start_date']);
$event['start'] = $agenda->formatEventDate($row['start_date']);
$event['start_date_localtime'] = api_get_local_time($row['start_date']);
}
if (!empty($row['end_date'])) {
$event['end'] = $calendar->formatEventDate($row['end_date']);
$event['end'] = $agenda->formatEventDate($row['end_date']);
$event['end_date_localtime'] = api_get_local_time($row['end_date']);
}

@ -13,3 +13,5 @@ $strings['DifferenceOfDaysAndCalendar'] = 'Difference of days and calendar';
$strings['EventTypeTaken'] = 'Taken';
$strings['EventTypeExam'] = 'Exam';
$strings['EventTypeFree'] = 'Free';
$strings['CourseHoursDuration'] = 'Course hours duration';

Loading…
Cancel
Save