<commit_before>class Quizzes::QuizQuestion::LearnosityQuestion < Quizzes::QuizQuestion::Base

  def requires_manual_scoring?(user_answer)
    !user_answer.answer_details['scores'] || user_answer.answer_details['scores'].empty?
  end

  def correct_answer_parts(user_answer)
    scores = user_answer.answer_details['scores']
    return nil unless scores && !scores.empty? && scores["#{self.question_id}"] && scores["#{self.question_id}"]['score']
    scores = scores["#{self.question_id}"]
    scores['max_score'] == scores['score']
  end

  def score_question(answer_data, user_answer=nil)
    user_answer = Quizzes::QuizQuestion::LearnosityAnswer.new(self.question_id, self.points_possible, answer_data)
    super(answer_data, user_answer)
  end

  def stats(responses)
    stats = {:learnosity_responses => []}

    responses.each do |response|
      stats[:learnosity_responses] << {
        :user_id => response[:user_id],
        :points_awarded => (response['scores']["#{response[:question_id]}"]['score'] rescue 0),
      }
    end

    @question_data.merge stats
  end

end<commit_msg>CNS-612: System ignores the points obtained in the Quiz Statistics<commit_after>class Quizzes::QuizQuestion::LearnosityQuestion < Quizzes::QuizQuestion::Base

  def requires_manual_scoring?(user_answer)
    !user_answer.answer_details['scores'] || user_answer.answer_details['scores'].empty?
  end

  def correct_answer_parts(user_answer)
    scores = user_answer.answer_details['scores']
    return nil unless scores && !scores.empty? && scores["#{self.question_id}"] && scores["#{self.question_id}"]['score']
    scores = scores["#{self.question_id}"]
    scores['max_score'] == scores['score']
  end

  def score_question(answer_data, user_answer=nil)
    user_answer = Quizzes::QuizQuestion::LearnosityAnswer.new(self.question_id, self.points_possible, answer_data)
    super(answer_data, user_answer)
  end

  def stats(responses)
    stats = {:learnosity_responses => []}

    responses.each do |response|
      stats[:learnosity_responses] << {
        :user_id => response[:user_id],
        :points_awarded => (response[:points] rescue 0),
      }
    end

    @question_data.merge stats
  end

end
{'fraction_non_alphanumeric': 0.13772727272727273, 'fraction_numerical': 0.0022727272727272726, 'mean_word_length': 5.03013698630137, 'pattern_counts': {'":': 0, '<': 9, '<?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': '4370812', 'n_tokens_mistral': 723, 'n_tokens_neox': 693, 'n_words': 114}