Skip to content

Commit

Permalink
Merge 2a091b5 into 695772b
Browse files Browse the repository at this point in the history
  • Loading branch information
Ragavendran B committed Nov 29, 2017
2 parents 695772b + 2a091b5 commit 1245ec1
Show file tree
Hide file tree
Showing 11 changed files with 528 additions and 254 deletions.
477 changes: 246 additions & 231 deletions Gemfile.lock

Large diffs are not rendered by default.

17 changes: 17 additions & 0 deletions app/controllers/grades_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ def retrieve_questions(questionnaires)

def view_my_scores
@participant = AssignmentParticipant.find(params[:id])
# Getting the team data from participant, for the purpose of assigning it in the VM object
@team = @participant.team
@team_id = TeamsUser.team_id(@participant.parent_id, @participant.user_id)
return if redirect_when_disallowed
@assignment = @participant.assignment
Expand All @@ -78,6 +80,7 @@ def view_my_scores
retrieve_questions questionnaires
# @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)

make_chart
@topic_id = SignedUpTeam.topic_id(@participant.assignment.id, @participant.user_id)
@stage = @participant.assignment.get_current_stage(@topic_id)
Expand All @@ -88,6 +91,20 @@ def view_my_scores
@summary = sum.summary
@avg_scores_by_round = sum.avg_scores_by_round
@avg_scores_by_criterion = sum.avg_scores_by_criterion
# The computation of composite self review scores,require both self review and peer review scores
# the computation is same as we do in alternate view
# refer view_team action for the same computation that goes there
questionnaires.each do |questionnaire|
if questionnaire.type == "ReviewQuestionnaire"
@vm = VmQuestionResponse.new(questionnaire, @assignment)
vmquestions = questionnaire.questions
@vm.add_questions(vmquestions)
@vm.add_team_members(@team)
@vm.add_reviews(@participant, @team,@assignment.varying_rubrics_by_round?)
@vm.get_number_of_comments_greater_than_10_words

end
end
end

# method for alternative view
Expand Down
4 changes: 3 additions & 1 deletion app/models/response_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ def self.get_assessments_for(team)
maps.each do |map|
next if map.response.empty?
@all_resp = Response.where(map_id: map.map_id).last
if map.type.eql?('ReviewResponseMap')
# this method (i.e get_assessments_for) should be available for both self and peer review
# this method is inherited in both ReviewResponseMap and SelfReviewResponseMap class where it will be used.
if map.type.eql?('ReviewResponseMap') || map.type.eql?('SelfReviewResponseMap')
# If its ReviewResponseMap then only consider those response which are submitted.
@array_sort << @all_resp if @all_resp.is_submitted
else
Expand Down
58 changes: 50 additions & 8 deletions app/models/vm_question_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
class VmQuestionResponse
@questionnaire = nil
@assignment = nil
@self_reviews = nil

def initialize(questionnaire, assignment=nil)
@assignment = assignment
Expand All @@ -13,17 +14,18 @@ def initialize(questionnaire, assignment=nil)
end

@rounds = @assignment.rounds_of_reviews

@list_of_rows = []
@list_of_reviewers = []
@list_of_reviews = []

@list_of_team_participants = []
@max_score = questionnaire.max_question_score
@questionnaire_type = questionnaire.type
@questionnaire_display_type = questionnaire.display_type
@rounds = rounds
@round = round
@name = questionnaire.name
@aggregate_self_review_composite_score = 0
end

attr_reader :name
Expand All @@ -44,19 +46,28 @@ def add_questions(questions)

def add_reviews(participant, team, vary)
if @questionnaire_type == "ReviewQuestionnaire"
# 1799
# should add types of Self_review_Resonse_map too in the response
reviews = if vary
ReviewResponseMap.get_responses_for_team_round(team, @round)
else
ReviewResponseMap.get_assessments_for(team)
end

self_reviews = SelfReviewResponseMap.get_assessments_for(team)

reviews.each do |review|
review_mapping = ReviewResponseMap.find(review.map_id)
if review_mapping.present?
review_mapping = ReviewResponseMap.find_by(review.map_id)
self_review_mapping = SelfReviewResponseMap.find_by(review.map_id)
if review_mapping && review_mapping.present?
participant = Participant.find(review_mapping.reviewer_id)
@list_of_reviewers << participant
end
end
end
@list_of_reviews = reviews

@list_of_reviews = reviews
@self_reviews = self_reviews

elsif @questionnaire_type == "AuthorFeedbackQuestionnaire"
reviews = participant.feedback # feedback reviews
reviews.each do |review|
Expand Down Expand Up @@ -85,12 +96,21 @@ def add_reviews(participant, team, vary)
end
end

# 1799 adding answers part
reviews.each do |review|
answers = Answer.where(response_id: review.response_id)
answers.each do |answer|
add_answer(answer)
add_answer(answer,"ResponseReview")
end
end

if self_reviews
answers = Answer.where(response_id: self_reviews[0].response_id)
answers.each do |answer|
add_answer(answer,"SelfReview")
end
end

end

def display_team_members
Expand Down Expand Up @@ -134,13 +154,30 @@ def max_score_for_questionnaire

attr_reader :list_of_reviews

attr_reader :self_reviews

attr_reader :list_of_rows

attr_reader :list_of_reviewers

def add_answer(answer)
attr_reader :aggregate_self_review_composite_score





def computed_self_review_score
total_self_review_composite_score =0
if @list_of_rows.length > 0
total_self_review_composite_score = @aggregate_self_review_composite_score * 100 / @list_of_rows.length
end
total_self_review_composite_score.round(2)
end

def add_answer(answer,review_type)
# We want to add each response score from this review (answer) to its corresponding
# question row.

@list_of_rows.each do |row|
next unless row.question_id == answer.question_id
# Go ahead and calculate what the color code for this score should be.
Expand Down Expand Up @@ -173,13 +210,18 @@ def add_answer(answer)

# Now construct the color code and we're good to go!
color_code = "c#{color_code_number}"

if review_type == "ResponseReview"
row.score_row.push(VmQuestionResponseScoreCell.new(answer.answer, color_code, answer.comments, vm_tag_prompts))
else
row.self_review_score = VmQuestionResponseScoreCell.new(answer.answer, color_code, answer.comments, vm_tag_prompts)
@aggregate_self_review_composite_score += row.weighted_diff_for_row
end
end
end

def get_number_of_comments_greater_than_10_words
first_time = true

@list_of_reviews.each do |review|
answers = Answer.where(response_id: review.response_id)
answers.each do |answer|
Expand Down
15 changes: 15 additions & 0 deletions app/models/vm_question_response_row.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ def initialize(questionText, question_id, weight, question_max_score, seq)
@score_row = []

@countofcomments = 0

@self_review_score = -1
end

attr_reader :countofcomments
Expand All @@ -28,6 +30,8 @@ def initialize(questionText, question_id, weight, question_max_score, seq)

attr_reader :weight

attr_accessor :self_review_score

# the question max score is the max score of the questionnaire, except if the question is a true/false, in which case
# the max score is one.
def question_max_score
Expand All @@ -51,4 +55,15 @@ def average_score_for_row
row_average_score /= @score_row.length.to_f
row_average_score.round(2)
end

# it calculates the difference between the self review score and average of all reviews.
def weighted_diff_for_row
weighted_average_score = average_score_for_row / question_max_score
weighted_self_review_score = self_review_score.score_value / question_max_score
result = weighted_average_score - weighted_self_review_score
result = result > 0 ? result : -result
end



end
5 changes: 5 additions & 0 deletions app/views/grades/_participant.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
rscore_metareview = Rscore.new(pscore,:metareview) if pscore[:metareview]
rscore_feedback = Rscore.new(pscore,:feedback) if pscore[:feedback]
rscore_teammate = Rscore.new(pscore,:teammate) if pscore[:teammate]
self_review_score = @vm.computed_self_review_score
%>

<TR <% if team %> id="<%= prefix %>" style="display:none; background-color: white;" <% end %>>
Expand Down Expand Up @@ -142,6 +143,10 @@
<% end %>
</TD>
<% end %>
<TD align="center">
<%= self_review_score.is_a?(Float)?sprintf("%.2f",self_review_score):rscore_review.my_avg %><%= score_postfix %>
</TD>

</TR>

<% if (controller.action_name != "view_my_scores" and index == team_size - 1) or controller.action_name == "view_my_scores" %>
Expand Down
19 changes: 19 additions & 0 deletions app/views/grades/_participant_charts.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@

</div>
</th>


<th style="text-align:center;" WIDTH="<%= colwidth %>%">&nbsp;
<div class="circle" id="self-review-circle">

</div>
</th>

</TR>

Expand Down Expand Up @@ -94,6 +101,18 @@
textClass: 'circles-final'
});

var myCircle = Circles.create({
id: 'self-review-circle',
radius: 35,
value: <%= @vm.computed_self_review_score.to_i %>,
maxValue: 100,
width: 15,
text: '<%=@vm.computed_self_review_score.to_i==-1? "N/A":@vm.computed_self_review_score.to_i%>',
colors: ['#99ffa4', '#077512'],
duration: 700,
textClass: 'self-review-circle'
});

</script>

<style>
Expand Down
19 changes: 16 additions & 3 deletions app/views/grades/_participant_title.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@
<!--100 = 16 + 6 * 12 + 12-->
<% namecolwidth = 16 %>
<% colwidth = 12 %>
<% else %>
<!--100 = 25 + 4 * 15 + 15-->
<% namecolwidth = 25 %>
<% colwidth = 15 %>
<% end %>
<%if @vm.self_reviews %>
<% colwidth = 10 %>
<%end%>

<tr <% if prefix %>id='<%= prefix %>_1' style="background-color: lightgray;"<% end %>>
<th style="text-align:center;" WIDTH="<%= namecolwidth %>%">&nbsp;</th>
<th style="text-align:center;" COLSPAN="2" WIDTH="<%= colwidth*2 %>%">Submitted work</th>
Expand All @@ -22,7 +27,11 @@
<% if has_team_and_metareview?[:has_team] %>
<th style="text-align:center;" COLSPAN="2" WIDTH="<%= colwidth*2 %>%">Teammate Review</th>
<% end %>
<th style="text-align:center;" WIDTH="<%= colwidth %>%">&nbsp;</th></tr>

<th style="text-align:center;" WIDTH="<%= colwidth %>%">&nbsp;</th>
<th style="text-align:center;" WIDTH="<%= colwidth %>%">&nbsp;</th>

</tr>

<tr <% if prefix %>id='<%= prefix %>_2' style="display:none; background-color: lightgray;"<% end %>>
<th style="text-align:left;" WIDTH="<%= namecolwidth %>%" ALIGN="LEFT">Contributor</th>
Expand All @@ -39,5 +48,9 @@
<th style="text-align:center;" WIDTH="<%= colwidth %>%">Average</th>
<th style="text-align:center;" WIDTH="<%= colwidth %>%">Range </th>
<% end %>
<th style="text-align:center;" WIDTH="<%= colwidth %>%">Final Score</th></tr>

<th style="text-align:center;" WIDTH="<%= colwidth %>%">Final Score</th>
<%if @vm.self_reviews%>
<th style="text-align:center;" WIDTH="<%= colwidth * 2 %>%">Self Review Score</th>
<%end%>

</tr>
5 changes: 4 additions & 1 deletion app/views/grades/view_my_scores.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@
:participant_id => ptid = @participant.id,
:index => 0,
:team_size => 1,
:pscore => @pscore} %>
:pscore => @pscore,
:vm => @vm} %>


</TABLE>

<% case @assignment.reputation_algorithm %>
<% when 'Hamer' %>
<h3>Reputation</h3>
Expand Down
Loading

0 comments on commit 1245ec1

Please sign in to comment.