-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathshow.html.erb
More file actions
145 lines (138 loc) · 6.74 KB
/
Copy pathshow.html.erb
File metadata and controls
145 lines (138 loc) · 6.74 KB
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
<%= render partial: 'nav' %>
<h2>My Account</h2>
<div class="participant-details">
<%= image_tag @user.gravatar_url(:rating => 'R', :secure => true, :size => 200, default: 'mm'), class: 'avatar' %>
<section class="participant-entries">
<ul class="nobullets">
<li>E-mail: <%= mail_to(@user.email, @user.email) %></li>
<% for field in UserField.all %>
<% if field.field_type != :html %>
<li><%= raw(field.name.humanize) %>: <%= extra_field_value(@user.field_value_record(field)) %></li>
<% end %>
<% end %>
<% if current_user.administrator? %>
<li>Username: <%= @user.login %> (shown to you because you're an admin)</li>
<li>Account created: <%= @user.created_at %> (shown to you because you're an admin)</li>
<% end %>
<% if current_user.administrator? && !@user.administrator? %>
<li><%= link_to 'Generate password reset link', password_reset_link_participant_path, class: 'btn btn-primary' %> (shown to you because you're an admin)</li>
<% end %>
<% if current_user.administrator? %>
<li>Courses.mooc.fi managed: <%= @user.password_managed_by_courses_mooc_fi ? 'yes' : 'no' %> (shown to you because you're an admin)</li>
<li>Courses.mooc.fi user id: <%= @user.courses_mooc_fi_user_id.presence || 'not set' %> (shown to you because you're an admin)</li>
<li>Courses.mooc.fi status: <%= @courses_mooc_fi_status_label %> (shown to you because you're an admin)</li>
<% if @courses_mooc_fi_status %>
<li>
Courses.mooc.fi says: account exists=<%= @courses_mooc_fi_status[:shadow_user_exists] %>,
id=<%= @courses_mooc_fi_status[:courses_mooc_fi_user_id] || 'none' %>,
password set=<%= @courses_mooc_fi_status[:password_set] %><% if @courses_mooc_fi_status[:deleted_at] %>, deleted at <%= @courses_mooc_fi_status[:deleted_at] %><% end %>
(shown to you because you're an admin)
</li>
<% else %>
<li>Could not reach courses.mooc.fi to confirm live status. (shown to you because you're an admin)</li>
<% end %>
<% end %>
<% if current_user.administrator? && !@user.administrator? && @courses_mooc_fi_force_migrate_available %>
<% confirm_text = if @user.managed_externally?
"#{@user.email} is flagged as migrated locally, but courses.mooc.fi doesn't have a live account for them. Force migrating will (re)create the account on courses.mooc.fi and relink them to it. Continue?"
elsif @courses_mooc_fi_status&.dig(:password_set)
"#{@user.email} already has a working password on courses.mooc.fi. Force migrating will still wipe their local tmc-server password and relink them to that existing account. Continue?"
else
"Force migrate #{@user.email} to courses.mooc.fi now?"
end %>
<li><%= button_to 'Force migrate to courses.mooc.fi', force_migrate_to_courses_mooc_fi_participant_path, method: :post, class: 'btn btn-primary', data: { confirm: confirm_text } %> (shown to you because you're an admin)</li>
<% end %>
<% if current_user.administrator? && @user.courses_mooc_fi_profile_url %>
<li><%= link_to 'View on courses.mooc.fi', @user.courses_mooc_fi_profile_url, target: '_blank', rel: 'noopener', class: 'btn btn-primary' %> (shown to you because you're an admin)</li>
<% end %>
</ul>
</section>
</div>
<% unless @user.email_verified? %>
<div class="alert alert-warning" role="alert">
Your email address is not verified yet. <%= link_to 'Resend verification email', send_verification_email_path(@user), method: :post %>.
</div>
<% end %>
<section>
<br>
<h2>Points</h2>
<br>
<% for course in @courses %>
<div class="card">
<div class="card-body">
<h3 class="card-title">
<% if can? :read, course %>
<%= link_to course.title, organization_course_path(course.organization, course) %>
<% else %>
<%= course.title %>
<% end %>
</h3>
<br>
<% if can? :see_points, course %>
<span class="progress-label">Awarded points</span>
<div class="progress course-points-progress">
<div class="progress-bar" role="progressbar" style="width: <%= @percent_completed[course.id] %>%" aria-valuenow="<%= @percent_completed[course.id] %>" aria-valuemin="0" aria-valuemax="100">
<%= @percent_completed[course.id].floor(0) %>%
</div>
</div>
<% if @group_completion_counts[course.id] %>
<% @group_completion_counts[course.id].each do |group, counts| %>
<br>
<span class="progress-label">Awarded points for <%= group %></span>
<div class="progress course-points-progress">
<% unless (counts[:awarded] + counts[:late]).zero? %>
<% calculated_ratio = (counts[:awarded] + counts[:late] * course.soft_deadline_point_multiplier).to_f / counts[:available_points] %>
<div class="progress-bar bg-info" role="progressbar" style="width: <%= calculated_ratio * 100 %>%" aria-valuenow="<%= calculated_ratio * 100 %>" aria-valuemin="0" aria-valuemax="100">
<%= (calculated_ratio * 100).floor(0) %>%
</div>
<% end %>
</div>
<% end %>
<br>
<% end %>
<br>
<table class="table table-hover">
<thead class="">
<tr>
<th></th>
<th>Point names</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Awarded points</td>
<td><%= points_list(@awarded_points[course.id][:awarded]) %></td>
</tr>
<% unless @awarded_points[course.id][:late].empty? %>
<tr>
<th scope="row">Points awarded, but late</td>
<td><%= points_list(@awarded_points[course.id][:late]) %></td>
</tr>
<% end %>
<tr>
<th scope="row">Missing points</td>
<td><%= points_list(@missing_points[course.id]) %></td>
</tr>
</tbody>
</table>
<% else %>
For this course points are not visible.
<% end %>
</div>
</div>
<br>
<% end %>
</section>
<section>
<h2>Submissions</h2>
<% if @submissions.size < @submission_count %>
<p>Showing latest <%= @submissions.size%> of <%= @submission_count %> submissions. <%= link_to "View all submissions", participant_path(@user, view_all: 1) %></p>
<% end %>
<%= show_submission_list(@submissions) %>
</section>
<% if @app_data %>
<section>
<h2>App data</h2>
<pre><%= @app_data %></pre>
<section>
<% end %>