mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-50729-master' of git://github.com/ankitagarwal/moodle
This commit is contained in:
commit
6b9d6d2eab
@ -85,6 +85,16 @@ abstract class base implements \IteratorAggregate {
|
||||
*/
|
||||
const NOT_FOUND = -31338;
|
||||
|
||||
/**
|
||||
* User id to use when the user is not logged in.
|
||||
*/
|
||||
const USER_NOTLOGGEDIN = 0;
|
||||
|
||||
/**
|
||||
* User id to use when actor is not an actual user but system, cli or cron.
|
||||
*/
|
||||
const USER_OTHER = -1;
|
||||
|
||||
/** @var array event data */
|
||||
protected $data;
|
||||
|
||||
|
@ -53,10 +53,12 @@ class user_graded extends base {
|
||||
* Utility method to create new event.
|
||||
*
|
||||
* @param \grade_grade $grade
|
||||
* @param null|int $userid Id of user responsible for this event.
|
||||
*
|
||||
* @return user_graded
|
||||
*/
|
||||
public static function create_from_grade(\grade_grade $grade) {
|
||||
$event = self::create(array(
|
||||
public static function create_from_grade(\grade_grade $grade, $userid = null) {
|
||||
$gradedata = array(
|
||||
'context' => \context_course::instance($grade->grade_item->courseid),
|
||||
'objectid' => $grade->id,
|
||||
'relateduserid' => $grade->userid,
|
||||
@ -64,7 +66,11 @@ class user_graded extends base {
|
||||
'itemid' => $grade->itemid,
|
||||
'overridden' => !empty($grade->overridden),
|
||||
'finalgrade' => $grade->finalgrade),
|
||||
));
|
||||
);
|
||||
if ($userid !== null) {
|
||||
$gradedata["userid"] = $userid;
|
||||
}
|
||||
$event = self::create($gradedata);
|
||||
$event->grade = $grade;
|
||||
return $event;
|
||||
}
|
||||
|
@ -658,7 +658,7 @@ class grade_category extends grade_object {
|
||||
|
||||
// If successful trigger a user_graded event.
|
||||
if ($success) {
|
||||
\core\event\user_graded::create_from_grade($grade)->trigger();
|
||||
\core\event\user_graded::create_from_grade($grade, \core\event\base::USER_OTHER)->trigger();
|
||||
}
|
||||
}
|
||||
$dropped = $grade_values;
|
||||
@ -743,7 +743,7 @@ class grade_category extends grade_object {
|
||||
|
||||
// If successful trigger a user_graded event.
|
||||
if ($success) {
|
||||
\core\event\user_graded::create_from_grade($grade)->trigger();
|
||||
\core\event\user_graded::create_from_grade($grade, \core\event\base::USER_OTHER)->trigger();
|
||||
}
|
||||
}
|
||||
$this->set_usedinaggregation($userid, $usedweights, $novalue, $dropped, $extracredit);
|
||||
@ -786,7 +786,7 @@ class grade_category extends grade_object {
|
||||
|
||||
// If successful trigger a user_graded event.
|
||||
if ($success) {
|
||||
\core\event\user_graded::create_from_grade($grade)->trigger();
|
||||
\core\event\user_graded::create_from_grade($grade, \core\event\base::USER_OTHER)->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -775,7 +775,7 @@ class grade_item extends grade_object {
|
||||
// If successful trigger a user_graded event.
|
||||
if ($success) {
|
||||
$grade->load_grade_item();
|
||||
\core\event\user_graded::create_from_grade($grade)->trigger();
|
||||
\core\event\user_graded::create_from_grade($grade, \core\event\base::USER_OTHER)->trigger();
|
||||
} else {
|
||||
$result = "Internal error updating final grade";
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user