<commit_before>class StudentsClassroomsController < ApplicationController

    def create
      @user = current_user
      classcode = params[:classcode]
      begin
        classroom = Classroom.where(code: classcode).first
        Associators::StudentsToClassrooms.run(@user, classroom)
        JoinClassroomWorker.perform_async(@user.id)
      rescue NoMethodError => exception
        if Classroom.unscoped.where(code: classcode).first.nil?
          render json: {error: "No such classcode"}, status: 400
        else
          render json: {error: "Class is archived"}, status: 400
        end
      else
        render json: classroom.attributes
      end
    end

    def hide
      sc = StudentsClassrooms.find(params[:id])
      sc.update(visible: false)
      render json: sc
    end

    def unhide
      sc = StudentsClassrooms.unscoped.find(params[:id])
      sc.update(visible: true)
      render json: sc
    end

    def teacher_hide
      row = StudentsClassrooms.where(student_id: params[:student_id], classroom_id: params[:classroom_id]).first
      row.update(visible: false)
      redirect_to teachers_classrooms_path<commit_msg>removes white space when student enters classcode<commit_after>class StudentsClassroomsController < ApplicationController

    def create
      @user = current_user
      classcode = params[:classcode].downcase.gsub(/\s+/, "")
      begin
        classroom = Classroom.where(code: classcode).first
        Associators::StudentsToClassrooms.run(@user, classroom)
        JoinClassroomWorker.perform_async(@user.id)
      rescue NoMethodError => exception
        if Classroom.unscoped.where(code: classcode).first.nil?
          render json: {error: "No such classcode"}, status: 400
        else
          render json: {error: "Class is archived"}, status: 400
        end
      else
        render json: classroom.attributes
      end
    end

    def hide
      sc = StudentsClassrooms.find(params[:id])
      sc.update(visible: false)
      render json: sc
    end

    def unhide
      sc = StudentsClassrooms.unscoped.find(params[:id])
      sc.update(visible: true)
      render json: sc
    end

    def teacher_hide
      row = StudentsClassrooms.where(student_id: params[:student_id], classroom_id: params[:classroom_id]).first
      row.update(visible: false)
      redirect_to teachers_classrooms_path
{'fraction_non_alphanumeric': 0.08844688954718578, 'fraction_numerical': 0.0050782903089293275, 'mean_word_length': 2.856443719412724, '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': '408333', 'n_tokens_mistral': 664, 'n_tokens_neox': 645, 'n_words': 159}