diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb
index d371ed4cb..664dc4cf5 100644
--- a/app/controllers/attachments_controller.rb
+++ b/app/controllers/attachments_controller.rb
@@ -438,6 +438,46 @@ class AttachmentsController < ApplicationController
end
end
+ def add_exist_file_to_org_subfield
+ file = Attachment.find(params[:file_id])
+ org_subfields = params[:org_subfields][:org_subfield]
+ @message = ""
+ org_subfields.each do |org_subfield|
+ s = OrgSubfield.find(org_subfield)
+ if s.attachments.include?file
+ if @message && @message == ""
+ @message += l(:label_resource_subfield_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed)
+ next
+ else
+ @message += "
" + l(:label_resource_subfield_prompt) + c.name + l(:label_contain_resource) + file.filename + l(:label_quote_resource_failed)
+ next
+ end
+ end
+ attach_copied_obj = file.copy
+ attach_copied_obj.tag_list.add(file.tag_list) # tag关联
+ attach_copied_obj.container = s
+ attach_copied_obj.created_on = Time.now
+ attach_copied_obj.author_id = User.current.id
+ attach_copied_obj.copy_from = file.copy_from.nil? ? file.id : file.copy_from
+ if attach_copied_obj.attachtype == nil
+ attach_copied_obj.attachtype = 4
+ end
+ @obj = s
+ @save_flag = attach_copied_obj.save
+ @save_message = attach_copied_obj.errors.full_messages
+ update_quotes attach_copied_obj
+ end
+ respond_to do |format|
+ format.js
+ end
+ rescue NoMethodError
+ @save_flag = false
+ @save_message = [] << l(:label_resource_subfield_empty_select)
+ respond_to do |format|
+ format.js
+ end
+ end
+
def update_quotes attachment
if attachment.copy_from
attachments = Attachment.find_by_sql("select * from attachments where copy_from = #{attachment.copy_from} or id = #{attachment.copy_from}")
diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb
index 1b0ead141..aa0e1596f 100644
--- a/app/controllers/courses_controller.rb
+++ b/app/controllers/courses_controller.rb
@@ -36,17 +36,18 @@ class CoursesController < ApplicationController
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
+ limit = 15
course_org_ids = OrgCourse.find_by_sql("select distinct organization_id from org_courses where course_id = #{params[:id]}").map(&:organization_id)
if course_org_ids.empty?
- @orgs_not_in_course = Organization.where("(is_public or creator_id =?) and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10)
+ @orgs_not_in_course = Organization.where("(is_public or creator_id =?) and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
@org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
else
course_org_ids = "(" + course_org_ids.join(',') + ")"
- @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10)
+ @orgs_not_in_course = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
@org_count = Organization.where("id not in #{course_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
end
# @course_count = Project.course_entities.visible.like(params[:name]).page(params[:page]).count
- @orgs_page = Paginator.new @org_count, 10,params[:page]
+ @orgs_page = Paginator.new @org_count, limit,params[:page]
@hint_flag = params[:hint_flag]
#render :json => {:orgs => @orgs_not_in_course, :count => @org_count}.to_json
respond_to do |format|
diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb
index 2a75d0580..75751e4f7 100644
--- a/app/controllers/exercise_controller.rb
+++ b/app/controllers/exercise_controller.rb
@@ -27,7 +27,7 @@ class ExerciseController < ApplicationController
if @is_teacher || User.current.admin?
exercises = @course.exercises.order("created_at asc")
else
- exercises = @course.exercises.where(:exercise_status => 2).order("created_at asc")
+ exercises = @course.exercises.where("exercise_status <> 1").order("created_at asc")
end
@exercises = paginateHelper exercises,20 #分页
respond_to do |format|
@@ -54,41 +54,26 @@ class ExerciseController < ApplicationController
end
@exercise = Exercise.find params[:id]
@is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin?
- if @exercise.exercise_status != 2 && (!(User.current.allowed_to?(:as_teacher,@course) || User.current.admin?))
- render_403
- return
- end
exercise_end = @exercise.end_time > Time.now
if @exercise.time == -1
@can_edit_excercise = exercise_end
else
- @can_edit_excercise = (!has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end) || User.current.admin?
+ @can_edit_excercise = !has_commit_exercise?(@exercise.id,User.current.id)&& exercise_end
end
- @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
- # 学生点击的时候即创建关联,自动保存
- #eu = ExerciseUser.create(:user_id => User.current, :exercise_id => @exercise.id, :start_at => Time.now, :status => false)
-
- # 已提交问卷的用户不能再访问该界面
-=begin
- if has_commit_exercise?(@exercise.id, User.current.id) && (!User.current.admin?)
- respond_to do |format|
- format.html {render :layout => 'base_courses'}
- end
- else
-=end
- if !@is_teacher && !has_click_exercise?(@exercise.id, User.current.id)
+ unless @is_teacher
+ @exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
+ if @exercise_user.nil?
eu = ExerciseUser.create(:user_id => User.current.id, :exercise_id => @exercise.id, :start_at => Time.now, :status => false)
@exercise_user = ExerciseUser.where("user_id=? and exercise_id=?", User.current.id, @exercise.id).first
end
- # @percent = get_percent(@exercise,User.current)
- exercise_questions = @exercise.exercise_questions
- @exercise_questions = paginateHelper exercise_questions,5 #分页
score = calculate_student_score(@exercise, User.current)
- eu = get_exercise_user(@exercise.id, User.current.id)
- eu.update_attributes(:score => score)
- respond_to do |format|
- format.html {render :layout => 'base_courses'}
- end
+ @exercise_user.update_attributes(:score => score)
+ end
+ # @percent = get_percent(@exercise,User.current)
+ @exercise_questions = @exercise.exercise_questions
+ respond_to do |format|
+ format.html {render :layout => 'base_courses'}
+ end
#end
end
@@ -537,12 +522,9 @@ class ExerciseController < ApplicationController
# @score = 100
if @uncomplete_question.count < 1
# 查看是否有已提交记录
- eu = get_exercise_user(@exercise.id, User.current.id)
- eu.user_id = User.current.id
- eu.exercise_id = @exercise.id
- eu.score = @score
- if eu.save
- #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
+ cur_exercise_user.score = @score
+ if cur_exercise_user.save
+ #redirect_to poll_index_path(:polls_group_id => @course.id,:polls_type => 'Course')
@status = 0 #提交成功
else
@status = 2 #未知错误
@@ -550,6 +532,7 @@ class ExerciseController < ApplicationController
else
@status = 1 #有未做得必答题
end
+ @save = params[:save].to_i if params[:save]
respond_to do |format|
format.js
end
diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb
index 328446fbb..68f7cc9cb 100644
--- a/app/controllers/files_controller.rb
+++ b/app/controllers/files_controller.rb
@@ -131,6 +131,45 @@ class FilesController < ApplicationController
end
end
+ def search_files_in_subfield
+ sort = ""
+ @sort = ""
+ @order = ""
+ @is_remote = true
+ @q = params[:name].strip
+ if params[:sort]
+ order_by = params[:sort].split(":")
+ @sort = order_by[0]
+ if order_by.count > 1
+ @order = order_by[1]
+ end
+ sort = "#{@sort} #{@order}"
+ end
+ # show_attachments [@course]
+ begin
+ q = "%#{params[:name].strip}%"
+ #(redirect_to stores_url, :notice => l(:label_sumbit_empty);return) if params[:name].blank?
+ if params[:insite]
+ if q == "%%"
+ @result = []
+ @searched_attach = paginateHelper @result,10
+ else
+ @result = find_public_attache q,sort
+ @result = visable_attachemnts_insite @result,@org_subfield
+ @searched_attach = paginateHelper @result,10
+ end
+ else
+ @result = find_org_subfield_attache q,@org_subfield,sort
+ @result = visable_attachemnts @result
+ @searched_attach = paginateHelper @result,10
+ @tag_list = attachment_tag_list @result
+ end
+ #rescue Exception => e
+ # #render 'stores'
+ # redirect_to search_course_files_url
+ end
+ end
+
def find_course_attache keywords,course,sort = ""
if sort == ""
sort = "created_on DESC"
@@ -144,6 +183,19 @@ class FilesController < ApplicationController
#resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
end
+ def find_org_subfield_attache keywords,org_subfield,sort = ""
+ if sort == ""
+ sort = "created_on DESC"
+ end
+ if keywords != "%%"
+ resultSet = Attachment.where("attachments.container_type = 'OrgSubfield' And attachments.container_id = '#{org_subfield.id}' AND filename LIKE :like ", like: "%#{keywords}%").
+ reorder(sort)
+ else
+ resultSet = Attachment.where("attachments.container_type = 'OrgSubfield' And attachments.container_id = '#{org_subfield.id}' "). reorder(sort)
+ end
+ #resultSet = Attachment.find_by_sql("SELECT `attachments`.* FROM `attachments` LEFT OUTER JOIN `homework_attaches` ON `attachments`.container_type = 'HomeworkAttach' AND `attachments`.container_id = `homework_attaches`.id LEFT OUTER JOIN `homework_for_courses` ON `homework_attaches`.bid_id = `homework_for_courses`.bid_id LEFT OUTER JOIN `homework_for_courses` AS H_C ON `attachments`.container_type = 'Bid' AND `attachments`.container_id = H_C.bid_id WHERE (`homework_for_courses`.course_id = 117 OR H_C.course_id = 117 OR (`attachments`.container_type = 'Course' AND `attachments`.container_id = 117)) AND `attachments`.filename LIKE '%#{keywords}%'").reorder("created_on DESC")
+ end
+
def find_project_attache keywords,project,sort = ""
if sort == ""
sort = "created_on DESC"
@@ -298,10 +350,52 @@ class FilesController < ApplicationController
render :layout => 'base_courses'
elsif params[:org_subfield_id]
+ 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
- @organization = Organization.find(params[:organization_id])
@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
render :layout => 'base_org'
# @subfield = params[:org_subfield_id]
end
@@ -318,6 +412,12 @@ class FilesController < ApplicationController
@can_quote = attachment_candown @file
end
+ def quote_resource_show_org_subfield
+ @file = Attachment.find(params[:id])
+ @org_subfield = OrgSubfield.find(params[:org_subfield_id])
+ @can_quote = attachment_candown @file
+ end
+
def new
@versions = @project.versions.sort
@course_tag = @project.project_type
@@ -430,14 +530,29 @@ class FilesController < ApplicationController
end
elsif @org_subfield
@addTag=false
- # if params[:in_org_subfield_toolbar]
- # @in_org_subfield_toolbar = params[:in_org_subfield_toolbar]
- # end
attachments = Attachment.attach_filesex(@org_subfield, params[:attachments], params[:org_subfield_attachment_type])
- # if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added')
- # Mailer.run.attachments_added(attachments[:files])
- # end
+ if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type].is_a?(Array)
+ params[:org_subfield_attachment_type].each do |type|
+ tag_name = get_tag_name_by_type_number type
+ if !attachments.empty? && attachments[:files] && tag_name != ""
+ attachments[:files].each do |attachment|
+ attachment.tag_list.add(tag_name)
+ attachment.save
+ end
+ end
+ end
+ else
+ if params[:org_subfield_attachment_type] && params[:org_subfield_attachment_type] != "5"
+ tag_name = get_tag_name_by_type_number params[:org_subfield_attachment_type]
+ if !attachments.empty? && attachments[:files] && tag_name != ""
+ attachments[:files].each do |attachment|
+ attachment.tag_list.add(tag_name)
+ attachment.save
+ end
+ end
+ end
+ end
# TODO: 临时用 nyan
sort_init 'created_on', 'desc'
@@ -446,19 +561,18 @@ class FilesController < ApplicationController
'size' => "#{Attachment.table_name}.filesize",
'downloads' => "#{Attachment.table_name}.downloads"
- @containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)] #modify by Long Jun
- # @containers += @org_subfield.versions.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").all.sort
+ @containers = [OrgSubfield.includes(:attachments).reorder("#{Attachment.table_name}.created_on DESC").find(@org_subfield.id)]
show_attachments @containers
-
+ @tag_list = attachment_tag_list @all_attachments
@attachtype = 0
@contenttype = 0
respond_to do |format|
format.js
- format.html {
- redirect_to org_subfield_files_url(@org_subfield)
- }
+ # format.html {
+ # redirect_to org_subfield_files_url(@org_subfield)
+ # }
end
end
end
@@ -640,4 +754,34 @@ class FilesController < ApplicationController
# format.html
end
end
+
+ #搜索资源栏目的指定TAG的资源列表
+ def search_org_subfield_tag_attachment
+ @q,@tag_name,@order = params[:q],params[:tag_name]
+ @is_remote = true
+ if params[:sort]
+ order_by = params[:sort].split(":")
+ @sort = order_by[0]
+ if order_by.count > 1
+ @order = order_by[1]
+ end
+ sort = "#{@sort} #{@order}"
+ end
+
+ 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?
+ @searched_attach = paginateHelper @result,10
+ @tag_list = get_org_subfield_tag_list @org_subfield
+
+ respond_to do |format|
+ format.js
+ # format.html
+ end
+ end
+
+ def subfield_upload_file
+ @org_subfield = OrgSubfield.find(params[:org_subfield_id])
+ end
end
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb
index ab2cfa2ba..ccebdccfa 100644
--- a/app/controllers/projects_controller.rb
+++ b/app/controllers/projects_controller.rb
@@ -75,17 +75,18 @@ class ProjectsController < ApplicationController
if !params[:name].nil?
condition = "%#{params[:name].strip}%".gsub(" ","")
end
+ limit = 15
project_org_ids = OrgProject.find_by_sql("select distinct organization_id from org_projects where project_id = #{params[:id]}").map(&:organization_id)
if project_org_ids.empty?
- @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(10)
+ @orgs_not_in_project = Organization.where("(is_public or creator_id =?) = 1 and name like ?",User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
@org_count = Organization.where("is_public = 1 or creator_id =?", User.current.id).where("name like ?", condition).count
else
project_org_ids = "(" + project_org_ids.join(',') + ")"
- @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(10)
+ @orgs_not_in_project = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?) and name like ?", User.current.id, condition).page((params[:page].to_i || 1)).per(limit)
@org_count = Organization.where("id not in #{project_org_ids} and (is_public = 1 or creator_id =?)", User.current.id).where("name like ?", condition).count
end
# @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count
- @orgs_page = Paginator.new @org_count, 10,params[:page]
+ @orgs_page = Paginator.new @org_count, limit,params[:page]
@no_roll_hint = params[:hint_flag]
#render :json => {:orgs => @orgs_not_in_project, :count => @org_count}.to_json
respond_to do |format|
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index cb61177f5..d40bc7c7c 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -227,6 +227,12 @@ class TagsController < ApplicationController
@tag_list = get_course_tag_list @course
@select_tag_name = params[:select_tag_name]
end
+
+ if @obj && @object_flag == '6' && @obj.container.kind_of?(OrgSubfield)
+ @org_subfield = @obj.container
+ @tag_list = get_org_subfield_tag_list @org_subfield
+ @select_tag_name = params[:select_tag_name]
+ end
# end
end
end
@@ -314,6 +320,86 @@ class TagsController < ApplicationController
end
end
+ def update_org_subfield_tag_name
+ @tag_name = params[:tagName]
+ @rename_tag_name = params[:renameName]
+ @taggable_id = params[:taggableId]
+ @taggable_type = numbers_to_object_type(params[:taggableType])
+ @rename_tag = (ActsAsTaggableOn::Tag.find_by_name(@rename_tag_name)) #查找重命名后的tag
+ @tag_id = (ActsAsTaggableOn::Tag.find_by_name(@tag_name)).id #重命名前的tag_id
+ @taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,@taggable_id,@taggable_type) unless @taggable_id.blank?
+ @obj = get_object(@taggable_id,params[:taggableType]) unless @taggable_id.blank?
+ if @taggable_id.blank? #如果没有传tag_id,那么直接更新tag_name就好了。但是要防止 重命名后的tag存在。
+ if params[:org_subfield_id]
+ org_subfield = OrgSubfield.find params[:org_subfield_id]
+ if org_subfield
+ org_subfield.attachments.each do |attachment|
+ taggings = ActsAsTaggableOn::Tagging.find_by_tag_id_and_taggable_id_and_taggable_type(@tag_id,attachment.id,attachment.class)
+ if taggings
+ taggings.delete
+ attachment.tag_list.add(@rename_tag_name.split(","))
+ attachment.save
+ end
+ end
+ end
+ end
+ else
+ if(@rename_tag.nil?) #这次命名的是新的tag
+
+ # 是否还有其他记录 引用了 tag_id
+ @tagging = ActsAsTaggableOn::Tagging.where("tag_id = #{@tag_id}")
+ # 如果taggings表中记录为 1 ,那么改变@tag_id对应的tag的名字
+ if @tagging.count == 1
+ @tag = ActsAsTaggableOn::Tag.find_by_id(@tag_id)
+ @tag.update_attributes({:name=>@rename_tag_name})
+ else #如果tagging表中的记录大于1,那么就要新增tag记录
+
+ unless @obj.nil?
+ @obj.tag_list.add(@rename_tag_name.split(","))
+ @obj.save
+ end
+ #删除原来的对应的taggings的记录
+ unless @taggings.nil?
+ @taggings.delete
+ end
+ end
+ else #这是已有的tag
+ # 更改taggings记录里的tag_id
+ unless @taggings.nil?
+ @taggings.update_attributes({:tag_id=>@rename_tag.id})
+ end
+ end
+ end
+
+ @obj_flag = params[:taggableType]
+ if @obj && @obj_flag == '6' && @obj.container.kind_of?(OrgSubfield)
+ @org_subfield = @obj.container
+ @tag_list = @tag_list = get_org_subfield_tag_list @org_subfield
+ elsif params[:org_subfield_id]
+ @org_subfield = OrgSubfield.find(params[:org_subfield_id])
+ @tag_list = get_org_subfield_tag_list @org_subfield
+
+ #这里要引用FilesController里的逻辑了。将资源库当前的文件列表刷新一遍。
+ @flag = params[:flag] || false
+ sort = ""
+ @sort = ""
+ @order = ""
+ @is_remote = false
+ @isproject = false
+
+ sort = "#{Attachment.table_name}.created_on desc"
+
+ @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)]
+
+ show_attachments @containers
+ elsif @obj && @obj_flag == '5'
+ @forum = @obj
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+
def show_attachments obj
@attachments = []
obj.each do |container|
@@ -372,6 +458,10 @@ class TagsController < ApplicationController
@course = @obj.container
@tag_list = @tag_list = get_course_tag_list @course
end
+ if @obj && @obj_flag == '6' && @obj.container.kind_of?(OrgSubfield)
+ @org_subfield = @obj.container
+ @tag_list = @tag_list = get_org_subfield_tag_list @org_subfield
+ end
respond_to do |format|
format.js
format.html
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 81d42c1e6..ce4c07c55 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1924,6 +1924,8 @@ module ApplicationHelper
elsif attachment.container.is_a?(Course)
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
elsif (attachment.container.has_attribute?(:board) || attachment.container.has_attribute?(:board_id)) && attachment.container.board &&
attachment.container.board.course
course = attachment.container.board.course
@@ -2380,6 +2382,15 @@ module ApplicationHelper
tag_list
end
+ def get_org_subfield_tag_list org_subfield
+ all_attachments = org_subfield.attachments.select{|attachment| attachment.is_public? ||
+ (attachment.container_type == "OrgSubfield" && User.current.member_of_org?(org_subfield.organization))||
+ attachment.author_id == User.current.id
+ }
+ tag_list = attachment_tag_list all_attachments
+ tag_list
+ end
+
#获取匿评相关连接代码
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")
diff --git a/app/helpers/files_helper.rb b/app/helpers/files_helper.rb
index cf9cbcc32..bd023f6d0 100644
--- a/app/helpers/files_helper.rb
+++ b/app/helpers/files_helper.rb
@@ -67,6 +67,17 @@ module FilesHelper
s.html_safe
end
+ #带勾选框的组织资源栏目列表
+ def org_subfields_check_box_tags(name,org_subfields,attachment)
+ s = ''
+ org_subfields.each do |org_subfield|
+ if !org_subfield.attachments.include?attachment
+ s << "
"
+ end
+ end
+ s.html_safe
+ end
+
#判断用户是否拥有不包含当前资源的课程,需用户在该课程中角色为教师且该课程属于当前学期或下一学期
def has_course? user,file
result = false
@@ -141,6 +152,12 @@ module FilesHelper
result << attachment
end
end
+ elsif obj.is_a?(OrgSubfield)
+ attachments.each do |attachment|
+ if attachment.is_public? || (attachment.container_type == "OrgSubfield" && attachment.container_id == obj.id )|| attachment.author_id == User.current.id
+ result << attachment
+ end
+ end
end
end
result
diff --git a/app/views/attachments/add_exist_file_to_org_subfield.js.erb b/app/views/attachments/add_exist_file_to_org_subfield.js.erb
new file mode 100644
index 000000000..4c4208f76
--- /dev/null
+++ b/app/views/attachments/add_exist_file_to_org_subfield.js.erb
@@ -0,0 +1,8 @@
+<% if !@save_flag && @save_message %>
+ $("#error_show").html("<%= @save_message.join(', ') %>");
+<% elsif @message && @message != "" %>
+ $("#error_show").html("<%= @message.html_safe %>");
+<% else %>
+ closeModal();
+ location.reload();
+<% end %>
\ No newline at end of file
diff --git a/app/views/courses/search_public_orgs_not_in_course.js.erb b/app/views/courses/search_public_orgs_not_in_course.js.erb
index 2669f8a0f..ebd0c58a7 100644
--- a/app/views/courses/search_public_orgs_not_in_course.js.erb
+++ b/app/views/courses/search_public_orgs_not_in_course.js.erb
@@ -11,7 +11,7 @@ $("#search_orgs_result_list").append('
<%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %> | 下载<%= file.downloads %> | 引用<%= file.quotes.nil? ? 0:file.quotes %>