<?php
$mycourses = get_my_courses($USER->id);
$catArr = array();
foreach ($mycourses as $mycourse){
array_push($catArr,$mycourse->category);
}
$catArr = array_unique($catArr);
sort($catArr);
foreach ($catArr as $cat){
$myCat = get_records_select('course_categories',"id='$cat'",'name ASC','id, name');
foreach ($myCat as $mCat){
echo '<h4>'.$mCat->name.'</h4>';
}
echo '<ul>';
foreach ($mycourses as $mycourse){
if ($mycourse->category == $cat){
echo '<li><a href="../course/view.php?id='.$mycourse->id.'">'.$mycourse->fullname.'</a></li>';
}
}
echo '</ul>';
}
?>
Hi Kate.
I can display the categories by using Dale's code but not the activity within the courses as you have in your screenshot. How did you do it?
Barbara
Hi,
Can i know where to edit or add this code into ? index.php ?
I created a little update to your script:
Categories sorted by name, Courses in categories sorted by name, Categories & courses color coded with css!
Install:
Extract the nicemy.zip to a folder of your local harddisk.
1. rename (=backup) the /moodle/my directory
2. copy the my folder (extracted by now) to /moodle/my (so you have a new my folder).
3. Adjust your themes stylesheet styles_layout.css: Add the contents of the file add2-styles_layout.css into your theme into the file styles_layout.css !
See the image: This is what your moodle/my could look like!
Any feedback?
just to let you know: I am working on an improved version (better CSS naming, user defined sort (similar to http://moodle.org/mod/forum/discuss.php?d=122236#p555851), show/hide categories)
Olaf
Your colour code my courses is excellent. My teachers really appreciated it.
How did you get on with the user defined my courses?
Cheers
Chris
The tree view in "Meine Kurs" block - how did you do that? It looks very convenient for the learner especially is there are many courses enrolled.
And what does the colour-coding (blue, orange, grey) describe?
Dan
the color coding is the category and the courses. I used a simple online color picker to choose some nice matching colors for each category and it's entries, but differnt colors for different categories so that they are easy to distinguish.
The "Meine Kurse" is a block: http://moodle.org/mod/forum/discuss.php?d=67494#p545593 (you can search the moodle forum, but I simnply uploaded the block (exactly as I downloaded it - also the filename) (also look here for comparison: http://moodle.org/mod/forum/discuss.php?d=55625#p253733 )
Just remove the original block in moodle settings -> blocks -> fixed blocks -> my page and replace it with this block.
Olaf
Hey !! (Lieber Olaf...)
Why did you not give credit to JULIAN RIDDEN and ROSARIO CARCÒ who adapted and reworked the original myCourses Block out of the FN_Moodle project?
NEVER upload such copies of code because all development is done and documented in its original Forum Thread.
Since Version 06r a lot of enhancements have been done and there is also a block called siteNavigation which shows up ALL categories and ALL courses of your Moodle-Site.
So navigate to the original threads if you want to use and upgrade your myCourses and/or siteNavigation Blocks:
myCourses: http://moodle.org/mod/forum/discuss.php?d=67494
siteNavigation: http://moodle.org/mod/forum/discuss.php?d=103703
Rosario
oh, that color coding: you (as admin/user, depending on settings) can switch things on/off with these "buttons". Please try or read forum link I posted before.
Olaf
It is a pity, the work is magnificent
like this
medicine faculty --- first level category
Medicine --- second level category
course1
course2 --- courses
course3
Nursery --- second level
course1
course2
course3
One of my promises, when I coded the siteNavigation Block, was to create also a copy of the code to be used in the center part of the FrontPage.
Unfortunately develpment and enhancement of the code still takes all my resources. Actually I am rewriting the code to display myCourses and siteNavigation in a popUp-window because the block width of 210 pixels is simply too small/narrow for large scale sites with more than 1'500 courses deeply nested into more than 1'000 categories.
But as soon as I have this code, it could simply be extracted to put the php-code into any place where you can output HTML-Code.
Have a look at the siteNavigation thread to observe development:
http://moodle.org/mod/forum/discuss.php?d=103703
Rosario
Hello,
Does anyone know how to display the categories and the subcategories?
Olaf Code' displays only the latest level of the category but I need The fist level of categories and the second level (sub-categories).
I hope somebody can help us.
Thanks! I'm sorry about my english!
Hi
Has anyone configured Olaf's nicemy for Moodle 2.+?
Cheers
Where file should i put this code into?
regrds
combro
www/my/index.php
This would eventually replace whatever existing code you have in there to output the course list.
Can i know where to edit or add this code into ? index.php ?
Hi Dale,
I copied your code to my index.php. But when i clicked on myhome...it shows
Fatal error: Call to undefined function get_records_select() in C:\wamp\www\moodleNew\my\index.php on line 157......
Can you help me out of this.....it's very important for me......
Thanks.
get_my_courses($USER->id); function is not working.