MDL-45837 Grades: Minor fixes to grade_letter events
This commit is contained in:
committed by
David Monllao
parent
e4607502bf
commit
b4993d29f7
@@ -139,7 +139,16 @@ if (!$edit) {
|
||||
|
||||
} else if ($data = $mform->get_data()) {
|
||||
if (!$admin and empty($data->override)) {
|
||||
$DB->delete_records('grade_letters', array('contextid' => $context->id));
|
||||
$records = $DB->get_records('grade_letters', array('contextid' => $context->id));
|
||||
foreach ($records as $record) {
|
||||
$DB->delete_record('grade_letters', array('id' => $record->id));
|
||||
// Trigger the letter grade deleted event.
|
||||
$event = \core\event\grade_letter_deleted::create(array(
|
||||
'objectid' => $record->id,
|
||||
'context' => $context,
|
||||
));
|
||||
$event->trigger();
|
||||
}
|
||||
redirect($returnurl);
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class grade_letter_created extends base {
|
||||
public function get_description() {
|
||||
if ($this->courseid) {
|
||||
return "The user with id '$this->userid' created the letter grade with id '$this->objectid'".
|
||||
" in the course in the id '".$this->courseid."'.";
|
||||
" in the course with the id '".$this->courseid."'.";
|
||||
} else {
|
||||
return "The user with id '$this->userid' created the letter grade with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class grade_letter_deleted extends base {
|
||||
public function get_description() {
|
||||
if ($this->courseid) {
|
||||
return "The user with id '$this->userid' deleted the letter grade with id '$this->objectid'".
|
||||
" from the course in the id '".$this->courseid."'.";
|
||||
" from the course with the id '".$this->courseid."'.";
|
||||
}
|
||||
|
||||
return "The user with id '$this->userid' deleted the letter grade with id '$this->objectid'.";
|
||||
|
||||
@@ -64,7 +64,7 @@ class grade_letter_updated extends base {
|
||||
public function get_description() {
|
||||
if ($this->courseid) {
|
||||
return "The user with id '$this->userid' updated the letter grade with id '$this->objectid'".
|
||||
" in the course in the id '".$this->courseid."'.";
|
||||
" in the course with the id '".$this->courseid."'.";
|
||||
} else {
|
||||
return "The user with id '$this->userid' updated the letter grade with id '$this->objectid'.";
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ class scale_created extends base {
|
||||
public function get_description() {
|
||||
if ($this->courseid) {
|
||||
return "The user with id '$this->userid' created the custom scale with id '$this->objectid'".
|
||||
" from the course in the id '".$this->courseid."'.";
|
||||
" from the course with the id '".$this->courseid."'.";
|
||||
}
|
||||
|
||||
return "The user with id '$this->userid' created the standard scale with id '$this->objectid'.";
|
||||
|
||||
@@ -64,7 +64,7 @@ class scale_updated extends base {
|
||||
public function get_description() {
|
||||
if ($this->courseid) {
|
||||
return "The user with id '$this->userid' updated the custom scale with id '$this->objectid'".
|
||||
" from the course in the id '".$this->courseid."'.";
|
||||
" from the course with the id '".$this->courseid."'.";
|
||||
}
|
||||
|
||||
return "The user with id '$this->userid' updated the standard scale with id '$this->objectid'.";
|
||||
|
||||
@@ -126,7 +126,7 @@ class grade_scale extends grade_object {
|
||||
if (!empty($this->standard)) {
|
||||
$eventcontext = context_system::instance();
|
||||
} else {
|
||||
if ((!empty($this->courseid)) && ($this->courseid != SITEID)) {
|
||||
if (!empty($this->courseid)) {
|
||||
$eventcontext = context_course::instance($this->courseid);
|
||||
} else {
|
||||
$eventcontext = context_system::instance();
|
||||
@@ -156,7 +156,7 @@ class grade_scale extends grade_object {
|
||||
if (!empty($this->standard)) {
|
||||
$eventcontext = context_system::instance();
|
||||
} else {
|
||||
if ((!empty($this->courseid)) && ($this->courseid != SITEID)) {
|
||||
if (!empty($this->courseid)) {
|
||||
$eventcontext = context_course::instance($this->courseid);
|
||||
} else {
|
||||
$eventcontext = context_system::instance();
|
||||
@@ -184,7 +184,7 @@ class grade_scale extends grade_object {
|
||||
if (!empty($this->standard)) {
|
||||
$eventcontext = context_system::instance();
|
||||
} else {
|
||||
if ((!empty($this->courseid)) && ($this->courseid != SITEID)) {
|
||||
if (!empty($this->courseid)) {
|
||||
$eventcontext = context_course::instance($this->courseid);
|
||||
} else {
|
||||
$eventcontext = context_system::instance();
|
||||
|
||||
+20
-2
@@ -1399,7 +1399,16 @@ function remove_grade_letters($context, $showfeedback) {
|
||||
|
||||
$strdeleted = get_string('deleted');
|
||||
|
||||
$DB->delete_records('grade_letters', array('contextid'=>$context->id));
|
||||
$records = $DB->get_records('grade_letters', array('contextid' => $context->id));
|
||||
foreach ($records as $record) {
|
||||
$DB->delete_record('grade_letters', array('id' => $record->id));
|
||||
// Trigger the letter grade deleted event.
|
||||
$event = \core\event\grade_letter_deleted::create(array(
|
||||
'objectid' => $record->id,
|
||||
'context' => $context,
|
||||
));
|
||||
$event->trigger();
|
||||
}
|
||||
if ($showfeedback) {
|
||||
echo $OUTPUT->notification($strdeleted.' - '.get_string('letters', 'grades'), 'notifysuccess');
|
||||
}
|
||||
@@ -1462,7 +1471,16 @@ function grade_course_category_delete($categoryid, $newparentid, $showfeedback)
|
||||
global $DB;
|
||||
|
||||
$context = context_coursecat::instance($categoryid);
|
||||
$DB->delete_records('grade_letters', array('contextid'=>$context->id));
|
||||
$records = $DB->get_records('grade_letters', array('contextid' => $context->id));
|
||||
foreach ($records as $record) {
|
||||
$DB->delete_record('grade_letters', array('id' => $record->id));
|
||||
// Trigger the letter grade deleted event.
|
||||
$event = \core\event\grade_letter_deleted::create(array(
|
||||
'objectid' => $record->id,
|
||||
'context' => $context,
|
||||
));
|
||||
$event->trigger();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user