From b8af670b764c61a13c45a55249de9dd2eb78718f Mon Sep 17 00:00:00 2001 From: jhs-panda Date: Fri, 27 Sep 2024 14:57:38 -0400 Subject: [PATCH 1/7] Reformat UI of Edit Assessment page to make disabling assessments more clear. --- app/views/assessments/_edit_handin.html.erb | 33 ++++++++++++++++----- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/app/views/assessments/_edit_handin.html.erb b/app/views/assessments/_edit_handin.html.erb index ac249c0a3..9e5e9b1d6 100644 --- a/app/views/assessments/_edit_handin.html.erb +++ b/app/views/assessments/_edit_handin.html.erb @@ -1,5 +1,19 @@ <% content_for :javascripts do %> <%= javascript_include_tag "init_handin_datetimepickers" %> + <% end %> <%# Initialize datepickers by defining linked relationships (using IDs) %> <%= f.datetime_select :start_at, @@ -15,7 +29,6 @@ style: "margin-top: 0 !important;", help_text: "Last possible time that students can submit (except those granted extensions.)", greater_than: "assessment_start_at assessment_due_at" %> - <% if GithubIntegration.connected %> <%= f.check_box :github_submission_enabled, display_name: "Allow Github submissions", @@ -29,14 +42,18 @@ help_text: "Autolab has not been configured to use Github integration. Please contact your Autolab admin to perform the necessary setup and configuration based on the instructions on our docs." %> <% end %> -<% unless f.object.disable_handins %> - <%= f.text_field :handin_filename, help_text: "The suffix that is appended to student submission files. - Autolab stores submission files in the handin directory as email/version_fname", placeholder: "E.g. mm.c" %> -<% end %> -<%= f.text_field :max_size, help_text: "The maximum size that a handin file can have in megabytes (MB)." %> <%= f.check_box :disable_handins, - help_text: "Check this to disallow handins through Autolab. This option can be used to track scores - for assignments that are not submitted through Autolab such as midterms and written assignments." %> + display_name: "Disable Autolab submissions", + help_text: "Check this to disallow handins through Autolab. This option can be used to track scores for assignments that are not submitted through Autolab such as midterms and written assignments.", + class: "disable-handins-toggle", + onchange: "toggleHandinAutolab(this)" %> +<%= f.text_field :handin_filename, + value: "handin.c", + disabled: true, + help_text: "The suffix that is appended to student submission files. Autolab stores submission files in the handin directory as email/version_fname", + placeholder: "E.g. mm.c", + class: "handin-filename-field" %> +<%= f.text_field :max_size, help_text: "The maximum size that a handin file can have in megabytes (MB)." %>
<%= f.submit "Save", name: "handin" %> From 20e9ad2db160f712c2f1566ff939334899325bd0 Mon Sep 17 00:00:00 2001 From: jhs-panda Date: Fri, 27 Sep 2024 14:58:43 -0400 Subject: [PATCH 2/7] fix formatting from diff --- app/views/assessments/_edit_handin.html.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/assessments/_edit_handin.html.erb b/app/views/assessments/_edit_handin.html.erb index 9e5e9b1d6..5d8123cbe 100644 --- a/app/views/assessments/_edit_handin.html.erb +++ b/app/views/assessments/_edit_handin.html.erb @@ -29,6 +29,7 @@ style: "margin-top: 0 !important;", help_text: "Last possible time that students can submit (except those granted extensions.)", greater_than: "assessment_start_at assessment_due_at" %> + <% if GithubIntegration.connected %> <%= f.check_box :github_submission_enabled, display_name: "Allow Github submissions", From 0ac3f1a771271cb335460e39be64be7b1e377584 Mon Sep 17 00:00:00 2001 From: jhs-panda Date: Fri, 27 Sep 2024 16:45:29 -0400 Subject: [PATCH 3/7] Clarify message on submission page. --- app/views/assessments/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/assessments/show.html.erb b/app/views/assessments/show.html.erb index 8d97ece57..6738afc1e 100755 --- a/app/views/assessments/show.html.erb +++ b/app/views/assessments/show.html.erb @@ -181,7 +181,7 @@

file_upload_off -  Handins are disabled for this assessment. +  Autolab handins are disabled for this assessment.

From a9a71e27bc5d1de701560052437f5d005a9ec9c5 Mon Sep 17 00:00:00 2001 From: jhs-panda Date: Sun, 27 Oct 2024 11:14:24 -0400 Subject: [PATCH 4/7] corrected errors --- app/views/assessments/_edit_handin.html.erb | 8 +++++--- lib/update_course.rb | 22 +++++++++++++++++++++ test.txt | 2 ++ test2.txt | 2 ++ 4 files changed, 31 insertions(+), 3 deletions(-) create mode 100644 lib/update_course.rb create mode 100644 test.txt create mode 100644 test2.txt diff --git a/app/views/assessments/_edit_handin.html.erb b/app/views/assessments/_edit_handin.html.erb index 5d8123cbe..15953d527 100644 --- a/app/views/assessments/_edit_handin.html.erb +++ b/app/views/assessments/_edit_handin.html.erb @@ -4,7 +4,7 @@ function toggleHandinAutolab(disable_button) { var handinField = document.querySelector('.handin-filename-field'); handinField.disabled = disable_button.checked; - if (!handinField.disabled) { + if (!handinField.disabled && !handinField.value) { handinField.value = 'handin.c'; } } @@ -12,6 +12,9 @@ document.addEventListener('DOMContentLoaded', function() { var disableHandinsCheckbox = document.querySelector('.disable-handins-toggle'); toggleHandinAutolab(disableHandinsCheckbox); + disableHandinsCheckbox.addEventListener('change', function() { + toggleHandinAutolab(disableHandinsCheckbox); + }); }); <% end %> @@ -49,8 +52,7 @@ class: "disable-handins-toggle", onchange: "toggleHandinAutolab(this)" %> <%= f.text_field :handin_filename, - value: "handin.c", - disabled: true, + value: f.object.handin_filename.presence || "handin.c", help_text: "The suffix that is appended to student submission files. Autolab stores submission files in the handin directory as email/version_fname", placeholder: "E.g. mm.c", class: "handin-filename-field" %> diff --git a/lib/update_course.rb b/lib/update_course.rb new file mode 100644 index 000000000..3660f5b1a --- /dev/null +++ b/lib/update_course.rb @@ -0,0 +1,22 @@ +class Updater + def self.update(course) + # Simulate some processing + sleep(2) # Simulate a time-consuming task + "Successfully updated the course: #{course.name}" + end + end + + # Simulated course class + class Course + attr_accessor :name + + def initialize(name) + @name = name + end + end + + # This is where the action gets executed with a simulated course + if __FILE__ == $0 + course = Course.new("Introduction to Ruby") + puts Updater.update(course) + end \ No newline at end of file diff --git a/test.txt b/test.txt new file mode 100644 index 000000000..9db7df02b --- /dev/null +++ b/test.txt @@ -0,0 +1,2 @@ +hello +world \ No newline at end of file diff --git a/test2.txt b/test2.txt new file mode 100644 index 000000000..9db7df02b --- /dev/null +++ b/test2.txt @@ -0,0 +1,2 @@ +hello +world \ No newline at end of file From 377b22f6c998d5e7aa73c7665de771fc54b0b6d9 Mon Sep 17 00:00:00 2001 From: jhs-panda Date: Sun, 27 Oct 2024 11:16:20 -0400 Subject: [PATCH 5/7] Remove irrelevant files. --- lib/update_course.rb | 22 ---------------------- test.txt | 2 -- test2.txt | 2 -- 3 files changed, 26 deletions(-) delete mode 100644 lib/update_course.rb delete mode 100644 test.txt delete mode 100644 test2.txt diff --git a/lib/update_course.rb b/lib/update_course.rb deleted file mode 100644 index 3660f5b1a..000000000 --- a/lib/update_course.rb +++ /dev/null @@ -1,22 +0,0 @@ -class Updater - def self.update(course) - # Simulate some processing - sleep(2) # Simulate a time-consuming task - "Successfully updated the course: #{course.name}" - end - end - - # Simulated course class - class Course - attr_accessor :name - - def initialize(name) - @name = name - end - end - - # This is where the action gets executed with a simulated course - if __FILE__ == $0 - course = Course.new("Introduction to Ruby") - puts Updater.update(course) - end \ No newline at end of file diff --git a/test.txt b/test.txt deleted file mode 100644 index 9db7df02b..000000000 --- a/test.txt +++ /dev/null @@ -1,2 +0,0 @@ -hello -world \ No newline at end of file diff --git a/test2.txt b/test2.txt deleted file mode 100644 index 9db7df02b..000000000 --- a/test2.txt +++ /dev/null @@ -1,2 +0,0 @@ -hello -world \ No newline at end of file From e022e01fdfced5ffd13587cd07a11752bbe5dca8 Mon Sep 17 00:00:00 2001 From: jhs-panda Date: Thu, 14 Nov 2024 23:26:09 -0500 Subject: [PATCH 6/7] Add pattern checking for the handin filename field (from CodeRabbit) --- app/views/assessments/_edit_handin.html.erb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/views/assessments/_edit_handin.html.erb b/app/views/assessments/_edit_handin.html.erb index 15953d527..0313a1a6c 100644 --- a/app/views/assessments/_edit_handin.html.erb +++ b/app/views/assessments/_edit_handin.html.erb @@ -55,7 +55,9 @@ value: f.object.handin_filename.presence || "handin.c", help_text: "The suffix that is appended to student submission files. Autolab stores submission files in the handin directory as email/version_fname", placeholder: "E.g. mm.c", - class: "handin-filename-field" %> + class: "handin-filename-field", + pattern: "^[a-zA-Z0-9._]+$", + title: "Only alphanumeric characters, dots, and underscores are allowed." %> <%= f.text_field :max_size, help_text: "The maximum size that a handin file can have in megabytes (MB)." %>
From 468f0e453281414345c32ba0ac3cf56c81fe0880 Mon Sep 17 00:00:00 2001 From: jhs-panda Date: Thu, 14 Nov 2024 23:35:05 -0500 Subject: [PATCH 7/7] Changed variables from var to const (CodeRabbit suggestion) --- app/views/assessments/_edit_handin.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/assessments/_edit_handin.html.erb b/app/views/assessments/_edit_handin.html.erb index 0313a1a6c..4e4dc931e 100644 --- a/app/views/assessments/_edit_handin.html.erb +++ b/app/views/assessments/_edit_handin.html.erb @@ -2,7 +2,7 @@ <%= javascript_include_tag "init_handin_datetimepickers" %>