Skip to content

Commit 29adf9f

Browse files
author
Hasso Plattner Institut
committed
Export release-9011@21680e7b
1 parent 5bb2d5b commit 29adf9f

File tree

22 files changed

+528
-68
lines changed

22 files changed

+528
-68
lines changed

app/components/course/learner_dashboard/course_progress.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def main_points
9191
private
9292

9393
def section_completed_items_count(section)
94-
return 0 if section['discarded']
94+
return 0 if section['discarded'] || section['items'].blank?
9595

9696
section['items'].count {|item| completed_item?(item) && !item['discarded'] }
9797
end

app/controllers/quiz_submission_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def auth_context
272272

273273
def create_item_presenter!
274274
Acfs.on the_item, the_section, the_course, the_quiz do |item, section, course, quiz|
275-
presenter_class = Module.const_get "#{item.content_type}_item_presenter".camelize
275+
presenter_class = ItemPresenter.lookup(item)
276276
@item_presenter = presenter_class.build item, section, course, current_user, quiz
277277
end
278278
end

app/helpers/item_context_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def create_position_presenter!
3737

3838
def create_item_presenter!
3939
Acfs.on the_item, the_section, the_course do |item, section, course|
40-
presenter_class = Module.const_get "#{item.content_type}_item_presenter".camelize
40+
presenter_class = ItemPresenter.lookup(item)
4141
@item_presenter = presenter_class.build item, section, course, current_user, params:
4242
end
4343
end

app/presenters/item_presenter.rb

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,18 @@ class ItemPresenter < PrivatePresenter
1919
def_delegator :@section, :pinboard_closed, :section_pinboard_closed?
2020
def_delegator :@course, :lang, :lang
2121

22+
class << self
23+
def lookup(item)
24+
"#{item.content_type}_item_presenter".camelize.constantize
25+
rescue NameError
26+
UnsupportedItemPresenter
27+
end
28+
29+
def for(item, course: nil, user: nil)
30+
lookup(item).new(item:, course:, user:)
31+
end
32+
end
33+
2234
def partial_name
2335
"items/#{content_type}/show_item_#{content_type}"
2436
end
@@ -44,11 +56,6 @@ def exercise_type
4456
@item['exercise_type']
4557
end
4658

47-
def self.for(item, course: nil, user: nil)
48-
class_name = Module.const_get "#{item.content_type}_item_presenter".camelize
49-
class_name.new(item:, course:, user:)
50-
end
51-
5259
def redirect(controller)
5360
controller.redirect_to @redirect
5461
end
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# frozen_string_literal: true
2+
3+
require 'addressable'
4+
5+
class UnsupportedItemPresenter < ItemPresenter
6+
def self.build(item, section, course, user, **)
7+
new(item:, section:, user:, course:)
8+
end
9+
10+
def partial_name
11+
'items/show_unsupported_item'
12+
end
13+
end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.col-md-12
2+
.course-area-main data-lanalytics-context={course_id: item.course_id}.to_json
3+
= render 'items/header', item: item
4+
5+
= render Global::Callout.new(t(:'items.show.unsupported_item_type'), type: :error)
6+
7+
.mt40
8+
= render Course::BottomNavigation.new(course_id: position.course.id,
9+
prev_item_id: position.prev_item&.id,
10+
next_item_id: position.next_item&.id)

config/initializers/sentry.rb

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,50 @@
3232
# Do not send full list of gems with each event
3333
config.send_modules = false
3434

35-
# Set sampling rates to 1.0 to capture 100% of transactions and
36-
# profiles for performance monitoring.
37-
config.traces_sample_rate = 1.0
38-
config.profiles_sample_rate = 1.0
39-
4035
filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
4136
config.before_send = lambda do |event, _hint|
4237
# use Rails' parameter filter to sanitize the event
4338
filter.filter(event.to_hash)
4439
end
40+
41+
# The default sampling rate for Sentry transactions. Unless other
42+
# rules apply below, sample all requests by default.
43+
#
44+
# Collect profiles are transactions that are sampled.
45+
config.traces_sample_rate = ENV.fetch('SENTRY_TRACES_SAMPLE_RATE', '1.0').to_f
46+
config.profiles_sample_rate = 1.0
47+
48+
config.traces_sampler = lambda do |ctx|
49+
# If this is the continuation of a trace, just use that decision
50+
# (rate controlled by the caller).
51+
unless ctx[:parent_sampled].nil?
52+
next ctx[:parent_sampled]
53+
end
54+
55+
# `transaction_context` is the transaction object in hash form. Keep
56+
# in mind that sampling happens right after the transaction is
57+
# initialized for example, at the beginning of the request.
58+
transaction_context = ctx[:transaction_context]
59+
60+
# `transaction_context` helps you sample transactions with more
61+
# sophistication. For example, you can provide different sample
62+
# rates based on the operation or name.
63+
op = transaction_context[:op]
64+
transaction_name = transaction_context[:name]
65+
66+
case op
67+
when 'http.server'
68+
# For Rails applications, the transaction name would be the
69+
# request's path (env["PATH_INFO"]) instead of
70+
# "Controller#action".
71+
case transaction_name
72+
when %r{^/(up|ping|system_info)}
73+
return 0.0 # Ignore health check requests
74+
end
75+
end
76+
77+
config.traces_sample_rate
78+
end
4579
end
4680

4781
Sentry.set_tags(

config/locales/de.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1997,6 +1997,7 @@ de:
19971997
prev_item: Zurück
19981998
next_item: Weiter
19991999
unsupported_browser: Ihr Browser wird nicht unterstützt. Bitte benutzen Sie einen modernen Browser.
2000+
unsupported_item_type: Diese Art von Lerninhalt wird nicht mehr unterstützt. Bitte fahren Sie mit dem nächsten fort.
20002001
video:
20012002
preview:
20022003
info: "Dieses Video gehört zum %{platform}-Kurs <b>%{course_title}</b>. Möchten Sie mehr sehen?"

config/locales/en.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,6 +2760,7 @@ en:
27602760
prev_item: Previous
27612761
next_item: Next
27622762
unsupported_browser: Your browser is not supported. Please use a modern browser.
2763+
unsupported_item_type: This item type is no longer supported. Please skip to the next item.
27632764
video:
27642765
preview:
27652766
info: "This video belongs to the %{platform} course <b>%{course_title}</b>. Do you want to see more?"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ requires-python = ">=3.12"
55
dependencies = [
66
"mkdocs-awesome-pages-plugin==2.10.1",
77
"mkdocs-git-revision-date-plugin==0.3.2",
8-
"mkdocs-material==9.6.7",
8+
"mkdocs-material==9.6.9",
99
]

0 commit comments

Comments
 (0)