commit
93e8fa2bde
@ -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
|
||||
def matches?(request)
|
||||
return false unless request.session[:user_id]
|
||||
user = User.find request.session[:user_id]
|
||||
laboratory = Laboratory.first
|
||||
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?
|
||||
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,6 +1,7 @@
|
||||
class HackSet < ApplicationRecord
|
||||
validates :input, presence: { message: "测试集输入不能为空" }
|
||||
#validates :input, presence: { message: "测试集输入不能为空" }
|
||||
validates :output, presence: { message: "测试集输出不能为空" }
|
||||
validates_uniqueness_of :input, scope: [:hack_id, :input], message: "多个测试集的输入不能相同"
|
||||
# 编程题测试集
|
||||
belongs_to :hack
|
||||
end
|
||||
|
@ -1,4 +1,7 @@
|
||||
class HackUserCode < ApplicationRecord
|
||||
# 用户编程题的信息
|
||||
belongs_to :hack
|
||||
belongs_to :hack_user_lastest_code
|
||||
|
||||
scope :created_order, ->{ order("created_at desc")}
|
||||
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
|
@ -1 +1,3 @@
|
||||
$("#course-item-<%= @course.id %>").html("<%= j render partial: "admins/courses/shared/td",locals: {course: @course} %>")
|
||||
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');
|
||||
$.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');
|
||||
$.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 +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 +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');
|
||||
$.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);
|
@ -0,0 +1,25 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('实训修改记录') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container shixun-modify-record-list-form">
|
||||
<%= form_tag(admins_shixun_modify_records_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
|
||||
<div class="form-group col-12 col-md-4">
|
||||
<label for="user_name">用户名:</label>
|
||||
<%= text_field_tag :user_name, params[:user_name], class: 'form-control flex-1', placeholder: '真实姓名搜索' %>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-12 col-md-auto">
|
||||
<label for="status">时间范围:</label>
|
||||
<% data_arrs = [['最近一周', 'weekly'], ['最近一个月', 'monthly']] %>
|
||||
<%= select_tag(:date, options_for_select(data_arrs, params[:date]), class: 'form-control') %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag('搜索', class: 'btn btn-primary ml-3', 'data-disable-with': '搜索中...') %>
|
||||
<input type="reset" class="btn btn-secondary clear-btn" value="清空"/>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="box admin-list-container shixun-modify-record-list-container">
|
||||
<%= render partial: 'admins/shixun_modify_records/shared/list', locals: { records: @records } %>
|
||||
</div>
|
@ -0,0 +1 @@
|
||||
$('.shixun-modify-record-list-container').html("<%= j( render partial: 'admins/shixun_modify_records/shared/list', locals: { records: @records } ) %>");
|
@ -0,0 +1,36 @@
|
||||
<% if records.present? %>
|
||||
<% records.each do |record| %>
|
||||
<div class="card mb-5">
|
||||
<div class="card-header font-16">
|
||||
<span><%= record.user.real_name %></span>
|
||||
<span class="ml-3"><%= format_time record.created_at %></span>
|
||||
</div>
|
||||
|
||||
<div class="mt-2 mb-3 ml-3 font-14">
|
||||
<span>实训名称:<%= record.container&.shixun&.name %></span>
|
||||
<% if record.container_type == "Challenge" %>
|
||||
<span class="ml-3">/</span>
|
||||
<span class="ml-3">关卡名:<%= record.container&.subject %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
<div class="diff font-12">
|
||||
<ul>
|
||||
<% record.diff_record_content&.content&.split("\n").each do |line| %>
|
||||
<% if line =~ /^[\+]/ %>
|
||||
<li class="ins"><ins><%= line %></ins></li>
|
||||
<% elsif line =~ /^[\-]/ %>
|
||||
<li class="del"><del><%= line %></del></li>
|
||||
<% else %>
|
||||
<li class="unchanged"><span><%= line %></span></li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: records } %>
|
@ -1,3 +1,8 @@
|
||||
json.(@hack_user, :id, :status, :error_line, :error_msg, :expected_output,
|
||||
:input, :output, :execute_time, :execute_memory)
|
||||
json.language @hack_user.hack.language
|
||||
:input, :output, :execute_time, :execute_memory, :created_at, :code)
|
||||
json.language @hack_user.hack.language
|
||||
json.name @hack_user.hack.name
|
||||
json.myproblem_identifier @my_hack.identifier
|
||||
json.user do
|
||||
json.partial! 'users/user', user: current_user
|
||||
end
|
@ -1,12 +1,19 @@
|
||||
json.hack do
|
||||
json.(@hack, :difficult, :time_limit, :description, :score, :identifier)
|
||||
json.(@hack, :name, :difficult, :time_limit, :description, :score, :identifier)
|
||||
json.language @hack.language
|
||||
json.username @hack.user.real_name
|
||||
json.code @my_hack.code
|
||||
json.pass_count @hack.pass_num
|
||||
json.submit_count @hack.submit_num
|
||||
json.modify_code @modify
|
||||
end
|
||||
|
||||
json.test_case do
|
||||
json.input @hack.input_test_case
|
||||
end
|
||||
|
||||
json.user do
|
||||
json.partial! 'users/user', user: current_user
|
||||
json.hack_manager @hack.manager?(current_user)
|
||||
|
||||
end
|
@ -1,4 +1,4 @@
|
||||
json.array! @my_hack.hack_user_codes do |hack_user|
|
||||
json.array! @records do |hack_user|
|
||||
json.(hack_user, :id, :created_at, :status, :execute_time, :execute_memory)
|
||||
json.language hack_user.hack.language
|
||||
end
|
@ -0,0 +1 @@
|
||||
json.code @hack.code
|
@ -0,0 +1,3 @@
|
||||
json.user do
|
||||
json.partial! 'users/user', user: current_user
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class AddModifyTimeForHackCodes < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :hack_codes, :modify_time, :timestamp
|
||||
add_column :hack_user_lastest_codes, :modify_time, :timestamp
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class AddIndexForHackCodes < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
HackCode.destroy_all
|
||||
add_index :hack_codes, [:hack_id, :language], unique: true
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddVipToShixun < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :shixuns, :vip, :boolean, default: 0
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue