Add option to suppress feedback messages

This is used to dynamically exclude some test results from being shown to users, but still allows them to run in the background (e.g., for research).
This commit is contained in:
Sebastian Serth
2023-07-27 10:38:49 +02:00
parent 5faf5be033
commit db56a690c7
9 changed files with 20 additions and 35 deletions

View File

@ -34,7 +34,7 @@ module FileParameters
def file_attributes def file_attributes
%w[content context_id feedback_message file_id file_type_id hidden id name native_file path read_only role weight %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 end
private :file_attributes private :file_attributes
end end

View File

@ -49,6 +49,7 @@ module CodeOcean
validates :feedback_message, absence: true, unless: :teacher_defined_assessment? validates :feedback_message, absence: true, unless: :teacher_defined_assessment?
validates :hashed_content, if: :content_present?, presence: true validates :hashed_content, if: :content_present?, presence: true
validates :hidden, inclusion: [true, false] validates :hidden, inclusion: [true, false]
validates :hidden_feedback, inclusion: [true, false]
validates :name, presence: true validates :name, presence: true
validates :read_only, inclusion: [true, false] validates :read_only, inclusion: [true, false]
validates :role, inclusion: {in: ROLES} validates :role, inclusion: {in: ROLES}

View File

@ -283,7 +283,7 @@ class Submission < ApplicationRecord
end end
output.merge!(assessment) 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) output.except!(:messages)
end end
@ -329,12 +329,6 @@ class Submission < ApplicationRecord
end end
end end
# Return all test results except for those of a linter if not allowed outputs&.reject {|output| output[:hidden_feedback] if output.present? }
show_linter = Python20CourseWeek.show_linter? exercise
outputs&.reject do |output|
next if show_linter || output.blank?
output[:file_role] == 'teacher_defined_linter'
end
end end
end end

View File

@ -30,10 +30,14 @@ li.card.mt-2
label.form-check-label label.form-check-label
= f.check_box(:hidden, class: 'form-check-input') = f.check_box(:hidden, class: 'form-check-input')
= t('activerecord.attributes.file.hidden') = t('activerecord.attributes.file.hidden')
.form-check.mb-3 .form-check
label.form-check-label label.form-check-label
= f.check_box(:read_only, class: 'form-check-input') = f.check_box(:read_only, class: 'form-check-input')
= t('activerecord.attributes.file.read_only') = 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'};" .test-related-fields style="display: #{f.object.teacher_defined_assessment? ? 'initial' : 'none'};"
.mb-3 .mb-3
= f.label(:name, t('activerecord.attributes.file.feedback_message'), class: 'form-label') = f.label(:name, t('activerecord.attributes.file.feedback_message'), class: 'form-label')

View File

@ -75,6 +75,7 @@ de:
file_type: Dateityp file_type: Dateityp
file_type_id: Dateityp file_type_id: Dateityp
hidden: Versteckt hidden: Versteckt
hidden_feedback: Feedback ausblenden
name: Name name: Name
path: Pfad path: Pfad
read_only: Schreibgeschützt read_only: Schreibgeschützt

View File

@ -75,6 +75,7 @@ en:
file_type: File Type file_type: File Type
file_type_id: File Type file_type_id: File Type
hidden: Hidden hidden: Hidden
hidden_feedback: Suppress feedback
name: Name name: Name
path: Path path: Path
read_only: Read-only read_only: Read-only

View File

@ -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

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # 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 # These are extensions that must be enabled in order to support this database
enable_extension "pg_trgm" enable_extension "pg_trgm"
enable_extension "pgcrypto" enable_extension "pgcrypto"
@ -284,6 +284,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_03_20_220012) do
t.float "weight" t.float "weight"
t.string "path" t.string "path"
t.integer "file_template_id" 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" t.index ["context_id", "context_type"], name: "index_files_on_context_id_and_context_type"
end end

View File

@ -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