diff --git a/app/assets/javascripts/admin.js b/app/assets/javascripts/admin.js index 1e1f384ff..27844be53 100644 --- a/app/assets/javascripts/admin.js +++ b/app/assets/javascripts/admin.js @@ -19,6 +19,8 @@ $.fn.select2.defaults.set('theme', 'bootstrap4'); $.fn.select2.defaults.set('language', 'zh-CN'); +Turbolinks.setProgressBarDelay(200); + $(document).on('turbolinks:load', function(){ $('[data-toggle="tooltip"]').tooltip(); $('[data-toggle="popover"]').popover(); diff --git a/app/controllers/admins/base_controller.rb b/app/controllers/admins/base_controller.rb index 43f18b39c..6f89e7afa 100644 --- a/app/controllers/admins/base_controller.rb +++ b/app/controllers/admins/base_controller.rb @@ -7,6 +7,8 @@ class Admins::BaseController < ApplicationController before_action :require_login, :require_admin! + after_action :rebind_event_if_ajax_render_partial + private def require_login @@ -21,4 +23,16 @@ class Admins::BaseController < ApplicationController render_forbidden end + + # 触发after ajax render partial hooks,执行一些因为局部刷新后失效的绑定事件 + def rebind_event_if_ajax_render_partial + return if request.format.symbol != :js + return if response.content_type != 'text/javascript' + + path = Rails.root.join('app/views/admins/shared/after_render_js_hook.js.erb') + return unless File.exists?(path) + + append_js = ERB.new(File.open(path).read).result + response.body += append_js + end end \ No newline at end of file diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index bea9e6173..57eed15fd 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -40,7 +40,7 @@ class ApplicationController < ActionController::Base if @user_course_identity > Course::STUDENT && @course.is_public == 0 tip_exception(401, "..") unless User.current.logged? check_account - tip_exception(409, "您没有权限进入") + tip_exception(@course.excellent ? 410 : 409, "您没有权限进入") end uid_logger("###############user_course_identity:#{@user_course_identity}") end @@ -568,7 +568,7 @@ class ApplicationController < ActionController::Base end def strf_date(date) - date.blank? ? '' : date.strftime("%Y-%m-%d") + date.blank? ? '' : date.to_date.strftime("%Y-%m-%d") end def logger_error(error) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index d6694baa6..6194b7b41 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -26,7 +26,7 @@ class CoursesController < ApplicationController :base_info, :get_historical_courses, :create_group_by_importing_file, :attahcment_category_list,:export_member_scores_excel, :duplicate_course, :switch_to_teacher, :switch_to_assistant, :switch_to_student, :exit_course, - :informs, :update_informs, :online_learning, :update_task_position, :tasks_list] + :informs, :update_informs, :online_learning, :update_task_position, :tasks_list, :join_excellent_course] before_action :user_course_identity, except: [:join_excellent_course, :index, :create, :new, :apply_to_join_course, :search_course_list, :get_historical_course_students, :mine, :search_slim] before_action :teacher_allowed, only: [:update, :destroy, :settings, :search_teacher_candidate, @@ -158,6 +158,8 @@ class CoursesController < ApplicationController @course.subject.subject_members.where.not(user_id: current_user.id).each do |s_member| CourseMember.create!(course_id: @course.id, user_id: s_member.user_id, role: 2) end + + Inform.create(container: @course, description: @subject.learning_notes) end course_module_types = params[:course_module_types] @@ -179,7 +181,7 @@ class CoursesController < ApplicationController extra_params = Hash.new extra_params[:school_id] = @school.id - if @course.is_end && (course_params[:end_date].blank? || course_params[:end_date].to_date > Date.today) + if @course.is_end && (course_params[:end_date].blank? || course_params[:end_date].to_date >= Date.today) extra_params[:is_end] = 0 elsif !@course.is_end && !course_params[:end_date].blank? && course_params[:end_date].to_date < Date.today extra_params[:is_end] = 1 @@ -1193,8 +1195,8 @@ class CoursesController < ApplicationController @subject = @course.present? ? @course.subject : Subject.find_by!(id: params[:subject_id]) tip_exception("开始时间不能为空") if params[:start_date].blank? tip_exception("结束时间不能为空") if params[:end_date].blank? - tip_exception("结束时间必须晚于开始时间") if params[:end_date] <= params[:start_date] - tip_exception("开始时间和结束时间不能与往期开课时间重叠") if @course.nil? && @subject.max_course_end_date && params[:start_date] <= strf_date(@subject.max_course_end_date) + tip_exception("结束时间必须晚于开始时间") if strf_date(params[:end_date]) <= strf_date(params[:start_date]) + tip_exception("开始时间和结束时间不能与往期开课时间重叠") if @course.nil? && @subject.max_course_end_date && strf_date(params[:start_date]) <= strf_date(@subject.max_course_end_date) validate_start_end_date if @course.present? tip_exception("开放课堂必须包含公告栏和在线学习模块") unless params[:course_module_types].include?("announcement") && params[:course_module_types].include?("online_learning") end @@ -1206,8 +1208,8 @@ class CoursesController < ApplicationController def validate_start_end_date prev_course = @subject.courses.where("id < #{@course.id}").last 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 next_course && params[:end_date] >= strf_date(next_course.start_date) + tip_exception("开始时间不能与往期开课时间重叠") if prev_course && strf_date(params[:start_date]) <= strf_date(prev_course.end_date) + tip_exception("结束时间不能与后期开课时间重叠") if next_course && strf_date(params[:end_date]) >= strf_date(next_course.start_date) end # 超级管理员和课堂管理员的权限判断 diff --git a/app/helpers/subjects_helper.rb b/app/helpers/subjects_helper.rb index 8aff41d25..75ae9f041 100644 --- a/app/helpers/subjects_helper.rb +++ b/app/helpers/subjects_helper.rb @@ -24,8 +24,8 @@ module SubjectsHelper elsif course.start_date && course.start_date > Date.today {status: 0, time: ""} elsif course.start_date && course.start_date <= Date.today && course.end_date >= Date.today - sum_week = ((course.end_date - course.start_date).to_i / 7.0).ceil - curr_week = ((Date.today - course.start_date).to_i / 7.0).ceil + sum_week = (((course.end_date - course.start_date).to_i + 1) / 7.0).ceil + curr_week = (((Date.today - course.start_date).to_i + 1) / 7.0).ceil {status: 1, time: "进行至第#{curr_week}周,共#{sum_week}周"} else {status: -1, time: ""} diff --git a/app/views/admins/daily_school_statistics/shared/_list.html.erb b/app/views/admins/daily_school_statistics/shared/_list.html.erb index b71be485e..af23e09f6 100644 --- a/app/views/admins/daily_school_statistics/shared/_list.html.erb +++ b/app/views/admins/daily_school_statistics/shared/_list.html.erb @@ -1,12 +1,12 @@
单位名称 | +单位名称 | -<%= sort_tag('教师总人数', name: 'teacher_count', path: admins_daily_school_statistics_path) %> | -<%= sort_tag('学生总人数', name: 'student_count', path: admins_daily_school_statistics_path) %> | +<%= sort_tag('教师总数', name: 'teacher_count', path: admins_daily_school_statistics_path) %> | +<%= sort_tag('学生总数', name: 'student_count', path: admins_daily_school_statistics_path) %> | <%= sort_tag('课堂总数', name: 'course_count', path: admins_daily_school_statistics_path) %> | -<%= sort_tag('正在进行课堂数', name: 'active_course_count', path: admins_daily_school_statistics_path) %> | +<%= sort_tag('正在进行课堂数', name: 'active_course_count', path: admins_daily_school_statistics_path) %> | <%= sort_tag('实训总数', name: 'shixun_count', path: admins_daily_school_statistics_path) %> | <%= sort_tag('实训评测总数', name: 'shixun_evaluate_count', path: admins_daily_school_statistics_path) %> @@ -14,17 +14,16 @@ | <%= sort_tag('实训作业总数', name: 'homework_count', path: admins_daily_school_statistics_path) %> | <%= sort_tag('其它作业总数', name: 'other_homework_count', path: admins_daily_school_statistics_path) %> | -<%= sort_tag('动态时间', name: 'nearly_course_time', path: admins_daily_school_statistics_path) %> | +<%= sort_tag('动态时间', name: 'nearly_course_time', path: admins_daily_school_statistics_path) %> |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
- <%= link_to '#' do %> - <%= overflow_hidden_span statistic[:name], width: '200px' %> - <% end %> + | + <%= link_to statistic[:name], "/colleges/#{statistic[:id]}/statistics", + target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' } %> | <%= statistic[:teacher_count].to_i %> | <%= statistic[:student_count].to_i %> | diff --git a/app/views/admins/school_statistics/shared/_contrast_list.html.erb b/app/views/admins/school_statistics/shared/_contrast_list.html.erb index 049711ca2..928340c80 100644 --- a/app/views/admins/school_statistics/shared/_contrast_list.html.erb +++ b/app/views/admins/school_statistics/shared/_contrast_list.html.erb @@ -30,7 +30,8 @@ <% statistics.each do |statistic| %>|||||||||||
- <%= link_to statistic.school_name, '' %> + <%= link_to statistic.school_name, "/colleges/#{statistic.school_id}/statistics", + target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' } %> | <%= statistic['total'] %> | <%= statistic['other_total'] %> | diff --git a/app/views/admins/school_statistics/shared/_list.html.erb b/app/views/admins/school_statistics/shared/_list.html.erb index 72b92c13d..aa043f097 100644 --- a/app/views/admins/school_statistics/shared/_list.html.erb +++ b/app/views/admins/school_statistics/shared/_list.html.erb @@ -35,7 +35,8 @@ <% statistics.each do |statistic| %>||||||||||||
- <%= link_to statistic.school_name, '' %> + <%= link_to statistic.school_name, "/colleges/#{statistic.school_id}/statistics", + target: '_blank', data: { toggle: 'tooltip', title: '点击查看学校统计概况' } %> | <%= statistic.teacher_increase_count.to_i %> | <%= statistic.student_increase_count.to_i %> | diff --git a/app/views/admins/shared/after_render_js_hook.js.erb b/app/views/admins/shared/after_render_js_hook.js.erb new file mode 100644 index 000000000..9ceb13f5c --- /dev/null +++ b/app/views/admins/shared/after_render_js_hook.js.erb @@ -0,0 +1,3 @@ +; +$('[data-toggle="tooltip"]').tooltip(); +$('[data-toggle="popover"]').popover(); \ No newline at end of file diff --git a/config/locales/tidings/zh-CN.yml b/config/locales/tidings/zh-CN.yml index 347b0139a..e6e8e676d 100644 --- a/config/locales/tidings/zh-CN.yml +++ b/config/locales/tidings/zh-CN.yml @@ -49,9 +49,9 @@ Apply_end: "申请发布实训:%{name}" ApplySubject: System: - "1_end": "你提交的实训课程发布申请:%{name},审核已通过" - "2_end": "你提交的实训课程发布申请:%{name},审核未通过