diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 1b95ef895..7602b10a5 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -160,7 +160,7 @@ class AdminController < ApplicationController
@sort = ""
if params[:sort] && (params[:order] == 'name')
# courses = School.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) #{params[:sort]}, c.id desc")
- school = School.find_by_sql(" SELECT aas.name FROM apply_add_schools aas where aas.status = '0' GROUP BY CONVERT(name USING gbk) #{params[:sort]}, aas.id desc ")
+ school = School.find_by_sql(" SELECT aas.name FROM apply_add_schools aas where aas.status = '0' ORDER BY CONVERT(aas.name USING gbk) #{params[:sort]}, aas.id asc ")
@order = params[:order]
@sort = params[:sort]
end
diff --git a/app/controllers/applied_project_controller.rb b/app/controllers/applied_project_controller.rb
index b9824976b..d779c7759 100644
--- a/app/controllers/applied_project_controller.rb
+++ b/app/controllers/applied_project_controller.rb
@@ -1,44 +1,70 @@
class AppliedProjectController < ApplicationController
-
+ helper :watchers
#申请加入项目
def applied_join_project
- @user_id = params[:user_id]
- @project = Project.find_by_id(params[:project_id])
- if params[:project_join]
- if @project
- user = User.find @user_id
- if user.member_of?(@project)
- @status = 3
- else
- @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
- if @applieds.count == 0
- appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
- Mailer.run.applied_project(appliedproject)
- @status = 2
- else
- @status = 1
- end
- end
- else
- @status = 0
- end
- respond_to do |format|
- format.js
- end
- return
+ if params[:object_id]
+ @project = Project.find_by_id(params[:object_id])
end
+ # @user_id = params[:user_id]
+ # if params[:project_join]
+ # if @project
+ # user = User.find @user_id
+ # if user.member_of?(@project)
+ # @status = 3
+ # else
+ # @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
+ # if @applieds.count == 0
+ # appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
+ # Mailer.run.applied_project(appliedproject)
+ # @status = 2
+ # else
+ # @status = 1
+ # end
+ # end
+ # else
+ # @status = 0
+ # end
+ # respond_to do |format|
+ # format.js
+ # end
+ # return
+ # end
+ #
+ # @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
+ # if @applieds.count == 0
+ # appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
+ # Mailer.run.applied_project(appliedproject)
+ # end
+ #
+ # #redirect_to project_path(params[:project_id])
+ # #redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true}
+ # respond_to do |format|
+ # format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
+ # format.js { render :partial => 'set_applied'}
+ # end
+ end
- @applieds = AppliedProject.where("user_id = ? and project_id = ?", params[:user_id],params[:project_id])
- if @applieds.count == 0
- appliedproject = AppliedProject.create(:user_id => params[:user_id], :project_id => params[:project_id])
- Mailer.run.applied_project(appliedproject)
+ # @flage:提示语标志(1:邀请码错误;2:已经是项目成员; 3:角色没有选择; 4:申请成功)
+ # role:成员角色 => 0(4:管理人员;5:开发人员;6:报告人员)
+ # 申请成功则发送消息
+ def applied_project_info
+ if params[:project_id].nil?
+ @project = Project.where(:invite_code => params[:invite_code]).first
+ else
+ @project = Project.find(params[:project_id])
end
-
- #redirect_to project_path(params[:project_id])
- #redirect_to_referer_or {render :text => ( 'applied success.'), :layout => true}
- respond_to do |format|
- format.html { redirect_to_referer_or {render :text => (watching ? 'Watcher added.' : 'Watcher removed.'), :layout => true}}
- format.js { render :partial => 'set_applied'}
+ if !@project || params[:invite_code].to_s != @project.invite_code
+ @flag = 1
+ elsif User.current.member_of?(@project)
+ @flag = 2
+ elsif params[:member].nil?
+ @flag = 3
+ else
+ @flag = 4
+ role = params[:member] == "member_manager" ? 3 : (params[:member] = "member_developer" ? 4 :5)
+ applied_project = AppliedProject.create(:user_id => User.current.id, :project_id => @project.id, :role => role)
+ # 申请成功则给项目管理员发送邮件及发送消息
+ Mailer.run.applied_project(applied_project)
end
end
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index a38cc8d34..2614b6271 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -23,7 +23,7 @@ class CoursesController < ApplicationController
before_filter :can_show_course, :except => []
before_filter :logged_user_by_apptoken,:only => [:show,:feedback]
- before_filter :find_course, :except => [ :index, :search, :new,:join,:unjoin, :create, :new_join, :course,:join_private_courses]
+ before_filter :find_course, :except => [ :index, :search, :new,:join,:unjoin, :create, :new_join, :course,:join_private_courses, :join_course_multi_role]
before_filter :authorize_course, :only => [:show, :settings, :update, :course]
before_filter :authorize_course_global, :only => [:new,:create]
before_filter :toggleCourse, :only => [:finishcourse, :restartcourse]
@@ -81,6 +81,22 @@ class CoursesController < ApplicationController
end
+ def join_course_multi_role
+ if User.current.logged?
+ cs = CoursesService.new
+ @user = User.current
+ join = cs.join_course_roles params,@user
+ @state = join[:state]
+ @course = join[:course]
+ else
+ @state = 5 #未登录
+ end
+ @object_id = @course.id if @course
+ respond_to do |format|
+ format.js
+ end
+ end
+
def unjoin
if User.current.logged?
cs = CoursesService.new
@@ -1136,6 +1152,21 @@ class CoursesController < ApplicationController
end
end
+ #切换身份
+ def switch_role
+ members = @course.members.where("user_id = #{params[:user_id]}")
+ unless members.blank?
+ #role = MemberRole.where("member_id = #{members.first.id} and role_id = #{params[:role]}").first
+ curr_role = MemberRole.find_by_member_id_and_role_id(members.first.id, params[:curr_role])
+ tar_role = MemberRole.find_by_member_id_and_role_id(members.first.id, params[:tar_role])
+ unless (curr_role.nil? || tar_role.nil?)
+ curr_role.update_column('is_current', 0)
+ tar_role.update_column('is_current', 1)
+ end
+ end
+ redirect_to course_path(@course)
+ end
+
private
def update_quotes attachment
if attachment.copy_from
diff --git a/app/controllers/members_controller.rb b/app/controllers/members_controller.rb
index 4dc2c52f5..0a76cfb78 100644
--- a/app/controllers/members_controller.rb
+++ b/app/controllers/members_controller.rb
@@ -17,10 +17,11 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class MembersController < ApplicationController
+ helper :users
model_object Member
- before_filter :find_model_object, :except => [:index, :create, :autocomplete]
+ before_filter :find_model_object, :except => [:index, :create, :autocomplete, :allow_to_join_project, :refused_allow_to_join_project]
#before_filter :find_model_object_contest, :except => [:index, :create, :autocomplete]
- before_filter :find_project_from_association, :except => [:index, :create, :autocomplete]
+ before_filter :find_project_from_association, :except => [:index, :create, :autocomplete, :allow_to_join_project, :refused_allow_to_join_project]
before_filter :find_project_by_project_id, :only => [:index, :create, :autocomplete]
before_filter :authorize
accept_api_auth :index, :show, :create, :update, :destroy
@@ -49,6 +50,62 @@ class MembersController < ApplicationController
end
end
+ # 同意消息中申请加入项目
+ # 之所以role不在参数中传送是考虑到安全问题
+ # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:决绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息)
+ def allow_to_join_project
+ @applied_message = AppliedMessage.find(params[:applied_message_id])
+ applied_project = @applied_message.applied
+ user = User.find(@applied_message.applied_user_id)
+ project = Project.find(applied_project.project_id)
+ if user.member_of?(project)
+ @flash_message = "您已经是项目成员了"
+ @applied_message.update_attribute(:status, 2)
+ else
+ ap_role = applied_project.try(:role)
+ if ap_role
+ begin
+ members = []
+ user_grades = []
+ project_info = []
+ members << Member.new(:role_ids => ["#{ap_role}"], :user_id => @applied_message.applied_user_id)
+ user_grades << UserGrade.new(:user_id => @applied_message.applied_user_id, :project_id => project.id)
+ role = Role.find(ap_role)
+ project_info << ProjectInfo.new(:project_id => project.id, :user_id => @applied_message.applied_user_id) if role.allowed_to?(:is_manager)
+ project.members << members
+ project.project_infos << project_info
+ project.user_grades << user_grades unless user_grades.first.user_id.nil?
+ @applied_message.update_attribute(:status, 2)
+ # 添加成功后,申请人收到消息
+ AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
+ :status => 6, :viewed => true, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id)
+ # 添加成功后,批准人收到消息
+ AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,
+ :status => 7, :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id)
+ rescue Exception => e
+ puts e
+ end
+ end
+ end
+ end
+
+ # 同意消息中拒绝加入项目
+ # params[:user_id]为申请者ID
+ # params[:send_id]为拒绝人ID
+ # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:拒绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息)
+ def refused_allow_to_join_project
+ @applied_message = AppliedMessage.find(params[:applied_message_id])
+ @applied_message.update_attribute(:status, 3)
+ applied_project = @applied_message.applied
+ # 发送消息给被拒者,user_id对应的收到信息的用户
+ AppliedMessage.create(:user_id => @applied_message.applied_user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 4,
+ :viewed => true, :applied_user_id => @applied_message.user_id, :role => applied_project.role, :project_id => applied_project.project_id)
+ # 发送消息给拒绝者
+ AppliedMessage.create(:user_id => @applied_message.user_id, :applied_type => "AppliedProject", :applied_id => applied_project.id ,:status => 5,
+ :viewed => true, :applied_user_id => @applied_message.applied_user_id, :role => applied_project.role, :project_id => applied_project.project_id)
+ applied_project.delete
+ end
+
def create
if params[:refusal_button]
members = []
@@ -154,9 +211,11 @@ class MembersController < ApplicationController
user_ids = attrs.delete(:user_ids)
user_ids.each do |user_id|
member = Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
- role = Role.find_by_id(params[:membership][:role_ids])
+
+ role_ids = attrs.delete(:role_ids)
+ #role = Role.find(params[:membership][:role_ids])
# 这里的判断只能通过角色名,可以弄成常量
- if role && (role.name == "学生" || role.name == "Student")
+ if role_ids && role_ids.include?("10")
StudentsForCourse.create(:student_id => user_id, :course_id =>@course.id)
end
@@ -252,7 +311,10 @@ class MembersController < ApplicationController
if (params[:membership][:role_ids])
role = Role.find(params[:membership][:role_ids][0])
# 这里的判断只能通过角色名,可以弄成常量
- if role.name == "学生" || role.name == "Student"
+ attrs = params[:membership].dup
+ role_ids = attrs.delete(:role_ids)
+
+ if role_ids && role_ids.include?("10")
StudentsForCourse.create(:student_id => @member.user_id, :course_id =>@course.id)
else
joined = StudentsForCourse.where('student_id = ? and course_id = ?', @member.user_id,@course.id)
@@ -313,6 +375,11 @@ class MembersController < ApplicationController
grade.destroy
end
end
+ # 移出的时候删除申请消息,不需要删除消息,所以不必要关联删除
+ applied_projects = AppliedProject.where(:project_id => @project.id, :user_id => @member.user_id).first
+ unless applied_projects.nil?
+ applied_projects.delete
+ end
#移出项目发送消息
ForgeMessage.create(:user_id => @member.user_id, :project_id => @project.id, :forge_message_type => "RemoveFromProject", :viewed => false, :forge_message_id => User.current.id)
end
diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb
index 80c5a2468..c9873ade4 100644
--- a/app/controllers/quality_analysis_controller.rb
+++ b/app/controllers/quality_analysis_controller.rb
@@ -37,7 +37,7 @@ class QualityAnalysisController < ApplicationController
quality_an.delete unless quality_an.blank?
end
# Checks if the given job exists in Jenkins.
- unless @client.job.exists?(job_name)
+ # unless @client.job.exists?(job_name)
@g = Gitlab.client
branch = params[:branch]
language = swith_language_type(params[:language])
@@ -111,7 +111,7 @@ class QualityAnalysisController < ApplicationController
end
end
end
- end
+ # end
rescue => e
@message = e.message
end
diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb
index 38ec3e254..76d149f94 100644
--- a/app/controllers/school_controller.rb
+++ b/app/controllers/school_controller.rb
@@ -187,6 +187,12 @@ class SchoolController < ApplicationController
user_extention= User.current.extensions
user_extention.school_id = school.id
user_extention.save!
+
+ # status=4 向管理员发送信息
+ users = User.where(:admin => 1)
+ users.each do |user|
+ AppliedMessage.create(:user_id => user.id, :status => 4, :applied_user_id => User.current.id, :viewed => true, :applied_id => school.id, :applied_type => "ApplyAddSchools", :name => school.name )
+ end
else
data[:result] = 3
end
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 5e968e854..2f1d6a4db 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -41,7 +41,7 @@ class UsersController < ApplicationController
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
- :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist]
+ :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course,:user_courselist,:user_projectlist,:sort_syllabus_list]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@@ -133,6 +133,7 @@ class UsersController < ApplicationController
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@homepage = params[:homepage]
+ @user_id = params[:user_id]
@type = 'BlogComment'
when 'OrgDocumentComment'
@reply = OrgDocumentComment.find params[:reply_id]
@@ -149,6 +150,9 @@ class UsersController < ApplicationController
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'Issue'
+ when 'Syllabus'
+ @reply = JournalsForMessage.find params[:reply_id]
+ @type = 'Syllabus'
end
respond_to do |format|
format.js
@@ -351,15 +355,21 @@ class UsersController < ApplicationController
case params[:agree]
when 'Y'
apply_user = User.find(@msg.course_message_id)
-
+ ids = @msg.content.split(",") # [@msg.content] msg content保存的是申请的职位角色
+ integer_ids = []
+ ids.each do |role_id|
+ integer_ids << role_id.to_i
+ end
if apply_user.member_of_course?(Course.find(@msg.course_id))
#将角色改为老师或者教辅
member = Course.find(@msg.course_id).members.where(:user_id=>apply_user.id).all[0]
- member.role_ids = [@msg.content] # msg content保存的是申请的职位角色
- #删除为学生的记录
- joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,@msg.course_id)
- joined.each do |join|
- join.delete
+ member.role_ids = integer_ids
+ #删除为学生的记录
+ unless member.role_ids.include?(10)
+ joined = StudentsForCourse.where('student_id = ? and course_id = ?', member.user_id,@msg.course_id)
+ joined.each do |join|
+ join.delete
+ end
end
member.course_group_id = 0
@@ -368,7 +378,7 @@ class UsersController < ApplicationController
@msg.update_attributes(:status=>1,:viewed=>1)
else
members = []
- members << Member.new(:role_ids => [@msg.content.to_i], :user_id => @msg.course_message_id)
+ members << Member.new(:role_ids => integer_ids, :user_id => @msg.course_message_id)
Course.find(@msg.course_id).members << members
CourseMessage.create(:user_id => @msg.course_message_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>User.current.id,:content=>@msg.content,:course_message_type=>'CourseRequestDealResult',:status=>1)
@msg.update_attributes(:status=>1,:viewed=>1)
@@ -3225,7 +3235,35 @@ class UsersController < ApplicationController
end
def user_courselist
- @order, @c_sort,@type = params[:order] || 1, params[:sort] || 1, params[:type] || 1
+ @order, @c_sort, @type, @list_type = 1, 2, 1, 1
+
+ @my_syllabuses = @user.syllabuses
+
+ sy_courses = @user.courses.visible.where("is_delete =? and tea_id != ?", 0, @user.id)
+ syllabus_ids = sy_courses.empty? ? '(-1)' : "(" + sy_courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
+ @join_syllabuses = Syllabus.where("id in #{syllabus_ids} and user_id != #{@user.id}")
+
+ @my_syllabuses = syllabus_course_list_sort @my_syllabuses
+ @join_syllabuses = syllabus_course_list_sort @join_syllabuses
+ @my_syllabuses = @my_syllabuses.sort{|x,y| y[:last_update] <=> x[:last_update]}
+ @join_syllabuses = @join_syllabuses.sort{|x,y| y[:last_update] <=> x[:last_update]}
+
+ #分页
+ # @limit = 10
+ # @is_remote = true
+ # @atta_count = @syllabus.count
+ # @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
+ # @offset ||= @atta_pages.offset
+ # @syllabus = paginateHelper @syllabus,@limit
+
+ respond_to do |format|
+ format.html {render :layout => 'new_base_user'}
+ end
+ end
+
+ #课程列表的排序
+ def sort_syllabus_list
+ @order, @c_sort, @type, @list_type = params[:order] || 1, params[:sort] || 1, params[:type] || 1, params[:list_type] || 1
#确定 sort_type
if @order.to_i == @type.to_i
@@ -3235,40 +3273,48 @@ class UsersController < ApplicationController
end
sort_name = "updated_at"
- sort_type = @c_sort == 1 ? "asc" : "desc"
- @courses = @user.courses.visible.where("is_delete =?", 0)
- syllabus_ids = @courses.empty? ? '(-1)' : "(" + @courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
- @syllabus = Syllabus.where("id in #{syllabus_ids} or user_id = #{User.current.id}").order("#{sort_name} #{sort_type}")
+ if @list_type.to_i == 1
+ @syllabuses = @user.syllabuses.order("updated_at desc")
+ else
+ sy_courses = @user.courses.visible.where("is_delete =? and tea_id != ?", 0, @user.id)
+ syllabus_ids = sy_courses.empty? ? '(-1)' : "(" + sy_courses.map{|course| !course.syllabus_id.nil? && course.syllabus_id}.join(",") + ")"
+ @syllabuses = Syllabus.where("id in #{syllabus_ids} and user_id != #{@user.id}").order("updated_at desc")
+ end
- #根据 作业+资源数排序
- if @order.to_i == 2
+ if @order.to_i == 1 #根据 班级更新时间排序
+ @syllabuses = syllabus_course_list_sort @syllabuses
+ @c_sort == 1 ? (@syllabuses = @syllabuses.sort{|x,y| x[:last_update] <=> y[:last_update] }) : (@syllabuses = @syllabuses.sort{|x,y| y[:last_update] <=> x[:last_update]})
+ @type = 1
+ elsif @order.to_i == 2 #根据 作业+资源数排序
@type = 2
- @syllabus.each do |syllabus|
+ @syllabuses.each do |syllabus|
count = 0
- courses = @courses.where("syllabus_id = #{syllabus.id}")
+ courses = syllabus.courses.not_deleted
courses.each do |c|
count += (User.current.admin? || User.current.allowed_to?(:as_teacher,c)) ? (c.homework_commons.count + visable_attachemnts_incourse(c).count) : (c.homework_commons.where("publish_time <= '#{Date.today}'").count + visable_attachemnts_incourse(c).count)
end
syllabus[:infocount] = count
end
- @c_sort == 1 ? (@syllabus = @syllabus.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@syllabus = @syllabus.sort{|x,y| y[:infocount] <=> x[:infocount]})
- @syllabus = sortby_time_countcommon_nosticky @syllabus,sort_name
+ @c_sort == 1 ? (@syllabuses = @syllabuses.sort{|x,y| x[:infocount] <=> y[:infocount] }) : (@syllabuses = @syllabuses.sort{|x,y| y[:infocount] <=> x[:infocount]})
+ @syllabuses = sortby_time_countcommon_nosticky @syllabuses,sort_name
else
@type = 1
end
- #分页
- @limit = 10
- @is_remote = true
- @atta_count = @syllabus.count
- @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
- @offset ||= @atta_pages.offset
- @syllabus = paginateHelper @syllabus,@limit
-
respond_to do |format|
format.js
- format.html {render :layout => 'new_base_user'}
+ end
+ end
+
+ #展开课程下的班级
+ def expand_courses
+ @syllabus = Syllabus.where("id = #{params[:syllabus_id]}").first
+ unless @syllabus.nil?
+ @courses = @syllabus.courses.not_deleted.select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS updatetime").order("updatetime desc")
+ respond_to do |format|
+ format.js
+ end
end
end
@@ -3342,6 +3388,8 @@ class UsersController < ApplicationController
when 'Syllabus'
obj = Syllabus.where('id = ?', params[:id].to_i).first
@journals = obj.journals_for_messages.reorder("created_on desc")
+ @type = 'Syllabus'
+ @user_activity_id = params[:div_id].to_i if params[:div_id]
when 'JournalsForMessage'
obj = JournalsForMessage.where('id = ?', params[:id].to_i).first
journals = []
@@ -3358,6 +3406,7 @@ class UsersController < ApplicationController
@user_activity_id = params[:div_id].to_i if params[:div_id]
@homepage = params[:homepage].to_i
@type = 'BlogComment'
+ @user_id = obj.author_id
comments = []
@journals = get_all_children(comments, obj)
when 'HomeworkCommon'
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index 828739cc4..499272706 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -112,6 +112,10 @@ class WordsController < ApplicationController
end
@is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
+ elsif @journal_destroyed.jour_type == 'Syllabus'
+ @syllabus = Syllabus.find @journal_destroyed.jour_id
+ @count = @syllabus.journals_for_messages.count
+ @comments = @syllabus.journals_for_messages.reorder("created_on desc").limit(3)
end
respond_to do |format|
format.js
@@ -352,6 +356,35 @@ class WordsController < ApplicationController
render_403
end
end
+
+ #课程大纲的二级回复
+ def reply_to_syllabus
+ if User.current.logged?
+ @user = User.current
+ reply = JournalsForMessage.find params[:id].to_i
+ @syllabus = Syllabus.find reply.jour_id
+ if params[:reply_message].size>0 && User.current.logged? && @user
+ options = {:notes => params[:reply_message], :reply_id => reply.user_id,:user_id => @user.id,:m_parent_id => params[:id].to_i,:m_reply_id => params[:id].to_i}
+ feedback = Syllabus.add_syllabus_jour(@user, params[:reply_message], reply.jour_id, options)
+ if (feedback.errors.empty?)
+ if params[:asset_id]
+ ids = params[:asset_id].split(',')
+ update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
+ end
+ @syllabus.update_column('updated_at', Time.now)
+ @count = @syllabus.journals_for_messages.count
+ @comments = @syllabus.journals_for_messages.reorder("created_on desc").limit(3)
+ respond_to do |format|
+ format.js
+ end
+ else
+ flash[:error] = feedback.errors.full_messages[0]
+ end
+ end
+ else
+ render_403
+ end
+ end
def add_brief_introdution
user = User.current
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index e1dda3554..b3e946f95 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -274,14 +274,19 @@ module CoursesHelper
#searchPeopleByRoles(project, TeacherRoles)
members = []
project.members.includes(:user).each do |m|
- members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
+ #members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
+ members << m if m && m.user && m.user.has_teacher_role(project)
end
members
end
def TeacherAndAssistantCount course
- students_count = course.student.count
- number = course.members.count - students_count
+ #students_count = course.student.count
+ #number = course.members.count - students_count
+ member_ids = course.members.includes(:user).blank? ? "(-1)" : "(" + course.members.includes(:user).map { |mem| mem.id}.join(",") + ")"
+ role_ids = "(3, 7, 9)"
+ number = MemberRole.where("member_id in #{member_ids} and role_id in #{role_ids}").count
+ #number = (searchTeacherAndAssistant course).count
end
def search_student_in_group(project, course_group_id)
@@ -789,7 +794,7 @@ module CoursesHelper
if user.logged?
joined = course.members.includes(:user).map{|member| member.user_id}.include? user.id
text = joined ? l(:label_course_exit_student) : l(:label_course_join_student)
- url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id)
+ url = joined ? join_path(:object_id => course.id) : join_private_courses_courses_path()
method = joined ? 'delete' : 'post'
if joined
link = link_to(text, url, :remote => true, :method => method, :class => "sy_btn_grey fl", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out))
@@ -831,6 +836,10 @@ module CoursesHelper
result = l(:label_student)
elsif role == "Manager"
result = l(:field_admin)
+ elsif role.include?("TeachingAsistant") && role.include?("Student")
+ result = l(:label_TA) + " " + l(:label_student)
+ elsif role.include?("Teacher") && role.include?("Student")
+ result = l(:label_teacher) + " " + l(:label_student)
end
result
end
@@ -914,5 +923,15 @@ module CoursesHelper
resource_num*5 + journal_num + homework_journal_num ) desc limit 3;")
end
+ #用户在该课程是否具有某个角色
+ def get_user_member_roles_course course, user, role
+ members = course.members.where("user_id = #{user.id}")
+ result = false
+ unless members.blank?
+ m_roles = MemberRole.where("member_id = #{members.first.id} and role_id = #{role}")
+ end
+ result = !m_roles.blank?
+ result
+ end
end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index 98b993183..91743289a 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -54,6 +54,44 @@ module UsersHelper
end
end
+ # 获取消息角色
+ def applied_project_message_type role
+ case role
+ when 3
+ "管理员"
+ when 4
+ "开发人员"
+ when 5
+ "报告人员"
+ end
+ end
+
+ # 判断当前用户能否对消息进行操作
+ def allow_to_show applied_message
+ (User.current.id == applied_message.user_id && applied_message.status == 1) ? true : false
+ end
+
+ # 项目申请消息通过状态判断用户
+ # status(1:申请的消息;2:已操作过该消息(包括同意或者拒绝,消息状态更新);3:拒绝消息;4:被拒人收到消息;5:拒绝者收到消息;6:同意后申请人收到消息;7:同意后批准人收到消息)
+ def applied_project_users applied_message
+ # case applied_message.status
+ # when 3,2,1,5,4,7,6
+ user = User.find(applied_message.applied_user_id)
+ # end
+ end
+
+ # 项目申请消息通过状态判断tip描述
+ def applied_project_tip applied_message
+ case applied_message.status
+ when 4
+ "拒绝申请加入项目:"
+ when 5,3,2,1,7
+ "申请加入项目:"
+ when 6
+ "同意申请加入项目"
+ end
+ end
+
def get_resource_origin attach
type = attach.container_type
content = attach.container
@@ -690,4 +728,18 @@ module UsersHelper
end
result_ids
end
+
+ #课程的班级列表最近更新时间
+ def syllabus_course_list_sort syllabuses
+ syllabuses.each do |sy|
+ updated_at = sy.updated_at
+ courses = sy.courses.not_deleted
+ unless courses.empty?
+ course_ids = "(" + courses.map { |course| course.id}.join(",") + ")"
+ updated_at = CourseActivity.where("course_id in #{course_ids}").order("updated_at desc").first.updated_at
+ end
+ sy[:last_update] = updated_at
+ end
+ syllabuses
+ end
end
diff --git a/app/helpers/watchers_helper.rb b/app/helpers/watchers_helper.rb
index 52f2ea119..d846071b5 100644
--- a/app/helpers/watchers_helper.rb
+++ b/app/helpers/watchers_helper.rb
@@ -364,22 +364,29 @@ module WatchersHelper
:class => "pr_join_a" ,:id=>id
end
- #申请加入项目
+ # 申请加入项目
def join_in_project_link(project, user, options=[])
- return '' unless user && user.logged?
applied = project.applied_projects.find_by_user_id(user.id)
text = applied ? l(:label_unapply_project) : l(:label_apply_project)
- @applied_flag = project.instance_of?(Project)
+ url = applied_join_project_path(:object_id => project.id)
+ method = 'post'
+ @applied_flag = project.instance_of?(Project)
if applied
- appliedid = applied.id
+ link = "#{text} "
+ else
+ link = link_to(text, url, :remote => true, :method => method, :id => "#{project.id}", :class => "pr_join_a")
end
- id = applied_css(project)
- url = appliedproject_path(
- :id=>appliedid,
- :user_id => user.id,
- :project_id => project.id)
- method = applied ? 'delete' : 'post'
- link_to text, url, :remote => true, :method => method , :class => "pr_join_a",:id => id
+ link.html_safe
+ # if applied
+ # appliedid = applied.id
+ # end
+ # id = applied_css(project)
+ # url = appliedproject_path(
+ # :id=>appliedid,
+ # :user_id => user.id,
+ # :project_id => project.id)
+ # method = applied ? 'delete' : 'post'
+ # link_to text, url, :remote => true, :method => method , :class => "pr_join_a",:id => id
end
def paginateHelper obj, pre_size=20
diff --git a/app/models/applied_message.rb b/app/models/applied_message.rb
index de07dae22..cbba74f95 100644
--- a/app/models/applied_message.rb
+++ b/app/models/applied_message.rb
@@ -1,6 +1,7 @@
class AppliedMessage < ActiveRecord::Base
# status: 0表示未批准; status:1表示已批准; status: 2表示已拒绝
- attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :name
+
+ attr_accessible :applied_id, :applied_type, :status, :user_id, :viewed, :applied_user_id, :role, :project_id, :name
belongs_to :applied ,:polymorphic => true
belongs_to :apply_add_schools
belongs_to :user
diff --git a/app/models/applied_project.rb b/app/models/applied_project.rb
index fb8bf90af..b1945a937 100644
--- a/app/models/applied_project.rb
+++ b/app/models/applied_project.rb
@@ -1,18 +1,16 @@
class AppliedProject < ActiveRecord::Base
- attr_accessible :project_id, :user_id
+ attr_accessible :project_id, :user_id, :role
belongs_to :user
belongs_to :project
- has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
+ has_many :applied_messages, :class_name => 'AppliedMessage', :as => :applied, :dependent => :destroy
after_create :send_appliled_message
+ # 仅仅给项目管理人员发送消息
def send_appliled_message
- # if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
- self.project.members.each do |m|
- if m.roles.first.to_s.include?("Manager")
- self.forge_messages << ForgeMessage.new(:user_id => m.user_id, :project_id => self.project_id, :viewed => false)
- end
+ self.project.managers.each do |member|
+ self.applied_messages << AppliedMessage.new(:user_id => member.user_id, :status => true, :viewed => false, :applied_user_id => self.user_id, :role => self.role, :project_id => self.project_id)
end
# end
end
diff --git a/app/models/member.rb b/app/models/member.rb
index 3cb70a8fe..cb15e067b 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -53,7 +53,15 @@ class Member < ActiveRecord::Base
new_role_ids = ids - role_ids
# Add new roles
- new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
+ if new_role_ids.include?(7) && new_role_ids.include?(10)
+ member_roles << MemberRole.new(:role_id => 7)
+ member_roles << MemberRole.new(:role_id => 10, :is_current => 0)
+ elsif new_role_ids.include?(9) && new_role_ids.include?(10)
+ member_roles << MemberRole.new(:role_id => 9)
+ member_roles << MemberRole.new(:role_id => 10, :is_current => 0)
+ else
+ new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
+ end
# Remove roles (Rails' #role_ids= will not trigger MemberRole#on_destroy)
member_roles_to_destroy = member_roles.select {|mr| !ids.include?(mr.role_id)}
if member_roles_to_destroy.any?
diff --git a/app/models/member_role.rb b/app/models/member_role.rb
index 4d493cb27..799720833 100644
--- a/app/models/member_role.rb
+++ b/app/models/member_role.rb
@@ -16,6 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class MemberRole < ActiveRecord::Base
+ # multi_role 课程中的多重角色 0:单角色/学生,1:管理员&学生,2:教师&学生,3:教辅&学生
belongs_to :member
belongs_to :role
diff --git a/app/models/project.rb b/app/models/project.rb
index aa70084d2..67f010210 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -269,6 +269,11 @@ class Project < ActiveRecord::Base
notified.collect(&:mail)
end
+ # 返回为member类型数组
+ def managers
+ self.members.includes(:roles).select{|member| member.roles[0].try(:name) == "Manager"}
+ end
+
def initialize(attributes=nil, *args)
super
@@ -905,6 +910,24 @@ class Project < ActiveRecord::Base
User.find(self.user_id)
end
+ # 延迟生成邀请码
+ def invite_code
+ return generate_invite_code
+ end
+
+ # 生成邀请码
+ # 如果已有改邀请码,则重新生成
+ CODES = %W(2 3 4 5 6 7 8 9 A B C D E F G H J K L N M O P Q R S T U V W X Y Z)
+ def generate_invite_code
+ code = read_attribute(:invite_code)
+ if !code || code.size <6
+ code = CODES.sample(6).join
+ return generate_invite_code if Project.where(invite_code: code).present?
+ update_attribute(:invite_code, code)
+ end
+ code
+ end
+
private
def after_parent_changed(parent_was)
diff --git a/app/models/user.rb b/app/models/user.rb
index 996aa9be7..a4b7f3b25 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -42,12 +42,12 @@ class User < Principal
# Different ways of displaying/sorting users
USER_FORMATS = {
:firstname_lastname => {
- :string => '#{firstname} #{lastname}',
+ :string => '#{firstname}#{lastname}',
:order => %w(firstname lastname id),
:setting_order => 1
},
:firstname_lastinitial => {
- :string => '#{firstname} #{lastname.to_s.chars.first}.',
+ :string => '#{firstname}#{lastname.to_s.chars.first}.',
:order => %w(firstname lastname id),
:setting_order => 2
},
@@ -57,7 +57,7 @@ class User < Principal
:setting_order => 3
},
:lastname_firstname => {
- :string => '#{lastname} #{firstname}',
+ :string => '#{lastname}#{firstname}',
:order => %w(lastname firstname id),
:setting_order => 4
},
@@ -369,7 +369,8 @@ class User < Principal
system_messages_count = SystemMessage.where("created_at >?", onclick_time).count
at_count = AtMessage.where("user_id =? and viewed =? and created_at >?", user.id, 0, onclick_time).count
org_count = OrgMessage.where("user_id=? and viewed =? and created_at >?", user.id,0, onclick_time).count
- messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count
+ applied_count = AppliedMessage.where("user_id=? and viewed =? and created_at >?", user.id, 0, onclick_time).count
+ messages_count = course_count + forge_count + user_feedback_count + user_memo_count + system_messages_count + at_count + org_count + applied_count
end
# 查询指派给我的缺陷记录
@@ -823,7 +824,7 @@ class User < Principal
# Find course membership
membership = coursemembership(course)
if membership
- roles = membership.roles
+ roles = membership.roles.where("is_current = 1")
else
@role_non_member ||= Role.non_member
roles << @role_non_member
@@ -918,6 +919,12 @@ class User < Principal
end
end
+ #是否具有老师角色
+ def has_teacher_role(course)
+ member = course.members.where("user_id = #{self.id}").first
+ role = MemberRole.where("member_id = #{member.id} and role_id in (3, 7, 9)")
+ !role.blank?
+ end
# Return true if the user is allowed to do the specified action on a specific context
# Action can be:
diff --git a/app/services/courses_service.rb b/app/services/courses_service.rb
index 811d73f55..ce3157d5f 100644
--- a/app/services/courses_service.rb
+++ b/app/services/courses_service.rb
@@ -391,6 +391,103 @@ class CoursesService
{:state => @state,:course => course}
end
+ #多个角色加入课程
+ def join_course_roles params,current_user
+ course = Course.find_by_invite_code(params[:invite_code]) if params[:invite_code]
+
+ @state = 10
+ if course
+ if course_endTime_timeout? course
+ @state = 2
+ elsif course[:is_delete] == 1
+ @state = 11
+ else
+ if current_user.member_of_course?(course) #如果已经是成员
+ @state = 3
+ # member = course.members.where("user_id=#{current_user.id} and course_id=#{course.id}")[0]
+ # role_ids = params[:role]
+ # #roleName = member.roles[0].name if member
+ # #roleName = member.roles.map{|role| role.name}.join(",") if member
+ # if params[:invite_code].present?
+ # #如果加入角色为学生 并且当前是学生
+ # if role_ids == "10" && roleName.include?("Student") && !roleName.include?("Teacher") && !roleName.include?("TeachingAsistant")&& !roleName.include?("Manager")
+ # @state = 3
+ # #如果加入的角色为老师,并且当前已经是老师
+ # elsif role_ids == "9" && roleName.include?("Teacher") && !roleName.include?("Student")
+ # @state = 8
+ # #如果加入的角色教辅并且当前为教辅
+ # elsif role_ids == "7" && roleName.include?("TeachingAsistant") && !roleName.include?("Student")
+ # @state = 9
+ # elsif roleName.include?("Manager")
+ # @state = 10
+ # #如果加入角色为教师或者教辅,并且当前是学生,或者是要成为教辅,当前不是教辅,或者要成为教师,当前不是教师。那么要发送请求
+ # elsif (params[:role] != "10" && roleName == "Student") || (params[:role] == "7" && roleName != "TeachingAsistant" ) || (params[:role] == "9" && roleName != "Teacher" )
+ # #如果已经发送过消息了,那么就要给个提示
+ # if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = #{params[:role]} and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0 ").count != 0
+ # @state = 7
+ # else
+ # Mailer.run.join_course_request(course, User.current, params[:role])
+ # CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> params[:role],:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
+ # @state = 6
+ # end
+ # #如果加入角色是学生,但是是当前课程的教师或者教辅
+ # elsif params[:role] == "10" && roleName != "Student"
+ # member.role_ids = [params[:role]]
+ # member.save
+ # StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id)
+ # @state = 0
+ # end
+ # else
+ # @state = 1
+ # end
+ else
+ if params[:invite_code].present?
+ role_ids = params[:role]
+ role_str = role_ids.join(",")
+ if role_ids.include?("10") && !role_ids.include?("7") && !role_ids.include?("9")
+ members = []
+ members << Member.new(:role_ids => [10], :user_id => current_user.id)
+ course.members << members
+ StudentsForCourse.create(:student_id => current_user.id, :course_id => course.id)
+ @state = 0
+ else
+ is_stu = false
+ if role_ids.include?("10")
+ members = []
+ members << Member.new(:role_ids => [10], :user_id => current_user.id)
+ course.members << members
+ StudentsForCourse.create(:student_id => current_user.id, :course_id =>course.id)
+ is_stu = true
+ end
+ #如果已经发送过消息了,那么就要给个提示
+ if CourseMessage.where("course_message_type = 'JoinCourseRequest' and user_id = #{course.tea_id} and content = '#{role_str}' and course_message_id = #{User.current.id} and course_id = #{course.id} and status = 0").count != 0
+ if is_stu
+ @state = 12
+ else
+ @state = 7
+ end
+ else
+ Mailer.run.join_course_request(course, User.current, params[:role])
+ CourseMessage.create(:user_id => course.tea_id, :course_id => course.id, :viewed => false,:content=> role_str,:course_message_id=>User.current.id,:course_message_type=>'JoinCourseRequest',:status=>0)
+ if is_stu
+ @state = 13
+ else
+ @state = 6
+ end
+ end
+ end
+ else
+ @state = 1
+ end
+ end
+ end
+ else
+ @state = 4
+ end
+ {:state => @state,:course => course}
+ end
+
+
#作业列表
#已提交的作业数量获取 bid.homeworks.count
#学生提问数量获取 bid.commit.nil? ? 0 : bid.commit
diff --git a/app/views/admin/_all_schools.html.erb b/app/views/admin/_all_schools.html.erb
index af59d7687..d4cf916f5 100644
--- a/app/views/admin/_all_schools.html.erb
+++ b/app/views/admin/_all_schools.html.erb
@@ -1,5 +1,4 @@
<%= stylesheet_link_tag 'css/common','css/popup' %>
-
更改为
diff --git a/app/views/admin/_courselist_detail_tr.html.erb b/app/views/admin/_courselist_detail_tr.html.erb
index 83b7904ce..6bec90845 100644
--- a/app/views/admin/_courselist_detail_tr.html.erb
+++ b/app/views/admin/_courselist_detail_tr.html.erb
@@ -7,7 +7,7 @@
- <%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %>
+ <%= link_to(course.teacher.show_name, user_path(course.teacher)) %>
<%= course.class_period %>
diff --git a/app/views/admin/applied_schools.html.erb b/app/views/admin/applied_schools.html.erb
index 61db6769f..c9ebdfb66 100644
--- a/app/views/admin/applied_schools.html.erb
+++ b/app/views/admin/applied_schools.html.erb
@@ -60,7 +60,7 @@
<% user = User.where("id=?", apply.user_id).first %>
<% unless user.nil? %>
- <%= user.login %>
+ <%=link_to user.show_name, user_path(user) %>
<% end %>
@@ -106,7 +106,7 @@
-
+
<%= apply.address %>
@@ -118,9 +118,9 @@
<%= format_date(apply.created_at) %>
- <%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }) %>
- <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id, :tip => 'unapplied' },:method => :delete, :confirm => l(:text_are_you_sure)) %>
- <%=link_to '更改', admin_all_schools_path(:school_id =>apply.id), :remote => true %>
+ <%= link_to( l(:label_approve), { :controller => 'admin', :action => 'approve_applied_schools', :id => apply.id }, :class => "application-default-link" ) %>
+ <%= link_to( l(:button_delete), { :controller => 'admin', :action => 'delete_applied_schools', :id => apply.id, :tip => 'unapplied' },:method => :delete, :confirm => l(:text_are_you_sure), :class => "application-default-link") %>
+ <%=link_to '更改', admin_all_schools_path(:school_id =>apply.id), :remote => true, :class => "application-default-link" %>
diff --git a/app/views/admin/has_applied_schools.html.erb b/app/views/admin/has_applied_schools.html.erb
index cbb0e70e5..b0419bcab 100644
--- a/app/views/admin/has_applied_schools.html.erb
+++ b/app/views/admin/has_applied_schools.html.erb
@@ -29,7 +29,7 @@
申请者
-
+
地区
@@ -38,6 +38,9 @@
原名
+
+ 用户
+
创建时间
@@ -53,7 +56,7 @@
<%= apply.id %>
-
+
<% unless apply.school_id.nil? %>
<% school_name = School.where("id=?", apply.school_id).first %>
<%= school_name %>
@@ -63,7 +66,7 @@
<% user = User.where("id=?", apply.user_id).first %>
<% unless user.nil? %>
- <%= user.login %>
+ <%=link_to user.show_name, user_path(user) %>
<% end %>
@@ -109,13 +112,17 @@
-
+
<%= apply.address %>
<%= apply.name %>
+
+ <% count = UserExtensions.where("school_id = #{apply.school_id}").count %>
+ <%= count %>
+
<%= format_date(apply.created_at) %>
@@ -126,18 +133,8 @@
- <% unless apply.remarks.blank? %>
-
-
-
-
-
- <%= apply.remarks %>
-
-
<% end %>
<% end %>
- <% end %>
\ No newline at end of file
diff --git a/app/views/admin/non_syllabus_courses.html.erb b/app/views/admin/non_syllabus_courses.html.erb
index 1be979eeb..c5a2c81ec 100644
--- a/app/views/admin/non_syllabus_courses.html.erb
+++ b/app/views/admin/non_syllabus_courses.html.erb
@@ -72,7 +72,7 @@
- <%= link_to(course.teacher.show_name.truncate(6, omission: '...'), user_path(course.teacher)) %>
+ <%= link_to(course.teacher.show_name, user_path(course.teacher)) %>
<%= course.class_period %>
diff --git a/app/views/admin/syllabuses.html.erb b/app/views/admin/syllabuses.html.erb
index 194091abc..5098131da 100644
--- a/app/views/admin/syllabuses.html.erb
+++ b/app/views/admin/syllabuses.html.erb
@@ -52,7 +52,7 @@
- <%= link_to(syllabus.try(:user).try(:realname).truncate(6, omission: '...'), user_path(syllabus.user)) %>
+ <%= link_to syllabus.user.show_name, user_path(syllabus.user) %>
<%= format_date(syllabus.created_at) %>
@@ -70,7 +70,7 @@
<%= render :partial => 'admin/rename_course_name', :locals => {:course => course} %>
- <%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
+ <%= link_to(course.teacher.show_name, user_path(course.teacher)) %>
<%= format_date(course.created_at) %>
diff --git a/app/views/applied_project/_applied_join_project.html.erb b/app/views/applied_project/_applied_join_project.html.erb
new file mode 100644
index 000000000..457cdf9cc
--- /dev/null
+++ b/app/views/applied_project/_applied_join_project.html.erb
@@ -0,0 +1,29 @@
+
+
diff --git a/app/views/applied_project/_applied_project_tip.js.erb b/app/views/applied_project/_applied_project_tip.js.erb
new file mode 100644
index 000000000..56e5270d6
--- /dev/null
+++ b/app/views/applied_project/_applied_project_tip.js.erb
@@ -0,0 +1,25 @@
+
\ No newline at end of file
diff --git a/app/views/applied_project/applied_join_project.js.erb b/app/views/applied_project/applied_join_project.js.erb
index ae9d3f467..5d9f7f87a 100644
--- a/app/views/applied_project/applied_join_project.js.erb
+++ b/app/views/applied_project/applied_join_project.js.erb
@@ -1,14 +1,3 @@
-// @status: 0 该项目不存在;1 不重复加入;2 成功加入; 3 已是项目成员;其它 加入失败
-<% if @status == 0%>
- alert("<%= l('project.join.tips.notexist') %>");
-<% elsif @status == 1%>
- alert("<%= l('project.join.tips.repeat') %>");
-<% elsif @status == 2%>
- alert("<%= l('project.join.tips.success') %>");
- hideModal($("#popbox"));
- $("#applied_project_link_<%= @project.id%>").replaceWith("<%=escape_javascript(link_to '取消申请',appliedproject_applied_path(:project_id => @project.id,:user_id => User.current.id),:class => "blue_n_btn fr mt20", :remote => "true",:method => "delete",:id => "applied_project_link_#{@project.id}")%>");
-<% elsif @status == 3%>
- alert("<%= l('project.join.tips.has') %>");
-<%else%>
- alert("<%= l('project.join.tips.fail') %>");
-<%end%>
\ No newline at end of file
+var htmlvalue = "<%= escape_javascript(render :partial => 'applied_join_project', locals: {:project_id => (@project.nil? ? nil : @project.id)}) %>";
+pop_box_new(htmlvalue,460,40,50);
+
diff --git a/app/views/applied_project/applied_project_info.js.erb b/app/views/applied_project/applied_project_info.js.erb
new file mode 100644
index 000000000..ab3cb396d
--- /dev/null
+++ b/app/views/applied_project/applied_project_info.js.erb
@@ -0,0 +1,5 @@
+<% if @project %>
+$("#join_in_project_applied").html('<%= escape_javascript( render :partial => 'projects/applied_status') %>');
+<% end %>
+var htmlvalue = "<%= escape_javascript(render :partial => 'applied_project/applied_project_tip') %>";
+pop_box_new(htmlvalue,380,40,50);
diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb
index 0f7e8a012..759a9a735 100644
--- a/app/views/attachments/_project_file_links.html.erb
+++ b/app/views/attachments/_project_file_links.html.erb
@@ -92,7 +92,7 @@
<% end %>
<% if options[:author] %>
- <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "c_orange" %>,
+ <%= link_to h(truncate(attachment.author.name, length: 10, omission: '...')),user_path(attachment.author),:class => "link-blue" %>,
<%= format_time(attachment.created_on) %>
<% end %>
diff --git a/app/views/blog_comments/destroy.js.erb b/app/views/blog_comments/destroy.js.erb
index c34986977..52ecbb925 100644
--- a/app/views/blog_comments/destroy.js.erb
+++ b/app/views/blog_comments/destroy.js.erb
@@ -1,5 +1,5 @@
<% if @in_user_homepage %>
- <% homepage = BlogComment.find(User.current.blog.homepage_id) %>
+ <% homepage = BlogComment.find(@user.blog.homepage_id) %>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/homepage', :locals => {:activity => @blog_comment, :user_activity_id => homepage.id}) %>");
<% else%>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @blog_comment,:user_activity_id =>@user_activity_id}) %>");
diff --git a/app/views/blogs/_homepage.html.erb b/app/views/blogs/_homepage.html.erb
index a16547836..a076ed15c 100644
--- a/app/views/blogs/_homepage.html.erb
+++ b/app/views/blogs/_homepage.html.erb
@@ -1,6 +1,5 @@
-
<% if activity.author.id == User.current.id%>
<%end%>
-
<%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id,
:blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey", :style => 'text-align:center;' %>
@@ -45,7 +43,6 @@
-
<% all_comments = []%>
@@ -57,7 +54,7 @@
<% comments = get_all_children(all_comments, activity)[0..2] %>
<% if count > 0 %>
- <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id, :homepage => 1}%>
+ <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'BlogComment', :activity_id =>activity.id, :homepage => 1, :user_id => activity.author_id}%>
<% end %>
diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb
index 55217017b..9f45172bc 100644
--- a/app/views/courses/_copy_course.html.erb
+++ b/app/views/courses/_copy_course.html.erb
@@ -114,7 +114,7 @@
资源
-
复制到新班级的资源将在1个月后发布,请您调整资源的发布时间,否则学生可能看不到资源。
+
复制到新班级的资源将在1个月后发布,请您调整资源的发布时间,否则学生将看不到资源。
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/app/views/courses/_join_private_course.html.erb b/app/views/courses/_join_private_course.html.erb
index ec5d18c7e..f95129903 100644
--- a/app/views/courses/_join_private_course.html.erb
+++ b/app/views/courses/_join_private_course.html.erb
@@ -1,100 +1,52 @@
-
-
-
-
-
快速进入班级通道
-
-
-
+
+
+
+
+ 确 定
+ 取 消
-
-
-
-
-
快速加入班级通道
-
只要持有班级邀请码,就可以快速加入所在班级。班级页面搜索不到的私有班级只能从此通道进入哦!
-
-
-
+
+
+
+ <% end %>
+
-
-
-
+
\ No newline at end of file
diff --git a/app/views/courses/_member.html.erb b/app/views/courses/_member.html.erb
index 95177c92c..9e6abcf4f 100644
--- a/app/views/courses/_member.html.erb
+++ b/app/views/courses/_member.html.erb
@@ -10,7 +10,7 @@
) do |f| %>
<% @roles.each do |role| %>
- <%= radio_button_tag 'membership[role_ids][]', role.id, member.roles.include?(role),
+ <%= check_box_tag 'membership[role_ids][]', role.id, member.roles.include?(role), :id => "edit_member_role_#{member.id}_#{role.id}",
:disabled => member.member_roles.detect { |mr| mr.role_id == role.id && !mr.inherited_from.nil? } %>
<%= zh_course_role(h role) %>
@@ -35,4 +35,25 @@
:data => (!User.current.admin? && member.include?(User.current) ? {:confirm => l(:text_own_membership_delete_confirmation)} : {confirm: l(:label_delete_confirm)}) if member.deletable? %>
<% end%>
-<% end%>
\ No newline at end of file
+
+
+<% end%>
diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb
index c41edf680..5f9e512d7 100644
--- a/app/views/courses/_tool_expand.html.erb
+++ b/app/views/courses/_tool_expand.html.erb
@@ -29,7 +29,7 @@
<% if show_nav?(course_feedback_count) %>
留言
- <%= link_to "", course_feedback_path(@course), :class => 'sy_class_add', :title =>"#{l(:label_course_feedback)}", :id => "course_jour_count"%>
+ <%= link_to "", course_feedback_path(@course), :class => 'sy_class_add', :title =>"#{l(:label_course_feedback)}"%>
<% end %>
<% if show_nav?(course_poll_count) %>
diff --git a/app/views/courses/join.js.erb b/app/views/courses/join.js.erb
index ac8b717d1..52c1347a5 100644
--- a/app/views/courses/join.js.erb
+++ b/app/views/courses/join.js.erb
@@ -36,6 +36,10 @@ window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/co
alert("您已经是该班级的管理员了");
hidden_join_course_form();
window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% elsif @state == 11%>
+alert("该班级已被删除");
+hidden_join_course_form();
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
<% else %>
alert("未知错误,请稍后再试");
<% end %>
diff --git a/app/views/courses/join_course_multi_role.js.erb b/app/views/courses/join_course_multi_role.js.erb
new file mode 100644
index 000000000..97d6b33ce
--- /dev/null
+++ b/app/views/courses/join_course_multi_role.js.erb
@@ -0,0 +1,52 @@
+<% if @object_id && @state != 6 && @state !=4 %>
+$("#join_in_course_header").html("<%= escape_javascript(join_in_course_header(@course, @user)) %>");
+<% end %>
+<% if @state %>
+<% if @state == 0 %>
+alert("加入成功");
+hideModal();
+$("#try_join_course_link").replaceWith(" 'index',:course=>@course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品 ");
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% elsif @state == 1 %>
+alert("密码错误");
+<% elsif @state == 2 %>
+alert("班级已过期\n请联系班级管理员重启班级。(在配置班级处)");
+<% elsif @state == 3 %>
+alert("您已经加入了班级");
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% elsif @state == 4 %>
+alert("您加入的班级不存在");
+<% elsif @state == 5 %>
+alert("您还未登录");
+<% elsif @state == 6 %>
+alert("申请成功,请等待审核");
+hidden_join_course_form();
+<% elsif @state == 7%>
+alert("您已经发送过申请了,请耐心等待");
+hidden_join_course_form();
+<% elsif @state == 8%>
+alert("您已经是该班级的教师了");
+hidden_join_course_form();
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% elsif @state == 9%>
+alert("您已经是该班级的教辅了");
+hidden_join_course_form();
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% elsif @state == 10%>
+alert("您已经是该班级的管理员了");
+hidden_join_course_form();
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% elsif @state == 11%>
+alert("该班级已被删除");
+hidden_join_course_form();
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% elsif @state == 12 %>
+alert("您已经发送过申请了,请耐心等待");
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% elsif @state == 13 %>
+alert("申请成功,请等待审核");
+window.location.href= "<%= Setting.protocol%>://"+"<%= Setting.host_name%>"+"/courses/" + "<%= @course.id%>"
+<% else %>
+alert("未知错误,请稍后再试");
+<% end %>
+<% end %>
diff --git a/app/views/courses/join_private_courses.js.erb b/app/views/courses/join_private_courses.js.erb
index 199cfb5ae..14402a9ff 100644
--- a/app/views/courses/join_private_courses.js.erb
+++ b/app/views/courses/join_private_courses.js.erb
@@ -1,11 +1,2 @@
-$('#topnav_course_menu').hide();
-$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_private_course') %>');
-showModal('ajax-modal', '540px');
-$('#ajax-modal').css('height','390px');
-//$('#ajax-modal').siblings().remove();
-$('#ajax-modal').siblings().hide();
-$('#ajax-modal').before("" +
- " ");
-$('#ajax-modal').parent().removeClass("alert_praise");
-$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
-$('#ajax-modal').parent().addClass("alert_box");
+var htmlvalue = "<%= escape_javascript(render :partial => 'join_private_course') %>";
+pop_box_new(htmlvalue,460,40,50);
diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb
index fe6b3e596..f53c8c716 100644
--- a/app/views/courses/new.html.erb
+++ b/app/views/courses/new.html.erb
@@ -17,13 +17,13 @@
* <%= l(:label_tags_course_name)%> :
-
+
班级名称不能为空且至少有两个字符
* <%= l(:label_class_period)%> :
-
+
diff --git a/app/views/issues/_detail.html.erb b/app/views/issues/_detail.html.erb
index ec9a0bc54..ac912a71c 100644
--- a/app/views/issues/_detail.html.erb
+++ b/app/views/issues/_detail.html.erb
@@ -20,7 +20,7 @@
<%= get_issue_priority(@issue.priority_id)[1] %>
- 由<%= @issue.author %> 添加于 <%= format_time(@issue.created_on).html_safe %>
+ 由<%=link_to @issue.author, user_path(@issue.author), :class => "link-blue" %>添加于 <%= format_time(@issue.created_on).html_safe %>
diff --git a/app/views/layouts/_base_course_old.html.erb b/app/views/layouts/_base_course_old.html.erb
deleted file mode 100644
index 4b2077cf8..000000000
--- a/app/views/layouts/_base_course_old.html.erb
+++ /dev/null
@@ -1,278 +0,0 @@
-<%# course_model %>
-<% course_file_num = visable_attachemnts_incourse(@course).count%>
-<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) %>
-<% homework_num = visable_course_homework @course %>
-
-
-
-
-
-
- <%= h html_title %>
-
-
-
- <%= csrf_meta_tag %>
- <%= favicon %>
- <%= javascript_heads %>
- <%= heads_for_theme %>
- <%= call_hook :view_layouts_base_html_head %>
- <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup'%>
- <%= javascript_include_tag "course","sy_public", "syllabus","header","attachments",'prettify' %>
-
- <%= yield :header_tags -%>
-
-
-
-
-
-
-
-
-
-
-
- <% if User.current.logged? %>
- <%= render :partial => 'layouts/logined_header' %>
- <% else%>
- <%= render :partial => 'layouts/unlogin_header' %>
- <% end%>
-
-
-
-
-
-
- <%=render :partial=>'layouts/project_info' %>
-
-
-
-
- <%= l(:label_main_teacher)%> : <%= link_to(@course.teacher.lastname+@course.teacher.firstname, user_path(@course.teacher), :class => 'c_dblue') %>
- <%= l(:label_class_period)%> : <%= @course.class_period %> <%= l(:label_class_hour) %>
- <%= l(:label_main_term)%> : <%= current_time_and_term @course %>
- <% if @course.school%>
- <%= l(:label_course_organizers)%> : <%= @course.school%>
- <% end%>
-
-
-
- <%# 更新访问数,刷新的时候更新访问次数 %>
- <% update_visiti_count @course %>
- <%# over %>
-
-
- <% unless show_nav?(@course.course_activities.count) %>
-
- <%= link_to l(:label_activity), course_path(@course), :class => "f14 c_blue02" %>
-
- <%= link_to "(#{@course.course_activities.count})", course_path(@course), :class => "subnav_num c_orange"%>
-
- <% end %>
- <% unless show_nav?(@course.homework_commons.count) %>
-
- <%= link_to l(:label_homework), homework_common_index_path(:course => @course.id), :class => "f14 c_blue02"%>
- <%= link_to "(#{homework_num})", homework_common_index_path(:course => @course.id), :class => "subnav_num c_orange"%>
- <%= link_to( "", homework_common_index_path(:course => @course.id,:is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_homework_new)}") if is_teacher %>
-
- <% end %>
- <% unless show_nav?(@course.news.count) %>
-
- <%= link_to "通知", course_news_index_path(@course), :class => "f14 c_blue02" %>
- <%= link_to "(#{@course.news.count})", course_news_index_path(@course), :class => "subnav_num c_orange"%>
- <%= link_to( "", new_course_news_path(@course,:is_new=>1), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
-
- <% end %>
- <% unless show_nav?(course_file_num) %>
-
- <%= link_to l(:label_course_file), course_files_path(@course), :class => "f14 c_blue02" %>
- <%= link_to "(#{course_file_num})", course_files_path(@course), :class => "subnav_num c_orange",:id=>'courses_files_count_nav' %>
- <% if is_teacher || (@course.publish_resource == 1 && User.current.member_of_course?(@course)) %>
-
-
- <% end %>
-
- <% end %>
- <% unless show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
-
- <%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>
- <%= link_to "(#{@course.boards.first ? (@course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", @course.boards.first.id, nil).count) : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
- <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") %>
-
- <% end %>
- <% unless show_nav?(course_feedback_count) %>
-
- <%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02" %>
- <%= link_to "(#{course_feedback_count})", course_feedback_path(@course), :class => "subnav_num c_orange", :id => "course_jour_count"%>
- <%= link_to "", course_feedback_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_feedback)}", :id => "course_jour_count"%>
-
- <% end %>
- <% unless show_nav?(course_poll_count) %>
-
- <%= link_to l(:label_poll), poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => " f14 c_blue02"%>
- <%= link_to "(#{course_poll_count})", poll_index_path(:polls_type => "Course", :polls_group_id => @course.id), :class => "subnav_num c_orange" %>
- <%= link_to( "", new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => 'courseMenuSetting', :title =>"#{l(:label_new_poll)}") if is_teacher %>
-
- <% end %>
- <% unless show_nav?(User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status <> 1").count) %>
-
- <%= link_to "在线测验", exercise_index_path(:course_id => @course.id), :class => " f14 c_blue02"%>
- <%= link_to "(#{User.current.allowed_to?(:as_teacher,@course)? @course.exercises.count : @course.exercises.where("exercise_status <> 1").count})", exercise_index_path(:course_id => @course.id), :class => "subnav_num c_orange" %>
- <%= link_to( "", new_exercise_path(:course_id => @course.id), :class => 'courseMenuSetting', :title =>"新建试卷") if is_teacher %>
-
- <% end %>
- <%# 工具栏展开 %>
- <% if @course.homework_commons.count == 0 || @course.news.count == 0 || course_file_num == 0 || course_poll_count == 0 || @course.exercises.count == 0 ||
- course_feedback_count == 0 || @course.exercises.count == 0 || (@course.boards.first ? @course.boards.first.topics.count : 0) == 0 %>
-
-
<%= l(:label_project_more) %>
-
- <%= render 'courses/tool_expand', :locals => {:is_teacher => is_teacher, :course_file_num => course_file_num} %>
-
- <% end %>
-
- <%# 课程活跃度 %>
-
- <%= render :partial => 'courses/course_activity_users', :locals => {:course => @course} %>
- <%# 课程英雄榜 %>
- <%= render :partial => 'courses/course_heroes', :locals => {:course => @course} %>
-
- <% if @course.description && !@course.description.blank? %>
-
-
-
<%= l(:label_course_brief_introduction)%>:
-
- <%= textilizable(@course.description) if @course.description && !@course.description.blank? %>
-
-
-
-
- <% end %>
-
-
<%= l(:label_tag)%>:
-
- <%= render :partial => 'tags/new_tag', :locals => {:obj => @course, :object_flag => "9"} %>
-
-
-
-
- <%= render :partial => 'courses/recommendation', :locals => {:course => @course} %>
-
访问计数 <%= @course.visits.to_i %> (自2016年5月)
-
-
-
- <%= yield %>
- <%#= render_flash_messages %>
- <%#= call_hook :view_layouts_base_content %>
-
-
-
-
-
-
-
-
-<%= render :partial => 'layouts/footer' %>
-
-
-<%= render :partial => 'layouts/new_feedback' %>
-
- <%= l(:label_loading) %>
-
-
-<%= call_hook :view_layouts_base_body_bottom %>
-
-
-
-
\ No newline at end of file
diff --git a/app/views/layouts/_base_syllabus_old.html.erb b/app/views/layouts/_base_syllabus_old.html.erb
deleted file mode 100644
index 45e77dbad..000000000
--- a/app/views/layouts/_base_syllabus_old.html.erb
+++ /dev/null
@@ -1,151 +0,0 @@
-
-
-
-
- <%= h html_title %>
-
-
- <%= csrf_meta_tag %>
- <%= favicon %>
- <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'syllabus','css/common','css/public','css/structure','css/courses','css/popup','prettify',:media => 'all' %>
- <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
- <%= javascript_heads %>
- <%= javascript_include_tag "bootstrap","avatars","course",'attachments','prettify','syllabus'%>
- <%= heads_for_theme %>
- <%= call_hook :view_layouts_base_html_head %>
- <%= yield :header_tags -%>
-
-
-
-
-
-
-
-<% is_current_user = User.current.logged?%>
-
- <% if User.current.logged? %>
- <%= render :partial => 'layouts/logined_header' %>
- <% else%>
- <%= render :partial => 'layouts/unlogin_header' %>
- <% end%>
-
-
-
-
-
-
- <%=render :partial => 'layouts/syllabus_info' %>
-
- <% update_visiti_count @syllabus %>
-
-
-
-
-
-
-
标签:
-
- <%= render :partial => 'tags/syllabus_tag', :locals => {:obj => @syllabus,:object_flag => "11"}%>
-
-
-
-
访问计数 <%=@syllabus.visits %> (自2016年7月)
-
-
-
-
- <%= render :partial => 'layouts/new_feedback' %>
-
-
-<%= render :partial => 'layouts/footer' %>
-
-
-
-
- <%= l(:label_loading) %>
-
-
-
-
diff --git a/app/views/layouts/_course_base_info.html.erb b/app/views/layouts/_course_base_info.html.erb
index 546b27421..1c01ecf53 100644
--- a/app/views/layouts/_course_base_info.html.erb
+++ b/app/views/layouts/_course_base_info.html.erb
@@ -11,16 +11,13 @@
<% if is_teacher %>
-
+
-
-
- <%= link_to "班级配置", {:controller => 'courses', :action => 'settings', :id => @course}, :class => "postOptionLink" %>
- <%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "postOptionLink" %>
- <%= link_to "复制学期", copy_course_course_path(@course.id),:remote=>true, :class => "postOptionLink" %>
- <% if @course.syllabus %>
- <%= link_to "进入课程", syllabus_path(@course.syllabus), :class => "postOptionLink", :target => "_blank" %>
- <% end %>
+
+
+ <%= link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => 'courses', :action => 'private_or_public', :id => @course},:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗", :class => "sy_class_option" %>
+ <%= link_to "复制班级", copy_course_course_path(@course.id),:remote=>true, :class => "sy_class_option" %>
+ <%= link_to "进入课程", syllabus_path(@course.syllabus), :class => "sy_class_option", :target => "_blank" %>
@@ -45,7 +42,7 @@
<%=@course.name %>
-
<%=@course.is_public == 0 ? '私有' : '公开' %>
+
教师:<%= course_teacher_link teacher_num %>
学生:<%= course_student_link student_num %>
@@ -59,8 +56,18 @@
学期:<%= current_time_and_term @course %>
单位:<%= get_occupation_from_user(@course.teacher).blank? ? '无' : get_occupation_from_user(@course.teacher) %>
-
- <% unless is_teacher %>
+ <% if is_teacher %>
+ <%= link_to "班级设置", {:controller => 'courses', :action => 'settings', :id => @course}, :class => "sy_btn_grey mr10 fl" %>
+ <% end %>
+ <% is_TA = get_user_member_roles_course @course, User.current, 7 %>
+ <% is_TE = get_user_member_roles_course @course, User.current, 9 %>
+ <% is_ST = get_user_member_roles_course @course, User.current, 10 %>
+ <% if !is_teacher && (is_TA || is_TE) %>
+ <%= link_to '教师身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => 10, :tar_role => (is_TA ? 7 : 9)), :class => "sy_btn_orange mr10 fl", :title => "由学生身份切换至教师身份" %>
+ <% elsif is_teacher && is_ST %>
+ <%= link_to '学生身份', switch_role_course_path(@course, :user_id => User.current.id, :curr_role => (is_TA ? 7 : 9), :tar_role => 10), :class => "sy_btn_orange mr10 fl", :title => "由教师身份切换至学生身份" %>
+ <% end %>
+ <% unless (is_teacher || is_TA || is_TE) %>
<% end %>
diff --git a/app/views/layouts/_join_exit_project.html.erb b/app/views/layouts/_join_exit_project.html.erb
index 35d8f87ef..7d2f1b4d2 100644
--- a/app/views/layouts/_join_exit_project.html.erb
+++ b/app/views/layouts/_join_exit_project.html.erb
@@ -1,12 +1,8 @@
- <% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %>
-
<%= watcher_link_for_project(@project, User.current) %>
- <% end %>
-
- <% if !User.current.member_of?(@project) && User.current.login? && !User.current.admin %>
- <%= join_in_project_link(@project, User.current) %>
- <% end %>
+
+ <%= render :partial => "projects/applied_status" %>
+
<% if User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) %>
<%= link_to "
#{l(:button_configure)}".html_safe, settings_project_path(@project), :class => "pr_join_a" %>
diff --git a/app/views/layouts/base_admin.html.erb b/app/views/layouts/base_admin.html.erb
index 81cc2df9d..7f62da514 100644
--- a/app/views/layouts/base_admin.html.erb
+++ b/app/views/layouts/base_admin.html.erb
@@ -62,3 +62,10 @@
<%= call_hook :view_layouts_base_body_bottom %>