New Format Section Naming

New Format Section Naming

by Gareth J Barnard -
Number of replies: 5
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Hi,

With Moodle 1.9.3 - 15/10/2008...

I am experimenting with a new course format and read the Readme.txt in /course/format about adding language strings to a file (line 28+) to make get_string in /lib/moodlelib.php find them and then putting that file in /lang/en_utf8. However it does not! Therefore when you come to edit a section name you see ' two left square brackets nameyourformat two right square brackets' instead of the string in the file you placed in /lang/en_utf8. I had a go at putting the strings in /lang/en_utf8/moodle.php and the problem was solved.

I had a quick look on tracker and could not see anything that immediately stood out.

Is this a known issue or something that needs to be put in the tracker. If the latter, I am new to this - so help!

BTW - I installed the Accordian format in the same version of Moodle and it appears to have the same issue.

Cheers,

Gareth
Average of ratings: -
In reply to Gareth J Barnard

Re: New Format Section Naming

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Gareth - I am happy to help you figure out what is happening with language strings in the course format. In order to keep things as modular as possible, your course format should have its own language file called /course/format/newformat/lang/en_utf8/format_newformat.php. Then when you want to get a string from it you would use:

get_string('showmyformatstring','format_newformat');

That is how things are designed to work. So if there is an issue with the accordian format we should file an issue in the tracker. Let me know if you have any further questions. Peace - Anthony
In reply to Anthony Borrow

Re: New Format Section Naming

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Anthony,

Thank you for your reply.

I do have a file called format_newformat.php as you state. I tracked down my issue to line 55 of editsection.php in /course/ version 1.25 which calls get_string() to populate the variable $sectionname.

I installed the Accordian format in my local copy of Moodle - 1.9.3 - build 15th October 2008 and saw the same thing happening.

The error manifests itself when editing the section title.

Cheers,

Gareth
In reply to Gareth J Barnard

Re: New Format Section Naming

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Gareth - Could you email me (anthony [a t] moodle [d o t] org) a zip file of either of the course formats that you are having trouble with so that I can reproduce the error. It may be better to jus work with your new format. I am not familiar with the Accordion course format but did find one that Urs worked on for Moodle 1.5 and 1.6. On his site, he indicated that it was not for later versions of Moodle. AFAIK, there is not a version for 1.9 but I could easily be mistaken. I simply looked in the Moodle.org Modules and Plugins database and did not see an entry for it and the code is not in CONTRIB. If you are thinking of sharing your code with the larger Moodle community you may also want to take a look at Development:Guidelines_for_contributed_code. You should not have to modify any core code (such as /course/editsection.php) to make things work properly. If so, we need to file an issue in the tracker to fix it so you do not. Peace - Anthony
In reply to Gareth J Barnard

Re: New Format Section Naming

by Anthony Borrow -
Picture of Core developers Picture of Plugin developers Picture of Testers
Gareth - I did a little further looking and was able to reproduce what I think you were describing with the months format. The problem was that as you describe the $sectionname is populated by a function called get_section_name which looks for a string called name$format so in your case with the newformat example it would be namenewformat and you would need that string defined in your format's language file (/course/format/newformat/lang/en_utf8/format_newformat.php) with a line like:

$string['namenewformat'] = 'New format';

Give that a shot and see if it helps. If not, let me know. Peace - Anthony

p.s. - Actually your question allowed me to improve the months format by fixing the missing string. Thanks!
In reply to Anthony Borrow

Re: New Format Section Naming

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers
Dear Anthony,

I have tried that and no joy.

I have eMailed you some info.

Thank you for the links they will help.

Cheers,

Gareth