From d9260c36467713f5c12460e13ca59d0fd41fe56c Mon Sep 17 00:00:00 2001 From: Kanittha Thaveesittikullarp Date: Sat, 7 Dec 2024 22:33:07 -0500 Subject: [PATCH 1/4] Added confirmation prompt for late days --- app/views/assessments/_handin_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/assessments/_handin_form.html.erb b/app/views/assessments/_handin_form.html.erb index f00857d5f..d0d91ed62 100644 --- a/app/views/assessments/_handin_form.html.erb +++ b/app/views/assessments/_handin_form.html.erb @@ -53,7 +53,7 @@
<% if @aud.past_due_at? then %>
- <%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled") %> + <%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "You are #{grace_late_info}. Are you sure you want to continue?" }) %>
<% else %>
From 61f50a7a824cfcc0648dd42cabfaa64d50c728b7 Mon Sep 17 00:00:00 2001 From: evelynzhengg Date: Sun, 8 Dec 2024 20:38:01 -0500 Subject: [PATCH 2/4] modify message and add testing --- app/views/assessments/_handin_form.html.erb | 18 +++++++++--------- spec/models/handin_form_spec.rb | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 spec/models/handin_form_spec.rb diff --git a/app/views/assessments/_handin_form.html.erb b/app/views/assessments/_handin_form.html.erb index d0d91ed62..e9704e26d 100644 --- a/app/views/assessments/_handin_form.html.erb +++ b/app/views/assessments/_handin_form.html.erb @@ -9,14 +9,14 @@ <% days_late = (days_late / 1.day).ceil %> <% grace_days_left = @aud.grace_days_usable %> <% if grace_days_left >= days_late %> - <% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(days_late, 'grace day')}" %> + <% grace_late_info = "#{pluralize(days_late, 'day')} late using #{pluralize(days_late, 'grace day')}" %> <% elsif grace_days_left > 0 %> - <% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(grace_days_left, 'grace day')} with #{pluralize(days_late - grace_days_left, 'penalty late day')}" %> + <% grace_late_info = "#{pluralize(days_late, 'day')} late using #{pluralize(grace_days_left, 'grace day')} and #{pluralize(days_late - grace_days_left, 'penalty late day')}" %> <% else %> - <% grace_late_info = "submitting #{pluralize(days_late, 'day')} late using #{pluralize(days_late, 'penalty late day')}" %> + <% grace_late_info = "#{pluralize(days_late, 'day')} late using #{pluralize(days_late, 'penalty late day')}" %> <% end %> - <% late_confirm = " and that I am #{grace_late_info} under the late policy as defined in the syllabus" %> -

Warning: Submitting late may result in the usage of a grace day or a grade penalty!

+ <% late_confirm = " and are #{grace_late_info}" %> +

Warning: Submitting late will result in grace day usage or penalties as per the syllabus!

<% end %>
@@ -44,8 +44,8 @@ <% end %> <%= 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#{late_confirm}.") %> + <%= content_tag("span", "I affirm that I comply with this course's academic + integrity policy#{late_confirm}.") %> <% end %> <%= f.file_field :file %> @@ -53,11 +53,11 @@
<% if @aud.past_due_at? then %>
- <%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "You are #{grace_late_info}. Are you sure you want to continue?" }) %> + <%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "Autolab Notification: You are #{grace_late_info}. Continue?" }) %>
<% else %>
- <%= f.submit("Submit", id: "fake-submit", class: "btn primary handin-btn disabled") %> + <%= f.submit("Submit", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "Autolab Notification: Confirm submission?" }) %>
<% end %>
diff --git a/spec/models/handin_form_spec.rb b/spec/models/handin_form_spec.rb new file mode 100644 index 000000000..910b08228 --- /dev/null +++ b/spec/models/handin_form_spec.rb @@ -0,0 +1,19 @@ +require 'rails_helper' + +RSpec.describe "handin_form", type: :view do + let(:assessment) { create(:assessment) } + let(:aud) { create(:assessment_user_datum, assessment: assessment, past_due_at: true) } + let(:grace_late_info) { "using 1 late day" } + + before do + assign(:aud, aud) + allow(view).to receive(:grace_late_info).and_return(grace_late_info) + render partial: "assessments/handin_form", locals: { f: ActionView::Helpers::FormBuilder.new(nil, nil, self, {}) } + end + + it "renders the Submit Late button with a confirmation prompt" do + expect(rendered).to have_selector("input[type='submit'][id='fake-submit']") + expect(rendered).to have_selector("input[data-confirm='You are #{grace_late_info}. Are you sure you want to continue?']") + end +end + From fd3cf02da64be4d6ed4ab4e3fd2be38a78b81aae Mon Sep 17 00:00:00 2001 From: evelynzhengg Date: Sun, 8 Dec 2024 20:42:44 -0500 Subject: [PATCH 3/4] edit message --- app/views/assessments/_handin_form.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/assessments/_handin_form.html.erb b/app/views/assessments/_handin_form.html.erb index e9704e26d..b9bda5f67 100644 --- a/app/views/assessments/_handin_form.html.erb +++ b/app/views/assessments/_handin_form.html.erb @@ -53,7 +53,7 @@
<% if @aud.past_due_at? then %>
- <%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "Autolab Notification: You are #{grace_late_info}. Continue?" }) %> + <%= f.submit("Submit Late", id: "fake-submit", class: "btn primary handin-btn disabled", data: { confirm: "Autolab Notification: You are #{grace_late_info}. Click to confirm!" }) %>
<% else %>
From e10db9d8fc5fa10f02ef128e6307c1f183f6f992 Mon Sep 17 00:00:00 2001 From: evelynzhengg Date: Sun, 8 Dec 2024 21:15:38 -0500 Subject: [PATCH 4/4] change expected message --- spec/models/handin_form_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/models/handin_form_spec.rb b/spec/models/handin_form_spec.rb index 910b08228..a8b747af3 100644 --- a/spec/models/handin_form_spec.rb +++ b/spec/models/handin_form_spec.rb @@ -13,7 +13,7 @@ it "renders the Submit Late button with a confirmation prompt" do expect(rendered).to have_selector("input[type='submit'][id='fake-submit']") - expect(rendered).to have_selector("input[data-confirm='You are #{grace_late_info}. Are you sure you want to continue?']") + expect(rendered).to have_selector("input[data-confirm='Autolab Notification: You are #{grace_late_info}. Click to confirm!']") end end