## Gradebook

### Grade mirrored in assign_grades and grade_grades

This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.
Grade mirrored in assign_grades and grade_grades

I'm a bit confused about where user grades are actually stored. For the assign module, are they stored in grade_grades and in assign_grades?

I ask because I recently upgraded from 1.9 to 2.5 and noticed that a few things are no longer working. I created a page that does manual grading on assignments and inserts the grade into grade_grades using direct sql (I know, bad idea). It worked fine in 1.9 but no longer in 2.5. Now the grade shows up in the gradebook but does not show up when browsing the submissions for the assignment. My guess is that the grade is in grade_grades but not in assign_grades.

I hope that is clear.

Any ideas?

Thanks,

Mitchell

Re: Grade mirrored in assign_grades and grade_grades

Hi Mitchell

Did you ever get to the bottom of this?

I'm having exactly the same problem, I use the following code to create a grade in the gradebook.

$grade = new stdClass();$grade->userid   = 'userid';$grade->rawgrade = '100'; assign_grade_item_update('assignment',$grade);

It appears in the gradebook fine, but when a teacher goes to manually grade the assignment through the assignment link the grade doesn't appear.

As you have highlighted there is no submission for the grade in the 'assign_grades' table which I assume is the problem. I haven't yet found a method for adding the grade to both the gradebook and the assign_grades. You would assume the function 'assign_grade_item' would grade the assignment not just the gradebook.

Does anyone have any ideas?

Steve

Re: Grade mirrored in assign_grades and grade_grades

Hi again

The following code does the job creates the grade in both assign_grades and grade_grades.

global $DB,$USER;
require_once($CFG->dirroot.'/mod/assign/lib.php');$grade = new stdClass();$grade->assignment = 'assignment';$grade->userid = 'userid';$grade->timecreated = time();$grade->timemodified = $grade->timecreated;$grade->grader = $USER->id;$grade->grade = '100';$grade->locked = 0;$grade->mailed = 0;
//check if grade exists if so overwrite instead of adding a new one
$checkIfGraded =$DB->get_record('assign_grades', array('userid'=>$grade->userid, 'assignment'=>$grade->assignment));if($checkIfGraded){$result = $DB->update_record('assign_grades',$grade);} else {         $result =$DB->insert_record('assign_grades', $grade);} if ($result) {         $grade2 = new stdClass();$grade2->userid   = $grade->userid;$grade2->rawgrade = $grade->grade;$grade2->usermodified = $grade->grader;$grade2->datesubmitted = NULL;         $grade2->dategraded =$grade->timemodified;         //$grade2->feedbackformat = ''; //$grade2->feedback = '';         assign_grade_item_update('assignment', \$grade2);}

If anyone has any observation they would be appreciated?

Regards

Steve