<commit_before>class ReviewMappingController < ApplicationController
  #include GC4R
  autocomplete :user, :name
  #use_google_charts
  require 'gchart'
  #helper :dynamic_review_assignment
  helper :submitted_content

  def action_allowed?
    case params[:action]
    when 'add_dynamic_reviewer', 'release_reservation', 'show_available_submissions', 'assign_reviewer_dynamically', 'assign_metareviewer_dynamically', 'add_quiz_response_map', 'assign_quiz_dynamically'
      true
    else
      ['Instructor',
       'Teaching Assistant',
       'Administrator'].include? current_role_name
    end
  end

  def add_calibration
    participant = AssignmentParticipant.where(parent_id: params[:id], user_id: session[:user].id).first rescue nil
    if participant.nil?
      participant = AssignmentParticipant.create(parent_id: params[:id], user_id: session[:user].id, can_submit: 1, can_review: 1, can_take_quiz: 1)
    end
    map = ReviewResponseMap.where(reviewed_object_id: params[:id], reviewer_id: instructor.id, reviewee_id: team.id, calibrate_to: true).first rescue nil
    if !map
      map = ReviewResponseMap.create(reviewed_object_id: params[:id], reviewer_id: participant.id, reviewee_id: params[:team_id], calibrate_to: true)
    end
    redirect_to controller: 'response', action: 'new', id: map.id, assignment_id: params[:id], return: 'assignment_edit'
  end

  def auto_complete_for_user_name
    name = params[:user][:name]+"%"
    assignment_id = session[:contributor].parent_id
    @users = User.join(:participants)
      .where( ['participants.type = "AssignmentParticipant" and users.name like ? and participants.parent_id = ?',name,assignment_id])
      .order ('name')

    render :inline => "<%= auto_complete_result @users, 'name' %>", :layout => false
  end

  def select_reviewer
    assignment = Assignment.find(params[:id])
    @contributor = assignment.get_contributor(params[:contributor_id])
    session[:contributor] = @contributor<commit_msg>Fix calibration: create participant when instructor is not.<commit_after>class ReviewMappingController < ApplicationController
  #include GC4R
  autocomplete :user, :name
  #use_google_charts
  require 'gchart'
  #helper :dynamic_review_assignment
  helper :submitted_content

  def action_allowed?
    case params[:action]
    when 'add_dynamic_reviewer', 'release_reservation', 'show_available_submissions', 'assign_reviewer_dynamically', 'assign_metareviewer_dynamically', 'add_quiz_response_map', 'assign_quiz_dynamically'
      true
    else
      ['Instructor',
       'Teaching Assistant',
       'Administrator'].include? current_role_name
    end
  end

  def add_calibration
    participant = AssignmentParticipant.where(parent_id: params[:id], user_id: session[:user].id).first rescue nil
    if participant.nil?
      participant = AssignmentParticipant.create(parent_id: params[:id], user_id: session[:user].id, can_submit: 1, can_review: 1, can_take_quiz: 1, handle: 'handle')
    end
    map = ReviewResponseMap.where(reviewed_object_id: params[:id], reviewer_id: instructor.id, reviewee_id: team.id, calibrate_to: true).first rescue nil
    if !map
      map = ReviewResponseMap.create(reviewed_object_id: params[:id], reviewer_id: participant.id, reviewee_id: params[:team_id], calibrate_to: true)
    end
    redirect_to controller: 'response', action: 'new', id: map.id, assignment_id: params[:id], return: 'assignment_edit'
  end

  def auto_complete_for_user_name
    name = params[:user][:name]+"%"
    assignment_id = session[:contributor].parent_id
    @users = User.join(:participants)
      .where( ['participants.type = "AssignmentParticipant" and users.name like ? and participants.parent_id = ?',name,assignment_id])
      .order ('name')

    render :inline => "<%= auto_complete_result @users, 'name' %>", :layout => false
  end

  def select_reviewer
    assignment = Assignment.find(params[:id])
    @contributor = assignment.get_contributor(params[:contributor_id])
    session[:contributor] = @contributor
{'fraction_non_alphanumeric': 0.11354581673306773, 'fraction_numerical': 0.00199203187250996, 'mean_word_length': 5.132824427480916, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, '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': '3303399', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1229, 'n_words': 266}