Hide score button if exercise has no tests
We check for all teacher-defined assessments (linter and unit tests) to determine whether scoring should be possible
This commit is contained in:

committed by
Sebastian Serth

parent
ba5918b4ca
commit
e0c2c7b806
@@ -324,6 +324,8 @@ class ExercisesController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
@embed_options[:disable_score] = true unless @exercise.teacher_defined_assessment?
|
||||
|
||||
@hide_rfc_button = @embed_options[:disable_rfc]
|
||||
|
||||
@search = Search.new
|
||||
|
@@ -83,7 +83,7 @@ class SubmissionsController < ApplicationController
|
||||
client_socket = tubesock
|
||||
|
||||
client_socket.onopen do |_event|
|
||||
kill_client_socket(client_socket) if @embed_options[:disable_run]
|
||||
return kill_client_socket(client_socket) if @embed_options[:disable_run]
|
||||
end
|
||||
|
||||
client_socket.onclose do |_event|
|
||||
@@ -199,7 +199,7 @@ class SubmissionsController < ApplicationController
|
||||
hijack do |tubesock|
|
||||
tubesock.onopen do |_event|
|
||||
switch_locale do
|
||||
kill_client_socket(tubesock) if @embed_options[:disable_score]
|
||||
return kill_client_socket(tubesock) if @embed_options[:disable_score] || !@submission.exercise.teacher_defined_assessment?
|
||||
|
||||
# The score is stored separately, we can forward it to the client immediately
|
||||
tubesock.send_data(JSON.dump(@submission.calculate_score))
|
||||
@@ -226,7 +226,7 @@ class SubmissionsController < ApplicationController
|
||||
hijack do |tubesock|
|
||||
tubesock.onopen do |_event|
|
||||
switch_locale do
|
||||
kill_client_socket(tubesock) if @embed_options[:disable_run]
|
||||
return kill_client_socket(tubesock) if @embed_options[:disable_run]
|
||||
|
||||
# The score is stored separately, we can forward it to the client immediately
|
||||
tubesock.send_data(JSON.dump(@submission.test(@file)))
|
||||
|
@@ -205,6 +205,10 @@ class Exercise < ApplicationRecord
|
||||
"
|
||||
end
|
||||
|
||||
def teacher_defined_assessment?
|
||||
files.any?(&:teacher_defined_assessment?)
|
||||
end
|
||||
|
||||
def get_working_times_for_study_group(study_group_id, user = nil)
|
||||
user_progress = []
|
||||
additional_user_data = []
|
||||
|
@@ -29,10 +29,14 @@ class ExercisePolicy < AdminOrAuthorPolicy
|
||||
define_method(action) { (admin? || teacher_in_study_group? || author?) && @user.codeharbor_link }
|
||||
end
|
||||
|
||||
%i[implement? working_times? intervention? search? submit? reload?].each do |action|
|
||||
%i[implement? working_times? intervention? search? reload?].each do |action|
|
||||
define_method(action) { everyone }
|
||||
end
|
||||
|
||||
def submit?
|
||||
everyone && @record.teacher_defined_assessment?
|
||||
end
|
||||
|
||||
class Scope < Scope
|
||||
def resolve
|
||||
if @user.admin?
|
||||
|
Reference in New Issue
Block a user