When deleting categories, LPs inside are moved in the "No category" section see BT#5763

skala
Julio Montoya 13 years ago
parent 2758b2bd29
commit d565ca0801
  1. 37
      main/inc/Entity/EntityCLp.php
  2. 4
      main/inc/Entity/Repository/LpRepository.php
  3. 33
      main/newscorm/learnpath.class.php
  4. 8
      main/newscorm/lp_add_category.php
  5. 6
      main/newscorm/lp_edit.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

@ -10,7 +10,5 @@ use Doctrine\ORM\EntityRepository;
*/
class LpRepository extends EntityRepository
{
public function getSubscribedStudentsInLP($course_id, $lp_id)
{
}
}

@ -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;
}
}

@ -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

@ -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') {

Loading…
Cancel
Save