diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index e197ee92..ef627c63 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -443,6 +443,7 @@ class ExercisesController < ApplicationController if current_user.admin? || current_user.teacher? redirect_to(@exercise, alert: t('exercises.implement.unpublished')) if @exercise.unpublished? redirect_to(@exercise, alert: t('exercises.implement.no_files')) unless @exercise.files.visible.exists? + redirect_to(@exercise, alert: t('exercises.implement.no_execution_environment')) if @exercise.execution_environment.blank? else render_not_authorized end diff --git a/app/policies/exercise_policy.rb b/app/policies/exercise_policy.rb index 42bcf48c..f10c446a 100644 --- a/app/policies/exercise_policy.rb +++ b/app/policies/exercise_policy.rb @@ -31,7 +31,7 @@ class ExercisePolicy < AdminOrAuthorPolicy %i[implement? working_times? intervention? search? reload?].each do |action| define_method(action) do - return no_one unless @record.files.visible.exists? + return no_one unless @record.files.visible.exists? && @record.execution_environment.present? admin? || teacher_in_study_group? || author? || (everyone && !@record.unpublished?) end diff --git a/config/locales/de.yml b/config/locales/de.yml index b8ffdf25..80790d07 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -451,6 +451,7 @@ de: not_graded: ohne Punkte hint: Hinweis no_files: Die Aufgabe umfasst noch keine sichtbaren Dateien. + no_execution_environment: Für die Aufgabe wurde noch keine Ausführungsumgebung gewählt. no_output: Die letzte Code-Ausführung terminierte am %{timestamp} ohne Ausgabe. no_output_exit_successful: Die letzte Code-Ausführung terminierte am %{timestamp} ohne Ausgabe and wurde erfolgreich beendet (Statuscode %{exit_code}). no_output_exit_failure: Die letzte Code-Ausführung terminierte am %{timestamp} ohne Ausgabe und wurde mit einem Fehler beendet (Statuscode %{exit_code}). diff --git a/config/locales/en.yml b/config/locales/en.yml index 9345245a..4aa44e7b 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -451,6 +451,7 @@ en: not_graded: not graded hint: Hint no_files: The exercise does not comprise visible files yet. + no_execution_environment: No execution environment has been selected for the exercise yet. no_output: The last code run finished on %{timestamp} without any output. no_output_exit_successful: The last code run finished on %{timestamp} without any output and exited successfully (status code %{exit_code}). no_output_exit_failure: The last code run finished on %{timestamp} without any output and exited with a failure (status code %{exit_code}). @@ -464,7 +465,7 @@ en: results: Results start: Start Coding test_count: '%{count} test files have been executed.' - unpublished: The selected exercises has been deactivated. Hence, you cannot implement this exercise at the moment. + unpublished: The selected exercise has been deactivated. Hence, you cannot implement this exercise at the moment. workspace: Workspace comment: a_comment: comment