Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ending time to challenges #506

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

camdenmoors
Copy link
Collaborator

@camdenmoors camdenmoors commented Jun 24, 2020

This closes #487

  • Adds a challenge_end column to challenges
  • Adds method before_close? to the challenge model to check if it's before closing time
  • Modifies challenge.open? to call before_close?
  • Adds a test to make sure you can't access a challenge past it's due date.

app/models/challenge.rb Outdated Show resolved Hide resolved
@rbclark
Copy link
Contributor

rbclark commented Jun 24, 2020

Does this work with PentestFlags? Also does this stop the calculation for ShareChallenges when the challenge closes? (

def calc_points_for_first_solve
first_capture_point_bonus + calc_point_value(start_calculation_at, Game.instance.defense_end)
end
def calc_points_for_solve
potential_shares = calc_shares(first_solve_time, Game.instance.defense_end)
convert_shares_to_points_for(
potential_shares,
calc_offensive_shares_for_solved_challenges.values.sum + potential_shares,
calc_point_value(start_calculation_at, first_solve_time)
)
end
)

@camdenmoors
Copy link
Collaborator Author

camdenmoors commented Jun 29, 2020

Does this stop the calculation for ShareChallenges when the challenge closes?

It should stop calculation now based on challenge.close_challenge_at (if it exists)

Copy link
Contributor

@rbclark rbclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this stop the calculation for ShareChallenges when the challenge closes?

It should stop calculation now based on challenge.close_challenge_at (if it exists)

I don't see any committed changes modifying the flag_challenge_share_module or ShareChallenge model.

You should be able to test whether the challenge close time exists by creating a copy of the following test:

test 'point value stops increasing and decreasing after game completion' do
@game.update(start: 3.hours.ago, stop: 2.hours.ago)
unsolve_team = create(:team)
point_value = @challenge.defense_flags.sample.display_point_value(unsolve_team)
assert_equal 102, point_value
end
test 'point value stops increasing and decreasing after game completion for solved challenge' do
@game.update(start: 3.hours.ago, stop: 2.hours.ago)
solve_team = create(:team)
unsolve_team = create(:team)
solved_challenge = create(:pentest_solved_challenge, team: solve_team, challenge: @challenge, created_at: 3.hours.ago)
# Points decrease at ~3 points per hour with the challenge defined above
# This game only lasts 1 hour and therefore unsolve_team is shown they would've received
# 47 points if they solved this challenge right at the end of the game.
assert_equal 47, solved_challenge.flag.display_point_value(unsolve_team)
end

Change the game to close at the current time instead of 2 hours ago, and change the challenge to close 2 hours ago. The score should then be exactly the same even though the game was open an additional 2 hours (since the challenge was closed).

db/migrate/20200624162213_add_challenge_end_time.rb Outdated Show resolved Hide resolved
test/models/challenge_test.rb Outdated Show resolved Hide resolved
@camdenmoors camdenmoors marked this pull request as draft June 30, 2020 14:05
@camdenmoors
Copy link
Collaborator Author

Putting this as a draft until I can figure out what's making it return the wrong value for flags

@mergify
Copy link
Contributor

mergify bot commented Nov 25, 2021

This pull request has conflict. Could you fix it @camdenmoors?

1 similar comment
@mergify
Copy link
Contributor

mergify bot commented Sep 26, 2022

This pull request has conflict. Could you fix it @camdenmoors?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow challenges to close at before the rest of the competition
2 participants