Only vote when all teachers registered
All checks were successful
continuous-integration/drone/pr Build is passing
continuous-integration/drone/push Build is passing

This commit is contained in:
Dominic Grimm 2022-03-10 20:58:15 +01:00
parent 78acebcd70
commit 8dda0d29ba
No known key found for this signature in database
GPG key ID: 27C59510125F3C8A

View file

@ -143,7 +143,10 @@ module Backend
def create_vote(context : Context, input : VoteCreateInput) : Vote
context.student!
raise "Teacher selection can't be empty" if input.teacher_ids.empty?
raise "Not enough teachers" if input.teacher_ids.empty?
teacher_role_count = Db::User.where(role: Db::UserRole::Teacher.to_s).count.run.as(Int64)
raise "Teachers not registered" if teacher_role_count != Db::Teacher.count ||
teacher_role_count.zero?
skif = context.external.as(Db::Student).skif
input.teacher_ids.each do |id|