|
|
|
@ -518,7 +518,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
|
begin
|
|
|
|
|
#cloud_bridge = edu_setting('cloud_bridge')
|
|
|
|
|
cloud_bridge = edu_setting('cloud_bridge')
|
|
|
|
|
myshixun_identifier = generate_identifier Myshixun, 10
|
|
|
|
|
myshixun = @shixun.myshixuns.create!(user_id: current_user.id, identifier: myshixun_identifier,
|
|
|
|
|
modify_time: @shixun.modify_time, reset_time: @shixun.reset_time,
|
|
|
|
@ -622,10 +622,16 @@ class ShixunsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def add_collaborators
|
|
|
|
|
raise("搜索内容不能为空") unless params[:search]
|
|
|
|
|
member_ids = "(" + @shixun.shixun_members.map(&:user_id).join(',') + ")"
|
|
|
|
|
condition = "%#{params[:search].strip}%".gsub(" ","")
|
|
|
|
|
@users = User.where("id not in #{member_ids} and status = 1 and LOWER(concat(lastname, firstname, login, mail, nickname)) LIKE '#{condition}'")
|
|
|
|
|
user_name = "%#{params[:user_name].strip}%"
|
|
|
|
|
school_name = "%#{params[:school_name].strip}%"
|
|
|
|
|
if user_name.present? || school_name.present?
|
|
|
|
|
@users = User.joins(user_extension: :school).where("users.id not in #{member_ids} AND users.status = 1 AND
|
|
|
|
|
LOWER(users.lastname) LIKE '#{user_name}' AND LOWER(schools.name) LIKE
|
|
|
|
|
'#{school_name}'")
|
|
|
|
|
else
|
|
|
|
|
@users = User.none
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def shixun_members_added
|
|
|
|
@ -667,14 +673,14 @@ class ShixunsController < ApplicationController
|
|
|
|
|
limit = params[:limit] || 20
|
|
|
|
|
if params[:search]
|
|
|
|
|
search = "%#{params[:search].to_s.strip.downcase}%"
|
|
|
|
|
course_ids = Course.find_by_sql("SELECT c.id FROM courses c, members m, member_roles mr
|
|
|
|
|
WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9)
|
|
|
|
|
course_ids = Course.find_by_sql("SELECT c.id FROM courses c, course_members m
|
|
|
|
|
WHERE m.course_id = c.id AND m.role in (1,2,3)
|
|
|
|
|
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0
|
|
|
|
|
AND c.name like '#{search}' ").map(&:id)
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
course_ids = Course.find_by_sql("SELECT c.id, c.name FROM courses c, members m, member_roles mr
|
|
|
|
|
WHERE m.course_id = c.id AND m.id=mr.member_id AND mr.role_id in (3,7,9)
|
|
|
|
|
course_ids = Course.find_by_sql("SELECT c.id, c.name FROM courses c, course_members m
|
|
|
|
|
WHERE m.course_id = c.id AND m.role in (1,2,3)
|
|
|
|
|
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id)
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
@ -686,7 +692,7 @@ class ShixunsController < ApplicationController
|
|
|
|
|
# 将实训发送到课程
|
|
|
|
|
def send_to_course
|
|
|
|
|
@course = Course.find(params[:course_id])
|
|
|
|
|
homework = HomeworksService.new.create_homework shixun, @course, nil, current_user
|
|
|
|
|
homework = HomeworksService.new.create_homework @shixun, @course, nil, current_user
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# 二维码扫描下载
|
|
|
|
|