General developer forum

 
 
Picture of Graham Bowman
Retrieve a manual grade
 

I am trying to make a simple block to display a student's target grade. 

In each course a manual grade item will be created called 'target' and I want the block to show this grade.

I have found documentation here which shows how to return the users grade for an activity but its says "Manual, course or category items can not be queried".

Does anyone know a way to query a manual item?

 

Thanks

Graham  

 
Average of ratings: -
Picture of Bob Puffer
Re: Retrieve a manual grade
Group Particularly helpful Moodlers

That documentation doesn't look up-to-date.  Grade schemas don't change all that much and what you're looking for has hardly changed at all since 1.95. You don't mention your version so I'll assume you're wise enough not to be using a version unsupported for security fixes.  In that case your query would be:

$params = array('userid' => $USER->id, 'itemid' => <the itemid from grade_items you want to display>);

$gradeval = $DB->get_record('grade_grades', $params);

 
Average of ratings: -
Picture of Graham Bowman
Re: Retrieve a manual grade
 

Thanks so much for posting that code. It really helped me. 

I have published my block on github  https://github.com/gbowman85/Moodle-block_my_target

 
Average of ratings: -