mirror of
https://github.com/aljazceru/CTFd.git
synced 2025-12-18 14:34:21 +01:00
Fix dynamic challenges to work in user mode and team mode (#760)
* Fix dynamic challenges to work in user mode and team mode (Closes #759) * Add test for solving dynamic challenges and challenge de-valuation * Add missing oauth_login link to team_enrollment.html
This commit is contained in:
@@ -7,6 +7,7 @@ from CTFd import utils
|
||||
from CTFd.utils.migrations import upgrade
|
||||
from CTFd.utils.user import get_ip
|
||||
from CTFd.utils.uploads import upload_file, delete_file
|
||||
from CTFd.utils.modes import get_model
|
||||
from flask import Blueprint
|
||||
import math
|
||||
|
||||
@@ -92,9 +93,11 @@ class DynamicValueChallenge(BaseChallenge):
|
||||
for attr, value in data.items():
|
||||
setattr(challenge, attr, value)
|
||||
|
||||
Model = get_model()
|
||||
|
||||
solve_count = Solves.query \
|
||||
.join(Teams, Solves.team_id == Teams.id) \
|
||||
.filter(Solves.challenge_id == challenge.id, Teams.banned == False) \
|
||||
.join(Model, Solves.account_id == Model.id) \
|
||||
.filter(Solves.challenge_id == challenge.id, Model.hidden == False, Model.banned == False) \
|
||||
.count()
|
||||
|
||||
# It is important that this calculation takes into account floats.
|
||||
@@ -165,9 +168,11 @@ class DynamicValueChallenge(BaseChallenge):
|
||||
data = request.form or request.get_json()
|
||||
submission = data['submission'].strip()
|
||||
|
||||
solve_count = Solves.query\
|
||||
.join(Teams, Solves.team_id == Teams.id)\
|
||||
.filter(Solves.challenge_id == chal.id, Teams.banned == False)\
|
||||
Model = get_model()
|
||||
|
||||
solve_count = Solves.query \
|
||||
.join(Model, Solves.account_id == Model.id) \
|
||||
.filter(Solves.challenge_id == challenge.id, Model.hidden == False, Model.banned == False) \
|
||||
.count()
|
||||
|
||||
# It is important that this calculation takes into account floats.
|
||||
|
||||
Reference in New Issue
Block a user