Skip to content

Commit

Permalink
Updated variable names for vary_by_round, vary_by_topic, reviewer_is_…
Browse files Browse the repository at this point in the history
…team
  • Loading branch information
namanshrimali committed Jul 7, 2022
1 parent 689447d commit c8f83d9
Show file tree
Hide file tree
Showing 39 changed files with 85 additions and 85 deletions.
8 changes: 4 additions & 4 deletions app/controllers/grades_controller.rb
Expand Up @@ -38,7 +38,7 @@ def controller_locale
def view
@assignment = Assignment.find(params[:id])
questionnaires = @assignment.questionnaires
if @assignment.vary_by_round
if @assignment.vary_by_round?
@questions = retrieve_questions questionnaires, @assignment.id
else
@questions = {}
Expand Down Expand Up @@ -91,7 +91,7 @@ def view_team
counter_for_same_rubric = 0
questionnaires.each do |questionnaire|
@round = nil
if @assignment.vary_by_round && questionnaire.type == 'ReviewQuestionnaire'
if @assignment.vary_by_round? && questionnaire.type == 'ReviewQuestionnaire'
questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, questionnaire_id: questionnaire.id)
if questionnaires.count > 1
@round = questionnaires[counter_for_same_rubric].used_in_round
Expand Down Expand Up @@ -193,7 +193,7 @@ def populate_view_model(questionnaire)
vmquestions = questionnaire.questions
vm.add_questions(vmquestions)
vm.add_team_members(@team)
vm.add_reviews(@participant, @team, @assignment.vary_by_round)
vm.add_reviews(@participant, @team, @assignment.vary_by_round?)
vm.calculate_metrics
vm
end
Expand Down Expand Up @@ -232,7 +232,7 @@ def make_chart
participant_score_types = %i[metareview feedback teammate]
if @pscore[:review]
scores = []
if @assignment.vary_by_round
if @assignment.vary_by_round?
(1..@assignment.rounds_of_reviews).each do |round|
responses = @pscore[:review][:assessments].select { |response| response.round == round }
scores = scores.concat(score_vector(responses, 'review' + round.to_s))
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/popup_controller.rb
Expand Up @@ -47,7 +47,7 @@ def team_users_popup
# However, we want their user_id. This is not possible for teams, so we just return the current id
reviewer_id = ResponseMap.find(params[:id2]).reviewer_id
# E2060 - we had to change this if/else clause in order to properly view reports page
@reviewer_id = if @assignment.reviewer_is_team
@reviewer_id = if @assignment.team_reviewing_enabled?
reviewer_id
else
Participant.find(reviewer_id).user_id
Expand Down Expand Up @@ -89,7 +89,7 @@ def view_review_scores_popup
@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
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
6 changes: 3 additions & 3 deletions app/controllers/response_controller.rb
Expand Up @@ -57,7 +57,7 @@ def json
# E2218: Method to delete a response.
def delete
# The locking was added for E1973, team-based reviewing. See lock.rb for details
if @map.reviewer_is_team
if @map.team_reviewing_enabled?
@response = Lock.get_lock(@response, current_user, Lock::DEFAULT_TIMEOUT)
if @response.nil?
response_lock_action
Expand Down Expand Up @@ -93,7 +93,7 @@ def edit
end
# Added for E1973, team-based reviewing
@map = @response.map
if @map.reviewer_is_team
if @map.team_reviewing_enabled?
@response = Lock.get_lock(@response, current_user, Lock::DEFAULT_TIMEOUT)
if @response.nil?
response_lock_action
Expand All @@ -119,7 +119,7 @@ def update
begin
# the response to be updated
# Locking functionality added for E1973, team-based reviewing
if @map.reviewer_is_team && !Lock.lock_between?(@response, current_user)
if @map.team_reviewing_enabled? && !Lock.lock_between?(@response, current_user)
response_lock_action
return
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/student_review_controller.rb
Expand Up @@ -28,7 +28,7 @@ def list
if @participant.get_reviewer
# ACS Removed the if condition(and corresponding else) which differentiate assignments as team and individual assignments
# to treat all assignments as team assignments
@review_mappings = ReviewResponseMap.where(reviewer_id: @participant.get_reviewer.id, reviewer_is_team: @assignment.reviewer_is_team)
@review_mappings = ReviewResponseMap.where(reviewer_id: @participant.get_reviewer.id, team_reviewing_enabled?: @assignment.team_reviewing_enabled?)
else
@review_mappings = []
end
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/grades_helper.rb
Expand Up @@ -132,7 +132,7 @@ def view_heatgrid(participant_id, type)
# loop through each questionnaire, and populate the view model for all data necessary
# to render the html tables.
questionnaires.each do |questionnaire|
@round = if @assignment.vary_by_round && questionnaire.type == 'ReviewQuestionnaire'
@round = if @assignment.vary_by_round? && questionnaire.type == 'ReviewQuestionnaire'
AssignmentQuestionnaire.find_by(assignment_id: @assignment.id, questionnaire_id: questionnaire.id).used_in_round
end
next unless questionnaire.type == type
Expand All @@ -141,7 +141,7 @@ def view_heatgrid(participant_id, type)
questions = questionnaire.questions
vm.add_questions(questions)
vm.add_team_members(@team)
vm.add_reviews(@participant, @team, @assignment.vary_by_round)
vm.add_reviews(@participant, @team, @assignment.vary_by_round?)
vm.number_of_comments_greater_than_10_words
@vmlist << vm
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/report_formatter_helper.rb
Expand Up @@ -13,7 +13,7 @@ def review_response_map(params, _session = nil)
def feedback_response_map(params, _session = nil)
assign_basics(params)
# If review report for feedback is required call feedback_response_report method in feedback_review_response_map model
if @assignment.vary_by_round
if @assignment.vary_by_round?
@authors, @all_review_response_ids_round_one, @all_review_response_ids_round_two, @all_review_response_ids_round_three =
FeedbackResponseMap.feedback_response_report(@id, @type)
else
Expand Down
2 changes: 1 addition & 1 deletion app/models/assignment.rb
Expand Up @@ -491,7 +491,7 @@ def self.export(csv, parent_id, options)
@questions = {}
questionnaires = @assignment.questionnaires
questionnaires.each do |questionnaire|
if @assignment.vary_by_round
if @assignment.vary_by_round?
round = AssignmentQuestionnaire.find_by(assignment_id: @assignment.id, questionnaire_id: @questionnaire.id).used_in_round
questionnaire_symbol = round.nil? ? questionnaire.symbol : (questionnaire.symbol.to_s + round.to_s).to_sym
else
Expand Down
8 changes: 4 additions & 4 deletions app/models/assignment_form.rb
Expand Up @@ -62,7 +62,7 @@ def update(attributes, user, _vary_by_topic_desired = false)
end
update_assignment(attributes[:assignment])
update_assignment_questionnaires(attributes[:assignment_questionnaire]) unless @has_errors
update_assignment_questionnaires(attributes[:topic_questionnaire]) unless @has_errors || attributes[:assignment][:vary_by_topic] == 'false'
update_assignment_questionnaires(attributes[:topic_questionnaire]) unless @has_errors || attributes[:assignment][:vary_by_topic?] == 'false'
update_due_dates(attributes[:due_date], user) unless @has_errors
update_assigned_badges(attributes[:badge], attributes[:assignment]) unless @has_errors
add_simicheck_to_delayed_queue(attributes[:assignment][:simicheck])
Expand Down Expand Up @@ -240,21 +240,21 @@ def assignment_questionnaire(questionnaire_type, round_number, topic_id, duty_id
# If the AQ questionnaire matches the type of the questionnaire that needs to be updated, return it
return aq if aq.questionnaire_id && Questionnaire.find(aq.questionnaire_id).type == questionnaire_type
end
elsif @assignment.vary_by_round && @assignment.vary_by_topic
elsif @assignment.vary_by_round? && @assignment.vary_by_topic?
# Get all AQs for the assignment and specified round number and topic
assignment_questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, used_in_round: round_number, topic_id: topic_id)
assignment_questionnaires.each do |aq|
# If the AQ questionnaire matches the type of the questionnaire that needs to be updated, return it
return aq if aq.questionnaire_id && Questionnaire.find(aq.questionnaire_id).type == questionnaire_type
end
elsif @assignment.vary_by_round
elsif @assignment.vary_by_round?
# Get all AQs for the assignment and specified round number by round #
assignment_questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, used_in_round: round_number)
assignment_questionnaires.each do |aq|
# If the AQ questionnaire matches the type of the questionnaire that needs to be updated, return it
return aq if aq.questionnaire_id && Questionnaire.find(aq.questionnaire_id).type == questionnaire_type
end
elsif @assignment.vary_by_topic
elsif @assignment.vary_by_topic?
# Get all AQs for the assignment and specified round number by topic
assignment_questionnaires = AssignmentQuestionnaire.where(assignment_id: @assignment.id, topic_id: topic_id)
assignment_questionnaires.each do |aq|
Expand Down
4 changes: 2 additions & 2 deletions app/models/assignment_participant.rb
Expand Up @@ -54,10 +54,10 @@ def reviews
ReviewResponseMap.assessments_for(team)
end

# returns the reviewer of the assignment. Checks the reviewer_is_team flag to
# returns the reviewer of the assignment. Checks the team_reviewing_enabled? flag to
# determine whether this AssignmentParticipant or their team is the reviewer
def get_reviewer
return team if assignment.reviewer_is_team
return team if assignment.team_reviewing_enabled?

self
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/assignment_team.rb
Expand Up @@ -62,7 +62,7 @@ def assign_reviewer(reviewer)
assignment = Assignment.find(parent_id)
raise 'The assignment cannot be found.' if assignment.nil?

ReviewResponseMap.create(reviewee_id: id, reviewer_id: reviewer.get_reviewer.id, reviewed_object_id: assignment.id, reviewer_is_team: assignment.reviewer_is_team)
ReviewResponseMap.create(reviewee_id: id, reviewer_id: reviewer.get_reviewer.id, reviewed_object_id: assignment.id, team_reviewing_enabled?: assignment.team_reviewing_enabled?)
end

# E-1973 If a team is being treated as a reviewer of an assignment, then they are the reviewer
Expand Down
4 changes: 2 additions & 2 deletions app/models/feedback_response_map.rb
Expand Up @@ -45,7 +45,7 @@ def self.feedback_response_report(id, _type)
@temp_review_responses = Response.where(['map_id IN (?)', @review_response_map_ids]).order('created_at DESC')
# we need to pick the latest version of review for each round
@temp_response_map_ids = []
if Assignment.find(id).vary_by_round
if Assignment.find(id).vary_by_round?
@all_review_response_ids_round_one = []
@all_review_response_ids_round_two = []
@all_review_response_ids_round_three = []
Expand All @@ -68,7 +68,7 @@ def self.feedback_response_report(id, _type)
end
# @feedback_response_map_ids = ResponseMap.where(["reviewed_object_id IN (?) and type = ?", @all_review_response_ids, type]).pluck("id")
# @feedback_responses = Response.where(["map_id IN (?)", @feedback_response_map_ids]).pluck("id")
if Assignment.find(id).vary_by_round
if Assignment.find(id).vary_by_round?
return @authors, @all_review_response_ids_round_one, @all_review_response_ids_round_two, @all_review_response_ids_round_three
else
return @authors, @all_review_response_ids
Expand Down
8 changes: 4 additions & 4 deletions app/models/review_response_map.rb
Expand Up @@ -8,7 +8,7 @@ class ReviewResponseMap < ResponseMap
# ReviewResponseMap was created in so many places, I thought it best to add this here as a catch-all
def after_initialize
# If an assignment supports team reviews, it is marked in each mapping
assignment.reviewer_is_team
assignment.team_reviewing_enabled?
end

# Find a review questionnaire associated with this review response map's assignment
Expand Down Expand Up @@ -116,7 +116,7 @@ def get_reviewer
# the assignment is used to determine if the reviewer is a participant or a team
def self.get_reviewer_with_id(assignment_id, reviewer_id)
assignment = Assignment.find(assignment_id)
if assignment.reviewer_is_team
if assignment.team_reviewing_enabled?
return AssignmentTeam.find(reviewer_id)
else
return AssignmentParticipant.find(reviewer_id)
Expand All @@ -142,7 +142,7 @@ def self.review_response_report(id, assignment, type, review_user)
@reviewers << ReviewResponseMap.get_reviewer_with_id(assignment.id, reviewer_id_from_response_map.reviewer_id)
end
# we sort the reviewer by name here, using whichever class it is an instance of
@reviewers = if assignment.reviewer_is_team
@reviewers = if assignment.team_reviewing_enabled?
Team.sort_by_name(@reviewers)
else
Participant.sort_by_name(@reviewers)
Expand All @@ -151,7 +151,7 @@ def self.review_response_report(id, assignment, type, review_user)
# This is a search, so find reviewers by user's full name
user_ids = User.select('DISTINCT id').where('fullname LIKE ?', '%' + review_user[:fullname] + '%')
# E1973 - we use a separate query depending on if the reviewer is a team or participant
if assignment.reviewer_is_team
if assignment.team_reviewing_enabled?
reviewer_participants = AssignmentTeam.where('id IN (?) and parent_id = ?', team_ids, assignment.id)
@reviewers = []
reviewer_participants.each do |participant|
Expand Down
2 changes: 1 addition & 1 deletion app/models/tag_prompt_deployment.rb
Expand Up @@ -34,7 +34,7 @@ def assignment_tagging_progress
user_answer_tagging = []
unless teams.empty? || questions.empty?
teams.each do |team|
if assignment.vary_by_round
if assignment.vary_by_round?
responses = []
1.upto(assignment.rounds_of_reviews).each do |round|
responses += ReviewResponseMap.get_responses_for_team_round(team, round)
Expand Down
8 changes: 4 additions & 4 deletions app/views/assignments/edit/_review_strategy.html.erb
Expand Up @@ -131,10 +131,10 @@
</tr>

<tr>
<td id='reviewer_is_team'>
<input name="assignment_form[assignment][reviewer_is_team]" type="hidden" value="false"/>
<%= check_box_tag('assignment_form[assignment][reviewer_is_team]', 'true', @assignment_form.assignment.reviewer_is_team) %>
<%= label_tag('assignment_form[assignment][reviewer_is_team]', 'Is Review done by Teams?') %>
<td id='team_reviewing_enabled?'>
<input name="assignment_form[assignment][team_reviewing_enabled?]" type="hidden" value="false"/>
<%= check_box_tag('assignment_form[assignment][team_reviewing_enabled?]', 'true', @assignment_form.assignment.team_reviewing_enabled?) %>
<%= label_tag('assignment_form[assignment][team_reviewing_enabled?]', 'Is Review done by Teams?') %>
<img src="/assets/info.png" title='You can select whether the reviews should be done by individual students or teams'>
</td>
</tr>
Expand Down
18 changes: 9 additions & 9 deletions app/views/assignments/edit/_rubrics.html.erb
Expand Up @@ -392,16 +392,16 @@
</script>

<!--Add a review varies by round checkbox. -->
<!-- This is vary_by_round attribute of assignment created by migration -->
<input name="assignment_form[assignment][vary_by_round]" type="hidden" value="false" />
<%= check_box_tag('assignment_form[assignment][vary_by_round]', 'true', @assignment_form.assignment.vary_by_round, onclick: "handleCheckReviewVaryByRound(this)") %>
<%= label_tag('assignment_form[assignment][vary_by_round]', 'Review rubric varies by round?') %>
<!-- This is vary_by_round? attribute of assignment created by migration -->
<input name="assignment_form[assignment][vary_by_round?]" type="hidden" value="false" />
<%= check_box_tag('assignment_form[assignment][vary_by_round?]', 'true', @assignment_form.assignment.vary_by_round?, onclick: "handleCheckReviewVaryByRound(this)") %>
<%= label_tag('assignment_form[assignment][vary_by_round?]', 'Review rubric varies by round?') %>
<br>
<!-- Add a review varies by topic checkbox -->
<!-- This is vary_by_topic attribute of assignment created by migration -->
<input name="assignment_form[assignment][vary_by_topic]" type="hidden" value="false" />
<%= check_box_tag('assignment_form[assignment][vary_by_topic]', 'true', @assignment_form.assignment.vary_by_topic) %>
<%= label_tag('assignment_form[assignment][vary_by_topic]', 'Review rubric varies by topic?') %>
<!-- This is vary_by_topic? attribute of assignment created by migration -->
<input name="assignment_form[assignment][vary_by_topic?]" type="hidden" value="false" />
<%= check_box_tag('assignment_form[assignment][vary_by_topic?]', 'true', @assignment_form.assignment.vary_by_topic?) %>
<%= label_tag('assignment_form[assignment][vary_by_topic?]', 'Review rubric varies by topic?') %>
<br>
<!--Add a review varies by duties (role in the UI) checkbox if teams is allowed -->
<!-- This is questionnaire_varies_by_duty attribute of assignment created by migration -->
Expand Down Expand Up @@ -433,7 +433,7 @@
insertTeamBasedElements()
});

<% if @assignment_form.assignment.vary_by_round %>
<% if @assignment_form.assignment.vary_by_round? %>
<% 1.upto(@assignment_form.assignment.rounds_of_reviews) do |i| %>
<% assignment_questionnaire = @assignment_form.assignment_questionnaire('ReviewQuestionnaire', i, nil) %>
<% questionnaire = @assignment_form.questionnaire(assignment_questionnaire, 'ReviewQuestionnaire') %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/grades/_review_table.html.erb
@@ -1,5 +1,5 @@
<table class="table table-striped grades" class="width: 100%">
<%if ctrl=='review' && @assignment.vary_by_round %>
<%if ctrl=='review' && @assignment.vary_by_round? %>
<% reviews = reviews.select{|response| response.round == round}.reverse.uniq{|response| response.map_id}.sort_by{|response| response.map_id} %>
<%else%>
<% reviews = reviews.sort_by{|response| response.map_id} %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/grades/_reviews.html.erb
Expand Up @@ -63,7 +63,7 @@
<% count = count + 1 %>
<% prefix = nil if controller.action_name == "view_my_scores" %>
<!--change code in order to compat to multi-round review-->
<% if @assignment.vary_by_round and !review.round.nil? %>
<% if @assignment.vary_by_round? and !review.round.nil? %>
<% review_symbol = 'review' + review.round.to_s %>
<% else %>
<% review_symbol = 'review' %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/grades/_tabbed_reviews.html.erb
Expand Up @@ -21,7 +21,7 @@

<!--<%= review.display_as_html(nil, count, nil, true) %><BR/>-->
<!--change code in order to compat to multi-round review-->
<% if @assignment.vary_by_round and !review.round.nil? %>
<% if @assignment.vary_by_round? and !review.round.nil? %>
<% review_symbol = 'review' + review.round.to_s %>
<% else %>
<% review_symbol = 'review' %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/reports/_feedback_report.html.erb
Expand Up @@ -22,7 +22,7 @@

<% @authors.each do |rejoinder| %>
<% next unless rejoinder %>
<% if @assignment.vary_by_round %>
<% if @assignment.vary_by_round? %>
<% get_each_review_and_feedback_response_map(rejoinder) %>
<% else %>
<% get_certain_review_and_feedback_response_map(rejoinder) %>
Expand All @@ -31,7 +31,7 @@
<% @first_col_identifier = true %>

<!-- if the assignment varies by round, prepare data for table: -->
<% if @assignment.vary_by_round %>
<% if @assignment.vary_by_round? %>
<!--data prepare-->
<% @count_round_one, @count_round_two, @count_round_three = 0, 0, 0 %>
<% unless @feedback_response_maps_round_one.nil? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/sign_up_sheet/_table_header.html.erb
@@ -1,6 +1,6 @@
<th width="5%"><%=t ".topic_id"%></th>
<th width="5%"><%=t ".select"%></th>
<% if @assignment.vary_by_topic %>
<% if @assignment.vary_by_topic? %>
<th width="25%"><%=t ".topic_name"%></th>
<th width="25%"><%=t ".questionnaire"%></th>
<% else %>
Expand Down
4 changes: 2 additions & 2 deletions app/views/sign_up_sheet/_table_line.html.erb
Expand Up @@ -45,13 +45,13 @@
<td align="center"><%= topic.micropayment %></td>
<% end %>
<% if @assignment.vary_by_topic %>
<% if @assignment.vary_by_topic? %>
<% table_id = "topic_questionnaire_table" + i.to_s %>
<td>
<table id = <%=table_id %>>
<tr>
<script>
<% if @assignment.vary_by_round %>
<% if @assignment.vary_by_round? %>
<% 1.upto(@assignment.rounds_of_reviews) do |round| %>
<% assignment_questionnaire = @assignment_form.assignment_questionnaire('ReviewQuestionnaire', round, topic.id) %>
<% questionnaire = @assignment_form.questionnaire(assignment_questionnaire, 'ReviewQuestionnaire') %>
Expand Down
@@ -1,5 +1,5 @@
class AddVaryByTopicToAssignments < ActiveRecord::Migration[4.2]
def change
add_column :assignments, :vary_by_topic, :boolean, default: false
add_column :assignments, :vary_by_topic?, :boolean, default: false
end
end

0 comments on commit c8f83d9

Please sign in to comment.