Merge branch '1.11.x' of https://github.com/chamilo/chamilo-lms into 1.11.x

pull/2487/head
Alex Aragon 9 years ago
commit 51431381a2
  1. 4
      main/badge/issued_all.php
  2. 4
      main/inc/lib/api.lib.php
  3. 19
      main/inc/lib/tracking.lib.php
  4. 34
      main/mySpace/myStudents.php
  5. 26
      src/Chamilo/CoreBundle/Entity/Repository/SkillRepository.php
  6. 133
      src/Chamilo/CoreBundle/Entity/SkillRelUser.php

@ -36,8 +36,8 @@ if (!$user || !$skill) {
}
$userSkills = $skillUserRepo->findBy([
'userId' => $user->getId(),
'skillId' => $skill->getId()
'user' => $user,
'skill' => $skill
]);
$userInfo = [

@ -4263,6 +4263,10 @@ function api_get_language_info($languageId) {
$language = Database::getManager()
->find('ChamiloCoreBundle:Language', intval($languageId));
if (!$language) {
return [];
}
return [
'id' => $language->getId(),
'original_name' => $language->getOriginalName(),

@ -5835,8 +5835,8 @@ class Tracking
/**
* Get the HTML code for show a block with the achieved user skill on course/session
* @param int $userId
* @param int $courseId
* @param int $sessionId
* @param int $courseId Optional.
* @param int $sessionId Optional.
* @return string
*/
public static function displayUserSkills($userId, $courseId = 0, $sessionId = 0)
@ -5849,15 +5849,10 @@ class Tracking
return '';
}
$filter = ['userId' => $userId];
if (!empty($courseId)) {
$filter['courseId'] = $courseId;
}
$filter = ['user' => $userId];
if (!empty($sessionId)) {
$filter['sessionId'] = $sessionId;
}
$filter['course'] = $courseId ?: null;
$filter['session'] = $sessionId ?: null;
$em = Database::getManager();
@ -5883,11 +5878,11 @@ class Tracking
';
foreach ($skillsRelUser as $userSkill) {
$skill = $em->find('ChamiloCoreBundle:Skill', $userSkill->getSkillId());
$skill = $userSkill->getSkill();
$html .= '
<li class="thumbnail">
<a href="' . api_get_path(WEB_PATH) . 'badge/' . $skill->getId() . '/user/' . $userId . '" target="_blank">
<a href="' . api_get_path(WEB_PATH) . 'badge/' . $userSkill->getId() . '/user/' . $userId . '" target="_blank">
<img class="img-responsive" title="' . $skill->getName() . '" src="' . $skill->getWebIconPath() . '" width="64" height="64">
<div class="caption">
<p class="text-center">' . $skill->getName() . '</p>

@ -653,14 +653,14 @@ if (!empty($student_id)) {
);
$attendance = new Attendance();
foreach ($courses_in_session as $sessionId => $courses) {
foreach ($courses_in_session as $sId => $courses) {
$session_name = '';
$access_start_date = '';
$access_end_date = '';
$date_session = '';
$title = Display::return_icon('course.png', get_lang('Courses'), array(), ICON_SIZE_SMALL).' '.get_lang('Courses');
$session_info = api_get_session_info($sessionId);
$session_info = api_get_session_info($sId);
if ($session_info) {
$session_name = $session_info['name'];
if (!empty($session_info['access_start_date']) && $session_info['access_start_date'] != '0000-00-00') {
@ -702,15 +702,15 @@ if (!empty($student_id)) {
if (CourseManager :: is_user_subscribed_in_course($student_id, $courseCodeItem, true)) {
$time_spent_on_course = api_time_to_hms(
Tracking :: get_time_spent_on_the_course($user_info['user_id'], $courseId, $sessionId)
Tracking :: get_time_spent_on_the_course($user_info['user_id'], $courseId, $sId)
);
// get average of faults in attendances by student
$results_faults_avg = $attendance->get_faults_average_by_course($student_id, $courseCodeItem, $sessionId);
$results_faults_avg = $attendance->get_faults_average_by_course($student_id, $courseCodeItem, $sId);
if (!empty($results_faults_avg['total'])) {
if (api_is_drh()) {
$attendances_faults_avg =
'<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sessionId.'&student_id='.$student_id.'">'.
'<a title="'.get_lang('GoAttendance').'" href="'.api_get_path(WEB_CODE_PATH).'attendance/index.php?cidReq='.$courseCodeItem.'&id_session='.$sId.'&student_id='.$student_id.'">'.
$results_faults_avg['faults'].'/'.$results_faults_avg['total'].' ('.$results_faults_avg['porcent'].'%)</a>';
} else {
$attendances_faults_avg =
@ -724,12 +724,12 @@ if (!empty($student_id)) {
}
// Get evaluations by student
$cats = Category::load(null, null, $courseCodeItem, null, null, $sessionId);
$cats = Category::load(null, null, $courseCodeItem, null, null, $sId);
$scoretotal = array();
if (isset($cats) && isset($cats[0])) {
if (!empty($sessionId)) {
$scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem, $sessionId);
if (!empty($sId)) {
$scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem, $sId);
} else {
$scoretotal= $cats[0]->calc_score($student_id, null, $courseCodeItem);
}
@ -743,8 +743,8 @@ if (!empty($student_id)) {
' ('.round(($scoretotal[0] / $scoretotal[1]) * 100, 2).' %)';
}
$progress = Tracking::get_avg_student_progress($user_info['user_id'], $courseCodeItem, null, $sessionId);
$score = Tracking :: get_avg_student_score($user_info['user_id'], $courseCodeItem, null, $sessionId);
$progress = Tracking::get_avg_student_progress($user_info['user_id'], $courseCodeItem, null, $sId);
$score = Tracking :: get_avg_student_score($user_info['user_id'], $courseCodeItem, null, $sId);
$progress = empty($progress) ? '0%' : $progress.'%';
$score = empty($score) ? '0%' : $score.'%';
@ -759,7 +759,7 @@ if (!empty($student_id)) {
);
echo '<tr>
<td ><a href="' .$courseInfoItem['course_public_url'] .'?id_session=' . $sessionId . '">'.
<td ><a href="' .$courseInfoItem['course_public_url'] .'?id_session=' . $sId . '">'.
$courseInfoItem['title'].'</a></td>
<td >'.$time_spent_on_course .'</td>
<td >'.$progress.'</td>
@ -768,10 +768,10 @@ if (!empty($student_id)) {
<td >'.$scoretotal_display.'</td>';
if (isset($_GET['id_coach']) && intval($_GET['id_coach']) != 0) {
echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.$origin.'&id_session='.$sessionId.'#infosStudent">
echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&id_coach='.Security::remove_XSS($_GET['id_coach']).'&origin='.$origin.'&id_session='.$sId.'#infosStudent">
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
} else {
echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&origin='.$origin.'&id_session='.$sessionId.'#infosStudent">
echo '<td width="10"><a href="'.api_get_self().'?student='.$user_info['user_id'].'&details=true&course='.$courseInfoItem['code'].'&origin='.$origin.'&id_session='.$sId.'#infosStudent">
'.Display::return_icon('2rightarrow.png', get_lang('Details')).'</a></td>';
}
echo '</tr>';
@ -1304,9 +1304,13 @@ if (!empty($student_id)) {
</table>
</div>
<?php
echo Tracking::displayUserSkills($user_info['user_id'], $courseInfo['id'], $sessionId);
} //end details
echo Tracking::displayUserSkills(
$user_info['user_id'],
$courseInfo ? $courseInfo['real_id'] : 0,
$sessionId
);
}
if ($export) {

@ -29,29 +29,31 @@ class SkillRepository extends EntityRepository
{
$qb = $this->createQueryBuilder('s');
$qb->innerJoin(
'ChamiloCoreBundle:SkillRelUser',
'su',
Join::WITH,
's.id = su.skillId'
)
->where(
$qb->expr()->eq('su.userId', $user->getId())
);
$qb
->innerJoin(
'ChamiloCoreBundle:SkillRelUser',
'su',
Join::WITH,
's.id = su.skill'
)
->where(
$qb->expr()->eq('su.user', $user->getId())
);
if ($course) {
$qb->andWhere(
$qb->expr()->eq('su.courseId', $course->getId())
$qb->expr()->eq('su.course', $course->getId())
);
}
if ($session) {
$qb->andWhere(
$qb->expr()->eq('su.sessionId', $session->getId())
$qb->expr()->eq('su.session', $session->getId())
);
}
$qb->setMaxResults(1)
$qb
->setMaxResults(1)
->orderBy('su.id', 'DESC');
return $qb->getQuery()->getOneOrNullResult();

@ -4,12 +4,10 @@
namespace Chamilo\CoreBundle\Entity;
use Chamilo\SkillBundle\Entity\Level;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\Mapping as ORM;
use Chamilo\UserBundle\Entity\User;
use Doctrine\Common\Collections\ArrayCollection;
use Chamilo\CoreBundle\Entity\Skill;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
/**
* SkillRelUser
@ -35,20 +33,6 @@ class SkillRelUser
*/
private $id;
/**
* @var integer
*
* @ORM\Column(name="user_id", type="integer", nullable=false)
*/
private $userId;
/**
* @var integer
*
* @ORM\Column(name="skill_id", type="integer", nullable=false)
*/
private $skillId;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\UserBundle\Entity\User", inversedBy="achievedSkills", cascade={"persist"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
@ -74,23 +58,9 @@ class SkillRelUser
*/
private $assignedBy;
/**
* @var integer
*
* @ORM\Column(name="course_id", type="integer", nullable=false)
*/
private $courseId;
/**
* @var integer
*
* @ORM\Column(name="session_id", type="integer", nullable=false)
*/
private $sessionId;
/**
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="issuedSkills", cascade={"persist"})
* @ORM\JoinColumn(name="course_id", referencedColumnName="id")
* @ORM\JoinColumn(name="course_id", referencedColumnName="id", nullable=true)
*/
private $course;
@ -98,7 +68,7 @@ class SkillRelUser
* @var Session
*
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", inversedBy="issuedSkills", cascade={"persist"})
* @ORM\JoinColumn(name="session_id", referencedColumnName="id")
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=true)
*/
private $session;
@ -137,52 +107,6 @@ class SkillRelUser
$this->comments = new ArrayCollection();
}
/**
* Set userId
*
* @param integer $userId
* @return SkillRelUser
*/
public function setUserId($userId)
{
$this->userId = $userId;
return $this;
}
/**
* Get userId
*
* @return integer
*/
public function getUserId()
{
return $this->userId;
}
/**
* Set skillId
*
* @param integer $skillId
* @return SkillRelUser
*/
public function setSkillId($skillId)
{
$this->skillId = $skillId;
return $this;
}
/**
* Get skillId
*
* @return integer
*/
public function getSkillId()
{
return $this->skillId;
}
/**
* Set user
* @param User $user
@ -314,52 +238,6 @@ class SkillRelUser
return $this->assignedBy;
}
/**
* Set courseId
*
* @param integer $courseId
* @return SkillRelUser
*/
public function setCourseId($courseId)
{
$this->courseId = $courseId;
return $this;
}
/**
* Get courseId
*
* @return integer
*/
public function getCourseId()
{
return $this->courseId;
}
/**
* Set sessionId
*
* @param integer $sessionId
* @return SkillRelUser
*/
public function setSessionId($sessionId)
{
$this->sessionId = $sessionId;
return $this;
}
/**
* Get sessionId
*
* @return integer
*/
public function getSessionId()
{
return $this->sessionId;
}
/**
* Get id
*
@ -499,9 +377,9 @@ class SkillRelUser
public function getComments($sortDescByDateTime = false)
{
if ($sortDescByDateTime) {
$criteria = \Doctrine\Common\Collections\Criteria::create();
$criteria = Criteria::create();
$criteria->orderBy([
'feedbackDateTime' => \Doctrine\Common\Collections\Criteria::DESC
'feedbackDateTime' => Criteria::DESC
]);
return $this->comments->matching($criteria);
@ -517,7 +395,6 @@ class SkillRelUser
public function getAverage()
{
$sum = 0;
$average = 0;
$countValues = 0;
foreach ($this->comments as $comment) {

Loading…
Cancel
Save