<commit_before>class ParticipantsController < ApplicationController
  auto_complete_for :user, :name
  
  def list
    @root_node = Object.const_get(params[:model]+"Node").find_by_node_object_id(params[:id])     
    @parent = Object.const_get(params[:model]).find(params[:id])
    @participants = @parent.get_participants  
    @model = params[:model]    
  end
  
  def add    
    curr_object = Object.const_get(params[:model]).find(params[:id])    
    begin
      curr_object.add_participant(params[:user][:name])
    rescue
      flash[:error] = $!
    end
    redirect_to :action => 'list', :id => curr_object.id, :model => params[:model]
  end
    
  def delete
    participant = Participant.find(params[:id])
    parent_id = participant.parent_id
    if participant.type.to_s == 'AssignmentParticipant'
      model = 'Assignment'
    else
      model = 'Course'
    end
    participant.delete
    redirect_to :action => 'list', :id => parent_id, :model => model
  end
  
 # Copies existing participants from a course down to an assignment
 def inherit
   assignment = Assignment.find(params[:id])
   if assignment.course_id > 0
    course = Course.find(assignment.course_id)
    participants = course.get_participants
    if participants.length > 0 
      participants.each{
        |participant|
        participant.copy(assignment.id)
      }
    else
      flash[:note] = "No participants were found to inherit."
    end
   else
     flash[:error] = "No course was found for this assignment."<commit_msg>Remove deprecated call<commit_after>class ParticipantsController < ApplicationController
  auto_complete_for :user, :name
  
  def list
    @root_node = Object.const_get(params[:model]+"Node").find_by_node_object_id(params[:id])     
    @parent = Object.const_get(params[:model]).find(params[:id])
    @participants = @parent.get_participants  
    @model = params[:model]    
  end
  
  def add    
    curr_object = Object.const_get(params[:model]).find(params[:id])    
    begin
      curr_object.add_participant(params[:user][:name])
    rescue
      flash[:error] = $!
    end
    redirect_to :action => 'list', :id => curr_object.id, :model => params[:model]
  end
    
  def delete
    participant = Participant.find(params[:id])
    parent_id = participant.parent_id
    if participant.class == AssignmentParticipant
      model = 'Assignment'
    else
      model = 'Course'
    end
    participant.delete
    redirect_to :action => 'list', :id => parent_id, :model => model
  end
  
 # Copies existing participants from a course down to an assignment
 def inherit
   assignment = Assignment.find(params[:id])
   if assignment.course_id > 0
    course = Course.find(assignment.course_id)
    participants = course.get_participants
    if participants.length > 0 
      participants.each{
        |participant|
        participant.copy(assignment.id)
      }
    else
      flash[:note] = "No participants were found to inherit."
    end
   else
     flash[:error] = "No course was found for this assignment."
{'fraction_non_alphanumeric': 0.11037891268533773, 'fraction_numerical': 0.0013179571663920922, 'mean_word_length': 3.1933701657458564, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '5096233', 'n_tokens_mistral': 915, 'n_tokens_neox': 910, 'n_words': 207}