/
show.html.erb
executable file
·318 lines (280 loc) · 14.9 KB
/
show.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
308
309
310
311
312
313
314
315
316
317
318
<% content_for :javascripts do %>
<%= javascript_include_tag "assessments_show" %>
<%= javascript_include_tag 'validateIntegrity.js' %>
<script>
function toggleAria(id) {
var expanded = document.getElementById(id).getAttribute("aria-expanded");
if (expanded == "true") {
expanded = "false"
} else {
expanded = "true"
}
document.getElementById(id).setAttribute("aria-expanded", expanded);
}
$(document).ready(function(){
$('.collapsible').collapsible();
});
</script>
<% end %>
<%# Make sure these options are not on the general user options list. %>
<%# We have to do this because we exposed the internal interface for building options lists %>
<%# and some users have fiddled with this in their assessment.rb file %>
<%# These options have been eliminated %>
<% @list.delete("listAdmin") %>
<%# These options should only be on the admin list %>
<% @list.delete("edit") %>
<% @list.delete("viewGradesheet") %>
<% @list.delete("attachments") %>
<% @list.delete("extension") %>
<% @list.delete("submission") %>
<% @list.delete("reload") %>
<div class="">
<div class="row">
<div class="col s12 m12">
<h2 class="">
<%= @assessment.display_name %>
</h2>
<p style="margin-left: 5px"><i><%= @assessment.description %></i></p>
</div>
</div>
<hr>
<div class="row">
<div class="col s12 m4">
<%# Display any optional instructor admin options %>
<% if @cud.instructor? then %>
<ul class="collapsible" data-collapsible="accordion">
<li class="collapsible-menu-link active" id="admin-options" aria-role="button" aria-expanded="true" onclick="toggleAria('admin-options')" onkeydown="toggleAria('admin-options')">
<div class="collapsible-header"><h5>Admin Options</h5></div>
<div class="collapsible-body">
<ul class="options">
<li> <%= link_to "Edit assessment", {:action => "edit" }, {:title=> "View and modify the properties for this assessment, including its problems", :class=>""} %></li>
<li> <%= link_to "Grade submissions", {:action => "viewGradesheet" }, {:title=> "View and enter grades on the gradesheet" } %></li>
<li> <%= link_to "Export assessment", {:action => "export" }, {:title=> "Export persistent properties that will be imported when you install this assessment in a future term" } %></li>
<% if @assessment.has_autograder? then %>
<li><%= link_to "Autograder settings", [:edit, @course, @assessment, :autograder], title: "Modify autograding properties such as the VM image and the timeout value" %></li>
<% end %>
<% if @assessment.has_groups? %>
<li><%= link_to "Group settings", [@course, @assessment, :groups], title: "Manage group settings" %></li>
<% end %>
<% if @assessment.has_scoreboard? %>
<li><%= link_to "Scoreboard settings", [:edit, @course, @assessment, :scoreboard], title: "Configure the appearance of the scoreboard" %></li>
<% end %>
<li> <%= link_to "Manage extensions", [@course, @assessment, :extensions], { title: "Give extensions to students" } %></li>
<li> <%= link_to "Manage submissions", [@course, @assessment, :submissions], { title: "Create, view, export, and re-autograde submissions" } %></li>
<li> <%= link_to "View statistics", {:action => "statistics" }, {:title=> "View detailed stats for this assessment" } %></li>
<li> <%= link_to "Bulk import grades", {:action => "bulkGrade" }, {:title=> "Upload scores or feedback for multiple students from a CSV file" } %></li>
<li> <%= link_to "Bulk export grades", {:action => "bulkExport" }, {:title=> "Export grades (with sub-scores) \nfor all students to a CSV file" } %></li>
<li class="collection-item red-text danger-bottom no-hover"><h4>Danger Zone</h4></li>
<li class="danger-side">
<%= link_to "Release all grades", { :action => "releaseAllGrades" }, { :title=> "Make all scores for this assessment visible to students", data: {confirm: "Are you sure you want to release all grades?", method: "post"}} %>
</li>
<li class="danger-side">
<%= link_to "Withdraw all grades", { :action => "withdrawAllGrades" }, {:title=> "Hide all scores for this assessment from students", data: {confirm: "Are you sure you want to withdraw all grades?", method: "post"}} %>
</li>
<li class="danger-side danger-bottom"> <%= link_to "Reload config file", {:action => "reload" }, {:title=> "Reload the assessment config file (provided for backward compatibility with legacy assessments)", data: {confirm: "Are you sure you want to reload the config file?"}} %></li>
</ul>
</div>
</li>
</ul>
<% end %>
<%# Display the optional CA admin options %>
<% if @cud.course_assistant? or @cud.instructor? then %>
<ul class="collapsible" data-collapsible="accordion">
<li class="collapsible-menu-link" id="ca-options" aria-role="button" aria-expanded="false" onclick="toggleAria('ca-options')" onkeydown="toggleAria('ca-options')">
<div class="collapsible-header"><h5>CA Options</h5></div>
<div class="collapsible-body">
<ul class="options">
<li><%= link_to "Grade section #{@cud.section} submissions", url_for(:action => 'viewGradesheet', :section => '1', :escape => false),
:title=> "View and enter grades for your section. Make sure your instructor has assigned you to a section in your Autolab account" %></li>
<li><%= link_to "Grade all submissions", url_for(:action => 'viewGradesheet'),
:title=> "View and enter grades for all sections" %></li>
<% if !@assessment.disable_handins %>
<li><%= link_to "Download section #{@cud.section} submissions", [:downloadAll, @course, @assessment, :submissions, final: true], title: "Download section #{@cud.section} submissions" %></li>
<% end %>
<li class="collection-item red-text danger-bottom no-hover"><h4>Danger Zone</h4></li>
<li class="danger-side"><%= link_to "Reload config file", url_for(:action => 'reload'),
:title=> "Reload the assessment configuration file (provided for backward compatibility with legacy assessments)", data: {confirm: "Are you sure you want to reload the config file?"} %></li>
<li class="danger-side danger-bottom">
<%= link_to "Release section grades", { :action => "releaseSectionGrades" }, { :title=> "Make all scores visible to the students in your section. This will work only if your instructor has assigned you to a lecture and section in your Autolab account.", data: {confirm: "Are you sure you want to release section grades?", method: "post"}} %>
</li>
</ul>
</div>
</li>
</ul>
<% end %>
<ul class="collapsible" data-collapsible="accordion">
<% if @cud.course_assistant? or @cud.instructor? then %>
<li class="collapsible-menu-link" id="options" aria-role="button" aria-expanded="false" onclick="toggleAria('options')" onkeydown="toggleAria('options')">
<% else %>
<li class="collapsible-menu-link active" id="options" aria-role="button" aria-expanded="true" onclick="toggleAria('options')" onkeydown="toggleAria('options')">
<% end %>
<div class="collapsible-header active"><h5>Options</h5></div>
<div class="collapsible-body">
<ul class="options">
<li> <%= link_to "View handin history", {:action => 'history'}, {:title=> "View your submissions, scores, and feedback from the course staff" } %> </li>
<li> <%= link_to "View writeup", {:action => 'writeup'}, {:title=> "View the assessment writeup", :class=>""}%> </li>
<li> <%= link_to "Download handout", {:action => 'handout'}, {:title=> "Download handout materials and starter code" } %> </li>
<% if @assessment.has_groups? %>
<% if @aud.membership_status != AssessmentUserDatum::UNCONFIRMED then %>
<li><%= link_to "Group options", [@course, @assessment, @aud.group], title: "Check your group settings." %></li>
<% else %>
<li><%= link_to "Group options", [:new, @course, @assessment, :group], title: "Check your group settings." %></li>
<% end %>
<% end %>
<% if @assessment.has_scoreboard? %>
<li><%= link_to "View scoreboard", [@course, @assessment, :scoreboard], title: "View the assessment scoreboard" %></li>
<% end %>
<% @list.sort { |a,b| a[1] <=> b[1] }.each { |key, value| %>
<% if value.size > 0 then %>
<li> <%= link_to value, {:action => key}, {:title=>(@list_title[key] || "")} %> </li>
<% end %>
<% } %>
</ul>
</div>
</li>
</ul>
</div>
<div class="col s12 m8">
<br>
<br>
<div class="handin-panel card z-depth-0">
<div class="card-content">
<p class="valign-wrapper">
<i class="material-icons valign">access_time</i>
Due<% if @extension then %> (with <%=@extension.days %> day extension)<% end %>:
<b><span class="moment-date-time" data-format="MMMM Do YYYY, h:mm a z"> <%= due_at_display @aud.due_at %></span></b>
</p>
<p class="valign-wrapper">
<i class="valign material-icons">today</i> Last day to handin: <b><span class="moment-date-time" data-format="MMMM Do YYYY, h:mm a z"> <%= end_at_display(@aud.end_at false) %></span></b>
</p>
<% if @cud.instructor? and @assessment.exam? %>
<p class="attention">This is an exam. While it is in progress, please check Admin > Edit Course > Exam In Progress.</p>
<% end %>
</div>
<%= render partial: "handin_form", locals: {modal: false, id: "handin_show_assessment"} %>
</div>
</div>
</div>
<% download_access = (@cud.instructor?) %>
<%# Display any attachments %>
<% if @assessment.attachments.length > 0 or @cud.instructor? %>
<h2>Handouts</h2>
<ul class="collection with-header attachments">
<%= render @assessment.attachments %>
<% # this code is temporarily "commented out" because Dan wants to preserve the logic for future changes to _attachment.html.erb %>
<% if false then %>
<% for a in @assessment.attachments do %>
<% if a.released? then %>
<% if (Time.now() > @assessment.start_at) or (@cud.instructor?) then %>
<li><%= link_to a.name, [@course, @assessment, a] %></li>
<% else %>
<li><%= a.name %></li>
<% end %>
<% elsif @cud.instructor? then %>
<li><i><%= link_to a.name, [@course, @assessment, a] %>*</i></li>
<% end %>
<% end %>
<% end %>
<% if @cud.instructor? then %>
<li class="collection-item add">
<%= link_to new_course_assessment_attachment_path(@course, @assessment) do %>
<i class="material-icons left">note_add</i>Add Attachment
<% end %>
<span class="secondary-content"></span>
</li>
<% end %>
</ul>
<hr>
<% end %>
<% if @assessment.embedded_quiz %>
<script>
$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name] !== undefined) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};
$(function() {
$('form').submit(function() {
$('#results').text(JSON.stringify($('#quiz_form').serializeObject()));
showForm();
//return false;
});
});
function showForm() {
var save = document.getElementById('results').innerHTML;
console.log(save);
document.getElementById("submission_embedded_quiz_form_answer").value = save;
}
</script>
<% if @cud.instructor %>
<div class = "row">
<div class = "col s12 offset-s0">
<b>This is how students will view this assessment:</b>
</div>
</div>
<% end %>
<div class = "row">
<div class = "col s10 offset-s1">
<hr>
<%= form_for @submission, url: {action: :handin}, :html => {:id => "quiz_form", :onclick => "return validateIntegrity();"}, method: :post do |f| %>
<%= f.hidden_field :embedded_quiz_form_answer, value: "" %>
<%# Render instructor's custom quiz form elements. %>
<p>
<% begin %>
<%= @assessment.embedded_quiz_form_data.html_safe %>
<% rescue %>
<p style = "color: red">Your assessment has no content yet! </p>
<% end %>
</p>
<% if @can_submit %>
<!-- Academic integrity checkbox -->
<%= label_tag(:integrity_checkbox) do %>
<%= check_box_tag(:integrity_checkbox) %>
<%= content_tag("span", "I affirm that I have complied with this course's academic integrity policy as defined in the syllabus.") %>
<% end %>
<div class = "row" style = "margin-top: 10px !important">
<input type="submit" class = "btn primary handin-btn" onclick = "setSubmitClicked()">
<span id="submission_error" style = "margin-left: 10px !important; color: red"></span>
</div>
<% end %>
<% end %>
<hr>
</div>
</div>
<pre class="hide" id="results"></pre>
<% end %>
<% if @assessment.exam? %>
<% if download_access %>
<p>Students will not be able to view previous exam submissions.</p>
<% else %>
<p>You cannot view previous exam submissions.</p>
<% end %>
<% elsif @assessment.course.exam_in_progress? %>
<% if download_access %>
<p>Students will not be able to view previous submissions while an exam is in progress.</p>
<% else %>
<p>You cannot view previous submissions while an exam is in progress.</p>
<% end %>
<% end %>
<% if @submissions.size == 0 then %>
No Submissions yet!
<% else %>
<% for submission in @submissions.first(limit=3) do %>
<%= render partial: "submission_summary_row",
locals: { submission: submission,
download_access: download_access } %>
<% end %>
<%= link_to "See all submissions", {:action => "history"} %></li>
<% end %>
</div>