修改学生作业列表弹出框不正确

This commit is contained in:
sw 2015-03-23 20:36:52 +08:00
parent 221276ba1f
commit 584dcabeaa
3 changed files with 190 additions and 189 deletions

View File

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

View File

@ -1,5 +1,5 @@
class HomeworkAttachController < ApplicationController
layout "base_courses"
layout "course_base"
include CoursesHelper
include HomeworkAttachHelper
helper :words

View File

@ -44,11 +44,13 @@ a:hover.tb_all{ background:#eaeaea; text-decoration:none;}
.dis ul li.wping{margin-left:12px; }
.dis ul li.wping a{ margin-top:18px; margin-bottom:3px; width:43px; height:23px; background:#15bccf; color:#fff; text-align:center; padding-top:3px;}
.dis ul li.wping a:hover{ background-color:#03a1b3;}
/*ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; }*/
/*.wlist span{ border:1px solid #15bccf; padding:0 5px; margin-left:3px;}*/
/*.wlist a{ border:1px solid #15bccf; padding:0 5px; margin-left:3px;}*/
/*.wlist a:hover{ background:#15bccf; color:#fff; text-decoration:none;}*/
/*.wlist_select { background-color:#64bdd9; color:#fff; padding:0 5px; margin-left:3px; border:1px solid #64bdd9;}*/
/****翻页***/
ul.wlist{ float:right; border-bottom:none; height:30px; margin-top:20px; }
ul.wlist li{float: left;}
ul.wlist li a{ border:1px solid #15bccf; padding: 1px 4px 1px 4px; margin-left:3px;}
ul.wlist li a:hover{ background:#15bccf; color:#fff; text-decoration:none;}
.wlist_select { background-color:#64bdd9; color:#fff; padding: 1px 5px 0px 5px; margin-left:3px;margin-top: -2px; border:1px solid #64bdd9;}
.code_list{ float:right; font-size:12px; color:#484848; padding:5px 3px; border-bottom:2px solid #15bccf; width:687px; }
.code_list a{ color:#787878;}
.fr{ float:right;}