diff --git a/.gitignore b/.gitignore --- a/.gitignore +++ b/.gitignore @@ -29,7 +29,7 @@ *.swp #ignore rvm setting file -.ruby-gemset -.ruby-version +#.ruby-gemset +#.ruby-version /config/secrets.yml diff --git a/.ruby-gemset b/.ruby-gemset new file mode 100644 --- /dev/null +++ b/.ruby-gemset @@ -0,0 +1,1 @@ +grader diff --git a/.ruby-version b/.ruby-version new file mode 100644 --- /dev/null +++ b/.ruby-version @@ -0,0 +1,1 @@ +ruby-2.6.3 diff --git a/Gemfile b/Gemfile --- a/Gemfile +++ b/Gemfile @@ -60,7 +60,8 @@ gem 'rouge' #bootstrap add-ons -gem 'bootstrap-sass', '~> 3.2.0' +gem 'bootstrap-sass', '~> 3.4.1' +gem 'sassc-rails', '>= 2.1.0' gem 'bootstrap-switch-rails' gem 'bootstrap-toggle-rails' gem 'autoprefixer-rails' diff --git a/Gemfile.lock b/Gemfile.lock --- a/Gemfile.lock +++ b/Gemfile.lock @@ -11,94 +11,98 @@ specs: RubyInline (3.12.4) ZenTest (~> 4.3) - ZenTest (4.11.1) - ace-rails-ap (4.1.1) - actionmailer (4.2.7.1) - actionpack (= 4.2.7.1) - actionview (= 4.2.7.1) - activejob (= 4.2.7.1) + ZenTest (4.11.2) + ace-rails-ap (4.2) + actionmailer (4.2.11.1) + actionpack (= 4.2.11.1) + actionview (= 4.2.11.1) + activejob (= 4.2.11.1) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) - actionpack (4.2.7.1) - actionview (= 4.2.7.1) - activesupport (= 4.2.7.1) + actionpack (4.2.11.1) + actionview (= 4.2.11.1) + activesupport (= 4.2.11.1) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) - actionview (4.2.7.1) - activesupport (= 4.2.7.1) + actionview (4.2.11.1) + activesupport (= 4.2.11.1) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) - rails-html-sanitizer (~> 1.0, >= 1.0.2) - activejob (4.2.7.1) - activesupport (= 4.2.7.1) + rails-html-sanitizer (~> 1.0, >= 1.0.3) + activejob (4.2.11.1) + activesupport (= 4.2.11.1) globalid (>= 0.3.0) - activemodel (4.2.7.1) - activesupport (= 4.2.7.1) + activemodel (4.2.11.1) + activesupport (= 4.2.11.1) builder (~> 3.1) - activerecord (4.2.7.1) - activemodel (= 4.2.7.1) - activesupport (= 4.2.7.1) + activerecord (4.2.11.1) + activemodel (= 4.2.11.1) + activesupport (= 4.2.11.1) arel (~> 6.0) - activerecord-session_store (1.0.0) - actionpack (>= 4.0, < 5.1) - activerecord (>= 4.0, < 5.1) + activerecord-session_store (1.1.3) + actionpack (>= 4.0) + activerecord (>= 4.0) multi_json (~> 1.11, >= 1.11.2) rack (>= 1.5.2, < 3) - railties (>= 4.0, < 5.1) - activesupport (4.2.7.1) + railties (>= 4.0) + activesupport (4.2.11.1) i18n (~> 0.7) - json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) ansi (1.5.0) arel (6.0.4) - autoprefixer-rails (6.6.0) + autoprefixer-rails (9.5.1.1) execjs best_in_place (3.0.3) actionpack (>= 3.2) railties (>= 3.2) - bootstrap-datepicker-rails (1.7.1.1) + bootstrap-datepicker-rails (1.8.0.1) railties (>= 3.0) - bootstrap-sass (3.2.0.2) - sass (~> 3.2) - bootstrap-switch-rails (3.3.3) + bootstrap-sass (3.4.1) + autoprefixer-rails (>= 5.2.1) + sassc (>= 2.0.0) + bootstrap-switch-rails (3.3.4) bootstrap-toggle-rails (2.2.1.0) bootstrap3-datetimepicker-rails (4.17.47) momentjs-rails (>= 2.8.1) - builder (3.2.2) - coffee-rails (4.2.1) + builder (3.2.3) + coffee-rails (4.2.2) coffee-script (>= 2.2.0) - railties (>= 4.0.0, < 5.2.x) + railties (>= 4.0.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) - concurrent-ruby (1.0.4) + concurrent-ruby (1.1.5) + crass (1.0.4) dynamic_form (1.1.4) erubis (2.7.0) execjs (2.7.0) - fuzzy-string-match (1.0.0) + ffi (1.11.1) + fuzzy-string-match (1.0.1) RubyInline (>= 3.8.6) - globalid (0.3.7) - activesupport (>= 4.1.0) - haml (4.0.7) + globalid (0.4.2) + activesupport (>= 4.2.0) + haml (5.1.0) + temple (>= 0.8.0) tilt - haml-rails (0.9.0) + haml-rails (1.0.0) actionpack (>= 4.0.1) activesupport (>= 4.0.1) - haml (>= 4.0.6, < 5.0) + haml (>= 4.0.6, < 6.0) html2haml (>= 1.0.1) railties (>= 4.0.1) - html2haml (2.0.0) + html2haml (2.2.0) erubis (~> 2.7.0) - haml (~> 4.0.0) - nokogiri (~> 1.6.0) + haml (>= 4.0, < 6) + nokogiri (>= 1.6.0) ruby_parser (~> 3.5) - i18n (0.7.0) + i18n (0.9.5) + concurrent-ruby (~> 1.0) in_place_editing (1.2.0) jquery-countdown-rails (2.0.2) jquery-datatables-rails (3.4.0) @@ -106,100 +110,115 @@ jquery-rails railties (>= 3.1) sass-rails - jquery-rails (4.2.1) + jquery-rails (4.3.3) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) thor (>= 0.14, < 2.0) - jquery-tablesorter (1.23.3) + jquery-tablesorter (1.26.1) railties (>= 3.2, < 6) jquery-timepicker-addon-rails (1.4.1) railties (>= 3.1) jquery-ui-rails (6.0.1) railties (>= 3.2.16) - json (1.8.3) - loofah (2.0.3) + loofah (2.2.3) + crass (~> 1.0.2) nokogiri (>= 1.5.9) - mail (2.6.4) - mime-types (>= 1.16, < 4) - mime-types (3.1) - mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) - mini_portile2 (2.1.0) - minitest (5.10.1) - minitest-reporters (1.1.13) + mail (2.7.1) + mini_mime (>= 0.1.1) + mini_mime (1.0.1) + mini_portile2 (2.4.0) + minitest (5.11.3) + minitest-reporters (1.3.6) ansi builder minitest (>= 5.0) ruby-progressbar - momentjs-rails (2.15.1) + momentjs-rails (2.20.1) railties (>= 3.1) - multi_json (1.12.1) - mysql2 (0.4.5) - nokogiri (1.6.8.1) - mini_portile2 (~> 2.1.0) - rack (1.6.5) + multi_json (1.13.1) + mysql2 (0.5.2) + nokogiri (1.10.3) + mini_portile2 (~> 2.4.0) + rack (1.6.11) rack-test (0.6.3) rack (>= 1.0) - rails (4.2.7.1) - actionmailer (= 4.2.7.1) - actionpack (= 4.2.7.1) - actionview (= 4.2.7.1) - activejob (= 4.2.7.1) - activemodel (= 4.2.7.1) - activerecord (= 4.2.7.1) - activesupport (= 4.2.7.1) + rails (4.2.11.1) + actionmailer (= 4.2.11.1) + actionpack (= 4.2.11.1) + actionview (= 4.2.11.1) + activejob (= 4.2.11.1) + activemodel (= 4.2.11.1) + activerecord (= 4.2.11.1) + activesupport (= 4.2.11.1) bundler (>= 1.3.0, < 2.0) - railties (= 4.2.7.1) + railties (= 4.2.11.1) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) - rails-dom-testing (1.0.8) - activesupport (>= 4.2.0.beta, < 5.0) + rails-dom-testing (1.0.9) + activesupport (>= 4.2.0, < 5.0) nokogiri (~> 1.6) rails-deprecated_sanitizer (>= 1.0.1) - rails-html-sanitizer (1.0.3) - loofah (~> 2.0) - rails_bootstrap_sortable (2.0.1) + rails-html-sanitizer (1.0.4) + loofah (~> 2.2, >= 2.2.2) + rails_bootstrap_sortable (2.0.6) momentjs-rails (>= 2.8.3) - railties (4.2.7.1) - actionpack (= 4.2.7.1) - activesupport (= 4.2.7.1) + railties (4.2.11.1) + actionpack (= 4.2.11.1) + activesupport (= 4.2.11.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) - rake (12.0.0) + rake (12.3.2) + rb-fsevent (0.10.3) + rb-inotify (0.10.0) + ffi (~> 1.0) rdiscount (2.2.0.1) - rouge (2.0.7) - ruby-progressbar (1.8.1) - ruby_parser (3.8.3) - sexp_processor (~> 4.1) - sass (3.4.23) - sass-rails (5.0.6) + rouge (3.3.0) + ruby-progressbar (1.10.0) + ruby_parser (3.13.1) + sexp_processor (~> 4.9) + sass (3.7.4) + sass-listen (~> 4.0.0) + sass-listen (4.0.0) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + sass-rails (5.0.7) railties (>= 4.0.0, < 6) sass (~> 3.1) sprockets (>= 2.8, < 4.0) sprockets-rails (>= 2.0, < 4.0) tilt (>= 1.1, < 3) + sassc (2.0.1) + ffi (~> 1.9) + rake + sassc-rails (2.1.1) + railties (>= 4.0.0) + sassc (>= 2.0) + sprockets (> 3.0) + sprockets-rails + tilt select2-rails (4.0.3) thor (~> 0.14) - sexp_processor (4.7.0) - sprockets (3.7.1) + sexp_processor (4.12.0) + sprockets (3.7.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) - sprockets-rails (3.2.0) + sprockets-rails (3.2.1) actionpack (>= 4.0) activesupport (>= 4.0) sprockets (>= 3.0.0) - sqlite3 (1.3.12) - thor (0.19.4) - thread_safe (0.3.5) - tilt (2.0.5) - tzinfo (1.2.2) + sqlite3 (1.4.1) + temple (0.8.1) + thor (0.20.3) + thread_safe (0.3.6) + tilt (2.0.9) + tzinfo (1.2.5) thread_safe (~> 0.1) - uglifier (3.0.4) + uglifier (4.1.20) execjs (>= 0.3.0, < 3) will_paginate (3.0.12) - yaml_db (0.4.2) - rails (>= 3.0, < 5.1) + yaml_db (0.7.0) + rails (>= 3.0) rake (>= 0.8.7) PLATFORMS @@ -211,7 +230,7 @@ autoprefixer-rails best_in_place (~> 3.0.1) bootstrap-datepicker-rails - bootstrap-sass (~> 3.2.0) + bootstrap-sass (~> 3.4.1) bootstrap-switch-rails bootstrap-toggle-rails bootstrap3-datetimepicker-rails @@ -236,6 +255,7 @@ rdiscount rouge sass-rails + sassc-rails (>= 2.1.0) select2-rails sqlite3 uglifier @@ -244,4 +264,4 @@ yaml_db BUNDLED WITH - 1.15.4 + 1.17.2 diff --git a/README b/README deleted file mode 100644 --- a/README +++ /dev/null @@ -1,10 +0,0 @@ -== cafe grader - -cafe grader is a programming contest platform used in Thailand IOI training. -The package includes 2 repositories, jittat/cafe-grader-web and jittat/cafe-grader-judge-scripts. - -=== Installation - -The system is tested on ubuntu 14.04 LTS. Use the installation script in -cafe-grader-judge-scripts/installer/install.sh . See http://theory.cpe.ku.ac.th/wiki/index.php/%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%95%E0%B8%B4%E0%B8%94%E0%B8%95%E0%B8%B1%E0%B9%89%E0%B8%87_Cafe_grader for the detail. - diff --git a/README.rdoc b/README.rdoc --- a/README.rdoc +++ b/README.rdoc @@ -51,9 +51,7 @@ === 3. Install necessary package - cafe@grader:~$ sudo apt install libmysqlclient-dev default-jdk unzip nodejs php7.2-cli apache2 dirmngr gnupg apache2-dev - -curl build-essential + cafe@grader:~$ sudo apt install libmysqlclient-dev default-jdk unzip nodejs php-cli apache2 dirmngr gnupg apache2-dev === 4. Install cafe-grader diff --git a/app/controllers/problems_controller.rb b/app/controllers/problems_controller.rb --- a/app/controllers/problems_controller.rb +++ b/app/controllers/problems_controller.rb @@ -304,7 +304,7 @@ private def problem_params - params.require(:problem).permit(:name, :full_name, :full_score, :date_added, :available, :test_allowed,:output_only, :url, :description, tag_ids:[]) + params.require(:problem).permit(:name, :full_name, :full_score, :change_date_added, :date_added, :available, :test_allowed,:output_only, :url, :description, tag_ids:[]) end end diff --git a/app/models/problem.rb b/app/models/problem.rb --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -13,6 +13,8 @@ has_many :test_pairs, :dependent => :delete_all has_many :testcases, :dependent => :destroy + has_many :submissions + validates_presence_of :name validates_format_of :name, :with => /\A\w+\z/ validates_presence_of :full_name diff --git a/app/views/application/_submission_short.html.haml b/app/views/application/_submission_short.html.haml --- a/app/views/application/_submission_short.html.haml +++ b/app/views/application/_submission_short.html.haml @@ -22,7 +22,9 @@ %strong View: - if GraderConfiguration.show_grading_result = link_to '[detailed result]', :action => 'result', :id => submission.id - = link_to "#{t 'main.cmp_msg'}", {:action => 'compiler_msg', :id => submission.id}, {popup: true,class: 'btn btn-xs btn-info'} if submission.graded_at + - if submission.graded_at + %button.btn.btn-info.btn-xs{type: 'button', data: {toggle: 'modal', target: '#compiler'}} + =t 'main.cmp_msg' = link_to "#{t 'main.src_link'}", download_submission_path(submission.id), class: 'btn btn-xs btn-info' = link_to "#{t 'main.submissions_link'}", problem_submissions_path(problem_id), class: 'btn btn-xs btn-info' diff --git a/app/views/submissions/edit.html.haml b/app/views/submissions/edit.html.haml --- a/app/views/submissions/edit.html.haml +++ b/app/views/submissions/edit.html.haml @@ -51,6 +51,18 @@ %h2 Console %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20} +.modal.fade#compiler{tabindex: -1,role: 'dialog'} + .modal-dialog.modal-lg{role:'document'} + .modal-content + .modal-header + %button.close{type: 'button', data: {dismissed: :modal}, aria: {label: 'close'}} + %span{aria: {hidden: 'true'}, data: {dismiss: 'modal'}} × + %h4 Compiler message + .modal-body + %pre#compiler_msg= @submission.compiler_message + .modal-footer + %button.btn.btn-default{type: 'button', data: {dismiss: 'modal'}} Close + :javascript $(document).ready(function() { e = ace.edit("editor") diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -5,13 +5,13 @@ -#%p -#You can edit your alias and e-mails. Just click on the text and edit it. -%table.uinfo +%table.table.table-bordered{:style => "width:30%"} %tr - %th.uinfo Login - %td.uinfo= @user.login + %th Login + %td= @user.login %tr - %th.uinfo Full name - %td.uinfo= @user.full_name + %th Full name + %td= @user.full_name -#%tr -#%th.uinfo Alias -#%td.uinfo= in_place_editor_field :user, 'alias_for_editing', {}, :rows => 1 @@ -19,17 +19,18 @@ -#%th.uinfo E-mail -#%td.uinfo= in_place_editor_field :user, 'email_for_editing', {}, :rows => 1 %tr - %th.uinfo Password - %td.uinfo + %th Password + %td = form_tag :action => 'chg_passwd', :method => 'post' do %table %tr - %td= password_field_tag 'passwd' + %td + %input{:type => "password", :class => "form-control", :name => "passwd", :id => "passwd"} %td (new) %tr - %td= password_field_tag 'passwd_verify' + %td + %input{:type => "password", :class => "form-control", :name => "passwd_verify", :id => "passwd_verify"} %td (verify) %tr %td{:colspan => "2"} - = submit_tag 'change password' - + %input{:type => "button", :class => "btn btn-default", :name => "commit", :value => "Change Password"} diff --git a/db/schema.rb b/db/schema.rb --- a/db/schema.rb +++ b/db/schema.rb @@ -17,8 +17,8 @@ t.string "author", limit: 255 t.text "body", limit: 65535 t.boolean "published" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "frontpage", default: false t.boolean "contest_only", default: false t.string "title", limit: 255 @@ -28,8 +28,8 @@ create_table "contests", force: :cascade do |t| t.string "title", limit: 255 t.boolean "enabled" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "name", limit: 255 end @@ -45,23 +45,23 @@ create_table "countries", force: :cascade do |t| t.string "name", limit: 255 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "descriptions", force: :cascade do |t| t.text "body", limit: 65535 t.boolean "markdowned" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "grader_configurations", force: :cascade do |t| t.string "key", limit: 255 t.string "value_type", limit: 255 t.string "value", limit: 255 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.text "description", limit: 65535 end @@ -70,14 +70,14 @@ t.integer "pid", limit: 4 t.string "mode", limit: 255 t.boolean "active" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "task_id", limit: 4 t.string "task_type", limit: 255 t.boolean "terminated" end - add_index "grader_processes", ["host", "pid"], name: "index_grader_processes_on_ip_and_pid", using: :btree + add_index "grader_processes", ["host", "pid"], name: "index_grader_processes_on_host_and_pid", using: :btree create_table "groups", force: :cascade do |t| t.string "name", limit: 255 @@ -101,8 +101,8 @@ create_table "heart_beats", force: :cascade do |t| t.integer "user_id", limit: 4 t.string "ip_address", limit: 255 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.string "status", limit: 255 end @@ -118,8 +118,8 @@ create_table "logins", force: :cascade do |t| t.integer "user_id", limit: 4 t.string "ip_address", limit: 255 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "messages", force: :cascade do |t| @@ -128,8 +128,8 @@ t.integer "replying_message_id", limit: 4 t.text "body", limit: 65535 t.boolean "replied" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "problems", force: :cascade do |t| @@ -192,8 +192,8 @@ t.string "name", limit: 255 t.boolean "started" t.datetime "start_time" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.integer "country_id", limit: 4 t.string "password", limit: 255 end @@ -201,8 +201,8 @@ create_table "submission_view_logs", force: :cascade do |t| t.integer "user_id", limit: 4 t.integer "submission_id", limit: 4 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "submissions", force: :cascade do |t| @@ -249,8 +249,8 @@ t.integer "problem_id", limit: 4 t.text "input", limit: 16777215 t.text "solution", limit: 16777215 - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" end create_table "test_requests", force: :cascade do |t| @@ -261,13 +261,13 @@ t.string "output_file_name", limit: 255 t.string "running_stat", limit: 255 t.integer "status", limit: 4 - t.datetime "updated_at", null: false + t.datetime "updated_at" t.datetime "submitted_at" t.datetime "compiled_at" t.text "compiler_message", limit: 65535 t.datetime "graded_at" t.string "grader_comment", limit: 255 - t.datetime "created_at", null: false + t.datetime "created_at" t.float "running_time", limit: 24 t.string "exit_status", limit: 255 t.integer "memory_usage", limit: 4 @@ -291,8 +291,8 @@ create_table "user_contest_stats", force: :cascade do |t| t.integer "user_id", limit: 4 t.datetime "started_at" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at" + t.datetime "updated_at" t.boolean "forced_logout" end @@ -308,10 +308,10 @@ t.boolean "activated", default: false t.datetime "created_at" t.datetime "updated_at" + t.string "section", limit: 255 t.boolean "enabled", default: true t.string "remark", limit: 255 t.string "last_ip", limit: 255 - t.string "section", limit: 255 end add_index "users", ["login"], name: "index_users_on_login", unique: true, using: :btree