定义当前任务
This commit is contained in:
parent
b87f095556
commit
45911e770e
|
@ -27,7 +27,7 @@ class MyshixunsController < ApplicationController
|
|||
|
||||
def show
|
||||
respond_to do |format|
|
||||
format.html{redirect_to myshixun_games_path(@myshixun)}
|
||||
format.html{redirect_to myshixun_game_path(@myshixun.current_task, :myshixun_id => @myshixun)}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -5,6 +5,16 @@ class Myshixun < ActiveRecord::Base
|
|||
has_one :repository
|
||||
has_many :games, :dependent => :destroy, :order => "games.id ASC"
|
||||
|
||||
# 当前任务:一个实训中只可能一个未完成任务(status 0或1只会存在一条记录)
|
||||
# 优先取未完成的任务,如果任务都完成则取stage最大的任务(有下一步)
|
||||
def current_task
|
||||
games = self.games
|
||||
current_game = games.select{|game| game.status != 2}
|
||||
if undo_agame.blank?
|
||||
current_game = Game.find_by_sql("SELECT * FROM `games` where myshixun_id=#{self.id} and status = 2 order by stage desc;")
|
||||
end
|
||||
end
|
||||
|
||||
def parent
|
||||
Shixun.find(self.parent_id)
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
class ShixunTags < ActiveRecord::Base
|
||||
# attr_accessible :title, :body
|
||||
end
|
|
@ -25,7 +25,7 @@
|
|||
<div class="user-info">
|
||||
<%= link_to image_tag(url_to_avatar(@myshixun.owner), :width => "100", :height => "100"), user_path(@myshixun.owner), :alt => "用户头像", :class => "user-info-img" %>
|
||||
<!--<a href="#" class="user-info-img"><img src="images/user/male.jpg" width="100" height="" alt="100"></a>-->
|
||||
<a href="#" class="user-info-name">胡莎莎</a>
|
||||
<%= link_to @myshixun.owner.try(:show_name), user_path(@myshixun.owner), :class => "user-info-name" %>
|
||||
</div>
|
||||
<div class="leftnav">
|
||||
<ul>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class CreateShixunTags < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :shixun_tags do |t|
|
||||
t.string :name
|
||||
t.integer :game_id
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
44
db/schema.rb
44
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20170315103005) do
|
||||
ActiveRecord::Schema.define(:version => 20170316032420) do
|
||||
|
||||
create_table "activities", :force => true do |t|
|
||||
t.integer "act_id", :null => false
|
||||
|
@ -1144,8 +1144,8 @@ ActiveRecord::Schema.define(:version => 20170315103005) do
|
|||
t.string "name"
|
||||
t.integer "user_id"
|
||||
t.text "description"
|
||||
t.datetime "publish_time"
|
||||
t.datetime "end_time"
|
||||
t.date "publish_time"
|
||||
t.date "end_time"
|
||||
t.integer "homework_type", :default => 1
|
||||
t.string "late_penalty"
|
||||
t.integer "course_id"
|
||||
|
@ -1242,19 +1242,6 @@ ActiveRecord::Schema.define(:version => 20170315103005) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "ii", :force => true do |t|
|
||||
t.integer "project_id"
|
||||
t.string "author_login"
|
||||
t.string "rep_identifier"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "sonar_version", :default => 0
|
||||
t.string "path"
|
||||
t.string "branch"
|
||||
t.string "language"
|
||||
t.string "sonar_name"
|
||||
end
|
||||
|
||||
create_table "innodb_monitor", :id => false, :force => true do |t|
|
||||
t.integer "a"
|
||||
end
|
||||
|
@ -2121,21 +2108,32 @@ ActiveRecord::Schema.define(:version => 20170315103005) do
|
|||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "shixun_tags", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "game_id"
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
end
|
||||
|
||||
create_table "shixuns", :force => true do |t|
|
||||
t.string "name"
|
||||
t.text "description"
|
||||
t.text "script"
|
||||
t.boolean "is_public", :default => true
|
||||
t.boolean "is_public", :default => true
|
||||
t.integer "parent_id"
|
||||
t.integer "user_id"
|
||||
t.integer "gpid"
|
||||
t.integer "forked_count", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "forked_count", :default => 0
|
||||
t.integer "visits", :default => 0
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.integer "changeset_num"
|
||||
t.integer "forked_form"
|
||||
t.integer "status", :default => 0
|
||||
t.integer "status", :default => 0
|
||||
t.text "ready_knowledge"
|
||||
t.text "task_pass"
|
||||
t.text "answer"
|
||||
t.integer "score"
|
||||
end
|
||||
|
||||
create_table "softapplications", :force => true do |t|
|
||||
|
@ -2430,7 +2428,7 @@ ActiveRecord::Schema.define(:version => 20170315103005) do
|
|||
t.datetime "updated_at", :null => false
|
||||
t.integer "author_id"
|
||||
t.integer "status", :limit => 1, :default => 0
|
||||
t.integer "position", :limit => 1, :default => 0
|
||||
t.integer "position", :limit => 1
|
||||
t.integer "result", :default => 0
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
FactoryGirl.define do
|
||||
factory :shixun_tag, :class => 'ShixunTags' do
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
require 'rails_helper'
|
||||
|
||||
RSpec.describe ShixunTags, :type => :model do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
Loading…
Reference in New Issue