/
show.html.erb
174 lines (171 loc) · 9.14 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
<% content_for :title, @assignment.name + " - Assignment Details" %>
<div class="container">
<% if notice %>
<div class="row" id='alertdiv'>
<div class="alert alert-success alert-dismissible container text-center">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<h6><%= notice %></h6>
</div>
</div>
<% end %>
<div class="row center-row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<h1 class="submain-heading">ASSIGNMENT DETAILS</h1>
</div>
</div>
<div class="assignments-container">
<div class="row center-row">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="assignments-data">
<p><strong>Name: </strong><%= @assignment.name %></p>
<p><strong>Group: </strong><%= @assignment.group.name %></p>
<p><strong>Deadline: </strong><span class="assignments-deadline" data-year=<%= deadline_year(@assignment) %>
data-month=<%= deadline_month(@assignment) %> data-day=<%= deadline_day(@assignment) %>
data-hour=<%= deadline_hour(@assignment) %> data-minute=<%= deadline_minute(@assignment) %>
data-second=<%= deadline_second(@assignment) %>><%= @assignment.deadline %></span></p>
<% if(@assignment.deadline > Time.now) %>
<p><strong>Time Remaining: </strong><%= AssignmentDecorator.new(@assignment).time_remaining %></p>
<% end %>
<p><strong>Graded: </strong><%= @assignment.graded %></p>
<% if @assignment.description %>
<p><strong>Description: </strong></p>
<div class="assignments-description">
<%= sanitize @assignment.description&.html_safe %>
</div>
<% end %>
<% if @assignment.restricted_circuit_elements != "None" %>
<p><strong>Restricted Circuited Elements: </strong><%= @assignment.restricted_circuit_elements %></p>
<% end %>
<% if policy(@assignment).admin_access? && @assignment.status!="closed" %>
<br>
<%= link_to edit_group_assignment_path(@group, @assignment), class:"mini-button groups-reopen-mini-button" do %>
<%= image_tag("SVGs/editGroup.svg", alt: "Edit Assignment") %>
<span>Edit</span>
<% end %>
<% end %>
<% if policy(@assignment).can_be_graded? %>
<%= link_to 'Export Grades', grades_to_csv_path(@assignment, format: "csv"), class: "btn primary-button" %>
<% end %>
<%= link_to 'Back', group_path(@group), class: "anchor-text" %>
<br> <br>
<hr class="assignments-horizontal-rule">
<% if policy(@assignment).admin_access? %>
<h3 class="assignments-submission-heading">Submissions :</h3>
<script>
$( function() {
$('.list-group-item-action').on('click', function (e) {
e.preventDefault()
$("#assignmentPreview").attr("src","/simulator/" + e.currentTarget.id );
$(this).tab('show')
$('#project-description').html($(e.currentTarget).attr('data-description'));
var cssLink = document.createElement("link");
cssLink.href = '/css/embed.css';
cssLink.rel = 'stylesheet';
cssLink.type ='text/css';
frames['assignmentPreview'].document.head.appendChild(cssLink);
})
});
</script>
<% if @assignment.project_order.blank? %>
<div class="assignments-no-submission">
<h5>No submissions yet!</h5>
</div>
<% else %>
<div class="assignments-submission">
<div class="row assignments-submission-row">
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3 assignments-submission-col-3">
<div id="list-tab" role="tablist">
<ul class="list-group assignments-list-group">
<% @assignment.project_order.each do |project| %>
<li><a class="list-group-item list-group-item-action assignments-list-item assignments-username-truncate" id="<%= project.id %>" data-grade="<%= project.grade_str %>" data-remarks="<%= project.remarks_str %>" data-description="<%= project.description %>"><%= project.author.name %></a></li>
<% end %>
</ul>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9 assignments-iframe">
<div class="embed-responsive embed-responsive-4by3 ">
<iframe src="" name="assignmentPreview" id="assignmentPreview" scrolling="no" webkitAllowFullScreen mozAllowFullScreen allowFullScreen> </iframe>
</div>
</div>
</div>
<div class="row assignments-submission-row assignments-submission-description assignments-description">
<h6 class="assignments-project-decription-heading">Description:</h6>
<p id="project-description"></p>
</div>
</div>
<% if policy(@assignment).can_be_graded? %>
<div class="assignments-grading-container">
<h5 class="assignments-grading-heading">Grades & Remarks</h5>
<span id="project-grade-error" class="assignments-error"></span>
<%= form_with(model: Grade.new, multipart: true,id:"assignment-grade-form",url: "/grades") do |form| %>
<%= form.hidden_field :project_id, id: "assignment-project-id" %>
<%= form.hidden_field :assignment_id, value: @assignment.id %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<h6>Grade</h6>
<% if @assignment.grading_scale == "percent" %>
<%= form.number_field :grade,id: "assignment-grade-grade", min: 0, max: 100, class: "form-control form-input" %>
<% elsif @assignment.grading_scale == "letter" || @assignment.grading_scale == "custom" %>
<%= form.text_field :grade,id: "assignment-grade-grade", class: "form-control form-input" %>
<% end %>
</div>
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<h6>Remarks</h6>
<%= form.text_field :remarks,id: "assignment-grade-remarks", class: "form-control form-input" %>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<button name="button" type="submit" id="grade-form-submit" class="btn primary-button mt-4">Submit</button>
</div>
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8 assignments-grading-help">
<% if @assignment.grading_scale == "percent" %>
<small>Assignments can be graded with percentage (1-100)</small>
<% elsif @assignment.grading_scale == "letter" || @assignment.grading_scale == "custom" %>
<small>Assignments can be graded with any of letters A/B/C/D/E/F</small>
<% end %>
</div>
</div>
<% end %>
</div>
<div class="assignments-grading-container">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<h6>Grade</h6>
<span id="project-grade"></span>
<br>
<div class="assignments-grade-horizontal-rule"></div>
</div>
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<h6>Remarks</h6>
<span id="project-remarks"></span>
<br>
</div>
</div>
<div class="row">
<%= button_tag 'Remove', id: "grade-form-remove", class: "btn ml-3 primary-delete-button" %>
</div>
</div>
<% end %>
<% end %>
<% end %>
</div>
</div>
</div>
</div>
</div>
<script src="/js/grading.js"> </script>
<script type="text/javascript">
$(document).ready(function() {
$('.assignments-deadline').each(function(){
let month = $('.assignments-deadline').data("month") -1;
let date = new Date($('.assignments-deadline').data("year"), month, $('.assignments-deadline').data("day"), $('.assignments-deadline').data("hour"), $('.assignments-deadline').data("minute"), $('.assignments-deadline').data("second"), 0);
let offset = date.getTimezoneOffset();
let localTime = new Date(date.getTime() - offset * 60 * 1000);
this.innerHTML = localTime;
});
});
</script>