original_string: protected static function delete_stats(int $courseid, int $userid = null) {
          global $DB;
          $params = (isset($userid)) ? ['courseid' => $courseid, 'userid' => $userid] : ['courseid' => $courseid];
          $DB->delete_records('stats_user_daily', $params);
          $DB->delete_records('stats_user_weekly', $params);
          $DB->delete_records('stats_user_monthly', $params);
      }
code: protected static function delete_stats(int $courseid, int $userid = null) {
          global $DB;
          $params = (isset($userid)) ? ['courseid' => $courseid, 'userid' => $userid] : ['courseid' => $courseid];
          $DB->delete_records('stats_user_daily', $params);
          $DB->delete_records('stats_user_weekly', $params);
          $DB->delete_records('stats_user_monthly', $params);
      }
code_tokens: protected static function delete_stats ( int $ courseid , int $ userid = null ) { global $ DB ; $ params = ( isset ( $ userid ) ) ? [ 'courseid' => $ courseid , 'userid' => $ userid ] : [ 'courseid' => $ courseid ] ; $ DB -> delete_records ( 'stats_user_daily' , $ params ) ; $ DB -> delete_records ( 'stats_user_weekly' , $ params ) ; $ DB -> delete_records ( 'stats_user_monthly' , $ params ) ; }
docstring: Deletes stats for a given course.
  
  @param int $courseid The course ID to delete the stats for.
  @param int $userid Optionally a user id to delete records with.
docstring_tokens: Deletes stats for a given course .