Esempio n. 1
0
 /**
  * If parent::delete() is successful, send force_regrading message to parent category.
  *
  * @param string $source from where was the object deleted (mod/forum, manual, etc.)
  * @return bool success
  */
 public function delete($source = null)
 {
     $grade_item = $this->load_grade_item();
     if ($this->is_course_category()) {
         if ($categories = grade_category::fetch_all(array('courseid' => $this->courseid))) {
             foreach ($categories as $category) {
                 if ($category->id == $this->id) {
                     continue;
                     // do not delete course category yet
                 }
                 $category->delete($source);
             }
         }
         if ($items = grade_item::fetch_all(array('courseid' => $this->courseid))) {
             foreach ($items as $item) {
                 if ($item->id == $grade_item->id) {
                     continue;
                     // do not delete course item yet
                 }
                 $item->delete($source);
             }
         }
     } else {
         $this->force_regrading();
         $parent = $this->load_parent_category();
         // Update children's categoryid/parent field first
         if ($children = grade_item::fetch_all(array('categoryid' => $this->id))) {
             foreach ($children as $child) {
                 $child->set_parent($parent->id);
             }
         }
         if ($children = grade_category::fetch_all(array('parent' => $this->id))) {
             foreach ($children as $child) {
                 $child->set_parent($parent->id);
             }
         }
     }
     // first delete the attached grade item and grades
     $grade_item->delete($source);
     // delete category itself
     return parent::delete($source);
 }
Esempio n. 2
0
 /**
  * Delete all grades and force_regrading of parent category.
  * @param string $source from where was the object deleted (mod/forum, manual, etc.)
  * @return boolean success
  */
 function delete($source = null)
 {
     $this->delete_all_grades($source);
     return parent::delete($source);
 }
 /**
  * Deletes this outcome from the database.
  * @param string $source from where was the object deleted (mod/forum, manual, etc.)
  * @return boolean success
  */
 function delete($source = null)
 {
     if (!empty($this->courseid)) {
         delete_records('grade_outcomes_courses', 'outcomeid', $this->id, 'courseid', $this->courseid);
     }
     return parent::delete($source);
 }
Esempio n. 4
0
 /**
  * Deletes the grade_grade instance from the database.
  *
  * @param string $source The location the deletion occurred (mod/forum, manual, etc.).
  * @return bool Returns true if the deletion was successful, false otherwise.
  */
 public function delete($source = null)
 {
     $success = parent::delete($source);
     // If the grade was deleted successfully trigger a grade_deleted event.
     if ($success) {
         $this->load_grade_item();
         \core\event\grade_deleted::create_from_grade($this)->trigger();
     }
     return $success;
 }
Esempio n. 5
0
 /**
  * Deletes this outcome from the database.
  *
  * @param string $source from where was the object deleted (mod/forum, manual, etc.)
  * @return bool success
  */
 public function delete($source = null)
 {
     global $DB;
     if (!empty($this->courseid)) {
         $DB->delete_records('grade_outcomes_courses', array('outcomeid' => $this->id, 'courseid' => $this->courseid));
     }
     if (parent::delete($source)) {
         $context = context_system::instance();
         $fs = get_file_storage();
         $files = $fs->get_area_files($context->id, 'grade', 'outcome', $this->id);
         foreach ($files as $file) {
             $file->delete();
         }
         return true;
     }
     return false;
 }
Esempio n. 6
0
 /**
  * Delete all grades and force_regrading of parent category.
  * @param string $source from where was the object deleted (mod/forum, manual, etc.)
  * @return boolean success
  */
 function delete($source = null)
 {
     if (!$this->is_course_item()) {
         $this->force_regrading();
     }
     if ($grades = grade_grade::fetch_all(array('itemid' => $this->id))) {
         foreach ($grades as $grade) {
             $grade->delete($source);
         }
     }
     return parent::delete($source);
 }
Esempio n. 7
0
 /**
  * Deletes this outcome from the database.
  * @param string $source from where was the object deleted (mod/forum, manual, etc.)
  * @return boolean success
  */
 public function delete($source = null)
 {
     global $DB;
     if (!empty($this->courseid)) {
         $DB->delete_records('grade_outcomes_courses', array('outcomeid' => $this->id, 'courseid' => $this->courseid));
     }
     return parent::delete($source);
 }
Esempio n. 8
0
 /**
  * Deletes this outcome from the database.
  *
  * @param string $source from where was the object deleted (mod/forum, manual, etc.)
  * @return bool success
  */
 public function delete($source = null)
 {
     global $DB;
     if (parent::delete($source)) {
         $context = context_system::instance();
         $fs = get_file_storage();
         $files = $fs->get_area_files($context->id, 'grade', 'scale', $this->id);
         foreach ($files as $file) {
             $file->delete();
         }
         return true;
     }
     return false;
 }