<commit_before>require 'task_serializer'

# Shallow serialization is used for student...
class ShallowProjectSerializer < ActiveModel::Serializer
  attributes :unit_id, :unit_code, :unit_name,
             :project_id, :student_name,
             :tutor_name, :target_grade,
             :has_portfolio, :start_date

  def project_id
    object.id
  end
end

class ProjectSerializer < ActiveModel::Serializer
  attributes :unit_id,
             :project_id,
             :student_id,
             :started,
             :stats,
             :student_name,
             :tutor_name,
             :tutorial_id,
             :burndown_chart_data,
             :enrolled,
             :target_grade,
             :portfolio_files,
             :compile_portfolio,
             :portfolio_available,
             :grade,
             :grade_rationale,
             :tasks

  def project_id<commit_msg>NEW: Expose teaching period to units study<commit_after>require 'task_serializer'

# Shallow serialization is used for student...
class ShallowProjectSerializer < ActiveModel::Serializer
  attributes :unit_id, :unit_code, :unit_name,
             :project_id, :student_name,
             :tutor_name, :target_grade,
             :has_portfolio, :start_date, :teaching_period

  def project_id
    object.id
  end

  def teaching_period
    if object.unit.teaching_period_id.present?
      teachingPeriod = TeachingPeriod.find(object.unit.teaching_period_id)
      ::TeachingPeriodSerializer.new(teachingPeriod).attributes
    end
  end
end

class ProjectSerializer < ActiveModel::Serializer
  attributes :unit_id,
             :project_id,
             :student_id,
             :started,
             :stats,
             :student_name,
             :tutor_name,
             :tutorial_id,
             :burndown_chart_data,
             :enrolled,
             :target_grade,
             :portfolio_files,
             :compile_portfolio,
             :portfolio_available,
             :grade,
             :grade_rationale,
             :tasks

  def project_id
{'fraction_non_alphanumeric': 0.07322987390882638, 'fraction_numerical': 0.0, 'mean_word_length': 1.9855282199710564, 'pattern_counts': {'":': 0, '<': 7, '<?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': '393991', 'n_tokens_mistral': 584, 'n_tokens_neox': 567, 'n_words': 113}