-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
view_team.html.erb
307 lines (284 loc) · 17.2 KB
/
view_team.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
<script type="text/javascript" src="/assets/view_team_in_grades.js"></script>
<script type="text/javascript">
$( document ).ready(function() {
$('#tag_prompt_toggler').click(function () {
if ($('#tag_prompt_toggler').text() == t(".hide_tags"))
$('#tag_prompt_toggler').text(t(".show_tags"))
else
$('#tag_prompt_toggler').text(t(".hide_tags"))
$('.tag_prompt_container').toggle();
$('.tag_heat_grid').toggle();
});
tagActionOnLoad(); // Added March 2021 -- Sets up Tagging Report Heatgrid On Load
});
function toggleFunction(elementId) {
var target = document.getElementById(elementId);
if (target.style.display === 'none') {
target.style.display = 'block';
} else {
target.style.display = 'none';
}
}
</script>
<h2><%=t ".summary_report"%> <%= @assignment.name %></h2>
<!-- Anchor for Tag Heatgrid. Heatgrid generation code located in /assets/javascripts/view_team_in_grades.js -->
<table id="tag_heat_grid" class="tag_heat_grid"></table>
<h4><%=t ".team"%> <%= @team.name(session[:ip]) %></h4>
<!--Obtain topic name from assignment helper-->
<% topic_id, topic_name, users_for_curr_team, participants = get_data_for_list_submissions(@team) %>
<% if @assignment.topics? %>
<h4><%=t ".topic"%> <%= topic_id + '. ' + topic_name %></h4>
<% end %>
<!--Obtain only review scores
Bugfix E2100 -- Single-round reviews use the :review symbol, multi-round reviews use :review1 and :review2. Average
score not being computed and shown for multi-round reviews. Check for :review1 and :review2 symbols, generate arithmetic
means of each, and take arithmetic mean of both to display. If :review symbol present, use original logic.
-->
<% if @pscore[:review1] && @pscore[:review2] && @pscore[:review1]
[:assessments].any? && @pscore[:review2][:assessments].any? %>
<% rscore_review1 = Rscore.new(@pscore,:review1) %>
<% rscore_review2 = Rscore.new(@pscore,:review2) %>
<!--Bugfix 2570 -- Added condition to check if my_avg is "N/A" for any review. The reviews with a valid average is considered.
-->
<% average = 0 %>
<% number_of_reviews = 0 %>
<% if rscore_review1.my_avg != "N/A" %>
<% average += rscore_review1.my_avg %>
<% number_of_reviews += 1 %>
<% end %>
<% if rscore_review2.my_avg != "N/A" %>
<% average += rscore_review2.my_avg %>
<% number_of_reviews += 1 %>
<% end %>
<% average /= number_of_reviews unless number_of_reviews.zero? %>
<h4><%=t ".average_peer_review"%> <span class = "c5"><%= average.is_a?(Float)? sprintf("%.2f",average): average %></span></h4>
<% elsif @pscore[:review] %>
<% rscore_review = Rscore.new(@pscore,:review)%>
<h4><%=t ".average_peer_review"%> <span class = "c5"><%= rscore_review.my_avg.is_a?(Float)? sprintf("%.2f",rscore_review.my_avg): rscore_review.my_avg %></span></h4>
<%else %>
<h4> <%=t ".no_reviews_for_assignment"%></h4>
<%end %>
<!--Toggle submission-->
<button onclick="toggleFunction('<%= @participant.id.to_s%>')" class="btn btn-default"><%=t ".show_submission"%></button>
<div id="<%= @participant.id.to_s%>" style="display:none;">
<% if @participant.team.hyperlinks.try(:length) %>
<%= render :partial => 'submitted_content/hyperlink', :locals => {participant: @participant, stage: @stage} %>
<% else %>
<b><%=t ".no_submission"%></b>
<% end %>
</div><br><br>
<!-- For each of the models in the list, generate a heatgrid table. this is the outer most loop -->
<% @vmlist.each_with_index do |vm, table_count| %>
<% if (vm.questionnaire_display_type == "Metareview" || vm.questionnaire_display_type == "Author Feedback" || vm.questionnaire_display_type == "Teammate Review") and @current_role_name.eql?'Student' %>
<% else %>
<% if vm.list_of_reviewers.length > 0 %>
<!-- display the list of questions for this questionnaire -->
<div id="hid<%= vm.questionnaire_type + vm.round.to_s %>" class="accordion-body collapse" style="max-width: 80%">
<table class="table table-striped">
<thead>
<th>#</th>
<th><%=t ".question"%></th>
</thead>
<% vm.list_of_rows.each_with_index do |row, count| %>
<% if row.score_row.count > 0 %>
<tr style="background-color: #ffffff;">
<td><%= count %></td>
<td><%= row.question_text %></td>
</tr>
<% end %>
<% end %>
</table>
</div>
<!-- display the table title and tooltips -->
<span style="width:100%;">
<h4 style="display:inline-block;"><%= vm.questionnaire_display_type %>
<% if vm.questionnaire_type == "ReviewQuestionnaire" %>
(<%=t ".round"%>: <%= vm.round.to_s %> <%=t ".of"%> <%= vm.rounds.to_s %>)
<%end %>
</h4>
<span class="spn_qsttog" data-toggle="collapse" class="accordion-toggle" data-target="#hid<%= vm.questionnaire_type + vm.round.to_s %>" data-toggle="tooltip" data-placement="right" title="Click to display/hide questions"><%=t ".toggle_question_list"%></span>
<% if @assignment.is_answer_tagging_allowed %>
<span class="spn_qsttog" id="tag_prompt_toggler" title=""><%=t ".hide_tags"%></span>
<% end %>
<span class="spn_tooltip" data-toggle="tooltip" data-placement="right" title="Colors are scaled from poor to excellent in the following order: red, orange, yellow, light-green, dark-green"><%=t ".color_legend"%></span>
<span class="spn_tooltip" data-toggle="tooltip" data-placement="right" title=t(".interaction_legend_tooltip")><%=t ".interaction_legend"%></span>
</span>
<!--
Changes to this was done as part of E1788_OSS_project_Maroon_Heatmap_fixes
scoreTable was previously assigned as id for all the table which required to be sortable
change was made to keep it unique by adding round number at the end
also scoreTable was added as class to each of the table to make it sortable
remaining changes could be found in app/assets/javascripts/view_team_in_grades.js
fix comment end
-->
<br/>
<!-- This iterates over the list of metrics and shows them as checkboxes which can be used for toggling the metric in heatgrid-->
<% vm.list_of_rows.first.metric_hash.each do |key, value| %>
<% newKey = key.split(" ").join("") %>
<input type="checkbox" id="<%= newKey %>" onchange = onMetricToggle(this)><%=key%> </input>
<% end %>
<div class="hide-scrollbar">
<table id="scoresTable<%= vm.round.to_s %>" class="scoresTable tbl_heat tablesorter">
<!-- display the header row of the heatgrid table. this involves iterating through reviewers.-->
<thead>
<tr class="hide-scrollbar">
<th class="sorter-true">Question<span></span></th>
<% i_final = 0 %>
<% vm.list_of_reviews.each_with_index do |review, i| %>
<!-- instructors (or higher level users) see reviewer name, students see anonymized string -->
<% if (['Student'].include? @current_role_name) && @assignment.is_anonymous%>
<%= render :partial => 'add_icon_to_name', :locals => {review: review, i: i} %>
<% else %>
<% user_name = User.find(Participant.find(ResponseMap.find(Response.find(review.id).map_id).reviewer_id).user_id).fullname(session[:ip]).to_s %>
<%= render :partial => 'add_icon_to_name', :locals => {review: review, i: i} %>
<% end %>
<% i_final = 0%>
<% end %>
<th class="sorter-true" align="right" >
Avg<span></span>
</th>
<!-- <span data-toggle="tooltip" data-placement="right" title="<%=t(".metric_tooltip")%>"><%=t ".metric1"%></span> -->
<!-- Iterating over the list of metrics and showing them in the header of table -->
<% vm.list_of_rows.first.metric_hash.each do |key, value| %>
<% newKey = key.split(" ").join("") %>
<th class="sorter-false metric-header <%= newKey %>" style="display:none">
<span data-toggle="tooltip" data-placement="right" title="<%=t(".metric_tooltip")%>" ><%=key%></span>
</th>
<% end %>
</tr>
</thead>
<% score_row_count = vm.list_of_rows.first.score_row.count %>
<!-- here, starts a series of nested loops. loops for the rows, and for the cells of the rows.-->
<!-- additionally, there are hidden rows (expandable) which are also generated via iteration. -->
<% vm.list_of_rows.each_with_index do |row, j| %>
<!-- notice the data-target. because we're toggling via looped code, we need to dynamically generate the identifier. -->
<tr data-toggle="collapse" class="accordion-toggle" data-target="#hid<%= row.question_id.to_s + vm.round.to_s %>">
<td class = 'cf' data-toggle="tooltip" title="<%= row.question_text %>"> <div style='float: left'><%= (j+1).to_s %></div><div style='float: right'> &#<%= type_and_max(row) %>;</div> </td>
<!-- actual cells with scores and colored background. -->
<% row.score_row.each do |score| %>
<% score_comment = score.comment.nil? ? '' : score.comment %>
<td class="<%= score.color_code %>" align="center" data-toggle="tooltip" title="<%= strip_tags(score_comment).html_safe%>">
<span class="<%= underlined?(score) %>"><%= score.score_value.to_s %></span>
</td>
<% end %>
<% if row.score_row.count.zero? %>
<% (0.upto(score_row_count - 1)).each do |index| %>
<td align="center">
<%= "" %>
</td>
<% end %>
<% end %>
<td class = 'cf' align="right">
<%= row.average_score_for_row.to_s %>
</td>
<!-- Iterating over the list of metrics and showing them in the table -->
<% row.metric_hash.each do |key, value| %>
<% newKey = key.split(" ").join("") %>
<td class = 'cf metric-value <%= newKey %>' align="center" style="display:none">
<%= value.to_s %>
</td>
<% end %>
</tr>
<!--loop that creates the collapsed-by-default row, which lists all comments. -->
<tr class="tablesorter-childRow">
<td colspan="<%= (i_final+1).to_s %>" class="hiddenRow" ><div id="hid<%= row.question_id.to_s + vm.round.to_s %>" class="accordion-body collapse" style="margin-left:10px;">
<div style="padding-top: 10px; padding-bottom: 10px;"><%= sanitize row.question_text %></div>
<div>
<table class="table tbl_questlist">
<thead>
<th><%=t ".review"%> </th>
<th><%=t ".score"%></th>
<th><%=t ".Comment"%></th>
</thead>
<% (0.upto(row.score_row.length - 1)).each do |index| %>
<tr>
<td><%=t ".review"%> <%=index + 1%></td>
<td class="<%= row.score_row[index].color_code.to_s %>" align="center" ><%= row.score_row[index].score_value.to_s %></td>
<% if vm.questionnaire_type == "ReviewQuestionnaire" %>
<!-- E2100 : Set id and data of this <td> to be queried by jQuery for the tagging report
HTML "id" format: "rr3_13" == ReviewRow Question 3 Review 13
"j" "index" and "round" are legacy variables from past projects; populate jQueryable
data- fields with these data to be queried later.
"round" represents number of this review round
"j" represents number of this question
"index" represents number of this review
-->
<td id="<%= 'rr'+ (j+1).to_s + '_' + index.to_s %>" data-round="<%= vm.round.to_s %>="
data-question_num="<%= (j+1).to_s %>" data-review_num="<%= index.to_s %>"
data-has_tag="<%= row.score_row[index].vm_prompts.count > 0 ? "true":"false"%>">
<% else %>
<td>
<% end %>
<%= row.score_row[index].comment.html_safe unless row.score_row[index].comment.nil? %>
<% if row.score_row[index].vm_prompts.count > 0 %>
<div class="tag_prompt_container">
<% row.score_row[index].vm_prompts.each do |vm_tag_prompt| %>
<%= vm_tag_prompt.tag_prompt.html_control(vm_tag_prompt.tag_dep, vm_tag_prompt.answer, @current_user) %>
<% end %>
</div>
<% end %>
</td>
</tr>
<% end %>
</table>
</div>
</div>
</td>
</tr>
<% end %>
<!--displays the row for the addl comments, by default: collapsed. -->
<tr>
<td colspan="<%= (i_final+1).to_s %>" class="hiddenRow" >
<div id="hid<%= vm.questionnaire_type + vm.round.to_s + "comment" %>" class="accordion-body collapse" style="margin-left:10px;">
<div style="background-color:#A9A9F5;padding:4px;">
<table class="table tbl_addlcmt">
<thead>
<th><%=t ".review"%></th>
<th ><%=t ".additional_comments"%></th>
</thead>
<tbody>
<% vm.list_of_reviews.each_with_index do |review, k| %>
<tr><td ><%= k+1 %></td>
<td ><%= Response.find(review.id)["additional_comment"] %></td></tr>
<% end %>
</tbody>
</table>
</div>
</div>
</td>
</tr>
</table>
</div>
<!-- Display the list of team members, for Peer Reviews. -->
<div style="margin-top:5px"></div>
<input class="btn btn-default" type="button" href="#" onclick="col_sort(<%=table_count%>)" data-toggle="tooltip" title="Sort reviews in ascending/descending order of the total score. Consecutive clicks will alternate between ascending and descending sort order" value="Sort by total review score"/>
<span> <%= vm.display_team_members(session[:ip]) %></span>
<!-- this elsif terminates the heatgrid code. -->
<% elsif vm.questionnaire_type != "ReviewQuestionnaire" %>
<br><div class="alert alert-warning"><%=t ".no_review_of"%> <%= vm.questionnaire_type %> TYPE EXISTS. </div>
<% end %>
<br/>
<% end %>
<% end %>
<!-- termination of the main outer loop.-->
<!-- Get course ID and TA ID to restrict TAs ability to update his grades-->
<%
@course_id = Assignment.find_by(id: @participant.parent_id).course_id
@ta_id = @participant.user_id
%>
<h4 style="font-weight:bold;display:inline-block;"><%=t ".grade_and_comment"%></h4><br/>
<% if ['Student', 'Teaching Assistant'].include? current_user.role.name %>
<%=t ".grade"%>: <%= label_tag 'grade_for_submission', @team.try(:grade_for_submission) %><br/>
<%=t ".Comment"%>: <%= label_tag 'comment_for_submission', @team.try(:comment_for_submission) %><br>
<%=t ".late_penalty"%>: <%= label_tag 'late_penalty', @penalties[:submission] %><br/>
<% end %>
<% if TaMapping.where(ta_id: @ta_id, course_id: @course_id).exists? || current_user == @assignment.instructor%>
<h4 style="font-weight:bold;display:inline-block;">TA Grade-Comment:</h4><br/>
<%= form_tag 'save_grade_and_comment_for_submission' do %>
<%= hidden_field_tag :participant_id, params[:id] %>
<%= number_field_tag 'grade_for_submission', @team.try(:grade_for_submission) ,min: 0, max: 100, maxlength: 3, size: 3, class: "form-control width-150", placeholder: t(".grade") %><br/>
<%= text_area_tag 'comment_for_submission', @team.try(:comment_for_submission), size: '75x10', placeholder: t(".Comment"), class: "form-control width-500" %><br>
<%= submit_tag t(".save") ,class: "btn btn-default" %>
<% end %>
<% end %>
<%= link_to 'Back', :back %>