Minor - format code.

pull/2487/head
jmontoyaa 7 years ago
parent 8ed3049a9e
commit 244d38a3ed
  1. 68
      main/inc/lib/attendance.lib.php
  2. 13
      main/inc/lib/career.lib.php
  3. 260
      main/inc/lib/course.lib.php
  4. 14
      main/inc/lib/course_description.lib.php
  5. 30
      main/inc/lib/course_home.lib.php
  6. 10
      main/inc/lib/exercise_show_functions.lib.php

@ -60,19 +60,16 @@ class Attendance
/**
* Get attendance list only the id, name and attendance_qualify_max fields
* @param string $course_id course db name (optional)
* @param int $course_id course db name (optional)
* @param int $session_id session id (optional)
* @return array attendances list
*/
public function get_attendances_list($course_id = '', $session_id = 0)
public function get_attendances_list($course_id = 0, $session_id = 0)
{
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$data = array();
$table = Database::get_course_table(TABLE_ATTENDANCE);
$course_id = intval($course_id);
if (empty($course_id)) {
$course_id = api_get_course_int_id();
} else {
$course_id = intval($course_id);
}
$session_id = !empty($session_id) ? intval($session_id) : api_get_session_id();
@ -80,11 +77,12 @@ class Attendance
// Get attendance data
$sql = "SELECT id, name, attendance_qualify_max
FROM $tbl_attendance
FROM $table
WHERE c_id = $course_id AND active = 1 $condition_session ";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$result = Database::query($sql);
$data = [];
if (Database::num_rows($result) > 0) {
while ($row = Database::fetch_array($result, 'ASSOC')) {
$data[$row['id']] = $row;
}
}
@ -142,7 +140,7 @@ class Attendance
LIMIT $from,$number_of_items ";
$res = Database::query($sql);
$attendances = array();
$attendances = [];
$user_info = api_get_user_info();
$allowDelete = api_get_setting('allow_delete_attendance');
@ -186,19 +184,19 @@ class Attendance
if (api_is_platform_admin()) {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_edit&attendance_id='.$attendance[0].'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>&nbsp;';
// Visible
if ($attendance[5] == 1) {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_set_invisible&attendance_id='.$attendance[0].'">'.
Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('visible.png', get_lang('Hide'), [], ICON_SIZE_SMALL).'</a>';
} else {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_set_visible&attendance_id='.$attendance[0].'">'.
Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('invisible.png', get_lang('Show'), [], ICON_SIZE_SMALL).'</a>';
$attendance[2] = '<span class="muted">'.$attendance[2].'</span>';
}
if ($allowDelete === 'true') {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'.
Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).'</a>';
}
} else {
$is_locked_attendance = self::is_locked_attendance($attendance[0]);
@ -207,19 +205,19 @@ class Attendance
$actions .= Display::return_icon('visible.png', get_lang('Hide'));
} else {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_edit&attendance_id='.$attendance[0].'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>&nbsp;';
if ($attendance[5] == 1) {
$actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_set_invisible&attendance_id='.$attendance[0].'">'.
Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('visible.png', get_lang('Hide'), [], ICON_SIZE_SMALL).'</a>';
} else {
$actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_set_visible&attendance_id='.$attendance[0].'">'.
Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('invisible.png', get_lang('Show'), [], ICON_SIZE_SMALL).'</a>';
$attendance[2] = '<span class="muted">'.$attendance[2].'</span>';
}
if ($allowDelete === 'true') {
$actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'.
Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).'</a>';
}
}
}
@ -279,7 +277,7 @@ class Attendance
$tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE);
$attendanceId = intval($attendanceId);
$course_id = api_get_course_int_id();
$attendance_data = array();
$attendance_data = [];
$sql = "SELECT * FROM $tbl_attendance
WHERE c_id = $course_id AND id = '$attendanceId'";
$res = Database::query($sql);
@ -643,7 +641,7 @@ class Attendance
$current_session_id = api_get_session_id();
$current_course_id = api_get_course_id();
$currentCourseIntId = api_get_course_int_id();
$studentInGroup = array();
$studentInGroup = [];
if (!empty($current_session_id)) {
$a_course_users = CourseManager:: get_user_list_from_course_code(
@ -672,9 +670,9 @@ class Attendance
}
// get registered users inside current course
$a_users = array();
$a_users = [];
foreach ($a_course_users as $key => $user_data) {
$value = array();
$value = [];
$uid = $user_data['user_id'];
$userInfo = api_get_user_info($uid);
$status = $user_data['status'];
@ -867,7 +865,7 @@ class Attendance
null,
true
);
$calendar_ids = array();
$calendar_ids = [];
// get all dates from calendar by current attendance
foreach ($attendance_calendar as $cal) {
$calendar_ids[] = $cal['id'];
@ -1019,7 +1017,7 @@ class Attendance
{
$user_id = intval($user_id);
$attendanceId = intval($attendanceId);
$results = array();
$results = [];
$calendar_count = self::get_number_of_attendance_calendar(
$attendanceId,
$groupId,
@ -1077,7 +1075,7 @@ class Attendance
// get all courses of current user
$courses = CourseManager::get_courses_list_by_user_id($user_id, true);
$user_id = intval($user_id);
$results = array();
$results = [];
$total_faults = $total_weight = $porcent = 0;
foreach ($courses as $course) {
//$course_code = $course['code'];
@ -1133,7 +1131,7 @@ class Attendance
$course_info = api_get_course_info($course_code);
$tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT);
$user_id = intval($user_id);
$results = array();
$results = [];
$total_faults = $total_weight = $porcent = 0;
$attendances_by_course = $this->get_attendances_list(
$course_info['real_id'],
@ -1188,7 +1186,7 @@ class Attendance
null,
$groupId
);
$calendar_ids = array();
$calendar_ids = [];
// get all dates from calendar by current attendance
foreach ($attendance_calendar as $cal) {
$calendar_ids[] = $cal['id'];
@ -1196,7 +1194,7 @@ class Attendance
$course_id = api_get_course_int_id();
$data = array();
$data = [];
if (empty($user_id)) {
// get all registered users inside current course
$users = $this->get_users_rel_course();
@ -1362,7 +1360,7 @@ class Attendance
$sql = "SELECT * FROM $table
WHERE c_id = $course_id AND id = '$calendar_id' ";
$rs = Database::query($sql);
$data = array();
$data = [];
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs)) {
$row['date_time'] = api_get_local_time($row['date_time']);
@ -1449,7 +1447,7 @@ class Attendance
$sql .= " ORDER BY date_time ";
$rs = Database::query($sql);
$data = array();
$data = [];
if (Database::num_rows($rs) > 0) {
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$row['db_date_time'] = $row['date_time'];
@ -1627,7 +1625,7 @@ class Attendance
* @param array $groupList
* @return int affected rows
*/
public function attendance_calendar_add($attendanceId, $groupList = array())
public function attendance_calendar_add($attendanceId, $groupList = [])
{
$tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR);
$affected_rows = 0;
@ -1775,7 +1773,7 @@ class Attendance
$start_date,
$end_date,
$repeat_type,
$groupList = array()
$groupList = []
) {
$attendanceId = intval($attendanceId);
// save start date
@ -2053,7 +2051,7 @@ class Attendance
$dateTimeEnd->format('Y-m-d H:i:s')
);
$results = array();
$results = [];
if (!empty($accessData)) {
foreach ($accessData as $data) {
$onlyDate = substr($data['login_course_date'], 0, 10);

@ -36,7 +36,7 @@ class Career extends Model
$row = Database::select(
'count(*) as count',
$this->table,
array(),
[],
'first'
);
return $row['count'];
@ -120,9 +120,9 @@ class Career extends Model
$header = get_lang('Modify');
}
$form->addElement('header', $header);
$id = isset($_GET['id']) ? intval($_GET['id']) : '';
$form->addElement('hidden', 'id', $id);
$form->addHeader($header);
$form->addHidden('id', $id);
$form->addElement('text', 'name', get_lang('Name'), array('size' => '70'));
$form->addHtmlEditor(
'description',
@ -214,9 +214,9 @@ class Career extends Model
*/
public function get_status($career_id)
{
$TBL_CAREER = Database::get_main_table(TABLE_CAREER);
$table = Database::get_main_table(TABLE_CAREER);
$career_id = intval($career_id);
$sql = "SELECT status FROM $TBL_CAREER WHERE id = '$career_id'";
$sql = "SELECT status FROM $table WHERE id = '$career_id'";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$data = Database::fetch_array($result);
@ -296,9 +296,6 @@ class Career extends Model
if (!($graph instanceof Graph)) {
return '';
}
$debug = false;
// Getting max column
$maxColumn = 0;
foreach ($graph->getVertices() as $vertex) {

@ -28,7 +28,7 @@ class CourseManager
* list (userportal), footer, etc */
const USER_SEPARATOR = ' |';
const COURSE_FIELD_TYPE_CHECKBOX = 10;
public $columns = array();
public $columns = [];
/**
* Creates a course
@ -93,7 +93,6 @@ class CourseManager
$params['directory'] = $keys['currentCourseRepository'];
$course_info = api_get_course_info($params['code']);
if (empty($course_info)) {
$course_id = AddCourse::register_course($params);
$course_info = api_get_course_info_by_id($course_id);
@ -903,103 +902,6 @@ class CourseManager
return $result['number'] > 0;
}
/**
* Get course list as coach
*
* @param int $user_id
* @param bool $include_courses_in_sessions
* @return array Course list
*
**/
public static function get_course_list_as_coach(
$user_id,
$include_courses_in_sessions = false
) {
// 1. Getting courses as teacher (No session)
$courses_temp = self::get_course_list_of_user_as_course_admin($user_id);
$courseList = array();
if (!empty($courses_temp)) {
foreach ($courses_temp as $course_item) {
$courseList[0][$course_item['code']] = $course_item['code'];
}
}
//2. Include courses in sessions
if ($include_courses_in_sessions) {
$sessions = Tracking::get_sessions_coached_by_user($user_id);
if (!empty($sessions)) {
foreach ($sessions as $session_item) {
$courses = Tracking::get_courses_followed_by_coach(
$user_id,
$session_item['id']
);
if (is_array($courses)) {
foreach ($courses as $course_item) {
$courseList[$session_item['id']][$course_item] = $course_item;
}
}
}
}
}
return $courseList;
}
/**
* @param int $user_id
* @param bool $include_sessions
* @return array
*/
public static function get_user_list_from_courses_as_coach($user_id, $include_sessions = true)
{
$students_in_courses = array();
$sessions = self::get_course_list_as_coach($user_id, true);
if (!empty($sessions)) {
foreach ($sessions as $session_id => $courses) {
if (!$include_sessions) {
if (!empty($session_id)) {
continue;
}
}
if (empty($session_id)) {
foreach ($courses as $course_code) {
$students_in_course = self::get_user_list_from_course_code($course_code);
foreach ($students_in_course as $user_item) {
//Only students
if ($user_item['status_rel'] == STUDENT) {
$students_in_courses[$user_item['user_id']] = $user_item['user_id'];
}
}
}
} else {
$students_in_course = SessionManager::get_users_by_session($session_id, '0');
if (is_array($students_in_course)) {
foreach ($students_in_course as $user_item) {
$students_in_courses[$user_item['user_id']] = $user_item['user_id'];
}
}
}
}
}
$students = Tracking:: get_student_followed_by_coach($user_id);
if (!empty($students_in_courses)) {
if (!empty($students)) {
$students = array_merge($students, $students_in_courses);
} else {
$students = $students_in_courses;
}
}
if (!empty($students)) {
$students = array_unique($students);
}
return $students;
}
/**
* @param int $user_id
* @param string $startsWith Optional
@ -1009,14 +911,14 @@ class CourseManager
public static function get_course_list_of_user_as_course_admin($user_id, $startsWith = '')
{
if ($user_id != strval(intval($user_id))) {
return array();
return [];
}
// Definitions database tables and variables
$tbl_course = Database::get_main_table(TABLE_MAIN_COURSE);
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$user_id = intval($user_id);
$data = array();
$data = [];
$sql = "SELECT
course.code,
@ -1163,8 +1065,7 @@ class CourseManager
return true;
}
$sql = 'SELECT 1 FROM '.$tableSessionCourseUser.
' WHERE user_id = '.$user_id.' AND status=2 '.$condition_course;
$sql = 'SELECT 1 FROM '.$tableSessionCourseUser.' WHERE user_id = '.$user_id.' AND status=2 '.$condition_course;
if (Database::num_rows(Database::query($sql)) > 0) {
return true;
}
@ -1256,10 +1157,10 @@ class CourseManager
// A course coach?
if (Database::num_rows(Database::query("SELECT user_id
FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)."
WHERE session_id='" . $session_id."'
FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)."
WHERE session_id='".$session_id."'
AND user_id = '$user_id' AND status = 2
AND c_id ='$courseId'"))
AND c_id = '$courseId'"))
) {
return true;
}
@ -1267,8 +1168,8 @@ class CourseManager
// A session coach?
if (Database::num_rows(Database::query("SELECT id_coach
FROM " . Database::get_main_table(TABLE_MAIN_SESSION)." AS session
WHERE session.id='" . $session_id."'
AND id_coach='$user_id'"))
WHERE session.id='".$session_id."'
AND id_coach = '$user_id'"))
) {
return true;
}
@ -2177,15 +2078,15 @@ class CourseManager
if ($in_get_empty_group == 0) {
// get only groups that are not empty
$sql = "SELECT DISTINCT g.id, g.iid, g.name
FROM " . Database::get_course_table(TABLE_GROUP)." AS g
INNER JOIN " . Database::get_course_table(TABLE_GROUP_USER)." gu
FROM ".Database::get_course_table(TABLE_GROUP)." AS g
INNER JOIN ".Database::get_course_table(TABLE_GROUP_USER)." gu
ON (g.id = gu.group_id AND g.c_id = $course_id AND gu.c_id = $course_id)
$session_condition
ORDER BY g.name";
} else {
// get all groups even if they are empty
$sql = "SELECT g.id, g.name, g.iid
FROM " . Database::get_course_table(TABLE_GROUP)." AS g
FROM ".Database::get_course_table(TABLE_GROUP)." AS g
$session_condition
AND c_id = $course_id";
}
@ -2214,7 +2115,6 @@ class CourseManager
* @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.
* @todo Remove globals
*/
public static function delete_course($code)
{
@ -2378,13 +2278,12 @@ class CourseManager
$extraFieldValues->deleteValuesByItem($courseId);
// Add event to system log
$user_id = api_get_user_id();
Event::addEvent(
LOG_COURSE_DELETE,
LOG_COURSE_CODE,
$code,
api_get_utc_datetime(),
$user_id,
api_get_user_id(),
$courseId
);
}
@ -2461,7 +2360,7 @@ class CourseManager
);
$sql = 'SELECT course.code as code, course.title as title, cu.sort as sort
FROM ' . $TABLECOURSUSER.' as cu, '.$TABLECOURSE.' as course
FROM '.$TABLECOURSUSER.' as cu, '.$TABLECOURSE.' as course
WHERE course.id = cu.c_id AND user_id = "' . $user_id.'" AND
cu.relation_type<>' . COURSE_RELATION_TYPE_RRHH.' AND
user_course_cat = 0
@ -2509,8 +2408,13 @@ class CourseManager
// We must register the course in the beginning of the list
if (!$course_found) {
$course_sort = Database::result(Database::query('SELECT min(sort) as min_sort FROM '.$TABLECOURSUSER.' WHERE user_id="'.$user_id.'" AND user_course_cat="0"'),
0, 0);
$course_sort = Database::result(
Database::query(
'SELECT min(sort) as min_sort FROM '.$TABLECOURSUSER.' WHERE user_id="'.$user_id.'" AND user_course_cat="0"'
),
0,
0
);
Database::query('UPDATE '.$TABLECOURSUSER.' SET sort = sort+1 WHERE user_id= "'.$user_id.'" AND user_course_cat="0"');
}
}
@ -2525,7 +2429,7 @@ class CourseManager
public static function course_exists($course_code)
{
$sql = 'SELECT 1 FROM '.Database::get_main_table(TABLE_MAIN_COURSE).'
WHERE code="' . Database::escape_string($course_code).'"';
WHERE code="'.Database::escape_string($course_code).'"';
return Database::num_rows(Database::query($sql));
}
@ -2577,8 +2481,12 @@ class CourseManager
$emailbody .= get_lang('FirstName').': '.$student['firstname']."\n";
}
$emailbody .= get_lang('Email').': <a href="mailto:'.$student['email'].'">'.$student['email']."</a>\n\n";
$recipient_name = api_get_person_name($tutor['firstname'], $tutor['lastname'], null,
PERSON_NAME_EMAIL_ADDRESS);
$recipient_name = api_get_person_name(
$tutor['firstname'],
$tutor['lastname'],
null,
PERSON_NAME_EMAIL_ADDRESS
);
$sender_name = api_get_person_name(api_get_setting('administratorName'),
api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS);
$email_admin = api_get_setting('emailAdministrator');
@ -2714,6 +2622,7 @@ class CourseManager
* @param bool $loadSpecialCourses
* @param array $skipCourseList List of course ids to skip
* @param bool $useUserLanguageFilterIfAvailable
* @param bool $showCoursesSessionWithDifferentKey
* @return array List of codes and db name
* @author isaac flores paz
*/
@ -2911,7 +2820,7 @@ class CourseManager
* */
public static function get_emails_of_tutors_to_course($courseId)
{
$list = array();
$list = [];
$res = Database::query("SELECT user_id FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)."
WHERE c_id ='" . intval($courseId)."' AND status=1");
while ($list_users = Database::fetch_array($res)) {
@ -3159,9 +3068,9 @@ class CourseManager
*/
public static function get_course_category($code)
{
$table_categories = Database::get_main_table(TABLE_MAIN_CATEGORY);
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$code = Database::escape_string($code);
$sql = "SELECT * FROM $table_categories WHERE code = '$code'";
$sql = "SELECT * FROM $table WHERE code = '$code'";
return Database::fetch_array(Database::query($sql));
}
@ -3169,18 +3078,18 @@ class CourseManager
* Returns the details of a course category
*
* @param string Category code
* @return array Course category
* @return array Course category list
*/
public static function getCategoriesList()
{
$table_categories = Database::get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT * FROM $table_categories";
$table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$sql = "SELECT * FROM $table";
$result = Database::query($sql);
$category = array();
$categoryList = [];
while ($row = Database::fetch_array($result, 'ASSOC')) {
$category[$row['code']] = $row['name'];
$categoryList[$row['code']] = $row['name'];
}
return $category;
return $categoryList;
}
/**
@ -3650,13 +3559,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']);
}
}
@ -3894,14 +3803,26 @@ 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>';
$params['document'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class' => 'document_preview_container'));
.Display::returnFontAwesomeIcon('folder-open').'</a>';
$params['document'] .= Display::div(
'',
array(
'id' => 'document_result_'.$course_info['real_id'].'_0',
'class' => 'document_preview_container',
)
);
}
}
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>';
$params['document'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class' => 'document_preview_container'));
$params['document'] .= Display::div(
'',
array(
'id' => 'document_result_'.$course_info['real_id'].'_0',
'class' => 'document_preview_container',
)
);
}
$courseUrl = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0';
@ -4051,7 +3972,7 @@ class CourseManager
}
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'));
}
@ -4096,8 +4017,8 @@ class CourseManager
public static function get_user_course_categories($userId = 0)
{
$userId = empty($userId) ? api_get_user_id() : (int) $userId;
$table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM $table_category
$table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM $table
WHERE user_id = $userId
ORDER BY sort ASC
";
@ -4217,7 +4138,7 @@ class CourseManager
// Display course entry.
// Show a hyperlink to the course, unless the course is closed and user is not course admin.
$session_url = '';
$params = array();
$params = [];
$params['icon'] = Display::return_icon(
'blackboard_blue.png',
null,
@ -4383,7 +4304,7 @@ class CourseManager
if (Skill::isAllowed($user_id, false)) {
$em = Database::getManager();
$objUser = $em->find('ChamiloUserBundle:User', $user_id);
$objUser = api_get_user_entity($user_id);
$objCourse = $em->find('ChamiloCoreBundle:Course', $course['real_id']);
$objSession = $em->find('ChamiloCoreBundle:Session', $session_id);
@ -4444,7 +4365,7 @@ class CourseManager
* @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 array $params
*
* @return array
*/
@ -4453,7 +4374,7 @@ class CourseManager
$source_course_code,
$source_session_id = 0,
$destination_session_id = 0,
$params = array()
$params = []
) {
$source_course_info = api_get_course_info($source_course_code);
if (!empty($source_course_info)) {
@ -4721,9 +4642,7 @@ class CourseManager
) {
// Course catalog stats modifications see #4191
$table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
$now = api_get_utc_datetime();
$course_id = empty($course_id) ? api_get_course_int_id() : intval($course_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);
@ -5071,12 +4990,12 @@ class CourseManager
*/
public static function return_most_accessed_courses($limit = 5)
{
$table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING);
$params['url_id'] = api_get_current_access_url_id();
$result = Database::select(
'c_id, accesses, total_score, users',
$table_course_ranking,
$table,
array('where' => array('url_id = ?' => $params), 'order' => 'accesses DESC', 'limit' => $limit),
'all',
true
@ -5233,7 +5152,7 @@ class CourseManager
*
* @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())
static function get_access_link_by_user($uid, $course, $user_courses = [])
{
if (empty($uid) || empty($course)) {
return false;
@ -6180,20 +6099,6 @@ class CourseManager
return $form_data;
}
/**
* return html code for displaying a course title in the standard view (not the Session view)
* @param $courseId
* @param bool $loadDirs
* @return string
*/
public static function displayCourseHtml($courseId, $loadDirs = false)
{
$params = self::getCourseParamsForDisplay($courseId, $loadDirs);
$html = self::course_item_html($params, false);
return $html;
}
/**
* Return tab of params to display a course title in the My Courses tab
* Check visibility, right, and notification icons, and load_dirs option
@ -6284,7 +6189,9 @@ class CourseManager
if (api_is_platform_admin()) {
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'] .= '<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(
@ -6293,16 +6200,14 @@ class CourseManager
)
);
} 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>';
}
if ($course_info['status'] == COURSEMANAGER) {
//echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;'));
$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>';
}
} else {
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'] .= '<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(
@ -6312,7 +6217,8 @@ class CourseManager
);
} 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>';
$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>';
}
}
}
@ -6557,22 +6463,26 @@ class CourseManager
*/
public static function returnDescriptionButton($course)
{
$title = $course['title'];
$html = '';
if (empty($course)) {
return '';
}
if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') {
$title = $course['title'];
$url = api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'];
$html = Display::url(
Display::returnFontAwesomeIcon('info-circle', 2),
api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'],
array(
$url,
[
'class' => 'ajax btn btn-default btn-sm',
'data-title' => $title,
'title' => get_lang('Description'),
'aria-label' => get_lang('Description'),
'data-size' => 'lg'
)
]
);
}
return $html;
}
return '';
}
}

@ -238,7 +238,7 @@ class CourseDescription
);
}
return ($last_id > 0) ? 1 : 0;
return $last_id > 0 ? 1 : 0;
}
/**
@ -304,7 +304,7 @@ class CourseDescription
);
if ($this->id > 0) {
//insert into item_property
// Insert into item_property
api_item_property_update(
api_get_course_info(),
TOOL_COURSE_DESCRIPTION,
@ -375,7 +375,7 @@ class CourseDescription
*/
public function get_default_description_title()
{
$default_description_titles = array();
$default_description_titles = [];
$default_description_titles[1] = get_lang('GeneralDescription');
$default_description_titles[2] = get_lang('Objectives');
$default_description_titles[3] = get_lang('Topics');
@ -394,7 +394,7 @@ class CourseDescription
*/
public function get_default_description_title_editable()
{
$default_description_title_editable = array();
$default_description_title_editable = [];
$default_description_title_editable[1] = true;
$default_description_title_editable[2] = true;
$default_description_title_editable[3] = true;
@ -413,7 +413,7 @@ class CourseDescription
*/
public function get_default_description_icon()
{
$default_description_icon = array();
$default_description_icon = [];
$default_description_icon[1] = 'info.png';
$default_description_icon[2] = 'objective.png';
$default_description_icon[3] = 'topics.png';
@ -433,7 +433,7 @@ class CourseDescription
*/
public function get_default_question()
{
$question = array();
$question = [];
$question[1] = get_lang('GeneralDescriptionQuestions');
$question[2] = get_lang('ObjectivesQuestions');
$question[3] = get_lang('TopicsQuestions');
@ -452,7 +452,7 @@ class CourseDescription
*/
public function get_default_information()
{
$information = array();
$information = [];
$information[1] = get_lang('GeneralDescriptionInformation');
$information[2] = get_lang('ObjectivesInformation');
$information[3] = get_lang('TopicsInformation');

@ -35,7 +35,8 @@ class CourseHome
$condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND (t.position="basic" OR a.name = "'.TOOL_TRACKING.'") ';
}
$sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
$sql = "SELECT a.*, t.image img, t.row, t.column
FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
$condition_display_tools ORDER BY t.row, t.column";
break;
case 'External':
@ -52,12 +53,16 @@ class CourseHome
}
break;
case 'courseAdmin':
$sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE a.c_id = $course_id AND admin=1 AND a.link=t.link ORDER BY t.row, t.column";
$sql = "SELECT a.*, t.image img, t.row, t.column
FROM $TBL_ACCUEIL a, $TABLE_TOOLS t
WHERE a.c_id = $course_id AND admin=1 AND a.link=t.link
ORDER BY t.row, t.column";
break;
case 'platformAdmin':
$sql = "SELECT *, image img FROM $TBL_ACCUEIL WHERE c_id = $course_id AND visibility = 2 ORDER BY id";
$sql = "SELECT *, image img FROM $TBL_ACCUEIL
WHERE c_id = $course_id AND visibility = 2
ORDER BY id";
}
$result = Database::query($sql);
@ -729,15 +734,14 @@ class CourseHome
// Get blog members
if ($is_platform_admin) {
$sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
WHERE blog_id =".$blog_id;
$sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
WHERE blog_id = ".$blog_id;
} else {
$sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
WHERE blog_id =".$blog_id." AND user_id = ".$userId;
$sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user
WHERE blog_id = ".$blog_id." AND user_id = ".$userId;
}
$result_blogs = Database::query($sql_blogs);
if (Database::num_rows($result_blogs) > 0) {
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$all_tools_list[] = $tool;
}
} else {
@ -1028,7 +1032,9 @@ class CourseHome
'onclick' => 'javascript: window.open(\''.$tool['link'].'\',\'window_visio'.api_get_course_id().'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')',
'target' => $tool['target']
);
} elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) {
} elseif (strpos($tool['name'], 'chat') !== false &&
api_get_course_setting('allow_open_chat_window')
) {
$tool_link_params = array(
'id' => 'tooldesc_'.$toolIid,
'class' => $class,

@ -38,7 +38,12 @@ class ExerciseShowFunctions
$originalStudentAnswer = '',
$showTotalScoreAndUserChoices
) {
$answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices);
$answerHTML = FillBlanks::getHtmlDisplayForAnswer(
$answer,
$feedbackType,
$resultsDisabled,
$showTotalScoreAndUserChoices
);
if (strpos($originalStudentAnswer, 'font color') !== false) {
$answerHTML = $originalStudentAnswer;
}
@ -156,8 +161,7 @@ class ExerciseShowFunctions
$fileUrl = null,
$results_disabled = 0,
$questionScore = 0
)
{
) {
if (isset($fileUrl)) {
echo '
<tr>

Loading…
Cancel
Save