<commit_before># frozen_string_literal: true
json.course do
  user_role = current_user&.role(@course) || CoursesUsers::Roles::VISITOR_ROLE

  json.call(@course, :id, :title, :description, :start, :end, :school,
            :subject, :slug, :url, :submitted, :expected_students, :timeline_start,
            :timeline_end, :day_exceptions, :weekdays, :no_day_exceptions,
            :updated_at, :string_prefix, :use_start_and_end_times, :type,
            :home_wiki, :upload_count, :uploads_in_use_count, :upload_usages_count)

  json.term @course.cloned_status == 1 ? '' : @course.term
  json.cloned_status @course.cloned_status
  json.legacy @course.legacy?
  json.ended !current?(@course) && @course.start < Time.zone.now
  json.published CohortsCourses.exists?(course_id: @course.id)
  json.enroll_url "#{request.base_url}#{course_slug_path(@course.slug)}/enroll/"

  json.created_count number_to_human @course.new_article_count
  json.edited_count number_to_human @course.article_count
  json.edit_count number_to_human @course.revision_count
  json.student_count @course.user_count
  json.trained_count @course.trained_count
  json.word_count number_to_human @course.word_count
  json.view_count number_to_human @course.view_sum
  json.syllabus @course.syllabus.url if @course.syllabus.file?

  if user_role.zero? # student role
    ctpm = CourseTrainingProgressManager.new(current_user, @course)
    json.incomplete_assigned_modules ctpm.incomplete_assigned_modules
  end

  if user_role >= 0 # user enrolled in course
    json.survey_notifications(current_user.survey_notifications.active) do |notification|
      if notification.course.id == @course.id
        json.id notification.id
        json.survey_url course_survey_url(notification).to_s
        json.message notification.survey_assignment.custom_banner_message
      end
    end
  end

  if user_role.positive? # non-student role
    json.passcode @course.passcode
    json.canUploadSyllabus true
  elsif @course.passcode
    json.passcode '****'
    json.canUploadSyllabus false
  end
end
<commit_msg>Hotfix workaround for errors in banner messages<commit_after># frozen_string_literal: true
json.course do
  user_role = current_user&.role(@course) || CoursesUsers::Roles::VISITOR_ROLE

  json.call(@course, :id, :title, :description, :start, :end, :school,
            :subject, :slug, :url, :submitted, :expected_students, :timeline_start,
            :timeline_end, :day_exceptions, :weekdays, :no_day_exceptions,
            :updated_at, :string_prefix, :use_start_and_end_times, :type,
            :home_wiki, :upload_count, :uploads_in_use_count, :upload_usages_count)

  json.term @course.cloned_status == 1 ? '' : @course.term
  json.cloned_status @course.cloned_status
  json.legacy @course.legacy?
  json.ended !current?(@course) && @course.start < Time.zone.now
  json.published CohortsCourses.exists?(course_id: @course.id)
  json.enroll_url "#{request.base_url}#{course_slug_path(@course.slug)}/enroll/"

  json.created_count number_to_human @course.new_article_count
  json.edited_count number_to_human @course.article_count
  json.edit_count number_to_human @course.revision_count
  json.student_count @course.user_count
  json.trained_count @course.trained_count
  json.word_count number_to_human @course.word_count
  json.view_count number_to_human @course.view_sum
  json.syllabus @course.syllabus.url if @course.syllabus.file?

  if user_role.zero? # student role
    ctpm = CourseTrainingProgressManager.new(current_user, @course)
    json.incomplete_assigned_modules ctpm.incomplete_assigned_modules
  end

  if user_role >= 0 # user enrolled in course
    json.survey_notifications(current_user.survey_notifications.active) do |notification|
      if notification.course.id == @course.id
        json.id notification.id
        json.survey_url course_survey_url(notification).to_s
        # json.message notification.survey_assignment.custom_banner_message
      end
    end
  end

  if user_role.positive? # non-student role
    json.passcode @course.passcode
    json.canUploadSyllabus true
  elsif @course.passcode
    json.passcode '****'
    json.canUploadSyllabus false
  end
end

{'fraction_non_alphanumeric': 0.09980852082336046, 'fraction_numerical': 0.0009573958831977022, 'mean_word_length': 4.601876675603217, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '3853970', 'n_tokens_mistral': 1417, 'n_tokens_neox': 1392, 'n_words': 246}