合并阿里云

dev_local_2
杨树林 5 years ago
commit 9c29d2de28

@ -95,3 +95,4 @@ gem 'bulk_insert'
gem 'searchkick'
gem 'aasm'
gem 'enumerize'

@ -106,6 +106,8 @@ GEM
elasticsearch-transport (7.2.0)
faraday
multi_json
enumerize (2.3.1)
activesupport (>= 3.2)
erubi (1.7.1)
execjs (2.7.0)
faraday (0.15.4)
@ -366,6 +368,7 @@ DEPENDENCIES
byebug
capybara (>= 2.15, < 4.0)
chromedriver-helper
enumerize
faraday (~> 0.15.4)
font-awesome-sass (= 4.7.0)
gitlab!

@ -13,10 +13,14 @@
//= require bootstrap-datepicker
//= require bootstrap.viewer
//= require jquery.mloading
//= require common
//= require echarts
//= require lib/codemirror
//= require mode/shell/shell
//= require codemirror/lib/codemirror
//= require codemirror/mode/shell/shell
//= require editormd/editormd
//= require editormd/languages/zh-tw
//= require dragula/dragula
//= require_tree ./i18n
//= require_tree ./admins
@ -41,7 +45,7 @@ $.notifyDefaults({
});
$(document).on('turbolinks:load', function(){
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="tooltip"]').tooltip({ trigger : 'hover' });
$('[data-toggle="popover"]').popover();
// 图片查看大图

@ -0,0 +1,5 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-abouts-edit-page, body.admins-abouts-update-page').length > 0) {
createMDEditor('about-us-editor', {});
}
})

@ -0,0 +1,5 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-agreements-edit-page, body.admins-agreements-update-page').length > 0) {
createMDEditor('agreement-editor', {});
}
})

@ -0,0 +1,96 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-cooperatives-index-page').length > 0) {
// ------------ 保存链接 -----------
$('.coo-img-card').on('click', '.save-url-btn', function(){
var $link = $(this);
var cooId = $link.data('id');
var url = $('.coo-img-item-' + cooId).find('.url-input').val();
$link.attr('disabled', true);
$.ajax({
url: '/admins/cooperatives/' + cooId,
method: 'PATCH',
dataType: 'json',
data: { url: url },
success: function(data){
$.notify({ message: '保存成功' });
},
error: ajaxErrorNotifyHandler,
complete: function(){
$link.removeAttr('disabled');
}
})
});
// ------------ 拖拽 -------------
var onDropFunc = function(el, _target, _source, sibling){
var moveId = $(el).data('id');
var insertId = $(sibling).data('id') || '';
$.ajax({
url: '/admins/cooperatives/drag',
method: 'POST',
dataType: 'json',
data: { move_id: moveId, after_id: insertId },
success: function(data){
},
error: function(res){
var data = res.responseJSON;
$.notify({message: '移动失败,原因:' + data.message}, {type: 'danger'});
}
})
};
var ele1 = document.getElementById('coo-img-container-alliance_coop');
dragula([ele1], { mirrorContainer: ele1 }).on('drop', onDropFunc);
var ele2 = document.getElementById('coo-img-container-com_coop');
dragula([ele2], { mirrorContainer: ele2 }).on('drop', onDropFunc);
var ele3 = document.getElementById('coo-img-container-edu_coop');
dragula([ele3], { mirrorContainer: ele3 }).on('drop', onDropFunc);
// ----------- 新增 --------------
var $createModal = $('.modal.admin-add-cooperative-modal');
var $createForm = $createModal.find('form.admin-add-cooperative-form');
$createForm.validate({
errorElement: 'span',
errorClass: 'danger text-danger',
rules: {
"coo_img[image]": {
required: true
}
}
});
$createModal.on('show.bs.modal', function(event){
resetFileInputFunc($createModal.find('.img-file-input'));
$createModal.find('.file-names').html('选择文件');
var $link = $(event.relatedTarget);
var imgType = $link.data('imgType');
$createForm.find('input[name="coo_img[img_type]"]').val(imgType);
});
$createModal.on('click', '.submit-btn', function() {
$createForm.find('.error').html('');
if ($createForm.valid()) {
$createForm.submit();
} else {
$createForm.find('.error').html('请选择图片');
}
});
$createModal.on('change', '.img-file-input', function(){
var file = $(this)[0].files[0];
$createModal.find('.file-names').html(file ? file.name : '请选择文件');
})
// -------------- 重新上传图片 --------------
//replace_image_url
$('.modal.admin-upload-file-modal').on('upload:success', function(e, data){
var $cooImgItem = $('.coo-img-item-' + data.source_id);
$.post('/admins/cooperatives/'+ data.source_id + '/replace_image_url');
$cooImgItem.find('.coo-img-item-img img').attr('src', data.url);
})
}
})

@ -1,22 +0,0 @@
$(document).on('turbolinks:load', function() {
var $editModal = $('.department-apply-edit-modal');
if($editModal.length > 0){
var $form = $editModal.find('form.department-apply-form');
var $applyIdInput = $form.find('input[name="id"]');
$editModal.on('show.bs.modal', function (event) {
var $link = $(event.relatedTarget);
var applyId = $link.data('id');
$applyIdInput.val(applyId);
});
$editModal.on('click', '.submit-btn', function(){
$.ajax({
method: "PUT",
dataType: 'script',
url: "/admins/department_applies/"+ $applyIdInput.val(),
data: $form.serialize(),
}).done(function(){
$editModal.modal('hide');
});
});
}
});

@ -0,0 +1,5 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-help-centers-edit-page, body.admins-help-centers-update-page').length > 0) {
createMDEditor('help-center-editor', {});
}
})

@ -66,10 +66,11 @@ $(document).on('turbolinks:load', function() {
var $link = $(event.relatedTarget);
var schoolId = $link.data('schoolId');
var url = $link.data('url');
$schoolIdInput.val(schoolId);
$originDepartmentIdInput.val($link.data('departmentId'));
$form.data('url', url);
$.ajax({
url: '/api/schools/' + schoolId + '/departments/for_option.json',
dataType: 'json',

@ -122,10 +122,6 @@ $(document).on('turbolinks:load', function(){
// 导入学生
var $importUserModal = $('.modal.admin-import-user-modal');
var $importUserForm = $importUserModal.find('form.admin-import-user-form')
var resetFileInputFunc = function(file){
file.after(file.clone().val(""));
file.remove();
}
$importUserModal.on('show.bs.modal', function(){
resetFileInputFunc($importUserModal.find('.upload-file-input'));

@ -0,0 +1,44 @@
function createMDEditor(element, opts){
var defaults = {
path: '/editormd/lib/',
syncScrolling: "single",
tex: true,
tocm: true,
emoji: true,
taskList: true,
codeFold: true,
searchReplace: true,
htmlDecode: "style,script,iframe",
sequenceDiagram: true,
autoFocus: false,
toolbarIcons: function () {
// Or return editormd.toolbarModes[name]; // full, simple, mini
// Using "||" set icons align right.
return ["bold", "italic", "|", "list-ul", "list-ol", "|", "code", "code-block", "|", "image", "table", '|', "watch", "clear"]
},
//这个配置在simple.html中并没有但是为了能够提交表单使用这个配置可以让构造出来的HTML代码直接在第二个隐藏的textarea域中方便post提交表单。
saveHTMLToTextarea: true,
dialogMaskOpacity: 0.6,
imageUpload: true,
imageFormats: ["jpg", "jpeg", "gif", "png", "bmp", "webp", "JPG", "JPEG", "GIF", "PNG", "BMP", "WEBP"],
imageUploadURL: '/api/attachments.json'
}
var options = $.extend({}, defaults, opts);
return editormd(element, options);
}
function ajaxErrorNotifyHandler(res) {
var message = '';
if(res.status !== 500){
message = res.responseJSON.message;
} else {
message = '系统错误';
}
return $.notify({message: message}, {type: 'danger'});
}
function resetFileInputFunc(file){
file.after(file.clone().val(""));
file.remove();
}

@ -6,7 +6,10 @@
@import "bootstrap-datepicker";
@import "bootstrap-datepicker.standalone";
@import "jquery.mloading";
@import "lib/codemirror";
@import "codemirror/lib/codemirror";
@import "editormd/css/editormd.min";
@import "dragula/dragula";
@import "common";
@import "admins/*";

@ -0,0 +1,35 @@
.admins-cooperatives-index-page {
.coo-img-card {
.coo-img-item {
& > .drag {
cursor: move;
background: #fff;
box-shadow: 1px 2px 5px 3px #f0f0f0;
}
&-img {
cursor: pointer;
width: 100%;
height: 40px;
margin-bottom: 10px;
& > img {
width: 100%;
height: 40px;
}
}
.delete-btn {
position: absolute;
top: 3px;
right: 20px;
color: red;
cursor: pointer;
}
.save-url-btn {
cursor: pointer;
}
}
}
}

@ -0,0 +1,18 @@
class Admins::AboutsController < Admins::BaseController
def edit
current_doc
end
def update
current_doc.update!(about_us: params[:about_us])
flash[:success] = '保存成功'
redirect_to edit_admins_about_path
end
private
def current_doc
@doc ||= Help.first || Help.create
end
end

@ -0,0 +1,18 @@
class Admins::AgreementsController < Admins::BaseController
def edit
current_doc
end
def update
current_doc.update!(agreement: params[:agreement])
flash[:success] = '保存成功'
redirect_to edit_admins_agreement_path
end
private
def current_doc
@doc ||= Help.first || Help.create
end
end

@ -0,0 +1,28 @@
class Admins::ContactUsController < Admins::BaseController
def edit
@cooperations = Cooperation.all.group(:user_type)
@help = Help.first
end
def update
cooperation = Cooperation.find(params[:id])
cooperation.update!(update_cooperation_params)
flash[:success] = '保存成功'
redirect_to edit_admins_contact_us_path
end
def update_address
help = Help.first || Help.create
help.update!(status: params.dig('help', 'status'))
flash[:success] = '保存成功'
redirect_to edit_admins_contact_us_path
end
private
def update_cooperation_params
params.require(:cooperation).permit(:name, :qq, :mail)
end
end

@ -0,0 +1,84 @@
class Admins::CooperativesController < Admins::BaseController
before_action :convert_file!, only: [:create]
def index
@data = { 'alliance_coop' => [], 'com_coop' => [], 'edu_coop' => [] }
@data = @data.merge CooImg.all.group_by(&:img_type)
end
def create
position = CooImg.where(img_type: create_params[:img_type]).count + 1
ActiveRecord::Base.transaction do
coo = CooImg.create!(create_params.merge(position: position))
file_path = Util::FileManage.disk_filename('CooImg', coo.id)
File.delete(file_path) if File.exist?(file_path) # 删除之前的文件
Util.write_file(@file, file_path)
coo.update!(url_states: Util::FileManage.disk_file_url('CooImg', coo.id))
end
flash[:success] = '保存成功'
redirect_to admins_cooperatives_path
end
def update
current_coo.update!(src_states: params[:url])
render_ok
end
def destroy
ActiveRecord::Base.transaction do
current_coo.destroy!
# 前移
CooImg.where(img_type: current_coo.img_type).where('position > ?', current_coo.position)
.update_all('position = position - 1')
file_path = Util::FileManage.disk_filename('CooImg', current_coo.id)
File.delete(file_path) if File.exist?(file_path)
end
render_delete_success
end
def drag
move = CooImg.find_by(id: params[:move_id])
after = CooImg.find_by(id: params[:after_id])
Admins::DragCooperativeService.call(move, after)
render_ok
rescue Admins::DragCooperativeService::Error => e
render_error(e.message)
end
def replace_image_url
current_coo.update!(url_states: Util::FileManage.disk_file_url('CooImg', current_coo.id))
render_ok
end
private
def current_coo
@_current_coo ||= CooImg.find(params[:id])
end
def create_params
params.require(:coo_img).permit(:img_type, :src_states)
end
def convert_file!
max_size = 10 * 1024 * 1024 # 10M
file = params.dig('coo_img', 'image')
if file.class == ActionDispatch::Http::UploadedFile
@file = file
render_error('请上传文件') if @file.size.zero?
render_error('文件大小超过限制') if @file.size > max_size
else
file = file.to_s.strip
return render_error('请上传正确的图片') if file.blank?
@file = Util.convert_base64_image(file, max_size: max_size)
end
rescue Base64ImageConverter::Error => ex
render_error(ex.message)
end
end

@ -1,6 +1,7 @@
class Admins::DepartmentAppliesController < Admins::BaseController
before_action :get_apply,only:[:agree,:edit,:update,:destroy]
before_action :get_apply,only:[:agree,:destroy]
def index
params[:status] ||= 0
params[:sort_by] = params[:sort_by].presence || 'created_at'
@ -19,47 +20,77 @@ class Admins::DepartmentAppliesController < Admins::BaseController
end
end
def update
depart_name = params[:name]
def merge
apply_id = params[:origin_department_id]
apply_add =ApplyAddDepartment.find(apply_id)
origin_id = apply_add&.department_id
new_id = params[:department_id]
return render_error('请选择其它部门') if origin_id.to_s == new_id.to_s
origin_department = apply_add&.department
to_department = Department.find(new_id)
return render_error('部门所属单位不相同') if origin_department&.school_id != to_department&.school_id
ActiveRecord::Base.transaction do
@depart_apply.update_attribute("name",depart_name)
@depart_apply&.department&.update_attribute("name",depart_name)
extra = depart_name + "(#{@depart_apply&.department&.school&.try(:name)})"
applied_message = AppliedMessage.where(applied_id: origin_id, applied_type: "ApplyAddDepartment")
applied_message.update_all(:status => 4)
apply_add.update_attribute(:status, 2)
apply_add.tidings.update_all(:status => 1)
extra = to_department&.name + "(#{apply_add&.department&.school&.try(:name)})"
tiding_params = {
user_id: @depart_apply.user_id,
user_id: apply_add.user_id,
trigger_user_id: 0,
container_id: @depart_apply.id,
container_id: apply_add.id,
container_type: 'ApplyAddDepartment',
belong_container_id: @depart_apply.department.school_id,
belong_container_id: apply_add&.department&.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 3,
extra: extra
}
Tiding.create(tiding_params)
render_success_js
origin_department.apply_add_departments.delete_all
origin_department.user_extensions.update_all(department_id: new_id)
if to_department.identifier.blank? && origin_department.identifier.present?
to_department.update!(identifier: origin_department.identifier)
end
origin_department.destroy!
apply_add.destroy!
end
render_ok
end
def destroy
ActiveRecord::Base.transaction do
@depart_apply.update_attribute("status",3)
@depart_apply&.applied_messages&.update_all(status:3)
if params[:tip] == 'unapplied' #未审批时候删除
UserExtension.where(department_id: @depart_apply.department_id).update_all(department_id:nil)
tiding_params = {
user_id: @depart_apply.user_id,
trigger_user_id: 0,
container_id: @depart_apply.id,
container_type: 'ApplyAddDepartment',
belong_container_id: @depart_apply&.department&.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 2,
extra: params[:reason]
}
Tiding.create(tiding_params)
end
@depart_apply&.department&.destroy
@depart_apply&.user&.user_extension&.update_attribute("department_id", nil)
@depart_apply&.user.update_attribute(:profile_completed, false)
tiding_params = {
user_id: @depart_apply.user_id,
trigger_user_id: 0,
container_id: @depart_apply.id,
container_type: 'ApplyAddDepartment',
belong_container_id: @depart_apply.department.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 2,
extra: params[:reason]
}
Tiding.create(tiding_params)
@depart_apply.destroy
render_success_js
end
end

@ -6,7 +6,7 @@ class Admins::FilesController < Admins::BaseController
Util.write_file(@file, file_path)
render_ok(source_id: params[:source_id], source_type: params[:source_type].to_s, url: file_url)
render_ok(source_id: params[:source_id], source_type: params[:source_type].to_s, url: file_url + "?t=#{Random.rand}")
rescue StandardError => ex
logger_error(ex)
render_error('上传失败')
@ -33,22 +33,14 @@ class Admins::FilesController < Admins::BaseController
@_file_path ||= begin
case params[:source_type].to_s
when 'Shixun' then
disk_filename('Shixun', params[:source_id])
Util::FileManage.disk_filename('Shixun', params[:source_id])
else
disk_filename(params[:source_type].to_s, params[:source_id].to_s)
Util::FileManage.disk_filename(params[:source_type].to_s, params[:source_id].to_s)
end
end
end
def disk_filename(type, id)
File.join(storage_path, type.to_s, id.to_s)
end
def storage_path
@_storage_path ||= File.join(Rails.root, 'public', 'images', 'avatars')
end
def file_url
File.join('/images/avatars/', params[:source_type].to_s, params[:source_id].to_s)
Util::FileManage.disk_file_url(params[:source_type].to_s, params[:source_id].to_s)
end
end

@ -0,0 +1,18 @@
class Admins::HelpCentersController < Admins::BaseController
def edit
current_doc
end
def update
current_doc.update!(help_center: params[:help_center])
flash[:success] = '保存成功'
redirect_to edit_admins_help_center_path
end
private
def current_doc
@doc ||= Help.first || Help.create
end
end

@ -0,0 +1,122 @@
class Admins::UnitAppliesController < Admins::BaseController
before_action :get_apply,only: [:agree,:destroy,:edit,:update]
def index
params[:sort_by] ||= 'created_at'
params[:sort_direction] ||= 'desc'
unit_applies = Admins::UnitApplyQuery.call(params)
@unit_applies = paginate unit_applies.preload(:school, :user)
end
def agree
ActiveRecord::Base.transaction do
begin
@unit_apply.update_attribute("status",1)
@unit_apply&.applied_messages&.update_all(status:1)
@unit_apply&.school&.update_attribute("province",@unit_apply.province)
# #申请信息的创建
apply_message_params = {
user_id: @unit_apply&.user_id,
status: 1,
viewed: 0,
applied_id: @unit_apply.school_id,
applied_type: "ApplyAddSchools",
name: @unit_apply.name,
}
AppliedMessage.new(apply_message_params).save(validate: false)
Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
#消息的创建
tiding_params = {
user_id: @unit_apply.user_id,
trigger_user_id: 0,
container_id: @unit_apply.id,
container_type: 'ApplyAddSchools',
belong_container_id: @unit_apply.school_id,
belong_container_type: "School",
tiding_type: "System",
status: 1
}
Tiding.create(tiding_params)
render_success_js
rescue Exception => e
Rails.logger.info("############_________________#########{e}")
end
end
end
def destroy
Admins::DeleteUnitApplyService.call(@unit_apply, params)
render_success_js
end
def edit
@all_schools = School.where.not(id: @unit_apply.school_id).pluck("name","id")
end
def update
school = School.find_by(id: params[:school_id])
ActiveRecord::Base.transaction do
@unit_apply&.applied_messages&.update_all(status:4)
Tiding.where(user_id: 1, trigger_user_id: @unit_apply.user_id, container_id: @unit_apply.id,
container_type: 'ApplyAddSchools', status: 0, tiding_type: "Apply").update_all(status: 1)
#消息的创建
tiding_params = {
user_id: @unit_apply.user_id,
trigger_user_id: 0,
container_id: @unit_apply.id,
container_type: 'ApplyAddSchools',
belong_container_id: params[:school_id],
belong_container_type: "School",
tiding_type: "System",
status: 3,
extra: school.try(:name).to_s
}
Tiding.create(tiding_params)
UserExtension.where(school_id: @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
ApplyAddDepartment.where(:school_id => @unit_apply.school_id).update_all(school_id: params[:school_id].to_i)
# 判断重复
before_apply_departments = Department.where(school_id: @unit_apply.school_id)
before_apply_departments.each do |department|
after_dep = Department.where(school_id: params[:school_id].to_i, name: department.name)&.first
if after_dep.present?
UserExtension.where(school_id: @unit_apply.school_id, department_id: department.id).update_all(department_id: after_dep.id)
department.destroy
department.apply_add_departments.destroy_all
else
department.apply_add_departments.update_all(school_id: school.id)
department.update_attribute(:school_id, school.id)
end
end
@unit_apply&.school&.destroy
apply_params = {
status: 2,
name: school&.name.to_s,
school_id: params[:school_id],
province: params[:province],
city: params[:city],
address: params[:address]
}
@unit_apply.update_attributes(apply_params)
# render_success_js
end
end
private
def get_apply
@unit_apply = ApplyAddSchool.find_by(id:params[:id])
end
def disk_auth_filename(source_type, source_id, type)
File.join(storage_path, "#{source_type}", "#{source_id}#{type}")
end
end

@ -1484,8 +1484,10 @@ class CoursesController < ApplicationController
shixun_titles = shixun_homeworks.pluck(:name) + ["总得分"]
# 更新实训作业成绩
shixun_homeworks.includes(:homework_challenge_settings, :published_settings, :homework_commons_shixun).each do |homework|
homework.update_homework_work_score
unless course.is_end
shixun_homeworks.includes(:homework_challenge_settings, :published_settings, :homework_commons_shixun).each do |homework|
homework.update_homework_work_score
end
end
shixun_homeworks = shixun_homeworks&.includes(score_student_works: :user)

@ -74,7 +74,7 @@ class ExerciseBanksController < ApplicationController
#判断实训是否已选择
def commit_shixun_present
question_shixun_ids = @exercise.exercise_bank_questions.pluck(:shixun_id).reject(&:blank?)
question_shixun_ids = @bank.exercise_bank_questions.pluck(:shixun_id).reject(&:blank?)
shixun_id = params[:shixun_id]
@shixun = Shixun.find_by(id: shixun_id)
if shixun_id.present? && question_shixun_ids.include?(shixun_id)
@ -85,45 +85,47 @@ class ExerciseBanksController < ApplicationController
end
def get_exercise_question_count
@exercise_ques_count = @exercise_questions.size # 全部的题目数
@exercise_ques_scores = @exercise_questions.pluck(:question_score).sum
exercise_questions = @bank.exercise_bank_questions
@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 = 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 = 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 = 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 = 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 = 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 = 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 get_poll_question_count
@poll_questions_count = @exercise_questions&.size # 全部的题目数
@poll_question_singles = @exercise_questions.find_by_custom("question_type", 1).size # 单选题
@poll_question_doubles = @exercise_questions.find_by_custom("question_type", 2).size # 多选题
@poll_question_mains = @exercise_questions.find_by_custom("question_type", 3).size #主观题
exercise_questions = @bank.exercise_bank_questions
@poll_questions_count = exercise_questions&.size # 全部的题目数
@poll_question_singles = exercise_questions.find_by_custom("question_type", 1).size # 单选题
@poll_question_doubles = exercise_questions.find_by_custom("question_type", 2).size # 多选题
@poll_question_mains = exercise_questions.find_by_custom("question_type", 3).size #主观题
end
end

@ -59,7 +59,7 @@ class GamesController < ApplicationController
record_onsume_time: record_onsume_time, prev_game: prev_game, next_game: next_game,
praise_count: praise_count, user_praise: user_praise, time_limit: time_limit,
tomcat_url: edu_setting('cloud_tomcat_php'), is_teacher: is_teacher,
myshixun_manager: myshixun_manager}
myshixun_manager: myshixun_manager, git_url: (@shixun.vnc ? repo_url(@myshixun.repo_path) : "")}
if @shixun.vnc
begin
shixun_tomcat = edu_setting('cloud_bridge')

@ -230,6 +230,7 @@ class GraduationTopicsController < ApplicationController
topic_repeat: topic.topic_repeat,
province: topic.province,
city: topic.city,
topic_type: topic.topic_type,
course_list_id: @course.course_list_id)
topic_bank.attachments.destroy_all
else
@ -241,6 +242,7 @@ class GraduationTopicsController < ApplicationController
topic_repeat: topic.topic_repeat,
province: topic.province,
city: topic.city,
topic_type: topic.topic_type,
course_list_id: @course.course_list_id,
user_id: current_user.id,
graduation_topic_id: topic.id)

@ -57,8 +57,8 @@ class HomeworkBanksController < ApplicationController
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("最小人数不能为空") if params[:homework_bank][:min_num].blank?
tip_exception("最大人数参数不能为空") 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

@ -930,6 +930,7 @@ class HomeworkCommonsController < ApplicationController
shixuns.each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, @category, current_user
@homework_ids << homework.id
CreateStudentWorkJob.perform_later(homework.id)
end
rescue Exception => e
uid_logger(e.message)
@ -1031,6 +1032,7 @@ class HomeworkCommonsController < ApplicationController
stage.shixuns.where.not(shixuns: {id: none_shixun_ids}).unhidden.each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
@homework_ids << homework.id
CreateStudentWorkJob.perform_later(homework.id)
end
end
end

@ -88,7 +88,7 @@ class QuestionBanksController < ApplicationController
end
def send_to_course
banks = object_banks
banks = @object_type.classify.constantize.where(id: params[:object_id])
course = current_user.manage_courses.find_by!(id: params[:course_id])
banks.each do |bank|
case @object_type

@ -8,11 +8,11 @@ class ShixunsController < ApplicationController
before_action :find_shixun, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
:propaedeutics, :departments, :apply_shixun_mirror,
:get_mirror_script, :download_file]
:get_mirror_script, :download_file, :shixun_list]
before_action :shixun_access_allowed, except: [:index, :new, :create, :menus, :get_recommend_shixuns,
:propaedeutics, :departments, :apply_shixun_mirror,
:get_mirror_script, :download_file]
:get_mirror_script, :download_file, :shixun_list]
before_action :find_repo_name, only: [:repository, :commits, :file_content, :update_file, :shixun_exec, :copy, :add_file]
before_action :allowed, only: [:update, :close, :update_propaedeutics, :settings, :publish,
@ -98,6 +98,45 @@ class ShixunsController < ApplicationController
.each_with_object({}) { |r, obj| obj[r.shixun_id] = r.name }
end
def shixun_list
# 全部实训/我的实训
type = params[:type] || "all"
# 状态:已发布/未发布
status = params[:status] || "all"
# 超级管理员用户显示所有未隐藏的实训、非管理员显示所有已发布的实训(对本单位公开且未隐藏未关闭)
if type == "mine"
@shixuns = current_user.shixuns.none_closed
else
if current_user.admin?
@shixuns = Shixun.none_closed.where(hidden: 0)
else
none_shixun_ids = ShixunSchool.where("school_id != #{current_user.school_id}").pluck(:shixun_id)
@shixuns = Shixun.where.not(id: none_shixun_ids).none_closed.where(hidden: 0)
end
end
unless status == "all"
@shixuns = status == "published" ? @shixuns.where(status: 2) : @shixuns.where(status: [0, 1])
end
## 筛选 难度
if params[:diff].present? && params[:diff].to_i != 0
@shixuns = @shixuns.where(trainee: params[:diff])
end
page = params[:page] || 1
limit = params[:limit] || 10
offset = (page.to_i - 1) * limit
order = params[:order] || "desc"
## 搜索关键字创建者、实训名称、院校名称
keyword = params[:search]
@shixuns = Shixun.search keyword, where: {id: @shixuns.pluck(:id)}, order: {"myshixuns_count" => order}, limit: limit, offset: offset
@total_count = @shixuns.total_count
end
## 获取顶部菜单
def menus
@repertoires = Repertoire.includes(sub_repertoires: [:tag_repertoires]).order("updated_at asc")
@ -865,6 +904,7 @@ class ShixunsController < ApplicationController
def send_to_course
@course = Course.find(params[:course_id])
homework = HomeworksService.new.create_homework @shixun, @course, nil, current_user
CreateStudentWorkJob.perform_later(homework.id)
end
# 二维码扫描下载

@ -8,12 +8,15 @@ class StudentWorksController < ApplicationController
before_action :find_work, only: [:shixun_work_report, :adjust_review_score, :shixun_work, :commit_des, :update_des,
:adjust_score, :show, :adjust_score, :supply_attachments, :revise_attachment,
:comment_list, :add_score, :add_score_reply, :destroy_score, :appeal_anonymous_score,
:deal_appeal_score, :cancel_appeal, :edit, :update, :export_shixun_work_report]
:deal_appeal_score, :cancel_appeal, :edit, :update, :export_shixun_work_report,
:shixun_work_comment, :destroy_work_comment]
before_action :user_course_identity
before_action :allow_add_score, only: [:add_score]
before_action :homework_publish
before_action :teacher_allowed, only: [:adjust_score, :adjust_review_score, :deal_appeal_score]
before_action :teacher_allowed, only: [:adjust_score, :adjust_review_score, :deal_appeal_score, :shixun_work_comment,
:destroy_work_comment]
before_action :course_student, only: [:new, :commit_des, :update_des, :create, :edit, :update, :search_member_list, :relate_project,
:cancel_relate_project, :relate_project, :delete_work]
@ -455,6 +458,7 @@ class StudentWorksController < ApplicationController
@shixun = @homework.shixuns.take
# 提示: 这里如果includes outputs表的话 sum(:evaluate_count)会出现错误
@games = @work.myshixun.games.joins(:challenge).reorder("challenges.position asc") if @work.myshixun
@comment = @work.student_works_scores.shixun_comment.first
# 用户最大评测次数
if @games
@ -468,6 +472,23 @@ class StudentWorksController < ApplicationController
@echart_data = student_efficiency(@homework, @work)
end
# 实训作品的评阅
def shixun_work_comment
tip_exception("评阅不能为空") if params[:comment].blank?
tip_exception("缺少is_hidden参数") if params[:is_hidden].blank? || ![1, 0].include?(params[:is_hidden])
comment = @work.student_works_scores.shixun_comment.first || StudentWorksScore.new(student_work_id: @work.id, user_id: current_user.id)
comment.comment = params[:comment]
comment.is_hidden = params[:is_hidden]
comment.save!
normal_status("评阅成功")
end
# 删除实训作品评阅
def destroy_work_comment
@work.student_works_scores.shixun_comment.first.destroy! if @work.student_works_scores.shixun_comment.first.present?
normal_status("删除成功")
end
def export_shixun_work_report
@user = @work.user
@shixun = @homework.shixuns.take

@ -214,6 +214,7 @@ class SubjectsController < ApplicationController
stage.shixuns.where(id: params[:shixun_ids], status: 2).each do |shixun|
homework = HomeworksService.new.create_homework shixun, @course, category, current_user
CreateStudentWorkJob.perform_later(homework.id)
end
end
rescue Exception => e

@ -1,7 +1,10 @@
class Wechats::JsSdkSignaturesController < ApplicationController
def create
signature = Util::Wechat.js_sdk_signature(params[:url], params[:noncestr], params[:timestamp])
render_ok(signature: signature)
timestamp = (Time.now.to_f * 1000).to_i
noncestr = ('A'..'z').to_a.sample(8).join
signature = Util::Wechat.js_sdk_signature(params[:url], noncestr, timestamp)
render_ok(appid: Util::Wechat.appid, timestamp: timestamp, noncestr: noncestr, signature: signature)
rescue Util::Wechat::Error => ex
render_error(ex.message)
end

@ -18,7 +18,7 @@ module Admins::BaseHelper
def sidebar_item(url, text, **opts)
content =
link_to url, 'data-controller': opts[:controller] do
content_tag(:i, '', class: "fa fa-#{opts[:icon]}", 'data-toggle': 'tooltip', 'data-placement': 'right', 'data-boundary': 'window', title: text) +
content_tag(:i, '', class: "fa fa-#{opts[:icon]} fa-fw", 'data-toggle': 'tooltip', 'data-placement': 'right', 'data-boundary': 'window', title: text) +
content_tag(:span, text)
end
@ -87,13 +87,17 @@ module Admins::BaseHelper
raw link_to(name, url, { method: :post, remote: true, class: klass, 'data-confirm': '确认审核通过?'}.merge(opts))
end
def delete_link(name, url, **opts)
def delete_link(name, url, **opts, &block)
klass = ['action delete-action', opts.delete(:class)].compact.join(' ')
refresh_url_data = "refresh_url=#{CGI::escape(request.fullpath)}"
url = url + (url.index('?') ? '&' : '?') + refresh_url_data
raw link_to(name, url, { method: :delete, remote: true, class: klass, 'data-confirm': '确认删除?'}.merge(opts))
if block_given?
raw link_to(url, { method: :delete, remote: true, class: klass, 'data-confirm': '确认删除?'}.merge(opts), &block)
else
raw link_to(name, url, { method: :delete, remote: true, class: klass, 'data-confirm': '确认删除?'}.merge(opts))
end
end
def unsafe_params

@ -113,7 +113,7 @@ module ExportHelper
end
else #实训题
shixun = homework.shixuns.first
shixun_head_cells = %w(完成情况 通关时间 总耗时 总评测次数 获得经验值 关卡得分)
shixun_head_cells = %w(完成情况 通关时间 学员在EduCoder做实训花费的时间 总评测次数 获得经验值 关卡得分)
eff_boolean = homework.work_efficiency
if eff_boolean
eff_score_cell = ["效率分"]
@ -123,7 +123,7 @@ module ExportHelper
if allow_late_boolean #允许迟交
eff_score_cell.push("迟交扣分")
end
shixun_time_cells = %w(最终成绩 更新时间 提交耗时 评语)
shixun_time_cells = %w(最终成绩 更新时间 作业发布到学员完成作业所耗的时间 评语)
@work_head_cells = (head_cells_format + shixun_head_cells + eff_score_cell + shixun_time_cells).reject(&:blank?)
works.includes(:student_works_scores, user: :user_extension, myshixun: :games).each_with_index do |w, index|
myshixun = w.try(:myshixun)
@ -163,7 +163,8 @@ module ExportHelper
end
w_15 = w.work_score.nil? ? "--" : w.work_score.round(1)
w_16 = w.update_time ? format_time(w.update_time) : "--" "更新时间"
w_17 = w.cost_time ? (game_spend_time w.cost_time) : "--"
myshixun_complete = myshixun && myshixun.status == 1
w_17 = myshixun_complete && w.cost_time ? (game_spend_time w.cost_time) : "未完成"
teacher_comments = w.student_works_scores
if teacher_comments.present?
w_18 = ""

@ -10,10 +10,18 @@ module Util::FileManage
File.join(Rails.root, "public", "images", relative_path)
end
def disk_filename(source_type,source_id,image_file=nil)
def disk_filename(source_type, source_id,image_file=nil)
File.join(storage_path, "#{source_type}", "#{source_id}")
end
def exist?(source_type, source_id)
File.exist?(disk_filename(source_type, source_id))
end
def disk_file_url(source_type, source_id)
File.join('/images', relative_path, "#{source_type}", "#{source_id}")
end
def disk_auth_filename(source_type, source_id, type)
File.join(storage_path, "#{source_type}", "#{source_id}#{type}")
end

@ -1,10 +1,12 @@
class ApplyAddSchool < ApplicationRecord
belongs_to :school
belongs_to :user
has_many :applied_messages, as: :applied
has_many :tidings, as: :container, dependent: :destroy
after_create :send_notify
# after_destroy :after_delete_apply
private
@ -12,4 +14,9 @@ class ApplyAddSchool < ApplicationRecord
Tiding.create!(user_id: 1, status: 0, container_id: id, container_type: 'ApplyAddSchools',
trigger_user_id: user_id, belong_container: school, tiding_type: 'Apply')
end
# def after_delete_apply
#
# end
end

@ -0,0 +1,5 @@
class CooImg < ApplicationRecord
extend Enumerize
enumerize :img_type, in: %i[com_coop edu_coop alliance_coop]
end

@ -0,0 +1,9 @@
class Cooperation < ApplicationRecord
def user_type_text
case user_type.to_i
when 1 then '高校合作'
when 2 then '企业合作'
when 3 then '实训投稿'
end
end
end

@ -0,0 +1,3 @@
class Help < ApplicationRecord
end

@ -16,6 +16,8 @@ class School < ApplicationRecord
has_many :customers, dependent: :destroy
has_many :partners, dependent: :destroy
has_many :apply_add_departments, dependent: :destroy
# 学校管理员
def manager?(user)
ec_school_users.exists?(user_id: user.id)

@ -14,7 +14,9 @@ module Searchable::Shixun
def search_data
{
name: name,
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH]
description: Util.extract_content(description)[0..Searchable::MAXIMUM_LENGTH],
status: status,
myshixuns_count: myshixuns_count
}.merge!(searchable_user_data)
.merge!(searchable_challenge_data)
end
@ -37,7 +39,7 @@ module Searchable::Shixun
end
def should_index?
status == 2 # published
[0, 1, 2].include?(status) # published
end
def to_searchable_json

@ -59,6 +59,7 @@ class Shixun < ApplicationRecord
scope :visible, -> { where.not(status: -1) }
scope :published, lambda{ where(status: 2) }
scope :published_closed, lambda{ where(status: [2, 3]) }
scope :none_closed, lambda{ where(status: [0, 1, 2]) }
scope :unhidden, lambda{ where(hidden: 0, status: 2) }
scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) }
scope :find_by_ids,lambda{|k| where(id:k)}

@ -9,6 +9,9 @@ belongs_to :student_work
validates :comment, length: { maximum: 2000 }
scope :shixun_comment, lambda { where(is_ultimate: 0) }
def show_name identity, user
identity < Course::STUDENT || self.user == user || self.reviewer_role != 3
end

@ -0,0 +1,24 @@
class Admins::UnitApplyQuery < ApplicationQuery
include CustomSortable
attr_reader :params
sort_columns :created_at, default_by: :created_at, default_direction: :desc
def initialize(params)
@params = params
end
def call
unit_applies = ApplyAddSchool.where(status:0)
# 关键字模糊查询
keyword = params[:keyword].to_s.strip
if keyword.present?
unit_applies = unit_applies.where("name like ?","%#{keyword}%")
end
custom_sort(unit_applies, params[:sort_by], params[:sort_direction])
end
end

@ -0,0 +1,56 @@
class Admins::DeleteUnitApplyService < ApplicationService
attr_reader :department, :params
def initialize(unit_apply, params)
@unit_apply = unit_apply
@params = params
end
def call
ActiveRecord::Base.transaction do
@unit_apply.update_attribute("status",3)
@unit_apply&.applied_messages&.update_all(status:3)
@unit_apply&.school&.apply_add_departments&.update_all(status:3)
applied_departments = ApplyAddDepartment.where(school_id: @unit_apply.school_id)
applied_departments.update_all(status: 3)
use_extensions = UserExtension&.where(school_id: @unit_apply.school_id)
user_ids = UserExtension&.where(school_id: @unit_apply.school_id)&.pluck(:user_id)
User.where(id: user_ids).update_all(profile_completed: false)
use_extensions.update_all(school_id: nil,department_id: nil)
@unit_apply&.user&.user_extension&.update_attribute("department_id", nil)
# 申请了职业认证的用户撤销申请
apply_user_auth = ApplyUserAuthentication.where(user_id: user_ids, auth_type: 2, status: 0)
apply_user_auth.each do |apply|
apply.tidings.destroy_all
apply.update_attribute('status', 3)
diskfile2 = disk_auth_filename('UserAuthentication', apply.user_id, 'PRO')
diskfilePRO = diskfile2 + 'temp'
File.delete(diskfilePRO) if File.exist?(diskfilePRO)
File.delete(diskfile2) if File.exist?(diskfile2)
end
# 未审批删除
if params[:tip] == "unapplied"
Tiding.where(:user_id => 1, :trigger_user_id => @unit_apply.user_id, :container_id => @unit_apply.id, :container_type => 'ApplyAddSchools', :status => 0, :tiding_type => "Apply").update_all(status: 1)
Tiding.create(:user_id => @unit_apply.user_id, :trigger_user_id => 0, :container_id => @unit_apply.id, :container_type =>'ApplyAddSchools', :belong_container_id => @unit_apply.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2, :extra => params[:reason])
Tiding.where(:user_id => 1, :container_id => applied_departments.pluck(:id), :container_type => 'ApplyAddDepartment', :status => 0, :tiding_type => "Apply").update_all(status: 1)
if applied_departments&.first.present?
Tiding.create(:user_id => applied_departments.first.user_id, :trigger_user_id => 0, :container_id => applied_departments.first.id, :container_type =>'ApplyAddDepartment', :belong_container_id => @unit_apply.school_id, :belong_container_type=> 'School', :tiding_type => "System", :status => 2)
AppliedMessage.create(:user_id => applied_departments.first.user_id, :status => 3, :viewed => 0, :applied_id => applied_departments.first.id, :applied_type => "ApplyAddDepartment", :name => applied_departments.first.name )
end
@unit_apply&.school&.destroy
@unit_apply&.school&.departments&.destroy_all
elsif params[:tip] == "applied"
applied_departments.destroy_all
@unit_apply.destroy
end
end
end
end

@ -0,0 +1,35 @@
class Admins::DragCooperativeService < ApplicationService
Error = Class.new(StandardError)
attr_reader :move, :after
def initialize(move, after)
@move = move
@after = after # 移动后下一个位置的元素
end
def call
return if move.position + 1 == after&.position # 未移动
raise Error, '未知错误' if after && move.img_type != after.img_type
coo_imgs = CooImg.where(img_type: move.img_type)
ActiveRecord::Base.transaction do
if after.blank? # 移动至末尾
total = coo_imgs.count
coo_imgs.where('position > ?', move.position).update_all('position = position - 1')
move.update!(position: total)
return
end
if move.position > after.position # 前移
coo_imgs.where('position >= ? AND position < ?', after.position, move.position).update_all('position = position + 1')
move.update!(position: after.position)
else # 后移
coo_imgs.where('position > ? AND position <= ?', move.position, after.position).update_all('position = position - 1')
move.update!(position: after.position)
end
end
end
end

@ -15,7 +15,6 @@ class HomeworksService
homework_detail_manual.save! if homework_detail_manual
HomeworkCommonsShixun.create!(homework_common_id: homework.id, shixun_id: shixun.id)
HomeworksService.new.create_shixun_homework_cha_setting(homework, shixun)
CreateStudentWorkJob.perform_later(homework.id)
# HomeworksService.new.create_works_list(homework, course)
end
homework

@ -14,10 +14,12 @@ class SearchService < ApplicationService
private
def search_options
{
model_options = {
index_name: index_names,
model_includes: model_includes
}.merge(default_options)
}
model_options.merge(where: { status: 2 }) if index_names == [Shixun]
model_options.merge(default_options)
end
def index_names

@ -85,7 +85,7 @@ class Users::QuestionBankService
def custom_sort(relations, sort_by, sort_direction)
case sort_by
when 'updated_at' then
relations.order(updated_at: sort_direction)
relations.order("updated_at #{sort_direction}, id #{sort_direction}")
when 'name' then
relations.order("CONVERT(name USING gbk) COLLATE gbk_chinese_ci #{sort_direction}")
when 'contributor' then

@ -53,7 +53,7 @@ class Users::UpdateAccountService < ApplicationService
RewardGradeService.call(user, container_id: user.id, container_type: 'Account', score: 500)
if user.user_extension.teacher?
join_course(user.id,1309, 2)
sms_notify_admin(user.lastname)
# sms_notify_admin(user.lastname)
end
end

@ -0,0 +1,15 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('关于我们') %>
<% end %>
<div class="box edit-about-us-container">
<%= simple_form_for(@doc, url: admins_about_path) do |f| %>
<div class="form-group" id="about-us-editor">
<%= text_area_tag('about_us', @doc.about_us, style: 'display: none') %>
</div>
<div class="form-row mt-4">
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4', 'data-disable-with': '保存中...' %>
</div>
<% end %>
</div>

@ -0,0 +1,15 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('服务协议') %>
<% end %>
<div class="box edit-agreement-container">
<%= simple_form_for(@doc, url: admins_agreement_path) do |f| %>
<div class="form-group" id="agreement-editor">
<%= text_area_tag('agreement', @doc.agreement, style: 'display: none') %>
</div>
<div class="form-row mt-4">
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4', 'data-disable-with': '保存中...' %>
</div>
<% end %>
</div>

@ -0,0 +1,41 @@
<%
define_admin_breadcrumbs do
add_admin_breadcrumb('联系我们')
end
%>
<div class="row">
<% @cooperations.each do |cooperation| %>
<div class="mb-4 col-12 col-lg-6">
<div class="card">
<div class="card-header"><%= cooperation.user_type_text %></div>
<div class="card-body">
<%= simple_form_for(cooperation, url: admins_contact_us_path(id: cooperation.id), wrapper: :horizontal_form) do |f| %>
<%= f.input :name, label: '联系人:' %>
<%= f.input :qq, label: 'QQ:' %>
<%= f.input :mail, label: 'Email:' %>
<div class="text-right">
<%= f.button :submit, value: '保存', class: 'btn-primary btn-sm', 'data-disable-with': '保存中...' %>
</div>
<% end %>
</div>
</div>
</div>
<% end %>
<div class="mb-4 col-12 col-lg-6">
<div class="card">
<div class="card-header">公司地址</div>
<div class="card-body">
<%= simple_form_for(@help, url: update_address_admins_contact_us_path, wrapper: :horizontal_form) do |f| %>
<%= f.input :status, label: '地址:' %>
<div class="text-right">
<%= f.button :submit, value: '保存', class: 'btn-primary btn-sm', 'data-disable-with': '保存中...' %>
</div>
<% end %>
</div>
</div>
</div>
</div>

@ -0,0 +1,38 @@
<%
define_admin_breadcrumbs do
add_admin_breadcrumb('合作伙伴')
end
%>
<% @data.each do |type, objs| %>
<div class="card mb-5 coo-img-card">
<div class="card-header d-flex justify-content-between align-items-center">
<span class="flex-1"><%= t("enumerize.coo_img.img_type.#{type}") %></span>
<%= javascript_void_link '添加', class: 'btn btn-primary btn-sm add-btn', data: { img_type: type, toggle: 'modal', target: '.admin-add-cooperative-modal' } %>
</div>
<div class="card-body row" id="coo-img-container-<%= type %>">
<% objs.sort_by(&:position).each do |obj| %>
<div class="col-12 col-md-6 col-lg-3 coo-img-item coo-img-item-<%= obj.id %>" data-id="<%= obj.id %>">
<div class="border rounded relative p-3 mb-3 drag">
<%= delete_link '删除', admins_cooperative_path(obj, element: ".coo-img-item-#{obj.id}", not_refresh: true) do %>
<i class="fa fa-trash-o delete-btn" data-id="<%= obj.id %>"></i>
<% end %>
<div class="coo-img-item-img" data-source-id="<%= obj.id %>" data-source-type="CooImg" data-toggle="modal" data-target=".admin-upload-file-modal">
<img src="<%= obj.url_states || (Util::FileManage.exist?('CooImg', obj.id) ? Util::FileManage.disk_file_url('CooImg', obj.id) : '') %>" data-toggle="tooltip" data-title="重新上传"/>
</div>
<div class="input-group input-group-sm">
<input type="text" value="<%= obj.src_states %>" class="form-control url-input" placeholder="请输入跳转地址">
<div class="input-group-prepend">
<button class="input-group-text save-url-btn" data-id="<%= obj.id %>">保存</button>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
<% end %>
<%= render partial: 'admins/cooperatives/shared/add_cooperative_modal' %>
<%= render partial: 'admins/shared/modal/upload_file_modal' %>

@ -0,0 +1,37 @@
<div class="modal fade admin-add-cooperative-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">&times;</span>
</button>
</div>
<div class="modal-body">
<%= simple_form_for(CooImg.new, url: admins_cooperatives_path, html: { class: 'admin-add-cooperative-form', enctype: 'multipart/form-data' }) do |f| %>
<%= f.input :img_type, as: :hidden %>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text">图片</span>
</div>
<div class="custom-file flex-row-reverse">
<input type="file" name="coo_img[image]" class="img-file-input" id="img-file-input" accept="image/*">
<label class="custom-file-label file-names" for="img-file-input">选择文件</label>
</div>
</div>
</div>
<%= f.input :src_states, as: :url, label: '链接地址', placeholder: '请输入跳转地址' %>
<div class="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>

@ -1,2 +0,0 @@
//$("#apply-id-<%= @depart_apply.id %>").remove()
//pop_box_new("批准成功", 400, 248);

@ -15,4 +15,4 @@
</div>
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>
<%= render partial: 'admins/department_applies/shared/edit_modal' %>
<%= render 'admins/departments/shared/merge_department_modal' %>

@ -1,26 +0,0 @@
<div class="modal fade department-apply-edit-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">&times;</span>
</button>
</div>
<div class="modal-body">
<form class="department-apply-form" data-remote="true">
<%= hidden_field_tag(:id, nil) %>
<div class="form-group">
<label for="grade" class="col-form-label">名称:</label>
<%= text_field_tag(:name,nil,class:"form-control",placeholder:"输入新的名称") %>
</div>
<div class="error text-danger"></div>
</form>
</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>

@ -1,12 +1,12 @@
<table class="table table-hover text-center department_applies-list-table">
<thead class="thead-light">
<tr>
<th width="9%">ID</th>
<th width="25%" class="edu-txt-left">部门名称</th>
<th width="20%" class="edu-txt-left">单位名称</th>
<th width="8%">ID</th>
<th width="22%" class="text-left">部门名称</th>
<th width="20%" class="text-left">单位名称</th>
<th width="15%">创建者</th>
<th width="15%"><%= sort_tag('创建于', name: 'created_at', path: admins_department_applies_path) %></th>
<th width="16%">操作</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
@ -14,8 +14,8 @@
<% applies.each do |apply| %>
<tr class="department-apply-<%= apply.id %>">
<td><%= apply.id %></td>
<td class="edu-txt-left"> <%= apply.name %></td>
<td class="edu-txt-left"> <%= apply.school.try(:name) %></td>
<td class="text-left"> <%= apply.name %></td>
<td class="text-left"> <%= apply.school.try(:name) %></td>
<td><%= apply.user.show_real_name %></td>
<td><%= format_time apply.created_at %></td>
<td class="action-container">
@ -23,17 +23,16 @@
<%= javascript_void_link('删除', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id, title: "删除原因", type: "delete",
url: admins_department_apply_path(apply, element: ".department-apply-#{apply.id}")
url: admins_department_apply_path(apply,tip:"unapplied", element: ".department-apply-#{apply.id}")
}) %>
<%= javascript_void_link('修改', class: 'action department-apply-action', data: { toggle: 'modal', target: '.department-apply-edit-modal', id: apply.id }) %>
<%= javascript_void_link '更改', class: 'action', data: { school_id: apply.school_id, department_id: apply.id,
toggle: 'modal', target: '.admin-merge-department-modal', url: merge_admins_department_applies_path } %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -28,7 +28,8 @@
<%= javascript_void_link '添加管理员', class: 'action', data: { department_id: department.id, toggle: 'modal', target: '.admin-add-department-member-modal' } %>
<%= javascript_void_link '更改', class: 'action', data: { school_id: department.school_id, department_id: department.id, toggle: 'modal', target: '.admin-merge-department-modal' } %>
<%= javascript_void_link '更改', class: 'action', data: { school_id: department.school_id, department_id: department.id,
toggle: 'modal', target: '.admin-merge-department-modal', url: merge_admins_departments_path } %>
<%= delete_link '删除', admins_department_path(department, element: ".department-item-#{department.id}"), class: 'delete-department-action' %>
</td>

@ -18,7 +18,6 @@
<select id="department_id" name="department_id" class="form-control department-select"></select>
</div>
</div>
<div class="error text-danger"></div>
</form>
</div>

@ -0,0 +1,15 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('帮助中心') %>
<% end %>
<div class="box edit-help-center-container">
<%= simple_form_for(@doc, url: admins_help_center_path) do |f| %>
<div class="form-group" id="help-center-editor">
<%= text_area_tag('help_center', @doc.help_center, style: 'display: none') %>
</div>
<div class="form-row mt-4">
<%= f.button :submit, value: '保存', class: 'btn-primary mr-3 px-4', 'data-disable-with': '保存中...' %>
</div>
<% end %>
</div>

@ -56,7 +56,8 @@
<%= sidebar_item_group('#apply-review-submenu', '审核', icon: 'gavel') do %>
<li><%= sidebar_item(admins_identity_authentications_path, '实名认证', icon: 'id-card-o', controller: 'admins-identity_authentications') %></li>
<li><%= sidebar_item(admins_professional_authentications_path, '职业认证', icon: 'drivers-license', controller: 'admins-professional_authentications') %></li>
<li><%= sidebar_item(admins_department_applies_path, '部门审批', icon: 'building', controller: 'admins-department_applies') %></li>
<li><%= sidebar_item(admins_department_applies_path, '部门审批', icon: 'newspaper-o', controller: 'admins-department_applies') %></li>
<li><%= sidebar_item(admins_unit_applies_path, '单位审批', icon: 'building-o', controller: 'admins-unit_applies') %></li>
<li><%= sidebar_item(admins_shixun_authorizations_path, '实训发布', icon: 'object-ungroup', controller: 'admins-shixun_authorizations') %></li>
<li><%= sidebar_item(admins_subject_authorizations_path, '实践课程发布', icon: 'object-group', controller: 'admins-subject_authorizations') %></li>
<li><%= sidebar_item(admins_library_applies_path, '教学案例发布', icon: 'language', controller: 'admins-library_applies') %></li>
@ -64,6 +65,17 @@
<li><%= sidebar_item(admins_video_applies_path, '视频发布', icon: 'film', controller: 'admins-video_applies') %></li>
<% end %>
</li>
<li>
<%= sidebar_item_group('#helps-submenu', '帮助中心', icon: 'info-circle') do %>
<li><%= sidebar_item(edit_admins_about_path, '关于我们', icon: 'smile-o', controller: 'admins-abouts') %></li>
<li><%= sidebar_item(edit_admins_contact_us_path, '联系我们', icon: 'commenting-o', controller: 'admins-contact_us') %></li>
<li><%= sidebar_item(admins_cooperatives_path, '合作伙伴', icon: 'handshake-o', controller: 'admins-cooperatives') %></li>
<li><%= sidebar_item(edit_admins_agreement_path, '服务协议', icon: 'file-text-o', controller: 'admins-agreements') %></li>
<li><%= sidebar_item(edit_admins_help_center_path, '帮助中心', icon: 'question-circle-o', controller: 'admins-help_centers') %></li>
<% end %>
</li>
<li><%= sidebar_item('/', '返回主站', icon: 'sign-out', controller: 'root') %></li>
</ul>
</nav>

@ -1,4 +1,4 @@
;
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="tooltip"]').tooltip({ trigger : 'hover' });
$('[data-toggle="popover"]').popover();
$('img.preview-image').bootstrapViewer();

@ -1,22 +1,27 @@
var deleteRow = $('<%= params[:element] %>');
var refreshUrl = '<%= params[:refresh_url] %>';
var notRefresh = <%= !!params[:not_refresh] %>;
$.notify({ message: '操作成功' },{ type: 'success' });
var refreshFunc = function(url) {
$.ajax({
url: url.length > 0 ? url : window.location.href,
method: 'GET',
dataType: "script"
})
}
if (!notRefresh) {
var refreshFunc = function(url) {
$.ajax({
url: url.length > 0 ? url : window.location.href,
method: 'GET',
dataType: "script"
})
}
if(deleteRow.length > 0){
var needRefresh = deleteRow.siblings().length == 0;
if(deleteRow.length > 0){
var needRefresh = deleteRow.siblings().length == 0;
deleteRow.remove();
deleteRow.remove();
if(needRefresh){ refreshFunc(refreshUrl); }
if(needRefresh){ refreshFunc(refreshUrl); }
} else {
refreshFunc(refreshUrl);
}
} else {
refreshFunc(refreshUrl);
deleteRow.remove();
}

@ -0,0 +1,56 @@
$("body").append("<%= j render partial: "admins/unit_applies/shared/edit_modal",locals: {apply: @unit_apply, schools: @all_schools} %>")
var uni_edit_modal = $(".admin-unit-edit-modal")
uni_edit_modal.modal("show")
uni_edit_modal.on("hidden.bs.modal",function () {
$(".admin-unit-edit-modal").remove()
$("body").removeClass("modal-open")
})
// 初始化学校选择器
var matcherFunc = function(params, data){
if ($.trim(params.term) === '') {
return data;
}
if (typeof data.text === 'undefined') {
return null;
}
if (data.name && data.name.indexOf(params.term) > -1) {
var modifiedData = $.extend({}, data, true);
return modifiedData;
}
// Return `null` if the term should not be displayed
return null;
}
$.ajax({
url: '/api/schools/for_option.json',
dataType: 'json',
type: 'GET',
success: function(data) {
$("#all-schools").select2({
theme: 'bootstrap4',
placeholder: '查询学校/单位',
minimumInputLength: 1,
data: data.schools,
templateResult: function (item) {
if(!item.id || item.id === '') return item.text;
return item.name;
},
templateSelection: function(item){
return item.name || item.text;
},
matcher: matcherFunc
})
}
});
$("#all-schools").select2({})
$("#show-province-<%= @unit_apply.id %>").select2()
$("#schoolCity_<%= @unit_apply.id %>").select2()
// **************** 地区选择 ****************
$('.province-city-select').cxSelect({
url: '/javascripts/educoder/province-data.json',
selects: ['province-select', 'city-select']
});

@ -0,0 +1,17 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('单位审批') %>
<% end %>
<div class="box search-form-container flex-column mb-0 pb-0 unit-applies-list-form">
<%= form_tag(admins_unit_applies_path(unsafe_params), method: :get, class: 'form-inline search-form mt-3', remote: true) do %>
<%= text_field_tag(:keyword, params[:keyword], class: 'form-control col-sm-2 ml-3', placeholder: '单位名称检索') %>
<%= submit_tag('搜索', class: 'btn btn-primary ml-3','data-disable-with':"搜索中...") %>
<%= link_to "清除",admins_unit_applies_path(keyword:nil),class:"btn btn-default",remote:true %>
<% end %>
</div>
<div class="box unit-applies-list-container">
<%= render(partial: 'admins/unit_applies/shared/list', locals: { applies: @unit_applies }) %>
</div>
<%= render(partial: 'admins/shared/admin_common_refuse_modal') %>

@ -0,0 +1 @@
$(".unit-applies-list-container").html("<%= j render partial: "admins/unit_applies/shared/list", locals: {applies: @unit_applies} %>")

@ -0,0 +1,17 @@
<td><%= apply.id %></td>
<td class="text-left"><%= overflow_hidden_span apply.name %></td>
<td class="text-left">
<%= "#{apply&.province.to_s}"+"#{apply&.city.to_s}" %>
</td>
<td class="text-left"><%= overflow_hidden_span apply.address %></td>
<td><%= apply.user.try(:show_real_name) %></td>
<td><%= format_time apply.created_at %></td>
<td class="action-container">
<%= agree_link '批准', agree_admins_unit_apply_path(apply, element: ".unit-apply-#{apply.id}"), 'data-confirm': '确认批准通过?' %>
<%= javascript_void_link('删除', class: 'action refuse-action',
data: {
toggle: 'modal', target: '.admin-common-refuse-modal', id: apply.id, title: "删除原因", type: "delete",
url: admins_unit_apply_path(apply, tip: "unapplied", element: ".unit-apply-#{apply.id}")
}) %>
<%= link_to "更改",edit_admins_unit_apply_path(apply), remote: true, class:"action",'data-disable-with': '打开中...' %>
</td>

@ -0,0 +1,43 @@
<div class="modal fade admin-unit-edit-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">&times;</span>
</button>
</div>
<%= form_tag(admins_unit_apply_path, method: :put, remote: true) do %>
<div class="modal-body">
<div class="form-group d-flex">
<label for="school_id" class="col-form-label">更改学校:</label>
<div class="d-flex flex-column-reverse w-75">
<%= select_tag :school_id, [apply&.school_id], class: 'form-control school-select optional',id: "all-schools" %>
</div>
</div>
<div class="form-group d-flex">
<label for="school_id" class="col-form-label">更改城市:</label>
<div class="d-flex w-75 province-city-select">
<div class="w-50 mr-3">
<%= select_tag('province', [], class: 'form-control province-select optional', 'data-value': apply.province, 'data-first-title': '请选择', id:"show-province-#{apply.id}") %>
</div>
<div class="w-50">
<%= select_tag('city', [], class: 'form-control city-select optional', 'data-value': apply.city, id: "schoolCity_#{apply.id}") %>
</div>
</div>
</div>
<div class="form-group d-flex">
<label for="school_id" class="col-form-label">更改地址:</label>
<div class="d-flex w-75 flex-column-reverse">
<%= text_field_tag :address,apply.address,class:"form-control" %>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
<%= submit_tag "确认",class:"btn btn-primary" %>
</div>
<% end %>
</div>
</div>
</div>

@ -0,0 +1,26 @@
<table class="table table-hover text-center unit-applies-list-table">
<thead class="thead-light">
<tr>
<th width="8%">ID</th>
<th width="20%" class="text-left">单位名称</th>
<th width="12%" class="text-left">地区</th>
<th width="20%" class="text-left">详细地址</th>
<th width="10%">申请者</th>
<th width="15%"><%= sort_tag('创建于', name: 'created_at', path: admins_unit_applies_path) %></th>
<th width="15%">操作</th>
</tr>
</thead>
<tbody>
<% if applies.present? %>
<% applies.each do |apply| %>
<tr class="unit-apply-<%= apply.id %>">
<%= render partial: "admins/unit_applies/shared/apply_item", locals: {apply: apply} %>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>
<%= render partial: 'admins/shared/paginate', locals: { objects: applies } %>

@ -0,0 +1,3 @@
$('.modal.admin-unit-edit-modal').modal('hide');
$('.unit-applies-list-table .unit-apply-<%= @unit_apply.id %>').remove()
$.notify({ message: '操作成功' });

@ -2,6 +2,7 @@ if @bank.container_type == "Exercise"
json.exercise do
json.extract! @bank, :id, :name, :description, :is_public
end
json.authorize @bank.user_id == current_user.id || current_user.admin?
json.partial! "exercises/exercise_scores"
@ -20,6 +21,7 @@ else
json.poll do
json.extract! @bank, :id, :name, :description, :is_public
end
json.authorize @bank.user_id == current_user.id || current_user.admin?
json.question_types do
json.q_counts @poll_questions_count

@ -1,6 +1,6 @@
json.(@base_date, :st, :discusses_count, :game_count, :record_onsume_time, :prev_game, :next_game, :praise_count,
:user_praise, :time_limit, :tomcat_url, :is_teacher, :myshixun_manager, :game, :challenge,
:shixun, :myshixun)
:shixun, :myshixun, :git_url)
if @shixun.vnc
json.vnc_url @vnc_url
end

@ -1,6 +1,7 @@
json.partial! "public_navigation", locals: {graduation: @task, course: @course}
json.description @task.description
json.user_id @task.user_id
json.authorize @task.user_id == current_user.id || current_user.admin?
# 附件
json.attachments @attachments do |attachment|
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}

@ -1,5 +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.authorize @bank.user_id == current_user.id || current_user.admin?
json.attachment_list @bank_attachments do |attachment|
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}

@ -1,4 +1,5 @@
json.(@bank, :id, :name, :description, :homework_type, :is_public, :min_num, :max_num, :base_on_project, :reference_answer)
json.authorize @bank.user_id == current_user.id || current_user.admin?
json.attachments @bank_attachments do |attachment|
json.partial! "attachments/attachment_simple", locals: {attachment: attachment}

@ -0,0 +1,17 @@
json.shixuns_count @total_count
json.shixun_list do
json.array! @shixuns.with_highlights(multiple: true) do |obj, highlights|
puts obj
json.merge! obj.to_searchable_json
json.challenge_names obj.challenges.pluck(:subject)
json.title highlights.delete(:name)&.join('...') || obj.searchable_title
# json.description highlights.values[0,5].each { |arr| arr.is_a?(Array) ? arr.join('...') : arr }.join('<br/>')
json.content highlights
json.level level_to_s(obj.trainee)
json.subjects obj.subjects do |subject|
json.(subject, :id, :name)
end
end
end

@ -46,6 +46,16 @@ if @shixun
json.user_id @user.id
json.username @user.real_name
json.student_id @user.student_id
json.image_url url_to_avatar(@user)
json.complete_count @work.myshixun&.passed_count
json.challenges_count @shixun.challenges_count
json.efficiency @homework.work_efficiency ? number_with_precision(@work.efficiency, precision: 2) : nil
json.max_efficiency @homework.work_efficiency ? number_with_precision(@homework.max_efficiency, precision: 2) : nil
json.passed_time @work.myshixun&.passed_time
# 评阅信息
json.work_comment @user_course_identity < Course::STUDENT || !@comment&.is_hidden ? @comment&.comment : nil
json.work_comment_hidden @comment&.is_hidden
# 图形统计
# 1 效率

@ -20,6 +20,7 @@ if @course
json.group_info @course.teacher_group(@user.id) if @course_identity < Course::STUDENT
end
json.first_category_url module_url(@course.none_hidden_course_modules.first, @course)
json.course_is_end @course.is_end
end
if params[:school]

@ -1,6 +1,9 @@
json.count @count
json.course_list @course_lists, partial: 'users/question_banks/shared/course_list', as: :course_list
json.course_list @course_lists do |course_list|
json.id course_list.id
json.name course_list.name
end
json.question_banks @question_banks do |question_bank|
json.id question_bank.id
@ -11,4 +14,5 @@ json.question_banks @question_banks do |question_bank|
json.course_list_name question_bank.course_list&.name
json.updated_at question_bank.updated_at
json.solve_count @solve_count_map.fetch(question_bank.id, 0)
json.authorize question_bank.user_id == current_user.id || current_user.admin?
end

@ -0,0 +1,7 @@
zh-CN:
enumerize:
coo_img:
img_type:
com_coop: '知名企业'
edu_coop: '各类院校'
alliance_coop: '产学联盟'

@ -184,6 +184,7 @@ Rails.application.routes.draw do
get :get_mirror_script
post :apply_shixun_mirror
get :download_file
get :shixun_list
end
member do
@ -442,6 +443,8 @@ Rails.application.routes.draw do
post :deal_appeal_score
post :cancel_appeal
get :export_shixun_work_report
post :shixun_work_comment
delete :destroy_work_comment
end
collection do
@ -781,6 +784,10 @@ Rails.application.routes.draw do
end
post 'callbacks/aliyun_vod', to: 'callbacks/aliyun_vods#create'
namespace :wechats do
resource :js_sdk_signature, only: [:create]
end
end
namespace :admins do
@ -856,7 +863,15 @@ Rails.application.routes.draw do
end
resources :shixuns, only: [:index,:destroy]
resources :shixun_settings, only: [:index,:update]
resources :department_applies,only: [:index,:edit,:update,:destroy] do
resources :department_applies,only: [:index,:destroy] do
collection do
post :merge
end
member do
post :agree
end
end
resources :unit_applies,only: [:index,:destroy,:edit,:update] do
member do
post :agree
end
@ -874,6 +889,17 @@ Rails.application.routes.draw do
post :merge, on: :collection
end
resources :myshixuns, only: [:index]
resource :about, only: [:edit, :update]
resource :agreement, only: [:edit, :update]
resource :help_center, only: [:edit, :update]
resource :contact_us, only: [:edit, :update] do
patch :update_address, on: :collection
end
resources :cooperatives, only: [:index, :create, :update, :destroy] do
post :drag, on: :collection
post :replace_image_url, on: :member
end
end
resources :colleges, only: [] do
@ -889,10 +915,6 @@ Rails.application.routes.draw do
end
end
namespace :wechats do
resource :js_sdk_signature, only: [:create]
end
#git 认证回调
match 'gitauth/*url', to: 'gits#auth', via: :all

@ -0,0 +1,9 @@
class ReorderCooImgPosition < ActiveRecord::Migration[5.2]
def change
CooImg.all.group_by(&:img_type).each do |_type, objs|
objs.sort_by(&:position).each_with_index do |obj, index|
obj.update!(position: index + 1)
end
end
end
end

@ -0,0 +1,20 @@
class ChangePublicModelDefaultValue < ActiveRecord::Migration[5.2]
def change
#试卷的默认值的修改
change_column_default :exercises,:show_result,0
change_column_default :exercises, :answer_open, false
change_column_default :exercises, :score_open, false
#问卷的默认值的修改
change_column_default :polls, :show_result, 0
#实训作业/普通作业/分组作业
change_column_default :homework_commons, :score_open, false
change_column_default :homework_commons, :work_public, false
change_column_default :homework_commons, :answer_public, false
#毕设任务
change_column_default :graduation_tasks, :open_score, false
change_column_default :graduation_tasks, :open_work, false
end
end

@ -0,0 +1,152 @@
#coding=utf-8
# 执行示例 RAILS_ENV=production bundle exec rake public_classes:student args=3,3056,'2019-03-01','2019-03-31',10,1
# args 第一个参数是subject_id第二个参数是课程course_id
# 第一期时间2018-12-16 至2019-03-31
# 第二期时间2019-04-07 至2019-07-28
#
# 这次学习很有收获,感谢老师提供这么好的资源和细心的服务🎉🎉🎉
#
desc "同步精品课数据"
namespace :public_classes do
if ENV['args']
subject_id = ENV['args'].split(",")[0] # 对应课程的id
course_id = ENV['args'].split(",")[1] # 对应课堂的id
start_time = ENV['args'].split(",")[2] # 表示课程模块
end_time = ENV['args'].split(",")[3] # 表示课程模块
limit = ENV['args'].split(",")[4] # 限制导入的数量
type = ENV['args'].split(",")[5] # 表示课程模块
end
task :student => :environment do
puts "subject_id is #{subject_id}"
puts "course_id is #{course_id}"
puts "start time is #{start_time}"
puts "end time is #{end_time}"
puts "limt is #{limit}"
user_ids = Myshixun.find_by_sql("select distinct(user_id) from myshixuns where created_at between '#{start_time}' and '#{end_time}' and shixun_id in (select shixun_id from stage_shixuns
where stage_id in (select id from stages where subject_id=#{subject_id})) limit #{limit}").map(&:user_id)
puts "user_ids count is #{user_ids.count}"
if user_ids.present?
user_ids.each do |user_id|
puts user_id
begin
CourseMember.create!(course_id: course_id, user_id: user_id, role: 4)
rescue Exception => e
Rails.logger(e.message)
end
end
end
end
task :test_user => :environment do
users = User.where(is_test: true).limit(limit)
users.find_each do |user|
puts user.id
CourseMember.create!(course_id: course_id, user_id: user.id, role: 4)
end
end
# 更新某个课程的某类时间
# 执行示例 RAILS_ENV=production bundle exec rake public_course:time args=-1,2932,1,1
task :time => :environment do
# course_id = ENV['args'].split(",")[0] # 对应课堂的id
# type = ENV['args'].split(",")[1]
course = Course.find(course_id)
case type.to_i
when 1
# 讨论区
messages = Message.where(board_id: course.boards)
messages.each do |message|
created_on = random_time start_time, end_time
puts created_on
message.update_columns(created_on: created_on, updated_on: created_on)
MessageDetail.where(message_id: message.id).each do |detail|
rand_created_on = random_time start_time, end_time
detail.update_columns(created_at: rand_created_on, updated_at: rand_created_on)
end
end
when 2
# 作业
course.homework_commons.each do |homework|
created_at = random_time(start_time, end_time)
publish_time = random_larger_time created_at, start_time, end_time
end_time = random_larger_time publish_time, start_time, end_time
updated_at = end_time
homework.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at)
homework.homework_detail_manual.update_columns(comment_status: 6, created_at: created_at, updated_at: updated_at)
homework.student_works.where("work_status !=0 and update_time > '#{end_time}'").update_all(update_time: end_time)
end
when 3
# 试卷
course.exercises.each do |exercise|
created_at = random_time start_time, end_time
publish_time = random_larger_time created_at, start_time, end_time
end_time = random_larger_time publish_time, start_time, end_time
updated_at = end_time
exercise.update_columns(publish_time: publish_time, end_time: end_time, created_at: created_at, updated_at: updated_at, exercise_status: 3)
end
when 4
# 资源
course.attachments.each do |atta|
created_on = random_time start_time, end_time
atta.update_columns(is_publish: 1, created_on: created_on, publish_time: created_on)
end
end
end
task :create_homework_work => :environment do
course = Course.find(course_id)
course.practice_homeworks.each do |homework|
if homework.student_works.count == 0
str = ""
CourseMember.students(course).each do |student|
str += "," if str != ""
str += "(#{homework.id},#{student.user_id}, '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}', '#{Time.now.strftime('%Y-%m-%d %H:%M:%S')}')"
end
if str != ""
sql = "insert into student_works (homework_common_id, user_id, created_at, updated_at) values" + str
ActiveRecord::Base.connection.execute sql
end
end
end
end
def min_swith(time)
puts time
return time < 9 ? "0#{time}" : time
end
def random_time(start_time, end_time)
hour = (6..23).to_a.sample(1).first
min = rand(60)
sec = rand(60)
start_time = Date.parse(start_time)
end_time = Date.parse(end_time)
date = (start_time..end_time).to_a.sample(1).first
time = "#{date} #{min_swith(hour)}:#{min_swith(min)}:#{min_swith(sec)}"
puts time
time
end
def random_larger_time(time, start_time, end_time)
large_time = random_time(start_time, end_time)
while large_time <= time
large_time = random_time(start_time, end_time)
end
large_time
end
end

@ -1,30 +1,22 @@
# bundle exec rake sync:public_message args=149,2903
namespace :sync do
task :public_message => :environment do
if ENV['args']
subject_id = ENV['args'].split(",")[0] # 对应课程的id
shixun_id = ENV['args'].split(",")[1] # 对应课程的id
board_id = ENV['args'].split(",")[2]
message_id = ENV['args'].split(",")[3]
status = ENV['args'].split(",")[4] # 表示相应的期数
if status.to_i == 1
start_time = '2018-12-16'
end_time = '2019-04-01'
elsif status.to_i == 2
start_time = '2019-04-07'
end_time = '2019-07-28'
else
# 这种情况是取所有的
start_time = '2015-01-01'
end_time = '2022-07-28'
end
start_time = ENV['args'].split(",")[4] # 表示课程模块
end_time = ENV['args'].split(",")[5] # 表示课程模块
limit = ENV['args'].split(",")[6] # 限制导入的数量
end
task :public_message => :environment do
shixun_ids = Shixun.find_by_sql("select shixun_id from stage_shixuns where stage_id in (select id from stages where
subject_id=#{subject_id}) ").map(&:shixun_id)
discusses = Discuss.where(dis_id: shixun_ids).where("created_at >? and created_at <?", start_time, end_time)
if discusses.present?
discusses.find_each do |discuss|
discusses.limit(limit).find_each do |discuss|
puts discuss.user_id
puts board_id
puts message_id
@ -35,23 +27,6 @@ namespace :sync do
end
task :sigle_message => :environment do
subject_id = ENV['args'].split(",")[0] # 对应课程的id
shixun_id = ENV['args'].split(",")[1] # 对应课程的id
board_id = ENV['args'].split(",")[2]
message_id = ENV['args'].split(",")[3]
status = ENV['args'].split(",")[4] # 表示相应的期数
if status.to_i == 1
start_time = '2018-12-16'
end_time = '2019-04-01'
elsif status.to_i == 2
start_time = '2019-04-07'
end_time = '2019-07-28'
else
# 这种情况是取所有的
start_time = '2015-01-01'
end_time = '2022-07-28'
end
if subject_id.to_i == -1
discusses = Discuss.where("parent_id is null and dis_id=?", shixun_id)
@ -119,18 +94,8 @@ namespace :sync do
end
end
task :board_count => :environment do
Course.find_each do |course|
puts course.id
begin
messages_count = Message.find_by_sql("select count(*) as count from messages where board_id in (select id from boards where course_id=#{course.id})").first.try(:count)
Board.update_column(messages_count: messages_count)
rescue
end
end
task :delete_boards => :environment do
course = Course.find(course_id)
course.boards.destroy
end
end

File diff suppressed because one or more lines are too long

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save