parent
02e3c30d35
commit
f4188df2a1
@ -0,0 +1,80 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
use Chamilo\SkillBundle\Entity\SkillRelCourse; |
||||||
|
|
||||||
|
$cidReset = true; |
||||||
|
require_once __DIR__.'/../inc/global.inc.php'; |
||||||
|
|
||||||
|
if (api_get_configuration_value('allow_skill_rel_items') == false) { |
||||||
|
api_not_allowed(true); |
||||||
|
} |
||||||
|
|
||||||
|
$courseId = isset($_GET['course_id']) ? (int) $_GET['course_id'] : 0; |
||||||
|
|
||||||
|
$course = api_get_course_entity($courseId); |
||||||
|
if (empty($course)) { |
||||||
|
api_not_allowed(true); |
||||||
|
} |
||||||
|
|
||||||
|
$sessionId = isset($_GET['session_id']) ? (int) $_GET['session_id'] : null; |
||||||
|
|
||||||
|
$url = api_get_self().'?course_id='.$courseId.'&session_id='.$sessionId; |
||||||
|
$form = new FormValidator('skills', 'post', $url); |
||||||
|
|
||||||
|
$sessionName = $course->getTitleAndCode(); |
||||||
|
if (!empty($sessionId)) { |
||||||
|
$session = api_get_session_entity($sessionId); |
||||||
|
$sessionName = ' '.$session->getName().' - '.$course->getTitleAndCode(); |
||||||
|
} |
||||||
|
|
||||||
|
$form->addHeader(get_lang('AddSkills').$sessionName); |
||||||
|
|
||||||
|
$skillList = []; |
||||||
|
$em = Database::getManager(); |
||||||
|
$items = $em->getRepository('ChamiloSkillBundle:SkillRelCourse')->findBy( |
||||||
|
['course' => $courseId, 'session' => $sessionId] |
||||||
|
); |
||||||
|
/** @var SkillRelCourse $skillRelCourse */ |
||||||
|
foreach ($items as $skillRelCourse) { |
||||||
|
$skillList[$skillRelCourse->getSkill()->getId()] = $skillRelCourse->getSkill()->getName(); |
||||||
|
} |
||||||
|
|
||||||
|
$form->addHidden('course_id', $courseId); |
||||||
|
$form->addHidden('session_id', $sessionId); |
||||||
|
|
||||||
|
$form->addSelectAjax( |
||||||
|
'skills', |
||||||
|
get_lang('Skills'), |
||||||
|
$skillList, |
||||||
|
[ |
||||||
|
'url' => api_get_path(WEB_AJAX_PATH).'skill.ajax.php?a=search_skills', |
||||||
|
'multiple' => 'multiple', |
||||||
|
] |
||||||
|
); |
||||||
|
|
||||||
|
$form->addButtonSave(get_lang('Save')); |
||||||
|
|
||||||
|
$form->setDefaults(['skills' => array_keys($skillList)]); |
||||||
|
|
||||||
|
if ($form->validate()) { |
||||||
|
Skill::saveSkillsToCourseFromForm($form); |
||||||
|
Display::addFlash(Display::return_message(get_lang('Updated'))); |
||||||
|
header('Location: '.$url); |
||||||
|
exit; |
||||||
|
} |
||||||
|
$content = $form->returnForm(); |
||||||
|
|
||||||
|
$interbreadcrumb[] = [ |
||||||
|
'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php', |
||||||
|
'name' => get_lang('SessionList'), |
||||||
|
]; |
||||||
|
|
||||||
|
$interbreadcrumb[] = [ |
||||||
|
'url' => api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$sessionId, |
||||||
|
'name' => get_lang('SessionOverview'), |
||||||
|
]; |
||||||
|
|
||||||
|
$template = new Template(get_lang('SkillRelCourses')); |
||||||
|
$template->assign('content', $content); |
||||||
|
$template->display_one_col_template(); |
@ -0,0 +1,182 @@ |
|||||||
|
<?php |
||||||
|
/* For licensing terms, see /license.txt */ |
||||||
|
|
||||||
|
namespace Chamilo\SkillBundle\Entity; |
||||||
|
|
||||||
|
use Chamilo\CoreBundle\Entity\Course; |
||||||
|
use Chamilo\CoreBundle\Entity\Session; |
||||||
|
use Chamilo\CoreBundle\Entity\Skill; |
||||||
|
use Doctrine\ORM\Mapping as ORM; |
||||||
|
use Gedmo\Mapping\Annotation as Gedmo; |
||||||
|
|
||||||
|
/** |
||||||
|
* SkillRelCourse |
||||||
|
* |
||||||
|
* @ORM\Table(name="skill_rel_course") |
||||||
|
* ORM\Entity // uncomment if api_get_configuration_value('allow_skill_rel_items') |
||||||
|
*/ |
||||||
|
class SkillRelCourse |
||||||
|
{ |
||||||
|
/** |
||||||
|
* @var integer |
||||||
|
* |
||||||
|
* @ORM\Column(name="id", type="integer") |
||||||
|
* @ORM\Id |
||||||
|
* @ORM\GeneratedValue |
||||||
|
*/ |
||||||
|
protected $id; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var Skill |
||||||
|
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Skill", inversedBy="courses") |
||||||
|
* @ORM\JoinColumn(name="skill_id", referencedColumnName="id") |
||||||
|
**/ |
||||||
|
protected $skill; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var Course |
||||||
|
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course", inversedBy="skills", cascade={"persist"}) |
||||||
|
* @ORM\JoinColumn(name="c_id", referencedColumnName="id", nullable=false) |
||||||
|
*/ |
||||||
|
protected $course; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var Session |
||||||
|
* @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session", inversedBy="skills", cascade={"persist"}) |
||||||
|
* @ORM\JoinColumn(name="session_id", referencedColumnName="id", nullable=false) |
||||||
|
*/ |
||||||
|
protected $session; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var \DateTime $created |
||||||
|
* |
||||||
|
* @Gedmo\Timestampable(on="create") |
||||||
|
* @ORM\Column(name="created_at", type="datetime") |
||||||
|
*/ |
||||||
|
protected $createdAt; |
||||||
|
|
||||||
|
/** |
||||||
|
* @var \DateTime $updated |
||||||
|
* |
||||||
|
* @Gedmo\Timestampable(on="update") |
||||||
|
* @ORM\Column(name="updated_at", type="datetime") |
||||||
|
*/ |
||||||
|
protected $updatedAt; |
||||||
|
|
||||||
|
/** |
||||||
|
* SkillRelItem constructor. |
||||||
|
*/ |
||||||
|
public function __construct() |
||||||
|
{ |
||||||
|
$this->createdAt = new \DateTime('now'); |
||||||
|
$this->updatedAt = new \DateTime('now'); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return int |
||||||
|
*/ |
||||||
|
public function getId() |
||||||
|
{ |
||||||
|
return $this->id; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param int $id |
||||||
|
* @return SkillRelCourse |
||||||
|
*/ |
||||||
|
public function setId($id) |
||||||
|
{ |
||||||
|
$this->id = $id; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return Skill |
||||||
|
*/ |
||||||
|
public function getSkill() |
||||||
|
{ |
||||||
|
return $this->skill; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param Skill $skill |
||||||
|
* @return SkillRelCourse |
||||||
|
*/ |
||||||
|
public function setSkill($skill) |
||||||
|
{ |
||||||
|
$this->skill = $skill; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return Course |
||||||
|
*/ |
||||||
|
public function getCourse() |
||||||
|
{ |
||||||
|
return $this->course; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param Course $course |
||||||
|
* @return SkillRelCourse |
||||||
|
*/ |
||||||
|
public function setCourse($course) |
||||||
|
{ |
||||||
|
$this->course = $course; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return Session |
||||||
|
*/ |
||||||
|
public function getSession() |
||||||
|
{ |
||||||
|
return $this->session; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param Session $session |
||||||
|
* @return SkillRelCourse |
||||||
|
*/ |
||||||
|
public function setSession($session) |
||||||
|
{ |
||||||
|
$this->session = $session; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return \DateTime |
||||||
|
*/ |
||||||
|
public function getCreatedAt() |
||||||
|
{ |
||||||
|
return $this->createdAt; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param \DateTime $createdAt |
||||||
|
* @return SkillRelCourse |
||||||
|
*/ |
||||||
|
public function setCreatedAt($createdAt) |
||||||
|
{ |
||||||
|
$this->createdAt = $createdAt; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @return \DateTime |
||||||
|
*/ |
||||||
|
public function getUpdatedAt() |
||||||
|
{ |
||||||
|
return $this->updatedAt; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param \DateTime $updatedAt |
||||||
|
* @return SkillRelCourse |
||||||
|
*/ |
||||||
|
public function setUpdatedAt($updatedAt) |
||||||
|
{ |
||||||
|
$this->updatedAt = $updatedAt; |
||||||
|
return $this; |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue