Skip to content

Commit

Permalink
Merge branch ChangingSchema into main
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Mar 24, 2024
2 parents 73dc777 + aa6a606 commit e5aa71e
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions app/controllers/assessment360_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def course_student_grade_summary
# break out of the loop if there are no participants in the assignment
next if assignment.participants.find_by(user_id: user_id).nil?
# break out of the loop if the participant has no team
next if TeamsUser.team_id(assignment_id, user_id).nil?
next if TeamsParticipant.team_id(assignment_id, user_id).nil?

assignment_participant = Participant.find_by(user_id: user_id, parent_id: assignment_id)
penalties = calculate_penalty(assignment_participant.id)
Expand Down Expand Up @@ -134,7 +134,7 @@ def assignment_grade_summary(cp, assignment_id, penalties)
topic_id = SignedUpTeam.topic_id(assignment_id, user_id)
@topics[cp.id][assignment_id] = SignUpTopic.find_by(id: topic_id)
# instructor grade is stored in the team model, which is found by finding the user's team for the assignment
team_id = TeamsUser.team_id(assignment_id, user_id)
team_id = TeamsParticipant.team_id(assignment_id, user_id)
team = Team.find(team_id)
@assignment_grades[cp.id][assignment_id] = team[:grade_for_submission] ? (team[:grade_for_submission] - penalties[:submission]).round(2) : nil
return if @assignment_grades[cp.id][assignment_id].nil?
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/grades_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def view

def view_my_scores
@participant = AssignmentParticipant.find(params[:id])
@team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)
@team_id = TeamsParticipant.team_id(@participant.parent_id, @participant.user_id)
return if redirect_when_disallowed

@assignment = @participant.assignment
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/invitations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def check_team_before_invitation
end

# participant information about student you are trying to invite to the team
team_member = TeamsUser.where('team_id = ? and user_id = ?', @team.id, @user.id)
team_member = TeamsParticipant.where('team_id = ? and user_id = ?', @team.id, @user.id)
# check if invited user is already in the team

return if team_member.empty?
Expand Down Expand Up @@ -160,6 +160,6 @@ def invitation_accept

@student = Participant.find(params[:student_id])
# Remove the users previous team since they are accepting an invite for possibly a new team.
TeamsUser.remove_team(@student.user_id, params[:team_id])
TeamsParticipant.remove_team(@student.user_id, params[:team_id])
end
end
2 changes: 1 addition & 1 deletion app/controllers/join_team_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def decline

def check_team_status
# check if the advertisement is from a team member and if so disallow requesting invitations
team_member = TeamsUser.where(['team_id =? and user_id =?', params[:team_id], session[:user][:id]])
team_member = TeamsParticipant.where(['team_id =? and user_id =?', params[:team_id], session[:user][:id]])
team = Team.find(params[:team_id])
return flash[:error] = 'This team is full.' if team.full?
return flash[:error] = 'You are already a member of this team.' unless team_member.empty?
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/lottery_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ def match_new_teams_to_topics(assignment)
# and we also need to think about, how to sort teams when they have the same team size and number of bids
# maybe we can use timestamps in this case
unassigned_teams.sort! do |t1, t2|
[TeamsUser.where(team_id: t2.id).size, Bid.where(team_id: t1.id).size] <=>
[TeamsUser.where(team_id: t1.id).size, Bid.where(team_id: t2.id).size]
[TeamsParticipant.where(team_id: t2.id).size, Bid.where(team_id: t1.id).size] <=>
[TeamsParticipant.where(team_id: t1.id).size, Bid.where(team_id: t2.id).size]
end

teams_bidding_info = construct_teams_bidding_info(unassigned_teams, sign_up_topics)
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/pair_programming_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,24 @@ def action_allowed?
end

def send_invitations
users = TeamsUser.where(team_id: params[:team_id])
users = TeamsParticipant.where(team_id: params[:team_id])
users.each { |user| user.update_attributes(pair_programming_status: "W") }
TeamsUser.find_by(team_id: params[:team_id], user_id: current_user.id).update_attributes(pair_programming_status: "A")
TeamsParticipant.find_by(team_id: params[:team_id], user_id: current_user.id).update_attributes(pair_programming_status: "A")
# ExpertizaLogger.info "Accepting Invitation #{params[:inv_id]}: #{accepted}"
Team.find(params[:team_id]).update_attributes(pair_programming_request: 1)
flash[:success] = "Invitations have been sent successfully!"
redirect_to view_student_teams_path student_id: params[:student_id]
end

def accept
user = TeamsUser.find_by(team_id: params[:team_id], user_id: current_user.id)
user = TeamsParticipant.find_by(team_id: params[:team_id], user_id: current_user.id)
user.update_attributes(pair_programming_status: "A")
flash[:success] = "Pair Programming Request Accepted Successfully!"
redirect_to view_student_teams_path student_id: params[:student_id]
end

def decline
user = TeamsUser.find_by(team_id: params[:team_id], user_id: current_user.id)
user = TeamsParticipant.find_by(team_id: params[:team_id], user_id: current_user.id)
user.update_attributes(pair_programming_status: "D")
Team.find(params[:team_id]).update_attributes(pair_programming_request: 0)
flash[:success] = "Pair Programming Request Declined!"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/popup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def team_users_popup
@sum = 0
@team = Team.find(params[:id])
@assignment = Assignment.find(@team.parent_id)
@team_users = TeamsUser.where(team_id: params[:id])
@team_users = TeamsParticipant.where(team_id: params[:id])

# id2 is a response_map id
unless params[:id2].nil?
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/review_mapping_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def add_reviewer
user_id = User.where(name: params[:user][:name]).first.id
# If instructor want to assign one student to review his/her own artifact,
# it should be counted as "self-review" and we need to make /app/views/submitted_content/_selfreview.html.erb work.
if TeamsUser.exists?(team_id: params[:contributor_id], user_id: user_id)
if TeamsParticipant.exists?(team_id: params[:contributor_id], user_id: user_id)
flash[:error] = 'You cannot assign this student to review his/her own artifact.'
else
# Team lazy initialization
Expand Down Expand Up @@ -342,7 +342,7 @@ def automatic_review_mapping
if teams.empty? && max_team_size == 1
participants.each do |participant|
user = participant.user
next if TeamsUser.team_id(assignment_id, user.id)
next if TeamsParticipant.team_id(assignment_id, user.id)

if assignment.auto_assign_mentor
team = MentoredTeam.create_team_and_node(assignment_id)
Expand Down Expand Up @@ -485,7 +485,7 @@ def assign_reviewers_for_team(assignment_id, review_strategy, participants_hash)

participants_with_insufficient_review_num.each do |participant_id|
teams_hash.each_key do |team_id, _num_review_received|
next if TeamsUser.exists?(team_id: team_id,
next if TeamsParticipant.exists?(team_id: team_id,
user_id: Participant.find(participant_id).user_id)

participant = AssignmentParticipant.find(participant_id)
Expand Down Expand Up @@ -513,10 +513,10 @@ def peer_review_strategy(assignment_id, review_strategy, participants_hash)
if !team.equal? teams.last
# need to even out the # of reviews for teams
while selected_participants.size < review_strategy.reviews_per_team
num_participants_this_team = TeamsUser.where(team_id: team.id).size
num_participants_this_team = TeamsParticipant.where(team_id: team.id).size
# If there are some submitters or reviewers in this team, they are not treated as normal participants.
# They should be removed from 'num_participants_this_team'
TeamsUser.where(team_id: team.id).each do |team_user|
TeamsParticipant.where(team_id: team.id).each do |team_user|
temp_participant = Participant.where(user_id: team_user.user_id, parent_id: assignment_id).first
num_participants_this_team -= 1 unless temp_participant.can_review && temp_participant.can_submit
end
Expand All @@ -536,7 +536,7 @@ def peer_review_strategy(assignment_id, review_strategy, participants_hash)
# if participants_with_min_assigned_reviews is blank
if_condition_1 = participants_with_min_assigned_reviews.empty?
# or only one element in participants_with_min_assigned_reviews, prohibit one student to review his/her own artifact
if_condition_2 = ((participants_with_min_assigned_reviews.size == 1) && TeamsUser.exists?(team_id: team.id, user_id: participants[participants_with_min_assigned_reviews[0]].user_id))
if_condition_2 = ((participants_with_min_assigned_reviews.size == 1) && TeamsParticipant.exists?(team_id: team.id, user_id: participants[participants_with_min_assigned_reviews[0]].user_id))
rand_num = if if_condition_1 || if_condition_2
# use original method to get random number
rand(0..num_participants - 1)
Expand All @@ -546,7 +546,7 @@ def peer_review_strategy(assignment_id, review_strategy, participants_hash)
end
end
# prohibit one student to review his/her own artifact
next if TeamsUser.exists?(team_id: team.id, user_id: participants[rand_num].user_id)
next if TeamsParticipant.exists?(team_id: team.id, user_id: participants[rand_num].user_id)

if_condition_1 = (participants_hash[participants[rand_num].id] < review_strategy.reviews_per_student)
if_condition_2 = (!selected_participants.include? participants[rand_num].id)
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/sign_up_sheet_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def delete_signup_as_instructor
# find participant using assignment using team and topic ids
team = Team.find(params[:id])
assignment = Assignment.find(team.parent_id)
user = TeamsUser.find_by(team_id: team.id).user
user = TeamsParticipant.find_by(team_id: team.id).user
participant = AssignmentParticipant.find_by(user_id: user.id, parent_id: assignment.id)
drop_topic_deadline = assignment.due_dates.find_by(deadline_type_id: 6)
if !participant.team.submitted_files.empty? || !participant.team.hyperlinks.empty?
Expand Down Expand Up @@ -411,7 +411,7 @@ def show_team
end
@results.each do |result|
@team_members = ''
TeamsUser.where(team_id: result[:team_id]).each do |teamuser|
TeamsParticipant.where(team_id: result[:team_id]).each do |teamuser|
@team_members += User.find(teamuser.user_id).name + ' '
end
end
Expand All @@ -421,7 +421,7 @@ def show_team

def switch_original_topic_to_approved_suggested_topic
assignment = AssignmentParticipant.find(params[:id]).assignment
team_id = TeamsUser.team_id(assignment.id, session[:user].id)
team_id = TeamsParticipant.team_id(assignment.id, session[:user].id)

# Tmp variable to store topic id before change
original_topic_id = SignedUpTeam.topic_id(assignment.id.to_i, session[:user].id)
Expand All @@ -441,7 +441,7 @@ def switch_original_topic_to_approved_suggested_topic
# check the waitlist of original topic. Let the first waitlisted team hold the topic, if exists.
waitlisted_teams = SignedUpTeam.where(topic_id: original_topic_id, is_waitlisted: 1)
if waitlisted_teams.present?
waitlisted_first_team_first_user_id = TeamsUser.where(team_id: waitlisted_teams.first.team_id).first.user_id
waitlisted_first_team_first_user_id = TeamsParticipant.where(team_id: waitlisted_teams.first.team_id).first.user_id
SignUpSheet.signup_team(assignment.id, waitlisted_first_team_first_user_id, original_topic_id)
end
redirect_to action: 'list', id: params[:id]
Expand Down
16 changes: 8 additions & 8 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20231203230237) do
ActiveRecord::Schema.define(version: 20240324044135) do

create_table "account_requests", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
t.string "name"
Expand Down Expand Up @@ -528,7 +528,7 @@
t.float "Hamer", limit: 24, default: 1.0
t.float "Lauw", limit: 24, default: 0.0
t.integer "duty_id"
t.boolean "can_mentor"
t.boolean "can_mentor", default: false
t.index ["duty_id"], name: "index_participants_on_duty_id"
t.index ["user_id"], name: "fk_participant_users"
end
Expand Down Expand Up @@ -937,13 +937,13 @@
t.integer "pair_programming_request", limit: 1
end

create_table "teams_users", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
create_table "teams_participants", id: :integer, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=latin1" do |t|
t.integer "team_id"
t.integer "user_id"
t.integer "duty_id"
t.string "pair_programming_status", limit: 1
t.integer "participant_id"
t.index ["duty_id"], name: "index_teams_users_on_duty_id"
t.index ["duty_id"], name: "index_teams_participants_on_duty_id"
t.index ["participant_id"], name: "fk_rails_7192605c92"
t.index ["team_id"], name: "fk_users_teams"
t.index ["user_id"], name: "fk_teams_users"
Expand Down Expand Up @@ -1078,8 +1078,8 @@
add_foreign_key "tag_prompt_deployments", "assignments"
add_foreign_key "tag_prompt_deployments", "questionnaires"
add_foreign_key "tag_prompt_deployments", "tag_prompts"
add_foreign_key "teams_users", "duties"
add_foreign_key "teams_users", "participants"
add_foreign_key "teams_users", "teams", name: "fk_users_teams"
add_foreign_key "teams_users", "users", name: "fk_teams_users"
add_foreign_key "teams_participants", "duties"
add_foreign_key "teams_participants", "participants"
add_foreign_key "teams_participants", "teams", name: "fk_users_teams"
add_foreign_key "teams_participants", "users", name: "fk_teams_users"
end

0 comments on commit e5aa71e

Please sign in to comment.