From 39467ad0e025832a4d261fbd404971095d8e9c14 Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Mon, 8 Mar 2021 23:20:42 +0100 Subject: [PATCH] Hide linter in week 1 and 2 of Python course --- .../concerns/submission_scoring.rb | 8 +++++ lib/python20_course_week.rb | 29 +++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 lib/python20_course_week.rb diff --git a/app/controllers/concerns/submission_scoring.rb b/app/controllers/concerns/submission_scoring.rb index 279e7a05..b04f0fe2 100644 --- a/app/controllers/concerns/submission_scoring.rb +++ b/app/controllers/concerns/submission_scoring.rb @@ -92,5 +92,13 @@ module SubmissionScoring output.except!(:error_messages, :count, :failed, :filename, :message, :passed, :stderr, :stdout) end end + + # Return all test results except for those of a linter if not allowed + show_linter = Python20CourseWeek.show_linter? submission.exercise + outputs&.reject do |output| + next if show_linter || output.blank? + + output[:file_role] == 'teacher_defined_linter' + end end end diff --git a/lib/python20_course_week.rb b/lib/python20_course_week.rb new file mode 100644 index 00000000..7d510ea6 --- /dev/null +++ b/lib/python20_course_week.rb @@ -0,0 +1,29 @@ +# 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/ + 4 + when /Python20 Snake/ + 4 + else + # Not part of the Python20 course + nil + 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