Fix SkillRelUser entity - refs BT#10856

remotes/angel/1.11.x
Angel Fernando Quiroz Campos 9 years ago
parent c874509662
commit 9525b351e9
  1. 4
      main/badge/issued_all.php
  2. 8
      main/inc/lib/tracking.lib.php
  3. 26
      main/mySpace/myStudents.php
  4. 8
      src/Chamilo/CoreBundle/Entity/Repository/SkillRepository.php
  5. 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 = [

@ -5849,14 +5849,14 @@ class Tracking
return '';
}
$filter = ['userId' => $userId];
$filter = ['user' => $userId];
if (!empty($courseId)) {
$filter['courseId'] = $courseId;
$filter['course'] = $courseId;
}
if (!empty($sessionId)) {
$filter['sessionId'] = $sessionId;
$filter['session'] = $sessionId;
}
$em = Database::getManager();
@ -5883,7 +5883,7 @@ class Tracking
';
foreach ($skillsRelUser as $userSkill) {
$skill = $em->find('ChamiloCoreBundle:Skill', $userSkill->getSkillId());
$skill = $em->find('ChamiloCoreBundle:Skill', $userSkill->getSkill()->getId());
$html .= '
<li class="thumbnail">

@ -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>';

@ -33,21 +33,21 @@ class SkillRepository extends EntityRepository
'ChamiloCoreBundle:SkillRelUser',
'su',
Join::WITH,
's.id = su.skillId'
's.id = su.skill'
)
->where(
$qb->expr()->eq('su.userId', $user->getId())
$qb->expr()->eq('su.user', $user)
);
if ($course) {
$qb->andWhere(
$qb->expr()->eq('su.courseId', $course->getId())
$qb->expr()->eq('su.course', $course)
);
}
if ($session) {
$qb->andWhere(
$qb->expr()->eq('su.sessionId', $session->getId())
$qb->expr()->eq('su.session', $session)
);
}

@ -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