Moodle

Activity Module: Allow modname to contain an underscore (_)

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Won't Fix
  • Affects Version/s: 1.9
  • Fix Version/s: None
  • Component/s: Course
  • Labels:
    None
  • Affected Branches:
    MOODLE_19_STABLE

Description

I was working with the ILP project which contains two modules that I had suggested be renamed to ilp_target and ilp_concern; however, then we discovered that it chokes with /course/mod.php because the variable must be a PARAM_ALPHA which excludes the underscore (_). For consistency, it would be good if modules could have the underscore. Tablenames, blocks, function names all allow the use of the underscore so this issue caught me by surprise.

I'm filing this under course since that is where I found it but it may be more far reaching. Since Petr indicated that the issue is not trivial and that we may be able to address it in 2.0 I am initially assigning to him.

Issue Links

Activity

Hide
Anthony Borrow added a comment -

Working with the ilp project, I initially thought it would be helpful to add a prefix to the module name similar to how we do with blocks; however, I was not aware that the underscores were stripped away. We have since renamed but the hope is that using the underscore for a module name will be allowed in Moodle 2.0 to be consistent with Moodle naming conventions. In other words, since the underscore is used in tablenames, blocks, etc. it makes sense that a module should also be able to use it (IMHO). Peace - Anthony

Show
Anthony Borrow added a comment - Working with the ilp project, I initially thought it would be helpful to add a prefix to the module name similar to how we do with blocks; however, I was not aware that the underscores were stripped away. We have since renamed but the hope is that using the underscore for a module name will be allowed in Moodle 2.0 to be consistent with Moodle naming conventions. In other words, since the underscore is used in tablenames, blocks, etc. it makes sense that a module should also be able to use it (IMHO). Peace - Anthony
Hide
Petr Škoda (skodak) added a comment -

Hello, I am sorry, modules will never be allowed to contain '_' because we need this for BC.

Petr

Show
Petr Škoda (skodak) added a comment - Hello, I am sorry, modules will never be allowed to contain '_' because we need this for BC. Petr
Hide
Anthony Borrow added a comment -

Petr - For consistency, would it helpful to not allow any plugin (blocks, filters, authentication types, etc.) to contain underscores? Even if we do not prevent the underscore in the code for all plugins, should we consider making that a recommendation when naming or does it make sense to just not allow the underscore for activity modules? Peace - Anthony

Show
Anthony Borrow added a comment - Petr - For consistency, would it helpful to not allow any plugin (blocks, filters, authentication types, etc.) to contain underscores? Even if we do not prevent the underscore in the code for all plugins, should we consider making that a recommendation when naming or does it make sense to just not allow the underscore for activity modules? Peace - Anthony
Hide
Petr Škoda (skodak) added a comment -

The problem is that the 'mod_' is option for modules, when normalising the component names we look for '', if it is there the stuff before the first '' is type of plugin and the rest is plugin name. If there is no component it is either core component or module, allowing '_' in modules would break it completely, that is why it can not be allowed.

I would vote to forbidding '' in all plugins but it is already in multiple official blocks and other plugins, upgrade would be painful, the contrib is full of plugins with '' too.

Petr

Show
Petr Škoda (skodak) added a comment - The problem is that the 'mod_' is option for modules, when normalising the component names we look for '', if it is there the stuff before the first '' is type of plugin and the rest is plugin name. If there is no component it is either core component or module, allowing '_' in modules would break it completely, that is why it can not be allowed. I would vote to forbidding '' in all plugins but it is already in multiple official blocks and other plugins, upgrade would be painful, the contrib is full of plugins with '' too. Petr
Hide
Anthony Borrow added a comment -

Thanks Petr - It sounds like we live in an imperfect world. Perhaps we could just make a recommendation to avoid the underscore in plugins with the understanding that it will not work with activity modules. It sounds like trying to fix the existing stuff would be more work with no significant benefits other than theoretically being more consistent. I'm certainly OK with leaving things as they are. Happy Holidays. Peace - Anthony

Show
Anthony Borrow added a comment - Thanks Petr - It sounds like we live in an imperfect world. Perhaps we could just make a recommendation to avoid the underscore in plugins with the understanding that it will not work with activity modules. It sounds like trying to fix the existing stuff would be more work with no significant benefits other than theoretically being more consistent. I'm certainly OK with leaving things as they are. Happy Holidays. Peace - Anthony
Hide
Petr Škoda (skodak) added a comment -

I am personally recommending no underscores in plugin names for many years. Thanks for your attention to details like this!

Show
Petr Škoda (skodak) added a comment - I am personally recommending no underscores in plugin names for many years. Thanks for your attention to details like this!
Hide
Petr Škoda (skodak) added a comment -

Merry Christmas to you too.

Show
Petr Škoda (skodak) added a comment - Merry Christmas to you too.

People

Vote (1)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: