Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor scores in assignment and participant #2038

Merged
merged 25 commits into from Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/assessment360_controller.rb
Expand Up @@ -174,7 +174,7 @@ def find_peer_review_score(user_id, assignment_id)
participant = AssignmentParticipant.find_by(user_id: user_id, parent_id: assignment_id)
assignment = participant.assignment
questions = retrieve_questions assignment.questionnaires, assignment_id
participant.scores(questions)
ResponseMap.participant_scores(participant, questions)
end

def format_topic(topic)
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/bookmarks_controller.rb
Expand Up @@ -78,7 +78,7 @@ def save_bookmark_rating_score
# calculate average questionnaire score for 'Your rating' for specific bookmark
def specific_average_score(bookmark)
if bookmark.nil?
return '-'
'-'
else
assessment = SignUpTopic.find(bookmark.topic_id).assignment
questions = assessment.questionnaires.where(type: 'BookmarkRatingQuestionnaire').flat_map(&:questions)
Expand All @@ -98,7 +98,7 @@ def specific_average_score(bookmark)
# calculate average questionnaire score for 'Avg. rating' for specific bookmark
def total_average_score(bookmark)
if bookmark.nil?
return '-'
'-'
else
assessment = SignUpTopic.find(bookmark.topic_id).assignment
questions = assessment.questionnaires.where(type: 'BookmarkRatingQuestionnaire').flat_map(&:questions)
Expand Down
12 changes: 6 additions & 6 deletions app/controllers/grades_controller.rb
Expand Up @@ -43,8 +43,8 @@ def view
end
end

@scores = @assignment.scores(@questions)
averages = vector(@assignment.scores(@questions))
@scores = ResponseMap.scores(@assignment,@questions)
averages = vector(@scores)
@average_chart = bar_chart(averages, 300, 100, 5)
@avg_of_avg = mean(averages)
penalties(@assignment.id)
Expand All @@ -60,10 +60,10 @@ def view_my_scores
questionnaires = @assignment.questionnaires
@questions = retrieve_questions questionnaires, @assignment.id
# @pscore has the newest versions of response for each response map, and only one for each response map (unless it is vary rubric by round)
@pscore = @participant.scores(@questions)
@pscore = ResponseMap.participant_scores(@participant, @questions)
make_chart
@topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)
@stage = @participant.assignment.get_current_stage(@topic_id)
@stage = @participant.assignment.current_stage(@topic_id)
penalties(@assignment.id)
# prepare feedback summaries
summary_ws_url = WEBSERVICE_CONFIG["summary_webservice_url"]
Expand All @@ -81,7 +81,7 @@ def view_team
@team_id = @team.id
questionnaires = @assignment.questionnaires
@questions = retrieve_questions questionnaires, @assignment.id
@pscore = @participant.scores(@questions)
@pscore = ResponseMap.participant_scores(@participant, @questions)
@vmlist = []

# loop through each questionnaire, and populate the view model for all data necessary
Expand All @@ -108,7 +108,7 @@ def edit
@participant = AssignmentParticipant.find(params[:id])
@assignment = @participant.assignment
@questions = list_questions(@assignment)
@scores = @participant.scores(@questions)
@scores = ResponseMap.participant_scores(@participant, @questions)
end

def instructor_review
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/response_controller.rb
Expand Up @@ -123,7 +123,7 @@ def update
def new
assign_action_parameters
set_content(true)
@stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id)) if @assignment
@stage = @assignment.current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id)) if @assignment
# Because of the autosave feature and the javascript that sync if two reviewing windows are opened
# The response must be created when the review begin.
# So do the answers, otherwise the response object can't find the questionnaire when the user hasn't saved his new review and closed the window.
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/student_review_controller.rb
Expand Up @@ -16,7 +16,7 @@ def list
@assignment = @participant.assignment
# Find the current phase that the assignment is in.
@topic_id = SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id)
@review_phase = @assignment.get_current_stage(@topic_id)
@review_phase = @assignment.current_stage(@topic_id)
# E-1973 calling get_reviewer on a participant will return either that participant
# or there team, depending on if reviewers are teams. If the reviewer is not yet on a team, just set review_mappings
# to an empty list to prevent errors
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/student_teams_controller.rb
Expand Up @@ -171,7 +171,7 @@ def student_team_requirements_met?
return false
end
#checks that the student has selected some topics
return @student.assignment.topics?
@student.assignment.topics?

end

Expand Down
10 changes: 5 additions & 5 deletions app/controllers/submitted_content_controller.rb
Expand Up @@ -30,7 +30,7 @@ def edit
SignUpSheet.signup_team(@assignment.id, @participant.user_id, nil) if @participant.team.nil?
# @can_submit is the flag indicating if the user can submit or not in current stage
@can_submit = !params.key?(:view)
@stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))
@stage = @assignment.current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))
end

# view is called when @assignment.submission_allowed(topic_id) is false
Expand All @@ -41,7 +41,7 @@ def view
@assignment = @participant.assignment
# @can_submit is the flag indicating if the user can submit or not in current stage
@can_submit = false
@stage = @assignment.get_current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))
@stage = @assignment.current_stage(SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id))
redirect_to action: 'edit', id: params[:id], view: true
end

Expand Down Expand Up @@ -191,20 +191,20 @@ def download
def check_content_type_integrity(file_content)
limited_types = ['application/pdf', 'image/png', 'image/jpeg', 'application/zip', 'application/x-tar', 'application/x-7z-compressed', 'application/vnd.oasis.opendocument.text', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']
mime = MimeMagic.by_magic(file_content)
return limited_types.include? mime.to_s
limited_types.include? mime.to_s
end

# Verify the size of uploaded file is under specific value.
# @param file [Object] uploaded file
# @param size [Integer] maximum size(MB)
# @return [Boolean] the result of verification
def check_content_size(file, size)
return !(file.size > size*1024*1024)
!(file.size > size*1024*1024)
end

def get_file_type file_name
base = File.basename(file_name)
return base.split(".")[base.split(".").size - 1] if base.split(".").size > 1
base.split(".")[base.split(".").size - 1] if base.split(".").size > 1
end

def move_selected_file
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/tree_display_controller.rb
Expand Up @@ -295,8 +295,8 @@ def serialize_folder_to_json(folder_type, node)
serialize_assignment_to_json(node, json)
end
end
return json

json
end

# Creates a json object that can be displayed by the UI
Expand All @@ -320,8 +320,8 @@ def serialize_sub_folder_to_json(node)
serialize_assignment_to_json(node, json)
end
end
return json

json
end

# Checks if the user is the instructor for the course or assignment node provided.
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/authorization_helper.rb
Expand Up @@ -150,7 +150,7 @@ def find_assignment_from_response_id(response_id)
response = Response.find(response_id.to_i)
response_map = response.response_map
if response_map.assignment
return response_map.assignment
response_map.assignment
else
find_assignment_from_response_id(response_map.reviewed_object_id)
end
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/conference_helper.rb
Expand Up @@ -29,9 +29,9 @@ def get_redirect_url_link
#if conference user is already logged in the redirect to Student_task list page
# else redirect to login page.
if current_user && current_role_name == "Student"
return '/student_task/list'
'/student_task/list'
else
return '/'
'/'
end
end

Expand Down Expand Up @@ -68,7 +68,7 @@ def create_coauthor
password = @user.reset_password
#Mail to be sent to co-author once the user has been created. New partial is used as content for email is different from normal user
MailerHelper.send_mail_for_conference_user(@user, "Your Expertiza account has been created.", "user_conference_invitation", password,current_user.name).deliver
return @user
@user
end
end

Expand Down
12 changes: 6 additions & 6 deletions app/helpers/grades_helper.rb
@@ -1,7 +1,7 @@
module GradesHelper
# Render the title
def get_accordion_title(last_topic, new_topic)
if last_topic.eql? nil
def accordion_title(last_topic, new_topic)
if last_topic.nil?
# this is the first accordion
render partial: "response/accordion", locals: {title: new_topic, is_first: true}
elsif !new_topic.eql? last_topic
Expand Down Expand Up @@ -152,23 +152,23 @@ def view_heatgrid(participant_id, type)
def type_and_max(row)
question = Question.find(row.question_id)
if question.type == "Checkbox"
return 10_003
10_003
elsif question.is_a? ScoredQuestion
return 9311 + row.question_max_score
else
return 9998
9998
end
end

def underlined?(score)
return "underlined" if score.comment.present?
"underlined" if score.comment.present?
end

def retrieve_questions(questionnaires, assignment_id)
questions = {}
questionnaires.each do |questionnaire|
round = AssignmentQuestionnaire.where(assignment_id: assignment_id, questionnaire_id: questionnaire.id).first.used_in_round
questionnaire_symbol = if !round.nil?
questionnaire_symbol = unless round.nil?
(questionnaire.symbol.to_s + round.to_s).to_sym
else
questionnaire.symbol
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/penalty_helper.rb
Expand Up @@ -17,7 +17,7 @@ def calculate_penalty(participant_id)
# use its value to check if the penalty is to be calculated for the assignment or not
if calculate_penalty == true
topic_id = SignedUpTeam.topic_id(@participant.parent_id, @participant.user_id)
stage = @assignment.get_current_stage(topic_id)
stage = @assignment.current_stage(topic_id)
if stage == "Finished"
penalties[:submission] = calculate_submission_penalty
penalties[:review] = calculate_review_penalty
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/review_mapping_helper.rb
Expand Up @@ -320,15 +320,15 @@ def calculate_key_chart_information(intervals)
intervals = intervals.select{|v| v < threshold}

#Get Metrics once tagging intervals are available
if not intervals.empty?
unless intervals.empty?
metrics = Hash.new
metrics[:mean] = (intervals.reduce(:+) / intervals.size.to_f).round(interval_precision)
metrics[:min] = intervals.min
metrics[:max] = intervals.max
sum = intervals.inject(0){|accum, i| accum +(i- metrics[:mean])**2}
metrics[:variance] = (sum/(intervals.size).to_f).round(interval_precision)
metrics[:stand_dev] = Math.sqrt(metrics[:variance]).round(interval_precision)
return metrics
metrics
end
#if no Hash object is returned, the UI handles it accordingly
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/string_operation_helper.rb
Expand Up @@ -8,7 +8,7 @@ def string_similarity(str1, str2)
pairs1 = get_ngrams(str1,3)
pairs2 = get_ngrams(str2,3)

return (2.0 * (pairs1 & pairs2).size / (pairs1.size + pairs2.size))
(2.0 * (pairs1 & pairs2).size / (pairs1.size + pairs2.size))
end

private
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/student_task_helper.rb
Expand Up @@ -14,7 +14,7 @@ def get_review_grade_info(participant)
end

def check_reviewable_topics(assignment)
return true if !assignment.topics? and assignment.get_current_stage != "submission"
return true if !assignment.topics? and assignment.current_stage != "submission"
sign_up_topics = SignUpTopic.where(assignment_id: assignment.id)
sign_up_topics.each {|topic| return true if assignment.can_review(topic.id) }
false
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/submitted_content_helper.rb
Expand Up @@ -4,7 +4,7 @@ def display_directory_tree(participant, files, display_to_reviewer_flag)
participant = @participant if @participant # TODO: Verify why this is needed
assignment = participant.assignment # participant is @map.contributor
topic_id = SignedUpTeam.topic_id(participant.parent_id, participant.user_id) # participant is @map.reviewer
check_stage = assignment.get_current_stage(topic_id)
check_stage = assignment.current_stage(topic_id)

ret = "\n<table id='file_table' cellspacing='5'>"
ret += "\n <tr><th>Name</th><th>Size</th><th>Type</th><th>Date Modified</th></tr>"
Expand Down
3 changes: 1 addition & 2 deletions app/models/answer_tag.rb
Expand Up @@ -9,8 +9,7 @@ class AnswerTag < ActiveRecord::Base

def tag_prompt
tag_dep = TagPromptDeployment.find(self.tag_prompt_deployment_id)
tag_prompt = TagPrompt.find(tag_dep.tag_prompt_id)
tag_prompt
TagPrompt.find(tag_dep.tag_prompt_id)
end

def tag_prompt_html_control user_id
Expand Down