Courses and course formats

 
 
Picture of Paul K
Unlimited length of course section name
 

Hi,

today I have found out, that the section name in course can have unlimited lenght. It looks like a general error in this particular module. Does anyone know how to limit the length of the section name? I'm using Moodle 2.5.2.

Would appreciate for any hint.

 
Average of ratings: -
Gareth J Barnard
Re: Unlimited length of course section name
Group DevelopersGroup Particularly helpful Moodlers

Hi Paul,

If you look in '/lib/db/install.xml', table 'course_sections', attribute 'name' you will find it is currently defined at 255.

Gareth

 
Average of ratings: -
Picture of Paul K
Re: Unlimited length of course section name
 

Hi Gareth,

thanks for your tip. However, this has nothing to do with the problem presented above. I'm able to write more than 255 letters in the section name. There should be somewhere an option to defined the lenght of the section name. Unfortunately this is not the file which you have mentioned.

 
Average of ratings: -
Gareth J Barnard
Re: Unlimited length of course section name
Group DevelopersGroup Particularly helpful Moodlers

Dear Paul,

I beg to differ as that is where the section name is stored in the database and using the website www.lipsum.com to generate a 256 byte (character) string results in the following error when setting the section name:

So therefore it 'is' the file of which I mention and 'is' to do with the problem!  That is unless you are thinking of the section summary which is defined as 'text' resulting in the 'longtext' in an MySQL database which I think is around 4294967296 - 4 characters.

Please screen shot your evidence and prove me wrong smile

Cheers,

Gareth

 
Average of ratings: -
Picture of Paul K
Re: Unlimited length of course section name
 

Hi Gareth,

my mistake that I haven't expressed myself correctly. I fully agree with you, that you are able to change the length in this particular field in xml file, or even change the length of the section name field in the database. This field is defined in the database as varchar with 256 bytes of length.

I agree with you that at the time, that someone will put more characters, the message "Error writing to database" will appear.


But let me come back to the point and to my question. I asked whether it is possible to specify the number of characters, so that it will be possible to put somewhere more user-friendly message, instead of the above notice about error with writing to database.

I want to avoid such situation, of getting bunch of emails from users who will be not able to find out, what went wrong.

Is there any chance to control the number of characters and display more user-friendly message, at the time when the number of characters will exceed the given limit?

 
Average of ratings: -
Gareth J Barnard
Re: Unlimited length of course section name
Group DevelopersGroup Particularly helpful Moodlers

Dear Paul,

Oh now I see.  You have the situation where users are entering long section names and they are getting the 'Error writing to database' error.

I looked into it and there is no suitable code to cope with the situation.  So, I've created come and raised MDL-42270 to fix it in Moodle 2.4, 2.5 and 2.6.  Moodle 2.3 only has security fixes applied to it and M2.2- is no longer supported.

Cheers,

Gareht

 
Average of ratings: -
Picture of Paul K
Re: Unlimited length of course section name
 

Dear Gareth,

thank you for your help with this. Hopefully this will be patched or this bug will be fixed in one of the next Moodle versions. I will look how the discussion develops.

Best regards,

Paul

 
Average of ratings: -