commit
0eb0868b7e
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 2
|
||||||
|
}
|
@ -1,426 +0,0 @@
|
|||||||
PATH
|
|
||||||
remote: lib/gitlab-cli
|
|
||||||
specs:
|
|
||||||
gitlab (3.2.0)
|
|
||||||
httparty
|
|
||||||
terminal-table
|
|
||||||
|
|
||||||
GEM
|
|
||||||
remote: https://gems.ruby-china.com/
|
|
||||||
specs:
|
|
||||||
aasm (5.0.5)
|
|
||||||
concurrent-ruby (~> 1.0)
|
|
||||||
actioncable (5.2.1)
|
|
||||||
actionpack (= 5.2.1)
|
|
||||||
nio4r (~> 2.0)
|
|
||||||
websocket-driver (>= 0.6.1)
|
|
||||||
actionmailer (5.2.1)
|
|
||||||
actionpack (= 5.2.1)
|
|
||||||
actionview (= 5.2.1)
|
|
||||||
activejob (= 5.2.1)
|
|
||||||
mail (~> 2.5, >= 2.5.4)
|
|
||||||
rails-dom-testing (~> 2.0)
|
|
||||||
actionpack (5.2.1)
|
|
||||||
actionview (= 5.2.1)
|
|
||||||
activesupport (= 5.2.1)
|
|
||||||
rack (~> 2.0)
|
|
||||||
rack-test (>= 0.6.3)
|
|
||||||
rails-dom-testing (~> 2.0)
|
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
|
||||||
actionview (5.2.1)
|
|
||||||
activesupport (= 5.2.1)
|
|
||||||
builder (~> 3.1)
|
|
||||||
erubi (~> 1.4)
|
|
||||||
rails-dom-testing (~> 2.0)
|
|
||||||
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
|
||||||
active_decorator (1.2.0)
|
|
||||||
activejob (5.2.1)
|
|
||||||
activesupport (= 5.2.1)
|
|
||||||
globalid (>= 0.3.6)
|
|
||||||
activemodel (5.2.1)
|
|
||||||
activesupport (= 5.2.1)
|
|
||||||
activerecord (5.2.1)
|
|
||||||
activemodel (= 5.2.1)
|
|
||||||
activesupport (= 5.2.1)
|
|
||||||
arel (>= 9.0)
|
|
||||||
activestorage (5.2.1)
|
|
||||||
actionpack (= 5.2.1)
|
|
||||||
activerecord (= 5.2.1)
|
|
||||||
marcel (~> 0.3.1)
|
|
||||||
activesupport (5.2.1)
|
|
||||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
||||||
i18n (>= 0.7, < 2)
|
|
||||||
minitest (~> 5.1)
|
|
||||||
tzinfo (~> 1.1)
|
|
||||||
acts-as-taggable-on (6.0.0)
|
|
||||||
activerecord (~> 5.0)
|
|
||||||
addressable (2.7.0)
|
|
||||||
public_suffix (>= 2.0.2, < 5.0)
|
|
||||||
archive-zip (0.11.0)
|
|
||||||
io-like (~> 0.3.0)
|
|
||||||
arel (9.0.0)
|
|
||||||
autoprefixer-rails (9.6.1)
|
|
||||||
execjs
|
|
||||||
awesome_print (1.8.0)
|
|
||||||
axlsx (3.0.0.pre)
|
|
||||||
htmlentities (~> 4.3, >= 4.3.4)
|
|
||||||
mimemagic (~> 0.3)
|
|
||||||
nokogiri (~> 1.8, >= 1.8.2)
|
|
||||||
rubyzip (~> 1.2, >= 1.2.1)
|
|
||||||
axlsx_rails (0.5.2)
|
|
||||||
actionpack (>= 3.1)
|
|
||||||
axlsx (>= 2.0.1)
|
|
||||||
bindex (0.5.0)
|
|
||||||
bootsnap (1.3.1)
|
|
||||||
msgpack (~> 1.0)
|
|
||||||
bootstrap (4.3.1)
|
|
||||||
autoprefixer-rails (>= 9.1.0)
|
|
||||||
popper_js (>= 1.14.3, < 2)
|
|
||||||
sassc-rails (>= 2.0.0)
|
|
||||||
builder (3.2.3)
|
|
||||||
bulk_insert (1.7.0)
|
|
||||||
activerecord (>= 3.2.0)
|
|
||||||
byebug (10.0.2)
|
|
||||||
capybara (3.5.1)
|
|
||||||
addressable
|
|
||||||
mini_mime (>= 0.1.3)
|
|
||||||
nokogiri (~> 1.8)
|
|
||||||
rack (>= 1.6.0)
|
|
||||||
rack-test (>= 0.6.3)
|
|
||||||
xpath (~> 3.1)
|
|
||||||
childprocess (0.9.0)
|
|
||||||
ffi (~> 1.0, >= 1.0.11)
|
|
||||||
chromedriver-helper (1.2.0)
|
|
||||||
archive-zip (~> 0.10)
|
|
||||||
nokogiri (~> 1.8)
|
|
||||||
chunky_png (1.3.10)
|
|
||||||
concurrent-ruby (1.0.5)
|
|
||||||
connection_pool (2.2.2)
|
|
||||||
crass (1.0.4)
|
|
||||||
diff-lcs (1.3)
|
|
||||||
diffy (3.3.0)
|
|
||||||
elasticsearch (7.2.0)
|
|
||||||
elasticsearch-api (= 7.2.0)
|
|
||||||
elasticsearch-transport (= 7.2.0)
|
|
||||||
elasticsearch-api (7.2.0)
|
|
||||||
multi_json
|
|
||||||
elasticsearch-transport (7.2.0)
|
|
||||||
faraday
|
|
||||||
multi_json
|
|
||||||
enumerize (2.3.1)
|
|
||||||
activesupport (>= 3.2)
|
|
||||||
erubi (1.7.1)
|
|
||||||
execjs (2.7.0)
|
|
||||||
faraday (0.15.4)
|
|
||||||
multipart-post (>= 1.2, < 3)
|
|
||||||
ffi (1.9.25)
|
|
||||||
font-awesome-sass (4.7.0)
|
|
||||||
sass (>= 3.2)
|
|
||||||
globalid (0.4.1)
|
|
||||||
activesupport (>= 4.2.0)
|
|
||||||
grape-entity (0.7.1)
|
|
||||||
activesupport (>= 4.0)
|
|
||||||
multi_json (>= 1.3.2)
|
|
||||||
hashie (3.5.7)
|
|
||||||
htmlentities (4.3.4)
|
|
||||||
httparty (0.16.2)
|
|
||||||
multi_xml (>= 0.5.2)
|
|
||||||
i18n (1.1.0)
|
|
||||||
concurrent-ruby (~> 1.0)
|
|
||||||
io-like (0.3.0)
|
|
||||||
jbuilder (2.7.0)
|
|
||||||
activesupport (>= 4.2.0)
|
|
||||||
multi_json (>= 1.2)
|
|
||||||
jquery-rails (4.3.5)
|
|
||||||
rails-dom-testing (>= 1, < 3)
|
|
||||||
railties (>= 4.2.0)
|
|
||||||
thor (>= 0.14, < 2.0)
|
|
||||||
jwt (2.1.0)
|
|
||||||
kaminari (1.1.1)
|
|
||||||
activesupport (>= 4.1.0)
|
|
||||||
kaminari-actionview (= 1.1.1)
|
|
||||||
kaminari-activerecord (= 1.1.1)
|
|
||||||
kaminari-core (= 1.1.1)
|
|
||||||
kaminari-actionview (1.1.1)
|
|
||||||
actionview
|
|
||||||
kaminari-core (= 1.1.1)
|
|
||||||
kaminari-activerecord (1.1.1)
|
|
||||||
activerecord
|
|
||||||
kaminari-core (= 1.1.1)
|
|
||||||
kaminari-core (1.1.1)
|
|
||||||
listen (3.1.5)
|
|
||||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
|
||||||
rb-inotify (~> 0.9, >= 0.9.7)
|
|
||||||
ruby_dep (~> 1.2)
|
|
||||||
loofah (2.2.2)
|
|
||||||
crass (~> 1.0.2)
|
|
||||||
nokogiri (>= 1.5.9)
|
|
||||||
mail (2.7.0)
|
|
||||||
mini_mime (>= 0.1.1)
|
|
||||||
marcel (0.3.2)
|
|
||||||
mimemagic (~> 0.3.2)
|
|
||||||
method_source (0.9.0)
|
|
||||||
mimemagic (0.3.2)
|
|
||||||
mini_mime (1.0.0)
|
|
||||||
mini_portile2 (2.3.0)
|
|
||||||
minitest (5.11.3)
|
|
||||||
msgpack (1.2.4)
|
|
||||||
multi_json (1.13.1)
|
|
||||||
multi_xml (0.6.0)
|
|
||||||
multipart-post (2.0.0)
|
|
||||||
mustermann (1.0.3)
|
|
||||||
mysql2 (0.5.2)
|
|
||||||
nio4r (2.3.1)
|
|
||||||
nokogiri (1.8.4)
|
|
||||||
mini_portile2 (~> 2.3.0)
|
|
||||||
oauth2 (1.4.1)
|
|
||||||
faraday (>= 0.8, < 0.16.0)
|
|
||||||
jwt (>= 1.0, < 3.0)
|
|
||||||
multi_json (~> 1.3)
|
|
||||||
multi_xml (~> 0.5)
|
|
||||||
rack (>= 1.2, < 3)
|
|
||||||
omniauth (1.9.0)
|
|
||||||
hashie (>= 3.4.6, < 3.7.0)
|
|
||||||
rack (>= 1.6.2, < 3)
|
|
||||||
omniauth-oauth2 (1.6.0)
|
|
||||||
oauth2 (~> 1.1)
|
|
||||||
omniauth (~> 1.9)
|
|
||||||
pdfkit (0.8.4.1)
|
|
||||||
popper_js (1.14.5)
|
|
||||||
public_suffix (4.0.1)
|
|
||||||
puma (3.12.0)
|
|
||||||
rack (2.0.5)
|
|
||||||
rack-cors (1.0.2)
|
|
||||||
rack-protection (2.0.5)
|
|
||||||
rack
|
|
||||||
rack-test (1.1.0)
|
|
||||||
rack (>= 1.0, < 3)
|
|
||||||
rails (5.2.1)
|
|
||||||
actioncable (= 5.2.1)
|
|
||||||
actionmailer (= 5.2.1)
|
|
||||||
actionpack (= 5.2.1)
|
|
||||||
actionview (= 5.2.1)
|
|
||||||
activejob (= 5.2.1)
|
|
||||||
activemodel (= 5.2.1)
|
|
||||||
activerecord (= 5.2.1)
|
|
||||||
activestorage (= 5.2.1)
|
|
||||||
activesupport (= 5.2.1)
|
|
||||||
bundler (>= 1.3.0)
|
|
||||||
railties (= 5.2.1)
|
|
||||||
sprockets-rails (>= 2.0.0)
|
|
||||||
rails-dom-testing (2.0.3)
|
|
||||||
activesupport (>= 4.2.0)
|
|
||||||
nokogiri (>= 1.6)
|
|
||||||
rails-html-sanitizer (1.0.4)
|
|
||||||
loofah (~> 2.2, >= 2.2.2)
|
|
||||||
rails-i18n (5.1.3)
|
|
||||||
i18n (>= 0.7, < 2)
|
|
||||||
railties (>= 5.0, < 6)
|
|
||||||
railties (5.2.1)
|
|
||||||
actionpack (= 5.2.1)
|
|
||||||
activesupport (= 5.2.1)
|
|
||||||
method_source
|
|
||||||
rake (>= 0.8.7)
|
|
||||||
thor (>= 0.19.0, < 2.0)
|
|
||||||
rake (12.3.1)
|
|
||||||
rb-fsevent (0.10.3)
|
|
||||||
rb-inotify (0.9.10)
|
|
||||||
ffi (>= 0.5.0, < 2)
|
|
||||||
rchardet (1.8.0)
|
|
||||||
redcarpet (3.4.0)
|
|
||||||
redis (4.1.0)
|
|
||||||
redis-actionpack (5.0.2)
|
|
||||||
actionpack (>= 4.0, < 6)
|
|
||||||
redis-rack (>= 1, < 3)
|
|
||||||
redis-store (>= 1.1.0, < 2)
|
|
||||||
redis-activesupport (5.0.7)
|
|
||||||
activesupport (>= 3, < 6)
|
|
||||||
redis-store (>= 1.3, < 2)
|
|
||||||
redis-rack (2.0.5)
|
|
||||||
rack (>= 1.5, < 3)
|
|
||||||
redis-store (>= 1.2, < 2)
|
|
||||||
redis-rails (5.0.2)
|
|
||||||
redis-actionpack (>= 5.0, < 6)
|
|
||||||
redis-activesupport (>= 5.0, < 6)
|
|
||||||
redis-store (>= 1.2, < 2)
|
|
||||||
redis-store (1.6.0)
|
|
||||||
redis (>= 2.2, < 5)
|
|
||||||
roo (2.8.2)
|
|
||||||
nokogiri (~> 1)
|
|
||||||
rubyzip (>= 1.2.1, < 2.0.0)
|
|
||||||
roo-xls (1.2.0)
|
|
||||||
nokogiri
|
|
||||||
roo (>= 2.0.0, < 3)
|
|
||||||
spreadsheet (> 0.9.0)
|
|
||||||
rqrcode (0.10.1)
|
|
||||||
chunky_png (~> 1.0)
|
|
||||||
rqrcode_png (0.1.5)
|
|
||||||
chunky_png
|
|
||||||
rqrcode
|
|
||||||
rspec-core (3.8.0)
|
|
||||||
rspec-support (~> 3.8.0)
|
|
||||||
rspec-expectations (3.8.1)
|
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
|
||||||
rspec-support (~> 3.8.0)
|
|
||||||
rspec-mocks (3.8.0)
|
|
||||||
diff-lcs (>= 1.2.0, < 2.0)
|
|
||||||
rspec-support (~> 3.8.0)
|
|
||||||
rspec-rails (3.8.0)
|
|
||||||
actionpack (>= 3.0)
|
|
||||||
activesupport (>= 3.0)
|
|
||||||
railties (>= 3.0)
|
|
||||||
rspec-core (~> 3.8.0)
|
|
||||||
rspec-expectations (~> 3.8.0)
|
|
||||||
rspec-mocks (~> 3.8.0)
|
|
||||||
rspec-support (~> 3.8.0)
|
|
||||||
rspec-support (3.8.0)
|
|
||||||
ruby-ole (1.2.12.2)
|
|
||||||
ruby_dep (1.5.0)
|
|
||||||
rubyzip (1.2.1)
|
|
||||||
sass (3.5.7)
|
|
||||||
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.2)
|
|
||||||
railties (>= 4.0.0)
|
|
||||||
sassc (>= 2.0)
|
|
||||||
sprockets (> 3.0)
|
|
||||||
sprockets-rails
|
|
||||||
tilt
|
|
||||||
searchkick (3.1.3)
|
|
||||||
activemodel (>= 4.2)
|
|
||||||
elasticsearch (>= 5)
|
|
||||||
hashie
|
|
||||||
selenium-webdriver (3.14.0)
|
|
||||||
childprocess (~> 0.5)
|
|
||||||
rubyzip (~> 1.2)
|
|
||||||
sidekiq (5.2.7)
|
|
||||||
connection_pool (~> 2.2, >= 2.2.2)
|
|
||||||
rack (>= 1.5.0)
|
|
||||||
rack-protection (>= 1.5.0)
|
|
||||||
redis (>= 3.3.5, < 5)
|
|
||||||
simple_form (4.1.0)
|
|
||||||
actionpack (>= 5.0)
|
|
||||||
activemodel (>= 5.0)
|
|
||||||
simple_xlsx_reader (1.0.4)
|
|
||||||
nokogiri
|
|
||||||
rubyzip
|
|
||||||
sinatra (2.0.5)
|
|
||||||
mustermann (~> 1.0)
|
|
||||||
rack (~> 2.0)
|
|
||||||
rack-protection (= 2.0.5)
|
|
||||||
tilt (~> 2.0)
|
|
||||||
spreadsheet (1.2.3)
|
|
||||||
ruby-ole (>= 1.0)
|
|
||||||
spring (2.0.2)
|
|
||||||
activesupport (>= 4.2)
|
|
||||||
spring-watcher-listen (2.0.1)
|
|
||||||
listen (>= 2.7, < 4.0)
|
|
||||||
spring (>= 1.2, < 3.0)
|
|
||||||
sprockets (3.7.2)
|
|
||||||
concurrent-ruby (~> 1.0)
|
|
||||||
rack (> 1, < 3)
|
|
||||||
sprockets-rails (3.2.1)
|
|
||||||
actionpack (>= 4.0)
|
|
||||||
activesupport (>= 4.0)
|
|
||||||
sprockets (>= 3.0.0)
|
|
||||||
terminal-table (1.8.0)
|
|
||||||
unicode-display_width (~> 1.1, >= 1.1.1)
|
|
||||||
thor (0.20.0)
|
|
||||||
thread_safe (0.3.6)
|
|
||||||
tilt (2.0.8)
|
|
||||||
turbolinks (5.2.0)
|
|
||||||
turbolinks-source (~> 5.2)
|
|
||||||
turbolinks-source (5.2.0)
|
|
||||||
tzinfo (1.2.5)
|
|
||||||
thread_safe (~> 0.1)
|
|
||||||
uglifier (4.1.17)
|
|
||||||
execjs (>= 0.3.0, < 3)
|
|
||||||
unicode-display_width (1.4.0)
|
|
||||||
web-console (3.6.2)
|
|
||||||
actionview (>= 5.0)
|
|
||||||
activemodel (>= 5.0)
|
|
||||||
bindex (>= 0.4.0)
|
|
||||||
railties (>= 5.0)
|
|
||||||
websocket-driver (0.7.0)
|
|
||||||
websocket-extensions (>= 0.1.0)
|
|
||||||
websocket-extensions (0.1.3)
|
|
||||||
wkhtmltopdf-binary (0.12.4)
|
|
||||||
xpath (3.1.0)
|
|
||||||
nokogiri (~> 1.8)
|
|
||||||
|
|
||||||
PLATFORMS
|
|
||||||
ruby
|
|
||||||
|
|
||||||
DEPENDENCIES
|
|
||||||
aasm
|
|
||||||
active_decorator
|
|
||||||
acts-as-taggable-on (~> 6.0)
|
|
||||||
awesome_print
|
|
||||||
axlsx (~> 3.0.0.pre)
|
|
||||||
axlsx_rails (~> 0.5.2)
|
|
||||||
bootsnap (>= 1.1.0)
|
|
||||||
bootstrap (~> 4.3.1)
|
|
||||||
bulk_insert
|
|
||||||
byebug
|
|
||||||
capybara (>= 2.15, < 4.0)
|
|
||||||
chromedriver-helper
|
|
||||||
diffy
|
|
||||||
enumerize
|
|
||||||
faraday (~> 0.15.4)
|
|
||||||
font-awesome-sass (= 4.7.0)
|
|
||||||
gitlab!
|
|
||||||
grape-entity (~> 0.7.1)
|
|
||||||
jbuilder (~> 2.5)
|
|
||||||
jquery-rails
|
|
||||||
kaminari (~> 1.1, >= 1.1.1)
|
|
||||||
listen (>= 3.0.5, < 3.2)
|
|
||||||
mysql2 (>= 0.4.4, < 0.6.0)
|
|
||||||
oauth2
|
|
||||||
omniauth (~> 1.9.0)
|
|
||||||
omniauth-oauth2 (~> 1.6.0)
|
|
||||||
pdfkit
|
|
||||||
puma (~> 3.11)
|
|
||||||
rack-cors
|
|
||||||
rails (~> 5.2.0)
|
|
||||||
rails-i18n (~> 5.1)
|
|
||||||
rchardet (~> 1.8)
|
|
||||||
redcarpet (~> 3.4)
|
|
||||||
redis-rails
|
|
||||||
roo-xls
|
|
||||||
rqrcode (~> 0.10.1)
|
|
||||||
rqrcode_png
|
|
||||||
rspec-rails (~> 3.8)
|
|
||||||
ruby-ole
|
|
||||||
rubyzip
|
|
||||||
sass-rails (~> 5.0)
|
|
||||||
searchkick
|
|
||||||
selenium-webdriver
|
|
||||||
sidekiq
|
|
||||||
simple_form
|
|
||||||
simple_xlsx_reader
|
|
||||||
sinatra
|
|
||||||
spreadsheet
|
|
||||||
spring
|
|
||||||
spring-watcher-listen (~> 2.0.0)
|
|
||||||
turbolinks (~> 5)
|
|
||||||
tzinfo-data
|
|
||||||
uglifier (>= 1.3.0)
|
|
||||||
web-console (>= 3.3.0)
|
|
||||||
wkhtmltopdf-binary
|
|
||||||
|
|
||||||
RUBY VERSION
|
|
||||||
ruby 2.3.7p456
|
|
||||||
|
|
||||||
BUNDLED WITH
|
|
||||||
1.17.3
|
|
@ -0,0 +1,2 @@
|
|||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,148 @@
|
|||||||
|
$(document).on('turbolinks:load', function() {
|
||||||
|
if ($('body.cooperative-competitions-index-page').length > 0) {
|
||||||
|
$('.modal.cooperative-upload-file-modal').on('upload:success', function(e, data){
|
||||||
|
var $imageElement = $('.competition-image-' + data.source_id);
|
||||||
|
$imageElement.attr('src', data.url);
|
||||||
|
$imageElement.show();
|
||||||
|
$imageElement.next().html('重新上传');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$(".cooperative-competition-list-form").on("change", '.competitions-hot-select', function () {
|
||||||
|
var s_value = $(this).get(0).checked ? 1 : 0;
|
||||||
|
var json = {};
|
||||||
|
json["hot"] = s_value;
|
||||||
|
$.ajax({
|
||||||
|
url: "/cooperative/competitions/hot_setting",
|
||||||
|
type: "POST",
|
||||||
|
dataType:'json',
|
||||||
|
data: json,
|
||||||
|
success: function(){
|
||||||
|
$.notify({ message: '操作成功' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// ============== 新增竞赛 ===============
|
||||||
|
var $modal = $('.modal.cooperative-create-competition-modal');
|
||||||
|
var $form = $modal.find('form.cooperative-create-competition-form');
|
||||||
|
var $competitionNameInput = $form.find('input[name="competition_name"]');
|
||||||
|
|
||||||
|
$form.validate({
|
||||||
|
errorElement: 'span',
|
||||||
|
errorClass: 'danger text-danger',
|
||||||
|
rules: {
|
||||||
|
competition_name: {
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// modal ready fire
|
||||||
|
$modal.on('show.bs.modal', function () {
|
||||||
|
$competitionNameInput.val('');
|
||||||
|
});
|
||||||
|
|
||||||
|
$modal.on('click', '.submit-btn', function(){
|
||||||
|
$form.find('.error').html('');
|
||||||
|
|
||||||
|
if ($form.valid()) {
|
||||||
|
var url = $form.data('url');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
url: url,
|
||||||
|
data: $form.serialize(),
|
||||||
|
success: function(){
|
||||||
|
$.notify({ message: '创建成功' });
|
||||||
|
$modal.modal('hide');
|
||||||
|
|
||||||
|
setTimeout(function(){
|
||||||
|
window.location.reload();
|
||||||
|
}, 500);
|
||||||
|
},
|
||||||
|
error: function(res){
|
||||||
|
var data = res.responseJSON;
|
||||||
|
$form.find('.error').html(data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 导入学生
|
||||||
|
var $importScoreModal = $('.modal.cooperative-import-competition-score-modal');
|
||||||
|
var $importScoreForm = $importScoreModal.find('form.cooperative-import-competition-score-form');
|
||||||
|
var $competitionIdInput = $importScoreForm.find('input[name="competition_id"]');
|
||||||
|
|
||||||
|
$importScoreModal.on('show.bs.modal', function(event){
|
||||||
|
resetFileInputFunc($importScoreModal.find('.upload-file-input'));
|
||||||
|
$importScoreModal.find('.file-names').html('选择文件');
|
||||||
|
$importScoreModal.find('.upload-file-input').trigger('click');
|
||||||
|
|
||||||
|
var $link = $(event.relatedTarget);
|
||||||
|
var competitionId = $link.data('competition-id');
|
||||||
|
$competitionIdInput.val(competitionId);
|
||||||
|
});
|
||||||
|
|
||||||
|
$importScoreModal.on('change', '.upload-file-input', function(e){
|
||||||
|
var file = $(this)[0].files[0];
|
||||||
|
$importScoreModal.find('.file-names').html(file ? file.name : '请选择文件');
|
||||||
|
});
|
||||||
|
|
||||||
|
var importUserFormValid = function(){
|
||||||
|
if($importScoreForm.find('input[name="file"]').val() == undefined || $importScoreForm.find('input[name="file"]').val().length == 0){
|
||||||
|
$importScoreForm.find('.error').html('请选择文件');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
var buildResultMessage = function(data){
|
||||||
|
var messageHtml = "<div>导入结果:成功" + data.success + "条,失败"+ data.fail.length + "条</div>";
|
||||||
|
|
||||||
|
if(data.fail.length > 0){
|
||||||
|
messageHtml += '<table class="table"><thead class="thead-light"><tr><th>数据</th><th>失败原因</th></tr></thead><tbody>';
|
||||||
|
|
||||||
|
data.fail.forEach(function(item){
|
||||||
|
messageHtml += '<tr><td>' + item.data + '</td><td>' + item.message + '</td></tr>';
|
||||||
|
});
|
||||||
|
|
||||||
|
messageHtml += '</tbody></table>'
|
||||||
|
}
|
||||||
|
|
||||||
|
return messageHtml;
|
||||||
|
};
|
||||||
|
|
||||||
|
$importScoreModal.on('click', '.submit-btn', function(){
|
||||||
|
$importScoreForm.find('.error').html('');
|
||||||
|
|
||||||
|
if (importUserFormValid()) {
|
||||||
|
$('body').mLoading({ text: '正在导入...' });
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
method: 'POST',
|
||||||
|
dataType: 'json',
|
||||||
|
url: '/cooperative/import_competition_scores',
|
||||||
|
data: new FormData($importScoreForm[0]),
|
||||||
|
processData: false,
|
||||||
|
contentType: false,
|
||||||
|
success: function(data){
|
||||||
|
$('body').mLoading('destroy');
|
||||||
|
$importScoreModal.modal('hide');
|
||||||
|
|
||||||
|
showMessageModal(buildResultMessage(data), function(){
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: function(res){
|
||||||
|
$('body').mLoading('destroy');
|
||||||
|
var data = res.responseJSON;
|
||||||
|
$importScoreForm.find('.error').html(data.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
@ -0,0 +1,9 @@
|
|||||||
|
$(document).on('turbolinks:load', function() {
|
||||||
|
if($('body.cooperative-enroll-lists-index-page').length > 0){
|
||||||
|
var search_form = $(".search-form");
|
||||||
|
//导出
|
||||||
|
$(".competition-enroll-list-form").on("click","#enroll-lists-export",function () {
|
||||||
|
window.location.href = "/cooperative/competitions/"+$(this).attr("data-competition-id")+"/enroll_lists/export.xlsx?" + search_form.serialize();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,2 @@
|
|||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,2 @@
|
|||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the comments controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,116 @@
|
|||||||
|
.cooperative-competition-settings-index-page {
|
||||||
|
.competition-mode-container {
|
||||||
|
.row {
|
||||||
|
height: 35px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.des-row {
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control {
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
//.mode-input {
|
||||||
|
// input {
|
||||||
|
// width: 40%;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
.col-md-label{
|
||||||
|
-webkit-box-flex: 0;
|
||||||
|
flex: 0 0 10%;
|
||||||
|
max-width: 10%;
|
||||||
|
min-width: 30px;
|
||||||
|
padding-right: 15px;
|
||||||
|
padding-left: 15px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.col-md-label-s{
|
||||||
|
-webkit-box-flex: 0;
|
||||||
|
flex: 0 0 30px;
|
||||||
|
padding-right: 15px;
|
||||||
|
padding-left: 15px;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.setBtn_s{
|
||||||
|
height: 35px;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sponsor_label{
|
||||||
|
border:1px solid #4CACFF;
|
||||||
|
border-radius: 5px;
|
||||||
|
background-color: rgba(76,172,255,0.3);
|
||||||
|
color: #333;
|
||||||
|
padding:0px 4px;
|
||||||
|
height: 30px;
|
||||||
|
line-height: 30px;
|
||||||
|
float: left;
|
||||||
|
margin: 4px 5px;
|
||||||
|
|
||||||
|
span{
|
||||||
|
display: block;
|
||||||
|
float: left;
|
||||||
|
height: 28px;
|
||||||
|
line-height: 28px;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
a{
|
||||||
|
font-size: 18px;
|
||||||
|
float: left;
|
||||||
|
height: 28px;
|
||||||
|
line-height: 28px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.large_panel{
|
||||||
|
padding:0px 15px;
|
||||||
|
|
||||||
|
.large_panel_part{
|
||||||
|
border-top: 1px solid #eaeaea;
|
||||||
|
}
|
||||||
|
.large_panel_part:first-child{
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.large_panel_part >.row ,.small_panel >.row{
|
||||||
|
border-bottom: 1px solid #eaeaea;
|
||||||
|
padding:20px 0px;
|
||||||
|
}
|
||||||
|
.small_panel{
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
.row:last-child{
|
||||||
|
border:none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.task_Input_div:nth-child(3n-2) > span.col-4{
|
||||||
|
flex: 0 0 81px;
|
||||||
|
max-width: 81px;
|
||||||
|
}
|
||||||
|
.task_Input_div:nth-child(3n-2){
|
||||||
|
flex: 0 0 50%;
|
||||||
|
max-width: 50%;
|
||||||
|
}
|
||||||
|
.task_Input_div:nth-child(3n-1){
|
||||||
|
flex: 0 0 25%;
|
||||||
|
max-width: 25%;
|
||||||
|
}
|
||||||
|
.task_Input_div:nth-child(3n){
|
||||||
|
flex: 0 0 25%;
|
||||||
|
max-width: 25%;
|
||||||
|
}
|
||||||
|
.task_Input_div:nth-child(3n) > span.col-4{
|
||||||
|
flex: 0 0 33.3%;
|
||||||
|
max-width: 33.3%;
|
||||||
|
}
|
||||||
|
.task_Input_div:nth-child(3n) > div.col-6{
|
||||||
|
flex: 0 0 50%;
|
||||||
|
max-width: 50%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the HackUserLastestCodes controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,3 @@
|
|||||||
|
// Place all the styles related to the hacks controller here.
|
||||||
|
// They will automatically be included in application.css.
|
||||||
|
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,14 @@
|
|||||||
|
class Admins::ShixunFeedbackMessagesController < Admins::BaseController
|
||||||
|
|
||||||
|
def index
|
||||||
|
default_sort('created_at', 'desc')
|
||||||
|
@params_page = params[:page] || 1
|
||||||
|
if params[:keyword]
|
||||||
|
discusses = Discuss.find_by_sql("select * from discusses join shixuns on discusses.dis_id = shixuns.id where discusses.dis_type='Shixun' AND
|
||||||
|
shixuns.name like '%#{params[:keyword]}%'")
|
||||||
|
else
|
||||||
|
discusses = Discuss.where(:dis_type => 'Shixun').includes(:user, :dis)
|
||||||
|
end
|
||||||
|
@discusses = paginate discusses
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,59 @@
|
|||||||
|
class CommentsController < ApplicationController
|
||||||
|
before_action :find_hack
|
||||||
|
before_action :require_login
|
||||||
|
|
||||||
|
|
||||||
|
# 评论
|
||||||
|
def create
|
||||||
|
begin
|
||||||
|
@discuss = @hack.discusses.new(comment_params) # 管理员回复的能够显示
|
||||||
|
@discuss.hidden = false
|
||||||
|
@discuss.user_id = current_user.id
|
||||||
|
@discuss.save!
|
||||||
|
rescue Exception => e
|
||||||
|
uid_logger_error("create discuss failed : #{e.message}")
|
||||||
|
render_error("评论异常")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 回复
|
||||||
|
def reply
|
||||||
|
begin
|
||||||
|
@discuss = @hack.discusses.new(reply_params)
|
||||||
|
@discuss.hidden = false
|
||||||
|
@discuss.user_id = current_user.id
|
||||||
|
@discuss.root_id = params[:parent_id]
|
||||||
|
@discuss.save!
|
||||||
|
rescue Exception => e
|
||||||
|
uid_logger_error("reply discuss failed : #{e.message}")
|
||||||
|
render_error("回复评论异常")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 列表
|
||||||
|
def index
|
||||||
|
disscusses = @hack.disscusses.where(:root_id => nil)
|
||||||
|
@disscuss_count = disscusses.count
|
||||||
|
@disscusses= paginate disscusses
|
||||||
|
end
|
||||||
|
|
||||||
|
# 删除
|
||||||
|
def destroy
|
||||||
|
@hack.discusses.find_by(id: params[:id]).destroy
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
private
|
||||||
|
def find_hack
|
||||||
|
@hack = Hack.find_by_identifier params[:identifier]
|
||||||
|
end
|
||||||
|
|
||||||
|
def comment_params
|
||||||
|
params.require(:comments).permit(:content)
|
||||||
|
end
|
||||||
|
|
||||||
|
def reply_params
|
||||||
|
params.require(:comments).permit(:content, :parent_id)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,51 @@
|
|||||||
|
class Cooperative::CompetitionPrizeUsersController < Cooperative::BaseController
|
||||||
|
def index
|
||||||
|
@competition = current_competition
|
||||||
|
|
||||||
|
prize_users = Admins::CompetitionPrizeUserQuery.call(params.merge(competition_id: current_competition.id))
|
||||||
|
include_class = [:competition_team, :competition_prize, :approver,
|
||||||
|
user: [:process_real_name_apply, :process_professional_apply, user_extension: :school]]
|
||||||
|
@prize_users = paginate(prize_users.preload(include_class))
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
format.html
|
||||||
|
format.xlsx do
|
||||||
|
@all_prize_users = prize_users
|
||||||
|
filename = "#{@competition.name}竞赛获奖人信息列表_#{Time.current.strftime('%Y%m%d%H%M%S')}.xlsx"
|
||||||
|
render xlsx: 'index', filename: filename
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
Admins::CreateCompetitionPrizeUsersService.call(current_competition)
|
||||||
|
render_ok
|
||||||
|
rescue ApplicationService::Error => ex
|
||||||
|
render_error(ex.message)
|
||||||
|
end
|
||||||
|
|
||||||
|
def approve
|
||||||
|
Admins::ApproveCompetitionPrizeUserService.call(current_prize_user, current_user)
|
||||||
|
@prize_user = current_prize_user
|
||||||
|
rescue ApplicationService::Error => ex
|
||||||
|
render_js_error(ex.message, type: :notify)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unapprove
|
||||||
|
Admins::UnapproveCompetitionPrizeUserService.call(current_prize_user, current_user)
|
||||||
|
@prize_user = current_prize_user
|
||||||
|
rescue ApplicationService::Error => ex
|
||||||
|
render_js_error(ex.message, type: :notify)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def current_prize_user
|
||||||
|
@_current_prize_user ||= current_competition.competition_prize_users.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_competition
|
||||||
|
@_current_competition ||= current_laboratory.competitions.find(params[:competition_id])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,43 @@
|
|||||||
|
class Cooperative::CompetitionPrizesController < Cooperative::BaseController
|
||||||
|
def index
|
||||||
|
@competition = current_competition
|
||||||
|
end
|
||||||
|
|
||||||
|
def new
|
||||||
|
@prize = current_competition.competition_prizes.new
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@prize = current_competition.competition_prizes.create!(save_params)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@prize = current_competition_prize
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
current_competition_prize.update!(save_params)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
current_competition_prize.destroy!
|
||||||
|
|
||||||
|
render_delete_success
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def current_competition_prize
|
||||||
|
@_current_competition_prize ||= current_competition.competition_prizes.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def current_competition
|
||||||
|
@_current_competition ||= current_laboratory.competitions.find(params[:competition_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_params
|
||||||
|
params.require(:competition_prize).permit(:name, :category, :num)
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,33 @@
|
|||||||
|
class Cooperative::CompetitionSettingsController < Cooperative::BaseController
|
||||||
|
def index
|
||||||
|
@competition = current_competition
|
||||||
|
end
|
||||||
|
|
||||||
|
def basic_setting
|
||||||
|
Admins::CompetitionBasicSettingService.call(current_competition, basic_form_params)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def nav_setting
|
||||||
|
Admins::CompetitionNavSettingService.call(current_competition, nav_form_params)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def current_competition
|
||||||
|
@_current_competition ||= current_laboratory.competitions.find(params[:competition_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
def basic_form_params
|
||||||
|
params.permit(:identifier, :name, :sub_title, :start_time, :end_time, :mode,
|
||||||
|
:identifier, :bonus, :awards_count, :description, :course_id, :teach_start_time,
|
||||||
|
:teach_end_time, sponsor_schools: [], region_schools: [], manager_ids: [])
|
||||||
|
end
|
||||||
|
|
||||||
|
def nav_form_params
|
||||||
|
params.permit(:enroll_end_time,
|
||||||
|
competition_staffs: %i[category minimum maximum mutiple_limited],
|
||||||
|
navbar: %i[module_type module_id name hidden position url])
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,57 @@
|
|||||||
|
class Cooperative::CompetitionsController < Cooperative::BaseController
|
||||||
|
before_action :find_competition, except: [:index]
|
||||||
|
|
||||||
|
def index
|
||||||
|
# params[:sort_by] = params[:sort_by].presence || 'created_at'
|
||||||
|
# params[:sort_direction] = params[:sort_direction].presence || 'desc'
|
||||||
|
@competitions = current_laboratory.competitions.order("created_at desc")
|
||||||
|
@params_page = params[:page] || 1
|
||||||
|
@competitions = paginate @competitions
|
||||||
|
ids = @competitions.map(&:id)
|
||||||
|
@member_count_map = TeamMember.where(competition_id: ids).group(:competition_id).count
|
||||||
|
|
||||||
|
@competition_hot = ModuleSetting.exists?(module_type: "Competition", property: "hot")
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
format.html
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
name = params[:competition_name].to_s.strip
|
||||||
|
Competition.create!(name: name)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def hot_setting
|
||||||
|
if params[:hot].to_i == 1 && !ModuleSetting.exists?(module_type: "Competition", property: "hot")
|
||||||
|
ModuleSetting.create!(module_type: "Competition", property: "hot")
|
||||||
|
elsif params[:hot].to_i == 0 && ModuleSetting.exists?(module_type: "Competition", property: "hot")
|
||||||
|
ModuleSetting.where(module_type: "Competition", property: "hot").destroy_all
|
||||||
|
end
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
def publish
|
||||||
|
@competition.update_attributes!(published_at: Time.now)
|
||||||
|
end
|
||||||
|
|
||||||
|
def unpublish
|
||||||
|
@competition.update_attributes!(published_at: nil)
|
||||||
|
end
|
||||||
|
|
||||||
|
def online_switch
|
||||||
|
if @competition.status
|
||||||
|
@competition.update_attributes!(status: false)
|
||||||
|
else
|
||||||
|
@competition.update_attributes!(status: true, online_time: Time.now)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def find_competition
|
||||||
|
@competition = current_laboratory.competitions.find_by(id: params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,33 @@
|
|||||||
|
class Cooperative::EnrollListsController < Cooperative::BaseController
|
||||||
|
|
||||||
|
def index
|
||||||
|
@competition = current_competition
|
||||||
|
default_sort('created_at', 'desc')
|
||||||
|
enroll_lists = Admins::CompetitionEnrollListQuery.call(@competition, params)
|
||||||
|
|
||||||
|
@params_page = params[:page] || 1
|
||||||
|
@enroll_lists = paginate enroll_lists.preload(competition_team: [:user, :teachers], user: { user_extension: :school })
|
||||||
|
@personal = @competition.personal?
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
format.html
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def export
|
||||||
|
default_sort('created_at', 'desc')
|
||||||
|
@enroll_lists = Admins::CompetitionEnrollListQuery.call(current_competition, params)
|
||||||
|
@enroll_lists = @enroll_lists.preload(competition_team: [:user, :teachers], user: { user_extension: :school })
|
||||||
|
@competition_scores = current_competition.competition_scores.where(competition_stage_id: 0).order("score desc, cost_time desc").pluck(:competition_team_id)
|
||||||
|
@personal = current_competition.personal?
|
||||||
|
filename = ["#{current_competition.name}竞赛报名列表", Time.zone.now.strftime('%Y-%m-%d%H:%M:%S')].join('-') << '.xlsx'
|
||||||
|
render xlsx: 'export', filename: filename
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def current_competition
|
||||||
|
@_current_competition ||= current_laboratory.competitions.find(params[:competition_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,205 @@
|
|||||||
|
class HacksController < ApplicationController
|
||||||
|
before_action :require_login, except: [:index]
|
||||||
|
before_action :find_hack, only: [:edit, :update, :publish, :start, :update_set, :delete_set]
|
||||||
|
before_action :require_teacher_identity, only: [:create, :update_set]
|
||||||
|
before_action :require_auth_identity, only: [:update, :edit, :publish, :update_set, :delete_set]
|
||||||
|
|
||||||
|
|
||||||
|
# 开启编程,如果第一次开启,创建一条记录,如果已经开启过的话,直接返回标识即可
|
||||||
|
def start
|
||||||
|
# 未发布的编程题,只能作者、或管理员访问
|
||||||
|
start_hack_auth
|
||||||
|
user_hack = @hack.hack_user_lastest_codes.mine(current_user.id)
|
||||||
|
identifier =
|
||||||
|
if user_hack.present?
|
||||||
|
user_hack.identifier
|
||||||
|
else
|
||||||
|
user_identifier = generate_identifier HackUserLastestCode, 12
|
||||||
|
user_code = {user_id: current_user.id, code: @hack.code,
|
||||||
|
identifier: user_identifier, language: @hack.language}
|
||||||
|
@hack.hack_user_lastest_codes.create!(user_code)
|
||||||
|
user_identifier
|
||||||
|
end
|
||||||
|
render_ok(identifier: identifier)
|
||||||
|
end
|
||||||
|
|
||||||
|
# 首页
|
||||||
|
def index
|
||||||
|
# 筛选过滤与排序
|
||||||
|
params_filter_or_order
|
||||||
|
# 我解决的编程题数
|
||||||
|
user_codes = HackUserLastestCode.joins(:hack).mine_hack(current_user).passed
|
||||||
|
@simple_count = user_codes.where(hacks: {difficult: 1}).count
|
||||||
|
@medium_count = user_codes.where(hacks: {difficult: 2}).count
|
||||||
|
@diff_count = user_codes.where(hacks: {difficult: 3}).count
|
||||||
|
@pass_count = @simple_count + @medium_count + @diff_count
|
||||||
|
|
||||||
|
@hacks_count = @hacks.count("hacks.id")
|
||||||
|
@hacks = paginate @hacks
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
begin
|
||||||
|
logger.info("##########{hack_params}")
|
||||||
|
hack = Hack.new(hack_params)
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
hack.user_id = current_user.id
|
||||||
|
hack.identifier = generate_identifier Hack, 8
|
||||||
|
hack.save!
|
||||||
|
# 创建测试集与代码
|
||||||
|
hack.hack_sets.create!(hack_sets_params)
|
||||||
|
hack.hack_codes.create!(hack_code_params)
|
||||||
|
end
|
||||||
|
render_ok({identifier: hack.identifier})
|
||||||
|
rescue Exception => e
|
||||||
|
logger.error("########create_hack_error: #{e.message}")
|
||||||
|
render_error("创建失败")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
begin
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
@hack.update_attributes!(hack_params)
|
||||||
|
set_ids = @hack.hack_sets.pluck(:id)
|
||||||
|
# 更新
|
||||||
|
param_update_sets params[:update_hack_sets], set_ids
|
||||||
|
# 新建
|
||||||
|
@hack.hack_sets.create!(hack_sets_params)
|
||||||
|
# 更新代码
|
||||||
|
@hack.hack_codes.create!(hack_code_params)
|
||||||
|
end
|
||||||
|
render_ok
|
||||||
|
rescue Exception => e
|
||||||
|
logger.error("####update_hack_error: #{e.message}")
|
||||||
|
render_error("更新失败")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 更新测试集接口
|
||||||
|
def update_set
|
||||||
|
set = @hack.hack_sets.find_by(id: params[:id])
|
||||||
|
set.update_attributes!(hack_set_params)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
# 单独删除测试集
|
||||||
|
def delete_set
|
||||||
|
set = @hack.hack_sets.find_by(id: params[:id])
|
||||||
|
set.destroy!
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
# 发布功能
|
||||||
|
def publish
|
||||||
|
@hack.update_attribute(:status, 1)
|
||||||
|
render_ok
|
||||||
|
end
|
||||||
|
|
||||||
|
# 发布列表
|
||||||
|
def unpulished_list
|
||||||
|
limit = params[:limit] || 16
|
||||||
|
page = params[:page] || 1
|
||||||
|
hacks = Hack.where(user_id: current_user.id, status: 0)
|
||||||
|
@hacks_count = hacks.count
|
||||||
|
@hacks = hacks.includes(:hack_sets).page(page).per(limit)
|
||||||
|
end
|
||||||
|
|
||||||
|
def edit;end
|
||||||
|
|
||||||
|
private
|
||||||
|
# 实名认证老师,管理员与运营人员权限
|
||||||
|
def require_teacher_identity
|
||||||
|
unless current_user.certification_teacher? || admin_or_business?
|
||||||
|
tip_exception(403, "..")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 只有自己,或者管理员才能更新
|
||||||
|
def require_auth_identity
|
||||||
|
unless @hack.user_id == current_user.id || admin_or_business?
|
||||||
|
tip_exception(403, "..")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_hack
|
||||||
|
@hack = Hack.find_by_identifier(params[:identifier])
|
||||||
|
end
|
||||||
|
|
||||||
|
def hack_params
|
||||||
|
params.require(:hack).permit(:name, :description, :difficult, :category, :open_or_not, :time_limit, :score)
|
||||||
|
end
|
||||||
|
|
||||||
|
def hack_sets_params
|
||||||
|
params.permit(hack_sets: [:input, :output, :position])[:hack_sets]
|
||||||
|
end
|
||||||
|
|
||||||
|
def hack_set_params
|
||||||
|
params.require(:hack_set).permit(:id, :input, :output, :position)
|
||||||
|
end
|
||||||
|
|
||||||
|
def hack_code_params
|
||||||
|
params.require(:hack_codes).permit(:code, :language)
|
||||||
|
end
|
||||||
|
|
||||||
|
def publish_params
|
||||||
|
params.require(:hack).permit(:difficult, :category, :open_or_not, :time_limit, :score)
|
||||||
|
end
|
||||||
|
|
||||||
|
def param_update_sets sets, all_sets_id
|
||||||
|
delete_set_ids = all_sets_id - sets.map{|set|set[:id]}
|
||||||
|
@hack.hack_sets.where(id: delete_set_ids).destroy_all
|
||||||
|
sets.each do |set|
|
||||||
|
if all_sets_id.include?(set[:id])
|
||||||
|
update_attrs = {input: set[:input], output: set[:output], position: set[:position]}
|
||||||
|
@hack.hack_sets.find_by!(id: set[:id]).update_attributes(update_attrs)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def params_filter_or_order
|
||||||
|
# 如果有来源,就不管发布公开私有
|
||||||
|
select_sql = "hacks.*, if(hacks.hack_user_lastest_codes_count=0, 0, hacks.pass_num/hacks.hack_user_lastest_codes_count) passed_rate"
|
||||||
|
if params[:come_from]
|
||||||
|
hacks = Hack.select(select_sql).mine(current_user.id)
|
||||||
|
else
|
||||||
|
# 全部包括已经发布的,和我的未发布的
|
||||||
|
hacks = Hack.select(select_sql).published.opening.or(Hack.select(select_sql).unpublish.mine(current_user.id))
|
||||||
|
end
|
||||||
|
# 搜索
|
||||||
|
if params[:search]
|
||||||
|
hacks = hacks.where("name like ?", "%#{params[:search]}%")
|
||||||
|
end
|
||||||
|
# 难度
|
||||||
|
if params[:difficult]
|
||||||
|
hacks = hacks.where(difficult: params[:difficult])
|
||||||
|
end
|
||||||
|
# 状态
|
||||||
|
if params[:status]
|
||||||
|
user_hacks = HackUserLastestCode.where(user_id: current_user.id)
|
||||||
|
if params[:status].to_i == -1
|
||||||
|
if user_hacks.present?
|
||||||
|
hacks = hacks.where.not(id: user_hacks.pluck(:hack_id))
|
||||||
|
end
|
||||||
|
else
|
||||||
|
hacks = hacks.joins(:hack_user_lastest_codes).where(hack_user_lastest_codes: {status: params[:status]})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# 分类
|
||||||
|
if params[:category]
|
||||||
|
hacks = hacks.where(category: params[:category])
|
||||||
|
end
|
||||||
|
|
||||||
|
# 排序
|
||||||
|
sort_by = params[:sort_by] || "hack_user_lastest_codes_count"
|
||||||
|
sort_direction = params[:sort_direction] || "desc"
|
||||||
|
@hacks = hacks.order("#{sort_by} #{sort_direction}")
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_hack_auth
|
||||||
|
return true if @hack == 1
|
||||||
|
require_auth_identity
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,2 @@
|
|||||||
|
module CommentsHelper
|
||||||
|
end
|
@ -0,0 +1,2 @@
|
|||||||
|
module HackUserLastestCodesHelper
|
||||||
|
end
|
@ -0,0 +1,2 @@
|
|||||||
|
module HacksHelper
|
||||||
|
end
|
@ -0,0 +1,67 @@
|
|||||||
|
module Weapps::CoursesHelper
|
||||||
|
require 'chinese_pinyin'
|
||||||
|
|
||||||
|
def teacher_list teachers
|
||||||
|
data = []
|
||||||
|
teachers.each do |teacher|
|
||||||
|
if teacher.user.present?
|
||||||
|
teacher_user = teacher.user
|
||||||
|
name = teacher_user.real_name
|
||||||
|
role = teacher.role == "CREATOR" ? "管理员" : teacher.role == "PROFESSOR" ? "教师" : "助教"
|
||||||
|
item = {name: name, course_member_id: teacher.id, login: teacher_user.login, user_id: teacher.user_id, role: role,
|
||||||
|
school: teacher_user.school_name, image_url: url_to_avatar(teacher_user)}
|
||||||
|
pinyin = Pinyin.t(name.strip, splitter: '')
|
||||||
|
first_char = pinyin[0]
|
||||||
|
letter = first_letter first_char
|
||||||
|
if data.pluck(:letter).include?(letter)
|
||||||
|
data.select{|a|a[:letter]==letter}.first[:items] << item
|
||||||
|
else
|
||||||
|
data << {letter: letter, items: [item]}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# data = data.sort do |a, b|
|
||||||
|
# [a[:letter]] <=> [b[:letter]]
|
||||||
|
# end
|
||||||
|
# data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def student_list students, excellent
|
||||||
|
data = []
|
||||||
|
students.each do |student|
|
||||||
|
if student.user.present?
|
||||||
|
student_user = student.user
|
||||||
|
name = student_user.real_name
|
||||||
|
phone = excellent ? "" : student_user.hidden_phone
|
||||||
|
item = {name: name, course_member_id: student.id, login: student_user.login, user_id: student.user_id,
|
||||||
|
student_id: student_user.student_id, image_url: url_to_avatar(student_user), phone: phone}
|
||||||
|
pinyin = Pinyin.t(name.strip, splitter: '')
|
||||||
|
first_char = pinyin[0]
|
||||||
|
letter = first_letter first_char
|
||||||
|
if data.pluck(:letter).include?(letter)
|
||||||
|
data.select{|a|a[:letter]==letter}.first[:items] << item
|
||||||
|
else
|
||||||
|
data << {letter: letter, items: [item]}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# data = data.sort do |a, b|
|
||||||
|
# [a[:letter]] <=> [b[:letter]]
|
||||||
|
# end
|
||||||
|
# data.push(data.shift) if data.select{|a|a[:letter]=='#'}.first.present? # '#'排在最后
|
||||||
|
return data
|
||||||
|
end
|
||||||
|
|
||||||
|
def first_letter char
|
||||||
|
if char.ord >= 97 && char.ord <= 122
|
||||||
|
letter = (char.ord - 32).chr.to_s
|
||||||
|
elsif char.ord >= 65 && char.ord <= 90
|
||||||
|
letter = char
|
||||||
|
else
|
||||||
|
letter = '#'
|
||||||
|
end
|
||||||
|
letter
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,10 @@
|
|||||||
|
class UpdateShixunWorkScoreJob < ApplicationJob
|
||||||
|
queue_as :default
|
||||||
|
|
||||||
|
def perform(homework_id)
|
||||||
|
homework = HomeworkCommon.find_by(id: homework_id)
|
||||||
|
return if homework.blank?
|
||||||
|
|
||||||
|
homework.update_homework_work_score
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,3 @@
|
|||||||
|
class HackCode < ApplicationRecord
|
||||||
|
# 编程题代码相关
|
||||||
|
end
|
@ -0,0 +1,6 @@
|
|||||||
|
class HackSet < ApplicationRecord
|
||||||
|
validates :input, presence: { message: "测试集输入不能为空" }
|
||||||
|
validates :output, uniqueness: { message: "测试集输出不能为空" }
|
||||||
|
# 编程题测试集
|
||||||
|
belongs_to :hack
|
||||||
|
end
|
@ -0,0 +1,4 @@
|
|||||||
|
class HackUserCode < ApplicationRecord
|
||||||
|
# 用户编程题的信息
|
||||||
|
belongs_to :hack
|
||||||
|
end
|
@ -0,0 +1,4 @@
|
|||||||
|
class HackUserDebug < ApplicationRecord
|
||||||
|
belongs_to :hack
|
||||||
|
belongs_to :hack_user_lastest_code
|
||||||
|
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue