|
|
@ -41,7 +41,6 @@ class CoursesController < ApplicationController
|
|
|
|
before_action :find_board, only: :board_list
|
|
|
|
before_action :find_board, only: :board_list
|
|
|
|
before_action :validate_page_size, only: :mine
|
|
|
|
before_action :validate_page_size, only: :mine
|
|
|
|
before_action :course_tasks, only: [:tasks_list, :update_task_position]
|
|
|
|
before_action :course_tasks, only: [:tasks_list, :update_task_position]
|
|
|
|
before_action :find_container, only: [:update_task_position]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if RUBY_PLATFORM =~ /linux/
|
|
|
|
if RUBY_PLATFORM =~ /linux/
|
|
|
|
require 'simple_xlsx_reader'
|
|
|
|
require 'simple_xlsx_reader'
|
|
|
@ -62,6 +61,9 @@ class CoursesController < ApplicationController
|
|
|
|
@courses = Course.where(is_delete: 0, is_hidden: 0, is_end: 0)
|
|
|
|
@courses = Course.where(is_delete: 0, is_hidden: 0, is_end: 0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 金课未开课的不显示在首页
|
|
|
|
|
|
|
|
@courses = @courses.where("start_date is null or start_date <= '#{Date.today}'")
|
|
|
|
|
|
|
|
|
|
|
|
# 根据搜索关键字进一步筛选
|
|
|
|
# 根据搜索关键字进一步筛选
|
|
|
|
if params[:search].present?
|
|
|
|
if params[:search].present?
|
|
|
|
# REDO:Extension
|
|
|
|
# REDO:Extension
|
|
|
@ -1150,17 +1152,20 @@ class CoursesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def update_task_position
|
|
|
|
def update_task_position
|
|
|
|
tip_exception("缺少position参数") if params[:position].blank?
|
|
|
|
Rails.logger.info("#######task_ids_length#{params[:task_ids].uniq.length}#########task_count:#{@tasks.count}")
|
|
|
|
unless params[:position].to_i == @task.position
|
|
|
|
tip_exception("task_ids参数有误") if params[:task_ids].blank? || params[:task_ids].uniq.length != @tasks.count
|
|
|
|
if params[:position].to_i < @task.position
|
|
|
|
ActiveRecord::Base.transaction do
|
|
|
|
@tasks.where("position < #{@task.position} and position >= ?", params[:position]).update_all("position = position + 1")
|
|
|
|
begin
|
|
|
|
else
|
|
|
|
@tasks.each do |task|
|
|
|
|
@tasks.where("position > #{@task.position} and position <= ?", params[:position]).update_all("position = position - 1")
|
|
|
|
position = params[:task_ids].reverse.index(task.id).to_i + 1
|
|
|
|
|
|
|
|
task.update_attributes!(position: position)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@task.update_attributes(position: params[:position])
|
|
|
|
|
|
|
|
normal_status(0, "移动成功")
|
|
|
|
normal_status(0, "移动成功")
|
|
|
|
else
|
|
|
|
rescue Exception => e
|
|
|
|
normal_status(-1, "位置没有变化")
|
|
|
|
uid_logger(e.message)
|
|
|
|
|
|
|
|
tip_exception(e.message)
|
|
|
|
|
|
|
|
raise ActiveRecord::Rollback
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
@ -1199,8 +1204,8 @@ class CoursesController < ApplicationController
|
|
|
|
def validate_start_end_date
|
|
|
|
def validate_start_end_date
|
|
|
|
prev_course = @subject.courses.where("id < #{@course.id}").last
|
|
|
|
prev_course = @subject.courses.where("id < #{@course.id}").last
|
|
|
|
next_course = @subject.courses.where("id > #{@course.id}").first
|
|
|
|
next_course = @subject.courses.where("id > #{@course.id}").first
|
|
|
|
tip_exception("开始时间和结束时间不能与其他期开课时间重叠") if prev_course && params[:start_date] <= strf_date(prev_course.end_date)
|
|
|
|
tip_exception("开始时间不能与往期开课时间重叠") if prev_course && params[:start_date] <= strf_date(prev_course.end_date)
|
|
|
|
tip_exception("开始时间和结束时间不能与其他期开课时间重叠") if next_course && params[:end_date] >= strf_date(next_course.start_date)
|
|
|
|
tip_exception("结束时间不能与后期开课时间重叠") if next_course && params[:end_date] >= strf_date(next_course.start_date)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
# 超级管理员和课堂管理员的权限判断
|
|
|
|
# 超级管理员和课堂管理员的权限判断
|
|
|
@ -1247,24 +1252,24 @@ class CoursesController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def find_container
|
|
|
|
# def find_container
|
|
|
|
case params[:container_type]
|
|
|
|
# case params[:container_type]
|
|
|
|
when 'shixun_homework', 'common_homework', 'group_homework'
|
|
|
|
# when 'shixun_homework', 'common_homework', 'group_homework'
|
|
|
|
@task = HomeworkCommon.find_by(id: params[:container_id])
|
|
|
|
# @task = HomeworkCommon.find_by(id: params[:container_id])
|
|
|
|
when 'exercise'
|
|
|
|
# when 'exercise'
|
|
|
|
@task = Exercise.find_by(id: params[:container_id])
|
|
|
|
# @task = Exercise.find_by(id: params[:container_id])
|
|
|
|
when 'poll'
|
|
|
|
# when 'poll'
|
|
|
|
@task = Poll.find_by(id: params[:container_id])
|
|
|
|
# @task = Poll.find_by(id: params[:container_id])
|
|
|
|
when 'graduation_topic'
|
|
|
|
# when 'graduation_topic'
|
|
|
|
@task = GraduationTopic.find_by(id: params[:container_id])
|
|
|
|
# @task = GraduationTopic.find_by(id: params[:container_id])
|
|
|
|
when 'graduation_task'
|
|
|
|
# when 'graduation_task'
|
|
|
|
@task = GraduationTask.find_by(id: params[:container_id])
|
|
|
|
# @task = GraduationTask.find_by(id: params[:container_id])
|
|
|
|
when 'attachment'
|
|
|
|
# when 'attachment'
|
|
|
|
@task = Attachment.find_by(id: params[:container_id])
|
|
|
|
# @task = Attachment.find_by(id: params[:container_id])
|
|
|
|
else
|
|
|
|
# else
|
|
|
|
tip_exception("container_type参数有误")
|
|
|
|
# tip_exception("container_type参数有误")
|
|
|
|
end
|
|
|
|
# end
|
|
|
|
end
|
|
|
|
# end
|
|
|
|
|
|
|
|
|
|
|
|
def student_act_score group_id, search
|
|
|
|
def student_act_score group_id, search
|
|
|
|
sql_select = %Q{SELECT cm.*,(
|
|
|
|
sql_select = %Q{SELECT cm.*,(
|
|
|
|