<commit_before>require 'grape'

module Api
  class TeachingPeriods < Grape::API
    helpers AuthenticationHelpers
    helpers AuthorisationHelpers

    before do
      authenticated?
    end

    desc 'Add a Teaching Period'
    params do
      requires :teaching_period, type: Hash do
        optional :period, type: String, desc: 'The name of the teaching period'
        optional :start_date, type: Date, desc: 'The start date of the teaching period'
        optional :end_date, type: Date, desc: 'The end date of the teaching period'
      end
    end
    post '/teaching_periods' do
      unless authorise? current_user, User, :handle_teaching_period
        error!({ error: 'Not authorised to create a teaching period' }, 403)
      end
      teaching_period_parameters = ActionController::Parameters.new(params)
                                                               .require(:teaching_period)
                                                               .permit(:period,<commit_msg>NEW: Add year to Add teaching period<commit_after>require 'grape'

module Api
  class TeachingPeriods < Grape::API
    helpers AuthenticationHelpers
    helpers AuthorisationHelpers

    before do
      authenticated?
    end

    desc 'Add a Teaching Period'
    params do
      requires :teaching_period, type: Hash do
        optional :period, type: String, desc: 'The name of the teaching period'
        optional :year, type: Integer, desc: 'The year of the teaching period'
        optional :start_date, type: Date, desc: 'The start date of the teaching period'
        optional :end_date, type: Date, desc: 'The end date of the teaching period'
      end
    end
    post '/teaching_periods' do
      unless authorise? current_user, User, :handle_teaching_period
        error!({ error: 'Not authorised to create a teaching period' }, 403)
      end
      teaching_period_parameters = ActionController::Parameters.new(params)
                                                               .require(:teaching_period)
                                                               .permit(:period,
                                                                       :year,
{'fraction_non_alphanumeric': 0.06422018348623854, 'fraction_numerical': 0.0027522935779816515, 'mean_word_length': 1.9235924932975872, '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': 11, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2944525', 'n_tokens_mistral': 526, 'n_tokens_neox': 515, 'n_words': 191}