From 3c5807343df5777a6f4a45d839298c916945141e Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 31 Mar 2017 10:07:08 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E8=AE=AD=E6=96=B0=E5=BB=BA=E5=8F=8A?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=9A=84=E6=97=B6=E5=80=99=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E8=AF=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 ++ app/models/shixun.rb | 2 +- app/views/games/_games_list.html.erb | 2 +- app/views/shixuns/_form.html.erb | 4 ++++ app/views/shixuns/_settings_edit.html.erb | 4 ++++ .../20170331013652_add_language_to_shixuns.rb | 5 +++++ db/schema.rb | 17 +++++++++-------- public/stylesheets/css/common.css | 2 +- 8 files changed, 27 insertions(+), 11 deletions(-) create mode 100644 db/migrate/20170331013652_add_language_to_shixuns.rb diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index e680065fd..0b2756afe 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -70,6 +70,7 @@ class ShixunsController < ApplicationController def create @shixun = Shixun.new(params[:shixun]) @shixun.user_id = User.current.id + @shixun.language = params[:language] (params[:shixun][:is_public] == "1" ? @shixun.is_public = true : @shixun.is_public = false) respond_to do |format| if @shixun.save @@ -96,6 +97,7 @@ class ShixunsController < ApplicationController def update @shixun.attributes = params[:shixun] + @shixun.language = params[:language] params[:shixun][:is_public] == "on" ? @shixun.is_public = 1 : @shixun.is_public = 0 @shixun.save respond_to do |format| diff --git a/app/models/shixun.rb b/app/models/shixun.rb index 87cb79151..5ab4e4b99 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -1,6 +1,6 @@ # status 控制实训的状态,0:未开启;1: 已开启(TPM) class Shixun < ActiveRecord::Base - attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid + attr_accessible :description, :is_public, :name, :changeset_num, :status, :user_id, :gpid, :language has_many :users, :through => :shixun_members has_many :shixun_members diff --git a/app/views/games/_games_list.html.erb b/app/views/games/_games_list.html.erb index c663c77d4..a7a980b0b 100644 --- a/app/views/games/_games_list.html.erb +++ b/app/views/games/_games_list.html.erb @@ -11,7 +11,7 @@

第<%= game.challenge.try(:position) %>关 <%= link_to game.challenge.try(:subject), myshixun_game_path(game, :myshixun_id => @myshixun), :remote => true %>

- 已闯关:<%#= had_pass(@myshixun) %>人 + 已闯关:<%= had_pass(@myshixun) %>人 平均耗时:0小时28分

diff --git a/app/views/shixuns/_form.html.erb b/app/views/shixuns/_form.html.erb index 078d56c26..020d12da2 100644 --- a/app/views/shixuns/_form.html.erb +++ b/app/views/shixuns/_form.html.erb @@ -31,6 +31,10 @@ %>
+
  • + + <%= select_tag :language, options_for_select(["Java","C","C++","Python","Ruby"], "Java"), :id => 'shixun[language]', :class => "ml5", :style => "height: 28px;" %> +
  • <%= f.text_field :is_public, :id => "project_is_public", :name => "shixun[is_public]", :type => "checkbox", :value => "1", :checked => "checked" %> diff --git a/app/views/shixuns/_settings_edit.html.erb b/app/views/shixuns/_settings_edit.html.erb index 70cec3aa2..3f0018610 100644 --- a/app/views/shixuns/_settings_edit.html.erb +++ b/app/views/shixuns/_settings_edit.html.erb @@ -23,6 +23,10 @@ :maxlength => 5000 } %>
  • +
  • + + <%= select_tag :language, options_for_select(["Java","C","C++","Python","Ruby"], @shixun.language), :id => 'shixun[language]', :style => "height: 28px;" %> +
  • class="fl mt15 mr10" name="shixun[is_public]" /> diff --git a/db/migrate/20170331013652_add_language_to_shixuns.rb b/db/migrate/20170331013652_add_language_to_shixuns.rb new file mode 100644 index 000000000..c71b5ab4b --- /dev/null +++ b/db/migrate/20170331013652_add_language_to_shixuns.rb @@ -0,0 +1,5 @@ +class AddLanguageToShixuns < ActiveRecord::Migration + def change + add_column :shixuns, :language, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index bf20d13f5..a45e6c0d1 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20170328082148) do +ActiveRecord::Schema.define(:version => 20170331013652) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -350,15 +350,15 @@ ActiveRecord::Schema.define(:version => 20170328082148) do t.string "subject" t.text "description" t.integer "user_id" - t.integer "status", :limit => 1, :default => 0 - t.integer "position", :limit => 1, :default => 1 - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "status", :limit => 1, :default => 0 + t.integer "position", :limit => 1, :default => 1 + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.text "ready_knowledge" - t.text "task_pass" - t.text "answer" + t.text "task_pass", :limit => 2147483647 + t.text "answer", :limit => 2147483647 t.integer "score" - t.integer "visits", :default => 0 + t.integer "visits", :default => 0 t.string "path" end @@ -2147,6 +2147,7 @@ ActiveRecord::Schema.define(:version => 20170328082148) do t.text "task_pass" t.text "answer" t.integer "score" + t.string "language" end create_table "softapplications", :force => true do |t| diff --git a/public/stylesheets/css/common.css b/public/stylesheets/css/common.css index eddbb65a2..4a910aaed 100644 --- a/public/stylesheets/css/common.css +++ b/public/stylesheets/css/common.css @@ -89,7 +89,7 @@ h4{ font-size:14px;}/*color:#3b3b3b;*/ .ml10{ margin-left:10px;}.ml14{ margin-left:14px;}.ml15{ margin-left:15px;}.ml16{ margin-left:16px;}.ml20{ margin-left:20px;}.ml21{ margin-left:21px;} .ml24{margin-left:24px;}.ml25{margin-left:25px;}.ml30{margin-left:30px !important;}.ml35{margin-left: 35px;}.ml36{ margin-left:36px; }.ml38{ margin-left:38px;} .ml39{ margin-left:39px;}.ml40{ margin-left:40px;}.ml41{ margin-left:41px;}.ml42{ margin-left:42px;}.ml45{ margin-left:45px;}.ml48{ margin-left:48px;}.ml50{ margin-left: 50px;} -.ml53{margin-left:53px;}.ml55{ margin-left:55px;}.ml56{ margin-left:56px !important;}.ml58{margin-left:58px;}.ml60{ margin-left:60px;}.ml65{ margin-left:65px;} +.ml53{margin-left:53px;}.ml55{ margin-left:55px;}.ml56{ margin-left:56px !important;}.ml58{margin-left:58px;}.ml60{ margin-left:60px;}.ml65{ margin-left:65px;}.ml63{ margin-left:63px;} .ml70{margin-left: 70px;}.ml78{ margin-left:78px;}.ml80{ margin-left:80px;}.ml85{margin-left:85px;}.ml90{ margin-left:90px;}.ml95{margin-left:95px;}.ml100{ margin-left:100px;} .ml110{ margin-left:110px;}.ml125 { margin-left:125px;}.ml130 { margin-left:130px;}.ml140 { margin-left:140px;}.ml150 { margin-left:150px;} .ml160 {margin-left:160px;}.ml250 {margin-left:250px;}.ml258{ margin-left:258px;}.ml320{ margin-left:320px;}.ml358{ margin-left:358px;}.mr-5 {margin-right:-5px;}