Merge branch 'develop' into educoder

dev_library
jingquan huang 6 years ago
commit 8304988420

@ -376,7 +376,7 @@ class ApplicationController < ActionController::Base
def require_admin
return unless require_login
if !User.current.admin? && @shixun.status > 1
if !User.current.admin?
render_403
return false
end

@ -32,6 +32,15 @@ class ManagementsController < ApplicationController
# 实训课程等级体系
def subject_level_system
@levels = SubjectLevelSystem.all
respond_to do |format|
format.js
format.html
format.xls{
time = Time.now.strftime("%Y%m%d")
filename = "实训课程体系#{time}.xls"
send_data(export_subject_level_system(), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
end
end
# 创建课程等级体系
@ -4152,7 +4161,7 @@ end
sheet1 = book.create_worksheet :name => "sheet"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
sheet1.row(0).concat(["姓名", "手机号","邮箱","单位名称", "职位","专业", "学号", "支付方式","支付状态","支付时间", "发票类型", "发票抬头","税务登记号", "发票内容", "备注", "微信支付单号", "报名时间"])
sheet1.row(0).concat(["姓名", "手机号","邮箱","单位名称", "职位","专业", "学号", '培训类型', '授课/研究领域' "支付方式","支付状态","支付时间", "发票类型", "发票抬头","税务登记号", "发票内容", "备注", "微信支付单号", "报名时间"])
count_row = 1
trainings.find_each do |t|
sheet1[count_row, 0] = t.name
@ -4162,16 +4171,18 @@ end
sheet1[count_row, 4] = t.position
sheet1[count_row, 5] = t.major
sheet1[count_row, 6] = t.student_id
sheet1[count_row, 7] = t.training_payinfo.try(:pay_type_str)
sheet1[count_row, 8] = t.training_payinfo.try(:pay_status_str)
sheet1[count_row, 9] = format_time t.training_payinfo.try(:pay_time)
sheet1[count_row, 10] = t.training_payinfo.try(:invoice_title).present? ? '需要' : '不需要'
sheet1[count_row, 11] = t.training_payinfo.try(:invoice_title)
sheet1[count_row, 12] = t.training_payinfo.try(:invoice_no)
sheet1[count_row, 13] = t.training_payinfo.try(:invoice_content)
sheet1[count_row, 14] = t.training_payinfo.try(:info)
sheet1[count_row, 15] = t.training_payinfo.try(:out_trade_no)
sheet1[count_row, 16] = format_time t.created_at
sheet1[count_row, 7] = t.training_category
sheet1[count_row, 8] = t.research_field
sheet1[count_row, 9] = t.training_payinfo.try(:pay_type_str)
sheet1[count_row, 10] = t.training_payinfo.try(:pay_status_str)
sheet1[count_row, 11] = format_time t.training_payinfo.try(:pay_time)
sheet1[count_row, 12] = t.training_payinfo.try(:invoice_title).present? ? '需要' : '不需要'
sheet1[count_row, 13] = t.training_payinfo.try(:invoice_title)
sheet1[count_row, 14] = t.training_payinfo.try(:invoice_no)
sheet1[count_row, 15] = t.training_payinfo.try(:invoice_content)
sheet1[count_row, 16] = t.training_payinfo.try(:info)
sheet1[count_row, 17] = t.training_payinfo.try(:out_trade_no)
sheet1[count_row, 18] = format_time t.created_at
count_row += 1
end
book.write xls_report
@ -4286,6 +4297,33 @@ end
return sheet.rows
end
def export_subject_level_system
xls_report = StringIO.new
book = Spreadsheet::Workbook.new
sheet1 = book.create_worksheet :name => "实训课程等级体系"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue
count_row = 1
sheet1.row(0).concat(["序号", "等级", "实训课程名称", "实训课程url", "实训名称"])
levels = SubjectLevelSystem.includes(subjects: [stage_shixuns: :shixun]).where(nil)
levels.each_with_index do |level, i|
sheet1[count_row, 0] = i + 1
sheet1[count_row, 1] = level.name
level.subjects.each do |subject|
sheet1[count_row, 2] = subject.name
sheet1[count_row, 3] = "#{Setting.protocol}://#{Setting.host_name}#{subject_path(subject)}"
count_row += 1
subject.shixuns.each do |shixun|
sheet1[count_row, 4] = shixun.name
count_row += 1
end
end
count_row += 1
end
book.write xls_report
xls_report.string
end
def shixun_feedback_xls shixun_ids, beginTime, endTime
xls_report = StringIO.new
book = Spreadsheet::Workbook.new

@ -10,7 +10,7 @@ class ShixunsController < ApplicationController
before_filter :view_allow, :only => [:collaborators, :propaedeutics, :shixun_discuss, :ranking_list]
before_filter :require_manager, :only => [ :settings, :add_script, :publish, :collaborators_delete, :shixun_members_added, :add_collaborators, :update, :destroy]
before_filter :validation_email, :only => [:new]
before_filter :require_admin, :only => [:destroy]
#before_filter :require_manager, :only => [:destroy]
# 移动云ToC模式权限控制
# before_filter :ecloud_auth, :except => [:show, :index]
@ -1117,6 +1117,7 @@ class ShixunsController < ApplicationController
end
def destroy
render_403 if @shixun.status > 1 && !User.current.admin?
ActiveRecord::Base.transaction do
g = Gitlab.client
g.delete_project(@shixun.gpid) if @shixun.try(:gpid).present?

@ -496,7 +496,7 @@ class StudentWorkController < ApplicationController
def _index
# REDO:分班信息提前查出来,然后循环中根据匹配去取
@is_teacher = User.current.logged? ? (User.current.allowed_to?(:as_teacher,@course) || User.current.admin?) : false
@is_teacher = User.current.logged? ? (User.current.allowed_to?(:as_teacher,@course) || User.current.admin? || User.current.business?) : false
@member = @course.members.where(:user_id => User.current.id).first
# 判断学生是否有权限查看(作业未发布、作业已发布但不是统一设置的未分班学生、分班设置的作业未发布)
if User.current.member_of_course?(@course) && !@is_teacher

@ -3,11 +3,14 @@ require 'base64'
class TrainingsController < ApplicationController
wechat_responder
skip_before_filter :verify_signature, only: [:show, :create, :test]
skip_before_filter :verify_signature, only: [:show, :create, :update, :test, :enroll]
ROOT_URL = ENV["wechat_url"] || "#{Setting.protocol}://#{Setting.host_name}"
before_filter :authenticate, except: [:auth, :auth_callback, :pay_callback]
before_filter :find_tag_id
before_filter :find_training, only: [:show, :test]
before_filter :valid_training, only: [:pay, :result, :pay_js]
@ -15,18 +18,18 @@ class TrainingsController < ApplicationController
layout 'base_trainings'
TAG_ID = 'bigdata_hnjcxy_2019'
# TAG_ID = 'bigdata_hnjcxy_2019'
def show
@training = current_training
url = nil
if @training && !@training.pay?
url = enroll_training_path(id: TAG_ID)
url = enroll_training_path(id: @tag_id)
elsif @training && @training.pay?
url = result_training_path(id: TAG_ID)
url = result_training_path(id: @tag_id)
else
url = enroll_training_path(id: TAG_ID)
url = enroll_training_path(id: @tag_id)
end
redirect_to url
@ -34,10 +37,11 @@ class TrainingsController < ApplicationController
def enroll
@training = current_training || Training.new
Rails.logger.info("##########training_type:#{@training_type}")
@training_title = @training_type == 3 ? "信息技术新工科产学研联盟师资培训班" : "工程教育认证"
Rails.logger.info("##########training_title:#{@training_title}")
end
def pay
_pay_params
@ -45,7 +49,7 @@ class TrainingsController < ApplicationController
# 防止重复支付,对于已支付过的,不应该再到这个页来
if @training.payed?
redirect_to result_training_path(id: TAG_ID)
redirect_to result_training_path(id: @tag_id)
return
end
@ -100,11 +104,16 @@ class TrainingsController < ApplicationController
def create
@training = current_training || Training.new(params)
@training.training_type = Training::Training_Type
@training.training_type = @training_type
if @training_type == 3
@training.research_field = params[:research_field].select(&:present?).uniq.join(",")
@training.training_category = params[:training_category]
end
@training.openid = session[:wechat_open_id]
@training.save!
redirect_to pay_training_path(id: TAG_ID)
redirect_to enroll_training_path(id: @tag_id)
# redirect_to pay_training_path(id: @tag_id)
end
@ -115,8 +124,15 @@ class TrainingsController < ApplicationController
return
end
@training.update_attributes(params)
redirect_to pay_training_path(id: TAG_ID)
@training.assign_attributes(params)
if @training.training_type == 3
@training.research_field = params[:research_field].select(&:present?).uniq.join(",")
@training.training_category = params[:training_category]
end
@training.save!
redirect_to enroll_training_path(id: @tag_id)
# redirect_to pay_training_path(id: @tag_id)
end
@ -168,7 +184,7 @@ class TrainingsController < ApplicationController
if params[:js] == 'true'
_pay_js(training_info.fee)
else
redirect_to url = result_training_path(id: TAG_ID)
redirect_to url = result_training_path(id: @tag_id)
end
end
@ -232,11 +248,11 @@ class TrainingsController < ApplicationController
url = ''
if !@training
url = training_path(id: TAG_ID)
url = training_path(id: @tag_id)
elsif !@training.pay?
url = enroll_training_path(id: TAG_ID)
url = enroll_training_path(id: @tag_id)
else
url = result_training_path(id: TAG_ID)
url = result_training_path(id: @tag_id)
end
redirect_to url
@ -262,8 +278,15 @@ class TrainingsController < ApplicationController
end
end
def find_tag_id
@tag_id = params[:tag_id] || params[:id]
Rails.logger.info("##########TAG_ID:#{@tag_id}")
@training_type = @tag_id == "aeee0601_2019" ? 3 : @tag_id == "ceeaa06_2019" ? 4 : 0
render_404 if @training_type == 0
end
def find_training
if params[:id] == TAG_ID
if params[:id] == @tag_id
@training = current_training
else
render_404
@ -271,18 +294,16 @@ class TrainingsController < ApplicationController
end
def current_training
Training.where(openid: session[:wechat_open_id], training_type: Training::Training_Type).first
Rails.logger.info("##########openid:#{session[:wechat_open_id]}, training_type: #{@training_type}")
Training.where(openid: session[:wechat_open_id], training_type: @training_type).first
end
def valid_training
unless current_training
redirect_to training_path(id: TAG_ID)
redirect_to training_path(id: @tag_id)
end
end
private
def js_function_call
begin
yield if block_given?

@ -3,7 +3,7 @@ class Training < ActiveRecord::Base
attr_accessible :address, :email, :name, :phone, :position, :school, :sex, :openid, :training_type,
:major, :student_id
# training_type 1 2018-培训会 2 警察学院大数据培训会
# training_type 1 2018-培训会 2 警察学院大数据培训会 3 大数据和人工智能 4 工程教育认证
has_one :training_payinfo
@ -21,4 +21,8 @@ class Training < ActiveRecord::Base
pay? && training_payinfo.payed?
end
def research_field_include?(str)
research_field.present? && research_field.split(',').include?(str)
end
end

@ -1119,7 +1119,7 @@ class User < Principal
end
def member_of_course?(course)
courses.to_a.include?(course)
courses.to_a.include?(course) || User.current.business?
end
def member_of_contest?(contest)
@ -1323,7 +1323,7 @@ class User < Principal
if Project === context
return false unless context.allows_to?(action)
# Admin users are authorized for anything else
return true if admin?
return true if admin? || business?
# 课程:作品关联项目的老师也可以访问私有项目
course_ids = context.student_work_projects.blank? ? "(-1)" : "(" + context.student_work_projects.map{|swp| swp.course_id}.join(",") + ")"

@ -25,13 +25,12 @@ class StatisticSchoolDailyReportTask
.where(homework_type: 4, created_at: yesterday).count
# 新增实训评测数量
shixun_evaluate_count = Output.joins(game: :challenge)
.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = challenges.shixun_id')
shixun_evaluate_count = EvaluateRecord.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = evaluate_records.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN members ON members.user_id = games.user_id')
.joins('LEFT JOIN members ON members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON members.course_id = courses.id AND hc.course_id = courses.id')
.where(courses: { school_id: school.id })
.where(created_at: yesterday).count
.where(created_at: yesterday).reorder(nil).count
# 无有效数据时不记录
data = [teacher_count, student_count, course_count, shixun_count, active_user_count,

@ -1,3 +1,6 @@
<div class="edu-con-top clearfix xmt10 bor-grey-e mt10">
<a href="<%= subject_level_system_managements_path(:format => "xls") %>" class="fr task-btn task-btn-orange ml5" >导出excel</a>
</div>
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0">
<thead>
<th width="10%">等级</th>

@ -1,4 +1,5 @@
<div>
<% if false %>
<div>
<p class="collegeInfo">湖南警察学院大数据培训缴费</p>
<%= form_for @training do |f| %>
<p class="subtitle">基本信息</p>
@ -11,7 +12,7 @@
<span class="left_tag fl">性别</span>
<label class="fr" id="sexl" style="margin-right: 24px;"><%= @training.sex == 1 ? '男' : '女' %></label>
<i class="iconfont icon-youjiantou rightArrow"></i>
<input type="hidden" id="sex" name="sex" value="<%= @training.sex ==1 ?1 : 2 %>">
<input type="hidden" id="sex" name="sex" value="<%= @training.sex == 1 ? 1 : 2 %>">
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">专业</span>
@ -63,6 +64,191 @@
<p style="height: 50px;"></p>
<a href="javascript:void(0)" class="EnrollNext" onclick="NextStep();">下一步</a>
<% end %>
</div>
<div class="sexDownNav downNav">
<li>男</li>
<li>女</li>
</div>
<script>
$(function () {
var down = $('#userSex');
var downNav = $(".sexDownNav");
showNav(down, downNav, "down");
$(".sexDownNav li").on("click", function () {
$(down).find("#sexl").html($(this).html());
hideNav(downNav);
if ($(this).html() == '男') {
$('#sex').val("1");
} else {
$('#sex').val("2");
}
})
})
//下一步
function NextStep() {
var username = $("#username").val();
var userMajor = $("#userMajor").val();
var userphone = $("#userphone").val();
var userID = $("#userID").val();
if (username == '') {
alert("请输入真实姓名");
return;
}
if (userMajor == '') {
alert("请输入专业");
return;
}
if (userID == '') {
alert("请输入学号");
return;
}
if (userphone == '') {
alert("请输入手机号码");
return;
} else if (!/^1\d{10}$/.test(userphone) && !/^[a-zA-Z0-9]+([.\-_\\]*[a-zA-Z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$/.test(userphone)) {
alert("请输入正确的手机号码");
return;
}
$('form').submit();
}
</script>
<% end %>
<div>
<p class="collegeInfo"><%= @training_title %></p>
<%= form_for @training do |f| %>
<%= hidden_field_tag(:tag_id, @tag_id) %>
<p class="subtitle">基本信息</p>
<li class="clearfix infoBar">
<span class="left_tag fl">姓名</span>
<input type="text" class="right_input" id="username" name="name"
placeholder="请输入真实姓名" value="<%= @training.name %>"/>
</li>
<li class="clearfix infoBar" id="userSex" NavShow>
<span class="left_tag fl">性别</span>
<label class="fr" id="sexl" style="margin-right: 24px;"><%= @training.sex == 1 ? '男' : '女' %></label>
<i class="iconfont icon-youjiantou rightArrow"></i>
<input type="hidden" id="sex" name="sex" value="<%= @training.sex == 1 ? 1 : 2 %>">
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">单位</span>
<input type="text" class="right_input" id="userUnit" placeholder="请输入单位名称或者学校"
name="school"
value="<%= @training.school %>"/>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">职称</span>
<input type="text" class="right_input" id="userPositional" placeholder="请输入职称"
name="position"
value="<%= @training.position %>"/>
</li>
<% if @training_type == 3 %>
<p class="subtitle">培训类型</p>
<li class="clearfix infoBar">
<span class="left_tag fl">大数据方向</span>
<span class="fr">
<%= radio_button_tag(:training_category, '大数据方向', @training.training_category == '大数据方向', id: 'type_1', class: 'magic-radio') %>
<label for="type_1" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">人工智能方向</span>
<span class="fr">
<%= radio_button_tag(:training_category, '人工智能方向', @training.training_category == '人工智能方向', id: 'type_2', class: 'magic-radio') %>
<label for="type_2" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">大数据+人工智能方向</span>
<span class="fr">
<%= radio_button_tag(:training_category, '大数据+人工智能方向', @training.training_category == '大数据+人工智能方向', id: 'type_3', class: 'magic-radio') %>
<label for="type_3" style="top:8px">&nbsp;</label>
</span>
</li>
<p class="subtitle">您的授课/研究领域最少选1项</p>
<li class="clearfix infoBar">
<span class="left_tag fl">机器学习/深度学习</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="机器学习/深度学习" <%= @training.research_field_include?("机器学习/深度学习") ? "checked" : "" %> id="check_1" class="magic-checkbox">
<label for="check_1" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机结构与组成</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机结构与组成" <%= @training.research_field_include?("计算机结构与组成") ? "checked" : "" %> id="check_2" class="magic-checkbox">
<label for="check_2" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机系统</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机系统" <%= @training.research_field_include?("计算机系统") ? "checked" : "" %> id="check_3" class="magic-checkbox">
<label for="check_3" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机软件技术和应用</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机软件技术和应用" <%= @training.research_field_include?("计算机软件技术和应用") ? "checked" : "" %> id="check_4" class="magic-checkbox">
<label for="check_4" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机理论</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机理论" <%= @training.research_field_include?("计算机理论") ? "checked" : "" %> id="check_5" class="magic-checkbox">
<label for="check_5" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">计算机应用与学科交叉</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="计算机应用与学科交叉" <%= @training.research_field_include?("计算机应用与学科交叉") ? "checked" : "" %> id="check_6" class="magic-checkbox">
<label for="check_6" style="top:8px">&nbsp;</label>
</span>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">其他</span>
<span class="fr">
<input type="checkbox" name="research_field[]" value="其他" <%= @training.research_field_include?("其他") ? "checked" : "" %> id="check_7" class="magic-checkbox">
<label for="check_7" style="top:8px">&nbsp;</label>
</span>
</li>
<% end %>
<p class="subtitle">通讯地址</p>
<li class="clearfix infoBar">
<!--<div class="clearfix" id="userArea" NavShow>-->
<!--<span class="left_tag fl">地区</span>-->
<!--<input type="text" class="right_input" id="usertitle" placeholder="填写区域"/>-->
<!--<i class="iconfont icon-youjiantou rightArrow"></i>-->
<!--</div>-->
<textarea class="DetailAddress" placeholder="请输入详细地址" name="address" id="DetailAdd" style="margin-top: 15px;"><%= @training.address %></textarea>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">手机号码</span>
<input type="text" class="right_input" placeholder="请输入手机号" id="userphone"
name="phone"
value="<%= @training.phone %>"/>
</li>
<li class="clearfix infoBar">
<span class="left_tag fl">Email</span>
<input type="text" class="right_input" placeholder="请输入Email" id="userEmail" name="email" value="<%= @training.email %>"/>
</li>
<p style="height: 50px;"></p>
<a href="javascript:void(0)" class="EnrollNext" onclick="NextStep();">完成</a>
<% end %>
</div>
<div class="sexDownNav downNav">
@ -79,7 +265,7 @@
$(down).find("#sexl").html($(this).html());
hideNav(downNav);
if ($(this).html()=='男'){
if ($(this).html() == '男') {
$('#sex').val("1");
} else {
$('#sex').val("2");
@ -108,6 +294,19 @@
return;
}
<% if @training_type == 3 %>
var trainingCategory = $('input[type="radio"][name="training_category"]:checked').val();
if (trainingCategory == undefined || trainingCategory == '') {
alert('请选择培训类型');
return;
}
if ($("input[type='checkbox'][name='research_field[]']:checked").length == 0) {
alert('请选择授课类型/研究领域');
return;
}
<% end %>
if (userphone == '') {
alert("请输入手机号码");
return;

@ -15,22 +15,22 @@
<div class="flex1 accountRight">
<li class="df">
<label class="fl">账&nbsp;&nbsp;&nbsp;号:</label>
<p class="fl flex1 break-word">800190320609016</p>
<p class="fl flex1 break-word">1901008009200085901</p>
</li>
<li class="df">
<label class="fl">户&nbsp;&nbsp;&nbsp;名:</label>
<p class="fl flex1">湖南酷得网络科技有限公司</p>
<p class="fl flex1">长沙智擎信息技术有限公司</p>
</li>
<li class="df">
<label class="fl">开户行:</label>
<p class="fl flex1">长沙银行股份有限公司四方支行</p>
<p class="fl flex1">工商银行长沙市岳麓山支行</p>
</li>
</div>
</div>
<p class="payTip">完成线下支付后,请将支付截图粘贴到备注中,以便财务审核</p>
</div>
</div>
<!--发票<div class="infoBar mb10">
<div class="infoBar mb10">
<p class="clearfix" id="billLine" NavShow>
<span class="grey fl">发票</span>
<label class="fr" id="billDemand" status=2 style="margin-right: 24px;">不需要</label>
@ -41,7 +41,7 @@
<input type="text" name="invoice_content" class="right_input"
value="<%#= @training.training_payinfo.invoice_content.presence || '会议注册费' %>"/>
</p>
</div>-->
</div>
<div class="infoBar mb10">
<p>备注</p>
<textarea class="remarkAccount" name="info" id="info"><%= @training.training_payinfo.info %></textarea>
@ -137,20 +137,20 @@
// invoiceNo: '<%#= @training.training_payinfo.invoice_no %>'
// };
//点击弹出发票弹框
//aboutBillType(userInfo);
aboutBillType(userInfo);
//点击弹出支付方式弹框
aboutPayType();
//初始化发票类型
/*InitBill(userInfo);*/
InitBill(userInfo);
//切换发票类型
/*$(".billType li").on("click", function () {
$(".billType li").on("click", function () {
$(".billType li").removeClass("active");
$(this).addClass("active");
billTypeShowFun(parseInt($(this).index()),userInfo);
})*/
})
//关闭弹窗
$(".billClose").on("click", function () {
hideNav($(".downNav"));
@ -257,7 +257,7 @@
})
})
//页面加载时,初始化发票类型
/*function InitBill(userInfo){
function InitBill(userInfo){
var index=2;
$("#billDemand").html("不需要").attr("status",2);
if(userInfo.invoiceTitle != "" && userInfo.invoiceNo != ""){
@ -271,7 +271,7 @@
$(".billType li").removeClass("active");
$(".billType li").eq(index).addClass("active");
billTypeShowFun(index,userInfo);
}*/
}
function billTypeShowFun(index,userInfo){
if (parseInt(index) == 0) {
$(".needWrite").removeClass("none");
@ -288,11 +288,11 @@
}
//点击弹出发票类型弹框
/*function aboutBillType(userInfo){
function aboutBillType(userInfo){
var bill = $("#billLine");
var billNav = $(".billDownNav");
showNav(bill, billNav, "down");
}*/
}
//点击弹出支付方式弹框
function aboutPayType() {

@ -46,7 +46,7 @@
<%#= render :partial => "users/course_item", :locals => {:objects => @objects} %>
<% @objects.each do |object| %>
<% allow_visit = @show_all || object.is_public == 1 || User.current.member_of_course?(object) %>
<% allow_visit = @show_all || object.is_public == 1 || User.current.member_of_course?(object) || User.current.business? %>
<div class="square-Item" onclick="open_course(<%= object.id %>, <%= allow_visit %>)" style="cursor: pointer;">
<% if object.is_public == 1 %>
<div class="publicpart <%= object.id == 1309 ? 'orangeBlack' : '' %>"></div>

@ -0,0 +1,5 @@
class AddReseachFieldToTrainings < ActiveRecord::Migration
def change
add_column :trainings, :research_field, :string
end
end

@ -0,0 +1,8 @@
class ModifyInputForTestSets < ActiveRecord::Migration
def up
change_column :test_sets, :input, :text
end
def down
end
end

@ -0,0 +1,5 @@
class AddTrainingCategoryToTrainings < ActiveRecord::Migration
def change
add_column :trainings, :training_category, :string
end
end

@ -70,55 +70,106 @@ namespace :school_daily_report do
end
end
desc 'statistic old shixun homework count and shixun evaluate count'
task :statistic_shixun_info_count, [:date] => :environment do |_, args|
# 统计学校历史每天实训作业新增数
desc 'statistic school shixun homework count everyday'
task :statistic_shixun_homework_count, [:date] => :environment do |_, args|
date = Time.zone.parse(args[:date]).beginning_of_day
current_date = (Time.zone.now - 5.hour).beginning_of_day
custom_logger("statistic range: #{date}..#{current_date}")
while current_date > date
date_str = date.strftime('%Y-%m-%d')
# 检查当天数据是否已经统计
school_count = School.count
query_times = school_count % query_size == 0 ? school_count / query_size : (school_count / query_size) + 1
custom_logger("Start statistic => Date: #{date_str} ~")
custom_logger("Start statistic => Date: #{date_str}, school count: #{school_count}, insert times: #{query_times} ~")
query_times.times do |index|
sql = school_daily_report_sql(date, query_size, index * query_size)
reports = School.find_by_sql(sql)
begin_date = (date + 5.hour).strftime('%Y-%m-%d %H:%M:%S')
end_date = (date + 1.day + 5.hour).strftime('%Y-%m-%d %H:%M:%S')
if SchoolDailyReport.exists?(date: date)
data = []
reports.each do |report|
next if %w(teacher_count student_count course_count shixun_count shixun_homework_count shixun_evaluate_count active_user_count).all? { |key| report[key].zero? }
homework_count_map = HomeworkCommon.joins('LEFT JOIN courses cs ON homework_commons.course_id = cs.id')
.where('cs.school_id IS NOT NULL')
.where(homework_type: 4, created_at: begin_date...end_date).reorder(nil)
.group('cs.school_id').count
record = SchoolDailyReport.where(school_id: report['id'], date: date_str).first
ActiveRecord::Base.transaction do
exist_school_ids = SchoolDailyReport.where(date: date_str).pluck(:school_id)
if record.present?
record.update_attributes(shixun_homework_count: report['shixun_homework_count'], shixun_evaluate_count: report['shixun_evaluate_count'])
updated_school_ids = homework_count_map.keys & exist_school_ids # 需要更新的
updated_reports = []
created_reports = []
homework_count_map.each do |school_id, homework_count|
if updated_school_ids.include?(school_id)
updated_reports << "WHEN #{school_id} THEN #{homework_count}"
else
data << [
report['id'], report['name'], report['teacher_count'], report['student_count'], report['course_count'],
report['shixun_count'], report['shixun_homework_count'], report['shixun_evaluate_count'],
report['active_user_count'], date_str, current_datetime, current_datetime
]
created_reports << "(#{school_id}, '#{date_str}', #{homework_count})"
end
end
if updated_reports.present?
# 这样更新快些
SchoolDailyReport.connection.execute("UPDATE school_daily_reports SET shixun_homework_count = CASE school_id #{updated_reports.join(' ')} END "\
"WHERE school_id IN (#{updated_school_ids.join(',')}) AND date = '#{date_str}'")
end
if created_reports.present?
SchoolDailyReport.connection.execute("INSERT INTO school_daily_reports(school_id, date, shixun_homework_count) VALUES#{created_reports.join(',')}")
end
end
custom_logger("Statistic complete! date: #{date_str}")
date += 1.day
end
end
# 统计学校历史每天实训评测新增数
desc 'statistic school shixun evaluate count everyday'
task :statistic_shixun_evaluate_count, [:date] => :environment do |_, args|
date = Time.zone.parse(args[:date]).beginning_of_day
current_date = (Time.zone.now - 5.hour).beginning_of_day
custom_logger("statistic range: #{date}..#{current_date}")
while current_date > date
date_str = date.strftime('%Y-%m-%d')
custom_logger("Start statistic => Date: #{date_str} ~")
begin_date = (date + 5.hour).strftime('%Y-%m-%d %H:%M:%S')
end_date = (date + 1.day + 5.hour).strftime('%Y-%m-%d %H:%M:%S')
evaluate_count_map = EvaluateRecord.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = evaluate_records.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN members ON members.user_id = evaluate_records.user_id')
.joins('LEFT JOIN courses ON members.course_id = courses.id AND hc.course_id = courses.id')
.where(created_at: begin_date...end_date).where('courses.school_id IS NOT NULL')
.reorder(nil).group('courses.school_id').count
ActiveRecord::Base.transaction do
exist_school_ids = SchoolDailyReport.where(date: date_str).pluck(:school_id)
updated_school_ids = evaluate_count_map.keys & exist_school_ids # 需要更新的
updated_reports = []
created_reports = []
evaluate_count_map.each do |school_id, evaluate_count|
if updated_school_ids.include?(school_id)
updated_reports << "WHEN #{school_id} THEN #{evaluate_count}"
else
data = reports.map do |report|
# 无效数据不记录
next if %w(teacher_count student_count course_count shixun_count shixun_homework_count shixun_evaluate_count active_user_count).all? { |key| report[key].zero? }
created_reports << "(#{school_id}, '#{date_str}', #{evaluate_count})"
end
end
[
report['id'], report['name'], report['teacher_count'], report['student_count'], report['course_count'],
report['shixun_count'], report['shixun_homework_count'], report['shixun_evaluate_count'],
report['active_user_count'], date_str, current_datetime, current_datetime
]
end.compact
batch_create_school_daily_reports!(data) if data.present?
if updated_reports.present?
# 这样更新快些
SchoolDailyReport.connection.execute("UPDATE school_daily_reports SET shixun_evaluate_count = CASE school_id #{updated_reports.join(' ')} END "\
"WHERE school_id IN (#{updated_school_ids.join(',')}) AND date = '#{date_str}'")
end
if created_reports.present?
SchoolDailyReport.connection.execute("INSERT INTO school_daily_reports(school_id, date, shixun_evaluate_count) VALUES#{created_reports.join(',')}")
end
end
custom_logger("Statistic complete! date: #{date_str}")
date += 1.day
@ -181,14 +232,12 @@ namespace :school_daily_report do
LEFT JOIN courses cs ON hc.course_id = cs.id
WHERE cs.school_id = schools.id AND hc.homework_type = 4 AND hc.created_at BETWEEN "#{begin_date}" AND "#{end_date}"
) shixun_homework_count, (
SELECT COUNT(*) FROM outputs os
LEFT JOIN games gs ON os.game_id = gs.id
LEFT JOIN members ON members.user_id = gs.user_id
LEFT JOIN challenges cls ON gs.challenge_id = cls.id
LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = cls.shixun_id
SELECT COUNT(*) FROM evaluate_records er
LEFT JOIN members ON members.user_id = er.user_id
LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = er.shixun_id
LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id
LEFT JOIN courses ON hc.course_id = courses.id AND members.course_id = courses.id
WHERE courses.school_id = schools.id AND os.created_at BETWEEN "#{begin_date}" AND "#{end_date}"
WHERE courses.school_id = schools.id AND er.created_at BETWEEN "#{begin_date}" AND "#{end_date}"
) shixun_evaluate_count, (
SELECT COUNT(*) FROM users u
LEFT JOIN user_extensions ue ON ue.user_id = u.id

File diff suppressed because one or more lines are too long

@ -120,8 +120,15 @@ input::-ms-input-placeholder,textarea::-ms-input-placeholder {color:#cccccc;}
span.left_tag{font-weight:bold; }
input[type='text'].right_input{
float: right;border: none;text-align: right;height: 44px;line-height: 44px;outline: none;
font-size: 1.4rem;width: 70%;margin-right: 24px;
font-size: 1.4rem;width: 70%;/*margin-right: 24px;*/
}
.PositionalRight .magic-radio + label:before,.PositionalRight .magic-checkbox + label:before{
top:13px!important;
}
.PositionalRight .magic-radio + label:after{
top: 18px!important;
}
.mr15{margin-right: 15px;}
.infoBar label.right_tag{
float: right;color: #cccccc;font-size: 1.4rem;margin-right: 24px;
}

Loading…
Cancel
Save