ouyangxuhua v20160318_06
linchun 10 years ago
commit 6284b8d4f9

@ -17,7 +17,7 @@ gem 'daemons'
gem 'grape', '~> 0.9.0' gem 'grape', '~> 0.9.0'
gem 'grape-entity' gem 'grape-entity'
gem 'seems_rateable', '~> 1.0.13' gem 'seems_rateable', '~> 1.0.13'
gem "rails", "3.2.13" gem "rails", "~> 3.2.13"
gem "jquery-rails", "~> 2.0.2" gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0" gem "i18n", "~> 0.6.0"
gem 'coderay', '~> 1.1.0' gem 'coderay', '~> 1.1.0'

@ -40,12 +40,16 @@ class AdminController < ApplicationController
@projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all @projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all
=end =end
@projects = Project.like(@name).order('created_on desc') @projects = Project.like(@name).order('created_on desc')
@projects = paginateHelper @projects,30
@page = (params['page'] || 1).to_i - 1
render :action => "projects", :layout => false if request.xhr? render :action => "projects", :layout => false if request.xhr?
end end
def courses def courses
@name = params[:name] @name = params[:name]
@courses = Course.like(@name).order('created_at desc') @courses = Course.like(@name).order('created_at desc')
@courses = paginateHelper @courses,30
@page = (params['page'] || 1).to_i - 1
respond_to do |format| respond_to do |format|
format.html format.html
end end

@ -8,6 +8,15 @@ class AtController < ApplicationController
users = find_at_users(params[:type], params[:id]) users = find_at_users(params[:type], params[:id])
@users = users @users = users
@users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users @users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id }.sort{|x,y| to_pinyin(x.show_name) <=> to_pinyin(y.show_name)} if users
#加上all
if @users.size > 0
allUser = Struct.new(:id, :name).new
allUser.id = @users.map{|u| u.id}.join(",")
allUser.name = "all"
@users.insert(0, allUser)
end
@users
end end
private private

@ -103,6 +103,9 @@ class AttachmentsController < ApplicationController
direct_download_history direct_download_history
end end
else else
# 记录用户行为
record_user_actions(params[:id])
# 直接下载历史版本
direct_download_history direct_download_history
end end
end end
@ -113,6 +116,14 @@ class AttachmentsController < ApplicationController
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html" redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
end end
def record_user_actions id
if params[:action] == "download_history"
UserActions.create(:action_id => id, :action_type => "AttachmentHistory", :user_id => User.current.id) unless id.nil?
elsif params[:action] == "download"
UserActions.create(:action_id => id, :action_type => "Attachment", :user_id => User.current.id) unless id.nil?
end
end
def download def download
# modify by nwb # modify by nwb
# 下载添加权限设置 # 下载添加权限设置
@ -135,6 +146,8 @@ class AttachmentsController < ApplicationController
direct_download direct_download
end end
else else
# 记录用户行为
record_user_actions(params[:id])
direct_download direct_download
end end
end end
@ -572,6 +585,15 @@ class AttachmentsController < ApplicationController
end end
end end
#找到文件的所有的历史版本及当前版本
def attachment_history_download
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
respond_to do |format|
format.js
end
end
private private
def find_project def find_project
@attachment = Attachment.find(params[:id]) @attachment = Attachment.find(params[:id])

@ -91,8 +91,12 @@ class BlogCommentsController < ApplicationController
def edit def edit
@article = BlogComment.find(params[:id]) @article = BlogComment.find(params[:id])
respond_to do |format| if User.current.admin? || User.current.id == @article.author_id
format.html {render :layout=>'new_base_user'} respond_to do |format|
format.html { render :layout => 'new_base_user' }
end
else
render_403
end end
end end

@ -7,6 +7,7 @@ class CoursesController < ApplicationController
helper :members helper :members
helper :words helper :words
helper :attachments helper :attachments
helper :files
helper :activity_notifys helper :activity_notifys
before_filter :auth_login1, :only => [:show, :course_activity, :feedback] before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
@ -902,10 +903,7 @@ class CoursesController < ApplicationController
end end
def feedback def feedback
@course.journals_for_messages.each do |messages| CourseMessage.where("user_id = ? and course_id = ?", User.current, @course.id).update_all(:viewed => true)
query = messages.course_messages.where("user_id = ?", User.current.id)
query.update_all(:viewed => true);
end
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course))) if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
page = params[:page] page = params[:page]

@ -207,8 +207,7 @@ class FilesController < ApplicationController
sort = "created_on DESC" sort = "created_on DESC"
end end
if keywords != "%%" if keywords != "%%"
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%"). resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
reorder(sort)
else else
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort) resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
end end
@ -854,9 +853,7 @@ class FilesController < ApplicationController
@result = visable_attachemnts @result @result = visable_attachemnts @result
if params[:other] if params[:other]
@result = @result.select{|attachment| @result = @result.select{|attachment|
attachment.tag_list.exclude?('软件') && attachment.tag_list.index{|tag|tag != '软件' and tag != '媒体' and tag != '代码'}.present?
attachment.tag_list.exclude?('媒体') &&
attachment.tag_list.exclude?('代码')
} }
else else
@result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank? @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?

@ -17,9 +17,9 @@ class HomeworkCommonController < ApplicationController
@page = params[:page] ? params[:page].to_i + 1 : 0 @page = params[:page] ? params[:page].to_i + 1 : 0
@is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course))
if @is_teacher if @is_teacher
@homeworks = @course.homework_commons.order("updated_at desc").limit(10).offset(@page * 10) @homeworks = @course.homework_commons.order("created_at desc").limit(10).offset(@page * 10)
else else
@homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("updated_at desc").limit(10).offset(@page * 10) @homeworks = @course.homework_commons.where("publish_time <= '#{Date.today}'").order("created_at desc").limit(10).offset(@page * 10)
end end
@is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher))
@is_new = params[:is_new] @is_new = params[:is_new]
@ -51,8 +51,14 @@ class HomeworkCommonController < ApplicationController
@user = User.current @user = User.current
@is_in_course = params[:is_in_course].to_i @is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i @course_activity = params[:course_activity].to_i
respond_to do |format| if @is_in_course == 1 || @course_activity == 1
format.html{render :layout => 'new_base_user'} respond_to do |format|
format.html{render :layout => 'base_courses'}
end
else
respond_to do |format|
format.html{render :layout => 'new_base_user'}
end
end end
end end
@ -73,9 +79,11 @@ class HomeworkCommonController < ApplicationController
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0 if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1 homework_detail_manual.comment_status = 1
end end
homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start] eval_start = homework_detail_manual.evaluation_start
homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end] if eval_start <= @homework.end_time && homework_detail_manual.comment_status <= 1
homework_detail_manual.evaluation_start = @homework.end_time + 7
homework_detail_manual.evaluation_end = homework_detail_manual.evaluation_start + 7
end
@homework.save_attachments(params[:attachments]) @homework.save_attachments(params[:attachments])
render_attachment_warning_if_needed(@homework) render_attachment_warning_if_needed(@homework)

@ -118,6 +118,9 @@ class IssuesController < ApplicationController
end end
def show def show
# 打开编辑内容
@is_edit = true unless params[:edit].nil?
# 当前用户查看指派给他的缺陷消息,则设置消息为已读 # 当前用户查看指派给他的缺陷消息,则设置消息为已读
query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first
query.update_attribute(:viewed, true) unless query.nil? query.update_attribute(:viewed, true) unless query.nil?
@ -387,6 +390,9 @@ class IssuesController < ApplicationController
end end
def destroy def destroy
# 增加删除页面类型,如果是个人主页,则返回该主页,项目动态则返回项目动态页眉
page_classify = params[:page_classify] unless params[:page_classify].nil?
page_id = params[:page_id] unless params[:page_id].nil?
@hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f @hours = TimeEntry.sum(:hours, :conditions => ['issue_id IN (?)', @issues]).to_f
if @hours > 0 if @hours > 0
case params[:todo] case params[:todo]
@ -415,7 +421,11 @@ class IssuesController < ApplicationController
end end
end end
respond_to do |format| respond_to do |format|
format.html { redirect_back_or_default _project_issues_path(@project) } if page_classify
format.html { redirect_back_or_default _project_issues_path(@project, page_classify, page_id) }
else
format.html { redirect_back_or_default _project_issues_path(@project) }
end
format.api { render_api_ok } format.api { render_api_ok }
end end
end end

@ -1,6 +1,6 @@
class OrgDocumentCommentsController < ApplicationController class OrgDocumentCommentsController < ApplicationController
before_filter :find_organization, :only => [:new, :create, :show, :index] before_filter :find_organization, :only => [:new, :create, :show, :index]
helper :attachments helper :attachments,:organizations
layout 'base_org' layout 'base_org'
def new def new

@ -5,9 +5,8 @@ class OrgSubfieldsController < ApplicationController
def create def create
if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0 if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0
@res = true @res = true
@subfield = OrgSubfield.create(:name => params[:name])
@organization = Organization.find(params[:organization_id]) @organization = Organization.find(params[:organization_id])
@organization.org_subfields << @subfield @subfield = OrgSubfield.create(:name => params[:name], :organization_id => params[:organization_id],:priority => @organization.org_subfields.order("priority").last.priority + 1)
if !params[:sub_dir].blank? if !params[:sub_dir].blank?
sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+
"and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
@ -15,7 +14,7 @@ class OrgSubfieldsController < ApplicationController
SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir]) SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir])
end end
end end
@subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type]) @subfield.update_attributes(:field_type => params[:field_type])
else else
@res = false @res = false
end end
@ -125,6 +124,12 @@ class OrgSubfieldsController < ApplicationController
end end
end end
def update_priority
@org_subfield = OrgSubfield.find(params[:id])
@org_subfield.update_attribute(:priority, params[:priority].to_i)
@organization = @org_subfield.organization
end
def show_attachments obj def show_attachments obj
@attachments = [] @attachments = []
obj.each do |container| obj.each do |container|

@ -317,7 +317,7 @@ class OrganizationsController < ApplicationController
@organization = Organization.find(params[:id]) @organization = Organization.find(params[:id])
admins = User.where("admin=1") admins = User.where("admin=1")
admins.each do |admin| admins.each do |admin|
OrgMessage.create(:user_id => admin.id, :organization_id => @organization.id, :message_type => 'ApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:domain]) OrgMessage.create(:user_id => admin.id, :organization_id => @organization.id, :message_type => 'ApplySubdomain', :message_id => @organization.id, :sender_id => User.current.id, :viewed => 0, :content => params[:domain].downcase)
end end
end end

@ -300,66 +300,27 @@ class ProjectsController < ApplicationController
end end
# 统计访问量 # 统计访问量
@project.update_attribute(:visits, @project.visits.to_i + 1) @project.update_attribute(:visits, @project.visits.to_i + 1)
=begin
cond = @project.project_condition(Setting.display_subprojects_issues?)
has = {
"show_issues" => true ,
"show_files" => true,
"show_documents" => true,
"show_messages" => true,
"show_news" => true,
"show_bids" => true,
"show_contests" => true,
"show_wiki_edits"=>true,
"show_journals_for_messages" => true
}
# 读取项目默认展示的动态时间天数
@days = Setting.activity_days_default.to_i
@date_to ||= Date.today + 1
# 时间跨度不能太大,不然很慢,所以删掉了-1.years
@date_from = @date_to - @days
@with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1')
=end
@author = params[:user_id].blank? ? nil : User.active.find(params[:user_id]) @author = params[:user_id].blank? ? nil : User.active.find(params[:user_id])
# 决定显示所用用户或单个用户活动
=begin
@activity = Redmine::Activity::Fetcher.new(User.current,
:project => @project,
:with_subprojects => @with_subprojects,
:author => @author)
@activity.scope_select {|t| !has["show_#{t}"].nil?}
=end
@page = params[:page] ? params[:page].to_i + 1 : 0 @page = params[:page] ? params[:page].to_i + 1 : 0
# 根据私密性,取出符合条件的所有数据 # 根据私密性,取出符合条件的所有数据
if User.current.member_of?(@project) || User.current.admin? if User.current.member_of?(@project) || User.current.admin?
case params[:type] case params[:type]
when nil when nil
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo')",@project).order("updated_at desc").limit(10).offset(@page * 10) @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo', 'Attachment')",@project).order("updated_at desc").limit(10).offset(@page * 10)
when 'issue' when 'issue'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10) @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10)
when 'news' when 'news'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10) @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10)
when 'message' when 'message'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page * 10) @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page * 10)
when 'attachment'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Attachment'",@project).order("updated_at desc").limit(10).offset(@page * 10)
end end
#events = @activity.events(@date_from, @date_to)
else else
@events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public
= ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc") = ? and forge_act_type != ? ",@project,1, "Document").order("created_at desc")
.page(params['page'|| 1]).per(10); .page(params['page'|| 1]).per(10);
# @events = @activity.events(@date_from, @date_to, :is_public => 1)
end end
=begin
@events_pages = Paginator.new events.count, 10, params['page']
# 总的数据中取出某一页
events = events.slice(@events_pages.offset,10)
# 按天分组
@events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)}
=end
boards = @project.boards.includes(:last_message => :author).all boards = @project.boards.includes(:last_message => :author).all
@topic_count = @project.boards.count @topic_count = @project.boards.count
# 根据对应的请求,返回对应的数据 # 根据对应的请求,返回对应的数据

@ -1,3 +1,4 @@
#encoding: utf-8
class StudentWorkController < ApplicationController class StudentWorkController < ApplicationController
layout "base_courses" layout "base_courses"
include StudentWorkHelper include StudentWorkHelper
@ -282,7 +283,7 @@ class StudentWorkController < ApplicationController
@submit_result = true @submit_result = true
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id] student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
student_work ||= StudentWork.new student_work ||= StudentWork.new
student_work.name = params[:student_work][:name] student_work.name = params[:student_work][:name] == "#{@homework.name}的作品提交(可修改)" ? "#{@homework.name}的作品提交" : params[:student_work][:name]
student_work.description = params[:student_work][:description] student_work.description = params[:student_work][:description]
student_work.homework_common_id = @homework.id student_work.homework_common_id = @homework.id
student_work.user_id = User.current.id student_work.user_id = User.current.id

@ -110,8 +110,7 @@ class UsersController < ApplicationController
elsif @user != User.current && !User.current.admin? elsif @user != User.current && !User.current.admin?
return render_403 return render_403
end end
# 初始化/更新 点击按钮时间 # 初始化/更新 点击按钮时间, 24小时内显示系统消息
# 24小时内显示系统消息
update_onclick_time update_onclick_time
# 全部设为已读 # 全部设为已读
if params[:viewed] == "all" if params[:viewed] == "all"
@ -190,17 +189,19 @@ class UsersController < ApplicationController
# 消息设置为已读 # 消息设置为已读
def update_message_viewed(user) def update_message_viewed(user)
course_querys = CourseMessage.where("user_id =? and viewed =?", user, 0)
forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0)
user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0)
forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0)
org_querys = OrgMessage.where("user_id=? and viewed=0", user)
if User.current.id == @user.id if User.current.id == @user.id
course_querys.update_all(:viewed => true) course_querys = CourseMessage.where("user_id =? and viewed =?", user, 0)
forge_querys.update_all(:viewed => true) forge_querys = ForgeMessage.where("user_id =? and viewed =?", user, 0)
user_querys.update_all(:viewed => true) user_querys = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0)
forum_querys.update_all(:viewed => true) forum_querys = MemoMessage.where("user_id =? and viewed =?", user, 0)
org_querys.update_all(:viewed => true) org_querys = OrgMessage.where("user_id=? and viewed=0", user)
at_querys = AtMessage.where("user_id=? and viewed=0", user)
course_querys.update_all(:viewed => true) unless course_querys.nil?
forge_querys.update_all(:viewed => true) unless forge_querys.nil?
user_querys.update_all(:viewed => true) unless user_querys.nil?
forum_querys.update_all(:viewed => true) unless forum_querys.nil?
org_querys.update_all(:viewed => true) unless org_querys.nil?
at_querys.update_all(:viewed => true) unless at_querys.nil?
end end
end end
@ -387,12 +388,12 @@ class UsersController < ApplicationController
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}") @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
end end
@type = params[:type] @type = params[:type]
@limit = 15 @limit = 25
@is_remote = true @is_remote = true
@hw_count = @homeworks.count @hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset @offset ||= @hw_pages.offset
@homeworks = paginateHelper @homeworks,15 @homeworks = paginateHelper @homeworks,25
respond_to do |format| respond_to do |format|
format.js format.js
format.html {render :layout => 'static_base'} format.html {render :layout => 'static_base'}
@ -546,13 +547,13 @@ class UsersController < ApplicationController
end end
@type = params[:type] @type = params[:type]
@property = params[:property] @property = params[:property]
@limit = 15 @is_import = params[:is_import]
@limit = params[:is_import].to_i == 1 ? 15 : 25
@is_remote = true @is_remote = true
@hw_count = @homeworks.count @hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset @offset ||= @hw_pages.offset
@homeworks = paginateHelper @homeworks,15 @homeworks = paginateHelper @homeworks,@limit
@is_import = params[:is_import]
respond_to do |format| respond_to do |format|
format.js format.js
end end
@ -572,31 +573,48 @@ class UsersController < ApplicationController
@r_sort = @b_sort == "desc" ? "asc" : "desc" @r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current @user = User.current
search = params[:name].to_s.strip.downcase search = params[:name].to_s.strip.downcase
if(params[:type].blank? || params[:type] == "1") #全部 type_ids = params[:property]=="" || params[:property].nil? ? "(1, 2, 3)" : "(" + params[:property] + ")"
if(params[:type].blank? || params[:type] == "1") #全部
visible_course = Course.where("is_public = 1 && is_delete = 0") visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")" visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'") all_homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'")
all_user_ids = all_homeworks.map{|hw| hw.user_id} all_user_ids = all_homeworks.map{|hw| hw.user_id}
user_str_ids = search_user_by_name all_user_ids, search user_str_ids = search_user_by_name all_user_ids, search
user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")" user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}") if @order == "course_name"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_type in #{type_ids} and course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%' or homework_commons.user_id in #{user_ids}) order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks = HomeworkCommon.find_by_sql(sql)
elsif @order == "user_name"
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
else
@homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and homework_type in #{type_ids} and (name like '%#{search}%' or user_id in #{user_ids})").order("#{@order} #{@b_sort}")
end
elsif params[:type] == "2" #课程资源 elsif params[:type] == "2" #课程资源
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("#{@order} #{@b_sort}") if @order == "course_name"
sql = "SELECT homework_commons.* FROM homework_commons INNER JOIN courses ON homework_commons.course_id = courses.id where homework_commons.user_id = #{@user.id} and homework_type in #{type_ids} and publish_time <= '#{Date.today}' and (homework_commons.name like '%#{search}%') order by CONVERT (courses.name USING gbk) COLLATE gbk_chinese_ci #{@b_sort}"
@homeworks = HomeworkCommon.find_by_sql(sql)
elsif @order == "user_name"
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").joins(:user).order("CONVERT (lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, CONVERT (firstname USING gbk) COLLATE gbk_chinese_ci #{@b_sort},login #{@b_sort}")
else
@homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%') and homework_type in #{type_ids}").order("#{@order} #{@b_sort}")
end
end end
=begin
if params[:property] && params[:property] == "1" if params[:property] && params[:property] == "1"
@homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}") @homeworks = @homeworks.where("homework_type = 1")
elsif params[:property] && params[:property] == "2" elsif params[:property] && params[:property] == "2"
@homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}") @homeworks = @homeworks.where("homework_type = 2")
elsif params[:property] && params[:property] == "3" elsif params[:property] && params[:property] == "3"
@homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}") @homeworks = @homeworks.where("homework_type = 3")
end end
=end
@type = params[:type] @type = params[:type]
@limit = 15 @limit = params[:is_import].to_i == 1 ? 15 : 25
@is_remote = true @is_remote = true
@hw_count = @homeworks.count @hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1 @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset @offset ||= @hw_pages.offset
@homeworks = paginateHelper @homeworks,15 @homeworks = paginateHelper @homeworks,@limit
@is_import = params[:is_import] @is_import = params[:is_import]
@property = params[:property] @property = params[:property]
@search = search @search = search
@ -823,20 +841,33 @@ class UsersController < ApplicationController
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") #全部 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) if params[:status] == "2"
elsif params[:type] == "2" # 课程资源 @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
@attachments = get_course_resources(params[:id], user_course_ids) elsif params[:status] == "3"
elsif params[:type] == "3" # 项目资源 @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
@attachments = get_project_resources(params[:id], user_project_ids) elsif params[:status] == "4"
elsif params[:type] == "4" #附件 @attachments = get_attch_resources(params[:id], @order, @score)
@attachments = get_attch_resources params[:id] elsif params[:status] == "5"
elsif params[:type] == "5" #用户资源 @attachments = get_principal_resources(params[:id], @order, @score)
@attachments = get_principal_resources params[:id] else
# 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
end
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
# 公共资源库:所有公开资源或者我上传的私有资源 if params[:status] == "2"
@attachments = get_public_resources(user_course_ids, user_project_ids) @attachments = get_course_resources_public( user_course_ids, @order, @score)
elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids, @order, @score)
elsif params[:status] == "4"
@attachments = get_attch_resources_public(@order, @score)
elsif params[:status] == "5"
@attachments = get_principal_resources_public(@order, @score)
else
# 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end
end end
@type = params[:type] @type = params[:type]
@limit = 7 @limit = 7
@ -946,12 +977,7 @@ class UsersController < ApplicationController
return return
end end
# 自己访问自己的页面才更新消息状态 # 自己访问自己的页面才更新消息状态
if User.current == @user UserFeedbackMessage.where("user_id =? and viewed =? and journals_for_message_type =? ", User.current.id, 0, "JournalsForMessage").update_all(:viewed => true)
journals_messages = UserFeedbackMessage.where("user_id =? and journals_for_message_type =? and viewed =?", User.current.id, "JournalsForMessage", 0)
journals_messages.each do |journals_message|
journals_message.update_attributes(:viewed => true)
end
end
# end # end
@page = params[:page] ? params[:page].to_i + 1 : 0 @page = params[:page] ? params[:page].to_i + 1 : 0
if params[:type].present? if params[:type].present?
@ -1553,43 +1579,39 @@ class UsersController < ApplicationController
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
@user = User.find(params[:id]) @user = User.find(params[:id])
#@user.save_attachments(params[:attachments],User.current) # 保存文件
# Container_type为Principal
attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true) attach = Attachment.attach_filesex_public(@user, params[:attachments], params[:attachment_type], is_public = true)
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == 2 if params[:status] == "2"
@attachments = get_course_resources(params[:id], user_course_ids) @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources(params[:id], user_project_ids) @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources params[:id] @attachments = get_attch_resources(params[:id], @order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources params[:id] @attachments = get_principal_resources(params[:id], @order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
end end
elsif params[:type] == "2" # 课程资源
@attachments = get_course_resources(params[:id], user_course_ids)
elsif params[:type] == "3" # 项目资源
@attachments = get_project_resources(params[:id], user_project_ids)
elsif params[:type] == "4" #附件
@attachments = get_attch_resources params[:id]
elsif params[:type] == "5" #用户资源
@attachments = get_principal_resources params[:id]
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
if params[:status] == "2" if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids) @attachments = get_course_resources_public( user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids) @attachments = get_project_resources_public(user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources_public @attachments = get_attch_resources_public(@order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources_public @attachments = get_principal_resources_public(@order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids) @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end end
end end
@status = params[:status] @status = params[:status]
@ -1609,49 +1631,44 @@ class UsersController < ApplicationController
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源 # 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
def user_resource_delete def user_resource_delete
if params[:resource_id].present? if params[:resource_id].present?
Attachment.where("author_id = #{User.current.id}").delete(params[:resource_id]) Attachment.where("author_id =? and id =?", User.current.id, params[:resource_id]).first.destroy
elsif params[:checkbox1].present? elsif params[:checkbox1].present?
params[:checkbox1].each do |id| params[:checkbox1].each do |id|
Attachment.where("author_id = #{User.current.id}").delete(id) Attachment.where("author_id =? and id =?", User.current.id, id).first.destroy
end end
end end
@user = User.current
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == 2 if params[:status] == "2"
@attachments = get_course_resources(params[:id], user_course_ids) @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources(params[:id], user_project_ids) @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources params[:id] @attachments = get_attch_resources(params[:id], @order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources params[:id] @attachments = get_principal_resources(params[:id], @order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
end end
elsif params[:type] == "2" # 课程资源
@attachments = get_course_resources(params[:id], user_course_ids)
elsif params[:type] == "3" # 项目资源
@attachments = get_project_resources(params[:id], user_project_ids)
elsif params[:type] == "4" #附件
@attachments = get_attch_resources params[:id]
elsif params[:type] == "5" #用户资源
@attachments = get_principal_resources params[:id]
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
if params[:status] == "2" if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids) @attachments = get_course_resources_public( user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids) @attachments = get_project_resources_public(user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources_public @attachments = get_attch_resources_public(@order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources_public @attachments = get_principal_resources_public(@order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids) @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end end
end end
@status = params[:status] @status = params[:status]
@ -1674,10 +1691,10 @@ class UsersController < ApplicationController
if !params[:search].nil? if !params[:search].nil?
search = "%#{params[:search].to_s.strip.downcase}%" search = "%#{params[:search].to_s.strip.downcase}%"
@course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search) @course = @user.courses.where(" #{Course.table_name}.id = #{params[:search].to_i } or #{Course.table_name}.name like :p",:p=>search)
.select { |course| @user.allowed_to?(:as_teacher,course)} .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 }
else else
@course = @user.courses @course = @user.courses
.select { |course| @user.allowed_to?(:as_teacher,course)} .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 }
end end
@search = params[:search] @search = params[:search]
#这里仅仅是传递需要发送的资源id #这里仅仅是传递需要发送的资源id
@ -1695,7 +1712,7 @@ class UsersController < ApplicationController
search = "%#{params[:search].to_s.strip.downcase}%" search = "%#{params[:search].to_s.strip.downcase}%"
@projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search) @projects = @user.projects.where(" #{Project.table_name}.id = #{params[:search].to_i } or #{Project.table_name}.name like :p",:p=>search)
else else
@projects = @user.projects @projects = @user.projects.visible
end end
@search = params[:search] @search = params[:search]
#这里仅仅是传递需要发送的资源id #这里仅仅是传递需要发送的资源id
@ -2339,59 +2356,125 @@ class UsersController < ApplicationController
end end
# 获取公共资源 # 获取公共资源
def get_public_resources user_course_ids, user_project_ids def get_public_resources user_course_ids, user_project_ids, order, score
attachments = Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("created_on desc") attachments = Attachment.where("(is_publish = 1 and is_public =1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course')) ").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源搜索
def get_public_resources_search user_course_ids, user_project_ids, order, score, search
attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的资源 # 获取我的资源
def get_my_resources author_id, user_course_ids, user_project_ids def get_my_resources author_id, user_course_ids, user_project_ids, order, score
attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ attachments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + "or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("created_on desc") "or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的资源查询结果
def get_my_resources_search (author_id, user_course_ids, user_project_ids, order, score, search)
@attachments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的课程资源 # 获取我的课程资源
def get_course_resources author_id, user_course_ids def get_course_resources author_id, user_course_ids, order, score
attchments = Attachment.where("(author_id = #{author_id} and container_type = 'Course' and is_publish = 1) or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1) ").order("created_on desc") attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
and is_publish = 1 and container_id is not null)" ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的课程资源中搜索结果
def get_course_resources_search author_id, user_course_ids, order, score, search
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Course')"+
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取公共资源课程 # 获取公共资源中课程资源
def get_course_resources_public user_course_ids def get_course_resources_public user_course_ids, order, score
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("created_on desc") attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1)").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源中课程资源搜索结果
def get_course_resources_public_search user_course_ids, order, score, search
attchments = Attachment.where("(container_type = 'Course'and container_id is not null and is_publish = 1 and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的项目资源 # 获取我的项目资源
def get_project_resources author_id, user_project_ids def get_project_resources author_id, user_project_ids, order, score
attchments = Attachment.where("(author_id = #{author_id} and container_type = 'Project') or (container_type = 'Course' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1) ").order("created_on desc") attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
and is_publish = 1 and container_id is not null)").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的项目资源搜索
def get_project_resources_search author_id, user_project_ids, order, score, search
attchments = Attachment.where("((author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Project') "+
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')})
and is_publish = 1 and container_id is not null)) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取公共资源的项目资源 # 获取公共资源的项目资源
def get_project_resources_public user_project_ids def get_project_resources_public user_project_ids, order, score
attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("created_on desc") attchments = Attachment.where("container_type = 'Project' and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源的项目资源搜索
def get_project_resources_public_search user_project_ids, order, score, search
attchments = Attachment.where("(container_type = 'Project' and container_id is not null and is_public =1) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我上传的附件 # 获取我上传的附件
def get_attch_resources author_id def get_attch_resources author_id, order, score
attchments = Attachment.where("author_id = #{author_id} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc") attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
'Document','Message','News','StudentWorkScore','HomewCommon'))").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我上传的附件搜索结果
def get_attch_resources_search author_id, order, score, search
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue',
'Document','Message','News','StudentWorkScore','HomewCommon')) and (filename like :p)", :p => search ).order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取公共资源中我上传的附件
def get_attch_resources_public order, score
attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取公共资源中我上传的附件 # 获取公共资源中我上传的附件
def get_attch_resources_public def get_attch_resources_public_search order, score, search
attchments = Attachment.where("container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal') and container_id is not null and is_public =1").order("created_on desc") attchments = Attachment.where("(container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')
and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的用户类型资源 # 获取我的用户类型资源
def get_principal_resources author_id def get_principal_resources author_id, order, score
attchments = Attachment.where("author_id = #{author_id} and container_type = 'Principal'").order("created_on desc") attchments = Attachment.where("author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal'").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的用户类型资源搜索
def get_principal_resources_search author_id, order, score, search
attchments = Attachment.where("(author_id = #{author_id} and is_publish = 1 and container_id is not null and container_type = 'Principal') and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 获取我的用户类型资源 # 获取我的用户类型资源
def get_principal_resources_public def get_principal_resources_public order, score
attchments = Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("created_on desc") attchments = Attachment.where("container_type = 'Principal'and container_id is not null and is_public =1").order("#{order.nil? ? 'created_on' : order} #{score}")
end
# 获取我的用户类型资源
def get_principal_resources_public_search order, score, search
attchments = Attachment.where("(container_type = 'Principal'and container_id is not null and is_public =1) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
end end
# 资源库 分为全部 课程资源 项目资源 附件 # 资源库 分为全部 课程资源 项目资源 附件
def user_resource def user_resource
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
# 别人的资源库是没有权限去看的 # 别人的资源库是没有权限去看的
if User.current.id.to_i != params[:id].to_i if User.current.id.to_i != params[:id].to_i
render_403 render_403
@ -2403,37 +2486,29 @@ class UsersController < ApplicationController
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
if params[:status] == "2" if params[:status] == "2"
@attachments = get_course_resources(params[:id], user_course_ids) @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources(params[:id], user_project_ids) @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources params[:id] @attachments = get_attch_resources(params[:id], @order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources params[:id] @attachments = get_principal_resources(params[:id], @order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
end end
elsif params[:type] == "2" # 课程资源
@attachments = get_course_resources(params[:id], user_course_ids)
elsif params[:type] == "3" # 项目资源
@attachments = get_project_resources(params[:id], user_project_ids)
elsif params[:type] == "4" #附件
@attachments = get_attch_resources params[:id]
elsif params[:type] == "5" #用户资源
@attachments = get_principal_resources params[:id]
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
if params[:status] == "2" if params[:status] == "2"
@attachments = get_course_resources_public( user_course_ids) @attachments = get_course_resources_public( user_course_ids, @order, @score)
elsif params[:status] == "3" elsif params[:status] == "3"
@attachments = get_project_resources_public(user_project_ids) @attachments = get_project_resources_public(user_project_ids, @order, @score)
elsif params[:status] == "4" elsif params[:status] == "4"
@attachments = get_attch_resources_public @attachments = get_attch_resources_public(@order, @score)
elsif params[:status] == "5" elsif params[:status] == "5"
@attachments = get_principal_resources_public @attachments = get_principal_resources_public(@order, @score)
else else
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids) @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end end
end end
@status = params[:status] @status = params[:status]
@ -2458,16 +2533,21 @@ class UsersController < ApplicationController
render_403 render_403
return return
end end
@resource_id = params[:project_id].nil? ? (params[:course_id].nil? ? params[:subfield_file_id] : params[:course_id]) : params[:project_id]
@resource_type = params[:project_id].nil? ? (params[:course_id].nil? ? "SubfieldFile" : "Course") : "Project"
@user = User.find(params[:id])
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id} # user_org_ids = User.current.organizations.map {|o| o.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
@attachments = get_my_resources(params[:id], user_course_ids, user_project_ids) @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids) @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end end
@status = params[:status]
@type = params[:type] @type = params[:type]
@limit = 10 @limit = 10
@is_remote = true @is_remote = true
@ -2483,26 +2563,28 @@ class UsersController < ApplicationController
end end
def import_resources_search def import_resources_search
search = "%#{params[:search].strip.downcase}%" @resource_id = params[:mul_id]
@resource_type = params[:mul_type]
@order, @b_sort = params[:order] || "created_on", params[:sort] || "asc"
@score = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
@switch_search = params[:name].nil? ? " " : params[:name]
search = "%#{@switch_search.strip.downcase}%"
# 别人的资源库是没有权限去看的 # 别人的资源库是没有权限去看的
if User.current.id.to_i != params[:id].to_i if User.current.id.to_i != params[:id].to_i
render_403 render_403
return return
end end
user_course_ids = User.current.courses.map { |c| c.id} @resource_id = params[:mul_id]
user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id}
if(params[:type].blank? || params[:type] == "1") # 我的资源 if(params[:type].blank? || params[:type] == "1") # 我的资源
# 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源 # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
user_course_ids = User.current.courses.map { |c| c.id} user_course_ids = User.current.courses.map { |c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} # user_org_ids = User.current.organizations.map {|o| o.id}
@attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" +
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("created_on desc")
elsif params[:type] == "6" # 公共资源 elsif params[:type] == "6" # 公共资源
# 公共资源库:所有公开资源或者我上传的私有资源 # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources(user_course_ids, user_project_ids) @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
end end
@type = params[:type] @type = params[:type]
@limit = 10 @limit = 10
@ -2511,10 +2593,10 @@ class UsersController < ApplicationController
@atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1 @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
@offset ||= @atta_pages.offset @offset ||= @atta_pages.offset
#@curse_attachments_all = @all_attachments[@offset, @limit] #@curse_attachments_all = @all_attachments[@offset, @limit]
@attachments = paginateHelper @attachments,10 @attachments = paginateHelper @attachments, 10
respond_to do |format| respond_to do |format|
format.js format.js
format.html {render :layout => 'new_base'} # format.html {render :layout => 'new_base'}
end end
end end
@ -2572,55 +2654,41 @@ class UsersController < ApplicationController
# 根据资源关键字进行搜索 # 根据资源关键字进行搜索
def resource_search def resource_search
search = "%#{params[:search].strip.downcase}%" @order, @b_sort = params[:order] || "created_on", params[:sort] || "desc"
user_course_ids = User.current.courses.map { |c| c.id} @score = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
@switch_search = params[:search].nil? ? " " : params[:search]
search = "%#{@switch_search.strip.downcase}%"
user_course_ids = User.current.courses.map {|c| c.id}
user_project_ids = User.current.projects.map {|p| p.id} user_project_ids = User.current.projects.map {|p| p.id}
# user_org_ids = User.current.organizations.map {|o| o.id} if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部
if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 if params[:status] == "2"
if User.current.id.to_i == params[:id].to_i @attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search)
elsif params[:status] == "3"
@attachments = Attachment.where("((author_id = #{params[:id]} and is_publish = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ @attachments = get_project_resources_search(params[:id], user_project_ids, @order, @score, search)
"or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}) and is_publish = 1 and container_id is not null)" + elsif params[:status] == "4"
"or (container_type = 'Project' and container_id in (#{user_project_ids.empty? ? '0': user_project_ids.join(',')}) and is_publish = 1 and container_id is not null)) and (filename like :p)" ,:p => search).order("created_on desc") @attachments = get_attch_resources_search(params[:id], @order, @score, search)
else elsif params[:status] == "5"
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = get_principal_resources_search(params[:id], @order, @score, search)
@attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" +
" ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+
" or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" +
" and (filename like :p) ",:p=>search).order("created_on desc")
end
elsif params[:type] == "2" #课程资源
if User.current.id.to_i == params[:id].to_i
user_course_ids = User.current.courses.map { |c| c.id}
@attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("created_on desc")
else
user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中
@attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+
"or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+
" and (filename like :p) ",:p=>search).order("created_on desc")
end
elsif params[:type] == "3" #项目资源
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("created_on desc")
else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like :p) ",:p=>search).order("created_on desc")
end
elsif params[:type] == "4" #附件
if User.current.id.to_i == params[:id].to_i
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("created_on desc")
else else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("created_on desc") # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
end end
elsif params[:type] == "5" #用户资源 elsif params[:type] == "6" # 公共资源
if User.current.id.to_i == params[:id].to_i if params[:status] == "2"
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") @attachments = get_course_resources_public_search(user_course_ids, @order, @score, search)
elsif params[:status] == "3"
@attachments = get_project_resources_public_search(user_project_ids, @order, @score, search)
elsif params[:status] == "4"
@attachments = get_attch_resources_public_search(@order, @score, search)
elsif params[:status] == "5"
@attachments = get_principal_resources_public_search(@order, @score, search)
else else
@attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") # 公共资源库:所有公开资源或者我上传的私有资源
@attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
end end
elsif params[:type] == "6" #全部资源
# 公共资源库:所有公开资源或者我上传的私有资源
@attachments = Attachment.where("is_publish = 1 and is_public = 1 and container_id is not null and container_type in('Project','OrgSubfield','Principal','Course') and (filename like :p)" ,:p => search).order("created_on desc")
end end
@status = params[:status]
@type = params[:type] @type = params[:type]
@limit = 25 @limit = 25
@is_remote = true @is_remote = true

@ -370,7 +370,7 @@ module ApplicationHelper
def link_to_short_attachment(attachment, options={}) def link_to_short_attachment(attachment, options={})
length = options[:length] ? options[:length]:23 length = options[:length] ? options[:length]:23
text = h(truncate(options.delete(:text) || attachment.filename, length: length, omission: '...')) text = h(truncate(options.delete(:text) || attachment.filename, length: length, omission: '...'))
route_method = options.delete(:download) ? :download_named_attachment_path : :named_attachment_path route_method = options.delete(:download) ? :download_named_attachment_url_without_domain : :named_attachment_url_without_domain
html_options = options.slice!(:only_path) html_options = options.slice!(:only_path)
url = send(route_method, attachment, attachment.filename, options) url = send(route_method, attachment, attachment.filename, options)
link_to text, url, html_options link_to text, url, html_options
@ -841,7 +841,7 @@ module ApplicationHelper
def project_member_check_box_tags_ex name, principals def project_member_check_box_tags_ex name, principals
s = '' s = ''
principals.each do |principal| principals.each do |principal|
s << "<li>#{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_path( principal.id)}</li>\n" s << "<li>#{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_url_in_org( principal.id)}</li>\n"
end end
s.html_safe s.html_safe
end end
@ -1044,9 +1044,9 @@ module ApplicationHelper
elsif @organization elsif @organization
title << @organization.name title << @organization.name
elsif @user elsif @user
title << @user.login title << @user.try(:realname)
else else
title << User.current.login title << User.current.try(:realname)
end end
if first_page.nil? || first_page.web_title.nil? if first_page.nil? || first_page.web_title.nil?
title << Setting.app_title unless Setting.app_title == title.last title << Setting.app_title unless Setting.app_title == title.last
@ -2069,7 +2069,7 @@ module ApplicationHelper
candown = User.current.member_of?(project) || (project.is_public && attachment_history.is_public == 1) candown = User.current.member_of?(project) || (project.is_public && attachment_history.is_public == 1)
elsif attachment_history.container_type == "OrgSubfield" elsif attachment_history.container_type == "OrgSubfield"
org = OrgSubfield.find(attachment_history.container_id) org = OrgSubfield.find(attachment_history.container_id)
candown = User.current.member_of_org?(org) || (org.organization.is_public && attachment_history.is_public == 1) candown = User.current.member_of_org?(org) || (org.organization.is_public && attachment_history.is_public == 1 && (User.current.logged? || org.organization.allow_guest_download?))
end end
end end
@ -2582,9 +2582,9 @@ module ApplicationHelper
elsif homework.student_works.count >= 2 && homework.homework_detail_manual#作业份数大于2 elsif homework.student_works.count >= 2 && homework.homework_detail_manual#作业份数大于2
case homework.homework_detail_manual.comment_status case homework.homework_detail_manual.comment_status
when 1 when 1
link = link_to '启动匿评', alert_anonymous_comment_homework_common_path(homework,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink' link = link_to '启动匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?is_in_course=" + is_in_course.to_s + "&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s, id: "#{homework.id}_start_anonymous_comment", remote: true, disable_with: '加载中...',:class => 'postOptionLink'
when 2 when 2
link = link_to '关闭匿评', alert_anonymous_comment_homework_common_path(homework,:is_in_course=>is_in_course,:user_activity_id=>user_activity_id,:course_activity=>course_activity), id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink' link = link_to '关闭匿评', Setting.protocol + "://" + Setting.host_name + "/homework_common/" + homework.id.to_s + "/alert_anonymous_comment?is_in_course=" + is_in_course.to_s + "&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s, id: "#{homework.id}_stop_anonymous_comment", remote: true,:class => 'postOptionLink'
when 3 when 3
# link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束" # link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
end end
@ -2631,7 +2631,7 @@ module ApplicationHelper
def user_for_homework_common homework,is_teacher def user_for_homework_common homework,is_teacher
if User.current.member_of_course?(homework.course) if User.current.member_of_course?(homework.course)
if is_teacher #老师显示作品数量 if is_teacher #老师显示作品数量
link_to "作品(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" link_to "作品(#{homework.student_works.count})", student_work_index_url_in_org(homework.id), :class => "c_blue"
else #学生显示提交作品、修改作品等按钮 else #学生显示提交作品、修改作品等按钮
work = cur_user_works_for_homework homework work = cur_user_works_for_homework homework
project = cur_user_projects_for_homework homework project = cur_user_projects_for_homework homework
@ -2639,30 +2639,30 @@ module ApplicationHelper
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "提交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品' link_to "提交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再提交作品'
else else
link_to "提交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' link_to "提交作品(#{homework.student_works.count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
end end
elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") elsif work.nil? && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d")
if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1 if homework.homework_type ==3 && project.nil? && homework.homework_detail_group.base_on_project == 1
link_to "补交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品' link_to "补交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品'
else else
link_to "补交作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_red' link_to "补交作品(#{homework.student_works.count})", new_student_work_url_without_domain(homework.id),:class => 'c_red'
end end
else else
if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前 if homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 2 #匿评作业,且作业状态不是在开启匿评之前
link_to "作品匿评", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品" link_to "作品匿评", student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "开启匿评后不可修改作品"
elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3 elsif homework.homework_detail_manual && homework.homework_detail_manual.comment_status == 3
link_to "查看作品(#{homework.student_works.count})", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "匿评已结束" link_to "查看作品(#{homework.student_works.count})",student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "匿评已结束"
elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品 elsif homework.homework_type == 2 && Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")#编程作业不能修改作品
link_to "修改作品(#{homework.student_works.count})", new_student_work_path(:homework => homework.id),:class => 'c_blue' link_to "修改作品(#{homework.student_works.count})", new_student_work_url_without_domain(homework.id),:class => 'c_blue'
elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id elsif Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d") && work.user_id == User.current.id
link_to "修改作品(#{homework.student_works.count})", edit_student_work_path(work.id),:class => 'c_blue' link_to "修改作品(#{homework.student_works.count})", edit_student_work_url_without_domain(work.id),:class => 'c_blue'
else else
link_to "查看作品(#{homework.student_works.count})", student_work_index_path(:homework => homework.id), :class => 'c_blue', :title => "作业截止后不可修改作品" link_to "查看作品(#{homework.student_works.count})", student_work_index_url_in_org(homework.id), :class => 'c_blue', :title => "作业截止后不可修改作品"
end end
end end
end end
else else
link_to "作品(#{homework.student_works.count})",student_work_index_path(:homework => homework.id),:class => "c_blue" link_to "作品(#{homework.student_works.count})",student_work_index_url_in_org(homework.id),:class => "c_blue"
end end
end end
@ -2943,11 +2943,104 @@ int main(int argc, char** argv){
end end
def user_url_in_org(user_id) def user_url_in_org(user_id)
if Rails.env.development? Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s
return "http://localhost:3000/users/" + user_id.to_s end
elsif Rails.env.test?
return "https://www.test.forge.trustie.net/users/" + user_id.to_s def project_issues_url_in_org(project_id)
else Setting.protocol + "://" + Setting.host_name + "/projects/" + project_id.to_s + "/issues"
return "https://www.trustie.net/users/" + user_id.to_s end
end
def issue_url_in_org(id)
Setting.protocol + "://" + Setting.host_name + "/issues/" + id.to_s
end
def project_boards_url_in_org(id)
Setting.protocol + "://" + Setting.host_name + "/projects/" + id.to_s + "/boards"
end
def board_message_url_in_org(board_id, message_id)
Setting.protocol + "://" + Setting.host_name + "/boards/" + board_id.to_s + "/topics/" + message_id.to_s
end
def project_url_in_org(id)
Setting.protocol + "://" + Setting.host_name + "/projects/" + id.to_s
end end
def homework_common_index_url_in_org(course_id)
Setting.protocol + "://" + Setting.host_name + "/homework_common?course=" + course_id.to_s
end
def student_work_index_url_in_org(homework_id)
Setting.protocol + "://" + Setting.host_name + "/student_work?homework=" + homework_id.to_s
end
def course_url_in_org(course_id)
Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s
end
def user_watchlist_url_in_org(id)
Setting.protocol + "://" + Setting.host_name + "/users/" + id.to_s + "/user_watchlist"
end
def user_fanslist_url_in_org(id)
Setting.protocol + "://" + Setting.host_name + "/users/" + id.to_s + "/user_fanslist"
end
def user_blogs_url_in_org(user_id)
Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s + "/blogs"
end
def feedback_url_in_org(user_id)
Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s + "/user_newfeedback"
end
def user_activities_url_in_org(user_id)
Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s + "/user_activities"
end
def course_news_index_url_in_org(course_id)
Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s + "/news"
end
def news_url_in_org(news_id)
Setting.protocol + "://" + Setting.host_name + "/news/" + news_id.to_s
end
def course_boards_url_in_org(course_id)
Setting.protocol + "://" + Setting.host_name + "/courses/" + course_id.to_s + "/boards"
end
def logout_url_without_domain
Setting.protocol + "://" + Setting.host_name + "/logout"
end
def signin_url_without_domain
Setting.protocol + "://" + Setting.host_name + "/login?login=true"
end
def register_url_without_domain
Setting.protocol + "://" + Setting.host_name + "/login?login=false"
end
def new_student_work_url_without_domain(homework_id)
Setting.protocol + "://" + Setting.host_name + "/student_work/new?homework=" + homework_id.to_s
end
def edit_student_work_url_without_domain(homework_id)
Setting.protocol + "://" + Setting.host_name + "/student_work/" + homework_id.to_s + "/edit"
end
def download_named_attachment_url_without_domain(id, filename, option={})
attachment_id = (Attachment === id ? id.id : id)
Setting.protocol + "://" + Setting.host_name + "/attachments/download/" + attachment_id.to_s + "/" + filename
end
def named_attachment_url_without_domain(id, filename, option={})
attachment_id = (Attachment === id ? id.id : id)
Setting.protocol + "://" + Setting.host_name + "/attachments/" + attachment_id.to_s + "/" + filename
end
#判断是否为默认的组织栏目
def is_default_field? field
(field.name == 'activity' || field.name == 'course' || field.name == 'project') && field.field_type == 'default'
end

@ -865,7 +865,7 @@ module CoursesHelper
# 学生按作业总分排序取前8个 # 学生按作业总分排序取前8个
def hero_homework_score(course, score_sort_by) def hero_homework_score(course, score_sort_by)
sql_select = "SELECT members.*,( sql_select = "SELECT members.*,(
SELECT SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty)) SELECT SUM(IF(student_works.final_score is null,null,IF(student_works.final_score = 0, 0, student_works.final_score - student_works.absence_penalty - student_works.late_penalty)))
FROM student_works,homework_commons FROM student_works,homework_commons
WHERE student_works.homework_common_id = homework_commons.id WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{course.id} AND homework_commons.course_id = #{course.id}

@ -22,10 +22,18 @@ module RoutesHelper
# Returns the path to project issues or to the cross-project # Returns the path to project issues or to the cross-project
# issue list if project is nil # issue list if project is nil
def _project_issues_path(project, *args) def _project_issues_path(project, *args)
if project if args[0].to_s.include? '_page'
project_issues_path(project, *args) if args[0].to_s == "user_page"
user_activities_path(args[1].to_i)
else
project_path(project)
end
else else
issues_path(*args) if project
project_issues_path(project, *args)
else
issues_path(*args)
end
end end
end end

@ -90,8 +90,8 @@ class Attachment < ActiveRecord::Base
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location before_save :files_to_final_location
after_save :act_as_course_activity after_save :act_as_course_activity,:act_as_forge_activity
after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index after_create :office_conver, :be_user_score,:create_attachment_ealasticsearch_index
after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index
after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score
@ -606,7 +606,7 @@ class Attachment < ActiveRecord::Base
# Author lizanle # Author lizanle
# Description 上传该项目的文档资料也要保存一份在公共表中 # Description 上传该项目的文档资料也要保存一份在公共表中
def act_as_forge_activity def act_as_forge_activity
if self.container_type == 'Project' if self.container_type == 'Project' && self.forge_acts.empty?
self.forge_acts << ForgeActivity.new(:user_id => self.author_id, self.forge_acts << ForgeActivity.new(:user_id => self.author_id,
:project_id => self.container_id) :project_id => self.container_id)
end end

@ -5,7 +5,7 @@ class CourseActivity < ActiveRecord::Base
belongs_to :course belongs_to :course
belongs_to :user belongs_to :user
has_many :user_acts, :class_name => 'UserAcivity',:as =>:act has_many :user_acts, :class_name => 'UserAcivity',:as =>:act
after_save :add_user_activity, :add_course_activity after_save :add_user_activity, :add_org_activity
after_create :add_course_lead after_create :add_course_lead
before_destroy :destroy_user_activity, :destroy_org_activity before_destroy :destroy_user_activity, :destroy_org_activity
@ -31,14 +31,16 @@ class CourseActivity < ActiveRecord::Base
end end
end end
def add_course_activity def add_org_activity
org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'").first org_activity = OrgActivity.where("org_act_type = '#{self.course_act_type.to_s}' and org_act_id = '#{self.course_act_id}'").first
if org_activity if org_activity
org_activity.updated_at = self.updated_at
org_activity.save org_activity.save
else else
if self.course_act_type == 'Message' && !self.course_act.parent_id.nil? if self.course_act_type == 'Message' && !self.course_act.parent_id.nil?
org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.course_act.parent.id}").first org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.course_act.parent.id}").first
org_activity.created_at = self.created_at org_activity.created_at = self.created_at
org_activity.updated_at = self.updated_at
org_activity.save org_activity.save
else else
OrgActivity.create(:user_id => self.user_id, OrgActivity.create(:user_id => self.user_id,
@ -64,15 +66,16 @@ class CourseActivity < ActiveRecord::Base
# 发布新课导语 # 发布新课导语
# 导语要放置在课程创建信息之后 # 导语要放置在课程创建信息之后
# 导语
def add_course_lead def add_course_lead
if self.course_act_type == "Course" # 避免空数据迁移报错问题
if self.course_act_type == "Course" and Message.where("id=12440").any?
lead_message = Message.find(12440) lead_message = Message.find(12440)
name = lead_message.subject name = lead_message.subject
content = lead_message.content content = lead_message.content
# message的status状态为0为正常为1表示创建课程时发送的message # message的status状态为0为正常为1表示创建课程时发送的message
message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => self.course.tea_id , :sticky => true, :status => true ) # author_id 默认为课程使者创建
# 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一直 message = Message.create(:subject => name, :content => content, :board_id => self.course.boards.first.id, :author_id => 1 , :sticky => true, :status => true )
# 更新的目的是为了排序,因为该条动态的时间可能与课程创建的动态创建时间一致
message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first message.course_acts.first.update_attribute(:updated_at, message.course_acts.first.updated_at + 1) if message.course_acts.first
end end
end end

@ -48,7 +48,7 @@ class ForgeActivity < ActiveRecord::Base
def add_org_activity def add_org_activity
org_activity = OrgActivity.where("org_act_type = '#{self.forge_act_type.to_s}' and org_act_id = #{self.forge_act_id}").first org_activity = OrgActivity.where("org_act_type = '#{self.forge_act_type.to_s}' and org_act_id = #{self.forge_act_id}").first
if org_activity if org_activity
org_activity.created_at = self.created_at org_activity.updated_at = self.updated_at
org_activity.save org_activity.save
else else
if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil? if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil?

@ -84,7 +84,9 @@ class Issue < ActiveRecord::Base
attr_reader :current_journal attr_reader :current_journal
# fq # fq
after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message, :add_issues_count after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message,
act_as_at_message(:description, :author_id), :add_issues_count
after_update :be_user_score,:update_activity after_update :be_user_score,:update_activity
after_destroy :down_user_score, :decrease_issues_count after_destroy :down_user_score, :decrease_issues_count
# after_create :be_user_score # after_create :be_user_score
@ -165,12 +167,12 @@ class Issue < ActiveRecord::Base
end end
# at 功能添加消息提醒 # at 功能添加消息提醒
def act_as_at_message # def act_as_at_message
users = self.description.scan /<span class="at" data-user-id="(\d+?)">/m # users = self.description.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid| # users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id) # self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
end # end
end # end
# 创建issue的时候issues_count加1 # 创建issue的时候issues_count加1
def add_issues_count def add_issues_count

@ -51,7 +51,7 @@ class Journal < ActiveRecord::Base
before_create :split_private_notes, :add_journals_count before_create :split_private_notes, :add_journals_count
# fq # fq
after_save :act_as_activity,:be_user_score, :act_as_forge_message, :act_as_at_message after_save :act_as_activity,:be_user_score, :act_as_forge_message, act_as_at_message(:notes, :user_id)
after_create :update_issue_time after_create :update_issue_time
# end # end
#after_destroy :down_user_score #after_destroy :down_user_score
@ -186,13 +186,6 @@ class Journal < ActiveRecord::Base
end end
end end
def act_as_at_message
users = self.notes.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id)
end
end
# 更新用户分数 -by zjc # 更新用户分数 -by zjc
def be_user_score def be_user_score
#新建了缺陷留言且留言不为空,不为空白 #新建了缺陷留言且留言不为空,不为空白

@ -68,7 +68,9 @@ class JournalsForMessage < ActiveRecord::Base
has_many :at_messages, as: :at_message, dependent: :destroy has_many :at_messages, as: :at_message, dependent: :destroy
validates :notes, presence: true, if: :is_homework_jour? validates :notes, presence: true, if: :is_homework_jour?
after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_at_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score after_create :act_as_activity, :act_as_course_activity, :act_as_course_message,
act_as_at_message(:notes, :user_id), :act_as_user_feedback_message,
:act_as_principal_activity, :act_as_student_score
after_create :reset_counters! after_create :reset_counters!
#after_update :update_activity #after_update :update_activity
after_destroy :reset_counters! after_destroy :reset_counters!
@ -253,12 +255,7 @@ class JournalsForMessage < ActiveRecord::Base
end end
end end
def act_as_at_message
users = self.notes.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id)
end
end
# 用户留言消息通知 # 用户留言消息通知
def act_as_user_feedback_message def act_as_user_feedback_message
# 主留言 # 主留言

@ -81,7 +81,8 @@ class Message < ActiveRecord::Base
after_update :update_messages_board, :update_activity after_update :update_messages_board, :update_activity
after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count, :down_course_score
after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity,
:act_as_system_message, :send_mail, :act_as_student_score, act_as_at_message(:content, :author_id)
#before_save :be_user_score #before_save :be_user_score
scope :visible, lambda {|*args| scope :visible, lambda {|*args|
@ -287,13 +288,6 @@ class Message < ActiveRecord::Base
end end
end end
def act_as_at_message
users = self.content.scan /<span class="at" data-user-id="(\d+?)">/m
users && users.flatten.uniq.each do |uid|
self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
end
end
#更新用户分数 -by zjc #更新用户分数 -by zjc
def be_user_score def be_user_score
#新建message且无parent的为发帖 #新建message且无parent的为发帖

@ -9,6 +9,7 @@ class OrgSubfield < ActiveRecord::Base
has_many :news, :dependent => :destroy has_many :news, :dependent => :destroy
acts_as_attachable acts_as_attachable
after_create :create_board_sync after_create :create_board_sync
after_destroy :update_priority
# 创建资源栏目讨论区 # 创建资源栏目讨论区
def create_board_sync def create_board_sync
@board = self.boards.build @board = self.boards.build
@ -25,4 +26,11 @@ class OrgSubfield < ActiveRecord::Base
def project def project
end end
def update_priority
OrgSubfield.where("organization_id=? and priority>?", self.organization_id, self.priority).each do |field|
field.decrement(:priority)
field.save
end
end
end end

@ -16,8 +16,8 @@ class Organization < ActiveRecord::Base
end end
def add_default_subfields def add_default_subfields
OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default') OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default', :priority => 1)
OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default') OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default', :priority => 2)
OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default') OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default', :priority => 3)
end end
end end

@ -116,7 +116,7 @@ class User < Principal
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference' has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'" has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'"
has_one :blog, :class_name => 'Blog', :foreign_key => "author_id" has_one :blog, :class_name => 'Blog', :foreign_key => "author_id"
has_many :org_document_comments, :dependent =>:destroy has_many :org_document_comments, :dependent =>:destroy, :foreign_key => "creator_id"
has_one :api_token, :class_name => 'Token', :conditions => "action='api'" has_one :api_token, :class_name => 'Token', :conditions => "action='api'"
belongs_to :auth_source belongs_to :auth_source
has_many :org_members has_many :org_members
@ -822,6 +822,9 @@ class User < Principal
end end
def member_of_org?(org) def member_of_org?(org)
if !self.logged?
return false
end
OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0 OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0
end end
@ -1064,6 +1067,16 @@ class User < Principal
anonymous_user anonymous_user
end end
# refactor User model find function,
# return anonymous user when can not find user id = user_id
def self.find (*args, &block)
begin
super
rescue
self.anonymous
end
# super
end
# Salts all existing unsalted passwords # Salts all existing unsalted passwords
# It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password)) # It changes password storage scheme from SHA1(password) to SHA1(salt + SHA1(password))
# This method is used in the SaltPasswords migration and is to be kept as is # This method is used in the SaltPasswords migration and is to be kept as is

@ -0,0 +1,4 @@
class UserActions < ActiveRecord::Base
attr_accessible :action_id, :action_type, :user_id
has_many :users
end

@ -73,4 +73,8 @@
</table> </table>
</div> </div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_course_all)) -%> <% html_title(l(:label_course_all)) -%>

@ -73,6 +73,10 @@
</table> </table>
</div> </div>
<div class="pagination">
<%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false %>
</div>
<% html_title(l(:label_project_plural)) -%> <% html_title(l(:label_project_plural)) -%>
<script> <script>

@ -1,6 +1,11 @@
[ [
<% @users && @users.each_with_index do |person,index| %> <% @users && @users.each_with_index do |person,index| %>
<% if index == 0 %>
{"id":<%=index%>, "userid": "<%=person.id%>", "name": "所有人", "login": "<%=person.name%>", "searchKey": "<%=person.name%>"}
<%= index != @users.size-1 ? ',' : '' %>
<% else %>
{"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"} {"id":<%=index%>, "userid": <%=person.id%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"}
<%= index != @users.size-1 ? ',' : '' %> <%= index != @users.size-1 ? ',' : '' %>
<% end %> <% end %>
<% end %>
] ]

@ -0,0 +1,30 @@
<script>
$(document).ready(function(){
$(".popupClose").click(function(){
$(".popupWrap").css("display","none");
});
});
</script>
<span class="f16 fontBlue fb">选择版本 </span>
<p class="c_red">注:该文件有历史版本,请选择您需要的文件,点击文件名下载。</p>
<p class="fontGrey3 mb4 fb">版本及序号</p>
<div style="max-height:165px; overflow-y:auto; background-color: #e3e3e3; line-height:33px;" class="p10">
<span class="attachment">
<%= link_to truncate(@attachment.filename,length: 35, omission: '...'),
download_named_attachment_path(@attachment.id, @attachment.filename),
:title => @attachment.filename+"\n"+@attachment.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
</span>
<span class="fr">版本号:当前</span>
<div class="cl"></div>
<% @attachment_histories.each do |history| %>
<span class="attachment">
<%= link_to truncate(history.filename,length: 35, omission: '...'),
download_history_attachment_path(history.id, history.filename),
:title => history.filename+"\n"+history.description.to_s,
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis; max-width:300px;",:class => "linkBlue f14 fb link_file_a2 fl" %>
</span>
<span class="fr">版本号:<%= history.version %></span>
<div class="cl"></div>
<% end %>
</div>

@ -0,0 +1,7 @@
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'attachments/attachment_history_download' )%>');
showModal('ajax-modal', '452px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').before("<a href='javascript:void(0)' onclick='hideModal();' style='margin-left: 435px;' class='resourceClose'></a>");
$('#ajax-modal').parent().css("top","40%").css("left","50%");
$('#ajax-modal').parent().addClass("resourceUploadPopup");
$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");

@ -1,6 +1,5 @@
<% if User.current.logged? && User.current.id == @user.id %>
<%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id, :is_homepage => params[:is_homepage],:in_act => params[:in_act]},:method=>'PUT', <%= form_for @article, :url =>{:controller=>'blog_comments',:action => 'update',:user_id=>@user.id , :blog_id => @article.id, :is_homepage => params[:is_homepage],:in_act => params[:in_act]},:method=>'PUT',
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %> <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %>
<% end %>
<% end %> <% end %>

@ -38,7 +38,7 @@
<%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %> <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
</div> </div>
<div class="postThemeWrap"> <div class="postThemeWrap">
<% if @article.author.id == User.current.id%> <% if @article.author.id == User.current.id || User.current.admin? %>
<div class="homepagePostSetting" id="message_setting_<%= @article.id%>" style="display: none"> <div class="homepagePostSetting" id="message_setting_<%= @article.id%>" style="display: none">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
@ -48,7 +48,7 @@
l(:button_edit), l(:button_edit),
{:action => 'edit', :id => @article.id,:in_act => params[:in_act]}, {:action => 'edit', :id => @article.id,:in_act => params[:in_act]},
:class => 'postOptionLink' :class => 'postOptionLink'
) if User.current && User.current.id == @article.author.id %> ) if User.current.admin? || User.current.id == @article.author.id %>
</li> </li>
<li> <li>
<%= link_to( <%= link_to(
@ -57,7 +57,7 @@
:method => :delete, :method => :delete,
:data => {:confirm => l(:text_are_you_sure)}, :data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink' :class => 'postOptionLink'
) if User.current && User.current.id == @article.author.id %> ) if User.current.admin? || User.current.id == @article.author.id %>
</li> </li>
<li> <li>
<% if @article.id == @article.blog.homepage_id %> <% if @article.id == @article.blog.homepage_id %>

@ -4,7 +4,7 @@
<%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<% if activity.author.id == User.current.id%> <% if activity.author.id == User.current.id || User.current.admin? %>
<div class="homepagePostSetting" id="message_setting_<%= activity.id%>" style="display: none"> <div class="homepagePostSetting" id="message_setting_<%= activity.id%>" style="display: none">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
@ -14,7 +14,7 @@
l(:button_edit), l(:button_edit),
{:controller => 'blog_comments',:action => 'edit',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id}, {:controller => 'blog_comments',:action => 'edit',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
:class => 'postOptionLink' :class => 'postOptionLink'
) if User.current && User.current.id == activity.author.id %> ) if User.current.admin? || User.current.id == activity.author.id %>
</li> </li>
<li> <li>
<%= link_to( <%= link_to(
@ -23,7 +23,7 @@
:method => :delete, :method => :delete,
:data => {:confirm => l(:text_are_you_sure)}, :data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink' :class => 'postOptionLink'
) if User.current && User.current.id == activity.author.id %> ) if User.current.admin? || User.current.id == activity.author.id %>
</li> </li>
<li> <li>
<% if activity.id == activity.blog.homepage_id %> <% if activity.id == activity.blog.homepage_id %>

@ -43,6 +43,8 @@
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.content} %> <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.content} %>
<div class="cl"></div> <div class="cl"></div>
<div id="intro_content_show_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[展开]</a></div>
<div id="intro_content_hide_<%= user_activity_id%>" class="fr" style="display:none;"><a href="javascript:void(0);" class="linkBlue">[收起]</a></div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>

@ -1,7 +1,123 @@
<%= content_for(:header_tags) do %> <%= content_for(:header_tags) do %>
<%= import_ke(enable_at: true, prettify: false) %> <%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<% end %> <% end %>
<script type="text/javascript">
function nh_check_field(params){
var result=true;
if(!regexTopicSubject()) {
result=false;
return result;
}
if(params.content!=undefined){
if(params.content.isEmpty()){
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
params.content.sync();
if(params.content.isEmpty())
{
params.contentmsg.text("描述不能为空");
params.contentmsg.css('color','#ff0000');
}
else if(params.content.html().length >=20000){
params.contentmsg.text("描述最多20000个汉字(或40000个英文字符)");
params.contentmsg.css('color','#ff0000');
result=false;
}
else
{
params.contentmsg.text("填写正确");
params.contentmsg.css('color','#008000');
}
}
}
return result;
}
function init_homework_form(params){
params.form.submit(function(){
params.textarea.html(params.editor.html());
params.editor.sync();
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = false;
is_checked = nh_check_field({
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
});
if(is_checked){
if(flag){
return true;
}else{
$(this)[0].submit();
return false;
}
}
return false;
});
}
function init_homework_editor(params){
params.textarea.removeAttr('placeholder');
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
var edit = this.edit;
var body = edit.doc.body;
edit.html(params.textarea.innerHTML);
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
elocalStorage(message_content_editor,'topic_course_<%=course.id %>');
}
}).loadPlugin('paste');
return editor;
}
KindEditor.ready(function(K){
$("div[nhname='topic_form']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[nhname='topic_textarea']",params.div_form);
params.contentmsg = $("#message_content_span");
params.submit_btn = $("#new_message_submit_btn");
if(params.textarea.data('init') == undefined) {
params.editor = init_homework_editor(params);
message_content_editor = params.editor;
init_homework_form(params);
params.submit_btn.click(function () {
params.form.submit();
});
params.textarea.data('init', 1);
}
});
});
</script>
<%= error_messages_for 'message' %> <%= error_messages_for 'message' %>
<div class="resources mt10"> <div class="resources mt10">
<div id="new_course_topic"> <div id="new_course_topic">
@ -25,7 +141,7 @@
<%= text_area :quote,:quote,:style => 'display:none' %> <%= text_area :quote,:quote,:style => 'display:none' %>
<%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %>
<%= f.kindeditor :content, :editor_id => 'message_content_editor', <%#= f.kindeditor :content, :editor_id => 'message_content_editor',
:owner_id => topic.nil? ? 0: topic.id, :owner_id => topic.nil? ? 0: topic.id,
:owner_type => OwnerTypeHelper::MESSAGE, :owner_type => OwnerTypeHelper::MESSAGE,
:width => '100%', :width => '100%',
@ -37,8 +153,11 @@
:maxlength => 5000 }, :maxlength => 5000 },
at_id: topic.id, at_type: topic.class.to_s at_id: topic.id, at_type: topic.class.to_s
%> %>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='topic_textarea' name="message[content]"><%=topic.content %></textarea>
<div class="cl"></div> <div class="cl"></div>
<p id="message_content_span"></p> <p id="message_content_span"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="mt10"> <div class="mt10">
@ -49,11 +168,11 @@
<div class="cl"></div> <div class="cl"></div>
<div class="mt5"> <div class="mt5">
<%if !edit_mode %> <%if !edit_mode %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_topic();">确定</a> <a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span> <span class="fr mr10 mt3">或</span>
<a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a> <a href="javascript:void(0);" class="fr mr10 mt3" onclick="reset_topic();">取消</a>
<% else %> <% else %>
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="submit_topic();">确定</a> <a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn" onclick="submit_topic();">确定</a>
<span class="fr mr10 mt3">或</span> <span class="fr mr10 mt3">或</span>
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%> <%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
<% end %> <% end %>

@ -25,11 +25,13 @@
课程问答区 课程问答区
</div> </div>
</div> </div>
<div nhname="topic_form">
<% if User.current.logged? %> <% if User.current.logged? %>
<%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, <%= labelled_form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'},
:html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %>
<%= render :partial => 'course_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :course => @board.course} %> <%= render :partial => 'course_new', :locals => {:f => f, :topic => @message, :edit_mode => false, :course => @board.course} %>
<% end %> <% end %>
<% end %> <% end %>
</div>
<%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %> <%= render :partial=> 'course_show_detail',:locals =>{:topics => @topics, :page => 0} %>
</div> </div>

@ -2,6 +2,8 @@
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<% end %> <% end %>
<script> <script>
var onUserCard = false;
var onImage = false;
$(document).ready(function(){ $(document).ready(function(){
$("#relateProject,.relatePInfo").mouseover(function(){ $("#relateProject,.relatePInfo").mouseover(function(){
$(".relatePInfo").css("display","block"); $(".relatePInfo").css("display","block");
@ -10,15 +12,24 @@
$(".relatePInfo").css("display","none"); $(".relatePInfo").css("display","none");
}) })
$(".homepagePostPortrait").mouseover(function(){ $(".homepagePostPortrait").mouseover(function(){
onImage = true;
$(this).children(".userCard").css("display","block"); $(this).children(".userCard").css("display","block");
}) })
$(".homepagePostPortrait").mouseout(function(){ $(".homepagePostPortrait").mouseout(function(){
$(this).children(".userCard").css("display","none"); var cur = $(this);
onImage = false;
setTimeout(function(){
if (onUserCard == false && onImage == false){
$(cur).children(".userCard").css("display", "none");
}
}, 500);
}) })
$(".userCard").mouseover(function(){ $(".userCard").mouseover(function(){
onUserCard = true;
$(this).css("display","block"); $(this).css("display","block");
}) })
$(".userCard").mouseout(function(){ $(".userCard").mouseout(function(){
onUserCard = false;
$(this).css("display","none"); $(this).css("display","none");
}) })
$(".coursesLineGrey").mouseover(function(){ $(".coursesLineGrey").mouseover(function(){

@ -8,11 +8,11 @@
<div class="fl"> <div class="fl">
<p class="f12 mb5"><%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %><div class="cl"></div> </p> <p class="f12 mb5"><%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %><div class="cl"></div> </p>
<p class="f12"> <p class="f12">
<% if e_course.attachments.count > 0 %> <% if visable_attachemnts_incourse(e_course).count > 0 %>
<span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)</span> <span class="fl mr15 fontGrey4"><%= l(:project_module_attachments) %>(<%= link_to visable_attachemnts_incourse(e_course).count, course_files_path(e_course), :class => "linkBlue2" %>)</span>
<% end %> <% end %>
<% if e_course.homework_commons.count > 0 %> <% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %>
<span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span> <span class="fl fontGrey4"><%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.where("publish_time <= '#{Date.today}'").count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)</span>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</p> </p>

@ -9,10 +9,10 @@
} }
<% else %> <% else %>
<% if @course.is_public? %> <% if @course.is_public? %>
$("#set_course_public_<%= @course.id %>").text("设为私有");
$("#show_course_<%= @course.id %>").attr("title","公开课程:<%= @course.name %><%= @course.time.to_s+ @course.term %>"); $("#show_course_<%= @course.id %>").attr("title","公开课程:<%= @course.name %><%= @course.time.to_s+ @course.term %>");
<% else %> <% else %>
$("#set_course_public_<%= @course.id %>").text("设为公开");
$("#show_course_<%= @course.id %>").attr("title","私有课程:<%= @course.name %><%= @course.time.to_s+ @course.term %>"); $("#show_course_<%= @course.id %>").attr("title","私有课程:<%= @course.name %><%= @course.time.to_s+ @course.term %>");
<% end %> <% end %>
$("#set_course_public_<%= @course.id %>").replaceWith('<%= escape_javascript(link_to @course.is_public == 0 ? "设为公开" : "设为私有", {:controller => "courses", :action => "private_or_public", :id => @course,:user_page => true},
:id => "set_course_public_#{@course.id.to_s}",:remote=>true,:confirm=>"您确定要设置为"+(@course.is_public == 0 ? "公开" : "私有")+"吗") %>');
<% end %> <% end %>

@ -108,23 +108,15 @@
<div class="cl"></div> <div class="cl"></div>
<div class="re_con_top"> <div class="re_con_top">
<p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p> <p class="f_l fontBlue f_b f_14">共有&nbsp;<span id="attachment_count"><%= @all_attachments.count%></span>&nbsp;个资源</p>
<p class="f_r" style="color: #808080"> <p class="f_r" style="color: #808080" id="course_filter_order">
<% if @order == "asc" %> <%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp; /&nbsp;
<%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>
</p> </p>
</div> </div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<div id="course_list"> <div id="course_list">
<%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %> <%= render :partial => 'course_list',:locals => {course: @course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} %>
</div> </div>
</div> </div>
<%# html_title(l(:label_attachment_plural)) -%> <%# html_title(l(:label_attachment_plural)) -%>

@ -0,0 +1,15 @@
<% if @order == "asc" %>
按&nbsp;<%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey", :remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey",:remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort => "quotes:desc", :tag_name => @tag_name.nil? ? " " : @tag_name, :q => @q.nil? ? " " : @q), :class => "f_b c_grey", :remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% else %>
按&nbsp;<%= link_to "时间", search_tag_attachment_course_files_path(@course, :sort => "created_on:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q), :class => "f_b c_grey" , :remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %>&nbsp;/&nbsp;
<%= link_to "下载次数", search_tag_attachment_course_files_path(@course, :sort => "downloads:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q), :class => "f_b c_grey", :remote => true %>
<%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>&nbsp;/&nbsp;
<%= link_to "引用次数", search_tag_attachment_course_files_path(@course, :sort =>"quotes:asc", :tag_name => @tag_name.nil? ? ' ' : @tag_name, :q => @q.nil? ? ' ' : @q),:class => "f_b c_grey", :remote => true %>
<%= render partial:'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %>&nbsp;排序
<% end %>

@ -9,9 +9,17 @@
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4"> <div class="homepagePostTitle break_word mt-4">
<%= link_to file.is_public? ? truncate(file.filename, length: 70) : truncate(file.filename,length: 50, omission: '...'), <%# 如果有历史版本则提供历史版本下载 %>
download_named_attachment_path(file.id, file.filename), <% if file.attachment_histories.count == 0 %>
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14 f_l" %> <%= link_to file.is_public? ? truncate(file.filename, length: 45) : truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
<% end %>
<%= file_preview_eye(file, class: 'preview') %> <%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>"> <span id="image_private_<%= file.id%>">
<% if file.is_public? == false%> <% if file.is_public? == false%>
@ -41,11 +49,13 @@
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
<li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li> <li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li>
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li> <li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
<% if file.container.try(:organization).try(:is_public?) %>
<li> <li>
<span id="is_public_<%= file.id %>"> <span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
</span> </span>
</li> </li>
<% end %>
<li> <li>
<%= link_to( '删除资源', attachment_path(file), <%= link_to( '删除资源', attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == org_subfield.id && file.container_type == "OrgSubfield" && file.destroyable %> :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == org_subfield.id && file.container_type == "OrgSubfield" && file.destroyable %>

@ -8,9 +8,17 @@
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4"> <div class="homepagePostTitle break_word mt-4">
<%= link_to truncate(file.filename,length: 35, omission: '...'), <%# 如果有历史版本则提供历史版本下载 %>
download_named_attachment_path(file.id, file.filename), <% if file.attachment_histories.count == 0 %>
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> <%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
<% end %>
<%= file_preview_eye(file, class: 'preview') %> <%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>"> <span id="image_private_<%= file.id%>">
<% if file.is_public? == false%> <% if file.is_public? == false%>

@ -6,9 +6,17 @@
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTitle break_word mt-4"> <div class="homepagePostTitle break_word mt-4">
<%= link_to truncate(file.filename,length: 35, omission: '...'), <%# 如果有历史版本则提供历史版本下载 %>
download_named_attachment_path(file.id, file.filename), <% if file.attachment_histories.count == 0 %>
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %> <%= link_to truncate(file.filename,length: 35, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
<%= link_to truncate(file.filename,length: 35, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
<% end %>
<%= file_preview_eye(file, class: 'preview') %> <%= file_preview_eye(file, class: 'preview') %>
<span id="image_private_<%= file.id%>"> <span id="image_private_<%= file.id%>">
<% if file.is_public? == false%> <% if file.is_public? == false%>
@ -38,31 +46,28 @@
<%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %> <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6",:tag_name => @tag_name} %>
</div> </div>
<div class="homepagePostSetting"> <div class="homepagePostSetting">
<ul> <ul>
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<% if User.current.logged? %> <% if User.current.logged? %>
<% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %> <% if (is_course_teacher(User.current,@course) || file.author_id == User.current.id) && course_contains_attachment?(@course,file) %>
<% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %> <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
<li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li> <li><%= link_to("发&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %></li>
<li><%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %></li> <li><%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %></li>
<li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li> <li><%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %></li>
<% if @course.is_public? %> <% if @course.is_public? %>
<li> <li>
<span id="is_public_<%= file.id %>"> <span id="is_public_<%= file.id %>">
<%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %>
</span> </span>
</li> </li>
<%end%> <%end%>
<li> <li>
<%= link_to( '删除资源', attachment_path(file), <%= link_to( '删除资源', attachment_path(file),
:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %> :data => {:confirm => l(:text_are_you_sure)},
:method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" && file.destroyable %>
</li> </li>
</ul> </ul>
<% end %> <% end %>
<%else%> <%else%>
<ul class="resourceSendO"> <ul class="resourceSendO">

@ -41,9 +41,10 @@
<%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%> <%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%>
<%= submit_tag "栏目内搜索", :class => "blueBtn mr5 fl",:style => 'width:72px;',:name => "inorg_subfield",:id => "inorg_subfield", :onmouseover => "presscss('inorg_subfield')",:onmouseout =>"buttoncss()" %> <%= submit_tag "栏目内搜索", :class => "blueBtn mr5 fl",:style => 'width:72px;',:name => "inorg_subfield",:id => "inorg_subfield", :onmouseover => "presscss('inorg_subfield')",:onmouseout =>"buttoncss()" %>
<%#= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> <%#= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %>
<input class="blueBtn fr mr5" value="上传资源" onclick="org_upload_files(<%= org_subfield.id %>);"> <% if User.current.member_of_org?(org_subfield.organization) %>
<%= link_to("导入资源", import_resources_user_path(User.current, :type => 6, :subfield_file_id => @org_subfield.id), :class => "blue-btn fr mr5", :remote => true) %> <input class="blueBtn fr mr5" value="上传资源" onclick="org_upload_files(<%= org_subfield.id %>);">
<%#= link_to "上传资源",subfield_upload_file_org_subfield_files_path(@org_subfield.id, :in_org => 1),:method => "post",:class=>"blueBtn fr mr5",:remote => true %> <%= link_to("导入资源", import_resources_user_path(User.current, :type => 6, :subfield_file_id => @org_subfield.id), :class => "blue-btn fr mr5", :remote => true) %>
<% end %>
<% end %> <% end %>
</div><!---re_top end--> </div><!---re_top end-->
<div class="cl"></div> <div class="cl"></div>

@ -1,5 +1,6 @@
<% if @course %> <% if @course %>
$("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>"); $("#course_list").html("<%= escape_javascript(render :partial => 'course_list',:locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach})%>");
$("#course_filter_order").html("<%= escape_javascript(render :partial => 'course_file_filter_order', :locals => {course: @course,all_attachments: @result,sort:@sort,order:@order,curse_attachments:@searched_attach, tag_name: @tag_name, q: @q})%>");
$("#attachment_count").html("<%= @result.count%>") $("#attachment_count").html("<%= @result.count%>")
<% else %> <% else %>
$("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>"); $("#course_list").html("<%= escape_javascript(render :partial => 'project_list',:locals => {project:@project, all_attachments:@result_search_project, sort:@sort, order:@order, project_attachments:@searched_attach}) %>");

@ -1,4 +1,10 @@
<script type="text/javascript"> <script type="text/javascript">
<% if @is_in_course == 1 || @course_activity == 1 %>
$(function(){
$("#RSide").removeAttr("id");
$("#Container").css("width","1000px");
});
<% end %>
function reset_homework(){ function reset_homework(){
$("#homework_name").val(""); $("#homework_name").val("");
$("#homework_publish_time").val(""); $("#homework_publish_time").val("");
@ -24,7 +30,7 @@
<% end %> <% end %>
} }
</script> </script>
<div class="homepageRightBanner mb10"> <div class="homepageRightBanner mb10 <%= (@is_in_course == 1 || @course_activity == 1) ? 'ml10' : '' %>">
<div class="NewsBannerName">编辑作业</div> <div class="NewsBannerName">编辑作业</div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>

@ -9,6 +9,10 @@
$(function(){ $(function(){
$("#RSide").removeAttr("id"); $("#RSide").removeAttr("id");
$("#Container").css("width","1000px"); $("#Container").css("width","1000px");
is_edit = <%= @is_edit.present? && @is_edit == true %>
if(is_edit) {
issueEditShow();
}
}); });
</script> </script>
<div class="homepageRight mt0 ml10" > <div class="homepageRight mt0 ml10" >

@ -100,7 +100,7 @@
</li> </li>
<!--<li><a href="javascript:void(0);" class="menuGrey">账号设置</a> </li>--> <!--<li><a href="javascript:void(0);" class="menuGrey">账号设置</a> </li>-->
<li> <li>
<%= link_to "退出",signout_path,:class => "menuGrey",:method => "post"%> <%= link_to "退出",logout_url_without_domain,:class => "menuGrey",:method => "post"%>
</li> </li>
</ul> </ul>
</li> </li>
@ -109,7 +109,7 @@
<div class="navHomepageNews"> <div class="navHomepageNews">
<%= link_to "", user_message_path(User.current), :class => "homepageNewsIcon", :target =>"_Blank", :title => "您的所有消息" %> <%= link_to "", user_message_path(User.current), :class => "homepageNewsIcon", :target =>"_Blank", :title => "您的所有消息" %>
<% if User.current.count_new_message >0 %> <% if User.current.count_new_message.to_i >0 %>
<div ><%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive", :target =>"_Blank" %></div> <div ><%= link_to User.current.count_new_message , user_message_path(User.current), :class => "newsActive", :target =>"_Blank" %></div>
<% end %> <% end %>
<%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %> <%#= link_to User.current.count_new_message, user_message_path(User.current), :class => "homepageNewsIcon" %>

@ -1,7 +1,7 @@
<% courses.each do |course|%> <% courses.each do |course|%>
<%# pro = Project.find course.course_id %> <%# pro = Project.find course.course_id %>
<li class="homepageLeftMenuCoursesLine" style="position:relative;"> <li class="homepageLeftMenuCoursesLine" style="position:relative;">
<%= link_to course.name, course_path(course.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => course.name%> <%= link_to course.name, course_url_in_org(course.id), :class => "coursesLineGrey hidden", :title => course.name%>
<!--<div class="homepagePostSetting mt5 mr10">--> <!--<div class="homepagePostSetting mt5 mr10">-->
<!--<ul>--> <!--<ul>-->
<!--<li class="menuSetting">--> <!--<li class="menuSetting">-->

@ -1,7 +1,7 @@
<% projects.each do |project|%> <% projects.each do |project|%>
<%# pro = Project.find project.project_id %> <%# pro = Project.find project.project_id %>
<li class="homepageLeftMenuCoursesLine" style="position:relative;"> <li class="homepageLeftMenuCoursesLine" style="position:relative;">
<%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => project.name%> <%= link_to project.name, project_url_in_org(project.id), :class => "coursesLineGrey hidden", :title => project.name%>
<!--<div class="homepagePostSetting mt5 mr10">--> <!--<div class="homepagePostSetting mt5 mr10">-->
<!--<ul>--> <!--<ul>-->
<!--<li class="menuSetting">--> <!--<li class="menuSetting">-->

@ -77,10 +77,10 @@
</div> </div>
<div id="loginInButton" class="fr ml20"> <div id="loginInButton" class="fr ml20">
<a href="<%= signin_path(:login=>true) %>" class="c_white db">登录</a> <a href="<%= signin_url_without_domain %>" class="c_white db">登录</a>
</div> </div>
<div id="loginSignButton" class="fr"> <div id="loginSignButton" class="fr">
<a href="<%= signin_path(:login=>false) %>" class="c_white db">注册</a> <a href="<%= register_url_without_domain %>" class="c_white db">注册</a>
</div> </div>
</div> </div>

@ -1,7 +1,7 @@
<% courses.each do |course|%> <% courses.each do |course|%>
<li class="homepageLeftMenuCoursesLine pr"> <li class="homepageLeftMenuCoursesLine pr">
<% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %> <% is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,course)) %>
<%= link_to course.name, course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}", <%= link_to course.name+"("+current_time_and_term_short(course)+")", course_path(course.id,:host=>Setting.host_course), :class => "coursesLineGrey hidden #{course_endTime_timeout?(course) ? 'c_dark_grey' : ''}",
:id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程:":"私有课程:")+course.name+""+current_time_and_term(course)+""%> :id => "show_course_#{course.id}", :target => '_blank', :title => (course.is_public? ? "公开课程:":"私有课程:")+course.name+""+current_time_and_term(course)+""%>
<% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %> <% count = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course' and shield_id=#{course.id}").count %>
<ul class="<%= count > 0 ? 'shild shildP':'subNavArrow'%>"> <ul class="<%= count > 0 ? 'shild shildP':'subNavArrow'%>">

@ -227,6 +227,7 @@
</ul> </ul>
<% end %> <% end %>
<% if @course.description && !@course.description.blank? %>
<div class="project_intro"> <div class="project_intro">
<div id="course_description" class="course_description"> <div id="course_description" class="course_description">
<h4 ><%= l(:label_course_brief_introduction)%></h4> <h4 ><%= l(:label_course_brief_introduction)%></h4>
@ -241,6 +242,7 @@
</span> </span>
</div> </div>
</div><!--项目简介 end--> </div><!--项目简介 end-->
<% end %>
<div class="project_Label"> <div class="project_Label">
<h4 class="mb5" ><%= l(:label_tag)%></h4> <h4 class="mb5" ><%= l(:label_tag)%></h4>
<div class="tag_h" > <div class="tag_h" >
@ -319,7 +321,7 @@
} }
}) })
//资源库上传附件
function course_files_upload(){ function course_files_upload(){
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/upload_course_files',:locals => {:course => @course,:course_attachment_type => 1}) %>'); $('#ajax-modal').html('<%= escape_javascript(render :partial => 'files/upload_course_files',:locals => {:course => @course,:course_attachment_type => 1}) %>');
showModal('ajax-modal', '513px'); showModal('ajax-modal', '513px');

@ -44,14 +44,14 @@
</li> </li>
<% if User.current.logged? %> <% if User.current.logged? %>
<li class="navOrgMenu fr" id="orgUser" style="cursor:pointer;"> <li class="navOrgMenu fr" id="orgUser" style="cursor:pointer;">
<%= link_to image_tag(url_to_avatar(User.current),:width => '23',:height => '23'), request.local? ? user_path(User.current):("https://www.trustie.net/users/" + User.current.id.to_s),:alt => '用户头像', :target => '_blank',:style=>'border-radius:3px; vertical-align:top; margin-top:3px; display:inline-block; margin-right:3px;' %> <%= link_to image_tag(url_to_avatar(User.current),:width => '23',:height => '23'), user_url_in_org(User.current.id),:alt => '用户头像', :target => '_blank',:style=>'border-radius:3px; vertical-align:top; margin-top:3px; display:inline-block; margin-right:3px;' %>
<%= link_to User.current, (request.local? || request.subdomain.blank?) ? user_path(User.current):("https://www.trustie.net/users/" + User.current.id.to_s),:id => "orgUserName",:class => 'fontGrey2 f14 mr5',:target => '_blank' %> <%= link_to User.current, user_url_in_org(User.current.id),:id => "orgUserName",:class => 'fontGrey2 f14 mr5',:target => '_blank' %>
<%= link_to "退出",(request.local? || request.subdomain.blank?) ? signout_path():"https://www.trustie.net/logout", :class =>"menuGrey", :method => 'post', :rel => "nofollow" %> <%= link_to "退出",logout_url_without_domain, :class =>"menuGrey", :method => 'post', :rel => "nofollow" %>
</li> </li>
<!--<li class="navOrgMenu fr"><%#=link_to User.current, user_path(User.current), :class => "linkGrey8 f14" %></li>--> <!--<li class="navOrgMenu fr"><%#=link_to User.current, user_path(User.current), :class => "linkGrey8 f14" %></li>-->
<% else %> <% else %>
<li class="navOrgMenu fr"><a href="<%= (request.local? || request.subdomain.blank?) ? signin_path(:login=>true):'https://www.trustie.net/login?login=true' %>" class="linkGrey8 f14">登录</a></li> <li class="navOrgMenu fr"><a href="<%= signin_url_without_domain %>" class="linkGrey8 f14">登录</a></li>
<li class="navOrgMenu fr"><a href="<%= (request.local? || request.subdomain.blank?) ? signin_path(:login=>false):'https://www.trustie.net/login?login=false' %>" class="linkGrey8 f14 mr15">注册</a></li> <li class="navOrgMenu fr"><a href="<%= register_url_without_domain %>" class="linkGrey8 f14 mr15">注册</a></li>
<% end %> <% end %>
</ul> </ul>
<!--<div class="navHomepageProfile"> <!--<div class="navHomepageProfile">

@ -28,6 +28,8 @@
}); });
</script> </script>
<script> <script>
var onUserCard = false;
var onImage = false;
$(document).ready(function(){ $(document).ready(function(){
$("#relateProject,.relatePInfo").mouseover(function(){ $("#relateProject,.relatePInfo").mouseover(function(){
$(".relatePInfo").css("display","block"); $(".relatePInfo").css("display","block");
@ -36,15 +38,24 @@
$(".relatePInfo").css("display","none"); $(".relatePInfo").css("display","none");
}) })
$(".homepagePostPortrait").mouseover(function(){ $(".homepagePostPortrait").mouseover(function(){
onImage = true;
$(this).children(".userCard").css("display","block"); $(this).children(".userCard").css("display","block");
}) })
$(".homepagePostPortrait").mouseout(function(){ $(".homepagePostPortrait").mouseout(function(){
$(this).children(".userCard").css("display","none"); var cur = $(this);
onImage = false;
setTimeout(function(){
if (onUserCard == false && onImage == false) {
$(cur).children(".userCard").css("display","none");
}
},500);
}) })
$(".userCard").mouseover(function(){ $(".userCard").mouseover(function(){
onUserCard = true;
$(this).css("display","block"); $(this).css("display","block");
}) })
$(".userCard").mouseout(function(){ $(".userCard").mouseout(function(){
onUserCard = false;
$(this).css("display","none"); $(this).css("display","none");
}) })
$(".coursesLineGrey").mouseover(function(){ $(".coursesLineGrey").mouseover(function(){
@ -193,7 +204,7 @@
<% end%> <% end%>
<% end%> <% end%>
</div> </div>
<% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %> <% courses = @user.courses.visible.where("is_delete =?", 0).select("courses.*,(SELECT MAX(updated_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").limit(5) %>
<div class="homepageLeftMenuCourses <%= courses.empty? ? 'none' : ''%>" id="homepageLeftMenuCourses"> <div class="homepageLeftMenuCourses <%= courses.empty? ? 'none' : ''%>" id="homepageLeftMenuCourses">
<ul> <ul>
<%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %> <%= render :partial => 'layouts/user_courses', :locals => {:courses => courses,:user => @user, :page => 0} %>

@ -95,8 +95,21 @@
</div> </div>
<div class="homepagePostReplyDes"> <div class="homepagePostReplyDes">
<div class="homepagePostReplyPublisher mt-4"><a href="<%=user_path(reply.author)%>" class="newsBlue mr10 f14"><%= reply.author.name%></a><%= format_date(reply.created_at) %></div> <div class="homepagePostReplyPublisher mt-4"><a href="<%=user_path(reply.author)%>" class="newsBlue mr10 f14"><%= reply.author.name%></a><%= format_date(reply.created_at) %></div>
<div class="homepagePostReplyContent"><%= reply.content.html_safe%></div> <div class="homepagePostReplyContent" id="activity_description_<%= reply.id %>"><%= reply.content.html_safe%></div>
</div> </div>
<script type="text/javascript">
$(function(){
$("#activity_description_<%= reply.id %> p,#activity_description__<%= reply.id %> span,#activity_description_<%= reply.id %> em").each(function(){
var postContent = $(this).html();
postContent = postContent.replace(/&nbsp;/g," ");
postContent= postContent.replace(/ {2}/g,"&nbsp; ");
postContent=postContent.replace(/&nbsp; &nbsp;/g,"&nbsp;&nbsp;&nbsp;");
postContent=postContent.replace(/&nbsp; /g,"&nbsp;&nbsp; ");
$(this).html(postContent);
});
description_show_hide(<%= reply.id %>);
});
</script>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<% end %> <% end %>

@ -34,11 +34,7 @@
<div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @topic.id%>').show();" onmouseout="$('#message_setting_<%= @topic.id%>').hide();"> <div class="postRightContainer ml10" onmouseover="$('#message_setting_<%= @topic.id%>').show();" onmouseout="$('#message_setting_<%= @topic.id%>').hide();">
<div class="postThemeContainer"> <div class="postThemeContainer">
<div class="postDetailPortrait"> <div class="postDetailPortrait">
<% if @topic.status == 1 %> <%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50,:alt=>'图像' ), user_path(@topic.author) %>
<%= image_tag("/images/trustie_logo1.png", width: "50px", height: "50px") %>
<% else %>
<%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50,:alt=>'图像' ), user_path(@topic.author) %>
<% end %>
</div> </div>
<div class="postThemeWrap"> <div class="postThemeWrap">
<% if User.current.logged? %> <% if User.current.logged? %>
@ -74,16 +70,11 @@
<a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= @topic.subject%></a> <a href="javascript:void(0);" class="f14 linkGrey4 fb" style="overflow:hidden;">主题: <%= @topic.subject%></a>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="postDetailCreater"> <div class="postDetailCreater">
<% if @topic.status == 1 %> <% if @topic.try(:author).try(:realname) == ' ' %>
<span class="fontBlue2">确实团队</span> <%= link_to @topic.try(:author), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<% else %> <% else %>
<% if @topic.try(:author).try(:realname) == ' ' %> <%= link_to @topic.try(:author).try(:realname), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<%= link_to @topic.try(:author), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<% else %>
<%= link_to @topic.try(:author).try(:realname), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<% end %>
<% end %> <% end %>
</div> </div>
<div class="postDetailDate mb5"><%= format_time( @topic.created_on)%></div> <div class="postDetailDate mb5"><%= format_time( @topic.created_on)%></div>

@ -12,6 +12,7 @@
<% end %> <% end %>
<% elsif @message.course %> <% elsif @message.course %>
<div nhname="topic_form">
<%= form_for @message, { <%= form_for @message, {
:as => :message, :as => :message,
:url => {:action => 'edit',:is_course=>@is_course,:is_board=>@is_board}, :url => {:action => 'edit',:is_course=>@is_course,:is_board=>@is_board},
@ -22,7 +23,7 @@
<%= render :partial => 'boards/course_message_edit', <%= render :partial => 'boards/course_message_edit',
:locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %> :locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %>
<% end %> <% end %>
</div>
<% elsif @message.board.org_subfield %> <% elsif @message.board.org_subfield %>
<%= form_for @message, { <%= form_for @message, {
:as => :message, :as => :message,

@ -50,6 +50,8 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<p id="homework_course_id_span" class="c_red mt5"></p> <p id="homework_course_id_span" class="c_red mt5"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
<div class="cl"></div> <div class="cl"></div>
<div class="mt10"> <div class="mt10">
<div class="fl" id="topic_attachments"> <div class="fl" id="topic_attachments">

@ -39,6 +39,8 @@
<div class="cl"></div> <div class="cl"></div>
<p id="homework_course_id_span" class="c_red mt5"></p> <p id="homework_course_id_span" class="c_red mt5"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
<div class="cl"></div> <div class="cl"></div>
<div class="mt10"> <div class="mt10">

@ -46,6 +46,8 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<p id="homework_course_id_span" class="c_red mt5"></p> <p id="homework_course_id_span" class="c_red mt5"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
<div class="cl"></div> <div class="cl"></div>
<div class="mt10"> <div class="mt10">
<div class="fl" id="topic_attachments"> <div class="fl" id="topic_attachments">

@ -8,11 +8,11 @@
<div class="resources" id="organization_document_<%= @document.id %>"> <div class="resources" id="organization_document_<%= @document.id %>">
<div class="homepagePostBrief"> <div class="homepagePostBrief">
<div class="homepagePostPortrait"> <div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_path(@document.creator_id) %> <%= link_to image_tag(url_to_avatar(User.find(@document.creator_id)), :width => 45, :heigth => 45), user_url_in_org(@document.creator_id) %>
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTo"> <div class="homepagePostTo">
<%= link_to User.find(@document.creator_id), user_path(@document.creator.id), :class => "newsBlue mr15" %> <%= link_to User.find(@document.creator_id), user_url_in_org(@document.creator_id), :class => "newsBlue mr15" %>
TO&nbsp;&nbsp;<%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %> TO&nbsp;&nbsp;<%= link_to @document.organization.name, organization_path(@document.organization), :class => "newsBlue" %>
| |
<% if @document.organization.home_id == @document.id %> <% if @document.organization.home_id == @document.id %>
@ -89,10 +89,10 @@
<% user = User.find(reply.creator_id) %> <% user = User.find(reply.creator_id) %>
<div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id %>').hide();"> <div class="homepagePostReplyContainer" onmouseover="$('#reply_edit_menu_<%= reply.id%>').show();" onmouseout="$('#reply_edit_menu_<%= reply.id %>').hide();">
<div class="homepagePostReplyPortrait"> <div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(user), :width => 33,:height => 33), user_path(user) %> <%= link_to image_tag(url_to_avatar(user), :width => 33,:height => 33), user_url_in_org(user.id) %>
</div> </div>
<div class="homepagePostReplyDes"> <div class="homepagePostReplyDes">
<%= link_to User.find(reply.creator_id).realname, user_path(reply.creator_id), :class => "newsBlue mr10 f14" %> <%= link_to User.find(reply.creator_id).realname, user_url_in_org(reply.creator_id), :class => "newsBlue mr10 f14" %>
<div class="homepagePostReplyContent upload_img break_word" id="reply_message_description_<%= reply.id %>"> <div class="homepagePostReplyContent upload_img break_word" id="reply_message_description_<%= reply.id %>">
<%= reply.content.html_safe unless reply.content.nil? %> <%= reply.content.html_safe unless reply.content.nil? %>
</div> </div>

@ -1,4 +1,5 @@
<script> <script>
var onUserCard = false;
$(document).ready(function(){ $(document).ready(function(){
$("#relateProject,.relatePInfo").mouseover(function(){ $("#relateProject,.relatePInfo").mouseover(function(){
$(".relatePInfo").css("display","block"); $(".relatePInfo").css("display","block");
@ -6,18 +7,6 @@
$("#relateProject,.relatePInfo").mouseout(function(){ $("#relateProject,.relatePInfo").mouseout(function(){
$(".relatePInfo").css("display","none"); $(".relatePInfo").css("display","none");
}) })
$(".homepagePostPortrait").mouseover(function(){
$(this).children(".userCard").css("display","block");
})
$(".homepagePostPortrait").mouseout(function(){
$(this).children(".userCard").css("display","none");
})
$(".userCard").mouseover(function(){
$(this).css("display","block");
})
$(".userCard").mouseout(function(){
$(this).css("display","none");
})
$(".coursesLineGrey").mouseover(function(){ $(".coursesLineGrey").mouseover(function(){
$(this).css("color","#ffffff"); $(this).css("color","#ffffff");
}) })

@ -1,8 +1,7 @@
<% if @res %> <% if @res %>
$("#org_subfield_list").html(""); $("#org_subfield_list").html("");
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',
:locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), :locals => {:subfields => @organization.org_subfields.order("priority") }) %>");
:subfields => @organization.org_subfields.where("field_type != 'default'") }) %>");
$("#sub_field_left_lists").html(""); $("#sub_field_left_lists").html("");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); $("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
$("#subfield_name").val(""); $("#subfield_name").val("");

@ -1,6 +1,5 @@
$("#org_subfield_list").html(""); $("#org_subfield_list").html("");
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',
:locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), :locals => {:subfields => @organization.org_subfields.order("priority") }) %>");
:subfields => @organization.org_subfields.where("field_type != 'default'") }) %>");
$("#sub_field_left_lists").html(""); $("#sub_field_left_lists").html("");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); $("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");

@ -0,0 +1,2 @@
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields.order("priority")}) %>");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");

@ -6,18 +6,6 @@
$("#relateProject,.relatePInfo").mouseout(function(){ $("#relateProject,.relatePInfo").mouseout(function(){
$(".relatePInfo").css("display","none"); $(".relatePInfo").css("display","none");
}) })
$(".homepagePostPortrait").mouseover(function(){
$(this).children(".userCard").css("display","block");
})
$(".homepagePostPortrait").mouseout(function(){
$(this).children(".userCard").css("display","none");
})
$(".userCard").mouseover(function(){
$(this).css("display","block");
})
$(".userCard").mouseout(function(){
$(this).css("display","none");
})
$(".coursesLineGrey").mouseover(function(){ $(".coursesLineGrey").mouseover(function(){
$(this).css("color","#ffffff"); $(this).css("color","#ffffff");
}) })

@ -12,10 +12,10 @@
<%= link_to activity.try(:teacher).try(:realname), user_url_in_org(activity.tea_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:teacher).try(:realname), user_url_in_org(activity.tea_id), :class => "newsBlue mr15" %>
<% end %> <% end %>
TO TO
<%= link_to activity.name.to_s+" | 课程", course_path(activity.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> <%= link_to activity.name.to_s+" | 课程", course_url_in_org(activity.id), :class => "newsBlue ml15" %>
</div> </div>
<div class="homepagePostTitle break_word" > <div class="homepagePostTitle break_word" >
<%= link_to activity.name, course_path(activity.id,:host=>Setting.host_course), :class => "postGrey" %> <%= link_to activity.name, course_url_in_org(activity.id), :class => "postGrey" %>
</div> </div>
<div class="homepagePostDate"> <div class="homepagePostDate">
创建时间:<%= format_time(activity.created_at) %> 创建时间:<%= format_time(activity.created_at) %>

@ -12,10 +12,10 @@
<% else %> <% else %>
<%= link_to activity.try(:user).try(:realname), user_url_in_org(activity.user_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:user).try(:realname), user_url_in_org(activity.user_id), :class => "newsBlue mr15" %>
<% end %> TO <!--+"(课程名称)" --> <% end %> TO <!--+"(课程名称)" -->
<%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%> <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_url_in_org(activity.course.id), :class => "newsBlue ml15"%>
</div> </div>
<div class="homepagePostTitle hidden m_w505 fl"> <!--+"(作业名称)"--> <div class="homepagePostTitle hidden m_w505 fl"> <!--+"(作业名称)"-->
<%= link_to activity.name.to_s, student_work_index_path(:homework => activity.id,:host=> Setting.host_course), :class => "postGrey"%> <%= link_to activity.name.to_s, student_work_index_url_in_org(activity.id), :class => "postGrey"%>
</div> </div>
<% if activity.homework_detail_manual%> <% if activity.homework_detail_manual%>
<% if activity.homework_detail_manual.comment_status == 1%> <% if activity.homework_detail_manual.comment_status == 1%>
@ -47,7 +47,7 @@
<% end%> <% end%>
<div class="cl"></div> <div class="cl"></div>
<% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1%> <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1%>
<span class="c_red">系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span> <span class="c_red">系统提示:该作业要求各组长<%=link_to "创建项目", "https://www.trustie.net/projects/new",:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!</span>
<% elsif activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 0%> <% elsif activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 0%>
<span class="c_red">系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!</span> <span class="c_red">系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!</span>
<% end %> <% end %>
@ -73,7 +73,7 @@
<% if activity.homework_type == 2 && is_teacher%> <% if activity.homework_type == 2 && is_teacher%>
<div class="homepagePostSubmit"> <div class="homepagePostSubmit">
<%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %> <%= link_to "模拟答题", Setting.protocol + "://" + Setting.host_name + "/users/new_user_commit_homework?homework_id="+activity.id.to_s + "&is_test=true", class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
</div> </div>
<% end %> <% end %>
<% if activity.homework_type == 2%> <% if activity.homework_type == 2%>
@ -129,7 +129,7 @@
<% if activity.student_works.count != 0 %> <% if activity.student_works.count != 0 %>
<% sw = activity.student_works.reorder("created_at desc").first %> <% sw = activity.student_works.reorder("created_at desc").first %>
<div class="mt10 homepagePostDeadline mb10"> <div class="mt10 homepagePostDeadline mb10">
#&nbsp;<%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品 #&nbsp;<%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_url_in_org(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
</div> </div>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
@ -141,7 +141,7 @@
<% last_score = student_work_scores.first %> <% last_score = student_work_scores.first %>
<div> <div>
<p class="mb10 fontGrey2">#&nbsp;<%=time_from_now last_score.created_at %> <p class="mb10 fontGrey2">#&nbsp;<%=time_from_now last_score.created_at %>
<%= link_to last_score.user.show_name, user_activities_path(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行: <%= link_to last_score.user.show_name, user_activities_url_in_org(last_score.user_id), :class => "newsBlue ml5 mr5"%>评阅了作品,优秀排行:
</p> </p>
</div> </div>
<% end %> <% end %>
@ -154,18 +154,8 @@
<% end %> <% end %>
<% student_works.each_with_index do |sw, i| %> <% student_works.each_with_index do |sw, i| %>
<div class="fl mr10 w100" style="text-align:center;"> <div class="fl mr10 w100" style="text-align:center;">
<a href="javascript:void(0);" class="linkBlue"> <a href="javascript:void(0);" class="linkBlue"><%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_url_in_org(activity.id), :alt => "学生头像" %>
<% if User.current.member_of_course?(activity.course) || User.current.admin? || activity.is_open == 1 %> <p class="w100 hidden"><%= link_to sw.user.show_name, student_work_index_url_in_org(activity.id)%></p>
<%= link_to image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40"), student_work_index_path(:homework => activity.id), :alt => "学生头像" %>
<p class="w100 hidden">
<%= link_to sw.user.show_name, student_work_index_path(:homework => activity.id)%>
</p>
<% else %>
<%= image_tag(url_to_avatar(User.find sw.user_id), :width => "40", :height => "40", :title => '该作业的作品暂未公开') %>
<p class="w100 hidden">
<a href="javascript:void(0);" title="该作业的作品暂未公开"><%=sw.user.show_name %></a>
</p>
<% end %>
</a> </a>
<% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %> <% score = sw.respond_to?("score") ? sw.score : (sw.final_score || 0) - sw.absence_penalty - sw.late_penalty %>
<p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分</span></p> <p class="fontGrey2">分数:<span class="c_red"><%=format("%.1f",score.to_i<0 ? 0 : score.to_i) %>分</span></p>
@ -175,7 +165,7 @@
<% end %> <% end %>
<% end %> <% end %>
<% if student_works.count > 5 %> <% if student_works.count > 5 %>
<%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%> <%= link_to "更多>>", student_work_index_url_in_org(activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
@ -187,7 +177,7 @@
<% sort_projects = project_sort_update projects %> <% sort_projects = project_sort_update projects %>
<div class="mt10 relatePWrap" id="relatePWrap_<%=user_activity_id %>"> <div class="mt10 relatePWrap" id="relatePWrap_<%=user_activity_id %>">
<div class="mr5 fontGrey2"> <div class="mr5 fontGrey2">
#&nbsp;<%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_path(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新: #&nbsp;<%=time_from_now sort_projects.first.updated_at %><%= link_to User.find(sort_projects.first.user_id).show_name, user_activities_url_in_org(sort_projects.first.user_id), :class => "newsBlue ml5 mr5"%>更新了项目,最近更新:
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<% sort_projects.each_with_index do |pro, i| %> <% sort_projects.each_with_index do |pro, i| %>
@ -204,7 +194,7 @@
<div class="mr10 mb10 mt10 fl w100 fontGrey2" style="text-align: center;"> <div class="mr10 mb10 mt10 fl w100 fontGrey2" style="text-align: center;">
<% if project.is_public || User.current.member_of?(project) || User.current.admin? %> <% if project.is_public || User.current.member_of?(project) || User.current.admin? %>
<%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像" %> <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_url_in_org(project.id),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像" %>
<% else %> <% else %>
<%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像") %> <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像") %>
<% end %> <% end %>
@ -237,17 +227,17 @@
<li class="homepagePostSettingIcon"> <li class="homepagePostSettingIcon">
<ul class="homepagePostSettiongText"> <ul class="homepagePostSettiongText">
<li> <li>
<%= link_to l(:button_edit),edit_homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity), :class => "postOptionLink"%> <%= link_to l(:button_edit),Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/edit?", :class => "postOptionLink"%>
</li> </li>
<li> <li>
<%= link_to(l(:label_bid_respond_delete), homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %> <%= link_to(l(:label_bid_respond_delete), Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "?is_in_course=-1&course_activity=" + course_activity.to_s,:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
</li> </li>
<li> <li>
<%= link_to("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => 0),:class => "postOptionLink", :remote => true) %> <%= link_to("评分设置", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/score_rule_set?is_in_course=0&user_activity_id=" + user_activity_id.to_s,:class => "postOptionLink", :remote => true) %>
</li> </li>
<% if activity.anonymous_comment == 0 %> <% if activity.anonymous_comment == 0 %>
<li> <li>
<%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%> <%= link_to("匿评设置", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/start_evaluation_set",:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%>
</li> </li>
<li> <li>
<%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %> <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %>
@ -255,17 +245,17 @@
<% end %> <% end %>
<% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%> <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
<li> <li>
<%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", <%= link_to("禁用匿评", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_forbidden_anonymous_comment?user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink",
:title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品",:remote => true)%> :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品",:remote => true)%>
</li> </li>
<% end %> <% end %>
<% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %> <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
<li> <li>
<%= link_to("公开作品", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> <%= link_to("公开作品", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_open_student_works?is_in_course=-1&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :remote => true)%>
</li> </li>
<% elsif activity.is_open == 1 %> <% elsif activity.is_open == 1 %>
<li> <li>
<%= link_to("取消公开", alert_open_student_works_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => -1,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%> <%= link_to("取消公开", Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/alert_open_student_works?is_in_course=-1&user_activity_id=" + user_activity_id.to_s + "&course_activity=" + course_activity.to_s,:class => "postOptionLink", :remote => true)%>
</li> </li>
<% end %> <% end %>
</ul> </ul>
@ -356,7 +346,7 @@
<%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %> <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %>
<div nhname='toolbar_container_<%= user_activity_id%>'></div> <div nhname='toolbar_container_<%= user_activity_id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="homework_message"></textarea> <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="homework_message"></textarea>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a> <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div> <div class="cl"></div>
<p nhname='contentmsg_<%= user_activity_id%>'></p> <p nhname='contentmsg_<%= user_activity_id%>'></p>
<% end%> <% end%>

@ -12,13 +12,13 @@
<%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
<% end %> <% end %>
TO TO
<%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%> <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_url_in_org(activity.course.id), :class => "newsBlue ml15 mr5"%>
</div> </div>
<div class="homepagePostTitle hidden m_w530 fl"> <div class="homepagePostTitle hidden m_w530 fl">
<% if activity.parent_id.nil? %> <!--+"(帖子标题)"--> <% if activity.parent_id.nil? %> <!--+"(帖子标题)"-->
<%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %> <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :class=> "postGrey" %>
<% else %> <% else %>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%> <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :class=> "postGrey"%>
<% end %> <% end %>
</div> </div>
<% if activity.sticky == 1%> <% if activity.sticky == 1%>

@ -11,10 +11,10 @@
<% else %> <% else %>
<%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
<% end %> TO <!--+"(课程名称)"--> <% end %> TO <!--+"(课程名称)"-->
<%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %> <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_url_in_org(activity.course.id), :class => "newsBlue ml15" %>
</div> </div>
<div class="homepagePostTitle break_word hidden fl m_w600"> <!--+"(通知标题)"--> <div class="homepagePostTitle break_word hidden fl m_w600"> <!--+"(通知标题)"-->
<%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %> <%= link_to activity.title.to_s, news_url_in_org(activity.id), :class => "postGrey" %>
</div> </div>
<% if activity.sticky == 1%> <% if activity.sticky == 1%>
<span class="sticky_btn_cir ml10">置顶</span> <span class="sticky_btn_cir ml10">置顶</span>
@ -110,7 +110,7 @@
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>"> <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<div nhname='toolbar_container_<%= user_activity_id%>'></div> <div nhname='toolbar_container_<%= user_activity_id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="comment"></textarea> <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="comment"></textarea>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a> <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div> <div class="cl"></div>
<p nhname='contentmsg_<%= user_activity_id%>'></p> <p nhname='contentmsg_<%= user_activity_id%>'></p>
<% end%> <% end%>

@ -16,15 +16,15 @@
<%= link_to activity.try(:user).try(:realname), user_url_in_org(activity.user_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:user).try(:realname), user_url_in_org(activity.user_id), :class => "newsBlue mr15" %>
<% end %> <% end %>
TO TO
<%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", poll_index_path(:polls_type => "Course", :polls_group_id => activity.polls_group_id), :class => "newsBlue ml15" %> <%= link_to Course.find(activity.polls_group_id).name.to_s+" | 问卷", Setting.protocol + "://" + Setting.host_name + "/poll?polls_type=Course&polls_group_id=" + activity.polls_group_id.to_s, :class => "newsBlue ml15" %>
<!--<a href="javascript:void(0);" class="newsBlue ml15">分布式计算环境(课程名称)</a>--> <!--<a href="javascript:void(0);" class="newsBlue ml15">分布式计算环境(课程名称)</a>-->
</div> </div>
<div class="homepagePostTitle break_word" > <div class="homepagePostTitle break_word" >
<%#= link_to activity.polls_name.to_s/*+"(问卷名称)"*/, %> <%#= link_to activity.polls_name.to_s/*+"(问卷名称)"*/, %>
<% if has_commit %> <% if has_commit %>
<%= link_to poll_name, poll_result_poll_path(activity.id), :class => "postGrey"%> <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s + "/poll_result", :class => "postGrey"%>
<% else %> <% else %>
<%= link_to poll_name, poll_path(activity.id), :class => "postGrey"%> <%= link_to poll_name, Setting.protocol + "://" + Setting.host_name + "/poll/" + activity.id.to_s, :class => "postGrey"%>
<% end %> <% end %>
</div> </div>
<div class="homepagePostDate fl"> <div class="homepagePostDate fl">

@ -1,4 +1,6 @@
<script> <script>
var onUserCard = false;
var onImage = false;
$(document).ready(function(){ $(document).ready(function(){
$("#relateProject,.relatePInfo").mouseover(function(){ $("#relateProject,.relatePInfo").mouseover(function(){
$(".relatePInfo").css("display","block"); $(".relatePInfo").css("display","block");
@ -7,15 +9,24 @@
$(".relatePInfo").css("display","none"); $(".relatePInfo").css("display","none");
}) })
$(".homepagePostPortrait").mouseover(function(){ $(".homepagePostPortrait").mouseover(function(){
onImage = true;
$(this).children(".userCard").css("display","block"); $(this).children(".userCard").css("display","block");
}) })
$(".homepagePostPortrait").mouseout(function(){ $(".homepagePostPortrait").mouseout(function(){
$(this).children(".userCard").css("display","none"); var cur = $(this);
onImage = false;
setTimeout(function(){
if (onUserCard == false && onImage == false) {
$(cur).children(".userCard").css("display", "none");
}
}, 500);
}) })
$(".userCard").mouseover(function(){ $(".userCard").mouseover(function(){
onUserCard = true;
$(this).css("display","block"); $(this).css("display","block");
}) })
$(".userCard").mouseout(function(){ $(".userCard").mouseout(function(){
onUserCard = false;
$(this).css("display","none"); $(this).css("display","none");
}) })
$(".coursesLineGrey").mouseover(function(){ $(".coursesLineGrey").mouseover(function(){
@ -34,71 +45,76 @@
}) })
}) })
</script> </script>
<% org_activity_field = organization.org_subfields.where('field_type="default" and name="activity" and field_type="default"').first %>
<% org_course_field = organization.org_subfields.where('field_type="default" and name="course" and field_type="default"').first %>
<% org_project_field = organization.org_subfields.where('field_type="default" and name="project" and field_type="default"').first %>
<div class="homepageLeftMenuBlock" style="display:<%= is_hide_org_left(org_activity_field) ? 'block':'none' %>;" id="org_subfield_<%= org_activity_field.id %>">
<%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
</div>
<div style="display:<%= is_hide_org_left(org_project_field) ? 'block':'none' %>;" id="org_subfield_<%= org_project_field.id %>">
<div class="homepageLeftMenuBlock">
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuProjects').slideToggle();">项目</a>
<% if User.current.logged? and User.current.admin_of_org?(organization) %>
<%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%>
<% end %>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuProjects" style="display:<%= organization.projects.count == 0?'none':'' %>">
<ul >
<%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> <% organization.org_subfields.order("priority").each do |field| %>
</ul> <% if is_default_field?(field) %>
</div> <% case field.name %>
</div> <% when 'activity' %>
<div style="display:<%= is_hide_org_left(org_course_field) ? 'block':'none' %>;" id="org_subfield_<%= org_course_field.id %>"> <div class="homepageLeftMenuBlock" style="display:<%= field.hide == 0 ? 'block':'none' %>;" id="org_subfield_<%= field.id %>">
<div class="homepageLeftMenuBlock"> <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuCourses').slideToggle();">课程</a> </div>
<% if User.current.logged? and User.current.admin_of_org?(organization) %> <% when 'course' %>
<%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> <div style="display:<%= field.hide == 0 ? 'block':'none' %>;" id="org_subfield_<%= field.id %>">
<% end %> <div class="homepageLeftMenuBlock">
</div> <a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuCourses').slideToggle();">课程</a>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuCourses" style="display:<%= organization.courses.count == 0 ?'none':'' %>"> <% if User.current.logged? and User.current.admin_of_org?(organization) %>
<ul > <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%>
<%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> <% end %>
</ul> </div>
</div> <div class="homepageLeftMenuCourses" id="homepageLeftMenuCourses" style="display:<%= organization.courses.count == 0 ?'none':'' %>">
</div> <ul >
<% organization.org_subfields.where("field_type != 'default'").each do |field| %> <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
<div class="homepageLeftMenuBlock" style="display:<%= field.hide == 0?'block':'none' %>;" id="org_subfield_<%= field.id %>"> </ul>
<% if field.field_type == "Post" %> </div>
<% if !field.subfield_subdomain_dir.nil? %> </div>
<% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> <% when 'project' %>
<%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> <div style="display:<%= field.hide == 0 ? 'block':'none' %>;" id="org_subfield_<%= field.id %>">
<div class="homepageLeftMenuBlock">
<a href="javascript:void(0);" class="homepageMenuText" onclick="$('#homepageLeftMenuProjects').slideToggle();">项目</a>
<% if User.current.logged? and User.current.admin_of_org?(organization) %>
<%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%>
<% end %>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuProjects" style="display:<%= organization.projects.count == 0?'none':'' %>">
<ul>
<%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
</ul>
</div>
</div>
<% end %>
<% else %>
<div class="homepageLeftMenuBlock" style="display:<%= field.hide == 0?'block':'none' %>;" id="org_subfield_<%= field.id %>">
<% if field.field_type == "Post" %>
<% if !field.subfield_subdomain_dir.nil? %>
<% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %>
<%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
<% else %>
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
<% end %>
<% else %> <% else %>
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> <%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %>
<% end %>
<% if User.current.member_of_org?organization %>
<%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%>
<% end %> <% end %>
<% else %> <% else %>
<%= link_to "#{field.name}", organization_path(organization, :org_subfield_id => field.id), :class => "homepageMenuText" %> <% if !field.subfield_subdomain_dir.nil? %>
<% end %> <% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %>
<% if User.current.member_of_org?organization %> <%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
<%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> <% else %>
<% end %> <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %>
<% else %> <% end %>
<% if !field.subfield_subdomain_dir.nil? %> <% else %>
<% if !request.local? and Secdomain.where("sub_type=2 and pid=?", organization.id).count > 0 and Secdomain.where("sub_type=2 and pid=?", organization.id).map(&:subname).include?(request.subdomain) %> <%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %>
<%= link_to "#{field.name}", show_subfield_without_id_path(:sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> <% end %>
<% else %> <% if User.current.member_of_org?organization %>
<%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :sub_dir_name => field.subfield_subdomain_dir.name), :class => "homepageMenuText" %> <%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %>
<!--<a class="homepageMenuSetting fr" title="上传资源" href="javascript:void(0);" onclick="org_subfield_files_upload(<%#= field.id %>);"> </a>-->
<% end %>
<!--<a href="javascript:void(0);" class="homepageMenuText"><%#= field.name %></a>-->
<% end %> <% end %>
<% else %> </div>
<%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %> <div class="homepageLeftMenuCourses" id="homepageLeftMenuField_<%= field.id %>" style="display:none;">
<% end %> </div>
<% if User.current.member_of_org?organization %> <% end %>
<%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %>
<!--<a class="homepageMenuSetting fr" title="上传资源" href="javascript:void(0);" onclick="org_subfield_files_upload(<%#= field.id %>);"> </a>-->
<% end %>
<!--<a href="javascript:void(0);" class="homepageMenuText"><%#= field.name %></a>-->
<% end %>
</div>
<div class="homepageLeftMenuCourses" id="homepageLeftMenuField_<%= field.id %>" style="display:none;">
</div>
<% end %> <% end %>

@ -1,9 +1,9 @@
<% members.each do |member|%> <% members.each do |member|%>
<ul class="orgListRow"> <ul class="orgListRow">
<li class="orgListUser"><a href="<%= user_path(User.find(member.user_id))%>" class="linkBlue"><%= User.find(member.user_id).realname.blank? ? User.find(member.user_id).login : User.find(member.user_id).realname %></a></li> <li class="orgListUser"><a href="<%= user_url_in_org(member.user_id) %>" class="linkBlue"><%= User.find(member.user_id).realname.blank? ? User.find(member.user_id).login : User.find(member.user_id).realname %></a></li>
<li class="orgListRole"> <li class="orgListRole">
<%= get_org_member_role_name member %> <%= get_org_member_role_name member %>
<%= form_for(member, {:as => :org_member, :remote => true, :url => org_member_path(member), <%= form_for(member, {:as => :org_member, :remote => true, :url => Setting.protocol + "://" + Setting.host_name + "/org_member/" + member.id.to_s,
:method => :put, :method => :put,
:html => {:id => "org-member-#{member.id}-roles-form", :style=>'display:none'}} :html => {:id => "org-member-#{member.id}-roles-form", :style=>'display:none'}}
) do |f| %> ) do |f| %>
@ -32,7 +32,7 @@
</li> </li>
<% if ( (User.current.id == member.organization.creator_id || User.current.admin_of_org?(member.organization) ) && member.user_id != member.organization.creator_id )%> <% if ( (User.current.id == member.organization.creator_id || User.current.admin_of_org?(member.organization) ) && member.user_id != member.organization.creator_id )%>
<a href="javascript:void(0);" style="color: #0781B4;margin-left: 30px;float: left" onclick="$(this).parent().height(70);$('#org-member-<%= member.id%>-roles-form').show();">编辑</a> <a href="javascript:void(0);" style="color: #0781B4;margin-left: 30px;float: left" onclick="$(this).parent().height(70);$('#org-member-<%= member.id%>-roles-form').show();">编辑</a>
<%= link_to '删除', org_member_path(member.id),:method=>'delete',:style=>'color: #0781B4;margin-left: 30px;float: left',:confirm=>'您确定要删除么?', :remote => true %><% end %> <%= link_to '删除', Setting.protocol + "://" + Setting.host_name + "/org_member/" + member.id.to_s,:method=>'delete',:style=>'color: #0781B4;margin-left: 30px;float: left',:confirm=>'您确定要删除么?', :remote => true %><% end %>
<div class="cl"></div> <div class="cl"></div>
</ul> </ul>
<% end %> <% end %>

@ -14,7 +14,7 @@
<%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %> <%= member.user.nil? ? '' : (image_tag(url_to_avatar(member.user), :width => 32, :height => 32)) %>
</a> </a>
<span class="fl ml10 c_grey"><%= l(:label_username)%></span> <span class="fl ml10 c_grey"><%= l(:label_username)%></span>
<%= link_to(member.user.show_name, user_path(member.user),:class => "ml5 c_blue02") %><br /> <%= link_to(member.user.show_name, user_url_in_org(member.user_id),:class => "ml5 c_blue02") %><br />
<span class="fl c_grey ml10">身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %></span> <span class="fl c_grey ml10">身份:<%= member.user.admin_of_org?(organization)?"组织管理员":"组织成员" %></span>
<% if member.created_at %> <% if member.created_at %>
<span class="fr c_grey"><%= format_time(member.created_at) %></span> <span class="fr c_grey"><%= format_time(member.created_at) %></span>

@ -11,10 +11,10 @@
<% else %> <% else %>
<%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
<% end %> TO <% end %> TO
<%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%> <%= link_to activity.project.name.to_s+" | 项目问题", project_issues_url_in_org(activity.project.id), :class => "newsBlue ml15"%>
</div> </div>
<div class="homepagePostTitle break_word"> <div class="homepagePostTitle break_word">
<%= link_to activity.subject.to_s, issue_path(activity), :class => "postGrey" %> <%= link_to activity.subject.to_s, issue_url_in_org(activity.id), :class => "postGrey" %>
<span class='<%#= get_issue_priority(activity.priority_id)[0] %>'> <span class='<%#= get_issue_priority(activity.priority_id)[0] %>'>
<%#= get_issue_priority(activity.priority_id)[1] %> <%#= get_issue_priority(activity.priority_id)[1] %>
</span> </span>
@ -127,7 +127,7 @@
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>"> <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<div nhname='toolbar_container_<%= user_activity_id%>'></div> <div nhname='toolbar_container_<%= user_activity_id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="notes"></textarea> <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="notes"></textarea>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a> <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div> <div class="cl"></div>
<p nhname='contentmsg_<%= user_activity_id%>'></p> <p nhname='contentmsg_<%= user_activity_id%>'></p>
<% end%> <% end%>

@ -3,21 +3,21 @@
<div class="resources mt10"> <div class="resources mt10">
<div class="homepagePostBrief"> <div class="homepagePostBrief">
<div class="homepagePostPortrait"> <div class="homepagePostPortrait">
<%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user), :alt => "用户头像" %> <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user.id), :alt => "用户头像" %>
<%= render :partial => 'users/show_detail_info', :locals => {:user => user} %> <%= render :partial => 'users/show_detail_info', :locals => {:user => user} %>
</div> </div>
<div class="homepagePostDes"> <div class="homepagePostDes">
<div class="homepagePostTo break_word mt-4"> <div class="homepagePostTo break_word mt-4">
<% if user.try(:realname) == ' ' %> <% if user.try(:realname) == ' ' %>
<%= link_to user, user_url_in_org(user), :class => "newsBlue mr15" %> <%= link_to user, user_url_in_org(user.id), :class => "newsBlue mr15" %>
<% else %> <% else %>
<%= link_to user.try(:realname), user_url_in_org(user), :class => "newsBlue mr15" %> <%= link_to user.try(:realname), user_url_in_org(user.id), :class => "newsBlue mr15" %>
<% end %> <% end %>
TO TO
<%= link_to project.to_s+" | 项目", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> <%= link_to project.to_s+" | 项目", project_url_in_org(project.id), :class => "newsBlue ml15" %>
</div> </div>
<div class="homepagePostTitle break_word" > <div class="homepagePostTitle break_word" >
<%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %> <%= link_to project.name, project_url_in_org(project.id), :class => "postGrey" %>
</div> </div>
<div class="homepagePostDate"> <div class="homepagePostDate">
创建时间:<%= format_time(project.created_on) %> 创建时间:<%= format_time(project.created_on) %>

@ -12,16 +12,15 @@
<%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %> <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
<% end %> <% end %>
TO TO
<%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_path(activity.project), :class => "newsBlue ml15 mr5"%> <%= link_to activity.project.name.to_s+" | 项目讨论区",project_boards_url_in_org(activity.project.id), :class => "newsBlue ml15 mr5"%>
<!--<a href="javascript:void(0);" class="newsBlue ml15 mr5"><%= activity.project.name %>(项目讨论区)</a>--> <!--<a href="javascript:void(0);" class="newsBlue ml15 mr5"><%= activity.project.name %>(项目讨论区)</a>-->
</div> </div>
<div class="homepagePostTitle break_word"> <div class="homepagePostTitle break_word">
<% if activity.parent_id.nil? %> <% if activity.parent_id.nil? %>
<%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board.id,activity.id), :class=> "postGrey"
%> %>
<% else %> <% else %>
<%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board.id,activity.id), :class=> "postGrey" %>
%>
<% end %> <% end %>
</div> </div>
<div class="homepagePostDate fl"> <div class="homepagePostDate fl">
@ -122,7 +121,7 @@
<input type="hidden" name="user_activity_id" value="<%=user_activity_id%>"> <input type="hidden" name="user_activity_id" value="<%=user_activity_id%>">
<div nhname='toolbar_container_<%= user_activity_id%>'></div> <div nhname='toolbar_container_<%= user_activity_id%>'></div>
<textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea> <textarea placeholder="有问题或有建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= user_activity_id%>' name="reply[content]"></textarea>
<a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a> <a id="new_message_submit_btn_<%= user_activity_id%>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;">发送</a>
<div class="cl"></div> <div class="cl"></div>
<p nhname='contentmsg_<%= user_activity_id%>'></p> <p nhname='contentmsg_<%= user_activity_id%>'></p>
<% end%> <% end%>

@ -111,7 +111,7 @@
</div> </div>
<div class="homepagePostReplyContainer borderBottomNone minHeight48"> <div class="homepagePostReplyContainer borderBottomNone minHeight48">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= act.id %>"> <div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= act.id %>">
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_url_in_org(User.current) %> <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33", :alt => "用户头像"), user_url_in_org(User.current.id) %>
</div> </div>
<div class="homepagePostReplyInputContainer"> <div class="homepagePostReplyInputContainer">
<div nhname='new_message_<%= act.id %>' style="display:none;"> <div nhname='new_message_<%= act.id %>' style="display:none;">
@ -119,7 +119,7 @@
<input type="hidden" name="org_activity_id" value="<%= act.id %>"/> <input type="hidden" name="org_activity_id" value="<%= act.id %>"/>
<div nhname='toolbar_container_<%= act.id %>'></div> <div nhname='toolbar_container_<%= act.id %>'></div>
<textarea placeholder="有问题或建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= act.id %>' name="org_content"></textarea> <textarea placeholder="有问题或建议,请直接给我留言吧!" style="display: none" nhname='new_message_textarea_<%= act.id %>' name="org_content"></textarea>
<a id="new_message_submit_btn_<%= act.id %>" href="javascript:void(0)" onclick="this.style.display='none'" class="blue_n_btn fr" style="display:none;margin-top:6px;line-height:18px;">发送</a> <a id="new_message_submit_btn_<%= act.id %>" href="javascript:void(0)" class="blue_n_btn fr" style="display:none;margin-top:6px;line-height:18px;">发送</a>
<div class="cl"></div> <div class="cl"></div>
<p nhname='contentmsg_<%= act.id %>'></p> <p nhname='contentmsg_<%= act.id %>'></p>

@ -1,4 +1,5 @@
<ul class="orgListRow"> <ul class="orgListRow">
<li class="orgOrder fb">顺序</li>
<li class="orgListUser fb">已有栏目</li> <li class="orgListUser fb">已有栏目</li>
<li class="orgListStatus fb">状态</li> <li class="orgListStatus fb">状态</li>
<li class="orgListStatus fb">类型</li> <li class="orgListStatus fb">类型</li>
@ -6,48 +7,64 @@
<div class="cl"></div> <div class="cl"></div>
</ul> </ul>
<% default_fields.each do |field| %>
<% name = get_default_name(field) %>
<ul class="orgListRow">
<li class="orgListUser"><%= name %></li>
<li class="orgListStatus">默认</li>
<li class="orgListStatus">默认</li>
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="hide($(this),'<%= field.id %>');" id="hide_<%= field.id %>"><%= field.hide==0?"设为隐藏":"设为可见" %></a>
<div class="cl"></div>
</ul>
<% end %>
<% subfields.each do |field| %> <% subfields.each do |field| %>
<ul class="orgListRow"> <% if is_default_field?(field) %>
<li class="orgListUser"> <% name = get_default_name(field) %>
<div id="subfield_show_<%= field.id %>"><%= field.name %></div> <ul class="orgListRow">
<div id="subfield_edit_<%= field.id %>" style="display:none;"> <li class="orgOrder">
<input type="text" name="name" onblur="update_subfield('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.name %>" style="width:70px;"/> <div id="show_priority_<%= field.id %>" ondblclick="edit_priority('#show_priority_<%= field.id %>','#edit_priority_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑">
</div> <%= field.priority %>
</li> </div>
<li class="orgListStatus">新增</li> <div id="edit_priority_<%= field.id %>" style="display:none;width:30px;">
<li class="orgListStatus"><%= field.field_type == "Post" ? "帖子" : "资源" %></li> <input type="text" onblur="update_priority('#show_priority_<%= field.id %>','#edit_priority_<%= field.id %>','<%= field.id %>',$(this).val());" style="width:20px;" value="<%= field.priority %>"/>
<li class="orgListUser hidden"> </div>
<% if Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 %> </li>
<div id="sub_dir_show_<%= field.id %>" ondblclick="edit_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑"> <li class="orgListUser"><%= name %></li>
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %> <li class="orgListStatus">默认</li>
<li class="orgListStatus">默认</li>
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="hide($(this),'<%= field.id %>');" id="hide_<%= field.id %>"><%= field.hide==0?"设为隐藏":"设为可见" %></a>
<div class="cl"></div>
</ul>
<% else %>
<ul class="orgListRow">
<li class="orgOrder">
<div id="show_priority_<%= field.id %>" ondblclick="edit_priority('#show_priority_<%= field.id %>','#edit_priority_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑">
<%= field.priority %>
</div>
<div id="edit_priority_<%= field.id %>" style="display:none;width:30px;">
<input type="text" onblur="update_priority('#show_priority_<%= field.id %>','#edit_priority_<%= field.id %>','<%= field.id %>',$(this).val());" style="width:20px;" value="<%= field.priority %>"/>
</div>
</li>
<li class="orgListUser">
<div id="subfield_show_<%= field.id %>"><%= field.name %></div>
<div id="subfield_edit_<%= field.id %>" style="display:none;">
<input type="text" name="name" onblur="update_subfield('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.name %>" style="width:70px;"/>
</div> </div>
<% else %> </li>
<div id="sub_dir_show_<%= field.id %>" > <li class="orgListStatus">新增</li>
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %> <li class="orgListStatus"><%= field.field_type == "Post" ? "帖子" : "资源" %></li>
<li class="orgListUser hidden">
<% if Secdomain.where("sub_type=2 and pid=?", @organization.id).count > 0 %>
<div id="sub_dir_show_<%= field.id %>" ondblclick="edit_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>');" style="cursor:pointer;background-color:#fffce6;color: #0d90c3;" title="双击可编辑">
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %>
</div>
<% else %>
<div id="sub_dir_show_<%= field.id %>" >
<%= field.subfield_subdomain_dir.nil? ? '未设置': field.subfield_subdomain_dir.name %>
</div>
<% end %>
<div id="sub_dir_edit_<%= field.id %>" style="display:none;">
<input type="text" name="name" onblur="update_sub_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.subfield_subdomain_dir.nil? ? '': field.subfield_subdomain_dir.name %>" style="width:70px;"/>
</div> </div>
<% end %> </li>
<div id="sub_dir_edit_<%= field.id %>" style="display:none;"> <%#= link_to "隐藏", hide_org_subfield_organizations_path(field), :method => 'post', :remote => true, :id => "hide_#{field.id}", :class => "linkBlue fr mr5" %>
<input type="text" name="name" onblur="update_sub_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.subfield_subdomain_dir.nil? ? '': field.subfield_subdomain_dir.name %>" style="width:70px;"/> <a href="javascript:void(0);" class="linkBlue fr mr10" onclick="hide($(this),'<%= field.id %>');" id="hide_<%= field.id %>"><%= field.hide==0?"设为隐藏":"设为可见" %></a>
</div> <%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr10" %>
</li> <a href="javascript:void(0);" class="linkBlue fr mr10" onclick="edit('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>');">编辑</a>
<%#= link_to "隐藏", hide_org_subfield_organizations_path(field), :method => 'post', :remote => true, :id => "hide_#{field.id}", :class => "linkBlue fr mr5" %>
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="hide($(this),'<%= field.id %>');" id="hide_<%= field.id %>"><%= field.hide==0?"设为隐藏":"设为可见" %></a>
<%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr10" %>
<a href="javascript:void(0);" class="linkBlue fr mr10" onclick="edit('#subfield_show_<%= field.id %>','#subfield_edit_<%= field.id %>');">编辑</a>
<div class="cl"></div> <div class="cl"></div>
</ul> </ul>
<% end %>
<% end %> <% end %>
<script> <script>
@ -96,6 +113,35 @@
$(show_id).show(); $(show_id).show();
$(edit_id).hide(); $(edit_id).hide();
} }
function edit_priority(show_id, edit_id){
$(show_id).toggle();
$(edit_id).toggle();
$(edit_id).find("input").focus();
$(edit_id).find("input").on('keypress',function(e){
if (e.keyCode == 13){
this.blur();
}
});
}
function update_priority(show_id, edit_id, field_id, input_value){
var re = /^[0-9]*[1-9]*[0-9]$/
if(re.test(input_value) && $(show_id).html().trim() != input_value.trim() && input_value.trim() != ''){
if(confirm("确定修改为" + input_value + "?")){
$.ajax({
url: "/org_subfields/" + field_id + "/update_priority?priority=" + input_value,
type: 'put'
});
}
}
else
{
$(edit_id).find("input").val($(show_id).html().trim());
}
$(show_id).show();
$(edit_id).hide();
}
function hide(content, id){ function hide(content, id){
if (content.text() == '设为隐藏') if (content.text() == '设为隐藏')
$.ajax({ $.ajax({

@ -70,7 +70,7 @@
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<div class="orgRow mb10 mt5"><span style="margin-left:38px;" >公开&nbsp;: </span> <div class="orgRow mb10 mt5"><span style="margin-left:38px;" >公开&nbsp;: </span>
<input type="checkbox" id="is_public" onblur="disable_down($(this), $('#allow_download'),$('#allow_down_hint'));" name="organization[is_public]" <%= @organization.is_public ? 'checked': ''%> class="ml3" /> <input type="checkbox" id="is_public" onclick="disable_down($(this), $('#allow_download'),$('#allow_down_hint'));" name="organization[is_public]" <%= @organization.is_public ? 'checked': ''%> class="ml3" />
</div> </div>
<div class="orgRow mb10 mt5"><span style="margin-left:10px;">下载支持&nbsp;: </span> <div class="orgRow mb10 mt5"><span style="margin-left:10px;">下载支持&nbsp;: </span>
<input id="allow_download" type="checkbox" style="margin-top:5px;" <%= @organization.is_public? ? "":"DISABLED" %> name="organization[allow_guest_download]" <%= @organization.allow_guest_download ? 'checked': ''%> class="ml3" /> <input id="allow_download" type="checkbox" style="margin-top:5px;" <%= @organization.is_public? ? "":"DISABLED" %> name="organization[allow_guest_download]" <%= @organization.allow_guest_download ? 'checked': ''%> class="ml3" />
@ -119,8 +119,7 @@
</div> </div>
<div class="undis ml15 mr15" id="orgContent_3"> <div class="undis ml15 mr15" id="orgContent_3">
<div class="orgMemberList" id="org_subfield_list"> <div class="orgMemberList" id="org_subfield_list">
<%= render :partial => 'organizations/subfield_list', :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), <%= render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields.order("priority")} %>
:subfields => @organization.org_subfields.where("field_type != 'default'") } %>
</div> </div>
<div class="fr orgMemContainer"> <div class="fr orgMemContainer">
<div class="fr"> <div class="fr">

@ -1,11 +1,11 @@
<% if PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",activity.id,activity.class.to_s,User.current.id).empty? %> <% if PraiseTread.where("praise_tread_object_id=? and praise_tread_object_type=? and user_id=?",activity.id,activity.class.to_s,User.current.id).empty? %>
<a href="<%= praise_tread_praise_plus_path({:obj_id=>activity.id,:obj_type=>activity.class,:user_activity_id=>user_activity_id,:type=>type })%>" data-remote="true" class="<%=type == 'reply'? 'fr' : 'ml15' %> likeButton" title="点赞" > <a href='<%= Setting.protocol+"://"+Setting.host_name+"/praise_tread/praise_plus?obj_id="+activity.id.to_s+"&obj_type="+activity.class.name+"&user_activity_id="+user_activity_id.to_s+"&type="+type.to_s %>' data-remote="true" class="<%=type == 'reply'? 'fr' : 'ml15' %> likeButton" title="点赞" >
<span class="likeText">赞</span> <span class="likeText">赞</span>
<% num = get_praise_num(activity) %> <% num = get_praise_num(activity) %>
<span class="likeNum"><%= num > 0 ? "#{num}" : "" %></span> <span class="likeNum"><%= num > 0 ? "#{num}" : "" %></span>
</a> </a>
<% else %> <% else %>
<a href="<%= praise_tread_praise_minus_path({:obj_id=>activity.id,:obj_type=>activity.class,:user_activity_id=>user_activity_id,:type=>type })%>" data-remote="true" class="<%=type == 'reply'? 'fr' : 'ml15' %> likeButton" title="取消点赞" > <a href='<%= Setting.protocol+"://"+Setting.host_name+"/praise_tread/praise_minus?obj_id="+activity.id.to_s+"&obj_type="+activity.class.name+"&user_activity_id="+user_activity_id.to_s+"&type="+type.to_s %>' data-remote="true" class="<%=type == 'reply'? 'fr' : 'ml15' %> likeButton" title="取消点赞" >
<span class="likeText">已赞</span> <span class="likeText">已赞</span>
<% num = get_praise_num(activity) %> <% num = get_praise_num(activity) %>
<span class="likeNum"><%= num > 0 ? "#{num}" : "" %></span> <span class="likeNum"><%= num > 0 ? "#{num}" : "" %></span>

@ -1,5 +1,7 @@
<%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
<script> <script>
var onUserCard = false;
var onImage = false;
$(document).ready(function(){ $(document).ready(function(){
$("#relateProject,.relatePInfo").mouseover(function(){ $("#relateProject,.relatePInfo").mouseover(function(){
$(".relatePInfo").css("display","block"); $(".relatePInfo").css("display","block");
@ -8,15 +10,24 @@
$(".relatePInfo").css("display","none"); $(".relatePInfo").css("display","none");
}) })
$(".homepagePostPortrait").mouseover(function(){ $(".homepagePostPortrait").mouseover(function(){
onImage = true;
$(this).children(".userCard").css("display","block"); $(this).children(".userCard").css("display","block");
}) })
$(".homepagePostPortrait").mouseout(function(){ $(".homepagePostPortrait").mouseout(function(){
$(this).children(".userCard").css("display","none"); var cur = $(this);
onImage = false;
setTimeout(function(){
if (onUserCard == false && onImage == false) {
$(cur).children(".userCard").css("display", "none");
}
}, 500);
}) })
$(".userCard").mouseover(function(){ $(".userCard").mouseover(function(){
onUserCard = true;
$(this).css("display","block"); $(this).css("display","block");
}) })
$(".userCard").mouseout(function(){ $(".userCard").mouseout(function(){
onUserCard = false;
$(this).css("display","none"); $(this).css("display","none");
}) })
$(".coursesLineGrey").mouseover(function(){ $(".coursesLineGrey").mouseover(function(){
@ -66,7 +77,7 @@
<%= render :partial => 'projects/project_create', :locals => {:activity => activity, :user_activity_id => activity.id} %> <%= render :partial => 'projects/project_create', :locals => {:activity => activity, :user_activity_id => activity.id} %>
<!--缺陷动态--> <!--缺陷动态-->
<% when "Issue" %> <% when "Issue" %>
<%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id} %> <%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %>
<!--message --> <!--message -->
<% when "Message" %> <% when "Message" %>
@ -78,7 +89,7 @@
<% end %> <% end %>
<!--Attachment --> <!--Attachment -->
<% when "Attachment" %> <% when "Attachment" %>
<%= render :partial => 'projects/attachment_acts', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> <%= render :partial => 'users/project_attachment', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %>
<!--<div class="problem_main">--> <!--<div class="problem_main">-->
<!--<a class="problem_pic fl"><%#= image_tag(url_to_avatar(activity.user), :width => "42", :height => "42") %></a>--> <!--<a class="problem_pic fl"><%#= image_tag(url_to_avatar(activity.user), :width => "42", :height => "42") %></a>-->

@ -1,7 +1,7 @@
<% if @project.is_public? %> <% if @project.is_public? %>
$("#set_project_public_<%= @project.id %>").text("设为私有");
$("#show_project_<%= @project.id %>").attr("title","公开项目:<%= @project.name %>"); $("#show_project_<%= @project.id %>").attr("title","公开项目:<%= @project.name %>");
<% else %> <% else %>
$("#set_project_public_<%= @project.id %>").text("设为公开");
$("#show_project_<%= @project.id %>").attr("title","私有项目:<%= @project.name %>"); $("#show_project_<%= @project.id %>").attr("title","私有项目:<%= @project.name %>");
<% end %> <% end %>
$("#set_project_public_<%= @project.id %>").replaceWith('<%= escape_javascript(link_to @project.is_public? ? "设为私有" : "设为公开", {:controller => "projects", :action => "set_public_or_private", :id => @project.id,:user_page => true},
:id => "set_project_public_"+ @project.id.to_s,:method => "post",:remote=>true,:confirm=>"您确定要设置为"+(@project.is_public? ? "私有" : "公开")+"吗") %>');

@ -21,7 +21,7 @@
<%= call_hook(:view_projects_settings_members_table_header, :project => @project) %> <%= call_hook(:view_projects_settings_members_table_header, :project => @project) %>
<% members.each do |member| %> <% members.each do |member| %>
<li > <li >
<%= link_to_user_header member.principal,false,:class => "w140_h c_setting_blue fl" %> <%= link_to_user_header member.principal, true, :class => "w140_h c_setting_blue fl" %>
<span class="w180_h fl"> <span class="w180_h fl">
<!--区分中英文角色显示的不同--> <!--区分中英文角色显示的不同-->
<% if User.current.language == "zh" %> <% if User.current.language == "zh" %>

@ -4,6 +4,9 @@
$("#pro_st_edit_ku").toggle(); $("#pro_st_edit_ku").toggle();
} }
</script> </script>
<% unless @project.repositories.any? %>
<p class="nodata">温馨提示:<%= l(:label_repository_no_data) %></p>
<% end %>
<%= str = error_messages_for 'repository' %> <%= str = error_messages_for 'repository' %>
<% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %> <% project_path_cut = RepositoriesHelper::PROJECT_PATH_CUT %>
<% ip = RepositoriesHelper::REPO_IP_ADDRESS %><!--Added by tanxianbo For formatting project's path--> <% ip = RepositoriesHelper::REPO_IP_ADDRESS %><!--Added by tanxianbo For formatting project's path-->
@ -87,8 +90,6 @@
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
<% else %>
<p class="nodata">温馨提示:<%= l(:label_repository_no_data) %></p>
<% end %> <% end %>

@ -18,7 +18,7 @@
<li><%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %></li> <li><%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %></li>
<!--<li><%#= link_to "作业动态", {:controller => "courses", :action => "show", :type => "homework"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>--> <!--<li><%#= link_to "作业动态", {:controller => "courses", :action => "show", :type => "homework"}, :class => "homepagePostTypeAssignment postTypeGrey" %></li>-->
<li><%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %></li> <li><%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %></li>
<!--<li><%#= link_to "资源库动态", {:controller => "projects", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey" %></li>--> <li><%= link_to "资源库动态", {:controller => "projects", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey" %></li>
<li><%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %></li> <li><%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %></li>
<!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %></li>--> <!--<li><%#= link_to "问卷动态", {:controller => "courses", :action => "show", :type => "poll"}, :class => "homepagePostTypeQuiz postTypeGrey" %></li>-->
</ul> </ul>

@ -25,7 +25,7 @@
<li > <li >
<span class="tit_fb ">编程代码:</span> <span class="tit_fb ">编程代码:</span>
<div class="showHworkP break_word"><pre id="work-src" style="display: none;"><%= work.description if work.description%></pre><div class="fontGrey2 font_cus" id="work-code_<%= work.id%>"> <div class="showHworkP break_word"><pre id="work-src_<%= work.id%>" style="display: none;"><%= work.description if work.description%></pre><div class="fontGrey2 font_cus" id="work-code_<%= work.id%>">
</div> </div>
</div> </div>
<div class="cl"></div> <div class="cl"></div>

@ -59,8 +59,8 @@
<li > <li >
<span class="tit_fb ">内容:</span> <span class="tit_fb ">内容:</span>
<div class="showHworkP break_word"> <div class="showHworkP break_word upload_img" id="student_work_img_<%=work.id %>">
<%= text_format(work.description) if work.description%> <%= work.description.html_safe if work.description%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
</li> </li>
@ -105,6 +105,9 @@
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(function(){
showNormalImage('student_work_img_<%=work.id %>');
});
function show_upload(){ function show_upload(){
$("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>'); $("#ajax-modal").html('<%= escape_javascript( render :partial => 'student_work/upload_attachment' ,:locals => {:work=>work})%>');
showModal('ajax-modal', '452px'); showModal('ajax-modal', '452px');

@ -71,7 +71,7 @@
indentUnit: 2, indentUnit: 2,
matchBrackets: true, matchBrackets: true,
readOnly: true, readOnly: true,
value: $("#work-src").text() value: $("#work-src_<%= work.id%>").text()
}); });
<% elsif @homework.homework_type == 1 %> <% elsif @homework.homework_type == 1 %>
$("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>"); $("#about_hwork_<%= work.id%>").html("<%= escape_javascript(render :partial => 'show',:locals => {:work => work, :score =>student_work_score(work,User.current),:student_work_scores => work.student_works_scores.order("updated_at desc")}) %>");

@ -4,9 +4,11 @@
<p class="f14 mt5"> <p class="f14 mt5">
<span class="fb">作品名称:</span><%=@student_work.name%> <span class="fb">作品名称:</span><%=@student_work.name%>
</p> </p>
<p class="f14 mt5"> <div class="f14 mt5" style="max-width: 425px; color:#808181">
<span class="fb">作品描述:</span><%=@student_work.description%> <div class="fb fl dis">作品描述:</div>
</p> <div class="upload_img fl" style="max-width: 350px;"><%=@student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5"> <p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span> <span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %> <% if @student_work.attachments.empty? %>

@ -4,9 +4,11 @@
<p class="f14 mt5"> <p class="f14 mt5">
<span class="fb">作品名称:</span><%=@student_work.name%> <span class="fb">作品名称:</span><%=@student_work.name%>
</p> </p>
<p class="f14 mt5"> <div class="f14 mt5" style="max-width: 425px; color:#808181">
<span class="fb">作品描述:</span><%=@student_work.description%> <div class="fb fl dis">作品描述:</div>
</p> <div class="upload_img fl" style="max-width: 350px;"><%=@student_work.description.html_safe %></div>
<div class="cl"></div>
</div>
<p class="mt5"> <p class="mt5">
<span class="fl fb mr30">附</span><span class="fb fl">件:</span> <span class="fl fb mr30">附</span><span class="fb fl">件:</span>
<% if @student_work.attachments.empty? %> <% if @student_work.attachments.empty? %>

@ -1,3 +1,7 @@
<% content_for :header_tags do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<%= javascript_include_tag 'homework','baiduTemplate' %>
<% end %>
<div class="homepageRightBanner mb10"> <div class="homepageRightBanner mb10">
<div class="NewsBannerName">编辑作品</div> <div class="NewsBannerName">编辑作品</div>
</div> </div>
@ -25,7 +29,7 @@
</div><!----HomeWorkBox end--> </div><!----HomeWorkBox end-->
<div class="cl"></div> <div class="cl"></div>
<div class="HomeWorkCon mt15"> <div class="HomeWorkCon mt15" nhname='student_work_form'>
<%= labelled_form_for @work,:html => { :multipart => true },:remote=>true do |f|%> <%= labelled_form_for @work,:html => { :multipart => true },:remote=>true do |f|%>
<div class=" c_red mb10"> <div class=" c_red mb10">
提示:作品名称和描述中不要出现真实的姓名信息 提示:作品名称和描述中不要出现真实的姓名信息
@ -46,13 +50,16 @@
<p id="student_work_name_span" class="c_red mb10"></p> <p id="student_work_name_span" class="c_red mb10"></p>
</div> </div>
<div class="mt10"> <div class="mt10">
<textarea name="student_work[description]" id="student_work_description" placeholder="请输入作品描述" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%= @work.description%></textarea> <textarea placeholder="请输入作品描述" style="display: none" nhname='student_work_textarea' name="student_work[description]"><%= @work.description%></textarea>
<script> <!--<textarea name="student_work[description]" id="student_work_description" placeholder="请输入作品描述" class="InputBox W700 H150" maxlength="6000" onkeyup="regexStudentWorkDescription();"><%#= @work.description%></textarea>-->
<!--<script>
var text = document.getElementById("student_work_description"); var text = document.getElementById("student_work_description");
autoTextarea(text);// 调用 autoTextarea(text);// 调用
</script> </script>-->
<div class="cl"></div> <div class="cl"></div>
<p id="student_work_description_textarea" class="c_red mb10"></p> <p id="student_work_description_textarea" class="c_red mb10"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</div> </div>
<div id="homework_attachments"> <div id="homework_attachments">
@ -66,7 +73,7 @@
<% end %> <% end %>
<div class="mt5"> <div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="popupRegex();edit_student_work(<%= @work.id%>);">确定</a> <a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">确定</a>
<span class="fr mr10 mt3">或</span> <span class="fr mr10 mt3">或</span>
<%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%> <%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%>
</div> </div>
@ -96,23 +103,130 @@
} }
function popupRegex(){ function popupRegex(){
if(regexStudentWorkName()&&regexStudentWorkDescription()) if($("#group_member_ids").length > 0) {
{ if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
if($("#group_member_ids").length > 0) {
if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
}
} else {
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>"); $('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
showModal('ajax-modal', '500px'); showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove(); $('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos"); $('#ajax-modal').parent().addClass("anonymos");
} }
} else {
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
}
}
function nh_check_field(params){
var result=true;
if(!regexStudentWorkName()) {
result=false;
return result;
}
if(params.content!=undefined){
if(params.content.isEmpty()){
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
params.content.sync();
if(params.content.isEmpty()){
params.contentmsg.html('作品描述不能为空');
}else{
params.contentmsg.html('');
}
}
} }
return result;
} }
function init_homework_form(params){
params.form.submit(function(){
params.textarea.html(params.editor.html());
params.editor.sync();
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = nh_check_field({
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
});
if(is_checked){
if(flag){
popupRegex();
return true;
}else{
$(this)[0].submit();
$("#ajax-indicator").hide();
return false;
}
}
return false;
});
}
function init_homework_editor(params){
params.textarea.removeAttr('placeholder');
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
var edit = this.edit;
var body = edit.doc.body;
edit.html(params.textarea.innerHTML);
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
elocalStorage(editor2,'student_work_<%=@work.id %>');
}
}).loadPlugin('paste');
return editor;
}
KindEditor.ready(function(K){
$("div[nhname='student_work_form']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[nhname='student_work_textarea']",params.div_form);
params.contentmsg = $("#student_work_description_textarea");
params.submit_btn = $("#new_message_submit_btn");
if(params.textarea.data('init') == undefined) {
params.editor = init_homework_editor(params);
editor2 = params.editor;
init_homework_form(params);
params.submit_btn.click(function () {
params.form.submit();
$("#ajax-indicator").hide();
});
params.textarea.data('init', 1);
}
});
});
</script> </script>

@ -172,7 +172,7 @@
<div class="mt5"> <div class="mt5">
<% if @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status < 2 %> <% if @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status < 2 %>
<div class="fontGrey2 db fl">提交截止时间:<%= @homework.end_time %>&nbsp;23:59</div> <div class="fontGrey2 db fl">提交截止时间:<%= @homework.end_time %>&nbsp;23:59</div>
<% elsif @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status >= 2 %> <% elsif @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status >= 2 && @homework.anonymous_comment == 0 %>
<div class="fontGrey2 db fl">匿评截止时间:<%= @homework.homework_detail_manual.evaluation_end %>&nbsp;23:59</div> <div class="fontGrey2 db fl">匿评截止时间:<%= @homework.homework_detail_manual.evaluation_end %>&nbsp;23:59</div>
<% end %> <% end %>
<% if @homework.homework_detail_manual.comment_status == 0 %> <% if @homework.homework_detail_manual.comment_status == 0 %>

@ -1,4 +1,9 @@
<!-- 此界面只用来新建匿评作业作品 --> <!-- 此界面只用来新建匿评作业作品 -->
<% content_for :header_tags do %>
<%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<%= javascript_include_tag 'homework','baiduTemplate' %>
<% end %>
<script type="text/javascript"> <script type="text/javascript">
<%if @homework.homework_detail_manual.comment_status != 1%> <%if @homework.homework_detail_manual.comment_status != 1%>
$(function(){ $(function(){
@ -57,26 +62,143 @@
} }
// 作品校验 // 作品校验
function popupRegex(){ function popupRegex(){
if(regexStudentWorkName()&&regexStudentWorkDescription()) if($("#group_member_ids").length > 0) {
{ if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
if($("#group_member_ids").length > 0) {
if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
}
} else {
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>"); $('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
showModal('ajax-modal', '500px'); showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove(); $('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9"); $('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos"); $('#ajax-modal').parent().addClass("anonymos");
} }
} else {
$('#ajax-modal').html("<div><p align='center' style='margin-top: 35px'>作品信息完整性校验中,请稍等...</p></div>");
showModal('ajax-modal', '500px');
$('#ajax-modal').siblings().remove();
$('#ajax-modal').parent().css("top","").css("left","").css("border","3px solid #269ac9");
$('#ajax-modal').parent().addClass("anonymos");
} }
} }
function nh_check_field(params){
var result=true;
if(!regexStudentWorkName()) {
result=false;
return result;
}
if(params.content!=undefined){
if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
result=false;
}
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html());
params.content.sync();
if(params.content.isEmpty() || /^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(params.content.html())){
params.contentmsg.html('作品描述不能为空');
}else{
params.contentmsg.html('');
}
}
}
return result;
}
function init_homework_form(params){
params.form.submit(function(){
params.textarea.html(params.editor.html());
params.editor.sync();
var flag = false;
if(params.form.attr('data-remote') != undefined ){
flag = true
}
var is_checked = nh_check_field({
issubmit:true,
content:params.editor,
contentmsg:params.contentmsg,
textarea:params.textarea
});
if(is_checked){
if(flag){
popupRegex();
return true;
}else{
$(this)[0].submit();
$("#ajax-indicator").hide();
return false;
}
}
return false;
});
}
function init_homework_editor(params){
params.textarea.removeAttr('placeholder');
var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",minHeight:"30px",height:"30px",
items : ['code','emoticons','fontname',
'forecolor', 'hilitecolor', 'bold', '|', 'justifyleft', 'justifycenter', 'insertorderedlist','insertunorderedlist', '|',
'formatblock', 'fontsize', '|','indent', 'outdent',
'|','imagedirectupload','table', 'media', 'preview',"more"
],
afterChange:function(){//按键事件
var edit = this.edit;
var body = edit.doc.body;
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + 33, 150));
},
afterBlur:function(){
if(this.isEmpty()) {
this.edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
}
},
afterFocus: function(){
var edit = this.edit;
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*[\uFE30-\uFFA0][\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(edit.html())){
edit.html('');
}
},
afterCreate:function(){
//init
var edit = this.edit;
var body = edit.doc.body;
edit.iframe[0].scroll = 'no';
body.style.overflowY = 'hidden';
//reset height
var edit = this.edit;
var body = edit.doc.body;
edit.html("<span id='hint' style='color: #999999; font-size: 12px'>请在此输入作品描述,您可以直接在这里粘贴作业图片</span>");
//paramsHeight = params.kindutil.removeUnit(this.height);
edit.iframe.height(150);
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) , 150));
elocalStorage(editor2,'student_work_<%=@homework.id %>');
}
}).loadPlugin('paste');
return editor;
}
KindEditor.ready(function(K){
$("div[nhname='student_work_form']").each(function(){
var params = {};
params.kindutil = K;
params.div_form = $(this);
params.form = $("form",params.div_form);
if(params.form==undefined || params.form.length==0){
return;
}
params.textarea = $("textarea[nhname='student_work_textarea']",params.div_form);
params.contentmsg = $("#student_work_description_textarea");
params.submit_btn = $("#new_message_submit_btn");
if(params.textarea.data('init') == undefined) {
params.editor = init_homework_editor(params);
editor2 = params.editor;
init_homework_form(params);
params.submit_btn.click(function () {
params.form.submit();
$("#ajax-indicator").hide();
});
params.textarea.data('init', 1);
}
});
});
</script> </script>
<div class="homepageRightBanner mb10"> <div class="homepageRightBanner mb10">
@ -110,7 +232,7 @@
</div><!----HomeWorkBox end--> </div><!----HomeWorkBox end-->
<div class="cl"></div> <div class="cl"></div>
<div class="HomeWorkCon mt15"> <div class="HomeWorkCon mt15" nhname='student_work_form'>
<%= form_for(@student_work, <%= form_for(@student_work,
:html => { :multipart => true }, :html => { :multipart => true },
:url => {:controller => 'student_work', :url => {:controller => 'student_work',
@ -127,18 +249,21 @@
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %> <%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %>
<% end %> <% end %>
<div> <div>
<%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请输入作品名称", :onkeyup => "regexStudentWorkName();" %> <%= f.text_field "name", :required => true, :size => 60, :class => "InputBox W700", :maxlength => 200, :placeholder => "请输入作品名称",:value=>"#{@homework.name}的作品提交(可修改)", :onkeyup => "regexStudentWorkName();" %>
<div class="cl"></div> <div class="cl"></div>
<p id="student_work_name_span" class="c_red mb10"></p> <p id="student_work_name_span" class="c_red mb10"></p>
</div> </div>
<div class="mt10"> <div class="mt10">
<%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%> <textarea placeholder="请输入作品描述" style="display: none" nhname='student_work_textarea' name="student_work[description]"></textarea>
<script> <%#= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请输入作品描述", :onkeyup => "regexStudentWorkDescription();"%>
<!--<script>
var text = document.getElementById("student_work_description"); var text = document.getElementById("student_work_description");
autoTextarea(text);// 调用 autoTextarea(text);// 调用
</script> </script>-->
<div class="cl"></div> <div class="cl"></div>
<p id="student_work_description_textarea" class="c_red mb10"></p> <p id="student_work_description_textarea" class="c_red mb10"></p>
<p id="e_tip" class="c_grey"></p>
<p id="e_tips" class="c_grey"></p>
</div> </div>
<div id="homework_attachments"> <div id="homework_attachments">
@ -167,9 +292,9 @@
</div>--> </div>-->
<div class="mt5"> <div class="mt5">
<a href="javascript:void(0);" class="BlueCirBtnMini fr" onclick="popupRegex();new_student_work();">提交</a> <a href="javascript:void(0);" class="BlueCirBtnMini fr" id="new_message_submit_btn">提交</a>
<span class="fr mr10 mt3">或</span> <span class="fr mr10 mt3">或</span>
<%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id), :class => "fr mr10 mt3"%> <%= link_to "取消", delete_work_student_work_index_path(:homework =>@homework.id),:id => 'new_message_cancel_btn', :class => "fr mr10 mt3"%>
</div> </div>
<div class="cl"></div> <div class="cl"></div>
<% end%> <% end%>

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save