Skip to content

Commit

Permalink
fix hound comments
Browse files Browse the repository at this point in the history
  • Loading branch information
syoopie committed Aug 20, 2024
1 parent 6bf6f8d commit 889de1f
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 21 deletions.
48 changes: 29 additions & 19 deletions app/controllers/concerns/course/statistics/live_feedback_concern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,41 @@ def fetch_hash_for_live_feedback_assessment(submissions, assessment_live_feedbac

def populate_hash(submissions, student_hash, assessment_live_feedbacks)
submissions.each do |submission|
submitter_course_user = submission.creator.course_users.select do |u|
u.course_id == @assessment.course_id
end.first
submitter_course_user = find_submitter_course_user(submission)
next unless submitter_course_user&.student?

# Initialize the feedback count array with zeros for each user
feedback_count = Array.new(@question_order_hash.size, 0)
feedback_count = initialize_feedback_count

user_assessment_live_feedback = assessment_live_feedbacks.select do |live_feedback|
live_feedback.creator == submitter_course_user
end
user_assessment_live_feedback = find_user_assessment_live_feedback(submitter_course_user,
assessment_live_feedbacks)

user_assessment_live_feedback.each do |feedback|
index = @question_order_hash[feedback.question_id]
# For each feedback, get all the code and all the corresponding comments
# If there is at least 1 comment within ALL the code, increment the feedback count
feedback.code.each do |code|
unless code.comments.empty?
feedback_count[index] += 1
break
end
end
end
update_feedback_count(feedback_count, user_assessment_live_feedback)

student_hash[submitter_course_user] = [submission, feedback_count]
end
end

def find_submitter_course_user(submission)
submission.creator.course_users.find { |u| u.course_id == @assessment.course_id }
end

def initialize_feedback_count
Array.new(@question_order_hash.size, 0)
end

def find_user_assessment_live_feedback(submitter_course_user, assessment_live_feedbacks)
assessment_live_feedbacks.select { |live_feedback| live_feedback.creator == submitter_course_user }
end

def update_feedback_count(feedback_count, user_assessment_live_feedback)
user_assessment_live_feedback.each do |feedback|
index = @question_order_hash[feedback.question_id]
feedback.code.each do |code|
unless code.comments.empty?
feedback_count[index] += 1
break
end
end
end
end
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true
class Course::Assessment::Submission::SubmissionsController <
class Course::Assessment::Submission::SubmissionsController < \
Course::Assessment::Submission::Controller
include Course::Assessment::Submission::SubmissionsControllerServiceConcern
include Signals::EmissionConcern
Expand Down
1 change: 1 addition & 0 deletions app/models/course/assessment/live_feedback.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# frozen_string_literal: true
class Course::Assessment::LiveFeedback < ApplicationRecord
belongs_to :assessment, class_name: 'Course::Assessment', foreign_key: 'assessment_id'
belongs_to :question, class_name: 'Course::Assessment::Question', foreign_key: 'question_id'
Expand Down
2 changes: 1 addition & 1 deletion app/models/course/assessment/live_feedback_comment.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# app/models/course/assessment/live_feedback_comment.rb
# frozen_string_literal: true
class Course::Assessment::LiveFeedbackComment < ApplicationRecord
belongs_to :code, class_name: 'Course::Assessment::LiveFeedbackCode', foreign_key: 'code_id'

Expand Down

0 comments on commit 889de1f

Please sign in to comment.