Skip to content

Commit

Permalink
Merge 9275cad into 24a38b8
Browse files Browse the repository at this point in the history
  • Loading branch information
qureshi-ali committed Apr 1, 2024
2 parents 24a38b8 + 9275cad commit 2aaa15b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 0 additions & 3 deletions app/controllers/popup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ def view_review_scores_popup
@assignment_id = params[:assignment_id]
@review_final_versions = ReviewResponseMap.final_versions_from_reviewer(@assignment_id, @reviewer_id)
@reviews = []

assignment = Assignment.find(@assignment_id)
flash.now[:error] = 'This report is not implemented for assignments where the rubric varies by topic.' if assignment.vary_by_topic?
end

# this can be called from "response_report" by clicking reviewer names from instructor end.
Expand Down
28 changes: 28 additions & 0 deletions app/models/review_response_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ def self.prepare_final_review_versions(assignment, maps)
(1..rounds_num).each do |round|
prepare_review_response(assignment, maps, review_final_versions, round)
end
elsif assignment.vary_by_topic?
prepare_review_response_by_topic(assignment, maps, review_final_versions)
else
prepare_review_response(assignment, maps, review_final_versions, nil)
end
Expand All @@ -207,4 +209,30 @@ def self.prepare_review_response(assignment, maps, review_final_versions, round)
end
review_final_versions[symbol][:response_ids] = response_ids
end

def self.prepare_review_response_by_topic(assignment, maps, review_final_versions)
responses_by_questionnaire = Hash.new { |hash, key| hash[key] = [] }

maps.each do |map|
team = AssignmentTeam.find(map.reviewee_id)
topic_id = SignedUpTeam.topic_id_by_team_id(team.id)
# Get the questionnaire ID corresponding to the assignment_id and topic_id of the participant
questionnaire = AssignmentQuestionnaire.where(assignment_id: assignment.id, topic_id: topic_id).first
questionnaire_id = questionnaire.questionnaire_id
# Get the responses for the response map
where_map = { map_id: map.id, round: 1 }
responses = Response.where(where_map)
# Append the response ID to the corresponding response_ids array
responses_by_questionnaire[questionnaire_id] << responses.last.id unless responses.empty?
end

# Iterate through the grouped responses
responses_by_questionnaire.each_with_index do |(questionnaire_id, response_ids), index|
symbol = "review for rubric #{index + 1}".to_sym
review_final_versions[symbol] = {
questionnaire_id: questionnaire_id,
response_ids: response_ids
}
end
end
end

0 comments on commit 2aaa15b

Please sign in to comment.