diff --git a/Gemfile b/Gemfile
index e292279ef..9fe511a59 100644
--- a/Gemfile
+++ b/Gemfile
@@ -18,7 +18,7 @@ gem 'daemons'
gem 'grape', '~> 0.9.0'
gem 'grape-entity'
gem 'seems_rateable', '~> 1.0.13'
-gem 'rails', '~> 3.2', '>= 3.2.22'
+gem 'rails', '~> 3.2'
gem "jquery-rails", "~> 2.0.2"
gem "i18n", "~> 0.6.0"
gem 'coderay', '~> 1.1.0'
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 01703f679..f8ca1d0e2 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -32,23 +32,60 @@ class AdminController < ApplicationController
end
def projects
+=begin
@status = params[:status] || 1
- scope = Project.status(@status).order('id asc')
+ scope = Project.status(@status)
scope = scope.like(params[:name]) if params[:name].present?
- @projects = scope.where(project_type: Project::ProjectType_project).all
-
+ @projects = scope.where(project_type: Project::ProjectType_project).reorder("created_on desc").all
+=end
+ @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?
end
def courses
@name = params[:name]
- @courses = Course.like(@name)
+ @courses = Course.like(@name).order('created_at desc')
+ @courses = paginateHelper @courses,30
+ @page = (params['page'] || 1).to_i - 1
respond_to do |format|
format.html
end
end
+ #管理员界面精品课程列表
+ def excellent_courses
+ @courses = Course.where("is_excellent =? or excellent_option =?", 1, 1 )
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ #管理员界面课程资源列表
+ def course_resource_list
+ @resource = Attachment.where(:container_type => 'Course')
+ @resource = paginateHelper @resource,30
+ @page = (params['page'] || 1).to_i - 1
+
+ respond_to do |format|
+ format.html
+ end
+ end
+
+ #管理员界面項目资源列表
+ def project_resource_list
+ @pro_resource = Attachment.where(:container_type => 'Project')
+ @pro_resource = paginateHelper @pro_resource,30
+ @page = (params['page'] || 1).to_i - 1
+
+ respond_to do |format|
+ format.html
+ end
+ end
+
+
def users
sort_init 'login', 'asc'
sort_update %w(login firstname lastname mail admin created_on last_login_on)
diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb
index 456306c64..fe16385f4 100644
--- a/app/controllers/at_controller.rb
+++ b/app/controllers/at_controller.rb
@@ -8,6 +8,15 @@ class AtController < ApplicationController
users = find_at_users(params[:type], params[:id])
@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
+
+ #加上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
private
diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index cf4e6a8e9..9853b4dc1 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -103,6 +103,9 @@ class AttachmentsController < ApplicationController
direct_download_history
end
else
+ # 记录用户行为
+ record_user_actions(params[:id])
+ # 直接下载历史版本
direct_download_history
end
end
@@ -113,6 +116,14 @@ class AttachmentsController < ApplicationController
redirect_to "http://" + (Setting.host_name.to_s) +"/file_not_found.html"
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
# modify by nwb
# 下载添加权限设置
@@ -135,6 +146,8 @@ class AttachmentsController < ApplicationController
direct_download
end
else
+ # 记录用户行为
+ record_user_actions(params[:id])
direct_download
end
end
@@ -251,7 +264,7 @@ class AttachmentsController < ApplicationController
@history.version = @old_history.nil? ? 1 : @old_history.version + 1
@history.save #历史记录保存完毕
#将最新保存的记录 数据替换到 需要修改的文件记录
- @old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads")
+ @old_attachment.attributes = @attachment.attributes.dup.except("id","container_id","container_type","is_public","downloads", "quotes")
@old_attachment.save
#删除当前记录
@attachment.delete
@@ -572,6 +585,15 @@ class AttachmentsController < ApplicationController
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
def find_project
@attachment = Attachment.find(params[:id])
diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb
index f5e3314bb..7220eec27 100644
--- a/app/controllers/blog_comments_controller.rb
+++ b/app/controllers/blog_comments_controller.rb
@@ -91,8 +91,12 @@ class BlogCommentsController < ApplicationController
def edit
@article = BlogComment.find(params[:id])
- respond_to do |format|
- format.html {render :layout=>'new_base_user'}
+ if User.current.admin? || User.current.id == @article.author_id
+ respond_to do |format|
+ format.html { render :layout => 'new_base_user' }
+ end
+ else
+ render_403
end
end
diff --git a/app/controllers/blogs_controller.rb b/app/controllers/blogs_controller.rb
index 842433ec6..7a226f50d 100644
--- a/app/controllers/blogs_controller.rb
+++ b/app/controllers/blogs_controller.rb
@@ -29,7 +29,7 @@ class BlogsController < ApplicationController
def set_homepage
@blog = Blog.find(params[:id])
@blog.update_attribute(:homepage_id, params[:article_id])
- redirect_to user_blogs_path(params[:user_id])
+ redirect_to user_path(params[:user_id])
end
def cancel_homepage
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index be96124c2..dfa30915e 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -7,6 +7,7 @@ class CoursesController < ApplicationController
helper :members
helper :words
helper :attachments
+ helper :files
helper :activity_notifys
before_filter :auth_login1, :only => [:show, :course_activity, :feedback]
@@ -240,6 +241,18 @@ class CoursesController < ApplicationController
# req[:message] = l(:modal_valid_passing) if req[:message].blank?
render :json => req
end
+
+ def teacher_assign_group
+ member = Member.where(:course_id => @course.id, :user_id => params[:user_id]).first
+ member.course_group_id = params[:course_group_id].to_i
+ member.save
+ @course_groups = @course.course_groups
+ @canShowCode = isCourseTeacher(User.current.id,@course) && params[:role] != '1'
+ respond_to do |format|
+ format.js
+ end
+ end
+
def join_group
@subPage_title = l :label_student_list
group = CourseGroup.find(params[:object_id])
@@ -838,6 +851,8 @@ class CoursesController < ApplicationController
# render_403
# return
# end
+ # 统计访问量
+ @course.update_attribute(:visits, @course.visits.to_i + 1)
#更新创建课程消息状态
create_course_messages = @course.course_messages.where("user_id =? and course_message_type =? and course_id =? and viewed =?", User.current.id, 'Course', @course.id, 0)
create_course_messages.update_all(:viewed => true)
@@ -888,10 +903,7 @@ class CoursesController < ApplicationController
end
def feedback
- @course.journals_for_messages.each do |messages|
- query = messages.course_messages.where("user_id = ?", User.current.id)
- query.update_all(:viewed => true);
- end
+ CourseMessage.where("user_id = ? and course_id = ?", User.current, @course.id).update_all(:viewed => true)
if (User.current.admin? || @course.is_public == 1 || (@course.is_public == 0 && User.current.member_of_course?(@course)))
page = params[:page]
@@ -1067,7 +1079,7 @@ class CoursesController < ApplicationController
sql_select = ""
if groupid == 0
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
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}
@@ -1079,7 +1091,7 @@ class CoursesController < ApplicationController
WHERE members.course_id = #{@course.id} ORDER BY score #{score_sort_by}"
else
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
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{@course.id}
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index ca37e445c..7ae1b85f8 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -207,8 +207,7 @@ class FilesController < ApplicationController
sort = "created_on DESC"
end
if keywords != "%%"
- resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").
- reorder(sort)
+ resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' AND filename LIKE :like ", like: "%#{keywords}%").reorder(sort)
else
resultSet = Attachment.where("attachments.container_type = 'Course' And attachments.container_id = '#{course.id}' "). reorder(sort)
end
@@ -406,10 +405,14 @@ class FilesController < ApplicationController
@container_type = 2
@containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
@organization = Organization.find(@containers.first.organization_id)
- show_attachments @containers
- @tag_list = attachment_tag_list @all_attachments
- @page = params[:page] || 1
- render :layout => 'base_org'
+ if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization)
+ show_attachments @containers
+ @tag_list = attachment_tag_list @all_attachments
+ @page = params[:page] || 1
+ render :layout => 'base_org'
+ else
+ render_403
+ end
# @subfield = params[:org_subfield_id]
end
@@ -529,6 +532,7 @@ class FilesController < ApplicationController
if attachment.publish_time > Date.today
attachment.is_publish = 0
end
+ attachment.description = params[:description]
attachment.save
end
end
@@ -554,7 +558,8 @@ class FilesController < ApplicationController
end
end
# 更新课程英雄榜得分
- update_contributor_score(@course, attachments[:files].first)
+ course_member_score(@course.id, attachments[:files].first.author_id, "Attachment")
+ # end
# end
# TODO: 临时用 nyan
sort_init 'created_on', 'desc'
@@ -627,20 +632,6 @@ class FilesController < ApplicationController
end
end
- def update_contributor_score(course, file )
- unless file.author.allowed_to?(:as_teacher, course)
- course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course.id, file.author.id).first
- if course_contributor_score.nil?
- CourseContributorScore.create(:course_id => course.id, :user_id => file.author.id, :message_num => 0, :message_reply_num => 0,
- :news_reply_num => 0, :resource_num => 5, :journal_num => 0, :journal_reply_num => 0, :total_score => 5)
- else
- score = course_contributor_score.resource_num + 5
- total_score = course_contributor_score.total_score + 5
- course_contributor_score.update_attributes(:resource_num => score, :total_score => total_score)
- end
- end
- end
-
def get_project_tag_name_by_type_nmuber type
case type
when "1"
@@ -860,7 +851,13 @@ class FilesController < ApplicationController
q = "%#{@q.strip}%"
@result = find_org_subfield_attache q,@org_subfield,sort
@result = visable_attachemnts @result
- @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
+ if params[:other]
+ @result = @result.select{|attachment|
+ attachment.tag_list.index{|tag|tag != '软件' and tag != '媒体' and tag != '代码'}.present?
+ }
+ else
+ @result = @result.select{|attachment| attachment.tag_list.include?(@tag_name)} unless @tag_name.blank?
+ end
@searched_attach = paginateHelper @result,10
@tag_list = get_org_subfield_tag_list @org_subfield
diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb
index 00b11323b..091e2b86b 100644
--- a/app/controllers/homework_common_controller.rb
+++ b/app/controllers/homework_common_controller.rb
@@ -51,8 +51,14 @@ class HomeworkCommonController < ApplicationController
@user = User.current
@is_in_course = params[:is_in_course].to_i
@course_activity = params[:course_activity].to_i
- respond_to do |format|
- format.html{render :layout => 'new_base_user'}
+ if @is_in_course == 1 || @course_activity == 1
+ 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
@@ -73,9 +79,11 @@ class HomeworkCommonController < ApplicationController
if @homework.publish_time <= Date.today && homework_detail_manual.comment_status == 0
homework_detail_manual.comment_status = 1
end
- homework_detail_manual.evaluation_start = params[:evaluation_start].blank? ? @homework.end_time + 7 : params[:evaluation_start]
- homework_detail_manual.evaluation_end = params[:evaluation_end].blank? ? homework_detail_manual.evaluation_start + 7 : params[:evaluation_end]
-
+ eval_start = homework_detail_manual.evaluation_start
+ 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])
render_attachment_warning_if_needed(@homework)
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index eb78c4c5b..44f0d15f4 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -118,6 +118,9 @@ class IssuesController < ApplicationController
end
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.update_attribute(:viewed, true) unless query.nil?
@@ -387,6 +390,9 @@ class IssuesController < ApplicationController
end
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
if @hours > 0
case params[:todo]
@@ -415,7 +421,11 @@ class IssuesController < ApplicationController
end
end
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 }
end
end
diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb
index 0962deb10..f45e1dbd7 100644
--- a/app/controllers/news_controller.rb
+++ b/app/controllers/news_controller.rb
@@ -107,32 +107,18 @@ class NewsController < ApplicationController
def show
# 更新news对应的forge_messages的消息viewed字段
+ ids = @news.comments.map { |comment| comment.id }.join(",") unless @news.comments.nil?
if @project
- query_message_news = @news.forge_messages
+ # 更新新闻
+ query_message_news = ForgeMessage.where("forge_message_id =? and user_id =? and viewed =?", @news.id, User.current.id, 0).first
+ # 更新新闻的时候一并更新回复
+ ForgeMessage.where("forge_message_id in (#{ids}) and forge_message_type = 'Comment' and user_id = #{User.current.id}").update_all(:viewed => true) unless ids.blank?
else
- query_message_news = @news.course_messages
+ query_message_news = CourseMessage.where("course_message_id =? and user_id =? and viewed =?", @news.id, User.current.id, 0).first
+ CourseMessage.where("course_message_id in (#{ids}) and course_message_type = 'Comment' and user_id = #{User.current.id}").update_all(:viewed => true) unless ids.blank?
end
- query_message_news.each do |query|
- if User.current.id == query.user_id
- query.update_attributes(:viewed => true)
- end
- end
- # 更新项目新闻的评阅的消息viewed字段
- current_message_comments = @news.comments
- current_message_comments.each do |current_message_comment|
- if @project
- query_message_comment = current_message_comment.forge_messages
- else
- query_message_comment = current_message_comment.course_messages
- end
- query_message_comment.each do |query|
- if User.current.id == query.user_id
- query.update_attributes(:viewed => true)
- end
- end
- end
- # end
-
+ query_message_news.update_attribute(:viewed, true) unless query_message_news.nil?
+ # over
cs = CoursesService.new
result = cs.show_course_news params,User.current
@news = result[:news]
diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb
index f250b46de..d1a8b23dd 100644
--- a/app/controllers/org_document_comments_controller.rb
+++ b/app/controllers/org_document_comments_controller.rb
@@ -1,6 +1,6 @@
class OrgDocumentCommentsController < ApplicationController
before_filter :find_organization, :only => [:new, :create, :show, :index]
- helper :attachments
+ helper :attachments,:organizations
layout 'base_org'
def new
diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb
index 2a4bcf9c8..ba4c1f18f 100644
--- a/app/controllers/org_subfields_controller.rb
+++ b/app/controllers/org_subfields_controller.rb
@@ -5,9 +5,8 @@ class OrgSubfieldsController < ApplicationController
def create
if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0
@res = true
- @subfield = OrgSubfield.create(:name => params[:name])
@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?
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]}'"
@@ -15,7 +14,7 @@ class OrgSubfieldsController < ApplicationController
SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir])
end
end
- @subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type])
+ @subfield.update_attributes(:field_type => params[:field_type])
else
@res = false
end
@@ -33,61 +32,65 @@ class OrgSubfieldsController < ApplicationController
domain = Secdomain.where("subname=?", request.subdomain).first
@organization = Organization.find(domain.pid)
end
- @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+
- "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+
- " org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first
- if @org_subfield.field_type == 'Post'
+ if @organization.is_public? or User.current.admin? or User.current.member_of_org?(@organization)
+ @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+
+ "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+
+ " org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir_name]}'").first
+ if @org_subfield.field_type == 'Post'
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@org_activities = OrgActivity.where("(org_act_type='OrgDocumentComment'and org_act_id in (#{@org_subfield_ids.join(",")})) || (container_type='OrgSubfield' and container_id=#{@org_subfield.id})").order('updated_at desc').page(params[:page] || 1).per(10)
#redirect_to organization_path(@organization, :org_subfield_id => @org_subfield.id)
- else
- if params[:sort]
- params[:sort].split(",").each do |sort_type|
- order_by = sort_type.split(":")
- case order_by[0]
- when "filename"
- attribute = "filename"
- when "size"
- attribute = "filesize"
- when "attach_type"
- attribute = "attachtype"
- when "content_type"
- attribute = "created_on"
- when "field_file_dense"
- attribute = "is_public"
- when "downloads"
- attribute = "downloads"
- when "created_on"
- attribute = "created_on"
- when "quotes"
- attribute = "quotes"
- else
- attribute = "created_on"
- end
- @sort = order_by[0]
- @order = order_by[1]
- if order_by.count == 1 && attribute
- sort += "#{Attachment.table_name}.#{attribute} asc "
- if sort_type != params[:sort].split(",").last
- sort += ","
- end
- elsif order_by.count == 2 && order_by[1]
- sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
- if sort_type != params[:sort].split(",").last
- sort += ","
- end
- end
- end
else
- sort = "#{Attachment.table_name}.created_on desc"
+ if params[:sort]
+ params[:sort].split(",").each do |sort_type|
+ order_by = sort_type.split(":")
+ case order_by[0]
+ when "filename"
+ attribute = "filename"
+ when "size"
+ attribute = "filesize"
+ when "attach_type"
+ attribute = "attachtype"
+ when "content_type"
+ attribute = "created_on"
+ when "field_file_dense"
+ attribute = "is_public"
+ when "downloads"
+ attribute = "downloads"
+ when "created_on"
+ attribute = "created_on"
+ when "quotes"
+ attribute = "quotes"
+ else
+ attribute = "created_on"
+ end
+ @sort = order_by[0]
+ @order = order_by[1]
+ if order_by.count == 1 && attribute
+ sort += "#{Attachment.table_name}.#{attribute} asc "
+ if sort_type != params[:sort].split(",").last
+ sort += ","
+ end
+ elsif order_by.count == 2 && order_by[1]
+ sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} "
+ if sort_type != params[:sort].split(",").last
+ sort += ","
+ end
+ end
+ end
+ else
+ sort = "#{Attachment.table_name}.created_on desc"
+ end
+ @container_type = 2
+ @containers = [OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
+ @organization = Organization.find(@containers.first.organization_id)
+ show_attachments @containers
+ @tag_list = attachment_tag_list @all_attachments
end
- @container_type = 2
- @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
- @organization = Organization.find(@containers.first.organization_id)
- show_attachments @containers
- @tag_list = attachment_tag_list @all_attachments
+ @page = params[:page] || 1
+ else
+ render_403
end
- @page = params[:page] || 1
#render :layout => 'base_org'
end
@@ -121,6 +124,12 @@ class OrgSubfieldsController < ApplicationController
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
@attachments = []
obj.each do |container|
diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb
index f225e7f50..239253d82 100644
--- a/app/controllers/organizations_controller.rb
+++ b/app/controllers/organizations_controller.rb
@@ -69,6 +69,8 @@ class OrganizationsController < ApplicationController
def show
if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
@organization = Organization.find(params[:id])
+ # 统计访问量
+ @organization.update_attribute(:visits, @organization.visits.to_i + 1)
if params[:org_subfield_id]
@org_subfield = OrgSubfield.find(params[:org_subfield_id])
@org_subfield_ids = @org_subfield.org_document_comments.map(&:id) << 0
@@ -315,7 +317,7 @@ class OrganizationsController < ApplicationController
@organization = Organization.find(params[:id])
admins = User.where("admin=1")
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
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index 2d1f8d771..2ced977be 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -66,6 +66,7 @@ class ProjectsController < ApplicationController
helper :words
helper :project_score
helper :user_score
+ include UsersHelper
### added by william
include ActsAsTaggableOn::TagsHelper
@@ -297,66 +298,29 @@ class ProjectsController < ApplicationController
if params[:jump] && redirect_to_project_menu_item(@project, params[:jump])
return
end
-=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
-
+ # 统计访问量
+ @project.update_attribute(:visits, @project.visits.to_i + 1)
@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
# 根据私密性,取出符合条件的所有数据
if User.current.member_of?(@project) || User.current.admin?
case params[:type]
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'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10)
when 'news'
@events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10)
when 'message'
@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
-
- #events = @activity.events(@date_from, @date_to)
else
@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")
.page(params['page'|| 1]).per(10);
- # @events = @activity.events(@date_from, @date_to, :is_public => 1)
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
@topic_count = @project.boards.count
# 根据对应的请求,返回对应的数据
@@ -405,11 +369,17 @@ class ProjectsController < ApplicationController
end
flash.now[:error] = html if !html.to_s.blank?
end
- scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
- @repository = Repository.factory(scm)
- @repository.is_default = @project.repository.nil?
- @repository.project = @project
-
+ # for:设置默认分支
+ scm = params[:repository_scm] || (Redmine::Scm::Base.all & Setting.enabled_scm).first
+ @repository = Repository.factory(scm)
+ @repository.is_default = @project.repository.nil?
+ @repository.project = @project
+ unless @project.gpid.nil?
+ g = Gitlab.client
+ @gitlab_branches = g.branches(@project.gpid)
+ @branch_names = g.branches(@project.gpid).map{|b| b.name}
+ @gitlab_default_branch = g.project(@project.gpid).default_branch
+ end
end
# 项目邀请用户加入实现过程
@@ -670,8 +640,7 @@ class ProjectsController < ApplicationController
# 更新公开私有时同步gitlab公开私有
unless @project.gpid.nil?
g = Gitlab.client
- gproject = g.project(@project.gpid)
- params[:project][:is_public] ? g.edit_project(gproject.id, 20) : g.edit_project(gproject.id, 0)
+ params[:project][:is_public] ? g.edit_project(@project.gpid, 20, params[:branch]) : g.edit_project(@project.gpid, 0, params[:branch])
end
# end
if validate_parent_id && @project.save
diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb
index 7655f1eb4..9bb6055ee 100644
--- a/app/controllers/repositories_controller.rb
+++ b/app/controllers/repositories_controller.rb
@@ -140,7 +140,7 @@ class RepositoriesController < ApplicationController
attrs = {:parent_id => project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_url(attrs, :course => '0')
else
- redirect_to settings_project_url(project)
+ redirect_to project_path(project)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => project.id) }
@@ -431,7 +431,10 @@ update
def entry
entry_and_raw(false)
- render :layout => 'base_projects'
+ @content = @repository.cat(@path, @rev)
+ if is_entry_text_data?(@content, @path)
+ render :layout => 'base_projects'
+ end
end
def entry_and_raw(is_raw)
@@ -443,9 +446,7 @@ update
@content = @repository.cat(@path, @rev)
(show_error_not_found; return) unless @content
- if is_raw ||
- (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) ||
- ! is_entry_text_data?(@content, @path)
+ if is_raw || (@content.size && @content.size > Setting.file_max_size_displayed.to_i.kilobyte) || !is_entry_text_data?(@content, @path)
# Force the download
send_opt = { :filename => filename_for_content_disposition(@path.split('/').last) }
send_type = Redmine::MimeType.of(@path)
@@ -633,9 +634,10 @@ update
end
(render_404; return false) unless @repository
@path = params[:path].is_a?(Array) ? params[:path].join('/') : params[:path].to_s
- @rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip
+ # gitlab端获取默认分支
+ gitlab_branchs = $g.project(@project.gpid).default_branch
+ @project.gpid.nil? ? (@rev = params[:rev].blank? ? @repository.default_branch : params[:rev].to_s.strip) : (@rev = params[:rev].blank? ? gitlab_branchs : params[:rev].to_s.strip)
@rev_to = params[:rev_to]
-
unless @rev.to_s.match(REV_PARAM_RE) && @rev_to.to_s.match(REV_PARAM_RE)
if @repository.branches.blank?
raise InvalidRevisionParam
diff --git a/app/controllers/student_work_controller.rb b/app/controllers/student_work_controller.rb
index a38d83851..a698823e5 100644
--- a/app/controllers/student_work_controller.rb
+++ b/app/controllers/student_work_controller.rb
@@ -1,3 +1,4 @@
+#encoding: utf-8
class StudentWorkController < ApplicationController
layout "base_courses"
include StudentWorkHelper
@@ -36,6 +37,14 @@ class StudentWorkController < ApplicationController
unless student_work.save
resultObj[:status] = 200
else
+ student_work.name = params[:title]
+ student_work.description = params[:src]
+ if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(Time.now.to_s).strftime("%Y-%m-%d")
+ student_work.late_penalty = @homework.late_penalty
+ else
+ student_work.late_penalty = 0
+ end
+ student_work.save
resultObj[:status] = result["status"].to_i
resultObj[:time] = student_work_test.created_at.to_s(:db)
resultObj[:index] = student_work.student_work_tests.count
@@ -91,25 +100,27 @@ class StudentWorkController < ApplicationController
else
student_in_group = '(' + group_students.map{|user| user.id}.join(',') + ')'
end
- #老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
- if @homework.is_open == 1
- @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ #开放作品 || 老师 || 超级管理员 || 禁用匿评&&作业截止&&已提交作品 显示所有列表
+ if @homework.is_open == 1 || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
+ if @order == 'lastname'
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
+ elsif @order == 'student_id'
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ end
@show_all = true
- elsif @homework.is_open == 0 && User.current.member_of_course?(@course) || User.current.admin?
- if @is_teacher || @homework.homework_detail_manual.nil? ||
- (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
- @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
- @show_all = true
- elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
+ elsif User.current.member_of_course?(@course)
+ if @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
@stundet_works = []
else
- @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
+ @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
end
else
- @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
end
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
if @homework.homework_type == 3
@@ -129,15 +140,21 @@ class StudentWorkController < ApplicationController
if pro.nil?
my_work = []
else
- my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
+ my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
end
else
- my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
end
if my_work.empty?
@stundet_works = []
else
- @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ if @order == 'lastname'
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
+ elsif @order == 'student_id'
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name
+ end
@show_all = true
end
else
@@ -148,25 +165,28 @@ class StudentWorkController < ApplicationController
return
end
- @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
+ @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).where("users.id in #{student_in_group}").order("#{@order} #{@b_sort}"),@name).count
else
- if @homework.is_open == 1
- @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ if @homework.is_open == 1 || @is_teacher || User.current.admin? || (User.current.member_of_course?(@course) && @homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?)
+ if @order == 'lastname'
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
+ elsif @order == 'student_id'
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name
+ end
@show_all = true
- elsif @homework.is_open == 0 && User.current.member_of_course?(@course) || User.current.admin?
- if @is_teacher || @homework.homework_detail_manual.nil? || (@homework.anonymous_comment == 1 && Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") && !@homework.student_works.where(:user_id => User.current.id).empty?) #老师 || 超级管理员 显示所有列表
- @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
- @show_all = true
- elsif @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
+ elsif User.current.member_of_course?(@course)
+ if @homework.homework_detail_manual.comment_status == 1 #学生 && 未开启匿评 只看到自己的
if @homework.homework_type == 3
pro = @homework.student_work_projects.where(:user_id => User.current.id).first
if pro.nil?
@stundet_works = []
else
- @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
+ @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
end
else
- @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ @stundet_works = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
end
elsif @homework.homework_detail_manual.comment_status == 2 #学生 && 开启匿评 看到匿评列表
if @homework.homework_type == 3
@@ -186,15 +206,21 @@ class StudentWorkController < ApplicationController
if pro.nil?
my_work = []
else
- my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:id => pro.student_work_id)
+ my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:id => pro.student_work_id)
end
else
- my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where(:user_id => User.current.id)
+ my_work = @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").where(:user_id => User.current.id)
end
if my_work.empty?
@stundet_works = []
else
- @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name
+ if @order == 'lastname'
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins(:user).order("CONVERT(lastname USING gbk) COLLATE gbk_chinese_ci #{@b_sort}, login #{@b_sort}"),@name
+ elsif @order == 'student_id'
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").joins("join user_extensions on student_works.user_id = user_extensions.user_id").order("#{@order} #{@b_sort}"),@name
+ else
+ @stundet_works = search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name
+ end
@show_all = true
end
else
@@ -205,7 +231,7 @@ class StudentWorkController < ApplicationController
return
end
- @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("#{@order} #{@b_sort}"),@name).count
+ @student_work_count = (search_homework_member @homework.student_works.select("student_works.*,IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as score").order("#{@order} #{@b_sort}"),@name).count
end
@score = @b_sort == "desc" ? "asc" : "desc"
@@ -257,7 +283,7 @@ class StudentWorkController < ApplicationController
@submit_result = true
student_work = StudentWork.find(params[:student_work_id]) if params[:student_work_id]
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.homework_common_id = @homework.id
student_work.user_id = User.current.id
@@ -303,6 +329,7 @@ class StudentWorkController < ApplicationController
stu_project.save
end
end
+ @homework.update_attributes(:updated_at => Time.now)
update_course_activity(@homework.class,@homework.id)
update_user_activity(@homework.class,@homework.id)
update_org_activity(@homework.class,@homework.id)
@@ -500,6 +527,10 @@ class StudentWorkController < ApplicationController
when 3 #学生评分 学生评分显示平均分
@work.student_score = @work.student_works_scores.where(:reviewer_role => 3).average(:score).try(:round, 2).to_f
end
+ @homework.update_attributes(:updated_at => Time.now)
+ update_course_activity(@homework.class,@homework.id)
+ update_user_activity(@homework.class,@homework.id)
+ update_org_activity(@homework.class,@homework.id)
if @work.save
respond_to do |format|
format.js
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index d1f98668c..9039fd041 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -26,6 +26,7 @@ class UsersController < ApplicationController
menu_item :user_information, :only => :info
menu_item :user_course, :only => :user_courses
menu_item :user_homework, :only => :user_homeworks
+ menu_item :student_homework, :only => :student_homeworks
menu_item :user_project, :only => [:user_projects, :watch_projects]
menu_item :requirement_focus, :only => :watch_contests
menu_item :user_newfeedback, :only => :user_newfeedback
@@ -35,12 +36,12 @@ class UsersController < ApplicationController
#
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses,
- :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
+ :user_homeworks,:student_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments,
:watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index,
:activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index,
:activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index,:user_resource,
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
- :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages]
+ :user_import_homeworks,:user_search_homeworks,:user_import_resource, :user_system_messages,:choose_user_course]
before_filter :auth_user_extension, only: :show
#before_filter :rest_user_score, only: :show
#before_filter :select_entry, only: :user_projects
@@ -57,6 +58,7 @@ class UsersController < ApplicationController
helper :sort
helper :attachments
include SortHelper
+ include ApplicationHelper
helper :custom_fields
include CustomFieldsHelper
include AvatarHelper
@@ -106,10 +108,9 @@ class UsersController < ApplicationController
redirect_to signin_url
return
elsif @user != User.current && !User.current.admin?
- return render_403
+ return render_403
end
- # 初始化/更新 点击按钮时间
- # 24小时内显示系统消息
+ # 初始化/更新 点击按钮时间, 24小时内显示系统消息
update_onclick_time
# 全部设为已读
if params[:viewed] == "all"
@@ -188,17 +189,19 @@ class UsersController < ApplicationController
# 消息设置为已读
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
- course_querys.update_all(:viewed => true)
- forge_querys.update_all(:viewed => true)
- user_querys.update_all(:viewed => true)
- forum_querys.update_all(:viewed => true)
- org_querys.update_all(:viewed => true)
+ 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)
+ 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
@@ -374,32 +377,133 @@ class UsersController < ApplicationController
#用户作业列表
def user_homeworks
- if User.current == @user
- @page = params[:page] ? params[:page].to_i + 1 : 0
- user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
+ @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
+ @user = User.current
+ @r_sort = @b_sort == "desc" ? "asc" : "desc"
+ if(params[:type].blank? || params[:type] == "1") #公共题库
+ visible_course = Course.where("is_public = 1 && is_delete = 0")
+ visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
+ @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
+ elsif params[:type] == "2" #我的题库
+ @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
+ end
+ @type = params[:type]
+ @limit = 25
+ @is_remote = true
+ @hw_count = @homeworks.count
+ @hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
+ @offset ||= @hw_pages.offset
+ @homeworks = paginateHelper @homeworks,25
+ respond_to do |format|
+ format.js
+ format.html {render :layout => 'static_base'}
+ end
+ end
- #判断当前用户在当前课程的身份
- visibleCourse = @user.courses.empty? ? [] : @user.courses.visible
- homework_ids = []
- visibleCourse.each do |course|
- if User.current.allowed_to?(:as_teacher,course)
- homeworks = HomeworkCommon.where("course_id = #{course.id}")
- homework_ids << homeworks.pluck(:id) unless homeworks.empty?
- else
- homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'")
- homework_ids << homeworks.pluck(:id) unless homeworks.empty?
+ def student_homeworks
+ if User.current == @user
+ @page = params[:page] ? params[:page].to_i + 1 : 0
+ user_course_ids = @user.courses.empty? ? "(-1)" :"(" + @user.courses.visible.map{|course| course.id}.join(",") + ")"
+
+ #判断当前用户在当前课程的身份
+ visibleCourse = @user.courses.empty? ? [] : @user.courses.visible
+ homework_ids = []
+ visibleCourse.each do |course|
+ homeworks = HomeworkCommon.where("course_id = #{course.id} and publish_time <= '#{Date.today}'")
+ homework_ids << homeworks.pluck(:id) unless homeworks.empty?
+ end
+ visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")"
+ @homework_commons = HomeworkCommon.where("id in #{visible_homework_ids}").order("created_at desc").limit(10).offset(@page * 10)
+ @is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)
+ @is_in_course = params[:is_in_course].to_i || 0
+ respond_to do |format|
+ format.js
+ format.html {render :layout => 'new_base_user'}
+ end
+ else
+ render_403
+ end
+ end
+
+ def choose_user_course
+ homework = HomeworkCommon.find params[:send_id].to_i
+ if !params[:search].nil?
+ search = "%#{params[:search].to_s.strip.downcase}%"
+ @course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id} and #{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)}
+ else
+ @course = @user.courses.where("is_delete = 0 and #{Course.table_name}.id != #{homework.course_id}").select { |course| @user.allowed_to?(:as_teacher,course)}
+ end
+ @search = params[:search]
+ #这里仅仅是传递需要发送的资源id
+ @send_id = params[:send_id]
+ respond_to do |format|
+ format.js
+ end
+ end
+
+ def send_homework_to_course
+ homework = HomeworkCommon.find params[:send_id].to_i
+ course_ids = params[:course_ids]
+ course_ids.each do |course_id|
+ course = Course.find course_id.to_i
+ new_homework = HomeworkCommon.new
+ new_homework.name = homework.name
+ new_homework.user_id = User.current.id
+ new_homework.description = homework.description
+ new_homework.homework_type = homework.homework_type
+ new_homework.late_penalty = homework.late_penalty
+ new_homework.course_id = course.id
+ new_homework.teacher_priority = homework.teacher_priority
+ new_homework.anonymous_comment = homework.anonymous_comment
+ new_homework.quotes = 0
+ new_homework.is_open = homework.is_open
+ homework.attachments.each do |attachment|
+ att = attachment.copy
+ att.container_id = nil
+ att.container_type = nil
+ att.copy_from = attachment.id
+ att.save
+ new_homework.attachments << att
+ end
+ homework_detail_manual = homework.homework_detail_manual
+ homework_detail_programing = homework.homework_detail_programing
+ homework_detail_group = homework.homework_detail_group
+ if homework_detail_manual
+ new_homework.homework_detail_manual = HomeworkDetailManual.new
+ new_homework_detail_manual = new_homework.homework_detail_manual
+ new_homework_detail_manual.ta_proportion = homework_detail_manual.ta_proportion
+ new_homework_detail_manual.comment_status = 0
+ new_homework_detail_manual.evaluation_num = homework_detail_manual.evaluation_num
+ new_homework_detail_manual.absence_penalty = homework_detail_manual.absence_penalty
+ end
+ if homework_detail_programing
+ new_homework.homework_detail_programing = HomeworkDetailPrograming.new
+ new_homework.homework_detail_programing.ta_proportion = homework_detail_programing.ta_proportion
+ new_homework.homework_detail_programing.language = homework_detail_programing.language
+ homework.homework_tests.each_with_index do |homework_test|
+ new_homework.homework_tests << HomeworkTest.new(
+ input: homework_test.input,
+ output: homework_test.output
+ )
end
end
- visible_homework_ids = homework_ids.size == 0 ? "(-1)" :"(" + homework_ids.join(",") + ")"
- @homework_commons = HomeworkCommon.where("id in #{visible_homework_ids}").order("created_at desc").limit(10).offset(@page * 10)
- @is_teacher = User.current.user_extensions && User.current.user_extensions.identity == 0 && User.current.allowed_to?(:add_course, nil, :global => true)
- @is_in_course = params[:is_in_course].to_i || 0
- respond_to do |format|
- format.js
- format.html {render :layout => 'new_base_user'}
+
+ if homework_detail_group
+ new_homework.homework_detail_group = HomeworkDetailGroup.new
+ new_homework.homework_detail_group.min_num = homework_detail_group.min_num
+ new_homework.homework_detail_group.max_num = homework_detail_group.max_num
+ new_homework.homework_detail_group.base_on_project = homework_detail_group.base_on_project
end
- else
- render_403
+ if new_homework.save
+ new_homework_detail_manual.save if new_homework_detail_manual
+ new_homework.homework_detail_programing.save if new_homework.homework_detail_programing
+ new_homework.homework_detail_group.save if new_homework.homework_detail_group
+ end
+ homework.update_attribute(:quotes, homework.quotes+1)
+ end
+ @homework = homework
+ respond_to do |format|
+ format.js
end
end
@@ -424,21 +528,32 @@ class UsersController < ApplicationController
end
def user_homework_type
+ @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
+ @r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
if(params[:type].blank? || params[:type] == "1") #公共题库
visible_course = Course.where("is_public = 1 && is_delete = 0")
visible_course_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
- @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("created_at desc")
+ @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
elsif params[:type] == "2" #我的题库
- @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("created_at desc")
+ @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}'").order("#{@order} #{@b_sort}")
+ end
+ if params[:property] && params[:property] == "1"
+ @homeworks = @homeworks.where("homework_type = 1").reorder("#{@order} #{@b_sort}")
+ elsif params[:property] && params[:property] == "2"
+ @homeworks = @homeworks.where("homework_type = 2").reorder("#{@order} #{@b_sort}")
+ elsif params[:property] && params[:property] == "3"
+ @homeworks = @homeworks.where("homework_type = 3").reorder("#{@order} #{@b_sort}")
end
@type = params[:type]
- @limit = 15
+ @property = params[:property]
+ @is_import = params[:is_import]
+ @limit = params[:is_import].to_i == 1 ? 15 : 25
@is_remote = true
@hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset
- @homeworks = paginateHelper @homeworks,15
+ @homeworks = paginateHelper @homeworks,@limit
respond_to do |format|
format.js
end
@@ -446,6 +561,7 @@ class UsersController < ApplicationController
def show_homework_detail
@homework = HomeworkCommon.find params[:homework].to_i
+ @is_import = params[:is_import]
respond_to do |format|
format.js
end
@@ -453,22 +569,55 @@ class UsersController < ApplicationController
#用户主页过滤作业
def user_search_homeworks
+ @order,@b_sort = params[:order] || "created_at",params[:sort] || "desc"
+ @r_sort = @b_sort == "desc" ? "asc" : "desc"
@user = User.current
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_ids = visible_course.empty? ? "(-1)" : "(" + visible_course.map{|course| course.id}.join(",") + ")"
- @homeworks = HomeworkCommon.where("course_id in #{visible_course_ids} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
+ 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}
+ user_str_ids = search_user_by_name all_user_ids, search
+ user_ids = user_str_ids.empty? ? "(-1)" : "(" + user_str_ids.join(",") + ")"
+ 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" #课程资源
- @homeworks = HomeworkCommon.where("user_id = #{@user.id} and publish_time <= '#{Date.today}' and (name like '%#{search}%')").order("created_at desc")
+ 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
+=begin
+ if params[:property] && params[:property] == "1"
+ @homeworks = @homeworks.where("homework_type = 1")
+ elsif params[:property] && params[:property] == "2"
+ @homeworks = @homeworks.where("homework_type = 2")
+ elsif params[:property] && params[:property] == "3"
+ @homeworks = @homeworks.where("homework_type = 3")
+ end
+=end
@type = params[:type]
- @limit = 15
+ @limit = params[:is_import].to_i == 1 ? 15 : 25
@is_remote = true
@hw_count = @homeworks.count
@hw_pages = Paginator.new @hw_count, @limit, params['page'] || 1
@offset ||= @hw_pages.offset
- @homeworks = paginateHelper @homeworks,15
+ @homeworks = paginateHelper @homeworks,@limit
+ @is_import = params[:is_import]
+ @property = params[:property]
+ @search = search
respond_to do |format|
format.js
end
@@ -568,9 +717,14 @@ class UsersController < ApplicationController
end
student_work.save
+ homework.update_attributes(:updated_at => Time.now)
+ update_course_activity(homework.class,homework.id)
+ update_user_activity(homework.class,homework.id)
+ update_org_activity(homework.class,homework.id)
+
flash[:notice] = l(:notice_successful_create)
redirect_to student_work_index_url(:homework => params[:homework])
- else
+ else
render_403
end
end
@@ -642,8 +796,8 @@ class UsersController < ApplicationController
homework_detail_programing.save if homework_detail_programing
homework_detail_group.save if homework_detail_group
if params[:quotes] && !params[:quotes].blank?
- homework = HomeworkCommon.find params[:quotes].to_i
- homework.update_attribute(:quotes, homework.quotes+1)
+ quotes_homework = HomeworkCommon.find params[:quotes].to_i
+ quotes_homework.update_attribute(:quotes, quotes_homework.quotes+1)
end
if params[:is_in_course] == "1"
redirect_to homework_common_index_path(:course => homework.course_id)
@@ -684,19 +838,36 @@ class UsersController < ApplicationController
render_403
return
end
- if(params[:type].blank? || params[:type] == "1") #全部
- user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源
- @attachments = Attachment.where("(author_id = #{params[:id]} 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(',')}))").order("created_on desc")
- elsif params[:type] == "2" #课程资源
- 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(',')})) ").order("created_on desc")
- elsif params[:type] == "3" #项目资源
- @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project'").order("created_on desc")
- elsif params[:type] == "4" #附件
- @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
- elsif params[:type] == "5" #用户资源
- @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on 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[:status] == "2"
+ @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources(params[:id], @order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources(params[:id], @order, @score)
+ else
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
+ end
+ elsif params[:type] == "6" # 公共资源
+ if params[:status] == "2"
+ @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
@type = params[:type]
@limit = 7
@@ -729,6 +900,8 @@ class UsersController < ApplicationController
@attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc")
elsif params[:type] == "5" #用户资源
@attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc")
+ elsif params[:type] == "6" #公共资源
+ @attachments = Attachment.where("(is_public =1 and is_publish = 1 and container_id is not null)" + "or (author_id = #{params[:id]} and is_publish = 0)").order("created_on desc")
end
@type = params[:type]
@limit = 7
@@ -769,7 +942,7 @@ class UsersController < ApplicationController
def store_selected_resource
session[:seleted_resource_ids] = [] if session[:seleted_resource_ids].nil?
if params[:save] == 'y'
- session[:seleted_resource_ids] << params[:res_id]
+ session[:seleted_resource_ids] << params[:res_id]
else
session[:seleted_resource_ids].delete( params[:res_id])
end
@@ -804,12 +977,7 @@ class UsersController < ApplicationController
return
end
# 自己访问自己的页面才更新消息状态
- if User.current == @user
- 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
+ UserFeedbackMessage.where("user_id =? and viewed =? and journals_for_message_type =? ", User.current.id, 0, "JournalsForMessage").update_all(:viewed => true)
# end
@page = params[:page] ? params[:page].to_i + 1 : 0
if params[:type].present?
@@ -1040,6 +1208,10 @@ class UsersController < ApplicationController
end
def show
+ # 统计访问量
+ unless User.current == @user
+ @user.update_attribute(:visits, @user.visits.to_i + 1)
+ end
#更新用户申请成为课程老师或教辅消息的状态
if params[:course_id] != nil
join_course_messages = CourseMessage.where("course_id =? and course_message_type =? and user_id =? and course_message_id =? and viewed =?",
@@ -1075,12 +1247,12 @@ class UsersController < ApplicationController
else
blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")"
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
- "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
+ "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id}) " +
- "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10)
+ "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(@page * 10)
end
else
- # @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
+ # @user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types}) or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types})or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{@user.id})").order('updated_at desc').limit(10).offset(@page * 10)
blog_ids = "("+@user.blog.id.to_s+","+((User.watched_by(@user.id).count == 0 )? '0' :User.watched_by(@user.id).map{|u| u.blog.id}.join(','))+")"
@user_activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
@@ -1403,50 +1575,47 @@ class UsersController < ApplicationController
# 上传用户资源
def user_resource_create
+ 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}
@user = User.find(params[:id])
- #@user.save_attachments(params[:attachments],User.current)
- # Container_type为Principal
- Attachment.attach_filesex(@user, params[:attachments], params[:attachment_type])
- if(params[:type].blank?|| params[:type] == "1") #全部
- 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 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(',')}))").order("created_on desc")
+ # 保存文件
+ 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[:status] == "2"
+ @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources(params[:id], @order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources(params[:id], @order, @score)
else
- user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
- @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
- "and container_type in('Project','OrgSubfield','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(',')}))").order("created_on desc")
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
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(',')})) ").order("created_on desc")
+ elsif params[:type] == "6" # 公共资源
+ if params[:status] == "2"
+ @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
- 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(',')}))").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'").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").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('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
- end
- elsif params[:type] == "5" #附件
- if User.current.id.to_i == params[:id].to_i
- @attachments = Attachment.where("author_id = #{params[:id]} and container_type ='Principal'").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type ='Principal'").order("created_on desc")
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end
end
- @type = params[:type] || 1
+ @status = params[:status]
+ @type = params[:type]
@limit = 25
@is_remote = true
@atta_count = @attachments.count
@@ -1462,52 +1631,47 @@ class UsersController < ApplicationController
# 删除用户资源,分为批量删除 和 单个删除,只能删除自己上传的资源
def user_resource_delete
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?
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
-
- if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部
- 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 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(',')}))").order("created_on desc")
+ @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_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[:status] == "2"
+ @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources(params[:id], @order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources(params[:id], @order, @score)
else
- user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
- @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 " +
- "and container_type in('Project','OrgSubfield','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(',')}))").order("created_on desc")
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
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(',')})) ").order("created_on desc")
+ elsif params[:type] == "6" # 公共资源
+ if params[:status] == "2"
+ @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
- 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(',')}))").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'").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").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('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon')").order("created_on desc")
- end
- elsif params[:type] == "5" #用户资源
- if User.current.id.to_i == params[:id].to_i
- @attachments = Attachment.where("author_id = #{params[:id]} and container_type ='Principal'").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type ='Principal'").order("created_on desc")
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end
end
+ @status = params[:status]
@type = params[:type]
@limit = 25
@is_remote = true
@@ -1527,10 +1691,10 @@ class UsersController < ApplicationController
if !params[:search].nil?
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)
- .select { |course| @user.allowed_to?(:as_teacher,course)}
+ .select { |course| @user.allowed_to?(:as_teacher,course) and course.is_delete == 0 }
else
@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
@search = params[:search]
#这里仅仅是传递需要发送的资源id
@@ -1548,7 +1712,7 @@ class UsersController < ApplicationController
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)
else
- @projects = @user.projects
+ @projects = @user.projects.visible
end
@search = params[:search]
#这里仅仅是传递需要发送的资源id
@@ -1564,17 +1728,17 @@ class UsersController < ApplicationController
@flag = true
if params[:send_id].present?
send_id = params[:send_id]
- ori = Attachment.find_by_id(send_id)
+ @ori = Attachment.find_by_id(send_id)
course_ids = params[:course_ids]
if course_ids.nil?
@flag = false
end
unless course_ids.nil?
course_ids.each do |id|
- next if ori.blank?
+ next if @ori.blank?
@exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源
- if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
+ if att.id == @ori.id || (!att.copy_from.nil? && !@ori.copy_from.nil? && att.copy_from == @ori.copy_from) || att.copy_from == @ori.id || att.id == @ori.copy_from
att.created_on = Time.now
att.save
@exist = true
@@ -1582,17 +1746,22 @@ class UsersController < ApplicationController
end
end
next if @exist
- attach_copied_obj = ori.copy
- attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
+ attach_copied_obj = @ori.copy
+ attach_copied_obj.tag_list.add(@ori.tag_list) # tag关联
attach_copied_obj.container = Course.find(id)
attach_copied_obj.created_on = Time.now
attach_copied_obj.author_id = User.current.id
attach_copied_obj.is_public = 0
- attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
+ attach_copied_obj.copy_from = @ori.copy_from.nil? ? @ori.id : @ori.copy_from #发送要添加copy_from
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
- attach_copied_obj.save
+ if attach_copied_obj.save
+ # 更新引用次数
+ quotes = @ori.quotes.to_i + 1
+ @ori.update_attribute(:quotes, quotes) unless @ori.nil?
+ @ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
+ end
@save_message = attach_copied_obj.errors.full_messages
end
end
@@ -1603,10 +1772,11 @@ class UsersController < ApplicationController
@flag = false
end
send_ids.each do |send_id|
+ quotes = 0
ori = Attachment.find_by_id(send_id)
-
unless course_ids.nil?
course_ids.each do |id|
+ quotes = 0
next if ori.blank?
@exist = false
Course.find(id).attachments.each do |att| #如果课程中包含该资源
@@ -1628,7 +1798,12 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 4
end
- attach_copied_obj.save
+ if attach_copied_obj.save
+ # 更新引用次数
+ quotes = ori.quotes.to_i + 1
+ ori.update_attribute(:quotes, quotes) unless ori.nil?
+ ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
+ end
@save_message = attach_copied_obj.errors.full_messages
end
end
@@ -1686,12 +1861,18 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
- attach_copied_obj.save
+ if attach_copied_obj.save
+ # 更新引用次数
+ quotes = ori.quotes.to_i + 1
+ ori.update_attribute(:quotes, quotes) unless ori.nil?
+ ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
+ end
unless Project.find(project_id).project_score.nil?
Project.find(project_id).project_score.update_attribute(:attach_num,
Project.find(project_id).project_score.attach_num + 1)
end
end
+ @ori = ori
end
elsif params[:send_ids].present?
send_ids = params[:send_ids].split(" ")
@@ -1700,10 +1881,11 @@ class UsersController < ApplicationController
@flag = false
end
send_ids.each do |send_id|
-
+ quotes = 0
ori = Attachment.find_by_id(send_id)
unless project_ids.nil?
project_ids.each do |project_id|
+ quotes = 0
next if ori.blank?
@exist = false
Project.find(project_id).attachments.each do |att| #如果课程中包含该资源
@@ -1725,7 +1907,12 @@ class UsersController < ApplicationController
if attach_copied_obj.attachtype == nil
attach_copied_obj.attachtype = 1
end
- attach_copied_obj.save
+ if attach_copied_obj.save
+ # 更新引用次数
+ quotes = ori.quotes.to_i + 1
+ ori.update_attribute(:quotes, quotes) unless ori.nil?
+ ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
+ end
unless Project.find(project_id).project_score.nil?
Project.find(project_id).project_score.update_attribute(:attach_num, Project.find(project_id).project_score.attach_num + 1)
end
@@ -1762,7 +1949,46 @@ class UsersController < ApplicationController
end
ori = Attachment.find_by_id(send_id)
unless subfield_id.nil?
- attach_copied_obj = ori.copy
+ attach_copied_obj = ori.copy
+ @exist = false
+ OrgSubfield.find(subfield_id).attachments.each do |att| #如果课程中包含该资源
+ if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
+ att.created_on = Time.now
+ att.save
+ @exist = true
+ break
+ end
+ end
+ if @exist == false #如果不存在该资源
+ attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
+ attach_copied_obj.container = OrgSubfield.find(subfield_id)
+ attach_copied_obj.created_on = Time.now
+ attach_copied_obj.author_id = User.current.id
+ attach_copied_obj.is_public = 0
+ attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
+ if attach_copied_obj.attachtype == nil
+ attach_copied_obj.attachtype = 1
+ end
+ if attach_copied_obj.save
+ # 更新引用次数
+ quotes = ori.quotes.to_i + 1
+ ori.update_attribute(:quotes, quotes) unless ori.nil?
+ ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
+ end
+ end
+ end
+ @ori = ori
+ elsif params[:send_ids].present?
+ send_ids = params[:send_ids].split(" ")
+ subfield_id = params[:subfield]
+ if subfield_id.nil?
+ @flag = false
+ end
+ send_ids.each do |send_id|
+ quotes = 0
+ ori = Attachment.find_by_id(send_id)
+ unless subfield_id.nil?
+ next if ori.blank?
@exist = false
OrgSubfield.find(subfield_id).attachments.each do |att| #如果课程中包含该资源
if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
@@ -1772,51 +1998,23 @@ class UsersController < ApplicationController
break
end
end
- if @exist == false #如果不存在该资源
- attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
- attach_copied_obj.container = OrgSubfield.find(subfield_id)
- attach_copied_obj.created_on = Time.now
- attach_copied_obj.author_id = User.current.id
- attach_copied_obj.is_public = 0
- attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
- if attach_copied_obj.attachtype == nil
- attach_copied_obj.attachtype = 1
- end
- attach_copied_obj.save
+ next if @exist
+ attach_copied_obj = ori.copy
+ attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
+ attach_copied_obj.container = OrgSubfield.find(subfield_id)
+ attach_copied_obj.created_on = Time.now
+ attach_copied_obj.author_id = User.current.id
+ attach_copied_obj.is_public = 0
+ attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
+ if attach_copied_obj.attachtype == nil
+ attach_copied_obj.attachtype = 1
+ end
+ if attach_copied_obj.save
+ # 更新引用次数
+ quotes = ori.quotes.to_i + 1
+ ori.update_attribute(:quotes, quotes) unless ori.nil?
+ ori.forwards << Forward.new(:to_type => attach_copied_obj.class.name, :to_id => attach_copied_obj.id,:created_at => Time.now)
end
- end
- elsif params[:send_ids].present?
- send_ids = params[:send_ids].split(" ")
- subfield_id = params[:subfield]
- if subfield_id.nil?
- @flag = false
- end
- send_ids.each do |send_id|
-
- ori = Attachment.find_by_id(send_id)
- unless subfield_id.nil?
- next if ori.blank?
- @exist = false
- OrgSubfield.find(subfield_id).attachments.each do |att| #如果课程中包含该资源
- if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
- att.created_on = Time.now
- att.save
- @exist = true
- break
- end
- end
- next if @exist
- attach_copied_obj = ori.copy
- attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
- attach_copied_obj.container = OrgSubfield.find(subfield_id)
- attach_copied_obj.created_on = Time.now
- attach_copied_obj.author_id = User.current.id
- attach_copied_obj.is_public = 0
- attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
- if attach_copied_obj.attachtype == nil
- attach_copied_obj.attachtype = 1
- end
- attach_copied_obj.save
end
end
else
@@ -1845,10 +2043,14 @@ class UsersController < ApplicationController
course_ids.each do |course_id|
if Course.find(course_id).news.map(&:id).exclude?(news.id)
course_news = News.create(:course_id => course_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1)
+ #record forward to table forwards if new record is valid
+ if course_news.valid?
+ news.forwards << Forward.new(:to_type => course_news.class.name, :to_id => course_news.id)
+ end
news.attachments.each do |attach|
course_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
- :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
- :is_public => attach.is_public, :quotes => 0)
+ :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
+ :is_public => attach.is_public, :quotes => 0)
end
end
end
@@ -1861,10 +2063,14 @@ class UsersController < ApplicationController
project = Project.find(project_id)
if project.news.map(&:id).exclude?(news.id)
message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id)
+ # record forward to table forwards if new record is valid
+ if message.valid?
+ news.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id)
+ end
news.attachments.each do |attach|
message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
- :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
- :is_public => attach.is_public, :quotes => 0)
+ :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
+ :is_public => attach.is_public, :quotes => 0)
end
end
end
@@ -1874,10 +2080,14 @@ class UsersController < ApplicationController
news = News.find(params[:send_id])
field_id = params[:subfield]
org_news = News.create(:org_subfield_id => field_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now,:project_id => -1)
+ # record forward to table forwards if new record is valid
+ if org_news.valid?
+ news.forwards << Forward.new(:to_type => org_news.class.name, :to_id => org_news.id)
+ end
news.attachments.each do |attach|
org_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
- :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
- :is_public => attach.is_public, :quotes => 0)
+ :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
+ :is_public => attach.is_public, :quotes => 0)
end
OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'News', :org_act_id => org_news.id, :user_id => User.current.id)
end
@@ -1889,6 +2099,10 @@ class UsersController < ApplicationController
course = Course.find(course_id)
if course.news.map(&:id).exclude?(@message.id)
message = Message.create(:board_id => course.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
+ # record forward to table forwards if new record is valid
+ if message.valid?
+ @message.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id)
+ end
@message.attachments.each do |attach|
message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
@@ -1905,6 +2119,10 @@ class UsersController < ApplicationController
project = Project.find(project_id)
if project.news.map(&:id).exclude?(@message.id)
message = Message.create(:board_id => project.boards.first.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
+ # record forward to table forwards if new record is valid
+ if message.valid?
+ @message.forwards << Forward.new(:to_type => message.class.name, :to_id => message.id)
+ end
@message.attachments.each do |attach|
message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
@@ -1921,6 +2139,10 @@ class UsersController < ApplicationController
@message.save
board = OrgSubfield.find(field_id).boards.first
mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id)
+ # record forward to table forwards if new record is valid
+ if mes.valid?
+ @message.forwards << Forward.new(:to_type => mes.class.name, :to_id => mes.id)
+ end
@message.attachments.each do |attach|
mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest,
:downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype,
@@ -2133,54 +2355,163 @@ class UsersController < ApplicationController
end
end
+ # 获取公共资源
+ 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("#{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
+
+ # 获取我的资源
+ 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')) "+
+ "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("#{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
+
+ # 获取我的课程资源
+ def get_course_resources author_id, user_course_ids, order, score
+ 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
+
+ # 获取公共资源中课程资源
+ 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("#{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
+
+ # 获取我的项目资源
+ def get_project_resources author_id, user_project_ids, order, score
+ 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
+
+ # 获取公共资源的项目资源
+ 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("#{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
+
+ # 获取我上传的附件
+ def get_attch_resources author_id, order, score
+ 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
+
+ # 获取公共资源中我上传的附件
+ 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) and (filename like :p)", :p => search).order("#{order.nil? ? 'created_on' : order} #{score}")
+ end
+
+ # 获取我的用户类型资源
+ def get_principal_resources author_id, order, score
+ 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
+
+ # 获取我的用户类型资源
+ def get_principal_resources_public order, score
+ 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
+
# 资源库 分为全部 课程资源 项目资源 附件
def user_resource
- #确定container_type
- # @user = User.find(params[:id])
+ @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
render_403
return
end
- if(params[:type].blank? || params[:type] == "1") #全部
- 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 is_publish = 1 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)").order("created_on 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[:status] == "2"
+ @attachments = get_course_resources(params[:id], user_course_ids, @order, @score)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources(params[:id], user_project_ids, @order, @score)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources(params[:id], @order, @score)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources(params[:id], @order, @score)
else
- user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #Ta的资源库的话,应该是他上传的公开资源 加上 他加入的所有我可见课程里的公开资源
- @attachments = Attachment.where("(author_id = #{params[:id]} and is_public = 1 and is_publish = 1 " +
- "and container_type in('Project','OrgSubfield','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 is_publish = 1)").order("created_on desc")
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
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' 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")
+ elsif params[:type] == "6" # 公共资源
+ if params[:status] == "2"
+ @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
- 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' and is_publish = 1)"+
- "or (container_type = 'Course' and is_public = 1 and is_publish = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))").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'").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' ").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('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon','OrgSubfield','Principal')").order("created_on desc")
- end
- elsif params[:type] == "5" #用户资源
- if User.current.id.to_i == params[:id].to_i
- @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal'").order("created_on desc")
- else
- @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal'").order("created_on desc")
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
end
end
+ @status = params[:status]
@type = params[:type]
@limit = 25
@is_remote = true
@@ -2191,54 +2522,173 @@ class UsersController < ApplicationController
@attachments = paginateHelper @attachments,25
respond_to do |format|
format.js
- format.html {render :layout => 'new_base_user'}
+ format.html {render :layout => 'new_base'}
+ end
+ end
+
+ # 导入资源
+ def import_resources
+ # 别人的资源库是没有权限去看的
+ if User.current.id.to_i != params[:id].to_i
+ render_403
+ return
+ 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_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") # 我的资源
+ # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
+ @attachments = get_my_resources(params[:id], user_course_ids, user_project_ids, @order, @score)
+ elsif params[:type] == "6" # 公共资源
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_public_resources(user_course_ids, user_project_ids, params[:order], @score)
+ end
+ @status = params[:status]
+ @type = params[:type]
+ @limit = 10
+ @is_remote = true
+ @atta_count = @attachments.count
+ @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
+ @offset ||= @atta_pages.offset
+ #@curse_attachments_all = @all_attachments[@offset, @limit]
+ @attachments = paginateHelper @attachments,10
+ respond_to do |format|
+ format.js
+ format.html {render :layout => 'new_base'}
+ end
+ end
+
+ def import_resources_search
+ @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
+ render_403
+ return
+ end
+ @resource_id = params[:mul_id]
+ if(params[:type].blank? || params[:type] == "1") # 我的资源
+ # 修正:我的资源库的话,那么应该是我上传的所有资源加上,我加入的课程、项目、组织的所有资源
+ 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}
+ @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
+ elsif params[:type] == "6" # 公共资源
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_public_resources_search(user_course_ids, user_project_ids, @order, @score, search)
+ end
+ @type = params[:type]
+ @limit = 10
+ @is_remote = true
+ @atta_count = @attachments.count
+ @atta_pages = Paginator.new @atta_count, @limit, params['page'] || 1
+ @offset ||= @atta_pages.offset
+ #@curse_attachments_all = @all_attachments[@offset, @limit]
+ @attachments = paginateHelper @attachments, 10
+ respond_to do |format|
+ format.js
+ # format.html {render :layout => 'new_base'}
+ end
+ end
+
+ # 内容导入到对象中
+ def import_into_container
+ send_ids = params[:checkbox1]
+ # mul_id为当前课程id、项目id、组织id的多种形态
+ mul_id = params[:mul_id]
+ if params[:mul_type] == "Course"
+ mul_container = Course.find(mul_id)
+ elsif params[:mul_type] == "Project"
+ mul_container = Project.find(mul_id)
+ elsif params[:mul_type] == "SubfieldFile"
+ mul_container = OrgSubfield.find(mul_id)
+ end
+ unless params[:checkbox1].blank?
+ send_ids.each do |send_id|
+ ori = Attachment.find_by_id(send_id)
+ # 如果该附件已经存课程中,则只更新附件创建时间
+ mul_container.attachments.each do |att|
+ if att.id == ori.id || (!att.copy_from.nil? && !ori.copy_from.nil? && att.copy_from == ori.copy_from) || att.copy_from == ori.id || att.id == ori.copy_from
+ att.created_on = Time.now
+ att.save
+ @exist = true
+ break
+ end
+ end
+ next if @exist
+ attach_copied_obj = ori.copy
+ attach_copied_obj.tag_list.add(ori.tag_list) # tag关联
+ attach_copied_obj.container = mul_container
+ attach_copied_obj.created_on = Time.now
+ attach_copied_obj.author_id = User.current.id
+ attach_copied_obj.is_public = 0
+ attach_copied_obj.copy_from = ori.copy_from.nil? ? ori.id : ori.copy_from #发送要添加copy_from
+ if attach_copied_obj.attachtype == nil
+ attach_copied_obj.attachtype = 4
+ end
+ attach_copied_obj.save
+ @save_message = attach_copied_obj.errors.full_messages
+ end
+ end
+ respond_to do |format|
+ format.html {
+ if params[:mul_type] == "Course"
+ redirect_to course_files_url(mul_container) unless mul_container.nil?
+ elsif params[:mul_type] == "Project"
+ redirect_to project_files_url(mul_container) unless mul_container.nil?
+ elsif params[:mul_type] == "SubfieldFile"
+ redirect_to org_subfield_files_url(mul_container) unless mul_container.nil?
+ end
+ }
end
end
# 根据资源关键字进行搜索
def resource_search
- search = "%#{params[:search].strip.downcase}%"
- if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部
- 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 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 (filename like :p) ",:p=>search).order("created_on desc")
+ @order, @b_sort = params[:order] || "created_on", params[:sort] || "desc"
+ @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}
+ if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') # 全部
+ if params[:status] == "2"
+ @attachments = get_course_resources_search(params[:id], user_course_ids, @order, @score, search)
+ elsif params[:status] == "3"
+ @attachments = get_project_resources_search(params[:id], user_project_ids, @order, @score, search)
+ elsif params[:status] == "4"
+ @attachments = get_attch_resources_search(params[:id], @order, @score, search)
+ elsif params[:status] == "5"
+ @attachments = get_principal_resources_search(params[:id], @order, @score, search)
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 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")
+ # 公共资源库:所有公开资源或者我上传的私有资源
+ @attachments = get_my_resources_search(params[:id], user_course_ids, user_project_ids, @order, @score, search)
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")
+ elsif params[:type] == "6" # 公共资源
+ if params[:status] == "2"
+ @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
- 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
- @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")
- end
- elsif params[:type] == "5" #用户资源
- if User.current.id.to_i == params[:id].to_i
- @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' 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 = '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
+ @status = params[:status]
@type = params[:type]
@limit = 25
@is_remote = true
diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb
index d1aa67483..e6d1d9117 100644
--- a/app/controllers/words_controller.rb
+++ b/app/controllers/words_controller.rb
@@ -276,7 +276,7 @@ class WordsController < ApplicationController
ids = params[:asset_id].split(',')
update_kindeditor_assets_owner ids,feedback[:id],OwnerTypeHelper::JOURNALSFORMESSAGE
end
-
+ @homework_common.update_attributes(:updated_at => Time.now)
update_course_activity(@homework_common.class,@homework_common.id)
update_user_activity(@homework_common.class,@homework_common.id)
update_org_activity(@homework_common.class,@homework_common.id)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 9d08be378..3a5cdb1a1 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -110,46 +110,109 @@ module ApplicationHelper
end
end
- # 更新课程英雄榜得分
- # user传过来必须是学生
+ # 更新课程活跃度得分
def course_member_score(course_id,user_id,type)
course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course_id, user_id).first
case type
- when "JournalForMessage"
+ when "HomeworkCommon"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
- :news_reply_num => 0, :resource_num => 0, :journal_num => 1, :journal_reply_num => 0, :total_score => 1)
+ :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :homework_journal_num => 1)
+ else
+ score = course_contributor_score.homework_journal_num + 1
+ course_contributor_score.update_attributes(:homework_journal_num => score)
+ end
+ # 课程留言
+ when "Course"
+ if course_contributor_score.nil?
+ CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
+ :news_reply_num => 0, :resource_num => 0, :journal_num => 1, :journal_reply_num => 0)
else
score = course_contributor_score.journal_num + 1
- total_score = course_contributor_score.total_score + 1
- course_contributor_score.update_attributes(:journal_num => score, :total_score => total_score)
+ course_contributor_score.update_attributes(:journal_num => score)
end
when "Message"
if course_contributor_score.nil?
- CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 2, :message_reply_num => 0,
- :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 2)
+ CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 1, :message_reply_num => 0,
+ :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0)
else
- score = course_contributor_score.message_num + 2
- total_score = course_contributor_score.total_score + 2
- course_contributor_score.update_attributes(:message_num => score, :total_score => total_score)
+ score = course_contributor_score.message_num + 1
+ course_contributor_score.update_attributes(:message_num => score)
end
when "MessageReply"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 1,
- :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
+ :news_reply_num => 0, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0)
else
score = course_contributor_score.message_reply_num + 1
- total_score = course_contributor_score.total_score + 1
- course_contributor_score.update_attributes(:message_reply_num => score, :total_score => total_score)
+ course_contributor_score.update_attributes(:message_reply_num => score)
end
when "NewReply"
if course_contributor_score.nil?
CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
- :news_reply_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0, :total_score => 1)
+ :news_reply_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0)
else
score = course_contributor_score.news_reply_num + 1
- total_score = course_contributor_score.total_score + 1
- course_contributor_score.update_attributes(:news_reply_num => score, :total_score => total_score)
+ course_contributor_score.update_attributes(:news_reply_num => score)
+ end
+ when "News"
+ if course_contributor_score.nil?
+ CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
+ :news_reply_num => 0, :news_num => 1, :resource_num => 0, :journal_num => 0, :journal_reply_num => 0)
+ else
+ score = course_contributor_score.news_num + 1
+ course_contributor_score.update_attributes(:news_num => score)
+ end
+ when "Attachment"
+ if course_contributor_score.nil?
+ CourseContributorScore.create(:course_id => course_id, :user_id => user_id, :message_num => 0, :message_reply_num => 0,
+ :news_reply_num => 0, :news_num => 0, :resource_num => 1, :journal_num => 0, :journal_reply_num => 0)
+ else
+ score = course_contributor_score.resource_num + 1
+ course_contributor_score.update_attributes(:resource_num => score)
+ end
+ end
+ end
+
+ # 删除某条记录相应减少课程统计数
+ def down_course_score_num (course_id,user_id,type)
+ course_contributor_score = CourseContributorScore.where("course_id =? and user_id =?", course_id, user_id).first
+ case type
+ when "HomeworkCommon"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.homework_journal_num - 1
+ course_contributor_score.update_attribute(:homework_journal_num, score < 0 ? 0 : score)
+ end
+ # 课程留言
+ when "Course"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.journal_num - 1
+ course_contributor_score.update_attribute(:journal_num, score < 0 ? 0 : score)
+ end
+ when "Message"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.message_num - 1
+ course_contributor_score.update_attribute(:message_num, score < 0 ? 0 : score)
+ end
+ when "MessageReply"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.message_reply_num - 1
+ course_contributor_score.update_attribute(:message_reply_num, score < 0 ? 0 : score)
+ end
+ when "NewReply"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.news_reply_num - 1
+ course_contributor_score.update_attribute(:news_reply_num, score < 0 ? 0 : score)
+ end
+ when "News"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.news_num - 1
+ course_contributor_score.update_attribute(:news_num, score < 0 ? 0 : score)
+ end
+ when "Attachment"
+ unless course_contributor_score.nil?
+ score = course_contributor_score.resource_num - 1
+ course_contributor_score.update_attribute(:resource_num, score < 0 ? 0 : score)
end
end
end
@@ -307,7 +370,7 @@ module ApplicationHelper
def link_to_short_attachment(attachment, options={})
length = options[:length] ? options[:length]:23
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)
url = send(route_method, attachment, attachment.filename, options)
link_to text, url, html_options
@@ -778,7 +841,7 @@ module ApplicationHelper
def project_member_check_box_tags_ex name, principals
s = ''
principals.each do |principal|
- s << "
#{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_path( principal.id)} \n"
+ s << "#{ check_box_tag name, principal.id, false, :id => nil } #{h link_to principal.userInfo, user_url_in_org( principal.id)} \n"
end
s.html_safe
end
@@ -981,9 +1044,9 @@ module ApplicationHelper
elsif @organization
title << @organization.name
elsif @user
- title << @user.login
+ title << @user.try(:realname)
else
- title << User.current.login
+ title << User.current.try(:realname)
end
if first_page.nil? || first_page.web_title.nil?
title << Setting.app_title unless Setting.app_title == title.last
@@ -2006,7 +2069,7 @@ module ApplicationHelper
candown = User.current.member_of?(project) || (project.is_public && attachment_history.is_public == 1)
elsif attachment_history.container_type == "OrgSubfield"
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
@@ -2032,9 +2095,11 @@ module ApplicationHelper
course = attachment.container
candown= User.current.member_of_course?(course) || (course.is_public==1 && attachment.is_public == 1)
elsif attachment.container.is_a?(OrgSubfield)
- candown = true
+ org = attachment.container.organization
+ candown = User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
elsif attachment.container.is_a?(OrgDocumentComment)
- candown = true
+ org = attachment.container.organization
+ candown = User.current.member_of_org?(org) || (org.is_public && attachment.is_public == 1)
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
attachment.container.board.course
course = attachment.container.board.course
@@ -2512,14 +2577,14 @@ module ApplicationHelper
#获取匿评相关连接代码
def homework_anonymous_comment (homework, is_in_course, user_activity_id = -1, course_activity = -1)
- if Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
+ if homework.homework_detail_manual.comment_status == 0 ||Time.parse(homework.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")
link = link_to "启动匿评","javascript:void(0)", :class => "postOptionLink", :title => "作业截止日期之前不可以启动匿评"
elsif homework.student_works.count >= 2 && homework.homework_detail_manual#作业份数大于2
case homework.homework_detail_manual.comment_status
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
- 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
# link = link_to "匿评结束","javascript:void(0)", :class => "postOptionLink", :title => "匿评结束"
end
@@ -2566,7 +2631,7 @@ module ApplicationHelper
def user_for_homework_common homework,is_teacher
if User.current.member_of_course?(homework.course)
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 #学生显示提交作品、修改作品等按钮
work = cur_user_works_for_homework homework
project = cur_user_projects_for_homework homework
@@ -2574,30 +2639,30 @@ module ApplicationHelper
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 => '请先关联项目再提交作品'
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
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
link_to "补交作品(#{homework.student_works.count})","javascript:void(0)", :class => 'c_grey',:style=>"cursor:not-allowed",:title => '请先关联项目再补交作品'
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
else
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
- 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")#编程作业不能修改作品
- 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
- 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
- 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
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
@@ -2876,3 +2941,106 @@ int main(int argc, char** argv){
end
end
end
+
+def user_url_in_org(user_id)
+ Setting.protocol + "://" + Setting.host_name + "/users/" + user_id.to_s
+end
+
+def project_issues_url_in_org(project_id)
+ Setting.protocol + "://" + Setting.host_name + "/projects/" + project_id.to_s + "/issues"
+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
+
+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
+
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index 2cdb277be..37c7deb4c 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -25,7 +25,7 @@ module CoursesHelper
# 获取tag匹配结果ID
a_tags = []
# kc = keywords.to_a
- Course.visible.where("is_excellent =?", 1).each do |ec|
+ Course.visible.where("is_excellent =? and is_public =?", 1, 1).each do |ec|
if ec.tags.any?{|value| current_course.name.include?(value.to_s)}
a_tags << ec.id
end
@@ -44,7 +44,7 @@ module CoursesHelper
excellent_ids = a_courses.flatten.uniq.delete_if{|i| i == current_course.id}
limit = 5 - excellent_ids.length.to_i
sql = "SELECT distinct c.id FROM course_activities cs, courses c where cs.course_id = c.id
- and c.is_excellent =1 and c.id != #{current_course.id} order by cs.updated_at desc;"
+ and c.is_excellent =1 and c.is_public = 1 and c.id != #{current_course.id} order by cs.updated_at desc;"
default_ecourse_ids = Course.find_by_sql(sql).flatten
# REDO:时间紧,待优化
default_ids =[]
@@ -71,6 +71,11 @@ module CoursesHelper
project.members.count
end
+ # 统计课程中作品的数量
+ def student_works_num course
+ StudentWork.find_by_sql("SELECT * FROM student_works WHERE homework_common_id IN (SELECT id FROM homework_commons WHERE course_id = '#{course.id}')").count
+ end
+
# 返回教师数量,即roles表中定义的Manager
def teacherCount project
project ? project.members.count - studentCount(project).to_i : 0
@@ -116,7 +121,7 @@ module CoursesHelper
@course.journals_for_messages.where('m_parent_id IS NULL').count
end
- #当前学期
+ #当前学期(2015春季学期)
def current_time_and_term course
str = ""
term = cur_course_term
@@ -144,6 +149,22 @@ module CoursesHelper
val
end
+ #当前学期(2015春)
+ def current_time_and_term_short course
+ str = ""
+ term = cur_course_term
+ if (course.time == course.end_time && course.term == course.end_term) || (course.end_term.nil? && course.end_time.nil?) || course.time > Time.now.year
+ str = course.time.to_s + course.term[0]
+ elsif course.time == Time.now.year && set_term_value(cur_course_term) <= set_term_value(course.term)
+ str = course.time.to_s + course.term[0]
+ elsif course.end_time < Time.now.year || (course.end_time == Time.now.year && set_term_value(cur_course_term) >= set_term_value(course.term))
+ str = course.end_time.to_s + course.end_term[0]
+ else
+ str = Time.now.year.to_s + cur_course_term[0]
+ end
+ str
+ end
+
# 返回学生数量,即roles表中定义的Reporter
#def studentCount project
# searchStudent(project).count
@@ -585,6 +606,24 @@ module CoursesHelper
Course.tagged_with(tag_name).order('updated_at desc')
end
+ #分班下拉框
+ def course_group_option course
+ type = []
+ option1 = []
+ option1 << "暂无"
+ option1 << 0
+ type << option1
+ unless course.course_groups.nil?
+ course.course_groups.each do |cg|
+ option = []
+ option << cg.name
+ option << cg.id
+ type << option
+ end
+ end
+ type
+ end
+
#课程实践年份下拉框
def course_time_option year
type = []
@@ -746,7 +785,7 @@ module CoursesHelper
return[] unless course
result = []
course.attachments.each do |attachment|
- if attachment.is_public? ||User.current == attachment.author ||User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id))|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin?
+ if (attachment.is_public? && attachment.is_publish == 1) ||User.current == attachment.author ||User.current.allowed_to?(:as_teacher,course)|| (User.current.member_of_course?(course) && attachment.is_publish == 1) || User.current.admin?
result << attachment
end
end
@@ -826,7 +865,7 @@ module CoursesHelper
# 学生按作业总分排序,取前8个
def hero_homework_score(course, score_sort_by)
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
WHERE student_works.homework_common_id = homework_commons.id
AND homework_commons.course_id = #{course.id}
@@ -840,7 +879,9 @@ module CoursesHelper
end
def contributor_course_scor(course_id)
- ccs = CourseContributorScore.where("course_id =?", course_id).order("total_score desc") .limit(9)
+ ccs = CourseContributorScore.find_by_sql("SELECT * FROM `course_contributor_scores` where course_id = #{course_id} order by
+ (message_num*2 + message_reply_num + news_reply_num + news_num +
+ resource_num*5 + journal_num + homework_journal_num ) desc limit 9;")
end
end
diff --git a/app/helpers/exercise_helper.rb b/app/helpers/exercise_helper.rb
index aba2fb58e..6dadf92b5 100644
--- a/app/helpers/exercise_helper.rb
+++ b/app/helpers/exercise_helper.rb
@@ -1,153 +1,178 @@
-# encoding: utf-8
-module ExerciseHelper
-
- # 单选
- def sigle_selection_standard_answer(params)
- size = params.ord - 96
- if size > 0 # 小写字母答案
- answer = params.ord - 96
- else
- answer = params.ord - 64
- end
- end
-
- # 多选
- def multiselect_standard_answer(params)
- size = params.ord - 96
- answer = []
- if size > 0 # 小写字母答案
- for i in 0..(params.length-1)
- answer << (params[i].ord - 96).to_s
- end
- else
- for i in 0..(params.length-1)
- answer << (params[i].ord - 64)
- end
- end
- answer = answer.sort
- answer.join("")
- end
-
- #
- def fill_standart_answer(params, standart_answer)
- params.each do |param|
- standart_answer.answer_text = param.value
- standart_answer.save
- end
- end
-
- # 获取多选的得分
- def get_mulscore(question, user)
- ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id)
- arr = []
- ecs.each do |ec|
- arr << ec.exercise_choice.choice_position
- end
- #arr = arr.sort
- str = arr.sort.join("")
- return str
- end
-
- # 判断用户是否已经提交了问卷
- # status 为0的时候是用户点击试卷。为1表示用户已经提交
- def has_commit_exercise?(exercise_id, user_id)
- pu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise_id, user_id, true)
- if pu.empty?
- false
- else
- true
- end
- end
-
- # 判断学生是否点击过问卷,点击则为他保存一个记录,记录start_at
- def has_click_exercise?(exercise_id, user_id)
- pu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise_id, user_id, false)
- if pu.empty?
- false
- else
- true
- end
- end
-
- def convert_to_char(str)
- result = ""
- length = str.length
- unless str.nil?
- if length === 1
- result += (str.to_i + 64).chr
- return result
- elsif length > 1
- for i in 0...length
- result += (str[i].to_i + 64).chr
- end
- return result
- end
- end
- return result
- end
-
- def get_current_score exercise
- score = 0
- unless exercise.nil?
- exercise.exercise_questions.each do |exercise_question|
- unless exercise_question.question_score.nil?
- score += exercise_question.question_score
- end
- end
- return score
- end
- return score
- end
-
- def answer_be_selected?(answer,user)
- pv = answer.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id} ")
- if !pv.nil? && pv.count > 0
- true
- else
- false
- end
- end
-
- #获取未完成的题目
- def get_uncomplete_question exercise,user
- all_questions = exercise.exercise_questions
- uncomplete_question = []
- all_questions.each do |question|
- answers = get_user_answer(question, user)
- if answers.empty?
- uncomplete_question << question
- end
- end
- uncomplete_question
- end
-
- #获取文本题答案
- def get_anwser_vote_text(question_id,user_id)
- pv = ExerciseAnswer.find_by_exercise_question_id_and_user_id(question_id,user_id)
- if pv.nil?
- ''
- else
- pv.answer_text
- end
- end
-
- # 获取当前学生回答问题的答案
- def get_user_answer(question,user)
- user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}")
- user_answer
- end
-
- # 获取问题的标准答案
- def get_user_standard_answer(question,user)
- if question.question_type == 3
- standard_answer =[]
- question.exercise_standard_answers.each do |answer|
- standard_answer << answer.answer_text
- end
- else
- standard_answer = question.exercise_standard_answers
- end
- standard_answer
- end
-
+# encoding: utf-8
+module ExerciseHelper
+
+ # 单选
+ def sigle_selection_standard_answer(params)
+ size = params.ord - 96
+ if size > 0 # 小写字母答案
+ answer = params.ord - 96
+ else
+ answer = params.ord - 64
+ end
+ end
+
+ # 多选
+ def multiselect_standard_answer(params)
+ size = params.ord - 96
+ answer = []
+ if size > 0 # 小写字母答案
+ for i in 0..(params.length-1)
+ answer << (params[i].ord - 96).to_s
+ end
+ else
+ for i in 0..(params.length-1)
+ answer << (params[i].ord - 64)
+ end
+ end
+ answer = answer.sort
+ answer.join("")
+ end
+
+ #
+ def fill_standart_answer(params, standart_answer)
+ params.each do |param|
+ standart_answer.answer_text = param.value
+ standart_answer.save
+ end
+ end
+
+ # 获取多选的得分
+ def get_mulscore(question, user)
+ ecs = ExerciseAnswer.where("user_id =? and exercise_question_id =?", user.id, question.id)
+ arr = []
+ ecs.each do |ec|
+ arr << ec.exercise_choice.choice_position
+ end
+ #arr = arr.sort
+ str = arr.sort.join("")
+ return str
+ end
+
+ # 判断用户是否已经提交了问卷
+ # status 为0的时候是用户点击试卷。为1表示用户已经提交
+ def has_commit_exercise?(exercise_id, user_id)
+ pu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise_id, user_id, true)
+ if pu.empty?
+ false
+ else
+ true
+ end
+ end
+
+ # 判断学生是否点击过问卷,点击则为他保存一个记录,记录start_at
+ def has_click_exercise?(exercise_id, user_id)
+ pu = ExerciseUser.where("exercise_id=? and user_id=? and status=?",exercise_id, user_id, false)
+ if pu.empty?
+ false
+ else
+ true
+ end
+ end
+
+ def convert_to_char(str)
+ result = ""
+ length = str.length
+ unless str.nil?
+ if length === 1
+ result += (str.to_i + 64).chr
+ return result
+ elsif length > 1
+ for i in 0...length
+ result += (str[i].to_i + 64).chr
+ end
+ return result
+ end
+ end
+ return result
+ end
+
+ def convert_to_chi_num num
+ result = ""
+ case num.to_i
+ when 1
+ result = '一'
+ when 2
+ result = '二'
+ when 3
+ result = '三'
+ when 4
+ result = '四'
+ when 5
+ result = '五'
+ when 6
+ result = '六'
+ when 7
+ result = '七'
+ when 8
+ result = '八'
+ when 9
+ result = '九'
+ end
+ return result
+ end
+
+ def get_current_score exercise
+ score = 0
+ unless exercise.nil?
+ exercise.exercise_questions.each do |exercise_question|
+ unless exercise_question.question_score.nil?
+ score += exercise_question.question_score
+ end
+ end
+ return score
+ end
+ return score
+ end
+
+ def answer_be_selected?(answer,user)
+ pv = answer.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id} ")
+ if !pv.nil? && pv.count > 0
+ true
+ else
+ false
+ end
+ end
+
+ #获取未完成的题目
+ def get_uncomplete_question exercise,user
+ all_questions = exercise.exercise_questions
+ uncomplete_question = []
+ all_questions.each do |question|
+ answers = get_user_answer(question, user)
+ if answers.empty?
+ uncomplete_question << question
+ end
+ end
+ uncomplete_question
+ end
+
+ #获取文本题答案
+ def get_anwser_vote_text(question_id,user_id)
+ pv = ExerciseAnswer.find_by_exercise_question_id_and_user_id(question_id,user_id)
+ if pv.nil?
+ ''
+ else
+ pv.answer_text
+ end
+ end
+
+ # 获取当前学生回答问题的答案
+ def get_user_answer(question,user)
+ user_answer = question.exercise_answers.where("#{ExerciseAnswer.table_name}.user_id = #{user.id}")
+ user_answer
+ end
+
+ # 获取问题的标准答案
+ def get_user_standard_answer(question,user)
+ if question.question_type == 3
+ standard_answer =[]
+ question.exercise_standard_answers.each do |answer|
+ standard_answer << answer.answer_text
+ end
+ else
+ standard_answer = question.exercise_standard_answers
+ end
+ standard_answer
+ end
+
end
\ No newline at end of file
diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb
index 6b748649b..913c49310 100644
--- a/app/helpers/files_helper.rb
+++ b/app/helpers/files_helper.rb
@@ -121,12 +121,13 @@ module FilesHelper
def visable_attachemnts attachments
result = []
attachments.each do |attachment|
- if attachment.is_public? ||
+ if (attachment.is_public? && attachment.container_type != "Course") ||
+ (attachment.is_public? && attachment.container_type == "Course" && attachment.is_publish == 1)||
(attachment.container_type == "Project" && User.current.member_of?(attachment.project)) ||
(attachment.container_type == "Course" && User.current.allowed_to?(:as_teacher,Course.find(attachment.container_id)))||
(attachment.container_type == "Course" && User.current.member_of_course?(Course.find(attachment.container_id)) && attachment.is_publish == 1)||
attachment.author_id == User.current.id ||
- attachment.container_type == "OrgSubfield"
+ (attachment.container_type == "OrgSubfield" and User.current.member_of_org?(attachment.container.organization))
result << attachment
end
end
diff --git a/app/helpers/routes_helper.rb b/app/helpers/routes_helper.rb
index 15c809964..8d08f22da 100644
--- a/app/helpers/routes_helper.rb
+++ b/app/helpers/routes_helper.rb
@@ -22,10 +22,18 @@ module RoutesHelper
# Returns the path to project issues or to the cross-project
# issue list if project is nil
def _project_issues_path(project, *args)
- if project
- project_issues_path(project, *args)
+ if args[0].to_s.include? '_page'
+ if args[0].to_s == "user_page"
+ user_activities_path(args[1].to_i)
+ else
+ project_path(project)
+ end
else
- issues_path(*args)
+ if project
+ project_issues_path(project, *args)
+ else
+ issues_path(*args)
+ end
end
end
diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb
index efb67a2ac..44b919121 100644
--- a/app/helpers/users_helper.rb
+++ b/app/helpers/users_helper.rb
@@ -1,609 +1,676 @@
-# encoding: utf-8
-#
-# Redmine - project management software
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-
-
-include AvatarHelper
-module UsersHelper
- def users_status_options_for_select(selected)
- user_count_by_status = User.count(:group => 'status').to_hash
- options_for_select([[l(:label_all), ''],
- ["#{l(:status_active)} (#{user_count_by_status[1].to_i})", '1'],
- ["#{l(:status_registered)} (#{user_count_by_status[2].to_i})", '2'],
- ["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s)
- end
-
- def get_resource_type type
- case type
- when 'Course'
- '课程资源'
- when 'Project'
- '项目资源'
- when 'Issue'
- '缺陷附件'
- when 'Message'
- '讨论区附件'
- when 'Document'
- '文档附件'
- when 'News'
- '通知附件'
- when 'HomewCommon'
- '作业附件'
- when 'StudentWorkScore'
- '批改附件'
- when 'Principal'
- '用户资源'
- when 'OrgSubfield'
- '组织资源'
- end
- end
-
- def title_for_message type
- case type
- when nil
- '消息'
- when 'unviewed'
- '未读消息'
- when 'apply'
- '用户申请'
- when 'system_messages'
- '系统消息'
- when 'homework'
- '作业消息'
- when 'course_message'
- '课程讨论'
- when 'course_news'
- '课程通知'
- when 'poll'
- '课程问卷'
- when 'issue'
- '项目任务'
- when 'forge_message'
- '项目讨论'
- when 'forge_news'
- '项目新闻'
- when 'forum'
- '贴吧帖子'
- when 'user_feedback'
- '用户留言'
- end
- end
-
- def link_to_user_version(version, options = {})
- return '' unless version && version.is_a?(Version)
- link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, :class => "linkBlue"
- end
-
- # 统计未读消息数
- def unviewed_message(user)
- course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count
- forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count
- org_count = OrgMessage.where("user_id =? and viewed =?", user, 0).count
- user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count
- user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count
- at_count = user.at_messages.where(viewed: false).count
- messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count
- end
-
- def user_mail_notification_options(user)
- user.valid_notification_options.collect {|o| [l(o.last), o.first]}
- end
-
- def change_status_link(user)
- url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
-
- if user.locked?
- link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
- elsif user.registered?
- link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
- elsif user != User.current
- link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock'
- end
- end
-
- def user_settings_tabs
- tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
- {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
- ]
- if Group.all.any?
- tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural}
- end
- tabs
- end
-
- # this method is used to get all projects that tagged one tag
- # added by william
- def get_users_by_tag(tag_name)
- User.tagged_with(tag_name).order('updated_on desc')
- end
-
- # added by fq
- #
-
- # TODO: 待删
- # def show_activity(state)
- # content = ''.html_safe
- # case state
- # when 0
- # s = content_tag('span', l(:label_user_all_activity), :class => "current-page")
- # content << content_tag('li', s)
- # content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1}))
- # content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2}))
- # when 1
- # s = content_tag('span', l(:label_user_activity_myself), :class => "current-page")
- # content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'}))
- # content << content_tag('li', s, :class => "current-page")
- # content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2}))
- # when 2
- # s = content_tag('span', l(:label_user_all_respond), :class => "current-page")
- # content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'}))
- # content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1}))
- # content << content_tag('li', s, :class => "current-page")
- # end
- # content_tag('div', content, :class => "pagination")
- # end
-
- #TODO: 待删
- def watch_projects(state)
- content = ''.html_safe
- case state
- when 0
- s = content_tag('span', l(:label_project_take), :class => "current-page")
- content << content_tag('li', s)
- content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1}))
- when 1
- s = content_tag('span', l(:label_has_watched_project), :class => "current-page")
- content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'}))
- content << content_tag('li', s, :class => "current-page")
- end
- content_tag('div', content, :class => "pagination")
- end
-
- def user_course(state)
- content = ''.html_safe
- if @user != User.current
- if @user.user_extensions.identity == 0
- case state
- when 0
- s = content_tag('span', '他执教的课程', :class => "current-page")
- content << content_tag('li', s)
- content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
- content_tag('div', content, :class => "pagination")
- when 1
- s = content_tag('span', '他发布的作业', :class => "current-page")
- content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'}))
- content << content_tag('li', s, :class => "current-page")
- content_tag('div', content, :class => "pagination")
- end
- else
- case state
- when 0
- s = content_tag('span', '他的课程', :class => "current-page")
- content << content_tag('li', s)
- content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
- content_tag('div', content, :class => "pagination")
- when 1
- s = content_tag('span', '他的作业', :class => "current-page")
- content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0}))
- content << content_tag('li', s, :class => "current-page")
- content_tag('div', content, :class => "pagination")
- end
- end
- else
- if @user.user_extensions.identity == 0
- case state
- when 0
- s = content_tag('span', l(:label_teaching_course), :class => "current-page")
- content << content_tag('li', s)
- content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1}))
- content_tag('div', content, :class => "pagination")
- when 1
- s = content_tag('span', l(:label_release_homework), :class => "current-page")
- content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'}))
- content << content_tag('li', s, :class => "current-page")
- content_tag('div', content, :class => "pagination")
- end
- else
- case state
- when 0
- s = content_tag('span', l(:label_my_course), :class => "current-page")
- content << content_tag('li', s)
- content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
- content_tag('div', content, :class => "pagination")
- when 1
- s = content_tag('span', '我的作业', :class => "current-page")
- content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
- content << content_tag('li', s, :class => "current-page")
- content_tag('div', content, :class => "pagination")
- end
- end
- end
- end
-
- # added by huang
- def sort_user(state, project_type)
- content = ''.html_safe
- case state
- when 0
- content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
- content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
- content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") )
- when 1
- content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") )
- content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
- content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
- when 2
- content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
- content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") )
- content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
- end
- content = content_tag('ul', content)
- content_tag('div', content, :class => "tabs")
- end
-
- def sort_user_enterprise(state, project_type)
- content = ''.html_safe
- case state
- when 0
- content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
- content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
- content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
- when 1
- content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
- content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
- content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
- when 2
- content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
- content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
- content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
- end
- content = content_tag('ul', content)
- content_tag('div', content, :class => "tabs_enterprise")
- end
-
- def gender_avatar_uri user
- img_uri = '/images/sidebar/female.png'
- return img_uri if user.user_extensions.blank?
- person_gender = user.user_extensions.gender
- img_uri = (person_gender == 1) ? '/images/sidebar/female.png' : '/images/sidebar/male.png'
- end
-
- include CoursesHelper
- def is_watching?(user)
- login_user = User.current# 登录者
-
- courses = user.projects.where('project_type=1')
- return true if ((login_user == user) or login_user.admin?)
- courses.each do |course|
- return true if login_user.member_of?(course)
- end
- ## 下面的代码只判断是否是老师或者助教,上面是成员都可以看到
- # people_ids = []
- # user.projects.where('project_type=1').each do |project|
- # tmp = searchTeacherAndAssistant(project)
- # people_ids += (members_to_user_ids(tmp)) unless tmp.nil?
- # end
- # people_ids.include?(login_user.id) or (login_user == user) or login_user.admin?
-
- false
- end
-
- # base user上面的navbar显示内容
- def show_item_on_navbar params
- displayed_item = %w|index|
- displayed_item.include?(params['action'])
- end
- # base user上面searchBar显示
- def show_search_bar params
- displayed_flag = %w|index|
- !displayed_flag.include?(params['action'])
- end
-
- #获取指定用户的未过期的课程列表
- def user_courses_list user
- result = []
- user.coursememberships.map(&:course).each do |course|
- if !course_endTime_timeout?(course)
- result << course
- end
- end
- return result
- end
-
- #获取用户参与的公开的课程列表
- def user_public_course_list user
- membership = user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
- membership.sort! {|older, newer| newer.created_on <=> older.created_on }
- memberships = []
- membership.collect { |e|
- memberships.push(e)
- }
- ## 判断课程是否过期 [需封装]
- memberships_doing = []
- memberships_done = []
- memberships.map { |e|
- if course_endTime_timeout?(e.course)
- memberships_done.push e
- else
- memberships_doing.push e
- end
- }
- end
-
- #获取用户留言相关的连接
- def user_jour_feed_back_url active
- if active.act_type == "JournalsForMessage"
- jour = JournalsForMessage.find active.act_id
- if jour
- case jour.jour_type
- when "Principal"
- link_to(l(:label_goto), user_newfeedback_user_path(jour.jour_id))
- when "Project"
- link_to(l(:label_goto), project_feedback_path(jour.jour_id))
- when "Bid"
- link_to(l(:label_goto), course_for_bid_path(jour.jour_id))
- when "Course"
- link_to(l(:label_goto), course_feedback_path(jour.jour_id))
- when "Contest"
- link_to(l(:label_goto), show_contest_contest_path(jour.jour_id))
- when "Softapplication"
- link_to(l(:label_goto), softapplication_path(jour.jour_id))
- when "HomeworkAttach"
- link_to(l(:label_goto), course_for_bid_path(jour.jour_id))
- end
- end
- end
- end
-
- def get_watcher_users(obj)
- count = User.watched_by(obj.id).count
- if count == 0
- return [0,[]]
- end
- list = User.watched_by(obj.id).order("#{Watcher.table_name}.id desc").limit(10).all
- return [count,list];
- end
-
- def get_fans_users(obj)
- count = obj.watcher_users.count
- if count == 0
- return [0,[]]
- end
- list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all
- return [count,list];
- end
-
- def get_visitor_users(obj)
- query = Visitor.where("master_id=?",obj.id)
- count = query.count
- if count == 0
- return [0,[]]
- end
- list = query.order("updated_on desc").limit(10).all
- return [count,list]
- end
-
- def get_create_course_count(user)
- user.courses.visible.where("tea_id = ?",user.id).count
- end
-
- #获取加入课程数
- def get_join_course_count(user)
- user.courses.visible.count - get_create_course_count(user)
- end
-
- #发布作业数
- def get_homework_commons_count(user)
- HomeworkCommon.where("user_id = ?",user.id).count
- end
-
- #资源数
- def get_projectandcourse_attachment_count(user)
- Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count
- end
-
- #创建项目数
- def get_create_project_count(user)
- user.projects.visible.where("projects.user_id=#{user.id}").count
- end
-
- #加入项目数
- def get_join_project_count(user)
- user.projects.visible.count - get_create_project_count(user)
- end
-
- #创建缺陷数
- def get_create_issue_count(user)
- Issue.where("author_id = ?",user.id).count
- end
-
- #解决缺陷数
- def get_resolve_issue_count(user)
- Issue.where("assigned_to_id = ? and status_id=3",user.id).count
- end
-
- #参与匿评数
- def get_anonymous_evaluation_count(user)
- StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count
- end
-
- def query_activities(query)
- list = query.limit(13).all
- result = []
- for item in list
- container = get_activity_container(item)
- result << { :item=>item,:e=>container }
- end
- result
- end
-
- def get_activity_container activity
- return activity.activity_container
- end
-
- def get_activity_act_showname_htmlclear(activity)
- str = get_activity_act_showname(activity)
- str = str.gsub(/<.*>/,'')
- str = str.gsub(/\r/,'')
- str = str.gsub(/\n/,'')
- str = str.lstrip.rstrip
- if str == ''
- str = 'RE:'
- end
- return str.html_safe
- end
-
- # journal.details 记录每个动作的新旧值
- def get_issue_des_update(journal)
- no_html = "message"
- arr = details_to_strings(journal.details, no_html)
- unless journal.notes.blank?
- arr << journal.notes
- end
- str = ''
- arr.each { |item| str = str+item }
- return str
- end
-
- def get_activity_act_showname(activity)
- case activity.act_type
- when "HomeworkCommon"
- return activity.act.name
- when "Issue"
- return activity.act.subject
- when "Journal"
- arr = details_to_strings(activity.act.details,true)
- arr << activity.act.notes
- str = ''
- arr.each { |item| str = str+item }
- return str
- when "JournalsForMessage"
- return activity.act.notes
- when "Message"
- return activity.act.subject
- when "News"
- return activity.act.title
- when "Poll"
- return activity.act.polls_name
- when "Contest"
- return ''
- when "Contestnotification"
- return ''
- when "Principal"
- return ''
- else
- return activity.act_type
- end
- end
-
- def get_activity_act_createtime(activity)
- case activity.act_type
- when "HomeworkCommon"
- return activity.act.created_at
- when "Poll"
- return activity.act.created_at
- else
- return activity.act.created_on
- end
- end
-
- def get_activity_container_url e
- if !e.visible?
- return "javascript:;"
- end
-
- if e.class.to_s == 'Course'
- return url_for(:controller => 'courses', :action=>"show", :id=>e.id, :host=>Setting.host_course)
- end
- return url_for(:controller => 'projects', :action=>"show", :id=>e.id, :host=>Setting.host_name)
- end
-
- def get_activity_url(activity,e)
- if !e.visible?
- return "javascript:;"
- end
-
- case activity.act_type
- # when "Contest"
- # when "Contestnotification"
- # when "Principal"
- when "HomeworkCommon"
- return homework_common_index_path( :course=>e.id )
- when "Issue"
- return issue_path(activity.act.id)
- when "Journal"
- return issue_path( activity.act.journalized_id )
- when "JournalsForMessage"
- return e.class.to_s == 'Course' ? course_feedback_path(e) : project_feedback_path(e)
- when "Message"
- return e.class.to_s == 'Course' ? course_boards_path(e) : project_boards_path(e)
- when "News"
- return news_path(activity.act)
- #return e.class.to_s == 'Course' ? course_news_index_path(e) : project_news_index_path(e)
- when "Poll"
- return poll_index_path( :polls_group_id=>activity.act.polls_group_id, :polls_type=>e.class.to_s )
- else
- return 'javascript:;'
- end
- end
-
- def get_activity_opt(activity,e)
- case activity.act_type
- when "HomeworkCommon"
- return '创建了作业'
- when "News"
- return e.class.to_s == 'Course' ? '发布了通知' : '添加了新闻'
- when "Issue"
- return '发表了问题'
- when "Journal"
- return '更新了问题'
- when "JournalsForMessage"
- return e.class.to_s == 'Course' ? '发表了留言' : '提交了反馈'
- #return ( activity.act.reply_id == nil || activity.act.reply_id == 0 ) ? '' : ''
- when "Message"
- return ( activity.act.parent_id == nil || activity.act.parent_id == '' ) ? '发布了帖子' : '回复了帖子'
- when "Poll"
- return '创建了问卷'
- else
- return '有了新动态'
- end
- end
-
- #获取指定用户作为老师的课程
- def get_as_teacher_courses user
- type = []
- option = []
- option << "请选择发布作业的课程"
- option << -1
- type << option
- 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").select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
- option = []
- option << course.name+"("+course.time.to_s+course.term+")"
- option << course.id
- type << option
- end
- type
- end
-
-end
+# encoding: utf-8
+#
+# Redmine - project management software
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+
+include AvatarHelper
+module UsersHelper
+ def users_status_options_for_select(selected)
+ user_count_by_status = User.count(:group => 'status').to_hash
+ options_for_select([[l(:label_all), ''],
+ ["#{l(:status_active)} (#{user_count_by_status[1].to_i})", '1'],
+ ["#{l(:status_registered)} (#{user_count_by_status[2].to_i})", '2'],
+ ["#{l(:status_locked)} (#{user_count_by_status[3].to_i})", '3']], selected.to_s)
+ end
+
+ def get_resource_type type
+ case type
+ when 'Course'
+ '课程资源'
+ when 'Project'
+ '项目资源'
+ when 'Issue'
+ '缺陷附件'
+ when 'Message'
+ '讨论区附件'
+ when 'Document'
+ '文档附件'
+ when 'News'
+ '通知附件'
+ when 'HomewCommon'
+ '作业附件'
+ when 'StudentWorkScore'
+ '批改附件'
+ when 'Principal'
+ '用户资源'
+ when 'OrgSubfield'
+ '组织资源'
+ end
+ end
+
+ def get_resource_origin attach
+ type = attach.container_type
+ content = attach.container
+ unless content.nil?
+ case type
+ when 'Course'
+ result = current_time_and_term_resource content
+ when 'Project'
+ result = content.name
+ when 'Issue'
+ result = content.subject
+ when 'Message'
+ result = content.subject
+ when 'News'
+ result = content.title
+ when 'HomewCommon'
+ result = content.name
+ when 'StudentWorkScore'
+ result = content.name
+ when 'Principal'
+ result = content.name
+ when 'OrgSubfield'
+ result = content.name
+ end
+ end
+ end
+
+ def current_time_and_term_resource course
+ str = ""
+ term = cur_course_term_resource
+ name = course.name
+ if (course.time == course.end_time && course.term == course.end_term) || (course.end_term.nil? && course.end_time.nil?) || course.time > Time.now.year
+ str = name + "(" + course.time.to_s + course.term.to_s + ")"
+ elsif course.time == Time.now.year && set_term_value(cur_course_term) <= set_term_value(course.term)
+ str = name + "(" + course.time.to_s + course.term.to_s + ")"
+ elsif course.end_time < Time.now.year || (course.end_time == Time.now.year && set_term_value(cur_course_term) >= set_term_value(course.term))
+ str = name + "(" + course.end_time.to_s + course.end_term.to_s + ")"
+ else
+ str = name + "(" + Time.now.year.to_s + cur_course_term_resource.to_s + ")"
+ end
+ str
+ end
+
+ def cur_course_term_resource
+ month = Time.now.month
+ if month >= 9 || month < 2
+ term = "秋"
+ elsif (month >= 7 && Time.now.day >= 15) || month == 8
+ term = "夏"
+ else
+ term = "春"
+ end
+ term
+ end
+
+ def title_for_message type
+ case type
+ when nil
+ '消息'
+ when 'unviewed'
+ '未读消息'
+ when 'apply'
+ '用户申请'
+ when 'system_messages'
+ '系统消息'
+ when 'homework'
+ '作业消息'
+ when 'course_message'
+ '课程讨论'
+ when 'course_news'
+ '课程通知'
+ when 'poll'
+ '课程问卷'
+ when 'issue'
+ '项目任务'
+ when 'forge_message'
+ '项目讨论'
+ when 'forge_news'
+ '项目新闻'
+ when 'forum'
+ '贴吧帖子'
+ when 'user_feedback'
+ '用户留言'
+ end
+ end
+
+ def link_to_user_version(version, options = {})
+ return '' unless version && version.is_a?(Version)
+ link_to_if version.visible?, format_version_name(version), { :controller => 'versions', :action => 'show', :id => version }, :class => "linkBlue"
+ end
+
+ # 统计未读消息数
+ def unviewed_message(user)
+ course_count = CourseMessage.where("user_id =? and viewed =?", user, 0).count
+ forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count
+ org_count = OrgMessage.where("user_id =? and viewed =?", user, 0).count
+ user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count
+ user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count
+ at_count = user.at_messages.where(viewed: false).count
+ messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count + org_count
+ end
+
+ def user_mail_notification_options(user)
+ user.valid_notification_options.collect {|o| [l(o.last), o.first]}
+ end
+
+ def change_status_link(user)
+ url = {:controller => 'users', :action => 'update', :id => user, :page => params[:page], :status => params[:status], :tab => nil}
+
+ if user.locked?
+ link_to l(:button_unlock), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
+ elsif user.registered?
+ link_to l(:button_activate), url.merge(:user => {:status => User::STATUS_ACTIVE}), :method => :put, :class => 'icon icon-unlock'
+ elsif user != User.current
+ link_to l(:button_lock), url.merge(:user => {:status => User::STATUS_LOCKED}), :method => :put, :class => 'icon icon-lock'
+ end
+ end
+
+ def user_settings_tabs
+ tabs = [{:name => 'general', :partial => 'users/general', :label => :label_general},
+ {:name => 'memberships', :partial => 'users/memberships', :label => :label_project_plural}
+ ]
+ if Group.all.any?
+ tabs.insert 1, {:name => 'groups', :partial => 'users/groups', :label => :label_group_plural}
+ end
+ tabs
+ end
+
+ # this method is used to get all projects that tagged one tag
+ # added by william
+ def get_users_by_tag(tag_name)
+ User.tagged_with(tag_name).order('updated_on desc')
+ end
+
+ # added by fq
+ #
+
+ # TODO: 待删
+ # def show_activity(state)
+ # content = ''.html_safe
+ # case state
+ # when 0
+ # s = content_tag('span', l(:label_user_all_activity), :class => "current-page")
+ # content << content_tag('li', s)
+ # content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1}))
+ # content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2}))
+ # when 1
+ # s = content_tag('span', l(:label_user_activity_myself), :class => "current-page")
+ # content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'}))
+ # content << content_tag('li', s, :class => "current-page")
+ # content << content_tag('li', link_to(l(:label_user_all_respond), {:controller => 'users', :action => 'show', :type => 2}))
+ # when 2
+ # s = content_tag('span', l(:label_user_all_respond), :class => "current-page")
+ # content << content_tag('li', link_to(l(:label_user_all_activity), {:controller => 'users', :action => 'show'}))
+ # content << content_tag('li', link_to(l(:label_user_activity_myself), {:controller => 'users', :action => 'show', :type => 1}))
+ # content << content_tag('li', s, :class => "current-page")
+ # end
+ # content_tag('div', content, :class => "pagination")
+ # end
+
+ #TODO: 待删
+ def watch_projects(state)
+ content = ''.html_safe
+ case state
+ when 0
+ s = content_tag('span', l(:label_project_take), :class => "current-page")
+ content << content_tag('li', s)
+ content << content_tag('li', link_to(l(:label_has_watched_project), {:controller => 'users', :action => 'watch_projects', :type => 1}))
+ when 1
+ s = content_tag('span', l(:label_has_watched_project), :class => "current-page")
+ content << content_tag('li', link_to(l(:label_project_take), {:controller => 'users', :action => 'user_projects'}))
+ content << content_tag('li', s, :class => "current-page")
+ end
+ content_tag('div', content, :class => "pagination")
+ end
+
+ def user_course(state)
+ content = ''.html_safe
+ if @user != User.current
+ if @user.user_extensions.identity == 0
+ case state
+ when 0
+ s = content_tag('span', '他执教的课程', :class => "current-page")
+ content << content_tag('li', s)
+ content << content_tag('li', link_to('他发布的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
+ content_tag('div', content, :class => "pagination")
+ when 1
+ s = content_tag('span', '他发布的作业', :class => "current-page")
+ content << content_tag('li', link_to('他执教的课程', {:controller => 'users', :action => 'user_courses'}))
+ content << content_tag('li', s, :class => "current-page")
+ content_tag('div', content, :class => "pagination")
+ end
+ else
+ case state
+ when 0
+ s = content_tag('span', '他的课程', :class => "current-page")
+ content << content_tag('li', s)
+ content << content_tag('li', link_to('他的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
+ content_tag('div', content, :class => "pagination")
+ when 1
+ s = content_tag('span', '他的作业', :class => "current-page")
+ content << content_tag('li', link_to('他的课程', {:controller => 'users', :action => 'user_courses', :type => 0}))
+ content << content_tag('li', s, :class => "current-page")
+ content_tag('div', content, :class => "pagination")
+ end
+ end
+ else
+ if @user.user_extensions.identity == 0
+ case state
+ when 0
+ s = content_tag('span', l(:label_teaching_course), :class => "current-page")
+ content << content_tag('li', s)
+ content << content_tag('li', link_to(l(:label_release_homework), {:controller => 'users', :action => 'user_courses', :type => 1}))
+ content_tag('div', content, :class => "pagination")
+ when 1
+ s = content_tag('span', l(:label_release_homework), :class => "current-page")
+ content << content_tag('li', link_to(l(:label_teaching_course), {:controller => 'users', :action => 'user_courses'}))
+ content << content_tag('li', s, :class => "current-page")
+ content_tag('div', content, :class => "pagination")
+ end
+ else
+ case state
+ when 0
+ s = content_tag('span', l(:label_my_course), :class => "current-page")
+ content << content_tag('li', s)
+ content << content_tag('li', link_to('我的作业', {:controller => 'users', :action => 'user_courses', :type => 1}))
+ content_tag('div', content, :class => "pagination")
+ when 1
+ s = content_tag('span', '我的作业', :class => "current-page")
+ content << content_tag('li', link_to(l(:label_my_course), {:controller => 'users', :action => 'user_courses', :type => 0}))
+ content << content_tag('li', s, :class => "current-page")
+ content_tag('div', content, :class => "pagination")
+ end
+ end
+ end
+ end
+
+ # added by huang
+ def sort_user(state, project_type)
+ content = ''.html_safe
+ case state
+ when 0
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) ), :class=>"selected") )
+ when 1
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) ), :class=>"selected") )
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) )))
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
+ when 2
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(params.merge({:user_sort_type => '1', :project_type => project_type}) )))
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(params.merge({:user_sort_type => '2', :project_type => project_type}) ), :class=>"selected") )
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(params.merge({:user_sort_type => '0', :project_type => project_type}) )))
+ end
+ content = content_tag('ul', content)
+ content_tag('div', content, :class => "tabs")
+ end
+
+ def sort_user_enterprise(state, project_type)
+ content = ''.html_safe
+ case state
+ when 0
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type), :class=>"selected"), :class=>"selected")
+ when 1
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type), :class=>"selected"), :class=>"selected")
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type)))
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
+ when 2
+ content << content_tag('li', link_to(l(:label_sort_by_active), users_path(:user_sort_type => '1', :project_type => project_type)))
+ content << content_tag('li', link_to(l(:label_sort_by_influence), users_path(:user_sort_type => '2', :project_type => project_type), :class=>"selected"), :class=>"selected")
+ content << content_tag('li', link_to(l(:label_sort_by_time), users_path(:user_sort_type => '0', :project_type => project_type)))
+ end
+ content = content_tag('ul', content)
+ content_tag('div', content, :class => "tabs_enterprise")
+ end
+
+ def gender_avatar_uri user
+ img_uri = '/images/sidebar/female.png'
+ return img_uri if user.user_extensions.blank?
+ person_gender = user.user_extensions.gender
+ img_uri = (person_gender == 1) ? '/images/sidebar/female.png' : '/images/sidebar/male.png'
+ end
+
+ include CoursesHelper
+ def is_watching?(user)
+ login_user = User.current# 登录者
+
+ courses = user.projects.where('project_type=1')
+ return true if ((login_user == user) or login_user.admin?)
+ courses.each do |course|
+ return true if login_user.member_of?(course)
+ end
+ ## 下面的代码只判断是否是老师或者助教,上面是成员都可以看到
+ # people_ids = []
+ # user.projects.where('project_type=1').each do |project|
+ # tmp = searchTeacherAndAssistant(project)
+ # people_ids += (members_to_user_ids(tmp)) unless tmp.nil?
+ # end
+ # people_ids.include?(login_user.id) or (login_user == user) or login_user.admin?
+
+ false
+ end
+
+ # base user上面的navbar显示内容
+ def show_item_on_navbar params
+ displayed_item = %w|index|
+ displayed_item.include?(params['action'])
+ end
+ # base user上面searchBar显示
+ def show_search_bar params
+ displayed_flag = %w|index|
+ !displayed_flag.include?(params['action'])
+ end
+
+ #获取指定用户的未过期的课程列表
+ def user_courses_list user
+ result = []
+ user.coursememberships.map(&:course).each do |course|
+ if !course_endTime_timeout?(course)
+ result << course
+ end
+ end
+ return result
+ end
+
+ #获取用户参与的公开的课程列表
+ def user_public_course_list user
+ membership = user.coursememberships.all#@user.coursememberships.all(:conditions => Course.visible_condition(User.current))
+ membership.sort! {|older, newer| newer.created_on <=> older.created_on }
+ memberships = []
+ membership.collect { |e|
+ memberships.push(e)
+ }
+ ## 判断课程是否过期 [需封装]
+ memberships_doing = []
+ memberships_done = []
+ memberships.map { |e|
+ if course_endTime_timeout?(e.course)
+ memberships_done.push e
+ else
+ memberships_doing.push e
+ end
+ }
+ end
+
+ #获取用户留言相关的连接
+ def user_jour_feed_back_url active
+ if active.act_type == "JournalsForMessage"
+ jour = JournalsForMessage.find active.act_id
+ if jour
+ case jour.jour_type
+ when "Principal"
+ link_to(l(:label_goto), user_newfeedback_user_path(jour.jour_id))
+ when "Project"
+ link_to(l(:label_goto), project_feedback_path(jour.jour_id))
+ when "Bid"
+ link_to(l(:label_goto), course_for_bid_path(jour.jour_id))
+ when "Course"
+ link_to(l(:label_goto), course_feedback_path(jour.jour_id))
+ when "Contest"
+ link_to(l(:label_goto), show_contest_contest_path(jour.jour_id))
+ when "Softapplication"
+ link_to(l(:label_goto), softapplication_path(jour.jour_id))
+ when "HomeworkAttach"
+ link_to(l(:label_goto), course_for_bid_path(jour.jour_id))
+ end
+ end
+ end
+ end
+
+ def get_watcher_users(obj)
+ count = User.watched_by(obj.id).count
+ if count == 0
+ return [0,[]]
+ end
+ list = User.watched_by(obj.id).order("#{Watcher.table_name}.id desc").limit(10).all
+ return [count,list];
+ end
+
+ def get_fans_users(obj)
+ count = obj.watcher_users.count
+ if count == 0
+ return [0,[]]
+ end
+ list = obj.watcher_users.order("#{Watcher.table_name}.id desc").limit(10).all
+ return [count,list];
+ end
+
+ def get_visitor_users(obj)
+ query = Visitor.where("master_id=?",obj.id)
+ count = query.count
+ if count == 0
+ return [0,[]]
+ end
+ list = query.order("updated_on desc").limit(10).all
+ return [count,list]
+ end
+
+ def get_create_course_count(user)
+ user.courses.visible.where("tea_id = ?",user.id).count
+ end
+
+ #获取加入课程数
+ def get_join_course_count(user)
+ user.courses.visible.count - get_create_course_count(user)
+ end
+
+ #发布作业数
+ def get_homework_commons_count(user)
+ HomeworkCommon.where("user_id = ?",user.id).count
+ end
+
+ #资源数
+ def get_projectandcourse_attachment_count(user)
+ Attachment.where("author_id = ? and container_type in ('Project','Course')",user.id).count
+ end
+
+ #创建项目数
+ def get_create_project_count(user)
+ user.projects.visible.where("projects.user_id=#{user.id}").count
+ end
+
+ #加入项目数
+ def get_join_project_count(user)
+ user.projects.visible.count - get_create_project_count(user)
+ end
+
+ #创建缺陷数
+ def get_create_issue_count(user)
+ Issue.where("author_id = ?",user.id).count
+ end
+
+ #解决缺陷数
+ def get_resolve_issue_count(user)
+ Issue.where("assigned_to_id = ? and status_id=3",user.id).count
+ end
+
+ #参与匿评数
+ def get_anonymous_evaluation_count(user)
+ StudentWorksScore.where("user_id = ? and reviewer_role=3",user.id).count
+ end
+
+ def query_activities(query)
+ list = query.limit(13).all
+ result = []
+ for item in list
+ container = get_activity_container(item)
+ result << { :item=>item,:e=>container }
+ end
+ result
+ end
+
+ def get_activity_container activity
+ return activity.activity_container
+ end
+
+ def get_activity_act_showname_htmlclear(activity)
+ str = get_activity_act_showname(activity)
+ str = str.gsub(/<.*>/,'')
+ str = str.gsub(/\r/,'')
+ str = str.gsub(/\n/,'')
+ str = str.lstrip.rstrip
+ if str == ''
+ str = 'RE:'
+ end
+ return str.html_safe
+ end
+
+ # journal.details 记录每个动作的新旧值
+ def get_issue_des_update(journal)
+ no_html = "message"
+ arr = details_to_strings(journal.details, no_html)
+ unless journal.notes.blank?
+ arr << journal.notes
+ end
+ str = ''
+ arr.each { |item| str = str+item }
+ return str
+ end
+
+ def get_activity_act_showname(activity)
+ case activity.act_type
+ when "HomeworkCommon"
+ return activity.act.name
+ when "Issue"
+ return activity.act.subject
+ when "Journal"
+ arr = details_to_strings(activity.act.details,true)
+ arr << activity.act.notes
+ str = ''
+ arr.each { |item| str = str+item }
+ return str
+ when "JournalsForMessage"
+ return activity.act.notes
+ when "Message"
+ return activity.act.subject
+ when "News"
+ return activity.act.title
+ when "Poll"
+ return activity.act.polls_name
+ when "Contest"
+ return ''
+ when "Contestnotification"
+ return ''
+ when "Principal"
+ return ''
+ else
+ return activity.act_type
+ end
+ end
+
+ def get_activity_act_createtime(activity)
+ case activity.act_type
+ when "HomeworkCommon"
+ return activity.act.created_at
+ when "Poll"
+ return activity.act.created_at
+ else
+ return activity.act.created_on
+ end
+ end
+
+ def get_activity_container_url e
+ if !e.visible?
+ return "javascript:;"
+ end
+
+ if e.class.to_s == 'Course'
+ return url_for(:controller => 'courses', :action=>"show", :id=>e.id, :host=>Setting.host_course)
+ end
+ return url_for(:controller => 'projects', :action=>"show", :id=>e.id, :host=>Setting.host_name)
+ end
+
+ def get_activity_url(activity,e)
+ if !e.visible?
+ return "javascript:;"
+ end
+
+ case activity.act_type
+ # when "Contest"
+ # when "Contestnotification"
+ # when "Principal"
+ when "HomeworkCommon"
+ return homework_common_index_path( :course=>e.id )
+ when "Issue"
+ return issue_path(activity.act.id)
+ when "Journal"
+ return issue_path( activity.act.journalized_id )
+ when "JournalsForMessage"
+ return e.class.to_s == 'Course' ? course_feedback_path(e) : project_feedback_path(e)
+ when "Message"
+ return e.class.to_s == 'Course' ? course_boards_path(e) : project_boards_path(e)
+ when "News"
+ return news_path(activity.act)
+ #return e.class.to_s == 'Course' ? course_news_index_path(e) : project_news_index_path(e)
+ when "Poll"
+ return poll_index_path( :polls_group_id=>activity.act.polls_group_id, :polls_type=>e.class.to_s )
+ else
+ return 'javascript:;'
+ end
+ end
+
+ def get_activity_opt(activity,e)
+ case activity.act_type
+ when "HomeworkCommon"
+ return '创建了作业'
+ when "News"
+ return e.class.to_s == 'Course' ? '发布了通知' : '添加了新闻'
+ when "Issue"
+ return '发表了问题'
+ when "Journal"
+ return '更新了问题'
+ when "JournalsForMessage"
+ return e.class.to_s == 'Course' ? '发表了留言' : '提交了反馈'
+ #return ( activity.act.reply_id == nil || activity.act.reply_id == 0 ) ? '' : ''
+ when "Message"
+ return ( activity.act.parent_id == nil || activity.act.parent_id == '' ) ? '发布了帖子' : '回复了帖子'
+ when "Poll"
+ return '创建了问卷'
+ else
+ return '有了新动态'
+ end
+ end
+
+ #获取指定用户作为老师的课程
+ def get_as_teacher_courses user
+ type = []
+ option = []
+ option << "请选择发布作业的课程"
+ option << -1
+ type << option
+ 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").select{|c| user.allowed_to?(:as_teacher,c)}.each do |course|
+ option = []
+ option << course.name+"("+course.time.to_s+course.term+")"
+ option << course.id
+ type << option
+ end
+ type
+ end
+
+ #根据姓名搜索用户
+ def search_user_by_name user_ids, name
+ result_ids = []
+ user_ids.each do |user_id|
+ user = User.find user_id
+ username = user.lastname.to_s.downcase + user.firstname.to_s.downcase
+ if username.include?(name)
+ result_ids << user_id
+ end
+ end
+ result_ids
+ end
+end
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index e29f8698f..714da9920 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -28,7 +28,7 @@ class Attachment < ActiveRecord::Base
belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id"
# 被ForgeActivity虚拟关联
has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy
- has_many :forwards, :as => :from
+ has_many :forwards, :as => :from, :dependent => :destroy
# 课程动态
has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy
# end
@@ -43,6 +43,7 @@ class Attachment < ActiveRecord::Base
#elasticsearch
include Elasticsearch::Model
+ include ApplicationHelper
#elasticsearch kaminari init
Kaminari::Hooks.init
Elasticsearch::Model::Response::Response.__send__ :include, Elasticsearch::Model::Response::Pagination::Kaminari
@@ -89,10 +90,10 @@ class Attachment < ActiveRecord::Base
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location
- after_save :act_as_course_activity
- after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index
+ after_save :act_as_course_activity,:act_as_forge_activity
+ after_create :office_conver, :be_user_score,:create_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
+ after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index, :decrease_attchments_count, :down_course_score
# add by nwb
# 获取所有可公开的资源文件列表
@@ -498,6 +499,12 @@ class Attachment < ActiveRecord::Base
result
end
+ def self.attach_filesex_public(obj, attachments,attachment_type, is_public)
+ result = obj.save_attachmentsex_public(attachments, User.current,attachment_type, is_public)
+ obj.attach_saved_attachments
+ result
+ end
+
def self.latest_attach(attachments, filename)
attachments.sort_by(&:created_on).reverse.detect {
|att| att.filename.downcase == filename.downcase
@@ -599,7 +606,7 @@ class Attachment < ActiveRecord::Base
# Author lizanle
# Description 上传该项目的文档资料也要保存一份在公共表中
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,
:project_id => self.container_id)
end
@@ -655,6 +662,12 @@ class Attachment < ActiveRecord::Base
self.container.project_score.update_attribute(:attach_num, attach_count < 0 ? 0 : attach_count)
end
end
+
+ def down_course_score
+ if self.container_type == "Course"
+ down_course_score_num(self.container_id, self.author_id, "Attachment")
+ end
+ end
end
# Delete the previous articles index in Elasticsearch
diff --git a/app/models/comment.rb b/app/models/comment.rb
index 69753d81c..b87203a50 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -36,6 +36,7 @@ class Comment < ActiveRecord::Base
validates_presence_of :commented, :author, :comments
safe_attributes 'comments'
after_create :send_mail, :act_as_system_message, :act_as_student_score
+ after_destroy :down_course_score
def act_as_system_message
if self.commented.course
@@ -82,9 +83,14 @@ class Comment < ActiveRecord::Base
# 课程成员得分(英雄榜)
def act_as_student_score
if self.commented.course
- unless self.author.allowed_to?(:as_teacher, self.commented.course)
- course_member_score(self.commented.course.id, self.author_id, "NewReply")
- end
+ course_member_score(self.commented.course.id, self.author_id, "NewReply")
+ end
+ end
+
+ # 课程新闻数减少
+ def down_course_score
+ if self.commented.course
+ down_course_score_num(self.commented.course.id, self.author_id, "NewReply")
end
end
diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb
index 9c1431d5d..96ec6e355 100644
--- a/app/models/course_activity.rb
+++ b/app/models/course_activity.rb
@@ -5,7 +5,7 @@ class CourseActivity < ActiveRecord::Base
belongs_to :course
belongs_to :user
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
before_destroy :destroy_user_activity, :destroy_org_activity
@@ -31,14 +31,16 @@ class CourseActivity < ActiveRecord::Base
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
if org_activity
+ org_activity.updated_at = self.updated_at
org_activity.save
else
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.created_at = self.created_at
+ org_activity.updated_at = self.updated_at
org_activity.save
else
OrgActivity.create(:user_id => self.user_id,
@@ -64,15 +66,16 @@ class CourseActivity < ActiveRecord::Base
# 发布新课导语
# 导语要放置在课程创建信息之后
- # 导语
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)
name = lead_message.subject
content = lead_message.content
# 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
end
end
diff --git a/app/models/course_contributor_score.rb b/app/models/course_contributor_score.rb
index f2b05458f..4f3b3e187 100644
--- a/app/models/course_contributor_score.rb
+++ b/app/models/course_contributor_score.rb
@@ -1,5 +1,6 @@
class CourseContributorScore < ActiveRecord::Base
- attr_accessible :course_id, :journal_num, :journal_reply_num, :message_num, :message_reply_num, :news_reply_num, :resource_num, :user_id, :total_score
+ attr_accessible :course_id, :journal_num, :journal_reply_num, :message_num, :message_reply_num, :news_reply_num,
+ :resource_num, :user_id, :total_score, :homework_journal_num, :news_num
belongs_to :course
belongs_to :user
end
diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb
index c98c5475b..c044392a0 100644
--- a/app/models/forge_activity.rb
+++ b/app/models/forge_activity.rb
@@ -48,7 +48,7 @@ class ForgeActivity < ActiveRecord::Base
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
if org_activity
- org_activity.created_at = self.created_at
+ org_activity.updated_at = self.updated_at
org_activity.save
else
if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil?
diff --git a/app/models/issue.rb b/app/models/issue.rb
index c82f6f0be..0d72407ba 100644
--- a/app/models/issue.rb
+++ b/app/models/issue.rb
@@ -84,7 +84,9 @@ class Issue < ActiveRecord::Base
attr_reader :current_journal
# 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_destroy :down_user_score, :decrease_issues_count
# after_create :be_user_score
@@ -165,12 +167,12 @@ class Issue < ActiveRecord::Base
end
# at 功能添加消息提醒
- def act_as_at_message
- users = self.description.scan //m
- users && users.flatten.uniq.each do |uid|
- self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
- end
- end
+ # def act_as_at_message
+ # users = self.description.scan //m
+ # users && users.flatten.uniq.each do |uid|
+ # self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id)
+ # end
+ # end
# 创建issue的时候,issues_count加1
def add_issues_count
diff --git a/app/models/journal.rb b/app/models/journal.rb
index c37b8d2c5..fd67e8a62 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -51,7 +51,7 @@ class Journal < ActiveRecord::Base
before_create :split_private_notes, :add_journals_count
# 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
# end
#after_destroy :down_user_score
@@ -186,13 +186,6 @@ class Journal < ActiveRecord::Base
end
end
- def act_as_at_message
- users = self.notes.scan //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
def be_user_score
#新建了缺陷留言且留言不为空,不为空白
diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb
index cdcf9d19e..fa5beb813 100644
--- a/app/models/journals_for_message.rb
+++ b/app/models/journals_for_message.rb
@@ -68,12 +68,14 @@ class JournalsForMessage < ActiveRecord::Base
has_many :at_messages, as: :at_message, dependent: :destroy
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_update :update_activity
after_destroy :reset_counters!
after_save :be_user_score
- after_destroy :down_user_score
+ after_destroy :down_user_score, :down_course_score
# default_scope { where('m_parent_id IS NULL') }
@@ -184,6 +186,7 @@ class JournalsForMessage < ActiveRecord::Base
end
end
end
+
# 更新用户分数 -by zjc
def down_user_score
#删除了留言回复
@@ -252,12 +255,7 @@ class JournalsForMessage < ActiveRecord::Base
end
end
- def act_as_at_message
- users = self.notes.scan //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
# 主留言
@@ -283,10 +281,21 @@ class JournalsForMessage < ActiveRecord::Base
end
end
- # 课程成员得分(英雄榜)
+ # 课程成员得分(活跃度)
def act_as_student_score
- if !self.user.allowed_to?(:as_teacher, self.jour) && self.jour_type == "Course"
- course_member_score(self.jour_id, self.user_id, "JournalForMessage")
+ if self.jour_type == "Course"
+ course_member_score(self.jour_id, self.user_id, "Course")
+ elsif self.jour_type == "HomeworkCommon"
+ course_member_score(self.jour.course_id, self.user_id, "HomeworkCommon")
+ end
+ end
+
+ # 删除操作的时候相应扣掉回复数
+ def down_course_score
+ if self.jour_type == "Course"
+ down_course_score_num(self.jour_id, self.user_id, "Course")
+ elsif self.jour_type == "HomeworkCommon"
+ down_course_score_num(self.jour.course_id, self.user_id, "HomeworkCommon")
end
end
diff --git a/app/models/member.rb b/app/models/member.rb
index 413fedc07..9eac21fa7 100644
--- a/app/models/member.rb
+++ b/app/models/member.rb
@@ -1,185 +1,185 @@
-# Redmine - project management software
-# Copyright (C) 2006-2013 Jean-Philippe Lang
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-
-class Member < ActiveRecord::Base
- belongs_to :user
- belongs_to :principal, :foreign_key => 'user_id'
- has_many :member_roles, :dependent => :destroy
- has_many :roles, :through => :member_roles
-
- belongs_to :project
- belongs_to :course
-
- belongs_to :course_group
- validates_presence_of :principal
- validates_uniqueness_of :user_id, :scope => [:project_id,:course_id]
- validate :validate_role
-
- before_destroy :set_issue_category_nil
- # 删除项目成员一并删除该成员的邀请记录
- after_destroy :delete_ivite_list
-
-
-
- def role
- end
-
- def role=
- end
-
- def name
- self.user.name
- end
-
- alias :base_role_ids= :role_ids=
- def role_ids=(arg)
- ids = (arg || []).collect(&:to_i) - [0]
- # Keep inherited roles
- ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
-
- new_role_ids = ids - role_ids
- # Add new roles
- new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
- # Remove roles (Rails' #role_ids= will not trigger MemberRole#on_destroy)
- member_roles_to_destroy = member_roles.select {|mr| !ids.include?(mr.role_id)}
- if member_roles_to_destroy.any?
- member_roles_to_destroy.each(&:destroy)
- end
- end
-
- def <=>(member)
- a, b = roles.sort.first, member.roles.sort.first
- if a == b
- if principal
- principal <=> member.principal
- else
- 1
- end
- elsif a
- a <=> b
- else
- 1
- end
- end
-
- def deletable?
- member_roles.detect {|mr| mr.inherited_from}.nil?
- end
-
- def include?(user)
- if principal.is_a?(Group)
- !user.nil? && user.groups.include?(principal)
- else
- self.user == user
- end
- end
-
- def set_issue_category_nil
- if user
- # remove category based auto assignments for this member
- #modify by nwb
- if project
- IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
- elsif course
- #IssueCategory.update_all "assigned_to_id = NULL", ["course_id = ? AND assigned_to_id = ?", course.id, user.id]
- end
-
- end
- end
-
- # 删除成员一并删除该成员的邀请信息
- def delete_ivite_list
- member_invite_lists = InviteList.where("user_id =? and project_id =?", self.user_id, self.project_id)
- unless member_invite_lists.nil?
- member_invite_lists.each do |member_invite_list|
- member_invite_list.destroy
- end
- end
- end
-
- # Find or initilize a Member with an id, attributes, and for a Principal
- def self.edit_membership(id, new_attributes, principal=nil)
- @membership = id.present? ? Member.find(id) : Member.new(:principal => principal)
- @membership.attributes = new_attributes
- @membership
- end
-
- # Finds or initilizes a Member for the given project and principal
- def self.find_or_new(project, principal)
- project_id = project.is_a?(Project) ? project.id : project
- principal_id = principal.is_a?(Principal) ? principal.id : principal
-
- member = Member.find_by_project_id_and_user_id(project_id, principal_id)
- member ||= Member.new(:project_id => project_id, :user_id => principal_id)
- member
- end
-
- # 查找每个学生每个作业的评分
- def student_homework_score
- homework_score = StudentWork.find_by_sql("SELECT homework_commons.name,student_works.final_score as score
- FROM student_works,homework_commons
- WHERE student_works.homework_common_id = homework_commons.id
- AND homework_commons.course_id = #{self.course_id}
- AND student_works.user_id = #{self.user_id}")
- score_count = StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
- [homework_score, format("%0.2f", score_count)]
- end
-
- def student_work_score
- StudentWork.select("homework_commons.name, student_works.final_score").joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}")
- end
-
- #当前课程的作业列表
- def homework_common_list
- HomeworkCommon.where(:course_id => self.course_id)
- end
-
- #当前学生在指定作业内的得分
- def homework_common_score homework_common
- StudentWork.select("IF(final_score is null,null,final_score - absence_penalty - late_penalty) as final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
- end
-
- def student_work_score_avg
- StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
- end
-
- def student_work_score_sum
- sql_select = "SELECT (SUM(IF(student_works.final_score is null,null,student_works.final_score - student_works.absence_penalty - student_works.late_penalty))) as score
- FROM student_works,homework_commons
- WHERE student_works.homework_common_id = homework_commons.id
- AND homework_commons.course_id = #{self.course_id}
- AND student_works.user_id = #{self.user_id}"
- score = StudentWork.find_by_sql(sql_select)
- end
-
- protected
-
- def validate_role
- errors.add_on_empty :role if member_roles.empty? && roles.empty?
- end
-
-
-
- def searchTeacherAndAssistant project
- #searchPeopleByRoles(project, TeacherRoles)
- members = []
- project.members.each do |m|
- members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
- end
- members
- end
-end
+# Redmine - project management software
+# Copyright (C) 2006-2013 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+class Member < ActiveRecord::Base
+ belongs_to :user
+ belongs_to :principal, :foreign_key => 'user_id'
+ has_many :member_roles, :dependent => :destroy
+ has_many :roles, :through => :member_roles
+
+ belongs_to :project
+ belongs_to :course
+
+ belongs_to :course_group
+ validates_presence_of :principal
+ validates_uniqueness_of :user_id, :scope => [:project_id,:course_id]
+ validate :validate_role
+
+ before_destroy :set_issue_category_nil
+ # 删除项目成员一并删除该成员的邀请记录
+ after_destroy :delete_ivite_list
+
+
+
+ def role
+ end
+
+ def role=
+ end
+
+ def name
+ self.user.name
+ end
+
+ alias :base_role_ids= :role_ids=
+ def role_ids=(arg)
+ ids = (arg || []).collect(&:to_i) - [0]
+ # Keep inherited roles
+ ids += member_roles.select {|mr| !mr.inherited_from.nil?}.collect(&:role_id)
+
+ new_role_ids = ids - role_ids
+ # Add new roles
+ new_role_ids.each {|id| member_roles << MemberRole.new(:role_id => id) }
+ # Remove roles (Rails' #role_ids= will not trigger MemberRole#on_destroy)
+ member_roles_to_destroy = member_roles.select {|mr| !ids.include?(mr.role_id)}
+ if member_roles_to_destroy.any?
+ member_roles_to_destroy.each(&:destroy)
+ end
+ end
+
+ def <=>(member)
+ a, b = roles.sort.first, member.roles.sort.first
+ if a == b
+ if principal
+ principal <=> member.principal
+ else
+ 1
+ end
+ elsif a
+ a <=> b
+ else
+ 1
+ end
+ end
+
+ def deletable?
+ member_roles.detect {|mr| mr.inherited_from}.nil?
+ end
+
+ def include?(user)
+ if principal.is_a?(Group)
+ !user.nil? && user.groups.include?(principal)
+ else
+ self.user == user
+ end
+ end
+
+ def set_issue_category_nil
+ if user
+ # remove category based auto assignments for this member
+ #modify by nwb
+ if project
+ IssueCategory.update_all "assigned_to_id = NULL", ["project_id = ? AND assigned_to_id = ?", project.id, user.id]
+ elsif course
+ #IssueCategory.update_all "assigned_to_id = NULL", ["course_id = ? AND assigned_to_id = ?", course.id, user.id]
+ end
+
+ end
+ end
+
+ # 删除成员一并删除该成员的邀请信息
+ def delete_ivite_list
+ member_invite_lists = InviteList.where("user_id =? and project_id =?", self.user_id, self.project_id)
+ unless member_invite_lists.nil?
+ member_invite_lists.each do |member_invite_list|
+ member_invite_list.destroy
+ end
+ end
+ end
+
+ # Find or initilize a Member with an id, attributes, and for a Principal
+ def self.edit_membership(id, new_attributes, principal=nil)
+ @membership = id.present? ? Member.find(id) : Member.new(:principal => principal)
+ @membership.attributes = new_attributes
+ @membership
+ end
+
+ # Finds or initilizes a Member for the given project and principal
+ def self.find_or_new(project, principal)
+ project_id = project.is_a?(Project) ? project.id : project
+ principal_id = principal.is_a?(Principal) ? principal.id : principal
+
+ member = Member.find_by_project_id_and_user_id(project_id, principal_id)
+ member ||= Member.new(:project_id => project_id, :user_id => principal_id)
+ member
+ end
+
+ # 查找每个学生每个作业的评分
+ def student_homework_score
+ homework_score = StudentWork.find_by_sql("SELECT homework_commons.name,student_works.final_score as score
+ FROM student_works,homework_commons
+ WHERE student_works.homework_common_id = homework_commons.id
+ AND homework_commons.course_id = #{self.course_id}
+ AND student_works.user_id = #{self.user_id}")
+ score_count = StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
+ [homework_score, format("%0.2f", score_count)]
+ end
+
+ def student_work_score
+ StudentWork.select("homework_commons.name, student_works.final_score").joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}")
+ end
+
+ #当前课程的作业列表
+ def homework_common_list
+ HomeworkCommon.where(:course_id => self.course_id)
+ end
+
+ #当前学生在指定作业内的得分
+ def homework_common_score homework_common
+ StudentWork.select("IF(final_score is null,null,IF(final_score = 0, 0, final_score - absence_penalty - late_penalty)) as final_score").where(:homework_common_id => homework_common.id,:user_id => self.user_id)
+ end
+
+ def student_work_score_avg
+ StudentWork.joins(:homework_common).where("student_works.user_id = #{self.user_id} and homework_commons.course_id = #{self.course_id}").average(:final_score).try(:round, 2).to_f
+ end
+
+ def student_work_score_sum
+ sql_select = "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)))) as score
+ FROM student_works,homework_commons
+ WHERE student_works.homework_common_id = homework_commons.id
+ AND homework_commons.course_id = #{self.course_id}
+ AND student_works.user_id = #{self.user_id}"
+ score = StudentWork.find_by_sql(sql_select)
+ end
+
+ protected
+
+ def validate_role
+ errors.add_on_empty :role if member_roles.empty? && roles.empty?
+ end
+
+
+
+ def searchTeacherAndAssistant project
+ #searchPeopleByRoles(project, TeacherRoles)
+ members = []
+ project.members.each do |m|
+ members << m if m && m.user && m.user.allowed_to?(:as_teacher,project)
+ end
+ members
+ end
+end
diff --git a/app/models/message.rb b/app/models/message.rb
index 6381f444f..d697db236 100644
--- a/app/models/message.rb
+++ b/app/models/message.rb
@@ -45,6 +45,8 @@ class Message < ActiveRecord::Base
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
+ #转发表
+ has_many :forwards, :as => :from, :dependent => :destroy
after_destroy :delete_org_activities
acts_as_searchable :columns => ['subject', 'content'],
@@ -77,9 +79,10 @@ class Message < ActiveRecord::Base
after_create :add_author_as_watcher, :reset_counters!, :add_boards_count
after_update :update_messages_board, :update_activity
- after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count
+ 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
scope :visible, lambda {|*args|
@@ -285,13 +288,6 @@ class Message < ActiveRecord::Base
end
end
- def act_as_at_message
- users = self.content.scan //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
def be_user_score
#新建message且无parent的为发帖
@@ -339,17 +335,27 @@ class Message < ActiveRecord::Base
delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE
end
- # 课程成员得分(英雄榜)
+ # 课程成员得分(活跃度)
def act_as_student_score
if self.course
- unless self.author.allowed_to?(:as_teacher, self.course)
- if self.parent_id.nil?
- # 发帖
- course_member_score(self.course.id, self.author_id, "Message")
- else
- # 回帖
- course_member_score(self.course.id, self.author_id, "MessageReply")
- end
+ if self.parent_id.nil?
+ # 发帖
+ course_member_score(self.course.id, self.author_id, "Message")
+ else
+ # 回帖
+ course_member_score(self.course.id, self.author_id, "MessageReply")
+ end
+ end
+ end
+
+ # 删除帖子的时候更新课程帖子总数, 删除回复的时候减少总数
+ def down_course_score
+ if self.course
+ if self.parent_id.nil? # 发帖
+ down_course_score_num(self.course.id, self.author_id, "Message")
+ else
+ # 回帖
+ down_course_score_num(self.course.id, self.author_id, "MessageReply")
end
end
end
diff --git a/app/models/news.rb b/app/models/news.rb
index d0fccae17..6746d90cd 100644
--- a/app/models/news.rb
+++ b/app/models/news.rb
@@ -37,6 +37,9 @@ class News < ActiveRecord::Base
has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy
#end
+ #转发表
+ has_many :forwards, :as => :from, :dependent => :destroy
+
has_many :ActivityNotifies,:as => :activity, :dependent => :destroy
validates_presence_of :title, :description
@@ -56,9 +59,9 @@ class News < ActiveRecord::Base
:author_key => :author_id
acts_as_watchable
- after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail, :add_news_count
+ after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail, :add_news_count, :act_as_student_score
after_update :update_activity
- after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities
+ after_destroy :delete_kindeditor_assets, :decrease_news_count, :delete_org_activities, :down_course_score
scope :visible, lambda {|*args|
includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args))
@@ -192,4 +195,18 @@ class News < ActiveRecord::Base
OrgActivity.where("container_type='OrgSubfield' and org_act_type='News' and org_act_id=?", self.id).destroy_all
end
+ # 新增新闻统计数增加
+ def act_as_student_score
+ if self.course
+ course_member_score(self.course.id, self.author_id, "News")
+ end
+ end
+
+ # 删除新闻统计数减少
+ def down_course_score
+ if self.course
+ down_course_score_num(self.course.id, self.author_id, "News")
+ end
+ end
+
end
\ No newline at end of file
diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb
index c62cbf4f8..8cec49686 100644
--- a/app/models/org_subfield.rb
+++ b/app/models/org_subfield.rb
@@ -9,6 +9,7 @@ class OrgSubfield < ActiveRecord::Base
has_many :news, :dependent => :destroy
acts_as_attachable
after_create :create_board_sync
+ after_destroy :update_priority
# 创建资源栏目讨论区
def create_board_sync
@board = self.boards.build
@@ -25,4 +26,11 @@ class OrgSubfield < ActiveRecord::Base
def project
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
\ No newline at end of file
diff --git a/app/models/organization.rb b/app/models/organization.rb
index fcb777fb6..248783a26 100644
--- a/app/models/organization.rb
+++ b/app/models/organization.rb
@@ -16,8 +16,8 @@ class Organization < ActiveRecord::Base
end
def add_default_subfields
- OrgSubfield.create(:organization_id => self.id, :name => 'activity', :field_type => 'default')
- OrgSubfield.create(:organization_id => self.id, :name => 'course', :field_type => 'default')
- OrgSubfield.create(:organization_id => self.id, :name => 'project', :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', :priority => 2)
+ OrgSubfield.create(:organization_id => self.id, :name => 'project', :field_type => 'default', :priority => 3)
end
end
diff --git a/app/models/praise_tread.rb b/app/models/praise_tread.rb
index 3df5c72d9..b1b7e0908 100644
--- a/app/models/praise_tread.rb
+++ b/app/models/praise_tread.rb
@@ -2,8 +2,8 @@ class PraiseTread < ActiveRecord::Base
attr_accessible :user_id,:praise_tread_object_id,:praise_tread_object_type,:praise_or_tread
belongs_to :user
belongs_to :praise_tread_object, polymorphic: true
- after_create :be_user_score
- after_destroy :down_user_score
+ #after_create :be_user_score
+ #after_destroy :down_user_score
include UserScoreHelper
def self.find_object_by_type_and_id(type,id)
@obj = nil
diff --git a/app/models/user.rb b/app/models/user.rb
index 42acbb539..4e62f3bd0 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -116,7 +116,7 @@ class User < Principal
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
has_one :rss_token, :class_name => 'Token', :conditions => "action='feeds'"
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'"
belongs_to :auth_source
has_many :org_members
@@ -823,6 +823,9 @@ class User < Principal
end
def member_of_org?(org)
+ if !self.logged?
+ return false
+ end
OrgMember.where("user_id =? and organization_id =?", self.id, org.id).count > 0
end
@@ -1065,6 +1068,16 @@ class User < Principal
anonymous_user
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
# 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
diff --git a/app/models/user_actions.rb b/app/models/user_actions.rb
new file mode 100644
index 000000000..de2388911
--- /dev/null
+++ b/app/models/user_actions.rb
@@ -0,0 +1,4 @@
+class UserActions < ActiveRecord::Base
+ attr_accessible :action_id, :action_type, :user_id
+ has_many :users
+end
diff --git a/app/views/admin/course_resource_list.html.erb b/app/views/admin/course_resource_list.html.erb
new file mode 100644
index 000000000..4316555f7
--- /dev/null
+++ b/app/views/admin/course_resource_list.html.erb
@@ -0,0 +1,64 @@
+<%=l(:label_course_resource_list)%>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/courses.html.erb b/app/views/admin/courses.html.erb
index 1615bccbc..2505b3d06 100644
--- a/app/views/admin/courses.html.erb
+++ b/app/views/admin/courses.html.erb
@@ -73,4 +73,8 @@
+
+
<% html_title(l(:label_course_all)) -%>
diff --git a/app/views/admin/excellent_courses.html.erb b/app/views/admin/excellent_courses.html.erb
new file mode 100644
index 000000000..e21ba32aa
--- /dev/null
+++ b/app/views/admin/excellent_courses.html.erb
@@ -0,0 +1,75 @@
+
+ <%=l(:label_excellent_courses_list)%>
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/latest_login_teachers.html.erb b/app/views/admin/latest_login_teachers.html.erb
index 06c0386f5..05f20ba8d 100644
--- a/app/views/admin/latest_login_teachers.html.erb
+++ b/app/views/admin/latest_login_teachers.html.erb
@@ -1,84 +1,84 @@
-<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
-
- <%=l(:label_latest_login_user_list)%>
-
-<%= render 'tab_users' %>
-
-
- 最近登录老师列表
-
-<%= form_tag({}, :method => :get) do %>
-
-
- <%= l(:label_filter_plural) %>
-
- 开始日期:
- <%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange=>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
- <%= calendar_for('startdate')%>
- 结束日期:
- <%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
- <%= calendar_for('enddate')%>
- <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
- <%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_teachers'}, :class => 'icon icon-reload' %>
-
-<% end %>
-
-
-
+<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', :media => 'all' %>
+
+ <%=l(:label_latest_login_user_list)%>
+
+<%= render 'tab_users' %>
+
+
+ 最近登录老师列表
+
+<%= form_tag({}, :method => :get) do %>
+
+
+ <%= l(:label_filter_plural) %>
+
+ 开始日期:
+ <%= text_field_tag 'startdate', params[:startdate], :size => 15, :onchange=>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
+ <%= calendar_for('startdate')%>
+ 结束日期:
+ <%= text_field_tag 'enddate', params[:enddate], :size => 15, :onchange =>"$('#ui-datepicker-div').hide()", :style=>"float:left"%>
+ <%= calendar_for('enddate')%>
+ <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'latest_login_teachers'}, :class => 'icon icon-reload' %>
+
+<% end %>
+
+
+
diff --git a/app/views/admin/project_resource_list.html.erb b/app/views/admin/project_resource_list.html.erb
new file mode 100644
index 000000000..c245f73b8
--- /dev/null
+++ b/app/views/admin/project_resource_list.html.erb
@@ -0,0 +1,64 @@
+<%=l(:label_project_resource_list)%>
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/projects.html.erb b/app/views/admin/projects.html.erb
index 3f6ee36f0..5e3a927da 100644
--- a/app/views/admin/projects.html.erb
+++ b/app/views/admin/projects.html.erb
@@ -45,8 +45,8 @@
- <% project_tree(@projects) do |project, level| %>
- <%= project.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
+ <% @projects.each do |project| %>
+ ">
<%= project.id %>
@@ -73,6 +73,10 @@
+
+
<% html_title(l(:label_project_plural)) -%>
+选择版本
+注:该文件有历史版本,请选择您需要的文件,点击文件名下载。
+版本及序号
+
+
+
+ <%= 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" %>
+
+
版本号:当前
+
+ <% @attachment_histories.each do |history| %>
+
+ <%= 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" %>
+
+
版本号:<%= history.version %>
+
+ <% end %>
+
diff --git a/app/views/attachments/attachment_history_download.js.erb b/app/views/attachments/attachment_history_download.js.erb
new file mode 100644
index 000000000..352a2ef93
--- /dev/null
+++ b/app/views/attachments/attachment_history_download.js.erb
@@ -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(" ");
+$('#ajax-modal').parent().css("top","40%").css("left","50%");
+$('#ajax-modal').parent().addClass("resourceUploadPopup");
+$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
\ No newline at end of file
diff --git a/app/views/blog_comments/_simple_ke_reply_form.html.erb b/app/views/blog_comments/_simple_ke_reply_form.html.erb
index e222d8e56..ac953b254 100644
--- a/app/views/blog_comments/_simple_ke_reply_form.html.erb
+++ b/app/views/blog_comments/_simple_ke_reply_form.html.erb
@@ -1,21 +1,21 @@
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
-
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+
\ No newline at end of file
diff --git a/app/views/blog_comments/edit.html.erb b/app/views/blog_comments/edit.html.erb
index 704342fc0..1e29d0a14 100644
--- a/app/views/blog_comments/edit.html.erb
+++ b/app/views/blog_comments/edit.html.erb
@@ -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',
- :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} %>
- <% end %>
-<% end %>
\ No newline at end of file
+
+<%= 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| %>
+ <%= render :partial => 'blog_comments/edit', :locals => {:f => f, :article => @article, :edit_mode => true, :user => @user} %>
+<% end %>
diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb
index c80274db4..de7f1647d 100644
--- a/app/views/blog_comments/show.html.erb
+++ b/app/views/blog_comments/show.html.erb
@@ -38,7 +38,7 @@
<%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
- <% if @article.author.id == User.current.id%>
+ <% if @article.author.id == User.current.id || User.current.admin? %>
@@ -48,7 +48,7 @@
l(:button_edit),
{:action => 'edit', :id => @article.id,:in_act => params[:in_act]},
:class => 'postOptionLink'
- ) if User.current && User.current.id == @article.author.id %>
+ ) if User.current.admin? || User.current.id == @article.author.id %>
<%= link_to(
@@ -57,7 +57,7 @@
:method => :delete,
:data => {:confirm => l(:text_are_you_sure)},
:class => 'postOptionLink'
- ) if User.current && User.current.id == @article.author.id %>
+ ) if User.current.admin? || User.current.id == @article.author.id %>
<% if @article.id == @article.blog.homepage_id %>
diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb
index 05f69055f..edbce26d3 100644
--- a/app/views/blogs/_article.html.erb
+++ b/app/views/blogs/_article.html.erb
@@ -1,226 +1,226 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
-
-
- <% if activity.author.id == User.current.id%>
-
-
-
-
-
- <%= link_to(
- l(:button_edit),
- {:controller => 'blog_comments',:action => 'edit',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
- :class => 'postOptionLink'
- ) if User.current && User.current.id == activity.author.id %>
-
-
- <%= link_to(
- l(:button_delete),
- {:controller => 'blog_comments',:action => 'destroy',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
- :method => :delete,
- :data => {:confirm => l(:text_are_you_sure)},
- :class => 'postOptionLink'
- ) if User.current && User.current.id == activity.author.id %>
-
-
- <% if activity.id == activity.blog.homepage_id %>
- <%= link_to(
- l(:button_cancel_homepage),
- {:controller => 'blogs',:action => 'cancel_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
- :method => :post,
- :class => 'postOptionLink'
- ) if User.current && User.current.id == activity.blog.author_id %>
- <% else %>
- <%= link_to(
- l(:button_set_homepage),
- {:controller => 'blogs',:action => 'set_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
- :method => :post,
- :class => 'postOptionLink'
- ) if User.current && User.current.id == activity.blog.author_id %>
- <% end %>
-
-
-
-
-
- <%end%>
-
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% end %>
- TO
- <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%>
- <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
- 已设为首页
- <% end %>
-
-
-
- <% if activity.parent_id.nil? %>
- <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey" %>
- <% else %>
- <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey"%>
- <% end %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
- <% if activity.locked%>
-
- <% end%>
-
-
- 发帖时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(activity.updated_on) %>
-
-
- <% if activity.parent_id.nil? %>
- <% content= activity.content%>
- <% else %>
- <% content= activity.parent.content%>
- <% end %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
-
-
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
-
- <% count=0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#=format_date(activity.updated_on)%>
- <%if count > 3 %>
-
- <% end %>
-
-
- <% activity= activity.parent ? activity.parent : activity%>
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.children.reorder("created_on desc").each do |reply|%>
-
- <% replies_all_i=replies_all_i+1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.author == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
- <%= reply.content.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
- <% if !activity.locked? %>
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%>
-
-
-
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
- <% end %>
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
+
+
+ <% if activity.author.id == User.current.id || User.current.admin? %>
+
+
+
+
+
+ <%= link_to(
+ l(:button_edit),
+ {:controller => 'blog_comments',:action => 'edit',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
+ :class => 'postOptionLink'
+ ) if User.current.admin? || User.current.id == activity.author.id %>
+
+
+ <%= link_to(
+ l(:button_delete),
+ {:controller => 'blog_comments',:action => 'destroy',:user_id=>activity.author_id,:blog_id=>activity.blog_id, :id => activity.id},
+ :method => :delete,
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if User.current.admin? || User.current.id == activity.author.id %>
+
+
+ <% if activity.id == activity.blog.homepage_id %>
+ <%= link_to(
+ l(:button_cancel_homepage),
+ {:controller => 'blogs',:action => 'cancel_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
+ :method => :post,
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == activity.blog.author_id %>
+ <% else %>
+ <%= link_to(
+ l(:button_set_homepage),
+ {:controller => 'blogs',:action => 'set_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id},
+ :method => :post,
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == activity.blog.author_id %>
+ <% end %>
+
+
+
+
+
+ <%end%>
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ <% end %>
+ TO
+ <%= link_to activity.blog.name+" | 博客", user_blogs_path(:user_id=>activity.author_id,:host=>Setting.host_user), :class => "newsBlue ml15 mr5"%>
+ <% if activity.blog.homepage_id and activity.id == activity.blog.homepage_id %>
+ 已设为首页
+ <% end %>
+
+
+
+ <% if activity.parent_id.nil? %>
+ <%= link_to activity.title.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey" %>
+ <% else %>
+ <%= link_to activity.title.subject.to_s.html_safe, user_blog_blog_comment_path(:user_id=>activity.author_id, :blog_id=>activity.blog.id,:id=>activity), :class=> "postGrey"%>
+ <% end %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+ <% if activity.locked%>
+
+ <% end%>
+
+
+ 发帖时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(activity.updated_on) %>
+
+
+ <% if activity.parent_id.nil? %>
+ <% content= activity.content%>
+ <% else %>
+ <% content= activity.parent.content%>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+
+
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+
+ <% count=0 %>
+ <% if activity.parent %>
+ <% count=activity.parent.children.count%>
+ <% else %>
+ <% count=activity.children.count%>
+ <% end %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#=format_date(activity.updated_on)%>
+ <%if count > 3 %>
+
+ <% end %>
+
+
+ <% activity= activity.parent ? activity.parent : activity%>
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |reply|%>
+
+ <% replies_all_i=replies_all_i+1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.author == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+ <%= reply.content.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !activity.locked? %>
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller=>'blog_comments',:action => 'reply', :id => activity.id, :blog_id => activity.blog.id, :user_id => activity.author_id},:method => "post",:remote=>true) do |f|%>
+
+
+
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+ <% end %>
+
+
+
diff --git a/app/views/blogs/_homepage.html.erb b/app/views/blogs/_homepage.html.erb
index 80ae8c9f4..5dbee59d6 100644
--- a/app/views/blogs/_homepage.html.erb
+++ b/app/views/blogs/_homepage.html.erb
@@ -43,6 +43,8 @@
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.content} %>
+
+
diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb
index 31cdf41eb..3deb04f6c 100644
--- a/app/views/boards/_course_new.html.erb
+++ b/app/views/boards/_course_new.html.erb
@@ -1,7 +1,123 @@
<%= content_for(:header_tags) do %>
- <%= import_ke(enable_at: true, prettify: false) %>
+ <%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
<% end %>
-
+
<%= error_messages_for 'message' %>
@@ -25,7 +141,7 @@
<%= text_area :quote,:quote,: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_type => OwnerTypeHelper::MESSAGE,
:width => '100%',
@@ -37,8 +153,11 @@
:maxlength => 5000 },
at_id: topic.id, at_type: topic.class.to_s
%>
+
+
+
@@ -49,11 +168,11 @@
<%if !edit_mode %>
-
确定
+
确定
或
取消
<% else %>
-
确定
+
确定
或
<%= link_to "取消",board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "fr mr10 mt3"%>
<% end %>
diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb
index de3b038e6..d33b75f82 100644
--- a/app/views/boards/_course_show.html.erb
+++ b/app/views/boards/_course_show.html.erb
@@ -22,14 +22,16 @@
diff --git a/app/views/courses/_copy_course.html.erb b/app/views/courses/_copy_course.html.erb
index 68184d352..402e00cf6 100644
--- a/app/views/courses/_copy_course.html.erb
+++ b/app/views/courses/_copy_course.html.erb
@@ -1,4 +1,11 @@
+
diff --git a/app/views/courses/_recommendation.html.erb b/app/views/courses/_recommendation.html.erb
index f26c5fd41..a0c659493 100644
--- a/app/views/courses/_recommendation.html.erb
+++ b/app/views/courses/_recommendation.html.erb
@@ -6,14 +6,15 @@
<%= image_tag(url_to_avatar(e_course), :width => "40", :height => "40", :class => "fl mr10 rankPortrait", :alt => "logo") %>
-
<%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %>
+
<%=link_to e_course.name, course_path(e_course.id), :class => "hidden fl w170" %>
- <% if e_course.attachments.count > 0 %>
- <%= l(:project_module_attachments) %>(<%= link_to e_course.attachments.count, course_files_path(e_course), :class => "linkBlue2" %>)
+ <% if visable_attachemnts_incourse(e_course).count > 0 %>
+ <%= l(:project_module_attachments) %>(<%= link_to visable_attachemnts_incourse(e_course).count, course_files_path(e_course), :class => "linkBlue2" %>)
<% end %>
- <% if e_course.homework_commons.count > 0 %>
- <%= l(:label_homework_commont) %>(<%= link_to e_course.homework_commons.count, homework_common_index_path(:course=>e_course.id), :class => "linkBlue2" %>)
+ <% if e_course.homework_commons.where("publish_time <= '#{Date.today}'").count > 0 %>
+ <%= 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" %>)
<% end %>
+
diff --git a/app/views/courses/_tool_expand.html.erb b/app/views/courses/_tool_expand.html.erb
index 3ded0cb1d..52a971826 100644
--- a/app/views/courses/_tool_expand.html.erb
+++ b/app/views/courses/_tool_expand.html.erb
@@ -8,7 +8,7 @@
<% end %>
<% if show_nav?(@course.news.count) %>
- <%= link_to l(:label_course_news), course_news_index_path(@course), :class => "f12 c_blue02 ml10 fn" %>
+ <%= link_to "通知", course_news_index_path(@course), :class => "f12 c_blue02 ml10 fn" %>
<%= link_to( "", new_course_news_path(@course), :class => 'courseMenuSetting', :title =>"#{l(:label_course_news_new)}") if is_teacher %>
<% end %>
@@ -24,7 +24,7 @@
<% if show_nav?(@course.boards.first ? @course.boards.first.topics.count : 0) %>
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f12 c_blue02 ml10 fn" %>
- <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") if User.current.member_of_course?(@course) && @course.boards.first %>
+ <%= link_to( "",course_boards_path(@course, :flag => true, :is_new => 1), :class => 'courseMenuSetting', :title =>"#{l(:label_message_new)}") %>
<% end %>
<% if show_nav?(course_feedback_count) %>
diff --git a/app/views/courses/member.html.erb b/app/views/courses/member.html.erb
index 2fe18c4eb..7a58315a2 100644
--- a/app/views/courses/member.html.erb
+++ b/app/views/courses/member.html.erb
@@ -2,7 +2,7 @@
<%= @subPage_title%>
<% if User.current.allowed_to?(:as_teacher,@course) %>
- <%=link_to "修改角色", :controller => 'courses', :action => 'settings', :id => @course.id, :tab=>'member' %>
+ <%=link_to "成员管理", :controller => 'courses', :action => 'settings', :id => @course.id, :tab=>'member' %>
<% end %>
diff --git a/app/views/courses/private_or_public.js.erb b/app/views/courses/private_or_public.js.erb
index 10b787dd4..4e512a6a0 100644
--- a/app/views/courses/private_or_public.js.erb
+++ b/app/views/courses/private_or_public.js.erb
@@ -9,10 +9,10 @@
}
<% else %>
<% if @course.is_public? %>
- $("#set_course_public_<%= @course.id %>").text("设为私有");
$("#show_course_<%= @course.id %>").attr("title","公开课程:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)");
<% else %>
- $("#set_course_public_<%= @course.id %>").text("设为公开");
$("#show_course_<%= @course.id %>").attr("title","私有课程:<%= @course.name %>(<%= @course.time.to_s+ @course.term %>)");
<% 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 %>
\ No newline at end of file
diff --git a/app/views/courses/syllabus.html.erb b/app/views/courses/syllabus.html.erb
index e12876ce9..8be245958 100644
--- a/app/views/courses/syllabus.html.erb
+++ b/app/views/courses/syllabus.html.erb
@@ -1,218 +1,218 @@
-
-<%= content_for(:header_tags) do %>
- <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
- <%= javascript_include_tag 'blog' %>
-<% end %>
-
-
-
-
-
-
- <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
-
-
- <% if User.current && @article.author.id == User.current.id%>
-
-
-
-
-
- 重设大纲
-
-
- <%= link_to(
- '取消大纲',
- {:controller => 'blog_comments',:action => 'destroy',:user_id=>BlogComment.find(@course.outline).author_id,:blog_id=>BlogComment.find(@course.outline).blog_id, :id => @course.outline,:course_id=>@course.id},
- :method => :delete,
- :data => {:confirm => '您确定要取消么?'},
- :class => 'postOptionLink'
- ) if User.current && User.current.id == @article.author.id %>
-
-
-
-
-
-
-
-
-
-
-
-
-
- <%end%>
-
-
-
-
- <% if @article.try(:author).try(:realname) == ' ' %>
- <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
- <% else %>
- <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
- <% end %>
-
-
<%= format_time( @article.created_on)%>
-
-
- <%= @article.content.html_safe%>
-
-
-
- <%#= link_to_attachments_course @topic, :author => false %>
- <% if @article.attachments.any?%>
- <% options = {:author => true, :deletable => false} %>
- <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %>
- <% end %>
-
-
-
-
-
- <% count=0 %>
- <% if @article.parent %>
- <% count=@article.parent.children.count%>
- <% else %>
- <% count=@article.children.count%>
- <% end %>
-
- <% unless count == 0 %>
-
-
- <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %>
-
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
-
-
- <%= reply.content.html_safe%>
-
-
- <%= format_time(reply.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
- <% if !@article.locked? && User.current.logged?%>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@article.author_id), :alt => "用户头像" %>
-
-
- <%= form_for 'blog_comment',:url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id},:method => "post",:html => {:multipart => true, :id => 'message_form'} do |f|%>
-
-
-
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
- <% end %>
-
-
-
+
+
+
+
+ <%= link_to image_tag(url_to_avatar(@article.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@article.author) %>
+
+
+ <% if User.current && @article.author.id == User.current.id%>
+
+
+
+
+
+ 重设大纲
+
+
+ <%= link_to(
+ '取消大纲',
+ {:controller => 'blog_comments',:action => 'destroy',:user_id=>BlogComment.find(@course.outline).author_id,:blog_id=>BlogComment.find(@course.outline).blog_id, :id => @course.outline,:course_id=>@course.id},
+ :method => :delete,
+ :data => {:confirm => '您确定要取消么?'},
+ :class => 'postOptionLink'
+ ) if User.current && User.current.id == @article.author.id %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ <%end%>
+
+
+
+
+ <% if @article.try(:author).try(:realname) == ' ' %>
+ <%= link_to @article.try(:author), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
+ <% else %>
+ <%= link_to @article.try(:author).try(:realname), user_path(@article.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
+ <% end %>
+
+
<%= format_time( @article.created_on)%>
+
+
+ <%= @article.content.html_safe%>
+
+
+
+ <%#= link_to_attachments_course @topic, :author => false %>
+ <% if @article.attachments.any?%>
+ <% options = {:author => true, :deletable => false} %>
+ <%= render :partial => 'blog_comments/attachments_links', :locals => {:attachments => @article.attachments, :options => options, :is_float => true} %>
+ <% end %>
+
+
+
+
+
+ <% count=0 %>
+ <% if @article.parent %>
+ <% count=@article.parent.children.count%>
+ <% else %>
+ <% count=@article.children.count%>
+ <% end %>
+
+ <% unless count == 0 %>
+
+
+ <%@article.children.reorder('created_on desc').each_with_index do |reply,i| %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% end %>
+
+
+ <%= reply.content.html_safe%>
+
+
+ <%= format_time(reply.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !@article.locked? && User.current.logged?%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@article.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for 'blog_comment',:url => {:action => 'reply',:controller => 'blog_comments',:user_id=>@article.author.id,:blog_id=>@article.blog_id, :id => @article.id},:method => "post",:html => {:multipart => true, :id => 'message_form'} do |f|%>
+
+
+
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/courses/teacher_assign_group.js.erb b/app/views/courses/teacher_assign_group.js.erb
new file mode 100644
index 000000000..1429bb753
--- /dev/null
+++ b/app/views/courses/teacher_assign_group.js.erb
@@ -0,0 +1 @@
+$("#st_groups").html("<%=escape_javascript(render :partial => 'new_groups_name', :locals => {:course_groups => @course_groups}) %>");
\ No newline at end of file
diff --git a/app/views/exercise/_edit_MC.html.erb b/app/views/exercise/_edit_MC.html.erb
index f4ececf8f..1da0b9038 100644
--- a/app/views/exercise/_edit_MC.html.erb
+++ b/app/views/exercise/_edit_MC.html.erb
@@ -8,7 +8,7 @@
$("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>")
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" +
"
" +
- "选项<%=convert_to_char (index+1).to_s %> : " +
+ "选项<%=convert_to_char (index+1).to_s %> : " +
" " +
" " +
" " +
@@ -34,7 +34,7 @@
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
- 选项<%=convert_to_char (index+1).to_s %> :
+ 选项<%=convert_to_char (index+1).to_s %> :
diff --git a/app/views/exercise/_edit_MCQ.html.erb b/app/views/exercise/_edit_MCQ.html.erb
index 18ae79d1c..48422be1c 100644
--- a/app/views/exercise/_edit_MCQ.html.erb
+++ b/app/views/exercise/_edit_MCQ.html.erb
@@ -8,7 +8,7 @@
$("#poll_question_standard_answer_<%=exercise_question.id %>").val("<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s)%>")
$("#poll_answers_<%=exercise_question.id%>").html("<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>" +
" " +
- "选项<%=convert_to_char (index+1).to_s %> : " +
+ "选项<%=convert_to_char (index+1).to_s %> : " +
" " +
" " +
" " +
@@ -34,7 +34,7 @@
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
- 选项<%=convert_to_char (index+1).to_s %> :
+ 选项<%=convert_to_char (index+1).to_s %> :
diff --git a/app/views/exercise/_edit_single.html.erb b/app/views/exercise/_edit_single.html.erb
index 0ce2f0943..42878454d 100644
--- a/app/views/exercise/_edit_single.html.erb
+++ b/app/views/exercise/_edit_single.html.erb
@@ -1,59 +1,59 @@
-<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
-
-
-
-
-
+<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:remote => true) do |f|%>
+
+
+
+
+
<% end%>
\ No newline at end of file
diff --git a/app/views/exercise/_exercise_form.html.erb b/app/views/exercise/_exercise_form.html.erb
index f0bef74bf..ec099cb09 100644
--- a/app/views/exercise/_exercise_form.html.erb
+++ b/app/views/exercise/_exercise_form.html.erb
@@ -162,15 +162,38 @@
//单选题
function add_single_answer(doc)
{
- doc.parent().after(" 选项 : " +
+ var li = doc.parent().after("选项 : " +
" "+
"
");
+ var select_items =$("label[name='select_items']",li.parent());
+ for(var i=0; i
: ");
+ }
}
function add_candidate_answer(doc)
{
- doc.parent().after("候选答案 : " +
+ doc.parent().after("候选答案 : " +
" "+
"
");
+ var select_items =$("label[name='candiate_items']",doc.parent().parent());
+ for(var i=0; i: ");
+ }
+ }
+ function revert_to_chinese_num(num){
+ var s_num = "";
+ switch (num) {
+ case 1: s_num = '一'; break;
+ case 2: s_num = '二'; break;
+ case 3: s_num = '三'; break;
+ case 4: s_num = '四'; break;
+ case 5: s_num = '五'; break;
+ case 6: s_num = '六'; break;
+ case 7: s_num = '七'; break;
+ case 8: s_num = '八'; break;
+ case 9: s_num = '九'; break;
+ }
+ return s_num;
}
function remove_single_answer(doc)
{
@@ -180,7 +203,16 @@
}
else
{
+ var parent = doc.parent().parent();
doc.parent().remove();
+ var select_items =$("label[name='select_items']",parent);
+ var candiate_items =$("label[name='candiate_items']",parent);
+ for(var i=0; i: ");
+ }
+ for(var i=0; i: ");
+ }
}
}
diff --git a/app/views/exercise/_new_MC.html.erb b/app/views/exercise/_new_MC.html.erb
index 0d7350570..6fd6c201e 100644
--- a/app/views/exercise/_new_MC.html.erb
+++ b/app/views/exercise/_new_MC.html.erb
@@ -18,28 +18,28 @@
- 选项A :
+ 选项A :
- 选项B :
+ 选项B :
- 选项C :
+ 选项C :
- 选项D :
+ 选项D :
diff --git a/app/views/exercise/_new_MCQ.html.erb b/app/views/exercise/_new_MCQ.html.erb
index 3ea198d8f..a24835fc1 100644
--- a/app/views/exercise/_new_MCQ.html.erb
+++ b/app/views/exercise/_new_MCQ.html.erb
@@ -18,28 +18,28 @@
- 选项A :
+ 选项A :
- 选项B :
+ 选项B :
- 选项C :
+ 选项C :
- 选项D :
+ 选项D :
diff --git a/app/views/exercise/_new_single.html.erb b/app/views/exercise/_new_single.html.erb
index 061b053fd..6180dac8e 100644
--- a/app/views/exercise/_new_single.html.erb
+++ b/app/views/exercise/_new_single.html.erb
@@ -1,50 +1,50 @@
-<%= form_for(ExerciseQuestion.new,
- :html => { :multipart => true },
- :url=>create_exercise_question_exercise_path(exercise.id),
- :remote=>true ) do |f| %>
-
+<%= form_for(ExerciseQuestion.new,
+ :html => { :multipart => true },
+ :url=>create_exercise_question_exercise_path(exercise.id),
+ :remote=>true ) do |f| %>
+
<% end %>
\ No newline at end of file
diff --git a/app/views/exercise/_show_MC.html.erb b/app/views/exercise/_show_MC.html.erb
index d052bd6da..eef7546e5 100644
--- a/app/views/exercise/_show_MC.html.erb
+++ b/app/views/exercise/_show_MC.html.erb
@@ -55,28 +55,28 @@
' 分'+
' '+
'
'+
- '选项A : '+
+ '选项A : '+
' '+
' '+
' '+
' '+
'
'+
'
'+
- '选项B : '+
+ '选项B : '+
' '+
' '+
' '+
' '+
'
'+
'
'+
- '选项C : '+
+ '选项C : '+
' '+
' '+
' '+
' '+
'
'+
'
'+
- '选项D : '+
+ '选项D : '+
' '+
' '+
' '+
diff --git a/app/views/exercise/_show_MCQ.html.erb b/app/views/exercise/_show_MCQ.html.erb
index a477303d7..9e66f17f9 100644
--- a/app/views/exercise/_show_MCQ.html.erb
+++ b/app/views/exercise/_show_MCQ.html.erb
@@ -54,28 +54,28 @@
' 分'+
' '+
'
'+
- '选项A : '+
+ '选项A : '+
' '+
' '+
' '+
' '+
'
'+
'
'+
- '选项B : '+
+ '选项B : '+
' '+
' '+
' '+
' '+
'
'+
'
'+
- '选项C : '+
+ '选项C : '+
' '+
' '+
' '+
' '+
'
'+
'
'+
- '选项D : '+
+ '选项D : '+
' '+
' '+
' '+
diff --git a/app/views/exercise/_show_single.html.erb b/app/views/exercise/_show_single.html.erb
index 86203b8bb..90f604da1 100644
--- a/app/views/exercise/_show_single.html.erb
+++ b/app/views/exercise/_show_single.html.erb
@@ -9,7 +9,7 @@
<% exercise_question.exercise_standard_answers.reorder("created_at").each_with_index do |exercise_choice,index| %>
- 候选答案:<%= exercise_choice.answer_text%>
+ 候选答案<%= convert_to_chi_num(index+1) %>:<%= exercise_choice.answer_text%>
<% end %>
@@ -42,22 +42,22 @@
'
分'+
'
'+
diff --git a/app/views/files/_course_file.html.erb b/app/views/files/_course_file.html.erb
index cf91b7814..2cf43f896 100644
--- a/app/views/files/_course_file.html.erb
+++ b/app/views/files/_course_file.html.erb
@@ -91,9 +91,10 @@
<%= form_tag( search_course_files_path(@course), method: 'get',:class => "re_search",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%>
<%= submit_tag "课内搜索", :class => "blueBtn mr5 fl",:name => "incourse",:id => "incourse" %>
- <%= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite" %>
+ <%#= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite" %>
<% if is_course_teacher(User.current,@course) || (@course.publish_resource==1 && User.current.member_of_course?(@course) ) %>
-
+
+ <%= link_to("导入资源", import_resources_user_path(User.current, :type => 6, :course_id => @course.id), :class => "blue-btn fr mr5", :remote => true) %>
<% end %>
<% end %>
@@ -107,23 +108,15 @@
共有 <%= @all_attachments.count%> 个资源
-
- <% if @order == "asc" %>
- 按 <%= 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"} %> /
- <%= 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"} %> /
- <%= 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"} %> 排序
- <% else %>
- 按 <%= 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"} %> /
- <%= 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"} %> /
- <%= 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"} %> 排序
- <% end %>
+
+ <%= render :partial => 'course_file_filter_order', :locals => {:remote => @is_remote, :sort => @sort, :order => @order} %>
- <%= 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} %>
<%# html_title(l(:label_attachment_plural)) -%>
\ No newline at end of file
diff --git a/app/views/files/_course_file_filter_order.html.erb b/app/views/files/_course_file_filter_order.html.erb
new file mode 100644
index 000000000..a740d9481
--- /dev/null
+++ b/app/views/files/_course_file_filter_order.html.erb
@@ -0,0 +1,15 @@
+<% if @order == "asc" %>
+ 按 <%= 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"} %> /
+ <%= 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"} %> /
+ <%= 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"} %> 排序
+<% else %>
+ 按 <%= 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"} %> /
+ <%= 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"} %> /
+ <%= 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"} %> 排序
+<% end %>
\ No newline at end of file
diff --git a/app/views/files/_import_files.html.erb b/app/views/files/_import_files.html.erb
new file mode 100644
index 000000000..36fa96a0b
--- /dev/null
+++ b/app/views/files/_import_files.html.erb
@@ -0,0 +1,138 @@
+<%#= render :partial => 'users/user_resource_info' %>
+选用资源库中的资源
+ 公共资源 我的资源
+
+
+
+
+ 资源名称
+ 类别
+ 大小
+ 上传者
+ 上传时间
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb
index 866cf6fd8..722024a85 100644
--- a/app/views/files/_org_subfield_list.html.erb
+++ b/app/views/files/_org_subfield_list.html.erb
@@ -1,78 +1,90 @@
-<% delete_allowed = User.current.admin? %>
-
-<% org_subfield_attachments.each do |file| %>
-
-
-
- <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
-
-
-
- <%= 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 => "c_dblue f_14 f_b f_l" %>
- <%= file_preview_eye(file, class: 'preview') %>
-
- <% if file.is_public? == false%>
- 私有
- <%end %>
-
-
-
-
-
上传时间:<%= format_date(file.created_on)%>
- <% if file.tag_list.length > 0%>
-
上传类型:<%= file.tag_list[0] %>
- <% end %>
-
文件大小:<%= number_to_human_size(file.filesize) %>
-
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
-
-
-
- <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %>
- <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %>
-
-
-
-
- <% if User.current.logged? %>
- <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == org_subfield.id && file.container_type == "OrgSubfield" %>
-
- <%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
- <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
-
-
- <%= 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( '删除资源', 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 %>
-
-
- <%else%>
-
- <%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
-
- <% end %>
- <% end %>
-
-
-
-
-
-
-
-
-
-<% end %>
-
-<% if org_subfield_attachments.count == 10 %>
- <% if params[:action] == 'search_files_in_subfield' %>
- <%=link_to "点击展开更多", search_files_in_subfield_org_subfield_files_path(:org_subfield_id => org_subfield.id,:page => @page.to_i + 1, :name => params[:name],:insite => params[:insite]),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
- <% else %>
-
- <%=link_to "点击展开更多", org_subfield_files_path(:org_subfield_id => org_subfield.id, :page => @page.nil? ? 2 :(@page.to_i + 1)), :id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
- <%end%>
-<% end%>
-
+<% delete_allowed = User.current.admin? %>
+
+<% org_subfield_attachments.each do |file| %>
+ <% if file.is_public == 1 or User.current.member_of_org?(file.container.organization) %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
+
+
+
+ <%# 如果有历史版本则提供历史版本下载 %>
+ <% if file.attachment_histories.count == 0 %>
+ <%= 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') %>
+
+ <% if file.is_public? == false%>
+ 私有
+ <%end %>
+
+
+
+
+
上传时间:<%= format_date(file.created_on)%>
+ <% if file.tag_list.length > 0%>
+
上传类型:<%= file.tag_list[0] %>
+ <% end %>
+
文件大小:<%= number_to_human_size(file.filesize) %>
+
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
+
+
+
+ <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %>
+ <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %>
+
+
+
+
+ <% if User.current.logged? %>
+ <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == org_subfield.id && file.container_type == "OrgSubfield" %>
+
+ <%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
+ <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
+ <% if file.container.try(:organization).try(:is_public?) %>
+
+
+ <%= 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 %>
+
+
+ <% end %>
+
+ <%= 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 %>
+
+
+ <%else%>
+
+ <%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
+
+ <% end %>
+ <% end %>
+
+
+
+
+
+
+
+
+
+ <% end %>
+<% end %>
+
+<% if org_subfield_attachments.count == 10 %>
+ <% if params[:action] == 'search_files_in_subfield' %>
+ <%=link_to "点击展开更多", search_files_in_subfield_org_subfield_files_path(:org_subfield_id => org_subfield.id,:page => @page.to_i + 1, :name => params[:name],:insite => params[:insite]),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
+ <% else %>
+
+ <%=link_to "点击展开更多", org_subfield_files_path(:org_subfield_id => org_subfield.id, :page => @page.nil? ? 2 :(@page.to_i + 1)), :id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
+ <%end%>
+<% end%>
+
diff --git a/app/views/files/_project_file.html.erb b/app/views/files/_project_file.html.erb
index e8f4f023b..98b9ad514 100644
--- a/app/views/files/_project_file.html.erb
+++ b/app/views/files/_project_file.html.erb
@@ -62,10 +62,12 @@
<%= form_tag( search_project_project_files_path(@project), method: 'get',:class => "re_search",:remote=>true) do %>
<%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%>
<%= submit_tag "项目内搜索", :class => "re_schbtn b_lblue",:name => "incourse",:id => "incourse", :onmouseover => "presscss('incourse')",:onmouseout =>"buttoncss()", :style =>"width:72px;" %>
- <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %>
+ <%#= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %>
<% if User.current.member_of?(@project) %>
+ <%= link_to("导入资源", import_resources_user_path(User.current, :type => 6, :project_id => @project.id), :class => "blue-btn fr mr5", :remote => true) %>
+
<% end %>
<% end %>
diff --git a/app/views/files/_project_list.html.erb b/app/views/files/_project_list.html.erb
index 391430126..2ee726d77 100644
--- a/app/views/files/_project_list.html.erb
+++ b/app/views/files/_project_list.html.erb
@@ -1,61 +1,69 @@
-<% delete_allowed = User.current.allowed_to?(:manage_files, project) %>
-<% project_attachments.each do |file| %>
- <% if file.is_public? || User.current.member_of?(project) || User.current.admin? %>
-
-
-
- <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
-
-
-
- <%= 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 => "linkBlue f_14 f_b" %>
- <%= file_preview_eye(file, class: 'preview') %>
-
- <% if file.is_public? == false%>
- 私有
- <%end %>
-
-
-
-
上传时间:<%= format_time(file.created_on)%>
- <% if file.tag_list.length > 0%>
-
上传类型:<%= file.tag_list[0] %>
- <% end %>
-
文件大小:<%= number_to_human_size(file.filesize) %>
-
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
-
-
-
-
- <%= render :partial => 'tags/tag_new', :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} %>
-
-
- <%= render :partial => 'files/tool_settings', :locals => {:project => @project, :delete_allowed => delete_allowed, :file => file} %>
-
-
-
-
-
-
- <% else %>
- <%= file.filename %>是私有资源
- <% end %>
-<% end %>
-
-<% if project_attachments.count == 10%>
- <% if params[:action] == 'search_project' %>
-
-
-
- <%=link_to "点击展开更多", search_project_project_files_path({:project_id => project.id, :page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
- <%else%>
-
- <%=link_to "点击展开更多", project_files_path(:project_id => project.id,:page => @page),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
- <%end%>
-<% end%>
-
-
-
+<% delete_allowed = User.current.allowed_to?(:manage_files, project) %>
+<% project_attachments.each do |file| %>
+ <% if file.is_public? || User.current.member_of?(project) || User.current.admin? %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
+
+
+
+ <%# 如果有历史版本则提供历史版本下载 %>
+ <% if file.attachment_histories.count == 0 %>
+ <%= 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') %>
+
+ <% if file.is_public? == false%>
+ 私有
+ <%end %>
+
+
+
+
上传时间:<%= format_time(file.created_on)%>
+ <% if file.tag_list.length > 0%>
+
上传类型:<%= file.tag_list[0] %>
+ <% end %>
+
文件大小:<%= number_to_human_size(file.filesize) %>
+
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
+
+
+
+
+ <%= render :partial => 'tags/tag_new', :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} %>
+
+
+ <%= render :partial => 'files/tool_settings', :locals => {:project => @project, :delete_allowed => delete_allowed, :file => file} %>
+
+
+
+
+
+
+ <% else %>
+ <%= file.filename %>是私有资源
+ <% end %>
+<% end %>
+
+<% if project_attachments.count == 10%>
+ <% if params[:action] == 'search_project' %>
+
+
+
+ <%=link_to "点击展开更多", search_project_project_files_path({:project_id => project.id, :page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
+ <%else%>
+
+ <%=link_to "点击展开更多", project_files_path(:project_id => project.id,:page => @page),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %>
+ <%end%>
+<% end%>
+
+
+
diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb
index fd0a165aa..20ffb1e50 100644
--- a/app/views/files/_resource_detail.html.erb
+++ b/app/views/files/_resource_detail.html.erb
@@ -1,77 +1,86 @@
-<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
-
-
-
- <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
-
-
-
- <%= 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 => "linkBlue f_14 f_b" %>
- <%= file_preview_eye(file, class: 'preview') %>
-
- <% if file.is_public? == false%>
- 私有
- <%end %>
-
- <% if file.is_publish == 0 %>
- <%=file.publish_time %> 0点发布
- <% end %>
-
-
-
上传时间:<%= format_time(file.created_on)%>
- <% if file.tag_list.length > 0%>
-
上传类型:<%= file.tag_list[0] %>
- <% end %>
-
文件大小:<%= number_to_human_size(file.filesize) %>
-
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
-
-
-
-
- <%= render :partial => 'tags/tag_new', :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} %>
-
-
-
-
-
- <% if User.current.logged? %>
-
- <% 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" %>
-
-
- <%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
- <%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %>
- <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
- <% if @course.is_public? %>
-
-
- <%= 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 %>
-
-
- <%end%>
-
- <%= 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 %>
-
-
-
- <% end %>
- <%else%>
-
- <%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
-
- <% end %>
- <% end %>
-
-
-
-
-
-
-
-
+<% delete_allowed = User.current.allowed_to?(:manage_files, @course) %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %>
+
+
+
+ <%# 如果有历史版本则提供历史版本下载 %>
+ <% if file.attachment_histories.count == 0 %>
+ <%= 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') %>
+
+ <% if file.is_public? == false%>
+ 私有
+ <%end %>
+
+ <% if file.is_publish == 0 %>
+ <%=file.publish_time %> 0点发布
+ <% end %>
+
+
+
上传时间:<%= format_time(file.created_on)%>
+ <% if file.tag_list.length > 0%>
+
上传类型:<%= file.tag_list[0] %>
+ <% end %>
+
文件大小:<%= number_to_human_size(file.filesize) %>
+
下载<%= file.downloads%> | 引用<%= file.quotes.nil? ? 0:file.quotes %>
+
+ <% unless file.description.blank? %>
+
+
资源描述:<%= file.description %>
+ <% end %>
+
+
+
+ <%= render :partial => 'tags/tag_new', :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} %>
+
+
+
+
+ <% if User.current.logged? %>
+ <% 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" %>
+
+ <%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
+ <%= link_to '延期发布',file_hidden_course_file_path(@course,file),:class => "postOptionLink",:remote=>true %>
+ <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
+ <% if @course.is_public? %>
+
+
+ <%= 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 %>
+
+
+ <%end%>
+
+ <%= 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 %>
+
+
+ <% end %>
+ <%else%>
+
+ <%= link_to("发 送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}','#{User.current.id}','file')") %>
+
+ <% end %>
+ <% end %>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/files/_subfield_files.html.erb b/app/views/files/_subfield_files.html.erb
index 1de0e8dc2..9e0dd41d0 100644
--- a/app/views/files/_subfield_files.html.erb
+++ b/app/views/files/_subfield_files.html.erb
@@ -1,85 +1,87 @@
-<%= stylesheet_link_tag 'courses'%>
-
-
-
-<%# html_title(l(:label_attachment_plural)) -%>
-
+
+
+<%# html_title(l(:label_attachment_plural)) -%>
+
\ No newline at end of file
diff --git a/app/views/files/_upload_course_files.erb b/app/views/files/_upload_course_files.erb
index de43977cd..0a35c783c 100644
--- a/app/views/files/_upload_course_files.erb
+++ b/app/views/files/_upload_course_files.erb
@@ -1,84 +1,92 @@
-
-
-
-
<%= l(:label_upload_files)%>
-
- <%= error_messages_for 'attachment' %>
-
<%= l(:label_file_upload_error_messages)%>
-
- <%= form_tag(course_files_path(course), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
-
-
-
- 课件 |
- 软件 |
- 媒体 |
- 代码 |
- 论文 |
- 其他
-
-
-
- <%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %>
-
-
- <% if User.current.allowed_to?(:as_teacher,course) %>
-
-
延迟发布:
-
-
- <%#= calendar_for('attachment_publish_time')%>
-
-
-
-
- <% end %>
-
<%= l(:button_cancel)%>
-
<%= l(:button_confirm)%>
- <%#= submit_tag '确定',:onclick=>'submit_course_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %>
- <% end %>
-
-
-
- <% content_for :header_tags do %>
- <%= javascript_include_tag 'attachments' %>
- <% end %>
-
-
-
+
+
+
<%= l(:label_upload_files)%>
+
+ <%= error_messages_for 'attachment' %>
+
<%= l(:label_file_upload_error_messages)%>
+
+ <%= form_tag(course_files_path(course), :multipart => true,:remote => !ie8?,:name=>"upload_form") do %>
+
+
+
+ 课件 |
+ 软件 |
+ 媒体 |
+ 代码 |
+ 论文 |
+ 其他
+
+
+
+ <%= render :partial => 'files/new_style_attachment_list',:locals => {:container => course} %>
+
+
+
+
+ <% if User.current.allowed_to?(:as_teacher,course) %>
+
+
延迟发布:
+
+
+ <%#= calendar_for('attachment_publish_time')%>
+
+
+
+
+ <% end %>
+
<%= l(:button_cancel)%>
+
<%= l(:button_confirm)%>
+ <%#= submit_tag '确定',:onclick=>'submit_course_resource();',:onfocus=>'this.blur()',:id=>'submit_resource',:class=>'sendSourceText fr' %>
+ <% end %>
+
+
+
+ <% content_for :header_tags do %>
+ <%= javascript_include_tag 'attachments' %>
+ <% end %>
+
+
+
\ No newline at end of file
diff --git a/app/views/files/index.html.erb b/app/views/files/index.html.erb
index d4d12232e..528265c26 100644
--- a/app/views/files/index.html.erb
+++ b/app/views/files/index.html.erb
@@ -1,480 +1,479 @@
-
- <% if @container_type == 0 %>
-
- <%= render :partial => 'project_file', locals: {project: @project} %>
-
- <% elsif @container_type == 1 %>
-
- <%= render :partial => 'course_file', locals: {course: @course} %>
-
- <% elsif @container_type == 2 %>
-
- <%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %>
-
- <% end %>
-
-
-
-
-
-
+
+ <% if @container_type == 0 %>
+
+ <%= render :partial => 'project_file', locals: {project: @project} %>
+
+ <% elsif @container_type == 1 %>
+
+ <%= render :partial => 'course_file', locals: {course: @course} %>
+
+ <% elsif @container_type == 2 %>
+
+ <%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %>
+
+ <% end %>
+
+
+
+
+
diff --git a/app/views/files/search_tag_attachment.js.erb b/app/views/files/search_tag_attachment.js.erb
index 31df68b6a..3003d8b98 100644
--- a/app/views/files/search_tag_attachment.js.erb
+++ b/app/views/files/search_tag_attachment.js.erb
@@ -1,5 +1,6 @@
<% 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_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%>")
<% 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}) %>");
diff --git a/app/views/homework_common/edit.html.erb b/app/views/homework_common/edit.html.erb
index f95739f26..0c120b7c2 100644
--- a/app/views/homework_common/edit.html.erb
+++ b/app/views/homework_common/edit.html.erb
@@ -1,4 +1,10 @@
-
+
<%= render_flash_messages %>
<%= yield %>
diff --git a/app/views/layouts/new_base_user.html.erb b/app/views/layouts/new_base_user.html.erb
index 731162920..c90c69f75 100644
--- a/app/views/layouts/new_base_user.html.erb
+++ b/app/views/layouts/new_base_user.html.erb
@@ -28,6 +28,8 @@
});
-
-
-
-
-
-
- <% if User.current.logged? %>
- <%= render :partial => 'layouts/logined_header',:locals=>{:name=>@name,:type=>@type} %>
- <% else%>
- <%= render :partial => 'layouts/unlogin_header',:locals=>{:name=>@name,:type=>@type} %>
- <% end%>
-
-
-
-
-<%= render :partial => 'layouts/footer' %>
-
-
-<%= call_hook :view_layouts_base_body_bottom %>
-
-
+
+
+
+
+
<%=h html_title %>
+
+
+ <%= csrf_meta_tag %>
+ <%= favicon %>
+ <%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2', 'application', 'nyan','prettify', :media => 'all' %>
+ <%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
+ <%= javascript_heads %>
+ <%= javascript_include_tag "jquery.leanModal.min",'prettify' %>
+ <%= javascript_include_tag 'seems_rateable/jRating', 'seems_rateable/rateable'%>
+ <%= heads_for_theme %>
+ <%= call_hook :view_layouts_base_html_head %>
+
+ <%= yield :header_tags -%>
+ <%= stylesheet_link_tag 'base','header', :media => 'all'%>
+
+
+
+
+
+
+
+
+ <% if User.current.logged? %>
+ <%= render :partial => 'layouts/logined_header',:locals=>{:name=>@name,:type=>@type} %>
+ <% else%>
+ <%= render :partial => 'layouts/unlogin_header',:locals=>{:name=>@name,:type=>@type} %>
+ <% end%>
+
+
+
+
+<%= render :partial => 'layouts/footer' %>
+
+
+
+ <%= l(:label_loading) %>
+
+<%= call_hook :view_layouts_base_body_bottom %>
+
+
diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb
index 16bc5c742..83b90dc93 100644
--- a/app/views/memos/show.html.erb
+++ b/app/views/memos/show.html.erb
@@ -61,7 +61,7 @@
<%= link_to @memo.author.name, user_path(@memo.author), :class => "linkBlue2", :target=> "_blank"%>
<%= format_date( @memo.created_at)%>
-
+
<%= @memo.content.html_safe%>
@@ -95,8 +95,21 @@
<%= reply.author.name%> <%= format_date(reply.created_at) %>
-
<%= reply.content.html_safe%>
+
<%= reply.content.html_safe%>
+
<% end %>
@@ -113,7 +126,7 @@
<%= hidden_field_tag :quote,"",:required => false,:style => 'display:none' %>
- 发送
+ 发送
<% end%>
@@ -126,7 +139,7 @@
\ No newline at end of file
diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb
index 49207d5c5..f36f8a63c 100644
--- a/app/views/messages/_course_show.html.erb
+++ b/app/views/messages/_course_show.html.erb
@@ -34,11 +34,7 @@
- <% if @topic.status == 1 %>
- <%= 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 %>
+ <%= link_to image_tag(url_to_avatar(@topic.author), :width => 50, :height => 50,:alt=>'图像' ), user_path(@topic.author) %>
<% if User.current.logged? %>
@@ -74,16 +70,11 @@
主题: <%= @topic.subject%>
-
- <% if @topic.status == 1 %>
- 确实团队
+ <% if @topic.try(:author).try(:realname) == ' ' %>
+ <%= link_to @topic.try(:author), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<% else %>
- <% if @topic.try(:author).try(:realname) == ' ' %>
- <%= 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 %>
+ <%= link_to @topic.try(:author).try(:realname), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %>
<% end %>
<%= format_time( @topic.created_on)%>
diff --git a/app/views/messages/_reply_message.html.erb b/app/views/messages/_reply_message.html.erb
index 2d957dbda..faa0bd0ce 100644
--- a/app/views/messages/_reply_message.html.erb
+++ b/app/views/messages/_reply_message.html.erb
@@ -1,19 +1,19 @@
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
-
-
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %>
+
+
\ No newline at end of file
diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb
index 89fe71c65..324b1edf1 100644
--- a/app/views/messages/edit.html.erb
+++ b/app/views/messages/edit.html.erb
@@ -12,6 +12,7 @@
<% end %>
<% elsif @message.course %>
+
<%= form_for @message, {
:as => :message,
:url => {:action => 'edit',:is_course=>@is_course,:is_board=>@is_board},
@@ -22,7 +23,7 @@
<%= render :partial => 'boards/course_message_edit',
:locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %>
<% end %>
-
+
<% elsif @message.board.org_subfield %>
<%= form_for @message, {
:as => :message,
diff --git a/app/views/org_document_comments/_new.html.erb b/app/views/org_document_comments/_new.html.erb
index 9d3fe2de8..f462df2c9 100644
--- a/app/views/org_document_comments/_new.html.erb
+++ b/app/views/org_document_comments/_new.html.erb
@@ -1,6 +1,6 @@
<%= content_for(:header_tags) do %>
<%= import_ke(enable_at: false, prettify: false, init_activity: false) %>
- <%= javascript_include_tag "des_KindEditor" %>
+ <%= javascript_include_tag "des_kindEditor" %>
<% end %>
<% if act.container_type == 'Organization' %>
- <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %>
+ <% if act.org_act_type == 'OrgDocumentComment' %>
<%= render :partial => 'organizations/show_org_document', :locals => {:document => act.org_act, :act => act, :flag => 2, :org_subfield_id => params[:org_subfield_id]} %>
<% end %>
<% end %>
diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb
index d035ab5cd..84b69717a 100644
--- a/app/views/org_subfields/create.js.erb
+++ b/app/views/org_subfields/create.js.erb
@@ -1,8 +1,7 @@
<% if @res %>
$("#org_subfield_list").html("");
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',
- :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"),
- :subfields => @organization.org_subfields.where("field_type != 'default'") }) %>");
+ :locals => {:subfields => @organization.org_subfields.order("priority") }) %>");
$("#sub_field_left_lists").html("");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
$("#subfield_name").val("");
diff --git a/app/views/org_subfields/destroy.js.erb b/app/views/org_subfields/destroy.js.erb
index 2ba03fc36..d069b1cd8 100644
--- a/app/views/org_subfields/destroy.js.erb
+++ b/app/views/org_subfields/destroy.js.erb
@@ -1,6 +1,5 @@
$("#org_subfield_list").html("");
$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',
- :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"),
- :subfields => @organization.org_subfields.where("field_type != 'default'") }) %>");
+ :locals => {:subfields => @organization.org_subfields.order("priority") }) %>");
$("#sub_field_left_lists").html("");
$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>");
\ No newline at end of file
diff --git a/app/views/org_subfields/update_priority.js.erb b/app/views/org_subfields/update_priority.js.erb
new file mode 100644
index 000000000..475649aac
--- /dev/null
+++ b/app/views/org_subfields/update_priority.js.erb
@@ -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}) %>");
\ No newline at end of file
diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb
index 20b98ffa0..a3e62fd16 100644
--- a/app/views/organizations/_org_activities.html.erb
+++ b/app/views/organizations/_org_activities.html.erb
@@ -6,18 +6,6 @@
$("#relateProject,.relatePInfo").mouseout(function(){
$(".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(){
$(this).css("color","#ffffff");
})
@@ -50,7 +38,7 @@
<%= render :partial => 'users/show_detail_info', :locals => {:user => User.find(act.user_id)} %>
-
diff --git a/app/views/organizations/_org_course_create.html.erb b/app/views/organizations/_org_course_create.html.erb
index dc1e0ee81..875c45059 100644
--- a/app/views/organizations/_org_course_create.html.erb
+++ b/app/views/organizations/_org_course_create.html.erb
@@ -1,21 +1,21 @@
- <%= link_to image_tag(url_to_avatar(activity.teacher), :width => "50", :height => "50"), user_path(activity.tea_id), :alt => "用户头像" %>
+ <%= link_to image_tag(url_to_avatar(activity.teacher), :width => "50", :height => "50"), user_url_in_org(activity.tea_id), :alt => "用户头像" %>
<%= render :partial => 'users/show_detail_info', :locals => {:user => activity.teacher} %>
<% if activity.try(:teacher).try(:realname) == ' ' %>
- <%= link_to activity.try(:teacher), user_path(activity.tea_id), :class => "newsBlue mr15" %>
+ <%= link_to activity.try(:teacher), user_url_in_org(activity.tea_id), :class => "newsBlue mr15" %>
<% else %>
- <%= link_to activity.try(:teacher).try(:realname), user_path(activity.tea_id), :class => "newsBlue mr15" %>
+ <%= link_to activity.try(:teacher).try(:realname), user_url_in_org(activity.tea_id), :class => "newsBlue mr15" %>
<% end %>
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" %>
- <%= 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" %>
创建时间:<%= format_time(activity.created_at) %>
diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb
index 77ff5de13..025bb48af 100644
--- a/app/views/organizations/_org_course_homework.html.erb
+++ b/app/views/organizations/_org_course_homework.html.erb
@@ -1,363 +1,370 @@
-<% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %>
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
-
-
-
- <% if activity.try(:user).try(:realname) == ' ' %>
- <%= link_to activity.try(:user), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% 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.name.to_s, student_work_index_path(:homework => activity.id,:host=> Setting.host_course), :class => "postGrey"%>
-
- <% if activity.homework_detail_manual%>
- <% if activity.homework_detail_manual.comment_status == 1%>
- <% if activity.anonymous_comment == 0%>
-
未开启匿评
- <% else %>
-
匿评已禁用
- <% end %>
- <% if Time.parse(activity.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")%>
-
作品提交中
- <% elsif Time.parse(activity.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") %>
-
作品补交中
- <% end %>
- <% elsif activity.homework_detail_manual.comment_status == 2%>
- <% if activity.anonymous_comment == 0%>
-
匿评中
- <% else %>
-
匿评已禁用
- <% end %>
-
教师评阅中
- <% elsif activity.homework_detail_manual.comment_status == 3%>
- <% if activity.anonymous_comment == 0%>
-
匿评已结束
- <% else %>
-
匿评已禁用
- <% end %>
-
教师评阅中
- <% end%>
- <% end%>
-
- <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1%>
-
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
- <% elsif activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 0%>
-
系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!
- <% end %>
-
- <% if activity.homework_type == 3 && !is_teacher && activity.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(activity.course)%>
- <% projects = cur_user_projects_for_homework activity %>
- <% works = cur_user_works_for_homework activity %>
- <% if works.nil? && projects.nil? %>
-
- <%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => activity.id,:is_in_course=>-1,:user_activity_id=>user_activity_id,:course_activity=>course_activity),remote: true,:class=> 'c_blue', :title=> '请各组长关联作业项目' %>
- <%#= relate_project(activity,is_teacher,-1,user_activity_id,course_activity) %>
-
- <% elsif works.nil? %>
-
- <%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => activity.id,:is_in_course=>-1,:user_activity_id=>user_activity_id,:course_activity=>course_activity), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %>
-
- <% end %>
- <% end %>
-
- <% is_teacher = User.current.allowed_to?(:as_teacher,activity.course) %>
- <%= user_for_homework_common activity,is_teacher %>
-
-
- <% if activity.homework_type == 2 && is_teacher%>
-
- <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: activity.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
-
- <% end %>
- <% if activity.homework_type == 2%>
-
- 语言:
- <%= activity.language_name%>
-
- <% end %>
- <% if activity.homework_type == 3 && activity.homework_detail_group%>
-
- 分组人数:<%=activity.homework_detail_group.min_num %>-<%=activity.homework_detail_group.max_num %> 人
-
- <% end %>
- <% if activity.homework_detail_manual && activity.homework_detail_manual.comment_status < 2 %>
-
提交截止时间:<%= activity.end_time.to_s %> 23:59
- <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 %>
-
匿评截止时间:<%= activity.homework_detail_manual.evaluation_end.to_s %> 23:59
- <% end %>
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
-
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
- 迟交扣分:<%= activity.late_penalty%>分
-
- <% if activity.anonymous_comment == 0%>
-
- 匿评开启时间:<%= activity.homework_detail_manual.evaluation_start%> 00:00
-
- <% end %>
-
-
-
- <% if activity.anonymous_comment == 0%>
-
- 缺评扣分:<%= activity.homework_detail_manual.absence_penalty%>分/作品
-
- <% end %>
- <% if activity.anonymous_comment == 0%>
-
- 匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end%> 23:59
-
- <% end %>
-
-
- <% if activity.student_works.count != 0 %>
- <% sw = activity.student_works.reorder("created_at desc").first %>
-
- # <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
-
- <% end %>
-
- <% if activity.student_works.count != 0 %>
- <% sw_id = "("+activity.student_works.map{|sw| sw.id}.join(",")+")" %>
- <% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
- <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %>
- <% unless student_work_scores.empty? %>
- <% last_score = student_work_scores.first %>
-
-
# <%=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"%>评阅了作品,优秀排行:
-
- <% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
- <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
- <% student_works.each_with_index do |sw, i| %>
-
- <% if i == 4 %>
- <% break %>
- <% end %>
- <% end %>
- <% if student_works.count > 5 %>
- <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%>
- <% end %>
-
-
- <% end %>
- <% end %>
-
- <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %>
- <% projects = activity.student_work_projects.where("is_leader = 1") %>
- <% unless projects.empty? %>
- <% sort_projects = project_sort_update projects %>
-
-
- # <%=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"%>更新了项目,最近更新:
-
-
- <% sort_projects.each_with_index do |pro, i| %>
- <% project = Project.find pro.project_id %>
-
-
-
- <% 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 =>"项目头像" %>
- <% 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 =>"项目头像") %>
- <% end %>
- <% com_time = project.project_score.commit_time %>
- <% time=project.updated_on %>
- <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
-
<%=(User.find project.user_id).show_name %> (组长)
-
<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %> <%= project.project_score.changeset_num %>提交
-
- 项目名称:<%=project.name %>
- 创建者:<%=(User.find project.user_id).show_name %>(组长)
- 更新时间:<%=time_from_now time %>
-
-
- <% if i == 9 && projects.count > 10 %>
-
更多>>
- <% end %>
- <% if i > 9 && i == (projects.count - 1) %>
-
收回<<
- <% end %>
- <% end %>
-
- <% end %>
- <% end %>
-
- <% if is_teacher%>
- <% comment_status = activity.homework_detail_manual.comment_status %>
-
-
-
-
-
- <%= link_to l(:button_edit),edit_homework_common_path(activity,:is_in_course => -1,:course_activity=>course_activity), :class => "postOptionLink"%>
-
-
- <%= 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("评分设置", score_rule_set_homework_common_path(activity,:user_activity_id => user_activity_id, :is_in_course => 0),:class => "postOptionLink", :remote => true) %>
-
- <% if activity.anonymous_comment == 0 %>
-
- <%= link_to("匿评设置", start_evaluation_set_homework_common_path(activity),:class => "postOptionLink", :remote => true) if activity.homework_detail_manual.comment_status == 1%>
-
-
- <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %>
-
- <% end %>
- <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
-
- <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%>
-
- <% end %>
- <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
-
- <%= 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)%>
-
- <% elsif activity.is_open == 1 %>
-
- <%= 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)%>
-
- <% end %>
-
-
-
-
- <% end%>
-
-
-
-
- <% count=activity.journals_for_messages.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.user == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.journals_for_messages.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%>
- <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
- <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %>
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
-
+
+
+ <% 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_url_in_org(project.id),:id=>"project_img_"+project.id.to_s+"_"+activity.id.to_s,:alt =>"项目头像" %>
+ <% 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 =>"项目头像") %>
+ <% end %>
+ <% com_time = project.project_score.commit_time %>
+ <% time=project.updated_on %>
+ <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
+
<%=(User.find project.user_id).show_name %> (组长)
+
<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %> <%= project.project_score.changeset_num %>提交
+
+ 项目名称:<%=project.name %>
+ 创建者:<%=(User.find project.user_id).show_name %>(组长)
+ 更新时间:<%=time_from_now time %>
+
+
+ <% if i == 9 && projects.count > 10 %>
+
更多>>
+ <% end %>
+ <% if i > 9 && i == (projects.count - 1) %>
+
收回<<
+ <% end %>
+ <% end %>
+
+ <% end %>
+ <% end %>
+
+ <% if is_teacher%>
+ <% comment_status = activity.homework_detail_manual.comment_status %>
+
+
+
+
+
+ <%= link_to l(:button_edit),Setting.protocol + "://" + Setting.host_name + "/homework_common/" + activity.id.to_s + "/edit?", :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") %>
+
+
+ <%= 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) %>
+
+ <% if activity.anonymous_comment == 0 %>
+
+ <%= 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%>
+
+
+ <%= homework_anonymous_comment activity,-1,user_activity_id,course_activity %>
+
+ <% end %>
+ <% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
+
+ <%= 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)%>
+
+ <% end %>
+ <% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
+
+ <%= 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)%>
+
+ <% elsif activity.is_open == 1 %>
+
+ <%= 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)%>
+
+ <% end %>
+
+
+
+
+ <% end%>
+
+
+
+
+ <% count=activity.journals_for_messages.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.user == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.journals_for_messages.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_url_in_org(comment.user_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:user).try(:realname) == ' ' %>
+ <%= link_to comment.try(:user), user_url_in_org(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:user).try(:realname), user_url_in_org(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => activity.id},:method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
+ <%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %>
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/organizations/_org_course_message.html.erb b/app/views/organizations/_org_course_message.html.erb
index 4f13e1b4f..9a9943e9b 100644
--- a/app/views/organizations/_org_course_message.html.erb
+++ b/app/views/organizations/_org_course_message.html.erb
@@ -1,159 +1,159 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% end %>
- TO
- <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%>
-
-
- <% if activity.parent_id.nil? %>
- <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
- <% else %>
- <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%>
- <% end %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
- <% if activity.locked%>
-
- <% end%>
-
-
- 发帖时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
-
-
- <% if activity.parent_id.nil? %>
- <% content = activity.content%>
- <% else %>
- <% content = activity.parent.content%>
- <% end %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
-
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
-
- <% count=0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#=format_date(activity.updated_on)%>
- <%if count > 3 %>
-
- <% end %>
-
-
- <% activity= activity.parent ? activity.parent : activity%>
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.children.reorder("created_on desc").each do |reply|%>
-
- <% replies_all_i=replies_all_i+1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.author == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
- <%= reply.content.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
- <% if !activity.locked? && authorize_for_course('messages', 'reply') %>
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
- <% end %>
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %>
+ TO
+ <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_url_in_org(activity.course.id), :class => "newsBlue ml15 mr5"%>
+
+
+ <% if activity.parent_id.nil? %>
+ <%= link_to activity.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :class=> "postGrey" %>
+ <% else %>
+ <%= link_to activity.parent.subject.to_s.html_safe, board_message_url_in_org(activity.board_id, activity.id), :class=> "postGrey"%>
+ <% end %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+ <% if activity.locked%>
+
+ <% end%>
+
+
+ 发帖时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <% if activity.parent_id.nil? %>
+ <% content = activity.content%>
+ <% else %>
+ <% content = activity.parent.content%>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+
+ <% count=0 %>
+ <% if activity.parent %>
+ <% count=activity.parent.children.count%>
+ <% else %>
+ <% count=activity.children.count%>
+ <% end %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#=format_date(activity.updated_on)%>
+ <%if count > 3 %>
+
+ <% end %>
+
+
+ <% activity= activity.parent ? activity.parent : activity%>
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |reply|%>
+
+ <% replies_all_i=replies_all_i+1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_url_in_org(reply.author_id), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_url_in_org(reply.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.author == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+ <%= reply.content.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !activity.locked? && authorize_for_course('messages', 'reply') %>
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%>
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+ <% end %>
+
+
diff --git a/app/views/organizations/_org_course_news.html.erb b/app/views/organizations/_org_course_news.html.erb
index 665f5c1ae..7f50b3725 100644
--- a/app/views/organizations/_org_course_news.html.erb
+++ b/app/views/organizations/_org_course_news.html.erb
@@ -1,20 +1,20 @@
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_url_in_org(activity.author_id), :alt => "用户头像" %>
<%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
<% if @ctivity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <%= link_to activity.try(:author), user_url_in_org(activity.author_id), :class => "newsBlue mr15" %>
<% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(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
- <%= 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" %>
- <%= 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" %>
<% if activity.sticky == 1%>
置顶
@@ -74,14 +74,14 @@
<% replies_all_i = replies_all_i + 1 %>
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
+ <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_url_in_org(comment.author_id), :alt => "用户头像" %>
<% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <%= link_to comment.try(:author), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
<% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <%= link_to comment.try(:author).try(:realname), user_url_in_org(comment.author_id), :class => "newsBlue mr10 f14" %>
<% end %>
<%= format_time(comment.created_on) %>
-<% else %>
- 温馨提示:<%= l(:label_repository_no_data) %>
<% end %>
diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb
index a58aeb281..f2b6cadeb 100644
--- a/app/views/projects/show.html.erb
+++ b/app/views/projects/show.html.erb
@@ -18,7 +18,7 @@
<%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %>
<%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %>
-
+ <%= link_to "资源库动态", {:controller => "projects", :action => "show", :type => "attachment"}, :class => "homepagePostTypeResource resourcesGrey" %>
<%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %>
diff --git a/app/views/repositories/_navigation.html.erb b/app/views/repositories/_navigation.html.erb
index c3e154f17..d99df5ed1 100644
--- a/app/views/repositories/_navigation.html.erb
+++ b/app/views/repositories/_navigation.html.erb
@@ -18,7 +18,7 @@
<% if !@repository.branches.nil? && @repository.branches.length > 0 -%>
<%= l(:label_branch) %>:
- <%= select_tag :branch, options_for_select([''] + @repository.branches, @rev), :id => 'branch' %>
+ <%= select_tag :branch, options_for_select(@repository.branches, @rev), :id => 'branch' %>
<% end -%>
<% if !@repository.tags.nil? && @repository.tags.length > 0 -%>
diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb
index 76d5745df..750a3c6ec 100644
--- a/app/views/repositories/show.html.erb
+++ b/app/views/repositories/show.html.erb
@@ -1,81 +1,81 @@
-<%= call_hook(:view_repositories_show_contextual, {:repository => @repository, :project => @project}) %>
-
-
<%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
-
-
- <% if @entries.nil? %>
- <%# 未提交代码提示 %>
-
- <% if @entries.nil? && authorize_for('repositories', 'browse') %>
-
- 该版本库还没有上传代码!
-
- <% end %>
- <% if @repository.type.to_s=="Repository::Gitlab" %>
- 版本库地址:<%= @repos_url %>
- <% else %>
- 版本库地址:<%= h @repository.url %>
- <% end %>
-
-
-
- <% else %>
- <%= render :partial => 'navigation' %>
-
克隆网址:
-
-
-
- <%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %>
- <% if User.current.id != @project.user_id %>
-
<%= link_to " ".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn", :confirm=>"平台将为您创建一个新的同名项目和版本库,请问是否继续?" %>
- <%= @project.forked_count.to_i %>
-
- <% end %>
-
-
- <% if @changesets && !@changesets.empty? %>
- <% if !user_commit_rep(@changesets_latest_coimmit.author_email).nil? %>
- <%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
-
<%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %>
- 提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
- <%= @changesets_latest_coimmit.message %>
-
- <% else %>
-
<%=@changesets_latest_coimmit.author_email %>
- 提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
- <%= @changesets_latest_coimmit.message %>
-
- <%end%>
- <% end %>
-
- <%= @repository.branches.count %> 个分支
-
-
-
- <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> 提交
-
-
-
- <% end %>
-
-
-
-<% if !@entries.nil? && authorize_for('repositories', 'browse') %>
- <%# 数据统计 %>
- <%#= render :partial => 'summary' %>
- <%# end %>
- <%= render :partial => 'dir_list' %>
-<% end %>
-<%#= render_properties(@properties) %>
-
-
-<%#= render_properties(@properties) %>
-
-
-
如何提交代码
-
-<% content_for :header_tags do %>
- <%= stylesheet_link_tag "scm" %>
-<% end %>
-
-<% html_title(l(:label_repository)) -%>
+<%= call_hook(:view_repositories_show_contextual, {:repository => @repository, :project => @project}) %>
+
+
<%= render :partial => 'breadcrumbs', :locals => {:path => @path, :kind => 'dir', :revision => @rev} %>
+
+
+ <% if @entries.nil? %>
+ <%# 未提交代码提示 %>
+
+ <% if @entries.nil? && authorize_for('repositories', 'browse') %>
+
+ 该版本库还没有上传代码!
+
+ <% end %>
+ <% if @repository.type.to_s=="Repository::Gitlab" %>
+ 版本库地址:<%= @repos_url %>
+ <% else %>
+ 版本库地址:<%= h @repository.url %>
+ <% end %>
+
+
+
+ <% else %>
+ <%= render :partial => 'navigation' %>
+
克隆网址:
+
+
+
+ <%# 针对公开项目:用户必须创建了项目,否则用户无法同步 %>
+ <% if User.current.id != @project.user_id %>
+
<%= link_to " ".html_safe+"Fork", {:controller => 'repositories', :action => 'forked'}, :class=>"vl_btn", :target => "_blank", :confirm=>"平台将为您创建一个新的同名项目和版本库,请问是否继续?" %>
+ <%= @project.forked_count.to_i %>
+
+ <% end %>
+
+
+ <% if @changesets && !@changesets.empty? %>
+ <% if !user_commit_rep(@changesets_latest_coimmit.author_email).nil? %>
+ <%= image_tag(url_to_avatar(user_commit_rep(@changesets_latest_coimmit.author_email)), :width => "25", :height => "25", :class => "fl portraitRadius mt2 ml4 mr5") %>
+
<%=link_to user_commit_rep(@changesets_latest_coimmit.author_email), user_path(user_commit_rep(@changesets_latest_coimmit.author_email)) %>
+ 提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
+ <%= @changesets_latest_coimmit.message %>
+
+ <% else %>
+
<%=@changesets_latest_coimmit.author_email %>
+ 提交于<%= time_tag(@changesets_latest_coimmit.created_at) %>:
+ <%= @changesets_latest_coimmit.message %>
+
+ <%end%>
+ <% end %>
+
+ <%= @repository.branches.count %> 个分支
+
+
+
+ <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> 提交
+
+
+
+ <% end %>
+
+
+
+<% if !@entries.nil? && authorize_for('repositories', 'browse') %>
+ <%# 数据统计 %>
+ <%#= render :partial => 'summary' %>
+ <%# end %>
+ <%= render :partial => 'dir_list' %>
+<% end %>
+<%#= render_properties(@properties) %>
+
+
+<%#= render_properties(@properties) %>
+
+
+
如何提交代码
+
+<% content_for :header_tags do %>
+ <%= stylesheet_link_tag "scm" %>
+<% end %>
+
+<% html_title(l(:label_repository)) -%>
diff --git a/app/views/student_work/_evaluation_un_title.html.erb b/app/views/student_work/_evaluation_un_title.html.erb
index 66b96431e..aee833b70 100644
--- a/app/views/student_work/_evaluation_un_title.html.erb
+++ b/app/views/student_work/_evaluation_un_title.html.erb
@@ -2,8 +2,16 @@
作品名称
<% if @homework.homework_type != 3 %>
- 姓名
- 学号
+
+ <%= link_to "姓名",@show_all ? student_work_index_path(:homework => @homework.id,:order => "lastname", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl" ,:remote => true%>
+ <% if @show_all && @order == "lastname"%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "lastname", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt10" ,:remote => true%>
+ <% end%>
+
+ <%= link_to "学号",@show_all ? student_work_index_path(:homework => @homework.id,:order => "student_id", :sort => @score, :name => @name, :group => @group) : "javascript:void(0)",:class => "c_dark f14 fb fl ml50" ,:remote => true%>
+ <% if @show_all && @order == "student_id"%>
+ <%= link_to "", student_work_index_path(:homework => @homework.id,:order => "student_id", :sort => @score, :name => @name, :group => @group) ,:class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt10" ,:remote => true%>
+ <% end%>
<% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
关联项目
<% end %>
diff --git a/app/views/student_work/_evaluation_un_work.html.erb b/app/views/student_work/_evaluation_un_work.html.erb
index bf022f64c..884bb8eb1 100644
--- a/app/views/student_work/_evaluation_un_work.html.erb
+++ b/app/views/student_work/_evaluation_un_work.html.erb
@@ -1,102 +1,102 @@
-
-
-
-
-
- <%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40"),user_activities_path(student_work.user)) %>
-
-
-
- <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
-
- <%= link_to student_work_name,"javascript:void(0)" ,:title => student_work_name, :class => "linkGrey f14 StudentName break_word #{@homework.homework_type == 2 ? '' : 'width165'}"%>
-
-
-
- <% if @homework.homework_type != 3 %>
-
-
- <%= student_work.user.show_name%>
-
-
- <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
-
-
- <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
-
-
- <%= student_work.project.name %>
-
-
- <% end %>
-
-
-
-
-
- <% if student_work.created_at && @homework.end_time%>
- <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>
- <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %>
- [迟交]
- <% end %>
- <% end %>
-
-
- <%= student_work.teacher_score.nil? ? "--" : format("%.1f",student_work.teacher_score)%>
-
-
- <%= student_work.teaching_asistant_score.nil? ? "--" : format("%.1f",student_work.teaching_asistant_score)%>
-
-
- <% if @homework.homework_type == 2%>
-
-
- <%= student_work.system_score.nil? ? "--" : format("%.1f",student_work.system_score)%>
-
- <% end%>
-
- <% if @homework.anonymous_comment == 0%>
-
- <%= student_work.student_score.nil? ? "未参与" : format("%.1f",student_work.student_score)%>
- <% unless student_work.student_score.nil?%>
-
- (<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>)
-
-
- 现共有
- <%= student_work.student_works_scores.where(:reviewer_role => 3).count%>
- 名学生进行了匿评,平均分为
- <%= format("%.1f",student_work.student_score)%> 分。
-
- <% end%>
-
- <% end %>
-
- <% score = student_work.respond_to?("score") ? student_work.score : (student_work.final_score || 0) - student_work.absence_penalty - student_work.late_penalty%>
-
- <%= score.nil? ? "--" : format("%.1f",score<0 ? 0 : score)%>
- <% unless score.nil?%>
-
- 作品最终评分为
- <%= student_work.final_score%> 分。
- 迟交扣分
- <%= student_work.late_penalty%> 分,
- 缺评扣分
- <%= student_work.absence_penalty%> 分,
- 最终成绩为
- <%= format("%.1f",score<0 ? 0 : score)%> 分。
-
- <% end%>
-
- 点击查看详情
-
-
-
+
+
+
+
+
+ <%= link_to(image_tag(url_to_avatar(student_work.user),:width =>"40",:height => "40"),user_activities_path(student_work.user)) %>
+
+
+
+ <% student_work_name = student_work.name.nil? || student_work.name.empty? ? student_work.user.show_name + '的作品' : student_work.name%>
+
+ <%= link_to student_work_name,"javascript:void(0)" ,:title => student_work_name, :class => "linkGrey f14 StudentName break_word #{@homework.homework_type == 2 ? '' : 'width165'}"%>
+
+
+
+ <% if @homework.homework_type != 3 %>
+
+
+ <%= student_work.user.show_name%>
+
+ ">
+ <%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
+
+
+ <% elsif @homework.homework_type == 3 && @homework.homework_detail_group.base_on_project == 1 %>
+
+
+ <%= student_work.project.name %>
+
+
+ <% end %>
+
+
+
+
+
+ <% if student_work.created_at && @homework.end_time%>
+ <%= Time.parse(format_time(student_work.created_at)).strftime("%m-%d %H:%M")%>
+ <% if Time.parse(@homework.end_time.to_s).strftime("%Y-%m-%d") < Time.parse(format_time(student_work.created_at)).strftime("%Y-%m-%d") %>
+ [迟交]
+ <% end %>
+ <% end %>
+
+
+ <%= student_work.teacher_score.nil? ? "--" : format("%.1f",student_work.teacher_score)%>
+
+
+ <%= student_work.teaching_asistant_score.nil? ? "--" : format("%.1f",student_work.teaching_asistant_score)%>
+
+
+ <% if @homework.homework_type == 2%>
+
+
+ <%= student_work.system_score.nil? ? "--" : format("%.1f",student_work.system_score)%>
+
+ <% end%>
+
+ <% if @homework.anonymous_comment == 0%>
+
+ <%= student_work.student_score.nil? ? "未参与" : format("%.1f",student_work.student_score)%>
+ <% unless student_work.student_score.nil?%>
+
+ (<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>)
+
+
+ 现共有
+ <%= student_work.student_works_scores.where(:reviewer_role => 3).count%>
+ 名学生进行了匿评,平均分为
+ <%= format("%.1f",student_work.student_score)%> 分。
+
+ <% end%>
+
+ <% end %>
+
+ <% score = student_work.respond_to?("score") ? student_work.score : (student_work.final_score || 0) - student_work.absence_penalty - student_work.late_penalty%>
+
+ <%= score.nil? ? "--" : format("%.1f",score<0 ? 0 : score)%>
+ <% unless score.nil?%>
+
+ 作品最终评分为
+ <%= student_work.final_score%> 分。
+ 迟交扣分
+ <%= student_work.late_penalty%> 分,
+ 缺评扣分
+ <%= student_work.absence_penalty%> 分,
+ 最终成绩为
+ <%= format("%.1f",score<0 ? 0 : score)%> 分。
+
+ <% end%>
+
+ 点击查看详情
+
+
+
diff --git a/app/views/student_work/_evaluation_work.html.erb b/app/views/student_work/_evaluation_work.html.erb
index cc346361e..f97a8dd2d 100644
--- a/app/views/student_work/_evaluation_work.html.erb
+++ b/app/views/student_work/_evaluation_work.html.erb
@@ -21,10 +21,10 @@
<% if @homework.homework_type != 3 %>
-
+
<%= student_work.user.show_name%>
-
+ ">
<%= student_work.user.user_extensions.nil? ? "--" : student_work.user.user_extensions.student_id%>
diff --git a/app/views/student_work/_programing_work_show.html.erb b/app/views/student_work/_programing_work_show.html.erb
index d6977325c..20d6df9ba 100644
--- a/app/views/student_work/_programing_work_show.html.erb
+++ b/app/views/student_work/_programing_work_show.html.erb
@@ -25,7 +25,7 @@
编程代码:
- <%= work.description if work.description%>
+
<%= work.description if work.description%>
diff --git a/app/views/student_work/_show.html.erb b/app/views/student_work/_show.html.erb
index d66a30718..67c04d71f 100644
--- a/app/views/student_work/_show.html.erb
+++ b/app/views/student_work/_show.html.erb
@@ -59,8 +59,8 @@
内容:
-
- <%= text_format(work.description) if work.description%>
+
+ <%= work.description.html_safe if work.description%>
@@ -105,6 +105,9 @@
+ -->
+
+
@@ -66,7 +73,7 @@
<% end %>
-
确定
+
确定
或
<%= link_to "取消", student_work_index_path(:homework => @homework), :class => "fr mr10 mt3"%>
@@ -96,23 +103,130 @@
}
function popupRegex(){
- if(regexStudentWorkName()&®exStudentWorkDescription())
- {
- if($("#group_member_ids").length > 0) {
- if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
- $('#ajax-modal').html("
");
- 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 {
+ if($("#group_member_ids").length > 0) {
+ if(regexStudentWorkMember(parseInt($.trim($("#min_num_member").html())),parseInt($.trim($("#max_num_member").html())))) {
$('#ajax-modal').html("
");
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("
");
+ 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);
+ }
+ });
+ });
\ No newline at end of file
diff --git a/app/views/student_work/index.html.erb b/app/views/student_work/index.html.erb
index 41ec2b61b..8e7d87302 100644
--- a/app/views/student_work/index.html.erb
+++ b/app/views/student_work/index.html.erb
@@ -172,7 +172,7 @@
<% if @homework.homework_detail_manual && @homework.homework_detail_manual.comment_status < 2 %>
提交截止时间:<%= @homework.end_time %> 23:59
- <% 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 %>
匿评截止时间:<%= @homework.homework_detail_manual.evaluation_end %> 23:59
<% end %>
<% if @homework.homework_detail_manual.comment_status == 0 %>
diff --git a/app/views/student_work/new.html.erb b/app/views/student_work/new.html.erb
index 99c317314..a7e223ac1 100644
--- a/app/views/student_work/new.html.erb
+++ b/app/views/student_work/new.html.erb
@@ -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 %>
+
-
+
<%= form_for(@student_work,
:html => { :multipart => true },
:url => {:controller => 'student_work',
@@ -127,18 +249,21 @@
<%=hidden_field_tag 'group_member_ids', params[:group_member_ids], :value=>User.current.id %>
<% end %>
- <%= 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();" %>
- <%= f.text_area "description", :class => "InputBox W700 H150", :placeholder => "请介绍你的作品", :onkeyup => "regexStudentWorkDescription();"%>
-
+ -->
+
+
@@ -167,9 +292,9 @@
-->
-
提交
+
提交
或
- <%= 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"%>
<% end%>
diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb
index 477f06e0f..135da3c0d 100644
--- a/app/views/student_work/show.js.erb
+++ b/app/views/student_work/show.js.erb
@@ -17,7 +17,7 @@ else{
program_name = 'text/x-java';
}
- var editor = CodeMirror(document.getElementById("work-code"), {
+ var editor = CodeMirror(document.getElementById("work-code_<%= @work.id%>"), {
mode: {name: program_name,
version: 2,
singleLineStringErrors: false},
@@ -25,7 +25,7 @@ else{
indentUnit: 2,
matchBrackets: true,
readOnly: true,
- value: $("#work-src").text()
+ value: $("#work-src_<%= @work.id%>").text()
}
);
diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb
index b43951c08..ee49e3cfc 100644
--- a/app/views/users/_course_homework.html.erb
+++ b/app/views/users/_course_homework.html.erb
@@ -47,7 +47,7 @@
<% end%>
<% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1%>
-
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
+
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"linkBlue",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
<% elsif activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 0%>
系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!
<% end %>
@@ -89,7 +89,7 @@
<% end %>
<% if activity.homework_detail_manual && activity.homework_detail_manual.comment_status < 2 %>
提交截止时间:<%= activity.end_time.to_s %> 23:59
- <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 %>
+ <% elsif activity.homework_detail_manual && activity.homework_detail_manual.comment_status >= 2 && activity.anonymous_comment == 0%>
匿评截止时间:<%= activity.homework_detail_manual.evaluation_end.to_s %> 23:59
<% end %>
@@ -128,7 +128,7 @@
<% if activity.student_works.count != 0 %>
<% sw = activity.student_works.reorder("created_at desc").first %>
-
+
# <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
<% end %>
@@ -138,30 +138,46 @@
<% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
<% unless student_work_scores.empty? %>
<% last_score = student_work_scores.first %>
-
+
# <%=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"%>评阅了作品,优秀排行:
- <% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
- <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
- <% student_works.each_with_index do |sw, i| %>
-
- <% if i == 4 %>
- <% break %>
- <% end %>
- <% end %>
- <% if student_works.count > 5 %>
- <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%>
- <% end %>
-
<% end %>
+
+ <% if activity.homework_type != 2 %>
+ <% ids = student_work_scores.empty? ? "(-1)" : '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
+ <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
+ <% else %>
+ <% student_works = activity.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").order("score desc") %>
+ <% end %>
+ <% student_works.each_with_index do |sw, i| %>
+
+ <% if i == 4 %>
+ <% break %>
+ <% end %>
+ <% end %>
+ <% if student_works.count > 5 %>
+ <%= link_to "更多>>", student_work_index_path(:homework => activity.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%>
+ <% end %>
+
+
<% end %>
<% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %>
@@ -238,7 +254,8 @@
<% end %>
<% if activity.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
- <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink", :remote => true)%>
+ <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(activity,:user_activity_id => user_activity_id,:course_activity=>course_activity),:class => "postOptionLink",
+ :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%>
<% end %>
<% if (activity.anonymous_comment == 1 && activity.is_open == 0) || (activity.anonymous_comment == 0 && comment_status == 3 && activity.is_open == 0) %>
@@ -339,7 +356,7 @@
<%= hidden_field_tag 'course_activity',params[:course_activity],:value =>course_activity %>
-
发送
+
发送
<% end%>
diff --git a/app/views/users/_course_journalsformessage.html.erb b/app/views/users/_course_journalsformessage.html.erb
index 6b28fb568..f9a59f024 100644
--- a/app/views/users/_course_journalsformessage.html.erb
+++ b/app/views/users/_course_journalsformessage.html.erb
@@ -1,110 +1,110 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
-
-
-
- <% if activity.try(:user).try(:realname) == ' ' %>
- <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <% course=Course.find(activity.jour_id) %>
- <%= link_to course.name.to_s+" | 课程留言", course_feedback_path(course), :class => "newsBlue ml15" %>
-
-
- <% if activity.parent %>
- <%= link_to activity.parent.notes.html_safe, course_feedback_path(course), :class => "postGrey" %>
- <% else %>
- <%= link_to activity.notes.html_safe, course_feedback_path(course), :class => "postGrey" %>
- <% end %>
-
-
- 留言时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
-
-
-
-
-
- <% count = fetch_user_leaveWord_reply(activity).count %>
-
-
-
-
- 回复(<%= count %>)
-
-
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% fetch_user_leaveWord_reply(activity).each do |comment| unless fetch_user_leaveWord_reply(activity).nil? %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
- <% end %>
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id}, :method => "post", :remote => true) do |f|%>
- <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %>
- <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
- <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
- <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
- <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
+
+
+
+ <% if activity.try(:user).try(:realname) == ' ' %>
+ <%= link_to activity.try(:user), user_path(activity.user_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:user).try(:realname), user_path(activity.user_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <% course=Course.find(activity.jour_id) %>
+ <%= link_to course.name.to_s+" | 课程留言", course_feedback_path(course), :class => "newsBlue ml15" %>
+
+
+ <% if activity.parent %>
+ <%= link_to activity.parent.notes.html_safe, course_feedback_path(course), :class => "postGrey" %>
+ <% else %>
+ <%= link_to activity.notes.html_safe, course_feedback_path(course), :class => "postGrey" %>
+ <% end %>
+
+
+ 留言时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+
+
+
+
+
+ <% count = fetch_user_leaveWord_reply(activity).count %>
+
+
+
+
+ 回复(<%= count %>)
+
+
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% fetch_user_leaveWord_reply(activity).each do |comment| unless fetch_user_leaveWord_reply(activity).nil? %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:user).try(:realname) == ' ' %>
+ <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+ <% end %>
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id}, :method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %>
+ <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
+ <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
+ <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
+ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
+
diff --git a/app/views/users/_course_message.html.erb b/app/views/users/_course_message.html.erb
index 7e8a24bb2..aed741ce5 100644
--- a/app/views/users/_course_message.html.erb
+++ b/app/views/users/_course_message.html.erb
@@ -1,194 +1,178 @@
-
-
-
- <% if activity.status == 1 %>
- <%= image_tag("/images/trustie_logo1.png", width: "50px", height: "50px") %>
- <% else %>
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
- <% end %>
-
-
-
- <% if activity.status == 1 %>
- 确实团队
- <% else %>
- <% if activity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
- <% end %>
- <% end %>
- TO
- <%= link_to activity.course.name.to_s+" | 课程讨论区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%>
-
-
- <% if activity.parent_id.nil? %>
- <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
- <% else %>
- <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%>
- <% end %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
- <% if activity.locked%>
-
- <% end%>
-
-
- 发帖时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
-
-
- <% if activity.parent_id.nil? %>
- <% content = activity.content%>
- <% else %>
- <% content = activity.parent.content%>
- <% end %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
- <% if activity.status == 1 %>
-
<%= activity.created_on.year %>
-
年
-
<%= activity.created_on.month %>
-
月
-
<%= activity.created_on.day %>
-
日
- <% end %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
-
-
- <% if activity.author.id == User.current.id%>
-
- <%= link_to(
- l(:button_edit),
- edit_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
- :class => 'postOptionLink'
- ) if activity.course_editable_by?(User.current) %>
-
-
- <%= link_to(
- l(:button_delete),
- delete_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
- :method => :post,
- :data => {:confirm => l(:text_are_you_sure)},
- :class => 'postOptionLink'
- ) if activity.course_destroyable_by?(User.current) %>
-
- <% end %>
- <%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %>
-
-
-
-
-
-
-
-
- <% count=0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#=format_date(activity.updated_on)%>
- <%if count > 3 %>
-
- <% end %>
-
-
- <% activity= activity.parent ? activity.parent : activity%>
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.children.reorder("created_on desc").each do |reply|%>
-
- <% replies_all_i=replies_all_i+1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.author == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
-
- <%= reply.content.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
- <% if !activity.locked? && authorize_for_course('messages', 'reply') %>
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => is_board,is_course=>is_course},:method => "post", :remote => true) do |f|%>
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
- <% end %>
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id,:host=>Setting.host_user), :class => "newsBlue mr15" %>
+ <% end %>
+ TO
+ <%= link_to activity.course.name.to_s+" | 课程问答区", course_boards_path(activity.course,:host=> Setting.host_course), :class => "newsBlue ml15 mr5"%>
+
+
+ <% if activity.parent_id.nil? %>
+ <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey" %>
+ <% else %>
+ <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board_id, activity), :class=> "postGrey"%>
+ <% end %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+ <% if activity.locked%>
+
+ <% end%>
+
+
+ 发帖时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <% if activity.parent_id.nil? %>
+ <% content = activity.content%>
+ <% else %>
+ <% content = activity.parent.content%>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+
+
+ <% if activity.author.id == User.current.id%>
+
+ <%= link_to(
+ l(:button_edit),
+ edit_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
+ :class => 'postOptionLink'
+ ) if activity.course_editable_by?(User.current) %>
+
+
+ <%= link_to(
+ l(:button_delete),
+ delete_board_message_path(activity.id,:board_id=>activity.board_id,:is_course=>is_course,:is_board=>is_board),
+ :method => :post,
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if activity.course_destroyable_by?(User.current) %>
+
+ <% end %>
+ <%= link_to "发送", "javascript:void(0);", :onclick => "show_send(#{activity.id}, #{User.current.id}, 'message');", :class => "postOptionLink" %>
+
+
+
+
+
+
+
+
+ <% count=0 %>
+ <% if activity.parent %>
+ <% count=activity.parent.children.count%>
+ <% else %>
+ <% count=activity.children.count%>
+ <% end %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#=format_date(activity.updated_on)%>
+ <%if count > 3 %>
+
+ <% end %>
+
+
+ <% activity= activity.parent ? activity.parent : activity%>
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |reply|%>
+
+ <% replies_all_i=replies_all_i+1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id,:host=>Setting.host_user), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:author).try(:realname) == ' ' %>
+ <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.author == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+
+ <%= reply.content.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if !activity.locked? && authorize_for_course('messages', 'reply') %>
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => is_board,is_course=>is_course},:method => "post", :remote => true) do |f|%>
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+ <% end %>
+
+
+
diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb
index 15dd486ec..efaa72beb 100644
--- a/app/views/users/_course_news.html.erb
+++ b/app/views/users/_course_news.html.erb
@@ -1,148 +1,148 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if @ctivity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
-
-
- <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
-
-
- 发布时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
-
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% if User.current.logged? %>
-
- <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
-
- <%= link_to(
- l(:button_edit),
- {controller:'news', :action => 'edit', :id => activity.id},
- :class => 'postOptionLink'
- ) if User.current.allowed_to?(:manage_news, activity.course) %>
-
-
- <%= delete_link(
- news_path(activity),
- :data => {:confirm => l(:text_are_you_sure)},
- :class => 'postOptionLink'
- ) if User.current.allowed_to?(:manage_news, activity.course) %>
-
-
- <% end %>
-
-
-
-
-
-
- <% count=activity.comments.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.comments.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if @ctivity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <%= link_to activity.course.name.to_s+" | 课程通知", course_news_index_path(activity.course), :class => "newsBlue ml15" %>
+
+
+ <%= link_to activity.title.to_s, news_path(activity), :class => "postGrey" %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(CourseActivity.where("course_act_type='#{activity.class}' and course_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% if User.current.logged? %>
+
+ <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
+
+ <%= link_to(
+ l(:button_edit),
+ {controller:'news', :action => 'edit', :id => activity.id},
+ :class => 'postOptionLink'
+ ) if User.current.allowed_to?(:manage_news, activity.course) %>
+
+
+ <%= delete_link(
+ news_path(activity),
+ :data => {:confirm => l(:text_are_you_sure)},
+ :class => 'postOptionLink'
+ ) if User.current.allowed_to?(:manage_news, activity.course) %>
+
+
+ <% end %>
+
+
+
+
+
+
+ <% count=activity.comments.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.comments.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:author).try(:realname) == ' ' %>
+ <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%>
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
diff --git a/app/views/users/_homework_detail_information.html.erb b/app/views/users/_homework_detail_information.html.erb
index d650cd084..1829fa61c 100644
--- a/app/views/users/_homework_detail_information.html.erb
+++ b/app/views/users/_homework_detail_information.html.erb
@@ -1,31 +1,41 @@
-
题目信息
-
- <% if homework.nil? %>
-
请先在左侧选择作业
- <% else %>
-
标题:<%=homework.name %>
- 来源:<%=homework.course.name %>
- <% if homework.homework_type == 2 && homework.homework_detail_programing %>
- 编程语言:<%=homework.language_name %>
- <% end %>
- 贡献者:<%=homework.user.show_name %>
- <% if homework.user.user_extensions.occupation && homework.user.user_extensions.occupation!="" %>
- ,<%=homework.user.user_extensions.occupation%>
- <% end %>
-
- 描述如下:
-
-
- <%=homework.description.html_safe %>
-
- <% if homework.homework_type == 2 %>
-
- 测试集:<%=homework.homework_tests.count %>组
-
- <% elsif homework.homework_type ==3 && homework.homework_detail_group %>
-
- 分组人数:<%=homework.homework_detail_group.min_num %> - <%=homework.homework_detail_group.max_num %>人
-
- <% end %>
- <% end %>
+
题目信息
+
+ <% if homework.nil? %>
+
本题库遵循创作共用许可证
+
+教师给学生出题本质上是一种创作行为,题目的作者通常为此付出大量时间和精力。好的题目不仅能加深学生对知识点的理解,还能激发学生兴趣,提升学习效率。为此,本网站的题库许可证基于创作共用许可证( Creative Commons License )建立,其核心条款包括:
+
+1. 署名:必须提到原作者。
+
+2. 非商业用途:不得用于盈利性目的。
+
+3. 相同方式共享:允许修改原作品,但必须使用相同的许可证发布。
+
+对此许可证的支持或反对,请在网站中留言,我们不断完善,谢谢!
+ <% else %>
+
标题:<%=homework.name %>
+ 来源:<%=homework.course.name %>
+ <% if homework.homework_type == 2 && homework.homework_detail_programing %>
+ 编程语言:<%=homework.language_name %>
+ <% end %>
+ 贡献者:<%=homework.user.show_name %>
+ <% if homework.user.user_extensions.occupation && homework.user.user_extensions.occupation!="" %>
+ ,<%=homework.user.user_extensions.occupation%>
+ <% end %>
+
+ 描述如下:
+
+
+ <%=homework.description.html_safe %>
+
+ <% if homework.homework_type == 2 %>
+
+ 测试集:<%=homework.homework_tests.count %>组
+
+ <% elsif homework.homework_type ==3 && homework.homework_detail_group %>
+
+ 分组人数:<%=homework.homework_detail_group.min_num %> - <%=homework.homework_detail_group.max_num %>人
+
+ <% end %>
+ <% end %>
\ No newline at end of file
diff --git a/app/views/users/_homework_post_notice.html.erb b/app/views/users/_homework_post_notice.html.erb
new file mode 100644
index 000000000..d67fa44ae
--- /dev/null
+++ b/app/views/users/_homework_post_notice.html.erb
@@ -0,0 +1,12 @@
+
+
+
+ 题目已发送到目标课程的作业列表,但需要您设置发布和截止时间,以激活相应作业,谢谢!
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_homework_repository.html.erb b/app/views/users/_homework_repository.html.erb
new file mode 100644
index 000000000..a30e21a3f
--- /dev/null
+++ b/app/views/users/_homework_repository.html.erb
@@ -0,0 +1,39 @@
+
+
+
+ <% homeworks.each do |homework| %>
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_homework_repository_detail.html.erb b/app/views/users/_homework_repository_detail.html.erb
new file mode 100644
index 000000000..efbf24955
--- /dev/null
+++ b/app/views/users/_homework_repository_detail.html.erb
@@ -0,0 +1,44 @@
+
+
题目信息
+
+ <% if homework.nil? %>
+
本题库遵循创作共用许可证
+
+教师给学生出题本质上是一种创作行为,题目的作者通常为此付出大量时间和精力。好的题目不仅能加深学生对知识点的理解,还能激发学生兴趣,提升学习效率。为此,本网站的题库许可证基于创作共用许可证( Creative Commons License )建立,其核心条款包括:
+
+1. 署名:必须提到原作者。
+
+2. 非商业用途:不得用于盈利性目的。
+
+3. 相同方式共享:允许修改原作品,但必须使用相同的许可证发布。
+
+对此许可证的支持或反对,请在网站中留言,我们不断完善,谢谢!
+
+ <% else %>
+
标题:<%=homework.name %>
+ 来源:<%=homework.course.name %>
+ <% if homework.homework_type == 2 && homework.homework_detail_programing %>
+ 编程语言:<%=homework.language_name %>
+ <% end %>
+ 贡献者:<%=homework.user.show_name %>
+ <% if homework.user.user_extensions.occupation && homework.user.user_extensions.occupation!="" %>
+ ,<%=homework.user.user_extensions.occupation%>
+ <% end %>
+
+ 描述如下:
+
+
+ <%=homework.description.html_safe %>
+
+ <% if homework.homework_type == 2 %>
+
+ 测试集:<%=homework.homework_tests.count %>组
+
+ <% elsif homework.homework_type ==3 && homework.homework_detail_group %>
+
+ 分组人数:<%=homework.homework_detail_group.min_num %> - <%=homework.homework_detail_group.max_num %>人
+
+ <% end %>
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/users/_homework_repository_list.html.erb b/app/views/users/_homework_repository_list.html.erb
new file mode 100644
index 000000000..678bf65d7
--- /dev/null
+++ b/app/views/users/_homework_repository_list.html.erb
@@ -0,0 +1,36 @@
+
+ 作业名称
+
+ <%= link_to "来源",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "course_name", :sort => @r_sort),:class => "fl ml55",:remote => true%>
+ <% if @order == "course_name"%>
+ <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "course_name", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%>
+ <% end%>
+
+
+ <%= link_to "类别",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "homework_type", :sort => @r_sort),:class => "fl ml10",:remote => true%>
+ <% if @order == "homework_type"%>
+ <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "homework_type", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%>
+ <% end%>
+
+
+ <%= link_to "贡献者",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "user_name", :sort => @r_sort),:class => "fl ml20",:remote => true%>
+ <% if @order == "user_name"%>
+ <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "user_name", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%>
+ <% end%>
+
+
+ <%= link_to "引用数",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort),:class => "fl ml5",:remote => true%>
+ <% if @order == "quotes"%>
+ <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "quotes", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%>
+ <% end%>
+
+
+ <%= link_to "发布时间",user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "publish_time", :sort => @r_sort),:class => "fl",:remote => true%>
+ <% if @order == "publish_time"%>
+ <%= link_to "", user_search_homeworks_user_path(@user,:name=>search,:type => type,:is_import=>is_import,:property=>property,:order => "publish_time", :sort => @r_sort),:class => "#{@r_sort == 'desc' ? 'st_up' : 'st_down'} mt12 fl" ,:remote => true%>
+ <% end%>
+
+
+
+ <%=render :partial => 'homework_repository', :locals => {:homeworks => homeworks} %>
+
\ No newline at end of file
diff --git a/app/views/users/_homework_repository_search.html.erb b/app/views/users/_homework_repository_search.html.erb
new file mode 100644
index 000000000..dfbaacd05
--- /dev/null
+++ b/app/views/users/_homework_repository_search.html.erb
@@ -0,0 +1,29 @@
+
+
\ No newline at end of file
diff --git a/app/views/users/_homework_search_input.html.erb b/app/views/users/_homework_search_input.html.erb
index ba85f0d09..31d7602d4 100644
--- a/app/views/users/_homework_search_input.html.erb
+++ b/app/views/users/_homework_search_input.html.erb
@@ -1,29 +1,29 @@
-
-
\ No newline at end of file
diff --git a/app/views/users/_import_resource_info.html.erb b/app/views/users/_import_resource_info.html.erb
new file mode 100644
index 000000000..0a9d92b5c
--- /dev/null
+++ b/app/views/users/_import_resource_info.html.erb
@@ -0,0 +1,63 @@
+
+
选用资源库中的资源
+
+ <% if !params[:course_id].nil? %>
+
公共资源
+
我的资源
+ <% elsif !params[:project_id].nil? %>
+
公共资源
+
我的资源
+ <% elsif !params[:subfield_file_id].nil? %>
+
公共资源
+
我的资源
+ <% end %>
+
+ <%=render :partial=>'users/user_import_resource_search', :locals => {:type => @type, :search => '', :mul_id => @resource_id, :mul_type => @resource_type} %>
+
+
+
+
+
+
+
+
+
+
+
+ 资源名称
+ 类别
+ 大小
+ 上传者
+ 上传时间
+
+
+ <%= render :partial => 'users/user_import_resource_list',:locals => {:project_id => params[:project_id], :subfield_file_id => params[:subfield_file_id], :course_id => params[:course_id]} %>
+
+
+
+
+
+
+
+
+
+
diff --git a/app/views/users/_project_attachment.html.erb b/app/views/users/_project_attachment.html.erb
index b98356c7b..deb0cb4c6 100644
--- a/app/views/users/_project_attachment.html.erb
+++ b/app/views/users/_project_attachment.html.erb
@@ -1,18 +1,32 @@
+
+
-
+
-
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
-
-
-
-
-
截止时间:2015-08-20
+
+ <% if activity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %>
+ TO
+ <%= link_to activity.project.name.to_s+" | 项目资源", project_files_path(activity.course), :class => "newsBlue ml15" %>
-
(作业描述)系统中有多个ckeditor,且每个ckeditor的id未知,怎么样做到当光标聚焦某个ckeditor的文本框中,该编辑器的默认值应自动消失的处理;网络拓扑图开发;
-
+
+ <%= link_to activity.filename, project_files_path(activity.course), :class => "postGrey" %>
+
+
+
+ 文件大小:
+ <%= number_to_human_size activity.filesize%>
+
+
上传时间:<%= format_time(activity.created_on) %>
+
+
diff --git a/app/views/users/_project_issue.html.erb b/app/views/users/_project_issue.html.erb
index 1ce03da17..5d472497d 100644
--- a/app/views/users/_project_issue.html.erb
+++ b/app/views/users/_project_issue.html.erb
@@ -13,6 +13,29 @@
<% end %> TO
<%= link_to activity.project.name.to_s+" | 项目问题", project_issues_path(activity.project), :class => "newsBlue ml15"%>
+
+
+
+
+
+ <%= link_to l(:button_edit), issue_path(activity.id, :edit => 'true'), :class => 'postOptionLink', :accesskey => accesskey(:edit) if activity.editable? && User.current.allowed_to?(:edit_issues, activity.project) %>
+
+
+ <% if !defined?(project_id) && !defined?(user_id) %>
+ <%= link_to l(:button_delete), issue_path(activity.id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %>
+ <% elsif defined?(project_id) %>
+ <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "project_page", :page_id => project_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %>
+ <% elsif defined?(user_id) %>
+ <%= link_to l(:button_delete), issue_path(activity.id, :page_classify => "user_page", :page_id => user_id), :data => {:confirm => issues_destroy_confirmation_message(activity)}, :method => :delete, :class => 'postOptionLink' if User.current.allowed_to?(:delete_issues, activity.project) %>
+ <% end %>
+
+
+ <%= link_to l(:button_copy), project_copy_issue_path(activity.project, activity), :class => 'postOptionLink' if User.current.allowed_to?(:add_issues, activity.project) %>
+
+
+
+
+
<% case activity.tracker_id %>
<% when 1%>
@@ -51,6 +74,10 @@
<%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.description} %>
+
+
+
+
<%# 局部刷新:修改xissue属性 %>
<% if User.current.member_of?(activity.project) %>
<% unless params[:action] == "index" %>
@@ -59,10 +86,7 @@
<% end %>
<% end %>
-
-
-
-
+
<%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
diff --git a/app/views/users/_project_issue_reply.html.erb b/app/views/users/_project_issue_reply.html.erb
index adebd74ad..16d681dc9 100644
--- a/app/views/users/_project_issue_reply.html.erb
+++ b/app/views/users/_project_issue_reply.html.erb
@@ -1,89 +1,89 @@
-<% count = activity.journals.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <% if count > 3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.journals.reorder("created_on desc").each do |reply| %>
-
- <% replies_all_i=replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %>
-
-
-
- <% if reply.try(:user).try(:realname) == ' ' %>
- <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(reply.created_on) %>
-
- <% if reply.user == User.current %>
- 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
- <% end %>
-
-
-
- <% if reply.details.any? %>
- <% details_to_strings(reply.details).each do |string| %>
-
<%= string %>
- <% end %>
- <% end %>
-
<%= reply.notes.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => add_journal_issue_path(activity.id, :user_activity_id => user_activity_id),:method => "post", :remote => true) do |f| %>
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
+<% count = activity.journals.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <% if count > 3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.journals.reorder("created_on desc").each do |reply| %>
+
+ <% replies_all_i=replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %>
+
+
+
+ <% if reply.try(:user).try(:realname) == ' ' %>
+ <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(reply.created_on) %>
+
+ <% if reply.user == User.current %>
+ 赞 <%= get_praise_num(reply) > 0 ? "(#{get_praise_num(reply)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>reply, :user_activity_id=>reply.id,:type=>"reply"}%>
+ <% end %>
+
+
+
+ <% if reply.details.any? %>
+ <% details_to_strings(reply.details).each do |string| %>
+
<%= string %>
+ <% end %>
+ <% end %>
+
<%= reply.notes.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => add_journal_issue_path(activity.id, :user_activity_id => user_activity_id),:method => "post", :remote => true) do |f| %>
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb
index 30183c4d1..dd2c832cf 100644
--- a/app/views/users/_project_message.html.erb
+++ b/app/views/users/_project_message.html.erb
@@ -154,7 +154,7 @@
-
发送
+
发送
<% end%>
diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb
index 9e02c4cf4..7f5d185e5 100644
--- a/app/views/users/_project_news.html.erb
+++ b/app/views/users/_project_news.html.erb
@@ -132,7 +132,7 @@
-
发送
+
发送
<% end%>
diff --git a/app/views/users/_resource_search_form.html.erb b/app/views/users/_resource_search_form.html.erb
index c629f9f32..9e42f9c96 100644
--- a/app/views/users/_resource_search_form.html.erb
+++ b/app/views/users/_resource_search_form.html.erb
@@ -1,7 +1,7 @@
-<%= form_tag( url_for(:controller => 'users',:action => 'resource_search',:id=>user.id),
- :remote=>true ,:method => 'get',:class=>'resourcesSearchloadBox',:id=>'resource_search_form') do %>
-
- <%= hidden_field_tag(:type,type.nil? ? 1 : type) %>
- <%= submit_tag '',:class=>'homepageSearchIcon',:onfocus=>'this.blur();',:style=>'border-style:none' %>
-
+<%= form_tag( url_for(:controller => 'users', :action => 'resource_search', :id => user.id),
+ :remote => true , :method => 'get', :class => 'resourcesSearchloadBox mt10', :id => 'resource_search_form') do %>
+
+ <%= hidden_field_tag(:type,type.nil? ? 1 : type) %>
+ <%= submit_tag '', :class => 'homepageSearchIcon', :onfocus => 'this.blur();', :style => 'border-style:none' %>
+
<% end %>
\ No newline at end of file
diff --git a/app/views/users/_resources_list.html.erb b/app/views/users/_resources_list.html.erb
index a0a1377f1..a545038f1 100644
--- a/app/views/users/_resources_list.html.erb
+++ b/app/views/users/_resources_list.html.erb
@@ -1,27 +1,374 @@
-
-<% if attachments.nil? || attachments.empty? %>
-
-
-
-<% else %>
- <% attachments.each do |attach| %>
-
-
-
- <% end %>
-<% end %>
+<% if attachments.nil? || attachments.empty? %>
+
+
+
+<% else %>
+ <% attachments.each do |attach| %>
+
+
+ <% end %>
+<% end %>
+
+
diff --git a/app/views/users/_send_homework_to_course.html.erb b/app/views/users/_send_homework_to_course.html.erb
new file mode 100644
index 000000000..b19fbd1a8
--- /dev/null
+++ b/app/views/users/_send_homework_to_course.html.erb
@@ -0,0 +1,79 @@
+
+
+
+
+
+
+
+ <%= form_tag send_homework_to_course_user_path(user),:remote=>true,:id=>'choose_course_list_form' %>
+
+ <%= hidden_field_tag(:send_id, send_id) %>
+
+ <% if !courses.empty? %>
+ <% courses.each do |course| %>
+
+ <% end %>
+
+
+
+
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/users/_show_detail_info.html.erb b/app/views/users/_show_detail_info.html.erb
index 9de431336..7d4919149 100644
--- a/app/views/users/_show_detail_info.html.erb
+++ b/app/views/users/_show_detail_info.html.erb
@@ -1,6 +1,6 @@
- <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_path(user), :alt => "用户头像", :target => '_blank' %>
+ <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_url_in_org(user.id), :alt => "用户头像", :target => '_blank' %>
<%#= image_tag(url_to_avatar(user), :width => "50", :height => "50") %>
@@ -21,18 +21,18 @@
-
<%= link_to User.watched_by(user.id).count, {:controller=>"users", :action=>"user_watchlist",:id=>user.id}, :class => 'homepageImageNumber',:target => "_blank" %>
-
<%= link_to '关注',{:controller=>"users", :action=>"user_watchlist",:id=>user.id},:target => "_blank" %>
+
<%= link_to User.watched_by(user.id).count, user_watchlist_url_in_org(user.id), :class => 'homepageImageNumber',:target => "_blank" %>
+
<%= link_to '关注',user_watchlist_url_in_org(user.id),:target => "_blank" %>
-
<%= link_to user.watcher_users.count,{:controller=>"users", :action=>"user_fanslist",:id=>user.id}, :class => "homepageImageNumber fans_count_#{user.id}",:target => "_blank" %>
-
<%= link_to '粉丝', {:controller=>"users", :action=>"user_fanslist",:id=>user.id},:target => "_blank" %>
+
<%= link_to user.watcher_users.count,user_fanslist_url_in_org(user.id), :class => "homepageImageNumber fans_count_#{user.id}",:target => "_blank" %>
+
<%= link_to '粉丝', user_fanslist_url_in_org(user.id),:target => "_blank" %>
-
<%= link_to user.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count, user_blogs_path(user), :class => 'homepageImageNumber',:target => "_blank" %>
-
<%= link_to '博客', user_blogs_path(user),:target => "_blank" %>
+
<%= link_to user.blog.blog_comments.where("#{BlogComment.table_name}.parent_id is null").count, user_blogs_url_in_org(user.id), :class => 'homepageImageNumber',:target => "_blank" %>
+
<%= link_to '博客', user_blogs_url_in_org(user.id),:target => "_blank" %>
<% if User.current != user %>
@@ -40,8 +40,8 @@
<%= render :partial => 'users/watch_btn_for_picture', :locals => {:user => user} %>
- <%= link_to "留言", feedback_path(user), :class => 'greyBtn fr', :target => "_blank" %>
- <%= link_to "私信", feedback_path(user), :class => 'greyBtn fr', :style => 'margin-right:20px;', :target => "_blank" %>
+ <%= link_to "留言", feedback_url_in_org(user.id), :class => 'greyBtn fr', :target => "_blank" %>
+ <%= link_to "私信", feedback_url_in_org(user.id), :class => 'greyBtn fr', :style => 'margin-right:20px;', :target => "_blank" %>
<% end %>
diff --git a/app/views/users/_show_user_homework_form.html.erb b/app/views/users/_show_user_homework_form.html.erb
index 004c8fec4..be9a5bf13 100644
--- a/app/views/users/_show_user_homework_form.html.erb
+++ b/app/views/users/_show_user_homework_form.html.erb
@@ -1,12 +1,13 @@
<% homeworks.each do |homework| %>
-
-
-
+
<% end %>
+
+
选用题库中的题目
+
+
公共题库
+
我的题库
+
+ <%=render :partial=>'homework_search_input', :locals=>{:type => @type,:is_import => 1} %>
+
+
+
+
+ 作业名称
+ 来源
+ 类别
+ 贡献者
+ 引用数
+ 发布时间
+
+
+ <%= form_tag(user_select_homework_users_path, :multipart => true,:remote => true,:name=>"select_homework_form",:id=>'select_homework_form') do %>
+
+
+ <%= render :partial => 'users/show_user_homework_form', :locals => {:homeworks => @homeworks}%>
+
+ <% end %>
+
+
+
+
+ <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
+
+
+
+
+
+ <%=render :partial=>'homework_detail_information', :locals=>{:homework=>nil} %>
+
+
+
+
diff --git a/app/views/users/_upload_resource.html.erb b/app/views/users/_upload_resource.html.erb
index c973217f6..1e691c3b7 100644
--- a/app/views/users/_upload_resource.html.erb
+++ b/app/views/users/_upload_resource.html.erb
@@ -1,54 +1,54 @@
-
- 上传资源
-
-
- <%= form_tag(user_resource_create_user_path, :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %>
-
-
- <% if defined?(container) && container && container.saved_attachments %>
-
- <% container.attachments.each_with_index do |attachment, i| %>
-
- <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
- <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
- <%= l(:field_is_public)%>:
- <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'remove-upload')%>
- <%= if attachment.id.nil?
- #待补充代码
- else
- link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
- end
- %>
- <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
-
- <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
-
- <% end %>
- <% end %>
-
-
-
-
-
- <%= render :partial => 'attachment_list' %>
-
-
-
-
-
-
-
(未选择文件)
-
您可以上传小于50MB 的文件
-
-
-
-
-
-
- <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %>
-
-
-
- <% end %>
-
+
+ 上传资源
+
+
+ <%= form_tag(user_resource_create_user_path(:type=>type,:status=>status), :multipart => true,:remote => !ie8?,:name=>"upload_form",:id=>'upload_form') do %>
+
+
+ <% if defined?(container) && container && container.saved_attachments %>
+
+ <% container.attachments.each_with_index do |attachment, i| %>
+
+ <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly=>'readonly')%>
+ <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style=>"display: inline-block;") %>
+ <%= l(:field_is_public)%>:
+ <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public,attachment.is_public == 1 ? true : false,:class => 'remove-upload')%>
+ <%= if attachment.id.nil?
+ #待补充代码
+ else
+ link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload')
+ end
+ %>
+ <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %>
+
+ <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %>
+
+ <% end %>
+ <% end %>
+
+
+
+
+
+ <%= render :partial => 'attachment_list' %>
+
+
+
+
+
+
+
(未选择文件)
+
您可以上传小于50MB 的文件
+
+
+
+
+
+
+ <%= submit_tag '确定',:onclick=>'submit_files();',:onfocus=>'this.blur()',:id=>'upload_files_submit_btn',:class=>'sendSourceText' %>
+
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb
index 0e55c246c..eb73f9226 100644
--- a/app/views/users/_user_activities.html.erb
+++ b/app/views/users/_user_activities.html.erb
@@ -9,19 +9,6 @@
$("#relateProject,.relatePInfo").mouseout(function(){
$(".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(){
$(this).css("color","#ffffff");
})
@@ -89,7 +76,7 @@
<% if act %>
<% case user_activity.act_type.to_s %>
<% when 'Issue' %>
- <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
+ <%= render :partial => 'project_issue', :locals => {:activity => act,:user_activity_id =>user_activity.id, :user_id => user_id} %>
<% when 'Message' %>
<%= render :partial => 'project_message', :locals => {:activity => act,:user_activity_id =>user_activity.id,:is_course=>0,:is_board=>0} %>
<% when 'ProjectCreateInfo'%>
diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb
index f174e8513..089171c3d 100644
--- a/app/views/users/_user_at_message.html.erb
+++ b/app/views/users/_user_at_message.html.erb
@@ -1,21 +1,33 @@
-<% if AtMessage === ma && ma.at_valid? %>
-
- <%=link_to image_tag(url_to_avatar(ma.author), :width => "30", :height => "30"),user_path(ma.author) %>
-
- <%= ma.author.login %> 提到了你:
-
-
- <%= link_to ma.subject.html_safe, ma.url,
- :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
-
-
标题: <%= ma.subject %>
- <% unless ma.description.nil? %>
-
内容:
-
<%= ma.description.html_safe %>
- <% end %>
-
- <%= time_tag(ma.created_at).html_safe %>
-
+<% if AtMessage === ma && ma.at_valid? %>
+
+ <%=link_to image_tag(url_to_avatar(ma.author), :width => "30", :height => "30"),user_path(ma.author) %>
+
+ <%= ma.author.login %> 提到了你:
+
+
+ <% if ma.at_message_type == "Message" && !ma.at_message.course.nil? %>
+ <%= link_to ma.subject.html_safe, course_boards_path(ma.at_message.course,
+ :parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id),
+ :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}" %>
+
+
+ <% elsif ma.at_message_type == "Message" && !ma.at_message.project.nil? %>
+ <%= link_to ma.subject.html_safe, project_boards_path(ma.at_message.project,
+ :parent_id => ma.at_message.parent_id ? ma.at_message.parent_id : ma.at_message.id, :topic_id => ma.at_message.id),
+ :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}" %>
+
+
+ <% else %>
+ <%= link_to ma.subject.html_safe, ma.url, :class =>"#{ma.viewed? ? "newsGrey" : "newsBlack"}", :onmouseover =>"message_titile_show($(this),event)", :onmouseout => "message_titile_hide($(this))" %>
+ <% end %>
+
+
+
标题: <%= ma.subject %>
+ <% unless ma.description.nil? %>
+
内容:
+
<%= ma.description.html_safe %>
+ <% end %>
+
+ <%= time_tag(ma.created_at).html_safe %>
+
<% end %>
\ No newline at end of file
diff --git a/app/views/users/_user_blog.html.erb b/app/views/users/_user_blog.html.erb
index 244951dfa..841fd9377 100644
--- a/app/views/users/_user_blog.html.erb
+++ b/app/views/users/_user_blog.html.erb
@@ -1,147 +1,147 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
-
-
-
- <% if @ctivity.try(:author).try(:realname) == ' ' %>
- <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% else %>
- <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
- <% end %> TO
- <%= link_to activity.author.name.to_s+" | 博客", user_blogs_path(:user_id=>activity.author_id), :class => "newsBlue ml15" %>
-
-
-
- <%= link_to activity.title.to_s, user_blog_blog_comment_path(:user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id,:in_act => true), :class => "postGrey" %>
-
- <% if activity.sticky == 1%>
-
置顶
- <% end%>
- <% if activity.locked%>
-
- <% end%>
-
-
-
-
- 发布时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(UserActivity.where("act_type='#{activity.class}' and act_id =#{activity.id}").first.updated_at) %>
-
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.content} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
-
-
-
-
- <% count=activity.children.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.author == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
<%#= format_date(activity.updated_on) %>
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% activity.children.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:author).try(:realname) == ' ' %>
- <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
- <% if activity.locked == false && User.current.logged?%>
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'blog_comments', :action => 'reply', :user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id},:method => "post", :remote => true) do |f|%>
-
-
-
-
-
-
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
- <% end %>
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.author} %>
+
+
+
+ <% if @ctivity.try(:author).try(:realname) == ' ' %>
+ <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% else %>
+ <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %>
+ <% end %> TO
+ <%= link_to activity.author.name.to_s+" | 博客", user_blogs_path(:user_id=>activity.author_id), :class => "newsBlue ml15" %>
+
+
+
+ <%= link_to activity.title.to_s, user_blog_blog_comment_path(:user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id,:in_act => true), :class => "postGrey" %>
+
+ <% if activity.sticky == 1%>
+
置顶
+ <% end%>
+ <% if activity.locked%>
+
+ <% end%>
+
+
+
+
+ 发布时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(UserActivity.where("act_type='#{activity.class}' and act_id =#{activity.id}").first.updated_at) %>
+
+
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>activity.content} %>
+
+
+
+
+
+ <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => activity} %>
+
+
+
+
+ <% count=activity.children.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.author == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% activity.children.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:author).try(:realname) == ' ' %>
+ <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+ <% if activity.locked == false && User.current.logged?%>
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'blog_comments', :action => 'reply', :user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id},:method => "post", :remote => true) do |f|%>
+
+
+
+
+
+
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+ <% end %>
+
+
+
diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb
index 4c980d7fc..a196ee6c0 100644
--- a/app/views/users/_user_homework_detail.html.erb
+++ b/app/views/users/_user_homework_detail.html.erb
@@ -1,365 +1,384 @@
-<% is_teacher = User.current.allowed_to?(:as_teacher,homework_common.course) %>
-
-
-
- <%=link_to image_tag(url_to_avatar(homework_common.user),width:"50px", height: "50px"), user_activities_path(homework_common.user.id)%>
-
-
-
- <%= link_to homework_common.user.show_name, user_activities_path(homework_common.user_id), :class => "newsBlue mr15"%>
- TO
- <%= link_to homework_common.course.name, course_path(homework_common.course_id), :class => "newsBlue ml15"%>
-
-
- <%= link_to homework_common.name,student_work_index_path(:homework => homework_common.id),:class => "postGrey"%>
-
-
- <% if homework_common.homework_detail_manual%>
- <% if homework_common.homework_detail_manual.comment_status == 0 %>
-
未发布
- <% elsif homework_common.homework_detail_manual.comment_status == 1%>
- <% if homework_common.anonymous_comment == 0%>
-
未开启匿评
- <% else %>
-
匿评已禁用
- <% end %>
- <% if Time.parse(homework_common.end_time.to_s).strftime("%Y-%m-%d") >= Time.now.strftime("%Y-%m-%d")%>
-
作品提交中
- <% elsif Time.parse(homework_common.end_time.to_s).strftime("%Y-%m-%d") < Time.now.strftime("%Y-%m-%d") %>
-
作品补交中
- <% end %>
- <% elsif homework_common.homework_detail_manual.comment_status == 2%>
- <% if homework_common.anonymous_comment == 0%>
-
匿评中
- <% else %>
-
匿评已禁用
- <% end %>
-
教师评阅中
- <% elsif homework_common.homework_detail_manual.comment_status == 3%>
- <% if homework_common.anonymous_comment == 0%>
-
匿评已结束
- <% else %>
-
匿评已禁用
- <% end %>
-
教师评阅中
- <% end%>
- <% end%>
-
- <% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1%>
-
系统提示:该作业要求各组长<%=link_to "创建项目", new_project_path(:host=>Setting.host_name),:class=>"c_red",:title=>"新建项目",:style=>"text-decoration:underline;"%>,组成员加入项目,然后由组长关联项目。谢谢配合!
- <% elsif homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 0%>
-
系统提示:该作业要求各组长提交作品,提交作品时请添加组成员。谢谢配合!
- <% end %>
-
- <% if homework_common.homework_type == 3 && !is_teacher && homework_common.homework_detail_group.base_on_project == 1 && User.current.member_of_course?(homework_common.course) %>
- <% projects = cur_user_projects_for_homework homework_common %>
- <% works = cur_user_works_for_homework homework_common %>
- <% if works.nil? && projects.nil? %>
-
- <%=link_to "关联项目",new_student_work_project_student_work_index_path(:homework => homework_common.id,:is_in_course=>is_in_course,:user_activity_id=>-1,:course_activity=>-1),remote: true,:class=> 'c_blue', :title=> '请各组长关联作业项目' %>
- <%#= relate_project(activity,is_teacher,-1,user_activity_id,course_activity) %>
-
- <% elsif works.nil? %>
-
- <%=link_to "取消关联",cancel_relate_project_student_work_index_path(:homework => homework_common.id,:is_in_course=>is_in_course,:user_activity_id=>-1,:course_activity=>-1), :confirm => "您确定要取消关联吗?", remote: true,:class => "c_blue", :title=> '取消关联项目' %>
-
- <% end %>
- <% end %>
-
- <%= user_for_homework_common homework_common,is_teacher %>
-
- <% if homework_common.homework_type == 2 && is_teacher%>
-
- <%= link_to "模拟答题", new_user_commit_homework_users_path(homework_id: homework_common.id, is_test: true), class: 'c_blue test-program-btn', title: '教师可以通过模拟答题设置作业的标准答案' %>
-
- <% end %>
- <% if homework_common.homework_type == 2%>
-
- 语言:
- <%= homework_common.language_name%>
-
- <% end %>
- <% if homework_common.homework_type == 3 && homework_common.homework_detail_group%>
-
- 分组人数:<%=homework_common.homework_detail_group.min_num %>-<%=homework_common.homework_detail_group.max_num %> 人
-
- <% end %>
- <% if homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status < 2 %>
-
提交截止时间:<%= homework_common.end_time.to_s %> 23:59
- <% elsif homework_common.homework_detail_manual && homework_common.homework_detail_manual.comment_status >= 2 %>
-
匿评截止时间:<%= homework_common.homework_detail_manual.evaluation_end.to_s %> 23:59
- <% end %>
- <% if homework_common.homework_detail_manual.comment_status == 0 %>
-
- <%= l(:label_publish_time)%>:<%= homework_common.publish_time%> 00:00
-
- <% end %>
-
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>homework_common.id, :content=>homework_common.description} %>
-
-
-
-
-
- <%= render :partial=>"attachments/activity_attach", :locals=>{:activity => homework_common} %>
-
-
-
- 迟交扣分:<%= homework_common.late_penalty%>分
-
- <% if homework_common.anonymous_comment == 0%>
-
- 匿评开启时间:<%= homework_common.homework_detail_manual.evaluation_start%> 00:00
-
- <% end %>
-
-
-
- <% if homework_common.anonymous_comment == 0 %>
-
- 缺评扣分:<%= homework_common.homework_detail_manual.absence_penalty%>分/作品
-
- <% end %>
- <% if homework_common.anonymous_comment == 0%>
-
- 匿评关闭时间:<%= homework_common.homework_detail_manual.evaluation_end%> 23:59
-
- <% end %>
-
-
- <% if homework_common.student_works.count != 0 %>
- <% sw = homework_common.student_works.reorder("created_at desc").first %>
-
- # <%=time_from_now sw.created_at %><%= link_to sw.user.show_name, user_activities_path(sw.user_id), :class => "newsBlue ml5 mr5"%>提交了作品
-
- <% end %>
-
- <% if homework_common.student_works.count != 0 %>
- <% sw_id = "("+homework_common.student_works.map{|sw| sw.id}.join(",")+")" %>
- <% student_work_scores = StudentWorksScore.find_by_sql("select max(created_at) as created_at, student_work_id, user_id from student_works_scores where student_work_id in #{sw_id} group by student_work_id order by max(created_at) desc") %>
- <%# student_work_scores = StudentWorksScore.where("student_work_id in #{sw_id}").reorder("created_at desc") %>
- <% unless student_work_scores.empty? %>
- <% last_score = student_work_scores.first %>
-
-
# <%=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"%>评阅了作品,优秀排行:
-
- <% ids = '('+student_work_scores.map{|sw|sw.student_work_id}.join(',')+')' %>
- <% student_works = homework_common.student_works.select("student_works.*,IF(final_score is null,null,final_score - absence_penalty - late_penalty) as score").where("student_works.id in #{ids}").order("score desc") %>
- <% student_works.each_with_index do |sw, i| %>
-
- <% if i == 4 %>
- <% break %>
- <% end %>
- <% end %>
- <% if student_works.count > 5%>
- <%= link_to "更多>>", student_work_index_path(:homework => homework_common.id),:class=>'linkGrey2 fl ml50',:style=>'margin-top:60px;'%>
- <% end %>
-
-
- <% end %>
- <% end %>
-
- <% if homework_common.homework_type == 3 && homework_common.homework_detail_group.base_on_project == 1 %>
- <% projects = homework_common.student_work_projects.where("is_leader = 1") %>
- <% unless projects.empty? %>
- <% sort_projects = project_sort_update projects %>
-
-
- # <%=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"%>更新了项目,最近更新:
-
-
- <% sort_projects.each_with_index do |pro, i| %>
- <% project = Project.find pro.project_id %>
-
-
-
- <% 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+"_"+homework_common.id.to_s,:alt =>"项目头像" %>
- <% else %>
- <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+homework_common.id.to_s,:alt =>"项目头像") %>
- <% end %>
- <% com_time = project.project_score.commit_time %>
- <% time=project.updated_on %>
- <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
-
<%=(User.find project.user_id).show_name %> (组长)
-
<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %> <%= project.project_score.changeset_num %>提交
-
- 项目名称:<%=project.name %>
- 创建者:<%=(User.find project.user_id).show_name %>(组长)
- 更新时间:<%=time_from_now time %>
-
-
- <% if i == 9 && projects.count > 10 %>
-
更多>>
- <% end %>
- <% if i > 9 && i == (projects.count - 1) %>
-
收回<<
- <% end %>
- <% end %>
-
- <% end %>
- <% end %>
-
- <% if is_teacher%>
- <% comment_status = homework_common.homework_detail_manual.comment_status%>
-
-
-
-
-
- <%= link_to l(:button_edit),edit_homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1), :class => "postOptionLink"%>
-
-
- <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
-
-
- <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true) %>
-
- <% if homework_common.anonymous_comment == 0 &&(comment_status == 0 || comment_status == 1)%>
-
- <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true)%>
-
- <% end %>
- <% if homework_common.anonymous_comment == 0%>
-
- <%= homework_anonymous_comment(homework_common, is_in_course) %>
-
- <% end %>
- <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
-
- <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink", :remote => true)%>
-
- <% end %>
- <% if (homework_common.anonymous_comment == 1 && homework_common.is_open == 0) || (homework_common.anonymous_comment == 0 && comment_status == 3 && homework_common.is_open == 0) %>
-
- <%= link_to("公开作品", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%>
-
- <% elsif homework_common.is_open == 1 %>
-
- <%= link_to("取消公开", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%>
-
- <% end %>
-
-
-
-
- <% end%>
-
-
-
-
- <% count=homework_common.journals_for_messages.count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if homework_common.user == User.current %>
- 赞 <%= get_praise_num(homework_common) > 0 ? "(#{get_praise_num(homework_common)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>homework_common, :user_activity_id=>homework_common.id,:type=>"activity"}%>
- <% end %>
-
-
-
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% homework_common.journals_for_messages.reorder("created_on desc").each do |comment| %>
-
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => homework_common.id},:method => "post", :remote => true) do |f|%>
- <%= hidden_field_tag 'homework_common_id',params[:homework_common_id],:value =>homework_common.id %>
- <%= hidden_field_tag 'is_in_course',params[:is_in_course],:value =>is_in_course %>
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
-
-
+
+
+ <% 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+"_"+homework_common.id.to_s,:alt =>"项目头像" %>
+ <% else %>
+ <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s+"_"+homework_common.id.to_s,:alt =>"项目头像") %>
+ <% end %>
+ <% com_time = project.project_score.commit_time %>
+ <% time=project.updated_on %>
+ <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>
+
<%=(User.find project.user_id).show_name %> (组长)
+
<%=time_from_now !com_time.nil? && format_time(com_time) > format_time(time) ? com_time : time %> <%= project.project_score.changeset_num %>提交
+
+ 项目名称:<%=project.name %>
+ 创建者:<%=(User.find project.user_id).show_name %>(组长)
+ 更新时间:<%=time_from_now time %>
+
+
+ <% if i == 9 && projects.count > 10 %>
+ 更多>>
+ <% end %>
+ <% if i > 9 && i == (projects.count - 1) %>
+ 收回<<
+ <% end %>
+ <% end %>
+
+ <% end %>
+ <% end %>
+
+ <% if is_teacher%>
+ <% comment_status = homework_common.homework_detail_manual.comment_status%>
+
+
+
+
+
+ <%= link_to l(:button_edit),edit_homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1), :class => "postOptionLink"%>
+
+
+ <%= link_to(l(:label_bid_respond_delete), homework_common_path(homework_common,:is_in_course => is_in_course,:course_activity=>-1),:method => 'delete', :confirm => l(:text_are_you_sure), :class => "postOptionLink") %>
+
+
+ <%= link_to("评分设置", score_rule_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true) %>
+
+ <% if homework_common.anonymous_comment == 0 &&(comment_status == 0 || comment_status == 1)%>
+
+ <%= link_to("匿评设置", start_evaluation_set_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=>-1),:class => "postOptionLink", :remote => true)%>
+
+ <% end %>
+ <% if homework_common.anonymous_comment == 0%>
+
+ <%= homework_anonymous_comment(homework_common, is_in_course) %>
+
+ <% end %>
+ <% if homework_common.anonymous_comment == 0 && (comment_status == 0 || comment_status == 1)%>
+
+ <%= link_to("禁用匿评", alert_forbidden_anonymous_comment_homework_common_path(homework_common,:is_in_course => is_in_course),:class => "postOptionLink",
+ :title => "匿评是同学之间的双盲互评过程:每个同学将评阅系统分配给他/她的若干个作品", :remote => true)%>
+
+ <% end %>
+ <% if (homework_common.anonymous_comment == 1 && homework_common.is_open == 0) || (homework_common.anonymous_comment == 0 && comment_status == 3 && homework_common.is_open == 0) %>
+
+ <%= link_to("公开作品", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%>
+
+ <% elsif homework_common.is_open == 1 %>
+
+ <%= link_to("取消公开", alert_open_student_works_homework_common_path(homework_common, :is_in_course => is_in_course,:course_activity=> -1),:class => "postOptionLink", :remote => true)%>
+
+ <% end %>
+
+
+
+
+ <% end%>
+
+
+
+
+ <% count=homework_common.journals_for_messages.count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if homework_common.user == User.current %>
+ 赞 <%= get_praise_num(homework_common) > 0 ? "(#{get_praise_num(homework_common)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>homework_common, :user_activity_id=>homework_common.id,:type=>"activity"}%>
+ <% end %>
+
+
+
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% homework_common.journals_for_messages.reorder("created_on desc").each do |comment| %>
+
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:user).try(:realname) == ' ' %>
+ <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_homework_message', :id => homework_common.id},:method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'homework_common_id',params[:homework_common_id],:value =>homework_common.id %>
+ <%= hidden_field_tag 'is_in_course',params[:is_in_course],:value =>is_in_course %>
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_user_homework_form.html.erb b/app/views/users/_user_homework_form.html.erb
index 0d542882a..54fe4396b 100644
--- a/app/views/users/_user_homework_form.html.erb
+++ b/app/views/users/_user_homework_form.html.erb
@@ -1,268 +1,272 @@
-<% content_for :header_tags do %>
- <%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
-
- <%= javascript_include_tag 'homework','baiduTemplate' %>
-
-<% end %>
-
-
-
-
-
-
-
- <%= link_to("导入作业", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%>
- <% unless edit_mode %>
-
- <% end %>
- <% if edit_mode %>
-
截止日期:
- <% end %>
-
-
- <% if homework.homework_detail_manual.comment_status.to_i < 3 %>
- <%= calendar_for('homework_end_time')%>
- <% end %>
-
- <% if edit_mode %>
-
发布日期(可选):
- <% end %>
-
-
- <% if homework.homework_detail_manual.comment_status.to_i == 0 %>
- <%= calendar_for('homework_publish_time')%>
- <% end %>
-
- <% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
-
-
- 禁用匿评
-
- <% end %>
-
-
-
-
-
-
- <% if edit_mode %>
-
- <%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %>
- <% else %>
- <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %>
-
- <%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px",at_id: homework.id, at_type: homework.class.to_s %>
- <% end %>
-
-
-
-
- <%= select_tag :course_id, options_for_select(get_as_teacher_courses(User.current), homework.course_id), {:class => "InputBox w709",:value => "请选择发布作业的课程"} %>
-
-
-
-
-
-
- <%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type != 2), :has_group=>(!(edit_mode && homework.homework_type != 3))&& homework.student_works.empty?,:show_member => true} %>
-
-
-
- <% if edit_mode %>
-
确定
-
或
- <%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
-
取消
- <% else %>
-
发送
-
或
-
取消
- <% end %>
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-<% unless edit_mode %>
-
+<% content_for :header_tags do %>
+ <%= import_ke(enable_at: true, prettify: false, init_activity: false) %>
+
+ <%= javascript_include_tag 'homework','baiduTemplate' %>
+
+<% end %>
+
+
+
+
+
+
+
+ <%= link_to("从题库选用", user_import_homeworks_user_path(User.current.id,:select_course => defined?(select_course)),:class => "BlueCirBtn fl mr10",:remote => true,:title=>"导入自己发布过的作业,或者共享题库中的作业") unless edit_mode%>
+ <% unless edit_mode %>
+
+ <% end %>
+ <% if edit_mode %>
+
截止日期:
+ <% end %>
+
+
+ <% if homework.homework_detail_manual.comment_status.to_i < 2 %>
+ <%= calendar_for('homework_end_time')%>
+ <% end %>
+
+ <% if edit_mode %>
+
发布日期(可选):
+ <% end %>
+
+
+ <% if homework.homework_detail_manual.comment_status.to_i == 0 %>
+ <%= calendar_for('homework_publish_time')%>
+ <% end %>
+
+ <% if !edit_mode || edit_mode && homework.homework_detail_manual.comment_status < 2 %>
+
+
+ 禁用匿评
+
+ <% end %>
+
+
+
+
+
+
+ <% if edit_mode %>
+
+ <%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px", :owner_id => homework.id, :owner_type => OwnerTypeHelper::HOMEWORKCOMMON, at_id: homework.id, at_type: homework.class.to_s %>
+ <% else %>
+ <%= hidden_field_tag :asset_id, params[:asset_id], :required => false, :style => 'display:none' %>
+
+ <%#= f.kindeditor :description, :editor_id => 'homework_description_editor', :height => "150px",at_id: homework.id, at_type: homework.class.to_s %>
+ <% end %>
+
+
+
+
+ <%= hidden_field_tag :course_id, params[:course_id], :value =>homework.course_id %>
+
+
+
+
+
+
+
+ <%= render :partial => 'users/user_homework_attachment', :locals => {:container => homework, :has_program=>!(edit_mode && homework.homework_type != 2), :has_group=>(!(edit_mode && homework.homework_type != 3))&& homework.student_works.empty?,:show_member => true} %>
+
+
+
+ <% if edit_mode %>
+
确定
+
或
+ <%#= link_to "取消",user_homeworks_user_path(User.current.id),:class => "fr mr10 mt3"%>
+
取消
+ <% else %>
+
发送
+
或
+
取消
+ <% end %>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<% unless edit_mode %>
+
<% end %>
\ No newline at end of file
diff --git a/app/views/users/_user_homework_list.html.erb b/app/views/users/_user_homework_list.html.erb
index 34e975762..e42c5d8b2 100644
--- a/app/views/users/_user_homework_list.html.erb
+++ b/app/views/users/_user_homework_list.html.erb
@@ -1,40 +1,40 @@
-<%= content_for(:header_tags) do %>
- <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
-<% end %>
-
-
-<% homework_commons.each do |homework_common|%>
-
- <%= render :partial => 'users/user_homework_detail', :locals => {:homework_common => homework_common,:is_in_course => is_in_course} %>
-<% end%>
-<% if homework_commons.count == 10%>
- <% if is_in_course == 1%>
-
- <%= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
- <% else%>
-
- <%= link_to "点击展开更多",user_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
- <% end%>
-<% end%>
-
+<%= content_for(:header_tags) do %>
+ <%= import_ke(enable_at: true, prettify: false, init_activity: true) %>
+<% end %>
+
+
+<% homework_commons.each do |homework_common|%>
+
+ <%= render :partial => 'users/user_homework_detail', :locals => {:homework_common => homework_common,:is_in_course => is_in_course} %>
+<% end%>
+<% if homework_commons.count == 10%>
+ <% if is_in_course == 1%>
+
+ <%= link_to "点击展开更多",homework_common_index_path(:course => course_id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
+ <% else%>
+
+ <%= link_to "点击展开更多",student_homeworks_user_path(User.current.id,:page => page,:is_in_course => is_in_course),:id => "user_show_more_homework",:remote => "true",:class => "loadMore f_grey"%>
+ <% end%>
+<% end%>
+
diff --git a/app/views/users/_user_homeworks_old.html.erb b/app/views/users/_user_homeworks_old.html.erb
new file mode 100644
index 000000000..59ec24ad3
--- /dev/null
+++ b/app/views/users/_user_homeworks_old.html.erb
@@ -0,0 +1,47 @@
+
+
+
+
+<% if @is_teacher%>
+
+
+ <% homework = HomeworkCommon.new %>
+ <% homework.homework_detail_manual = HomeworkDetailManual.new%>
+ <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %>
+
+ <%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %>
+
+ <% end%>
+
+<% end%>
+
+<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0,:is_in_course => 0} %>
diff --git a/app/views/users/_user_import_resource_list.html.erb b/app/views/users/_user_import_resource_list.html.erb
new file mode 100644
index 000000000..f48e6c8fb
--- /dev/null
+++ b/app/views/users/_user_import_resource_list.html.erb
@@ -0,0 +1,19 @@
+<%= form_tag( url_for({:controller => 'users', :action => 'import_into_container',
+ :mul_id => @resource_id,
+ :mul_type => @resource_type}),
+ :method => 'post', :id => 'resource_import_container_form') do %>
+ <% @attachments.each do |attach| %>
+
+ <% end %>
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/_user_import_resource_search.html.erb b/app/views/users/_user_import_resource_search.html.erb
new file mode 100644
index 000000000..fc86ec26e
--- /dev/null
+++ b/app/views/users/_user_import_resource_search.html.erb
@@ -0,0 +1,29 @@
+
+
\ No newline at end of file
diff --git a/app/views/users/_user_journalsformessage.html.erb b/app/views/users/_user_journalsformessage.html.erb
index f49a65262..dde4f34ce 100644
--- a/app/views/users/_user_journalsformessage.html.erb
+++ b/app/views/users/_user_journalsformessage.html.erb
@@ -1,152 +1,152 @@
-
-
-
- <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
- <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
-
-
-
- <%= link_to activity.user.show_name, user_path(activity.user_id), :class => "newsBlue mr15" %>
- TO
- <% if activity.jour %>
- <%= link_to activity.jour.show_name+"("+(activity.jour.login ? activity.jour.login : activity.jour.show_name ).to_s+")的"+ (activity.private == 1? "私信":"留言"),
- feedback_path(activity.jour, :host=> Setting.host_user), :class => "newsBlue ml15" %>
- <% if activity.private == 1 %>
- 私信
- <% end %>
- <% end %>
-
- <% if is_activity.to_i == 1 %>
-
- <% if activity.parent %>
- <%= link_to activity.parent.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
- <% else %>
- <%= link_to activity.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
- <% end %>
-
- <% else %>
- <% if activity.parent %>
- <% content = activity.parent.notes %>
- <% else %>
- <% content = activity.notes %>
- <% end %>
- <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
- <% end %>
-
- 留言时间:<%= format_time(activity.created_on) %>
-
-
- 更新时间:<%= format_time(PrincipalActivity.where("principal_act_type='#{activity.class}' and principal_act_id =#{activity.id}").first.updated_at) %>
-
-
- <% if activity.user == User.current || User.current.admin?%>
-
-
-
-
-
- <%= link_to(l(:label_bid_respond_delete),
- {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id,:is_activity=>is_activity},
- :confirm => l(:text_are_you_sure), :method => 'delete',
- :class => "postOptionLink", :title => l(:button_delete)) %>
-
-
-
-
-
- <% end%>
-
-
-
- <% count=fetch_user_leaveWord_reply(activity).count %>
-
-
-
回复
- <%= count>0 ? "(#{count})" : "" %> ▪
-
- <% if activity.user == User.current %>
- 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
- <% else %>
- <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
- <% end %>
-
-
-
- <%if count>3 %>
-
- <% end %>
-
-
- <% replies_all_i = 0 %>
- <% if count > 0 %>
-
-
- <% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %>
- <% replies_all_i = replies_all_i + 1 %>
-
-
- <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
-
-
-
- <% if comment.try(:user).try(:realname) == ' ' %>
- <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
- <% end %>
- <%= format_time(comment.created_on) %>
-
-
-
-
- <%= comment.notes.html_safe %>
-
-
-
-
- <% end %>
-
-
- <% end %>
-
-
-
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
-
-
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id},:method => "post", :remote => true) do |f|%>
- <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %>
- <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
- <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
- <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
- <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
- <%= hidden_field_tag 'is_activity',params[:is_activity],:value =>is_activity %>
-
-
-
发送
-
-
- <% end%>
-
-
-
-
-
-
+
+
+
+ <%= link_to image_tag(url_to_avatar(activity.user), :width => "50", :height => "50"), user_path(activity.user_id), :alt => "用户头像" %>
+ <%= render :partial => 'users/show_detail_info', :locals => {:user => activity.user} %>
+
+
+
+ <%= link_to activity.user.show_name, user_path(activity.user_id), :class => "newsBlue mr15" %>
+ TO
+ <% if activity.jour %>
+ <%= link_to activity.jour.show_name+"("+(activity.jour.login ? activity.jour.login : activity.jour.show_name ).to_s+")的"+ (activity.private == 1? "私信":"留言"),
+ feedback_path(activity.jour, :host=> Setting.host_user), :class => "newsBlue ml15" %>
+ <% if activity.private == 1 %>
+ 私信
+ <% end %>
+ <% end %>
+
+ <% if is_activity.to_i == 1 %>
+
+ <% if activity.parent %>
+ <%= link_to activity.parent.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
+ <% else %>
+ <%= link_to activity.notes.html_safe, feedback_path(activity.jour, :host=> Setting.host_user), :class => "postGrey" %>
+ <% end %>
+
+ <% else %>
+ <% if activity.parent %>
+ <% content = activity.parent.notes %>
+ <% else %>
+ <% content = activity.notes %>
+ <% end %>
+ <%=render :partial =>"users/intro_content", :locals=>{:user_activity_id =>user_activity_id, :content=>content} %>
+ <% end %>
+
+ 留言时间:<%= format_time(activity.created_on) %>
+
+
+ 更新时间:<%= format_time(PrincipalActivity.where("principal_act_type='#{activity.class}' and principal_act_id =#{activity.id}").first.updated_at) %>
+
+
+ <% if activity.user == User.current || User.current.admin?%>
+
+
+
+
+
+ <%= link_to(l(:label_bid_respond_delete),
+ {:controller => 'words', :action => 'destroy', :object_id => activity, :user_id => activity.user,:user_activity_id => user_activity_id,:is_activity=>is_activity},
+ :confirm => l(:text_are_you_sure), :method => 'delete',
+ :class => "postOptionLink", :title => l(:button_delete)) %>
+
+
+
+
+
+ <% end%>
+
+
+
+ <% count=fetch_user_leaveWord_reply(activity).count %>
+
+
+
回复
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <% if activity.user == User.current %>
+ 赞 <%= get_praise_num(activity) > 0 ? "(#{get_praise_num(activity)})" : "" %>
+ <% else %>
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+ <% end %>
+
+
+
+ <%if count>3 %>
+
+ <% end %>
+
+
+ <% replies_all_i = 0 %>
+ <% if count > 0 %>
+
+
+ <% fetch_user_leaveWord_reply(activity).reorder("created_on desc").each do |comment| %>
+ <% replies_all_i = replies_all_i + 1 %>
+
+
+ <%= link_to image_tag(url_to_avatar(comment.user), :width => "33", :height => "33", :class =>"mt8"), user_path(comment.user_id), :alt => "用户头像" %>
+
+
+
+ <% if comment.try(:user).try(:realname) == ' ' %>
+ <%= link_to comment.try(:user), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% else %>
+ <%= link_to comment.try(:user).try(:realname), user_path(comment.user_id), :class => "newsBlue mr10 f14" %>
+ <% end %>
+ <%= format_time(comment.created_on) %>
+
+
+
+
+ <%= comment.notes.html_safe %>
+
+
+
+
+ <% end %>
+
+
+ <% end %>
+
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), :alt => "用户头像" %>
+
+
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => activity.id},:method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'reference_id', params[:reference_id], :value => activity.id %>
+ <%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => activity.user.id %>
+ <%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => activity.id %>
+ <%= hidden_field_tag 'show_name',params[:show_name],:value =>true %>
+ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>user_activity_id %>
+ <%= hidden_field_tag 'is_activity',params[:is_activity],:value =>is_activity %>
+
+
+
发送
+
+
+ <% end%>
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_user_message_course.html.erb b/app/views/users/_user_message_course.html.erb
index 9f7b90ee4..7de1ce417 100644
--- a/app/views/users/_user_message_course.html.erb
+++ b/app/views/users/_user_message_course.html.erb
@@ -5,9 +5,10 @@
<%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">发布了通知:
<%= link_to ma.course_message.title, {:controller => 'news', :action => 'show', :id => ma.course_message.id },
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
标题: <%= ma.course_message.title %>
<% unless ma.course_message.description.nil? %>
@@ -24,9 +25,10 @@
<%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">评论了通知:
<%= link_to ma.course_message.commented.title, {:controller => 'news', :action => 'show', :id => ma.course_message.commented.id },
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
评论对象: <%= ma.course_message.commented.title %>
<% unless ma.course_message.comments.nil? %>
@@ -46,14 +48,14 @@
<% if !User.current.allowed_to?(:as_teacher, ma.course_message.course) && cur_user_works_for_homework(ma.course_message).nil? %>
<%= link_to "作业标题:" + ma.course_message.name, new_student_work_path(:homework => ma.course_message.id),
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
<% else %>
<%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
- :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
<% end %>
@@ -104,9 +106,9 @@
">发布的作业:
<%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
- :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
<% if !User.current.allowed_to?(:as_teacher,ma.course_message.course) %>
@@ -173,9 +175,9 @@
<%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>
">关闭了作业匿评:
- <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))"%>
+ <%= link_to "作业标题:" + ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
@@ -208,9 +210,9 @@
">启动作业匿评失败
- <%= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因:提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to truncate(ma.course_message.name,:length=>25)+'(失败原因:提交作品的人数低于2人)', student_work_index_path(:homework => ma.course_message.id), :class => "#{ma.viewed == 0 ? "c_red" : "newsGrey "}" %>
+
+
@@ -234,9 +236,10 @@
<%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %>">发布了问卷:
<%= link_to format_activity_title(" #{ma.course_message.polls_name.nil? ? "未命名问卷" : ma.course_message.polls_name}"), poll_path(ma.course_message.id),
- :class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class=>"#{ma.viewed==0?"newsBlack":"newsGrey"}" %>
+
+
+
<%= ma.course_message.polls_name %>
@@ -246,13 +249,16 @@
<% if ma.course_message_type == "Message" %>
<%=link_to image_tag(url_to_avatar(ma.course_message.author), :width => "30", :height => "30"), user_path(ma.course_message.author) %>
- <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>"><%= ma.course_message.parent_id.nil? ? "发布了课程帖子:" : "评论了课程帖子:" %>
+
+ <%=link_to ma.course_message.author, user_path(ma.course_message.author), :class => "newsBlue homepageNewsPublisher" %>">
+ <%= ma.course_message.parent_id.nil? ? "发布了课程帖子:" : "评论了课程帖子:" %>
<% if ma.course_message.parent_id.nil? %>
<%= link_to ma.course_message.subject, course_boards_path(ma.course_message.course, :parent_id => ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id, :topic_id => ma.course_message.id),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
主题: <%= ma.course_message.subject %>
<% unless ma.course_message.content.nil? %>
@@ -263,9 +269,10 @@
<% else %>
<%= link_to ma.course_message.content.html_safe, course_boards_path(ma.course_message.course, :parent_id => ma.course_message.parent_id ? ma.course_message.parent_id : ma.course_message.id, :topic_id => ma.course_message.id),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
主题: <%= ma.course_message.subject %>
<% unless ma.course_message.content.nil? %>
@@ -301,9 +308,10 @@
<% unless ma.content.nil? %>
<%= link_to ma.content.html_safe, student_work_index_path(:homework => ma.course_message.student_work.homework_common_id),
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<%= User.current.show_name %>同学您好!
@@ -339,9 +347,10 @@
<%= link_to ma.course_message.notes.html_safe, course_feedback_path(:id => ma.course_id),
- :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<%= ma.course_message.notes.html_safe %>
@@ -361,9 +370,10 @@
">回复了作品评论:
- <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.course_message.notes, student_work_index_path(:homework => ma.course_message.jour.student_work.homework_common_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
@@ -382,7 +392,7 @@
<% end %>
<% end %>
- <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? %>
+ <% if ma.course_message_type == "StudentWork" && !ma.course_message.homework_common.nil? && !User.current.allowed_to?(:as_teacher, ma.course_message.homework_common.course) %>
<%= link_to image_tag(url_to_avatar(ma.course_message.homework_common.user), :width => "30", :height => "30"), user_path(ma.course_message.homework_common.user) %>
@@ -391,9 +401,10 @@
<%= link_to "作业标题:" + ma.course_message.homework_common.name, student_work_index_path(:homework => ma.course_message.homework_common_id),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
@@ -425,9 +436,10 @@
<%= link_to "课程名称:" + ma.course_message.name, course_path(ma.course_message),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<%= User.current.lastname + User.current.firstname %>老师您好!您成功创建了一个课程,详情如下:
@@ -457,9 +469,10 @@
<%= link_to User.find(ma.course_message_id).name+"申请成为课程\""+"#{Course.find(ma.course_id).name}"+"\"的"+"#{ma.content == '9' ? "教师" : "教辅"}", user_path(User.find(ma.course_message_id), :course_id => ma.course_id),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
@@ -500,9 +513,10 @@
'您申请成为课程"'+Course.find(ma.course_id).name+'"的'+(ma.content == '9' ? '老师' : '教辅')+'申请已通过'
:
'您申请成为课程"'+Course.find(ma.course_id).name+'"的'+(ma.content == '9' ? '老师' : '教辅')+'的申请被拒绝', course_path(Course.find(ma.course_id)),
- :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
@@ -529,9 +543,10 @@
">将您加入了课程:
- <%= link_to ma.course.name, course_member_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.course.name, course_member_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<% if ma.course.is_public? || User.current.member_of_course?(ma.course) || User.current.admin? %>
@@ -562,9 +577,10 @@
">您增加了新的课程成员:
- <%= link_to User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")", user_path(ma.course_message_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to User.find(ma.course_message_id).login+"("+(User.find(ma.course_message_id).realname ? User.find(ma.course_message_id).realname : User.find(ma.course_message_id).login) +")", user_path(ma.course_message_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<% if ma.course.is_public? || User.current.member_of_course?(ma.course) || User.current.admin? %>
@@ -595,9 +611,10 @@
">将您移出了课程:
- <%= link_to ma.course.name, member_course_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.course.name, member_course_path(ma.course), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<% if ma.course.is_public? || User.current.member_of?(ma.course) || User.current.admin? %>
@@ -626,9 +643,9 @@
<%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">发布了课程测验 :
- <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))"%>
+ <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
@@ -663,9 +680,9 @@
<%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + "老师",
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %> ">发布的测验:
- <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))"%>
+ <%= link_to "测验题目:" + ma.course_message.exercise_name, exercise_path(:id => ma.course_message.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
diff --git a/app/views/users/_user_message_forge.html.erb b/app/views/users/_user_message_forge.html.erb
index 967941a88..574411055 100644
--- a/app/views/users/_user_message_forge.html.erb
+++ b/app/views/users/_user_message_forge.html.erb
@@ -10,9 +10,10 @@
">申请加入项目:
- <%= link_to ma.project, settings_project_path(:id => ma.project, :tab => "members"), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.project, settings_project_path(:id => ma.project, :tab => "members"), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<%= ma.project %>
@@ -32,9 +33,10 @@
">将您加入了项目:
- <%= link_to ma.project, project_member_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.project, project_member_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<% if ma.project.is_public? || User.current.member_of?(ma.project) || User.current.admin? %>
@@ -67,9 +69,10 @@
">将您移出了项目:
- <%= link_to ma.project, member_project_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.project, member_project_path(ma.project), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
<% if ma.project.is_public? || User.current.member_of?(ma.project) || User.current.admin? %>
@@ -107,9 +110,9 @@
<% end %>
<%= link_to ma.project, project_path(ma.project),
- :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
<%= ma.project %>
@@ -136,9 +139,10 @@
"><%= ma.forge_message.tracker_id == 5 ? "发布的周报:":"指派给你的问题:"%>
- <%= link_to ma.forge_message.subject, issue_path(:id => ma.forge_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.forge_message.subject, issue_path(:id => ma.forge_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
主题: <%= ma.forge_message.subject %>
@@ -160,9 +164,10 @@
"><%= ma.forge_message.tracker_id == 5 ? "发布了周报:":"指派了问题给你:"%>
- <%= link_to ma.forge_message.subject, issue_path(:id => ma.forge_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.forge_message.subject, issue_path(:id => ma.forge_message.id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
主题: <%= ma.forge_message.subject %>
@@ -187,9 +192,10 @@
<%= link_to ma.forge_message.journalized.subject,
- issue_path(:id => ma.forge_message.journalized_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ issue_path(:id => ma.forge_message.journalized_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
问题标题: <%= ma.forge_message.journalized.subject %>
@@ -208,9 +214,10 @@
<%= link_to ma.forge_message.subject, project_boards_path(ma.forge_message.project,
:parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id,
- :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
主题: <%= ma.forge_message.subject %>
<% unless ma.forge_message.content.nil? %>
@@ -222,9 +229,10 @@
<%= link_to ma.forge_message.subject, project_boards_path(ma.forge_message.project,
:parent_id => ma.forge_message.parent_id ? ma.forge_message.parent_id : ma.forge_message.id,
- :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :topic_id => ma.forge_message.id), :class => "#{ma.viewed==0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
帖子主题: <%= ma.forge_message.subject %>
<% unless ma.forge_message.content.nil? %>
@@ -247,9 +255,10 @@
<%= link_to ("#{ma.forge_message.title.html_safe}"), {:controller => 'news', :action => 'show', :id => ma.forge_message.id},
- :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
标题: <%= ma.forge_message.title %>
@@ -268,9 +277,9 @@
">评论了新闻:
<%= link_to "#{ma.forge_message.commented.title}",
- {:controller => 'news', :action => 'show', :id => ma.forge_message.commented.id },:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover => "message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ {:controller => 'news', :action => 'show', :id => ma.forge_message.commented.id },:class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
新闻标题: <%= ma.forge_message.commented.title %>
diff --git a/app/views/users/_user_message_forum.html.erb b/app/views/users/_user_message_forum.html.erb
index 102b4a155..d18292068 100644
--- a/app/views/users/_user_message_forum.html.erb
+++ b/app/views/users/_user_message_forum.html.erb
@@ -10,9 +10,10 @@
<% if ma.memo.parent_id.nil? %>
- <%= link_to ma.memo.subject, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.memo.subject, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
标题: <%= ma.memo.subject %>
@@ -23,9 +24,10 @@
<% else %>
- <%= link_to ma.memo.content.html_safe, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+ <%= link_to ma.memo.content.html_safe, forum_memo_path(ma.memo.forum_id, ma.memo.parent_id ? ma.memo.parent_id: ma.memo.id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}" %>
+
+
+
标题: <%= ma.memo.subject %>
diff --git a/app/views/users/_user_message_system.html.erb b/app/views/users/_user_message_system.html.erb
index e3037f227..a80d35bd4 100644
--- a/app/views/users/_user_message_system.html.erb
+++ b/app/views/users/_user_message_system.html.erb
@@ -11,10 +11,9 @@
<%= link_to ma.subject.blank? ? (ma.content.nil? ? ma.description.html_safe : ma.content.html_safe) : ma.subject, user_system_messages_path(User.current),
- :id => "content_link_#{ma.id}",
- :onmouseover =>"message_titile_show($(this),event);",
- :onmouseout => "message_titile_hide($(this));"
- %>
+ :id => "content_link_#{ma.id}" %>
+
+
<% unless ma.subject.blank? %>
diff --git a/app/views/users/_user_message_userfeedaback.html.erb b/app/views/users/_user_message_userfeedaback.html.erb
index 23a0774c3..894eedbfc 100644
--- a/app/views/users/_user_message_userfeedaback.html.erb
+++ b/app/views/users/_user_message_userfeedaback.html.erb
@@ -8,10 +8,10 @@
<%=link_to ma.journals_for_message.user, user_path(ma.journals_for_message.user), :class => "newsBlue homepageNewsPublisher" %>
"><%= ma.journals_for_message.reply_id == 0 ? "给你留言了:" : "回复了你的留言:" %>
-
- <%= link_to ma.journals_for_message.notes.gsub("","").gsub("
","").gsub(" ","").html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
- :onmouseover =>"message_titile_show($(this),event)",
- :onmouseout => "message_titile_hide($(this))" %>
+
+ <%= link_to ma.journals_for_message.notes.gsub("","").gsub("
","").gsub(" ","").html_safe, feedback_path(ma.journals_for_message.jour_id), :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}"%>
+
+
<% if ma.journals_for_message.reply_id == 0 %>
diff --git a/app/views/users/_user_programing_attr.html.erb b/app/views/users/_user_programing_attr.html.erb
index 71816689b..e04caf533 100644
--- a/app/views/users/_user_programing_attr.html.erb
+++ b/app/views/users/_user_programing_attr.html.erb
@@ -7,12 +7,13 @@
<%= options_for_select({"C语言"=>1, "C++"=>2, "Python"=>3, "Java"=>4}, (edit_mode && homework.is_program_homework?) ? homework.language : 1) %>
-
+
<% if edit_mode && homework.is_program_homework? %>
<% homework.homework_tests.each_with_index do |test, index| %>
-
-
+
<%=index+1 %>
+
+
<% if index != 0 %>
@@ -22,8 +23,9 @@
<% end %>
<% else %>
@@ -39,8 +41,10 @@
\ No newline at end of file
diff --git a/app/views/users/_user_resource_info.html.erb b/app/views/users/_user_resource_info.html.erb
new file mode 100644
index 000000000..bea78130a
--- /dev/null
+++ b/app/views/users/_user_resource_info.html.erb
@@ -0,0 +1,48 @@
+
+
+
+ <%= render :partial => 'users/resource_search_form',:locals => {:user => @user, :type => @type, :order => @order, :sort => @score, :status => @status} %>
+
+
+
+<%= render :partial => 'users/user_resource_tip_list', :locals => { :type => @type, :status => @status} %>
+
+
+
+
+ <%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/_user_resource_tip_list.html.erb b/app/views/users/_user_resource_tip_list.html.erb
new file mode 100644
index 000000000..5d5876ac8
--- /dev/null
+++ b/app/views/users/_user_resource_tip_list.html.erb
@@ -0,0 +1,33 @@
+
+
+ 资源名称
+
+ <%= link_to "上传时间", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "created_on", :search => " "), :class => "fl", :remote => true %>
+ <% if @order == "created_on" %>
+ <%= link_to "", user_resource_user_path(:type => @type, :status => @status, :sort => @score, :order => "created_on", :search => " "), :class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt16", :remote => true %>
+ <% end %>
+
+
+ <%= link_to "引用数", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "quotes"), :class => "fl", :remote => true %>
+ <% if @order == "quotes" %>
+ <%= link_to "", user_resource_user_path(:type => @type, :status => @status, :sort => @score, :order => "quotes"), :class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt16", :remote => true %>
+ <% end %>
+
+
+ <%= link_to "下载数", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "downloads"), :class => "fl", :remote => true %>
+ <% if @order == "downloads" %>
+ <%= link_to "", user_resource_user_path(:type => @type, :status => @status, :sort => @score, :order => "downloads"), :class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt16", :remote => true %>
+ <% end %>
+
+
+
+ <%= link_to "大小", resource_search_user_path(:type => @type, :status => @status, :sort => @score, :order => "filesize"), :class => "fl", :remote => true %>
+ <% if @order == "filesize" %>
+ <%= link_to "", user_resource_user_path(:type => @type, :status => @status, :sort => @score, :order => "filesize"), :class => "#{@score == 'desc' ? 'st_up' : 'st_down'} mt16", :remote => true %>
+ <% end %>
+
+
+ 上传者
+ 类别
+ 来源
+
\ No newline at end of file
diff --git a/app/views/users/_user_resource_type_filter.html.erb b/app/views/users/_user_resource_type_filter.html.erb
new file mode 100644
index 000000000..6e5ed51c3
--- /dev/null
+++ b/app/views/users/_user_resource_type_filter.html.erb
@@ -0,0 +1,29 @@
+
diff --git a/app/views/users/_watch_btn_for_picture.html.erb b/app/views/users/_watch_btn_for_picture.html.erb
index e604be318..be8673468 100644
--- a/app/views/users/_watch_btn_for_picture.html.erb
+++ b/app/views/users/_watch_btn_for_picture.html.erb
@@ -2,8 +2,8 @@
<%= link_to("编辑资料", my_account_path, :class => "fl UsersEditBtn") %>
<% else %>
<%if(user.watched_by?(User.current))%>
- <%= link_to "取消关注",watch_path(:object_type=> 'user',:object_id=>user.id,:target_id=>user.id),:class => "userFollow mr27 fl", :method => "delete",:remote => "true", :title => "取消关注"%>
+ <%= link_to "取消关注",Setting.host_name + "/watch?object_type=user&object_id="+user.id.to_s + "&target_id="+user.id.to_s,:class => "userFollow mr27 fl", :method => "delete",:remote => "true", :title => "取消关注"%>
<% else %>
- <%= link_to "添加关注",watch_path(:object_type=> 'user',:object_id=>user.id,:target_id=>user.id),:class => "userFollow mr27 fl", :method => "post",:remote => "true", :title => "添加关注"%>
+ <%= link_to "添加关注",Setting.host_name + "/watch?object_type=user&object_id="+user.id.to_s + "&target_id="+user.id.to_s,:class => "userFollow mr27 fl", :method => "post",:remote => "true", :title => "添加关注"%>
<% end %>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/add_exist_file_to_course.js.erb b/app/views/users/add_exist_file_to_course.js.erb
index 57fe9d42d..c05a2ebd0 100644
--- a/app/views/users/add_exist_file_to_course.js.erb
+++ b/app/views/users/add_exist_file_to_course.js.erb
@@ -4,7 +4,8 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
+$("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
hideModal();
-alert("发送成功")
+alert("发送成功");
<% else%>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/add_exist_file_to_org.js.erb b/app/views/users/add_exist_file_to_org.js.erb
index 57fe9d42d..9bfe1230a 100644
--- a/app/views/users/add_exist_file_to_org.js.erb
+++ b/app/views/users/add_exist_file_to_org.js.erb
@@ -4,7 +4,10 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
+<% if @ori.present? and @ori.quotes.present? %>
+ $("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
+<% end %>
hideModal();
-alert("发送成功")
+alert("发送成功");
<% else%>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/add_exist_file_to_project.js.erb b/app/views/users/add_exist_file_to_project.js.erb
index 57fe9d42d..ed38fa066 100644
--- a/app/views/users/add_exist_file_to_project.js.erb
+++ b/app/views/users/add_exist_file_to_project.js.erb
@@ -4,7 +4,10 @@ $("#resources_list").html('<%= escape_javascript( render :partial => 'resources_
$("#res_count").html(0);
$("#checkboxAll").attr('checked',false);
$("#res_all_count").html(<%= @atta_count%>);
+<% if @ori and @ori.quotes.present? %>
+ $("#reference_number_<%= @ori.id %>").text("<%= @ori.quotes %>");
+<% end %>
hideModal();
-alert("发送成功")
+alert("发送成功");
<% else%>
<% end %>
\ No newline at end of file
diff --git a/app/views/users/choose_user_course.js.erb b/app/views/users/choose_user_course.js.erb
new file mode 100644
index 000000000..508004816
--- /dev/null
+++ b/app/views/users/choose_user_course.js.erb
@@ -0,0 +1,7 @@
+$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/send_homework_to_course', :locals => {:courses => @course, :user => @user, :send_id => @send_id}) %>');
+showModal('ajax-modal', '452px');
+$('#ajax-modal').siblings().remove();
+$('#ajax-modal').before("
");
+$('#ajax-modal').parent().css("top","50%").css("left","50%");
+$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
+$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
\ No newline at end of file
diff --git a/app/views/users/import_into_container.js.erb b/app/views/users/import_into_container.js.erb
new file mode 100644
index 000000000..2a1ea3599
--- /dev/null
+++ b/app/views/users/import_into_container.js.erb
@@ -0,0 +1,3 @@
+<% if @flag == true%>
+alert("发送成功")
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/import_resources.js.erb b/app/views/users/import_resources.js.erb
new file mode 100644
index 000000000..b07f534e7
--- /dev/null
+++ b/app/views/users/import_resources.js.erb
@@ -0,0 +1,18 @@
+<% if params[:project_id] %>
+$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :project_id => params[:project_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
+<% elsif params[:course_id] %>
+$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :course_id => params[:course_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
+<% elsif params[:subfield_file_id] %>
+$('#ajax-modal').html('<%= escape_javascript( render :partial => 'users/import_resource_info', :locals => {:user => User.current, :type => @type, :subfield_file_id => params[:subfield_file_id], :mul_id => @resource_id, :mul_type => @resource_type}) %>');
+<% end %>
+showModal('ajax-modal', '615px');
+$('#ajax-modal').siblings().remove();
+$('#ajax-modal').before("
");
+<% if params[:project_id] %>
+$('#ajax-modal').parent().css("top","10%").css("left","34%").css("border","3px solid #269ac9");
+<% else %>
+$('#ajax-modal').parent().css("top","20%").css("left","42%").css("border","3px solid #269ac9");
+<% end %>
+$('#ajax-modal').parent().addClass("popbox_polls");
+
+
diff --git a/app/views/users/import_resources_search.js.erb b/app/views/users/import_resources_search.js.erb
new file mode 100644
index 000000000..928235f4c
--- /dev/null
+++ b/app/views/users/import_resources_search.js.erb
@@ -0,0 +1,5 @@
+$("#import_resource_info_list").html('<%= escape_javascript( render :partial => 'user_import_resource_list',
+ :locals => {:user => @user, :type => @type,
+ :mul_id => @resource_id,
+ :mul_type => @resource_type}) %>');
+$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
diff --git a/app/views/users/new_user_commit_homework.html.erb b/app/views/users/new_user_commit_homework.html.erb
index 02bfc9203..f8ce5cee4 100644
--- a/app/views/users/new_user_commit_homework.html.erb
+++ b/app/views/users/new_user_commit_homework.html.erb
@@ -85,7 +85,7 @@
style="display-hidden" id="data-language">
- <%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"请概括你的代码的功能" %>
+ <%= f.text_area :name, id: 'program-title', class:"InputBox W700", placeholder:"请概括你的代码的功能", value:"#{@homework.name}的作品提交" %>
<%= f.text_area :description, id: 'program-src', class:"InputBox W700 H150", placeholder:"请贴入你的代码", rows: 10 %>
@@ -97,7 +97,7 @@
测试代码
<% if @is_test %>
- <%=link_to '返 回',course_path(@course),:class=>'fr mt6' %>
+ <%=link_to '返 回',homework_common_index_path(:course => @course.id),:class=>'fr mt6' %>
<% else @is_test %>
提交代码
<% end %>
diff --git a/app/views/users/resource_search.js.erb b/app/views/users/resource_search.js.erb
index d295ce003..9583274c6 100644
--- a/app/views/users/resource_search.js.erb
+++ b/app/views/users/resource_search.js.erb
@@ -1,5 +1,14 @@
$("#resources_list").html('<%= escape_javascript( render :partial => 'resources_list' ,:locals=>{ :attachments => @attachments})%>');
+$("#resource_tip_list").html('<%= escape_javascript( render :partial => 'users/user_resource_tip_list', :locals => {:user => @user, :type => @type, :status => @status}) %>');
$("#pages").html('<%= pagination_links_full @atta_pages, @atta_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
$("#res_all_count").html(<%= @atta_count%>);
$("#res_count").html(0);
-$("#checkboxAll").attr('checked',false);
\ No newline at end of file
+$("#checkboxAll").attr('checked',false);
+//更新状态
+$("#public_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '6') %>');
+$("#my_resource_list").attr('href','<%= user_resource_user_path(@user, :type => '1') %>');
+$("#resource_type_all").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 1, :search => @switch_search) %>');
+$("#resource_type_course").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 2, :search => @switch_search) %>');
+$("#resource_type_project").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 3, :search => @switch_search) %>');
+$("#resource_type_user").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 5, :search => @switch_search) %>');
+$("#resource_type_file").attr('href','<%= resource_search_user_path(@user,:type => @type, :status => 4, :search => @switch_search) %>');
\ No newline at end of file
diff --git a/app/views/users/send_homework_to_course.js.erb b/app/views/users/send_homework_to_course.js.erb
new file mode 100644
index 000000000..b06d8e434
--- /dev/null
+++ b/app/views/users/send_homework_to_course.js.erb
@@ -0,0 +1,9 @@
+$("#subject_count_homework_<%=@homework.id %>").html(<%= @homework.quotes %>);
+$("#ajax-modal").html("<%=escape_javascript(render :partial => 'homework_post_notice') %>");
+showModal('ajax-modal', '500px');
+$('#ajax-modal').siblings().remove();
+$('#ajax-modal').before("
" +
+ " ");
+$('#ajax-modal').parent().css("top","50%").css("left","50%");
+$('#ajax-modal').parent().addClass("popbox").addClass("resourceUploadPopup");
+$('#ajax-modal').css("padding-left","16px").css("padding-bottom","16px");
\ No newline at end of file
diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb
index a56ca7b48..fa4eaacbe 100644
--- a/app/views/users/show.html.erb
+++ b/app/views/users/show.html.erb
@@ -45,5 +45,4 @@
<% homepage = BlogComment.find(@user.blog.homepage_id) %>
<%= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %>
<% end %>
-
-<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type} %>
+<%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type, :user_id => (@user.type == "AnonymousUser" ? User.current.id : @user.id)} %>
diff --git a/app/views/users/show_homework_detail.js.erb b/app/views/users/show_homework_detail.js.erb
index 12be1b786..a5dd82453 100644
--- a/app/views/users/show_homework_detail.js.erb
+++ b/app/views/users/show_homework_detail.js.erb
@@ -1 +1,5 @@
-$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>@homework}) %>")
\ No newline at end of file
+<% if @is_import.to_i == 1 %>
+ $("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>@homework}) %>");
+<% else %>
+ $("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>@homework}) %>");
+<% end %>
\ No newline at end of file
diff --git a/app/views/users/student_homeworks.html.erb b/app/views/users/student_homeworks.html.erb
new file mode 100644
index 000000000..59ec24ad3
--- /dev/null
+++ b/app/views/users/student_homeworks.html.erb
@@ -0,0 +1,47 @@
+
+
+
+
+<% if @is_teacher%>
+
+
+ <% homework = HomeworkCommon.new %>
+ <% homework.homework_detail_manual = HomeworkDetailManual.new%>
+ <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %>
+
+ <%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %>
+
+ <% end%>
+
+<% end%>
+
+<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0,:is_in_course => 0} %>
diff --git a/app/views/users/student_homeworks.js.erb b/app/views/users/student_homeworks.js.erb
new file mode 100644
index 000000000..c34be666c
--- /dev/null
+++ b/app/views/users/student_homeworks.js.erb
@@ -0,0 +1 @@
+$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>");
\ No newline at end of file
diff --git a/app/views/users/user_homework_type.js.erb b/app/views/users/user_homework_type.js.erb
index 691fdc72b..8cfb4dc04 100644
--- a/app/views/users/user_homework_type.js.erb
+++ b/app/views/users/user_homework_type.js.erb
@@ -1,4 +1,15 @@
-$("#homework_list_form_show").html('<%= escape_javascript(render :partial => 'users/show_user_homework_form', :locals => {:homeworks => @homeworks})%>');
-$("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
-$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
-$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type}) %>");
\ No newline at end of file
+<% if @is_import.to_i == 1 %>
+$("#homework_list_form_show").html('<%= escape_javascript(render :partial => 'users/show_user_homework_form', :locals => {:homeworks => @homeworks})%>');
+$("#homewrok_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
+$("#homework_detail_information").html("<%=escape_javascript(render :partial => 'users/homework_detail_information', :locals => {:homework=>nil}) %>");
+$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_search_input', :locals=>{:type=>@type,:is_import=>@is_import}) %>");
+<% else %>
+$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => @is_import,:property => @property,:search=>''})%>');
+$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
+$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
+$("#homework_search_input").html("<%=escape_javascript(render :partial=>'homework_repository_search', :locals=>{:type=>@type,:is_import=>@is_import,:property=>@property}) %>");
+$("#homework_type_all").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 0) %>');
+$("#homework_type_nor").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 1) %>');
+$("#homework_type_pro").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 2) %>');
+$("#homework_type_gro").attr('href','<%= user_homework_type_user_path(@user,:type => @type,:is_import => 0,:property => 3) %>');
+<% end %>
diff --git a/app/views/users/user_homeworks.html.erb b/app/views/users/user_homeworks.html.erb
index d0adb291f..2cd1f5b21 100644
--- a/app/views/users/user_homeworks.html.erb
+++ b/app/views/users/user_homeworks.html.erb
@@ -1,47 +1,83 @@
-
-
-
-
-<% if @is_teacher%>
-
-
- <% homework = HomeworkCommon.new %>
- <% homework.homework_detail_manual = HomeworkDetailManual.new%>
- <%= labelled_form_for homework,:url => user_new_homework_users_path,:method => "post" do |f| %>
-
- <%= render :partial => 'users/user_homework_form', :locals => { :homework => homework,:f => f,:edit_mode => false } %>
-
- <% end%>
-
-<% end%>
-
-<%= render :partial => 'users/user_homework_list', :locals => {:homework_commons => @homework_commons,:page => 0,:is_in_course => 0} %>
+<%= stylesheet_link_tag 'pleft','header','new_user','repository','org', 'public' %>
+
+
+
+
+
+
+
+
+ <%=render :partial=>'homework_repository_search', :locals=>{:type => @type,:is_import => 0,:property => nil} %>
+
+
+
+ <%=render :partial => 'homework_repository_list', :locals => {:homeworks => @homeworks,:type=>@type,:is_import => 0,:property => @property,:search=>''} %>
+
+
+ <%=render :partial => 'homework_repository_detail', :locals => {:homework => nil} %>
+
+
+
+
+ <%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true%>
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/users/user_homeworks.js.erb b/app/views/users/user_homeworks.js.erb
index cc1bc051a..ce1bb65e2 100644
--- a/app/views/users/user_homeworks.js.erb
+++ b/app/views/users/user_homeworks.js.erb
@@ -1,2 +1,4 @@
-$("#user_show_more_homework").replaceWith("<%= escape_javascript( render :partial => 'users/user_homework_list',:locals => {:homework_commons => @homework_commons, :page => @page,:is_in_course => 0} )%>");
-
+/*$("#homework_repository").html('<%#= escape_javascript(render :partial => 'users/homework_repository', :locals => {:homeworks => @homeworks})%>');*/
+$("#homework_repository_list").html('<%= escape_javascript(render :partial => 'users/homework_repository_list', :locals => {:homeworks => @homeworks,:sort => @order,:b_sort => @b_sort,:type=>@type,:is_import => 0,:property => @property,:search=>''})%>');
+$("#homework_pository_ref_pages").html('<%= pagination_links_full @hw_pages, @hw_count, :per_page_links => false, :remote => @is_remote, :flag => true %>');
+$("#homework_repository_detail").html("<%=escape_javascript(render :partial => 'users/homework_repository_detail', :locals => {:homework=>nil}) %>");
diff --git a/app/views/users/user_resource.html.erb b/app/views/users/user_resource.html.erb
index 5abadfb29..80167db56 100644
--- a/app/views/users/user_resource.html.erb
+++ b/app/views/users/user_resource.html.erb
@@ -1,31 +1,22 @@
-
-<%= javascript_include_tag 'bootstrap'%>
+<%= javascript_include_tag 'bootstrap' %>
<%= stylesheet_link_tag 'project' %>
<%= stylesheet_link_tag 'leftside' %>
-<%= javascript_include_tag 'attachments'%>
-
-
-
-
-
+<%= javascript_include_tag 'attachments' %>
+
-
-
-
-
-
-
- <%= render :partial => 'resource_search_form',:locals => {:user=>@user,:type=>@type} %>
-
-
为您找到<%= @atta_count%> 个资源
-
-
-
-
- 资源名称
- 大小
- 类别
- 上传者
- 上传时间
-
-
-