From 083d1b895dab241631c71e2f9281945d5e0fa9dd Mon Sep 17 00:00:00 2001 From: Joey Wildman Date: Tue, 5 Sep 2023 15:21:57 -0400 Subject: [PATCH] Lint views/groups (#1965) * begin linting views/groups * fix form autocomplete errors --- app/views/groups/_form.html.erb | 2 +- app/views/groups/_list_item.html.erb | 11 +++++----- app/views/groups/_new_form.html.erb | 10 ++++----- app/views/groups/index.html.erb | 26 ++++++++++++++++------- app/views/groups/new.html.erb | 8 ++++--- app/views/groups/show.html.erb | 31 +++++++++++++++++++--------- 6 files changed, 56 insertions(+), 32 deletions(-) diff --git a/app/views/groups/_form.html.erb b/app/views/groups/_form.html.erb index de9de4966..57e4c8bc5 100644 --- a/app/views/groups/_form.html.erb +++ b/app/views/groups/_form.html.erb @@ -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" %> diff --git a/app/views/groups/_list_item.html.erb b/app/views/groups/_list_item.html.erb index 7f66bb261..d3ac22ec9 100644 --- a/app/views/groups/_list_item.html.erb +++ b/app/views/groups/_list_item.html.erb @@ -1,11 +1,12 @@
  • <%= group.name %>

    -

    <%= group.assessment_user_data.all.map{|aud| aud.course_user_datum.full_name }.join(", ") %>

    +

    <%= group.assessment_user_data.all.map{ |aud| aud.course_user_datum.full_name }.join(", ") %>

    - <%= 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 %>

    -
  • \ No newline at end of file + diff --git a/app/views/groups/_new_form.html.erb b/app/views/groups/_new_form.html.erb index a694784af..0cbecf202 100644 --- a/app/views/groups/_new_form.html.erb +++ b/app/views/groups/_new_form.html.erb @@ -1,15 +1,15 @@ -<%= form_tag [@course, @assessment, @group] do %> +<%= form_tag action: :create do %>
    - <%= text_field_tag :group_name, nil, class: "form-control" %> + <%= text_field_tag :group_name, nil, class: "form-control", autocomplete: "off" %>

    Set the name of this group.

    - <%= text_field_tag :member_email, nil, class: "form-control" %> + <%= text_field_tag :member_email, nil, class: "form-control", autocomplete: "email" %>

    The email of your desired partner. They will need to confirm their membership.

    - <%= submit_tag "Create Group", class:"btn btn-primary" %> -<% end %> \ No newline at end of file + <%= submit_tag "Create Group", class: "btn btn-primary" %> +<% end %> diff --git a/app/views/groups/index.html.erb b/app/views/groups/index.html.erb index 23e425c40..1d7ea34fe 100644 --- a/app/views/groups/index.html.erb +++ b/app/views/groups/index.html.erb @@ -1,7 +1,9 @@ +<% @title = "Groups" %> + +

    Groups

    <% if @groups.size > 0 then %> -

    Groups

    - +
    @@ -14,7 +16,7 @@ <% @groups.each do |group| %> - + <% group.assessment_user_data.each do |aud| %> <% cud = aud.course_user_datum %> @@ -31,17 +33,25 @@ <% end %> <% end %>
    Group Name
    <%= link_to group.name, [@course, @assessment, group] %><%= link_to group.name, course_assessment_group_path(@course, @assessment, group) %> - <%= 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?" } %>
    <% else %> -

    No Groups have been set yet.

    +

    + No Groups have been set yet. +

    <% end %> -

    <%= link_to 'Create New Group', [:new, @course, @assessment, :group] %>

    +
    +<%= link_to new_course_assessment_group_path(@course, @assessment) do %> + + Create New Group + +<% end %> <% if @grouplessCUDs.size > 0 then %>

    Users Without Groups

    @@ -57,6 +67,6 @@

    Load Groups from Another Assessment

    <%= 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 %> diff --git a/app/views/groups/new.html.erb b/app/views/groups/new.html.erb index 73d37d546..a3deaee06 100644 --- a/app/views/groups/new.html.erb +++ b/app/views/groups/new.html.erb @@ -1,4 +1,6 @@ -

    Create a Group

    +<% @title = "New Group" %> + +

    Create New Group

    <%= render "new_form" %> @@ -9,7 +11,7 @@ <% @grouplessCUDs.each do |cud| %> <% if cud.id != @cud.id && cud.student? then %>
  • <%= cud.email %> - (<%= 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 %>)
  • <% end %> <% end %> @@ -21,7 +23,7 @@ <% end %> diff --git a/app/views/groups/show.html.erb b/app/views/groups/show.html.erb index 4eaabb94e..9fb9066cb 100644 --- a/app/views/groups/show.html.erb +++ b/app/views/groups/show.html.erb @@ -1,10 +1,11 @@ +<% @title = @group.name %>

    Group: <%= @group.name %>

    <% if @aud.group_id == @group.id or @cud.instructor then %> <% if (@aud.membership_status & AssessmentUserDatum::MEMBER_CONFIRMED) == 0 then %>

    You have not confirmed your group membership yet.

    - <%= 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 %>

    Your group has not confirmed your membership yet.

    <% end %> @@ -22,14 +23,22 @@ <% if !aud.group_confirmed(AssessmentUserDatum::MEMBER_CONFIRMED) then %>

    This Member has not Confirmed their Membership yet.

    <% if @group.is_member(@aud) or @cud.instructor then %> -

    <%= link_to "Cancel Request", [:leave, @course, @assessment, @group, member_id: cud.id], method: :post %>

    +

    + <%= link_to "Cancel Request", + leave_course_assessment_group_path(@course, @assessment, @group, member_id: cud.id), + method: :post %> +

    <% end %> <% elsif !aud.group_confirmed(AssessmentUserDatum::GROUP_CONFIRMED) then %>

    This Member has not been Confirmed by the Group yet.

    <% if @group.is_member(@aud) or @cud.instructor then %>

    - <%= 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 %>

    <% end %> <% end %> @@ -40,14 +49,14 @@ <% if @group.is_member(@aud) or @cud.instructor then %> <% if @group.assessment_user_data.size < @assessment.group_size then %>

    Invite Another Student to Join This Group

    - <%= form_tag [:add, @course, @assessment, @group] do %> + <%= form_tag add_course_assessment_group_path(@course, @assessment, @group) do %>
    - <%= text_field_tag :member_email, nil, class: "form-control" %> + <%= text_field_tag :member_email, nil, class: "form-control", autocomplete: "email" %>

    The email of your desired partner. They will need to confirm their membership.

    - <%= submit_tag "Invite to Group", class:"btn btn-primary" %> + <%= submit_tag "Invite to Group", class: "btn btn-primary" %> <% end %> <% end %> <% end %> @@ -58,7 +67,8 @@ <% @grouplessCUDs.each do |cud| %> <% if cud.id != @cud.id && cud.student? then %>
  • <%= cud.email %> - (<%= 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 %>)
  • <% end %> <% end %> @@ -67,7 +77,8 @@
    <% 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 %>