云上实验室课堂

dev_home
cxt 5 years ago
parent 8cbe1f84dc
commit fe11c1eab3

@ -160,5 +160,16 @@ $(document).on('turbolinks:load', function() {
$addMemberModal.modal('hide');
}
});
$(".laboratory-list-container").on("change", '.laboratory-sync-course', function () {
var s_id = $(this).attr("data-id");
var json = {};
$.ajax({
url: "/admins/laboratories/" + s_id + "/update_sync_course",
type: "POST",
dataType:'script',
data: json
})
});
}
});

@ -56,6 +56,10 @@ class Admins::LaboratoriesController < Admins::BaseController
users.update_all(laboratory_id: current_laboratory.id)
end
def update_sync_course
current_laboratory.update!(sync_course: !current_laboratory.sync_course)
@laboratory = current_laboratory
end
private

@ -61,7 +61,7 @@ class CoursesController < ApplicationController
@user = current_user
# 根据分类查询课堂(全部,我的,最新,最热)
@order = params[:order].present? ? params[:order] : "all"
@courses = current_laboratory.courses.not_deleted
@courses = current_laboratory.all_courses.not_deleted
if @order == "visits"
order_str = "courses.id = 1309 DESC, courses.visits DESC"
@courses = @courses.where(is_hidden: 0)

@ -977,9 +977,7 @@ class ShixunsController < ApplicationController
@courses = Course.where(:id => course_ids)
## 云上实验室过滤
unless current_laboratory.main_site?
@courses = @courses.where(laboratory_id: current_laboratory.id )
end
@courses = @courses.where(id: current_laboratory.all_courses)
@course_count = @courses.count
@courses = @courses.page(page).per(limit)

@ -218,9 +218,8 @@ class SubjectsController < ApplicationController
AND m.user_id=#{current_user.id} AND c.is_delete = 0 AND c.is_end = 0").map(&:id)
@courses = Course.where(id: course_ids)
## 云上实验室过滤
unless current_laboratory.main_site?
@courses = @courses.where(laboratory_id: current_laboratory.id )
end
@courses = @courses.where(id: current_laboratory.all_courses)
@none_shixun_ids = ShixunSchool.where("school_id != #{current_user.user_extension.try(:school_id).to_i}").pluck(:shixun_id)
end

@ -2,7 +2,7 @@ class Users::CoursesController < Users::BaseController
def index
courses = Users::CourseService.new(observed_user, query_params).call
courses = courses.where(laboratory_id: current_laboratory.id)
courses = courses.where(id: current_laboratory.all_courses)
@count = courses.count
@courses = paginate(courses.includes(teacher: { user_extension: :school }), special: observed_user.is_teacher?)

@ -54,6 +54,10 @@ class Laboratory < ApplicationRecord
main_site? ? Subject.all : Subject.joins(:laboratory_subjects).where(laboratory_subjects: { laboratory_id: id })
end
def all_courses
main_site? || !sync_course ? courses : courses.or(Course.where(school_id: school_id))
end
def shixun_repertoires
where_sql = ShixunTagRepertoire.where("shixun_tag_repertoires.tag_repertoire_id = tag_repertoires.id")

@ -29,6 +29,11 @@
</div>
</td>
<td><%= laboratory.created_at.strftime('%Y-%m-%d %H:%M') %></td>
<td>
<% if school.present? && laboratory.id != 1 %>
<%= check_box_tag :sync_course,!laboratory.sync_course,laboratory.sync_course,remote:true,data:{id:laboratory.id},class:"laboratory-sync-course" %>
<% end %>
</td>
<td class="action-container">
<%= link_to '定制', admins_laboratory_laboratory_setting_path(laboratory), class: 'action' %>

@ -1,11 +1,12 @@
<table class="table table-hover text-center laboratory-list-table">
<thead class="thead-light">
<tr>
<th width="20%" class="text-left">单位名称</th>
<th width="14%" class="text-left">单位名称</th>
<th width="16%" class="text-left">域名</th>
<th width="10%">统计链接</th>
<th width="22%">管理员</th>
<th width="14%"><%= sort_tag('创建时间', name: 'id', path: admins_laboratories_path) %></th>
<th width="6%" title="同步显示显示主站下该单位的课堂">同步课堂</th>
<th width="20%">操作</th>
</tr>
</thead>

@ -0,0 +1 @@
$("#laboratory-item-<%= @laboratory.id %>").html("<%= j render partial: 'admins/laboratories/shared/laboratory_item', locals: {laboratory: @laboratory} %>")

@ -1077,6 +1077,7 @@ Rails.application.routes.draw do
get :shixuns_for_select
get :subjects_for_select
get :synchronize_user
post :update_sync_course
end
resource :laboratory_setting, only: [:show, :update]

@ -0,0 +1,5 @@
class AddSyncCourseToLaboratorySettings < ActiveRecord::Migration[5.2]
def change
add_column :laboratories, :sync_course, :boolean, default: 0
end
end
Loading…
Cancel
Save