Minor - format code, remove unused code.

pull/3023/head
Julio Montoya 6 years ago
parent 106f8eb6cb
commit 3bc5a7b57d
  1. 34
      main/auth/hrm_courses.php
  2. 1
      main/badge/assign.php
  3. 1
      main/badge/issued_all.php
  4. 1
      main/course_info/infocours.php
  5. 78
      main/exercise/TestCategory.php
  6. 41
      main/extra/userInfoLib.php
  7. 2
      main/gradebook/certificate_report.php
  8. 16
      main/group/member_settings.php
  9. 18
      main/group/tutor_settings.php
  10. 121
      main/inc/lib/link.lib.php
  11. 90
      main/inc/lib/social.lib.php
  12. 86
      main/inc/lib/system_announcements.lib.php
  13. 4
      main/inc/lib/template.lib.php
  14. 299
      main/inc/lib/tracking.lib.php
  15. 64
      main/survey/surveyUtil.class.php
  16. 10
      main/ticket/new_ticket.php
  17. 11
      main/ticket/report.php
  18. 2
      main/webservices/access_url.php

@ -1,11 +1,9 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Course;
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
api_block_anonymous_users(true); api_block_anonymous_users();
$isHrm = api_is_drh(); $isHrm = api_is_drh();
@ -13,36 +11,6 @@ if (!$isHrm) {
api_not_allowed(true); api_not_allowed(true);
} }
function formatCourseInfo(Course $course, $sessionId = 0, $showCourseCode = false)
{
$sysCoursePath = api_get_path(SYS_COURSE_PATH).$course->getDirectory();
$webCoursePath = api_get_path(WEB_COURSE_PATH).$course->getDirectory();
return [
'visibility' => $course->getVisibility(),
'link' => api_get_course_url($course->getCode(), $sessionId),
'category' => $course->getCategoryCode(),
'title' => $course->getTitle(),
'title_cut' => $course->getTitle(),
'code_course' => $showCourseCode ? $course->getCode() : null,
'image' => file_exists($sysCoursePath.'/course-pic.png')
? $webCoursePath.'/course-pic.png'
: Display::return_icon(
'session_default.png',
null,
null,
null,
null,
true
),
'teachers' => api_get_setting('display_teacher_in_courselist') === 'true'
? $teachers = CourseManager::getTeachersFromCourse($course->getId(), true)
: [],
];
}
$showCourseCode = api_get_configuration_value('display_coursecode_in_courselist') === 'true';
$hrm = api_get_user_entity(api_get_user_id()); $hrm = api_get_user_entity(api_get_user_id());
$assignedUsers = UserManager::get_users_followed_by_drh($hrm->getId()); $assignedUsers = UserManager::get_users_followed_by_drh($hrm->getId());
$users = []; $users = [];

@ -2,7 +2,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Skill; use Chamilo\CoreBundle\Entity\Skill;
use Chamilo\UserBundle\Entity\User;
use Skill as SkillManager; use Skill as SkillManager;
/** /**

@ -3,7 +3,6 @@
use Chamilo\CoreBundle\Entity\SkillRelUser; use Chamilo\CoreBundle\Entity\SkillRelUser;
use Chamilo\CoreBundle\Entity\SkillRelUserComment; use Chamilo\CoreBundle\Entity\SkillRelUserComment;
use Chamilo\UserBundle\Entity\User;
use SkillRelUser as SkillRelUserManager; use SkillRelUser as SkillRelUserManager;
/** /**

@ -25,7 +25,6 @@ $_course = api_get_course_info();
/* Constants and variables */ /* Constants and variables */
define('MODULE_HELP_NAME', 'Settings'); define('MODULE_HELP_NAME', 'Settings');
define('COURSE_CHANGE_PROPERTIES', 'COURSE_CHANGE_PROPERTIES');
$currentCourseRepository = $_course['path']; $currentCourseRepository = $_course['path'];
$is_allowedToEdit = api_is_course_admin() || api_is_platform_admin(); $is_allowedToEdit = api_is_course_admin() || api_is_platform_admin();

@ -283,22 +283,6 @@ class TestCategory
return $result; return $result;
} }
/**
* true if question id has a category.
*
* @param int $questionId
*
* @return bool
*/
public static function isQuestionHasCategory($questionId)
{
if (self::getCategoryForQuestion($questionId) > 0) {
return true;
}
return false;
}
/** /**
* Return the category name for question with question_id = $questionId * Return the category name for question with question_id = $questionId
* In this version, a question has only 1 category. * In this version, a question has only 1 category.
@ -437,17 +421,6 @@ class TestCategory
return $result; return $result;
} }
/**
* return the number of differents categories for a test
* input : test_id
* return : integer
* hubert.borderiou 07-04-2011.
*/
public static function getNumberOfCategoriesForTest($id)
{
return count(self::getListOfCategoriesIDForTest($id));
}
/** /**
* return the number of question of a category id in a test. * return the number of question of a category id in a test.
* *
@ -672,22 +645,6 @@ class TestCategory
return $content; return $content;
} }
/**
* Display signs [+] and/or (>0) after question title if question has options
* scoreAlwaysPositive and/or uncheckedMayScore.
*
* @param $objQuestion
*/
public function displayQuestionOption($objQuestion)
{
if ($objQuestion->type == MULTIPLE_ANSWER && $objQuestion->scoreAlwaysPositive) {
echo "<span style='font-size:75%'> (>0)</span>";
}
if ($objQuestion->type == MULTIPLE_ANSWER && $objQuestion->uncheckedMayScore) {
echo "<span style='font-size:75%'> [+]</span>";
}
}
/** /**
* sortTabByBracketLabel ($tabCategoryQuestions) * sortTabByBracketLabel ($tabCategoryQuestions)
* key of $tabCategoryQuestions are the category id (0 for not in a category) * key of $tabCategoryQuestions are the category id (0 for not in a category)
@ -863,22 +820,6 @@ class TestCategory
return ''; return '';
} }
/**
* @return array
*/
public static function get_all_categories()
{
$table = Database::get_course_table(TABLE_QUIZ_CATEGORY);
$sql = "SELECT * FROM $table ORDER BY title ASC";
$res = Database::query($sql);
$array = [];
while ($row = Database::fetch_array($res, 'ASSOC')) {
$array[] = $row;
}
return $array;
}
/** /**
* @param Exercise $exercise * @param Exercise $exercise
* @param int $courseId * @param int $courseId
@ -1073,25 +1014,6 @@ class TestCategory
return $return; return $return;
} }
/**
* Sorts an array.
*
* @param array $array
*
* @return array
*/
public function sort_tree_array($array)
{
foreach ($array as $key => $row) {
$parent[$key] = $row['parent_id'];
}
if (count($array) > 0) {
array_multisort($parent, SORT_ASC, $array);
}
return $array;
}
/** /**
* Return true if a category already exists with the same name. * Return true if a category already exists with the same name.
* *

@ -459,47 +459,6 @@ function get_course_user_info($user_id)
return false; return false;
} }
/**
* get the main user information.
*
* @author - Hugues Peeters <peeters@ipm.ucl.ac.be>
* @author - Christophe Gesche <gesche@ipm.ucl.ac.be>
*
* @param int $user_id user id as stored in the Dokeos main db
*
* @return array containing user info as 'lastName', 'firstName', 'email', 'role'
*/
function get_main_user_info($user_id, $courseCode)
{
$user_id = (int) $user_id;
$courseCode = Database::escape_string($courseCode);
$courseId = api_get_course_int_id($courseCode);
if (0 == $user_id) {
return false;
}
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$table_user = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT u.*, u.lastname lastName, u.firstname firstName,
u.email, u.picture_uri picture,
cu.status status, cu.is_tutor as tutor_id
FROM $table_user u, $table_course_user cu
WHERE u.user_id = cu.user_id AND cu.relation_type<>".COURSE_RELATION_TYPE_RRHH."
AND u.user_id = $user_id
AND cu.c_id = $courseId";
$result = Database::query($sql);
if (Database::num_rows($result) > 0) {
$userInfo = Database::fetch_array($result, 'ASSOC');
$userInfo['password'] = '';
return $userInfo;
}
return false;
}
/** /**
* get the user content of a categories plus the categories definition. * get the user content of a categories plus the categories definition.
* *

@ -1,8 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/** /**
* List all certificates filtered by session/course and month/year. * List all certificates filtered by session/course and month/year.
* *

@ -32,22 +32,6 @@ if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
api_not_allowed(true); api_not_allowed(true);
} }
/**
* List all users registered to the course.
*/
function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword)
{
if (api_strripos($firstname, $keyword) !== false ||
api_strripos($lastname, $keyword) !== false ||
api_strripos($username, $keyword) !== false ||
api_strripos($official_code, $keyword) !== false
) {
return true;
} else {
return false;
}
}
/** /**
* Function to sort users after getting the list in the DB. * Function to sort users after getting the list in the DB.
* Necessary because there are 2 or 3 queries. Called by usort(). * Necessary because there are 2 or 3 queries. Called by usort().

@ -32,24 +32,6 @@ if (!api_is_allowed_to_edit(false, true) && !$is_group_member) {
api_not_allowed(true); api_not_allowed(true);
} }
/* FUNCTIONS */
/**
* List all users registered to the course.
*/
function search_members_keyword($firstname, $lastname, $username, $official_code, $keyword)
{
if (api_strripos($firstname, $keyword) !== false ||
api_strripos($lastname, $keyword) !== false ||
api_strripos($username, $keyword) !== false ||
api_strripos($official_code, $keyword) !== false
) {
return true;
} else {
return false;
}
}
/** /**
* Function to sort users after getting the list in the DB. * Function to sort users after getting the list in the DB.
* Necessary because there are 2 or 3 queries. Called by usort(). * Necessary because there are 2 or 3 queries. Called by usort().

@ -1313,127 +1313,6 @@ class Link extends Model
Display::addFlash(Display::return_message(get_lang('LinkMoved'))); Display::addFlash(Display::return_message(get_lang('LinkMoved')));
} }
/**
* CSV file import functions.
*
* @author René Haentjens , Ghent University
*
* @param string $catname
*
* @return int
*/
public static function get_cat($catname)
{
// Get category id (existing or make new).
$tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY);
$course_id = api_get_course_int_id();
$result = Database:: query(
"SELECT id FROM ".$tbl_categories."
WHERE c_id = $course_id AND category_title='".Database::escape_string($catname)."'"
);
if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array($result))) {
return $row['id']; // Several categories with same name: take the first.
}
$result = Database:: query(
"SELECT MAX(display_order) FROM ".$tbl_categories." WHERE c_id = $course_id "
);
list($max_order) = Database:: fetch_row($result);
$params = [
'c_id' => $course_id,
'category_title' => $catname,
'description' => '',
'display_order' => $max_order + 1,
];
$id = Database::insert($tbl_categories, $params);
return $id;
}
/**
* CSV file import functions.
*
* @author René Haentjens , Ghent University
*
* @param string $url
* @param string $title
* @param string $description
* @param string $on_homepage
* @param string $hidden
*/
public static function put_link($url, $cat, $title, $description, $on_homepage, $hidden)
{
$_course = api_get_course_info();
$_user = api_get_user_info();
$tbl_link = Database::get_course_table(TABLE_LINK);
$course_id = api_get_course_int_id();
$urleq = "url='".Database:: escape_string($url)."'";
$cateq = "category_id=".intval($cat);
$result = Database:: query(
"
SELECT id FROM $tbl_link
WHERE c_id = $course_id AND ".$urleq.' AND '.$cateq
);
if (Database:: num_rows($result) >= 1 && ($row = Database:: fetch_array($result))) {
$sql = "UPDATE $tbl_link SET
title = '".Database:: escape_string($title)."',
description = '".Database:: escape_string($description)."'
WHERE c_id = $course_id AND id='".Database:: escape_string($row['id'])."'";
Database:: query($sql);
$ipu = 'LinkUpdated';
$rv = 1; // 1 = upd
} else {
// Add new link
$result = Database:: query(
"SELECT MAX(display_order) FROM $tbl_link
WHERE c_id = $course_id AND category_id='".intval($cat)."'"
);
list($max_order) = Database:: fetch_row($result);
Database:: query(
"INSERT INTO $tbl_link (c_id, url, title, description, category_id, display_order, on_homepage)
VALUES (".api_get_course_int_id().",
'".Database:: escape_string($url)."',
'".Database:: escape_string($title)."',
'".Database:: escape_string($description)."',
'".intval($cat)."','".(intval($max_order) + 1)."',
'".intval($on_homepage).
"')"
);
$id = Database:: insert_id();
$ipu = 'LinkAdded';
$rv = 2; // 2 = new
}
api_item_property_update(
$_course,
TOOL_LINK,
$id,
$ipu,
$_user['user_id']
);
if ($hidden && $ipu == 'LinkAdded') {
api_item_property_update(
$_course,
TOOL_LINK,
$id,
'invisible',
$_user['user_id']
);
}
return $rv;
}
/** /**
* This function checks if the url is a vimeo link. * This function checks if the url is a vimeo link.
* *

@ -53,25 +53,6 @@ class SocialManager extends UserManager
} }
} }
/**
* Get relation type contact by name.
*
* @param string names of the kind of relation
*
* @return int
*
* @author isaac flores paz
*/
public static function get_relation_type_by_name($relation_type_name)
{
$list_type_friend = self::show_list_type_friends();
foreach ($list_type_friend as $value_type_friend) {
if (strtolower($value_type_friend['title']) == $relation_type_name) {
return $value_type_friend['id'];
}
}
}
/** /**
* Get the kind of relation between contacts. * Get the kind of relation between contacts.
* *
@ -2232,77 +2213,6 @@ class SocialManager extends UserManager
$template->assign('social_avatar_block', $template->fetch($templateName)); $template->assign('social_avatar_block', $template->fetch($templateName));
} }
/**
* @param int $user_id
* @param $link_shared
* @param $show_full_profile
*
* @return string
*/
public static function listMyFriends($user_id, $link_shared, $show_full_profile)
{
// SOCIALGOODFRIEND , USER_RELATION_TYPE_FRIEND, USER_RELATION_TYPE_PARENT
$friends = self::get_friends($user_id, USER_RELATION_TYPE_FRIEND);
$number_of_images = 30;
$number_friends = count($friends);
$friendHtml = '';
if ($number_friends != 0) {
if ($number_friends > $number_of_images) {
if (api_get_user_id() == $user_id) {
$friendHtml .= ' <span><a href="friends.php">'.get_lang('SeeAll').'</a></span>';
} else {
$friendHtml .= ' <span>'
.'<a href="'.api_get_path(WEB_CODE_PATH).'social/profile_friends_and_groups.inc.php'
.'?view=friends&height=390&width=610&user_id='.$user_id.'"'
.'class="ajax" data-title="'.get_lang('SeeAll').'" title="'.get_lang('SeeAll').'" >'.get_lang('SeeAll').'</a></span>';
}
}
$friendHtml .= '<ul class="nav nav-list">';
$j = 1;
for ($k = 0; $k < $number_friends; $k++) {
if ($j > $number_of_images) {
break;
}
if (isset($friends[$k])) {
$friend = $friends[$k];
$name_user = api_get_person_name($friend['firstName'], $friend['lastName']);
$user_info_friend = api_get_user_info($friend['friend_user_id'], true);
if ($user_info_friend['user_is_online']) {
$statusIcon = Display::span('', ['class' => 'online_user_in_text']);
} else {
$statusIcon = Display::span('', ['class' => 'offline_user_in_text']);
}
$friendHtml .= '<li>';
$friendHtml .= '<div>';
// the height = 92 must be the same in the image_friend_network span style in default.css
$friends_profile = UserManager::getUserPicture(
$friend['friend_user_id'],
USER_IMAGE_SIZE_SMALL
);
$friendHtml .= '<img src="'.$friends_profile.'" id="imgfriend_'.$friend['friend_user_id'].'" title="'.$name_user.'"/>';
$link_shared = (empty($link_shared)) ? '' : '&'.$link_shared;
$friendHtml .= $statusIcon.'<a href="profile.php?'.'u='.$friend['friend_user_id'].$link_shared.'">'.$name_user.'</a>';
$friendHtml .= '</div>';
$friendHtml .= '</li>';
}
$j++;
}
$friendHtml .= '</ul>';
} else {
$friendHtml .= '<div class="">'.get_lang('NoFriendsInYourContactList').'<br />
<a class="btn btn-primary" href="'.api_get_path(WEB_PATH).'whoisonline.php">
<em class="fa fa-search"></em> '.get_lang('TryAndFindSomeFriends').'</a></div>';
}
$friendHtml = Display::panel($friendHtml, get_lang('SocialFriend').' ('.$number_friends.')');
return $friendHtml;
}
/** /**
* @param int $user_id * @param int $user_id
* @param $link_shared * @param $link_shared

@ -52,92 +52,6 @@ class SystemAnnouncementManager
return $visibilityCondition; return $visibilityCondition;
} }
/**
* Displays all announcements.
*
* @param string $visibility VISIBLE_GUEST, VISIBLE_STUDENT or VISIBLE_TEACHER
* @param int $id The identifier of the announcement to display
*/
public static function display_announcements($visibility, $id = -1)
{
$user_selected_language = api_get_interface_language();
$db_table = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
$tbl_announcement_group = Database::get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
$userGroup = new UserGroup();
$temp_user_groups = $userGroup->get_groups_by_user(api_get_user_id(), 0);
$groups = [];
foreach ($temp_user_groups as $user_group) {
$groups = array_merge($groups, [$user_group['id']]);
$groups = array_merge(
$groups,
$userGroup->get_parent_groups($user_group['id'])
);
}
$groups_string = '('.implode($groups, ',').')';
$now = api_get_utc_datetime();
$sql = "SELECT *, DATE_FORMAT(date_start,'%d-%m-%Y %h:%i:%s') AS display_date
FROM $db_table
WHERE
(lang='$user_selected_language' OR lang IS NULL) AND
(('$now' BETWEEN date_start AND date_end) OR date_end='0000-00-00') ";
$sql .= self::getVisibilityCondition($visibility);
if (count($groups) > 0) {
$sql .= " OR id IN (
SELECT announcement_id FROM $tbl_announcement_group
WHERE group_id in $groups_string
) ";
}
$current_access_url_id = 1;
if (api_is_multiple_url_enabled()) {
$current_access_url_id = api_get_current_access_url_id();
}
$sql .= " AND access_url_id = '$current_access_url_id' ";
$sql .= " ORDER BY date_start DESC LIMIT 0,7";
$announcements = Database::query($sql);
if (Database::num_rows($announcements) > 0) {
$query_string = ereg_replace('announcement=[1-9]+', '', $_SERVER['QUERY_STRING']);
$query_string = ereg_replace('&$', '', $query_string);
$url = api_get_self();
echo '<div class="system_announcements">';
echo '<h3>'.get_lang('SystemAnnouncements').'</h3>';
echo '<div style="margin:10px;text-align:right;"><a href="news_list.php">'.get_lang('More').'</a></div>';
while ($announcement = Database::fetch_object($announcements)) {
if ($id != $announcement->id) {
if (strlen($query_string) > 0) {
$show_url = 'news_list.php#'.$announcement->id;
} else {
$show_url = 'news_list.php#'.$announcement->id;
}
$display_date = api_convert_and_format_date($announcement->display_date, DATE_FORMAT_LONG);
echo '<a name="'.$announcement->id.'"></a>
<div class="system_announcement">
<div class="system_announcement_title">
<a name="ann'.$announcement->id.'" href="'.$show_url.'">'.
$announcement->title.'</a>
</div>
<div class="system_announcement_date">'.$display_date.'</div>
</div>';
} else {
echo '<div class="system_announcement">
<div class="system_announcement_title">'
.$announcement->display_date.'
<a name="ann'.$announcement->id.'" href="'.$url.'?'.$query_string.'#ann'.$announcement->id.'">'.
$announcement->title.'
</a>
</div>';
}
echo '<br />';
}
echo '</div>';
}
}
/** /**
* @param string $visibility * @param string $visibility
* @param int $id * @param int $id

@ -94,7 +94,6 @@ class Template
]; ];
$urlId = api_get_current_access_url_id(); $urlId = api_get_current_access_url_id();
$cache_folder = api_get_path(SYS_ARCHIVE_PATH).'twig/'.$urlId.'/'; $cache_folder = api_get_path(SYS_ARCHIVE_PATH).'twig/'.$urlId.'/';
if (!is_dir($cache_folder)) { if (!is_dir($cache_folder)) {
@ -1225,9 +1224,10 @@ class Template
return implode(CourseManager::USER_SEPARATOR, $names); return implode(CourseManager::USER_SEPARATOR, $names);
} }
/*s /**
* Returns the teachers name for the current course * Returns the teachers name for the current course
* Function to use in Twig templates * Function to use in Twig templates
*
* @return string * @return string
*/ */
public static function returnTeachersNames() public static function returnTeachersNames()

@ -1839,49 +1839,6 @@ class Tracking
return false; return false;
} }
/**
* Get las connection date for a student.
*
* @param array $studentList Student id array
* @param int $days
* @param bool $getCount
*
* @return int
*/
public static function getInactiveUsers($studentList, $days, $getCount = true)
{
if (empty($studentList)) {
return 0;
}
$days = (int) $days;
$date = api_get_utc_datetime(strtotime($days.' days ago'));
$studentList = array_map('intval', $studentList);
$tbl_track_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$select = " SELECT login_user_id ";
if ($getCount) {
$select = " SELECT count(DISTINCT login_user_id) as count";
}
$sql = "$select
FROM $tbl_track_login
WHERE
login_user_id IN (' ".implode("','", $studentList)."' ) AND
login_date < '$date'
";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
if ($getCount) {
$count = Database::fetch_array($rs);
return $count['count'];
}
return Database::store_result($rs, 'ASSOC');
}
return false;
}
/** /**
* Get first user's connection date on the course. * Get first user's connection date on the course.
* *
@ -2446,182 +2403,6 @@ class Tracking
return $result.'%'; return $result.'%';
} }
/**
* get teacher progress by course and session.
*
* @param int course id
* @param int session id
*
* @return array
*/
public static function get_teachers_progress_by_course($courseId, $sessionId)
{
$course = api_get_course_info_by_id($courseId);
$sessionId = intval($sessionId);
$courseId = intval($courseId);
$sessionCourseUserTable = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$sessionTable = Database::get_main_table(TABLE_MAIN_SESSION);
//get teachers
$sql = "SELECT scu.session_id, scu.user_id, s.name
FROM $sessionCourseUserTable scu, $sessionTable s
WHERE
scu.session_id = s.id
AND scu.status = 2
AND scu.visibility = 1
AND scu.c_id = '%s'
AND scu.session_id = %s";
$query = sprintf($sql, intval($courseId), $sessionId);
$rs = Database::query($query);
$teachers = [];
while ($teacher = Database::fetch_array($rs, 'ASSOC')) {
$teachers[] = $teacher;
}
$data = [];
foreach ($teachers as $teacher) {
//total documents added
$sql = "SELECT count(*) as total
FROM c_item_property
WHERE lastedit_type = 'DocumentAdded'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalDocuments = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalDocuments = $row[0];
}
// Total links added
$sql = "SELECT count(*) as total
FROM c_item_property
WHERE lastedit_type = 'LinkAdded'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalLinks = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalLinks = $row[0];
}
//total forums added
$sql = "SELECT count(*) as total
FROM c_item_property
WHERE lastedit_type = 'ForumthreadVisible'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalForums = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalForums = $row[0];
}
//total wikis added
$sql = "SELECT COUNT(DISTINCT(ref)) as total
FROM c_item_property
WHERE lastedit_type = 'WikiAdded'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalWikis = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalWikis = $row[0];
}
// Total works added
$sql = "SELECT COUNT(*) as total
FROM c_item_property
WHERE lastedit_type = 'DirectoryCreated'
AND tool = 'work'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalWorks = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalWorks = $row[0];
}
//total announcements added
$sql = "SELECT COUNT(*) as total
FROM c_item_property
WHERE lastedit_type = 'AnnouncementAdded'
AND c_id = %s
AND insert_user_id = %s
AND session_id = %s";
$query = sprintf(
$sql,
$courseId,
$teacher['user_id'],
$teacher['session_id']
);
$rs = Database::query($query);
$totalAnnouncements = 0;
if ($rs) {
$row = Database::fetch_row($rs);
$totalAnnouncements = $row[0];
}
$tutor = api_get_user_info($teacher['user_id']);
$data[] = [
'course' => $course['title'],
'session' => $teacher['name'],
'tutor' => $tutor['username'].' - '.$tutor['lastname'].' '.$tutor['firstname'],
'documents' => $totalDocuments,
'links' => $totalLinks,
'forums' => $totalForums,
'works' => $totalWorks,
'wikis' => $totalWikis,
'announcements' => $totalAnnouncements,
];
}
return $data;
}
/** /**
* Returns the average student progress in the learning paths of the given * Returns the average student progress in the learning paths of the given
* course, it will take into account the progress that were not started. * course, it will take into account the progress that were not started.
@ -3566,60 +3347,6 @@ class Tracking
return $students; return $students;
} }
/**
* Get student followed by a coach inside a session.
*
* @param int Session id
* @param int Coach id
*
* @return array students list
*/
public static function get_student_followed_by_coach_in_a_session(
$id_session,
$coach_id
) {
$coach_id = intval($coach_id);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$students = [];
// At first, courses where $coach_id is coach of the course
$sql = 'SELECT c_id FROM '.$tbl_session_course_user.'
WHERE session_id="'.$id_session.'" AND user_id='.$coach_id.' AND status=2';
$result = Database::query($sql);
while ($a_courses = Database::fetch_array($result)) {
$courseId = $a_courses['c_id'];
$sql = "SELECT DISTINCT srcru.user_id
FROM $tbl_session_course_user AS srcru
WHERE
c_id = '$courseId' AND
session_id = '".$id_session."'";
$rs = Database::query($sql);
while ($row = Database::fetch_array($rs)) {
$students[$row['user_id']] = $row['user_id'];
}
}
// Then, courses where $coach_id is coach of the session
$sql = 'SELECT id_coach FROM '.$tbl_session.'
WHERE id="'.$id_session.'" AND id_coach="'.$coach_id.'"';
$result = Database::query($sql);
//He is the session_coach so we select all the users in the session
if (Database::num_rows($result) > 0) {
$sql = 'SELECT DISTINCT srcru.user_id
FROM '.$tbl_session_course_user.' AS srcru
WHERE session_id="'.$id_session.'"';
$result = Database::query($sql);
while ($row = Database::fetch_array($result)) {
$students[$row['user_id']] = $row['user_id'];
}
}
return $students;
}
/** /**
* Check if a coach is allowed to follow a student. * Check if a coach is allowed to follow a student.
* *
@ -6995,32 +6722,6 @@ class Tracking
return $allow; return $allow;
} }
public function getCoursesAndSessions($userId)
{
$userId = (int) $userId;
// Get the list of sessions where the user is subscribed as student
$sql = 'SELECT session_id, c_id
FROM '.Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER).'
WHERE user_id='.$userId;
$rs = Database::query($sql);
$tmp_sessions = [];
while ($row = Database::fetch_array($rs, 'ASSOC')) {
$tmp_sessions[] = $row['session_id'];
if ($drh_can_access_all_courses) {
if (in_array($row['session_id'], $tmp_sessions)) {
$courses_in_session[$row['session_id']][] = $row['c_id'];
}
} else {
if (isset($courses_in_session_by_coach[$row['session_id']])) {
if (in_array($row['session_id'], $tmp_sessions)) {
$courses_in_session[$row['session_id']][] = $row['c_id'];
}
}
}
}
}
} }
/** /**

@ -3748,70 +3748,6 @@ class SurveyUtil
return $field_list_array; return $field_list_array;
} }
/**
* @author Isaac Flores Paz <florespaz@bidsoftperu.com>
*
* @param int $user_id User ID
* @param string $survey_code
* @param int $user_answer User in survey answer table (user id or anonymous)
*
* @return bool
*/
public static function show_link_available($user_id, $survey_code, $user_answer)
{
$table_survey = Database::get_course_table(TABLE_SURVEY);
$table_survey_invitation = Database::get_course_table(TABLE_SURVEY_INVITATION);
$table_survey_answer = Database::get_course_table(TABLE_SURVEY_ANSWER);
$table_survey_question = Database::get_course_table(TABLE_SURVEY_QUESTION);
$survey_code = Database::escape_string($survey_code);
$user_id = (int) $user_id;
$user_answer = Database::escape_string($user_answer);
$course_id = api_get_course_int_id();
$sql = 'SELECT COUNT(*) as count
FROM '.$table_survey_invitation.'
WHERE
user='.$user_id.' AND
survey_code="'.$survey_code.'" AND
answered="1" AND
c_id = '.$course_id;
$sql2 = 'SELECT COUNT(*) as count
FROM '.$table_survey.' s
INNER JOIN '.$table_survey_question.' q
ON s.survey_id=q.survey_id AND s.c_id = q.c_id
WHERE
s.code="'.$survey_code.'" AND
q.type NOT IN("pagebreak","comment") AND
s.c_id = '.$course_id.' AND q.c_id = '.$course_id.' ';
$sql3 = 'SELECT COUNT(DISTINCT question_id) as count
FROM '.$table_survey_answer.'
WHERE survey_id=(
SELECT survey_id FROM '.$table_survey.'
WHERE
code = "'.$survey_code.'" AND
c_id = '.$course_id.'
) AND
user="'.$user_answer.'" AND
c_id = '.$course_id;
$result = Database::query($sql);
$result2 = Database::query($sql2);
$result3 = Database::query($sql3);
$row = Database::fetch_array($result, 'ASSOC');
$row2 = Database::fetch_array($result2, 'ASSOC');
$row3 = Database::fetch_array($result3, 'ASSOC');
if ($row['count'] == 1 && $row3['count'] != $row2['count']) {
return true;
} else {
return false;
}
}
/** /**
* Display survey question chart. * Display survey question chart.
* *

@ -113,16 +113,6 @@ $htmlHeadXtra[] = '<script>
var email = '.js_array($types, 'email', 'email'). var email = '.js_array($types, 'email', 'email').
'</script>'; '</script>';
/**
* @param $s
*
* @return string
*/
function js_str($s)
{
return '"'.addcslashes($s, "\0..\37\"\\").'"';
}
/** /**
* @param $array * @param $array
* @param $name * @param $name

@ -87,17 +87,6 @@ $tools['student_publication'] = ['id' => 'student_publication', 'name' => get_la
$tools['user'] = ['id' => 'user', 'name' => get_lang('User')]; $tools['user'] = ['id' => 'user', 'name' => get_lang('User')];
$tools['forum'] = ['id' => 'forum', 'name' => get_lang('Forum')]; $tools['forum'] = ['id' => 'forum', 'name' => get_lang('Forum')];
/**
* Returns the escaped string.
*
* @param string $s
*
* @return string
*/
function js_str($s)
{
return '"'.addcslashes($s, "\0..\37\"\\").'"';
}
/** /**
* This function is to show the ticket form. * This function is to show the ticket form.
* *

@ -1,8 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
use Chamilo\UserBundle\Entity\User;
/** /**
* @package chamilo.webservices * @package chamilo.webservices
*/ */

Loading…
Cancel
Save