<commit_before>class PopupController < ApplicationController
  layout 'standard'
  def team_users_popup
  @maxscore = 0
  @sum = 0  
  @count = 0
  @teamid = params[:id]
  @team = Team.find(params[:id])
  @assignment = Assignment.find(@team.parent_id)
  @assignment_id = @assignment.id
#  @teamname = Team.find(params[:id]).name
  @teamusers = TeamsUser.find_all_by_team_id(params[:id])
  
  if(params[:id2] == nil)
#  if(@reviewid == nil)
    @scores = nil
  else
    @reviewid = (Response.find_by_map_id(params[:id2])).id
    @pid = ResponseMap.find(params[:id2]).reviewer_id
    @reviewer_id = Participant.find(@pid).user_id
    
    @scores = Score.find_all_by_response_id(@reviewid)

    ##3
    @revqids = AssignmentQuestionnaires.find(:all, :conditions => ["assignment_id = ?",@assignment.id])
    @revqids.each do |rqid|
      rtype = Questionnaire.find(rqid.questionnaire_id).type
      if( rtype == ReviewQuestionnaire)
        @review_questionnaire_id = rqid.questionnaire_id
      end
    end
    if(@review_questionnaire_id)
      @review_questionnaire = Questionnaire.find(@review_questionnaire_id)
      @maxscore = @review_questionnaire.max_question_score
      @review_questions = @review_questionnaire.questions
    end


    ###
   # @maxscore = Questionnaire.find(@assignment.review_questionnaire_id).max_question_score
    
    if(@maxscore == nil)
      @maxscore = 5
    end
    
    @scores.each do |s|
      @sum = @sum + s.score
      @s = @sum
      @count = @count + 1
    end
    @sum1 = (100*@sum.to_f )/(@maxscore.to_f * @count.to_f)
    
  end
  
#    @review_questionnaire = Questionnaire.find(@assignment.review_questionnaire_id)
#    @review_questions = @review_questionnaire.questions
    #@maxscore = @review_questionnaire.max_question_score
    
  
end


def participants_popup
  
  @sum = 0  
  @count = 0
  @participantid = params[:id]
  @uid = Participant.find(params[:id]).user_id
  @assignment_id =   Participant.find(params[:id]).parent_id
  @user = User.find(@uid)
  @myuser = @user.id
  @temp = 0;
  @maxscore = 0
  
  if(params[:id2] == nil)
    @scores = nil
    
  else
    @reviewid = (Response.find_by_map_id(params[:id2])).id
    @pid = ResponseMap.find(params[:id2]).reviewer_id
    @reviewer_id = Participant.find(@pid).user_id
    #@reviewer_id = ReviewMapping.find(params[:id2]).reviewer_id
    @assignment_id = ResponseMap.find(params[:id2]).reviewed_object_id
    @assignment = Assignment.find(@assignment_id)
    @participant = Participant.find(:first, :conditions => ["id = ? and parent_id = ? ", params[:id],@assignment_id])

    ##3
    @revqids = AssignmentQuestionnaires.find(:all, :conditions => ["assignment_id = ?",@assignment.id])
    @revqids.each do |rqid|
      rtype = Questionnaire.find(rqid.questionnaire_id).type
      if( rtype == ReviewQuestionnaire)
        @review_questionnaire_id = rqid.questionnaire_id
      end
    end
    if(@review_questionnaire_id)
      @review_questionnaire = Questionnaire.find(@review_questionnaire_id)
      @maxscore = @review_questionnaire.max_question_score
      @review_questions = @review_questionnaire.questions
    end


    ###



   # @maxscore = Questionnaire.find(@assignment.review_questionnaire_id).max_question_score
    
    @scores = Score.find_all_by_response_id(@reviewid)
    @scores.each do |s|<commit_msg>Corrected all instances of string comparison with a class constant.<commit_after>class PopupController < ApplicationController
  layout 'standard'
  def team_users_popup
  @maxscore = 0
  @sum = 0  
  @count = 0
  @teamid = params[:id]
  @team = Team.find(params[:id])
  @assignment = Assignment.find(@team.parent_id)
  @assignment_id = @assignment.id
#  @teamname = Team.find(params[:id]).name
  @teamusers = TeamsUser.find_all_by_team_id(params[:id])
  
  if(params[:id2] == nil)
#  if(@reviewid == nil)
    @scores = nil
  else
    @reviewid = (Response.find_by_map_id(params[:id2])).id
    @pid = ResponseMap.find(params[:id2]).reviewer_id
    @reviewer_id = Participant.find(@pid).user_id
    
    @scores = Score.find_all_by_response_id(@reviewid)

    ##3
    @revqids = AssignmentQuestionnaires.find(:all, :conditions => ["assignment_id = ?",@assignment.id])
    @revqids.each do |rqid|
      rtype = Questionnaire.find(rqid.questionnaire_id).type
      if( rtype == 'ReviewQuestionnaire')
        @review_questionnaire_id = rqid.questionnaire_id
      end
    end
    if(@review_questionnaire_id)
      @review_questionnaire = Questionnaire.find(@review_questionnaire_id)
      @maxscore = @review_questionnaire.max_question_score
      @review_questions = @review_questionnaire.questions
    end


    ###
   # @maxscore = Questionnaire.find(@assignment.review_questionnaire_id).max_question_score
    
    if(@maxscore == nil)
      @maxscore = 5
    end
    
    @scores.each do |s|
      @sum = @sum + s.score
      @s = @sum
      @count = @count + 1
    end
    @sum1 = (100*@sum.to_f )/(@maxscore.to_f * @count.to_f)
    
  end
  
#    @review_questionnaire = Questionnaire.find(@assignment.review_questionnaire_id)
#    @review_questions = @review_questionnaire.questions
    #@maxscore = @review_questionnaire.max_question_score
    
  
end


def participants_popup
  
  @sum = 0  
  @count = 0
  @participantid = params[:id]
  @uid = Participant.find(params[:id]).user_id
  @assignment_id =   Participant.find(params[:id]).parent_id
  @user = User.find(@uid)
  @myuser = @user.id
  @temp = 0;
  @maxscore = 0
  
  if(params[:id2] == nil)
    @scores = nil
    
  else
    @reviewid = (Response.find_by_map_id(params[:id2])).id
    @pid = ResponseMap.find(params[:id2]).reviewer_id
    @reviewer_id = Participant.find(@pid).user_id
    #@reviewer_id = ReviewMapping.find(params[:id2]).reviewer_id
    @assignment_id = ResponseMap.find(params[:id2]).reviewed_object_id
    @assignment = Assignment.find(@assignment_id)
    @participant = Participant.find(:first, :conditions => ["id = ? and parent_id = ? ", params[:id],@assignment_id])

    ##3
    @revqids = AssignmentQuestionnaires.find(:all, :conditions => ["assignment_id = ?",@assignment.id])
    @revqids.each do |rqid|
      rtype = Questionnaire.find(rqid.questionnaire_id).type
      if( rtype == 'ReviewQuestionnaire')
        @review_questionnaire_id = rqid.questionnaire_id
      end
    end
    if(@review_questionnaire_id)
      @review_questionnaire = Questionnaire.find(@review_questionnaire_id)
      @maxscore = @review_questionnaire.max_question_score
      @review_questions = @review_questionnaire.questions
    end


    ###



   # @maxscore = Questionnaire.find(@assignment.review_questionnaire_id).max_question_score
    
    @scores = Score.find_all_by_response_id(@reviewid)
    @scores.each do |s|
{'fraction_non_alphanumeric': 0.12823179791976225, 'fraction_numerical': 0.006835066864784547, 'mean_word_length': 3.730147575544624, 'pattern_counts': {'":': 0, '<': 5, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4607342', 'n_tokens_mistral': 2376, 'n_tokens_neox': 2285, 'n_words': 356}