|
@@ -38,7 +38,7 @@ class CourseManager
|
|
|
public static $toolList;
|
|
|
public static $courseSettingsManager;
|
|
|
|
|
|
- /**
|
|
|
+ /**
|
|
|
* @param \Doctrine\ORM\EntityManager
|
|
|
*/
|
|
|
public static function setEntityManager($em)
|
|
@@ -330,14 +330,11 @@ class CourseManager
|
|
|
*/
|
|
|
public static function getUserCourseInfo($userId, $courseId)
|
|
|
{
|
|
|
- $result = Database::fetch_array(
|
|
|
- Database::query("
|
|
|
- SELECT * FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER)."
|
|
|
+ $sql = "SELECT * FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
|
|
|
WHERE
|
|
|
- c_id = '" . intval($courseId)."' AND
|
|
|
- user_id = " . intval($userId)
|
|
|
- )
|
|
|
- );
|
|
|
+ c_id = '".intval($courseId)."' AND
|
|
|
+ user_id = ".intval($userId);
|
|
|
+ $result = Database::fetch_array(Database::query($sql));
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
@@ -383,8 +380,8 @@ class CourseManager
|
|
|
SELECT is_tutor
|
|
|
FROM " . Database::get_main_table(TABLE_MAIN_COURSE_USER)."
|
|
|
WHERE
|
|
|
- c_id = '" . Database::escape_string($courseId)."' AND
|
|
|
- user_id = " . intval($user_id)
|
|
|
+ c_id = '".Database::escape_string($courseId)."' AND
|
|
|
+ user_id = ".intval($user_id)
|
|
|
)
|
|
|
);
|
|
|
|
|
@@ -402,6 +399,9 @@ class CourseManager
|
|
|
*/
|
|
|
public static function unsubscribe_user($user_id, $course_code, $session_id = 0)
|
|
|
{
|
|
|
+ if (empty($user_id)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (!is_array($user_id)) {
|
|
|
$user_id = array($user_id);
|
|
|
}
|
|
@@ -416,7 +416,7 @@ class CourseManager
|
|
|
$session_id = api_get_session_id();
|
|
|
}
|
|
|
|
|
|
- $user_list = array();
|
|
|
+ $userList = array();
|
|
|
|
|
|
// Cleaning the $user_id variable
|
|
|
if (is_array($user_id)) {
|
|
@@ -425,11 +425,11 @@ class CourseManager
|
|
|
$new_user_id_list[] = intval($my_user_id);
|
|
|
}
|
|
|
$new_user_id_list = array_filter($new_user_id_list);
|
|
|
- $user_list = $new_user_id_list;
|
|
|
+ $userList = $new_user_id_list;
|
|
|
$user_ids = implode(',', $new_user_id_list);
|
|
|
} else {
|
|
|
$user_ids = intval($user_id);
|
|
|
- $user_list[] = $user_id;
|
|
|
+ $userList[] = $user_id;
|
|
|
}
|
|
|
|
|
|
$course_info = api_get_course_info($course_code);
|
|
@@ -445,9 +445,9 @@ class CourseManager
|
|
|
|
|
|
// Erase user student publications (works) in the course - by André Boivin
|
|
|
|
|
|
- if (!empty($user_list)) {
|
|
|
+ if (!empty($userList)) {
|
|
|
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
|
|
|
- foreach ($user_list as $userId) {
|
|
|
+ foreach ($userList as $userId) {
|
|
|
// Getting all work from user
|
|
|
$workList = getWorkPerUser($userId);
|
|
|
if (!empty($workList)) {
|
|
@@ -465,8 +465,13 @@ class CourseManager
|
|
|
}
|
|
|
|
|
|
// Unsubscribe user from all blogs in the course.
|
|
|
- Database::query("DELETE FROM ".Database::get_course_table(TABLE_BLOGS_REL_USER)." WHERE c_id = $course_id AND user_id IN (".$user_ids.")");
|
|
|
- Database::query("DELETE FROM ".Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)." WHERE c_id = $course_id AND user_id IN (".$user_ids.")");
|
|
|
+ $sql = "DELETE FROM ".Database::get_course_table(TABLE_BLOGS_REL_USER)."
|
|
|
+ WHERE c_id = $course_id AND user_id IN (".$user_ids.")";
|
|
|
+ Database::query($sql);
|
|
|
+
|
|
|
+ $sql = "DELETE FROM ".Database::get_course_table(TABLE_BLOGS_TASKS_REL_USER)."
|
|
|
+ WHERE c_id = $course_id AND user_id IN (".$user_ids.")";
|
|
|
+ Database::query($sql);
|
|
|
|
|
|
// Deleting users in forum_notification and mailqueue course tables
|
|
|
$sql = "DELETE FROM ".Database::get_course_table(TABLE_FORUM_NOTIFICATION)."
|
|
@@ -487,7 +492,7 @@ class CourseManager
|
|
|
user_id IN ($user_ids)";
|
|
|
Database::query($sql);
|
|
|
|
|
|
- foreach ($user_list as $uid) {
|
|
|
+ foreach ($userList as $uid) {
|
|
|
// check if a user is register in the session with other course
|
|
|
$sql = "SELECT user_id FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)."
|
|
|
WHERE session_id='$session_id' AND user_id='$uid'";
|
|
@@ -538,9 +543,9 @@ class CourseManager
|
|
|
} else {
|
|
|
$sql = "DELETE FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
|
|
|
WHERE
|
|
|
- user_id IN (" . $user_ids.") AND
|
|
|
- relation_type<>" . COURSE_RELATION_TYPE_RRHH." AND
|
|
|
- c_id = '" . $course_id."'";
|
|
|
+ user_id IN (".$user_ids.") AND
|
|
|
+ relation_type <> ".COURSE_RELATION_TYPE_RRHH." AND
|
|
|
+ c_id = '".$course_id."'";
|
|
|
Database::query($sql);
|
|
|
|
|
|
// add event to system log
|
|
@@ -555,7 +560,7 @@ class CourseManager
|
|
|
$course_id
|
|
|
);
|
|
|
|
|
|
- foreach ($user_list as $userId) {
|
|
|
+ foreach ($userList as $userId) {
|
|
|
$userInfo = api_get_user_info($userId);
|
|
|
Event::addEvent(
|
|
|
LOG_UNSUBSCRIBE_USER_FROM_COURSE,
|
|
@@ -708,7 +713,6 @@ class CourseManager
|
|
|
$t_cfv = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
|
|
|
$table_field = Database::get_main_table(TABLE_EXTRA_FIELD);
|
|
|
$extraFieldType = EntityExtraField::COURSE_FIELD_TYPE;
|
|
|
-
|
|
|
$original_course_id_value = Database::escape_string($original_course_id_value);
|
|
|
$original_course_id_name = Database::escape_string($original_course_id_name);
|
|
|
|
|
@@ -852,7 +856,7 @@ class CourseManager
|
|
|
$debug = false;
|
|
|
$userTable = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
$courseUserTable = Database::get_main_table(TABLE_MAIN_COURSE_CATALOGUE_USER);
|
|
|
-
|
|
|
+ $visible = (int) $visible;
|
|
|
if (empty($userId) || empty($courseCode) || ($userId != strval(intval($userId)))) {
|
|
|
return false;
|
|
|
}
|
|
@@ -874,7 +878,7 @@ class CourseManager
|
|
|
$sql = "SELECT * FROM $courseUserTable
|
|
|
WHERE
|
|
|
user_id = $userId AND
|
|
|
- visible = ".$visible." AND
|
|
|
+ visible = $visible AND
|
|
|
c_id = $courseId";
|
|
|
if (Database::num_rows(Database::query($sql)) > 0) {
|
|
|
if ($debug) {
|
|
@@ -894,7 +898,6 @@ class CourseManager
|
|
|
return $insertId;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Remove the user $userId visibility to the course $courseCode in the catalogue.
|
|
|
* @author David Nos (https://github.com/dnos)
|
|
@@ -1059,7 +1062,7 @@ class CourseManager
|
|
|
* @return array An array with the course info of all the courses (real and virtual)
|
|
|
* of which the current user is course admin.
|
|
|
*/
|
|
|
- public static function get_course_list_of_user_as_course_admin($user_id, $startsWith = null)
|
|
|
+ public static function get_course_list_of_user_as_course_admin($user_id, $startsWith = '')
|
|
|
{
|
|
|
if ($user_id != strval(intval($user_id))) {
|
|
|
return array();
|
|
@@ -1171,7 +1174,7 @@ class CourseManager
|
|
|
$user_id,
|
|
|
$course_code = null,
|
|
|
$in_a_session = false,
|
|
|
- $session_id = null
|
|
|
+ $session_id = 0
|
|
|
) {
|
|
|
$user_id = intval($user_id);
|
|
|
|
|
@@ -1233,10 +1236,10 @@ class CourseManager
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Is the user a teacher in the given course?
|
|
|
+ * Is the user a teacher in the given course?
|
|
|
*
|
|
|
* @param integer $user_id , the id (int) of the user
|
|
|
- * @param $course_code , the course code
|
|
|
+ * @param string $course_code , the course code
|
|
|
*
|
|
|
* @return boolean if the user is a teacher in the course, false otherwise
|
|
|
*/
|
|
@@ -1247,12 +1250,13 @@ class CourseManager
|
|
|
}
|
|
|
|
|
|
$courseInfo = api_get_course_info($course_code);
|
|
|
+ if (empty($courseInfo)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
$courseId = $courseInfo['real_id'];
|
|
|
-
|
|
|
- $result = Database::query(
|
|
|
- 'SELECT status FROM '.Database::get_main_table(TABLE_MAIN_COURSE_USER).
|
|
|
- ' WHERE c_id = '.$courseId.' AND user_id = '.$user_id.''
|
|
|
- );
|
|
|
+ $sql = "SELECT status FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
|
|
|
+ WHERE c_id = $courseId AND user_id = $user_id ";
|
|
|
+ $result = Database::query($sql);
|
|
|
|
|
|
if (Database::num_rows($result) > 0) {
|
|
|
return Database::result($result, 0, 'status') == 1;
|
|
@@ -1269,15 +1273,16 @@ class CourseManager
|
|
|
* @deprecated linked_courses definition doesn't exists
|
|
|
* @return boolean if the user is registered in the real course or linked courses, false otherwise
|
|
|
*/
|
|
|
- public static function is_user_subscribed_in_real_or_linked_course($user_id, $courseId, $session_id = '')
|
|
|
+ public static function is_user_subscribed_in_real_or_linked_course($user_id, $courseId, $session_id = 0)
|
|
|
{
|
|
|
if ($user_id != strval(intval($user_id))) {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
$courseId = intval($courseId);
|
|
|
+ $session_id = intval($session_id);
|
|
|
|
|
|
- if ($session_id == '') {
|
|
|
+ if (empty($session_id)) {
|
|
|
$result = Database::fetch_array(
|
|
|
Database::query(
|
|
|
"SELECT *
|
|
@@ -1293,15 +1298,13 @@ class CourseManager
|
|
|
return !empty($result);
|
|
|
}
|
|
|
|
|
|
- $session_id = intval($session_id);
|
|
|
|
|
|
// From here we trust session id.
|
|
|
// Is he/she subscribed to the session's course?
|
|
|
-
|
|
|
// A user?
|
|
|
if (Database::num_rows(Database::query("SELECT user_id
|
|
|
FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)."
|
|
|
- WHERE session_id='" . $session_id."'
|
|
|
+ WHERE session_id='".$session_id."'
|
|
|
AND user_id ='$user_id'"))
|
|
|
) {
|
|
|
return true;
|
|
@@ -1466,11 +1469,11 @@ class CourseManager
|
|
|
}
|
|
|
|
|
|
$sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user '
|
|
|
- . ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_COURSE_USER).' as course_rel_user
|
|
|
+ . ' LEFT JOIN '.Database::get_main_table(TABLE_MAIN_COURSE_USER).' as course_rel_user
|
|
|
ON
|
|
|
user.id = course_rel_user.user_id AND
|
|
|
course_rel_user.relation_type <> ' . COURSE_RELATION_TYPE_RRHH.' '
|
|
|
- . " INNER JOIN $course_table course ON course_rel_user.c_id = course.id ";
|
|
|
+ . " INNER JOIN $course_table course ON course_rel_user.c_id = course.id ";
|
|
|
|
|
|
if (!empty($course_code)) {
|
|
|
$sql .= ' AND course_rel_user.c_id = "'.$courseId.'"';
|
|
@@ -1564,14 +1567,11 @@ class CourseManager
|
|
|
return $user['count'];
|
|
|
}
|
|
|
$report_info = array();
|
|
|
-
|
|
|
$user_info = $user;
|
|
|
$user_info['status'] = $user['status'];
|
|
|
-
|
|
|
if (isset($user['is_tutor'])) {
|
|
|
$user_info['is_tutor'] = $user['is_tutor'];
|
|
|
}
|
|
|
-
|
|
|
if (!empty($session_id)) {
|
|
|
$user_info['status_session'] = $user['status_session'];
|
|
|
}
|
|
@@ -1825,13 +1825,12 @@ class CourseManager
|
|
|
$course_code = Database::escape_string($course_code);
|
|
|
$courseInfo = api_get_course_info($course_code);
|
|
|
$courseId = $courseInfo['real_id'];
|
|
|
-
|
|
|
$session_id = intval($session_id);
|
|
|
$users = array();
|
|
|
|
|
|
// We get the coach for the given course in a given session.
|
|
|
$sql = 'SELECT user_id FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).
|
|
|
- ' WHERE session_id ="'.$session_id.'" AND c_id="'.$courseId.'" AND status = 2';
|
|
|
+ ' WHERE session_id ="'.$session_id.'" AND c_id="'.$courseId.'" AND status = 2';
|
|
|
$rs = Database::query($sql);
|
|
|
while ($user = Database::fetch_array($rs)) {
|
|
|
$userInfo = api_get_user_info($user['user_id']);
|
|
@@ -2020,7 +2019,7 @@ class CourseManager
|
|
|
$rs = Database::query($sql);
|
|
|
$listTeachers = array();
|
|
|
$teachers = array();
|
|
|
- $url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup';
|
|
|
+ $url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&course_id='.$courseId;
|
|
|
while ($teacher = Database::fetch_array($rs)) {
|
|
|
$teachers['id'] = $teacher['user_id'];
|
|
|
$teachers['lastname'] = $teacher['lastname'];
|
|
@@ -2028,6 +2027,7 @@ class CourseManager
|
|
|
$teachers['email'] = $teacher['email'];
|
|
|
$teachers['username'] = $teacher['username'];
|
|
|
$teachers['status'] = $teacher['status'];
|
|
|
+ $teachers['fullname'] = api_get_person_name($teacher['firstname'], $teacher['lastname']);
|
|
|
$teachers['avatar'] = '';
|
|
|
if ($loadAvatars) {
|
|
|
$userPicture = UserManager::getUserPicture($teacher['user_id'], USER_IMAGE_SIZE_SMALL);
|
|
@@ -2048,7 +2048,7 @@ class CourseManager
|
|
|
* @param bool $orderList
|
|
|
* @return string List of teachers teaching the course
|
|
|
*/
|
|
|
- public static function get_teacher_list_from_course_code_to_string(
|
|
|
+ public static function getTeacherListFromCourseCodeToString(
|
|
|
$course_code,
|
|
|
$separator = self::USER_SEPARATOR,
|
|
|
$add_link_to_profile = false,
|
|
@@ -2081,7 +2081,10 @@ class CourseManager
|
|
|
if ($orderList === true) {
|
|
|
$html .= '<ul class="user-teacher">';
|
|
|
foreach ($list as $teacher) {
|
|
|
- $html .= Display::tag('li', Display::return_icon('teacher.png', $teacher, null, ICON_SIZE_TINY).' '.$teacher);
|
|
|
+ $html .= '<li>';
|
|
|
+ $html .= Display::return_icon('teacher.png', '', null, ICON_SIZE_TINY);
|
|
|
+ $html .= ' '.$teacher;
|
|
|
+ $html .= '</li>';
|
|
|
}
|
|
|
$html .= '</ul>';
|
|
|
} else {
|
|
@@ -2163,7 +2166,7 @@ class CourseManager
|
|
|
foreach ($coachList as $coach_course) {
|
|
|
$coach_name = $coach_course['full_name'];
|
|
|
if ($add_link_to_profile) {
|
|
|
- $url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$coach_course['user_id'];
|
|
|
+ $url = api_get_path(WEB_AJAX_PATH).'user_manager.ajax.php?a=get_user_popup&user_id='.$coach_course['user_id'].'&course_id='.$courseId.'&session_id='.$session_id;
|
|
|
$coach_name = Display::url(
|
|
|
$coach_name,
|
|
|
$url,
|
|
@@ -2201,26 +2204,6 @@ class CourseManager
|
|
|
return $html;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Return user info array of all users registered in the specified course
|
|
|
- * this includes the users of the course itself and the users of all linked courses.
|
|
|
- *
|
|
|
- * @param string $course_code
|
|
|
- * @param bool $with_sessions
|
|
|
- * @param int $session_id
|
|
|
- * @return array with user info
|
|
|
- */
|
|
|
- public static function get_real_and_linked_user_list($course_code, $with_sessions = true, $session_id = 0)
|
|
|
- {
|
|
|
- $list = array();
|
|
|
- $userList = self::get_user_list_from_course_code($course_code, $session_id);
|
|
|
- foreach ($userList as $user) {
|
|
|
- $list[] = $user;
|
|
|
- }
|
|
|
-
|
|
|
- return $list;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Get the list of groups from the course
|
|
|
* @param string $course_code
|
|
@@ -2283,8 +2266,7 @@ class CourseManager
|
|
|
* so that a new course created with this code would not use the remains of an older
|
|
|
* course.
|
|
|
*
|
|
|
- * @param string The code of the course to delete
|
|
|
- * @param string $code
|
|
|
+ * @param string $code The code of the course to delete
|
|
|
* @todo When deleting a virtual course: unsubscribe users from that virtual
|
|
|
* course from the groups in the real course if they are not subscribed in
|
|
|
* that real course.
|
|
@@ -2517,9 +2499,8 @@ class CourseManager
|
|
|
|
|
|
/**
|
|
|
* Sort courses for a specific user ??
|
|
|
- * @param int User ID
|
|
|
- * @param string Course code
|
|
|
- * @param integer $user_id
|
|
|
+ * @param int $user_id User ID
|
|
|
+ * @param string $course_code Course code
|
|
|
* @return int Minimum course order
|
|
|
* @todo Review documentation
|
|
|
*/
|
|
@@ -2627,7 +2608,6 @@ class CourseManager
|
|
|
$courseId = intval($courseId);
|
|
|
$information = api_get_course_info_by_id($courseId);
|
|
|
$course_code = $information['code'];
|
|
|
-
|
|
|
$student = api_get_user_info($user_id);
|
|
|
|
|
|
$name_course = $information['title'];
|
|
@@ -2828,7 +2808,7 @@ class CourseManager
|
|
|
|
|
|
if ($adminGetsAllCourses && UserManager::is_admin($user_id)) {
|
|
|
// get the whole courses list
|
|
|
- $sql = "SELECT DISTINCT(course.code), course.id as real_id
|
|
|
+ $sql = "SELECT DISTINCT(course.code), course.id as real_id, course.title
|
|
|
FROM $tbl_course course
|
|
|
INNER JOIN $tableCourseUrl url
|
|
|
ON (course.id = url.c_id)
|
|
@@ -2851,7 +2831,8 @@ class CourseManager
|
|
|
if (!empty($withSpecialCourses)) {
|
|
|
$sql = "SELECT DISTINCT (course.code),
|
|
|
course.id as real_id,
|
|
|
- course.category_code AS category
|
|
|
+ course.category_code AS category,
|
|
|
+ course.title
|
|
|
FROM $tbl_course_user course_rel_user
|
|
|
LEFT JOIN $tbl_course course
|
|
|
ON course.id = course_rel_user.c_id
|
|
@@ -2881,7 +2862,8 @@ class CourseManager
|
|
|
$sql = "SELECT
|
|
|
DISTINCT(course.code),
|
|
|
course.id as real_id,
|
|
|
- course.category_code AS category
|
|
|
+ course.category_code AS category,
|
|
|
+ course.title
|
|
|
FROM $tbl_course course
|
|
|
INNER JOIN $tbl_course_user cru
|
|
|
ON (course.id = cru.c_id)
|
|
@@ -2912,7 +2894,7 @@ class CourseManager
|
|
|
if ($include_sessions === true) {
|
|
|
$sql = "SELECT DISTINCT (c.code),
|
|
|
c.id as real_id,
|
|
|
- course.category_code AS category
|
|
|
+ c.category_code AS category
|
|
|
FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." s,
|
|
|
$tbl_course c
|
|
|
WHERE user_id = $user_id AND s.c_id = c.id";
|
|
@@ -2996,9 +2978,8 @@ class CourseManager
|
|
|
|
|
|
/**
|
|
|
* Get coaches emails by session
|
|
|
- * @param int session id
|
|
|
+ * @param int $session_id
|
|
|
* @param int $courseId
|
|
|
- * @param integer $session_id
|
|
|
* @return array array(email => name_tutor) by coach
|
|
|
* @author Carlos Vargas <carlos.vargas@dokeos.com>
|
|
|
*/
|
|
@@ -3198,7 +3179,7 @@ class CourseManager
|
|
|
if (api_is_allowed_to_edit() && $action_show) {
|
|
|
//delete
|
|
|
$data .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete&description_id='.$description->id.'" onclick="javascript:if(!confirm(\''.addslashes(api_htmlentities(get_lang('ConfirmYourChoice'),
|
|
|
- ENT_QUOTES, $charset)).'\')) return false;">';
|
|
|
+ ENT_QUOTES, $charset)).'\')) return false;">';
|
|
|
$data .= Display::return_icon('delete.gif', get_lang('Delete'),
|
|
|
array('style' => 'vertical-align:middle;float:right;'));
|
|
|
$data .= '</a> ';
|
|
@@ -3224,7 +3205,7 @@ class CourseManager
|
|
|
/**
|
|
|
* Returns the details of a course category
|
|
|
*
|
|
|
- * @param string Category code
|
|
|
+ * @param string $code Category code
|
|
|
* @return array Course category
|
|
|
*/
|
|
|
public static function get_course_category($code)
|
|
@@ -3649,7 +3630,7 @@ class CourseManager
|
|
|
* @param int $user_id User id
|
|
|
* @param bool $load_dirs Whether to show the document quick-loader or not
|
|
|
* @param bool $useUserLanguageFilterIfAvailable
|
|
|
- * @return string
|
|
|
+ * @return array
|
|
|
*/
|
|
|
public static function returnSpecialCourses(
|
|
|
$user_id,
|
|
@@ -3720,13 +3701,13 @@ class CourseManager
|
|
|
$params['edit_actions'] .= api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'];
|
|
|
if ($load_dirs) {
|
|
|
$params['document'] = '<a id="document_preview_'.$courseId.'_0" class="document_preview btn btn-default btn-sm" href="javascript:void(0);">'
|
|
|
- . Display::returnFontAwesomeIcon('folder-open').'</a>';
|
|
|
+ . Display::returnFontAwesomeIcon('folder-open').'</a>';
|
|
|
$params['document'] .= Display::div('', ['id' => 'document_result_'.$courseId.'_0', 'class' => 'document_preview_container']);
|
|
|
}
|
|
|
} else {
|
|
|
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED && $load_dirs) {
|
|
|
$params['document'] = '<a id="document_preview_'.$courseId.'_0" class="document_preview btn btn-default btn-sm" href="javascript:void(0);">'
|
|
|
- . Display::returnFontAwesomeIcon('folder-open').'</a>';
|
|
|
+ . Display::returnFontAwesomeIcon('folder-open').'</a>';
|
|
|
$params['document'] .= Display::div('', ['id' => 'document_result_'.$courseId.'_0', 'class' => 'document_preview_container']);
|
|
|
}
|
|
|
}
|
|
@@ -3780,7 +3761,6 @@ class CourseManager
|
|
|
* @uses displayCoursesInCategory() to display the courses themselves
|
|
|
* @param int $user_id
|
|
|
* @param bool $load_dirs Whether to show the document quick-loader or not
|
|
|
- * @param integer $user_id
|
|
|
* @param bool $useUserLanguageFilterIfAvailable
|
|
|
*
|
|
|
* @return array
|
|
@@ -3844,7 +3824,7 @@ class CourseManager
|
|
|
* @param bool $load_dirs Whether to show the document quick-loader or not
|
|
|
* @param int $user_id
|
|
|
* @param bool $useUserLanguageFilterIfAvailable
|
|
|
- * @return string
|
|
|
+ * @return array
|
|
|
*/
|
|
|
public static function returnCoursesCategories(
|
|
|
$user_category_id,
|
|
@@ -3965,7 +3945,7 @@ class CourseManager
|
|
|
$params['edit_actions'] .= api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course_info['code'];
|
|
|
if ($load_dirs) {
|
|
|
$params['document'] = '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview btn btn-default btn-sm" href="javascript:void(0);">'
|
|
|
- . Display::returnFontAwesomeIcon('folder-open').'</a>';
|
|
|
+ . Display::returnFontAwesomeIcon('folder-open').'</a>';
|
|
|
$params['document'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class' => 'document_preview_container'));
|
|
|
}
|
|
|
}
|
|
@@ -4024,7 +4004,7 @@ class CourseManager
|
|
|
* @deprecated use self::returnCoursesCategories(0);
|
|
|
* @param int User category id
|
|
|
* @param bool Whether to show the document quick-loader or not
|
|
|
- * @return string
|
|
|
+ * @return array
|
|
|
*/
|
|
|
public static function returnCoursesWithoutCategories($user_category_id, $load_dirs = false)
|
|
|
{
|
|
@@ -4116,7 +4096,7 @@ class CourseManager
|
|
|
$params['edit_actions'] .= api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course_info['code'];
|
|
|
if ($load_dirs) {
|
|
|
$params['document'] = '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview btn btn-default btn-sm" href="javascript:void(0);">'
|
|
|
- . Display::returnFontAwesomeIcon('folder-open').'</a>';
|
|
|
+ . Display::returnFontAwesomeIcon('folder-open').'</a>';
|
|
|
$params['document'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class' => 'document_preview_container'));
|
|
|
}
|
|
|
}
|
|
@@ -4297,6 +4277,7 @@ class CourseManager
|
|
|
null,
|
|
|
true
|
|
|
);
|
|
|
+ $params['real_id'] = $course_info['real_id'];
|
|
|
|
|
|
// Display the "what's new" icons
|
|
|
$notifications = '';
|
|
@@ -4451,7 +4432,7 @@ class CourseManager
|
|
|
'session_category_id' => $session_category_id
|
|
|
);
|
|
|
|
|
|
- if (Skill::isAllow($user_id, false)) {
|
|
|
+ if (Skill::isAllowed($user_id, false)) {
|
|
|
$em = Database::getManager();
|
|
|
$objUser = $em->find('ChamiloUserBundle:User', $user_id);
|
|
|
$objCourse = $em->find('ChamiloCoreBundle:Course', $course['real_id']);
|
|
@@ -4474,12 +4455,12 @@ class CourseManager
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
- * @param string source course code
|
|
|
- * @param int source session id
|
|
|
- * @param string destination course code
|
|
|
- * @param int destination session id
|
|
|
- * @param integer $source_session_id
|
|
|
- * @param integer $destination_session_id
|
|
|
+ * @param string $source_course_code
|
|
|
+ * @param int $source_session_id
|
|
|
+ * @param string $destination_course_code
|
|
|
+ * @param int $destination_session_id
|
|
|
+ * @param array $params
|
|
|
+ *
|
|
|
* @return bool
|
|
|
*/
|
|
|
public static function copy_course(
|
|
@@ -4510,12 +4491,11 @@ class CourseManager
|
|
|
/**
|
|
|
* A simpler version of the copy_course, the function creates an empty course with an autogenerated course code
|
|
|
*
|
|
|
- * @param string new course title
|
|
|
- * @param string source course code
|
|
|
- * @param int source session id
|
|
|
- * @param int destination session id
|
|
|
- * @param bool new copied tools (Exercises and LPs)will be set to invisible by default?
|
|
|
- * @param string $new_title
|
|
|
+ * @param string $new_title new course title
|
|
|
+ * @param string source course code
|
|
|
+ * @param int source session id
|
|
|
+ * @param int destination session id
|
|
|
+ * @param bool new copied tools (Exercises and LPs)will be set to invisible by default?
|
|
|
*
|
|
|
* @return array
|
|
|
*/
|
|
@@ -4596,7 +4576,7 @@ class CourseManager
|
|
|
* @param int $session_id
|
|
|
* @return boolean
|
|
|
*/
|
|
|
- public static function is_user_accepted_legal($user_id, $course_code, $session_id = null)
|
|
|
+ public static function is_user_accepted_legal($user_id, $course_code, $session_id = 0)
|
|
|
{
|
|
|
$user_id = intval($user_id);
|
|
|
$course_code = Database::escape_string($course_code);
|
|
@@ -4661,7 +4641,6 @@ class CourseManager
|
|
|
$user_id = intval($user_id);
|
|
|
$course_code = Database::escape_string($course_code);
|
|
|
$session_id = intval($session_id);
|
|
|
-
|
|
|
$courseInfo = api_get_course_info($course_code);
|
|
|
$courseId = $courseInfo['real_id'];
|
|
|
|
|
@@ -4685,7 +4664,7 @@ class CourseManager
|
|
|
* @param int $url_id
|
|
|
* @return bool
|
|
|
*/
|
|
|
- public static function get_user_course_vote($user_id, $course_id, $session_id = null, $url_id = null)
|
|
|
+ public static function get_user_course_vote($user_id, $course_id, $session_id = 0, $url_id = 0)
|
|
|
{
|
|
|
$table_user_course_vote = Database::get_main_table(TABLE_MAIN_USER_REL_COURSE_VOTE);
|
|
|
$session_id = !isset($session_id) ? api_get_session_id() : intval($session_id);
|
|
@@ -4727,12 +4706,12 @@ class CourseManager
|
|
|
*/
|
|
|
public static function get_course_ranking(
|
|
|
$course_id,
|
|
|
- $session_id = null,
|
|
|
- $url_id = null
|
|
|
+ $session_id = 0,
|
|
|
+ $url_id = 0
|
|
|
) {
|
|
|
$table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
|
|
|
|
|
|
- $session_id = !isset($session_id) ? api_get_session_id() : intval($session_id);
|
|
|
+ $session_id = empty($session_id) ? api_get_session_id() : intval($session_id);
|
|
|
$url_id = empty($url_id) ? api_get_current_access_url_id() : intval($url_id);
|
|
|
$now = api_get_utc_datetime();
|
|
|
|
|
@@ -4776,15 +4755,17 @@ class CourseManager
|
|
|
*
|
|
|
* Updates the course ranking
|
|
|
* @param int course id
|
|
|
- * @param int session id
|
|
|
- * @param id url id
|
|
|
- * @param integer $session_id
|
|
|
+ * @param int $session_id
|
|
|
+ * @param int url id
|
|
|
+ * @param $points_to_add
|
|
|
+ * @param bool $add_access
|
|
|
+ * @param bool $add_user
|
|
|
* @return array
|
|
|
**/
|
|
|
public static function update_course_ranking(
|
|
|
- $course_id = null,
|
|
|
- $session_id = null,
|
|
|
- $url_id = null,
|
|
|
+ $course_id = 0 ,
|
|
|
+ $session_id = 0,
|
|
|
+ $url_id = 0,
|
|
|
$points_to_add = null,
|
|
|
$add_access = true,
|
|
|
$add_user = true
|
|
@@ -4795,7 +4776,7 @@ class CourseManager
|
|
|
$now = api_get_utc_datetime();
|
|
|
|
|
|
$course_id = empty($course_id) ? api_get_course_int_id() : intval($course_id);
|
|
|
- $session_id = !isset($session_id) ? api_get_session_id() : intval($session_id);
|
|
|
+ $session_id = empty($session_id) ? api_get_session_id() : intval($session_id);
|
|
|
$url_id = empty($url_id) ? api_get_current_access_url_id() : intval($url_id);
|
|
|
|
|
|
$params = array(
|
|
@@ -4866,8 +4847,8 @@ class CourseManager
|
|
|
$user_id,
|
|
|
$vote,
|
|
|
$course_id,
|
|
|
- $session_id = null,
|
|
|
- $url_id = null
|
|
|
+ $session_id = 0,
|
|
|
+ $url_id = 0
|
|
|
) {
|
|
|
$table_user_course_vote = Database::get_main_table(TABLE_MAIN_USER_REL_COURSE_VOTE);
|
|
|
$course_id = empty($course_id) ? api_get_course_int_id() : intval($course_id);
|
|
@@ -4880,7 +4861,7 @@ class CourseManager
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- $session_id = !isset($session_id) ? api_get_session_id() : intval($session_id);
|
|
|
+ $session_id = empty($session_id) ? api_get_session_id() : intval($session_id);
|
|
|
$url_id = empty($url_id) ? api_get_current_access_url_id() : intval($url_id);
|
|
|
$vote = intval($vote);
|
|
|
|
|
@@ -5013,7 +4994,7 @@ class CourseManager
|
|
|
|
|
|
if (Database::num_rows($result)) {
|
|
|
$courses = Database::store_result($result, 'ASSOC');
|
|
|
- $courses = self::process_hot_course_item($courses, $my_course_code_list);
|
|
|
+ $courses = self::processHotCourseItem($courses, $my_course_code_list);
|
|
|
}
|
|
|
|
|
|
return $courses;
|
|
@@ -5024,7 +5005,7 @@ class CourseManager
|
|
|
* @param array $my_course_code_list
|
|
|
* @return mixed
|
|
|
*/
|
|
|
- public static function process_hot_course_item($courses, $my_course_code_list = array())
|
|
|
+ public static function processHotCourseItem($courses, $my_course_code_list = array())
|
|
|
{
|
|
|
$hotCourses = [];
|
|
|
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
|
|
@@ -5088,7 +5069,7 @@ class CourseManager
|
|
|
get_lang('Subscribe').' '.
|
|
|
Display::returnFontAwesomeIcon('sign-in'),
|
|
|
api_get_path(WEB_COURSE_PATH).$course_info['path'].
|
|
|
- '/index.php?action=subscribe&sec_token='.$stok,
|
|
|
+ '/index.php?action=subscribe&sec_token='.$stok,
|
|
|
array(
|
|
|
'class' => 'btn btn-success btn-sm',
|
|
|
'title' => get_lang('Subscribe'),
|
|
@@ -5126,7 +5107,6 @@ class CourseManager
|
|
|
'aria-label' => get_lang('Unreg')
|
|
|
)
|
|
|
);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// start buycourse validation
|
|
@@ -5141,7 +5121,10 @@ class CourseManager
|
|
|
$my_course['price'] = $isThisCourseInSale['html'];
|
|
|
// set the Buy button instead register.
|
|
|
if ($isThisCourseInSale['verificator'] && !empty($my_course['register_button'])) {
|
|
|
- $my_course['register_button'] = $plugin->returnBuyCourseButton($course_info['real_id'], BuyCoursesPlugin::PRODUCT_TYPE_COURSE);
|
|
|
+ $my_course['register_button'] = $plugin->returnBuyCourseButton(
|
|
|
+ $course_info['real_id'],
|
|
|
+ BuyCoursesPlugin::PRODUCT_TYPE_COURSE
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
// end buycourse validation
|
|
@@ -5196,9 +5179,8 @@ class CourseManager
|
|
|
|
|
|
/**
|
|
|
* Get courses count
|
|
|
- * @param int Access URL ID (optional)
|
|
|
+ * @param int $access_url_id Access URL ID (optional)
|
|
|
* @param int $visibility
|
|
|
- * @param integer $access_url_id
|
|
|
*
|
|
|
* @return int Number of courses
|
|
|
*/
|
|
@@ -5296,7 +5278,6 @@ class CourseManager
|
|
|
/**
|
|
|
* Get available le courses count
|
|
|
* @param int $accessUrlId (optional)
|
|
|
- * @param integer $accessUrlId
|
|
|
* @return int Number of courses
|
|
|
*/
|
|
|
public static function countAvailableCourses($accessUrlId = 1)
|
|
@@ -5338,10 +5319,10 @@ class CourseManager
|
|
|
/**
|
|
|
* Return a link to go to the course, validating the visibility of the
|
|
|
* course and the user status
|
|
|
- * @param int User ID
|
|
|
+ * @param int $uid User ID
|
|
|
* @param array Course details array
|
|
|
* @param array List of courses to which the user is subscribed (if not provided, will be generated)
|
|
|
- * @param integer $uid
|
|
|
+ *
|
|
|
* @return mixed 'enter' for a link to go to the course or 'register' for a link to subscribe, or false if no access
|
|
|
*/
|
|
|
static function get_access_link_by_user($uid, $course, $user_courses = array())
|
|
@@ -5607,7 +5588,8 @@ class CourseManager
|
|
|
'show_system_folders',
|
|
|
'exercise_invisible_in_session',
|
|
|
'enable_forum_auto_launch',
|
|
|
- 'show_course_in_user_language'
|
|
|
+ 'show_course_in_user_language',
|
|
|
+ 'email_to_teachers_on_new_work_feedback'
|
|
|
);
|
|
|
|
|
|
if (!empty(ExerciseLib::getScoreModels())) {
|
|
@@ -5871,6 +5853,7 @@ class CourseManager
|
|
|
/**
|
|
|
* Returns the course name from a given code
|
|
|
* @param string $code
|
|
|
+ * @return string
|
|
|
*/
|
|
|
public static function getCourseNameFromCode($code)
|
|
|
{
|
|
@@ -5887,7 +5870,8 @@ class CourseManager
|
|
|
/**
|
|
|
* Generates a course code from a course title
|
|
|
* @todo Such a function might be useful in other places too. It might be moved in the CourseManager class.
|
|
|
- * @todo the function might be upgraded for avoiding code duplications (currently, it might suggest a code that is already in use)
|
|
|
+ * @todo the function might be upgraded for avoiding code duplications (currently,
|
|
|
+ * it might suggest a code that is already in use)
|
|
|
* @param string $title A course title
|
|
|
* @return string A proposed course code
|
|
|
* +
|
|
@@ -5926,26 +5910,29 @@ class CourseManager
|
|
|
/**
|
|
|
* this function gets all the users of the course,
|
|
|
* including users from linked courses
|
|
|
+ * @param $filterByActive
|
|
|
+ *
|
|
|
+ * @return array
|
|
|
*/
|
|
|
- public static function getCourseUsers()
|
|
|
+ public static function getCourseUsers($filterByActive = null)
|
|
|
{
|
|
|
- //this would return only the users from real courses:
|
|
|
- $session_id = api_get_session_id();
|
|
|
- if ($session_id != 0) {
|
|
|
- $user_list = self::get_real_and_linked_user_list(
|
|
|
- api_get_course_id(),
|
|
|
- true,
|
|
|
- $session_id
|
|
|
- );
|
|
|
- } else {
|
|
|
- $user_list = self::get_real_and_linked_user_list(
|
|
|
- api_get_course_id(),
|
|
|
- false,
|
|
|
- 0
|
|
|
- );
|
|
|
- }
|
|
|
+ // This would return only the users from real courses:
|
|
|
+ $userList = self::get_user_list_from_course_code(
|
|
|
+ api_get_course_id(),
|
|
|
+ api_get_session_id(),
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ null,
|
|
|
+ false,
|
|
|
+ false,
|
|
|
+ [],
|
|
|
+ [],
|
|
|
+ [],
|
|
|
+ $filterByActive
|
|
|
+ );
|
|
|
|
|
|
- return $user_list;
|
|
|
+ return $userList;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -5980,11 +5967,11 @@ class CourseManager
|
|
|
*/
|
|
|
public static function addUserGroupMultiSelect(&$form, $to_already_selected)
|
|
|
{
|
|
|
- $user_list = self::getCourseUsers();
|
|
|
+ $userList = self::getCourseUsers(true);
|
|
|
$group_list = self::getCourseGroups();
|
|
|
$array = self::buildSelectOptions(
|
|
|
$group_list,
|
|
|
- $user_list,
|
|
|
+ $userList,
|
|
|
$to_already_selected
|
|
|
);
|
|
|
|
|
@@ -6040,12 +6027,12 @@ class CourseManager
|
|
|
/**
|
|
|
* Shows the form for sending a message to a specific group or user.
|
|
|
* @param FormValidator $form
|
|
|
- * @param int $group_id id
|
|
|
+ * @param array $groupInfo
|
|
|
* @param array $to
|
|
|
*
|
|
|
* @return HTML_QuickForm_element
|
|
|
*/
|
|
|
- public static function addGroupMultiSelect($form, $groupInfo, $to = array())
|
|
|
+ public static function addGroupMultiSelect($form, $groupInfo, $to = [])
|
|
|
{
|
|
|
$group_users = GroupManager::get_subscribed_users($groupInfo);
|
|
|
$array = self::buildSelectOptions(null, $group_users, $to);
|
|
@@ -6061,13 +6048,13 @@ class CourseManager
|
|
|
/**
|
|
|
* this function shows the form for sending a message to a specific group or user.
|
|
|
* @param array $group_list
|
|
|
- * @param array $user_list
|
|
|
+ * @param array $userList
|
|
|
* @param array $to_already_selected
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function buildSelectOptions(
|
|
|
$group_list = array(),
|
|
|
- $user_list = array(),
|
|
|
+ $userList = array(),
|
|
|
$to_already_selected = array()
|
|
|
) {
|
|
|
if (empty($to_already_selected)) {
|
|
@@ -6097,8 +6084,8 @@ class CourseManager
|
|
|
}
|
|
|
|
|
|
// adding the individual users to the select form
|
|
|
- if ($user_list) {
|
|
|
- foreach ($user_list as $user) {
|
|
|
+ if ($userList) {
|
|
|
+ foreach ($userList as $user) {
|
|
|
if (is_array($to_already_selected)) {
|
|
|
if (!in_array(
|
|
|
"USER:".$user['user_id'],
|
|
@@ -6389,7 +6376,13 @@ class CourseManager
|
|
|
if ($loadDirs) {
|
|
|
$params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
|
|
|
$params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
|
|
|
- $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class'=>'document_preview_container'));
|
|
|
+ $params['right_actions'] .= Display::div(
|
|
|
+ '',
|
|
|
+ array(
|
|
|
+ 'id' => 'document_result_'.$course_info['real_id'].'_0',
|
|
|
+ 'class' => 'document_preview_container',
|
|
|
+ )
|
|
|
+ );
|
|
|
} else {
|
|
|
$params['right_actions'] .= '<a class="btn btn-default btn-sm" title="'.get_lang('Edit').'" href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::returnFontAwesomeIcon('pencil').'</a>';
|
|
|
}
|
|
@@ -6401,7 +6394,13 @@ class CourseManager
|
|
|
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
|
|
|
if ($loadDirs) {
|
|
|
$params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
|
|
|
- $params['right_actions'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class'=>'document_preview_container'));
|
|
|
+ $params['right_actions'] .= Display::div(
|
|
|
+ '',
|
|
|
+ array(
|
|
|
+ 'id' => 'document_result_'.$course_info['real_id'].'_0',
|
|
|
+ 'class' => 'document_preview_container',
|
|
|
+ )
|
|
|
+ );
|
|
|
} else {
|
|
|
if ($course_info['status'] == COURSEMANAGER) {
|
|
|
$params['right_actions'] .= '<a class="btn btn-default btn-sm" title="'.get_lang('Edit').'" href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::returnFontAwesomeIcon('pencil').'</a>';
|
|
@@ -6415,7 +6414,11 @@ class CourseManager
|
|
|
$course_title_url = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/?id_session=0';
|
|
|
$course_title = Display::url($course_info['title'], $course_title_url);
|
|
|
} else {
|
|
|
- $course_title = $course_info['title'].' '.Display::tag('span', get_lang('CourseClosed'), array('class'=>'item_closed'));
|
|
|
+ $course_title = $course_info['title'].' '.Display::tag(
|
|
|
+ 'span',
|
|
|
+ get_lang('CourseClosed'),
|
|
|
+ array('class' => 'item_closed')
|
|
|
+ );
|
|
|
}
|
|
|
|
|
|
// Start displaying the course block itself
|
|
@@ -6424,7 +6427,7 @@ class CourseManager
|
|
|
}
|
|
|
$teachers = '';
|
|
|
if (api_get_setting('display_teacher_in_courselist') === 'true') {
|
|
|
- $teachers = self::get_teacher_list_from_course_code_to_string(
|
|
|
+ $teachers = self::getTeacherListFromCourseCodeToString(
|
|
|
$course['code'],
|
|
|
self::USER_SEPARATOR,
|
|
|
true
|