|
|
@ -3,8 +3,8 @@ class EcCoursesController < ApplicationController
|
|
|
|
layout 'base_ec'
|
|
|
|
layout 'base_ec'
|
|
|
|
before_filter :find_ec_course, :except => [:create, :get_calculation_data, :sync_all_course_data]
|
|
|
|
before_filter :find_ec_course, :except => [:create, :get_calculation_data, :sync_all_course_data]
|
|
|
|
before_filter :find_year, :only => [:create, :get_calculation_data]
|
|
|
|
before_filter :find_year, :only => [:create, :get_calculation_data]
|
|
|
|
before_filter :require_login
|
|
|
|
before_filter :require_login, :except => [:sync_all_course_data]
|
|
|
|
before_filter :ec_auth, :except => [:sync_all_course_data]
|
|
|
|
before_filter :ec_auth, :except => [:search_courses]
|
|
|
|
skip_before_filter :verify_authenticity_token, :only => [:crud_targets, :crud_score_level, :sync_all_course_data, :search_courses,
|
|
|
|
skip_before_filter :verify_authenticity_token, :only => [:crud_targets, :crud_score_level, :sync_all_course_data, :search_courses,
|
|
|
|
:correlation_course, :delete_course]
|
|
|
|
:correlation_course, :delete_course]
|
|
|
|
|
|
|
|
|
|
|
@ -349,11 +349,11 @@ class EcCoursesController < ApplicationController
|
|
|
|
if user.try(:admin?)
|
|
|
|
if user.try(:admin?)
|
|
|
|
courses = Course.where(:is_delete => 0)
|
|
|
|
courses = Course.where(:is_delete => 0)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
course_ids = Member.where("user_id = #{params[:user_id]} and course_id != -1").pluck(:course_id)
|
|
|
|
course_ids = Member.where("user_id = #{user.try(:id)} and course_id != -1").pluck(:course_id)
|
|
|
|
courses = Course.where(:is_delete => 0, :id => course_ids)
|
|
|
|
courses = Course.where(:is_delete => 0, :id => course_ids)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if params[:search] && params[:search].strip != ""
|
|
|
|
if params[:search] && params[:search].strip != ""
|
|
|
|
courses = courses.where("name like '%#{params[:search].strip}%'").reorder("created_at desc")
|
|
|
|
courses = courses.where("name like ?", "%#{params[:search].strip}%").reorder("created_at desc")
|
|
|
|
else
|
|
|
|
else
|
|
|
|
courses = courses.reorder("created_at desc")
|
|
|
|
courses = courses.reorder("created_at desc")
|
|
|
|
end
|
|
|
|
end
|
|
|
|