Description:
heartbeat response full
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r649:3cb38436f7f6 - - 6 files changed: 42 inserted, 4 deleted
@@ -0,0 +1,9 | |||||
|
|
1 | + class AddHeartBeatFull < ActiveRecord::Migration | ||
|
|
2 | + def up | ||
|
|
3 | + GraderConfiguration.create key: 'right.heartbeat_response_full', value_type: 'string', value:'RESTART', description:'Heart beat response text when user got full score (set this value to the empty string to disable this feature)' | ||
|
|
4 | + end | ||
|
|
5 | + | ||
|
|
6 | + def down | ||
|
|
7 | + | ||
|
|
8 | + end | ||
|
|
9 | + end |
@@ -21,7 +21,22 | |||||
|
21 | #end |
|
21 | #end |
|
22 | #HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status]) |
|
22 | #HeartBeat.create(user_id: @user.id, ip_address: request.remote_ip, status: params[:status]) |
|
23 |
|
23 | ||
|
24 |
- re |
|
24 | + res = GraderConfiguration['right.heartbeat_response'] |
|
|
25 | + res.strip! if res | ||
|
|
26 | + full = GraderConfiguration['right.heartbeat_response_full'] | ||
|
|
27 | + full.strip! if full | ||
|
|
28 | + | ||
|
|
29 | + if full and full != '' | ||
|
|
30 | + l = Login.where(ip_address: request.remote_ip).last | ||
|
|
31 | + @user = l.user | ||
|
|
32 | + if @user.solve_all_available_problems? | ||
|
|
33 | + render text: (full || 'OK') | ||
|
|
34 | + else | ||
|
|
35 | + render text: (res || 'OK') | ||
|
|
36 | + end | ||
|
|
37 | + else | ||
|
|
38 | + render text: (GraderConfiguration['right.heartbeat_response'] || 'OK') | ||
|
|
39 | + end | ||
|
25 | end |
|
40 | end |
|
26 |
|
41 | ||
|
27 | def index |
|
42 | def index |
@@ -279,6 +279,15 | |||||
|
279 | return contest_problems |
|
279 | return contest_problems |
|
280 | end |
|
280 | end |
|
281 |
|
281 | ||
|
|
282 | + def solve_all_available_problems? | ||
|
|
283 | + available_problems.each do |p| | ||
|
|
284 | + u = self | ||
|
|
285 | + sub = Submission.find_last_by_user_and_problem(u.id,p.id) | ||
|
|
286 | + return false if !p or !sub or sub.points < p.full_score | ||
|
|
287 | + end | ||
|
|
288 | + return true | ||
|
|
289 | + end | ||
|
|
290 | + | ||
|
282 | def available_problems |
|
291 | def available_problems |
|
283 | if not GraderConfiguration.multicontests? |
|
292 | if not GraderConfiguration.multicontests? |
|
284 | return Problem.available_problems |
|
293 | return Problem.available_problems |
@@ -88,9 +88,7 | |||||
|
88 |
|
88 | ||
|
89 | #grader |
|
89 | #grader |
|
90 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
90 | get 'graders/list', to: 'graders#list', as: 'grader_list' |
|
91 | - |
|
||
|
92 |
|
91 | ||
|
93 | - get 'heartbeat/:id/edit' => 'heartbeat#edit' |
|
||
|
94 |
|
92 | ||
|
95 | # See how all your routes lay out with "rake routes" |
|
93 | # See how all your routes lay out with "rake routes" |
|
96 |
|
94 |
@@ -11,7 +11,7 | |||||
|
11 | # |
|
11 | # |
|
12 | # It's strongly recommended that you check this file into your version control system. |
|
12 | # It's strongly recommended that you check this file into your version control system. |
|
13 |
|
13 | ||
|
14 |
- ActiveRecord::Schema.define(version: 20170 |
|
14 | + ActiveRecord::Schema.define(version: 20170427070345) do |
|
15 |
|
15 | ||
|
16 | create_table "announcements", force: :cascade do |t| |
|
16 | create_table "announcements", force: :cascade do |t| |
|
17 | t.string "author", limit: 255 |
|
17 | t.string "author", limit: 255 |
@@ -90,6 +90,13 | |||||
|
90 | }, |
|
90 | }, |
|
91 |
|
91 | ||
|
92 | { |
|
92 | { |
|
|
93 | + :key => 'right.heartbeat_response_full', | ||
|
|
94 | + :value_type => 'string', | ||
|
|
95 | + :default_value => 'OK', | ||
|
|
96 | + :description => 'Heart beat response text when user got full score (set this value to the empty string to disable this feature)' | ||
|
|
97 | + }, | ||
|
|
98 | + | ||
|
|
99 | + { | ||
|
93 | :key => 'right.view_testcase', |
|
100 | :key => 'right.view_testcase', |
|
94 | :value_type => 'boolean', |
|
101 | :value_type => 'boolean', |
|
95 | :default_value => 'false', |
|
102 | :default_value => 'false', |
You need to be logged in to leave comments.
Login now