<commit_before>
class Question < ActiveRecord::Base
  belongs_to :scenario
  has_many :answers, dependent: :destroy

  def grade(student_answer, student_id)

  # Need to rewrite this securely, use find_by

  #   if self.answers.where("answer_text = '#{student_answer}'").first
  #     return
  #   end

  #   self.answer_text.split('&').each do |answer|
  #     answers_or = answer.split('|')

  #     answer = false
  #     correct = false
  #     answers_or.each do |answer_or|
  #       answer_or = answer_or.strip
  #       if self.answers.where("answer_text = '#{answer_or}'").first
  #         answer = true
  #       end
  #       if answer_or.eql?(student_answer)
  #         correct = true
  #       end
  #     end

  #     if correct and !answer
  #       answer = self.answers.new
  #       answer.student_id = student_id
  #       answer.answer_text = student_answer
  #       answer.correct = true
  #       answer.save!
  #       return 
  #     end

  #     if correct and answer
  #       return
  #     end

  #   end

  #   answer = self.answers.new
  #   answer.student_id = student_id
  #   answer.answer_text = student_answer
  #   answer.correct = false
  #   answer.save!
  # end
  
end
<commit_msg>fixed serror in question.rb<commit_after>
class Question < ActiveRecord::Base
  belongs_to :scenario
  has_many :answers, dependent: :destroy

  # Need to rewrite this securely, use find_by


  # def grade(student_answer, student_id)
  #   if self.answers.where("answer_text = '#{student_answer}'").first
  #     return
  #   end

  #   self.answer_text.split('&').each do |answer|
  #     answers_or = answer.split('|')

  #     answer = false
  #     correct = false
  #     answers_or.each do |answer_or|
  #       answer_or = answer_or.strip
  #       if self.answers.where("answer_text = '#{answer_or}'").first
  #         answer = true
  #       end
  #       if answer_or.eql?(student_answer)
  #         correct = true
  #       end
  #     end

  #     if correct and !answer
  #       answer = self.answers.new
  #       answer.student_id = student_id
  #       answer.answer_text = student_answer
  #       answer.correct = true
  #       answer.save!
  #       return 
  #     end

  #     if correct and answer
  #       return
  #     end

  #   end

  #   answer = self.answers.new
  #   answer.student_id = student_id
  #   answer.answer_text = student_answer
  #   answer.correct = false
  #   answer.save!
  # end
  
end

{'fraction_non_alphanumeric': 0.10560519902518278, 'fraction_numerical': 0.0, 'mean_word_length': 2.0864661654135337, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6399890', 'n_tokens_mistral': 846, 'n_tokens_neox': 819, 'n_words': 171}