General developer forum

Accessing the final (Overall) grade in PHP?

 
Picture of BAT BAT
Accessing the final (Overall) grade in PHP?
 

I know this has to be easy.  But I have searched through documentation and forum post and I cannot figure out how to get the final grade for a class.   I am designing a plugin that will run at the end of the semester and store the final grade in a crude transcript if you will.   I can access each of the ind. grades with the gradebook api, but I am not sure how (or even if I can) access the final grade found in the user report?

Is this possible or do I have to manually re-calculate the grade?   


Thanks, and thank you for such an awesome forum,


Cheers,
BAT

I am sorry if this is a re-post, I can't find the old discussion if it is.

 
Average of ratings: -
moi!!! it is what is is...
Re: Accessing the final (Overall) grade in PHP?
Documentation writersParticularly helpful Moodlers

Can't you create an SQL statement that automates the calculation of a final grade? Something like: 

SELECT <SQL{ as an Expression}>[arithmetic operator]<SQL{ as an expression> [and so on] ...
 FROM [table_name], [table_name], [and so on] 
 WHERE [expression];

But don't trust this as a reasonable model of what and how it is going to end up looking like. 

 
Average of ratings: -
Picture of BAT BAT
Re: Accessing the final (Overall) grade in PHP?
 

Hmm... I suppose, I didn't think about doing it on the sql side.   That would be one heck of a join grade item id -> item field -> group %.   But yes that could work.

I'll have to think about that one.


Thanks,

BAT

 
Average of ratings: -
Picture of Darko Miletić
Re: Accessing the final (Overall) grade in PHP?
Core developersParticularly helpful Moodlers

When you say final grade in a class are we talking about course grade for an individual user or something else?

require_once($CFG->libdir.'/gradelib.php');
require_once($CFG->dirroot.'/grade/querylib.php');

$grade = grade_get_course_grade($userid, $courseid);



 
Average of ratings: Useful (3)
Picture of BAT BAT
Re: Accessing the final (Overall) grade in PHP?
 

Perfect!!!!

grade_get_course_grade was what I was missing!

Thank you so much!


Cheers,
BAT

 
Average of ratings: -