Merge remote-tracking branch 'origin/master' into exercise-anomaly-detection

# Conflicts:
#	db/schema.rb
This commit is contained in:
Maximilian Grundke
2017-12-13 13:15:29 +01:00
95 changed files with 526 additions and 397 deletions

View File

@@ -37,6 +37,8 @@ class Exercise < ActiveRecord::Base
@working_time_statistics = nil
MAX_EXERCISE_FEEDBACKS = 20
def average_percentage
if average_score and maximum_score != 0.0 and submissions.exists?(cause: 'submit')
@@ -362,4 +364,8 @@ class Exercise < ActiveRecord::Base
end
private :valid_main_file?
def needs_more_feedback?
user_exercise_feedbacks.size <= MAX_EXERCISE_FEEDBACKS
end
end

View File

@@ -18,6 +18,8 @@ class Submission < ActiveRecord::Base
validates :cause, inclusion: {in: CAUSES}
validates :exercise_id, presence: true
MAX_COMMENTS_ON_RECOMMENDED_RFC = 5
def build_files_hash(files, attribute)
files.map(&attribute.to_proc).zip(files).to_h
end
@@ -53,4 +55,16 @@ class Submission < ActiveRecord::Base
def to_s
Submission.model_name.human
end
def redirect_to_feedback?
((user_id + exercise.created_at.to_i) % 10 == 1) && exercise.needs_more_feedback?
end
def own_unsolved_rfc
RequestForComment.unsolved.where(exercise_id: exercise, user_id: user_id).first
end
def unsolved_rfc
RequestForComment.unsolved.where(exercise_id: exercise).where.not(question: nil).order("RANDOM()").find { | rfc_element |(rfc_element.comments_count < MAX_COMMENTS_ON_RECOMMENDED_RFC) }
end
end

View File

@@ -2,10 +2,11 @@ class UserExerciseFeedback < ActiveRecord::Base
include Creation
belongs_to :exercise
has_one :execution_environment, through: :exercise
validates :user_id, uniqueness: { scope: [:exercise_id, :user_type] }
def to_s
"User Exercise Feedback"
end
end
end