Merge branch 'CourseModify' into szzh
Conflicts: app/views/layouts/base_courses.html.erb app/views/layouts/base_homework.html.erb app/views/projects/_course.html.erb db/schema.rb lib/redmine/activity/fetcher.rb
This commit is contained in:
commit
7425178419
|
@ -0,0 +1,2 @@
|
||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,2 @@
|
||||||
|
// Place all the behaviors and hooks related to the matching controller here.
|
||||||
|
// All this logic will automatically be available in application.js.
|
|
@ -0,0 +1,4 @@
|
||||||
|
/*
|
||||||
|
Place all the styles related to the matching controller here.
|
||||||
|
They will automatically be included in application.css.
|
||||||
|
*/
|
|
@ -0,0 +1,4 @@
|
||||||
|
/*
|
||||||
|
Place all the styles related to the matching controller here.
|
||||||
|
They will automatically be included in application.css.
|
||||||
|
*/
|
|
@ -233,7 +233,15 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
# Authorize the user for the requested action
|
# Authorize the user for the requested action
|
||||||
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
def authorize(ctrl = params[:controller], action = params[:action], global = false)
|
||||||
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
#modify by NWB
|
||||||
|
if @project
|
||||||
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
||||||
|
elsif @course
|
||||||
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @courses, :global => global)
|
||||||
|
else
|
||||||
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @project || @projects, :global => global)
|
||||||
|
end
|
||||||
|
|
||||||
if allowed
|
if allowed
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
|
@ -245,6 +253,24 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def authorize_course(ctrl = params[:controller], action = params[:action], global = false)
|
||||||
|
allowed = User.current.allowed_to?({:controller => ctrl, :action => action}, @course || @course, :global => global)
|
||||||
|
if allowed
|
||||||
|
true
|
||||||
|
else
|
||||||
|
if @course && @course.archived?
|
||||||
|
render_403 :message => :notice_not_authorized_archived_project
|
||||||
|
else
|
||||||
|
deny_access
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def authorize_course_global(ctrl = params[:controller], action = params[:action], global = true)
|
||||||
|
authorize_course(ctrl, action, global)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# Authorize the user for the requested action outside a project
|
# Authorize the user for the requested action outside a project
|
||||||
def authorize_global(ctrl = params[:controller], action = params[:action], global = true)
|
def authorize_global(ctrl = params[:controller], action = params[:action], global = true)
|
||||||
authorize(ctrl, action, global)
|
authorize(ctrl, action, global)
|
||||||
|
@ -259,9 +285,13 @@ class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
# Find project of id params[:project_id]
|
# Find project of id params[:project_id]
|
||||||
def find_project_by_project_id
|
def find_project_by_project_id
|
||||||
@project = Project.find(params[:project_id])
|
if params[:project_id]
|
||||||
|
@project = Project.find(params[:project_id])
|
||||||
|
elsif params[:course_id]
|
||||||
|
@course = Course.find(params[:course_id])
|
||||||
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_contest_by_contest_id
|
def find_contest_by_contest_id
|
||||||
|
@ -301,6 +331,10 @@ class ApplicationController < ActionController::Base
|
||||||
render_404 unless @object.present?
|
render_404 unless @object.present?
|
||||||
|
|
||||||
@project = @object.project
|
@project = @object.project
|
||||||
|
if @project == nil && @object.has_attribute?('course_id')
|
||||||
|
@course = @object.course
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_contest_from_association
|
def find_contest_from_association
|
||||||
|
@ -319,6 +353,14 @@ class ApplicationController < ActionController::Base
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#added by nwb
|
||||||
|
#»ñÈ¡¿Î³Ì
|
||||||
|
def find_course
|
||||||
|
@course= Course.find(params[:id])
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
# def find_model_object_contest
|
# def find_model_object_contest
|
||||||
# model = self.class.model_object
|
# model = self.class.model_object
|
||||||
# if model
|
# if model
|
||||||
|
|
|
@ -126,10 +126,19 @@ class AttachmentsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
if @project.nil?
|
# modify by nwb
|
||||||
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum,@attachment.container) }
|
if @attachment.container_type == 'Course'
|
||||||
|
if @course.nil?
|
||||||
|
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||||
|
else
|
||||||
|
format.html { redirect_to_referer_or course_path(@course) }
|
||||||
|
end
|
||||||
else
|
else
|
||||||
format.html { redirect_to_referer_or project_path(@project)}
|
if @project.nil?
|
||||||
|
format.html { redirect_to_referer_or forum_memo_path(@attachment.container.forum, @attachment.container) }
|
||||||
|
else
|
||||||
|
format.html { redirect_to_referer_or project_path(@project) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
format.js
|
format.js
|
||||||
|
@ -192,9 +201,14 @@ private
|
||||||
def find_project
|
def find_project
|
||||||
@attachment = Attachment.find(params[:id])
|
@attachment = Attachment.find(params[:id])
|
||||||
# Show 404 if the filename in the url is wrong
|
# Show 404 if the filename in the url is wrong
|
||||||
|
# modify by nwb
|
||||||
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
raise ActiveRecord::RecordNotFound if params[:filename] && params[:filename] != @attachment.filename
|
||||||
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
|
if @attachment.container_type == 'Course'
|
||||||
@project = @attachment.project
|
@course = @attachment.course
|
||||||
|
else
|
||||||
|
unless @attachment.container_type == 'Bid' || @attachment.container_type == 'HomeworkAttach' || @attachment.container_type == 'Memo' || @attachment.container_type == 'Softapplication'
|
||||||
|
@project = @attachment.project
|
||||||
|
end
|
||||||
end
|
end
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
|
|
|
@ -8,7 +8,7 @@ class BidsController < ApplicationController
|
||||||
menu_item :homework_statistics, :only => :homework_statistics
|
menu_item :homework_statistics, :only => :homework_statistics
|
||||||
#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_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
|
||||||
|
@ -189,7 +189,7 @@ class BidsController < ApplicationController
|
||||||
@homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
|
@homework.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
|
||||||
# @bid.
|
# @bid.
|
||||||
if @homework.save
|
if @homework.save
|
||||||
HomeworkForCourse.create(:project_id => params[:course], :bid_id => @homework.id)
|
HomeworkForCourse.create(:course_id => params[:course], :bid_id => @homework.id)
|
||||||
unless @bid.watched_by?(User.current)
|
unless @bid.watched_by?(User.current)
|
||||||
if @bid.add_watcher(User.current)
|
if @bid.add_watcher(User.current)
|
||||||
flash[:notice] = l(:label_bid_succeed)
|
flash[:notice] = l(:label_bid_succeed)
|
||||||
|
@ -199,11 +199,9 @@ class BidsController < ApplicationController
|
||||||
else
|
else
|
||||||
@bid.safe_attributes = params[:bid]
|
@bid.safe_attributes = params[:bid]
|
||||||
@courses = []
|
@courses = []
|
||||||
@membership = User.current.memberships.all(:conditions => Project.visible_condition(User.current))
|
@membership = User.current.coursememberships.all#(:conditions => Project.visible_condition(User.current))
|
||||||
@membership.each do |membership|
|
@membership.each do |membership|
|
||||||
if membership.project.project_type == 1
|
@courses << membership.course
|
||||||
@courses << membership.project
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
render :action => 'fork'
|
render :action => 'fork'
|
||||||
end
|
end
|
||||||
|
@ -289,6 +287,7 @@ class BidsController < ApplicationController
|
||||||
end
|
end
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
# 显示课程
|
||||||
def show_course
|
def show_course
|
||||||
bids = Bid.where('parent_id = ?', @bid.id)
|
bids = Bid.where('parent_id = ?', @bid.id)
|
||||||
@courses = []
|
@courses = []
|
||||||
|
@ -377,7 +376,7 @@ class BidsController < ApplicationController
|
||||||
unless(membership.project.project_type==1)
|
unless(membership.project.project_type==1)
|
||||||
membership.member_roles.each{|role|
|
membership.member_roles.each{|role|
|
||||||
if(role.role_id == 3)
|
if(role.role_id == 3)
|
||||||
@option << membership.project
|
@option << membership.project
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -399,18 +398,18 @@ class BidsController < ApplicationController
|
||||||
end
|
end
|
||||||
@bidding_project = @temp
|
@bidding_project = @temp
|
||||||
else
|
else
|
||||||
#added by nie
|
#added by nie
|
||||||
@temp = []
|
@temp = []
|
||||||
@bidding_project.each do |pro|
|
@bidding_project.each do |pro|
|
||||||
if pro.project && pro.project.project_status
|
if pro.project && pro.project.project_status
|
||||||
@temp << pro
|
@temp << pro
|
||||||
|
end
|
||||||
|
@temp
|
||||||
end
|
end
|
||||||
@temp
|
if @temp.size > 0
|
||||||
end
|
|
||||||
if @temp.size > 0
|
|
||||||
@bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
@bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||||
end
|
end
|
||||||
#ended
|
#ended
|
||||||
end
|
end
|
||||||
|
|
||||||
if @bid.homework_type == 1
|
if @bid.homework_type == 1
|
||||||
|
@ -421,9 +420,9 @@ class BidsController < ApplicationController
|
||||||
if params[:student_id].present?
|
if params[:student_id].present?
|
||||||
@temp = []
|
@temp = []
|
||||||
@homework_list.each do |pro|
|
@homework_list.each do |pro|
|
||||||
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||||
@temp << pro
|
@temp << pro
|
||||||
end
|
end
|
||||||
@temp
|
@temp
|
||||||
end
|
end
|
||||||
@homework_list = @temp
|
@homework_list = @temp
|
||||||
|
@ -432,17 +431,95 @@ 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_homework'
|
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
|
||||||
|
format.api
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 显示作业课程
|
||||||
|
# add by nwb
|
||||||
|
def show_courseEx
|
||||||
|
# flash[:notice] = ""
|
||||||
|
@membership = User.current.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||||
|
@option = []
|
||||||
|
@membership.each do |membership|
|
||||||
|
membership.member_roles.each{|role|
|
||||||
|
if(role.role_id == 3)
|
||||||
|
@option << membership.course
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
@user = @bid.author
|
||||||
|
@bidding_project = @bid.biding_projects.all
|
||||||
|
|
||||||
|
if params[:student_id].present?
|
||||||
|
@temp = []
|
||||||
|
@bidding_project.each do |pro|
|
||||||
|
if pro.project && pro.project.project_status
|
||||||
|
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||||
|
@temp << pro
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@temp
|
||||||
|
end
|
||||||
|
@bidding_project = @temp
|
||||||
|
else
|
||||||
|
#added by nie
|
||||||
|
@temp = []
|
||||||
|
@bidding_project.each do |pro|
|
||||||
|
if pro.project && pro.project.project_status
|
||||||
|
@temp << pro
|
||||||
|
end
|
||||||
|
@temp
|
||||||
|
end
|
||||||
|
if @temp.size > 0
|
||||||
|
@bidding_project = @temp.sort {|a,b| b.project.project_status.grade <=> a.project.project_status.grade}
|
||||||
|
end
|
||||||
|
#ended
|
||||||
|
end
|
||||||
|
|
||||||
|
if @bid.homework_type == 1
|
||||||
|
@homework = HomeworkAttach.new
|
||||||
|
#@homework_list = @bid.homeworks
|
||||||
|
#增加作业按评分排序,
|
||||||
|
@homework_list = @bid.homeworks.eager_load(:rate_averages, :user, :attachments).order('seems_rateable_cached_ratings.avg DESC').order("#{HomeworkAttach.table_name}.created_at ASC")
|
||||||
|
if params[:student_id].present?
|
||||||
|
@temp = []
|
||||||
|
@homework_list.each do |pro|
|
||||||
|
if /#{params[:student_id]}/ =~ pro.user.user_extensions.student_id
|
||||||
|
@temp << pro
|
||||||
|
end
|
||||||
|
@temp
|
||||||
|
end
|
||||||
|
@homework_list = @temp
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @bid.reward_type == 3
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base_homework'
|
||||||
|
}
|
||||||
|
elsif @bid.reward_type == 1
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base_bids'
|
||||||
|
}
|
||||||
|
else
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base_contest'
|
||||||
|
}
|
||||||
end
|
end
|
||||||
format.api
|
format.api
|
||||||
end
|
end
|
||||||
|
@ -711,7 +788,7 @@ class BidsController < ApplicationController
|
||||||
@bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
|
@bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
|
||||||
# @bid.
|
# @bid.
|
||||||
if @bid.save
|
if @bid.save
|
||||||
HomeworkForCourse.create(:project_id => params[:course_id], :bid_id => @bid.id)
|
HomeworkForCourse.create(:course_id => params[:course_id], :bid_id => @bid.id)
|
||||||
unless @bid.watched_by?(User.current)
|
unless @bid.watched_by?(User.current)
|
||||||
if @bid.add_watcher(User.current)
|
if @bid.add_watcher(User.current)
|
||||||
flash[:notice] = l(:label_bid_succeed)
|
flash[:notice] = l(:label_bid_succeed)
|
||||||
|
@ -721,19 +798,21 @@ class BidsController < ApplicationController
|
||||||
else
|
else
|
||||||
@bid.safe_attributes = params[:bid]
|
@bid.safe_attributes = params[:bid]
|
||||||
@homework = @bid
|
@homework = @bid
|
||||||
@project = Project.find_by_id(params[:course_id])
|
@course = Course.find_by_id(params[:course_id])
|
||||||
@project_id = @project.id
|
@course_id = @course.id
|
||||||
render file: 'projects/new_homework', layout: 'base_courses'
|
render file: 'courses/new_homework', layout: 'base_courses'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 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.id==@bid.author_id)
|
if (User.current.admin?||User.current.id==@bid.author_id)
|
||||||
@project_id = params[:project_id]
|
@course_id = params[:course_id]
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html {
|
format.html {
|
||||||
@project = Project.find(params[:project_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'
|
||||||
}
|
}
|
||||||
|
@ -745,11 +824,11 @@ class BidsController < ApplicationController
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@bid = Bid.find(params[:id])
|
@bid = Bid.find(params[:id])
|
||||||
@project = @bid.courses.first#Project.find(params[:course_id])
|
@course = @bid.courses.first#Project.find(params[:course_id])
|
||||||
@bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
|
@bid.save_attachments(params[:attachments] || (params[:bid] && params[:bid][:uploads]))
|
||||||
if @bid.update_attributes(params[:bid]) && @bid.save
|
if @bid.update_attributes(params[:bid]) && @bid.save
|
||||||
flash[:notice] = l(:label_update_homework_succeed)
|
flash[:notice] = l(:label_update_homework_succeed)
|
||||||
redirect_to project_homework_path(@project)
|
redirect_to course_homework_path(@course)
|
||||||
else
|
else
|
||||||
@bid.safe_attributes = params[:bid]
|
@bid.safe_attributes = params[:bid]
|
||||||
render :action => 'edit', :layout =>'base_courses'
|
render :action => 'edit', :layout =>'base_courses'
|
||||||
|
@ -894,9 +973,9 @@ class BidsController < ApplicationController
|
||||||
def memberAccess
|
def memberAccess
|
||||||
# 是课程,则判断当前用户是否参加了课程
|
# 是课程,则判断当前用户是否参加了课程
|
||||||
return true if current_user.admin?
|
return true if current_user.admin?
|
||||||
return 0 if @bid.courses.first.project_type == Project::ProjectType_project
|
#return 0 if @bid.courses.first.project_type == Project::ProjectType_project
|
||||||
currentUser = User.current
|
currentUser = User.current
|
||||||
render_403 unless currentUser.member_of?(@bid.courses.first)
|
render_403 unless currentUser.member_of_cousrse?(@bid.courses.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,17 +28,25 @@ class BoardsController < ApplicationController
|
||||||
helper :watchers
|
helper :watchers
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@boards = @project.boards.includes(:last_message => :author).all
|
#modify by nwb
|
||||||
@boards = [] << @boards[0] if @boards.any?
|
if @project
|
||||||
if @boards.size == 1
|
@boards = @project.boards.includes(:last_message => :author).all
|
||||||
@board = @boards.first
|
@boards = [] << @boards[0] if @boards.any?
|
||||||
show and return
|
if @boards.size == 1
|
||||||
end
|
@board = @boards.first
|
||||||
if @project.project_type == 1
|
show and return
|
||||||
render :layout => 'base_courses'
|
end
|
||||||
else
|
render :layout => false if request.xhr?
|
||||||
render :layout => false if request.xhr?
|
elsif @course
|
||||||
|
@boards = @course.boards.includes(:last_message => :author).all
|
||||||
|
@boards = [] << @boards[0] if @boards.any?
|
||||||
|
if @boards.size == 1
|
||||||
|
@board = @boards.first
|
||||||
|
show and return
|
||||||
|
end
|
||||||
|
render :layout => 'base_courses'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
@ -60,10 +68,11 @@ class BoardsController < ApplicationController
|
||||||
preload(:author, {:last_reply => :author}).
|
preload(:author, {:last_reply => :author}).
|
||||||
all
|
all
|
||||||
@message = Message.new(:board => @board)
|
@message = Message.new(:board => @board)
|
||||||
if @project.project_type ==1
|
#modify by nwb
|
||||||
render :action => 'show', :layout => 'base_courses'
|
if @project
|
||||||
else
|
|
||||||
render :action => 'show', :layout => !request.xhr?
|
render :action => 'show', :layout => !request.xhr?
|
||||||
|
elsif @course
|
||||||
|
render :action => 'show', :layout => 'base_courses'
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
format.atom {
|
format.atom {
|
||||||
|
@ -72,7 +81,12 @@ class BoardsController < ApplicationController
|
||||||
includes(:author, :board).
|
includes(:author, :board).
|
||||||
limit(Setting.feeds_limit.to_i).
|
limit(Setting.feeds_limit.to_i).
|
||||||
all
|
all
|
||||||
render_feed(@messages, :title => "#{@project}: #{@board}")
|
if @project
|
||||||
|
render_feed(@messages, :title => "#{@project}: #{@board}")
|
||||||
|
elsif @course
|
||||||
|
render_feed(@messages, :title => "#{@course}: #{@board}")
|
||||||
|
end
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -74,6 +74,25 @@ class ContestsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def homework
|
||||||
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
|
@bids = @course.homeworks.order('deadline DESC')
|
||||||
|
@bids = @bids.like(params[:name]) if params[:name].present?
|
||||||
|
@bid_count = @bids.count
|
||||||
|
@bid_pages = Paginator.new @bid_count, @limit, params['page']
|
||||||
|
|
||||||
|
@offset ||= @bid_pages.reverse_offset
|
||||||
|
unless @offset == 0
|
||||||
|
@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
||||||
|
else
|
||||||
|
limit = @bid_count % @limit
|
||||||
|
@bids = @bids.offset(@offset).limit(limit).all.reverse
|
||||||
|
end
|
||||||
|
render :layout => 'base_courses'
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def show_contest
|
def show_contest
|
||||||
@user = @contest.author
|
@user = @contest.author
|
||||||
@jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
@jours = @contest.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||||
|
|
|
@ -1,14 +1,27 @@
|
||||||
class CoursesController < ApplicationController
|
class CoursesController < ApplicationController
|
||||||
|
layout 'base_courses'
|
||||||
include CoursesHelper
|
include CoursesHelper
|
||||||
|
helper :activities
|
||||||
|
helper :members
|
||||||
|
helper :words
|
||||||
|
|
||||||
|
menu_item l(:label_sort_by_time), :only => :index
|
||||||
|
menu_item l(:label_sort_by_active), :only => :index
|
||||||
|
menu_item l(:label_sort_by_influence), :only => :index
|
||||||
|
|
||||||
|
before_filter :find_course, :except => [ :index, :search,:list, :new,:join,:unjoin, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise,:view_homework_attaches]
|
||||||
|
before_filter :authorize_course, :only => [:show, :settings, :edit, :update, :modules, :close, :reopen, :view_homework_attaches, :course]
|
||||||
|
before_filter :authorize_course_global, :only => [:view_homework_attaches, :new,:create]
|
||||||
|
before_filter :require_admin, :only => [:copy, :archive, :unarchive, :destroy, :calendar]
|
||||||
|
before_filter :toggleCourse, only: [:finishcourse, :restartcourse]
|
||||||
|
|
||||||
before_filter :require_login, :only => [:join, :unjoin]
|
before_filter :require_login, :only => [:join, :unjoin]
|
||||||
before_filter :allow_join, :only => [:join]
|
before_filter :allow_join, :only => [:join]
|
||||||
|
|
||||||
def join
|
def join
|
||||||
if User.current.logged?
|
if User.current.logged?
|
||||||
course = Project.find(params[:object_id])
|
course = Course.find(params[:object_id])
|
||||||
course_prefs = Course.find_by_extra(course.identifier)
|
if params[:course_password] == course.password
|
||||||
if params[:course_password] == course_prefs.password
|
|
||||||
members = []
|
members = []
|
||||||
members << Member.new(:role_ids => [10], :user_id => User.current.id)
|
members << Member.new(:role_ids => [10], :user_id => User.current.id)
|
||||||
course.members << members
|
course.members << members
|
||||||
|
@ -21,14 +34,14 @@ class CoursesController < ApplicationController
|
||||||
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, :course => Project.find(params[:object_id]), :object_id => params[:object_id]} }
|
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Course.find(params[:object_id]), :object_id => params[:object_id]} }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def unjoin
|
def unjoin
|
||||||
if User.current.logged?
|
if User.current.logged?
|
||||||
|
|
||||||
@member = Member.where('project_id = ? and user_id = ?', params[:object_id], User.current.id)
|
@member = Member.where('course_id = ? and user_id = ?', params[:object_id], User.current.id)
|
||||||
@member.first.destroy
|
@member.first.destroy
|
||||||
|
|
||||||
joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id])
|
joined = StudentsForCourse.where('student_id = ? and course_id = ?', User.current.id, params[:object_id])
|
||||||
|
@ -38,25 +51,642 @@ class CoursesController < ApplicationController
|
||||||
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, :course => Project.find(params[:object_id]), :object_id => params[:object_id]} }
|
format.js { render :partial => 'set_join', :locals => {:user => User.current, :course => Course.find(params[:object_id]), :object_id => params[:object_id]} }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#更新课程信息
|
||||||
|
def update
|
||||||
|
@course.safe_attributes = params[:course]
|
||||||
|
@course.class_period = params[:class_period]
|
||||||
|
if @course.save
|
||||||
|
if params[:course][:is_public] == '0'
|
||||||
|
course_status = CourseStatus.find_by_course_id(@course.id)
|
||||||
|
course_status.destroy if course_status
|
||||||
|
elsif params[:course][:is_public] == '1'
|
||||||
|
course_status = CourseStatus.find_by_course_id(@course.id)
|
||||||
|
course_status.destroy if course_status
|
||||||
|
course_status = CourseStatus.create(:course_id => @course.id, :grade => 0)
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_update)
|
||||||
|
redirect_to settings_course_path(@course)
|
||||||
|
}
|
||||||
|
format.api { render_api_ok }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
settings
|
||||||
|
render :action => 'settings'
|
||||||
|
}
|
||||||
|
format.api { render_validation_errors(@course) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_join
|
||||||
|
@course = Course.find(params[:object_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# 课程搜索
|
||||||
|
# add by nwb
|
||||||
|
def search
|
||||||
|
courses_all = Course.all_course
|
||||||
|
|
||||||
|
@courses = courses_all.visible
|
||||||
|
if params[:name].present?
|
||||||
|
@courses_all = @courses.like(params[:name])
|
||||||
|
else
|
||||||
|
@courses_all = @courses;
|
||||||
|
end
|
||||||
|
@course_count = @courses_all.count
|
||||||
|
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||||
|
|
||||||
|
# 课程的动态数
|
||||||
|
@course_activity_count=Hash.new
|
||||||
|
@courses_all.each do |course|
|
||||||
|
@course_activity_count[course.id]=0
|
||||||
|
end
|
||||||
|
|
||||||
|
case params[:course_sort_type]
|
||||||
|
when '0'
|
||||||
|
@courses = @courses_all.order("created_at desc")
|
||||||
|
@s_type = 0
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
|
|
||||||
|
when '1'
|
||||||
|
@courses = @courses_all.order("course_ac_para desc")
|
||||||
|
@s_type = 1
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
|
|
||||||
|
when '2'
|
||||||
|
@courses = @courses_all.order("watchers_count desc")
|
||||||
|
@s_type = 2
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
|
|
||||||
|
when '3'
|
||||||
|
@course_activity_count=get_course_activity @courses_all,@course_activity_count_array
|
||||||
|
@courses=handle_course @courses_all,@course_activity_count
|
||||||
|
@s_type = 3
|
||||||
|
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||||
|
|
||||||
|
else
|
||||||
|
@s_type = 0
|
||||||
|
@courses = @courses_all.order("created_at desc")
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base'
|
||||||
|
scope = Course
|
||||||
|
unless params[:closed]
|
||||||
|
scope = scope.active
|
||||||
|
end
|
||||||
|
}
|
||||||
|
format.atom {
|
||||||
|
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||||
|
render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def member
|
||||||
|
## 有角色参数的才是课程,没有的就是项目
|
||||||
|
@render_file = 'member_list'
|
||||||
|
@teachers= searchTeacherAndAssistant(@course)
|
||||||
|
@canShowCode = isCourseTeacher(User.current.id)
|
||||||
|
case params[:role]
|
||||||
|
when '1'
|
||||||
|
@subPage_title = l :label_teacher_list
|
||||||
|
@members = searchTeacherAndAssistant(@course)
|
||||||
|
when '2'
|
||||||
|
@subPage_title = l :label_student_list
|
||||||
|
@members = searchStudent(@course)
|
||||||
|
else
|
||||||
|
@subPage_title = ''
|
||||||
|
@members = @course.member_principals.includes(:roles, :principal).all.sort
|
||||||
|
end
|
||||||
|
@members = paginateHelper @members
|
||||||
|
render :layout => 'base_courses'
|
||||||
|
end
|
||||||
|
|
||||||
|
#判断指定用户是否为课程教师
|
||||||
|
def isCourseTeacher(id)
|
||||||
|
result = false
|
||||||
|
if @teachers.find_by_user_id(id) != nil
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def handle_course courses, activities
|
||||||
|
course_activity_count_array=activities.values()
|
||||||
|
|
||||||
|
course_array=[]
|
||||||
|
i=0;
|
||||||
|
courses.each do |course|
|
||||||
|
course_array[i]=course
|
||||||
|
i=i+1
|
||||||
|
end
|
||||||
|
|
||||||
|
courses=desc_sort_course_by_avtivity(course_activity_count_array, course_array)
|
||||||
|
|
||||||
|
return courses
|
||||||
|
end
|
||||||
|
|
||||||
|
def settings
|
||||||
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
|
@issue_category ||= IssueCategory.new
|
||||||
|
@member ||= @course.members.new
|
||||||
|
@trackers = Tracker.sorted.all
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
if User.current.user_extensions.identity
|
||||||
|
@course = Course.new
|
||||||
|
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
|
||||||
|
@course.safe_attributes = params[:course]
|
||||||
|
@course.tea_id = User.current.id
|
||||||
|
# added by bai
|
||||||
|
@course.term = params[:term]
|
||||||
|
@course.time = params[:time]
|
||||||
|
#@course.school_id = params[:occupation]
|
||||||
|
@course.school_id = User.current.user_extensions.school_id
|
||||||
|
@course.setup_time = params[:setup_time]
|
||||||
|
@course.endup_time = params[:endup_time]
|
||||||
|
@course.class_period = params[:class_period]
|
||||||
|
end
|
||||||
|
|
||||||
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
|
@trackers = Tracker.sorted.all
|
||||||
|
|
||||||
|
if User.current.user_extensions.identity == 0
|
||||||
|
if @course.save
|
||||||
|
#unless User.current.admin?
|
||||||
|
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
|
||||||
|
m = Member.new(:user => User.current, :roles => [r])
|
||||||
|
m.project_id = -1
|
||||||
|
course = CourseInfos.new(:user_id => User.current.id, :course_id => @course.id)
|
||||||
|
#user_grades = UserGrade.create(:user_id => User.current.id, :course_id => @course.id)
|
||||||
|
if params[:course][:is_public] == '1'
|
||||||
|
course_status = CourseStatus.create(:course_id => @course.id, :watchers_count => 0, :changesets_count => 0, :grade => 0, :course_type => @course_tag)
|
||||||
|
end
|
||||||
|
@course.members << m
|
||||||
|
@course.course_infos << course
|
||||||
|
#end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
flash[:notice] = l(:notice_successful_create)
|
||||||
|
if params[:continue]
|
||||||
|
redirect_to new_course_path(attrs, :course => '0')
|
||||||
|
elsif params[:course_continue]
|
||||||
|
redirect_to new_course_path(:course => '1')
|
||||||
|
else
|
||||||
|
redirect_to settings_course_path(@course, :course_type => 1)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'courses', :action => 'show', :id => @course.id) }
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@course.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { render :action => 'new', :layout => 'base' } #Added by young
|
||||||
|
format.api { render_validation_errors(@course) }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def course
|
||||||
|
@school_id = params[:school_id]
|
||||||
|
per_page_option = 10
|
||||||
|
if @school_id == "0" or @school_id.nil?
|
||||||
|
@courses_all = Course.active.visible.
|
||||||
|
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
|
||||||
|
where("#{Course.table_name}.course_type = ? ", Course::CourseType_course)
|
||||||
|
else
|
||||||
|
@courses_all = Course.active.visible.
|
||||||
|
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
|
||||||
|
joins(:course_extra).
|
||||||
|
where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
@course_count = @courses_all.count
|
||||||
|
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||||
|
|
||||||
|
#gcm activity count
|
||||||
|
|
||||||
|
@course_activity_count=Hash.new
|
||||||
|
#count initialize
|
||||||
|
@courses_all.each do |course|
|
||||||
|
@course_activity_count[course.id]=0
|
||||||
|
end
|
||||||
|
|
||||||
|
#@course_activity_count=get_course_activity @courses_all,@course_activity_count
|
||||||
|
#gcm end
|
||||||
|
|
||||||
|
|
||||||
|
case params[:course_sort_type]
|
||||||
|
when '0'
|
||||||
|
@courses = @courses_all.order("created_on desc")
|
||||||
|
@s_type = 0
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
|
#gcmend
|
||||||
|
|
||||||
|
when '1'
|
||||||
|
@courses = @courses_all.order("course_ac_para desc")
|
||||||
|
@s_type = 1
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
|
#gcmend
|
||||||
|
|
||||||
|
when '2'
|
||||||
|
@courses = @courses_all.order("watchers_count desc")
|
||||||
|
@s_type = 2
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
|
#gcmend
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
when '3'
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
@course_activity_count=get_course_activity @courses_all,@course_activity_count
|
||||||
|
#gcmend
|
||||||
|
|
||||||
|
@courses=handle_course @courses_all,@course_activity_count
|
||||||
|
@s_type = 3
|
||||||
|
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||||
|
else
|
||||||
|
@s_type = 0
|
||||||
|
@courses = @courses_all.order("created_on desc")
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
@course_activity_count=get_course_activity @courses,@course_activity_count
|
||||||
|
#gcmend
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base'
|
||||||
|
}
|
||||||
|
format.api {
|
||||||
|
# @offset, @limit = api_offset_and_limit
|
||||||
|
# @course_count = Course.visible.count
|
||||||
|
# @courses = Course.visible.offset(@offset).limit(@limit).order('lft').all
|
||||||
|
}
|
||||||
|
format.atom {
|
||||||
|
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||||
|
render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def new
|
||||||
|
@course_type = params[:course_type] ||= params[:course]
|
||||||
|
@issue_custom_fields = IssueCustomField.sorted.all
|
||||||
|
@trackers = Tracker.sorted.all
|
||||||
|
|
||||||
|
@course = Course.new
|
||||||
|
@course.safe_attributes = params[:course]
|
||||||
|
|
||||||
|
render :layout => 'base'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def desc_sort_course_by_avtivity(activity_count, courses)
|
||||||
|
return courses if activity_count.size<2
|
||||||
|
(activity_count.size-2).downto(0) do |i|
|
||||||
|
(0..i).each do |j|
|
||||||
|
if activity_count[j]<activity_count[j+1]
|
||||||
|
courses[j], courses[j+1]=courses[j+1], courses[j]
|
||||||
|
activity_count[j], activity_count[j+1]=activity_count[j+1], activity_count[j]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return courses
|
||||||
|
end
|
||||||
|
|
||||||
|
def index
|
||||||
|
@course_type = params[:course_type]
|
||||||
|
@school_id = params[:school_id]
|
||||||
|
per_page_option = 10
|
||||||
|
|
||||||
|
|
||||||
|
if @school_id == "0" or @school_id.nil?
|
||||||
|
@courses_all = Course.active.visible.
|
||||||
|
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id")
|
||||||
|
else
|
||||||
|
@courses_all = Course.active.visible.
|
||||||
|
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
|
||||||
|
joins(:course_extra).
|
||||||
|
where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
@course_count = @courses_all.count
|
||||||
|
@course_pages = Paginator.new @course_count, per_page_option, params['page']
|
||||||
|
|
||||||
|
@course_activity_count=Hash.new
|
||||||
|
@courses_all.each do |course|
|
||||||
|
@course_activity_count[course.id]=0
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
case params[:course_sort_type]
|
||||||
|
when '0'
|
||||||
|
@courses = @courses_all.order("created_at desc")
|
||||||
|
@s_type = 0
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses, @course_activity_count
|
||||||
|
when '1'
|
||||||
|
@courses = @courses_all.order("course_ac_para desc")
|
||||||
|
@s_type = 1
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses, @course_activity_count
|
||||||
|
when '2'
|
||||||
|
@courses = @courses_all.order("watchers_count desc")
|
||||||
|
@s_type = 2
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses, @course_activity_count
|
||||||
|
|
||||||
|
when '3'
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses_all, @course_activity_count
|
||||||
|
|
||||||
|
@courses=handle_course @courses_all, @course_activity_count
|
||||||
|
|
||||||
|
@s_type = 3
|
||||||
|
@courses = @courses[@course_pages.offset, @course_pages.per_page]
|
||||||
|
else
|
||||||
|
@s_type = 0
|
||||||
|
@courses = @courses_all.order("created_at desc")
|
||||||
|
@courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page)
|
||||||
|
|
||||||
|
@course_activity_count=get_course_activity @courses, @course_activity_count
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
render :layout => 'base'
|
||||||
|
}
|
||||||
|
format.atom {
|
||||||
|
courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all
|
||||||
|
render_feed(courses, :title => "#{Setting.app_title}: #{l(:label_course_latest)}")
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def homework
|
||||||
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
|
@bids = @course.homeworks.order('deadline DESC')
|
||||||
|
@bids = @bids.like(params[:name]) if params[:name].present?
|
||||||
|
@bid_count = @bids.count
|
||||||
|
@bid_pages = Paginator.new @bid_count, @limit, params['page']
|
||||||
|
|
||||||
|
@offset ||= @bid_pages.reverse_offset
|
||||||
|
unless @offset == 0
|
||||||
|
@bids = @bids.offset(@offset).limit(@limit).all.reverse
|
||||||
|
else
|
||||||
|
limit = @bid_count % @limit
|
||||||
|
if limit == 0
|
||||||
|
limit = 10
|
||||||
|
end
|
||||||
|
@bids = @bids.offset(@offset).limit(limit).all.reverse
|
||||||
|
end
|
||||||
|
render :layout => 'base_courses'
|
||||||
|
end
|
||||||
|
|
||||||
|
# 新建作业
|
||||||
|
def new_homework
|
||||||
|
if (User.current.logged? &&
|
||||||
|
(User.current.admin? ||
|
||||||
|
(
|
||||||
|
!Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.nil? &&
|
||||||
|
(
|
||||||
|
Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.roles &&
|
||||||
|
( Role.where(id: [3, 4, 7, 9]).size > 0 )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
@homework = Bid.new
|
||||||
|
@homework.safe_attributes = params[:bid]
|
||||||
|
render :layout => 'base_courses'
|
||||||
|
else
|
||||||
|
render_404
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_course_activity courses, activities
|
||||||
|
@course_ids=activities.keys()
|
||||||
|
|
||||||
|
days = Setting.activity_days_default.to_i
|
||||||
|
date_to ||= Date.today + 1
|
||||||
|
date_from = date_to - days-1.years
|
||||||
|
|
||||||
|
#file_count
|
||||||
|
Attachment.where(container_id: @course_ids, container_type: Course).where("created_on>?", date_from).each do |attachment|
|
||||||
|
activities[attachment.container_id]+=1
|
||||||
|
end
|
||||||
|
|
||||||
|
#message_count
|
||||||
|
Board.where(course_id: @course_ids).each do |board|
|
||||||
|
# activities[board.course_id]+=1
|
||||||
|
activities[board.course_id]+=board.messages.where("updated_on>?", date_from).count
|
||||||
|
end
|
||||||
|
|
||||||
|
#news
|
||||||
|
News.where(course_id: @course_ids).where("created_on>?",date_from).each do |news|
|
||||||
|
activities[news.course_id]+=1
|
||||||
|
end
|
||||||
|
|
||||||
|
#feedbackc_count
|
||||||
|
JournalsForMessage.where(jour_id: @course_ids, jour_type: Course).each do |jourformess|
|
||||||
|
activities[jourformess.jour_id]+=1
|
||||||
|
end
|
||||||
|
|
||||||
|
#activities!=0
|
||||||
|
i=0;
|
||||||
|
courses.each do |course|
|
||||||
|
id=course.id
|
||||||
|
if activities[id]==0
|
||||||
|
activities[id]=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return activities
|
||||||
|
end
|
||||||
|
|
||||||
|
def toggleCourse
|
||||||
|
@course_prefs = Course.find_by_extra(@course.extra)
|
||||||
|
unless (@course_prefs.teacher == User.current || User.current.admin?)
|
||||||
|
render_403
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def finishcourse
|
||||||
|
yesterday = Date.today.prev_day.to_time
|
||||||
|
|
||||||
|
@course_prefs.endup_time = yesterday
|
||||||
|
@save_flag = @course_prefs.save
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def restartcourse
|
||||||
|
day = Time.parse("3000-01-01")
|
||||||
|
|
||||||
|
@course_prefs.endup_time = day
|
||||||
|
@save_flag = @course_prefs.save
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js {
|
||||||
|
render action:'finishcourse'
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def show
|
||||||
|
# try to redirect to the requested menu item
|
||||||
|
if params[:jump] && redirect_to_course_menu_item(@course, params[:jump])
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
@users_by_role = @course.users_by_role
|
||||||
|
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
||||||
|
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@key = User.current.rss_key
|
||||||
|
#新增内容
|
||||||
|
@days = Setting.activity_days_default.to_i
|
||||||
|
|
||||||
|
if params[:from]
|
||||||
|
begin; @date_to = params[:from].to_date + 1; rescue; end
|
||||||
|
end
|
||||||
|
|
||||||
|
has = {
|
||||||
|
"show_course_files" => true,
|
||||||
|
"show_course_news" => true,
|
||||||
|
"show_course_messages" => true,
|
||||||
|
"show_bids" => true,
|
||||||
|
"show_course_journals_for_messages" => true
|
||||||
|
}
|
||||||
|
@date_to ||= Date.today + 1
|
||||||
|
@date_from = @date_to - @days-1.years
|
||||||
|
@author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id]))
|
||||||
|
# 决定显示所用用户或单个用户活动
|
||||||
|
@activity = Redmine::Activity::Fetcher.new(User.current, :course => @course,
|
||||||
|
:with_subprojects => false,
|
||||||
|
:author => @author)
|
||||||
|
@activity.scope_select {|t| has["show_#{t}"]}
|
||||||
|
events = @activity.events(@date_from, @date_to)
|
||||||
|
|
||||||
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
|
@events_count = events.count
|
||||||
|
@events_pages = Paginator.new @events_count, @limit, params['page']
|
||||||
|
@offset ||= @events_pages.offset
|
||||||
|
events = events.slice(@offset,@limit)
|
||||||
|
|
||||||
|
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
|
||||||
|
# documents
|
||||||
|
@sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category'
|
||||||
|
#
|
||||||
|
@teachers= searchTeacherAndAssistant(@course)
|
||||||
|
@canShowRealName = isCourseTeacher(User.current.id)
|
||||||
|
|
||||||
|
if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id)))
|
||||||
|
@user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{render :layout => 'base_courses'}
|
||||||
|
format.api
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#判断指定用户是否为课程教师
|
||||||
|
def isCourseTeacher(id)
|
||||||
|
result = false
|
||||||
|
if @teachers && @teachers.find_by_user_id(id) != nil
|
||||||
|
result = true
|
||||||
|
end
|
||||||
|
result
|
||||||
|
end
|
||||||
|
|
||||||
|
def feedback
|
||||||
|
page = params[:page]
|
||||||
|
# Find the page of the requested reply
|
||||||
|
@jours = @course.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||||
|
@limit = 10
|
||||||
|
if params[:r] && page.nil?
|
||||||
|
offset = @jours.count(:conditions => ["#{JournalsForMessage.table_name}.id > ?", params[:r].to_i])
|
||||||
|
page = 1 + offset / @limit
|
||||||
|
end
|
||||||
|
|
||||||
|
@feedback_count = @jours.count
|
||||||
|
@feedback_pages = Paginator.new @feedback_count, @limit, page
|
||||||
|
@offset ||= @feedback_pages.offset
|
||||||
|
@jour = @jours[@offset, @limit]
|
||||||
|
@state = false
|
||||||
|
respond_to do |format|
|
||||||
|
format.html{render :layout => 'base_courses'}
|
||||||
|
format.api
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def allow_join
|
def allow_join
|
||||||
if course_endTime_timeout? Project.find(params[:object_id])
|
if course_endTime_timeout? Course.find(params[:object_id])
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js{
|
format.js {
|
||||||
@state = 2
|
@state = 2
|
||||||
render :partial => 'set_join',
|
render :partial => 'set_join',
|
||||||
:locals => {:user => User.current,
|
:locals => {:user => User.current,
|
||||||
:course => Project.find(params[:object_id]),
|
:course => Course.find(params[:object_id]),
|
||||||
:object_id => params[:object_id]
|
:object_id => params[:object_id]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
|
@ -33,13 +33,15 @@ class FilesController < ApplicationController
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
|
if params[:project_id]
|
||||||
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
@isproject = true
|
||||||
|
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
||||||
if @project.project_type == 1
|
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||||
render :layout => 'base_courses'
|
|
||||||
else
|
|
||||||
render :layout => !request.xhr?
|
render :layout => !request.xhr?
|
||||||
|
elsif params[:course_id]
|
||||||
|
@isproject = false
|
||||||
|
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||||
|
render :layout => 'base_courses'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -60,37 +62,66 @@ class FilesController < ApplicationController
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@addTag=false
|
#modify by nwb
|
||||||
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
if @project
|
||||||
attachments = Attachment.attach_filesex(container, params[:attachments],params[:attachment_type])
|
@addTag=false
|
||||||
render_attachment_warning_if_needed(container)
|
container = (params[:version_id].blank? ? @project : @project.versions.find_by_id(params[:version_id]))
|
||||||
|
attachments = Attachment.attach_filesex(container, params[:attachments], params[:attachment_type])
|
||||||
|
render_attachment_warning_if_needed(container)
|
||||||
|
|
||||||
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||||
Mailer.attachments_added(attachments[:files]).deliver
|
Mailer.attachments_added(attachments[:files]).deliver
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: 临时用 nyan
|
# TODO: 临时用 nyan
|
||||||
sort_init 'created_on', 'desc'
|
sort_init 'created_on', 'desc'
|
||||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
'filename' => "#{Attachment.table_name}.filename",
|
'filename' => "#{Attachment.table_name}.filename",
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
|
@containers = [Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
|
||||||
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||||
|
|
||||||
@attachtype = 0
|
@attachtype = 0
|
||||||
@contenttype = 0
|
@contenttype = 0
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.js
|
format.js
|
||||||
format.html {
|
format.html {
|
||||||
redirect_to project_files_path(@project)
|
redirect_to project_files_path(@project)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
elsif @course
|
||||||
|
@addTag=false
|
||||||
|
attachments = Attachment.attach_filesex(@course, params[:attachments], params[:attachment_type])
|
||||||
|
|
||||||
end
|
if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
|
||||||
|
Mailer.attachments_added(attachments[:files]).deliver
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: 临时用 nyan
|
||||||
|
sort_init 'created_on', 'desc'
|
||||||
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
|
'filename' => "#{Attachment.table_name}.filename",
|
||||||
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
|
@containers = [Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||||
|
|
||||||
|
@attachtype = 0
|
||||||
|
@contenttype = 0
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
format.html {
|
||||||
|
redirect_to course_files_path(@course)
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def tag_saveEx
|
def tag_saveEx
|
||||||
|
@ -115,6 +146,8 @@ class FilesController < ApplicationController
|
||||||
@obj = Contest.find_by_id(@obj_id)
|
@obj = Contest.find_by_id(@obj_id)
|
||||||
when '8'
|
when '8'
|
||||||
@obj = OpenSourceProject.find_by_id(@obj_id)
|
@obj = OpenSourceProject.find_by_id(@obj_id)
|
||||||
|
when '9'
|
||||||
|
@obj = Course.find_by_id(@obj_id)
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
@ -131,6 +164,7 @@ class FilesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
# 返回制定资源类型的资源列表
|
# 返回制定资源类型的资源列表
|
||||||
|
# added by nwb
|
||||||
def getattachtype
|
def getattachtype
|
||||||
sort_init 'created_on', 'desc'
|
sort_init 'created_on', 'desc'
|
||||||
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
sort_update 'created_on' => "#{Attachment.table_name}.created_on",
|
||||||
|
@ -138,8 +172,12 @@ class FilesController < ApplicationController
|
||||||
'size' => "#{Attachment.table_name}.filesize",
|
'size' => "#{Attachment.table_name}.filesize",
|
||||||
'downloads' => "#{Attachment.table_name}.downloads"
|
'downloads' => "#{Attachment.table_name}.downloads"
|
||||||
|
|
||||||
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)] #modify by Long Jun
|
if @project
|
||||||
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
@containers = [ Project.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@project.id)]
|
||||||
|
@containers += @project.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
|
||||||
|
elsif @course
|
||||||
|
@containers = [ Course.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@course.id)]
|
||||||
|
end
|
||||||
|
|
||||||
@attachtype = params[:type].to_i
|
@attachtype = params[:type].to_i
|
||||||
@contenttype = params[:contentType].to_s
|
@contenttype = params[:contentType].to_s
|
||||||
|
|
|
@ -2,21 +2,21 @@ class HomeworkAttachController < ApplicationController
|
||||||
include CoursesHelper
|
include CoursesHelper
|
||||||
###############################
|
###############################
|
||||||
#判断当前角色权限时需先找到当前操作的project
|
#判断当前角色权限时需先找到当前操作的project
|
||||||
before_filter :find_project_by_bid_id, :only => [:new]
|
before_filter :find_course_by_bid_id, :only => [:new]
|
||||||
before_filter :find_project_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
|
before_filter :find_course_by_hoemwork_id, :only => [:edit,:update,:destroy,:show,:add_homework_users,:destory_homework_users]
|
||||||
#判断当前角色是否有操作权限
|
#判断当前角色是否有操作权限
|
||||||
#勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy]
|
#勿删 before_filter :authorize, :only => [:new,:edit,:update,:destroy]
|
||||||
|
|
||||||
def find_project_by_bid_id
|
def find_course_by_bid_id
|
||||||
@bid = Bid.find(params[:id])
|
@bid = Bid.find(params[:id])
|
||||||
@project = @bid.courses[0]
|
@course = @bid.courses[0]
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_project_by_hoemwork_id
|
def find_course_by_hoemwork_id
|
||||||
@homework = HomeworkAttach.find(params[:id])
|
@homework = HomeworkAttach.find(params[:id])
|
||||||
@project = @homework.bid.courses[0]
|
@course = @homework.bid.courses[0]
|
||||||
end
|
end
|
||||||
|
|
||||||
#获取作业的成员
|
#获取作业的成员
|
||||||
|
@ -36,7 +36,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
|
|
||||||
#作业添加成员(参与人员)
|
#作业添加成员(参与人员)
|
||||||
def add_homework_users
|
def add_homework_users
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first)
|
||||||
#@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if params[:membership]
|
if params[:membership]
|
||||||
if params[:membership][:user_ids]
|
if params[:membership][:user_ids]
|
||||||
|
@ -60,7 +60,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
#作业删除成员(参与人员)
|
#作业删除成员(参与人员)
|
||||||
def destory_homework_users
|
def destory_homework_users
|
||||||
#@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first)
|
||||||
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
|
homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first
|
||||||
homework_user.destroy
|
homework_user.destroy
|
||||||
get_homework_member @homework
|
get_homework_member @homework
|
||||||
|
@ -74,7 +74,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
|
|
||||||
def create
|
def create
|
||||||
bid = Bid.find params[:bid_id]
|
bid = Bid.find params[:bid_id]
|
||||||
if User.current.admin? || User.current.member_of?(bid.courses.first)
|
if User.current.admin? || User.current.member_of_course?(bid.courses.first) # modify by nwb
|
||||||
if bid.homeworks.where("user_id = ?",User.current).count == 0
|
if bid.homeworks.where("user_id = ?",User.current).count == 0
|
||||||
user_id = params[:user_id]
|
user_id = params[:user_id]
|
||||||
bid_id = params[:bid_id]
|
bid_id = params[:bid_id]
|
||||||
|
@ -108,7 +108,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
|
|
||||||
if @homework.save
|
if @homework.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to project_for_bid_path @homework.bid }
|
format.html { redirect_to course_for_bid_path @homework.bid }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -124,7 +124,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@bid = Bid.find(params[:id])
|
@bid = Bid.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@bid.courses.first)
|
if User.current.admin? || User.current.member_of_course?(@bid.courses.first) #nwb
|
||||||
#该课程的学生的集合(新建不实现功能:添加成员)
|
#该课程的学生的集合(新建不实现功能:添加成员)
|
||||||
#@members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]})
|
#@members = @bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id <> #{User.current.id}", {:role_id => [5, 10]})
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
def get_homework_member_list
|
def get_homework_member_list
|
||||||
@homework = HomeworkAttach.find(params[:bid_id])
|
@homework = HomeworkAttach.find(params[:bid_id])
|
||||||
course = @homework.bid.courses.first
|
course = @homework.bid.courses.first
|
||||||
if User.current.admin? || User.current.member_of?(course)
|
if User.current.admin? || User.current.member_of_course?(course)
|
||||||
get_homework_member @homework
|
get_homework_member @homework
|
||||||
else
|
else
|
||||||
raise "error"
|
raise "error"
|
||||||
|
@ -174,7 +174,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
#@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first)
|
||||||
#@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
|
#@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]})
|
||||||
get_homework_member @homework
|
get_homework_member @homework
|
||||||
else
|
else
|
||||||
|
@ -185,7 +185,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
def update
|
def update
|
||||||
#@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
course = @homework.bid.courses.first
|
course = @homework.bid.courses.first
|
||||||
if User.current.admin? || User.current.member_of?(course)
|
if User.current.admin? || User.current.member_of_course?(course)
|
||||||
name = params[:homework_name]
|
name = params[:homework_name]
|
||||||
description = params[:homework_description]
|
description = params[:homework_description]
|
||||||
if params[:homework_attach]
|
if params[:homework_attach]
|
||||||
|
@ -205,7 +205,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
end
|
end
|
||||||
if @homework.save
|
if @homework.save
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to project_for_bid_path @homework.bid }
|
format.html { redirect_to course_for_bid_path @homework.bid }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -220,7 +220,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
if User.current.admin? || User.current == @homework.user
|
if User.current.admin? || User.current == @homework.user
|
||||||
if @homework.destroy
|
if @homework.destroy
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { redirect_to project_for_bid_path @homework.bid }
|
format.html { redirect_to course_for_bid_path @homework.bid }
|
||||||
format.json { head :no_content }
|
format.json { head :no_content }
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
@ -233,7 +233,7 @@ class HomeworkAttachController < ApplicationController
|
||||||
#显示作业信息
|
#显示作业信息
|
||||||
def show
|
def show
|
||||||
#@homework = HomeworkAttach.find(params[:id])
|
#@homework = HomeworkAttach.find(params[:id])
|
||||||
if User.current.admin? || User.current.member_of?(@homework.bid.courses.first)
|
if User.current.admin? || User.current.member_of_course?(@homework.bid.courses.first)
|
||||||
# 打分统计
|
# 打分统计
|
||||||
stars_reates = @homework.
|
stars_reates = @homework.
|
||||||
rates(:quality)
|
rates(:quality)
|
||||||
|
|
|
@ -22,15 +22,16 @@ class MembersController < ApplicationController
|
||||||
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
|
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
|
||||||
before_filter :authorize
|
before_filter :authorize
|
||||||
accept_api_auth :index, :show, :create, :update, :destroy
|
accept_api_auth :index, :show, :create, :update, :destroy
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@offset, @limit = api_offset_and_limit
|
@offset, @limit = api_offset_and_limit
|
||||||
@member_count = @project.member_principals.count
|
@member_count = @project.member_principals.count
|
||||||
@member_pages = Paginator.new @member_count, @limit, params['page']
|
@member_pages = Paginator.new @member_count, @limit, params['page']
|
||||||
@offset ||= @member_pages.offset
|
@offset ||= @member_pages.offset
|
||||||
@members = @project.member_principals.all(
|
@members = @project.member_principals.all(
|
||||||
:order => "#{Member.table_name}.id",
|
:order => "#{Member.table_name}.id",
|
||||||
:limit => @limit,
|
:limit => @limit,
|
||||||
:offset => @offset
|
:offset => @offset
|
||||||
)
|
)
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
@ -60,121 +61,217 @@ class MembersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
#modify by nwb
|
||||||
|
#更改课程成员逻辑
|
||||||
applied_members = false
|
applied_members = false
|
||||||
members = []
|
members = []
|
||||||
project_info = []
|
|
||||||
user_grades = []
|
user_grades = []
|
||||||
if params[:membership]
|
if @project
|
||||||
if params[:membership][:user_ids]
|
project_info = []
|
||||||
attrs = params[:membership].dup
|
if params[:membership]
|
||||||
user_ids = attrs.delete(:user_ids)
|
if params[:membership][:user_ids]
|
||||||
user_ids.each do |user_id|
|
attrs = params[:membership].dup
|
||||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
user_ids = attrs.delete(:user_ids)
|
||||||
user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id)
|
user_ids.each do |user_id|
|
||||||
|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||||
|
user_grades << UserGrade.new(:user_id => user_id, :project_id => @project.id)
|
||||||
|
## added by nie
|
||||||
|
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||||
|
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id)
|
||||||
|
# ProjectInfo.create(:name => "test", :user_id => 123)
|
||||||
|
end
|
||||||
|
## end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||||
|
user_grades << UserGrade.new(:user_id => params[:membership][:user_id], :project_id => @project.id)
|
||||||
## added by nie
|
## added by nie
|
||||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||||
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id)
|
project_info << ProjectInfo.new(:project_id => @project.id, :user_id => params[:membership][:user_id])
|
||||||
# ProjectInfo.create(:name => "test", :user_id => 123)
|
|
||||||
end
|
end
|
||||||
## end
|
## end
|
||||||
end
|
|
||||||
else
|
|
||||||
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
|
||||||
user_grades << UserGrade.new(:user_id => params[:membership][:user_id], :project_id => @project.id)
|
|
||||||
## added by nie
|
|
||||||
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
|
||||||
project_info << ProjectInfo.new(:project_id => @project.id, :user_id => params[:membership][:user_id])
|
|
||||||
end
|
end
|
||||||
## end
|
@project.members << members
|
||||||
|
# added by nie
|
||||||
|
@project.project_infos << project_info
|
||||||
|
@project.user_grades << user_grades
|
||||||
|
# end
|
||||||
end
|
end
|
||||||
@project.members << members
|
if members.present? && members.all? { |m| m.valid? }
|
||||||
# added by nie
|
members.each do |member|
|
||||||
@project.project_infos << project_info
|
AppliedProject.deleteappiled(member.user_id, @project.id)
|
||||||
@project.user_grades << user_grades
|
end
|
||||||
# end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
if members.present? && members.all? {|m| m.valid? }
|
|
||||||
members.each do |member|
|
|
||||||
AppliedProject.deleteappiled(member.user_id, @project.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html { redirect_to_settings_in_projects }
|
|
||||||
format.js { @members = members;@applied_members = applied_members; }
|
|
||||||
format.api {
|
|
||||||
@member = members.first
|
|
||||||
if @member.valid?
|
|
||||||
render :action => 'show', :status => :created, :location => membership_url(@member)
|
|
||||||
else
|
|
||||||
render_validation_errors(@member)
|
|
||||||
end
|
end
|
||||||
}
|
respond_to do |format|
|
||||||
end
|
format.html { redirect_to_settings_in_projects }
|
||||||
|
format.js { @members = members; @applied_members = applied_members; }
|
||||||
|
format.api {
|
||||||
|
@member = members.first
|
||||||
|
if @member.valid?
|
||||||
|
render :action => 'show', :status => :created, :location => membership_url(@member)
|
||||||
|
else
|
||||||
|
render_validation_errors(@member)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
elsif @course
|
||||||
|
course_info = []
|
||||||
|
if params[:membership]
|
||||||
|
if params[:membership][:user_ids]
|
||||||
|
attrs = params[:membership].dup
|
||||||
|
user_ids = attrs.delete(:user_ids)
|
||||||
|
user_ids.each do |user_id|
|
||||||
|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
|
||||||
|
user_grades << UserGrade.new(:user_id => user_id, :course_id => @course.id)
|
||||||
|
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||||
|
course_info << CourseInfo.new(:user_id => user_id, :course_id => @course.id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
|
||||||
|
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||||
|
course_info << CourseInfo.new(:course_id => @course.id, :user_id => params[:membership][:user_id])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@course.members << members
|
||||||
|
@course.course_infos << course_info
|
||||||
|
end
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to_settings_in_courses }
|
||||||
|
format.js { @members = members; @applied_members = applied_members; }
|
||||||
|
format.api {
|
||||||
|
@member = members.first
|
||||||
|
if @member.valid?
|
||||||
|
render :action => 'show', :status => :created, :location => membership_url(@member)
|
||||||
|
else
|
||||||
|
render_validation_errors(@member)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end # end of if @project
|
||||||
|
|
||||||
|
end # end of params[:refusal_button]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
if params[:membership]
|
#modify by nwb
|
||||||
@member.role_ids = params[:membership][:role_ids]
|
#增加对课程成员修改的支持
|
||||||
|
if @project
|
||||||
|
if params[:membership]
|
||||||
|
@member.role_ids = params[:membership][:role_ids]
|
||||||
|
|
||||||
#added by nie
|
#added by nie
|
||||||
if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||||
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
|
||||||
@projectInfo.save
|
@projectInfo.save
|
||||||
else
|
else
|
||||||
|
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||||
|
if user_admin.size > 0
|
||||||
|
user_admin.each do |user|
|
||||||
|
user.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
saved = @member.save
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to_settings_in_projects }
|
||||||
|
format.js
|
||||||
|
format.api {
|
||||||
|
if saved
|
||||||
|
render_api_ok
|
||||||
|
else
|
||||||
|
render_validation_errors(@member)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
elsif @course
|
||||||
|
if params[:membership]
|
||||||
|
@member.role_ids = params[:membership][:role_ids]
|
||||||
|
|
||||||
|
if (params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
|
||||||
|
@courseInfo = CourseInfos.new(:user_id => @member.user_id, :course_id => @course.id)
|
||||||
|
@courseInfo.save
|
||||||
|
else
|
||||||
|
user_admin = CourseInfos.where("user_id = ? and course_id = ?", @member.user_id, @course.id)
|
||||||
|
if user_admin.size > 0
|
||||||
|
user_admin.each do |user|
|
||||||
|
user.destroy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
saved = @member.save
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to_settings_in_courses }
|
||||||
|
format.js
|
||||||
|
format.api {
|
||||||
|
if saved
|
||||||
|
render_api_ok
|
||||||
|
else
|
||||||
|
render_validation_errors(@member)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
#modify by nwb
|
||||||
|
#课程成员删除修改
|
||||||
|
if @project
|
||||||
|
if request.delete? && @member.deletable?
|
||||||
|
@member.destroy
|
||||||
|
# end
|
||||||
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||||
if user_admin.size > 0
|
if user_admin.size > 0
|
||||||
user_admin.each do |user|
|
user_admin.each do |user|
|
||||||
user.destroy
|
user.destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
||||||
end
|
if user_grade.size > 0
|
||||||
|
user_grade.each do |grade|
|
||||||
saved = @member.save
|
grade.destroy
|
||||||
respond_to do |format|
|
end
|
||||||
format.html { redirect_to_settings_in_projects }
|
|
||||||
format.js
|
|
||||||
format.api {
|
|
||||||
if saved
|
|
||||||
render_api_ok
|
|
||||||
else
|
|
||||||
render_validation_errors(@member)
|
|
||||||
end
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def destroy
|
|
||||||
if request.delete? && @member.deletable?
|
|
||||||
@member.destroy
|
|
||||||
# end
|
|
||||||
user_admin = ProjectInfo.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
|
||||||
if user_admin.size > 0
|
|
||||||
user_admin.each do |user|
|
|
||||||
user.destroy
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
user_grade = UserGrade.where("user_id = ? and project_id = ?", @member.user_id, @project.id)
|
respond_to do |format|
|
||||||
if user_grade.size > 0
|
format.html { redirect_to_settings_in_projects }
|
||||||
user_grade.each do |grade|
|
format.js
|
||||||
grade.destroy
|
format.api {
|
||||||
|
if @member.destroyed?
|
||||||
|
render_api_ok
|
||||||
|
else
|
||||||
|
head :unprocessable_entity
|
||||||
|
end
|
||||||
|
}
|
||||||
|
end
|
||||||
|
elsif @course
|
||||||
|
if request.delete? && @member.deletable?
|
||||||
|
@member.destroy
|
||||||
|
user_admin = CourseInfos.where("user_id = ? and course_id = ?", @member.user_id, @course.id)
|
||||||
|
if user_admin.size > 0
|
||||||
|
user_admin.each do |user|
|
||||||
|
user.destroy
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
respond_to do |format|
|
||||||
respond_to do |format|
|
format.html { redirect_to_settings_in_courses }
|
||||||
format.html { redirect_to_settings_in_projects }
|
format.js
|
||||||
format.js
|
format.api {
|
||||||
format.api {
|
if @member.destroyed?
|
||||||
if @member.destroyed?
|
render_api_ok
|
||||||
render_api_ok
|
else
|
||||||
else
|
head :unprocessable_entity
|
||||||
head :unprocessable_entity
|
end
|
||||||
end
|
}
|
||||||
}
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -189,4 +286,8 @@ class MembersController < ApplicationController
|
||||||
def redirect_to_settings_in_projects
|
def redirect_to_settings_in_projects
|
||||||
redirect_to settings_project_path(@project, :tab => 'members')
|
redirect_to settings_project_path(@project, :tab => 'members')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def redirect_to_settings_in_courses
|
||||||
|
redirect_to settings_course_path(@course, :tab => 'members')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -49,7 +49,7 @@ class MessagesController < ApplicationController
|
||||||
all
|
all
|
||||||
|
|
||||||
@reply = Message.new(:subject => "RE: #{@message.subject}")
|
@reply = Message.new(:subject => "RE: #{@message.subject}")
|
||||||
if @message.board.project.project_type ==1
|
if @course
|
||||||
render :action => "show", :layout => "base_courses"#by young
|
render :action => "show", :layout => "base_courses"#by young
|
||||||
else
|
else
|
||||||
render :action => "show", :layout => "base_projects"#by young
|
render :action => "show", :layout => "base_projects"#by young
|
||||||
|
@ -138,8 +138,14 @@ private
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_board
|
def find_board
|
||||||
@board = Board.find(params[:board_id], :include => :project)
|
#modify by nwb
|
||||||
@project = @board.project
|
@board = Board.find(params[:board_id])
|
||||||
|
if @board.project_id != -1 && @board.project_id != nil
|
||||||
|
@project = @board.project
|
||||||
|
elsif @board.course_id
|
||||||
|
@course = @board.course
|
||||||
|
end
|
||||||
|
|
||||||
rescue ActiveRecord::RecordNotFound
|
rescue ActiveRecord::RecordNotFound
|
||||||
render_404
|
render_404
|
||||||
nil
|
nil
|
||||||
|
|
|
@ -38,37 +38,62 @@ class NewsController < ApplicationController
|
||||||
@limit = 10
|
@limit = 10
|
||||||
end
|
end
|
||||||
|
|
||||||
scope = @project ? @project.news.visible : News.visible
|
# modify by nwb
|
||||||
|
if params[:course_id] && @course==nil
|
||||||
@news_count = scope.count
|
@course = Course.find(params[:course_id])
|
||||||
@news_pages = Paginator.new @news_count, @limit, params['page']
|
|
||||||
@offset ||= @news_pages.offset
|
|
||||||
@newss = scope.all(:include => [:author, :project],
|
|
||||||
:order => "#{News.table_name}.created_on DESC",
|
|
||||||
:offset => @offset,
|
|
||||||
:limit => @limit)
|
|
||||||
|
|
||||||
respond_to do |format|
|
|
||||||
format.html {
|
|
||||||
@news = News.new # for adding news inline
|
|
||||||
# huang
|
|
||||||
|
|
||||||
if @project.project_type == 1
|
|
||||||
render :layout => 'base_courses'
|
|
||||||
else
|
|
||||||
render :layout => false if request.xhr?
|
|
||||||
end
|
|
||||||
}
|
|
||||||
format.api
|
|
||||||
format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
|
|
||||||
end
|
end
|
||||||
end
|
if @project
|
||||||
|
scope = @project ? @project.news.visible : News.visible
|
||||||
|
|
||||||
|
@news_count = scope.count
|
||||||
|
@news_pages = Paginator.new @news_count, @limit, params['page']
|
||||||
|
@offset ||= @news_pages.offset
|
||||||
|
@newss = scope.all(:include => [:author, :project],
|
||||||
|
:order => "#{News.table_name}.created_on DESC",
|
||||||
|
:offset => @offset,
|
||||||
|
:limit => @limit)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
@news = News.new # for adding news inline
|
||||||
|
# huang
|
||||||
|
|
||||||
|
render :layout => false if request.xhr?
|
||||||
|
}
|
||||||
|
format.api
|
||||||
|
format.atom { render_feed(@newss, :title => (@project ? @project.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
|
||||||
|
end
|
||||||
|
elsif @course
|
||||||
|
scope = @course ? @course.news.course_visible : News.course_visible
|
||||||
|
|
||||||
|
@news_count = scope.count
|
||||||
|
@news_pages = Paginator.new @news_count, @limit, params['page']
|
||||||
|
@offset ||= @news_pages.offset
|
||||||
|
@newss = scope.all(:include => [:author, :course],
|
||||||
|
:order => "#{News.table_name}.created_on DESC",
|
||||||
|
:offset => @offset,
|
||||||
|
:limit => @limit)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html {
|
||||||
|
@news = News.new
|
||||||
|
render :layout => 'base_courses'
|
||||||
|
}
|
||||||
|
format.api
|
||||||
|
format.atom { render_feed(@newss, :title => (@course ? @course.name : Setting.app_title) + ": #{l(:label_news_plural)}") }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@comments = @news.comments
|
@comments = @news.comments
|
||||||
@comments.reverse! if User.current.wants_comments_in_reverse_order?
|
@comments.reverse! if User.current.wants_comments_in_reverse_order?
|
||||||
if @project.project_type == 1
|
#modify by nwb
|
||||||
render :layout => 'base_courses'
|
if @news.course_id
|
||||||
|
@course = Course.find(@news.course_id)
|
||||||
|
if @course
|
||||||
|
render :layout => 'base_courses'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -81,16 +106,31 @@ class NewsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@news = News.new(:project => @project, :author => User.current)
|
#modify by nwb
|
||||||
@news.safe_attributes = params[:news]
|
if @project
|
||||||
@news.save_attachments(params[:attachments])
|
@news = News.new(:project => @project, :author => User.current)
|
||||||
if @news.save
|
@news.safe_attributes = params[:news]
|
||||||
render_attachment_warning_if_needed(@news)
|
@news.save_attachments(params[:attachments])
|
||||||
flash[:notice] = l(:notice_successful_create)
|
if @news.save
|
||||||
redirect_to project_news_index_path(@project)
|
render_attachment_warning_if_needed(@news)
|
||||||
else
|
flash[:notice] = l(:notice_successful_create)
|
||||||
layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects'
|
redirect_to project_news_index_path(@project)
|
||||||
render :action => 'new', :layout => layout_file
|
else
|
||||||
|
layout_file = (@project.project_type == 1) ? 'base_courses' : 'base_projects'
|
||||||
|
render :action => 'new', :layout => layout_file
|
||||||
|
end
|
||||||
|
elsif @course
|
||||||
|
@news = News.new(:course => @course, :author => User.current)
|
||||||
|
@news.safe_attributes = params[:news]
|
||||||
|
@news.save_attachments(params[:attachments])
|
||||||
|
if @news.save
|
||||||
|
render_attachment_warning_if_needed(@news)
|
||||||
|
flash[:notice] = l(:notice_successful_create)
|
||||||
|
redirect_to course_news_index_path(@course)
|
||||||
|
else
|
||||||
|
layout_file = 'base_courses'
|
||||||
|
render :action => 'new', :layout => layout_file
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -111,7 +151,13 @@ class NewsController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@news.destroy
|
@news.destroy
|
||||||
redirect_to project_news_index_path(@project)
|
# modify by nwb
|
||||||
|
if @project
|
||||||
|
redirect_to project_news_index_path(@project)
|
||||||
|
elsif @course
|
||||||
|
redirect_to course_news_index_path(@course)
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -353,11 +353,6 @@ class ProjectsController < ApplicationController
|
||||||
#gcmend
|
#gcmend
|
||||||
|
|
||||||
|
|
||||||
# added by fq
|
|
||||||
def new_join
|
|
||||||
@course = Project.find(params[:object_id])
|
|
||||||
end
|
|
||||||
|
|
||||||
#Added by young
|
#Added by young
|
||||||
def homework
|
def homework
|
||||||
@offset, @limit = api_offset_and_limit({:limit => 10})
|
@offset, @limit = api_offset_and_limit({:limit => 10})
|
||||||
|
|
|
@ -5,6 +5,7 @@ class TagsController < ApplicationController
|
||||||
|
|
||||||
before_filter :require_admin,:only => :show
|
before_filter :require_admin,:only => :show
|
||||||
|
|
||||||
|
include CoursesHelper
|
||||||
include ProjectsHelper
|
include ProjectsHelper
|
||||||
include IssuesHelper
|
include IssuesHelper
|
||||||
include UsersHelper
|
include UsersHelper
|
||||||
|
@ -14,6 +15,7 @@ class TagsController < ApplicationController
|
||||||
include ContestsHelper
|
include ContestsHelper
|
||||||
include ActsAsTaggableOn::TagsHelper
|
include ActsAsTaggableOn::TagsHelper
|
||||||
helper :projects
|
helper :projects
|
||||||
|
helper :courses
|
||||||
include TagsHelper
|
include TagsHelper
|
||||||
helper :tags
|
helper :tags
|
||||||
include OpenSourceProjectsHelper
|
include OpenSourceProjectsHelper
|
||||||
|
@ -64,6 +66,7 @@ class TagsController < ApplicationController
|
||||||
# 获取搜索结果
|
# 获取搜索结果
|
||||||
@obj,@obj_pages,@results_count,@users_results,
|
@obj,@obj_pages,@results_count,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
|
@@courses_results,
|
||||||
@issues_results,
|
@issues_results,
|
||||||
@bids_results,
|
@bids_results,
|
||||||
@forums_results,
|
@forums_results,
|
||||||
|
@ -96,6 +99,7 @@ class TagsController < ApplicationController
|
||||||
# 获取搜索结果
|
# 获取搜索结果
|
||||||
@obj,@obj_pages,@results_count,@users_results,
|
@obj,@obj_pages,@results_count,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
|
@@courses_results,
|
||||||
@issues_results,
|
@issues_results,
|
||||||
@bids_results,
|
@bids_results,
|
||||||
@forums_results,
|
@forums_results,
|
||||||
|
@ -114,6 +118,7 @@ class TagsController < ApplicationController
|
||||||
# 获取搜索结果
|
# 获取搜索结果
|
||||||
@obj,@obj_pages,@results_count,@users_results,
|
@obj,@obj_pages,@results_count,@users_results,
|
||||||
@projects_results,
|
@projects_results,
|
||||||
|
@@courses_results,
|
||||||
@issues_results,
|
@issues_results,
|
||||||
@bids_results,
|
@bids_results,
|
||||||
@forums_results,
|
@forums_results,
|
||||||
|
@ -188,6 +193,7 @@ class TagsController < ApplicationController
|
||||||
@obj_pages = nil
|
@obj_pages = nil
|
||||||
@obj = nil
|
@obj = nil
|
||||||
@result = nil
|
@result = nil
|
||||||
|
@courses_results = nil
|
||||||
|
|
||||||
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
|
# 这里为了提高系统的响应速度 把搜索结果放到case中去了
|
||||||
case obj_flag
|
case obj_flag
|
||||||
|
@ -219,6 +225,9 @@ class TagsController < ApplicationController
|
||||||
when '8'
|
when '8'
|
||||||
@obj = OpenSourceProject.find_by_id(obj_id)
|
@obj = OpenSourceProject.find_by_id(obj_id)
|
||||||
@obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags))
|
@obj_pages, @open_source_projects_results, @results_count = for_pagination(get_open_source_projects_by_tag(selected_tags))
|
||||||
|
when '9' then
|
||||||
|
@obj = Course.find_by_id(obj_id)
|
||||||
|
@obj_pages, @courses_results, @results_count = for_pagination(get_courses_by_tag(selected_tags))
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
@ -232,6 +241,7 @@ class TagsController < ApplicationController
|
||||||
@forums_results,
|
@forums_results,
|
||||||
attachments_results,
|
attachments_results,
|
||||||
@contests_results,
|
@contests_results,
|
||||||
|
@courses_results,
|
||||||
@open_source_projects_results]
|
@open_source_projects_results]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -279,6 +289,8 @@ class TagsController < ApplicationController
|
||||||
return 'Contest'
|
return 'Contest'
|
||||||
when '8'
|
when '8'
|
||||||
return 'OpenSourceProject'
|
return 'OpenSourceProject'
|
||||||
|
when '9'
|
||||||
|
return 'Course'
|
||||||
else
|
else
|
||||||
render_error :message => e.message
|
render_error :message => e.message
|
||||||
return
|
return
|
||||||
|
|
|
@ -206,19 +206,19 @@ class UsersController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
membership = @user.memberships.all(:conditions => Project.visible_condition(User.current))
|
membership = @user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
|
||||||
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
membership.sort! {|older, newer| newer.created_on <=> older.created_on }
|
||||||
@memberships = []
|
@memberships = []
|
||||||
membership.collect { |e|
|
membership.collect { |e|
|
||||||
@memberships.push(e) if(e.project.project_type == 1)
|
@memberships.push(e)
|
||||||
}
|
}
|
||||||
## 判断课程是否过期 [需封装]
|
## 判断课程是否过期 [需封装]
|
||||||
@memberships_doing = []
|
@memberships_doing = []
|
||||||
@memberships_done = []
|
@memberships_done = []
|
||||||
now_time = Time.now.year
|
now_time = Time.now.year
|
||||||
@memberships.map { |e|
|
@memberships.map { |e|
|
||||||
end_time = e.project.course_extra.get_time.year
|
end_time = e.course.get_time.year
|
||||||
isDone = course_endTime_timeout?(e.project)
|
isDone = course_endTime_timeout?(e.course)
|
||||||
if isDone
|
if isDone
|
||||||
@memberships_done.push e
|
@memberships_done.push e
|
||||||
else
|
else
|
||||||
|
@ -675,6 +675,8 @@ class UsersController < ApplicationController
|
||||||
@obj = Contest.find_by_id(@obj_id)
|
@obj = Contest.find_by_id(@obj_id)
|
||||||
when '8'
|
when '8'
|
||||||
@obj = OpenSourceProject.find_by_id(@obj_id)
|
@obj = OpenSourceProject.find_by_id(@obj_id)
|
||||||
|
when '9'
|
||||||
|
@obj = Course.find_by_id(@obj_id)
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
@ -716,6 +718,8 @@ class UsersController < ApplicationController
|
||||||
@obj = Contest.find_by_id(@obj_id)
|
@obj = Contest.find_by_id(@obj_id)
|
||||||
when '8'
|
when '8'
|
||||||
@obj = OpenSourceProject.find_by_id(@obj_id)
|
@obj = OpenSourceProject.find_by_id(@obj_id)
|
||||||
|
when '9'
|
||||||
|
@obj = Course.find_by_id(@obj_id)
|
||||||
else
|
else
|
||||||
@obj = nil
|
@obj = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -164,6 +164,20 @@ class WordsController < ApplicationController
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# add by nwb
|
||||||
|
def leave_course_message
|
||||||
|
user = User.current
|
||||||
|
message = params[:new_form][:course_message]
|
||||||
|
feedback = Course.add_new_jour(user, message, params[:id])
|
||||||
|
if(feedback.errors.empty?)
|
||||||
|
redirect_to course_feedback_path(params[:id]), notice: l(:label_feedback_success)
|
||||||
|
else
|
||||||
|
flash[:error] = feedback.errors.full_messages[0]
|
||||||
|
redirect_to course_feedback_path(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
def add_brief_introdution
|
def add_brief_introdution
|
||||||
user = User.current
|
user = User.current
|
||||||
message = params[:new_form][:user_introduction]
|
message = params[:new_form][:user_introduction]
|
||||||
|
@ -182,10 +196,14 @@ class WordsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def obj_distinguish_url_origin
|
def obj_distinguish_url_origin
|
||||||
|
#modify by nwb
|
||||||
|
#添加对课程留言的支持
|
||||||
referer = request.headers["Referer"]
|
referer = request.headers["Referer"]
|
||||||
obj_id = referer.match(%r(/([0-9]{1,})(/|$)))[1]
|
obj_id = referer.match(%r(/([0-9]{1,})(/|$)))[1]
|
||||||
if referer.match(/project/)
|
if referer.match(/project/)
|
||||||
obj = Project.find_by_id(obj_id)
|
obj = Project.find_by_id(obj_id)
|
||||||
|
elsif referer.match(/course/)
|
||||||
|
obj = Course.find_by_id(obj_id)
|
||||||
elsif referer.match(/user/)
|
elsif referer.match(/user/)
|
||||||
obj = User.find_by_id(obj_id)
|
obj = User.find_by_id(obj_id)
|
||||||
elsif ( referer.match(/bids/) || referer.match(/calls/) )
|
elsif ( referer.match(/bids/) || referer.match(/calls/) )
|
||||||
|
@ -203,11 +221,15 @@ class WordsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_reply_adapter options
|
def add_reply_adapter options
|
||||||
|
#modify by nwb
|
||||||
|
#添加对课程留言的支持
|
||||||
obj = obj_distinguish_url_origin
|
obj = obj_distinguish_url_origin
|
||||||
if obj.kind_of? User
|
if obj.kind_of? User
|
||||||
obj.add_jour(nil, nil, nil, options)
|
obj.add_jour(nil, nil, nil, options)
|
||||||
elsif obj.kind_of? Project
|
elsif obj.kind_of? Project
|
||||||
Project.add_new_jour(nil, nil, obj.id, options)
|
Project.add_new_jour(nil, nil, obj.id, options)
|
||||||
|
elsif obj.kind_of? Course
|
||||||
|
Course.add_new_jour(nil, nil, obj.id, options)
|
||||||
elsif obj.kind_of? Bid
|
elsif obj.kind_of? Bid
|
||||||
obj.add_jour(nil, nil, nil, options)
|
obj.add_jour(nil, nil, nil, options)
|
||||||
elsif obj.kind_of? Contest
|
elsif obj.kind_of? Contest
|
||||||
|
|
|
@ -37,7 +37,7 @@ class ZipdownController < ApplicationController
|
||||||
#下载某一学生的作业的所有文件
|
#下载某一学生的作业的所有文件
|
||||||
def download_user_homework
|
def download_user_homework
|
||||||
homework = HomeworkAttach.find params[:homework]
|
homework = HomeworkAttach.find params[:homework]
|
||||||
if homework != nil && (User.current.admin? || User.current.member_of?(homework.bid.courses.first))
|
if homework != nil && (User.current.admin? || User.current.member_of_course?(homework.bid.courses.first))
|
||||||
zipfile = zip_homework_by_user homework
|
zipfile = zip_homework_by_user homework
|
||||||
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
|
send_file zipfile, :filename => homework.name+".zip", :type => detect_content_type(zipfile) if zipfile
|
||||||
else
|
else
|
||||||
|
|
|
@ -47,6 +47,11 @@ module ApplicationHelper
|
||||||
User.current.allowed_to?({:controller => controller, :action => action}, @project)
|
User.current.allowed_to?({:controller => controller, :action => action}, @project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# add by nwb
|
||||||
|
def authorize_for_course(controller, action)
|
||||||
|
User.current.allowed_to?({:controller => controller, :action => action}, @course)
|
||||||
|
end
|
||||||
|
|
||||||
def authorize_for_contest(controller, action)
|
def authorize_for_contest(controller, action)
|
||||||
User.current.allowed_to?({:controller => controller, :action => action}, @contest)
|
User.current.allowed_to?({:controller => controller, :action => action}, @contest)
|
||||||
end
|
end
|
||||||
|
@ -177,6 +182,18 @@ module ApplicationHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def link_to_course(course, options={}, html_options = nil)
|
||||||
|
if course.archived?
|
||||||
|
h(course.name)
|
||||||
|
elsif options.key?(:action)
|
||||||
|
ActiveSupport::Deprecation.warn "#link_to_course with :action option is deprecated and will be removed in Redmine 3.0."
|
||||||
|
url = {:controller => 'courses', :action => 'show', :id => project}.merge(options)
|
||||||
|
link_to course.name, url, html_options
|
||||||
|
else
|
||||||
|
link_to course.name, course_path(course, options), html_options
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Generates a link to a project settings if active
|
# Generates a link to a project settings if active
|
||||||
def link_to_project_settings(project, options={}, html_options=nil)
|
def link_to_project_settings(project, options={}, html_options=nil)
|
||||||
if project.active?
|
if project.active?
|
||||||
|
@ -303,7 +320,41 @@ module ApplicationHelper
|
||||||
@project = original_project
|
@project = original_project
|
||||||
end
|
end
|
||||||
s.html_safe
|
s.html_safe
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_course_nested_lists(courses)
|
||||||
|
s = ''
|
||||||
|
if courses.any?
|
||||||
|
ancestors = []
|
||||||
|
original_course = @course
|
||||||
|
#modified by nie
|
||||||
|
courses.each do |course|
|
||||||
|
# set the project environment to please macros.
|
||||||
|
@course = course
|
||||||
|
if (ancestors.empty? )#|| course.is_descendant_of?(ancestors.last))
|
||||||
|
s << "<ul class=courses'>\n"
|
||||||
|
else
|
||||||
|
ancestors.pop
|
||||||
|
s << "</li>"
|
||||||
|
while (ancestors.any? )#&& !course.is_descendant_of?(ancestors.last))
|
||||||
|
ancestors.pop
|
||||||
|
s << "</ul></li>\n"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
classes = (ancestors.empty? ? 'root' : 'child')
|
||||||
|
s << "<li class='project-table'><div class='#{classes}'>"
|
||||||
|
|
||||||
|
s << (render :partial => 'courses/course', :locals => {:course => course}).to_s
|
||||||
|
s << "</div>\n"
|
||||||
|
ancestors << course
|
||||||
|
end
|
||||||
|
s << ("</li></ul>\n" * ancestors.size)
|
||||||
|
@course = original_course
|
||||||
|
end
|
||||||
|
s.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
#added by young
|
#added by young
|
||||||
def render_project_nested_lists_new(projects)
|
def render_project_nested_lists_new(projects)
|
||||||
s = ''
|
s = ''
|
||||||
|
@ -1645,9 +1696,9 @@ module ApplicationHelper
|
||||||
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
|
main_project_link = link_to l(:label_project_deposit), {:controller => 'welcome', :action => 'index', :host => Setting.project_domain}
|
||||||
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
|
main_contest_link = link_to l(:label_contest_innovate), {:controller => 'welcome', :action => 'index', :host => Setting.contest_domain}
|
||||||
|
|
||||||
course_all_course_link = link_to l(:label_course_all), {:controller => 'projects', :action => 'course', :project_type => 1, :host => Setting.course_domain}
|
course_all_course_link = link_to l(:label_course_all), {:controller => 'courses', :action => 'index'}
|
||||||
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain}
|
course_teacher_all_link = link_to l(:label_teacher_all), {:controller => 'users', :action => 'index', :role => 'teacher', :host => Setting.course_domain}
|
||||||
courses_link = link_to l(:label_course_practice), {:controller => 'projects', :action => 'course', :project_type => 1, :host => Setting.course_domain}
|
courses_link = link_to l(:label_course_practice), {:controller => 'courses', :action => 'index'}
|
||||||
projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}
|
projects_link = link_to l(:label_project_deposit), {:controller => 'projects', :action => 'index', :project_type => 0, :host => Setting.project_domain}
|
||||||
users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain}
|
users_link = link_to l(:label_software_user), {:controller => 'users', :action => 'index', :host => Setting.user_domain}
|
||||||
contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'}
|
contest_link = link_to l(:label_contest_innovate), {:controller => 'contests', :action => 'index'}
|
||||||
|
|
|
@ -42,7 +42,7 @@ module AvatarHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_avatar?(source)
|
def get_avatar?(source)
|
||||||
if File.exist?(disk_filename(source.class,source.id))
|
if source && File.exist?(disk_filename(source.class,source.id))
|
||||||
return true
|
return true
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -29,6 +29,19 @@ module BoardsHelper
|
||||||
breadcrumb links
|
breadcrumb links
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# add by nwb
|
||||||
|
def course_board_breadcrumb(item)
|
||||||
|
board = item.is_a?(Message) ? item.board : item
|
||||||
|
links = [link_to(l(:label_board_plural), course_boards_path(item.course))]
|
||||||
|
boards = board.ancestors.reverse
|
||||||
|
if item.is_a?(Message)
|
||||||
|
boards << board
|
||||||
|
end
|
||||||
|
links += boards.map {|ancestor| link_to(h(ancestor.name), course_board_path(ancestor.course, ancestor))}
|
||||||
|
breadcrumb links
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def boards_options_for_select(boards)
|
def boards_options_for_select(boards)
|
||||||
options = []
|
options = []
|
||||||
Board.board_tree(boards) do |board, level|
|
Board.board_tree(boards) do |board, level|
|
||||||
|
|
|
@ -57,6 +57,7 @@ module ContestsHelper
|
||||||
#end
|
#end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#huang
|
#huang
|
||||||
def sort_contest(state)
|
def sort_contest(state)
|
||||||
content = ''.html_safe
|
content = ''.html_safe
|
||||||
|
|
|
@ -31,6 +31,39 @@ module CoursesHelper
|
||||||
# searchStudent(project).count
|
# searchStudent(project).count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 判断用户是否是课程的管理员
|
||||||
|
# add by nwb
|
||||||
|
def is_course_manager?(user_id,course_id)
|
||||||
|
@result = false
|
||||||
|
@user_id = CourseInfo.find_by_course_id(course_id)
|
||||||
|
if @user_id == user.id
|
||||||
|
@result = true
|
||||||
|
end
|
||||||
|
return @result
|
||||||
|
end
|
||||||
|
|
||||||
|
# 返回课程设置界面
|
||||||
|
def course_settings_tabs
|
||||||
|
tabs = [{:name => 'info', :action => :edit_course, :partial => 'courses/edit', :label => :label_information_plural},
|
||||||
|
{:name => 'members', :action => :manage_members, :partial => 'courses/settings/members', :label => :label_member_plural}
|
||||||
|
]
|
||||||
|
tabs.select { |tab| User.current.allowed_to?(tab[:action], @course) }
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
#是否启动互评下拉框
|
||||||
|
def is_evaluation_option
|
||||||
|
type = []
|
||||||
|
option1 = []
|
||||||
|
option2 = []
|
||||||
|
option1 << l(:lable_start_mutual_evaluation)
|
||||||
|
option1 << 1
|
||||||
|
option2 << l(:lable_close_mutual_evaluation)
|
||||||
|
option2 << 2
|
||||||
|
type << option1
|
||||||
|
type << option2
|
||||||
|
end
|
||||||
|
|
||||||
# garble count 混淆数量
|
# garble count 混淆数量
|
||||||
# alias projectCountOrigin projectCount
|
# alias projectCountOrigin projectCount
|
||||||
# def projectCount project
|
# def projectCount project
|
||||||
|
@ -38,6 +71,19 @@ module CoursesHelper
|
||||||
# garble count
|
# garble count
|
||||||
# end
|
# end
|
||||||
|
|
||||||
|
def homework_type_option
|
||||||
|
type = []
|
||||||
|
option1 = []
|
||||||
|
option2 = []
|
||||||
|
option1 << l(:label_task_submit_form_accessory)
|
||||||
|
option1 << 1
|
||||||
|
option2 << l(:label_task_submit_form_project)
|
||||||
|
option2 << 2
|
||||||
|
type << option1
|
||||||
|
type << option2
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
alias teacherCountOrigin teacherCount
|
alias teacherCountOrigin teacherCount
|
||||||
def teacherCount project
|
def teacherCount project
|
||||||
count = teacherCountOrigin project
|
count = teacherCountOrigin project
|
||||||
|
@ -45,11 +91,26 @@ module CoursesHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
alias studentCountOrigin studentCount
|
alias studentCountOrigin studentCount
|
||||||
def studentCount project
|
def studentCount course
|
||||||
count = studentCountOrigin project
|
count = studentCountOrigin course
|
||||||
garble count
|
garble count
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def eventToLanguageCourse event_type, course
|
||||||
|
case event_type
|
||||||
|
when "issue-note"
|
||||||
|
l :label_issue
|
||||||
|
when "issue"
|
||||||
|
l :label_issue
|
||||||
|
when "attachment"
|
||||||
|
l :label_attachment
|
||||||
|
when "news"
|
||||||
|
l :label_notification
|
||||||
|
else
|
||||||
|
""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def garble count
|
def garble count
|
||||||
count = count.round( 1-count.to_s.size ).to_i
|
count = count.round( 1-count.to_s.size ).to_i
|
||||||
return count.to_s if count.to_s.size.eql?(1)
|
return count.to_s if count.to_s.size.eql?(1)
|
||||||
|
@ -82,6 +143,35 @@ module CoursesHelper
|
||||||
members
|
members
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sort_courses(state)
|
||||||
|
content = ''.html_safe
|
||||||
|
case state
|
||||||
|
when 0
|
||||||
|
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1')))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2')))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0'), :class=>"selected"), :class=>"selected")
|
||||||
|
when 1
|
||||||
|
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1'), :class=>"selected"), :class=>"selected")
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2')))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0')))
|
||||||
|
when 2
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:courses_sort_type => '1')))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_influence), courses_path(:courses_sort_type => '2'), :class=>"selected"), :class=>"selected")
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:courses_sort_type => '0')))
|
||||||
|
end
|
||||||
|
content = content_tag('ul', content)
|
||||||
|
content_tag('div', content, :class => "tabs")
|
||||||
|
end
|
||||||
|
|
||||||
|
def render_course_hierarchy(courses)
|
||||||
|
render_course_nested_lists(courses) do |course|
|
||||||
|
s = link_to_course(course, {}, :class => "#{course.css_classes} #{User.current.member_of?(course) ? 'my-course' : nil}").html_safe
|
||||||
|
s
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
#useless
|
#useless
|
||||||
def searchMembersByRole project, role_id
|
def searchMembersByRole project, role_id
|
||||||
members = []
|
members = []
|
||||||
|
@ -93,6 +183,36 @@ module CoursesHelper
|
||||||
members
|
members
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def sort_course(state, school_id)
|
||||||
|
content = ''.html_safe
|
||||||
|
case state
|
||||||
|
when 0
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0'), :school_id => school_id, :class=>"selected"), :class=>"selected")
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id)))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id)))
|
||||||
|
|
||||||
|
when 1
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id)))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id), :class=>"selected"), :class=>"selected")
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id)))
|
||||||
|
|
||||||
|
when 2
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id)))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id)))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id)))
|
||||||
|
|
||||||
|
#gcm
|
||||||
|
when 3
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_time), courses_path(:course_sort_type => '0', :school_id => school_id)))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_active), courses_path(:course_sort_type => '1', :school_id => school_id)))
|
||||||
|
content << content_tag('li', link_to(l(:label_sort_by_activity), courses_path(:course_sort_type => '3', :school_id => school_id), :class=>"selected"), :class=>"selected")
|
||||||
|
end
|
||||||
|
#gcmend
|
||||||
|
|
||||||
|
content = content_tag('ul', content)
|
||||||
|
content_tag('div', content, :class => "tabs")
|
||||||
|
end
|
||||||
|
|
||||||
def findCourseTime project
|
def findCourseTime project
|
||||||
str = ""
|
str = ""
|
||||||
begin
|
begin
|
||||||
|
@ -109,8 +229,9 @@ module CoursesHelper
|
||||||
str
|
str
|
||||||
end
|
end
|
||||||
|
|
||||||
def get_course_term project
|
# added by nwb
|
||||||
str = ( project.try(:course_extra).try(:time).to_s << '.' << project.try(:course_extra).try(:term).to_s )
|
def get_course_term course
|
||||||
|
str = ( course.try(:time).to_s << '.' << course.try(:term).to_s )
|
||||||
str[0..-4]
|
str[0..-4]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -123,7 +244,7 @@ module CoursesHelper
|
||||||
end
|
end
|
||||||
# 截至到2014-03-17 这个是最终的判断课程是否过期的方法
|
# 截至到2014-03-17 这个是最终的判断课程是否过期的方法
|
||||||
def course_endTime_timeout? project
|
def course_endTime_timeout? project
|
||||||
end_time_str = Course.find_by_extra(project.try(:identifier)).try(:endup_time)
|
end_time_str = Course.find_by_extra(project.try(:extra)).try(:endup_time)
|
||||||
begin
|
begin
|
||||||
cTime = Time.parse(end_time_str.to_s)
|
cTime = Time.parse(end_time_str.to_s)
|
||||||
rescue TypeError,ArgumentError
|
rescue TypeError,ArgumentError
|
||||||
|
|
|
@ -33,6 +33,24 @@ module MembersHelper
|
||||||
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# add by nwb
|
||||||
|
# 课程可添加的成员列表
|
||||||
|
def render_principals_for_new_course_members(course)
|
||||||
|
scope = Principal.active.sorted.not_member_of_course(course).like(params[:q])
|
||||||
|
principal_count = scope.count
|
||||||
|
principal_pages = Redmine::Pagination::Paginator.new principal_count, 10, params['page']
|
||||||
|
principals = scope.offset(principal_pages.offset).limit(principal_pages.per_page).all
|
||||||
|
|
||||||
|
s = content_tag('div', principals_check_box_tags_ex('membership[user_ids][]', principals), :id => 'principals')
|
||||||
|
|
||||||
|
links = pagination_links_full(principal_pages, principal_count, :per_page_links => false) {|text, parameters, options|
|
||||||
|
link_to text, autocomplete_course_memberships_path(course, parameters.merge(:q => params[:q], :format => 'js')), :remote => true
|
||||||
|
}
|
||||||
|
|
||||||
|
s + content_tag('div', content_tag('ul', links), :class => 'pagination_new')
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
# 当前申请加入的成员名单
|
# 当前申请加入的成员名单
|
||||||
def render_principals_for_applied_members(project)
|
def render_principals_for_applied_members(project)
|
||||||
scope = Principal.active.sorted.applied_members(project).like(params[:q])
|
scope = Principal.active.sorted.applied_members(project).like(params[:q])
|
||||||
|
|
|
@ -16,6 +16,8 @@ module TagsHelper
|
||||||
@obj = Attachment.find_by_id(obj_id)
|
@obj = Attachment.find_by_id(obj_id)
|
||||||
when '7'
|
when '7'
|
||||||
@obj= Contest.find_by_id(obj_id)
|
@obj= Contest.find_by_id(obj_id)
|
||||||
|
when '9'
|
||||||
|
@obj= Course.find_by_id(obj_id)
|
||||||
else
|
else
|
||||||
raise Exception, '[TagsHelper] ===> tag type unknow.'
|
raise Exception, '[TagsHelper] ===> tag type unknow.'
|
||||||
end
|
end
|
||||||
|
@ -46,6 +48,8 @@ module TagsHelper
|
||||||
if user.id == obj_id
|
if user.id == obj_id
|
||||||
@result = true
|
@result = true
|
||||||
end
|
end
|
||||||
|
when '9'
|
||||||
|
@result = is_course_manager?(user.id,obj_id)
|
||||||
end
|
end
|
||||||
return @result
|
return @result
|
||||||
end
|
end
|
||||||
|
|
|
@ -71,7 +71,10 @@ module WatchersHelper
|
||||||
# Somebody may use option params
|
# Somebody may use option params
|
||||||
def join_in_course(course, user, options=[])
|
def join_in_course(course, user, options=[])
|
||||||
return '' unless user && user.logged?
|
return '' unless user && user.logged?
|
||||||
joined = user.member_of?(course)
|
# modify by nwb
|
||||||
|
# 主讲教师不允许退出课程
|
||||||
|
return '' if user.id == course.tea_id
|
||||||
|
joined = user.member_of_course?(course)
|
||||||
text = joined ? l(:label_exit_course) : l(:label_join_course)
|
text = joined ? l(:label_exit_course) : l(:label_join_course)
|
||||||
url_t = join_path(:object_id => course.id)
|
url_t = join_path(:object_id => course.id)
|
||||||
url_f = try_join_path(:object_id => course.id)
|
url_f = try_join_path(:object_id => course.id)
|
||||||
|
@ -83,9 +86,14 @@ module WatchersHelper
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 用户是否允许加入课程判断
|
||||||
|
# add by nwb
|
||||||
def join_in_course_for_list(course, user, options=[])
|
def join_in_course_for_list(course, user, options=[])
|
||||||
return '' unless user && user.logged?
|
return '' unless user && user.logged?
|
||||||
joined = user.member_of?(course)
|
# modify by nwb
|
||||||
|
# 主讲教师不允许退出课程
|
||||||
|
return '' if user.id == course.tea_id
|
||||||
|
joined = user.member_of_course?(course)
|
||||||
text = joined ? l(:label_exit_course) : l(:label_join_course)
|
text = joined ? l(:label_exit_course) : l(:label_join_course)
|
||||||
url_t = join_path(:object_id => course.id)
|
url_t = join_path(:object_id => course.id)
|
||||||
url_f = try_join_path(:object_id => course.id)
|
url_f = try_join_path(:object_id => course.id)
|
||||||
|
|
|
@ -21,6 +21,7 @@ require "fileutils"
|
||||||
class Attachment < ActiveRecord::Base
|
class Attachment < ActiveRecord::Base
|
||||||
belongs_to :container, :polymorphic => true
|
belongs_to :container, :polymorphic => true
|
||||||
belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'"
|
belongs_to :project, foreign_key: 'container_id', conditions: "attachments.container_type = 'Project'"
|
||||||
|
belongs_to :course, foreign_key: 'container_id', conditions: "attachments.container_type = 'Course'"
|
||||||
belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'"
|
belongs_to :softapplication, foreign_key: 'container_id', conditions: "attachments.container_type = 'Softapplication'"
|
||||||
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
belongs_to :author, :class_name => "User", :foreign_key => "author_id"
|
||||||
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
|
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
|
||||||
|
@ -30,12 +31,20 @@ class Attachment < ActiveRecord::Base
|
||||||
validates_length_of :disk_filename, :maximum => 255
|
validates_length_of :disk_filename, :maximum => 255
|
||||||
validates_length_of :description, :maximum => 255
|
validates_length_of :description, :maximum => 255
|
||||||
validate :validate_max_file_size
|
validate :validate_max_file_size
|
||||||
acts_as_taggable
|
|
||||||
|
|
||||||
|
|
||||||
|
acts_as_taggable
|
||||||
acts_as_event :title => :filename,
|
acts_as_event :title => :filename,
|
||||||
:url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}}
|
:url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id, :filename => o.filename}}
|
||||||
|
|
||||||
acts_as_activity_provider :type => 'files',
|
#课程资源文件
|
||||||
|
acts_as_activity_provider :type => 'course_files',
|
||||||
|
:permission => :view_files,
|
||||||
|
:author_key => :author_id,
|
||||||
|
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||||
|
:joins => "LEFT JOIN #{Course.table_name} ON ( #{Attachment.table_name}.container_type='Course' AND #{Attachment.table_name}.container_id = #{Course.table_name}.id )"}
|
||||||
|
|
||||||
|
acts_as_activity_provider :type => 'files',
|
||||||
:permission => :view_files,
|
:permission => :view_files,
|
||||||
:author_key => :author_id,
|
:author_key => :author_id,
|
||||||
:find_options => {:select => "#{Attachment.table_name}.*",
|
:find_options => {:select => "#{Attachment.table_name}.*",
|
||||||
|
@ -186,6 +195,10 @@ class Attachment < ActiveRecord::Base
|
||||||
container.try(:project)
|
container.try(:project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def course
|
||||||
|
container
|
||||||
|
end
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
if container_id
|
if container_id
|
||||||
container && container.attachments_visible?(user)
|
container && container.attachments_visible?(user)
|
||||||
|
|
|
@ -22,11 +22,11 @@ class Bid < ActiveRecord::Base
|
||||||
belongs_to :course
|
belongs_to :course
|
||||||
has_many :biding_projects, :dependent => :destroy
|
has_many :biding_projects, :dependent => :destroy
|
||||||
has_many :projects, :through => :biding_projects
|
has_many :projects, :through => :biding_projects
|
||||||
has_many :projects_member, :class_name => 'User', :through => :projects
|
has_many :courses_member, :class_name => 'User', :through => :courses
|
||||||
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||||
has_many :homework_for_courses, :dependent => :destroy
|
has_many :homework_for_courses, :dependent => :destroy
|
||||||
has_many :courses, :through => :homework_for_courses, :source => :project
|
has_many :courses, :through => :homework_for_courses, :source => :course
|
||||||
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
|
has_many :homeworks, :class_name => 'HomeworkAttach', :dependent => :destroy
|
||||||
has_many :join_in_contests, :dependent => :destroy
|
has_many :join_in_contests, :dependent => :destroy
|
||||||
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
class Board < ActiveRecord::Base
|
class Board < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
belongs_to :course
|
||||||
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
|
has_many :topics, :class_name => 'Message', :conditions => "#{Message.table_name}.parent_id IS NULL", :order => "#{Message.table_name}.created_on DESC"
|
||||||
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
|
has_many :messages, :dependent => :destroy, :order => "#{Message.table_name}.created_on DESC"
|
||||||
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
|
belongs_to :last_message, :class_name => 'Message', :foreign_key => :last_message_id
|
||||||
|
|
|
@ -1,13 +1,44 @@
|
||||||
class Course < ActiveRecord::Base
|
class Course < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
|
|
||||||
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password
|
STATUS_ACTIVE = 1
|
||||||
belongs_to :project, :class_name => 'Project', :foreign_key => :extra, primary_key: :identifier
|
STATUS_CLOSED = 5
|
||||||
|
STATUS_ARCHIVED = 9
|
||||||
|
|
||||||
|
attr_accessible :code, :extra, :name, :state, :tea_id, :time , :location, :state, :term, :password,:is_public,:description,:class_period
|
||||||
|
belongs_to :project, :class_name => 'Course', :foreign_key => :extra, primary_key: :identifier
|
||||||
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
|
belongs_to :teacher, :class_name => 'User', :foreign_key => :tea_id # 定义一个方法teacher,该方法通过tea_id来调用User表
|
||||||
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表
|
belongs_to :school, :class_name => 'School', :foreign_key => :school_id #定义一个方法school,该方法通过school_id来调用School表
|
||||||
has_many :bid
|
has_many :bid
|
||||||
|
|
||||||
|
has_many :members, :include => [:principal, :roles], :conditions => "#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE}"
|
||||||
|
has_many :memberships, :class_name => 'Member'
|
||||||
|
has_many :member_principals, :class_name => 'Member',
|
||||||
|
:include => :principal,
|
||||||
|
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
||||||
|
has_many :principals, :through => :member_principals, :source => :principal
|
||||||
|
has_many :users, :through => :members
|
||||||
|
has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy
|
||||||
|
has_many :journals_for_messages, :as => :jour, :dependent => :destroy
|
||||||
|
has_many :homework_for_courses, :dependent => :destroy
|
||||||
|
has_many :student, :through => :students_for_courses, :source => :user
|
||||||
|
has_many :course_infos, :class_name => 'CourseInfos',:dependent => :destroy
|
||||||
|
has_many :enabled_modules, :dependent => :delete_all
|
||||||
|
has_many :boards, :dependent => :destroy, :order => "position ASC"
|
||||||
|
#has_many :course_journals_for_messages, :class_name => 'CourseJournalsForMessage', :as => :jour, :dependent => :destroy
|
||||||
|
has_many :news, :dependent => :destroy, :include => :author
|
||||||
|
|
||||||
|
acts_as_taggable
|
||||||
|
acts_as_nested_set :order => 'name', :dependent => :destroy
|
||||||
|
acts_as_attachable :view_permission => :view_files,
|
||||||
|
:delete_permission => :manage_files
|
||||||
|
|
||||||
validates_presence_of :password, :term
|
validates_presence_of :password, :term
|
||||||
validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/
|
validates_format_of :class_period, :message => "class period can only digital!", :with =>/^[1-9]\d*$/
|
||||||
|
|
||||||
|
after_save :create_board_sync
|
||||||
|
before_destroy :delete_all_members
|
||||||
|
|
||||||
safe_attributes 'extra',
|
safe_attributes 'extra',
|
||||||
'time',
|
'time',
|
||||||
'name',
|
'name',
|
||||||
|
@ -17,15 +48,162 @@ class Course < ActiveRecord::Base
|
||||||
'tea_id',
|
'tea_id',
|
||||||
'password',
|
'password',
|
||||||
'term',
|
'term',
|
||||||
'password'
|
'is_public',
|
||||||
|
'description',
|
||||||
|
'class_period'
|
||||||
|
|
||||||
#自定义验证
|
acts_as_customizable
|
||||||
|
|
||||||
|
scope :all_course
|
||||||
|
scope :active, lambda { where(:status => STATUS_ACTIVE) }
|
||||||
|
scope :status, lambda {|arg| where(arg.blank? ? nil : {:status => arg.to_i}) }
|
||||||
|
scope :all_public, lambda { where(:is_public => true) }
|
||||||
|
scope :visible, lambda {|*args| where(Course.visible_condition(args.shift || User.current, *args)) }
|
||||||
|
scope :allowed_to, lambda {|*args|
|
||||||
|
user = User.current
|
||||||
|
permission = nil
|
||||||
|
if args.first.is_a?(Symbol)
|
||||||
|
permission = args.shift
|
||||||
|
else
|
||||||
|
user = args.shift
|
||||||
|
permission = args.shift
|
||||||
|
end
|
||||||
|
where(Course.allowed_to_condition(user, permission, *args))
|
||||||
|
}
|
||||||
|
scope :like, lambda {|arg|
|
||||||
|
if arg.blank?
|
||||||
|
where(nil)
|
||||||
|
else
|
||||||
|
pattern = "%#{arg.to_s.strip.downcase}%"
|
||||||
|
where("LOWER(extra) LIKE :p OR LOWER(name) LIKE :p ", :p => pattern)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
|
def visible?(user=User.current)
|
||||||
|
user.allowed_to?(:view_course, self)
|
||||||
|
end
|
||||||
|
|
||||||
|
def parent_id_changed?
|
||||||
|
false
|
||||||
|
end
|
||||||
|
|
||||||
|
# 课程的短描述信息
|
||||||
|
def short_description(length = 255)
|
||||||
|
description.gsub(/^(.{#{length}}[^\n\r]*).*$/m, '\1...').strip if description
|
||||||
|
end
|
||||||
|
|
||||||
|
def extra_frozen?
|
||||||
|
errors[:extra].blank? && !(new_record? || extra.blank?)
|
||||||
|
end
|
||||||
|
|
||||||
|
def archived?
|
||||||
|
self.status == STATUS_ARCHIVED
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.visible_condition(user, options={})
|
||||||
|
allowed_to_condition(user, :view_course, options)
|
||||||
|
end
|
||||||
|
|
||||||
|
# 获取课程的资源类型列表
|
||||||
|
def attachmenttypes
|
||||||
|
@attachmenttypes = Attachmentstype.find(:all, :conditions => ["#{Attachmentstype.table_name}.typeId= ?",self.attachmenttype ])
|
||||||
|
end
|
||||||
|
|
||||||
|
# 获取资源后缀名列表
|
||||||
|
def contenttypes
|
||||||
|
attachmenttypes
|
||||||
|
if @attachmenttypes.length >0
|
||||||
|
@attachmenttypes.last().suffixArr
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def active?
|
||||||
|
self.status == STATUS_ACTIVE
|
||||||
|
end
|
||||||
|
|
||||||
|
#课程权限判断
|
||||||
|
def allows_to?(action)
|
||||||
|
if archived?
|
||||||
|
# No action allowed on archived projects
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
unless active? || Redmine::AccessControl.read_action?(action)
|
||||||
|
# No write action allowed on closed projects
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
# No action allowed on disabled modules
|
||||||
|
if action.is_a? Hash
|
||||||
|
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
|
||||||
|
else
|
||||||
|
allowed_permissions.include? action
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 课程允许的权限集合
|
||||||
|
def allowed_permissions
|
||||||
|
@allowed_permissions ||= begin
|
||||||
|
module_names = enabled_modules.all(:select => :name).collect {|m| m.name}
|
||||||
|
Redmine::AccessControl.modules_permissions(module_names).collect {|p| p.name}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 课程允许的动作集合
|
||||||
|
def allowed_actions
|
||||||
|
@actions_allowed ||= allowed_permissions.inject([]) { |actions, permission| actions += Redmine::AccessControl.allowed_actions(permission) }.flatten
|
||||||
|
end
|
||||||
|
|
||||||
|
# 返回用户组可以访问的课程
|
||||||
|
def users_by_role
|
||||||
|
members.includes(:user, :roles).all.inject({}) do |h, m|
|
||||||
|
m.roles.each do |r|
|
||||||
|
h[r] ||= []
|
||||||
|
h[r] << m.user
|
||||||
|
end
|
||||||
|
h
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
#自定义验证
|
||||||
def validate
|
def validate
|
||||||
if !class_period.match([0-9])
|
if !class_period.match([0-9])
|
||||||
errors.add_to_base("class period can only digital")
|
errors.add_to_base("class period can only digital")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 创建课程讨论区
|
||||||
|
def create_board_sync
|
||||||
|
@board = self.boards.build
|
||||||
|
self.name=" #{l(:label_borad_course) }"
|
||||||
|
@board.name = self.name
|
||||||
|
@board.description = self.name.to_s
|
||||||
|
@board.project_id = -1
|
||||||
|
if @board.save
|
||||||
|
logger.debug "[Course Model] ===> #{@board.to_json}"
|
||||||
|
else
|
||||||
|
logger.error "[Course Model] ===> Auto create board when course saved, because #{@board.full_messages}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# 新增课程留言
|
||||||
|
# add by nwb
|
||||||
|
def self.add_new_jour(user, notes, id, options={})
|
||||||
|
course = Course.find(id)
|
||||||
|
if options.count == 0
|
||||||
|
pjfm = course.journals_for_messages.build(:user_id => user.id, :notes => notes, :reply_id => 0)
|
||||||
|
else
|
||||||
|
pjfm = course.journals_for_messages.build(options)
|
||||||
|
end
|
||||||
|
pjfm.save
|
||||||
|
pjfm
|
||||||
|
end
|
||||||
|
|
||||||
|
# 删除课程所有成员
|
||||||
|
def delete_all_members
|
||||||
|
me, mr = Member.table_name, MemberRole.table_name
|
||||||
|
connection.delete("DELETE FROM #{mr} WHERE #{mr}.member_id IN (SELECT #{me}.id FROM #{me} WHERE #{me}.course_id = #{id})")
|
||||||
|
Member.delete_all(['course_id = ?', id])
|
||||||
|
end
|
||||||
|
|
||||||
def get_endup_time
|
def get_endup_time
|
||||||
begin
|
begin
|
||||||
end_time = Time.parse(self.endup_time)
|
end_time = Time.parse(self.endup_time)
|
||||||
|
@ -47,4 +225,50 @@ class Course < ActiveRecord::Base
|
||||||
return time
|
return time
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.allowed_to_condition(user, permission, options={})
|
||||||
|
perm = Redmine::AccessControl.permission(permission)
|
||||||
|
base_statement = (perm && perm.read? ? "#{Course.table_name}.status <> #{Course::STATUS_ARCHIVED}" : "#{Course.table_name}.status = #{Course::STATUS_ACTIVE}")
|
||||||
|
if perm && perm.course_module
|
||||||
|
base_statement << " AND #{Course.table_name}.id IN (SELECT em.course_id FROM #{EnabledModule.table_name} em WHERE em.name='#{perm.course_module}')"
|
||||||
|
end
|
||||||
|
|
||||||
|
if options[:course]
|
||||||
|
course_statement = "#{Course.table_name}.id = #{options[:course].id}"
|
||||||
|
course_statement << " OR (#{Course.table_name}.lft > #{options[:course].lft} AND #{Course.table_name}.rgt < #{options[:course].rgt})" if options[:with_subcourses]
|
||||||
|
base_statement = "(#{course_statement}) AND (#{base_statement})"
|
||||||
|
end
|
||||||
|
|
||||||
|
if user.admin?
|
||||||
|
base_statement
|
||||||
|
else
|
||||||
|
statement_by_role = {}
|
||||||
|
unless options[:member]
|
||||||
|
role = user.logged? ? Role.non_member : Role.anonymous
|
||||||
|
if role.allowed_to?(permission)
|
||||||
|
statement_by_role[role] = "#{Course.table_name}.is_public = #{connection.quoted_true}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if user.logged?
|
||||||
|
user.courses_by_role.each do |role, courses|
|
||||||
|
if role.allowed_to?(permission) && courses.any?
|
||||||
|
statement_by_role[role] = "#{Course.table_name}.id IN (#{courses.collect(&:id).join(',')})"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if statement_by_role.empty?
|
||||||
|
"1=0"
|
||||||
|
else
|
||||||
|
if block_given?
|
||||||
|
statement_by_role.each do |role, statement|
|
||||||
|
if s = yield(role, user)
|
||||||
|
statement_by_role[role] = "(#{statement} AND (#{s}))"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
"((#{base_statement}) AND (#{statement_by_role.values.join(' OR ')}))"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
class CourseInfos < ActiveRecord::Base
|
||||||
|
attr_accessible :user_id, :course_id
|
||||||
|
belongs_to :user
|
||||||
|
belongs_to :course
|
||||||
|
end
|
|
@ -0,0 +1,3 @@
|
||||||
|
class CourseStatus < ActiveRecord::Base
|
||||||
|
attr_accessible :changesets_count, :course_ac_para, :course_id, :grade, :watchers_count
|
||||||
|
end
|
|
@ -1,8 +1,8 @@
|
||||||
class HomeworkForCourse < ActiveRecord::Base
|
class HomeworkForCourse < ActiveRecord::Base
|
||||||
attr_accessible :bid_id, :project_id
|
attr_accessible :bid_id, :course_id
|
||||||
|
|
||||||
belongs_to :bid
|
belongs_to :bid
|
||||||
belongs_to :project
|
belongs_to :course
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,9 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
belongs_to :project,
|
belongs_to :project,
|
||||||
:foreign_key => 'jour_id',
|
:foreign_key => 'jour_id',
|
||||||
:conditions => "#{self.table_name}.jour_type = 'Project' "
|
:conditions => "#{self.table_name}.jour_type = 'Project' "
|
||||||
|
belongs_to :course,
|
||||||
|
:foreign_key => 'jour_id',
|
||||||
|
:conditions => "#{self.table_name}.jour_type = 'Course' "
|
||||||
|
|
||||||
belongs_to :jour, :polymorphic => true
|
belongs_to :jour, :polymorphic => true
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
@ -36,6 +39,12 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
:timestamp => "#{self.table_name}.updated_on",
|
:timestamp => "#{self.table_name}.updated_on",
|
||||||
:find_options => {:include => :project }
|
:find_options => {:include => :project }
|
||||||
|
|
||||||
|
acts_as_activity_provider :type => 'course_journals_for_messages',
|
||||||
|
:author_key => :user_id,
|
||||||
|
:timestamp => "#{self.table_name}.updated_on",
|
||||||
|
:find_options => {:include => :course }
|
||||||
|
|
||||||
|
|
||||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||||
|
|
||||||
validates :notes, presence: true
|
validates :notes, presence: true
|
||||||
|
@ -89,6 +98,8 @@ class JournalsForMessage < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
elsif self.jour_type == 'Project'
|
elsif self.jour_type == 'Project'
|
||||||
self.acts << Activity.new(:user_id => self.reply_id)
|
self.acts << Activity.new(:user_id => self.reply_id)
|
||||||
|
elsif self.jour_type == 'Course'
|
||||||
|
self.acts << Activity.new(:user_id => self.reply_id)
|
||||||
else
|
else
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -22,9 +22,10 @@ class Member < ActiveRecord::Base
|
||||||
has_many :roles, :through => :member_roles
|
has_many :roles, :through => :member_roles
|
||||||
|
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
belongs_to :course
|
||||||
|
|
||||||
validates_presence_of :principal, :project
|
validates_presence_of :principal
|
||||||
validates_uniqueness_of :user_id, :scope => :project_id
|
validates_uniqueness_of :user_id, :scope => [:project_id,:course_id]
|
||||||
validate :validate_role
|
validate :validate_role
|
||||||
|
|
||||||
before_destroy :set_issue_category_nil
|
before_destroy :set_issue_category_nil
|
||||||
|
@ -85,7 +86,13 @@ class Member < ActiveRecord::Base
|
||||||
def set_issue_category_nil
|
def set_issue_category_nil
|
||||||
if user
|
if user
|
||||||
# remove category based auto assignments for this member
|
# remove category based auto assignments for this member
|
||||||
IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
|
#modify by nwb
|
||||||
|
if project
|
||||||
|
IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
|
||||||
|
elsif course
|
||||||
|
#IssueCategory.update_all "assigned_to_id = NULL", ["course_id = ? AND assigned_to_id = ?", course.id, user.id]
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -54,14 +54,16 @@ class MemberRole < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def add_role_to_subprojects
|
def add_role_to_subprojects
|
||||||
member.project.children.each do |subproject|
|
if member.project
|
||||||
if subproject.inherit_members?
|
member.project.children.each do |subproject|
|
||||||
child_member = Member.find_or_new(subproject.id, member.user_id)
|
if subproject.inherit_members?
|
||||||
child_member.member_roles << MemberRole.new(:role => role, :inherited_from => id)
|
child_member = Member.find_or_new(subproject.id, member.user_id)
|
||||||
child_member.save!
|
child_member.member_roles << MemberRole.new(:role => role, :inherited_from => id)
|
||||||
|
child_member.save!
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_inherited_roles
|
def remove_inherited_roles
|
||||||
MemberRole.where(:inherited_from => id).all.group_by(&:member).each do |member, member_roles|
|
MemberRole.where(:inherited_from => id).all.group_by(&:member).each do |member, member_roles|
|
||||||
|
|
|
@ -31,6 +31,10 @@ class Message < ActiveRecord::Base
|
||||||
:include => {:board => :project},
|
:include => {:board => :project},
|
||||||
:project_key => "#{Board.table_name}.project_id",
|
:project_key => "#{Board.table_name}.project_id",
|
||||||
:date_column => "#{table_name}.created_on"
|
:date_column => "#{table_name}.created_on"
|
||||||
|
acts_as_searchable :columns => ['subject', 'content'],
|
||||||
|
:include => {:board => :course},
|
||||||
|
:course_key => "#{Board.table_name}.course_id",
|
||||||
|
:date_column => "#{table_name}.created_at"
|
||||||
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
|
acts_as_event :title => Proc.new {|o| "#{o.board.name}: #{o.subject}"},
|
||||||
:description => :content,
|
:description => :content,
|
||||||
:datetime => :updated_on,
|
:datetime => :updated_on,
|
||||||
|
@ -42,6 +46,9 @@ class Message < ActiveRecord::Base
|
||||||
|
|
||||||
acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
|
acts_as_activity_provider :find_options => {:include => [{:board => :project}, :author]},
|
||||||
:author_key => :author_id
|
:author_key => :author_id
|
||||||
|
acts_as_activity_provider :find_options => {:include => [{:board => :course}, :author]},
|
||||||
|
:type => 'course_messages',
|
||||||
|
:author_key => :author_id
|
||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
|
|
||||||
validates_presence_of :board, :subject, :content
|
validates_presence_of :board, :subject, :content
|
||||||
|
@ -62,6 +69,11 @@ class Message < ActiveRecord::Base
|
||||||
includes(:board => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_messages, *args))
|
includes(:board => :project).where(Project.allowed_to_condition(args.shift || User.current, :view_messages, *args))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope :course_visible, lambda {|*args|
|
||||||
|
includes(:board => :course).where(Course.allowed_to_condition(args.shift || User.current, :view_course_messages, *args))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
safe_attributes 'subject', 'content'
|
safe_attributes 'subject', 'content'
|
||||||
safe_attributes 'locked', 'sticky', 'board_id',
|
safe_attributes 'locked', 'sticky', 'board_id',
|
||||||
:if => lambda {|message, user|
|
:if => lambda {|message, user|
|
||||||
|
@ -69,7 +81,11 @@ class Message < ActiveRecord::Base
|
||||||
}
|
}
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
!user.nil? && user.allowed_to?(:view_messages, project)
|
if project
|
||||||
|
!user.nil? && user.allowed_to?(:view_messages, project)
|
||||||
|
elsif course
|
||||||
|
!user.nil? && user.allowed_to?(:view_messages, course)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def cannot_reply_to_locked_topic
|
def cannot_reply_to_locked_topic
|
||||||
|
@ -104,6 +120,10 @@ class Message < ActiveRecord::Base
|
||||||
board.project
|
board.project
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def course
|
||||||
|
board.course
|
||||||
|
end
|
||||||
|
|
||||||
def editable_by?(usr)
|
def editable_by?(usr)
|
||||||
usr && usr.logged? && (usr.allowed_to?(:edit_messages, project) || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)))
|
usr && usr.logged? && (usr.allowed_to?(:edit_messages, project) || (self.author == usr && usr.allowed_to?(:edit_own_messages, project)))
|
||||||
end
|
end
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
class News < ActiveRecord::Base
|
class News < ActiveRecord::Base
|
||||||
include Redmine::SafeAttributes
|
include Redmine::SafeAttributes
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
|
#added by nwb
|
||||||
|
belongs_to :course
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
has_many :comments, :as => :commented, :dependent => :delete_all, :order => "created_on"
|
||||||
# fq
|
# fq
|
||||||
|
@ -33,6 +35,11 @@ class News < ActiveRecord::Base
|
||||||
acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
|
acts_as_event :url => Proc.new {|o| {:controller => 'news', :action => 'show', :id => o.id}}
|
||||||
acts_as_activity_provider :find_options => {:include => [:project, :author]},
|
acts_as_activity_provider :find_options => {:include => [:project, :author]},
|
||||||
:author_key => :author_id
|
:author_key => :author_id
|
||||||
|
#added by nwb
|
||||||
|
#课程新闻独立于项目
|
||||||
|
acts_as_activity_provider :type => 'course_news',
|
||||||
|
:find_options => {:include => [:course, :author]},
|
||||||
|
:author_key => :author_id
|
||||||
acts_as_watchable
|
acts_as_watchable
|
||||||
|
|
||||||
after_create :add_author_as_watcher
|
after_create :add_author_as_watcher
|
||||||
|
@ -44,6 +51,9 @@ class News < ActiveRecord::Base
|
||||||
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope :course_visible, lambda {|*args|
|
||||||
|
includes(:course).where(Course.allowed_to_condition(args.shift || User.current, :view_course_news, *args))
|
||||||
|
}
|
||||||
safe_attributes 'title', 'summary', 'description'
|
safe_attributes 'title', 'summary', 'description'
|
||||||
|
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
|
|
|
@ -26,7 +26,10 @@ class Principal < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :members, :foreign_key => 'user_id', :dependent => :destroy
|
has_many :members, :foreign_key => 'user_id', :dependent => :destroy
|
||||||
has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}", :order => "#{Project.table_name}.name"
|
has_many :memberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :project, :roles ], :conditions => "#{Project.table_name}.status<>#{Project::STATUS_ARCHIVED}", :order => "#{Project.table_name}.name"
|
||||||
|
has_many :coursememberships, :class_name => 'Member', :foreign_key => 'user_id', :include => [ :course, :roles ], :conditions => "#{Course.table_name}.status<>#{Course::STATUS_ARCHIVED}", :order => "#{Course.table_name}.name"
|
||||||
has_many :projects, :through => :memberships
|
has_many :projects, :through => :memberships
|
||||||
|
#add by nwb
|
||||||
|
has_many :courses, :through => :coursememberships
|
||||||
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
has_many :issue_categories, :foreign_key => 'assigned_to_id', :dependent => :nullify
|
||||||
|
|
||||||
# Groups and active users
|
# Groups and active users
|
||||||
|
@ -70,6 +73,17 @@ class Principal < ActiveRecord::Base
|
||||||
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
|
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE project_id IN (?))", ids)
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scope :not_member_of_course, lambda {|courses|
|
||||||
|
courses = [courses] unless courses.is_a?(Array)
|
||||||
|
if courses.empty?
|
||||||
|
where("1=0")
|
||||||
|
else
|
||||||
|
ids = courses.map(&:id)
|
||||||
|
where("#{Principal.table_name}.id NOT IN (SELECT DISTINCT user_id FROM #{Member.table_name} WHERE course_id IN (?))", ids)
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
scope :sorted, lambda { order(*Principal.fields_for_order_statement)}
|
scope :sorted, lambda { order(*Principal.fields_for_order_statement)}
|
||||||
|
|
||||||
scope :applied_members, lambda {|project|
|
scope :applied_members, lambda {|project|
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Project < ActiveRecord::Base
|
||||||
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
:conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})"
|
||||||
has_many :users, :through => :members
|
has_many :users, :through => :members
|
||||||
has_many :principals, :through => :member_principals, :source => :principal
|
has_many :principals, :through => :member_principals, :source => :principal
|
||||||
has_many :enabled_modules, :dependent => :delete_all
|
has_many :enabled_modules, :dependent => :delete_all
|
||||||
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
has_and_belongs_to_many :trackers, :order => "#{Tracker.table_name}.position"
|
||||||
has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
|
has_many :issues, :dependent => :destroy, :include => [:status, :tracker]
|
||||||
has_many :issue_changes, :through => :issues, :source => :journals
|
has_many :issue_changes, :through => :issues, :source => :journals
|
||||||
|
@ -1130,17 +1130,13 @@ class Project < ActiveRecord::Base
|
||||||
# 创建项目后在项目下同步创建一个讨论区
|
# 创建项目后在项目下同步创建一个讨论区
|
||||||
def create_board_sync
|
def create_board_sync
|
||||||
@board = self.boards.build
|
@board = self.boards.build
|
||||||
if project_type == 1
|
self.name=" #{l(:label_borad_course) }"
|
||||||
self.name=" #{l(:label_borad_course) }"
|
|
||||||
else
|
|
||||||
self.name =" #{l(:label_borad_project) }"
|
|
||||||
end
|
|
||||||
@board.name = self.name
|
@board.name = self.name
|
||||||
@board.description = self.name.to_s
|
@board.description = self.name.to_s
|
||||||
if @board.save
|
if @board.save
|
||||||
logger.debug "[Project Model] ===> #{@board.to_json}"
|
logger.debug "[Course Model] ===> #{@board.to_json}"
|
||||||
else
|
else
|
||||||
logger.error "[Project Model] ===> Auto create board when project saved, because #{@board.full_messages}"
|
logger.error "[Course Model] ===> Auto create board when Course saved, because #{@board.full_messages}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -151,7 +151,7 @@ class Role < ActiveRecord::Base
|
||||||
if action.is_a? Hash
|
if action.is_a? Hash
|
||||||
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
|
allowed_actions.include? "#{action[:controller]}/#{action[:action]}"
|
||||||
else
|
else
|
||||||
allowed_permissions.include? action
|
allowed_permissions.include? action
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
class StudentsForCourse < ActiveRecord::Base
|
class StudentsForCourse < ActiveRecord::Base
|
||||||
attr_accessible :course_id, :student_id
|
attr_accessible :course_id, :student_id
|
||||||
|
|
||||||
belongs_to :course, :class_name => 'Project', :foreign_key => :course_id
|
belongs_to :course, :class_name => 'Course', :foreign_key => :course_id
|
||||||
|
|
||||||
belongs_to :student, :class_name => 'User', :foreign_key => :student_id
|
belongs_to :student, :class_name => 'User', :foreign_key => :student_id
|
||||||
|
|
||||||
validates_presence_of :course_id, :student_id
|
validates_presence_of :course_id, :student_id
|
||||||
|
|
|
@ -101,7 +101,7 @@ class User < Principal
|
||||||
has_many :journal_replies, :dependent => :destroy
|
has_many :journal_replies, :dependent => :destroy
|
||||||
has_many :activities, :dependent => :destroy
|
has_many :activities, :dependent => :destroy
|
||||||
has_many :students_for_courses
|
has_many :students_for_courses
|
||||||
has_many :courses, :through => :students_for_courses, :source => :project
|
#has_many :courses, :through => :students_for_courses, :source => :project
|
||||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||||
has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'"
|
has_many :file_commit, :class_name => 'Attachment', :foreign_key => 'author_id', :conditions => "container_type = 'Project' or container_type = 'Version'"
|
||||||
####
|
####
|
||||||
|
@ -343,6 +343,7 @@ class User < Principal
|
||||||
def reload(*args)
|
def reload(*args)
|
||||||
@name = nil
|
@name = nil
|
||||||
@projects_by_role = nil
|
@projects_by_role = nil
|
||||||
|
@courses_by_role = nil
|
||||||
@membership_by_project_id = nil
|
@membership_by_project_id = nil
|
||||||
base_reload(*args)
|
base_reload(*args)
|
||||||
end
|
end
|
||||||
|
@ -658,6 +659,15 @@ class User < Principal
|
||||||
@membership_by_project_id[project_id]
|
@membership_by_project_id[project_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def coursemembership(course)
|
||||||
|
course_id = course.is_a?(Course) ? course.id : course
|
||||||
|
|
||||||
|
@membership_by_course_id ||= Hash.new {|h, course_id|
|
||||||
|
h[course_id] = coursememberships.where(:course_id => course_id).first
|
||||||
|
}
|
||||||
|
@membership_by_course_id[course_id]
|
||||||
|
end
|
||||||
|
|
||||||
# Return user's roles for project
|
# Return user's roles for project
|
||||||
def roles_for_project(project)
|
def roles_for_project(project)
|
||||||
roles = []
|
roles = []
|
||||||
|
@ -679,11 +689,36 @@ class User < Principal
|
||||||
roles
|
roles
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 用户课程权限判断
|
||||||
|
def roles_for_course(course)
|
||||||
|
roles = []
|
||||||
|
# No role on archived courses
|
||||||
|
return roles if course.nil? || course.archived?
|
||||||
|
if logged?
|
||||||
|
# Find course membership
|
||||||
|
membership = coursemembership(course)
|
||||||
|
if membership
|
||||||
|
roles = membership.roles
|
||||||
|
else
|
||||||
|
@role_non_member ||= Role.non_member
|
||||||
|
roles << @role_non_member
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@role_anonymous ||= Role.anonymous
|
||||||
|
roles << @role_anonymous
|
||||||
|
end
|
||||||
|
roles
|
||||||
|
end
|
||||||
|
|
||||||
# Return true if the user is a member of project
|
# Return true if the user is a member of project
|
||||||
def member_of?(project)
|
def member_of?(project)
|
||||||
projects.to_a.include?(project)
|
projects.to_a.include?(project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def member_of_course?(course)
|
||||||
|
courses.to_a.include?(course)
|
||||||
|
end
|
||||||
|
|
||||||
# Returns a hash of user's projects grouped by roles
|
# Returns a hash of user's projects grouped by roles
|
||||||
def projects_by_role
|
def projects_by_role
|
||||||
return @projects_by_role if @projects_by_role
|
return @projects_by_role if @projects_by_role
|
||||||
|
@ -704,6 +739,25 @@ class User < Principal
|
||||||
@projects_by_role
|
@projects_by_role
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# 课程的角色权限
|
||||||
|
def courses_by_role
|
||||||
|
return @courses_by_role if @courses_by_role
|
||||||
|
|
||||||
|
@courses_by_role = Hash.new([])
|
||||||
|
coursememberships.each do |membership|
|
||||||
|
if membership.course
|
||||||
|
membership.roles.each do |role|
|
||||||
|
@courses_by_role[role] = [] unless @courses_by_role.key?(role)
|
||||||
|
@courses_by_role[role] << membership.course
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@courses_by_role.each do |role, courses|
|
||||||
|
courses.uniq!
|
||||||
|
end
|
||||||
|
|
||||||
|
@courses_by_role
|
||||||
|
end
|
||||||
# Returns true if user is arg or belongs to arg
|
# Returns true if user is arg or belongs to arg
|
||||||
def is_or_belongs_to?(arg)
|
def is_or_belongs_to?(arg)
|
||||||
if arg.is_a?(User)
|
if arg.is_a?(User)
|
||||||
|
@ -738,7 +792,20 @@ class User < Principal
|
||||||
role.allowed_to?(action) &&
|
role.allowed_to?(action) &&
|
||||||
(block_given? ? yield(role, self) : true)
|
(block_given? ? yield(role, self) : true)
|
||||||
}
|
}
|
||||||
elsif context && context.is_a?(Array)
|
#添加课程相关的权限判断
|
||||||
|
elsif context && context.is_a?(Course)
|
||||||
|
return false unless context.allows_to?(action)
|
||||||
|
# Admin users are authorized for anything else
|
||||||
|
return true if admin?
|
||||||
|
|
||||||
|
roles = roles_for_course(context)
|
||||||
|
return false unless roles
|
||||||
|
roles.any? {|role|
|
||||||
|
(context.is_public? || role.member?) &&
|
||||||
|
role.allowed_to?(action) &&
|
||||||
|
(block_given? ? yield(role, self) : true)
|
||||||
|
}
|
||||||
|
elsif context && context.is_a?(Array)
|
||||||
if context.empty?
|
if context.empty?
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
|
@ -751,6 +818,9 @@ class User < Principal
|
||||||
|
|
||||||
# authorize if user has at least one role that has this permission
|
# authorize if user has at least one role that has this permission
|
||||||
roles = memberships.collect {|m| m.roles}.flatten.uniq
|
roles = memberships.collect {|m| m.roles}.flatten.uniq
|
||||||
|
if roles.count == 0
|
||||||
|
roles = coursememberships.collect {|m| m.roles}.flatten.uniq
|
||||||
|
end
|
||||||
roles << (self.logged? ? Role.non_member : Role.anonymous)
|
roles << (self.logged? ? Role.non_member : Role.anonymous)
|
||||||
roles.any? {|role|
|
roles.any? {|role|
|
||||||
role.allowed_to?(action) &&
|
role.allowed_to?(action) &&
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<% if attachmenttypes.any? %>
|
||||||
|
<div id="put-tag-form-<%=attachment.id%>" class="hidden">
|
||||||
|
<%= select_tag "attachment_type",
|
||||||
|
options_from_collection_for_select(attachmenttypes, "id",
|
||||||
|
"typeName",attachment.attachtype), :onchange=>"course_attachmenttypes_change("+attachment.id.to_s + ",this.value)"%>
|
||||||
|
</div>
|
||||||
|
<%= link_to(image_tag('edit/edit.png'), 'javascript:void(0);',:style=>"white-space:nowrap;", :id=>"edit_box"+attachment.id.to_s ,
|
||||||
|
:onclick =>"$('#put-tag-form-" +attachment.id.to_s+ "').show();
|
||||||
|
$('#attach_type_id_label" +attachment.id.to_s+ "').hide();
|
||||||
|
$('#edit_box" +attachment.id.to_s+ "').hide();") if edit_allowed %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<div class="tags_area">
|
||||||
|
<%= render :partial => 'tags/tagEx', :locals => {:obj => file, :object_flag => "6"} %>
|
||||||
|
</div>
|
|
@ -11,4 +11,6 @@ fileSpan.find('a.remove-upload')
|
||||||
"href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>'
|
"href": '<%= j attachment_path(@attachment, :attachment_id => params[:attachment_id], :format => 'js') %>'
|
||||||
})
|
})
|
||||||
.off('click');
|
.off('click');
|
||||||
|
//var divattach = fileSpan.find('div.div_attachments');
|
||||||
|
//divattach.html('<%= j(render :partial => 'tags/tagEx', :locals => {:obj => @attachment, :object_flag => "6"})%>');
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
<span class="font_lighter"><%= l(:label_user_create_project_homework) %></span>
|
<span class="font_lighter"><%= l(:label_user_create_project_homework) %></span>
|
||||||
<span><%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %></span>
|
<span><%= link_to(bid.name, respond_path(bid), :class => 'bid_path') %></span>
|
||||||
<span style="float: right">
|
<span style="float: right">
|
||||||
<% 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 course_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %>
|
||||||
<%# 提交作业按钮 %>
|
<%# 提交作业按钮 %>
|
||||||
<!--<%= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@project) %>-->
|
<!--<%= link_to l(:label_commit_homework), '#OpenWindow', rel: 'leanModal', onclick: "showSubH(#{bid.id}, '#{bid.name}');" if User.current.member_of?(@course) %>-->
|
||||||
<% cur_user_homework = cur_user_homework_for_bid(bid) %>
|
<% cur_user_homework = cur_user_homework_for_bid(bid) %>
|
||||||
<% if cur_user_homework!= nil && cur_user_homework.count == 0 %>
|
<% if cur_user_homework!= nil && cur_user_homework.count == 0 %>
|
||||||
<%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %>
|
<%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %>
|
||||||
|
@ -26,7 +26,7 @@
|
||||||
<% if (User.current.admin?||User.current.id==bid.author_id) %>
|
<% if (User.current.admin?||User.current.id==bid.author_id) %>
|
||||||
<%= link_to(
|
<%= link_to(
|
||||||
l(:button_edit),
|
l(:button_edit),
|
||||||
{:action => 'edit', :controller=>'bids', :project_id =>@project.id, :bid_id => bid.id},
|
{:action => 'edit', :controller=>'bids', :course_id =>@course.id, :bid_id => bid.id},
|
||||||
:class => 'icon icon-edit'
|
:class => 'icon icon-edit'
|
||||||
) %>
|
) %>
|
||||||
<%= link_to(
|
<%= link_to(
|
||||||
|
@ -51,9 +51,9 @@
|
||||||
end
|
end
|
||||||
%>
|
%>
|
||||||
<% if bid.homework_type == 1%>
|
<% if bid.homework_type == 1%>
|
||||||
<%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, project_for_bid_path(bid.id) %></strong>)
|
<%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<strong><%= link_to bid.homeworks.count, course_for_bid_path(bid.id) %></strong>)
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= l(:label_x_homework_project, :count => @temp.count) %>(<strong><%= link_to @temp.count, project_for_bid_path(bid.id) %></strong>)
|
<%= l(:label_x_homework_project, :count => @temp.count) %>(<strong><%= link_to @temp.count, course_for_bid_path(bid.id) %></strong>)
|
||||||
<% end %></span>
|
<% end %></span>
|
||||||
<span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= link_to bid.commit, respond_path(bid) %></strong>)</span>
|
<span class="font_lighter"><%= l(:label_x_responses, :count => bid.commit) %>(<strong><%= link_to bid.commit, respond_path(bid) %></strong>)</span>
|
||||||
<span style="float: right">
|
<span style="float: right">
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<% is_teacher = is_course_teacher User.current,@bid.courses.first %>
|
<% is_teacher = is_course_teacher User.current,@bid.courses.first %>
|
||||||
<!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能,2表示未启用 -->
|
<!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能,2表示未启用 -->
|
||||||
<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
|
<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
|
||||||
<%= form_tag(:controller => 'bids', :action => "show_project", :method => :get) do %>
|
<%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %>
|
||||||
<div class="project-search-block">
|
<div class="project-search-block">
|
||||||
<table width="100%" valign="center">
|
<table width="100%" valign="center">
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
<td>
|
<td>
|
||||||
<table width="580" border="0">
|
<table width="580" border="0">
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" valign="top"><span><%= link_to_project(course) %></span>
|
<td colspan="2" valign="top"><span><%= link_to_course(course) %></span>
|
||||||
<span style="float: right"><%= l(:label_homework) %> (<span class=""><%= link_to (course.homeworks.count), {:controller => 'projects', :action => 'homework', :id => course.identifier} %></span>)
|
<span style="float: right"><%= l(:label_homework) %> (<span class=""><%= link_to (course.homeworks.count), {:controller => 'courses', :action => 'homework', :id => course.id} %></span>)
|
||||||
|
|
||||||
<%= l(:label_course_news)%> (<span style="color: #ed8924"><%= link_to (course.news.count), {:controller => 'news', :action => 'index', :project_id => course.identifier} %></span>)
|
<%= l(:label_course_news)%> (<span style="color: #ed8924"><%= link_to (course.news.count), {:controller => 'news', :action => 'index', :course_id => course.id} %></span>)
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -22,10 +22,9 @@
|
||||||
</p></td>
|
</p></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="left"><span class="font_lighter"> <%= format_time(course.created_on) %></span></td><!-- modified by ming -->
|
<td align="left"><span class="font_lighter"> <%= format_time(course.created_at) %></span></td><!-- modified by ming -->
|
||||||
<td align="right" >
|
<td align="right" >
|
||||||
<% t_course = Course.find_by_extra(course.identifier) %>
|
教师:<%= link_to(course.teacher.lastname+course.teacher.firstname, user_path(course.teacher)) %>
|
||||||
教师:<%= link_to(t_course.teacher.lastname+t_course.teacher.firstname, user_path(t_course.teacher)) %>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table></td>
|
</table></td>
|
||||||
|
|
|
@ -0,0 +1,72 @@
|
||||||
|
<% if @bid.homework_type == Bid::HomeworkFile %>
|
||||||
|
<!-- 提交文件类型 -->
|
||||||
|
<%= render :partial => 'homework' %>
|
||||||
|
|
||||||
|
<% else %>
|
||||||
|
<!-- 提交引用项目 -->
|
||||||
|
<script type="text/javascript" language="javascript">
|
||||||
|
function clearInfo(id, content) {
|
||||||
|
var text = $('#' + id);
|
||||||
|
if (text.val() == content) {
|
||||||
|
$('#' + id).val('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showInfo(id, content) {
|
||||||
|
var text = $('#' + id);
|
||||||
|
if (text.val() == '') {
|
||||||
|
$('#' + id).val(content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cancel() {
|
||||||
|
$("#put-bid-form").hide();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<% if User.current.logged? %>
|
||||||
|
<!--我要竞标弹出框-->
|
||||||
|
<div id='flash' style="float:left; width: 100%; display: none"></div>
|
||||||
|
<div id="put-bid-form" style="display: none">
|
||||||
|
<%= form_for "bid_for_save", :remote => true, :url => {:controller => 'bids', :action => 'add'},
|
||||||
|
:update => "bidding_project_list",
|
||||||
|
:complete => '$("#put-bid-form").hide();' do |f| %>
|
||||||
|
<table id="bidding_table" border="0" width="100%" style="margin-left: 40px;">
|
||||||
|
<tr>
|
||||||
|
<td><%= select_tag 'bid', options_for_select(select_option_helper(@option)), :name => 'bid', :class => 'grayline' %></td>
|
||||||
|
<div id="prompt_create_pro">
|
||||||
|
<td>
|
||||||
|
|
||||||
|
<div class="font_lighter" style="font-size: 13px;">
|
||||||
|
<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</div>
|
||||||
|
</tr>
|
||||||
|
<% if @bid.reward_type == Bid::Homework %>
|
||||||
|
<tr>
|
||||||
|
<td><%= f.text_area :bid_message, :id => "bid_message", :required => true, :rows => 4, :cols => 40, :placeholder => l(:label_bid_reason_homework), :style => "resize: none;", :class => 'noline' %></td>
|
||||||
|
</tr>
|
||||||
|
<% else %>
|
||||||
|
<tr>
|
||||||
|
<td><%= f.text_area :bid_message, :id => "bid_message", :required => true, :rows => 4, :cols => 40, :placeholder => l(:label_bid_reason), :style => "resize: none;", :class => 'noline' %></td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
<tr>
|
||||||
|
<td align="right">
|
||||||
|
<%= submit_tag l(:button_add), :name => nil, :class => "enterprise",
|
||||||
|
:onmouseout => "this.style.backgroundPosition = 'left top'",
|
||||||
|
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
|
||||||
|
<%= submit_tag l(:button_cancel), :name => nil, :onclick => "cancel();",
|
||||||
|
:type => 'button', :class => "enterprise", :onmouseout => "this.style.backgroundPosition = 'left top'",
|
||||||
|
:onmouseover => "this.style.backgroundPosition = 'left -30px'" %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div id='bidding_project_list'>
|
||||||
|
<%= render :partial => 'project_list', :locals => {:bidding_project => @bidding_project, :bid => @bid} %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,106 @@
|
||||||
|
<!-- <%= course_board_breadcrumb(@board) %> -->
|
||||||
|
|
||||||
|
<!--new and follow-->
|
||||||
|
<!-- <div class="content-title-top">
|
||||||
|
<%= link_to l(:label_message_new),
|
||||||
|
new_board_message_path(@board),
|
||||||
|
:class => 'icon icon-add',
|
||||||
|
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %> -->
|
||||||
|
<!-- <%= watcher_link(@board, User.current) %> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<div id="add-message" class="add_frame" style="display:none;">
|
||||||
|
<% if User.current.logged? %>
|
||||||
|
<h3><%= link_to h(@board.name), course_board_path(@course, @board) %> » <%= l(:label_message_new) %></h3>
|
||||||
|
<div class="add_frame_header" >
|
||||||
|
<%= l(:label_message_new) %>
|
||||||
|
</div>
|
||||||
|
<%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||||
|
<%= render :partial => 'messages/form', :locals => {:f => f} %>
|
||||||
|
<p><%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
||||||
|
<%= preview_link(preview_board_message_path(@board), 'message-form' ,target='preview',{:class => 'whiteButton m3p10'} )%> |
|
||||||
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' ,:class => 'whiteButton m3p10' %></p>
|
||||||
|
<% end %>
|
||||||
|
<div id="preview" class="wiki"></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--display the board-->
|
||||||
|
<div class="borad-title"><%=h @board.name %></div>
|
||||||
|
|
||||||
|
<% if !User.current.logged?%>
|
||||||
|
<div style="font-size: 14px;margin:20px;">
|
||||||
|
<%= l(:label_user_login_course_board) %>
|
||||||
|
<%= link_to l(:label_user_login_new), signin_path %>
|
||||||
|
<hr/>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<!-- <div class="borad-description"><%=h @board.description %></div> -->
|
||||||
|
<div class="borad-setitle">
|
||||||
|
<span class="borad-topic-count">共有 <%=link_to @topics.count %> 个贴子</span>
|
||||||
|
<span>
|
||||||
|
<%= link_to l(:label_message_new),
|
||||||
|
new_board_message_path(@board),
|
||||||
|
:class => 'icon icon-add',
|
||||||
|
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div style="padding-top: 10px">
|
||||||
|
<% if @topics.any? %>
|
||||||
|
<!-- <table class="list messages">
|
||||||
|
<thead><tr>
|
||||||
|
<th><%= l(:field_subject) %></th>
|
||||||
|
<th><%= l(:field_author) %></th>
|
||||||
|
<%= sort_header_tag('created_on', :caption => l(:field_created_on)) %>
|
||||||
|
<%= sort_header_tag('replies', :caption => l(:label_reply_plural)) %>
|
||||||
|
<%= sort_header_tag('updated_on', :caption => l(:label_message_last)) %>
|
||||||
|
</tr></thead>
|
||||||
|
<tbody> -->
|
||||||
|
<% @topics.each do |topic| %>
|
||||||
|
<table class="content-text-list">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %></td>
|
||||||
|
<td>
|
||||||
|
<table width="640px" border="0">
|
||||||
|
<tr>
|
||||||
|
<td valign="top" width="500px" class=" <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), board_message_path(@board, topic) %></td>
|
||||||
|
<td align="right" rowspan="3"><table class="borad-count"><tr><td align="center" class="borad-count-digit"><%=link_to (topic.replies_count), board_message_path(@board, topic) %></td></tr>
|
||||||
|
<tr><td align="center">回答</td></tr>
|
||||||
|
</table></td>
|
||||||
|
</tr>
|
||||||
|
<!-- <tr><td colspan="2" ><span class="font_description">标签</span></td></tr> -->
|
||||||
|
<tr><td align="left" colspan="2" ><span class="font_lighter"><%= authoring topic.created_on, topic.author %><br /></span></td></tr>
|
||||||
|
</table></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- <tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>">
|
||||||
|
<td class="subject"><%= link_to h(topic.subject), board_message_path(@board, topic) %></td>
|
||||||
|
<td class="author"><%= link_to_user(topic.author) %></td>
|
||||||
|
<td class="created_on"><%= format_time(topic.created_on) %></td>
|
||||||
|
<td class="reply-count"><%= topic.replies_count %></td>
|
||||||
|
<td class="last_message">
|
||||||
|
<% if topic.last_reply %>
|
||||||
|
<%= authoring topic.last_reply.created_on, topic.last_reply.author %><br />
|
||||||
|
<%= link_to_message topic.last_reply %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr> -->
|
||||||
|
<% end %>
|
||||||
|
<!-- </tbody>
|
||||||
|
</table> -->
|
||||||
|
<div class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></div>
|
||||||
|
<% else %>
|
||||||
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% other_formats_links do |f| %>
|
||||||
|
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title @board.name %>
|
||||||
|
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@course}: #{@board}") %>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,110 @@
|
||||||
|
<!-- <%= board_breadcrumb(@board) %> -->
|
||||||
|
|
||||||
|
<!--new and follow-->
|
||||||
|
<!-- <div class="content-title-top">
|
||||||
|
<%= link_to l(:label_message_new),
|
||||||
|
new_board_message_path(@board),
|
||||||
|
:class => 'icon icon-add',
|
||||||
|
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %> -->
|
||||||
|
<!-- <%= watcher_link(@board, User.current) %> -->
|
||||||
|
<!-- </div> -->
|
||||||
|
<div id="add-message" class="add_frame" style="display:none;">
|
||||||
|
<% if User.current.logged? %>
|
||||||
|
<h3><%= link_to h(@board.name), project_board_path(@project, @board) %> » <%= l(:label_message_new) %></h3>
|
||||||
|
<div class="add_frame_header" >
|
||||||
|
<%= l(:label_message_new) %>
|
||||||
|
</div>
|
||||||
|
<%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||||
|
<%= render :partial => 'messages/form', :locals => {:f => f} %>
|
||||||
|
<p><%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
||||||
|
<%= preview_link(preview_board_message_path(@board), 'message-form' ,target='preview',{:class => 'whiteButton m3p10'} )%> |
|
||||||
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' ,:class => 'whiteButton m3p10' %></p>
|
||||||
|
<% end %>
|
||||||
|
<div id="preview" class="wiki"></div>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--display the board-->
|
||||||
|
<div class="borad-title"><%=h @board.name %></div>
|
||||||
|
|
||||||
|
<% if !User.current.logged?%>
|
||||||
|
<div style="font-size: 14px;margin:20px;">
|
||||||
|
<% if @project.project_type == 1 %>
|
||||||
|
<%= l(:label_user_login_course_board) %>
|
||||||
|
<% else %>
|
||||||
|
<%= l(:label_user_login_project_board) %>
|
||||||
|
<% end %>
|
||||||
|
<%= link_to l(:label_user_login_new), signin_path %>
|
||||||
|
<hr/>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<!-- <div class="borad-description"><%=h @board.description %></div> -->
|
||||||
|
<div class="borad-setitle">
|
||||||
|
<span class="borad-topic-count">共有 <%=link_to @topics.count %> 个贴子</span>
|
||||||
|
<span>
|
||||||
|
<%= link_to l(:label_message_new),
|
||||||
|
new_board_message_path(@board),
|
||||||
|
:class => 'icon icon-add',
|
||||||
|
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div style="padding-top: 10px">
|
||||||
|
<% if @topics.any? %>
|
||||||
|
<!-- <table class="list messages">
|
||||||
|
<thead><tr>
|
||||||
|
<th><%= l(:field_subject) %></th>
|
||||||
|
<th><%= l(:field_author) %></th>
|
||||||
|
<%= sort_header_tag('created_on', :caption => l(:field_created_on)) %>
|
||||||
|
<%= sort_header_tag('replies', :caption => l(:label_reply_plural)) %>
|
||||||
|
<%= sort_header_tag('updated_on', :caption => l(:label_message_last)) %>
|
||||||
|
</tr></thead>
|
||||||
|
<tbody> -->
|
||||||
|
<% @topics.each do |topic| %>
|
||||||
|
<table class="content-text-list">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %></td>
|
||||||
|
<td>
|
||||||
|
<table width="640px" border="0">
|
||||||
|
<tr>
|
||||||
|
<td valign="top" width="500px" class=" <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), board_message_path(@board, topic) %></td>
|
||||||
|
<td align="right" rowspan="3"><table class="borad-count"><tr><td align="center" class="borad-count-digit"><%=link_to (topic.replies_count), board_message_path(@board, topic) %></td></tr>
|
||||||
|
<tr><td align="center">回答</td></tr>
|
||||||
|
</table></td>
|
||||||
|
</tr>
|
||||||
|
<!-- <tr><td colspan="2" ><span class="font_description">标签</span></td></tr> -->
|
||||||
|
<tr><td align="left" colspan="2" ><span class="font_lighter"><%= authoring topic.created_on, topic.author %><br /></span></td></tr>
|
||||||
|
</table></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<!-- <tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>">
|
||||||
|
<td class="subject"><%= link_to h(topic.subject), board_message_path(@board, topic) %></td>
|
||||||
|
<td class="author"><%= link_to_user(topic.author) %></td>
|
||||||
|
<td class="created_on"><%= format_time(topic.created_on) %></td>
|
||||||
|
<td class="reply-count"><%= topic.replies_count %></td>
|
||||||
|
<td class="last_message">
|
||||||
|
<% if topic.last_reply %>
|
||||||
|
<%= authoring topic.last_reply.created_on, topic.last_reply.author %><br />
|
||||||
|
<%= link_to_message topic.last_reply %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr> -->
|
||||||
|
<% end %>
|
||||||
|
<!-- </tbody>
|
||||||
|
</table> -->
|
||||||
|
<div class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></div>
|
||||||
|
<% else %>
|
||||||
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% other_formats_links do |f| %>
|
||||||
|
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title @board.name %>
|
||||||
|
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %>
|
||||||
|
<% end %>
|
|
@ -1,110 +1,5 @@
|
||||||
<!-- <%= board_breadcrumb(@board) %> -->
|
<% if @project %>
|
||||||
|
<%= render :partial => 'project_show', locals: {project: @project} %>
|
||||||
<!--new and follow-->
|
<% elsif @course %>
|
||||||
<!-- <div class="content-title-top">
|
<%= render :partial => 'course_show', locals: {course: @course} %>
|
||||||
<%= link_to l(:label_message_new),
|
|
||||||
new_board_message_path(@board),
|
|
||||||
:class => 'icon icon-add',
|
|
||||||
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %> -->
|
|
||||||
<!-- <%= watcher_link(@board, User.current) %> -->
|
|
||||||
<!-- </div> -->
|
|
||||||
<div id="add-message" class="add_frame" style="display:none;">
|
|
||||||
<% if User.current.logged? %>
|
|
||||||
<h3><%= link_to h(@board.name), project_board_path(@project, @board) %> » <%= l(:label_message_new) %></h3>
|
|
||||||
<div class="add_frame_header" >
|
|
||||||
<%= l(:label_message_new) %>
|
|
||||||
</div>
|
|
||||||
<%= form_for @message, :url => new_board_message_path(@board), :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
|
||||||
<%= render :partial => 'messages/form', :locals => {:f => f} %>
|
|
||||||
<p><%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
|
||||||
<%= preview_link(preview_board_message_path(@board), 'message-form' ,target='preview',{:class => 'whiteButton m3p10'} )%> |
|
|
||||||
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-message").hide(); return false;' ,:class => 'whiteButton m3p10' %></p>
|
|
||||||
<% end %>
|
|
||||||
<div id="preview" class="wiki"></div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!--display the board-->
|
|
||||||
<div class="borad-title"><%=h @board.name %></div>
|
|
||||||
|
|
||||||
<% if !User.current.logged?%>
|
|
||||||
<div style="font-size: 14px;margin:20px;">
|
|
||||||
<% if @project.project_type == 1 %>
|
|
||||||
<%= l(:label_user_login_course_board) %>
|
|
||||||
<% else %>
|
|
||||||
<%= l(:label_user_login_project_board) %>
|
|
||||||
<% end %>
|
|
||||||
<%= link_to l(:label_user_login_new), signin_path %>
|
|
||||||
<hr/>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<!-- <div class="borad-description"><%=h @board.description %></div> -->
|
|
||||||
<div class="borad-setitle">
|
|
||||||
<span class="borad-topic-count">共有 <%=link_to @topics.count %> 个贴子</span>
|
|
||||||
<span>
|
|
||||||
<%= link_to l(:label_message_new),
|
|
||||||
new_board_message_path(@board),
|
|
||||||
:class => 'icon icon-add',
|
|
||||||
:onclick => 'showAndScrollTo("add-message", "message_subject"); return false;' if User.current.logged? %>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div style="padding-top: 10px">
|
|
||||||
<% if @topics.any? %>
|
|
||||||
<!-- <table class="list messages">
|
|
||||||
<thead><tr>
|
|
||||||
<th><%= l(:field_subject) %></th>
|
|
||||||
<th><%= l(:field_author) %></th>
|
|
||||||
<%= sort_header_tag('created_on', :caption => l(:field_created_on)) %>
|
|
||||||
<%= sort_header_tag('replies', :caption => l(:label_reply_plural)) %>
|
|
||||||
<%= sort_header_tag('updated_on', :caption => l(:label_message_last)) %>
|
|
||||||
</tr></thead>
|
|
||||||
<tbody> -->
|
|
||||||
<% @topics.each do |topic| %>
|
|
||||||
<table class="content-text-list">
|
|
||||||
<tr>
|
|
||||||
<td colspan="2" valign="top" width="50" ><%= link_to image_tag(url_to_avatar(topic.author), :class => "avatar"), user_path(topic.author) %></td>
|
|
||||||
<td>
|
|
||||||
<table width="640px" border="0">
|
|
||||||
<tr>
|
|
||||||
<td valign="top" width="500px" class=" <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>"><%= link_to h(topic.subject), board_message_path(@board, topic) %></td>
|
|
||||||
<td align="right" rowspan="3"><table class="borad-count"><tr><td align="center" class="borad-count-digit"><%=link_to (topic.replies_count), board_message_path(@board, topic) %></td></tr>
|
|
||||||
<tr><td align="center">回答</td></tr>
|
|
||||||
</table></td>
|
|
||||||
</tr>
|
|
||||||
<!-- <tr><td colspan="2" ><span class="font_description">标签</span></td></tr> -->
|
|
||||||
<tr><td align="left" colspan="2" ><span class="font_lighter"><%= authoring topic.created_on, topic.author %><br /></span></td></tr>
|
|
||||||
</table></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- <tr class="message <%= cycle 'odd', 'even' %> <%= topic.sticky? ? 'sticky' : '' %> <%= topic.locked? ? 'locked' : '' %>">
|
|
||||||
<td class="subject"><%= link_to h(topic.subject), board_message_path(@board, topic) %></td>
|
|
||||||
<td class="author"><%= link_to_user(topic.author) %></td>
|
|
||||||
<td class="created_on"><%= format_time(topic.created_on) %></td>
|
|
||||||
<td class="reply-count"><%= topic.replies_count %></td>
|
|
||||||
<td class="last_message">
|
|
||||||
<% if topic.last_reply %>
|
|
||||||
<%= authoring topic.last_reply.created_on, topic.last_reply.author %><br />
|
|
||||||
<%= link_to_message topic.last_reply %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr> -->
|
|
||||||
<% end %>
|
|
||||||
<!-- </tbody>
|
|
||||||
</table> -->
|
|
||||||
<div class="pagination"><%= pagination_links_full @topic_pages, @topic_count %></div>
|
|
||||||
<% else %>
|
|
||||||
<p class="nodata"><%= l(:label_no_data) %></p>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% other_formats_links do |f| %>
|
|
||||||
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% html_title @board.name %>
|
|
||||||
|
|
||||||
<% content_for :header_tags do %>
|
|
||||||
<%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@project}: #{@board}") %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -0,0 +1,87 @@
|
||||||
|
<div class="project-block">
|
||||||
|
<div class="img-tag-2">
|
||||||
|
<% if get_avatar?(course)%>
|
||||||
|
<%= image_tag(url_to_avatar(course), :class => "avatar2") %>
|
||||||
|
<% else %>
|
||||||
|
<%= image_tag('../images/avatars/course/course.jpg', :class => "avatar2") %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="wiki-description">
|
||||||
|
<p >
|
||||||
|
<%= content_tag('span',"#{l(:label_bid_show_course_name)}:", :class => "course-font")%>
|
||||||
|
<%= content_tag('span', link_to("#{@course.name}", course_path(@course), :class => "info"))%>
|
||||||
|
</p>
|
||||||
|
<p >
|
||||||
|
<%= content_tag('span', "#{l(:label_institution_name)}:", :class => "course-font")%>
|
||||||
|
<% @admin = @course.course_infos%>
|
||||||
|
<%if @admin&&@admin.first&&@admin.first.user&&@admin.first.user.user_extensions%>
|
||||||
|
<!-- <%= @admin.first.user.user_extensions.occupation %> -->
|
||||||
|
<%# unless @course.course_extra.school.nil? %>
|
||||||
|
<%= @course.teacher.user_extensions.school.try(:name) %>
|
||||||
|
<%# end %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
<p >
|
||||||
|
<%= content_tag('div', "#{l(:field_teacher_name)}:", :class => "info course-font teacher") %>
|
||||||
|
<% if @admin.size > 0 %>
|
||||||
|
<%= content_tag('a', @admin.collect{|u| link_to(u.user.lastname+u.user.firstname, user_path(u.user_id))}.join(", ").html_safe) %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="information_for_course" >
|
||||||
|
<p class="stats">
|
||||||
|
<%= content_tag('span', link_to("#{@course.homeworks.count}", homework_course_path(@course)), :class => "info") %>
|
||||||
|
<%= content_tag('span', l(:label_x_task, :count => @course.homeworks.count)) %>
|
||||||
|
</p>
|
||||||
|
<p class="stats">
|
||||||
|
<% files_count = @course.attachments.count %>
|
||||||
|
<%= content_tag('span', link_to(files_count, course_files_path(@course)), :class => "info") %>
|
||||||
|
<%= content_tag('span', l(:label_x_data,:count => files_count)) %>
|
||||||
|
</p>
|
||||||
|
<p class="stats">
|
||||||
|
<%= content_tag('span', "#{garble @course.members.count}", :class => "info") %>
|
||||||
|
<%= content_tag('span', l(:label_x_member, :count => @course.members.count)) %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<!--gcm-->
|
||||||
|
<p class="stats">
|
||||||
|
|
||||||
|
<%= content_tag('span', link_to("#{@course_activity_count[@course.id]}", course_path(@course)), :class => "info") %>
|
||||||
|
<%= content_tag('span', l(:label_x_activity, :count => @course_activity_count[@course.id])) %>
|
||||||
|
</p>
|
||||||
|
<!--gcm-->
|
||||||
|
|
||||||
|
<div class="buttons_for_course" style="margin-top:30px;margin-left:144px">
|
||||||
|
<span class="info"></span>
|
||||||
|
<% if(course_endTime_timeout? @course) %>
|
||||||
|
<span class="font_lighter">
|
||||||
|
课程学期已结束
|
||||||
|
</span>
|
||||||
|
<% else %>
|
||||||
|
<%= join_in_course_for_list(@course, User.current,['regular'])%>
|
||||||
|
<% end -%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="add-info">
|
||||||
|
<div class="main-language" style="margin-left: 30px;margin-top:-10px">
|
||||||
|
<%= content_tag "span","#{l(:label_duration_time)}:", :class => "course-font"%>
|
||||||
|
<%= get_course_term @course %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="add-info" style="margin-left: 30px; margin-top: -20px">
|
||||||
|
<%= content_tag "span", "#{l(:label_course_brief_introduction)}:", :class => "course-font" %>
|
||||||
|
<%= content_tag "div", course.short_description, :class => "brief_introduction", :title => course.short_description %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="tags">
|
||||||
|
<div id="tags">
|
||||||
|
<%= image_tag( "/images/sidebar/tags.png") %>
|
||||||
|
<%= render :partial => 'tags/tag_name', :locals => {:obj => @course,:object_flag => "9",:non_list_all => true }%>
|
||||||
|
</div>
|
||||||
|
</div>
|
|
@ -17,21 +17,21 @@
|
||||||
|
|
||||||
|
|
||||||
<% object = [] %>
|
<% object = [] %>
|
||||||
<% object << 'project' %>
|
<% object << 'course' %>
|
||||||
<% object << 'course' %>
|
<% object << 'course' %>
|
||||||
<%= error_messages_for object %>
|
<%= error_messages_for object %>
|
||||||
|
|
||||||
|
|
||||||
<!--[form:project]-->
|
<!--[form:course]-->
|
||||||
<% unless @project.new_record? %>
|
<% unless @course.new_record? %>
|
||||||
<p><%= render :partial=>"avatar/avatar_form",:locals=> {source:@project} %></p>
|
<p><%= render :partial=>"avatar/avatar_form",:locals=> {source:@course} %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- <p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %></p> -->
|
<!-- <p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;" %></p> -->
|
||||||
<p><label for="project_name" style="font-size: 13px;" ><%=l(:label_tags_course_name)%><span class="required", > * </span></label><input id="project_name" type="text" value="<%=@project.name%>" style="width:490px;" size="60" name="project[name]"></p>
|
<p><label for="course_name" style="font-size: 13px;" ><%=l(:label_tags_course_name)%><span class="required" > * </span></label><input id="course_name" type="text" value="<%=@course.name%>" style="width:490px;" size="60" name="course[name]"></p>
|
||||||
|
|
||||||
<!-- <p><%= f.text_field :identifier, :required => true, :size => 60, :style => "width:488px;", :disabled => @project.identifier_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
|
<!-- <p><%= f.text_field :extra, :required => true, :size => 60, :style => "width:488px;", :disabled => @course.extra_frozen?, :maxlength => Project::IDENTIFIER_MAX_LENGTH %>
|
||||||
<% unless @project.identifier_frozen? %>
|
<% unless @course.extra_frozen? %>
|
||||||
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_project_identifier_info).html_safe %></em>
|
<em class="info"><%= l(:text_length_between, :min => 1, :max => Project::IDENTIFIER_MAX_LENGTH) %> <%= l(:text_course_identifier_info).html_safe %></em>
|
||||||
<% end %></p> -->
|
<% end %></p> -->
|
||||||
|
|
||||||
<!-- added by bai 新增开课时间、结课时间、课时 -->
|
<!-- added by bai 新增开课时间、结课时间、课时 -->
|
||||||
|
@ -292,48 +292,33 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!-- added by huang -->
|
|
||||||
<!-- <p style="margin-left:-10px;"><%= m.text_field :password, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> -->
|
<!-- <p style="margin-left:-10px;"><%= m.text_field :password, :required => true, :size => 60, :style => "width:488px;margin-left: 10px;" %></p> -->
|
||||||
<p style="margin-left:-10px;"><label for="project[course]_password" style="font-size: 13px;" ><%=l(:label_new_course_password)%><span class="required"> *</span></label><input id="project_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%=@project.course_extra.password if @project.course_extra %>" size="60" name="project[course][password]"></p>
|
<p style="margin-left:-10px;"><label for="course[course]_password" style="font-size: 13px;" ><%=l(:label_new_course_password)%><span class="required"> *</span></label><input id="course_course_password" type="text" style="width:488px;margin-left: 10px;" value="<%=@course.password %>" size="60" name="course[password]"></p>
|
||||||
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
|
<em class="info" style="margin-left:95px;"><%= l(:text_command) %></em>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<!-- <p style="margin-left:-10px;padding-right: 20px;"><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %></p> -->
|
<!-- <p style="margin-left:-10px;padding-right: 20px;"><%= f.text_area :description, :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %></p> -->
|
||||||
<!--new added -->
|
<p style="margin-left:-20px;padding-right: 20px;"><label for="course_description" style="font-size: 13px;"><%=l(:label_new_course_description)%></label><span class="jstEditor"><textarea id="course_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="course[description]" cols="40" ><%=@course.description%></textarea></span></p>
|
||||||
<p style="margin-left:-20px;padding-right: 20px;"><label for="project_description" style="font-size: 13px;"><%=l(:label_new_course_description)%></label><span class="jstEditor"><textarea id="project_description" class="wiki-edit" style="font-size:small;width:490px;margin-left:10px;" rows="8" name="project[description]" cols="40" ><%=@project.description%></textarea></span></p>
|
|
||||||
|
|
||||||
|
|
||||||
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;"><%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_public_info) %></em></p><!-- modified by bai -->
|
<p style="margin-left:-10px;"><em style ="color: #888888;display: block;font-size: 90%;font-style: normal;"><%= f.check_box :is_public, :style => "margin-left:10px;" %><%= l(:label_course_public_info) %></em></p><!-- modified by bai -->
|
||||||
<p style="display:none;"><%= f.text_field :project_type, :value => 1 %></p>
|
<p style="display:none;"><%= f.text_field :course_type, :value => 1 %></p>
|
||||||
|
|
||||||
|
|
||||||
<%= wikitoolbar_for 'project_description' %>
|
<%= wikitoolbar_for 'course_description' %>
|
||||||
|
|
||||||
<% @project.custom_field_values.each do |value| %>
|
<% @course.custom_field_values.each do |value| %>
|
||||||
<p><%= custom_field_tag_with_label :project, value %></p>
|
<p><%= custom_field_tag_with_label :course, value %></p>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= call_hook(:view_projects_form, :project => @project, :form => f) %>
|
<%= call_hook(:view_courses_form, :course => @course, :form => f) %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<!--[eoform:project]-->
|
<!--[eoform:course]-->
|
||||||
|
|
||||||
<% unless @project.identifier_frozen? %>
|
<% unless @course.extra_frozen? %>
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<%= javascript_include_tag 'project_identifier' %>
|
<%= javascript_include_tag 'course_identifier' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if !User.current.admin? && @project.inherit_members? && @project.parent && User.current.member_of?(@project.parent) %>
|
|
||||||
<%= javascript_tag do %>
|
|
||||||
$(document).ready(function() {
|
|
||||||
$("#project_inherit_members").change(function(){
|
|
||||||
if (!$(this).is(':checked')) {
|
|
||||||
if (!confirm("<%= escape_javascript(l(:text_own_membership_delete_confirmation)) %>")) {
|
|
||||||
$("#project_inherit_members").attr("checked", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
<div class="box tabular" style="margin-right:10px;" >
|
||||||
|
<%= labelled_form_for @course do |f| %>
|
||||||
|
<%= render :partial => 'course_form', :locals => { :f => f } %>
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
|
@ -21,7 +21,6 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<%= error_messages_for 'bid' %>
|
<%= error_messages_for 'bid' %>
|
||||||
<!--[form:project]-->
|
|
||||||
<p><%= l(:label_homeworks_form_new_description) %></p>
|
<p><%= l(:label_homeworks_form_new_description) %></p>
|
||||||
<p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT %></p>
|
<p><%= f.text_field :name, :required => true, :size => 60, :style => "width:490px;", :maxlength => Bid::NAME_LENGTH_LIMIT %></p>
|
||||||
|
|
||||||
|
@ -34,7 +33,7 @@
|
||||||
</p>
|
</p>
|
||||||
<p><%= f.select :is_evaluation, is_evaluation_option %>
|
<p><%= f.select :is_evaluation, is_evaluation_option %>
|
||||||
</p>
|
</p>
|
||||||
<p><%= hidden_field_tag 'course_id', @project.id %>
|
<p><%= hidden_field_tag 'course_id', @course.id %>
|
||||||
</p>
|
</p>
|
||||||
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
|
<fieldset><legend><%= l(:label_attachment_plural) %></legend>
|
||||||
<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p>
|
<p><%= render :partial => 'attachments/form', :locals => {:container => @homework} %></p>
|
|
@ -0,0 +1,31 @@
|
||||||
|
<% if members.any? %>
|
||||||
|
<% members.each do |member| %>
|
||||||
|
<div class="well">
|
||||||
|
<% next if member.new_record? %>
|
||||||
|
<% unless member.created_on.nil? %>
|
||||||
|
<%= content_tag "p", "#{format_date(member.created_on)}#{l(:label_member_since)}", :class => "float_right member_since" %>
|
||||||
|
<% end %>
|
||||||
|
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :class => 'avatar')) %>
|
||||||
|
<%= content_tag "div", link_to(member.user.name, user_path(member.user)), :class => "nomargin avatar_name" %>
|
||||||
|
<!--teacher's code disapeared moified by huang-->
|
||||||
|
|
||||||
|
<% unless member.user.user_extensions.identity ==0 %>
|
||||||
|
<!-- added by bai 加学号 -->
|
||||||
|
<%if @canShowCode%>
|
||||||
|
<%= content_tag "p", "#{l(:label_bidding_user_studentcode)}#{' : '}#{member.user.user_extensions.student_id}", :class => "nomargin avatar_name" %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
<div class ="clear avatar_name">
|
||||||
|
<p>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= call_hook(:view_projects_settings_members_table_row, { :course => @course, :member => member}) %>
|
||||||
|
</div>
|
||||||
|
<% end; reset_cycle %>
|
||||||
|
<div class="pagination"><%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %></div>
|
||||||
|
<% else %>
|
||||||
|
<p class="nodata">
|
||||||
|
<%= l(:label_no_data) %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
|
@ -1,11 +1,11 @@
|
||||||
<%
|
<%
|
||||||
id = "finish_course_#{project.id}"
|
id = "finish_course_#{course.id}"
|
||||||
display = (project.course_extra.teacher.id == User.current.id || User.current.admin?)
|
display = (course.teacher.id == User.current.id || User.current.admin?)
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<% if display #如果课程已结束%>
|
<% if display #如果课程已结束%>
|
||||||
<% linkPath = course_endTime_timeout?(project) ? restartcourse_project_path(project) : finishcourse_project_path(project, format: :js) %>
|
<% linkPath = course_endTime_timeout?(course) ? restartcourse_course_path(course) : finishcourse_course_path(course, format: :js) %>
|
||||||
<% desc = course_endTime_timeout?(project) ? '重启' : '关闭' %>
|
<% desc = course_endTime_timeout?(course) ? '重启' : '关闭' %>
|
||||||
|
|
||||||
<%= link_to "#{desc}课程", linkPath, :remote => true, :method => :post, :id => id, :confirm => ("确定要#{desc}课程?") %>
|
<%= link_to "#{desc}课程", linkPath, :remote => true, :method => :post, :id => id, :confirm => ("确定要#{desc}课程?") %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
|
@ -0,0 +1,102 @@
|
||||||
|
<script>
|
||||||
|
var W3CDOM = document.createElement && document.getElementsByTagName;
|
||||||
|
|
||||||
|
window.onload = setMaxLength;
|
||||||
|
|
||||||
|
function setMaxLength() {
|
||||||
|
if (!W3CDOM) return;
|
||||||
|
var textareas = document.getElementsByTagName('textarea');
|
||||||
|
for (var i=0;i<textareas.length;i++) {
|
||||||
|
var textarea = textareas[i];
|
||||||
|
setMaxLengthItem(textareas[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function setMaxLengthItem(textarea){
|
||||||
|
if (textarea.getAttribute('maxlength')) {
|
||||||
|
var counter = document.createElement('div');
|
||||||
|
counter.className = 'counter';
|
||||||
|
var counterClone = counter.cloneNode(true);
|
||||||
|
counterClone.innerHTML = '<span>0</span>/'+textarea.getAttribute('maxlength');
|
||||||
|
textarea.parentNode.insertBefore(counterClone,textarea.nextSibling);
|
||||||
|
textarea.relatedElement = counterClone.getElementsByTagName('span')[0];
|
||||||
|
textarea.onkeyup = textarea.onchange = checkMaxLength;
|
||||||
|
textarea.onkeyup();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkMaxLength() {
|
||||||
|
var maxLength = this.getAttribute('maxlength');
|
||||||
|
var currentLength = this.value.length;
|
||||||
|
if (currentLength > maxLength)
|
||||||
|
this.relatedElement.className = 'toomuch';
|
||||||
|
else
|
||||||
|
this.relatedElement.className = '';
|
||||||
|
this.relatedElement.firstChild.nodeValue = currentLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
<!-- fq -->
|
||||||
|
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
|
||||||
|
|
||||||
|
<h3><%= l(:label_user_response) %></h3>
|
||||||
|
|
||||||
|
<% if !User.current.logged?%>
|
||||||
|
<div style="font-size: 14px;margin:20px;">
|
||||||
|
<%= l(:label_user_login_tips) %>
|
||||||
|
<%= link_to l(:label_user_login_new), signin_path %>
|
||||||
|
<hr/>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div style="width: 80%; margin-left:10%;">
|
||||||
|
<%= form_for('new_form', :method => :post,
|
||||||
|
:url => {:controller => 'words', :action => 'leave_course_message'}) do |f|%>
|
||||||
|
<%= f.text_area 'course_message', :rows => 3, :cols => 65,
|
||||||
|
:placeholder => "#{l(:label_welcome_my_respond)}",
|
||||||
|
:style => "resize: none; width: 98%",
|
||||||
|
:class => 'noline'%>
|
||||||
|
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "enterprise" , :style => "display: block; float: right; margin-right: 1%; margin-top: 1px;"%>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div style="clear: both;"></div>
|
||||||
|
<% if @jour.size >0 %>
|
||||||
|
<ul class="message-for-user">
|
||||||
|
<% for journal in @jour%>
|
||||||
|
<li id='word_li_<%=journal.id.to_s%>' class="outer-message-for-user">
|
||||||
|
<span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span>
|
||||||
|
<span class="body">
|
||||||
|
<span class="user"><%= link_to journal.user, user_path(journal.user)%></span>
|
||||||
|
<%= textilizable journal.notes%>
|
||||||
|
<span class="font_lighter"> <%= l :label_update_time %>: <%= format_time journal.created_on %></span>
|
||||||
|
<% id = 'course_respond_form_'+journal.id.to_s%>
|
||||||
|
<span>
|
||||||
|
<% if reply_allow %>
|
||||||
|
<%= link_to l(:label_projects_feedback_respond),'#',
|
||||||
|
{:focus => 'course_respond',
|
||||||
|
:onclick => "toggleAndSettingWordsVal($('##{id}'),
|
||||||
|
$('##{id} textarea'),
|
||||||
|
'#{l(:label_reply_plural)} #{journal.user.name}: ');
|
||||||
|
return false;"} %>
|
||||||
|
<% end %>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<div style="clear: both;"></div>
|
||||||
|
<% if reply_allow %>
|
||||||
|
<div id='<%= id %>' class="respond-form">
|
||||||
|
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div style="clear: both;"></div>
|
||||||
|
<div>
|
||||||
|
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="pagination" style="float:left;">
|
||||||
|
<ul>
|
||||||
|
<%= pagination_links_full @feedback_pages %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
|
@ -0,0 +1 @@
|
||||||
|
<h3>文件列表</h3>
|
|
@ -0,0 +1,8 @@
|
||||||
|
<% if @save_flag %>
|
||||||
|
<% if Rails.env.development? %>
|
||||||
|
console.debug('课程修改成功:结束时间改为<%=Course.find_by_extra(@course.extra).try(:endup_time)%>');
|
||||||
|
<% end %>
|
||||||
|
$('#finish_course_<%=@course.id%>').replaceWith("<%= j(render partial: 'courses/set_course_time', :locals => {:course => @course} )%>")
|
||||||
|
<% else %>
|
||||||
|
alert('权限不足,设置失败,请在论坛提交问题,等待管理员处理。');
|
||||||
|
<% end %>
|
|
@ -7,8 +7,8 @@
|
||||||
<!-- fq -->
|
<!-- fq -->
|
||||||
<!--modified by huang-->
|
<!--modified by huang-->
|
||||||
<div class="content-title-top">
|
<div class="content-title-top">
|
||||||
<% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where(id: [3, 4, 7, 9] )).size >0))%>
|
<% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.roles&Role.where(id: [3, 4, 7, 9] )).size >0))%>
|
||||||
<%= link_to(l(:label_course_homework_new), {:controller => 'projects', :action => 'new_homework'}, :class => 'icon icon-add') %>
|
<%= link_to(l(:label_course_homework_new), {:controller => 'courses', :action => 'new_homework'}, :class => 'icon icon-add') %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<div id="bid-show">
|
<div id="bid-show">
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
<div id="OpenWindow">
|
<div id="OpenWindow">
|
||||||
<div id="signup-ct">
|
<div id="signup-ct">
|
||||||
<div id="OpenWindow-header">
|
<div id="OpenWindow-header">
|
||||||
<h1> 课程: <%= @project.name%> </h1>
|
<h1> 课程: <%= @course.name%> </h1>
|
||||||
<p id='bid-desc'> 上传作业 </p>
|
<p id='bid-desc'> 上传作业 </p>
|
||||||
<a href="javascript:void(0);" class="modal_close"></a>
|
<a href="javascript:void(0);" class="modal_close"></a>
|
||||||
</div>
|
</div>
|
|
@ -0,0 +1,67 @@
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="top-content">
|
||||||
|
<%= form_tag(:controller => 'courses', :action => 'search', :method => :get) do %>
|
||||||
|
<table width="940px">
|
||||||
|
<tr>
|
||||||
|
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_practice) %></td>
|
||||||
|
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
|
||||||
|
<td rowspan="2">
|
||||||
|
<% if User.current.logged?%>
|
||||||
|
<% if User.current.user_extensions.identity == 0 %>
|
||||||
|
<%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new'},
|
||||||
|
:class => 'icon icon-add') if User.current.allowed_to?(:add_course,nil, :global => true) %></td>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td rowspan="2" >
|
||||||
|
<div class="course-search" style="float: right">
|
||||||
|
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||||
|
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/course", :controller => 'courses', :action => 'index', :course_type => 1 %> </a></td>
|
||||||
|
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index', :course_type => 1 %></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<%= sort_course(@s_type, @school_id)%>
|
||||||
|
|
||||||
|
<div id="courses-index">
|
||||||
|
<%if @courses%>
|
||||||
|
<%= render_course_hierarchy(@courses)%>
|
||||||
|
<%end%>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="pagination">
|
||||||
|
<ul>
|
||||||
|
<%= pagination_links_full @course_pages, @course_count %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if User.current.logged? %>
|
||||||
|
<p style="text-align:right;">
|
||||||
|
<span class="my-course"><%= l(:label_my_course) %></span>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% other_formats_links do |f| %>
|
||||||
|
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% content_for :sidebar do %>
|
||||||
|
<%= form_tag({}, :method => :get) do %>
|
||||||
|
<h3><%= l(:label_project_plural) %></h3>
|
||||||
|
<label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_projects) %></label>
|
||||||
|
<p>
|
||||||
|
<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title(l(:label_new_course)) -%>
|
|
@ -0,0 +1,10 @@
|
||||||
|
<div class="member_header">
|
||||||
|
<p>
|
||||||
|
<%= @subPage_title %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="member_content">
|
||||||
|
<%= error_messages_for 'member' %>
|
||||||
|
<%= render :partial => @render_file, :locals => {:members => @members} %>
|
||||||
|
</div>
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
<%= labelled_form_for @course do |f| %>
|
||||||
|
<h3><%=l(:label_course_new)%></h3>
|
||||||
|
<div class="box tabular">
|
||||||
|
<%= render :partial => 'course_form', :locals => { :f => f } %>
|
||||||
|
<span style="padding-left: 60px"><%= submit_tag l(:button_create), :class => "enterprise"%></span>
|
||||||
|
<!-- <%= submit_tag l(:button_create_and_continue), :name => 'course_continue' %> -->
|
||||||
|
<%= javascript_tag "$('#course_name').focus();" %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -0,0 +1,3 @@
|
||||||
|
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'projects/new_join', :locals => {:course => @course}) %>');
|
||||||
|
showModal('ajax-modal', '400px');
|
||||||
|
$('#ajax-modal').addClass('new-watcher');
|
|
@ -0,0 +1,66 @@
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= auto_discovery_link_tag(:atom, {:action => 'index', :format => 'atom', :key => User.current.rss_key}) %>
|
||||||
|
<% end %>
|
||||||
|
<div class="top-content">
|
||||||
|
<%= form_tag(:controller => 'courses', :action => 'search', :method => :get) do %>
|
||||||
|
<table width="940px">
|
||||||
|
<tr>
|
||||||
|
<td class="info_font" style="width: 220px; color: #15bccf"><%= l(:label_course_practice) %></td>
|
||||||
|
<td class="location-list"><strong><%= l(:label_user_location) %> :</strong></td>
|
||||||
|
<td rowspan="2">
|
||||||
|
<% if User.current.logged?%>
|
||||||
|
<% if User.current.user_extensions.identity == 0 %>
|
||||||
|
<%= link_to(l(:label_course_new), {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add') if User.current.allowed_to?(:add_course, nil, :global => true) %></td>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<td rowspan="2" >
|
||||||
|
<div class="project-search" style="float: right">
|
||||||
|
<%= text_field_tag 'name', params[:name], :size => 30 %>
|
||||||
|
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="padding-left: 8px"><a><%= link_to "forge.trustie.net/courses", :controller => 'courses', :action => 'index'%> </a></td>
|
||||||
|
<td ><%=link_to l(:field_homepage), home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if @courses.size == 0 %>
|
||||||
|
<%= render :partial => 'layouts/no_content'%>
|
||||||
|
<% else %>
|
||||||
|
<div id="courses-index">
|
||||||
|
<%= render_course_hierarchy(@courses)%>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div class="pagination">
|
||||||
|
<ul>
|
||||||
|
<%= pagination_links_full @course_pages %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% if User.current.logged? %>
|
||||||
|
<p style="text-align:right;">
|
||||||
|
<span class="my-project"><%= l(:label_my_projects) %></span>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% other_formats_links do |f| %>
|
||||||
|
<%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% content_for :sidebar do %>
|
||||||
|
<%= form_tag({}, :method => :get) do %>
|
||||||
|
<h3><%= l(:label_project_plural) %></h3>
|
||||||
|
<label for="closed"><%= check_box_tag 'closed', 1, params[:closed] %> <%= l(:label_show_closed_projects) %></label>
|
||||||
|
<p>
|
||||||
|
<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title(l(:label_course_all)) -%>
|
|
@ -0,0 +1,3 @@
|
||||||
|
<h3><%=l(:label_settings)%></h3>
|
||||||
|
<%= render_tabs course_settings_tabs %>
|
||||||
|
<% html_title(l(:label_settings)) -%>
|
|
@ -0,0 +1,92 @@
|
||||||
|
<%= error_messages_for 'member' %>
|
||||||
|
<%
|
||||||
|
roles = Role.givable.all
|
||||||
|
roles = roles[3..5]
|
||||||
|
members = @course.member_principals.includes(:roles, :principal).all.sort
|
||||||
|
%>
|
||||||
|
|
||||||
|
<div class="splitcontentleft">
|
||||||
|
<% if members.any? %>
|
||||||
|
<table class="list members">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th><%= l(:label_user) %></th>
|
||||||
|
<th><%= l(:label_role_plural) %></th>
|
||||||
|
<th style="width:15%"></th>
|
||||||
|
<%= call_hook(:view_projects_settings_members_table_header, :course => @course) %>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% members.each do |member| %>
|
||||||
|
<% next if member.new_record? %>
|
||||||
|
<tr id="member-<%= member.id %>" class="<%= cycle 'odd', 'even' %> member">
|
||||||
|
<td class="<%= member.principal.class.name.downcase %>"><%= link_to_user member.principal %></td>
|
||||||
|
<td class="roles">
|
||||||
|
<span id="member-<%= member.id %>-roles">
|
||||||
|
<%= h member.roles.sort.collect(&:to_s).join(', ') %>
|
||||||
|
</span>
|
||||||
|
<%= form_for(member, {:as => :membership, :remote => true, :url => membership_path(member),
|
||||||
|
:method => :put,
|
||||||
|
:html => {:id => "member-#{member.id}-roles-form", :class => 'hol'}}
|
||||||
|
) do |f| %>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<% roles.each do |role| %>
|
||||||
|
<label><%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
|
||||||
|
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %> <%= h role %></label><br/>
|
||||||
|
<% end %></p>
|
||||||
|
<%= hidden_field_tag 'membership[role_ids][]', '' %>
|
||||||
|
<p><%= submit_tag l(:button_change), :class => "small" %>
|
||||||
|
<%= link_to_function l(:button_cancel),
|
||||||
|
"$('#member-#{member.id}-roles').show(); $('#member-#{member.id}-roles-form').hide(); return false;"
|
||||||
|
%></p>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
<!--modified by huang for: if the user'roles is Manager that he will can't modified himself-->
|
||||||
|
<% if member.roles.first.to_s == "Manager" %>
|
||||||
|
<td class="buttons"></td>
|
||||||
|
<% else %>
|
||||||
|
<td class="buttons">
|
||||||
|
<%= link_to_function l(:button_edit),
|
||||||
|
"$('#member-#{member.id}-roles').hide(); $('#member-#{member.id}-roles-form').show(); return false;",
|
||||||
|
:class => 'icon icon-edit' %>
|
||||||
|
<%= delete_link membership_path(member),
|
||||||
|
:remote => true,
|
||||||
|
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {}) if member.deletable? %>
|
||||||
|
</td>
|
||||||
|
<% end %>
|
||||||
|
<!--end-->
|
||||||
|
<%= call_hook(:view_projects_settings_members_table_header, {:course => @course, :member => member}) %>
|
||||||
|
</tr>
|
||||||
|
<% end; reset_cycle %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% else %>
|
||||||
|
<p class="nodata"><%= l(:label_no_data) %></p>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="splitcontentright">
|
||||||
|
<% if roles.any? %>
|
||||||
|
<%= form_for(@member, {:as => :membership, :url => course_memberships_path(@course), :remote => true, :method => :post}) do |f| %>
|
||||||
|
<fieldset>
|
||||||
|
<legend><%= l(:label_member_new) %></legend>
|
||||||
|
|
||||||
|
<p><%= label_tag "principal_search", l(:label_principal_search) %><%= text_field_tag 'principal_search', nil %></p>
|
||||||
|
<%= javascript_tag "observeSearchfield('principal_search', null, '#{ escape_javascript autocomplete_course_memberships_path(@course, :format => 'js') }')" %>
|
||||||
|
|
||||||
|
<div id="principals_for_new_member">
|
||||||
|
<%= render_principals_for_new_course_members(@course) %>
|
||||||
|
</div>
|
||||||
|
<!--show the roles which will select-->
|
||||||
|
<p style="padding-top: 5px"><%= l(:label_role_plural) %>:
|
||||||
|
<% roles.each do |role| %>
|
||||||
|
|
||||||
|
<label><%= check_box_tag 'membership[role_ids][]', role.id %> <%= h role %></label>
|
||||||
|
<% end %></p>
|
||||||
|
|
||||||
|
<p><%= submit_tag l(:button_add), :id => 'member-add-submit' %></p>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
|
@ -0,0 +1,108 @@
|
||||||
|
<% if @events_by_day.size >0 %>
|
||||||
|
<div class="content-title-top-avtive">
|
||||||
|
<!-- <h3><%= @author.nil? ? l(:label_activity) : l(:label_user_activity, link_to_user(@author)).html_safe %></h3> -->
|
||||||
|
<p class="subtitle">
|
||||||
|
<%= l(:label_date_from_to, :start => format_date(@date_to - @days), :end => format_date(@date_to-1)) %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<% @events_by_day.keys.sort.reverse.each do |day| %>
|
||||||
|
<div>
|
||||||
|
<% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%>
|
||||||
|
<div>
|
||||||
|
<table class="underline-evreycontent" style="font-size: 14px;">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(e.event_author), :class => "avatar")%></td>
|
||||||
|
<td>
|
||||||
|
<table width="580px" border="0">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" valign="top">
|
||||||
|
<strong> <%= h(e.event_title) if @course.nil? || (e.course != nil && @course.id != e.course.id) %></strong>
|
||||||
|
<span class="font_lighter">
|
||||||
|
<% if @canShowRealName %>
|
||||||
|
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>(<%= link_to_user(e.event_author,@canShowRealName) if e.respond_to?(:event_author) %>)
|
||||||
|
<% else %>
|
||||||
|
<%= link_to_user(e.event_author) if e.respond_to?(:event_author) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= l(:label_new_activity) %> </span>
|
||||||
|
|
||||||
|
<%= link_to "#{eventToLanguageCourse(e.event_type, @course)}: "<< format_activity_title(e.event_title), (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : e.event_url %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" width="580px" >
|
||||||
|
<p class="info-break">
|
||||||
|
<%= h(truncate(strip_tags(e.event_description).gsub(/ /,' '), length: 30, omission:'...')) %>
|
||||||
|
</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="left"><span class="font_lighter"> <%= l :label_activity_time %>: <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %></span></td>
|
||||||
|
<% if e.event_type == "issue" %>
|
||||||
|
<td align="right"><span> <%= link_to l(:label_find_all_comments), issue_path(e) %> </span><span class="font_lighter"><%= l(:label_comments_count, :count => e.journals.count)%></span></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
</table></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Added by Longjun 在最后一页显示创建信息 -->
|
||||||
|
<% if format_date(day) == format_date(@date_to - @days) %>
|
||||||
|
<h1>Test</h1>
|
||||||
|
<div >
|
||||||
|
<table width="660">
|
||||||
|
<tr>
|
||||||
|
<td><%= image_tag(url_to_avatar(@user), :class => "avatar") %></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<table width="580">
|
||||||
|
<tr>
|
||||||
|
<td > <%= link_to (h @user.try(:name)), user_path(@user) if @user %> <%= l(:label_user_create_project) %> <%= link_to @course.name %><strong> !</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="font_lighter" style="float: right"><%= l :label_update_time %>: <%= format_time(@course.created_on) %>
|
||||||
|
</table></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<% end -%>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="pagination">
|
||||||
|
<ul>
|
||||||
|
<%= pagination_links_full @events_pages%>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="font_description">
|
||||||
|
<table width="660">
|
||||||
|
<tr>
|
||||||
|
<td><%= image_tag(url_to_avatar(@user), :class => "avatar") %></td>
|
||||||
|
<td colspan="2">
|
||||||
|
<table width="580">
|
||||||
|
<tr>
|
||||||
|
<td >
|
||||||
|
<%
|
||||||
|
#判断是否显示真名
|
||||||
|
if @canShowRealName
|
||||||
|
%>
|
||||||
|
<%= link_to (h @user.try(:name)), user_path(@user) if @user %>(<%= link_to (h @user.try(:realname)), user_path(@user) if @user %>)
|
||||||
|
<% else %>
|
||||||
|
<%= link_to (h @user.try(:name)), user_path(@user) if @user %>
|
||||||
|
<% end %>
|
||||||
|
<%= l(:label_user_create_project) %> <%= link_to @course.name %><strong> !</strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="font_lighter" style="float: right"><%= l :label_update_time %>: <%= format_time(@course.created_at) %>
|
||||||
|
</table></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
|
||||||
|
<% attachmenttypes = @course.attachmenttypes %>
|
||||||
|
<% sufixtypes = @course.contenttypes %>
|
||||||
|
|
||||||
|
<span class="borad-title"><%= t(:label_user_course) %>资源共享区</span>
|
||||||
|
|
||||||
|
<div class="content-title-top">
|
||||||
|
|
||||||
|
<%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
<div id="file_buttons" class="nhidden">
|
||||||
|
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
|
||||||
|
<% if attachmenttypes.any? %>
|
||||||
|
|
||||||
|
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
||||||
|
<%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
||||||
|
:onchange => "course_attachmenttypes_searchex(this.value)" %>
|
||||||
|
<% end %>
|
||||||
|
<% if sufixtypes.any? %>
|
||||||
|
|
||||||
|
<label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label>
|
||||||
|
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
||||||
|
:onchange => "course_attachment_contenttypes_searchex(this.value)" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div id="upload_file_div" class="relation_file_div hidden">
|
||||||
|
<%= render :partial => 'course_new', locals: {course: @course} %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="relation_file_div" class="relation_file_div hidden">
|
||||||
|
<fieldset>
|
||||||
|
<legend>搜索</legend>
|
||||||
|
<%= form_tag(
|
||||||
|
attachments_autocomplete_path(:format => 'js'),
|
||||||
|
:remote => true,
|
||||||
|
:method => :post) do %>
|
||||||
|
<%= label_tag(:attach_search, "按关键字搜索:") %>
|
||||||
|
<%= text_field_tag(:attach_search) %>
|
||||||
|
<%#= submit_tag("Search") %>
|
||||||
|
<% end -%>
|
||||||
|
<%= form_tag attach_relation_path(:format => 'js'),
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
id: "relation_file_form",
|
||||||
|
:class => 'hidden' do %>
|
||||||
|
<%= hidden_field_tag(:class_name, 'course') %>
|
||||||
|
<%= hidden_field_tag(:class_id, params[:course_id]) %>
|
||||||
|
<div id="relation_file">
|
||||||
|
</div>
|
||||||
|
<div class="kclearfix" style='margin-top: 10px;'>
|
||||||
|
<%= submit_tag(l(:button_add)) -%>
|
||||||
|
</div>
|
||||||
|
<% end -%>
|
||||||
|
</fieldset>
|
||||||
|
<div class="line_under" style="margin:20px 0px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:course_id => @course.id, :format => 'js') }')" %>
|
||||||
|
|
||||||
|
|
||||||
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
|
||||||
|
<div id="all_browse_div" class="all_browse_div">
|
||||||
|
<%= render :partial => 'course_show_all_attachment' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% html_title(l(:label_attachment_plural)) -%>
|
|
@ -0,0 +1,41 @@
|
||||||
|
<h3><%=l(:label_attachment_new)%></h3>
|
||||||
|
<% attachmenttypes = course.attachmenttypes %>
|
||||||
|
<%= error_messages_for 'attachment' %>
|
||||||
|
<%= form_tag(course_files_path(course), :multipart => true,:remote => true,:method => :post,:name=>"upload_form", :class => "tabular") do %>
|
||||||
|
<div class="box">
|
||||||
|
<p>
|
||||||
|
<% if attachmenttypes.any? %>
|
||||||
|
<%= l(:attachment_type) %></label>
|
||||||
|
<%= select_tag "attachment_type",
|
||||||
|
options_from_collection_for_select(attachmenttypes, "id",
|
||||||
|
"typeName", 2), {style: 'width:100px'} %>
|
||||||
|
<% end %>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
|
||||||
|
</div>
|
||||||
|
<%= submit_tag l(:button_add) %>
|
||||||
|
<% end %>
|
||||||
|
<div class="line_under" style="margin:20px 0px;"></div>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
function tagAddClick(id,objId,objTag)
|
||||||
|
{
|
||||||
|
alert("OK");
|
||||||
|
$.ajax({
|
||||||
|
type :"POST",
|
||||||
|
url :'<%= users_tag_saveEx_path%>',
|
||||||
|
data: {
|
||||||
|
tagname: $('tag_name').value,
|
||||||
|
obj_id: encodeURIComponent(objId),
|
||||||
|
obj_flag:encodeURIComponent(objTag)
|
||||||
|
},
|
||||||
|
success: function(data, textStatus){
|
||||||
|
alert("OK");
|
||||||
|
$(id).empty();
|
||||||
|
$(id).html('123');
|
||||||
|
$("#" + id + " #name").val("");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
|
@ -0,0 +1,72 @@
|
||||||
|
<% selAttachType =@attachtype %>
|
||||||
|
<% selContentType =@contenttype %>
|
||||||
|
<% attachmenttypes = @course.attachmenttypes %>
|
||||||
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<table class="list files" id="ver-zebra">
|
||||||
|
<colgroup>
|
||||||
|
<col class="vzebra-odd"/>
|
||||||
|
<col class="vzebra-even"/>
|
||||||
|
<col class="vzebra-odd"/>
|
||||||
|
<col class="vzebra-even"/>
|
||||||
|
<!-- <col class="vzebra-odd"/> -->
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
|
||||||
|
<%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %>
|
||||||
|
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
|
||||||
|
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
|
||||||
|
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-contenttype") %>
|
||||||
|
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
|
||||||
|
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
|
||||||
|
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @containers.each do |container| %>
|
||||||
|
<% next if container.attachments.empty? -%>
|
||||||
|
<% if container.is_a?(Version) -%>
|
||||||
|
<tr>
|
||||||
|
<th colspan="5" align="left" style="line-height: 30px; font-size: 14px; ">
|
||||||
|
<%= link_to(h(container), {:controller => 'versions', :action => 'show', :id => container}, :class => "icon icon-package", :style => "color: #666666;") %>
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
<% end -%>
|
||||||
|
<% container.attachments.each do |file| %>
|
||||||
|
<tr class="file <%= cycle("odd", "odd") %>">
|
||||||
|
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||||
|
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
|
||||||
|
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||||
|
<td class="attach_type">
|
||||||
|
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
|
||||||
|
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
|
||||||
|
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes, :attachment => file, :contentype => selContentType} %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||||
|
<td class="downloads"><%= file.downloads %></td>
|
||||||
|
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||||
|
<td align="center">
|
||||||
|
<%= link_to(image_tag('delete.png'), attachment_path(file),
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class='description' colspan="6">
|
||||||
|
<div class="tags_area">
|
||||||
|
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
|
||||||
|
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
|
||||||
|
<div class="tags_gradint"></div>
|
||||||
|
</div>
|
||||||
|
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a></div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end -%>
|
||||||
|
<% reset_cycle %>
|
||||||
|
<% end -%>
|
||||||
|
<!-- %= h downloadAll(@containers) % -->
|
||||||
|
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
|
@ -0,0 +1,71 @@
|
||||||
|
<% selAttachType =@attachtype %>
|
||||||
|
<% selContentType =@contenttype %>
|
||||||
|
<% attachmenttypes = @course.attachmenttypes %>
|
||||||
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<% edit_allowed = User.current.allowed_to?(:manage_files, @course) %>
|
||||||
|
<table class="list files" id="ver-zebra">
|
||||||
|
<colgroup>
|
||||||
|
<col class="vzebra-odd"/>
|
||||||
|
<col class="vzebra-even"/>
|
||||||
|
<col class="vzebra-odd"/>
|
||||||
|
<col class="vzebra-even"/>
|
||||||
|
<!-- <col class="vzebra-odd"/> -->
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<%= sort_header_tag('filename', :caption => l(:field_filename), :scope => "col", :id => "vzebra-adventure") %>
|
||||||
|
<%#= sort_header_tag('created_on', :caption => l(:label_date), :default_order => 'desc', :scope => "col", :id => "vzebra-comedy") %>
|
||||||
|
<%= sort_header_tag('size', :caption => l(:field_filesize), :default_order => 'desc', :scope => "col", :id => "vzebra-children") %>
|
||||||
|
<%= sort_header_tag('attach_type', :caption => l(:attachment_browse), :default_order => 'desc', :scope => "col", :id => "vzebra-attachmenttype") %>
|
||||||
|
<%= sort_header_tag('content_type', :caption => l(:attachment_sufix_browse), :default_order => 'desc', :scope =>"col", :id=> "vzebra-contenttype")%>
|
||||||
|
<%= sort_header_tag('downloads', :caption => l(:field_downloads), :default_order => 'desc', :scope => "col", :id => "vzebra-action") %>
|
||||||
|
<%= sort_header_tag('operation', :caption => "", :scope => "col", :id => "vzebra-children") %>
|
||||||
|
<!-- <%= sort_header_tag('description', :caption => l(:field_description)) %> -->
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<% @containers.each do |container| %>
|
||||||
|
<% next if container.attachments.empty? -%>
|
||||||
|
<% container.attachments.each do |file| %>
|
||||||
|
<% if isTypeOk(file,selAttachType,selContentType) %>
|
||||||
|
<tr class="file <%= cycle("odd", "odd") %>">
|
||||||
|
<td class="filename" style="font-size: 13px; "><%= link_to_attachment file, :download => true, :title => file.filename+"\n"+file.description.to_s, :style => "width: 230px; overflow: hidden; white-space: nowrap;text-overflow: ellipsis;" %></td>
|
||||||
|
<!-- <td class="created_on"><%#= format_time(file.created_on) %></td> -->
|
||||||
|
<td class="filesize"><%= number_to_human_size(file.filesize) %></td>
|
||||||
|
<td class="attach_type">
|
||||||
|
<span id="attach_type_id_label<%= file.id %>" style="white-space:nowrap;"><%= file.attachmentstype.typeName %></span>
|
||||||
|
|
||||||
|
<span id="attach_type_id_edit<%= file.id %>" style="white-space:nowrap;">
|
||||||
|
<%= render :partial => 'attachments/course_type_edit', :locals => {:attachmenttypes => attachmenttypes,
|
||||||
|
:attachment => file,:contentype=>selContentType} %>
|
||||||
|
</span>
|
||||||
|
</td>
|
||||||
|
<td class="content_type"><%= file.show_suffix_type %></td>
|
||||||
|
<td class="downloads"><%= file.downloads %></td>
|
||||||
|
<!-- <td class="digest" width="300px"><%= file.description %></td> -->
|
||||||
|
<td align="center">
|
||||||
|
<%= link_to(image_tag('delete.png'), attachment_path(file),
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete) if delete_allowed %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class='description' colspan="6">
|
||||||
|
<div class="tags_area">
|
||||||
|
<%# @preTags = %w|预设A 预设B 预设C 预设D 预设E 预设Z | %>
|
||||||
|
<%= render :partial => 'tags/tag', :locals => {:obj => file, :object_flag => "6"} %>
|
||||||
|
<div class="tags_gradint"></div>
|
||||||
|
</div>
|
||||||
|
<div class="read-more hidden"><a href="javascript:void(0);" onclick="readmore(this);"> 更多 </a>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end -%>
|
||||||
|
<% end -%>
|
||||||
|
<% reset_cycle %>
|
||||||
|
<% end -%>
|
||||||
|
<!-- %= h downloadAll(@containers) % -->
|
||||||
|
<!-- %= link_to "download all file", (downloadAll(@containers)) % -->
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<% versions = project.versions.sort %>
|
<% versions = project.versions.sort %>
|
||||||
<% attachmenttypes = project.attachmenttypes %>
|
<% attachmenttypes = project.attachmenttypes %>
|
||||||
<%= error_messages_for 'attachment' %>
|
<%= error_messages_for 'attachment' %>
|
||||||
<%= form_tag(project_files_path(project), :multipart => true,:remote => false,:method => :post,:name=>"upload_form", :class => "tabular") do %>
|
<%= form_tag(project_files_path(project), :multipart => true,:remote => true,:method => :post,:name=>"upload_form", :class => "tabular") do %>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
<p>
|
<p>
|
||||||
<table>
|
<table>
|
||||||
|
@ -13,6 +13,8 @@
|
||||||
<%= select_tag "version_id", content_tag('option', '') +
|
<%= select_tag "version_id", content_tag('option', '') +
|
||||||
options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %>
|
options_from_collection_for_select(versions, "id", "name"), {style: 'width:100px'} %>
|
||||||
</td>
|
</td>
|
||||||
|
<% else %>
|
||||||
|
<td><p></p></td> <td></td>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<% if attachmenttypes.any? %>
|
<% if attachmenttypes.any? %>
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
|
||||||
|
<% attachmenttypes = @project.attachmenttypes %>
|
||||||
|
<% sufixtypes = @project.contenttypes %>
|
||||||
|
|
||||||
|
<span class="borad-title"><%= (@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区</span>
|
||||||
|
|
||||||
|
<div class="content-title-top">
|
||||||
|
|
||||||
|
<%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
<div id="file_buttons" class="nhidden">
|
||||||
|
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %>
|
||||||
|
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
||||||
|
|
||||||
|
<% if attachmenttypes.any? %>
|
||||||
|
|
||||||
|
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
||||||
|
<%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
||||||
|
:onchange => "attachmenttypes_searchex(this.value)" %>
|
||||||
|
<% end %>
|
||||||
|
<% if sufixtypes.any? %>
|
||||||
|
|
||||||
|
<label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label>
|
||||||
|
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
||||||
|
:onchange => "attachment_contenttypes_searchex(this.value)" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div id="upload_file_div" class="relation_file_div hidden">
|
||||||
|
<%= render :partial => 'new', locals: {project: @project} %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="relation_file_div" class="relation_file_div hidden">
|
||||||
|
<fieldset>
|
||||||
|
<legend>搜索</legend>
|
||||||
|
<%= form_tag(
|
||||||
|
attachments_autocomplete_path(:format => 'js'),
|
||||||
|
:remote => true,
|
||||||
|
:method => :post) do %>
|
||||||
|
<%= label_tag(:attach_search, "按关键字搜索:") %>
|
||||||
|
<%= text_field_tag(:attach_search) %>
|
||||||
|
<%#= submit_tag("Search") %>
|
||||||
|
<% end -%>
|
||||||
|
<%= form_tag attach_relation_path(:format => 'js'),
|
||||||
|
method: :post,
|
||||||
|
remote: true,
|
||||||
|
id: "relation_file_form",
|
||||||
|
:class => 'hidden' do %>
|
||||||
|
<%= hidden_field_tag(:class_name, 'Project') %>
|
||||||
|
<%= hidden_field_tag(:class_id, params[:project_id]) %>
|
||||||
|
<div id="relation_file">
|
||||||
|
</div>
|
||||||
|
<div class="kclearfix" style='margin-top: 10px;'>
|
||||||
|
<%= submit_tag(l(:button_add)) -%>
|
||||||
|
</div>
|
||||||
|
<% end -%>
|
||||||
|
</fieldset>
|
||||||
|
<div class="line_under" style="margin:20px 0px;"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %>
|
||||||
|
|
||||||
|
|
||||||
|
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
||||||
|
|
||||||
|
<div id="all_browse_div" class="all_browse_div">
|
||||||
|
<%= render :partial => 'show_all_attachment' %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% html_title(l(:label_attachment_plural)) -%>
|
|
@ -0,0 +1,32 @@
|
||||||
|
<%if @addTag%>
|
||||||
|
<% if @obj_flag == '3'%>
|
||||||
|
|
||||||
|
$('#tags_show_issue').html('<%= escape_javascript(render :partial => 'tags/tag_name',
|
||||||
|
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
|
||||||
|
//$('#put-tag-form-issue').hide();
|
||||||
|
$('#name-issue').val("");
|
||||||
|
<% elsif @obj_flag == '6'%>
|
||||||
|
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").empty();
|
||||||
|
$("#tags_show-<%=@obj.class%>-<%=@obj.id%>").html('<%= escape_javascript(render :partial => 'tags/tag_name',
|
||||||
|
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
|
||||||
|
$("#put-tag-form- <%=@obj.class%>- <%=@obj.id%>").hide();
|
||||||
|
$("#put-tag-form-<%=@obj.class%>-<%=@obj.id%> #name").val("");
|
||||||
|
<% else %>
|
||||||
|
|
||||||
|
$('#tags_show').html('<%= escape_javascript(render :partial => 'tags/tag_name',
|
||||||
|
:locals => {:obj => @obj,:non_list_all => false,:object_flag => @obj_flag}) %>');
|
||||||
|
$('#tags_show').html('<%=render_attachments_tag_save(@project, nil)%>');
|
||||||
|
$('#put-tag-form #name').val("");
|
||||||
|
//$('#put-tag-form').hide();
|
||||||
|
<% end %>
|
||||||
|
<%else%>
|
||||||
|
$("#attachments_fields").children().remove();
|
||||||
|
$("#upload_file_count").text("未上传文件");
|
||||||
|
$('#upload_file_div').slideToggle('slow');
|
||||||
|
<%if @project%>
|
||||||
|
$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>');
|
||||||
|
<%elsif @course%>
|
||||||
|
$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>');
|
||||||
|
<%end%>
|
||||||
|
<% end %>
|
||||||
|
|
|
@ -1,5 +1,13 @@
|
||||||
<% if @attachtype==0 && @contenttype=='0' %>
|
<% if @attachtype==0 && @contenttype=='0' %>
|
||||||
|
<% if @project%>
|
||||||
$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>');
|
$("#all_browse_div").html('<%= j(render partial: "show_all_attachment")%>');
|
||||||
<%else%>
|
<% elsif @course%>
|
||||||
$("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>');
|
$("#all_browse_div").html('<%= j(render partial: "course_show_all_attachment")%>');
|
||||||
|
<%end%>
|
||||||
|
<%else%>
|
||||||
|
<% if @project%>
|
||||||
|
$("#all_browse_div").html('<%= j(render partial: "sort_by_attachtypel")%>')
|
||||||
|
<% elsif @course%>
|
||||||
|
$("#all_browse_div").html('<%= j(render partial: "course_sort_by_attachtypel")%>')
|
||||||
|
<%end%>;
|
||||||
<%end%>
|
<%end%>
|
||||||
|
|
|
@ -1,75 +1,10 @@
|
||||||
<!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 -->
|
<!-- <h3> --><!-- %=l(:label_attachment_plural)%></h3 -->
|
||||||
<% attachmenttypes = @project.attachmenttypes %>
|
<% if @isproject %>
|
||||||
<% sufixtypes = @project.contenttypes %>
|
<%= render :partial => 'project_file', locals: {project: @project} %>
|
||||||
|
<% else %>
|
||||||
|
<%= render :partial => 'course_file', locals: {course: @course} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<span class="borad-title"><%= (@project.project_type == 1) ? t(:label_user_course) : t(:label_project) %>资源共享区</span>
|
|
||||||
|
|
||||||
<div class="content-title-top">
|
|
||||||
|
|
||||||
<%#= link_to(l(:label_attachment_new), 'javascript:void(0);', :onclick=>"$('#file_buttons').slideToggle();", :class => 'icon icon-add') if User.current.allowed_to?(:manage_files, @project) %>
|
|
||||||
<div class="clearfix"></div>
|
|
||||||
<div id="file_buttons" class="nhidden">
|
|
||||||
<%#= link_to('上传文件', new_project_file_path(@project), :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
|
||||||
<%= link_to(l(:label_upload_files), 'javascript:void(0);', :class => 'icon m5p5 button_submit', :onclick => "$('#relation_file_div').slideUp();$('#upload_file_div').slideToggle('slow');") if User.current.allowed_to?(:manage_files, @project) %>
|
|
||||||
<%= link_to(l(:label_relation_files), 'javascript:void(0);', :onclick => "$('#upload_file_div').slideUp();$('#relation_file_div').slideToggle();", :class => 'icon m5p5 button_submit') if User.current.allowed_to?(:manage_files, @project) %>
|
|
||||||
|
|
||||||
<% if attachmenttypes.any? %>
|
|
||||||
|
|
||||||
<label for="attachment_browse_label"><%= l(:attachment_browse) %></label>
|
|
||||||
<%= select_tag "attachment_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_from_collection_for_select(attachmenttypes, "id", "typeName"),
|
|
||||||
:onchange => "attachmenttypes_searchex(this.value)" %>
|
|
||||||
<% end %>
|
|
||||||
<% if sufixtypes.any? %>
|
|
||||||
|
|
||||||
<label for="attach_sufix_browse_label"><%= l(:attachment_sufix_browse) %></label>
|
|
||||||
<%= select_tag "attach_sufix_browse", content_tag(:option, l(:attachment_all), :value => '0') +options_for_select(sufixtypes),
|
|
||||||
:onchange => "attachment_contenttypes_searchex(this.value)" %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<div id="upload_file_div" class="relation_file_div hidden">
|
|
||||||
<%= render :partial => 'new', locals: {project: @project} %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="relation_file_div" class="relation_file_div hidden">
|
|
||||||
<fieldset>
|
|
||||||
<legend>搜索</legend>
|
|
||||||
<%= form_tag(
|
|
||||||
attachments_autocomplete_path(:format => 'js'),
|
|
||||||
:remote => true,
|
|
||||||
:method => :post) do %>
|
|
||||||
<%= label_tag(:attach_search, "按关键字搜索:") %>
|
|
||||||
<%= text_field_tag(:attach_search) %>
|
|
||||||
<%#= submit_tag("Search") %>
|
|
||||||
<% end -%>
|
|
||||||
<%= form_tag attach_relation_path(:format => 'js'),
|
|
||||||
method: :post,
|
|
||||||
remote: true,
|
|
||||||
id: "relation_file_form",
|
|
||||||
:class => 'hidden' do %>
|
|
||||||
<%= hidden_field_tag(:class_name, 'Project') %>
|
|
||||||
<%= hidden_field_tag(:class_id, params[:project_id]) %>
|
|
||||||
<div id="relation_file">
|
|
||||||
</div>
|
|
||||||
<div class="kclearfix" style='margin-top: 10px;'>
|
|
||||||
<%= submit_tag(l(:button_add)) -%>
|
|
||||||
</div>
|
|
||||||
<% end -%>
|
|
||||||
</fieldset>
|
|
||||||
<div class="line_under" style="margin:20px 0px;"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<%= javascript_tag "observeSearchfield('attach_search', null, '#{ escape_javascript attachments_autocomplete_path(:project_id => @project.id, :format => 'js') }')" %>
|
|
||||||
|
|
||||||
|
|
||||||
<% delete_allowed = User.current.allowed_to?(:manage_files, @project) %>
|
|
||||||
|
|
||||||
<div id="all_browse_div" class="all_browse_div">
|
|
||||||
<%= render :partial => 'show_all_attachment' %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% html_title(l(:label_attachment_plural)) -%>
|
|
||||||
|
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var slideHeight = 29;
|
var slideHeight = 29;
|
||||||
|
@ -123,7 +58,40 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function attachment_contenttypes_searchex(value) {
|
||||||
|
<% if @project%>
|
||||||
|
$.ajax({
|
||||||
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||||||
|
type: "POST",
|
||||||
|
data: {
|
||||||
|
type: $('#attachment_browse').val(),
|
||||||
|
contentType: encodeURIComponent(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
}).complete(eval_ajax);
|
||||||
|
<%end%>
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function attachtype_edit(value) {
|
||||||
|
<% if @project%>
|
||||||
|
$.ajax({
|
||||||
|
|
||||||
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||||||
|
type: "POST",
|
||||||
|
data: {
|
||||||
|
type: $('#attachment_browse').val(),
|
||||||
|
contentType: encodeURIComponent(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
}).complete(eval_ajax);
|
||||||
|
<%end%>
|
||||||
|
}
|
||||||
|
|
||||||
function attachmenttypes_searchex(value) {
|
function attachmenttypes_searchex(value) {
|
||||||
|
<% if @project%>
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -133,12 +101,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}).complete(eval_ajax);
|
}).complete(eval_ajax);
|
||||||
|
<%end%>
|
||||||
}
|
}
|
||||||
|
|
||||||
function attachment_contenttypes_searchex(value) {
|
function course_attachmenttypes_searchex(value) {
|
||||||
|
<% if @course%>
|
||||||
|
$.ajax({
|
||||||
|
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
|
||||||
|
type: "POST",
|
||||||
|
data: {
|
||||||
|
type: encodeURIComponent(value),
|
||||||
|
contentType: $('#attach_sufix_browse').val()
|
||||||
|
}
|
||||||
|
|
||||||
|
}).complete(eval_ajax);
|
||||||
|
<%end%>
|
||||||
|
}
|
||||||
|
|
||||||
|
function course_attachment_contenttypes_searchex(value) {
|
||||||
|
<% if @course%>
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
|
||||||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
type: $('#attachment_browse').val(),
|
type: $('#attachment_browse').val(),
|
||||||
|
@ -146,12 +130,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}).complete(eval_ajax);
|
}).complete(eval_ajax);
|
||||||
|
<%end%>
|
||||||
}
|
}
|
||||||
|
function course_attachtype_edit(value) {
|
||||||
function attachtype_edit(value) {
|
<% if @course%>
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
|
||||||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
|
||||||
type: "POST",
|
type: "POST",
|
||||||
data: {
|
data: {
|
||||||
type: $('#attachment_browse').val(),
|
type: $('#attachment_browse').val(),
|
||||||
|
@ -159,9 +143,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}).complete(eval_ajax);
|
}).complete(eval_ajax);
|
||||||
|
<%end%>
|
||||||
}
|
}
|
||||||
|
|
||||||
function attachmenttypes_change(id, type) {
|
function attachmenttypes_change(id, type) {
|
||||||
|
<% if @project%>
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<%=updateType_attachments_path%>',
|
url: '<%=updateType_attachments_path%>',
|
||||||
type: "POST",
|
type: "POST",
|
||||||
|
@ -171,6 +157,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
}).complete(function (xhr, textStatus) {
|
}).complete(function (xhr, textStatus) {
|
||||||
|
|
||||||
if (textStatus == 'success') {
|
if (textStatus == 'success') {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
url: '<%=getattachtype_project_files_path(project_id: @project)%>',
|
||||||
|
@ -186,6 +173,39 @@
|
||||||
alert('An error has occurred');
|
alert('An error has occurred');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
<%end%>
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
function course_attachmenttypes_change(id, type) {
|
||||||
|
<% if @course%>
|
||||||
|
$.ajax({
|
||||||
|
url: '<%=updateType_attachments_path%>',
|
||||||
|
type: "POST",
|
||||||
|
data: {
|
||||||
|
attachmentid: encodeURIComponent(id),
|
||||||
|
newtype: encodeURIComponent(type)
|
||||||
|
}
|
||||||
|
|
||||||
|
}).complete(function (xhr, textStatus) {
|
||||||
|
|
||||||
|
if (textStatus == 'success') {
|
||||||
|
$.ajax({
|
||||||
|
url: '<%=getattachtype_course_files_path(course_id: @course)%>',
|
||||||
|
type: "POST",
|
||||||
|
data: {
|
||||||
|
type: $('#attachment_browse').val(),
|
||||||
|
contentType: $('#attach_sufix_browse').val()
|
||||||
|
}
|
||||||
|
}).error(function () {
|
||||||
|
alert('error');
|
||||||
|
});
|
||||||
|
} else if (textStatus == 'error') {
|
||||||
|
alert('An error has occurred');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
<%end%>
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -16,9 +16,9 @@
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%></a></td>
|
||||||
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> >
|
||||||
<span><%= link_to(@homework.bid.courses.first.name.to_s, homework_project_path(@homework.bid.courses.first)) if @homework.bid.courses.first%></span> >
|
<span><%= link_to(@homework.bid.courses.first.name.to_s, homework_course_path(@homework.bid.courses.first)) if @homework.bid.courses.first%></span> >
|
||||||
<%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <span><%= link_to "修改作业",edit_homework_attach_path(@homework)%></span></p></td>
|
<%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <span><%= link_to "修改作业",edit_homework_attach_path(@homework)%></span></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%></a></td>
|
||||||
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> >
|
||||||
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
|
<span><%= link_to(@bid.courses.first.name.to_s, homework_course_path(@bid.courses.first)) if @bid.courses.first%></span> >
|
||||||
<%=link_to(@bid.name, respond_path(@bid)) %> > <span><%= link_to "创建作业", new_homework_attach_path(@bid)%></span></p></td>
|
<%=link_to(@bid.name, respond_path(@bid)) %> > <span><%= link_to "创建作业", new_homework_attach_path(@bid)%></span></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index'%></a></td>
|
||||||
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> >
|
||||||
<span><%= link_to(homework_attach.bid.courses.first.name.to_s, homework_project_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%></span> >
|
<span><%= link_to(homework_attach.bid.courses.first.name.to_s, homework_course_path(homework_attach.bid.courses.first)) if homework_attach.bid.courses.first%></span> >
|
||||||
<%=link_to(homework_attach.bid.name, respond_path(homework_attach.bid)) %> > <span><%= link_to homework_attach.name.nil? ? homework_attach.attachments.first.filename : homework_attach.name,homework_attach_path(homework_attach)%></span></p></td>
|
<%=link_to(homework_attach.bid.name, respond_path(homework_attach.bid)) %> > <span><%= link_to homework_attach.name.nil? ? homework_attach.attachments.first.filename : homework_attach.name,homework_attach_path(homework_attach)%></span></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -26,72 +26,61 @@
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<!--added by huang-->
|
<!--added by huang-->
|
||||||
<div class="top-content">
|
<div class="top-content">
|
||||||
<% @project = Project.find_by_id(@project.id) %>
|
|
||||||
<% @course = Course.find_by_extra(@project.identifier) %>
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||||
<td style="color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
<td style="color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
<td rowspan="2" width="250px">
|
<td rowspan="2" width="250px">
|
||||||
<div class="top-content-search">
|
<div class="top-content-search">
|
||||||
<%= form_tag(:controller => 'projects', :action => 'search', :method => :get) do %>
|
<%= form_tag(:controller => 'courses', :action => 'search', :method => :get) do %>
|
||||||
<%= text_field_tag 'name', params[:name], :size => 20 %>
|
<%= text_field_tag 'name', params[:name], :size => 20 %>
|
||||||
<%= hidden_field_tag 'project_type', @project.project_type %>
|
|
||||||
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
<%= submit_tag l(:label_search), :class => "enterprise", :name => nil %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><%= link_to request.host()+"/course", :controller => 'projects', :action => 'course' %></td>
|
<td style="padding-left: 8px"><%= link_to request.host()+"/course", :controller => 'courses', :action => 'index' %></td>
|
||||||
<td><p class="top-content-list"><%= link_to "主页", home_path %>
|
<td><p class="top-content-list"><%= link_to "主页", home_path %>
|
||||||
> <%= link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %>
|
> <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %>
|
||||||
> <%= link_to @project.name, nil %></p></td>
|
> <%= link_to @course.name, nil %></p></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<!-- end -->
|
<!-- end -->
|
||||||
<!--project page-->
|
<!--course page-->
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<div class="spaceleft">
|
<div class="spaceleft">
|
||||||
<!--informations-->
|
<!--informations-->
|
||||||
<div class="inf_user_image">
|
<div class="inf_user_image">
|
||||||
<% @project = Project.find_by_id(@project.id) %>
|
|
||||||
<% @course = Course.find_by_extra(@project.identifier) %>
|
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<% if (@project.project_type==1) %>
|
<% if get_avatar?(@course) %>
|
||||||
<% if get_avatar?(@project) %>
|
<%= image_tag(url_to_avatar(@course), :class => "avatar2") %>
|
||||||
<%= image_tag(url_to_avatar(@project), :class => "avatar2") %>
|
|
||||||
<% else %>
|
|
||||||
<%= link_to image_tag('../images/avatars/Project/course.jpg', :class => "avatar2"), project_path(@project) %>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_tag(url_to_avatar(@project), :class => "avatar2") %>
|
<%= link_to image_tag('../images/avatars/course/course.jpg', :class => "avatar2"), course_path(@course) %>
|
||||||
<% end %> </td>
|
<% end %>
|
||||||
<td>
|
<td>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<!-- modified by zjc 课程名称添加超链接 -->
|
<!-- modified by zjc 课程名称添加超链接 -->
|
||||||
<td class="info-course"><%= link_to @project.name,project_path(@project) %></td>
|
<td class="info-course"><%= link_to @course.name,course_path(@course) %></td>
|
||||||
|
<td class="info-course"><%= @course.name %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td align="center">
|
<td align="center">
|
||||||
<div id="join_in_course">
|
<div id="join_in_course">
|
||||||
<% if User.current.logged? %>
|
<% if User.current.logged? %>
|
||||||
<% if @course.teacher.id == User.current.id %>
|
<% if @course.teacher.id == User.current.id %>
|
||||||
<%= link_to l(:label_course_modify_settings), {:controller => 'projects', :action => 'settings', :id => @project} %>
|
<%= link_to l(:label_course_modify_settings), {:controller => 'courses', :action => 'settings', :id => @course} %>
|
||||||
<%= render :partial => 'courses/set_course_time', :locals => {:project => @project} %>
|
<%= render :partial => 'courses/set_course_time', :locals => {:course => @course} %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|
||||||
<%= join_in_course(@project, User.current) %>
|
<%= join_in_course(@course, User.current) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% unless User.current.member_of?(@project) %>
|
<% unless User.current.member_of_course?(@course) %>
|
||||||
<!-- <%= image_tag "/images/fav.png" %> -->
|
<!-- <%= image_tag "/images/fav.png" %> -->
|
||||||
<div style="padding-right: 10px">
|
|
||||||
<span class="icon-fav icon"></span><span>
|
|
||||||
<%= watcher_link(@project, User.current) %></span></div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -108,34 +97,31 @@
|
||||||
|
|
||||||
<table width="240" border="0">
|
<table width="240" border="0">
|
||||||
<tr align="center" width="80px">
|
<tr align="center" width="80px">
|
||||||
<% files_count = @project.attachments.count %>
|
<% files_count = @course.attachments.count %>
|
||||||
<% @project.versions.each do |version| %>
|
|
||||||
<% files_count += version.attachments.count %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<td class="font_index">
|
<td class="font_index">
|
||||||
<!-- 1 教师; 2 学生;0 全部-->
|
<!-- 1 教师; 2 学生;0 全部-->
|
||||||
<% if User.current.member_of?(@project) %>
|
<% if User.current.member_of_course?(@course) %>
|
||||||
<%= link_to "#{teacherCount(@project)}", project_member_path(@project, :role => 1), :course => '1' %>
|
<%= link_to "#{teacherCount(@course)}", course_member_path(@course, :role => 1), :course => '1' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<span><%= teacherCount(@project)%></span> <!--<%= link_to "#{teacherCount(@project)}", "javascript:void(0)", :course => '1' %>-->
|
<span><%= teacherCount(@course)%></span> <!--<%= link_to "#{teacherCount(@course)}", "javascript:void(0)", :course => '1' %>-->
|
||||||
<% end%>
|
<% end%>
|
||||||
</td>
|
</td>
|
||||||
<td class="font_index">
|
<td class="font_index">
|
||||||
<% if User.current.member_of?(@project) %>
|
<% if User.current.member_of_course?(@course) %>
|
||||||
<%= link_to "#{studentCount(@project)}", project_member_path(@project, :role => 2), :course => '1' %>
|
<%= link_to "#{studentCount(@course)}", course_member_path(@course, :role => 2), :course => '1' %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<span><%= studentCount(@project)%></span>
|
<span><%= studentCount(@course)%></span>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td class="font_index"><%= link_to files_count, project_files_path(@project) %></td>
|
<td class="font_index"><%= link_to files_count, course_files_path(@course) %></td>
|
||||||
<tr class="font_aram">
|
<tr class="font_aram">
|
||||||
<td align="center" width="80px" id="teacherCount">
|
<td align="center" width="80px" id="teacherCount">
|
||||||
<!-- %= l(:label_x_base_courses_member, :count => @project.members.count) % -->
|
<!-- %= l(:label_x_base_courses_member, :count => @course.members.count) % -->
|
||||||
<%= l(:label_x_base_courses_teacher, :count => teacherCount(@project)) %>
|
<%= l(:label_x_base_courses_teacher, :count => teacherCount(@course)) %>
|
||||||
</td>
|
</td>
|
||||||
<td align="center" width="80px" id="studentCount">
|
<td align="center" width="80px" id="studentCount">
|
||||||
<%= l(:label_x_base_courses_student, :count => studentCount(@project)) %>
|
<%= l(:label_x_base_courses_student, :count => studentCount(@course)) %>
|
||||||
<!-- %= l(:label_x_course_data, :count => files_count) % -->
|
<!-- %= l(:label_x_course_data, :count => files_count) % -->
|
||||||
</td>
|
</td>
|
||||||
<td align="center" width="80px">
|
<td align="center" width="80px">
|
||||||
|
@ -198,22 +184,22 @@
|
||||||
<!--description-->
|
<!--description-->
|
||||||
<div class="inf_user_context">
|
<div class="inf_user_context">
|
||||||
<div class="font_title_left">
|
<div class="font_title_left">
|
||||||
<%= l(:label_project_overview) %>
|
<%= l(:label_course_overview) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style="padding-bottom: 8px">
|
<div style="padding-bottom: 8px">
|
||||||
<% if @project.description.size>0 %>
|
<% if @course.description && @course.description.size>0 %>
|
||||||
<div class="font_lighter_sidebar">
|
<div class="font_lighter_sidebar">
|
||||||
|
|
||||||
<%= textilizable @project.description %>
|
<%= textilizable @course.description %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="font_lighter_sidebar">
|
<div class="font_lighter_sidebar">
|
||||||
<%= l(:label_course_description_no) %>
|
<%= l(:label_course_description_no) %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="created_on_project">
|
<div class="created_on_course">
|
||||||
<strong style="color: #068d9c"><%= l(:label_create_time) %>:</strong><%= format_time(@project.created_on) %>
|
<strong style="color: #068d9c"><%= l(:label_create_time) %>:</strong><%= format_time(@course.created_at) %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="user_underline"></div>
|
<div class="user_underline"></div>
|
||||||
|
@ -224,7 +210,7 @@
|
||||||
<!-- added by william -for tag -->
|
<!-- added by william -for tag -->
|
||||||
<div class="user_tags">
|
<div class="user_tags">
|
||||||
<div id="tags">
|
<div id="tags">
|
||||||
<%= render :partial => 'tags/tag', :locals => {:obj => @project, :object_flag => "2"} %>
|
<%= render :partial => 'tags/tag', :locals => {:obj => @course, :object_flag => "9"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -236,25 +222,25 @@
|
||||||
<div class="tabs_new">
|
<div class="tabs_new">
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to l(:label_course_overview), project_path(@project), :class => link_class(:overviews) %>
|
<%= link_to l(:label_course_overview), course_path(@course), :class => link_class(:overview) %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to l(:label_homework), homework_project_path(@project), :class => link_class(:homework), :project_type => 1 %>
|
<%= link_to l(:label_homework), homework_course_path(@course), :class => link_class(:homework), :course_type => 1 %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to l(:label_course_file), project_files_path(@project), :class => link_class(:files) %>
|
<%= link_to l(:label_course_file), course_files_path(@course), :class => link_class(:files) %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :project_id => @project}, :class => link_class(:news) %>
|
<%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :course_id => @course}, :class => link_class(:news) %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to l(:label_course_board), {:controller => 'boards', :action => 'index', :project_id => @project}, :class => link_class(:boards) %>
|
<%= link_to l(:label_course_board), {:controller => 'boards', :action => 'index', :course_id => @course}, :class => link_class(:boards) %>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to l(:label_course_feedback), project_feedback_path(@project), :class => link_class(:feedback) %>
|
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => link_class(:feedback) %>
|
||||||
</li>
|
</li>
|
||||||
<!-- <li><%= link_to(l(:label_course_repository), {:controller => 'repositories', :action => 'show', :id => @project, :repository_id => nil, :path => nil, :rev => nil, :course => 1}) %></li> -->
|
<!-- <li><%= link_to(l(:label_course_repository), {:controller => 'repositories', :action => 'show', :id => @course, :repository_id => nil, :path => nil, :rev => nil, :course => 1}) %></li> -->
|
||||||
<% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 7, 9)).size >0)) %>
|
<% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @course.id).first.roles&Role.where('id = ? or id = ?', 7, 9)).size >0)) %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -18,100 +18,104 @@
|
||||||
<%= yield :header_tags -%>
|
<%= yield :header_tags -%>
|
||||||
</head>
|
</head>
|
||||||
<body class="<%= h body_css_classes %>">
|
<body class="<%= h body_css_classes %>">
|
||||||
<% project = @bid.courses.includes(:course_extra).first %>
|
<% course = @bid.courses.first %>
|
||||||
<% course = project.course_extra %>
|
<% if course %>
|
||||||
<div id="wrapper">
|
<div id="wrapper">
|
||||||
<div id="wrapper2">
|
<div id="wrapper2">
|
||||||
<div id="wrapper3">
|
<div id="wrapper3">
|
||||||
<%= render :partial => 'layouts/base_header'%>
|
<%= render :partial => 'layouts/base_header' %>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<!--added by huang-->
|
<!--added by huang-->
|
||||||
<div class="top-content">
|
<div class="top-content">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
<td class="info_font" style="width: 240px; color: #15bccf">高校课程实践社区</td>
|
||||||
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
<td style="width: auto; color: #15bccf"><strong><%= l(:label_user_location) %> : </strong></td>
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left: 8px"><a><%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%></a></td>
|
<td style="padding-left: 8px">
|
||||||
<td><p class="top-content-list-homework"><%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> >
|
<a><%= link_to request.host()+"/courses", :controller => 'courses', :action => 'index' %></a></td>
|
||||||
<span><%= link_to(@bid.courses.first.name.to_s, homework_project_path(@bid.courses.first)) if @bid.courses.first%></span> >
|
<td><p class="top-content-list-homework"><%= link_to "主页", home_path %>
|
||||||
<%=link_to(@bid.name, respond_path(@bid)) %></p></td>
|
> <%= link_to l(:label_course_practice), :controller => 'courses', :action => 'index' %> >
|
||||||
</tr>
|
<span><%= link_to(@bid.courses.first.name.to_s, homework_course_path(@bid.courses.first)) if @bid.courses.first %></span>
|
||||||
</table>
|
>
|
||||||
</div>
|
<%= link_to(@bid.name, respond_path(@bid)) %></p></td>
|
||||||
<!--end-->
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<!--end-->
|
||||||
|
|
||||||
<div id="sidebar">
|
<div id="sidebar">
|
||||||
<div class="main_context">
|
<div class="main_context">
|
||||||
<div class="spaceleft">
|
<div class="spaceleft">
|
||||||
<div>
|
<div>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-left:8px ">
|
<td style="padding-left:8px ">
|
||||||
<% if get_avatar?(project) %>
|
<% if get_avatar?(course) %>
|
||||||
<%= image_tag(url_to_avatar(project),:style => "width:80px;height:80px" ) %>
|
<%= image_tag(url_to_avatar(course), :style => "width:80px;height:80px") %>
|
||||||
<% else %>
|
<% else %>
|
||||||
<%= image_tag('../images/avatars/Project/course.jpg', :style => "width:80px;height:80px") %>
|
<%= image_tag('../images/avatars/course/course.jpg', :style => "width:80px;height:80px") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="vertical-align: top;font-size: 16px;text-align: center;" >
|
<td style="vertical-align: top;font-size: 16px;text-align: center;">
|
||||||
<span style=" word-wrap: break-word; word-break: break-all">
|
<span style=" word-wrap: break-word; word-break: break-all">
|
||||||
<strong>
|
<strong>
|
||||||
<%= link_to @bid.courses.first.name.to_s, homework_project_path(@bid.courses.first) if @bid.courses.first %>
|
<%= link_to @bid.courses.first.name.to_s, homework_course_path(@bid.courses.first) if @bid.courses.first %>
|
||||||
</strong>
|
</strong>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style=" word-wrap: break-word; word-break: break-all;font-size: 16px;text-align: center">
|
<td style=" word-wrap: break-word; word-break: break-all;font-size: 16px;text-align: center">
|
||||||
<span style=" color:#ed8924">
|
<span style=" color:#ed8924">
|
||||||
<!-- modified by zjc 添加超链接 -->
|
<!-- modified by zjc 添加超链接 -->
|
||||||
<strong><%=link_to(@bid.name, respond_path(@bid)) %></strong>
|
<strong><%=link_to(@bid.name, respond_path(@bid)) %></strong>
|
||||||
</span>
|
</span>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="user_underline"></div>
|
<div class="user_underline"></div>
|
||||||
<!--count-->
|
<!--count-->
|
||||||
|
|
||||||
<div class="inf_user_image">
|
<div class="inf_user_image">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" colspan="2" style="font-size: 16px;padding-left: 8px;"><strong><%= l(:label_new_course_description) %> :</strong></td>
|
<td valign="top" colspan="2" style="font-size: 16px;padding-left: 8px;">
|
||||||
</tr>
|
<strong><%= l(:label_new_course_description) %> :</strong></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="font_lighter_sidebar" colspan="2" style="padding-left: 8px;"><%= textilizable project.description %></td>
|
<td class="font_lighter_sidebar" colspan="2" style="padding-left: 8px;"><%= textilizable course.description %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" style="padding-left: 8px;"><%= l(:label_create_time) %> :</td>
|
<td valign="top" style="padding-left: 8px;"><%= l(:label_create_time) %> :</td>
|
||||||
<td class="font_lighter_sidebar"><%= format_time course.created_at %></td>
|
<td class="font_lighter_sidebar"><%= format_time course.created_at %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" style="padding-left: 8px; width:60px">主讲老师 :</td>
|
<td valign="top" style="padding-left: 8px; width:60px">主讲老师 :</td>
|
||||||
<td class="font_lighter_sidebar"><%= link_to(@user.lastname+@user.firstname, user_path(@user)) %></td>
|
<td class="font_lighter_sidebar"><%= link_to(@user.lastname+@user.firstname, user_path(@user)) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" style="padding-left: 8px;"><%= l(:label_class_period) %> :</td>
|
<td valign="top" style="padding-left: 8px;"><%= l(:label_class_period) %> :</td>
|
||||||
<td class="font_lighter_sidebar"><%= course.class_period.to_s %> <%= l(:label_class_hour) %></td>
|
<td class="font_lighter_sidebar"><%= course.class_period.to_s %> <%= l(:label_class_hour) %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" style="padding-left: 8px;"><%= l(:label_main_term) %> :</td>
|
<td valign="top" style="padding-left: 8px;"><%= l(:label_main_term) %> :</td>
|
||||||
<td class="font_lighter_sidebar"><%= course.time.to_s %> <%= course.term %></td>
|
<td class="font_lighter_sidebar"><%= course.time.to_s %> <%= course.term %></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td>
|
<td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td>
|
||||||
|
@ -124,112 +128,120 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="user_underline"></div>
|
<div class="user_underline"></div>
|
||||||
|
|
||||||
<!-- info -->
|
<!-- info -->
|
||||||
<div class="inf_user_image">
|
<div class="inf_user_image">
|
||||||
<table>
|
<table>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= l(:label_limit_time) %>: <%= @bid.deadline %></td>
|
<td><%= l(:label_limit_time) %>: <%= @bid.deadline %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>作业类型: <%=@bid.homework_type==Bid::HomeworkFile ? "提交文件" : "提交项目"%></td>
|
<td>作业类型: <%= @bid.homework_type==Bid::HomeworkFile ? "提交文件" : "提交项目" %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% unless @bid.parent_id.nil?%>
|
<% unless @bid.parent_id.nil? %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<div style=" color: rgb(255, 0, 0); width:200px">
|
<div style=" color: rgb(255, 0, 0); width:200px">
|
||||||
<% author=Bid.find(@bid.parent_id).author%>
|
<% author=Bid.find(@bid.parent_id).author %>
|
||||||
作业来源于<%= link_to(author.lastname+author.firstname, user_path(Bid.find(@bid.parent_id).author))%>的需求:<%= link_to(Bid.find(@bid.parent_id).name, respond_path(Bid.find(@bid.parent_id))) %>
|
作业来源于<%= link_to(author.lastname+author.firstname, user_path(Bid.find(@bid.parent_id).author)) %>
|
||||||
</div></td>
|
的需求:<%= link_to(Bid.find(@bid.parent_id).name, respond_path(Bid.find(@bid.parent_id))) %>
|
||||||
</tr>
|
</div>
|
||||||
<% end %>
|
</td>
|
||||||
</table>
|
</tr>
|
||||||
</div>
|
<% end %>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- tags -->
|
<!-- tags -->
|
||||||
<div class="user_fans">
|
<div class="user_fans">
|
||||||
<div class="user_underline"></div>
|
<div class="user_underline"></div>
|
||||||
<table style="font-family:'微软雅黑'; padding-left: 8px">
|
<table style="font-family:'微软雅黑'; padding-left: 8px">
|
||||||
<tr>
|
<tr>
|
||||||
<td><!-- added by william -for tag --> <%= render :partial => 'tags/tag', :locals => {:obj => @bid, :object_flag => "4"}%> </td>
|
<td><!-- added by william -for tag --> <%= render :partial => 'tags/tag', :locals => {:obj => @bid, :object_flag => "4"} %> </td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!--homework-->
|
<!--homework-->
|
||||||
<div class="user_fans">
|
<div class="user_fans">
|
||||||
|
|
||||||
<div class="user_underline"></div>
|
<div class="user_underline"></div>
|
||||||
<div class="font_title_left">
|
<div class="font_title_left">
|
||||||
<strong><%= l(:label_commit_homework) %></strong>
|
<strong><%= l(:label_commit_homework) %></strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="left_wf">
|
<div class="left_wf">
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding-top: 5px"> <% if @bid.homework_type == 1%>
|
<td style="padding-top: 5px">
|
||||||
<% if @bid.homeworks.size>0 %>
|
<% if @bid.homework_type == 1 %>
|
||||||
<% for homework in @bid.homeworks.eager_load(:user) %>
|
<% if @bid.homeworks.size>0 %>
|
||||||
<%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar", :title => homework.user.name), user_path(homework.user), :class => "avatar" %> <% end %>
|
<% for homework in @bid.homeworks.eager_load(:user) %>
|
||||||
<% else %>
|
<%= link_to image_tag(url_to_avatar(homework.user), :class => "avatar", :title => homework.user.name), user_path(homework.user), :class => "avatar" %>
|
||||||
<p class="font_lighter">
|
<% end %>
|
||||||
<%= l(:label_no_course_project) %>
|
<% else %>
|
||||||
</p> <% end %>
|
<p class="font_lighter">
|
||||||
<% else %>
|
<%= l(:label_no_course_project) %>
|
||||||
<% if @bid.projects.size>0 %>
|
</p>
|
||||||
<% for project in @bid.projects%>
|
|
||||||
<%= link_to image_tag(url_to_avatar(project), :class => "avatar", :title => project.name), project_path(project), :class => "avatar" %> <% end %>
|
|
||||||
<% else %>
|
|
||||||
<p class="font_lighter">
|
|
||||||
<%= l(:label_no_course_project) %>
|
|
||||||
</p> <% end %>
|
|
||||||
<% end %> </td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="user_underline"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- end -->
|
|
||||||
</div>
|
|
||||||
<div id="content">
|
|
||||||
|
|
||||||
<div class="tabs_new">
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show' },:class => link_class(:respond)%>
|
|
||||||
</li>
|
|
||||||
<% if User.current.member_of? @bid.courses.first%>
|
|
||||||
<li>
|
|
||||||
<% if User.current.logged? && @bid.courses.first && (!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) %>
|
|
||||||
<%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%>
|
|
||||||
<% else %>
|
|
||||||
<%= link_to l(:label_homework_info), {:controller => 'bids', :action => 'show_project' },:class => link_class(:project)%>
|
|
||||||
|
|
||||||
<% end %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<!-- <li><%= link_to l(:label_homework_statistics), { :controller => 'bids', :action => 'homework_statistics' },:class => link_class(:homework_statistics)%></li> -->
|
<% else %>
|
||||||
<!-- <li><%= link_to l(:label_homework_respond), { :controller => 'bids', :action => 'homework_respond' },:class => link_class(:homework_respond)%></li>
|
<% if @bid.courses.size>0 %>
|
||||||
|
<% for course in @bid.courses %>
|
||||||
|
<%= link_to image_tag(url_to_avatar(course), :class => "avatar", :title => course.name), course_path(course), :class => "avatar" %>
|
||||||
|
<% end %>
|
||||||
|
<% else %>
|
||||||
|
<p class="font_lighter">
|
||||||
|
<%= l(:label_no_course_project) %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% end %> </td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="user_underline"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- end -->
|
||||||
|
</div>
|
||||||
|
<div id="content">
|
||||||
|
|
||||||
|
<div class="tabs_new">
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<%= link_to l(:label_question_student), {:controller => 'bids', :action => 'show'}, :class => link_class(:respond) %>
|
||||||
|
</li>
|
||||||
|
<% if User.current.member_of? @bid.courses.first %>
|
||||||
|
<li>
|
||||||
|
<% if User.current.logged? && @bid.courses.first && (!Member.where('user_id = ? and course_id = ?', User.current.id, @bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, @bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?', 5, 10, 7)).size >0) %>
|
||||||
|
<%= link_to l(:label_homework_commit), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %>
|
||||||
|
<% else %>
|
||||||
|
<%= link_to l(:label_homework_info), {:controller => 'bids', :action => 'show_course'}, :class => link_class(:course) %>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
</li>
|
||||||
|
<% end %>
|
||||||
|
<!-- <li><%= link_to l(:label_homework_statistics), {:controller => 'bids', :action => 'homework_statistics'}, :class => link_class(:homework_statistics) %></li> -->
|
||||||
|
<!-- <li><%= link_to l(:label_homework_respond), {:controller => 'bids', :action => 'homework_respond'}, :class => link_class(:homework_respond) %></li>
|
||||||
--></ul>
|
--></ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= yield %>
|
<%= yield %>
|
||||||
<%= call_hook :view_layouts_base_content %>
|
<%= call_hook :view_layouts_base_content %>
|
||||||
<div style="clear:both;"></div>
|
<div style="clear:both;"></div>
|
||||||
</div>
|
</div>
|
||||||
<%= render :partial => 'layouts/base_footer'%>
|
<%= render :partial => 'layouts/base_footer' %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="ajax-indicator" style="display:none;">
|
<div id="ajax-indicator" style="display:none;">
|
||||||
<span><%= l(:label_loading) %></span>
|
<span><%= l(:label_loading) %></span>
|
||||||
</div>
|
</div>
|
||||||
<div id="ajax-modal" style="display:none;"></div>
|
<div id="ajax-modal" style="display:none;"></div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<%= call_hook :view_layouts_base_body_bottom %>
|
<%= call_hook :view_layouts_base_body_bottom %>
|
||||||
|
<% end %>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1 +1,5 @@
|
||||||
|
<% if @project%>
|
||||||
$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_members(@project)) %>');
|
$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_members(@project)) %>');
|
||||||
|
<% elsif @course%>
|
||||||
|
$('#principals_for_new_member').html('<%= escape_javascript(render_principals_for_new_course_members(@course)) %>');
|
||||||
|
<%end%>
|
||||||
|
|
|
@ -1,4 +1,9 @@
|
||||||
|
<%if @project%>
|
||||||
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>');
|
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>');
|
||||||
|
<%elsif @course%>
|
||||||
|
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'courses/settings/members') %>');
|
||||||
|
<%end%>
|
||||||
|
|
||||||
hideOnLoad();
|
hideOnLoad();
|
||||||
|
|
||||||
<%if !@applied_members%>
|
<%if !@applied_members%>
|
||||||
|
|
|
@ -1,2 +1,6 @@
|
||||||
|
<%if @project%>
|
||||||
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>');
|
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>');
|
||||||
|
<%elsif @course%>
|
||||||
|
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'courses/settings/members') %>');
|
||||||
|
<%end%>
|
||||||
hideOnLoad();
|
hideOnLoad();
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
<%if @project%>
|
||||||
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>');
|
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'projects/settings/members') %>');
|
||||||
|
<%elsif @course%>
|
||||||
|
$('#tab-content-members').html('<%= escape_javascript(render :partial => 'courses/settings/members') %>');
|
||||||
|
<%end%>
|
||||||
hideOnLoad();
|
hideOnLoad();
|
||||||
$("#member-<%= @member.id %>").effect("highlight");
|
$("#member-<%= @member.id %>").effect("highlight");
|
||||||
|
|
|
@ -0,0 +1,200 @@
|
||||||
|
<style type="text/css">
|
||||||
|
/** {
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
-box-sizing: border-box;
|
||||||
|
}*/
|
||||||
|
.lz {
|
||||||
|
position: relative;
|
||||||
|
min-height: 200px;
|
||||||
|
margin: 10px 2px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 1px 1px 6px #97EBF4;
|
||||||
|
}
|
||||||
|
.lz-left {
|
||||||
|
float: left;
|
||||||
|
margin: 2%;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.memo-section {
|
||||||
|
width: auto;
|
||||||
|
margin-left: 15%;
|
||||||
|
padding-top: 1%;
|
||||||
|
border-left: 2px dotted #EEE;/*#8BE9F3;*/
|
||||||
|
}
|
||||||
|
.memo-title {
|
||||||
|
margin: 1em 0;
|
||||||
|
padding-left: 1%;
|
||||||
|
padding-bottom: 1%;
|
||||||
|
font-weight: bold;
|
||||||
|
border-bottom: 1px dashed rgb(204, 204, 204);
|
||||||
|
}
|
||||||
|
.memo-content {
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
margin-bottom: 40px;
|
||||||
|
background-color: #F6F6F6;
|
||||||
|
white-space: normal;
|
||||||
|
/*word-break: break-all; */
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
.memo-timestamp {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
/*right: 0;*/
|
||||||
|
left: 0;
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
.replies {
|
||||||
|
float: right;
|
||||||
|
/*max-width: 90%;*/
|
||||||
|
}
|
||||||
|
.reply-box {
|
||||||
|
float: right;
|
||||||
|
width: 640px;
|
||||||
|
padding: 3%;
|
||||||
|
/*border: 2px solid #C6F3F9;*/
|
||||||
|
border-top: 2px double #C6F3F9;
|
||||||
|
/*border-radius: 10px;*/
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="lz">
|
||||||
|
<!-- 在这里添加赞和踩-->
|
||||||
|
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> </span>
|
||||||
|
<div class="contextual">
|
||||||
|
<%= watcher_link(@topic, User.current) %>
|
||||||
|
<%= link_to(
|
||||||
|
l(:button_quote),
|
||||||
|
{:action => 'quote', :id => @topic},
|
||||||
|
:remote => true,
|
||||||
|
:method => 'get',
|
||||||
|
:class => 'icon icon-comment',
|
||||||
|
:remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||||
|
<%= link_to(
|
||||||
|
l(:button_edit),
|
||||||
|
{:action => 'edit', :id => @topic},
|
||||||
|
:class => 'icon icon-edit'
|
||||||
|
) if @message.editable_by?(User.current) %>
|
||||||
|
<%= link_to(
|
||||||
|
l(:button_delete),
|
||||||
|
{:action => 'destroy', :id => @topic},
|
||||||
|
:method => :post,
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)},
|
||||||
|
:class => 'icon icon-del'
|
||||||
|
) if @message.destroyable_by?(User.current) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="lz-left">
|
||||||
|
<div class="">
|
||||||
|
<%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %>
|
||||||
|
</div>
|
||||||
|
<p class="">
|
||||||
|
<%= link_to @topic.author, user_path(@topic.author) %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="memo-section">
|
||||||
|
<div class="memo-title <%= @topic.sticky? ? 'sticky' : '' %> <%= @topic.locked? ? 'locked' : '' %>">
|
||||||
|
<% if @project %>
|
||||||
|
<%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project) %>
|
||||||
|
<% elsif @course %>
|
||||||
|
<%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, course_boards_path(@topic.course) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="memo-content">
|
||||||
|
<%= textilizable(@topic, :content) %>
|
||||||
|
<%= link_to_attachments @topic, :author => false %>
|
||||||
|
</div>
|
||||||
|
<div class="memo-timestamp">
|
||||||
|
<div style="float: left"><%= authoring @topic.created_on, @topic.author %></div>
|
||||||
|
|
||||||
|
|
||||||
|
<div style="float: right"><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% unless @replies.empty? %>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @reply_count %>)</h3>
|
||||||
|
<% reply_count = 0 %>
|
||||||
|
<% @replies.each do |message| %>
|
||||||
|
<div class="message reply" id="<%= "message-#{message.id}" %>">
|
||||||
|
|
||||||
|
<table class="borad-text-list">
|
||||||
|
<tr>
|
||||||
|
<!--<td class="font_lighter"> </td> -->
|
||||||
|
<td rowspan="3" valign="top" width="60px"><%= link_to image_tag(url_to_avatar(message.author), :class => "avatar"), user_path(message.author) %></td>
|
||||||
|
<td>
|
||||||
|
<div class="contextual-borad">
|
||||||
|
<%= link_to(
|
||||||
|
"引用",
|
||||||
|
{:action => 'quote', :id => message},
|
||||||
|
:remote => true,
|
||||||
|
:method => 'get',
|
||||||
|
:title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||||
|
<%= link_to(
|
||||||
|
#image_tag('edit.png'),
|
||||||
|
"编辑",
|
||||||
|
{:action => 'edit', :id => message},
|
||||||
|
:title => l(:button_edit)
|
||||||
|
) if message.editable_by?(User.current) %>
|
||||||
|
<%= link_to(
|
||||||
|
#image_tag('delete.png'),
|
||||||
|
"删除",
|
||||||
|
{:action => 'destroy', :id => message},
|
||||||
|
:method => :post,
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)},
|
||||||
|
:title => l(:button_delete)
|
||||||
|
) if message.destroyable_by?(User.current) %>
|
||||||
|
</div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="comments">
|
||||||
|
<div class="wiki">
|
||||||
|
<%= textilizable message, :content, :attachments => message.attachments %>
|
||||||
|
</div>
|
||||||
|
<%= link_to_attachments message, :author => false %> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="font_lighter" style="float: left"><%= authoring message.created_on, message.author %></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<div class="pagination">
|
||||||
|
<%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<% if !@topic.locked? && authorize_for_course('messages', 'reply') %>
|
||||||
|
<div id="reply" style="display:none;">
|
||||||
|
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||||
|
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
|
||||||
|
<%= submit_tag l(:button_submit) %>
|
||||||
|
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
|
||||||
|
<% end %>
|
||||||
|
<div id="preview" class="wiki"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title @topic.subject %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
jQuery(document).ready(function($) {
|
||||||
|
transpotUrl('#content');
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -19,7 +19,12 @@
|
||||||
|
|
||||||
<% if !replying && !@message.new_record? && @message.safe_attribute?('board_id') %>
|
<% if !replying && !@message.new_record? && @message.safe_attribute?('board_id') %>
|
||||||
<p><label><%= l(:label_board) %></label><br />
|
<p><label><%= l(:label_board) %></label><br />
|
||||||
<%= f.select :board_id, boards_options_for_select(@message.project.boards) %></p>
|
<%# modify by nwb%>
|
||||||
|
<% if @message.project %>
|
||||||
|
<%= f.select :board_id, boards_options_for_select(@message.project.boards) %></p>
|
||||||
|
<% elsif @message.course %>
|
||||||
|
<%= f.select :board_id, boards_options_for_select(@message.course.boards) %></p>
|
||||||
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -0,0 +1,200 @@
|
||||||
|
<style type="text/css">
|
||||||
|
/** {
|
||||||
|
-webkit-box-sizing: border-box;
|
||||||
|
-moz-box-sizing: border-box;
|
||||||
|
-box-sizing: border-box;
|
||||||
|
}*/
|
||||||
|
.lz {
|
||||||
|
position: relative;
|
||||||
|
min-height: 200px;
|
||||||
|
margin: 10px 2px;
|
||||||
|
border-radius: 5px;
|
||||||
|
box-shadow: 1px 1px 6px #97EBF4;
|
||||||
|
}
|
||||||
|
.lz-left {
|
||||||
|
float: left;
|
||||||
|
margin: 2%;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
.memo-section {
|
||||||
|
width: auto;
|
||||||
|
margin-left: 15%;
|
||||||
|
padding-top: 1%;
|
||||||
|
border-left: 2px dotted #EEE;/*#8BE9F3;*/
|
||||||
|
}
|
||||||
|
.memo-title {
|
||||||
|
margin: 1em 0;
|
||||||
|
padding-left: 1%;
|
||||||
|
padding-bottom: 1%;
|
||||||
|
font-weight: bold;
|
||||||
|
border-bottom: 1px dashed rgb(204, 204, 204);
|
||||||
|
}
|
||||||
|
.memo-content {
|
||||||
|
padding: 1%;
|
||||||
|
margin: 1%;
|
||||||
|
margin-bottom: 40px;
|
||||||
|
background-color: #F6F6F6;
|
||||||
|
white-space: normal;
|
||||||
|
/*word-break: break-all; */
|
||||||
|
word-wrap: break-word;
|
||||||
|
}
|
||||||
|
.memo-timestamp {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
/*right: 0;*/
|
||||||
|
left: 0;
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
.replies {
|
||||||
|
float: right;
|
||||||
|
/*max-width: 90%;*/
|
||||||
|
}
|
||||||
|
.reply-box {
|
||||||
|
float: right;
|
||||||
|
width: 640px;
|
||||||
|
padding: 3%;
|
||||||
|
/*border: 2px solid #C6F3F9;*/
|
||||||
|
border-top: 2px double #C6F3F9;
|
||||||
|
/*border-radius: 10px;*/
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<div class="lz">
|
||||||
|
<!-- 在这里添加赞和踩-->
|
||||||
|
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> </span>
|
||||||
|
<div class="contextual">
|
||||||
|
<%= watcher_link(@topic, User.current) %>
|
||||||
|
<%= link_to(
|
||||||
|
l(:button_quote),
|
||||||
|
{:action => 'quote', :id => @topic},
|
||||||
|
:remote => true,
|
||||||
|
:method => 'get',
|
||||||
|
:class => 'icon icon-comment',
|
||||||
|
:remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||||
|
<%= link_to(
|
||||||
|
l(:button_edit),
|
||||||
|
{:action => 'edit', :id => @topic},
|
||||||
|
:class => 'icon icon-edit'
|
||||||
|
) if @message.editable_by?(User.current) %>
|
||||||
|
<%= link_to(
|
||||||
|
l(:button_delete),
|
||||||
|
{:action => 'destroy', :id => @topic},
|
||||||
|
:method => :post,
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)},
|
||||||
|
:class => 'icon icon-del'
|
||||||
|
) if @message.destroyable_by?(User.current) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="lz-left">
|
||||||
|
<div class="">
|
||||||
|
<%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %>
|
||||||
|
</div>
|
||||||
|
<p class="">
|
||||||
|
<%= link_to @topic.author, user_path(@topic.author) %>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="memo-section">
|
||||||
|
<div class="memo-title <%= @topic.sticky? ? 'sticky' : '' %> <%= @topic.locked? ? 'locked' : '' %>">
|
||||||
|
<% if @project %>
|
||||||
|
<%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project) %>
|
||||||
|
<% elsif @course %>
|
||||||
|
<%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, course_boards_path(@topic.course) %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<div class="memo-content">
|
||||||
|
<%= textilizable(@topic, :content) %>
|
||||||
|
<%= link_to_attachments @topic, :author => false %>
|
||||||
|
</div>
|
||||||
|
<div class="memo-timestamp">
|
||||||
|
<div style="float: left"><%= authoring @topic.created_on, @topic.author %></div>
|
||||||
|
|
||||||
|
|
||||||
|
<div style="float: right"><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% unless @replies.empty? %>
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @reply_count %>)</h3>
|
||||||
|
<% reply_count = 0 %>
|
||||||
|
<% @replies.each do |message| %>
|
||||||
|
<div class="message reply" id="<%= "message-#{message.id}" %>">
|
||||||
|
|
||||||
|
<table class="borad-text-list">
|
||||||
|
<tr>
|
||||||
|
<!--<td class="font_lighter"> </td> -->
|
||||||
|
<td rowspan="3" valign="top" width="60px"><%= link_to image_tag(url_to_avatar(message.author), :class => "avatar"), user_path(message.author) %></td>
|
||||||
|
<td>
|
||||||
|
<div class="contextual-borad">
|
||||||
|
<%= link_to(
|
||||||
|
"引用",
|
||||||
|
{:action => 'quote', :id => message},
|
||||||
|
:remote => true,
|
||||||
|
:method => 'get',
|
||||||
|
:title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||||
|
<%= link_to(
|
||||||
|
#image_tag('edit.png'),
|
||||||
|
"编辑",
|
||||||
|
{:action => 'edit', :id => message},
|
||||||
|
:title => l(:button_edit)
|
||||||
|
) if message.editable_by?(User.current) %>
|
||||||
|
<%= link_to(
|
||||||
|
#image_tag('delete.png'),
|
||||||
|
"删除",
|
||||||
|
{:action => 'destroy', :id => message},
|
||||||
|
:method => :post,
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)},
|
||||||
|
:title => l(:button_delete)
|
||||||
|
) if message.destroyable_by?(User.current) %>
|
||||||
|
</div></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
|
||||||
|
<td class="comments">
|
||||||
|
<div class="wiki">
|
||||||
|
<%= textilizable message, :content, :attachments => message.attachments %>
|
||||||
|
</div>
|
||||||
|
<%= link_to_attachments message, :author => false %> </td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td class="font_lighter" style="float: left"><%= authoring message.created_on, message.author %></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% end %>
|
||||||
|
<div class="pagination">
|
||||||
|
<%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
|
||||||
|
<div id="reply" style="display:none;">
|
||||||
|
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
||||||
|
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
|
||||||
|
<%= submit_tag l(:button_submit) %>
|
||||||
|
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
|
||||||
|
<% end %>
|
||||||
|
<div id="preview" class="wiki"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title @topic.subject %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
jQuery(document).ready(function($) {
|
||||||
|
transpotUrl('#content');
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1,4 +1,8 @@
|
||||||
<%= board_breadcrumb(@message) %>
|
<% if @message.project %>
|
||||||
|
<%= board_breadcrumb(@message) %>
|
||||||
|
<% elsif @message.course %>
|
||||||
|
<%= course_board_breadcrumb(@message) %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<h3><%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %></h3>
|
<h3><%= avatar(@topic.author, :size => "24") %><%=h @topic.subject %></h3>
|
||||||
|
|
||||||
|
|
|
@ -1,196 +1,5 @@
|
||||||
<style type="text/css">
|
<% if @project %>
|
||||||
/** {
|
<%= render :partial => 'project_show', locals: {project: @project} %>
|
||||||
-webkit-box-sizing: border-box;
|
<% elsif @course %>
|
||||||
-moz-box-sizing: border-box;
|
<%= render :partial => 'course_show', locals: {course: @course} %>
|
||||||
-box-sizing: border-box;
|
|
||||||
}*/
|
|
||||||
.lz {
|
|
||||||
position: relative;
|
|
||||||
min-height: 200px;
|
|
||||||
margin: 10px 2px;
|
|
||||||
border-radius: 5px;
|
|
||||||
box-shadow: 1px 1px 6px #97EBF4;
|
|
||||||
}
|
|
||||||
.lz-left {
|
|
||||||
float: left;
|
|
||||||
margin: 2%;
|
|
||||||
padding: 0;
|
|
||||||
}
|
|
||||||
.memo-section {
|
|
||||||
width: auto;
|
|
||||||
margin-left: 15%;
|
|
||||||
padding-top: 1%;
|
|
||||||
border-left: 2px dotted #EEE;/*#8BE9F3;*/
|
|
||||||
}
|
|
||||||
.memo-title {
|
|
||||||
margin: 1em 0;
|
|
||||||
padding-left: 1%;
|
|
||||||
padding-bottom: 1%;
|
|
||||||
font-weight: bold;
|
|
||||||
border-bottom: 1px dashed rgb(204, 204, 204);
|
|
||||||
}
|
|
||||||
.memo-content {
|
|
||||||
padding: 1%;
|
|
||||||
margin: 1%;
|
|
||||||
margin-bottom: 40px;
|
|
||||||
background-color: #F6F6F6;
|
|
||||||
white-space: normal;
|
|
||||||
/*word-break: break-all; */
|
|
||||||
word-wrap: break-word;
|
|
||||||
}
|
|
||||||
.memo-timestamp {
|
|
||||||
position: absolute;
|
|
||||||
bottom: 0px;
|
|
||||||
/*right: 0;*/
|
|
||||||
left: 0;
|
|
||||||
margin: 20px;
|
|
||||||
}
|
|
||||||
.replies {
|
|
||||||
float: right;
|
|
||||||
/*max-width: 90%;*/
|
|
||||||
}
|
|
||||||
.reply-box {
|
|
||||||
float: right;
|
|
||||||
width: 640px;
|
|
||||||
padding: 3%;
|
|
||||||
/*border: 2px solid #C6F3F9;*/
|
|
||||||
border-top: 2px double #C6F3F9;
|
|
||||||
/*border-radius: 10px;*/
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<div class="lz">
|
|
||||||
<!-- 在这里添加赞和踩-->
|
|
||||||
<span id="praise_tread" style="float: right"> <%= render :partial => "/praise_tread/praise_tread",:locals => {:obj => @topic,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%> </span>
|
|
||||||
<div class="contextual">
|
|
||||||
<%= watcher_link(@topic, User.current) %>
|
|
||||||
<%= link_to(
|
|
||||||
l(:button_quote),
|
|
||||||
{:action => 'quote', :id => @topic},
|
|
||||||
:remote => true,
|
|
||||||
:method => 'get',
|
|
||||||
:class => 'icon icon-comment',
|
|
||||||
:remote => true) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
|
||||||
<%= link_to(
|
|
||||||
l(:button_edit),
|
|
||||||
{:action => 'edit', :id => @topic},
|
|
||||||
:class => 'icon icon-edit'
|
|
||||||
) if @message.editable_by?(User.current) %>
|
|
||||||
<%= link_to(
|
|
||||||
l(:button_delete),
|
|
||||||
{:action => 'destroy', :id => @topic},
|
|
||||||
:method => :post,
|
|
||||||
:data => {:confirm => l(:text_are_you_sure)},
|
|
||||||
:class => 'icon icon-del'
|
|
||||||
) if @message.destroyable_by?(User.current) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="lz-left">
|
|
||||||
<div class="">
|
|
||||||
<%= link_to image_tag(url_to_avatar(@topic.author), :class => "avatar"), user_path(@topic.author) %>
|
|
||||||
</div>
|
|
||||||
<p class="">
|
|
||||||
<%= link_to @topic.author, user_path(@topic.author) %>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="memo-section">
|
|
||||||
<div class="memo-title <%= @topic.sticky? ? 'sticky' : '' %> <%= @topic.locked? ? 'locked' : '' %>">
|
|
||||||
<%= label_tag l(:field_subject) %>: <%= link_to @topic.subject, project_boards_path(@topic.project) %>
|
|
||||||
</div>
|
|
||||||
<div class="memo-content">
|
|
||||||
<%= textilizable(@topic, :content) %>
|
|
||||||
<%= link_to_attachments @topic, :author => false %>
|
|
||||||
</div>
|
|
||||||
<div class="memo-timestamp">
|
|
||||||
<div style="float: left"><%= authoring @topic.created_on, @topic.author %></div>
|
|
||||||
|
|
||||||
|
|
||||||
<div style="float: right"><%= toggle_link l(:button_reply), "reply", :focus => 'message_content' %></div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% unless @replies.empty? %>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<h3 class="comments"><%= l(:label_reply_plural) %> (<%= @reply_count %>)</h3>
|
|
||||||
<% reply_count = 0 %>
|
|
||||||
<% @replies.each do |message| %>
|
|
||||||
<div class="message reply" id="<%= "message-#{message.id}" %>">
|
|
||||||
|
|
||||||
<table class="borad-text-list">
|
|
||||||
<tr>
|
|
||||||
<!--<td class="font_lighter"> </td> -->
|
|
||||||
<td rowspan="3" valign="top" width="60px"><%= link_to image_tag(url_to_avatar(message.author), :class => "avatar"), user_path(message.author) %></td>
|
|
||||||
<td>
|
|
||||||
<div class="contextual-borad">
|
|
||||||
<%= link_to(
|
|
||||||
"引用",
|
|
||||||
{:action => 'quote', :id => message},
|
|
||||||
:remote => true,
|
|
||||||
:method => 'get',
|
|
||||||
:title => l(:button_quote)) if !@topic.locked? && authorize_for('messages', 'reply') %>
|
|
||||||
<%= link_to(
|
|
||||||
#image_tag('edit.png'),
|
|
||||||
"编辑",
|
|
||||||
{:action => 'edit', :id => message},
|
|
||||||
:title => l(:button_edit)
|
|
||||||
) if message.editable_by?(User.current) %>
|
|
||||||
<%= link_to(
|
|
||||||
#image_tag('delete.png'),
|
|
||||||
"删除",
|
|
||||||
{:action => 'destroy', :id => message},
|
|
||||||
:method => :post,
|
|
||||||
:data => {:confirm => l(:text_are_you_sure)},
|
|
||||||
:title => l(:button_delete)
|
|
||||||
) if message.destroyable_by?(User.current) %>
|
|
||||||
</div></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
|
|
||||||
<td class="comments">
|
|
||||||
<div class="wiki">
|
|
||||||
<%= textilizable message, :content, :attachments => message.attachments %>
|
|
||||||
</div>
|
|
||||||
<%= link_to_attachments message, :author => false %> </td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td class="font_lighter" style="float: left"><%= authoring message.created_on, message.author %></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="pagination">
|
|
||||||
<%= pagination_links_full @reply_pages, @reply_count, :per_page_links => false %>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
|
|
||||||
<div id="reply" style="display:none;">
|
|
||||||
<%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
|
|
||||||
<%= render :partial => 'form', :locals => {:f => f, :replying => true} %>
|
|
||||||
<%= submit_tag l(:button_submit) %>
|
|
||||||
<%= preview_link({:controller => 'messages', :action => 'preview', :board_id => @board}, 'message-form') %>
|
|
||||||
<% end %>
|
|
||||||
<div id="preview" class="wiki"></div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<% html_title @topic.subject %>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
jQuery(document).ready(function($) {
|
|
||||||
transpotUrl('#content');
|
|
||||||
});
|
|
||||||
</script>
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<%= error_messages_for @news %>
|
||||||
|
<div class="add_frame_header" >
|
||||||
|
<% str = l(:bale_news_notice)%>
|
||||||
|
<%= str %>
|
||||||
|
</div>
|
||||||
|
<div class="box tabular">
|
||||||
|
<p><%= f.text_field :title, :required => true, :size => 60, :style => "width:488px;" %></p>
|
||||||
|
<!-- <p style="margin-left:-10px;"><%= f.text_area :summary, :cols => 60, :rows => 2, :style => "width:490px;margin-left:10px;" %></p> -->
|
||||||
|
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 11, :class => 'wiki-edit', :style => "width:490px;" %></p>
|
||||||
|
<p id="attachments_form" style="margin-left:-10px;"><label style="padding-right: 15px;"><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= wikitoolbar_for 'news_description' %>
|
|
@ -0,0 +1,94 @@
|
||||||
|
<%
|
||||||
|
btn_tips = l(:label_news_notice)
|
||||||
|
label_tips = l(:label_course_news)
|
||||||
|
%>
|
||||||
|
|
||||||
|
<span style="font-size: 16px; border-bottom:1px solid #f0f0f0; margin-right: 15px;">
|
||||||
|
<%= label_tips %>
|
||||||
|
</span>
|
||||||
|
<%= link_to(btn_tips,
|
||||||
|
new_course_news_path(@course),
|
||||||
|
:class => 'icon icon-add',
|
||||||
|
:onclick => 'showAndScrollTo("add-news", "news_title"); return false;') %>
|
||||||
|
|
||||||
|
<% if @course && User.current.allowed_to?(:manage_news, @course) %>
|
||||||
|
<div id="add-news" class="add_frame" style="display:none;">
|
||||||
|
<%= labelled_form_for @news, :url => course_news_index_path(@course),
|
||||||
|
:html => {:id => 'news-form', :multipart => true} do |f| %>
|
||||||
|
<%= render :partial => 'news/course_form', :locals => {:f => f} %>
|
||||||
|
<%= submit_tag l(:button_create), :class => 'whiteButton m3p10 h30', :name => nil %><!-- button-submit --> |
|
||||||
|
<%= preview_link preview_news_path(:course_id => @course), 'news-form', target='preview', {:class => 'whiteButton m3p10'} %>
|
||||||
|
|
|
||||||
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#add-news").hide()', :class => 'whiteButton m3p10' %>
|
||||||
|
<% end if @course %>
|
||||||
|
<div id="preview" class="wiki"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div>
|
||||||
|
<% if @newss.empty? %>
|
||||||
|
<p class="nodata">
|
||||||
|
<%= l(:label_no_data) %>
|
||||||
|
</p>
|
||||||
|
<% else %>
|
||||||
|
<% @newss.each do |news| %>
|
||||||
|
|
||||||
|
<table class="content-text-list">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" valign="top" width="50"><%= link_to image_tag(url_to_avatar(news.author), :class => "avatar"), user_path(news.author) %></td>
|
||||||
|
<td>
|
||||||
|
<table width="580px" border="0">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" valign="top">
|
||||||
|
<strong><%= link_to_user(news.author) if news.respond_to?(:author) %></strong><span style="margin-left: 4px;" class="font_lighter"><%= l(:label_project_notice) %></span><span><%= link_to h(news.title), news_path(news) %></span>
|
||||||
|
<span style="float: right"><%= delete_link news_path(news) if User.current.allowed_to?(:manage_news, @couese) %> </span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" width="580px">
|
||||||
|
<span class="font_description"><%= textilizable(news, :description) %></span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="left"><span class="font_lighter"> <%= l :label_update_time %>
|
||||||
|
: <%= format_time(news.created_on) %></span></td>
|
||||||
|
<td width="350" align="right" class="a"><%= link_to l(:label_project_newother), news_path(news) %><%= "(#{l(:label_x_comments, :count => news.comments_count)})" if news.comments_count >= 0 %></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
</div>
|
||||||
|
<!--end-->
|
||||||
|
<div style="padding-right: 10px">
|
||||||
|
<div class="pagination">
|
||||||
|
<ul>
|
||||||
|
<%= pagination_links_full @news_pages %>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<% other_formats_links do |f| %>
|
||||||
|
<%= f.link_to 'Atom', :url => {:course_id => @course, :key => User.current.rss_key} %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %>
|
||||||
|
<%= stylesheet_link_tag 'scm' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title(l(:label_news_plural)) -%>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type='text/javascript'>
|
||||||
|
$(document).ready(function ($) {
|
||||||
|
$('.content-text-list').each(function () {
|
||||||
|
$(this).find('.delete_icon').hide();
|
||||||
|
$(this).mouseenter(function (event) {
|
||||||
|
$(this).find('.delete_icon').show();
|
||||||
|
});
|
||||||
|
$(this).mouseleave(function (event) {
|
||||||
|
$(this).find('.delete_icon').hide();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -0,0 +1,85 @@
|
||||||
|
<div class="contextual">
|
||||||
|
<%= watcher_link(@news, User.current) %>
|
||||||
|
<%= link_to(l(:button_edit),
|
||||||
|
edit_news_path(@news),
|
||||||
|
:class => 'icon icon-edit',
|
||||||
|
:accesskey => accesskey(:edit),
|
||||||
|
:onclick => '$("#edit-news").show(); return false;') if User.current.allowed_to?(:manage_news, @course) %>
|
||||||
|
<%= delete_link news_path(@news) if User.current.allowed_to?(:manage_news, @course) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h3><strong><%=h @news.title %></strong></h3>
|
||||||
|
|
||||||
|
<% if authorize_for('news', 'edit') %>
|
||||||
|
<div id="edit-news" style="display:none;">
|
||||||
|
<%= labelled_form_for :news, @news, :url => news_path(@news),
|
||||||
|
:html => { :id => 'news-form', :multipart => true, :method => :put } do |f| %>
|
||||||
|
<%= render :partial => 'course_form', :locals => { :f => f } %>
|
||||||
|
<%= submit_tag l(:button_save) %>
|
||||||
|
<%= preview_link preview_news_path(:course_id => @course, :id => @news), 'news-form',target='preview',{:class => ''} %> |
|
||||||
|
<%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;' %>
|
||||||
|
<% end %>
|
||||||
|
<div id="preview" class="wiki"></div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<div id="comments" style="margin-bottom:16px;">
|
||||||
|
|
||||||
|
<div style="margin:15px">
|
||||||
|
<span class="font_description"> <%= textilizable(@news, :description) %> </span>
|
||||||
|
<br/>
|
||||||
|
<%= link_to_attachments @news %>
|
||||||
|
<br/>
|
||||||
|
<!--add comment-->
|
||||||
|
<% if @news.commentable? %>
|
||||||
|
<p>
|
||||||
|
<%= toggle_link l(:label_comment_add), "add_comment_form", :focus => "comment_comments" %>
|
||||||
|
</p>
|
||||||
|
<%= form_tag({:controller => 'comments', :action => 'create', :id => @news}, :id => "add_comment_form", :style => "display:none;") do %>
|
||||||
|
<div class="box">
|
||||||
|
<%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit' %>
|
||||||
|
<%= wikitoolbar_for 'comment_comments' %>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
<%= submit_tag l(:button_add) %>
|
||||||
|
</p>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% html_title @news.title -%>
|
||||||
|
|
||||||
|
<% content_for :header_tags do %>
|
||||||
|
<%= stylesheet_link_tag 'scm' %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<!--dispaly comments-->
|
||||||
|
<div class="line_heng"></div>
|
||||||
|
</div>
|
||||||
|
<h3 class="comments"><%= l(:label_comment_plural) %></h3>
|
||||||
|
<% comments = @comments.reverse %>
|
||||||
|
<% comments.each do |comment| %>
|
||||||
|
<% next if comment.new_record? %>
|
||||||
|
<table width="660px" border="0" align="center">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" valign="top" width="50" ><%= image_tag(url_to_avatar(comment.author), :class => "avatar")%></td>
|
||||||
|
<td>
|
||||||
|
<table width="580px" border="0">
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" valign="top"><strong><%= link_to_user(comment.author) if comment.respond_to?(:author) %> </strong><span class="font_lighter"><%= l(:label_project_newadd) %></span><%= l(:label_comment_plural) %></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" width="580px" >
|
||||||
|
<p class="font_description">
|
||||||
|
<%= textilizable(comment.comments) %>
|
||||||
|
</p></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align="left"><span class="font_lighter"> <%= format_time(comment.created_on) %></span></td>
|
||||||
|
<td width="200" align="right" class="a"><%= link_to_if_authorized image_tag('delete.png'), {:controller => 'comments', :action => 'destroy', :id => @news, :comment_id => comment},
|
||||||
|
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete, :title => l(:button_delete) %></td>
|
||||||
|
</tr>
|
||||||
|
</table></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
<% end if @comments.any? %>
|
||||||
|
</div>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue