diff --git a/main/inc/Entity/EntityCLp.php b/main/inc/Entity/EntityCLp.php index d57f91ebb2..e2fb4c29e9 100644 --- a/main/inc/Entity/EntityCLp.php +++ b/main/inc/Entity/EntityCLp.php @@ -234,18 +234,43 @@ class EntityCLp */ private $expiredOn; - public function __construct() { + /** + * @var integer + * + * @Column(name="category_id", type="integer", precision=0, scale=0, nullable=false, unique=false) + */ + private $categoryId; - } + /** + * + */ + public function __construct() + { - public function getLps() { - /*$query = $this->em->createQuery('SELECT u FROM Entity\Entry e WHERE :region_id MEMBER OF e.regions'); - $query->setParameter('region_id', 1); - return $query->getResult();*/ } + /** + * Set categoryId + * + * @param integer $id + * @return EntityCLp + */ + public function setCategoryId($id) + { + $this->categoryId = $id; + return $this; + } + /** + * Get categoryId + * + * @return integer + */ + public function getCategoryId() + { + return $this->categoryId; + } /** * Set cId diff --git a/main/inc/Entity/Repository/LpRepository.php b/main/inc/Entity/Repository/LpRepository.php index ce3c371726..95df1ebb13 100644 --- a/main/inc/Entity/Repository/LpRepository.php +++ b/main/inc/Entity/Repository/LpRepository.php @@ -10,7 +10,5 @@ use Doctrine\ORM\EntityRepository; */ class LpRepository extends EntityRepository { - public function getSubscribedStudentsInLP($course_id, $lp_id) - { - } + } \ No newline at end of file diff --git a/main/newscorm/learnpath.class.php b/main/newscorm/learnpath.class.php index e9f14a9b57..47cfef310b 100644 --- a/main/newscorm/learnpath.class.php +++ b/main/newscorm/learnpath.class.php @@ -9289,6 +9289,7 @@ class learnpath global $_course; $course_id = api_get_course_int_id(); + $links_to_create = null; // Remove memory and time limits as much as possible as this might be a long process... if (function_exists('ini_set')) { @@ -10308,7 +10309,7 @@ EOD; */ public function create_path($path) { - $path_bits = split('/', dirname($path)); + $path_bits = explode('/', dirname($path)); // IS_WINDOWS_OS has been defined in main_api.lib.php $path_built = IS_WINDOWS_OS ? '' : '/'; @@ -10574,7 +10575,8 @@ EOD; } } - static function move_up_category($id) { + static function move_up_category($id) + { global $app; $em = $app['orm.em']; $item = $em->find('Entity\EntityCLpCategory', $id); @@ -10586,7 +10588,8 @@ EOD; } } - static function move_down_category($id) { + static function move_down_category($id) + { global $app; $em = $app['orm.em']; $item = $em->find('Entity\EntityCLpCategory', $id); @@ -10597,6 +10600,7 @@ EOD; $em->flush(); } } + static function get_count_categories($course_id) { global $app; @@ -10652,21 +10656,40 @@ EOD; $em = $app['orm.em']; $item = $em->find('Entity\EntityCLpCategory', $id); if ($item) { + + $courseId = $item->getCId(); + $query = $em->createQuery('SELECT u FROM Entity\EntityCLp u WHERE u.cId = :id AND u.categoryId = :catId'); + $query->setParameter('id', $courseId); + $query->setParameter('catId', $item->getId()); + $lps = $query->getResult(); + + //Setting category = 0 + if ($lps) { + foreach ($lps as $lpItem) { + $lpItem->setCategoryId(0); + } + } + + //Removing category $em->remove($item); + $em->flush(); } } - static function get_category_from_course_into_select($course_id) + static function get_category_from_course_into_select($course_id, $addSelectOption = false) { $items = self::get_category_by_course($course_id); $cats = array(); + if ($addSelectOption) { + $cats = array(get_lang('SelectACategory')); + } + if (!empty($items)) { foreach ($items as $cat) { $cats[$cat->getId()] = $cat->getName(); } } - return $cats; } } diff --git a/main/newscorm/lp_add_category.php b/main/newscorm/lp_add_category.php index 5b75b467ff..957d1853eb 100644 --- a/main/newscorm/lp_add_category.php +++ b/main/newscorm/lp_add_category.php @@ -93,15 +93,13 @@ if (isset($_SESSION['gradebook'])){ if (!empty($gradebook) && $gradebook=='view') { $interbreadcrumb[]= array ( - 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], - 'name' => get_lang('ToolGradebook') - ); + 'url' => '../gradebook/'.$_SESSION['gradebook_dest'], + 'name' => get_lang('ToolGradebook') + ); } $interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths')); - - $form = new FormValidator('lp_add_category', 'post', 'lp_controller.php'); // Form title diff --git a/main/newscorm/lp_edit.php b/main/newscorm/lp_edit.php index 9f2d2cffb0..452783e0b1 100644 --- a/main/newscorm/lp_edit.php +++ b/main/newscorm/lp_edit.php @@ -72,14 +72,10 @@ $form->addElement('hidden', 'lp_encoding'); $referer = isset($_REQUEST['referer']) ? Security::remove_XSS($_REQUEST['referer']) : null; $form->addElement('hidden', 'referer', $referer); -$items = learnpath::get_category_from_course_into_select(api_get_course_int_id()); +$items = learnpath::get_category_from_course_into_select(api_get_course_int_id(), true); -if (!empty($items)) { - $items = array_merge(array(get_lang('SelectACategory')), $items); -} $form->addElement('select', 'category_id', get_lang('Category'), $items); - //Hide toc frame $hide_toc_frame = $form->addElement('checkbox', 'hide_toc_frame', null, get_lang('HideTocFrame'),array('onclick' => '$("#lp_layout_column").toggle()' )); if (api_get_setting('allow_course_theme') == 'true') {