I really enjoy the course_menu-block. But it seems that there is another bug when changing to another language, in my case German.
When I klick on a folder the correspondent course section does not appear. The url in the status bar is for example: http://moodle.kbz-zug.ch/course/view.php?id=11&Thema=4
The link: "show all sections" works correctly.
But when I change to English everything works well. The url then in the status bar is showing:
http://moodle.kbz-zug.ch/course/view.php?id=11&topic=4
Any hints, updates or suggestions?
Thanks a lot
Max
$sections = get_all_sections($this->course->id);
if ($this->course->format == 'topics') {
$format = 'topic';
}
else {
$format = 'week';
}
or here
if ($sectiongroup !== 'tree') { print_xtree_item('tree',$sectiongroup,ucwords($sectiongroup),
"$CFG->wwwroot/course/view.php?id={$this->course->id}&topic=all");
It is the last one that causes this malfunctioning.
I suppose the solution is to replace the word 'topic' by a reference to the string in the main moodle.php. Maybe something like get_string('topic') ? But I'm afraid as far as PHP programming is concerned I'm completely at a loss.
The team at Humboldt who developed this marvellous add on probably never realised how popular it would become and therefore didn't pay enough attention to the "international" item in their code. I hope they can tweak this in that direction.
Better to solve this the other way around. References to pages should not depend on the chosen language. Instead of replacing the word 'topic' with something language specific, make sure everywhere the words 'topic' or 'week' or used when referring to pages. (of course translating them when they are shown to the user)
I haven't tested this but I think the following is a solution:
open xtree.php in an editor
go to approx. line 240 and find
$sectionname = get_string("name$course->format");
replace it with the following lines:
if ($course->format == 'topics') { $sectionname = 'topic'; } else { $sectionname = 'week'; }
Proof that it is clearly related to the word 'topic' itself: when changing the string nametopics in moodle.php to 'topics' in any language pack, course menu behaves as expected.
I had another look and it seems the same line of code is also used in other parts of the block.
I tried changing line 46 (I double checked this one ) of block_course_menu.php as well.
$sectionname = get_string("name".$this->course->format);
should read...
if ($this->course->format == 'topics') {
$sectionname = 'topic';
} else {
$sectionname = 'week';
}
Unfortunately $sectionname is also used to name all the untitled topics in a course: 'topic 1', 'topic 2', etc.. Of course here Moodle should use the language string from the chosen language: 'Onderwerp 1', 'Onderwerp 2', etc...
This makes me think your solution of changing the language pack (then you should also change the string 'nameweeks' in moodle.php) is the easiest one after all!
Thanks for bringing this to my attention, and suggesting fixes. While they are not solutions they made fixing this much easier as it pointed out all of the flaws in the code.
I think I have fixed this bug. Could you please try the version now in CVS and let me know? I don't use UTF-8 or other international settings and I don't have time to try this out.
The links should now work regardless of language and the unnamed weeks/topics should render with the appropriate language. If they don't please let me know the status. ie. what link is showing in the status bar, and/or whether or not the topics/weeks are showing with the appropriate language.
regards,
Jeff
I've given the version in CVS a try but there's no change in behaviour. Actually, I wonder if CVS really has a new version: most files are still dated 01/07/05 and some 07/07/05, although I updated from CVS about 5 minutes ago.
Regards,
Leo
It usually takes some hours before new updates are available through anonymous cvs. You might have better luck tomorrow.
Hi Jeff,
Thanks for fixing this bug and for writing this nice block in the first place!
I second your compliment to Jeff!
I added a few more fixes in CVS as mentioned privately by Jan Dierckx.
- Section items with quotes had slashes displayed preceding the quotes. (FIXED)
- Additional use of translated string for variable names could cause potential problems with Javascript if characters such as (é , è , ä etc...) are used in the non-US translation. I think this is the last of this problem.
regards,
Jeff
Hello,
would you know if anyone has done a xtree menu for the 'Show course categories' on the home page or 'My courses' from the 'All courses' button. My list is getting quite long now especially after adding sub categories.
Thanks Gerald
Thank you for this update. I tested the course_menu_block with "German" and it works now perfectly.
Many thanks again.
regards
Max