This discussion has been locked because a year has elapsed since the last post. Please start a new discussion topic.

I hope that is clear.

Any ideas?

Thanks,

Mitchell

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

Hi again

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;
$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);}