实训预备知识独立数据迁移及数据读取处理

This commit is contained in:
huang 2017-05-18 14:50:39 +08:00
parent aa0ed21b8c
commit 8dd6b6ffe4
4 changed files with 15 additions and 2 deletions

View File

@ -33,6 +33,7 @@ class GamesController < ApplicationController
# logger.info("#################%%%%%%#{@game.outputs.first.out_put}")
# @games = @myshixun.games.includes(:challenge)
@challenges = Challenge.where(:shixun_id => @myshixun.shixun_id)
@shixun = @myshixun.shixun
# @games_count = @games.count
@game_challenge = @game.challenge
@had_done = @game.had_done

View File

@ -300,7 +300,7 @@ class ShixunsController < ApplicationController
CODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
def copy_myshixun shixun, gshixun
myshixun = Myshixun.new
myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier")
myshixun.attributes = shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier","propaedeutics")
myshixun.shixun_id = shixun.id
myshixun.user_id = User.current.id
myshixun.gpid = gshixun.id

View File

@ -38,7 +38,7 @@
<div class="fit -scroll">
<div class="-layout-v -fit">
<div class="-flex -scroll task-padding16 panel-box-sizing new_li" id="game_ready_knowledge">
<textarea style="display:none;"><%= @game_challenge.ready_knowledge %></textarea>
<textarea style="display:none;"><%= @shixun.propaedeutics %></textarea>
</div>
</div>
</div>

View File

@ -0,0 +1,12 @@
class SyncPropaedeuticsToShixuns < ActiveRecord::Migration
def up
change_column :challenges, :ready_knowledge, :longtext
Shixun.all.each do |shixun|
ready_knowledge = shixun.challenges.first.try(:ready_knowledge)
shixun.update_attribute(:propaedeutics, ready_knowledge)
end
end
def down
end
end