commit
24fac643cc
@ -0,0 +1,11 @@
|
|||||||
|
$(document).on('turbolinks:load', function () {
|
||||||
|
if ($('body.admins-projects-index-page').length > 0) {
|
||||||
|
var $form = $('.search-form');
|
||||||
|
|
||||||
|
// 清空
|
||||||
|
$form.on('click', '.clear-btn', function () {
|
||||||
|
$form.find('input[name="search"]').val('');
|
||||||
|
$form.find('input[type="submit"]').trigger('click');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,12 @@
|
|||||||
|
$(document).on('turbolinks:load', function () {
|
||||||
|
if ($('body.admins-shixun-modify-records-index-page').length > 0) {
|
||||||
|
var $form = $('.search-form');
|
||||||
|
|
||||||
|
// 清空
|
||||||
|
$form.on('click', '.clear-btn', function () {
|
||||||
|
$form.find('select[name="date"]').val('weekly');
|
||||||
|
$form.find('input[name="user_name"]').val('');
|
||||||
|
$form.find('input[type="submit"]').trigger('click');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
@ -0,0 +1,14 @@
|
|||||||
|
.diff{overflow:auto;}
|
||||||
|
.diff ul{background:#fff;overflow:auto;font-size:13px;list-style:none;margin:0;padding:0 1rem;display:table;width:100%;}
|
||||||
|
.diff del, .diff ins{display:block;text-decoration:none;}
|
||||||
|
.diff li{padding:0; display:table-row;margin: 0;height:1em;}
|
||||||
|
.diff li.ins{background:#dfd; color:#080}
|
||||||
|
.diff li.del{background:#fee; color:#b00}
|
||||||
|
.diff li:hover{background:#ffc}
|
||||||
|
|
||||||
|
/* try 'whitespace:pre;' if you don't want lines to wrap */
|
||||||
|
.diff del, .diff ins, .diff span{white-space:pre-wrap;font-family:courier;}
|
||||||
|
.diff del strong{font-weight:normal;background:#fcc;}
|
||||||
|
.diff ins strong{font-weight:normal;background:#9f9;}
|
||||||
|
.diff li.diff-comment { display: none; }
|
||||||
|
.diff li.diff-block-info { background: none repeat scroll 0 0 gray; }
|
@ -0,0 +1,7 @@
|
|||||||
|
.admins-shixun-feedback-messages-index-page {
|
||||||
|
.content-img {
|
||||||
|
img {
|
||||||
|
height: 60px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,7 +1,8 @@
|
|||||||
class AdminConstraint
|
class AdminConstraint
|
||||||
def matches?(request)
|
def matches?(request)
|
||||||
return false unless request.session[:user_id]
|
laboratory = Laboratory.first
|
||||||
user = User.find request.session[:user_id]
|
return false unless request.session[:"#{laboratory.try(:identifier).split('.').first}_user_id"]
|
||||||
|
user = User.find request.session[:"#{laboratory.try(:identifier).split('.').first}_user_id"]
|
||||||
user && user.admin?
|
user && user.admin?
|
||||||
end
|
end
|
||||||
end
|
end
|
@ -0,0 +1,9 @@
|
|||||||
|
class Admins::ShixunModifyRecordsController < Admins::BaseController
|
||||||
|
|
||||||
|
def index
|
||||||
|
records = Admins::ShixunModifyRecordQuery.call(params)
|
||||||
|
|
||||||
|
@records = paginate records.includes(:diff_record_content)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,38 @@
|
|||||||
|
class Weapps::HomeworkCommonsController < Weapps::BaseController
|
||||||
|
before_action :require_login
|
||||||
|
before_action :find_homework, :user_course_identity
|
||||||
|
before_action :teacher_allowed
|
||||||
|
|
||||||
|
def update_settings
|
||||||
|
begin
|
||||||
|
# 课堂结束后不能再更新
|
||||||
|
unless @course.is_end
|
||||||
|
UpdateHomeworkPublishSettingService.call(@homework, publish_params)
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
tip_exception("课堂已结束不能再更新")
|
||||||
|
end
|
||||||
|
rescue Exception => e
|
||||||
|
uid_logger(e.backtrace)
|
||||||
|
tip_exception(e.message)
|
||||||
|
raise ActiveRecord::Rollback
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def teacher_allowed
|
||||||
|
return render_forbidden unless @user_course_identity < Course::STUDENT
|
||||||
|
end
|
||||||
|
|
||||||
|
def find_homework
|
||||||
|
@homework = HomeworkCommon.find_by!(id: params[:id])
|
||||||
|
@course = @homework.course
|
||||||
|
@homework_detail_manual = @homework.homework_detail_manual
|
||||||
|
end
|
||||||
|
|
||||||
|
def publish_params
|
||||||
|
params.permit(:unified_setting, :publish_time, :end_time, group_settings: [:publish_time, :end_time, group_id: []])
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -1,4 +1,7 @@
|
|||||||
module CustomRegexp
|
module CustomRegexp
|
||||||
PHONE = /1\d{10}/
|
PHONE = /1\d{10}/
|
||||||
EMAIL = /^[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/
|
EMAIL = /\A[a-zA-Z0-9]+([._\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+\z/
|
||||||
|
LASTNAME = /\A[a-zA-Z0-9\u4e00-\u9fa5]+\z/
|
||||||
|
NICKNAME = /\A[\u4e00-\u9fa5_a-zA-Z0-9]+\z/
|
||||||
|
PASSWORD = /\A[a-z_A-Z0-9\-\.!@#\$%\\\^&\*\)\(\+=\{\}\[\]\/",'_<>~\·`\?:;|]{8,16}\z/
|
||||||
end
|
end
|
@ -1,6 +1,7 @@
|
|||||||
class HackSet < ApplicationRecord
|
class HackSet < ApplicationRecord
|
||||||
validates :input, presence: { message: "测试集输入不能为空" }
|
#validates :input, presence: { message: "测试集输入不能为空" }
|
||||||
validates :output, presence: { message: "测试集输出不能为空" }
|
validates :output, presence: { message: "测试集输出不能为空" }
|
||||||
|
validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同"
|
||||||
# 编程题测试集
|
# 编程题测试集
|
||||||
belongs_to :hack
|
belongs_to :hack
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
class HackUserCode < ApplicationRecord
|
class HackUserCode < ApplicationRecord
|
||||||
# 用户编程题的信息
|
# 用户编程题的信息
|
||||||
belongs_to :hack
|
belongs_to :hack
|
||||||
|
belongs_to :hack_user_lastest_code
|
||||||
|
|
||||||
|
scope :created_order, ->{ order("created_at desc")}
|
||||||
end
|
end
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
class ShixunServiceConfig < ApplicationRecord
|
class ShixunServiceConfig < ApplicationRecord
|
||||||
belongs_to :shixun
|
belongs_to :shixun
|
||||||
belongs_to :mirror_repository
|
belongs_to :mirror_repository
|
||||||
|
|
||||||
|
validates_presence_of :shixun_id, :mirror_repository_id
|
||||||
end
|
end
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
class Admins::ShixunModifyRecordQuery < ApplicationQuery
|
||||||
|
attr_reader :params
|
||||||
|
|
||||||
|
def initialize(params)
|
||||||
|
@params = params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
if params[:user_name].blank? || params[:date].blank?
|
||||||
|
records = DiffRecord.none
|
||||||
|
else
|
||||||
|
records = DiffRecord.joins(:user).where("concat(users.lastname, users.firstname) like ?", "%#{params[:user_name].strip}%")
|
||||||
|
if time_range.present?
|
||||||
|
records = records.where(created_at: time_range)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
records.order("diff_records.created_at desc")
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def time_range
|
||||||
|
@_time_range ||= begin
|
||||||
|
case params[:date]
|
||||||
|
when 'weekly' then 1.weeks.ago..Time.now
|
||||||
|
when 'monthly' then 1.months.ago..Time.now
|
||||||
|
when 'quarterly' then 3.months.ago..Time.now
|
||||||
|
when 'yearly' then 1.years.ago..Time.now
|
||||||
|
else ''
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -0,0 +1,104 @@
|
|||||||
|
class CreateShixunService < ApplicationService
|
||||||
|
attr_reader :user, :params, :permit_params
|
||||||
|
|
||||||
|
def initialize(user, permit_params, params)
|
||||||
|
@user = user
|
||||||
|
@params = params
|
||||||
|
@permit_params = permit_params
|
||||||
|
end
|
||||||
|
|
||||||
|
def call
|
||||||
|
shixun = Shixun.new(permit_params)
|
||||||
|
identifier = Util::UUID.generate_identifier(Shixun, 8)
|
||||||
|
shixun.identifier= identifier
|
||||||
|
shixun.user_id = user.id
|
||||||
|
main_mirror = MirrorRepository.find params[:main_type]
|
||||||
|
sub_mirrors = MirrorRepository.where(id: params[:sub_type])
|
||||||
|
ActiveRecord::Base.transaction do
|
||||||
|
shixun.save!
|
||||||
|
# 获取脚本内容
|
||||||
|
shixun_script = get_shixun_script(shixun, main_mirror, sub_mirrors)
|
||||||
|
# 创建额外信息
|
||||||
|
ShixunInfo.create!(shixun_id: shixun.id, evaluate_script: shixun_script, description: params[:description])
|
||||||
|
# 创建合作者
|
||||||
|
shixun.shixun_members.create!(user_id: user.id, role: 1)
|
||||||
|
# 创建镜像
|
||||||
|
ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => main_mirror.id)
|
||||||
|
# 创建主服务配置
|
||||||
|
ShixunServiceConfig.create!(:shixun_id => shixun.id, :mirror_repository_id => main_mirror.id)
|
||||||
|
# 创建子镜像相关数据(实训镜像关联表,子镜像服务配置)
|
||||||
|
sub_mirrors.each do |sub|
|
||||||
|
ShixunMirrorRepository.create!(:shixun_id => shixun.id, :mirror_repository_id => sub.id)
|
||||||
|
# 实训子镜像服务配置
|
||||||
|
name = sub.name #查看镜像是否有名称,如果没有名称就不用服务配置
|
||||||
|
ShixunServiceConfig.create!(:shixun_id => shixun.id, :mirror_repository_id => sub.id) if name.present?
|
||||||
|
end
|
||||||
|
# 创建版本库
|
||||||
|
repo_path = repo_namespace(user.login, shixun.identifier)
|
||||||
|
GitService.add_repository(repo_path: repo_path)
|
||||||
|
shixun.update_column(:repo_name, repo_path.split(".")[0])
|
||||||
|
# 如果是云上实验室,创建相关记录
|
||||||
|
if !Laboratory.current.main_site?
|
||||||
|
Laboratory.current.laboratory_shixuns.create!(shixun: shixun, ownership: true)
|
||||||
|
end
|
||||||
|
return shixun
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def get_shixun_script shixun, main_mirror, sub_mirrors
|
||||||
|
if !shixun.is_jupyter?
|
||||||
|
mirror = main_mirror.mirror_scripts
|
||||||
|
if main_mirror.blank?
|
||||||
|
modify_shixun_script shixun, mirror.first&.(:script)
|
||||||
|
else
|
||||||
|
sub_name = sub_mirrors.pluck(:type_name)
|
||||||
|
if main_mirror.type_name == "Java" && sub_name.include?("Mysql")
|
||||||
|
mirror.last.try(:script)
|
||||||
|
else
|
||||||
|
shixun_script = mirror.first&.script
|
||||||
|
modify_shixun_script shixun, shixun_script
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def modify_shixun_script shixun, script
|
||||||
|
if script.present?
|
||||||
|
source_class_name = []
|
||||||
|
challenge_program_name = []
|
||||||
|
shixun.challenges.map(&:exec_path).each do |exec_path|
|
||||||
|
challenge_program_name << "\"#{exec_path}\""
|
||||||
|
if shixun.main_mirror_name == "Java"
|
||||||
|
if exec_path.nil? || exec_path.split("src/")[1].nil?
|
||||||
|
source = "\"\""
|
||||||
|
else
|
||||||
|
source = "\"#{exec_path.split("src/")[1].split(".java")[0]}\""
|
||||||
|
end
|
||||||
|
logger.info("----source: #{source}")
|
||||||
|
source_class_name << source.gsub("/", ".") if source.present?
|
||||||
|
elsif shixun.main_mirror_name.try(:first) == "C#"
|
||||||
|
if exec_path.nil? || exec_path.split(".")[1].nil?
|
||||||
|
source = "\"\""
|
||||||
|
else
|
||||||
|
source = "\"#{exec_path.split(".")[0]}.exe\""
|
||||||
|
end
|
||||||
|
source_class_name << source if source.present?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
script = if script.include?("sourceClassName") && script.include?("challengeProgramName")
|
||||||
|
script.gsub(/challengeProgramNames=\(.*\)/,"challengeProgramNames=\(#{challenge_program_name.reject(&:blank?).join(" ")}\)").gsub(/sourceClassNames=\(.*\)/, "sourceClassNames=\(#{source_class_name.reject(&:blank?).join(" ")}\)")
|
||||||
|
else
|
||||||
|
script.gsub(/challengeProgramNames=\(.*\)/,"challengeProgramNames=\(#{challenge_program_name.reject(&:blank?).join(" ")}\)").gsub(/sourceClassNames=\(.*\)/, "sourceClassNames=\(#{challenge_program_name.reject(&:blank?).join(" ")}\)")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return script
|
||||||
|
end
|
||||||
|
|
||||||
|
# 版本库目录空间
|
||||||
|
def repo_namespace(user, shixun_identifier)
|
||||||
|
"#{user}/#{shixun_identifier}.git"
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
@ -0,0 +1,28 @@
|
|||||||
|
<td><%= list_index_no((params[:page] || 1).to_i, no) %></td>
|
||||||
|
<td><%= course.id %></td>
|
||||||
|
<td class="text-left">
|
||||||
|
<%= link_to(course.name, "/courses/#{course.id}", target: '_blank') %>
|
||||||
|
</td>
|
||||||
|
<td><%= course.course_members_count %></td>
|
||||||
|
<td><%= get_attachment_count(course, 0) %></td>
|
||||||
|
<td><%= course.course_homework_count(1) %></td>
|
||||||
|
<td><%= course.course_homework_count(3) %></td>
|
||||||
|
<td><%= course.course_homework_count(4) %></td>
|
||||||
|
<td><%= course.exercises_count %></td>
|
||||||
|
<td><%= course.evaluate_count %></td>
|
||||||
|
<td><%= course.is_public == 1 ? "--" : "√" %></td>
|
||||||
|
<td><%= course.is_end ? "已结束" : "正在进行" %></td>
|
||||||
|
<td><%= course.school&.name %></td>
|
||||||
|
<td><%= course.teacher&.real_name %></td>
|
||||||
|
<td><%= course.created_at&.strftime('%Y-%m-%d %H:%M') %></td>
|
||||||
|
<td>
|
||||||
|
<%= check_box_tag :homepage_show,!course.homepage_show,course.homepage_show,remote:true,data:{id:course.id},class:"course-setting-form" %>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<%= check_box_tag :email_notify,!course.email_notify,course.email_notify,remote:true,data:{id:course.id},class:"course-setting-form" %>
|
||||||
|
</td>
|
||||||
|
<td class="action-container">
|
||||||
|
<% if course.is_delete == 0 %>
|
||||||
|
<%= delete_link '删除', admins_course_path(course, element: ".course-item-#{course.id}"), class: 'delete-course-action' %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
@ -0,0 +1,3 @@
|
|||||||
|
var index = $("#course-item-<%= @course.id %>").children(":first").html();
|
||||||
|
$("#course-item-<%= @course.id %>").html("<%= j render partial: "admins/courses/shared/td",locals: {course: @course, no: 1} %>");
|
||||||
|
$("#course-item-<%= @course.id %>").children(":first").html(index);
|
@ -1,4 +1,6 @@
|
|||||||
$('.modal.admin-add-department-member-modal').modal('hide');
|
$('.modal.admin-add-department-member-modal').modal('hide');
|
||||||
$.notify({ message: '操作成功' });
|
$.notify({ message: '操作成功' });
|
||||||
|
|
||||||
$('.department-list-table .department-item-<%= current_department.id %>').html("<%= j(render partial: 'admins/departments/shared/department_item', locals: { department: current_department }) %>")
|
var index = $(".department-item-<%= current_department.id %>").children(":first").html();
|
||||||
|
$('.department-list-table .department-item-<%= current_department.id %>').html("<%= j(render partial: 'admins/departments/shared/department_item', locals: { department: current_department, index: 1 }) %>");
|
||||||
|
$(".department-item-<%= current_department.id %>").children(":first").html(index);
|
@ -1,4 +1,6 @@
|
|||||||
$('.modal.admin-edit-department-modal').modal('hide');
|
$('.modal.admin-edit-department-modal').modal('hide');
|
||||||
$.notify({ message: '操作成功' });
|
$.notify({ message: '操作成功' });
|
||||||
|
|
||||||
$('.department-list-table .department-item-<%= current_department.id %>').html("<%= j(render partial: 'admins/departments/shared/department_item', locals: { department: current_department }) %>")
|
var index = $(".department-item-<%= current_department.id %>").children(":first").html();
|
||||||
|
$('.department-list-table .department-item-<%= current_department.id %>').html("<%= j(render partial: 'admins/departments/shared/department_item', locals: {department: current_department, index: 1}) %>");
|
||||||
|
$(".department-item-<%= current_department.id %>").children(":first").html(index);
|
@ -0,0 +1,3 @@
|
|||||||
|
var index = $(".laboratory-item-<%= @laboratory.id %>").children(":first").html();
|
||||||
|
$(".laboratory-item-<%= @laboratory.id %>").html("<%= j render partial: "admins/laboratories/shared/laboratory_item",locals: {laboratory: @laboratory, index: 1} %>");
|
||||||
|
$(".laboratory-item-<%= @laboratory.id %>").children(":first").html(index);
|
@ -1 +1,3 @@
|
|||||||
$("#laboratory-item-<%= @laboratory.id %>").html("<%= j render partial: 'admins/laboratories/shared/laboratory_item', locals: {laboratory: @laboratory} %>")
|
var index = $(".laboratory-item-<%= @laboratory.id %>").children(":first").html();
|
||||||
|
$("#laboratory-item-<%= @laboratory.id %>").html("<%= j render partial: 'admins/laboratories/shared/laboratory_item', locals: {laboratory: @laboratory, index: 1} %>");
|
||||||
|
$(".laboratory-item-<%= @laboratory.id %>").children(":first").html(index);
|
@ -1,4 +1,6 @@
|
|||||||
$('.modal.admin-add-laboratory-user-modal').modal('hide');
|
$('.modal.admin-add-laboratory-user-modal').modal('hide');
|
||||||
$.notify({ message: '操作成功' });
|
$.notify({ message: '操作成功' });
|
||||||
|
|
||||||
$('.laboratory-list-table .laboratory-item-<%= current_laboratory.id %>').html("<%= j(render partial: 'admins/laboratories/shared/laboratory_item', locals: { laboratory: current_laboratory }) %>")
|
var index = $(".laboratory-item-<%= current_laboratory.id %>").children(":first").html();
|
||||||
|
$('.laboratory-list-table .laboratory-item-<%= current_laboratory.id %>').html("<%= j(render partial: 'admins/laboratories/shared/laboratory_item', locals: {laboratory: current_laboratory, index: 1}) %>");
|
||||||
|
$(".laboratory-item-<%= current_laboratory.id %>").children(":first").html(index);
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue