Skill: Rename Profile class to SkillLevelProfile

pull/5949/head
Angel Fernando Quiroz Campos 9 months ago
parent abac015729
commit 86ba829996
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 6
      public/main/inc/lib/SkillModel.php
  2. 6
      public/main/skills/assign.php
  3. 12
      public/main/skills/skill.php
  4. 8
      public/main/skills/skill_level.php
  5. 8
      public/main/skills/skill_profile.php
  6. 11
      src/CoreBundle/Entity/Level.php
  7. 12
      src/CoreBundle/Entity/Skill.php
  8. 4
      src/CoreBundle/Entity/SkillLevelProfile.php
  9. 10
      tests/CoreBundle/Repository/SkillRepositoryTest.php

@ -288,7 +288,7 @@ class SkillModel extends Model
'criteria' => $skill->getCriteria(),
'status' => $skill->getStatus(),
'asset_id' => (string) $skill->getAsset()?->getId(),
'profile_id' => $skill->getProfile()?->getId(),
'profile_id' => $skill->getLevelProfile()?->getId(),
'icons_small' => sprintf('badges/%s-small.png', sha1($skill['title'])),
];
}
@ -1023,7 +1023,7 @@ class SkillModel extends Model
if (!empty($skills)) {
foreach ($skills as &$skill) {
if (0 == $skill['parent_id']) {
$skill['parent_id'] = 1;
$skill['parent_id'] = '-1';
}
// because except main keys (id, title, children) others keys
@ -1070,7 +1070,7 @@ class SkillModel extends Model
// Check if the skill has related gradebooks
$skill['data']['skill_has_gradebook'] = false;
if (isset($skill['gradebooks']) && !empty($skill['gradebooks'])) {
if (!empty($skill['gradebooks'])) {
$skill['data']['skill_has_gradebook'] = true;
}
$refs[$skill['id']] = &$skill;

@ -123,13 +123,13 @@ $skillId = isset($_REQUEST['id']) ? (int) $_REQUEST['id'] : key($skillsOptions);
$skill = $skillRepo->find($skillId);
$profile = false;
if ($skill) {
$profile = $skill->getProfile();
$profile = $skill->getLevelProfile();
}
if (!empty($subSkillList)) {
$skillFromLastSkill = $skillRepo->find(end($subSkillList));
if ($skillFromLastSkill) {
$profile = $skillFromLastSkill->getProfile();
$profile = $skillFromLastSkill->getLevelProfile();
}
}
@ -139,7 +139,7 @@ if (!$profile) {
krsort($parents);
foreach ($parents as $parent) {
$skillParentId = $parent['skill_id'];
$profile = $skillRepo->find($skillParentId)->getProfile();
$profile = $skillRepo->find($skillParentId)->getLevelProfile();
if ($profile) {
break;

@ -1,7 +1,7 @@
<?php
/* For license terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Profile;
use Chamilo\CoreBundle\Entity\SkillLevelProfile;
use Chamilo\CoreBundle\Entity\Skill;
/**
@ -11,7 +11,7 @@ $cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
$em = Database::getManager();
$profiles = $em->getRepository(Profile::class)->findAll();
$profiles = $em->getRepository(SkillLevelProfile::class)->findAll();
$list = $em->getRepository(Skill::class)->findAll();
$listAction = api_get_self();
@ -40,11 +40,11 @@ $form->addHidden('id', $id);
$form->addButtonSave(get_lang('Update'));
if (!empty($item)) {
$profile = $item->getProfile();
$profile = $item->getLevelProfile();
if ($profile) {
$form->setDefaults(
[
'profile_id' => $item->getProfile()->getId(),
'profile_id' => $item->getLevelProfile()->getId(),
]
);
}
@ -63,9 +63,9 @@ switch ($action) {
if ($form->validate()) {
$values = $form->exportValues();
$profile = $em->getRepository(Profile::class)->find($values['profile_id']);
$profile = $em->getRepository(SkillLevelProfile::class)->find($values['profile_id']);
if ($profile) {
$item->setProfile($profile);
$item->setLevelProfile($profile);
$em->persist($item);
$em->flush();
Display::addFlash(Display::return_message(get_lang('Update successful')));

@ -2,7 +2,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Level;
use Chamilo\CoreBundle\Entity\Profile;
use Chamilo\CoreBundle\Entity\SkillLevelProfile;
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
use Chamilo\CoreBundle\Component\Utils\ObjectIcon;
/**
@ -15,7 +15,7 @@ require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
$em = Database::getManager();
$profiles = $em->getRepository(Profile::class)->findAll();
$profiles = $em->getRepository(SkillLevelProfile::class)->findAll();
$list = $em->getRepository(Level::class)->findAll();
$listAction = api_get_self();
@ -64,7 +64,7 @@ switch ($action) {
if ($form->validate()) {
$values = $form->exportValues();
if (isset($values['profile_id']) && !empty($values['profile_id'])) {
$profile = $em->getRepository(Profile::class)->find($values['profile_id']);
$profile = $em->getRepository(SkillLevelProfile::class)->find($values['profile_id']);
if ($profile) {
$item = new Level();
$item->setTitle($values['title']);
@ -101,7 +101,7 @@ switch ($action) {
$item->setTitle($values['title']);
$item->setShortTitle($values['short_title']);
$profile = $em->getRepository(Profile::class)->find($values['profile_id']);
$profile = $em->getRepository(SkillLevelProfile::class)->find($values['profile_id']);
if ($profile) {
$item->setProfile($profile);
}

@ -3,7 +3,7 @@
/* For licensing terms, see /license.txt */
use Chamilo\CoreBundle\Entity\Level;
use Chamilo\CoreBundle\Entity\Profile;
use Chamilo\CoreBundle\Entity\SkillLevelProfile;
use Chamilo\CoreBundle\Entity\Skill;
use Chamilo\CoreBundle\Component\Utils\ActionIcon;
use Chamilo\CoreBundle\Component\Utils\ObjectIcon;
@ -17,7 +17,7 @@ require_once __DIR__.'/../inc/global.inc.php';
api_protect_admin_script();
$em = Database::getManager();
$list = $em->getRepository(Profile::class)->findAll();
$list = $em->getRepository(SkillLevelProfile::class)->findAll();
$listAction = api_get_self();
@ -30,7 +30,7 @@ $id = isset($_GET['id']) ? $_GET['id'] : '';
$item = null;
if (!empty($id)) {
$item = $em->getRepository(Profile::class)->find($id);
$item = $em->getRepository(SkillLevelProfile::class)->find($id);
if (!$item) {
api_not_allowed();
}
@ -89,7 +89,7 @@ switch ($action) {
$tpl->assign('form', $formToDisplay);
if ($form->validate()) {
$values = $form->exportValues();
$item = new Profile();
$item = new SkillLevelProfile();
$item->setTitle($values['name']);
$em->persist($item);
$em->flush();

@ -33,9 +33,9 @@ class Level implements Stringable
protected string $shortTitle;
#[Gedmo\SortableGroup]
#[ORM\ManyToOne(targetEntity: Profile::class, inversedBy: 'levels')]
#[ORM\ManyToOne(targetEntity: SkillLevelProfile::class, inversedBy: 'levels')]
#[ORM\JoinColumn(name: 'profile_id', referencedColumnName: 'id')]
protected ?Profile $profile = null;
protected ?SkillLevelProfile $profile = null;
public function __toString(): string
{
@ -89,15 +89,12 @@ class Level implements Stringable
return $this;
}
/**
* @return Profile
*/
public function getProfile()
public function getProfile(): ?SkillLevelProfile
{
return $this->profile;
}
public function setProfile(Profile $profile): self
public function setProfile(SkillLevelProfile $profile): self
{
$this->profile = $profile;

@ -65,9 +65,9 @@ class Skill implements Stringable, Translatable
#[ORM\GeneratedValue]
protected ?int $id = null;
#[ORM\ManyToOne(targetEntity: Profile::class, inversedBy: 'skills')]
#[ORM\ManyToOne(targetEntity: SkillLevelProfile::class, inversedBy: 'skills')]
#[ORM\JoinColumn(name: 'profile_id', referencedColumnName: 'id')]
protected ?Profile $profile = null;
protected ?SkillLevelProfile $levelProfile = null;
/**
* @var Collection<int, SkillRelUser>
@ -259,14 +259,14 @@ class Skill implements Stringable, Translatable
return $this->id;
}
public function getProfile(): ?Profile
public function getLevelProfile(): ?SkillLevelProfile
{
return $this->profile;
return $this->levelProfile;
}
public function setProfile(Profile $profile): self
public function setLevelProfile(SkillLevelProfile $levelProfile): self
{
$this->profile = $profile;
$this->levelProfile = $levelProfile;
return $this;
}

@ -13,7 +13,7 @@ use Stringable;
#[ORM\Table(name: 'skill_level_profile')]
#[ORM\Entity]
class Profile implements Stringable
class SkillLevelProfile implements Stringable
{
#[ORM\Column(name: 'id', type: 'integer')]
#[ORM\Id]
@ -26,7 +26,7 @@ class Profile implements Stringable
/**
* @var Collection<int, Skill>
*/
#[ORM\OneToMany(mappedBy: 'profile', targetEntity: Skill::class, cascade: ['persist'])]
#[ORM\OneToMany(mappedBy: 'levelProfile', targetEntity: Skill::class, cascade: ['persist'])]
protected Collection $skills;
/**

@ -9,7 +9,7 @@ namespace Chamilo\Tests\CoreBundle\Repository;
use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Entity\GradebookCategory;
use Chamilo\CoreBundle\Entity\Level;
use Chamilo\CoreBundle\Entity\Profile;
use Chamilo\CoreBundle\Entity\SkillLevelProfile;
use Chamilo\CoreBundle\Entity\Skill;
use Chamilo\CoreBundle\Entity\SkillProfile;
use Chamilo\CoreBundle\Entity\SkillRelCourse;
@ -64,7 +64,7 @@ class SkillRepositoryTest extends AbstractApiTest
{
$em = $this->getEntityManager();
$skillRepo = self::getContainer()->get(SkillRepository::class);
$profileRepo = $em->getRepository(Profile::class);
$profileRepo = $em->getRepository(SkillLevelProfile::class);
$course = $this->createCourse('new');
$session = $this->createSession('session');
@ -79,7 +79,7 @@ class SkillRepositoryTest extends AbstractApiTest
;
$em->persist($skillProfile);
$profile = (new Profile())
$profile = (new SkillLevelProfile())
->setTitle('profile')
;
$em->persist($profile);
@ -97,7 +97,7 @@ class SkillRepositoryTest extends AbstractApiTest
->setShortCode('Dev')
->setStatus(Skill::STATUS_ENABLED)
->setAccessUrlId($accessUrl->getId())
->setProfile($profile)
->setLevelProfile($profile)
;
$skillRepo->update($skill);
@ -166,7 +166,7 @@ class SkillRepositoryTest extends AbstractApiTest
$em->flush();
$em->clear();
/** @var Profile $profile */
/** @var SkillLevelProfile $profile */
$profile = $profileRepo->find($profile->getId());
/** @var Skill $skill */

Loading…
Cancel
Save