Merge remote-tracking branch 'origin/dev_aliyun' into dev_tj

merge from aliyun
dev_forge
tangjiang 5 years ago
commit 88379e4c1a

@ -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)

@ -768,8 +768,9 @@ class GamesController < ApplicationController
# REDO:需要添加详细的说明
def cost_time
#return if @game.status >= 2
cost_time = (Time.now.to_i - @game.close_browse_time.to_i) + @game.cost_time.to_i
@game.update_attributes(close_browse_time: Time.now, cost_time: cost_time)
cost_time = (Time.now.to_i - @game.play_time.to_i) + @game.cost_time.to_i
@game.update_attributes(cost_time: cost_time, play_sign: 0)
render_ok
end
# 同步challenge的更新时间
@ -939,7 +940,13 @@ class GamesController < ApplicationController
game.update_attributes(status: 0, open_time: Time.now) if game.open_time.blank? || game.status == 3
# 开启实训更新myshixuns的时间方便跟踪用于的学习进度。
game.myshixun.update_column(:updated_at, Time.now)
@game.update_attribute(:close_browse_time, Time.now) if game.status < 2 && @game.close_browse_time.nil?
# 如果异常关闭的话 更新完关卡的时间
if game.status < 2 && @game.play_sign == 0
@game.update_attributes(play_time: Time.now, play_sign: 1)
elsif game.status < 2 && @game.play_sign == 1
cost_time = Time.now.to_i - (@game.play_time.presence || Time.now).to_i + cost_time.to_i
@game.update_attributes(play_time: Time.now, cost_time: cost_time, play_sign: 1)
end
end
# vnc连接

@ -38,7 +38,6 @@ class GitsController < ApplicationController
else
# 用户是否对对象拥有权限
system_user = User.find_by_login(input_username) || User.find_by_mail(input_username) || User.find_by_phone(input_username)
# 如果用户名密码错误
if system_user && !system_user.check_password?(input_password)
uid_logger_error("git start: password is wrong")
@ -49,7 +48,7 @@ class GitsController < ApplicationController
shixunname = git_url.split("/")[1].split(".")[0]
repo_name = username + "/" + shixunname
uid_logger("git start: repo_name is #{repo_name}")
shixun = Shixun.select([:id, :user_id, :repo_name, :identifier]).where(repo_name: repo_name, laboratory_id: nil).first
shixun = Shixun.select([:id, :user_id, :repo_name, :identifier]).where(repo_name: repo_name).first
uid_logger("git start auth: shixun identifier is #{shixun.try(:identifier)}")
uid_logger("git start auth: systemuser is #{system_user.try(:login)}")
@ -64,7 +63,7 @@ class GitsController < ApplicationController
else
uid_logger_error("shixun is not exist")
# result = false
result = true # 为了测试跳出
result = false # 为了测试跳出
end
end
end

@ -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?)

@ -66,7 +66,18 @@ class Weapps::CoursesController < Weapps::BaseController
end
def students
@course = current_course
course_group_id = params[:course_group_id].present? ? params[:course_group_id].to_i : nil
@students = CourseMember.students(@course)
if course_group_id.present?
course_group = CourseGroup.find(course_group_id) if course_group_id != 0
@students = @students.where(course_group_id: course_group&.id.to_i)
end
@students_count = @students.size
@students = @students.includes(user: :user_extension)
end
# 批量修改角色

@ -3,7 +3,7 @@
# modify_time 与challenges表的modify_time联合使用2个字段一致则标识测试集未修改反之被修改
# answer_open: 查看查看答案的深度, 0: 未查看过答案, 其他数值与challenge_answer的level值相关
# answer_deduction: 查看答案扣分的百分比;如 查看答案 扣除70%
#
#play_sign 与play_time: sign记录浏览器是否正常关闭 0表示正常1表示非正常 play_time表示游玩时间
class Game < ApplicationRecord
default_scope { order("games.created_at desc") }

@ -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")

@ -5,7 +5,8 @@ class Subjects::CopySubjectService < ApplicationService
@subject = subject
@user = user
@laboratory = laboratory
subject_params = subject.attributes.dup.except('id', 'copy_subject_id', 'user_id', 'homepage_show')
subject_params = subject.attributes.dup.except('id', 'copy_subject_id', 'user_id', 'homepage_show',
'stages_count', 'shixuns_count', 'stage_shixuns_count')
@to_subject = Subject.new(subject_params)
end
@ -59,7 +60,7 @@ class Subjects::CopySubjectService < ApplicationService
shixun = stage_shixun.shixun
to_shixun = Shixun.new
to_shixun.attributes = shixun.attributes.dup.except('id', 'user_id', 'identifier', 'homepage_show',
'use_scope', 'averge_star', 'myshixuns_count')
'use_scope', 'averge_star', 'myshixuns_count', 'challenges_count')
to_shixun.identifier = Util::UUID.generate_identifier(Shixun, 8)
to_shixun.user_id = user.id
if laboratory

@ -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} %>")

@ -7,7 +7,6 @@
<th width="8%">技术体系</th>
<th width="8%">等级体系</th>
<th width="8%">封面</th>
<th width="8%">二维码图片</th>
<th width="7%">创建者</th>
<th width="10%">单位</th>
<th width="6%">开课人数</th>
@ -34,13 +33,6 @@
<%= image_tag(image_exists ? Util::FileManage.source_disk_file_url(subject) : '', height: 40, class: "w-100 preview-image subject-image-#{subject.id}", style: image_exists ? '' : 'display:none') %>
<%= javascript_void_link image_exists ? '重新上传' : '上传图片', class: 'action upload-image-action', data: { source_id: subject.id, source_type: 'Subject', toggle: 'modal', target: '.admin-upload-file-modal' } %>
</td>
<td class="subject-setting-qrcode-image">
<% codeImageExists = Util::FileManage.exists?(subject, '_qrcode') %>
<% imageUrl = codeImageExists ? Util::FileManage.source_disk_file_url(subject, '_qrcode') : '' %>
<%= image_tag(imageUrl, width: 60, height: 40, class: "preview-image subject-weapp-image-#{subject.id}", data: { toggle: 'tooltip', title: '点击预览' }, style: codeImageExists ? '' : 'display:none') %>
<%= raw '<br/>' if codeImageExists %>
<%= javascript_void_link codeImageExists ? '重新上传' : '上传图片', class: 'action upload-subject-qrcode-image-action', data: { source_id: subject.id, source_type: 'Subject', suffix: '_qrcode', toggle: 'modal', target: '.admin-upload-file-modal' } %>
</td>
<td><%= subject.user.real_name %></td>
<td><%= subject.user.school_name %></td>
<td><%= subject.student_count %></td>

@ -0,0 +1,12 @@
json.students do
json.array! @students do |student|
json.user_id student.user_id
json.login student.user.try(:login)
json.name student.user.try(:real_name)
json.student_id student.user.try(:student_id)
json.course_member_id student.id
json.user_phone @course.excellent ? "" : student.user.hidden_phone
json.image_url url_to_avatar(student.user)
end
end
json.students_count @students_count

@ -908,6 +908,8 @@ Rails.application.routes.draw do
get :teachers
delete :delete_course_teachers
post :change_member_roles
get :students
delete :delete_course_students
end
end
end
@ -1075,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]

@ -1,5 +0,0 @@
class AddCloseBrowserTimeForGames < ActiveRecord::Migration[5.2]
def change
add_column :games, :close_browse_time, :timestamp
end
end

@ -0,0 +1,6 @@
class AddCloseBrowserTimeForGames < ActiveRecord::Migration[5.2]
def change
add_column :games, :play_time, :timestamp
add_column :games, :play_sign, :integer, :default => 0
end
end

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

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save