Merge branch 'dev_aliyun' of http://bdgit.educoder.net/Hjqreturn/educoder into dev_aliyun

dev_jupyter
anke1460 5 years ago
commit 262cafb327

@ -0,0 +1,74 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-salesman-channels-index-page').length > 0) {
// ============= 添加销售人员 ==============
var $addMemberModal = $('.admin-add-salesman-channel-user-modal');
var $addMemberForm = $addMemberModal.find('.admin-add-salesman-channel-user-form');
var $memberSelect = $addMemberModal.find('.salesman-channel-user-select');
var $salesmanIdInput = $('.salesman-channel-list-form').find(".btn-primary");
$addMemberModal.on('show.bs.modal', function(event){
var $link = $(event.relatedTarget);
// var salesmanId = $link.data('salesman_id');
// $salesmanIdInput.val(salesmanId);
$memberSelect.select2('val', ' ');
});
$memberSelect.select2({
theme: 'bootstrap4',
placeholder: '请输入要添加的单位',
multiple: true,
minimumInputLength: 1,
ajax: {
delay: 500,
url: '/admins/schools',
dataType: 'json',
data: function(params){
return { keyword: params.term };
},
processResults: function(data){
return { results: data.schools }
}
},
templateResult: function (item) {
if(!item.id || item.id === '') return '';
return $("<span>" + item.name + "</span>");
},
templateSelection: function(item){
if (item.id) {
}
return item.name || '';
}
});
$addMemberModal.on('click', '.submit-btn', function(){
$addMemberForm.find('.error').html('');
// var salesmanId = $salesmanIdInput.val();
var memberIds = $memberSelect.val();
if (memberIds && memberIds.length > 0) {
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/salesman_channels/batch_add',
data: { salesman_id: $salesmanIdInput.data("salesman-id"), school_ids: memberIds },
success: function(){
$.notify({ message: '创建成功' });
$addMemberModal.modal('hide');
setTimeout(function(){
window.location.reload();
}, 500);
},
error: function(res){
var data = res.responseJSON;
$form.find('.error').html(data.message);
}
});
} else {
$addMemberModal.modal('hide');
}
});
}
});

@ -0,0 +1,74 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-salesman-customers-index-page').length > 0) {
// ============= 添加销售人员 ==============
var $addMemberModal = $('.admin-add-salesman-customer-user-modal');
var $addMemberForm = $addMemberModal.find('.admin-add-salesman-customer-user-form');
var $memberSelect = $addMemberModal.find('.salesman-customer-user-select');
var $salesmanIdInput = $('.salesman-customer-list-form').find(".btn-primary");
$addMemberModal.on('show.bs.modal', function(event){
var $link = $(event.relatedTarget);
// var salesmanId = $link.data('salesman_id');
// $salesmanIdInput.val(salesmanId);
$memberSelect.select2('val', ' ');
});
$memberSelect.select2({
theme: 'bootstrap4',
placeholder: '请输入要添加的销售姓名',
multiple: true,
minimumInputLength: 1,
ajax: {
delay: 500,
url: '/admins/users',
dataType: 'json',
data: function(params){
return { name: params.term };
},
processResults: function(data){
return { results: data.users }
}
},
templateResult: function (item) {
if(!item.id || item.id === '') return item.text;
return $("<span>" + item.real_name + " <span class='font-12'>" + item.school_name + ' ' + item.hidden_phone + "</span></span>");
},
templateSelection: function(item){
if (item.id) {
}
return item.real_name || item.text;
}
});
$addMemberModal.on('click', '.submit-btn', function(){
$addMemberForm.find('.error').html('');
// var salesmanId = $salesmanIdInput.val();
var memberIds = $memberSelect.val();
if (memberIds && memberIds.length > 0) {
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/salesman_customers/batch_add',
data: { salesman_id: $salesmanIdInput.data("salesman-id"), user_ids: memberIds },
success: function(){
$.notify({ message: '创建成功' });
$addMemberModal.modal('hide');
setTimeout(function(){
window.location.reload();
}, 500);
},
error: function(res){
var data = res.responseJSON;
$form.find('.error').html(data.message);
}
});
} else {
$addMemberModal.modal('hide');
}
});
}
});

@ -0,0 +1,99 @@
$(document).on('turbolinks:load', function() {
if ($('body.admins-salesmans-index-page').length > 0) {
// ============= 添加销售人员 ==============
var $addMemberModal = $('.admin-add-salesman-user-modal');
var $addMemberForm = $addMemberModal.find('.admin-add-salesman-user-form');
var $memberSelect = $addMemberModal.find('.salesman-user-select');
// var $salesmanIdInput = $addMemberForm.find('input[name="salesman_id"]')
$addMemberModal.on('show.bs.modal', function(event){
var $link = $(event.relatedTarget);
// var salesmanId = $link.data('salesman-id');
// $salesmanIdInput.val(salesmanId);
$memberSelect.select2('val', ' ');
});
$memberSelect.select2({
theme: 'bootstrap4',
placeholder: '请输入要添加的销售姓名',
multiple: true,
minimumInputLength: 1,
ajax: {
delay: 500,
url: '/admins/users',
dataType: 'json',
data: function(params){
return { name: params.term };
},
processResults: function(data){
return { results: data.users }
}
},
templateResult: function (item) {
if(!item.id || item.id === '') return item.text;
return $("<span>" + item.real_name + " <span class='font-12'>" + item.school_name + ' ' + item.hidden_phone + "</span></span>");
},
templateSelection: function(item){
if (item.id) {
}
return item.real_name || item.text;
}
});
$addMemberModal.on('click', '.submit-btn', function(){
$addMemberForm.find('.error').html('');
// var salesmanId = $salesmanIdInput.val();
var memberIds = $memberSelect.val();
if (memberIds && memberIds.length > 0) {
$.ajax({
method: 'POST',
dataType: 'json',
url: '/admins/salesmans/batch_add',
data: { user_ids: memberIds },
success: function(){
$.notify({ message: '创建成功' });
$addMemberModal.modal('hide');
setTimeout(function(){
window.location.reload();
}, 500);
},
error: function(res){
var data = res.responseJSON;
$form.find('.error').html(data.message);
}
});
} else {
$addMemberModal.modal('hide');
}
});
$(".salesman-list-container").on("change", '.salesman-sync-course', function () {
var s_id = $(this).attr("data-id");
var json = {};
$.ajax({
url: "/admins/salesmans/" + s_id + "/update_sync_course",
type: "POST",
dataType:'script',
data: json
})
});
$(".salesman-list-container").on("change", '.salesman-sync-form', function () {
var s_id = $(this).attr("data-id");
var s_value = $(this).val();
var s_name = $(this).attr("name");
var json = {};
json[s_name] = s_value;
$.ajax({
url: "/admins/salesmans/" + s_id,
type: "PUT",
dataType:'script',
data: json
});
});
}
});

@ -0,0 +1,28 @@
class Admins::SalesmanChannelsController < Admins::BaseController
before_action :set_salesman
def index
@channels = SalesmanChannel.all
end
def batch_add
channel_ids = @salesman.salesman_channels.pluck(:school_id)
school_ids = params[:school_ids] - channel_ids
school_ids.each do |school_id|
school = School.find_by(id: school_id)
next if school.blank?
@salesman.salesman_channels.create!(school_id: school.id)
end
render_ok
end
def destroy
@salesman.salesman_channels.find_by!(id: params[:id]).destroy
end
private
def set_salesman
@salesman = Salesman.find params[:salesman_id]
end
end

@ -0,0 +1,28 @@
class Admins::SalesmanCustomersController < Admins::BaseController
before_action :set_salesman
def index
@customers = @salesman.salesman_customers.includes(:user, :school)
end
def batch_add
customer_ids = @salesman.salesman_customers.pluck(:user_id)
user_ids = params[:user_ids] - customer_ids
user_ids.each do |user_id|
user = UserExtension.find_by(user_id: user_id)
next if user.blank?
@salesman.salesman_customers.create!(user_id: user.user_id, school_id: user.school_id)
end
render_ok
end
def destroy
@salesman.salesman_customers.find_by!(id: params[:id]).destroy
end
private
def set_salesman
@salesman = Salesman.find params[:salesman_id]
end
end

@ -0,0 +1,29 @@
class Admins::SalesmansController < Admins::BaseController
before_action :set_salesman, except: [:index, :batch_add]
def index
@salesmans = Salesman.all
end
def destroy
@salesman.destroy!
end
# 批量增加销售人员
def batch_add
salesman_user_ids = Salesman.where(id: params[:user_ids]).pluck(:user_id)
user_ids = params[:user_ids] - salesman_user_ids
user_ids.each do |user_id|
user = User.find_by(id: user_id)
next if user.blank?
Salesman.create!(user_id: user.id, name: user.real_name)
end
render_ok
end
private
def set_salesman
@salesman = Salesman.find params[:id]
end
end

@ -4,7 +4,7 @@ class Admins::SchoolsController < Admins::BaseController
params[:sort_direction] ||= 'desc' params[:sort_direction] ||= 'desc'
schools = Admins::SchoolQuery.call(params) schools = Admins::SchoolQuery.call(params)
@total_count = schools.map(&:id).count
@schools = paginate schools @schools = paginate schools
school_ids = @schools.map(&:id) school_ids = @schools.map(&:id)

@ -49,7 +49,7 @@ class Admins::SubjectsController < Admins::BaseController
# 设为金课 # 设为金课
def excellent def excellent
current_subject.update!(excellent: true) current_subject.update!(excellent: true, public: 2)
render_ok render_ok
end end

@ -48,6 +48,19 @@ class ApplicationController < ActionController::Base
EduSetting.get(name) EduSetting.get(name)
end end
# 平台身份权限判断(学生用户无权限)
def identity_auth
ue = current_user.user_extension
tip_exception(403, "..") unless current_user.admin_or_business? || ue.teacher? || ue.professional?
end
# 平台已认证身份判断(已认证的老师和专业人士)
def certi_identity_auth
ue = current_user.user_extension
tip_exception(403, "..") unless current_user.admin_or_business? ||
(current_user.professional_certification && (ue.teacher? || ue.professional?))
end
def shixun_marker def shixun_marker
unless current_user.is_shixun_marker? || current_user.admin_or_business? unless current_user.is_shixun_marker? || current_user.admin_or_business?
tip_exception(403, "..") tip_exception(403, "..")
@ -73,7 +86,7 @@ class ApplicationController < ActionController::Base
check_account check_account
tip_exception(@course.excellent ? 410 : 409, "您没有权限进入") tip_exception(@course.excellent ? 410 : 409, "您没有权限进入")
end end
if @user_course_identity > Course::CREATOR && @user_course_identity <= Course::STUDENT if @user_course_identity > Course::CREATOR && @user_course_identity <= Course::STUDENT && @course.tea_id != current_user.id
# 实名认证和职业认证的身份判断 # 实名认证和职业认证的身份判断
tip_exception(411, "你的实名认证和职业认证审核未通过") if @course.authentication && tip_exception(411, "你的实名认证和职业认证审核未通过") if @course.authentication &&
@course.professional_certification && (!current_user.authentication && !current_user.professional_certification) @course.professional_certification && (!current_user.authentication && !current_user.professional_certification)
@ -308,7 +321,7 @@ class ApplicationController < ActionController::Base
end end
if !User.current.logged? && Rails.env.development? if !User.current.logged? && Rails.env.development?
User.current = User.find 8686 User.current = User.find 1
end end

@ -2,7 +2,7 @@ class CourseGroupsController < ApplicationController
before_action :require_login, :check_auth before_action :require_login, :check_auth
before_action :set_group, except: [:create] before_action :set_group, except: [:create]
before_action :find_course, only: [:create] before_action :find_course, only: [:create]
before_action :teacher_allowed before_action :teacher_allowed, except: [:set_invite_code_halt]
def create def create
tip_exception("分班名称不能为空") if params[:name].blank? tip_exception("分班名称不能为空") if params[:name].blank?
@ -55,6 +55,15 @@ class CourseGroupsController < ApplicationController
end end
end end
# 邀请码停用/启用
def set_invite_code_halt
teacher = @course.teachers.find_by(user_id: current_user.id)
tip_exception(403, "无权限") unless current_user.admin_or_business? ||
(teacher.present? && (teacher.teacher_course_groups.pluck(:course_group_id).include?(@group.id) || teacher.teacher_course_groups.size == 0))
@group.update!(invite_code_halt: !@group.invite_code_halt)
normal_status(0, "成功")
end
private private
def set_group def set_group

@ -1128,11 +1128,11 @@ class CoursesController < ApplicationController
return normal_status(-1, "邀请码不能为空") if params[:invite_code].blank? return normal_status(-1, "邀请码不能为空") if params[:invite_code].blank?
invite_code = params[:invite_code] invite_code = params[:invite_code]
course = Course.find_by(invite_code: invite_code, is_delete: 0, invite_code_halt: 0, laboratory_id: current_laboratory.id) course = Course.find_by(invite_code: invite_code, is_delete: 0, invite_code_halt: 0, laboratory_id: current_laboratory.id)
course_group = CourseGroup.find_by(invite_code: invite_code) course_group = CourseGroup.find_by(invite_code: invite_code, invite_code_halt: 0)
if course.blank? if course.blank?
return normal_status(-1, "邀请码无效") if course_group.blank? return normal_status(-1, "邀请码无效") if course_group.blank?
course = Course.find_by(id: course_group.course_id, is_delete: 0, invite_code_halt: 0, laboratory_id: current_laboratory.id) course = Course.find_by(id: course_group.course_id, is_delete: 0, laboratory_id: current_laboratory.id)
return normal_status(-1, "邀请码无效") if course.blank? return normal_status(-1, "邀请码无效") if course.blank?
end end

@ -1,8 +1,10 @@
class ExaminationBanksController < ApplicationController class ExaminationBanksController < ApplicationController
include PaginateHelper include PaginateHelper
before_action :require_login before_action :require_login
before_action :certi_identity_auth, only: [:create, :edit, :update, :destroy, :set_public, :revoke_item]
before_action :find_exam, except: [:index, :create] before_action :find_exam, except: [:index, :create]
before_action :edit_auth, only: [:update, :destroy, :set_public, :revoke_item] before_action :edit_auth, only: [:update, :destroy, :set_public, :revoke_item]
before_action :identity_auth, only: [:index]
def index def index
exams = ExaminationBankQuery.call(params) exams = ExaminationBankQuery.call(params)
@ -59,7 +61,7 @@ class ExaminationBanksController < ApplicationController
def set_public def set_public
tip_exception(-1, "该试卷已公开") if @exam.public? tip_exception(-1, "该试卷已公开") if @exam.public?
tip_exception(-1, "请勿重复提交申请") if ApplyAction.where(container_id: @exam.id, container_type: "ExaminationBank").exists? tip_exception(-1, "请勿重复提交申请") if ApplyAction.where(container_id: @exam.id, container_type: "ExaminationBank", status: 0).exists?
ApplyAction.create!(container_id: @exam.id, container_type: "ExaminationBank", user_id: current_user.id) ApplyAction.create!(container_id: @exam.id, container_type: "ExaminationBank", user_id: current_user.id)
# @exam.update_attributes!(public: 1) # @exam.update_attributes!(public: 1)
render_ok render_ok

@ -1,5 +1,6 @@
class ExaminationIntelligentSettingsController < ApplicationController class ExaminationIntelligentSettingsController < ApplicationController
before_action :require_login before_action :require_login
before_action :certi_identity_auth, only: [:create, :optinal_items, :save_exam, :exchange_one_item, :exchange_items]
before_action :find_exam, only: [:exchange_one_item, :exchange_items, :save_exam] before_action :find_exam, only: [:exchange_one_item, :exchange_items, :save_exam]
def optinal_items def optinal_items
@ -36,16 +37,19 @@ class ExaminationIntelligentSettingsController < ApplicationController
end end
def exchange_one_item def exchange_one_item
item = @exam.item_baskets.find_by!(id: params[:item_id]) item = @exam.item_baskets.find_by!(item_bank_id: params[:item_id])
exam_type_setting = @exam.examination_type_settings.find_by!(item_type: item.item_type) exam_type_setting = @exam.examination_type_settings.find_by!(item_type: item.item_type)
# 获取可选的题 # 获取可选的题
items = OptionalItemQuery.call(@exam.sub_discipline_id, @exam.tag_discipline_containers.pluck(:tag_discipline_id), @exam.difficulty, @exam.public) items = OptionalItemQuery.call(@exam.sub_discipline_id, @exam.tag_discipline_containers.pluck(:tag_discipline_id), @exam.difficulty, @exam.public)
# 可选题中去掉已组卷的试题
type_items = items.select{ |t_item| t_item.item_type == item.item_type } type_items = items.select{ |t_item| t_item.item_type == item.item_type }
# 如果可选的题数小于等于设置的题数则提示无可换的题 optional_item_ids = (type_items.pluck(:id) - @exam.item_baskets.where(item_type: item.item_type).pluck(:item_bank_id)).uniq
tip_exception("无可换的题") if type_items.size <= exam_type_setting.count
# 可选题中去掉已组卷的同题型试题 # 如果可选的题数等于0则提示无可换的题
optional_item_ids = type_items.pluck(:id) - @exam.item_baskets.where(item_type: item.item_type).pluck(:item_bank_id) tip_exception("无可换的题") if optional_item_ids.size == 0
new_item = ItemBank.find optional_item_ids.sample(1).first new_item = ItemBank.find optional_item_ids.sample(1).first
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
@exam.item_baskets << ItemBasket.new(item_bank_id: new_item.id, position: item.position, score: item.score, item_type: new_item.item_type) @exam.item_baskets << ItemBasket.new(item_bank_id: new_item.id, position: item.position, score: item.score, item_type: new_item.item_type)
@ -61,13 +65,15 @@ class ExaminationIntelligentSettingsController < ApplicationController
# 获取可选的题 # 获取可选的题
items = OptionalItemQuery.call(@exam.sub_discipline_id, @exam.tag_discipline_containers.pluck(:tag_discipline_id), @exam.difficulty, @exam.public) items = OptionalItemQuery.call(@exam.sub_discipline_id, @exam.tag_discipline_containers.pluck(:tag_discipline_id), @exam.difficulty, @exam.public)
type_items = items.select{ |t_item| t_item.item_type == params[:item_type] } type_items = items.select{ |t_item| t_item.item_type == params[:item_type] }
# 如果可选的题数小于等于设置的题数则提示无可换的题
tip_exception("无可换的题") if type_items.size <= exam_type_setting.count # 可选题中去掉已组卷的试题
# 可选题中去掉已组卷的同题型试题
choosed_item_ids = choosed_items.pluck(:item_bank_id) choosed_item_ids = choosed_items.pluck(:item_bank_id)
optional_item_ids = type_items.pluck(:id) - choosed_item_ids optional_item_ids = (type_items.pluck(:id) - choosed_item_ids).uniq
# 如果可选的题数等于0则提示无可换的题
tip_exception("无可换的题") if optional_item_ids.size == 0
# 如果可选题数小于设置的题数n则在原来的选题中随机选n个确保换题时能选到新的题 # 如果可选题数小于设置的题数n则在原来的选题中随机选n个确保换题时能选到新的题
if optional_item_ids.size < exam_type_setting.count if optional_item_ids.size < exam_type_setting.count
absence_count = exam_type_setting.count - optional_item_ids.size absence_count = exam_type_setting.count - optional_item_ids.size
optional_item_ids = optional_item_ids + choosed_item_ids.sample(absence_count) optional_item_ids = optional_item_ids + choosed_item_ids.sample(absence_count)

@ -1,5 +1,6 @@
class ExaminationItemsController < ApplicationController class ExaminationItemsController < ApplicationController
before_action :require_login before_action :require_login
before_action :certi_identity_auth, only: [:create, :destroy, :delete_item_type, :set_score, :batch_set_score, :adjust_position]
before_action :validate_score, only: [:set_score, :batch_set_score] before_action :validate_score, only: [:set_score, :batch_set_score]
before_action :find_exam, only: [:create, :batch_set_score, :delete_item_type] before_action :find_exam, only: [:create, :batch_set_score, :delete_item_type]
before_action :find_item, except: [:create, :batch_set_score, :delete_item_type] before_action :find_item, except: [:create, :batch_set_score, :delete_item_type]

@ -1,8 +1,10 @@
class ItemBanksController < ApplicationController class ItemBanksController < ApplicationController
include PaginateHelper include PaginateHelper
before_action :require_login before_action :require_login
before_action :certi_identity_auth, only: [:create, :edit, :update, :destroy, :set_public]
before_action :find_item, except: [:index, :create] before_action :find_item, except: [:index, :create]
before_action :edit_auth, only: [:update, :destroy, :set_public] before_action :edit_auth, only: [:update, :destroy, :set_public]
before_action :identity_auth, only: [:index]
def index def index
items = ItemBankQuery.call(params) items = ItemBankQuery.call(params)
@ -52,7 +54,7 @@ class ItemBanksController < ApplicationController
def set_public def set_public
tip_exception(-1, "该试题已公开") if @item.public? tip_exception(-1, "该试题已公开") if @item.public?
tip_exception(-1, "请勿重复提交申请") if ApplyAction.where(container_id: @item.id, container_type: 'ItemBank').exists? tip_exception(-1, "请勿重复提交申请") if ApplyAction.where(container_id: @item.id, container_type: 'ItemBank', status: 0).exists?
ApplyAction.create!(container_id: @item.id, container_type: 'ItemBank', user_id: current_user.id) ApplyAction.create!(container_id: @item.id, container_type: 'ItemBank', user_id: current_user.id)
# @item.update_attributes!(public: 1) # @item.update_attributes!(public: 1)
render_ok render_ok

@ -1,5 +1,6 @@
class ItemBasketsController < ApplicationController class ItemBasketsController < ApplicationController
before_action :require_login before_action :require_login
before_action :certi_identity_auth, only: [:create, :delete_item_type, :destroy, :set_score, :batch_set_score, :adjust_position]
before_action :validate_score, only: [:set_score, :batch_set_score] before_action :validate_score, only: [:set_score, :batch_set_score]
helper_method :current_basket helper_method :current_basket

@ -3,9 +3,10 @@ class SubjectsController < ApplicationController
# before_action :check_auth, except: [:index] # before_action :check_auth, except: [:index]
before_action :check_account, except: [:index, :show, :right_banner] before_action :check_account, except: [:index, :show, :right_banner]
before_action :find_subject, except: [:index, :create, :new, :append_to_stage, :add_shixun_to_stage] before_action :find_subject, except: [:index, :create, :new, :append_to_stage, :add_shixun_to_stage]
before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish, before_action :allowed, only: [:update, :edit, :destroy, :publish, :cancel_publish, :cancel_has_publish, :apply_public,
:search_members, :add_subject_members, :statistics, :shixun_report, :school_report, :search_members, :add_subject_members, :statistics, :shixun_report, :school_report,
:up_member_position, :down_member_position, :update_team_title, :statistics_info] :cancel_has_public, :up_member_position, :down_member_position, :update_team_title,
:statistics_info, :cancel_public]
before_action :require_admin, only: [:copy_subject] before_action :require_admin, only: [:copy_subject]
before_action :shixun_marker, only: [:add_shixun_to_stage] before_action :shixun_marker, only: [:add_shixun_to_stage]
@ -33,16 +34,16 @@ class SubjectsController < ApplicationController
laboratory_join = " AND subjects.id in #{subject_ids} " laboratory_join = " AND subjects.id in #{subject_ids} "
if select if select
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, subjects.public,
subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%' #{laboratory_join} subjects.hidden = 0 AND subjects.public = 2 AND subjects.name like '%#{search}%' #{laboratory_join}
AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC") AND subjects.repertoire_id = #{select} GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
else else
@subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, @subjects = Subject.find_by_sql("SELECT subjects.id, subjects.user_id, subjects.name, subjects.stages_count, subjects.repertoire_id, subjects.status, subjects.public,
subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns subjects.shixuns_count, subjects.excellent, sum(shixuns.myshixuns_count) AS myshixun_member_count FROM subjects join stage_shixuns
on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where on stage_shixuns.subject_id = subjects.id join shixuns on shixuns.id = stage_shixuns.shixun_id where
subjects.hidden = 0 AND subjects.status = 2 AND subjects.name like '%#{search}%' #{laboratory_join} subjects.hidden = 0 AND subjects.public = 2 AND subjects.name like '%#{search}%' #{laboratory_join}
GROUP BY subjects.id ORDER BY myshixun_member_count DESC") GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
end end
else else
@ -59,7 +60,7 @@ class SubjectsController < ApplicationController
elsif reorder == "publish_time" elsif reorder == "publish_time"
@subjects = @subjects.unhidden @subjects = @subjects.unhidden
else else
@subjects = @subjects.visible.unhidden @subjects = @subjects.publiced.unhidden
end end
# 类型 # 类型
@ -72,7 +73,7 @@ class SubjectsController < ApplicationController
end end
# 排序 # 排序
order_str = (reorder == "publish_time" ? "homepage_show desc, excellent desc, status = 2 desc, publish_time asc" : "homepage_show desc, excellent desc, updated_at desc") order_str = (reorder == "publish_time" ? "homepage_show desc, excellent desc, public = 2 desc, publish_time asc" : "homepage_show desc, excellent desc, updated_at desc")
@subjects = @subjects.reorder(order_str) @subjects = @subjects.reorder(order_str)
end end
@ -242,7 +243,8 @@ class SubjectsController < ApplicationController
## 云上实验室过滤 ## 云上实验室过滤
@courses = @courses.where(id: current_laboratory.all_courses) @courses = @courses.where(id: current_laboratory.all_courses)
@none_shixun_ids = @subject.shixuns.joins(:shixun_schools).where("school_id != #{current_user.user_extension.try(:school_id).to_i}").where(use_scope: 1).pluck(:id) @all_shixun_ids = @subject.shixuns.where(use_scope: 0).pluck(:id) +
@subject.shixuns.joins(:shixun_schools).where("school_id = #{current_user.user_extension.try(:school_id).to_i} and use_scope = 1").pluck(:id)
end end
def send_to_course def send_to_course
@ -272,14 +274,44 @@ class SubjectsController < ApplicationController
end end
def publish def publish
@subject.update_attributes(status: 2)
end
def cancel_publish
begin
apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first
if apply && apply.status == 0
apply.update_attributes(status: 3)
apply.tidings.destroy_all
end
@subject.update_attributes(status: 0)
rescue => e
uid_logger_error(e.message)
tip_exception("撤销申请失败")
end
end
def cancel_has_publish
begin
@subject.update_attributes(:status => 0)
rescue => e
uid_logger_error(e.message)
tip_exception("撤销发布失败")
raise ActiveRecord::Rollback
end
end
# 申请公开
def apply_public
tip_exception(-1, "请先发布课程再申请公开") if @subject.status != 2
apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first
if apply && apply.status == 0 if apply && apply.status == 0
@status = 0 @status = 0
else else
@subject.update_attributes(status: 1) @subject.update_attributes(public: 1)
ApplyAction.create(container_type: "ApplySubject", container_id: @subject.id, user_id: current_user.id, status: 0) ApplyAction.create(container_type: "ApplySubject", container_id: @subject.id, user_id: current_user.id, status: 0)
begin begin
status = Educoder::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员') Educoder::Sms.send(mobile: '18711011226', send_type:'publish_subject' , name: '管理员')
rescue => e rescue => e
uid_logger_error("发送验证码出错: #{e}") uid_logger_error("发送验证码出错: #{e}")
end end
@ -287,28 +319,28 @@ class SubjectsController < ApplicationController
end end
end end
def cancel_publish def cancel_public
begin begin
apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first apply = ApplyAction.where(container_type: "ApplySubject", container_id: @subject.id).order("created_at desc").first
if apply && apply.status == 0 if apply && apply.status == 0
apply.update_attributes(status: 3) apply.update_attributes(status: 3)
apply.tidings.destroy_all apply.tidings.destroy_all
end end
@subject.update_attributes(status: 0) @subject.update_attributes(public: 0)
render_ok
rescue => e rescue => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("撤销申请失败") tip_exception("撤销申请失败")
raise ActiveRecord::Rollback
end end
end end
def cancel_has_publish def cancel_has_public
begin begin
@subject.update_attributes(:status => 0) @subject.update_attributes(:public => 0)
render_ok
rescue => e rescue => e
uid_logger_error(e.message) uid_logger_error(e.message)
tip_exception("撤销发布失败") tip_exception("撤销公开失败")
raise ActiveRecord::Rollback
end end
end end

@ -42,11 +42,11 @@ class Weapps::CoursesController < Weapps::BaseController
tip_exception(-1, "邀请码不能为空") if params[:invite_code].blank? tip_exception(-1, "邀请码不能为空") if params[:invite_code].blank?
invite_code = params[:invite_code] invite_code = params[:invite_code]
course = Course.find_by(invite_code: invite_code, is_delete: 0, invite_code_halt: 0) course = Course.find_by(invite_code: invite_code, is_delete: 0, invite_code_halt: 0)
course_group = CourseGroup.find_by(invite_code: invite_code) course_group = CourseGroup.find_by(invite_code: invite_code, invite_code_halt: 0)
if course.blank? if course.blank?
tip_exception(-1, "邀请码无效") if course_group.blank? tip_exception(-1, "邀请码无效") if course_group.blank?
course = Course.find_by(id: course_group.course_id, is_delete: 0, invite_code_halt: 0) course = Course.find_by(id: course_group.course_id, is_delete: 0)
tip_exception(-1, "邀请码无效") if course.blank? tip_exception(-1, "邀请码无效") if course.blank?
end end

@ -1,11 +1,22 @@
module Admins::SubjectsHelper module Admins::SubjectsHelper
def display_subject_status(subject) def display_subject_status(subject)
style = style =
case subject.status case subject.public
when 0 then 'text-secondary' when 0 then 'text-secondary'
when 1 then 'text-warning' when 1 then 'text-warning'
when 2 then 'text-success' when 2 then 'text-success'
end end
raw content_tag(:span, t("subject.status.#{subject.status}"), class: style)
status =
if subject.public == 2
"publiced"
elsif subject.public == 1
"pending"
elsif subject.status == 2
"processed"
else
"editing"
end
raw content_tag(:span, t("subject.public.#{status}"), class: style)
end end
end end

@ -137,7 +137,7 @@ module ApplicationHelper
# 用户图像url如果不存在的话source为匿名用户即默认使用匿名用户图像 # 用户图像url如果不存在的话source为匿名用户即默认使用匿名用户图像
def url_to_avatar(source) def url_to_avatar(source)
if File.exist?(disk_filename(source.class, source.id)) if File.exist?(disk_filename(source&.class, source&.id))
ctime = File.ctime(disk_filename(source.class, source.id)).to_i ctime = File.ctime(disk_filename(source.class, source.id)).to_i
if source.class.to_s == 'User' if source.class.to_s == 'User'
File.join(relative_path, ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}" File.join(relative_path, ["#{source.class}", "#{source.id}"]) + "?t=#{ctime}"

@ -12,6 +12,12 @@ module CoursesHelper
# end # end
end end
def edit_auth group, teachers
User.current.admin_or_business? ||
teachers.select{|teacher| teacher.user_id == User.current.id &&
(teacher.teacher_course_groups.pluck(:course_group_id).include?(group.id) || teacher.teacher_course_groups.size == 0)}.size > 0
end
# 是否有切换为学生的入口 # 是否有切换为学生的入口
def switch_student_role is_teacher, course, user def switch_student_role is_teacher, course, user
is_teacher && course.course_members.where(user_id: user.id, role: %i(STUDENT)).exists? is_teacher && course.course_members.where(user_id: user.id, role: %i(STUDENT)).exists?

@ -177,6 +177,17 @@ module HomeworkCommonsHelper
type == 2 ? student_works.size : (type == 1 ? student_works.where("work_status != 0").size : student_works.where(work_status: 0).size) type == 2 ? student_works.size : (type == 1 ? student_works.where("work_status != 0").size : student_works.where(work_status: 0).size)
end end
# 作品数统计
def calculate_work_count homework_common, member
count = {}
student_works = homework_common.teacher_works(member)
count[:commit_count] = student_works.select{|work| work.work_status != 0 }.size
count[:uncommit_count] = student_works.select{|work| work.work_status == 0 }.size
count[:compelete_count] = Myshixun.where(id: student_works.pluck(:myshixun_id).reject(&:blank?), status: 1).size
count[:all_count] = student_works.size
count
end
# 上次查重的时间 # 上次查重的时间
def last_review_time homework_common, course_group def last_review_time homework_common, course_group
review = homework_common.homework_group_reviews.where(:course_group_id => course_group.id).last review = homework_common.homework_group_reviews.where(:course_group_id => course_group.id).last

@ -152,7 +152,7 @@ module ShixunsHelper
challenge_program_name = [] challenge_program_name = []
shixun.challenges.map(&:exec_path).each do |exec_path| shixun.challenges.map(&:exec_path).each do |exec_path|
challenge_program_name << "\"#{exec_path}\"" challenge_program_name << "\"#{exec_path}\""
if shixun.main_mirror_name == "Java" || shixun.main_mirror_name == "Openjdk10/VNC" if shixun.main_mirror_name == "Java" || shixun.main_mirror_name == "Openjdk10/VNC" || shixun.main_mirror_name == "JavaWeb"
if exec_path.nil? || exec_path.split("src/")[1].nil? if exec_path.nil? || exec_path.split("src/")[1].nil?
source = "\"\"" source = "\"\""
else else

@ -1,12 +1,23 @@
module SubjectsHelper module SubjectsHelper
# 实训路径的发布状态 # 实训路径的发布状态
def publish_status subject, is_manager, user def publish_status subject, is_manager
status = -1 status = -1
if is_manager if is_manager
status = 0 if subject.status == 0 status = 0 if subject.status == 0
status = 1 if subject.status == 1 status = 1 if subject.status == 1
status = 2 if subject.status == 2 && user.admin? status = 2 if subject.status == 2
end
status
end
# 实训路径的公开状态
def public_status subject, is_manager, user
status = -1
if is_manager
status = 0 if subject.public == 0
status = 1 if subject.public == 1
status = 2 if subject.public == 2 && user.admin?
end end
status status
end end

@ -1,3 +1,4 @@
class ItemAnalysis < ApplicationRecord class ItemAnalysis < ApplicationRecord
belongs_to :item_bank, touch: true belongs_to :item_bank, touch: true
validates :analysis, length: { maximum: 5000, too_long: "不能超过5000个字符" }
end end

@ -14,7 +14,6 @@ class ItemBank < ApplicationRecord
belongs_to :container, polymorphic: true, optional: true belongs_to :container, polymorphic: true, optional: true
validates :name, presence: true, length: { maximum: 1000, too_long: "不能超过1000个字符" } validates :name, presence: true, length: { maximum: 1000, too_long: "不能超过1000个字符" }
validates :analysis, length: { maximum: 5000, too_long: "不能超过5000个字符" }
def analysis def analysis
item_analysis&.analysis item_analysis&.analysis

@ -0,0 +1,7 @@
class Salesman < ApplicationRecord
belongs_to :user
# 渠道
has_many :salesman_channels, dependent: :destroy
# 客户
has_many :salesman_customers, dependent: :destroy
end

@ -0,0 +1,27 @@
class SalesmanChannel < ApplicationRecord
belongs_to :salesman, :touch => true, counter_cache: true
belongs_to :school
def school_name
school.name
end
def teacher_count
UserExtension.where(school_id: school_id).where.not(identity: 1).count
end
def student_count
UserExtension.where(school_id: school_id, identity: 1).count
end
def course_count
Course.where(school_id: school_id).count
end
def shixuns_count
ShixunMember.joins("join user_extensions on user_extensions.user_id = shixun_members.user_id")
.where(user_extensions: {school_id: school_id}).pluck(:shixun_id).uniq.count
end
end

@ -0,0 +1,22 @@
class SalesmanCustomer < ApplicationRecord
belongs_to :salesman, :touch => true, counter_cache: true
belongs_to :school
belongs_to :user
def name
user.real_name
end
def school_name
school.name
end
def courses_count
CourseMember.where(user_id: id).teachers_and_admin.count
end
def shixuns_count
ShixunMember.where(user_id: id, role: [1, 2]).count
end
end

@ -40,6 +40,7 @@ class Subject < ApplicationRecord
scope :visible, lambda{where(status: 2)} scope :visible, lambda{where(status: 2)}
scope :published, lambda{where(status: 1)} scope :published, lambda{where(status: 1)}
scope :unhidden, lambda{where(hidden: 0)} scope :unhidden, lambda{where(hidden: 0)}
scope :publiced, lambda{ where(public: 2) }
after_create :send_tiding after_create :send_tiding
def send_tiding def send_tiding

@ -16,12 +16,14 @@ class Admins::SubjectQuery < ApplicationQuery
# 状态过滤 # 状态过滤
status = status =
case params[:status].to_s.strip case params[:status].to_s.strip
when 'pending' then 0 when "editing" then {status: 0}
when 'applying' then 1 when "processed" then {status: 2, public: 0}
when 'published' then 2 when "pending" then {public: 1}
end when "publiced" then {public: 2}
subjects = subjects.where(status: status) if status end
subjects = subjects.where(status) if status
# 创建者单位 # 创建者单位
if params[:school_id].present? if params[:school_id].present?

@ -8,7 +8,7 @@ class Weapps::SubjectQuery < ApplicationQuery
end end
def call def call
subjects = @current_laboratory.subjects.unhidden.visible subjects = @current_laboratory.subjects.unhidden.publiced
# 课程体系的过滤 # 课程体系的过滤
if params[:sub_discipline_id].present? if params[:sub_discipline_id].present?

@ -10,7 +10,7 @@ class Admins::SubjectAuths::AgreeApplyService < ApplicationService
def call def call
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
apply.update!(status: 1, dealer_id: user.id) apply.update!(status: 1, dealer_id: user.id)
subject.update!(status: 2, publish_time: Time.now) subject.update!(public: 2, publish_time: Time.now)
deal_tiding! deal_tiding!
end end

@ -10,7 +10,7 @@ class Admins::SubjectAuths::RefuseApplyService < ApplicationService
def call def call
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
subject.update!(status: 0) subject.update!(public: 0)
apply.update!(status: 2, reason: reason, dealer_id: user.id) apply.update!(status: 2, reason: reason, dealer_id: user.id)
deal_tiding! deal_tiding!

@ -41,7 +41,8 @@ class SearchService < ApplicationService
when 'shixun' then when 'shixun' then
{ where: { id: Laboratory.current.shixuns.where(public: 2, status: 2, fork_from: nil).or(Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns)).pluck(:id) } } { where: { id: Laboratory.current.shixuns.where(public: 2, status: 2, fork_from: nil).or(Laboratory.current.shixuns.where(status: 2, id: User.current.shixuns)).pluck(:id) } }
when 'subject' then when 'subject' then
{ where: { id: Laboratory.current.subjects.pluck(:id) } } { where: { id: Laboratory.current.subjects.where(public: 2, status: 2)
.or( Laboratory.current.subjects.where(status: 2, id: User.current.subjects)).pluck(:id) } }
when 'course' then when 'course' then
{ where: { id: Laboratory.current.all_courses.pluck(:id) } } { where: { id: Laboratory.current.all_courses.pluck(:id) } }
else else

@ -17,9 +17,12 @@ class SubjectSearchService < ApplicationService
if type == "mine" if type == "mine"
@subjects = @subjects.where(id: User.current.subjects).visible.unhidden @subjects = @subjects.where(id: User.current.subjects).visible.unhidden
else else
@subjects = @subjects.visible.unhidden if User.current.admin? || User.current.business?
@subjects = @subjects.unhidden
else
@subjects = @subjects.publiced.unhidden.or(@subjects.where(id: User.current.subjects))
end
end end
Subject.search(keyword, search_options) Subject.search(keyword, search_options)
end end

@ -70,12 +70,21 @@ class Users::SubjectService
end end
def manage_subject_status_filter(relations) def manage_subject_status_filter(relations)
status = case params[:status] if params[:status] == "publiced"
when 'editing' then 0 relations = relations.where(public: 2)
when 'applying' then 1 elsif params[:status] == "applying"
when 'published' then 2 relations = relations.where(public: 1)
end else
relations = relations.where(status: status) if status status = case params[:status]
when 'editing' then
0
when 'applying' then
1
when 'published' then
2
end
relations = relations.where(status: status) if status
end
relations relations
end end

@ -1,27 +0,0 @@
<table class="table table-hover text-center repertoires-list-table">
<thead class="thead-light">
<tr>
<th width="6%">序号</th>
<th width="54%" class="text-left">技术体系</th>
<th width="16%">操作</th>
</tr>
</thead>
<tbody>
<% if @repertoires.present? %>
<% @repertoires.each_with_index do |repertoire, index| %>
<tr class="repertoire-item discipline-item-<%= repertoire.id %>">
<td><%= index + 1 %></td>
<td class="text-left">
<span><%= link_to repertoire.name, admins_sub_repertoires_path(repertoire_id: repertoire), :title => repertoire.name %></span>
</td>
<td>
<%= link_to '编辑', edit_admins_repertoire_path(repertoire), remote: true, class: 'action' %>
<%= delete_link '删除', admins_repertoire_path(repertoire, element: ".repertoire-item-#{repertoire.id}"), class: 'delete-repertoire-action' %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -0,0 +1,2 @@
$.notify({ message: '操作成功' },{ type: 'success' });
$("<%= params[:element]%>").remove();

@ -0,0 +1,15 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb("#{@salesman.name}的渠道", admins_salesmans_path) %>
<% end %>
<div class="box search-form-container salesman-channel-list-form rig">
<div class="flex-1">
<%= javascript_void_link '新增渠道', class: 'btn btn-primary', data: {salesman_id: @salesman.id, toggle: 'modal', target: '.admin-add-salesman-channel-user-modal' } %>
</div>
</div>
<div class="box admin-list-container salesman-channel-list-container">
<%= render(partial: 'admins/salesman_channels/shared/list') %>
</div>
<%= render 'admins/salesman_channels/shared/add_salesman_channels_user_modal' %>

@ -1,18 +1,25 @@
<div class="modal fade admin-edit-repertoire-modal" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade admin-add-salesman-channel-user-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title">编辑技术体系</h5> <h5 class="modal-title">添加渠道</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<%= simple_form_for([:admins, repertoire], html: { class: 'admin-edit-repertoire-form' }, defaults: { wrapper_html: { class: 'offset-md-1 col-md-10' } }) do |f| %> <form class="admin-add-salesman-user-form">
<%= f.input :name, as: :string, label: '名称' %> <%= hidden_field_tag(:salesman_id, nil) %>
<div class="form-group d-flex">
<label class="col-form-label">单位:</label>
<div class="d-flex flex-column-reverse w-75">
<select id="user_ids" name="user_ids" class="form-control salesman-channel-user-select"></select>
</div>
</div>
<div class="error text-danger"></div> <div class="error text-danger"></div>
<% end %> </form>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button> <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>

@ -0,0 +1,42 @@
<table class="table table-hover text-center salesman-channel-list-table">
<thead class="thead-light">
<tr>
<th width="6%">序号</th>
<th width="17%" class="text-left">名称</th>
<th width="15%" class="text-left">教师数</th>
<th width="15%" class="text-left">学生数</th>
<th width="15%">课堂数</th>
<th width="15%">实训数</th>
<th width="17%">操作</th>
</tr>
</thead>
<tbody>
<% if @channels.present? %>
<% @channels.each_with_index do |channel, index| %>
<tr class="channel-item salesman-channel-item-<%= channel.id %>">
<td><%= index + 1 %></td>
<td class="text-left">
<span><%= channel.school_name %></span>
</td>
<td class="text-left">
<span><%= channel.teacher_count %></span>
</td>
<td class="text-left">
<span><%= channel.student_count %></span>
</td>
<td>
<%= channel.course_count %>
</td>
<td>
<%= channel.shixuns_count %>
</td>
<td>
<%= delete_link '删除', admins_salesman_channel_path(channel, salesman_id: channel.salesman_id, element: ".salesman-channel-item-#{channel.id}"), class: 'delete-salesman-action' %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -0,0 +1,2 @@
$.notify({ message: '操作成功' },{ type: 'success' });
$("<%= params[:element]%>").remove();

@ -0,0 +1,15 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb("#{@salesman.name}的客户", admins_salesmans_path) %>
<% end %>
<div class="box search-form-container salesman-customer-list-form rig">
<div class="flex-1">
<%= javascript_void_link '新增客户', class: 'btn btn-primary', data: {salesman_id: @salesman.id, toggle: 'modal', target: '.admin-add-salesman-customer-user-modal' } %>
</div>
</div>
<div class="box admin-list-container salesman-customer-list-container">
<%= render(partial: 'admins/salesman_customers/shared/list') %>
</div>
<%= render 'admins/salesman_customers/shared/add_salesman_customers_user_modal' %>

@ -0,0 +1,30 @@
<div class="modal fade admin-add-salesman-customer-user-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="admin-add-salesman-user-form">
<%= hidden_field_tag(:salesman_id, nil) %>
<div class="form-group d-flex">
<label class="col-form-label">姓名:</label>
<div class="d-flex flex-column-reverse w-75">
<select id="user_ids" name="user_ids" class="form-control salesman-customer-user-select"></select>
</div>
</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>

@ -0,0 +1,38 @@
<table class="table table-hover text-center salesman-customer-list-table">
<thead class="thead-light">
<tr>
<th width="6%">序号</th>
<th width="20%" class="text-left">名称</th>
<th width="30%" class="text-left">单位</th>
<th width="12%" class="text-left">课堂数</th>
<th width="12%">实训数</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
<% if @customers.present? %>
<% @customers.each_with_index do |customer, index| %>
<tr class="customer-item salesman-customer-item-<%= customer.id %>">
<td><%= index + 1 %></td>
<td class="text-left">
<span><%= link_to customer.name, user_path(customer), :title => customer.name %></span>
</td>
<td class="text-left">
<span><%= customer.school_name %></span>
</td>
<td class="text-left">
<span><%= customer.courses_count %></span>
</td>
<td>
<%= customer.shixuns_count %>
</td>
<td>
<%= delete_link '删除', admins_salesman_customer_path(customer, salesman_id: customer.salesman_id, element: ".salesman-customer-item-#{customer.id}"), class: 'delete-salesman--action' %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -0,0 +1,2 @@
$.notify({ message: '操作成功' },{ type: 'success' });
$(".salesman-item-<%= params[:id]%>").remove();

@ -0,0 +1,15 @@
<% define_admin_breadcrumbs do %>
<% add_admin_breadcrumb('销售数据列表', admins_salesmans_path) %>
<% end %>
<div class="box search-form-container salesman-list-form rig">
<div class="flex-1">
<%= javascript_void_link '新增销售人员', class: 'btn btn-primary', data: { toggle: 'modal', target: '.admin-add-salesman-user-modal' } %>
</div>
</div>
<div class="box admin-list-container salesman-list-container">
<%= render(partial: 'admins/salesmans/shared/list') %>
</div>
<%= render 'admins/salesmans/shared/add_salesman_user_modal' %>

@ -1,18 +1,20 @@
<div class="modal fade admin-create-repertoire-modal" tabindex="-1" role="dialog" aria-hidden="true"> <div class="modal fade admin-add-salesman-user-modal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document"> <div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title">新建课程方向</h5> <h5 class="modal-title">添加销售人员</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close"> <button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</button> </button>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<form class="admin-create-repertoire-form" data-url="<%= admins_repertoires_path %>"> <form class="admin-add-salesman-user-form">
<%= hidden_field_tag(:salesman_id, nil) %>
<div class="form-group d-flex"> <div class="form-group d-flex">
<label for="new_mirror_id" class="col-form-label">名称:</label> <label class="col-form-label">名:</label>
<div class="w-75 d-flex flex-column"> <div class="d-flex flex-column-reverse w-75">
<%= text_field_tag(:name, nil, class: 'form-control', placeholder: '请输入名称') %> <select id="user_ids" name="user_ids" class="form-control salesman-user-select"></select>
</div> </div>
</div> </div>

@ -0,0 +1,37 @@
<table class="table table-hover text-center salesman-list-table">
<thead class="thead-light">
<tr>
<th width="6%">序号</th>
<th width="20%" class="text-left">名称</th>
<th width="30%" class="text-left">客户数(点击数字客户列表)</th>
<th width="30%" class="text-left">渠道数(点击数字渠道列表)</th>
<th width="14%">操作</th>
</tr>
</thead>
<tbody>
<% if @salesmans.present? %>
<% @salesmans.each_with_index do |salesman, index| %>
<tr class="salesman-item salesman-item-<%= salesman.id %>">
<td><%= index + 1 %></td>
<td class="text-left">
<span><%= link_to salesman.name, admins_salesman_path(salesman), :title => salesman.name %></span>
</td>
<td class="text-left">
<span><%= link_to salesman.salesman_customers_count.to_i,
admins_salesman_customers_path(salesman_id: salesman), :title => "点击进入客户列表" %></span>
</td>
<td class="text-left">
<span><%= link_to salesman.salesman_channels_count.to_i, admins_salesman_channels_path(salesman_id: salesman),
:title => "点击进入渠道列表" %></span>
</td>
<td>
<%= delete_link '删除', admins_salesman_path(salesman, element: ".salesman-item-#{salesman.id}"),
class: 'delete-salesman-action' %>
</td>
</tr>
<% end %>
<% else %>
<%= render 'admins/shared/no_data_for_table' %>
<% end %>
</tbody>
</table>

@ -0,0 +1,6 @@
json.count @total_count
json.schools do
json.array! @schools.each do |school|
json.extract! school, :id, :name
end
end

@ -87,6 +87,12 @@
<% end %> <% end %>
</li> </li>
<li>
<%= sidebar_item_group('#running_data', '运营数据', icon: 'bar-chart') do %>
<li><%= sidebar_item(admins_salesmans_path, '销售数据列表', icon: 'columns', controller: 'admins-salesman') %></li>
<% end %>
</li>
<li> <li>
<%= sidebar_item_group('#other-submenu', '其他', icon: 'list-alt') do %> <%= sidebar_item_group('#other-submenu', '其他', icon: 'list-alt') do %>
<li><%= sidebar_item(admins_repertoires_path, '技术体系', icon: 'sitemap', controller: 'admins-repertoire') %></li> <li><%= sidebar_item(admins_repertoires_path, '技术体系', icon: 'sitemap', controller: 'admins-repertoire') %></li>

@ -6,7 +6,7 @@
<%= form_tag(admins_subjects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %> <%= form_tag(admins_subjects_path, method: :get, class: 'form-inline search-form flex-1', remote: true) do %>
<div class="form-group mr-1"> <div class="form-group mr-1">
<label for="status">状态:</label> <label for="status">状态:</label>
<% status_options = [['全部', ''], ['编辑中', 'pending'], ['审核中', 'applying'], ['已发布', 'published']] %> <% status_options = [['全部', ''], ["编辑中", "editing"], ["已发布", 'processed'], ["待审核", 'pending'], ["已公开", 'publiced']] %>
<%= select_tag(:status, options_for_select(status_options), class: 'form-control') %> <%= select_tag(:status, options_for_select(status_options), class: 'form-control') %>
</div> </div>

@ -1,7 +1,8 @@
json.course_groups @course_groups.each do |group| json.course_groups @course_groups.each do |group|
json.(group, :id, :course_members_count, :name) json.(group, :id, :course_members_count, :name, :invite_code_halt)
json.invite_code group.invite_code if @user_course_identity < Course::STUDENT json.invite_code group.invite_code if @user_course_identity < Course::STUDENT
json.member_manager member_manager(group, @teachers) if @user_course_identity < Course::NORMAL json.member_manager member_manager(group, @teachers) if @user_course_identity < Course::NORMAL
json.edit_auth edit_auth(group, @teachers) if @user_course_identity < Course::STUDENT
end end
if @user_course_identity == Course::STUDENT if @user_course_identity == Course::STUDENT

@ -25,9 +25,11 @@ json.homeworks @homework_commons.each do |homework|
json.upper_category_name homework.course_second_category&.name unless params[:category] json.upper_category_name homework.course_second_category&.name unless params[:category]
unless curr_status[:status].include?("未发布") unless curr_status[:status].include?("未发布")
json.commit_count studentwork_count homework, 1, @member work_count = calculate_work_count homework, @member
json.uncommit_count studentwork_count homework, 0, @member json.commit_count work_count[:commit_count]
json.all_count studentwork_count homework, 2, @member json.uncommit_count work_count[:uncommit_count]
json.all_count work_count[:all_count]
json.compelete_count work_count[:compelete_count]
end end
if homework.homework_type == "practice" if homework.homework_type == "practice"

@ -171,7 +171,7 @@ elsif @homework.homework_type == "group" || @homework.homework_type == "normal"
json.user_login @is_evaluation ? "--" : work.user.try(:login) json.user_login @is_evaluation ? "--" : work.user.try(:login)
json.user_name @is_evaluation ? "匿名" : work.user.try(:real_name) json.user_name @is_evaluation ? "匿名" : work.user.try(:real_name)
json.user_img url_to_avatar(@is_evaluation ? "0" : work.user) json.user_img @is_evaluation ? "--" : url_to_avatar(work.user)
end end
end end

@ -0,0 +1,2 @@
json.status @status
json.message @status == 0 ? "已公开过申请,请等待管理员审核" : "公开申请已提交,请等待管理员的审核"

@ -1,2 +1,2 @@
json.status 1 json.status 0
json.subject_id @subject.id json.subject_id @subject.id

@ -7,7 +7,7 @@ end
json.stages @subject.stages.includes(shixuns: [user: :user_extension]) do |stage| json.stages @subject.stages.includes(shixuns: [user: :user_extension]) do |stage|
index = 1 index = 1
json.shixuns stage.shixuns do |shixun| json.shixuns stage.shixuns do |shixun|
if shixun.status == 2 && !shixun.is_jupyter && !@none_shixun_ids.include?(shixun.id) if shixun.status == 2 && !shixun.is_jupyter && @all_shixun_ids.include?(shixun.id)
json.shixun_id shixun.id json.shixun_id shixun.id
json.id shixun.id json.id shixun.id
json.identifier shixun.identifier json.identifier shixun.identifier

@ -1,2 +1,2 @@
json.status @status json.status 0
json.message @status == 0 ? "已发布过申请,请等待管理员审核" : "发布申请已提交,请等待管理员的审核" json.message "发布成功"

@ -6,7 +6,8 @@ json.subject_score @subject.all_score
json.member_count @subject.member_count json.member_count @subject.member_count
json.allow_delete (@subject.status != 2 && @is_creator) || @user.admin? json.allow_delete (@subject.status != 2 && @is_creator) || @user.admin?
json.publish_status publish_status(@subject, @is_manager, @user) json.publish_status publish_status(@subject, @is_manager)
json.public_status public_status(@subject, @is_manager, @user)
json.allow_statistics @is_manager json.allow_statistics @is_manager
json.allow_send @user.logged? json.allow_send @user.logged?
json.allow_visit @subject.status > 1 || @is_manager json.allow_visit @subject.status > 1 || @is_manager

@ -3,4 +3,9 @@
status: status:
'0': 编辑中 '0': 编辑中
'1': 审核中 '1': 审核中
'2': 已发布 '2': 已发布
public:
'editing': 编辑中
'processed': 已发布
'pending': 审核中
'publiced': 已公开

@ -406,9 +406,12 @@ Rails.application.routes.draw do
resources :subjects, path: :paths do resources :subjects, path: :paths do
member do member do
get 'choose_subject_shixun' get 'choose_subject_shixun'
get 'publish' post 'publish'
get 'cancel_publish' post :apply_public
get 'cancel_has_publish' post :cancel_public
post 'cancel_publish'
post 'cancel_has_publish'
post :cancel_has_public
get 'statistics' get 'statistics'
get 'statistics_info' get 'statistics_info'
get 'shixun_report' get 'shixun_report'
@ -662,6 +665,7 @@ Rails.application.routes.draw do
member do member do
post 'rename_group' post 'rename_group'
post 'move_category' post 'move_category'
post 'set_invite_code_halt'
end end
collection do collection do
@ -1356,6 +1360,16 @@ Rails.application.routes.draw do
resources :repertoires, only: [:index, :create, :edit, :update, :destroy] resources :repertoires, only: [:index, :create, :edit, :update, :destroy]
resources :sub_repertoires, only: [:index, :create, :edit, :update, :destroy] resources :sub_repertoires, only: [:index, :create, :edit, :update, :destroy]
resources :tag_repertoires, only: [:index, :create, :edit, :update, :destroy] resources :tag_repertoires, only: [:index, :create, :edit, :update, :destroy]
resources :salesmans, only: [:index, :create, :edit, :update, :destroy] do
post :batch_add, on: :collection
end
resources :salesman_channels, only: [:index, :create, :edit, :update, :destroy] do
post :batch_add, on: :collection
end
resources :salesman_customers, only: [:index, :create, :edit, :update, :destroy] do
post :batch_add, on: :collection
end
end end
namespace :cooperative do namespace :cooperative do

@ -0,0 +1,11 @@
class CreateSalesmen < ActiveRecord::Migration[5.2]
def change
create_table :salesmen do |t|
t.references :user
t.string :name
t.integer :salesman_channels_count
t.integer :salesman_customers_count
t.timestamps
end
end
end

@ -0,0 +1,9 @@
class CreateSalesmanChannels < ActiveRecord::Migration[5.2]
def change
create_table :salesman_channels do |t|
t.references :salesman
t.references :school
t.timestamps
end
end
end

@ -0,0 +1,10 @@
class CreateSalesmanCustomers < ActiveRecord::Migration[5.2]
def change
create_table :salesman_customers do |t|
t.references :salesman
t.references :user
t.references :school
t.timestamps
end
end
end

@ -0,0 +1,5 @@
class AddCodeHaltToCourseGroup < ActiveRecord::Migration[5.2]
def change
add_column :course_groups, :invite_code_halt, :boolean, default: false
end
end

@ -0,0 +1,5 @@
class AddPublicForSubjects < ActiveRecord::Migration[5.2]
def change
add_column :subjects, :public, :integer, :default => 0
end
end

@ -0,0 +1,7 @@
class MigrateSubjectStatus < ActiveRecord::Migration[5.2]
def change
Subject.unhidden.visible.update_all(public: 2)
Subject.where(status: 1, id: ApplyAction.where(container_type: 'ApplySubject', status: 0)
.pluck(:container_id)).update_all(status: 2, public: 1)
end
end

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

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