{{ comment.giver_complete_name }}
+{{ comment.datetime }}
+{{ comment.text }}
+| {{ 'Name' | get_lang }} | +{{ 'ShortName' | get_lang }} | + +{{ 'Profile' | get_lang }} | +{{ 'Actions' | get_lang }} | +
|---|---|---|---|
| {{ item.name }} | +{{ item.shortName }} | +{{ item.profile }} | +
+
+ |
+
{{ skill_info.name }}
-- {% if course.name %} - {{ 'TimeXThroughCourseY'|get_lang|format(course.date_issued, course.name) }} - {% else %} - {{ course.date_issued }} - {% endif %} -
- {% endfor %} -{{ issue_info.skill_name }}
+ {% if issue_info.skill_short_code %} +{{ issue_info.skill_short_code }}
+ {% endif %} +{{ issue_info.skill_description }}
+ {% endif %} + {% if issue_info.skill_criteria %} +{{ issue_info.skill_criteria }}
+ {% endif %}+ + {{ 'DownloadBadge'|get_lang }} + +
+ {% endif %} +{{ user_info.complete_name }}
-{{ skill_info.name }}
- {% if skill_info.short_code %} -{{ skill_info.short_code }}
+{{ issue_info.user_complete_name }}
+{{ 'UserXIndicated'|get_lang|format(issue_info.argumentation_author_name) }}
+ {% endif %} +{{ issue_info.argumentation }}
+ {% endif %} +{{ comment.datetime }}
+{{ comment.text }}
+{{ 'WithoutComment'|get_lang }}
+ {% endfor %} ++ {{ 'XComments'|get_lang|format(issue_info.comments|length) }} + / + {{ 'AverageRatingX'|get_lang|format(issue_info.feedback_average) }} +
{% endif %} -{{ skill_info.description }}
-{{ skill_info.criteria }}
-{{ badge.issue_info.skill_name }}
+ {% if badge.issue_info.skill_short_code %} +{{ badge.issue_info.skill_short_code }}
+ {% endif %} +{{ badge.issue_info.skill_description }}
+ {% endif %} + {% if badge.issue_info.skill_criteria %} +{{ badge.issue_info.skill_criteria }}
+ {% endif %} ++ + {{ 'DownloadBadge'|get_lang }} + +
+ {% endif %} +{{ badge.issue_info.user_complete_name }}
+{{ 'UserXIndicated'|get_lang|format(badge.issue_info.argumentation_author_name) }}
+ {% endif %} +{{ badge.issue_info.argumentation }}
+ {% endif %} +{{ comment.datetime }}
+{{ comment.text }}
+{{ 'WithoutComment'|get_lang }}
+ {% endfor %} ++ {{ 'XComments'|get_lang|format(badge.issue_info.comments|length) }} + / + {{ 'AverageRatingX'|get_lang|format(badge.issue_info.feedback_average) }} +
+ {% endif %} +{{ skill.name }}
diff --git a/src/Chamilo/CoreBundle/Entity/Course.php b/src/Chamilo/CoreBundle/Entity/Course.php index da3251ec56..396736024b 100644 --- a/src/Chamilo/CoreBundle/Entity/Course.php +++ b/src/Chamilo/CoreBundle/Entity/Course.php @@ -276,6 +276,11 @@ class Course **/ protected $currentSession; + /** + * @ORM\OneToMany(targetEntity="Chamilo\CoreBundle\Entity\SkillRelUser", mappedBy="course", cascade={"persist"}) + */ + protected $issuedSkills; + /** * Constructor */ diff --git a/src/Chamilo/CoreBundle/Entity/Skill.php b/src/Chamilo/CoreBundle/Entity/Skill.php index 25f2bdebc1..b356745f5e 100644 --- a/src/Chamilo/CoreBundle/Entity/Skill.php +++ b/src/Chamilo/CoreBundle/Entity/Skill.php @@ -1,5 +1,13 @@ getName(); + } /** * Set name @@ -195,16 +223,25 @@ class Skill } /** - * Get the icon URL + * Get the icon (badge image) URL + * @param boolean $getSmall Optional. Allow get the small image * @return string */ - public function getWebIconPath() + public function getWebIconPath($getSmall = false) { - if ($this->getIcon()) { - return api_get_path(WEB_UPLOAD_PATH) . "badges/{$this->getIcon()}"; + if ($getSmall) { + if (empty($this->icon)) { + return \Display::return_icon('badges-default.png', null, null, ICON_SIZE_BIG, null, true); + } + + return api_get_path(WEB_UPLOAD_PATH) . 'badges/' . sha1($this->name) . '-small.png'; + } + + if (empty($this->icon)) { + return \Display::return_icon('badges-default.png', null, null, ICON_SIZE_HUGE, null, true); } - return \Display::return_icon('badges-default.png', null, null, ICON_SIZE_HUGE, null, true); + return api_get_path(WEB_UPLOAD_PATH) . "badges/{$this->icon}"; } /** @@ -281,4 +318,34 @@ class Skill { return $this->id; } + + /** + * @return Profile + */ + public function getProfile() + { + return $this->profile; + } + + /** + * @param Profile $profile + * + * @return Skill + */ + public function setProfile($profile) + { + $this->profile = $profile; + + return $this; + } + + /** + * Get issuedSkills + * @return ArrayCollection + */ + public function getIssuedSkills() + { + return $this->issuedSkills; + } + } diff --git a/src/Chamilo/CoreBundle/Entity/SkillRelUser.php b/src/Chamilo/CoreBundle/Entity/SkillRelUser.php index 9146df32e6..439436ab7f 100644 --- a/src/Chamilo/CoreBundle/Entity/SkillRelUser.php +++ b/src/Chamilo/CoreBundle/Entity/SkillRelUser.php @@ -1,5 +1,13 @@ comments = new \Doctrine\Common\Collections\ArrayCollection(); + } /** * Set userId @@ -111,6 +179,91 @@ class SkillRelUser return $this->skillId; } + /** + * Set user + * @param \Chamilo\UserBundle\Entity\User $user + * @return \Chamilo\CoreBundle\Entity\SkillRelUser + */ + public function setUser(\Chamilo\UserBundle\Entity\User $user) + { + $this->user = $user; + + return $this; + } + + /** + * Get user + * @return \Chamilo\UserBundle\Entity\User + */ + public function getUser() + { + return $this->user; + } + + /** + * Set skill + * @param \Chamilo\CoreBundle\Entity\Skill $skill + * @return \Chamilo\CoreBundle\Entity\SkillRelUser + */ + public function setSkill(Skill $skill) + { + $this->skill = $skill; + + return $this; + } + + /** + * Get skill + * @return \Chamilo\CoreBundle\Entity\Skill + */ + public function getSkill() + { + return $this->skill; + } + + /** + * Set course + * @param \Chamilo\CoreBundle\Entity\Course $course + * @return \Chamilo\CoreBundle\Entity\SkillRelUser + */ + public function setCourse(Course $course) + { + $this->course = $course; + + return $this; + } + + /** + * Get course + * @return \Chamilo\CoreBundle\Entity\Course + */ + public function getCourse() + { + return $this->course; + } + + /** + * Set session + * @param \Chamilo\CoreBundle\Entity\Session $session + * @return \Chamilo\CoreBundle\Entity\SkillRelUser + */ + public function setSession(Session $session) + { + $this->session = $session; + + return $this; + } + + /** + * Get session + * @return \Chamilo\CoreBundle\Entity\Session + */ + public function getSession() + { + return $this->session; + } + + /** * Set acquiredSkillAt * @@ -212,4 +365,166 @@ class SkillRelUser { return $this->id; } + + /** + * Set acquiredLevel + * @param \Chamilo\SkillBundle\Entity\Level $acquiredLevel + * @return \Chamilo\CoreBundle\Entity\SkillRelUser + */ + public function setAcquiredLevel($acquiredLevel) + { + $this->acquiredLevel = $acquiredLevel; + + return $this; + } + + /** + * Get acquiredLevel + * @return \Chamilo\SkillBundle\Entity\Level + */ + public function getAcquiredLevel() + { + return $this->acquiredLevel; + } + + /** + * Set argumentationAuthorId + * @param integer $argumentationAuthorId + * @return \Chamilo\CoreBundle\Entity\SkillRelUser + */ + public function setArgumentationAuthorId($argumentationAuthorId) + { + $this->argumentationAuthorId = $argumentationAuthorId; + + return $this; + } + + /** + * Get argumentationAuthorId + * @return integer + */ + public function getArgumentationAuthorId() + { + return $this->argumentationAuthorId; + } + + /** + * Set argumentation + * @param string $argumentation + * @return \Chamilo\CoreBundle\Entity\SkillRelUser + */ + public function setArgumentation($argumentation) + { + $this->argumentation = $argumentation; + + return $this; + } + + /** + * Get argumentation + * @return string + */ + public function getArgumentation() + { + return $this->argumentation; + } + + /** + * Get the source which the skill was obtained + * @return string + */ + public function getSourceName() + { + $source = ''; + + if ($this->session && $this->session->getId() != 0) { + + $source .= "[{$this->session->getName()}] "; + } + + if ($this->course) { + $source .= $this->course->getTitle(); + } + + return $source; + } + + /** + * Get the URL for the issue + * @return string + */ + public function getIssueUrl() + { + return api_get_path(WEB_PATH) . "badge/{$this->id}"; + } + + /** + * Get the URL for the All issues page + * @return string + */ + public function getIssueUrlAll() + { + return api_get_path(WEB_PATH) . "skill/{$this->skill->getId()}/user/{$this->user->getId()}"; + } + + /** + * Get the URL for the assertion + * @return string + */ + public function getAssertionUrl() + { + $url = api_get_path(WEB_CODE_PATH) . "badge/assertion.php?"; + + $url .= http_build_query(array( + 'user' => $this->user->getId(), + 'skill' => $this->skill->getId(), + 'course' => $this->course ? $this->course->getId() : 0, + 'session' => $this->session ? $this->session->getId() : 0 + )); + + return $url; + } + + /** + * Get comments + * @param boolean $sortDescByDateTime + * @return ArrayCollection + */ + public function getComments($sortDescByDateTime = false) + { + if ($sortDescByDateTime) { + $criteria = \Doctrine\Common\Collections\Criteria::create(); + $criteria->orderBy([ + 'feedbackDateTime' => \Doctrine\Common\Collections\Criteria::DESC + ]); + + return $this->comments->matching($criteria); + } + + return $this->comments; + } + + /** + * Calculate the average value from the feedback comments + * @return type + */ + public function getAverage() + { + $sum = 0; + $average = 0; + $countValues = 0; + + foreach ($this->comments as $comment) { + if (!$comment->getFeedbackValue()) { + continue; + } + + $sum += $comment->getFeedbackValue(); + $countValues++; + } + + $average = $countValues > 0 ? $sum / $countValues : 0; + + return number_format($average, 2); + } } diff --git a/src/Chamilo/CoreBundle/Entity/SkillRelUserComment.php b/src/Chamilo/CoreBundle/Entity/SkillRelUserComment.php new file mode 100644 index 0000000000..fece1d2394 --- /dev/null +++ b/src/Chamilo/CoreBundle/Entity/SkillRelUserComment.php @@ -0,0 +1,183 @@ +id; + } + + /** + * Get skillRelUser + * @return Chamilo\CoreBundle\Entity\SkillRelUser + */ + public function getSkillRelUser() + { + return $this->skillRelUser; + } + + /** + * Get feedbackGiver + * @return Chamilo\UserBundle\Entity\User + */ + public function getFeedbackGiver() + { + return $this->feedbackGiver; + } + + /** + * Get feedbackText + * @return string + */ + public function getFeedbackText() + { + return $this->feedbackText; + } + + /** + * Get feedbackValue + * @return int + */ + public function getFeedbackValue() + { + return $this->feedbackValue; + } + + /** + * Get feedbackDateTime + * @return type + */ + public function getFeedbackDateTime() + { + return $this->feedbackDateTime; + } + + /** + * Set skillRelUser + * @param \Chamilo\CoreBundle\Entity\SkillRelUser $skillRelUser + * @return \Chamilo\CoreBundle\Entity\SkillRelUserComment + */ + public function setSkillRelUser(SkillRelUser $skillRelUser) + { + $this->skillRelUser = $skillRelUser; + + return $this; + } + + /** + * Set feedbackGiver + * @param \Chamilo\UserBundle\Entity\User $feedbackGiver + * @return \Chamilo\CoreBundle\Entity\SkillRelUserComment + */ + public function setFeedbackGiver(\Chamilo\UserBundle\Entity\User $feedbackGiver) + { + $this->feedbackGiver = $feedbackGiver; + + return $this; + } + + /** + * Set feedbackText + * @param string $feedbackText + * @return \Chamilo\CoreBundle\Entity\SkillRelUserComment + */ + public function setFeedbackText($feedbackText) + { + $this->feedbackText = $feedbackText; + + return $this; + } + + /** + * Set feebackValue + * @param int $feedbackValue + * @return \Chamilo\CoreBundle\Entity\SkillRelUserComment + */ + public function setFeedbackValue($feedbackValue) + { + $this->feedbackValue = $feedbackValue; + + return $this; + } + + /** + * Set feedbackDateTime + * @param \DateTime $feedbackDateTime + * @return \Chamilo\CoreBundle\Entity\SkillRelUserComment + */ + public function setFeedbackDateTime(\DateTime $feedbackDateTime) + { + $this->feedbackDateTime = $feedbackDateTime; + + return $this; + } +} diff --git a/src/Chamilo/SkillBundle/Entity/Level.php b/src/Chamilo/SkillBundle/Entity/Level.php new file mode 100644 index 0000000000..d2638688e5 --- /dev/null +++ b/src/Chamilo/SkillBundle/Entity/Level.php @@ -0,0 +1,160 @@ +getName(); + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param int $id + * @return Level + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * @return Level + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * @return mixed + */ + public function getPosition() + { + return $this->position; + } + + /** + * @param mixed $position + * @return Level + */ + public function setPosition($position) + { + $this->position = $position; + + return $this; + } + + /** + * @return mixed + */ + public function getShortName() + { + return $this->shortName; + } + + /** + * @param mixed $shortName + * @return Level + */ + public function setShortName($shortName) + { + $this->shortName = $shortName; + + return $this; + } + + /** + * @return Profile + */ + public function getProfile() + { + return $this->profile; + } + + /** + * @param mixed $profile + * @return Level + */ + public function setProfile($profile) + { + $this->profile = $profile; + + return $this; + } + + +} diff --git a/src/Chamilo/SkillBundle/Entity/Profile.php b/src/Chamilo/SkillBundle/Entity/Profile.php new file mode 100644 index 0000000000..c2a51b1841 --- /dev/null +++ b/src/Chamilo/SkillBundle/Entity/Profile.php @@ -0,0 +1,133 @@ +getName(); + } + + /** + * @return int + */ + public function getId() + { + return $this->id; + } + + /** + * @param int $id + * @return Profile + */ + public function setId($id) + { + $this->id = $id; + + return $this; + } + + /** + * @return string + */ + public function getName() + { + return $this->name; + } + + /** + * @param string $name + * @return Profile + */ + public function setName($name) + { + $this->name = $name; + + return $this; + } + + /** + * @return mixed + */ + public function getSkills() + { + return $this->skills; + } + + /** + * @param mixed $skills + * @return Profile + */ + public function setSkills($skills) + { + $this->skills = $skills; + + return $this; + } + + /** + * @return mixed + */ + public function getLevels() + { + return $this->levels; + } + + /** + * @param mixed $levels + * @return Profile + */ + public function setLevels($levels) + { + $this->levels = $levels; + + return $this; + } + +} diff --git a/src/Chamilo/UserBundle/Entity/User.php b/src/Chamilo/UserBundle/Entity/User.php index 526802de57..e4917a4923 100644 --- a/src/Chamilo/UserBundle/Entity/User.php +++ b/src/Chamilo/UserBundle/Entity/User.php @@ -1,6 +1,13 @@ firstname, $this->lastname).' ('.$this->username.')'; + } + /** * @todo don't use api_get_person_name * @return string @@ -2453,4 +2480,30 @@ class User implements UserInterface //implements ParticipantInterface, ThemeUser $this->id ) = $data; } + + /** + * Get achievedSkills + * @return ArrayCollection + */ + public function getAchievedSkills() + { + return $this->achievedSkills; + } + + /** + * Check if the user has the skill + * @param \Chamilo\CoreBundle\Entity\Skill $skill The skill + * @return boolean + */ + public function hasSkill(\Chamilo\CoreBundle\Entity\Skill $skill) + { + $achievedSkills = $this->getAchievedSkills(); + + foreach ($achievedSkills as $userSkill) { + if ($userSkill->getSkill()->getId() !== $skill->getId()) { + continue; + } + return true; + } + } }