Merge remote-tracking branch 'origin/master' into error-info
# Conflicts: # app/controllers/concerns/submission_scoring.rb # app/views/application/_navigation.html.slim # config/locales/de.yml # config/locales/en.yml # db/schema.rb
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
class Comment < ActiveRecord::Base
|
||||
# inherit the creation module: encapsulates that this is a polymorphic user, offers some aliases and makes sure that all necessary attributes are set.
|
||||
include Creation
|
||||
attr_accessor :username, :date, :updated
|
||||
attr_accessor :username, :date, :updated, :editable
|
||||
|
||||
belongs_to :file, class_name: 'CodeOcean::File'
|
||||
belongs_to :user, polymorphic: true
|
||||
|
@@ -2,4 +2,8 @@ class ExerciseCollection < ActiveRecord::Base
|
||||
|
||||
has_and_belongs_to_many :exercises
|
||||
|
||||
end
|
||||
def to_s
|
||||
"#{I18n.t('activerecord.models.exercise_collection.one')}: #{name} (#{id})"
|
||||
end
|
||||
|
||||
end
|
||||
|
@@ -5,11 +5,9 @@ class ExternalUser < ActiveRecord::Base
|
||||
validates :external_id, presence: true
|
||||
|
||||
def displayname
|
||||
result = "User " + id.to_s
|
||||
if(!consumer.nil? && consumer.name == 'openHPI')
|
||||
result = Rails.cache.fetch("#{cache_key}/displayname", expires_in: 12.hours) do
|
||||
Xikolo::UserClient.get(external_id.to_s)[:display_name]
|
||||
end
|
||||
result = name
|
||||
if(result == nil || result == "")
|
||||
result = "User " + id.to_s
|
||||
end
|
||||
result
|
||||
end
|
||||
|
@@ -37,35 +37,17 @@ class ProxyExercise < ActiveRecord::Base
|
||||
assigned_user_proxy_exercise.exercise
|
||||
else
|
||||
matching_exercise =
|
||||
if (token.eql? "47f4c736")
|
||||
Rails.logger.debug("Proxy exercise with token 47f4c736, split user in groups..")
|
||||
group = UserGroupSeparator.getGroupWeek2Testing(user)
|
||||
Rails.logger.debug("user assigned to group #{group}")
|
||||
case group
|
||||
when :group_a
|
||||
exercises.where(id: 348).first
|
||||
when :group_b
|
||||
exercises.where(id: 349).first
|
||||
when :group_c
|
||||
exercises.where(id: 350).first
|
||||
when :group_d
|
||||
exercises.where(id: 351).first
|
||||
end
|
||||
else
|
||||
Rails.logger.debug("find new matching exercise for user #{user.id}" )
|
||||
begin
|
||||
find_matching_exercise(user)
|
||||
rescue #fallback
|
||||
rescue => e #fallback
|
||||
Rails.logger.error("finding matching exercise failed. Fall back to random exercise! Error: #{$!}" )
|
||||
@reason[:reason] = "fallback because of error"
|
||||
@reason[:error] = "#{$!}"
|
||||
exercises.shuffle.first
|
||||
@reason[:error] = "#{$!}:\n\t#{e.backtrace.join("\n\t")}"
|
||||
exercises.where("expected_difficulty > 1").shuffle.first # difficulty should be > 1 to prevent dummy exercise from being chosen.
|
||||
end
|
||||
end
|
||||
user.user_proxy_exercise_exercises << UserProxyExerciseExercise.create(user: user, exercise: matching_exercise, proxy_exercise: self, reason: @reason.to_json)
|
||||
matching_exercise
|
||||
|
||||
|
||||
end
|
||||
recommended_exercise
|
||||
end
|
||||
@@ -136,6 +118,7 @@ class ProxyExercise < ActiveRecord::Base
|
||||
relative_knowledge_improvement[potex] += old_relative_loss_tag - new_relative_loss_tag
|
||||
end
|
||||
end
|
||||
|
||||
highest_difficulty_user_has_accessed = exercises_user_has_accessed.map{|e| e.expected_difficulty}.sort.last || 0
|
||||
best_matching_exercise = find_best_exercise(relative_knowledge_improvement, highest_difficulty_user_has_accessed)
|
||||
@reason[:reason] = "best matching exercise"
|
||||
|
@@ -5,6 +5,7 @@ class RequestForComment < ActiveRecord::Base
|
||||
belongs_to :file, class_name: 'CodeOcean::File'
|
||||
|
||||
has_many :comments, through: :submission
|
||||
has_many :subscriptions
|
||||
|
||||
scope :unsolved, -> { where(solved: [false, nil]) }
|
||||
|
||||
@@ -37,6 +38,14 @@ class RequestForComment < ActiveRecord::Base
|
||||
submission.files.map { |file| file.comments.size}.sum
|
||||
end
|
||||
|
||||
def commenters
|
||||
commenters = []
|
||||
comments.distinct.to_a.each {|comment|
|
||||
commenters.append comment.user
|
||||
}
|
||||
commenters.uniq {|user| user.id}
|
||||
end
|
||||
|
||||
def to_s
|
||||
"RFC-" + self.id.to_s
|
||||
end
|
||||
|
@@ -34,7 +34,7 @@ class Submission < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def normalized_score
|
||||
::NewRelic::Agent.add_custom_parameters({ unnormalized_score: score })
|
||||
::NewRelic::Agent.add_custom_attributes({ unnormalized_score: score })
|
||||
if !score.nil? && !exercise.maximum_score.nil? && (exercise.maximum_score > 0)
|
||||
score / exercise.maximum_score
|
||||
else
|
||||
|
4
app/models/subscription.rb
Normal file
4
app/models/subscription.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
class Subscription < ActiveRecord::Base
|
||||
belongs_to :user, polymorphic: true
|
||||
belongs_to :request_for_comment
|
||||
end
|
Reference in New Issue
Block a user