getTitleAndCode(); if (!empty($sessionId)) { $session = api_get_session_entity($sessionId); $courseExistsInSession = SessionManager::sessionHasCourse($sessionId, $course->getCode()); if (!$courseExistsInSession) { api_not_allowed(true); } $sessionName = ' '.$session->getName().' - '.$course->getTitleAndCode(); } $form->addHeader(get_lang('Add skills').$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()) { $result = Skill::saveSkillsToCourseFromForm($form); if ($result) { Display::addFlash(Display::return_message(get_lang('Update successful'))); } header('Location: '.$url); exit; } $content = $form->returnForm(); $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'session/session_list.php', 'name' => get_lang('Session list'), ]; $interbreadcrumb[] = [ 'url' => api_get_path(WEB_CODE_PATH).'session/resume_session.php?id_session='.$sessionId, 'name' => get_lang('Session overview'), ]; $template = new Template(get_lang('Courses-Skills associations')); $template->assign('content', $content); $template->display_one_col_template();