My Moodle: Formatting course details in My Moodle

My Moodle: Formatting course details in My Moodle

napisao/la Daniel Rivera -
Broj odgovora: 10
I have a need to add more content in the center section of My Moodle.

The blocks available are great: so far I'm using the Login/Logout block, View Certificates block and My Courses block. These are all very cool sticky block plugins that one can add in easily. See the modules & plugins page for the details. Thank you to to the folks who contributed those!

What has been hard for me to figure out is how to add things like "Date course last accessed" and a progress bar or at least a "Grade/Status" listing. Of course this info lives in other places in Moodle, I just need to know how I can aggregate the data into the My Moodle course list and also format the list a bit.

See my mock-up below.

Looking forward to any info you can provide. Thanks Moodlers.
Privitak my_moodle_centercontent.jpg
Odgovor na Daniel Rivera

Re: My Moodle: Formatting course details in My Moodle

napisao/la Jenny Gray -
I may be wrong but I don't *think* you'll find anything you can just install to do this for you. You'll need to do a bit of coding.

The key function that prints your course listings in the myMoodle page is called print_overview and you'll find it in course/lib.php. There are hooks for blocks and modules to send this function information automatically to be included.

I'm not aware of a hook for grades, or for course last accessed ($course->lastaccessed). These you might need to add for yourself.

The Certificate module I don't think supports myMoodle yet either - it could do by adding a print_overview function in mod/certificate/lib.php. This would need to control whether the current user has access to their certificate or not yet, and output appropriate text in the right format (I've done it for other modules and just copied from existing print_overview functions!!)

Odgovor na Jenny Gray

Re: My Moodle: Formatting course details in My Moodle

napisao/la Daniel Rivera -
Ok, I think I understand this better. Thank you Jenny! smile

I was sure it would be some coding but I really had no clue where to start. You have given me the info I needed.

Odgovor na Daniel Rivera

Re: My Moodle: Formatting course details in My Moodle

napisao/la José Ángel Polo -

Not very orthodox but it works

Edit /course/lib.php

In print_overview function ($courses) locate these lines: And replace it with this:
foreach ($ courses as $ course) (
print_simple_box_start ( 'center', '100% ','', 5, "coursebox");
$ linkcss ='';
if (empty ($ course-> visible)) (
$ linkcss = 'class = "dimmed"';
)

print_heading ('...');

if (array_key_exists ($ course-> id, $ htmlarray)) (

foreach ($courses as $course) (
print_simple_box_start('center', '100%', '', 5, "coursebox");
$linkcss = '';
if (empty($course->visible)) (
$linkcss = 'class="dimmed"';
)
$category = get_record("course_categories", "id", $course->category);

print_heading('<a title="'. format_string($category->name).'" href="'.$CFG->wwwroot.'/course/category.php?id='.$category->id.'">'. format_string($category->name).'</a>&nbsp;<a title="'. format_string($course->fullname).'" '.$linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'. format_string($course->fullname).'</a><br>'.format_time(time() - $course->lastaccess).'&nbsp;('.userdate($course->lastaccess, get_string('strftimerecentfull')).')');

/font>/font>

if (array_key_exists ($ course-> id, $ htmlarray)) (

Before showing the latest from the forums or tasks, will show in my courses (and therefore in my moodle) Category, Course, Date of last access and how long ago the last access.

/span>
Privitak mymoodlecenter.jpg
Odgovor na José Ángel Polo

Re: My Moodle: Formatting course details in My Moodle

napisao/la José Ángel Polo -
And if you want the ratings when appropriate ...

// Get course categories
$category = get_record("course_categories", "id", $course->category);
// Get course grade_item
require_once $CFG->dirroot.'/grade/report/overview/lib.php';
$grade_item = grade_item::fetch_course_item($course->id);
// Get the grade
$grade = new grade_grade(array('itemid'=>$grade_item->id, 'userid'=>$USER->id));
$grade->grade_item =& $grade_item;
$display_final_grade = grade_format_gradevalue($grade->finalgrade, $grade_item, true);
$display_final_grade = ' - '.$display_final_grade;
print_heading('<a title="'. format_string($course->fullname).'" '.$linkcss.' href="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'">'. format_string($course->fullname).'</a><br><a title="Categor&iacute;a: '. format_string($category->name).'" href="'.$CFG->wwwroot.'/course/category.php?id='.$category->id.'">'. format_string($category->name).'</a><br> '.userdate($course->lastaccess, get_string('strftimerecentfull')).'<br>'.format_time(time() - $course->lastaccess).'<br>'. format_string($display_final_grade).'');

Privitak mymoodlecenter2.jpg
Odgovor na José Ángel Polo

Re: My Moodle: Formatting course details in My Moodle

napisao/la Divya muvvala -
Hi Jose, displaying the total course grade is a great idea. And it works fine with my Moodle. Can you also help me to display outcomes for each completed lesson. I have been trying to twick code but did not succeed. So can you pl help me.
Odgovor na Daniel Rivera

Re: My Moodle: Formatting course details in My Moodle

napisao/la Ger Tielemans -
Odgovor na Ger Tielemans

Re: My Moodle: Formatting course details in My Moodle

napisao/la José Ángel Polo -
But you need a Progress bar block for each course.

There are other possibilities as MyMoodle Covcell Blocks:

http://moodle.org/mod/data/view.php?d=13&rid=1181

but always as blocks ...

Odgovor na José Ángel Polo

Re: My Moodle: Formatting course details in My Moodle

napisao/la Ger Tielemans -
yes, you are right, I see the difference