diff --git a/app/controllers/concerns/file_parameters.rb b/app/controllers/concerns/file_parameters.rb index 85675ce7..3f0e746f 100644 --- a/app/controllers/concerns/file_parameters.rb +++ b/app/controllers/concerns/file_parameters.rb @@ -34,7 +34,7 @@ module FileParameters def file_attributes %w[content context_id feedback_message file_id file_type_id hidden id name native_file path read_only role weight - file_template_id] + file_template_id hidden_feedback] end private :file_attributes end diff --git a/app/models/code_ocean/file.rb b/app/models/code_ocean/file.rb index 07eafcc4..d9f35510 100644 --- a/app/models/code_ocean/file.rb +++ b/app/models/code_ocean/file.rb @@ -49,6 +49,7 @@ module CodeOcean validates :feedback_message, absence: true, unless: :teacher_defined_assessment? validates :hashed_content, if: :content_present?, presence: true validates :hidden, inclusion: [true, false] + validates :hidden_feedback, inclusion: [true, false] validates :name, presence: true validates :read_only, inclusion: [true, false] validates :role, inclusion: {in: ROLES} diff --git a/app/models/submission.rb b/app/models/submission.rb index 7af947cc..485c040b 100644 --- a/app/models/submission.rb +++ b/app/models/submission.rb @@ -283,7 +283,7 @@ class Submission < ApplicationRecord end output.merge!(assessment) - output.merge!(filename:, message: feedback_message(file, output), weight: file.weight) + output.merge!(filename:, message: feedback_message(file, output), weight: file.weight, hidden_feedback: file.hidden_feedback) output.except!(:messages) end @@ -329,12 +329,6 @@ class Submission < ApplicationRecord end end - # Return all test results except for those of a linter if not allowed - show_linter = Python20CourseWeek.show_linter? exercise - outputs&.reject do |output| - next if show_linter || output.blank? - - output[:file_role] == 'teacher_defined_linter' - end + outputs&.reject {|output| output[:hidden_feedback] if output.present? } end end diff --git a/app/views/exercises/_file_form.html.slim b/app/views/exercises/_file_form.html.slim index 3ac07a8a..0028005f 100644 --- a/app/views/exercises/_file_form.html.slim +++ b/app/views/exercises/_file_form.html.slim @@ -30,10 +30,14 @@ li.card.mt-2 label.form-check-label = f.check_box(:hidden, class: 'form-check-input') = t('activerecord.attributes.file.hidden') - .form-check.mb-3 + .form-check label.form-check-label = f.check_box(:read_only, class: 'form-check-input') = t('activerecord.attributes.file.read_only') + .form-check.mb-3 + label.form-check-label + = f.check_box(:hidden_feedback, class: 'form-check-input') + = t('activerecord.attributes.file.hidden_feedback') .test-related-fields style="display: #{f.object.teacher_defined_assessment? ? 'initial' : 'none'};" .mb-3 = f.label(:name, t('activerecord.attributes.file.feedback_message'), class: 'form-label') diff --git a/config/locales/de.yml b/config/locales/de.yml index b9f1f7ac..97ae64c3 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -75,6 +75,7 @@ de: file_type: Dateityp file_type_id: Dateityp hidden: Versteckt + hidden_feedback: Feedback ausblenden name: Name path: Pfad read_only: Schreibgeschützt diff --git a/config/locales/en.yml b/config/locales/en.yml index fdb4937e..64e26d52 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -75,6 +75,7 @@ en: file_type: File Type file_type_id: File Type hidden: Hidden + hidden_feedback: Suppress feedback name: Name path: Path read_only: Read-only diff --git a/db/migrate/20230727080619_add_hidden_feedback_to_files.rb b/db/migrate/20230727080619_add_hidden_feedback_to_files.rb new file mode 100644 index 00000000..b372e9b9 --- /dev/null +++ b/db/migrate/20230727080619_add_hidden_feedback_to_files.rb @@ -0,0 +1,7 @@ +# frozen_string_literal: true + +class AddHiddenFeedbackToFiles < ActiveRecord::Migration[7.0] + def change + add_column :files, :hidden_feedback, :boolean, default: false, null: false + end +end diff --git a/db/schema.rb b/db/schema.rb index a7acc27f..fcea3229 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_03_20_220012) do +ActiveRecord::Schema[7.0].define(version: 2023_07_27_080619) do # These are extensions that must be enabled in order to support this database enable_extension "pg_trgm" enable_extension "pgcrypto" @@ -284,6 +284,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_20_220012) do t.float "weight" t.string "path" t.integer "file_template_id" + t.boolean "hidden_feedback", default: false, null: false t.index ["context_id", "context_type"], name: "index_files_on_context_id_and_context_type" end diff --git a/lib/python20_course_week.rb b/lib/python20_course_week.rb deleted file mode 100644 index 4b7e4f79..00000000 --- a/lib/python20_course_week.rb +++ /dev/null @@ -1,24 +0,0 @@ -# frozen_string_literal: true - -class Python20CourseWeek - def self.get_for(exercise) - case exercise.title - when /Python20 Aufgabe 1/ - 1 - when /Python20 Aufgabe 2/ - 2 - when /Python20 Aufgabe 3/ - 3 - when /Python20 Aufgabe 4/, /Python20 Snake/ - 4 - # else: Not part of the Python20 course - end - end - - def self.show_linter?(exercise) - week = get_for(exercise) - return true if week.nil? # Exercise is not part of the experiment - - [3, 4].include?(week) - end -end