Skip to content

Commit

Permalink
Lint views/groups (#1965)
Browse files Browse the repository at this point in the history
* begin linting views/groups

* fix form autocomplete errors
  • Loading branch information
20wildmanj authored Sep 5, 2023
1 parent d0757a4 commit 083d1b8
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/views/groups/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_for @group, url: [@course, @assessment, @group], builder: FormBuilderWithDateTimeInput do |f| %>
<%= form_for @group, url: course_assessment_group_url(@course, @assessment, @group), builder: FormBuilderWithDateTimeInput do |f| %>
<%= f.text_field :name, help_text: "Change the name of this group." %>
<%= f.submit "Change Name" %>
Expand Down
11 changes: 6 additions & 5 deletions app/views/groups/_list_item.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<li>
<h3><%= group.name %></h3>
<p><b><%= group.assessment_user_data.all.map{|aud| aud.course_user_datum.full_name }.join(", ") %></b></p>
<p><b><%= group.assessment_user_data.all.map{ |aud| aud.course_user_datum.full_name }.join(", ") %></b></p>
<p>
<%= link_to "Ask to Join Group", [:join, @course, @assessment, group], method: :post %>
<%= link_to "Ask to Join Group", join_course_assessment_group_path(@course, @assessment, group), method: :post %>
<% if @cud.instructor then %>
| <%= link_to "View", [@course, @assessment, group] %>
| <%= link_to "Destroy", [@course, @assessment, group], method: :delete, data: { confirm: "Are you sure you want to disband this group?" } %>
| <%= link_to "View", course_assessment_group_path(@course, @assessment, group) %>
| <%= link_to "Destroy", course_assessment_group_path(@course, @assessment, group),
method: :delete, data: { confirm: "Are you sure you want to disband this group?" } %>
<% end %>
</p>
</li>
</li>
10 changes: 5 additions & 5 deletions app/views/groups/_new_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<%= form_tag [@course, @assessment, @group] do %>
<%= form_tag action: :create do %>
<div class="form-group">
<label class="control-label" for="group_name">Group Name</label>
<%= text_field_tag :group_name, nil, class: "form-control" %>
<%= text_field_tag :group_name, nil, class: "form-control", autocomplete: "off" %>
<p class="help-block">Set the name of this group.</p>
</div>

<div class="form-group">
<label class="control-label" for="member_email">Partner Email</label>
<%= text_field_tag :member_email, nil, class: "form-control" %>
<%= text_field_tag :member_email, nil, class: "form-control", autocomplete: "email" %>
<p class="help-block">The email of your desired partner. They will need to confirm their membership.</p>
</div>

<%= submit_tag "Create Group", class:"btn btn-primary" %>
<% end %>
<%= submit_tag "Create Group", class: "btn btn-primary" %>
<% end %>
26 changes: 18 additions & 8 deletions app/views/groups/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<% @title = "Groups" %>

<h2>Groups</h2>
<% if @groups.size > 0 then %>
<h2>Groups</h2>

<table class=prettyBorder >
<table class=prettyBorder>
<tr>
<th>Group Name</th>

Expand All @@ -14,7 +16,7 @@

<% @groups.each do |group| %>
<tr>
<td><%= link_to group.name, [@course, @assessment, group] %></td>
<td><%= link_to group.name, course_assessment_group_path(@course, @assessment, group) %></td>

<% group.assessment_user_data.each do |aud| %>
<% cud = aud.course_user_datum %>
Expand All @@ -31,17 +33,25 @@
<% end %>

<td>
<%= link_to "Edit", [@course, @assessment, group] %> |
<%= link_to "Destroy", [@course, @assessment, group], method: :delete, data: { confirm: "Are you sure you want to disband this group?" } %>
<%= link_to "Edit", course_assessment_group_path(@course, @assessment, group) %> |
<%= link_to "Destroy", course_assessment_group_path(@course, @assessment, group),
method: :delete, data: { confirm: "Are you sure you want to disband this group?" } %>
</td>
</tr>
<% end %>
</table>
<% else %>
<h2>No Groups have been set yet.</h2>
<p>
No Groups have been set yet.
</p>
<% end %>

<h3><%= link_to 'Create New Group', [:new, @course, @assessment, :group] %></h3>
<br>
<%= link_to new_course_assessment_group_path(@course, @assessment) do %>
<span class="btn primary">
Create New Group
</span>
<% end %>
<% if @grouplessCUDs.size > 0 then %>
<h2>Users Without Groups</h2>
Expand All @@ -57,6 +67,6 @@
<h2>Load Groups from Another Assessment</h2>
<%= form_tag [:import, @course, @assessment, :groups] do %>
<%= select_tag :ass, options_from_collection_for_select(@groupAssessments, :id, :name) %>
<%= submit_tag 'Go!', class: "btn btn-primary" %>
<%= submit_tag 'Import Groups', class: "btn btn-primary" %>
<% end %>
<% end %>
8 changes: 5 additions & 3 deletions app/views/groups/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<h2>Create a Group</h2>
<% @title = "New Group" %>

<h2>Create New Group</h2>

<%= render "new_form" %>
Expand All @@ -9,7 +11,7 @@
<% @grouplessCUDs.each do |cud| %>
<% if cud.id != @cud.id && cud.student? then %>
<li><b><%= cud.email %></b>
(<%= link_to "Invite to Group", [@course, @assessment, @group, member_id: cud.id], method: :post %>)
(<%= link_to "Invite to Group", [@course, @assessment, @group, { member_id: cud.id }], method: :post %>)
</li>
<% end %>
<% end %>
Expand All @@ -21,7 +23,7 @@
<ul class="gray-box">
<% @unfullGroups.each do |group| %>
<%= render "list_item", {group: group} %>
<%= render "list_item", { group: group } %>
<% end %>
</ul>
<% end %>
Expand Down
31 changes: 21 additions & 10 deletions app/views/groups/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<% @title = @group.name %>
<h2>Group: <%= @group.name %></h2>

<% if @aud.group_id == @group.id or @cud.instructor then %>
<% if (@aud.membership_status & AssessmentUserDatum::MEMBER_CONFIRMED) == 0 then %>
<p>You have not confirmed your group membership yet.</p>
<%= link_to "Confirm Membership", [:join, @course, @assessment, @group], method: :post %> |
<%= link_to "Deny Membership", [:leave, @course, @assessment, @group], method: :post %>
<%= link_to "Confirm Membership", join_course_assessment_group_path(@course, @assessment, @group), method: :post %> |
<%= link_to "Deny Membership", leave_course_assessment_group_path(@course, @assessment, @group), method: :post %>
<% elsif (@aud.membership_status & AssessmentUserDatum::GROUP_CONFIRMED) == 0 then %>
<p>Your group has not confirmed your membership yet.</p>
<% end %>
Expand All @@ -22,14 +23,22 @@
<% if !aud.group_confirmed(AssessmentUserDatum::MEMBER_CONFIRMED) then %>
<p>This Member has not Confirmed their Membership yet.</p>
<% if @group.is_member(@aud) or @cud.instructor then %>
<p><%= link_to "Cancel Request", [:leave, @course, @assessment, @group, member_id: cud.id], method: :post %></p>
<p>
<%= link_to "Cancel Request",
leave_course_assessment_group_path(@course, @assessment, @group, member_id: cud.id),
method: :post %>
</p>
<% end %>
<% elsif !aud.group_confirmed(AssessmentUserDatum::GROUP_CONFIRMED) then %>
<p>This Member has not been Confirmed by the Group yet.</p>
<% if @group.is_member(@aud) or @cud.instructor then %>
<p>
<%= link_to "Confirm Membership", [:add, @course, @assessment, @group, member_id: cud.id], method: :post %> |
<%= link_to "Deny Membership", [:leave, @course, @assessment, @group, member_id: cud.id], method: :post %>
<%= link_to "Confirm Membership",
add_course_assessment_group_path(@course, @assessment, @group, member_id: cud.id),
method: :post %> |
<%= link_to "Deny Membership",
leave_course_assessment_group_path(@course, @assessment, @group, member_id: cud.id),
method: :post %>
</p>
<% end %>
<% end %>
Expand All @@ -40,14 +49,14 @@
<% if @group.is_member(@aud) or @cud.instructor then %>
<% if @group.assessment_user_data.size < @assessment.group_size then %>
<h2>Invite Another Student to Join This Group</h2>
<%= form_tag [:add, @course, @assessment, @group] do %>
<%= form_tag add_course_assessment_group_path(@course, @assessment, @group) do %>
<div class="form-group">
<label class="control-label" for="member_email">Partner Email</label>
<%= text_field_tag :member_email, nil, class: "form-control" %>
<%= text_field_tag :member_email, nil, class: "form-control", autocomplete: "email" %>
<p class="help-block">The email of your desired partner. They will need to confirm their membership.</p>
</div>

<%= submit_tag "Invite to Group", class:"btn btn-primary" %>
<%= submit_tag "Invite to Group", class: "btn btn-primary" %>
<% end %>
<% end %>
<% end %>
Expand All @@ -58,7 +67,8 @@
<% @grouplessCUDs.each do |cud| %>
<% if cud.id != @cud.id && cud.student? then %>
<li><b><%= cud.email %></b>
(<%= link_to "Invite to Group", [:add, @course, @assessment, @group, member_id: cud.id], method: :post %>)
(<%= link_to "Invite to Group", add_course_assessment_group_path(@course, @assessment, @group, member_id: cud.id),
method: :post %>)
</li>
<% end %>
<% end %>
Expand All @@ -67,7 +77,8 @@

<div style="margin-top: 1em">
<% if @group.is_member(@aud) then %>
<%= link_to "Leave Group", [:leave, @course, @assessment, @group], {method: :post, data: {confirm: "Are you sure you want to leave your group?"}} %> |
<%= link_to "Leave Group", leave_course_assessment_group_path(@course, @assessment, @group),
{ method: :post, data: { confirm: "Are you sure you want to leave your group?" } } %> |
<% end %>
<%= groups_back_link %>
</div>

0 comments on commit 083d1b8

Please sign in to comment.