<commit_before>class Portal::ClazzesController < ApplicationController
  # GET /portal_clazzes
  # GET /portal_clazzes.xml
  def index
    @portal_clazzes = Portal::Clazz.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @portal_clazzes }
    end
  end

  # GET /portal_clazzes/1
  # GET /portal_clazzes/1.xml
  def show
    @portal_clazz = Portal::Clazz.find(params[:id])
    @teacher = @portal_clazz.parent
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @portal_clazz }
    end
  end

  # GET /portal_clazzes/new
  # GET /portal_clazzes/new.xml
  def new
    @semesters = Portal::Semester.find(:all)
    @portal_clazz = Portal::Clazz.new
    if params[:teacher_id]
      @portal_clazz.teacher = Portal::Teacher.find(params[:teacher_id])
    elsif current_user.portal_teacher
      @portal_clazz.teacher = current_user.portal_teacher
    end
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @portal_clazz }
    end
  end

  # GET /portal_clazzes/1/edit
  def edit
    @portal_clazz = Portal::Clazz.find(params[:id])
    @semesters = Portal::Semester.find(:all)
    if request.xhr?
      render :partial => 'remote_form', :locals => { :portal_clazz => @portal_clazz }
    end
  end

  # POST /portal_clazzes
  # POST /portal_clazzes.xml
  def create
    @portal_clazz = Portal::Clazz.new(params[:portal_clazz])
    okToCreate = true
    if (! @portal_clazz.teacher)
      if current_user.anonymous?
        flash[:error] = "Anonymous can't create classes. Please log in and try again."
        okToCreate = false
      elsif current_user.portal_teacher
        @portal_clazz.teacher = current_user.portal_teacher
      else
        @portal_clazz.teacher = Portal::Teacher.create(:user_id => current_user.id)
        @portal_clazz.teacher.schools << Portal::School.find_by_name(APP_CONFIG['site_school'])
      end
    end
    respond_to do |format|
      if okToCreate && @portal_clazz.save
        flash[:notice] = 'Portal::Clazz was successfully created.'
        format.html { redirect_to(@portal_clazz) }
        format.xml  { render :xml => @portal_clazz, :status => :created, :location => @portal_clazz }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @portal_clazz.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /portal_clazzes/1
  # PUT /portal_clazzes/1.xml
  def update
    @portal_clazz = Portal::Clazz.find(params[:id])
    if request.xhr?
      @portal_clazz.update_attributes(params[:portal_clazz])
      render :partial => 'show', :locals => { :portal_clazz => @portal_clazz }
    else
      respond_to do |format|
        if @portal_clazz.update_attributes(params[:portal_portal_clazz])
          flash[:notice] = 'Portal::Clazz was successfully updated.'
          format.html { redirect_to(@portal_clazz) }
          format.xml  { head :ok }
        else
          format.html { render :action => "edit" }
          format.xml  { render :xml => @portal_clazz.errors, :status => :unprocessable_entity }
        end<commit_msg>Use colon notation instead of strings.<commit_after>class Portal::ClazzesController < ApplicationController
  # GET /portal_clazzes
  # GET /portal_clazzes.xml
  def index
    @portal_clazzes = Portal::Clazz.all

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @portal_clazzes }
    end
  end

  # GET /portal_clazzes/1
  # GET /portal_clazzes/1.xml
  def show
    @portal_clazz = Portal::Clazz.find(params[:id])
    @teacher = @portal_clazz.parent
    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @portal_clazz }
    end
  end

  # GET /portal_clazzes/new
  # GET /portal_clazzes/new.xml
  def new
    @semesters = Portal::Semester.find(:all)
    @portal_clazz = Portal::Clazz.new
    if params[:teacher_id]
      @portal_clazz.teacher = Portal::Teacher.find(params[:teacher_id])
    elsif current_user.portal_teacher
      @portal_clazz.teacher = current_user.portal_teacher
    end
    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @portal_clazz }
    end
  end

  # GET /portal_clazzes/1/edit
  def edit
    @portal_clazz = Portal::Clazz.find(params[:id])
    @semesters = Portal::Semester.find(:all)
    if request.xhr?
      render :partial => 'remote_form', :locals => { :portal_clazz => @portal_clazz }
    end
  end

  # POST /portal_clazzes
  # POST /portal_clazzes.xml
  def create
    @portal_clazz = Portal::Clazz.new(params[:portal_clazz])
    okToCreate = true
    if (! @portal_clazz.teacher)
      if current_user.anonymous?
        flash[:error] = "Anonymous can't create classes. Please log in and try again."
        okToCreate = false
      elsif current_user.portal_teacher
        @portal_clazz.teacher = current_user.portal_teacher
      else
        @portal_clazz.teacher = Portal::Teacher.create(:user_id => current_user.id)
        @portal_clazz.teacher.schools << Portal::School.find_by_name(APP_CONFIG[:site_school])
      end
    end
    respond_to do |format|
      if okToCreate && @portal_clazz.save
        flash[:notice] = 'Portal::Clazz was successfully created.'
        format.html { redirect_to(@portal_clazz) }
        format.xml  { render :xml => @portal_clazz, :status => :created, :location => @portal_clazz }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @portal_clazz.errors, :status => :unprocessable_entity }
      end
    end
  end

  # PUT /portal_clazzes/1
  # PUT /portal_clazzes/1.xml
  def update
    @portal_clazz = Portal::Clazz.find(params[:id])
    if request.xhr?
      @portal_clazz.update_attributes(params[:portal_clazz])
      render :partial => 'show', :locals => { :portal_clazz => @portal_clazz }
    else
      respond_to do |format|
        if @portal_clazz.update_attributes(params[:portal_portal_clazz])
          flash[:notice] = 'Portal::Clazz was successfully updated.'
          format.html { redirect_to(@portal_clazz) }
          format.xml  { head :ok }
        else
          format.html { render :action => "edit" }
          format.xml  { render :xml => @portal_clazz.errors, :status => :unprocessable_entity }
        end
{'fraction_non_alphanumeric': 0.11540880503144654, 'fraction_numerical': 0.0015723270440251573, 'mean_word_length': 2.9435833849969, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 36}, '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': '1359380', 'n_tokens_mistral': 2148, 'n_tokens_neox': 2213, 'n_words': 424}