Moodle

Category name is not being unique

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9.4
  • Fix Version/s: None
  • Component/s: Accessibility, Course, Usability
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE

Description

Bug :

1. Category name is not unique in present moodle 1.9.4 version which i am using.
2. This confuses the course creator or admin pertaining to which category to enter or move courses to when they have multiple categories in same name

Steps to replicate :

Follow normal procedure for creating a category twice but give the same name.
And then view list of categories (Change the frontpage view to show categories)

Activity

Hide
Robert Brenstein added a comment -

I vote against forcing unique course category names. This should be a site policy, enforced by local administrators, not a programmatically controlled requirement. There are scenerios when identical category names are quite appropriate. For example, having an "archive" subcategory for each course category. I have a production site which has a multitude of duplicate names and in that case, this is welcome by users rather than being an issue.

Show
Robert Brenstein added a comment - I vote against forcing unique course category names. This should be a site policy, enforced by local administrators, not a programmatically controlled requirement. There are scenerios when identical category names are quite appropriate. For example, having an "archive" subcategory for each course category. I have a production site which has a multitude of duplicate names and in that case, this is welcome by users rather than being an issue.
Hide
Robert Brenstein added a comment -

At most it could be an optional setting. Having extra code for conditional checking won't impact performance.

Show
Robert Brenstein added a comment - At most it could be an optional setting. Having extra code for conditional checking won't impact performance.
Hide
Ravishankar Somasundaram added a comment -

Dear Robert, Yes i agree its an asset if its a sub-category alone, on quoting your example think about having 5 categories with name "archives".

Show
Ravishankar Somasundaram added a comment - Dear Robert, Yes i agree its an asset if its a sub-category alone, on quoting your example think about having 5 categories with name "archives".
Hide
Ravishankar Somasundaram added a comment -

Posting a fix for this issue incase any ones interested, (pardon me for not giving a patch file , i have many other custom code with it )

in the file /course/editcategory_form.php

41. $this->add_action_buttons(true, $strsubmit);
42. }

add the below lines after line 42 which ends like above mentioned.

function validation($data, $files) {
global $CFG;

$errors = parent::validation($data, $files);
if($data['parent'] == 0)
{
if ($foundcategories = get_records('course_categories', 'name', $data['name'],'depth',1)) {
if (!empty($data['id'])) { unset($foundcategories[$data['id']]); }
$errors['name']= get_string('bdnametaken');
}
}
return $errors;
}

and in lang/en_utf8/moodle.php

add the below in any new line. (i would prefer adding it alphabetically as moodle does)

$string['bdnametaken'] = 'category already exist';

Show
Ravishankar Somasundaram added a comment - Posting a fix for this issue incase any ones interested, (pardon me for not giving a patch file , i have many other custom code with it ) in the file /course/editcategory_form.php 41. $this->add_action_buttons(true, $strsubmit); 42. } add the below lines after line 42 which ends like above mentioned. function validation($data, $files) { global $CFG; $errors = parent::validation($data, $files); if($data['parent'] == 0) { if ($foundcategories = get_records('course_categories', 'name', $data['name'],'depth',1)) { if (!empty($data['id'])) { unset($foundcategories[$data['id']]); } $errors['name']= get_string('bdnametaken'); } } return $errors; } and in lang/en_utf8/moodle.php add the below in any new line. (i would prefer adding it alphabetically as moodle does) $string['bdnametaken'] = 'category already exist';
Hide
Anthony Borrow added a comment -

I'm lowering the priority as this is certainly not major. I agree with Bob that there are scenarios where it would be desirable to have duplicate names. The workaround, from my perspective, is for the administrator to rename one of the categories if it is causing confusion. My vote would be to close this issue as not a bug. Peace - Anthony

Show
Anthony Borrow added a comment - I'm lowering the priority as this is certainly not major. I agree with Bob that there are scenarios where it would be desirable to have duplicate names. The workaround, from my perspective, is for the administrator to rename one of the categories if it is causing confusion. My vote would be to close this issue as not a bug. Peace - Anthony
Hide
Michael de Raadt added a comment -

Thanks for reporting this issue.

We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

Michael d;

lqjjLKA0p6

Show
Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
Hide
Michael de Raadt added a comment -

I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Show
Michael de Raadt added a comment - I'm closing this issue as it appears to have become inactive and is probably not relevant to a current supported version. If you are encountering this problem or one similar, please launch a new issue.

Dates

  • Created:
    Updated:
    Resolved: