commenting, improved readability

This commit is contained in:
Thomas Hille
2017-03-10 18:49:36 +01:00
parent 12adfde6c2
commit 8b67a70546
2 changed files with 16 additions and 15 deletions

View File

@ -587,6 +587,7 @@ configureEditors: function () {
}, },
dataType: 'json', dataType: 'json',
method: 'GET', method: 'GET',
// get working times for this exercise
url: $('#editor').data('working-times-url'), url: $('#editor').data('working-times-url'),
success: function (data) { success: function (data) {
var percentile75 = data['working_time_75_percentile']; var percentile75 = data['working_time_75_percentile'];

View File

@ -20,6 +20,15 @@ class ExercisesController < ApplicationController
end end
private :authorize! private :authorize!
def max_intervention_count
3
end
def java_course_token
"702cbd2a-c84c-4b37-923a-692d7d1532d0"
end
def batch_update def batch_update
@exercises = Exercise.all @exercises = Exercise.all
authorize! authorize!
@ -156,15 +165,10 @@ class ExercisesController < ApplicationController
def implement def implement
redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists? redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists?
user_got_enough_interventions = UserExerciseIntervention.where(exercise: @exercise, user: current_user).count >= 3 user_got_enough_interventions = UserExerciseIntervention.where(exercise: @exercise, user: current_user).count >= max_intervention_count
is_java_course = @course_token && @course_token.eql?(java_course_token) is_java_course = @course_token && @course_token.eql?(java_course_token)
@show_interventions = @show_interventions = (!is_java_course || user_got_enough_interventions) ? "false" : "true"
if !is_java_course || user_got_enough_interventions
"false"
else
"true"
end
@search = Search.new @search = Search.new
@search.exercise = @exercise @search.exercise = @exercise
@ -271,10 +275,10 @@ class ExercisesController < ApplicationController
def collect_set_and_unset_exercise_tags def collect_set_and_unset_exercise_tags
@search = policy_scope(Tag).search(params[:q]) @search = policy_scope(Tag).search(params[:q])
@tags = @search.result.order(:name) @tags = @search.result.order(:name)
exercise_tags = @exercise.exercise_tags checked_exercise_tags = @exercise.exercise_tags
tags_set = exercise_tags.collect{|e| e.tag}.to_set checked_tags = checked_exercise_tags.collect{|e| e.tag}.to_set
tags_not_set = Tag.all.to_set.subtract tags_set unchecked_tags = Tag.all.to_set.subtract checked_tags
@exercise_tags = exercise_tags + tags_not_set.collect { |tag| ExerciseTag.new(exercise: @exercise, tag: tag)} @exercise_tags = checked_exercise_tags + unchecked_tags.collect { |tag| ExerciseTag.new(exercise: @exercise, tag: tag)}
end end
private :collect_set_and_unset_exercise_tags private :collect_set_and_unset_exercise_tags
@ -379,8 +383,4 @@ class ExercisesController < ApplicationController
redirect_to_lti_return_path redirect_to_lti_return_path
end end
def java_course_token
"702cbd2a-c84c-4b37-923a-692d7d1532d0"
end
end end