<commit_before># frozen_string_literal: true
class Course::AnnouncementsController < Course::ComponentController
  load_and_authorize_resource :announcement, through: :course, class: Course::Announcement.name
  before_action :add_announcement_breadcrumb
  after_action :mark_announcements_as_read, only: :index

  def index # :nodoc:
    @announcements = @announcements.includes(:creator).sorted_by_sticky.sorted_by_date
    @announcements = @announcements.page(page_param).with_read_marks_for(current_user)
  end

  def show # :nodoc:
  end

  def new # :nodoc:
  end

  def create # :nodoc:
    if @announcement.save
      # Return all announcements for re-rendering ordering purposes
      redirect_to course_announcements_path(current_course)
    else
      render json: { errors: @announcement.errors }, status: :bad_request
    end
  end

  def edit # :nodoc:
  end

  def update # :nodoc:
    if @announcement.update(announcement_params)
      render partial: 'course/announcements/announcement_list_data',
             locals: { announcement: @announcement },
             status: :ok<commit_msg>fix(announcements): fix isUnread being overwritten<commit_after># frozen_string_literal: true
class Course::AnnouncementsController < Course::ComponentController
  load_and_authorize_resource :announcement, through: :course, class: Course::Announcement.name
  before_action :add_announcement_breadcrumb

  def index # :nodoc:
    respond_to do |format|
      format.html
      format.json do
        @announcements = @announcements.includes(:creator).sorted_by_sticky.sorted_by_date
        @announcements = @announcements.page(page_param).with_read_marks_for(current_user)
        mark_announcements_as_read
      end
    end
  end

  def show # :nodoc:
  end

  def new # :nodoc:
  end

  def create # :nodoc:
    if @announcement.save
      # Return all announcements for re-rendering ordering purposes
      redirect_to course_announcements_path(current_course)
    else
      render json: { errors: @announcement.errors }, status: :bad_request
    end
  end

  def edit # :nodoc:
  end

  def update # :nodoc:
    if @announcement.update(announcement_params)
      render partial: 'course/announcements/announcement_list_data',
             locals: { announcement: @announcement },
             status: :ok
{'fraction_non_alphanumeric': 0.0816414686825054, 'fraction_numerical': 0.0, 'mean_word_length': 3.9699570815450644, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6588', 'n_tokens_mistral': 730, 'n_tokens_neox': 717, 'n_words': 156}