Show More
Commit Description:
datatable now works
Commit Description:
datatable now works
References:
File last commit:
Show/Diff file:
Action:
app/models/site.rb
| 46 lines
| 904 B
| text/x-ruby
| RubyLexer
|
|
|
r85 | class Site < ActiveRecord::Base | ||
|
|
r106 | belongs_to :country | ||
| has_many :users | ||||
|
|
r85 | def clear_start_time_if_not_started | ||
| if !self.started | ||||
| self.start_time = nil | ||||
| end | ||||
| end | ||||
|
|
r123 | def time_left | ||
|
|
r320 | contest_time = GraderConfiguration.contest_time_limit | ||
|
|
r162 | |||
|
|
r217 | return nil if contest_time == nil | ||
| return contest_time if !self.started | ||||
|
|
r129 | |||
|
|
r217 | current_time = Time.now.gmtime | ||
| if self.start_time!=nil | ||||
| finish_time = self.start_time + contest_time | ||||
| else | ||||
| finish_time = current_time + contest_time | ||||
| end | ||||
|
|
r123 | |||
|
|
r217 | if current_time > finish_time | ||
| return current_time - current_time | ||||
|
|
r123 | else | ||
|
|
r217 | return finish_time - current_time | ||
|
|
r123 | end | ||
| end | ||||
|
|
r85 | def finished? | ||
| if !self.started | ||||
| return false | ||||
| end | ||||
|
|
r320 | contest_time = GraderConfiguration.contest_time_limit | ||
|
|
r217 | if contest_time!=nil | ||
| return Time.now.gmtime > (self.start_time + contest_time) | ||||
|
|
r85 | else | ||
| false | ||||
| end | ||||
| end | ||||
| end | ||||
