Display student grade in theme layout

Display student grade in theme layout

by Chris Kenniburg -
Number of replies: 9
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hello,

I am thinking I might need to ask this in the developer forum but I thought I'd start here.

What is the PHP code snippet needed to display a student's grade in a course?

I am wanting to add this into my theme in a special area I am designing and I am hoping that the code will take the course ID and grab the student grade.  

Am I being naive in thinking this can be done easily?  

I am hoping there is code that can be dropped into the layout file for course pages that will show the student their grade.  Any help or thoughts on this would be much appreciated.

Average of ratings: -
In reply to Chris Kenniburg

Re: Display student grade in theme layout

by Mary Evans -
Picture of Core developers Picture of Documentation writers Picture of Peer reviewers Picture of Plugin developers Picture of Testers

from memory this is possible already in Moodle 2.9 as a link in the User menu in the navbar.

if you do a search in Moodle Tracker you might find the code you need!

Cheers

Mary

In reply to Mary Evans

Re: Display student grade in theme layout

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Mary,

This is related to the enhancements we talked about with the drop down or slide in effect for the theme.  

I found some stuff but I am just not that skilled to get it to work or understand how to implement it in the layout files.  

In reply to Chris Kenniburg

Re: Display student grade in theme layout

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

Hi Chris,

You could look at what is in the '$USER' global and see if that has something.

Or pick a page on Moodle that displays the information you want, track down the code and then use that in the theme - or even better if it's a renderer then you could do something like:

$renderer = $PAGE->get_renderer('mod_thingy');

and have the renderer generate the output for you.

Cheers,

Gareth


In reply to Gareth J Barnard

Re: Display student grade in theme layout

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

I found this in the Grade>Report>User>render.php file  -----

$renderer = $PAGE->get_renderer('gradereport_user');

How would I go about displaying the grade in a layout file for the theme?

 If I just wanted to display the user's grade for the course in a layout page for a theme how would I do this.  I need the long version or an example with the chunks of code needed to pull this off if possible.  

Any help is greatly appreciated.  

In reply to Chris Kenniburg

Re: Display student grade in theme layout

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

See what the code does with $renderer and / or find the renderer class and see what methods it has.

In reply to Gareth J Barnard

Re: Display student grade in theme layout

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

That is the problem as I do not know what you mean.  I am a complete novice.  

In reply to Chris Kenniburg

Re: Display student grade in theme layout

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

Oh ok Chris, I'll see what I can do when I get a moment, been upgrading to Windows 10.....

In reply to Gareth J Barnard

Re: Display student grade in theme layout

by Chris Kenniburg -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Thank you Gareth.  No hurry.  It is for an idea to implement into a theme.  I am really at a loss as to how to implement it.  I just need the course grade to appear in a layout file for the theme.

If it cannot be done easily then just scrap the idea.  I'd like to keep it simple and this is obviously over my head, but if I could get this working it would be nice.  

The only other thing I'd like to figure out is how to add the custom menu which displays Course Activities in a drop down.  But this is a separate project.  

In reply to Chris Kenniburg

Re: Display student grade in theme layout

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

Hi Chris,

With "custom menu which displays Course Activities in a drop down", Essential already has something similar which originated from the BCU theme.

G