@ -15,7 +15,7 @@ class BidsController < ApplicationController
before_filter :can_show_contest , only : [ ]
before_filter :can_show_contest , only : [ ]
#Ended by young
#Ended by young
before_filter :find_bid , :only = > [ :show , :show_project , :create , :destroy , :more , :back , :add , :delete , :new , :show_results , :set_reward , :add_homework , :fork , :create_fork ,
before_filter :find_bid , :only = > [ :show , :show_project , :create , :destroy , :more , :back , :add , :delete , :new , :show_results , :set_reward , :add_homework , :fork , :create_fork ,
:show_course , :show_courseEx , :show_bid_project , :show_bid_user , :join_in_contest , :unjoin_in_contest , :new_join , :show_participator , :settings ]
:show_course , :show_courseEx , :show_bid_project , :show_bid_user , :join_in_contest , :unjoin_in_contest , :new_join , :show_participator , :settings ]
# added by fq
# added by fq
before_filter :require_login , :only = > [ :join_in_contest , :unjoin_in_contest ]
before_filter :require_login , :only = > [ :join_in_contest , :unjoin_in_contest ]
# end
# end
@ -48,7 +48,7 @@ class BidsController < ApplicationController
format . js
format . js
end
end
end
end
def index
def index
@project_type = params [ :project_type ]
@project_type = params [ :project_type ]
@ -57,8 +57,8 @@ class BidsController < ApplicationController
@offset , @limit = api_offset_and_limit ( { :limit = > 10 } )
@offset , @limit = api_offset_and_limit ( { :limit = > 10 } )
if @project_type == '1'
if @project_type == '1'
@bids = Bid . visible . where ( 'reward_type = ?' , 3 )
@bids = Bid . visible . where ( 'reward_type = ?' , 3 )
# elsif
# elsif
# @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
# @bids = Bid.visible.where('reward_type = ? or reward_type = ?', 4)
else
else
@bids = Bid . visible . where ( 'reward_type = ?' , 1 )
@bids = Bid . visible . where ( 'reward_type = ?' , 1 )
end
end
@ -71,33 +71,33 @@ class BidsController < ApplicationController
#added by nie
#added by nie
if params [ :bid_sort_type ] . present?
if params [ :bid_sort_type ] . present?
case params [ :bid_sort_type ]
case params [ :bid_sort_type ]
when '0'
when '0'
unless @offset == 0
unless @offset == 0
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
else
else
limit = @bid_count % @limit
limit = @bid_count % @limit
limit = @limit if limit == 0
limit = @limit if limit == 0
@bids = @bids . offset ( @offset ) . limit ( limit ) . all . reverse
@bids = @bids . offset ( @offset ) . limit ( limit ) . all . reverse
end
end
@s_state = 0
@s_state = 0
when '1'
when '1'
unless @offset == 0
unless @offset == 0
@bids = @bids . reorder ( 'bids.commit' ) . offset ( @offset ) . limit ( @limit ) . all . reverse
@bids = @bids . reorder ( 'bids.commit' ) . offset ( @offset ) . limit ( @limit ) . all . reverse
else
else
limit = @bid_count % @limit
limit = @bid_count % @limit
limit = @limit if limit == 0
limit = @limit if limit == 0
@bids = @bids . reorder ( 'bids.commit' ) . offset ( @offset ) . limit ( limit ) . all . reverse
@bids = @bids . reorder ( 'bids.commit' ) . offset ( @offset ) . limit ( limit ) . all . reverse
end
end
@s_state = 1
@s_state = 1
when '2'
when '2'
unless @offset == 0
unless @offset == 0
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
else
else
limit = @bid_count % @limit
limit = @bid_count % @limit
limit = @limit if limit == 0
limit = @limit if limit == 0
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
end
end
@s_state = 0
@s_state = 0
end
end
else
else
unless @offset == 0
unless @offset == 0
@ -109,7 +109,7 @@ class BidsController < ApplicationController
end
end
@s_state = 1
@s_state = 1
end
end
#end
#end
end
end
#huang
#huang
def contest
def contest
@ -130,33 +130,33 @@ class BidsController < ApplicationController
#added by nie
#added by nie
if params [ :contest_sort_type ] . present?
if params [ :contest_sort_type ] . present?
case params [ :contest_sort_type ]
case params [ :contest_sort_type ]
when '0'
when '0'
unless @offset == 0
unless @offset == 0
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
else
else
limit = @bid_count % @limit
limit = @bid_count % @limit
limit = @limit if limit == 0
limit = @limit if limit == 0
@bids = @bids . offset ( @offset ) . limit ( limit ) . all . reverse
@bids = @bids . offset ( @offset ) . limit ( limit ) . all . reverse
end
end
@s_state = 0
@s_state = 0
when '1'
when '1'
unless @offset == 0
unless @offset == 0
@bids = @bids . reorder ( 'bids.commit' ) . offset ( @offset ) . limit ( @limit ) . all . reverse
@bids = @bids . reorder ( 'bids.commit' ) . offset ( @offset ) . limit ( @limit ) . all . reverse
else
else
limit = @bid_count % @limit
limit = @bid_count % @limit
limit = @limit if limit == 0
limit = @limit if limit == 0
@bids = @bids . reorder ( 'bids.commit' ) . offset ( @offset ) . limit ( limit ) . all . reverse
@bids = @bids . reorder ( 'bids.commit' ) . offset ( @offset ) . limit ( limit ) . all . reverse
end
end
@s_state = 1
@s_state = 1
when '2'
when '2'
unless @offset == 0
unless @offset == 0
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
else
else
limit = @bid_count % @limit
limit = @bid_count % @limit
limit = @limit if limit == 0
limit = @limit if limit == 0
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
@bids = @bids . offset ( @offset ) . limit ( @limit ) . all . reverse
end
end
@s_state = 0
@s_state = 0
end
end
else
else
unless @offset == 0
unless @offset == 0
@ -168,7 +168,7 @@ class BidsController < ApplicationController
end
end
@s_state = 1
@s_state = 1
end
end
#end
#end
end
end
def fork
def fork
@ -176,7 +176,7 @@ class BidsController < ApplicationController
@membership = User . current . memberships . all ( :conditions = > Project . visible_condition ( User . current ) )
@membership = User . current . memberships . all ( :conditions = > Project . visible_condition ( User . current ) )
@membership . each do | membership |
@membership . each do | membership |
if membership . project . project_type == 1
if membership . project . project_type == 1
@courses << membership . project
@courses << membership . project
end
end
end
end
end
end
@ -229,12 +229,12 @@ class BidsController < ApplicationController
layout_file = ''
layout_file = ''
case @bid . reward_type
case @bid . reward_type
when 3
when 3
html_title ( l ( :label_question_student ) )
html_title ( l ( :label_question_student ) )
layout_file = 'base_courses '
layout_file = 'base_homework '
when 1
when 1
layout_file = 'base_bids'
layout_file = 'base_bids'
else
else
layout_file = 'base_contest'
layout_file = 'base_contest'
end
end
format . html {
format . html {
render :layout = > layout_file
render :layout = > layout_file
@ -242,7 +242,7 @@ class BidsController < ApplicationController
format . api
format . api
end
end
end
end
def join_in_contest
def join_in_contest
if @bid . reward_type == 2 && params [ :course_password ] == @bid . password
if @bid . reward_type == 2 && params [ :course_password ] == @bid . password
JoinInContest . create ( :user_id = > User . current . id , :bid_id = > @bid . id )
JoinInContest . create ( :user_id = > User . current . id , :bid_id = > @bid . id )
@ -250,49 +250,49 @@ class BidsController < ApplicationController
else
else
@state = 1
@state = 1
end
end
respond_to do | format |
respond_to do | format |
# format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
# format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
# TO_DO
# TO_DO
format . js { render :partial = > 'set_join' , :locals = > { :user = > User . current , :object_id = > params [ :id ] } }
format . js { render :partial = > 'set_join' , :locals = > { :user = > User . current , :object_id = > params [ :id ] } }
end
end
end
end
def unjoin_in_contest
def unjoin_in_contest
joined = JoinInContest . where ( 'bid_id = ? and user_id = ?' , @bid . id , User . current . id )
joined = JoinInContest . where ( 'bid_id = ? and user_id = ?' , @bid . id , User . current . id )
joined . each do | join |
joined . each do | join |
join . delete
join . delete
end
end
respond_to do | format |
respond_to do | format |
# format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
# format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
format . js { render :partial = > 'set_join' , :locals = > { :user = > User . current , :object_id = > params [ :id ] } }
format . js { render :partial = > 'set_join' , :locals = > { :user = > User . current , :object_id = > params [ :id ] } }
end
end
end
end
def new_join
def new_join
# added by fq
# added by fq
end
end
# added by bai 增加了参与者和竞赛设置
# added by bai 增加了参与者和竞赛设置
def show_participator
def show_participator
render :layout = > 'base_contest'
render :layout = > 'base_contest'
end
end
def settings
def settings
if @bid . author . id == User . current . id
if @bid . author . id == User . current . id
if @bid . reward_type == 2
if @bid . reward_type == 2
@contest = Bid . find_by_reward_type ( @bid . reward_type )
@contest = Bid . find_by_reward_type ( @bid . reward_type )
render :layout = > 'base_contest'
render :layout = > 'base_contest'
end
end
else
else
render_403 :message = > :notice_not_contest_setting_authorized
render_403 :message = > :notice_not_contest_setting_authorized
end
end
end
end
#end
#end
@ -307,16 +307,16 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
if @bid . reward_type == 3
if @bid . reward_type == 3
format . html {
format . html {
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
}
}
elsif @bid . reward_type == 1
elsif @bid . reward_type == 1
format . html {
format . html {
render :layout = > 'base_bids'
render :layout = > 'base_bids'
}
}
else
else
format . html {
format . html {
render :layout = > 'base_contest'
render :layout = > 'base_contest'
}
}
end
end
format . api
format . api
@ -333,16 +333,16 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
if @bid . reward_type == 3
if @bid . reward_type == 3
format . html {
format . html {
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
}
}
elsif @bid . reward_type == 1
elsif @bid . reward_type == 1
format . html {
format . html {
render :layout = > 'base_bids'
render :layout = > 'base_bids'
}
}
else
else
format . html {
format . html {
render :layout = > 'base_contest'
render :layout = > 'base_contest'
}
}
end
end
format . api
format . api
@ -361,16 +361,16 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
if @bid . reward_type == 3
if @bid . reward_type == 3
format . html {
format . html {
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
}
}
elsif @bid . reward_type == 1
elsif @bid . reward_type == 1
format . html {
format . html {
render :layout = > 'base_bids'
render :layout = > 'base_bids'
}
}
else
else
format . html {
format . html {
render :layout = > 'base_contest'
render :layout = > 'base_contest'
}
}
end
end
format . api
format . api
@ -439,7 +439,7 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
if @bid . reward_type == 3
if @bid . reward_type == 3
format . html {
format . html {
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
}
}
elsif @bid . reward_type == 1
elsif @bid . reward_type == 1
format . html {
format . html {
@ -533,7 +533,7 @@ class BidsController < ApplicationController
if @bid . reward_type == 3
if @bid . reward_type == 3
format . html {
format . html {
html_title ( l ( :label_homework_info ) )
html_title ( l ( :label_homework_info ) )
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
}
}
elsif @bid . reward_type == 1
elsif @bid . reward_type == 1
format . html {
format . html {
@ -565,16 +565,16 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
if @bid . reward_type == 3
if @bid . reward_type == 3
format . html {
format . html {
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
}
}
elsif @bid . reward_type == 1
elsif @bid . reward_type == 1
format . html {
format . html {
render :layout = > 'base_bids'
render :layout = > 'base_bids'
}
}
else
else
format . html {
format . html {
render :layout = > 'base_contest'
render :layout = > 'base_contest'
}
}
end
end
format . api
format . api
end
end
@ -586,19 +586,19 @@ class BidsController < ApplicationController
bid_message = params [ :bid_for_save ] [ :bid_message ]
bid_message = params [ :bid_for_save ] [ :bid_message ]
if BidingProject . where ( " project_id = ? and bid_id = ? " , project . id , @bid . id ) . size == 0
if BidingProject . where ( " project_id = ? and bid_id = ? " , project . id , @bid . id ) . size == 0
if BidingProject . cerate_bidding ( @bid . id , project . id , bid_message )
if BidingProject . cerate_bidding ( @bid . id , project . id , bid_message )
# added by bai type ==1 需求, type==2 竞赛, type==3 作业
# added by bai type ==1 需求, type==2 竞赛, type==3 作业
if @bid . reward_type == 1
if @bid . reward_type == 1
flash . now [ :notice ] = l ( :label_bidding_succeed )
flash . now [ :notice ] = l ( :label_bidding_succeed )
elsif @bid . reward_type == 2
elsif @bid . reward_type == 2
flash . now [ :notice ] = l ( :label_bidding_contest_succeed )
flash . now [ :notice ] = l ( :label_bidding_contest_succeed )
else @bid . reward_type == 3
else @bid . reward_type == 3
flash . now [ :notice ] = l ( :label_bidding_homework_succeed )
flash . now [ :notice ] = l ( :label_bidding_homework_succeed )
end
end
# end
# end
end
end
else
else
if @bid . reward_type == 3
if @bid . reward_type == 3
@ -609,11 +609,11 @@ class BidsController < ApplicationController
end
end
@bidding_project = @bid . biding_projects
@bidding_project = @bid . biding_projects
respond_to do | format |
respond_to do | format |
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
# format.html { redirect_to_referer_or {render :text => 'Watcher added.', :layout => true}}
# format.html
# format.html
format . html { redirect_to :back }
format . html { redirect_to :back }
format . js
format . js
#format.api { render_api_ok }
#format.api { render_api_ok }
end
end
end
end
@ -647,7 +647,7 @@ class BidsController < ApplicationController
@bid . set_commit ( @feedback_count )
@bid . set_commit ( @feedback_count )
respond_to do | format |
respond_to do | format |
format . js
format . js
#format.api { render_api_ok }
#format.api { render_api_ok }
end
end
end
end
@ -674,9 +674,9 @@ class BidsController < ApplicationController
# @message_count = a_message.count
# @message_count = a_message.count
respond_to do | format |
respond_to do | format |
# format.html
# format.html
format . js
format . js
#format.api { render_api_ok }
#format.api { render_api_ok }
end
end
end
end
@ -689,7 +689,7 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
format . html { redirect_to :back }
format . html { redirect_to :back }
format . js
format . js
#format.api { render_api_ok }
#format.api { render_api_ok }
end
end
end
end
@ -698,11 +698,11 @@ class BidsController < ApplicationController
def new
def new
@jour = JournalsForMessage . find ( params [ :journal_id ] ) if params [ :journal_id ]
@jour = JournalsForMessage . find ( params [ :journal_id ] ) if params [ :journal_id ]
if @jour
if @jour
user = @jour . user
user = @jour . user
text = @jour . notes
text = @jour . notes
else
else
user = @bid . author
user = @bid . author
text = @bid . description
text = @bid . description
end
end
# Replaces pre blocks with [...]
# Replaces pre blocks with [...]
text = text . to_s . strip . gsub ( %r{ <pre>((.| \ s)*?)</pre> }m , '[...]' )
text = text . to_s . strip . gsub ( %r{ <pre>((.| \ s)*?)</pre> }m , '[...]' )
@ -711,7 +711,7 @@ class BidsController < ApplicationController
@id = user . id
@id = user . id
rescue ActiveRecord :: RecordNotFound
rescue ActiveRecord :: RecordNotFound
render_404
render_404
end
end
##新建需求
##新建需求
def new_bid
def new_bid
@ -743,15 +743,15 @@ class BidsController < ApplicationController
end
end
end
end
# added by bai
# added by bai
def update_contest
def update_contest
@bid = Bid . find ( params [ :id ] )
@bid = Bid . find ( params [ :id ] )
@bid . name = params [ :bid ] [ :name ]
@bid . name = params [ :bid ] [ :name ]
@bid . description = params [ :bid ] [ :description ]
@bid . description = params [ :bid ] [ :description ]
@bid . reward_type = 2
@bid . reward_type = 2
@bid . budget = params [ :bid ] [ :budget ]
@bid . budget = params [ :bid ] [ :budget ]
@bid . deadline = params [ :bid ] [ :deadline ]
@bid . deadline = params [ :bid ] [ :deadline ]
@bid . password = params [ :bid ] [ :password ]
@bid . password = params [ :bid ] [ :password ]
@bid . author_id = User . current . id
@bid . author_id = User . current . id
@bid . commit = 0
@bid . commit = 0
if @bid . save
if @bid . save
@ -825,31 +825,31 @@ class BidsController < ApplicationController
@course = Course . find_by_id ( params [ :course_id ] )
@course = Course . find_by_id ( params [ :course_id ] )
@course_id = @course . id
@course_id = @course . id
#respond_to do |format|
#respond_to do |format|
# format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'}
# format.html { redirect_to new_homework_course_path(params[:course_id]),:layout => 'base_courses'}
# format.api { render_validation_errors(@bid) }
# format.api { render_validation_errors(@bid) }
#end
#end
render file : 'courses/new_homework' , layout : 'base_courses'
render file : 'courses/new_homework' , layout : 'base_courses'
end
end
end
end
# modify by nwb\
# modify by nwb\
# 编辑作业
# 编辑作业
def edit
def edit
@bid = Bid . find ( params [ :bid_id ] )
@bid = Bid . find ( params [ :bid_id ] )
if ( User . current . admin? || User . current . allowed_to? ( :as_teacher , @bid . courses . first ) )
if ( User . current . admin? || User . current . allowed_to? ( :as_teacher , @bid . courses . first ) )
@course_id = params [ :course_id ]
@course_id = params [ :course_id ]
respond_to do | format |
respond_to do | format |
format . html {
format . html {
@course = Course . find ( params [ :course_id ] )
@course = Course . find ( params [ :course_id ] )
@user = User . find ( User . current . id )
@user = User . find ( User . current . id )
render :layout = > 'base_courses'
render :layout = > 'base_courses'
}
}
end
end
else
else
render_403
render_403
end
end
end
end
def update
def update
@bid = Bid . find ( params [ :id ] )
@bid = Bid . find ( params [ :id ] )
@course = @bid . courses . first #Project.find(params[:course_id])
@course = @bid . courses . first #Project.find(params[:course_id])
@ -879,40 +879,40 @@ class BidsController < ApplicationController
#render html to prepare create submit homework
#render html to prepare create submit homework
find_bid
find_bid
find_bid
find_bid
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
end
end
def add_homework
def add_homework
if User . current . logged? && ( ! Member . where ( 'user_id = ? and project_id = ?' , User . current . id , @bid . courses . first . id ) . first . nil? && ( Member . where ( 'user_id = ? and project_id = ?' , User . current . id , @bid . courses . first . id ) . first . roles & Role . where ( 'id = ? or id = ? or id =?' , 5 , 10 , 7 ) ) . size > 0 )
if User . current . logged? && ( ! Member . where ( 'user_id = ? and project_id = ?' , User . current . id , @bid . courses . first . id ) . first . nil? && ( Member . where ( 'user_id = ? and project_id = ?' , User . current . id , @bid . courses . first . id ) . first . roles & Role . where ( 'id = ? or id = ? or id =?' , 5 , 10 , 7 ) ) . size > 0 )
# homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id)
# homework = HomeworkAttach.create(:bid_id => @bid.id, :user_id => User.current.id)
# homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
# homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
if hadcommittedhomework ( User . current . id , @bid . id ) == true
if hadcommittedhomework ( User . current . id , @bid . id ) == true
@homework_flag = l ( :label_bidding_homework_committed )
@homework_flag = l ( :label_bidding_homework_committed )
else
else
@homework = HomeworkAttach . new
@homework = HomeworkAttach . new
@homework . safe_attributes = params [ :homeworkattach ]
@homework . safe_attributes = params [ :homeworkattach ]
@homework . bid_id = @bid . id
@homework . bid_id = @bid . id
@homework . user_id = User . current . id
@homework . user_id = User . current . id
@homework . save_attachments ( params [ :attachments ] )
@homework . save_attachments ( params [ :attachments ] )
render_attachment_warning_if_needed ( @homework )
render_attachment_warning_if_needed ( @homework )
@homework_flag = if @homework . save
@homework_flag = if @homework . save
l ( :label_bidding_homework_succeed )
l ( :label_bidding_homework_succeed )
else
else
l ( :label_bidding_homework_failed )
l ( :label_bidding_homework_failed )
end
end
if @homework . attachments . empty?
if @homework . attachments . empty?
@homework . delete
@homework . delete
#flash[:error] = l(:no_attachmens_allowed)
#flash[:error] = l(:no_attachmens_allowed)
@homework_flag = l ( :no_attachmens_allowed )
@homework_flag = l ( :no_attachmens_allowed )
# else
# else
end
end
end
end
end
end
@homework_list = @bid . homeworks
@homework_list = @bid . homeworks
respond_to do | format |
respond_to do | format |
format . html {
format . html {
@ -931,7 +931,7 @@ class BidsController < ApplicationController
@member = [ ]
@member = [ ]
@course . memberships . each do | member |
@course . memberships . each do | member |
unless ( member . roles && Role . where ( 'id = ? ' , 3 ) ) . empty?
unless ( member . roles && Role . where ( 'id = ? ' , 3 ) ) . empty?
@member . push member
@member . push member
end
end
end
end
if @bid . homework_type = 1
if @bid . homework_type = 1
@ -942,12 +942,12 @@ class BidsController < ApplicationController
@homework_type = false
@homework_type = false
end
end
@user = @bid . author
@user = @bid . author
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
end
end
def homework_respond
def homework_respond
@user = @bid . author
@user = @bid . author
render :layout = > 'base_ courses '
render :layout = > 'base_ homework '
end
end
def more
def more
@ -958,7 +958,7 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
format . html { redirect_to :back }
format . html { redirect_to :back }
format . js
format . js
#format.api { render_api_ok }
#format.api { render_api_ok }
end
end
end
end
@ -970,7 +970,7 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
format . html { redirect_to :back }
format . html { redirect_to :back }
format . js
format . js
#format.api { render_api_ok }
#format.api { render_api_ok }
end
end
end
end
@ -999,7 +999,7 @@ class BidsController < ApplicationController
def manage
def manage
end
end
# 启动匿评
# 启动匿评
def start_anonymous_comment
def start_anonymous_comment
@bid = Bid . find ( params [ :id ] )
@bid = Bid . find ( params [ :id ] )
@ -1031,7 +1031,7 @@ class BidsController < ApplicationController
end
end
end
end
def stop_anonymous_comment
def stop_anonymous_comment
@bid = Bid . find ( params [ :id ] )
@bid = Bid . find ( params [ :id ] )
@bid . update_column ( 'comment_status' , 2 )
@bid . update_column ( 'comment_status' , 2 )
@ -1039,7 +1039,7 @@ class BidsController < ApplicationController
respond_to do | format |
respond_to do | format |
format . js
format . js
end
end
end
end
def alert_anonymous_comment
def alert_anonymous_comment
@bid = Bid . find params [ :id ]
@bid = Bid . find params [ :id ]
@ -1060,7 +1060,7 @@ class BidsController < ApplicationController
end
end
private
private
def get_assigned_homeworks ( homeworks , n , index )
def get_assigned_homeworks ( homeworks , n , index )
homeworks += homeworks
homeworks += homeworks
homeworks [ index + 1 .. index + n ]
homeworks [ index + 1 .. index + n ]
@ -1070,7 +1070,6 @@ class BidsController < ApplicationController
if params [ :id ]
if params [ :id ]
@bid = Bid . find ( params [ :id ] , :include = > [ { :homeworks = > :user } ] )
@bid = Bid . find ( params [ :id ] , :include = > [ { :homeworks = > :user } ] )
@user = @bid . author
@user = @bid . author
@course = @bid . courses . first
end
end
rescue
rescue
render_404
render_404