dev_aliyun_beta
commit
e55606426a
@ -0,0 +1,19 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-mirror-repositories-edit-page, body.admins-mirror-repositories-update-page').length > 0) {
|
||||
var $form = $('form.edit-mirror');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"mirror_repository[type_name]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$form.submit(function(e){
|
||||
if(!$form.valid()){ e.preventDefault(); }
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,4 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-mirror-repositories-index-page').length > 0) {
|
||||
}
|
||||
});
|
@ -0,0 +1,33 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
if ($('body.admins-mirror-scripts-edit-page, body.admins-mirror-scripts-update-page, body.admins-mirror-scripts-new-page, body.admins-mirror-scripts-create-page').length > 0) {
|
||||
var $form = $('form.script-form');
|
||||
|
||||
// codemirror编辑器
|
||||
var scriptEditor = CodeMirror.fromTextArea(document.getElementById('mirror_script_script'), {
|
||||
lineNumbers: true,
|
||||
mode: 'shell',
|
||||
theme: "default",
|
||||
indentUnit: 4, //代码缩进为一个tab的距离
|
||||
matchBrackets: true,
|
||||
autoRefresh: true,
|
||||
smartIndent: true,//智能换行
|
||||
styleActiveLine: true,
|
||||
lint: true
|
||||
});
|
||||
scriptEditor.setSize('auto', '600px');
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
"mirror_script[script_type]": {
|
||||
required: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$form.submit(function(e){
|
||||
if(!$form.valid()){ e.preventDefault(); }
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,32 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
$('.admin-modal-container').on('show.bs.modal', '.modal.admin-choose-mirror-modal', function(){
|
||||
var $modal = $('.modal.admin-choose-mirror-modal');
|
||||
var $form = $modal.find('form.admin-choose-mirror-form');
|
||||
|
||||
var validateForm = function(){
|
||||
var checkedValue = $form.find('input[name="mirror_number"]:checked').val();
|
||||
|
||||
if(checkedValue == undefined){
|
||||
$modal.find('.error').html('必须选择一种镜像保存!');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
var url = $form.attr('action');
|
||||
|
||||
if (validateForm()) {
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
}).done(function(){
|
||||
$modal.modal('hide');
|
||||
});
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
@ -0,0 +1,89 @@
|
||||
$(document).on('turbolinks:load', function() {
|
||||
var $modal = $('.modal.admin-replace-mirror-modal');
|
||||
if ($modal.length > 0) {
|
||||
var $form = $modal.find('form.admin-replace-mirror-form');
|
||||
var $mirrorIdInput = $modal.find('.modal-body input[name="mirror_id"]');
|
||||
var $mirrorSelect = $modal.find('.new-mirror-select');
|
||||
|
||||
var setMirror = function(id, name){
|
||||
$mirrorIdInput.val(id);
|
||||
$form.find('.mirror-id-container').html(id);
|
||||
$form.find('.mirror-name-container').html(name);
|
||||
}
|
||||
|
||||
$form.validate({
|
||||
errorElement: 'span',
|
||||
errorClass: 'danger text-danger',
|
||||
rules: {
|
||||
new_mirror_id: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
messages: {
|
||||
new_mirror_id: {
|
||||
required: '请选择新镜像'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// modal ready fire
|
||||
$modal.on('show.bs.modal', function (event) {
|
||||
var $link = $(event.relatedTarget);
|
||||
|
||||
var mirrorId = $link.data('id');
|
||||
var mirrorName = $link.data('name');
|
||||
|
||||
setMirror(mirrorId, mirrorName);
|
||||
$mirrorSelect.select2('val', ' ');
|
||||
});
|
||||
$modal.on('hide.bs.modal', function () {
|
||||
setMirror('', '');
|
||||
$mirrorSelect.select2('val', ' ');
|
||||
$('#new_mirror_id-error').remove();
|
||||
});
|
||||
|
||||
$mirrorSelect.select2({
|
||||
theme: 'bootstrap4',
|
||||
placeholder: '输入要合并的镜像名',
|
||||
minimumInputLength: 1,
|
||||
ajax: {
|
||||
url: '/admins/mirror_repositories/for_select',
|
||||
dataType: 'json',
|
||||
data: function(params){
|
||||
return { keyword: params.term };
|
||||
},
|
||||
processResults: function(data){
|
||||
return { results: data.mirrors }
|
||||
}
|
||||
},
|
||||
templateResult: function (item) {
|
||||
if(!item.id || item.id === '') return item.text;
|
||||
return item.name;
|
||||
},
|
||||
templateSelection: function(item){
|
||||
if (item.id) {
|
||||
$('#new_mirror_id-error').remove();
|
||||
$('#new_mirror_id').val(item.id);
|
||||
}
|
||||
return item.name || item.text;
|
||||
}
|
||||
});
|
||||
|
||||
$modal.on('click', '.submit-btn', function(){
|
||||
$form.find('.error').html('');
|
||||
|
||||
if ($form.valid()) {
|
||||
var url = $form.data('url');
|
||||
|
||||
$.ajax({
|
||||
method: 'POST',
|
||||
dataType: 'script',
|
||||
url: url,
|
||||
data: $form.serialize(),
|
||||
}).done(function(){
|
||||
$modal.modal('hide');
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
@ -0,0 +1,2 @@
|
||||
// Place all the behaviors and hooks related to the matching controller here.
|
||||
// All this logic will automatically be available in application.js.
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the homework_banks controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,11 @@
|
||||
class Admins::ChooseMirrorRepositoriesController < Admins::BaseController
|
||||
def new
|
||||
@mirror = MirrorRepository.find(params[:mirror_id])
|
||||
@new_mirror = MirrorOperationRecord.where(mirror_repository_id: @mirror.id, status: 1, user_id: -1).first
|
||||
end
|
||||
|
||||
def create
|
||||
mirror = MirrorRepository.find(params[:mirror_id])
|
||||
Admins::ChooseMirrorService.call(mirror, current_user, params[:mirror_number])
|
||||
end
|
||||
end
|
@ -0,0 +1,97 @@
|
||||
class Admins::MirrorRepositoriesController < Admins::BaseController
|
||||
before_action :check_shixun_mirrors!, only: [:index]
|
||||
|
||||
def index
|
||||
mirrors = MirrorRepository.all
|
||||
mirrors = mirrors.reorder(status: :desc, main_type: :desc, type_name: :asc)
|
||||
|
||||
@mirrors = paginate mirrors.includes(:mirror_scripts)
|
||||
@error_mirror_names = MirrorRepository.where(status: 5).pluck(:name)
|
||||
end
|
||||
|
||||
def new
|
||||
@mirror = MirrorRepository.new
|
||||
end
|
||||
|
||||
def create
|
||||
@mirror = MirrorRepository.new
|
||||
Admins::SaveMirrorRepositoryService.call(@mirror, current_user, form_params)
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_mirror_repository_path(@mirror)
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash.now[:danger] = '保存失败'
|
||||
render 'new'
|
||||
rescue Admins::SaveMirrorRepositoryService::Error => ex
|
||||
flash.now[:danger] = ex.message
|
||||
render 'new'
|
||||
end
|
||||
|
||||
def edit
|
||||
@mirror = current_mirror
|
||||
end
|
||||
|
||||
def update
|
||||
@mirror = current_mirror
|
||||
|
||||
Admins::SaveMirrorRepositoryService.call(current_mirror, current_user, form_params)
|
||||
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_mirror_repository_path(current_mirror)
|
||||
rescue ActiveRecord::RecordInvalid
|
||||
flash.now[:danger] = '保存失败'
|
||||
render 'edit'
|
||||
rescue Admins::SaveMirrorRepositoryService::Error => ex
|
||||
flash.now[:danger] = ex.message
|
||||
render 'edit'
|
||||
end
|
||||
|
||||
def destroy
|
||||
return render_js_error('该状态下不允许删除') unless current_mirror.deletable?
|
||||
|
||||
current_mirror.destroy!
|
||||
|
||||
render_delete_success
|
||||
end
|
||||
|
||||
def for_select
|
||||
mirrors = MirrorRepository.all
|
||||
|
||||
keyword = params[:keyword].to_s.strip
|
||||
mirrors = mirrors.where('name LIKE ?', "%#{keyword}%") if keyword.present?
|
||||
|
||||
@mirrors = paginate mirrors
|
||||
|
||||
render_ok(count: @mirrors.total_count, mirrors: @mirrors.as_json(only: %i[id name]))
|
||||
end
|
||||
|
||||
def merge
|
||||
origin_mirror = MirrorRepository.find(params[:mirror_id])
|
||||
mirror = MirrorRepository.find(params[:new_mirror_id])
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
origin_mirror.update!(name: mirror.name, mirrorID: mirror.mirrorID)
|
||||
mirror.destroy!
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_mirror
|
||||
@_current_mirror ||= MirrorRepository.find(params[:id])
|
||||
end
|
||||
|
||||
def form_params
|
||||
columns = %i[type_name main_type time_limit resource_limit cpu_limit memory_limit description status]
|
||||
params.require(:mirror_repository).permit(*columns)
|
||||
end
|
||||
|
||||
def check_shixun_mirrors!
|
||||
return
|
||||
return unless request.format.html?
|
||||
|
||||
Admins::CheckShixunMirrorsService.call
|
||||
rescue Admins::CheckShixunMirrorsService::Error => e
|
||||
internal_server_error(e.message)
|
||||
end
|
||||
end
|
@ -0,0 +1,59 @@
|
||||
class Admins::MirrorScriptsController < Admins::BaseController
|
||||
helper_method :current_mirror
|
||||
|
||||
def index
|
||||
scripts = current_mirror.mirror_scripts.order(updated_at: :desc)
|
||||
@scripts = paginate scripts
|
||||
end
|
||||
|
||||
def new
|
||||
@script = current_mirror.mirror_scripts.new
|
||||
end
|
||||
|
||||
def create
|
||||
@script = current_mirror.mirror_scripts.new(form_params)
|
||||
|
||||
if @script.save
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_mirror_repository_mirror_script_path(current_mirror, @script)
|
||||
else
|
||||
flash[:danger] = '保存失败'
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@script = current_script
|
||||
end
|
||||
|
||||
def update
|
||||
@script = current_script
|
||||
|
||||
if @script.update(form_params)
|
||||
flash[:success] = '保存成功'
|
||||
redirect_to edit_admins_mirror_repository_mirror_script_path(current_mirror, @script)
|
||||
else
|
||||
flash[:danger] = '保存失败'
|
||||
render 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
current_script.destroy!
|
||||
render_delete_success
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def current_script
|
||||
@_current_script ||= current_mirror.mirror_scripts.find(params[:id])
|
||||
end
|
||||
|
||||
def current_mirror
|
||||
@_current_mirror ||= MirrorRepository.find(params[:mirror_repository_id])
|
||||
end
|
||||
|
||||
def form_params
|
||||
params.require(:mirror_script).permit(:script_type, :description, :script)
|
||||
end
|
||||
end
|
@ -0,0 +1,60 @@
|
||||
#encoding: UTF-8
|
||||
class ExerciseBanksController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :find_bank
|
||||
before_action :bank_admin, only: [:update]
|
||||
|
||||
def show
|
||||
@exercise_questions = @bank.exercise_bank_questions&.includes(:exercise_bank_choices, :exercise_bank_shixun_challenges,
|
||||
:exercise_bank_standard_answers).order("question_number ASC")
|
||||
@exercise_ques_count = @exercise_questions.size # 全部的题目数
|
||||
@exercise_ques_scores = @exercise_questions.pluck(:question_score).sum
|
||||
|
||||
#单选题的数量及分数
|
||||
exercise_single_ques = @exercise_questions.find_by_custom("question_type", Exercise::SINGLE)
|
||||
@exercise_single_ques_count = exercise_single_ques.size
|
||||
@exercise_single_ques_scores = exercise_single_ques.pluck(:question_score).sum
|
||||
|
||||
#多选题的数量及分数
|
||||
exercise_double_ques = @exercise_questions.find_by_custom("question_type", Exercise::MULTIPLE)
|
||||
@exercise_double_ques_count = exercise_double_ques.size
|
||||
@exercise_double_ques_scores = exercise_double_ques.pluck(:question_score).sum
|
||||
|
||||
# 判断题数量及分数
|
||||
exercise_ques_judge = @exercise_questions.find_by_custom("question_type", Exercise::JUDGMENT)
|
||||
@exercise_ques_judge_count = exercise_ques_judge.size
|
||||
@exercise_ques_judge_scores = exercise_ques_judge.pluck(:question_score).sum
|
||||
|
||||
#填空题数量及分数
|
||||
exercise_ques_null = @exercise_questions.find_by_custom("question_type", Exercise::COMPLETION)
|
||||
@exercise_ques_null_count = exercise_ques_null.size
|
||||
@exercise_ques_null_scores = exercise_ques_null.pluck(:question_score).sum
|
||||
|
||||
#简答题数量及分数
|
||||
exercise_ques_main = @exercise_questions.find_by_custom("question_type", Exercise::SUBJECTIVE)
|
||||
@exercise_ques_main_count = exercise_ques_main.size
|
||||
@exercise_ques_main_scores = exercise_ques_main.pluck(:question_score).sum
|
||||
|
||||
#实训题数量及分数
|
||||
exercise_ques_shixun = @exercise_questions.find_by_custom("question_type", Exercise::PRACTICAL)
|
||||
@exercise_ques_shixun_count = exercise_ques_shixun.size
|
||||
@exercise_ques_shixun_scores = exercise_ques_shixun.pluck(:question_score).sum
|
||||
end
|
||||
|
||||
def update
|
||||
tip_exception("试卷标题不能为空!") if params[:exercise_name].blank?
|
||||
@bank.update_attributes!(name: params[:exercise_name], description: params[:exercise_description])
|
||||
normal_status(0,"试卷更新成功!")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_bank
|
||||
@bank = ExerciseBank.find_by!(id: params[:id])
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
|
||||
end
|
||||
|
||||
def bank_admin
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
|
||||
end
|
||||
end
|
@ -0,0 +1,39 @@
|
||||
class GtopicBanksController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :find_bank
|
||||
before_action :bank_admin, only: [:edit, :update]
|
||||
|
||||
def show
|
||||
@bank_attachments = @bank.attachments
|
||||
end
|
||||
|
||||
def edit
|
||||
@attachments = @bank.attachments
|
||||
end
|
||||
|
||||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
@bank.update_attributes(gtopic_bank_params)
|
||||
Attachment.associate_container(params[:attachment_ids], @bank.id, @bank.class) if params[:attachment_ids]
|
||||
normal_status(0, "更新成功")
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_bank
|
||||
@bank = GtopicBank.find_by!(id: params[:id])
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
|
||||
end
|
||||
|
||||
def bank_admin
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
|
||||
end
|
||||
|
||||
def gtopic_bank_params
|
||||
tip_exception("name参数不能为空") if params[:gtopic_bank][:name].blank?
|
||||
tip_exception("description参数不能为空") if params[:gtopic_bank][:description].blank?
|
||||
params.require(:gtopic_bank).permit(:name, :topic_type, :topic_source, :topic_property_first, :description,
|
||||
:topic_property_second, :source_unit, :topic_repeat, :province, :city)
|
||||
end
|
||||
end
|
@ -0,0 +1,63 @@
|
||||
class HomeworkBanksController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :find_bank
|
||||
before_action :bank_params, only: [:update]
|
||||
before_action :bank_admin, only: [:update, :destroy, :set_public]
|
||||
|
||||
def show
|
||||
@bank_attachments = @bank.attachments.where(attachtype: 1)
|
||||
@reference_attachments = @bank.attachments.where(attachtype: 2)
|
||||
end
|
||||
|
||||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
@bank.update_attributes(name: params[:name], description: params[:description], reference_answer: params[:reference_answer])
|
||||
|
||||
# 作业描述的附件
|
||||
Attachment.associate_container(params[:attachment_ids], @bank.id, @bank.class) if params[:attachment_ids]
|
||||
# 作业参考答案的附件
|
||||
Attachment.associate_container(params[:reference_attachment_ids], @bank.id, @bank.class, 2) if params[:reference_attachment_ids]
|
||||
|
||||
normal_status(0, "更新成功")
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
ActiveRecord::Base.transaction do
|
||||
@bank.homework_commons.update_all(homework_bank_id: nil)
|
||||
@bank.destroy!
|
||||
normal_status("删除成功")
|
||||
end
|
||||
end
|
||||
|
||||
def set_public
|
||||
@bank.update_attributes(is_public: 1)
|
||||
normal_status("更新成功")
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_bank
|
||||
@bank = HomeworkBank.find_by!(id: params[:id])
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
|
||||
end
|
||||
|
||||
def bank_admin
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
|
||||
end
|
||||
|
||||
def bank_params
|
||||
tip_exception("name参数不能为空") if params[:homework_bank][:name].blank?
|
||||
tip_exception("description参数不能为空") if params[:homework_bank][:description].blank?
|
||||
if @bank.homework_type == 3
|
||||
tip_exception("base_on_project参数不能为空") if params[:homework_bank][:base_on_project].nil?
|
||||
tip_exception("min_num参数不能为空") if params[:homework_bank][:min_num].blank?
|
||||
tip_exception("max_num参数不能为空") if params[:homework_bank][:max_num].blank?
|
||||
tip_exception("最小人数不能小于1") if params[:homework_bank][:min_num].to_i < 1
|
||||
tip_exception("最大人数不能小于最小人数") if params[:homework_bank][:max_num].to_i < params[:homework_bank][:min_num].to_i
|
||||
end
|
||||
params.require(:homework_bank).permit(:name, :description, :reference_answer) if @bank.homework_type == 1
|
||||
params.require(:homework_bank).permit(:name, :description, :reference_answer, :min_num, :max_num, :base_on_project) if @bank.homework_type == 3
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,48 @@
|
||||
class TaskBanksController < ApplicationController
|
||||
before_action :require_login
|
||||
before_action :find_bank
|
||||
before_action :bank_admin, only: [:update]
|
||||
|
||||
def show
|
||||
@bank_attachments = @bank.attachments
|
||||
end
|
||||
|
||||
def update
|
||||
ActiveRecord::Base.transaction do
|
||||
begin
|
||||
@bank.update_attributes(gtask_bank_params)
|
||||
Attachment.associate_container(params[:attachment_ids], @bank.id, @bank.class) if params[:attachment_ids]
|
||||
normal_status(0, "更新成功")
|
||||
rescue Exception => e
|
||||
uid_logger(e.message)
|
||||
tip_exception(e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_bank
|
||||
@bank = GtaskBank.find_by!(id: params[:id])
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && (@bank.is_public || @bank.user_id == current_user.id)) || current_user.admin?
|
||||
end
|
||||
|
||||
def bank_admin
|
||||
tip_exception(403, "无权限") unless (current_user.certification_teacher? && @bank.user_id == current_user.id) || current_user.admin?
|
||||
end
|
||||
|
||||
def gtask_bank_params
|
||||
tip_exception("name参数不能为空") if params[:gtask_bank][:name].blank?
|
||||
tip_exception("description参数不能为空") if params[:gtask_bank][:description].blank?
|
||||
if @bank.homework_type == 3
|
||||
tip_exception("base_on_project参数不能为空") if params[:gtask_bank][:base_on_project].nil?
|
||||
tip_exception("min_num参数不能为空") if params[:gtask_bank][:min_num].blank?
|
||||
tip_exception("max_num参数不能为空") if params[:gtask_bank][:max_num].blank?
|
||||
tip_exception("最小人数不能小于1") if params[:gtask_bank][:min_num].to_i < 1
|
||||
tip_exception("最大人数不能小于最小人数") if params[:gtask_bank][:max_num].to_i < params[:gtask_bank][:min_num].to_i
|
||||
end
|
||||
params.require(:gtask_bank).permit(:name, :description) if @bank.task_type == 1
|
||||
params.require(:gtask_bank).permit(:name, :description, :min_num, :max_num, :base_on_project) if @bank.task_type == 2
|
||||
end
|
||||
end
|
@ -0,0 +1,23 @@
|
||||
module Admins::MirrorRepositoriesHelper
|
||||
def mirror_type_tag(mirror)
|
||||
case mirror.main_type
|
||||
when '1' then '<i class="fa fa-star text-success font-16" aria-hidden="true" data-toggle="tooltip" data-title="主类别"></i>'.html_safe
|
||||
when '0' then '<i class="fa fa-star text-secondary font-16" aria-hidden="true" data-toggle="tooltip" data-title="子类别"></i>'.html_safe
|
||||
end
|
||||
end
|
||||
|
||||
def mirror_status_tag(mirror)
|
||||
case mirror.status
|
||||
when 0
|
||||
'<i class="fa fa-check-circle text-secondary font-16" data-toggle="tooltip" data-title="未发布"></i>'.html_safe
|
||||
when 1
|
||||
'<i class="fa fa-check-circle text-success font-16" data-toggle="tooltip" data-title="已发布"></i>'.html_safe
|
||||
when 2, 3
|
||||
'<i class="fa fa-exclamation-circle text-danger font-16" data-toggle="tooltip" data-title="被修改"></i>'.html_safe
|
||||
when 4
|
||||
'<i class="fa fa-times-circle text-danger font-18" data-toggle="tooltip" data-title="被删除"></i>'.html_safe
|
||||
when 5
|
||||
'<i class="fa fa-exclamation-circle text-warning font-16" data-toggle="tooltip" data-title="子节点异常"></i>'.html_safe
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module ExerciseBankQuestionsHelper
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module HomeworkBanksHelper
|
||||
end
|
@ -1,4 +1,7 @@
|
||||
class ExerciseBankChoice < ApplicationRecord
|
||||
belongs_to :exercise_bank_question
|
||||
has_many :exercise_bank_standard_answers
|
||||
|
||||
scope :find_choice_custom, lambda {|k,v| where("#{k} = ?",v)} #根据传入的参数查找问题
|
||||
scope :left_choice_choose, lambda {|k,v| where("#{k} > ?",v)} #根据传入的参数查找问题
|
||||
end
|
@ -0,0 +1,21 @@
|
||||
class Admins::ChooseMirrorService < ApplicationService
|
||||
attr_reader :mirror, :user, :number
|
||||
|
||||
def initialize(mirror, user, mirror_number)
|
||||
@mirror = mirror
|
||||
@user = user
|
||||
@number = mirror_number
|
||||
end
|
||||
|
||||
def call
|
||||
if mirror.mirrorID == number
|
||||
mirror.update_column(:status, 1)
|
||||
return
|
||||
end
|
||||
|
||||
old_number = mirror.mirrorID
|
||||
mirror.update!(mirrorID: number, status: 1)
|
||||
MirrorOperationRecord.create!(mirror_repository_id: mirror.id, mirror_id: number, mirror_name: mirror.name,
|
||||
status: 1, user_id: user.id, old_tag: old_number, new_tag: mirror.mirrorID)
|
||||
end
|
||||
end
|
@ -0,0 +1,37 @@
|
||||
class Admins::SaveMirrorRepositoryService < ApplicationService
|
||||
Error = Class.new(StandardError)
|
||||
|
||||
attr_reader :mirror, :user, :params
|
||||
|
||||
def initialize(mirror, user, params)
|
||||
@mirror = mirror
|
||||
@user = user
|
||||
@params = params
|
||||
end
|
||||
|
||||
def call
|
||||
mirror.assign_attributes(params)
|
||||
|
||||
raise Error, '镜像别名重复' if MirrorRepository.where.not(id: mirror.id).exists?(type_name: params[:type_name])
|
||||
|
||||
ActiveRecord::Base.transaction do
|
||||
record_operation! if mirror.persisted?
|
||||
|
||||
mirror.save!
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def record_operation!
|
||||
if mirror.type_name_changed?
|
||||
MirrorOperationRecord.create!(mirror_repository_id: mirror.id, status: 5,
|
||||
user_id: user.id, old_tag: mirror.type_name_in_database,
|
||||
new_tag: mirror.type_name)
|
||||
elsif mirror.status_changed?
|
||||
MirrorOperationRecord.create!(mirror_repository_id: mirror.id, status: 5,
|
||||
user_id: user.id, old_tag: mirror.status_in_database,
|
||||
new_tag: mirror.status)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
$.notify({ message: '操作成功' },{ type: 'success' });
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500)
|
@ -0,0 +1,2 @@
|
||||
$('.admin-modal-container').html("<%= j( render partial: 'admins/mirror_repositories/shared/choose_mirror_modal', locals: { mirror: @mirror, new_mirror: @new_mirror } ) %>");
|
||||
$('.modal.admin-choose-mirror-modal').modal('show');
|
@ -0,0 +1,8 @@
|
||||
<%
|
||||
define_admin_breadcrumbs do
|
||||
add_admin_breadcrumb('镜像管理', admins_mirror_repositories_path)
|
||||
add_admin_breadcrumb('镜像详情')
|
||||
end
|
||||
%>
|
||||
|
||||
<%= render partial: 'admins/mirror_repositories/shared/form', locals: { mirror: @mirror, form_action: 'update' } %>
|
@ -0,0 +1,23 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('镜像管理') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container mirror-repository-list-form">
|
||||
<form class="flex-1"></form>
|
||||
<%= link_to '新建', new_admins_mirror_repository_path, class: 'btn btn-primary' %>
|
||||
</div>
|
||||
|
||||
<% if @error_mirror_names.present? %>
|
||||
<div class="box pb-0">
|
||||
以下镜像异常:
|
||||
<% @error_mirror_names.each do |mirror_name| %>
|
||||
<span class="ml-2 text-danger"><%= mirror_name %></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="box mirror-repository-list-container">
|
||||
<%= render partial: 'admins/mirror_repositories/shared/list', locals: { mirrors: @mirrors } %>
|
||||
</div>
|
||||
|
||||
<%= render 'admins/mirror_repositories/shared/replace_mirror_modal' %>
|
@ -0,0 +1 @@
|
||||
$('.mirror-repository-list-container').html("<%= j( render partial: 'admins/mirror_repositories/shared/list', locals: { mirrors: @mirrors } ) %>");
|
@ -0,0 +1,5 @@
|
||||
$.notify({ message: '操作成功' },{ type: 'success' });
|
||||
|
||||
setTimeout(function(){
|
||||
window.location.reload();
|
||||
}, 500)
|
@ -0,0 +1,8 @@
|
||||
<%
|
||||
define_admin_breadcrumbs do
|
||||
add_admin_breadcrumb('镜像管理', admins_mirror_repositories_path)
|
||||
add_admin_breadcrumb('新建镜像')
|
||||
end
|
||||
%>
|
||||
|
||||
<%= render partial: 'admins/mirror_repositories/shared/form', locals: { mirror: @mirror, form_action: 'create' } %>
|
@ -0,0 +1,42 @@
|
||||
<div class="modal fade admin-choose-mirror-modal" tabindex="-1" role="dialog" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">更新镜像仓库</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<%= form_tag(admins_choose_mirror_repositories_path(mirror_id: mirror.id), method: :post, class: 'admin-choose-mirror-form') do %>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-2"></div>
|
||||
<div class="col-md-5">ID</div>
|
||||
<div class="col-md-5">名称</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-2">旧镜像</div>
|
||||
<div class="col-md-5 form-check">
|
||||
<input class="form-check-input" type="radio" name="mirror_number" id="old-mirror-check" value="<%= mirror.mirrorID %>">
|
||||
<label class="form-check-label" for="old-mirror-check"><%= mirror.mirrorID %></label>
|
||||
</div>
|
||||
<div class="col-md-5"><%= mirror.name %></div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col-md-2">新镜像</div>
|
||||
<div class="col-md-5 form-check">
|
||||
<input class="form-check-input" type="radio" name="mirror_number" id="new-mirror-check" value="<%= new_mirror.mirror_id %>">
|
||||
<label class="form-check-label" for="new-mirror-check"><%= new_mirror.mirror_id %></label>
|
||||
</div>
|
||||
<div class="col-md-5"><%= new_mirror.mirror_name %></div>
|
||||
</div>
|
||||
<div class="mt-2 error text-danger"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
|
||||
<button type="button" class="btn btn-primary submit-btn">确认</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
@ -0,0 +1,42 @@
|
||||
<div class="box edit-mirror-repository-container">
|
||||
<%= simple_form_for([:admins, mirror], url: { action: form_action }, html: { class: 'edit-mirror col-md-12' }, defaults: { wrapper_html: { class: 'col-md-4' } }) do |f| %>
|
||||
<% unless mirror.new_record? %>
|
||||
<div class="row">
|
||||
<%= f.input :mirrorID, label: '镜像ID', input_html: { readonly: true, class: 'form-control-plaintext' } %>
|
||||
<%= f.input :name, label: '镜像名称', input_html: { readonly: true, class: 'form-control-plaintext' } %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="row">
|
||||
<%= f.input :type_name, as: :string, label: '镜像别名 *' %>
|
||||
|
||||
<div class="form-group select optional col-md-4">
|
||||
<%= f.label :main_type, label: '类别' %>
|
||||
<%= f.select :main_type, [['主类别', 1],['小类别', 0]], {}, class: 'form-control optional' %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<%= f.input :time_limit, as: :integer, label: '评测时限(S)' %>
|
||||
<%= f.input :resource_limit, as: :integer, label: '磁盘限制(K)' %>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<%= f.input :cpu_limit, as: :integer, label: 'CPU限制(核)' %>
|
||||
<%= f.input :memory_limit, as: :integer, label: '内存限制(M)' %>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<%= f.input :description, as: :text, label: '描述', wrapper_html: { class: 'col-md-8' } %>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<%= f.input :status, as: :radio_buttons, label: '状态', collection: [%w(未发布 0), %w(已发布 1)], wrapper_html: { class: 'col-md-4' } %>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4', 'data-disable-with': '保存中...' %>
|
||||
<%= link_to '取消', admins_mirror_repositories_path, class: 'btn btn-secondary px-4' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
@ -0,0 +1,54 @@
|
||||
<table class="table table-hover text-center mirror-repository-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="6%">ID</th>
|
||||
<th width="6%">类别</th>
|
||||
<th width="12%" class="text-left">镜像别名</th>
|
||||
<th width="16%" class="text-left">镜像名称</th>
|
||||
<th width="22%" class="text-left">镜像描述</th>
|
||||
<th width="14%">修改时间</th>
|
||||
<th width="6%">脚本</th>
|
||||
<th width="6%">状态</th>
|
||||
<th width="12%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if mirrors.present? %>
|
||||
<% mirrors.each do |mirror| %>
|
||||
<tr class="mirror-repository-item-<%= mirror.id %>">
|
||||
<td><%= mirror.id %></td>
|
||||
<td><%= mirror_type_tag(mirror) %></td>
|
||||
<td class="text-left"><%= display_text(mirror.type_name) %></td>
|
||||
<td class="text-left"><%= overflow_hidden_span mirror.name, width: 150 %></td>
|
||||
<td class="text-left"><%= overflow_hidden_span mirror.description, width: 240 %></td>
|
||||
<td><%= mirror.updated_at.strftime('%Y-%m-%d %H:%M') %></td>
|
||||
<td>
|
||||
<% if mirror.main_type == "1" %>
|
||||
<%= link_to admins_mirror_repository_mirror_scripts_path(mirror) do %>
|
||||
<i class="fa fa-file-text <%= mirror.mirror_scripts.blank? ? 'text-danger' : 'text-success' %>" aria-hidden="true" data-toggle="tooltip" data-title="查看脚本"></i>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= mirror_status_tag mirror %></td>
|
||||
<td class="action-container">
|
||||
<%= link_to '编辑', edit_admins_mirror_repository_path(mirror), class: 'action edit-action' %>
|
||||
|
||||
<% if mirror.status == 2 %>
|
||||
<%= link_to '同步', new_admins_choose_mirror_repository_path(mirror_id: mirror.id), remote: true, class: 'action sync-action' %>
|
||||
<% end %>
|
||||
|
||||
<%= javascript_void_link '替换', class: 'action replace-action', data: { toggle: 'modal', target: '.admin-replace-mirror-modal', id: mirror.id, name: mirror.name } %>
|
||||
|
||||
<% if mirror.deletable? %>
|
||||
<%= delete_link '删除', admins_mirror_repository_path(mirror, element: ".mirror-repository-item-#{mirror.id}"), class: 'delete-mirror-repository-action' %>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: mirrors } %>
|
@ -0,0 +1,8 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('镜像管理', admins_mirror_repositories_path) %>
|
||||
<% add_admin_breadcrumb(current_mirror.type_name, edit_admins_mirror_repository_path(current_mirror)) %>
|
||||
<% add_admin_breadcrumb('脚本列表', admins_mirror_repository_mirror_scripts_path(current_mirror)) %>
|
||||
<% add_admin_breadcrumb('编辑脚本') %>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: 'admins/mirror_scripts/shared/form', locals: { mirror: current_mirror, script: @script, form_action: 'update' } %>
|
@ -0,0 +1,14 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('镜像管理', admins_mirror_repositories_path) %>
|
||||
<% add_admin_breadcrumb(current_mirror.type_name, edit_admins_mirror_repository_path(current_mirror)) %>
|
||||
<% add_admin_breadcrumb('脚本列表') %>
|
||||
<% end %>
|
||||
|
||||
<div class="box search-form-container mirror-script-list-form">
|
||||
<form class="flex-1"></form>
|
||||
<%= link_to '新建', new_admins_mirror_repository_mirror_script_path(current_mirror), class: 'btn btn-primary' %>
|
||||
</div>
|
||||
|
||||
<div class="box mirror-script-list-container">
|
||||
<%= render partial: 'admins/mirror_scripts/shared/list', locals: { mirror: current_mirror, scripts: @scripts } %>
|
||||
</div>
|
@ -0,0 +1,8 @@
|
||||
<% define_admin_breadcrumbs do %>
|
||||
<% add_admin_breadcrumb('镜像管理', admins_mirror_repositories_path) %>
|
||||
<% add_admin_breadcrumb(current_mirror.type_name, edit_admins_mirror_repository_path(current_mirror)) %>
|
||||
<% add_admin_breadcrumb('脚本列表', admins_mirror_repository_mirror_scripts_path(current_mirror)) %>
|
||||
<% add_admin_breadcrumb('新建脚本') %>
|
||||
<% end %>
|
||||
|
||||
<%= render partial: 'admins/mirror_scripts/shared/form', locals: { mirror: current_mirror, script: @script, form_action: 'create' } %>
|
@ -0,0 +1,12 @@
|
||||
<div class="box edit-mirror-script-container">
|
||||
<%= simple_form_for([:admins, mirror, script], url: { action: form_action }, html: { class: 'script-form' }) do |f| %>
|
||||
<%= f.input :script_type, label: '名称', input_html: { class: 'col-md-6' } %>
|
||||
<%= f.input :description, as: :text, label: '说明', input_html: { class: 'col-md-6' } %>
|
||||
<%= f.input :script, as: :text, label: '评测脚本' %>
|
||||
|
||||
<div class="form-row">
|
||||
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4', 'data-disable-with': '保存中...' %>
|
||||
<%= link_to '取消', admins_mirror_repository_mirror_scripts_path(mirror), class: 'btn btn-secondary px-4' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
@ -0,0 +1,32 @@
|
||||
<table class="table table-hover text-center mirror-script-list-table">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th width="10%">ID</th>
|
||||
<th width="20%" class="text-left">名称</th>
|
||||
<th width="34%" class="text-left">说明</th>
|
||||
<th width="16%">更新时间</th>
|
||||
<th width="20%">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% if scripts.present? %>
|
||||
<% scripts.each do |script| %>
|
||||
<tr class="mirror-script-item-<%= script.id %>">
|
||||
<td><%= script.id %></td>
|
||||
<td class="text-left"><%= overflow_hidden_span script.script_type, width: 200 %></td>
|
||||
<td class="text-left"><%= overflow_hidden_span script.description, width: 400 %></td>
|
||||
<td><%= script.updated_at.strftime('%Y-%m-%d %H:%M') %></td>
|
||||
<td class="action-container">
|
||||
<%= link_to '编辑', edit_admins_mirror_repository_mirror_script_path(mirror, script), class: 'action edit-action' %>
|
||||
|
||||
<%= delete_link '删除', admins_mirror_repository_mirror_script_path(mirror, script, element: ".mirror-script-item-#{script.id}"), class: 'delete-mirror-script-action' %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<%= render 'admins/shared/no_data_for_table' %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= render partial: 'admins/shared/paginate', locals: { objects: scripts } %>
|
@ -0,0 +1,6 @@
|
||||
<div class="d-flex flex-column align-items-center justify-content-center global-error">
|
||||
<div class="global-error-code">
|
||||
<span>403</span>
|
||||
</div>
|
||||
<div class="global-error-text">未授权</div>
|
||||
</div>
|
@ -1,5 +1,5 @@
|
||||
<div class="paginate-container">
|
||||
<% if objects.size.nonzero? %>
|
||||
<% if objects && objects.size.nonzero? %>
|
||||
<div class="paginate-total"><%= page_entries_info objects %></div>
|
||||
<% end %>
|
||||
<%= paginate objects, views_prefix: 'admins', remote: true %>
|
||||
|
@ -1,2 +1,2 @@
|
||||
json.status 1
|
||||
json.message "创建参考答案成功"
|
||||
json.message "操作成功"
|
@ -0,0 +1,29 @@
|
||||
wb = xlsx_package.workbook
|
||||
wb.use_shared_strings = true
|
||||
wb.styles do |s|
|
||||
no_wrap_sz = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: false,:horizontal => :center,:vertical => :center }
|
||||
sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
|
||||
row_cell = s.add_style :bg_color=> "FAEBDC",:border => { :style => :thin, :color =>"000000" },alignment: {wrap_text: true,:horizontal => :center,:vertical => :center }
|
||||
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
|
||||
|
||||
#课堂信息摘要
|
||||
wb.add_worksheet(name:course_info[0]) do |sheet|
|
||||
sheet.sheet_view.show_grid_lines = false
|
||||
course_main_info = course_info[1]
|
||||
course_group_info = course_info[2]
|
||||
group_info_d = course_group_info[0]
|
||||
group_info_detail = course_group_info[1]
|
||||
course_main_info.each do |c|
|
||||
sheet.add_row c, :style => sz_all #用户id
|
||||
end
|
||||
sheet["A1:A7"].each { |c| c.style = row_cell }
|
||||
sheet.add_row [],:style => sz_all
|
||||
if group_info_detail.count > 0
|
||||
sheet.add_row group_info_d, :style => blue_cell
|
||||
group_info_detail.each do |group|
|
||||
sheet.add_row group, :style => sz_all #用户id
|
||||
end
|
||||
sheet.column_info.second.width = 40
|
||||
end
|
||||
end #add_worksheet
|
||||
end
|
@ -0,0 +1,25 @@
|
||||
wb = xlsx_package.workbook
|
||||
wb.use_shared_strings = true
|
||||
wb.styles do |s|
|
||||
no_wrap_sz = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: false,:horizontal => :center,:vertical => :center }
|
||||
sz_all = s.add_style :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center }
|
||||
row_cell = s.add_style :bg_color=> "FAEBDC",:border => { :style => :thin, :color =>"000000" },alignment: {wrap_text: true,:horizontal => :center,:vertical => :center }
|
||||
blue_cell = s.add_style :bg_color => "FAEBDC", :sz => 10,:height => 25,:b => true, :border => { :style => :thin, :color =>"000000" },:alignment => {wrap_text: true,:horizontal => :center,:vertical => :center}
|
||||
|
||||
#课堂活跃度统计
|
||||
wb.add_worksheet(name:activity_level[0]) do |sheet|
|
||||
sheet.sheet_view.show_grid_lines = false
|
||||
sheet_title = activity_level[1]
|
||||
sheet_content = activity_level[2]
|
||||
sheet.add_row sheet_title, :height => 25,:style => blue_cell
|
||||
if sheet_content.count > 0
|
||||
sheet_content.each_with_index do |c,index|
|
||||
c_1 = (index+1)
|
||||
c_2 = [c_1] + c.values
|
||||
sheet.add_row c_2, :height => 25, :style => sz_all #用户id
|
||||
end
|
||||
sheet.column_widths *([20]*sheet.column_info.count)
|
||||
sheet.column_info.first.width = 8
|
||||
end
|
||||
end #add_worksheet
|
||||
end
|
@ -0,0 +1,16 @@
|
||||
json.exercise do
|
||||
json.extract! @bank, :id, :name, :description, :is_public
|
||||
end
|
||||
|
||||
json.partial! "exercises/exercise_scores"
|
||||
|
||||
json.exercise_questions do
|
||||
json.array! @exercise_questions do |q|
|
||||
json.partial! "exercise_bank_questions/exercise_bank_questions",
|
||||
question: q,
|
||||
choices:q.exercise_bank_choices,
|
||||
shixun_challenges: q.exercise_bank_shixun_challenges,
|
||||
ques_position:nil,
|
||||
edit_type:nil
|
||||
end
|
||||
end
|
@ -0,0 +1,15 @@
|
||||
json.topic_type topic_type
|
||||
json.topic_source topic_source
|
||||
json.topic_property_first topic_property_first
|
||||
json.topic_property_second topic_property_second
|
||||
json.topic_repeat topic_repeat
|
||||
|
||||
json.selected_data do
|
||||
json.(@bank, :name, :topic_type, :topic_source, :topic_property_first,
|
||||
:description, :topic_property_second, :source_unit, :topic_repeat,
|
||||
:province, :city, :is_public)
|
||||
end
|
||||
|
||||
json.attachments @attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
json.(@bank, :id, :name, :description, :is_public, :topic_type, :topic_source, :topic_property_first, :topic_property_second,
|
||||
:source_unit, :topic_repeat, :province, :city)
|
||||
|
||||
json.attachment_list @bank_attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
end
|
@ -0,0 +1,9 @@
|
||||
json.(@bank, :id, :name, :description, :homework_type, :is_public, :min_num, :max_num, :base_on_project, :reference_answer)
|
||||
|
||||
json.attachments @bank_attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
end
|
||||
|
||||
json.reference_attachments @reference_attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
json.courses @courses do |course|
|
||||
json.course_id course.id
|
||||
json.course_name course.name
|
||||
end
|
@ -0,0 +1,14 @@
|
||||
json.(@bank, :id, :name, :description, :task_type, :is_public)
|
||||
# 附件
|
||||
json.attachments @bank_attachments do |attachment|
|
||||
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}
|
||||
end
|
||||
|
||||
# 分组要求
|
||||
if @bank.task_type == 2
|
||||
json.group_info do
|
||||
json.max_number @bank.max_num
|
||||
json.min_number @bank.min_num
|
||||
json.base_on_project @bank.base_on_project
|
||||
end
|
||||
end
|
@ -1 +1 @@
|
||||
admins-users: admins-users
|
||||
admins-mirror_scripts: 'admins-mirror_repositories'
|
@ -0,0 +1,10 @@
|
||||
class ModifyChallnegeScoreForChoose < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
challenges = Challenge.where(st: 1)
|
||||
challenges.find_each do |c|
|
||||
puts(c.id)
|
||||
score = c.challenge_chooses.sum(:score)
|
||||
c.update_column(:score, score)
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,6 @@
|
||||
class AddUpdateUserIdToStudentWorks < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :student_works, :update_user_id, :integer
|
||||
StudentWork.update_all("update_user_id = commit_user_id")
|
||||
end
|
||||
end
|
@ -0,0 +1,5 @@
|
||||
class AddIsOrderedToExerciseBankQuestion < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :exercise_bank_questions, :is_ordered, :boolean, :default => true
|
||||
end
|
||||
end
|
File diff suppressed because one or more lines are too long
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
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