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 389bdac
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?

Check warning on line 19 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L17-L19

Added lines #L17 - L19 were not covered by tests

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

Check warning on line 21 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L21

Added line #L21 was not covered by tests

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,

Check warning on line 23 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L23

Added line #L23 was not covered by tests
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)

Check warning on line 26 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L26

Added line #L26 was not covered by tests

student_hash[submitter_course_user] = [submission, feedback_count]

Check warning on line 28 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L28

Added line #L28 was not covered by tests
end
end

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

Check warning on line 33 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L33

Added line #L33 was not covered by tests
end

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

Check warning on line 37 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L37

Added line #L37 was not covered by tests
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 }

Check warning on line 41 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L41

Added line #L41 was not covered by tests
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

Check warning on line 50 in app/controllers/concerns/course/statistics/live_feedback_concern.rb

View check run for this annotation

Codecov / codecov/patch

app/controllers/concerns/course/statistics/live_feedback_concern.rb#L45-L50

Added lines #L45 - L50 were not covered by tests
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'

Check warning on line 3 in app/models/course/assessment/live_feedback_comment.rb

View check run for this annotation

Codecov / codecov/patch

app/models/course/assessment/live_feedback_comment.rb#L2-L3

Added lines #L2 - L3 were not covered by tests

Expand Down

0 comments on commit 389bdac

Please sign in to comment.