<commit_before>class LessonPlanEntriesController < ApplicationController
  load_and_authorize_resource :course
  load_and_authorize_resource :lesson_plan_entry, through: :course

  before_filter :load_general_course_data, :only => [:index, :new, :edit, :overview]

  def index
    @milestones = get_milestones_for_course(@course)
  end

  def new
    @start_at = params[:start_at]
    @end_at = params[:end_at]

    @start_at = (DateTime.strptime(@start_at, '%d-%m-%Y') unless @start_at.empty?)
    @end_at = (DateTime.strptime(@end_at, '%d-%m-%Y') unless @end_at.empty?)
  end

  def create
    @lesson_plan_entry.creator = current_user
    @lesson_plan_entry.resources = if params[:resources] then
                                     build_resources(params[:resources])
                                   else
                                     []
                                   end
    
    respond_to do |format|
      if @lesson_plan_entry.save then
        path = course_lesson_plan_path(@course) + "#entry-" + @lesson_plan_entry.id.to_s
        format.html { redirect_to path,
                      notice: "The lesson plan entry #{@lesson_plan_entry.title} has been created." }
      else
        format.html { render action: "new" }
      end
    end
  end

  def edit
  end

  def update
    @lesson_plan_entry.resources = if params[:resources] then
                                     build_resources(params[:resources])
                                   else<commit_msg>fix can't create lesson plan<commit_after>class LessonPlanEntriesController < ApplicationController
  load_and_authorize_resource :course
  load_and_authorize_resource :lesson_plan_entry, through: :course

  before_filter :load_general_course_data, :only => [:index, :new, :edit, :overview]

  def index
    @milestones = get_milestones_for_course(@course)
  end

  def new
    @start_at = params[:start_at] || ""
    @end_at = params[:end_at] || ""

    @start_at = (DateTime.strptime(@start_at, '%d-%m-%Y') unless @start_at.empty?)
    @end_at = (DateTime.strptime(@end_at, '%d-%m-%Y') unless @end_at.empty?)
  end

  def create
    @lesson_plan_entry.creator = current_user
    @lesson_plan_entry.resources = if params[:resources] then
                                     build_resources(params[:resources])
                                   else
                                     []
                                   end
    
    respond_to do |format|
      if @lesson_plan_entry.save then
        path = course_lesson_plan_path(@course) + "#entry-" + @lesson_plan_entry.id.to_s
        format.html { redirect_to path,
                      notice: "The lesson plan entry #{@lesson_plan_entry.title} has been created." }
      else
        format.html { render action: "new" }
      end
    end
  end

  def edit
  end

  def update
    @lesson_plan_entry.resources = if params[:resources] then
                                     build_resources(params[:resources])
                                   else
{'fraction_non_alphanumeric': 0.09538052509139248, 'fraction_numerical': 0.0, 'mean_word_length': 2.093525179856115, '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': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6098714', 'n_tokens_mistral': 901, 'n_tokens_neox': 863, 'n_words': 183}