Merge branch 'MDL-64878-master' of git://github.com/damyon/moodle
This commit is contained in:
@@ -485,6 +485,9 @@ class restore_gradebook_structure_step extends restore_structure_step {
|
||||
// Freeze gradebook calculations if needed.
|
||||
$this->gradebook_calculation_freeze();
|
||||
|
||||
// Ensure the module cache is current when recalculating grades.
|
||||
rebuild_course_cache($this->get_courseid(), true);
|
||||
|
||||
// Restore marks items as needing update. Update everything now.
|
||||
grade_regrade_final_grades($this->get_courseid());
|
||||
}
|
||||
|
||||
@@ -2495,8 +2495,22 @@ class grade_item extends grade_object {
|
||||
*/
|
||||
public function get_context() {
|
||||
if ($this->itemtype == 'mod') {
|
||||
$cm = get_fast_modinfo($this->courseid)->instances[$this->itemmodule][$this->iteminstance];
|
||||
$context = \context_module::instance($cm->id);
|
||||
$modinfo = get_fast_modinfo($this->courseid);
|
||||
// Sometimes the course module cache is out of date and needs to be rebuilt.
|
||||
if (!isset($modinfo->instances[$this->itemmodule][$this->iteminstance])) {
|
||||
rebuild_course_cache($this->courseid, true);
|
||||
$modinfo = get_fast_modinfo($this->courseid);
|
||||
}
|
||||
// Even with a rebuilt cache the module does not exist. This means the
|
||||
// database is in an invalid state - we will log an error and return
|
||||
// the course context but the calling code should be updated.
|
||||
if (!isset($modinfo->instances[$this->itemmodule][$this->iteminstance])) {
|
||||
mtrace(get_string('moduleinstancedoesnotexist', 'error'));
|
||||
$context = \context_course::instance($this->courseid);
|
||||
} else {
|
||||
$cm = $modinfo->instances[$this->itemmodule][$this->iteminstance];
|
||||
$context = \context_module::instance($cm->id);
|
||||
}
|
||||
} else {
|
||||
$context = \context_course::instance($this->courseid);
|
||||
}
|
||||
|
||||
@@ -813,6 +813,7 @@ class assign {
|
||||
}
|
||||
|
||||
// Delete the instance.
|
||||
// We must delete the module record after we delete the grade item.
|
||||
$DB->delete_records('assign', array('id'=>$this->get_instance()->id));
|
||||
|
||||
return $result;
|
||||
|
||||
@@ -71,12 +71,13 @@ function assignment_delete_instance($id){
|
||||
$result = false;
|
||||
}
|
||||
|
||||
grade_update('mod/assignment', $assignment->course, 'mod', 'assignment', $assignment->id, 0, NULL, array('deleted'=>1));
|
||||
|
||||
// We must delete the module record after we delete the grade item.
|
||||
if (! $DB->delete_records('assignment', array('id'=>$assignment->id))) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
grade_update('mod/assignment', $assignment->course, 'mod', 'assignment', $assignment->id, 0, NULL, array('deleted'=>1));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -1153,12 +1153,13 @@ function data_delete_instance($id) { // takes the dataid
|
||||
$event->delete();
|
||||
}
|
||||
|
||||
// Delete the instance itself
|
||||
$result = $DB->delete_records('data', array('id'=>$id));
|
||||
|
||||
// cleanup gradebook
|
||||
data_grade_item_delete($data);
|
||||
|
||||
// Delete the instance itself
|
||||
// We must delete the module record after we delete the grade item.
|
||||
$result = $DB->delete_records('data', array('id'=>$id));
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -305,12 +305,13 @@ function forum_delete_instance($id) {
|
||||
|
||||
forum_tp_delete_read_records(-1, -1, -1, $forum->id);
|
||||
|
||||
forum_grade_item_delete($forum);
|
||||
|
||||
// We must delete the module record after we delete the grade item.
|
||||
if (!$DB->delete_records('forum', array('id'=>$forum->id))) {
|
||||
$result = false;
|
||||
}
|
||||
|
||||
forum_grade_item_delete($forum);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1642,6 +1642,9 @@ class lesson extends lesson_base {
|
||||
|
||||
$this->delete_all_overrides();
|
||||
|
||||
grade_update('mod/lesson', $this->properties->course, 'mod', 'lesson', $this->properties->id, 0, null, array('deleted'=>1));
|
||||
|
||||
// We must delete the module record after we delete the grade item.
|
||||
$DB->delete_records("lesson", array("id"=>$this->properties->id));
|
||||
$DB->delete_records("lesson_pages", array("lessonid"=>$this->properties->id));
|
||||
$DB->delete_records("lesson_answers", array("lessonid"=>$this->properties->id));
|
||||
@@ -1662,7 +1665,6 @@ class lesson extends lesson_base {
|
||||
$fs = get_file_storage();
|
||||
$fs->delete_area_files($context->id);
|
||||
|
||||
grade_update('mod/lesson', $this->properties->course, 'mod', 'lesson', $this->properties->id, 0, null, array('deleted'=>1));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@ function lti_delete_instance($id) {
|
||||
$cm = get_coursemodule_from_instance('lti', $id);
|
||||
\core_completion\api::update_completion_date_event($cm->id, 'lti', $id, null);
|
||||
|
||||
// We must delete the module record after we delete the grade item.
|
||||
return $DB->delete_records("lti", array("id" => $basiclti->id));
|
||||
}
|
||||
|
||||
|
||||
@@ -203,6 +203,7 @@ function quiz_delete_instance($id) {
|
||||
}
|
||||
|
||||
quiz_grade_item_delete($quiz);
|
||||
// We must delete the module record after we delete the grade item.
|
||||
$DB->delete_records('quiz', array('id' => $quiz->id));
|
||||
|
||||
return true;
|
||||
|
||||
+4
-2
@@ -301,6 +301,10 @@ function scorm_delete_instance($id) {
|
||||
}
|
||||
$DB->delete_records('scorm_scoes', array('scorm' => $scorm->id));
|
||||
}
|
||||
|
||||
scorm_grade_item_delete($scorm);
|
||||
|
||||
// We must delete the module record after we delete the grade item.
|
||||
if (! $DB->delete_records('scorm', array('id' => $scorm->id))) {
|
||||
$result = false;
|
||||
}
|
||||
@@ -327,8 +331,6 @@ function scorm_delete_instance($id) {
|
||||
$result = false;
|
||||
}*/
|
||||
|
||||
scorm_grade_item_delete($scorm);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@@ -290,13 +290,14 @@ function workshop_delete_instance($id) {
|
||||
$event->delete();
|
||||
}
|
||||
|
||||
// finally remove the workshop record itself
|
||||
$DB->delete_records('workshop', array('id' => $workshop->id));
|
||||
|
||||
// gradebook cleanup
|
||||
grade_update('mod/workshop', $workshop->course, 'mod', 'workshop', $workshop->id, 0, null, array('deleted' => true));
|
||||
grade_update('mod/workshop', $workshop->course, 'mod', 'workshop', $workshop->id, 1, null, array('deleted' => true));
|
||||
|
||||
// finally remove the workshop record itself
|
||||
// We must delete the module record after we delete the grade item.
|
||||
$DB->delete_records('workshop', array('id' => $workshop->id));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user