|
|
|
@ -39,20 +39,14 @@ class UsersController < ApplicationController
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
before_filter :can_show_course, :only => [:user_courses,:user_homeworks]
|
|
|
|
|
before_filter :require_admin, :except => [:show, :index, :search, :tag_save, :tag_saveEx,:user_projects, :user_newfeedback, :user_comments, :watch_contests, :info,
|
|
|
|
|
:user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :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,:update_score,:user_activities,:user_projects_index,
|
|
|
|
|
:user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,
|
|
|
|
|
:user_resource,:user_resource_create,:user_resource_delete,:rename_resource,:search_user_course,:add_exist_file_to_course,
|
|
|
|
|
:search_user_project,:resource_preview,:resource_search,:add_exist_file_to_project,:user_messages,:edit_brief_introduction,:user_new_homework]
|
|
|
|
|
#edit has been deleted by huang, 2013-9-23
|
|
|
|
|
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,
|
|
|
|
|
: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_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages,:edit_brief_introduction,
|
|
|
|
|
:user_import_homeworks,:user_search_homeworks]
|
|
|
|
|
before_filter :auth_user_extension, only: :show
|
|
|
|
|
#before_filter :rest_user_score, only: :show
|
|
|
|
|
#before_filter :select_entry, only: :user_projects
|
|
|
|
@ -311,7 +305,46 @@ class UsersController < ApplicationController
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
format.html {render :layout => 'new_base_user'}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#导入作业
|
|
|
|
|
def user_import_homeworks
|
|
|
|
|
@user_homeworks = HomeworkCommon.where(:user_id => @user.id).order("created_at desc")
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#用户主页过滤作业
|
|
|
|
|
def user_search_homeworks
|
|
|
|
|
@user_homeworks = HomeworkCommon.where("user_id = '#{@user.id}' and lower(name) like '%#{params[:name].to_s.downcase}%'").order("created_at desc")
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
#导入作业,确定按钮
|
|
|
|
|
def user_select_homework
|
|
|
|
|
homework = HomeworkCommon.find_by_id params[:checkMenu]
|
|
|
|
|
@homework = HomeworkCommon.new
|
|
|
|
|
if homework
|
|
|
|
|
@homework.name = homework.name
|
|
|
|
|
@homework.description = homework.description
|
|
|
|
|
@homework.end_time = homework.end_time
|
|
|
|
|
@homework.course_id = homework.course_id
|
|
|
|
|
homework.attachments.each do |attachment|
|
|
|
|
|
att = attachment.copy
|
|
|
|
|
att.container_id = nil
|
|
|
|
|
att.container_type = nil
|
|
|
|
|
att.copy_from = attachment.id
|
|
|
|
|
att.save
|
|
|
|
|
@homework.attachments << att
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def user_new_homework
|
|
|
|
@ -963,13 +996,13 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@type = params[:type] || 1
|
|
|
|
|
@limit = 15
|
|
|
|
|
@limit = 25
|
|
|
|
|
@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,15
|
|
|
|
|
@attachments = paginateHelper @attachments,25
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
@ -1019,13 +1052,13 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@type = params[:type]
|
|
|
|
|
@limit = 15
|
|
|
|
|
@limit = 25
|
|
|
|
|
@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,15
|
|
|
|
|
@attachments = paginateHelper @attachments,25
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
@ -1067,10 +1100,14 @@ class UsersController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 将资源发送到对应的课程,分为发送单个,或者批量发送
|
|
|
|
|
def add_exist_file_to_course
|
|
|
|
|
@flag = true
|
|
|
|
|
if params[:send_id].present?
|
|
|
|
|
send_id = params[: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?
|
|
|
|
@ -1088,9 +1125,13 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
elsif params[:send_ids].present?
|
|
|
|
|
send_ids = params[:send_ids].split(" ")
|
|
|
|
|
course_ids = params[:course_ids]
|
|
|
|
|
if course_ids.nil?
|
|
|
|
|
@flag = false
|
|
|
|
|
end
|
|
|
|
|
send_ids.each do |send_id|
|
|
|
|
|
ori = Attachment.find_by_id(send_id)
|
|
|
|
|
course_ids = params[:course_ids]
|
|
|
|
|
|
|
|
|
|
unless course_ids.nil?
|
|
|
|
|
course_ids.each do |id|
|
|
|
|
|
next if ori.blank?
|
|
|
|
@ -1107,6 +1148,8 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@flag = false
|
|
|
|
|
end
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
@ -1115,9 +1158,13 @@ class UsersController < ApplicationController
|
|
|
|
|
|
|
|
|
|
# 添加资源到对应的项目
|
|
|
|
|
def add_exist_file_to_project
|
|
|
|
|
@flag = true
|
|
|
|
|
if params[:send_id].present?
|
|
|
|
|
send_id = params[:send_id]
|
|
|
|
|
project_ids = params[:projects_ids]
|
|
|
|
|
if project_ids.nil?
|
|
|
|
|
@flag = false
|
|
|
|
|
end
|
|
|
|
|
ori = Attachment.find_by_id(send_id)
|
|
|
|
|
unless project_ids.nil?
|
|
|
|
|
project_ids.each do |project_id|
|
|
|
|
@ -1135,8 +1182,12 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
elsif params[:send_ids].present?
|
|
|
|
|
send_ids = params[:send_ids].split(" ")
|
|
|
|
|
project_ids = params[:projects_ids]
|
|
|
|
|
if project_ids.nil?
|
|
|
|
|
@flag = false
|
|
|
|
|
end
|
|
|
|
|
send_ids.each do |send_id|
|
|
|
|
|
project_ids = params[:projects_ids]
|
|
|
|
|
|
|
|
|
|
ori = Attachment.find_by_id(send_id)
|
|
|
|
|
unless project_ids.nil?
|
|
|
|
|
project_ids.each do |project_id|
|
|
|
|
@ -1154,6 +1205,7 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
else
|
|
|
|
|
@flag=true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
@ -1404,13 +1456,13 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@type = params[:type]
|
|
|
|
|
@limit = 15
|
|
|
|
|
@limit = 25
|
|
|
|
|
@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,15
|
|
|
|
|
@attachments = paginateHelper @attachments,25
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
format.html {render :layout => 'new_base_user'}
|
|
|
|
@ -1456,13 +1508,13 @@ class UsersController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
@type = params[:type]
|
|
|
|
|
@limit = 15
|
|
|
|
|
@limit = 25
|
|
|
|
|
@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,15
|
|
|
|
|
@attachments = paginateHelper @attachments,25
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.js
|
|
|
|
|
end
|
|
|
|
|