original_string: public static function remove_all_subscriptions_in_course($coursecontext) {
          global $DB;
  
          // Store all the subscriptions we have to delete.
          if ($subscriptions = $DB->get_records('tool_monitor_subscriptions', ['courseid' => $coursecontext->instanceid])) {
              // Delete subscriptions in bulk.
              $DB->delete_records('tool_monitor_subscriptions', ['courseid' => $coursecontext->instanceid]);
  
              // Trigger events one by one.
              foreach ($subscriptions as $subscription) {
                  $params = ['objectid' => $subscription->id, 'context' => $coursecontext];
                  $event = \tool_monitor\event\subscription_deleted::create($params);
                  $event->add_record_snapshot('tool_monitor_subscriptions', $subscription);
                  $event->trigger();
              }
          }
      }
code: public static function remove_all_subscriptions_in_course($coursecontext) {
          global $DB;
  
          // Store all the subscriptions we have to delete.
          if ($subscriptions = $DB->get_records('tool_monitor_subscriptions', ['courseid' => $coursecontext->instanceid])) {
              // Delete subscriptions in bulk.
              $DB->delete_records('tool_monitor_subscriptions', ['courseid' => $coursecontext->instanceid]);
  
              // Trigger events one by one.
              foreach ($subscriptions as $subscription) {
                  $params = ['objectid' => $subscription->id, 'context' => $coursecontext];
                  $event = \tool_monitor\event\subscription_deleted::create($params);
                  $event->add_record_snapshot('tool_monitor_subscriptions', $subscription);
                  $event->trigger();
              }
          }
      }
code_tokens: public static function remove_all_subscriptions_in_course ( $ coursecontext ) { global $ DB ; // Store all the subscriptions we have to delete. if ( $ subscriptions = $ DB -> get_records ( 'tool_monitor_subscriptions' , [ 'courseid' => $ coursecontext -> instanceid ] ) ) { // Delete subscriptions in bulk. $ DB -> delete_records ( 'tool_monitor_subscriptions' , [ 'courseid' => $ coursecontext -> instanceid ] ) ; // Trigger events one by one. foreach ( $ subscriptions as $ subscription ) { $ params = [ 'objectid' => $ subscription -> id , 'context' => $ coursecontext ] ; $ event = \ tool_monitor \ event \ subscription_deleted :: create ( $ params ) ; $ event -> add_record_snapshot ( 'tool_monitor_subscriptions' , $ subscription ) ; $ event -> trigger ( ) ; } } }
docstring: Delete all subscriptions in a course.
  
  This is called after a course was deleted, context no longer exists but we kept the object
  
  @param \context_course $coursecontext the context of the course
docstring_tokens: Delete all subscriptions in a course .