Description:
add model solution
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r854:14d6c4fb29b0 - - 12 files changed: 267 inserted, 180 deleted
@@ -0,0 +1,6 | |||
|
1 | + class AddTypeToSubmission < ActiveRecord::Migration[7.0] | |
|
2 | + def change | |
|
3 | + add_column :submissions, :tag, :integer, default: 0 | |
|
4 | + add_column :problems, :difficulty, :integer | |
|
5 | + end | |
|
6 | + end |
@@ -39,6 +39,17 | |||
|
39 | 39 | return true |
|
40 | 40 | end |
|
41 | 41 | |
|
42 | + #admin always count as every roles | |
|
43 | + def role_authorization(roles) | |
|
44 | + return false unless check_valid_login | |
|
45 | + user = User.find(session[:user_id]) | |
|
46 | + return true if user.admin? | |
|
47 | + roles.each do |r| | |
|
48 | + return true if user.has_role?(r) | |
|
49 | + end | |
|
50 | + unauthorized_redirect | |
|
51 | + end | |
|
52 | + | |
|
42 | 53 | def authorization_by_roles(allowed_roles) |
|
43 | 54 | return false unless check_valid_login |
|
44 | 55 | unless @current_user.roles.detect { |role| allowed_roles.member?(role.name) } |
@@ -71,7 +71,7 | |||
|
71 | 71 | end |
|
72 | 72 | |
|
73 | 73 | @submission.submitted_at = Time.new.gmtime |
|
74 |
- @submission.ip_address = |
|
|
74 | + @submission.ip_address = cookies.encrypted[:uuid] | |
|
75 | 75 | |
|
76 | 76 | if @current_user.admin? == false && GraderConfiguration.time_limit_mode? && @current_user.contest_finished? |
|
77 | 77 | @submission.errors.add(:base,"The contest is over.") |
@@ -234,16 +234,21 | |||
|
234 | 234 | |
|
235 | 235 | return unless @problem |
|
236 | 236 | |
|
237 | + #model submisssion | |
|
238 | + @model_subs = Submission.where(problem: @problem,tag: Submission.tags[:model]) | |
|
239 | + | |
|
240 | + | |
|
241 | + #calculate best submission | |
|
237 | 242 | @by_lang = {} #aggregrate by language |
|
238 | 243 | |
|
239 | 244 | range =65 |
|
240 | - @histogram = { data: Array.new(range,0), summary: {} } | |
|
245 | + #@histogram = { data: Array.new(range,0), summary: {} } | |
|
241 | 246 | @summary = {count: 0, solve: 0, attempt: 0} |
|
242 | 247 | user = Hash.new(0) |
|
243 | 248 | Submission.where(problem_id: @problem.id).find_each do |sub| |
|
244 | 249 | #histogram |
|
245 | 250 | d = (DateTime.now.in_time_zone - sub.submitted_at) / 24 / 60 / 60 |
|
246 | - @histogram[:data][d.to_i] += 1 if d < range | |
|
251 | + #@histogram[:data][d.to_i] += 1 if d < range | |
|
247 | 252 | |
|
248 | 253 | next unless sub.points |
|
249 | 254 | @summary[:count] += 1 |
@@ -311,9 +316,13 | |||
|
311 | 316 | end |
|
312 | 317 | end |
|
313 | 318 | |
|
314 | - @histogram[:summary][:max] = [@histogram[:data].max,1].max | |
|
319 | + #@histogram[:summary][:max] = [@histogram[:data].max,1].max | |
|
315 | 320 | @summary[:attempt] = user.count |
|
316 | 321 | user.each_value { |v| @summary[:solve] += 1 if v == 1 } |
|
322 | + | |
|
323 | + | |
|
324 | + #for new graph | |
|
325 | + @chart_dataset = @problem.get_jschart_history.to_json.html_safe | |
|
317 | 326 | end |
|
318 | 327 | |
|
319 | 328 | def stuck #report struggling user,problem |
@@ -1,7 +1,8 | |||
|
1 | 1 | class SubmissionsController < ApplicationController |
|
2 | + before_action :set_submission, only: [:show,:download,:compiler_msg,:rejudge,:set_tag, :edit] | |
|
2 | 3 | before_action :check_valid_login |
|
3 | 4 | before_action :submission_authorization, only: [:show, :download, :edit] |
|
4 | - before_action :admin_authorization, only: [:rejudge] | |
|
5 | + before_action only: [:rejudge, :set_tag] do role_authorization([:ta]) end | |
|
5 | 6 | |
|
6 | 7 | # GET /submissions |
|
7 | 8 | # GET /submissions.json |
@@ -27,8 +28,6 | |||
|
27 | 28 | # GET /submissions/1 |
|
28 | 29 | # GET /submissions/1.json |
|
29 | 30 | def show |
|
30 | - @submission = Submission.find(params[:id]) | |
|
31 | - | |
|
32 | 31 | #log the viewing |
|
33 | 32 | user = User.find(session[:user_id]) |
|
34 | 33 | SubmissionViewLog.create(user_id: session[:user_id],submission_id: @submission.id) unless user.admin? |
@@ -37,12 +36,10 | |||
|
37 | 36 | end |
|
38 | 37 | |
|
39 | 38 | def download |
|
40 | - @submission = Submission.find(params[:id]) | |
|
41 | 39 | send_data(@submission.source, {:filename => @submission.download_filename, :type => 'text/plain'}) |
|
42 | 40 | end |
|
43 | 41 | |
|
44 | 42 | def compiler_msg |
|
45 | - @submission = Submission.find(params[:id]) | |
|
46 | 43 | respond_to do |format| |
|
47 | 44 | format.js |
|
48 | 45 | end |
@@ -65,7 +62,6 | |||
|
65 | 62 | |
|
66 | 63 | # GET /submissions/1/edit |
|
67 | 64 | def edit |
|
68 | - @submission = Submission.find(params[:id]) | |
|
69 | 65 | @source = @submission.source.to_s |
|
70 | 66 | @problem = @submission.problem |
|
71 | 67 | @lang_id = @submission.language.id |
@@ -82,7 +78,6 | |||
|
82 | 78 | |
|
83 | 79 | # GET /submissions/:id/rejudge |
|
84 | 80 | def rejudge |
|
85 | - @submission = Submission.find(params[:id]) | |
|
86 | 81 | @task = @submission.task |
|
87 | 82 | @task.status_inqueue! if @task |
|
88 | 83 | respond_to do |format| |
@@ -90,6 +85,11 | |||
|
90 | 85 | end |
|
91 | 86 | end |
|
92 | 87 | |
|
88 | + def set_tag | |
|
89 | + @submission.update(tag: params[:tag]) | |
|
90 | + redirect_to @submission | |
|
91 | + end | |
|
92 | + | |
|
93 | 93 | protected |
|
94 | 94 | |
|
95 | 95 | def submission_authorization |
@@ -106,6 +106,10 | |||
|
106 | 106 | unauthorized_redirect |
|
107 | 107 | return false |
|
108 | 108 | end |
|
109 | + | |
|
110 | + def set_submission | |
|
111 | + @submission = Submission.find(params[:id]) | |
|
112 | + end | |
|
109 | 113 | |
|
110 | 114 | |
|
111 | 115 | end |
@@ -24,6 +24,28 | |||
|
24 | 24 | DEFAULT_TIME_LIMIT = 1 |
|
25 | 25 | DEFAULT_MEMORY_LIMIT = 32 |
|
26 | 26 | |
|
27 | + def get_jschart_history | |
|
28 | + start = 4.month.ago.beginning_of_day | |
|
29 | + start_date = start.to_date | |
|
30 | + count = Submission.where(problem: self).where('submitted_at >= ?', start).group('DATE(submitted_at)').count | |
|
31 | + i = 0 | |
|
32 | + label = [] | |
|
33 | + value = [] | |
|
34 | + while (start_date + i < Time.zone.now.to_date) | |
|
35 | + if (start_date+i).day == 1 | |
|
36 | + #label << (start_date+i).strftime("%d %b %Y") | |
|
37 | + #label << (start_date+i).strftime("%d") | |
|
38 | + else | |
|
39 | + #label << ' ' | |
|
40 | + #label << (start_date+i).strftime("%d") | |
|
41 | + end | |
|
42 | + label << (start_date+i).strftime("%d-%b") | |
|
43 | + value << (count[start_date+i] || 0) | |
|
44 | + i+=1 | |
|
45 | + end | |
|
46 | + return {labels: label,datasets: [label:'sub',data: value, backgroundColor: 'rgba(54, 162, 235, 0.2)', borderColor: 'rgb(75, 192, 192)']} | |
|
47 | + end | |
|
48 | + | |
|
27 | 49 | def self.available_problems |
|
28 | 50 | available.order(date_added: :desc).order(:name) |
|
29 | 51 | #Problem.available.all(:order => "date_added DESC, name ASC") |
@@ -1,5 +1,7 | |||
|
1 | 1 | class Submission < ActiveRecord::Base |
|
2 | 2 | |
|
3 | + enum tag: {default: 0, model: 1}, _prefix: true | |
|
4 | + | |
|
3 | 5 | belongs_to :language |
|
4 | 6 | belongs_to :problem |
|
5 | 7 | belongs_to :user |
@@ -24,12 +26,12 | |||
|
24 | 26 | def self.find_all_last_by_problem(problem_id) |
|
25 | 27 | # need to put in SQL command, maybe there's a better way |
|
26 | 28 | Submission.includes(:user).find_by_sql("SELECT * FROM submissions " + |
|
27 |
- |
|
|
28 |
- |
|
|
29 |
- |
|
|
30 |
- |
|
|
31 |
- |
|
|
32 |
- |
|
|
29 | + "WHERE id = " + | |
|
30 | + "(SELECT MAX(id) FROM submissions AS subs " + | |
|
31 | + "WHERE subs.user_id = submissions.user_id AND " + | |
|
32 | + "problem_id = " + problem_id.to_s + " " + | |
|
33 | + "GROUP BY user_id) " + | |
|
34 | + "ORDER BY user_id") | |
|
33 | 35 | end |
|
34 | 36 | |
|
35 | 37 | def self.find_in_range_by_user_and_problem(user_id, problem_id,since_id,until_id) |
@@ -75,12 +77,12 | |||
|
75 | 77 | i = 0 |
|
76 | 78 | source.each_line do |s| |
|
77 | 79 | if s =~ option |
|
78 |
- |
|
|
79 |
- |
|
|
80 | + words = s.split | |
|
81 | + return words[1] | |
|
80 | 82 | end |
|
81 | 83 | i = i + 1 |
|
82 | 84 | if i==10 |
|
83 |
- |
|
|
85 | + return nil | |
|
84 | 86 | end |
|
85 | 87 | end |
|
86 | 88 | return nil |
@@ -24,113 +24,131 | |||
|
24 | 24 | } |
|
25 | 25 | |
|
26 | 26 | |
|
27 | - .container | |
|
27 | + .container-fluid | |
|
28 | + .row | |
|
29 | + .col-md-8 | |
|
30 | + .card | |
|
31 | + .card-body | |
|
32 | + %h2.card-title Submission History | |
|
33 | + %canvas#chart{height: '50px'} | |
|
34 | + | |
|
35 | + .col-md-4 | |
|
36 | + .card | |
|
37 | + .card-body | |
|
38 | + %h2.card-title General Info | |
|
39 | + .row | |
|
40 | + .col-sm-6 | |
|
41 | + Subs | |
|
42 | + .col-sm-6 | |
|
43 | + = @summary[:count] | |
|
44 | + .row | |
|
45 | + .col-sm-6 | |
|
46 | + Solved/Attempted User | |
|
47 | + .col-sm-6 | |
|
48 | + #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%) | |
|
28 | 49 | .row |
|
29 | 50 | .col-md-4 |
|
30 | - %h2 Overall Stat | |
|
31 | - %table.table.table-hover | |
|
32 | - %thead | |
|
33 | - %tr | |
|
34 | - %th | |
|
35 | - %th | |
|
36 | - %tbody | |
|
37 | - %tr | |
|
38 | - %td.info_param Submissions | |
|
39 | - %td= @summary[:count] | |
|
40 | - %tr | |
|
41 | - %td.info_param Solved/Attempted User | |
|
42 | - %td #{@summary[:solve]}/#{@summary[:attempt]} (#{(@summary[:solve]*100.0/@summary[:attempt]).round(1)}%) | |
|
43 | - - if @best | |
|
44 | - %tr | |
|
45 | - %td.info_param Best Runtime | |
|
46 | - %td | |
|
47 | - by #{link_to @best[:runtime][:user], stat_user_path(@best[:runtime][:user_id])} | |
|
48 | - %br | |
|
49 | - using <span class="text-success">#{@best[:runtime][:lang]}</span> | |
|
50 | - %br | |
|
51 | - with <span class="text-success">#{@best[:runtime][:value] * 1000} milliseconds</span> | |
|
52 | - %br | |
|
53 | - at submission | |
|
54 | - = link_to "#" + @best[:runtime][:sub_id].to_s, submission_path(@best[:runtime][:sub_id]) | |
|
55 | - | |
|
56 | - %tr | |
|
57 | - %td.info_param | |
|
58 | - Best Memory Usage | |
|
59 | - %sup{ id: "xmem_remark", | |
|
60 | - style: "position:relative; color: blue;", | |
|
61 | - data: {toggle: 'tooltip', placement: 'top', animation: 'false', delay: 20}, | |
|
62 | - title: "This counts only for submission with 100% score. Right now, java is excluded from memory usage competition. (Because it always uses 2GB memory...)"} | |
|
63 | - [?] | |
|
64 | - %td | |
|
65 | - by #{link_to @best[:memory][:user], stat_user_path(@best[:memory][:user_id])} | |
|
66 | - %br | |
|
67 | - using <span class="text-success">#{@best[:memory][:lang]}</span> | |
|
68 | - %br | |
|
69 | - with <span class="text-success">#{number_with_delimiter(@best[:memory][:value])} kbytes </span> | |
|
70 | - %br | |
|
71 | - at submission | |
|
72 | - = link_to "#" + @best[:memory][:sub_id].to_s, submission_path(@best[:memory][:sub_id]) | |
|
73 | - | |
|
74 | - %tr | |
|
75 | - %td.info_param Shortest Code | |
|
76 | - %td | |
|
77 | - by #{link_to @best[:length][:user], stat_user_path(@best[:length][:user_id])} | |
|
78 | - %br | |
|
79 | - using <span class="text-success">#{@best[:length][:lang]}</span> | |
|
80 | - %br | |
|
81 | - with <span class="text-success">#{@best[:length][:value]} bytes</span> | |
|
82 | - %br | |
|
83 | - at submission | |
|
84 | - = link_to "#" + @best[:length][:sub_id].to_s, submission_path(@best[:length][:sub_id]) | |
|
85 | - | |
|
86 | - %tr | |
|
87 | - %td.info_param First solver | |
|
88 | - %td | |
|
89 | - - if @best[:first][:user] != '(NULL)' | |
|
90 | - #{link_to @best[:first][:user], stat_user_path(@best[:first][:user_id])} is the first solver | |
|
91 | - %br | |
|
92 | - using <span class="text-success">#{@best[:first][:lang]}</span> | |
|
93 | - %br | |
|
94 | - on <span class="text-success">#{@best[:first][:value]}</span> | |
|
95 | - %br | |
|
96 | - at submission | |
|
97 | - = link_to "#" + @best[:first][:sub_id].to_s, submission_path( @best[:first][:sub_id]) | |
|
98 | - - else | |
|
99 | - no first solver | |
|
100 | - .col-md-8 | |
|
101 | - - if @best | |
|
102 | - %h2 By Language | |
|
51 | + .card | |
|
52 | + .card-body | |
|
53 | + %h2.card-title Model submission | |
|
103 | 54 | %table.table.table-hover |
|
104 | 55 | %thead |
|
105 | 56 | %tr |
|
106 |
- %th |
|
|
107 |
- %th |
|
|
108 | - %th Best memory (kbytes) | |
|
109 | - %th Shortest Code (bytes) | |
|
110 | - %th First solver | |
|
57 | + %th #Sub | |
|
58 | + %th Author | |
|
111 | 59 | %tbody |
|
112 |
- - @ |
|
|
60 | + - @model_subs.each do |sub| | |
|
113 | 61 | %tr |
|
114 | - %td= lang | |
|
62 | + %td= link_to "##{sub.id}", submission_path(sub) | |
|
63 | + %td= sub.user.full_name | |
|
64 | + .col-md-8 | |
|
65 | + - if @best | |
|
66 | + .card | |
|
67 | + .card-body | |
|
68 | + %h2.card-title Top Submissions | |
|
69 | + %table.table.table-hover | |
|
70 | + %thead | |
|
71 | + %tr | |
|
72 | + %th Language | |
|
73 | + %th Best runtime (ms) | |
|
74 | + %th Best memory (kbytes) | |
|
75 | + %th Shortest Code (bytes) | |
|
76 | + %th First solver | |
|
77 | + %tbody | |
|
78 | + %tr.bg-warning | |
|
115 | 79 | %td |
|
116 | - = link_to value[:runtime][:user], stat_user_path(value[:runtime][:user_id]) | |
|
80 | + Overall | |
|
81 | + %td | |
|
82 | + by #{link_to @best[:runtime][:user], stat_user_path(@best[:runtime][:user_id])} | |
|
83 | + %br | |
|
84 | + using <span class="text-success">#{@best[:runtime][:lang]}</span> | |
|
85 | + %br | |
|
86 | + with <span class="text-success">#{@best[:runtime][:value] * 1000} milliseconds</span> | |
|
87 | + %br= link_to "#" + @best[:runtime][:sub_id].to_s, submission_path(@best[:runtime][:sub_id]) | |
|
88 | + %td | |
|
89 | + by #{link_to @best[:memory][:user], stat_user_path(@best[:memory][:user_id])} | |
|
117 | 90 | %br |
|
118 | - = "#{(value[:runtime][:value] * 1000).to_i} @" | |
|
119 | - = link_to "#" + value[:runtime][:sub_id].to_s, submission_path( value[:runtime][:sub_id]) | |
|
91 | + using <span class="text-success">#{@best[:memory][:lang]}</span> | |
|
92 | + %br | |
|
93 | + with <span class="text-success">#{number_with_delimiter(@best[:memory][:value])} kbytes </span> | |
|
94 | + %br= link_to "#" + @best[:memory][:sub_id].to_s, submission_path(@best[:memory][:sub_id]) | |
|
95 | + %td | |
|
96 | + by #{link_to @best[:length][:user], stat_user_path(@best[:length][:user_id])} | |
|
97 | + %br | |
|
98 | + using <span class="text-success">#{@best[:length][:lang]}</span> | |
|
99 | + %br | |
|
100 | + with <span class="text-success">#{@best[:length][:value]} bytes</span> | |
|
101 | + %br= link_to "#" + @best[:length][:sub_id].to_s, submission_path(@best[:length][:sub_id]) | |
|
120 | 102 | %td |
|
121 | - = link_to value[:memory][:user], stat_user_path( value[:memory][:user_id]) | |
|
122 | - %br | |
|
123 | - = "#{number_with_delimiter(value[:memory][:value])} @" | |
|
124 | - = link_to "#" + value[:memory][:sub_id].to_s, submission_path(value[:memory][:sub_id]) | |
|
125 |
- |
|
|
126 | - = link_to value[:length][:user], stat_user_path(value[:length][:user_id]) | |
|
127 | - %br | |
|
128 | - = "#{value[:length][:value]} @" | |
|
129 | - = link_to "#" + value[:length][:sub_id].to_s, submission_path(value[:length][:sub_id]) | |
|
130 | - %td | |
|
131 | - - if value[:first][:user] != '(NULL)' #TODO: i know... this is wrong... | |
|
132 | - = link_to value[:first][:user], stat_user_path(value[:first][:user_id]) | |
|
103 | + - if @best[:first][:user] != '(NULL)' | |
|
104 | + #{link_to @best[:first][:user], stat_user_path(@best[:first][:user_id])} is the first solver | |
|
105 | + %br | |
|
106 | + using <span class="text-success">#{@best[:first][:lang]}</span> | |
|
107 | + %br | |
|
108 | + on <span class="text-success">#{@best[:first][:value]}</span> | |
|
109 | + %br= link_to "#" + @best[:first][:sub_id].to_s, submission_path( @best[:first][:sub_id]) | |
|
110 | + - else | |
|
111 | + no first solver | |
|
112 | + - @by_lang.each do |lang,value| | |
|
113 | + %tr | |
|
114 | + %td= lang | |
|
115 | + %td | |
|
116 | + = link_to value[:runtime][:user], stat_user_path(value[:runtime][:user_id]) | |
|
117 | + %br | |
|
118 | + = "#{(value[:runtime][:value] * 1000).to_i} @" | |
|
119 | + = link_to "#" + value[:runtime][:sub_id].to_s, submission_path( value[:runtime][:sub_id]) | |
|
120 | + %td | |
|
121 | + = link_to value[:memory][:user], stat_user_path( value[:memory][:user_id]) | |
|
122 | + %br | |
|
123 | + = "#{number_with_delimiter(value[:memory][:value])} @" | |
|
124 | + = link_to "#" + value[:memory][:sub_id].to_s, submission_path(value[:memory][:sub_id]) | |
|
125 | + %td | |
|
126 | + = link_to value[:length][:user], stat_user_path(value[:length][:user_id]) | |
|
133 | 127 | %br |
|
134 |
- = "#{value[: |
|
|
135 |
- = link_to "#" + value[: |
|
|
128 | + = "#{value[:length][:value]} @" | |
|
129 | + = link_to "#" + value[:length][:sub_id].to_s, submission_path(value[:length][:sub_id]) | |
|
130 | + %td | |
|
131 | + - if value[:first][:user] != '(NULL)' #TODO: i know... this is wrong... | |
|
132 | + = link_to value[:first][:user], stat_user_path(value[:first][:user_id]) | |
|
133 | + %br | |
|
134 | + = "#{value[:first][:value]} @" | |
|
135 | + = link_to "#" + value[:first][:sub_id].to_s, submission_path( value[:first][:sub_id]) | |
|
136 | 136 | |
|
137 | + %script{src:"https://cdn.jsdelivr.net/npm/chart.js"} | |
|
138 | + :javascript | |
|
139 | + data = #{@chart_dataset} | |
|
140 | + config = { | |
|
141 | + type: 'bar', | |
|
142 | + data: data, | |
|
143 | + options: { | |
|
144 | + plugins: { | |
|
145 | + legend: { | |
|
146 | + display: false | |
|
147 | + }, | |
|
148 | + }, | |
|
149 | + } | |
|
150 | + } | |
|
151 | + Chart.defaults.font.size = 15 | |
|
152 | + //Chart.defaults.font.family = 'Sarabun Light' | |
|
153 | + chart = new Chart($('#chart'),config) | |
|
154 | + |
@@ -23,7 +23,7 | |||
|
23 | 23 | Please select a problem. |
|
24 | 24 | - else |
|
25 | 25 | %h1 [#{Problem.find(params[:id]).name}] #{Problem.find(params[:id]).full_name} |
|
26 | - %h2 Submission History | |
|
27 | - =render partial: 'application/bar_graph', locals: { histogram: @histogram } | |
|
26 | + -# %h2 Submission History | |
|
27 | + -# =render partial: 'application/bar_graph', locals: { histogram: @histogram } | |
|
28 | 28 | =render partial: 'task_hof' |
|
29 | 29 |
@@ -89,11 +89,6 | |||
|
89 | 89 | %td |
|
90 | 90 | %button.btn.btn-info.btn-xs{type: 'button', data: {toggle: 'modal', target: '#compiler'}} |
|
91 | 91 | view |
|
92 | - - if session[:admin] | |
|
93 | - %tr | |
|
94 | - %td.text-right | |
|
95 | - %strong IP | |
|
96 | - %td #{@submission.ip_address} | |
|
97 | 92 | %tr |
|
98 | 93 | %td.text-right |
|
99 | 94 | %strong Grading Task Status |
@@ -101,6 +96,23 | |||
|
101 | 96 | = @task.status_str if @task |
|
102 | 97 | - if session[:admin] |
|
103 | 98 | = link_to "rejudge", rejudge_submission_path, data: {remote: true}, class: 'btn btn-info btn-xs' |
|
99 | + - if session[:admin] | |
|
100 | + %tr | |
|
101 | + %td.text-right | |
|
102 | + %strong IP | |
|
103 | + %td #{@submission.ip_address} | |
|
104 | + %tr | |
|
105 | + %td.text-right | |
|
106 | + %strong Model solution | |
|
107 | + %td | |
|
108 | + - if @submission.tag_model? | |
|
109 | + YES | |
|
110 | + - if session[:admin] | |
|
111 | + = link_to "remove model status", set_tag_submission_path(@submission, tag: :default), class: 'btn btn-warning btn-xs' | |
|
112 | + - else | |
|
113 | + No | |
|
114 | + - if session[:admin] | |
|
115 | + = link_to "set as model solution", set_tag_submission_path(@submission, tag: :model), class: 'btn btn-success btn-xs' | |
|
104 | 116 | |
|
105 | 117 | |
|
106 | 118 | .modal.fade#compiler{tabindex: -1,role: 'dialog'} |
@@ -94,6 +94,7 | |||
|
94 | 94 | get 'download' |
|
95 | 95 | get 'compiler_msg' |
|
96 | 96 | get 'rejudge' |
|
97 | + get 'set_tag' | |
|
97 | 98 | end |
|
98 | 99 | collection do |
|
99 | 100 | get 'prob/:problem_id', to: 'submissions#index', as: 'problem' |
@@ -2,19 +2,19 | |||
|
2 | 2 | # of editing this file, please use the migrations feature of Active Record to |
|
3 | 3 | # incrementally modify your database, and then regenerate this schema definition. |
|
4 | 4 | # |
|
5 | - # Note that this schema.rb definition is the authoritative source for your | |
|
6 | - # database schema. If you need to create the application database on another | |
|
7 | - # system, you should be using db:schema:load, not running all the migrations | |
|
8 | - # from scratch. The latter is a flawed and unsustainable approach (the more migrations | |
|
9 | - # you'll amass, the slower it'll run and the greater likelihood for issues). | |
|
5 | + # This file is the source Rails uses to define your schema when running `bin/rails | |
|
6 | + # db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to | |
|
7 | + # be faster and is potentially less error prone than running all of your | |
|
8 | + # migrations from scratch. Old migrations may fail to apply correctly if those | |
|
9 | + # migrations use external dependencies or application code. | |
|
10 | 10 | # |
|
11 | 11 | # It's strongly recommended that you check this file into your version control system. |
|
12 | 12 | |
|
13 |
- ActiveRecord::Schema.define(version: 202 |
|
|
13 | + ActiveRecord::Schema.define(version: 2022_02_04_080936) do | |
|
14 | 14 | |
|
15 |
- create_table "announcements", id: :integer, |
|
|
15 | + create_table "announcements", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
16 | 16 | t.string "author" |
|
17 |
- t.text "body" |
|
|
17 | + t.text "body" | |
|
18 | 18 | t.boolean "published" |
|
19 | 19 | t.datetime "created_at", null: false |
|
20 | 20 | t.datetime "updated_at", null: false |
@@ -25,7 +25,7 | |||
|
25 | 25 | t.boolean "on_nav_bar", default: false |
|
26 | 26 | end |
|
27 | 27 | |
|
28 |
- create_table "contests", id: :integer, |
|
|
28 | + create_table "contests", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
29 | 29 | t.string "title" |
|
30 | 30 | t.boolean "enabled" |
|
31 | 31 | t.datetime "created_at", null: false |
@@ -33,39 +33,39 | |||
|
33 | 33 | t.string "name" |
|
34 | 34 | end |
|
35 | 35 | |
|
36 |
- create_table "contests_problems", id: false, |
|
|
36 | + create_table "contests_problems", id: false, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
37 | 37 | t.integer "contest_id" |
|
38 | 38 | t.integer "problem_id" |
|
39 | 39 | end |
|
40 | 40 | |
|
41 |
- create_table "contests_users", id: false, |
|
|
41 | + create_table "contests_users", id: false, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
42 | 42 | t.integer "contest_id" |
|
43 | 43 | t.integer "user_id" |
|
44 | 44 | end |
|
45 | 45 | |
|
46 |
- create_table "countries", id: :integer, |
|
|
46 | + create_table "countries", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
47 | 47 | t.string "name" |
|
48 | 48 | t.datetime "created_at", null: false |
|
49 | 49 | t.datetime "updated_at", null: false |
|
50 | 50 | end |
|
51 | 51 | |
|
52 |
- create_table "descriptions", id: :integer, |
|
|
53 |
- t.text "body" |
|
|
52 | + create_table "descriptions", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
53 | + t.text "body" | |
|
54 | 54 | t.boolean "markdowned" |
|
55 | 55 | t.datetime "created_at", null: false |
|
56 | 56 | t.datetime "updated_at", null: false |
|
57 | 57 | end |
|
58 | 58 | |
|
59 |
- create_table "grader_configurations", id: :integer, |
|
|
59 | + create_table "grader_configurations", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
60 | 60 | t.string "key" |
|
61 | 61 | t.string "value_type" |
|
62 | 62 | t.string "value" |
|
63 | 63 | t.datetime "created_at", null: false |
|
64 | 64 | t.datetime "updated_at", null: false |
|
65 |
- t.text "description" |
|
|
65 | + t.text "description" | |
|
66 | 66 | end |
|
67 | 67 | |
|
68 |
- create_table "grader_processes", id: :integer, |
|
|
68 | + create_table "grader_processes", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
69 | 69 | t.string "host" |
|
70 | 70 | t.integer "pid" |
|
71 | 71 | t.string "mode" |
@@ -78,25 +78,25 | |||
|
78 | 78 | t.index ["host", "pid"], name: "index_grader_processes_on_ip_and_pid" |
|
79 | 79 | end |
|
80 | 80 | |
|
81 |
- create_table "groups", id: :integer, |
|
|
81 | + create_table "groups", id: :integer, charset: "latin1", force: :cascade do |t| | |
|
82 | 82 | t.string "name" |
|
83 | 83 | t.string "description" |
|
84 | 84 | t.boolean "enabled", default: true |
|
85 | 85 | end |
|
86 | 86 | |
|
87 |
- create_table "groups_problems", id: false, |
|
|
87 | + create_table "groups_problems", id: false, charset: "latin1", force: :cascade do |t| | |
|
88 | 88 | t.integer "problem_id", null: false |
|
89 | 89 | t.integer "group_id", null: false |
|
90 | 90 | t.index ["group_id", "problem_id"], name: "index_groups_problems_on_group_id_and_problem_id" |
|
91 | 91 | end |
|
92 | 92 | |
|
93 |
- create_table "groups_users", |
|
|
93 | + create_table "groups_users", charset: "latin1", force: :cascade do |t| | |
|
94 | 94 | t.integer "group_id", null: false |
|
95 | 95 | t.integer "user_id", null: false |
|
96 | 96 | t.index ["user_id", "group_id"], name: "index_groups_users_on_user_id_and_group_id" |
|
97 | 97 | end |
|
98 | 98 | |
|
99 |
- create_table "heart_beats", id: :integer, |
|
|
99 | + create_table "heart_beats", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
100 | 100 | t.integer "user_id" |
|
101 | 101 | t.string "ip_address" |
|
102 | 102 | t.datetime "created_at", null: false |
@@ -105,14 +105,14 | |||
|
105 | 105 | t.index ["updated_at"], name: "index_heart_beats_on_updated_at" |
|
106 | 106 | end |
|
107 | 107 | |
|
108 |
- create_table "languages", id: :integer, |
|
|
108 | + create_table "languages", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
109 | 109 | t.string "name", limit: 10 |
|
110 | 110 | t.string "pretty_name" |
|
111 | 111 | t.string "ext", limit: 10 |
|
112 | 112 | t.string "common_ext" |
|
113 | 113 | end |
|
114 | 114 | |
|
115 |
- create_table "logins", id: :integer, |
|
|
115 | + create_table "logins", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
116 | 116 | t.integer "user_id" |
|
117 | 117 | t.string "ip_address" |
|
118 | 118 | t.datetime "created_at", null: false |
@@ -120,18 +120,18 | |||
|
120 | 120 | t.index ["user_id"], name: "index_logins_on_user_id" |
|
121 | 121 | end |
|
122 | 122 | |
|
123 |
- create_table "messages", id: :integer, |
|
|
123 | + create_table "messages", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
124 | 124 | t.integer "sender_id" |
|
125 | 125 | t.integer "receiver_id" |
|
126 | 126 | t.integer "replying_message_id" |
|
127 |
- t.text "body" |
|
|
127 | + t.text "body" | |
|
128 | 128 | t.boolean "replied" |
|
129 | 129 | t.datetime "created_at", null: false |
|
130 | 130 | t.datetime "updated_at", null: false |
|
131 | 131 | end |
|
132 | 132 | |
|
133 |
- create_table "problems", id: :integer, |
|
|
134 |
- t.string "name", limit: |
|
|
133 | + create_table "problems", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
134 | + t.string "name", limit: 30 | |
|
135 | 135 | t.string "full_name" |
|
136 | 136 | t.integer "full_score" |
|
137 | 137 | t.date "date_added" |
@@ -142,9 +142,10 | |||
|
142 | 142 | t.boolean "output_only" |
|
143 | 143 | t.string "description_filename" |
|
144 | 144 | t.boolean "view_testcase" |
|
145 | + t.integer "difficulty" | |
|
145 | 146 | end |
|
146 | 147 | |
|
147 |
- create_table "problems_tags", id: :integer, |
|
|
148 | + create_table "problems_tags", id: :integer, charset: "latin1", force: :cascade do |t| | |
|
148 | 149 | t.integer "problem_id" |
|
149 | 150 | t.integer "tag_id" |
|
150 | 151 | t.index ["problem_id", "tag_id"], name: "index_problems_tags_on_problem_id_and_tag_id", unique: true |
@@ -152,37 +153,37 | |||
|
152 | 153 | t.index ["tag_id"], name: "index_problems_tags_on_tag_id" |
|
153 | 154 | end |
|
154 | 155 | |
|
155 |
- create_table "rights", id: :integer, |
|
|
156 | + create_table "rights", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
156 | 157 | t.string "name" |
|
157 | 158 | t.string "controller" |
|
158 | 159 | t.string "action" |
|
159 | 160 | end |
|
160 | 161 | |
|
161 |
- create_table "rights_roles", id: false, |
|
|
162 | + create_table "rights_roles", id: false, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
162 | 163 | t.integer "right_id" |
|
163 | 164 | t.integer "role_id" |
|
164 | 165 | t.index ["role_id"], name: "index_rights_roles_on_role_id" |
|
165 | 166 | end |
|
166 | 167 | |
|
167 |
- create_table "roles", id: :integer, |
|
|
168 | + create_table "roles", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
168 | 169 | t.string "name" |
|
169 | 170 | end |
|
170 | 171 | |
|
171 |
- create_table "roles_users", id: false, |
|
|
172 | + create_table "roles_users", id: false, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
172 | 173 | t.integer "role_id" |
|
173 | 174 | t.integer "user_id" |
|
174 | 175 | t.index ["user_id"], name: "index_roles_users_on_user_id" |
|
175 | 176 | end |
|
176 | 177 | |
|
177 |
- create_table "sessions", id: :integer, |
|
|
178 | + create_table "sessions", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
178 | 179 | t.string "session_id" |
|
179 |
- t.text "data" |
|
|
180 | + t.text "data" | |
|
180 | 181 | t.datetime "updated_at" |
|
181 | 182 | t.index ["session_id"], name: "index_sessions_on_session_id" |
|
182 | 183 | t.index ["updated_at"], name: "index_sessions_on_updated_at" |
|
183 | 184 | end |
|
184 | 185 | |
|
185 |
- create_table "sites", id: :integer, |
|
|
186 | + create_table "sites", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
186 | 187 | t.string "name" |
|
187 | 188 | t.boolean "started" |
|
188 | 189 | t.datetime "start_time" |
@@ -192,37 +193,38 | |||
|
192 | 193 | t.string "password" |
|
193 | 194 | end |
|
194 | 195 | |
|
195 |
- create_table "submission_view_logs", id: :integer, |
|
|
196 | + create_table "submission_view_logs", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
196 | 197 | t.integer "user_id" |
|
197 | 198 | t.integer "submission_id" |
|
198 | 199 | t.datetime "created_at", null: false |
|
199 | 200 | t.datetime "updated_at", null: false |
|
200 | 201 | end |
|
201 | 202 | |
|
202 |
- create_table "submissions", id: :integer, |
|
|
203 | + create_table "submissions", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
203 | 204 | t.integer "user_id" |
|
204 | 205 | t.integer "problem_id" |
|
205 | 206 | t.integer "language_id" |
|
206 |
- t.text "source", |
|
|
207 | + t.text "source", size: :medium | |
|
207 | 208 | t.binary "binary" |
|
208 | 209 | t.datetime "submitted_at" |
|
209 | 210 | t.datetime "compiled_at" |
|
210 |
- t.text "compiler_message" |
|
|
211 | + t.text "compiler_message" | |
|
211 | 212 | t.datetime "graded_at" |
|
212 | 213 | t.integer "points" |
|
213 |
- t.text "grader_comment" |
|
|
214 | + t.text "grader_comment" | |
|
214 | 215 | t.integer "number" |
|
215 | 216 | t.string "source_filename" |
|
216 | 217 | t.float "max_runtime" |
|
217 | 218 | t.integer "peak_memory" |
|
218 | 219 | t.integer "effective_code_length" |
|
219 | 220 | t.string "ip_address" |
|
221 | + t.integer "tag", default: 0 | |
|
220 | 222 | t.index ["submitted_at"], name: "index_submissions_on_submitted_at" |
|
221 | 223 | t.index ["user_id", "problem_id", "number"], name: "index_submissions_on_user_id_and_problem_id_and_number", unique: true |
|
222 | 224 | t.index ["user_id", "problem_id"], name: "index_submissions_on_user_id_and_problem_id" |
|
223 | 225 | end |
|
224 | 226 | |
|
225 |
- create_table "tags", id: :integer, |
|
|
227 | + create_table "tags", id: :integer, charset: "latin1", force: :cascade do |t| | |
|
226 | 228 | t.string "name", null: false |
|
227 | 229 | t.text "description" |
|
228 | 230 | t.boolean "public" |
@@ -230,7 +232,7 | |||
|
230 | 232 | t.datetime "updated_at", null: false |
|
231 | 233 | end |
|
232 | 234 | |
|
233 |
- create_table "tasks", id: :integer, |
|
|
235 | + create_table "tasks", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
234 | 236 | t.integer "submission_id" |
|
235 | 237 | t.datetime "created_at" |
|
236 | 238 | t.integer "status" |
@@ -239,15 +241,15 | |||
|
239 | 241 | t.index ["submission_id"], name: "index_tasks_on_submission_id" |
|
240 | 242 | end |
|
241 | 243 | |
|
242 |
- create_table "test_pairs", id: :integer, |
|
|
244 | + create_table "test_pairs", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
243 | 245 | t.integer "problem_id" |
|
244 |
- t.text "input", |
|
|
245 |
- t.text "solution", |
|
|
246 | + t.text "input", size: :medium | |
|
247 | + t.text "solution", size: :medium | |
|
246 | 248 | t.datetime "created_at", null: false |
|
247 | 249 | t.datetime "updated_at", null: false |
|
248 | 250 | end |
|
249 | 251 | |
|
250 |
- create_table "test_requests", id: :integer, |
|
|
252 | + create_table "test_requests", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
251 | 253 | t.integer "user_id" |
|
252 | 254 | t.integer "problem_id" |
|
253 | 255 | t.integer "submission_id" |
@@ -258,7 +260,7 | |||
|
258 | 260 | t.datetime "updated_at", null: false |
|
259 | 261 | t.datetime "submitted_at" |
|
260 | 262 | t.datetime "compiled_at" |
|
261 |
- t.text "compiler_message" |
|
|
263 | + t.text "compiler_message" | |
|
262 | 264 | t.datetime "graded_at" |
|
263 | 265 | t.string "grader_comment" |
|
264 | 266 | t.datetime "created_at", null: false |
@@ -268,19 +270,19 | |||
|
268 | 270 | t.index ["user_id", "problem_id"], name: "index_test_requests_on_user_id_and_problem_id" |
|
269 | 271 | end |
|
270 | 272 | |
|
271 |
- create_table "testcases", id: :integer, |
|
|
273 | + create_table "testcases", id: :integer, charset: "latin1", force: :cascade do |t| | |
|
272 | 274 | t.integer "problem_id" |
|
273 | 275 | t.integer "num" |
|
274 | 276 | t.integer "group" |
|
275 | 277 | t.integer "score" |
|
276 |
- t.text "input", |
|
|
277 |
- t.text "sol", |
|
|
278 |
- t.datetime "created_at" |
|
|
279 |
- t.datetime "updated_at" |
|
|
278 | + t.text "input", size: :long | |
|
279 | + t.text "sol", size: :long | |
|
280 | + t.datetime "created_at" | |
|
281 | + t.datetime "updated_at" | |
|
280 | 282 | t.index ["problem_id"], name: "index_testcases_on_problem_id" |
|
281 | 283 | end |
|
282 | 284 | |
|
283 |
- create_table "user_contest_stats", id: :integer, |
|
|
285 | + create_table "user_contest_stats", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
284 | 286 | t.integer "user_id" |
|
285 | 287 | t.datetime "started_at" |
|
286 | 288 | t.datetime "created_at", null: false |
@@ -288,7 +290,7 | |||
|
288 | 290 | t.boolean "forced_logout" |
|
289 | 291 | end |
|
290 | 292 | |
|
291 |
- create_table "users", id: :integer, |
|
|
293 | + create_table "users", id: :integer, charset: "utf8", collation: "utf8_unicode_ci", force: :cascade do |t| | |
|
292 | 294 | t.string "login", limit: 50 |
|
293 | 295 | t.string "full_name" |
|
294 | 296 | t.string "hashed_password" |
@@ -300,10 +302,10 | |||
|
300 | 302 | t.boolean "activated", default: false |
|
301 | 303 | t.datetime "created_at" |
|
302 | 304 | t.datetime "updated_at" |
|
303 | - t.string "section" | |
|
304 | 305 | t.boolean "enabled", default: true |
|
305 | 306 | t.string "remark" |
|
306 | 307 | t.string "last_ip" |
|
308 | + t.string "section" | |
|
307 | 309 | t.integer "default_language" |
|
308 | 310 | t.index ["login"], name: "index_users_on_login", unique: true |
|
309 | 311 | end |
You need to be logged in to leave comments.
Login now