Merge branch 'dev_trainings' of https://bdgit.educoder.net/Hjqreturn/pgfqe6ch8 into dev_trainings

dev_trainings
caishi 6 years ago
commit 0d5d7f63c2

@ -63,8 +63,8 @@ gem 'elasticsearch-rails'
gem 'oauth2'
# xlsx
#gem 'axlsx', '3.0.0.pre'
#gem 'axlsx_rails', '0.3.0'
gem 'axlsx', '3.0.0.pre'
gem 'axlsx_rails', '0.3.0'
#Ruby 2.2+ has removed test/unit from the core library.
if RUBY_VERSION>='2.2'

@ -34,9 +34,9 @@ module Mobile
version 'v1', using: :path
format :json
content_type :json, "application/json;charset=UTF-8"
# use ActionDispatch::Session::CookieStore
#use ActionDispatch::Session::CookieStore, :expire_after => 8.hours, :key => '_educoder_session', :domain => :all
require 'digest'
use Mobile::Middleware::ErrorHandler
helpers do
@ -53,6 +53,27 @@ module Mobile
error!('401 Unauthorized', 401) if params[:private_token] != "hriEn3UwXfJs3PmyXnSG"
end
def cnmooc_access_key!
## 签名
accessKeyId = 'LTAISM4HFWpQHh3g'.freeze
accessKeySecret = '9NMU8ushmFu8SN1EKHOhvo9jmv1qp0'.freeze
str = []
params.each do |key, value|
if key != "sign"
str << "#{key}=#{value}"
end
end
sign_str = "#{str.join("&")}&sk=#{accessKeySecret}"
Rails.logger.info("#####sign_str: #{sign_str}")
sign = Digest::MD5.hexdigest("#{sign_str}").upcase
Rails.logger.info("#####sign: #{sign}")
Rails.logger.info("#####params[:sign]: #{params[:sign]}")
if params[:sign] != sign
error!('401 Unauthorized', 401)
end
end
# 有一些接口没登录也能查看数据
def career_authenticate!
pass = request.path.include?("introduction") || request.path.include?("get_published_careers")|| request.path.include?("get_current_user")
@ -62,6 +83,9 @@ module Mobile
end
def memo_authenticate!
Rails.logger.info("#######current_user: ###{current_user}")
Rails.logger.info("#######session: ###{session[:user_id]}")
pass = (request.path.match(/memos\/\d+/).present? && !request.path.include?("reply")) ||
request.path.include?("get_memos_list") ||
request.path.include?("memos?page=") || request.path.match(/memos$/).present?
@ -73,6 +97,8 @@ module Mobile
end
def discusses_authenticate!
Rails.logger.info("#######current_user: ###{current_user}")
Rails.logger.info("#######session: ###{session[:user_id]}")
pass = request.path.match(/discusses$/).present? || request.path.include?("discusses?page=")
unless pass
error!('401 Unauthorized', 401) unless current_user
@ -99,6 +125,13 @@ module Mobile
return uw.user if uw
end
# third_party_user_id = session[:third_party_user_id]
# Rails.logger.info("#########third_party_user_id: #{third_party_user_id}")
# if third_party_user_id
# c_user = UserSource.find_by_id(session[:third_party_user_id])
# return c_user.user if c_user
# end
token = ApiKey.where(access_token: params[:token]).first
if token && !token.expired?
return User.find(token.user_id)
@ -106,7 +139,9 @@ module Mobile
#
Rails.logger.info("########### host is #{request.host}")
if (Rails.env.development? && session[:user_id].blank?) || (session[:user_id].blank? && request.host.include?("testbdweb")) || params[:action] == "privateGit"
if (Rails.env.development? && session[:user_id].blank?) ||
(session[:user_id].blank? && request.host.include?("testbdweb")) ||
params[:action] == "privateGit"
session[:user_id] = 12 #116
end
@ -160,6 +195,7 @@ module Mobile
mount Apis::Careers
mount Apis::Assets
mount Apis::Ecloud
mount Apis::Cnmooc

@ -0,0 +1,84 @@
# encoding=utf-8
# 好大学接口数据
module Mobile
module Apis
class Cnmooc < Grape::API
# before {cnmooc_access_key!}
content_type :json, 'application/json;charset=UTF-8'
resources :cnmoocs do
desc '获取实训数据'
get "get_resources_data" do
CnmoocsService.new.get_resources_data params
end
desc "实训搜索功能"
params do
requires :name, type: String, desc: "搜索名称"
end
get 'search_resources' do
CnmoocsService.new.search_resources params
end
desc " 查找用户"
params do
requires :userName, type: String, desc: "好大学用户名"
end
get 'find_user' do
CnmoocsService.new.find_user params
end
desc "创建用户"
params do
requires :userName, type: String, desc: "好大学用户名"
end
post "create_user" do
CnmoocsService.new.create_user params
end
desc "获取资源访问地址"
params do
requires :userId, type: Integer, desc: "用户ID"
requires :resourceId, type: String, desc: "资源唯一标示"
requires :accessType, type: Integer, desc: "资源类型"
end
get "source_url" do
user = User.find_by_id(params[:userId])
return {error: -1, messages: "用户不存在,请先创建用户"} unless user
token = Token.get_or_create_permanent_login_token(user)
cookie_options = {
:value => token.value,
:expires => 1.month.from_now,
:path => (Redmine::Configuration['autologin_cookie_path'] || '/'),
:secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
:httponly => true
}
if Redmine::Configuration['cookie_domain'].present?
cookie_options = cookie_options.merge(domain: Redmine::Configuration['cookie_domain'])
end
cookies[Redmine::Configuration['autologin_cookie_name'].presence || 'autologin'] = cookie_options
CnmoocsService.new.source_url(params, token)
end
desc "远程登录"
params do
requires :mail, type: String, desc: "邮箱地址"
requires :password, type: String, desc: "密码"
end
get "login_educoder" do
CnmoocsService.new.login_educoder params
end
desc "资源学习情况查询"
params do
requires :userId, type: Integer, desc: "用户ID"
requires :resourceId, type: String, desc: "资源唯一标示"
end
get 'get_students_data' do
CnmoocsService.new.get_students_data params
end
end
end
end
end

@ -456,7 +456,9 @@ class AccountController < ApplicationController
@pref = @user.pref
@se = @user.extensions
# 已授权的用户修改单位名称,需要重新授权
old_identity = @se.identity
# 已授权的用户修改单位名称,需要重新授权
if @se.school_id != params[:occupation].to_i && @user.certification == 1
@user.certification = 0
apply_user = ApplyAction.where(:user_id => @user.id, :container_type => "TrialAuthorization")
@ -510,10 +512,15 @@ class AccountController < ApplicationController
@se.technical_title = params[:pro_technical_title] if params[:pro_technical_title]
@se.student_id = nil
end
# @se.brief_introduction = params[:brief_introduction]
if @user.save && @se.save
if old_identity.nil? && @se.identity == 0
Trustie::Sms.send(mobile: '17680641960', send_type:'teacher_register', name: @user.login, user_name: "管理员")
end
reward_grade(@user, @user.id, 'Account', 500)
if @user.certification != 1

@ -66,6 +66,8 @@ class ApplicationController < ActionController::Base
include Redmine::MenuManager::MenuController
helper Redmine::MenuManager::MenuHelper
helper_method :admin_or_business?
# 云启训练场EduCoder个人版 产品编码appId 9200108
# 产品名称 计费类型 套餐编码
# 云启训练场EduCoder个人版 固定包月 9200108001
@ -133,7 +135,7 @@ class ApplicationController < ActionController::Base
end
def ec_public_auth major_school
unless User.current.admin? || major_school.template_major || major_school.school.users.where(:id => User.current.id).count > 0 ||
unless admin_or_business? || major_school.template_major || major_school.school.users.where(:id => User.current.id).count > 0 ||
major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0 ||
EcCourseUser.where(:user_id => User.current.id, :ec_course_id => EcCourse.where(:ec_year_id => major_school.ec_years.pluck(:id)).pluck(:id)).count > 0
render_403
@ -193,6 +195,21 @@ class ApplicationController < ActionController::Base
find_current_user
end
def set_autologin_cookie(user)
token = Token.get_or_create_permanent_login_token(user)
cookie_options = {
:value => token.value,
:expires => 1.month.from_now,
:path => (Redmine::Configuration['autologin_cookie_path'] || '/'),
:secure => (Redmine::Configuration['autologin_cookie_secure'] ? true : false),
:httponly => true
}
if Redmine::Configuration['cookie_domain'].present?
cookie_options = cookie_options.merge(domain: Redmine::Configuration['cookie_domain'])
end
cookies[autologin_cookie_name] = cookie_options
end
def find_current_user
user = nil
unless api_request?
@ -207,6 +224,11 @@ class ApplicationController < ActionController::Base
elsif session[:wechat_openid]
uw = UserWechat.find_by_openid(session[:wechat_openid])
user = uw.user if uw
elsif params[:authToken]
user = Token.find_by_value(params[:authToken]).user
#set_autologin_cookie(user)
#start_user_session(user)
session[:user_id] = user.id
end
end
if user.nil? && Setting.rest_api_enabled? && accept_api_auth?
@ -332,6 +354,8 @@ class ApplicationController < ActionController::Base
end
def require_login
logger.info("#########login?: #{User.current.logged?}")
logger.info("#########get?: #{request.get?}")
if !User.current.logged?
# Extract only the basic url parameters on non-GET requests
if request.get?
@ -368,6 +392,10 @@ class ApplicationController < ActionController::Base
end
end
def admin_or_business?
User.current.business? || User.current.admin?
end
def deny_access
User.current.logged? ? render_403 : require_login
end

@ -27,6 +27,6 @@ class CareersController < ApplicationController
private
def render_react
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
end

@ -32,6 +32,6 @@ class CategoriesController < ApplicationController
private
def render_react
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
end

@ -16,6 +16,7 @@ class ChallengesController < ApplicationController
#before_filter :find_shixun_language, :only => [:show, :new, :edit]
before_filter :base_index, :only => [:index, :index_down, :index_up, :destroy]
before_filter :view_allow, :only => [:show]
# before_filter :check_cnmooc, :only => [:index]
include ApplicationHelper
@ -487,4 +488,12 @@ class ChallengesController < ApplicationController
response.headers['content--type'] = 'text/javascript'
request.format = 'js'
end
# def check_cnmooc
# if params[:authToken]
# user = User.find_by_id(session[:user_id])
# set_autologin_cookie(user)
# end
# end
end

@ -50,7 +50,7 @@ class CollegesController < ApplicationController
# Redo这样做内存会卡死的
# user_ids = User.find_by_sql("SELECT users.id FROM users LEFT JOIN user_extensions ON users.id=user_extensions.user_id WHERE user_extensions.`school_id` = #{@school.id}").map(&:id)
# Redo是否直接使用count会更好
all_course_ids = Course.joins("join users u on courses.tea_id = u.id").joins("join user_extensions ue on u.id = ue.user_id").where("courses.id != 1309 and ue.school_id = #{@school.id}")
all_course_ids = Course.where("id != 1309 and is_delete = 0 and school_id = #{@school.id}")
@courses_count = all_course_ids.size
# Redo对于量比较大的尽量不使用笛卡尔积
@ -131,7 +131,7 @@ class CollegesController < ApplicationController
(select count(m.id) from messages m inner join boards b on b.id=m.board_id and b.parent_id=0 where b.course_id=c.id group by c.id) as messages_count,
c.tea_id, c.name, c.is_end,
(SELECT MAX(created_at) FROM `course_activities` ca WHERE ca.course_id = c.id) AS update_time
FROM `courses` c WHERE (c.school_id = #{@school.id} and c.is_delete = 0)")
FROM `courses` c WHERE c.school_id = #{@school.id} and c.is_delete = 0")
@courses.each do |course|
course[:evaluating_count] = Output.find_by_sql("select sum(g.evaluate_count) as evaluating_count from games g inner join

@ -577,7 +577,7 @@ class CoursesController < ApplicationController
cha_member.member_roles.where("role_id = 10").first.destroy
StudentsForCourse.where(:course_id => @course.id, :student_id => cha_member.user_id).destroy_all
end
@course.update_attributes(:tea_id => cha_member.user_id)
@course.update_attributes(:tea_id => cha_member.user_id, :school_id => cha_member.user.try(:user_extensions).try(:school_id))
man_member.member_roles.first.update_attributes(:role_id => 9)
course_act = CourseActivity.where(:course_id => @course.id, :course_act_id => @course.id, :course_act_type => 'Course').first
course_act.update_column('user_id', cha_member.user_id)

@ -309,7 +309,7 @@ class EcCourseAchievementMethodsController < ApplicationController
@ec_course = EcCourse.find(params[:ec_course_id])
@year = @ec_course.ec_year
@ec_major_school = @year.ec_major_school
@template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@template_major = admin_or_business? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
@is_manager = @template_major || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end

@ -298,7 +298,7 @@ class EcCourseEvaluationsController < ApplicationController
def find_course
@ec_course = EcCourse.find params[:ec_course_id]
ec_major_school = @ec_course.ec_year.ec_major_school
@is_manager = User.current.admin? || ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@is_manager = admin_or_business? || ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id) || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end
@ -306,7 +306,7 @@ class EcCourseEvaluationsController < ApplicationController
@ce = EcCourseEvaluation.find params[:id]
@ec_course = @ce.ec_course
ec_major_school = @ec_course.ec_year.ec_major_school
@is_manager = User.current.admin? || ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@is_manager = admin_or_business? || ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id) || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end
end

@ -50,7 +50,7 @@ class EcCourseSupportsController < ApplicationController
max_support_count = 0
subitems_count = 0
major_school = @year.ec_major_school
is_manager = User.current.admin? || major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
is_manager = admin_or_business? || major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
ec_graduation_requirements.each_with_index do |gr, i|
logger.info("#############index:#{i}#####_ec_gradiation_reqiorements: #{gr.id}")
subitems_count += gr.ec_graduation_subitems.count

@ -88,7 +88,7 @@ class EcCoursesController < ApplicationController
def ec_course_support_setting
respond_to do |format|
format.html {
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
}
format.json {
course_targets = @ec_course.ec_course_targets.includes(:ec_graduation_subitems)
@ -152,19 +152,19 @@ class EcCoursesController < ApplicationController
# 课程体系(课程考核与数据来源)
# /ec_courses/1/ec_course_reach_setting
def ec_course_reach_setting
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
# 课程体系(课程目标评价方法)
# /ec_courses/1/evaluation_methods
def evaluation_methods
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
# 课程达成详情蓝胡12
# GET /ec_courses/1/competition_calculation_info
def competition_calculation_info
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
# 评价详情的导出
@ -346,7 +346,7 @@ class EcCoursesController < ApplicationController
# 关联课堂弹框-搜索
def search_courses
user = User.where(:id => params[:user_id]).first
if user.try(:admin?)
if user.try(:admin?) || user.try(:business?)
courses = Course.where(:is_delete => 0)
else
course_ids = Member.where("user_id = #{user.try(:id)} and course_id != -1").pluck(:course_id)
@ -425,7 +425,7 @@ class EcCoursesController < ApplicationController
format.html{
Rails.logger.info("1111111111111111111template_major: #{@template_major}")
Rails.logger.info("1111111111111111111is_manager: #{@is_manager}")
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
}
format.json{
levels = @ec_course.ec_score_levels
@ -588,7 +588,7 @@ class EcCoursesController < ApplicationController
@ec_course = EcCourse.find(params[:id])
@year = @ec_course.ec_year
@ec_major_school = @year.ec_major_school
@template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@template_major = admin_or_business? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
@is_manager = @template_major || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end
@ -596,7 +596,7 @@ class EcCoursesController < ApplicationController
def find_year
@year = EcYear.find(params[:ec_year_id])
@ec_major_school = @year.ec_major_school
@template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@template_major = admin_or_business? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) ||
@ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
#@is_manager = @template_major || @ec_course.ec_course_users.pluck(:user_id).include?(User.current.id)
end

@ -34,7 +34,7 @@ class EcGraduationRequirementsController < ApplicationController
ActiveRecord::Base.transaction do
@year = EcYear.find params[:year_id]
position = @year.ec_graduation_requirements ? @year.ec_graduation_requirements.count + 1 : 1
@template_major = User.current.admin? || @year.ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id)
@template_major = admin_or_business? || @year.ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id)
ec_requirement_id = EcGraduationRequirement.create(content: params[:requirement], :ec_year_id => @year.id, :position => position)
params[:subitems].try(:each_with_index) do |sub, index|
EcGraduationSubitem.create(content: sub, ec_graduation_requirement_id: ec_requirement_id.id, position: index+1)
@ -48,7 +48,7 @@ class EcGraduationRequirementsController < ApplicationController
def update
requirement = EcGraduationRequirement.find params[:id]
@year = requirement.ec_year
@template_major = User.current.admin? || @year.ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id)
@template_major = admin_or_business? || @year.ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id)
requirement.update_attribute(:content, params[:requirement])
requirement.ec_graduation_subitems.destroy_all
params[:subitems].try(:each_with_index) do |sub, index|

@ -13,7 +13,7 @@ class EcMajorSchoolsController < ApplicationController
# 这个status 用于创建界别时,局部刷新的状态
@status = params[:status]
@btn_text = @major_school.template_major && User.current.admin? ? "立即配置" :
@btn_text = @major_school.template_major && admin_or_business? ? "立即配置" :
(!@major_school.template_major && @major_manager ? "立即配置" : "查看")
if params[:search]
@ -84,7 +84,7 @@ class EcMajorSchoolsController < ApplicationController
user_url = user_path(User.current)
year = @year.year
# 学校操作权限
template_major = User.current.admin? || major.school.ec_school_users.pluck(:user_id).include?(User.current.id)
template_major = admin_or_business? || major.school.ec_school_users.pluck(:user_id).include?(User.current.id)
# 示例专业
example_major = major.template_major
ec_course_support_setting_url = ec_course_support_setting_ec_course_path(ec_course) if ec_course.present?
@ -122,7 +122,7 @@ class EcMajorSchoolsController < ApplicationController
requirement_vs_objective_url: "#{requirement_vs_objective_ec_major_school_ec_year_path(@year, :ec_major_school_id => @year.ec_major_school_id)}",
requirement_vs_standard: "#{requirement_vs_standard_ec_major_school_ec_year_path(@year, :ec_major_school_id => @year.ec_major_school_id)}",
requirement_vs_courses: "#{requirement_vs_courses_ec_major_school_ec_year_path(@year, :ec_major_school_id => @year.ec_major_school_id)}",
students_url: student_lists_ec_major_schools_ec_years_path(@year, ec_major_school_id: @year.ec_major_school_id),
students_url: student_lists_ec_major_school_ec_year_path(@year, ec_major_school_id: @year.ec_major_school_id),
go_back_url: ec_major_school_path(major),
ec_course_support_setting_url: ec_course_support_setting_url,
ec_course_reach_setting_url: ec_course_reach_setting_url,
@ -130,7 +130,7 @@ class EcMajorSchoolsController < ApplicationController
competition_calculation_info_url: competition_calculation_info_url,
score_level_setting_url: score_level_setting_url,
example_major: example_major,
allow_visit: User.current.admin? || (User.current.ec_school.present? && User.current.ec_school == major.school.id)
allow_visit: admin_or_business? || (User.current.ec_school.present? && User.current.ec_school == major.school.id)
}
end
@ -159,7 +159,7 @@ class EcMajorSchoolsController < ApplicationController
end
def add_manager
@is_school_manager = User.current.admin? || @major_school.school.users.where(:id => User.current.id).count > 0 # 学校管理员
@is_school_manager = admin_or_business? || @major_school.school.users.where(:id => User.current.id).count > 0 # 学校管理员
if @is_school_manager || @major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0
params[:user_id].each do |user_id|
if @major_school.ec_major_school_users.count < 5 && @major_school.ec_major_school_users.where(:user_id => user_id).count == 0
@ -172,7 +172,7 @@ class EcMajorSchoolsController < ApplicationController
end
def delete_manager
@is_school_manager = User.current.admin? || @major_school.school.users.where(:id => User.current.id).count > 0 # 学校管理员
@is_school_manager = admin_or_business? || @major_school.school.users.where(:id => User.current.id).count > 0 # 学校管理员
if @is_school_manager || @major_school.ec_major_school_users.where(:user_id => User.current.id).count > 0
@major_school.ec_major_school_users.where(:user_id => params[:user_id]).destroy_all
else
@ -184,7 +184,7 @@ class EcMajorSchoolsController < ApplicationController
def find_major_school
@major_school = EcMajorSchool.find(params[:id])
# 管理员权限
@major_manager = User.current.admin? || @major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || @major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
@major_manager = admin_or_business? || @major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || @major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
end
# 职业认证的权限判断

@ -25,7 +25,7 @@ class EcYearsController < ApplicationController
@status = 1
end
@major_manager = true
@btn_text = @major_school.template_major && User.current.admin? ? "立即配置" :
@btn_text = @major_school.template_major && admin_or_business? ? "立即配置" :
(!@major_school.template_major && @major_manager ? "立即配置" : "查看")
@years = EcYear.where(:ec_major_school_id => @major_school.id)
@years = paginateHelper @years, 10
@ -46,7 +46,7 @@ class EcYearsController < ApplicationController
def student_lists
respond_to do |format|
format.html {
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
}
end
end
@ -217,7 +217,7 @@ class EcYearsController < ApplicationController
# 本专业必要要求VS课程支撑体系
def requirement_vs_courses
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
# 导出课程支撑体系
@ -251,7 +251,7 @@ class EcYearsController < ApplicationController
# 课程达成点计算蓝胡13
# GET /ec_courses/1/competition_calculation_info
def reach_calculation_info
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
# 蓝胡13数据获取
@ -338,7 +338,7 @@ class EcYearsController < ApplicationController
@ec_major_school = EcMajorSchool.find(params[:ec_major_school_id])
@year = EcYear.find(params[:id])
# 专业管理员身份
@template_major = User.current.admin? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || @ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
@template_major = admin_or_business? || @ec_major_school.school.ec_school_users.pluck(:user_id).include?(User.current.id) || @ec_major_school.ec_major_school_users.pluck(:user_id).include?(User.current.id)
end
# 职业认证的权限判断

@ -7,7 +7,7 @@ class EcsController < ApplicationController
def department
@template_major = EcMajorSchool.where(:template_major => true).first
@school_managers = @school.users
@is_school_manager = User.current.admin? || @school.users.where(:id => User.current.id).count > 0 # 学校管理员
@is_school_manager = User.current.admin? || User.current.business? || @school.users.where(:id => User.current.id).count > 0 # 学校管理员
@major_schools = @school.ec_major_schools.where(:template_major => false)
unless @is_school_manager
@ -70,7 +70,7 @@ class EcsController < ApplicationController
end
def school_manager
unless User.current.admin? || @school.users.where(:id => User.current.id).count > 0
unless User.current.admin? || User.current.business? || @school.users.where(:id => User.current.id).count > 0
render_403
end
end

@ -104,6 +104,7 @@ class ExerciseBankController < ApplicationController
:question_type => params[:question_type] || 1,
:question_number => @exercise.exercise_bank_questions.count + 1,
:question_score => params[:question_score],
:shixun_name => params[:question_type] == '5' ? params[:shixun_name] : nil,
:shixun_id => params[:shixun],
:max_choices => params[:max_choices].to_i || 0,
:min_choices => params[:min_choices].to_i || 0
@ -271,6 +272,7 @@ class ExerciseBankController < ApplicationController
end
end
if @exercise_question.question_type == 5
@exercise_question.shixun_name = params[:shixun_name].strip if !params[:shixun_name].blank?
question_score = 0
@exercise_question.exercise_bank_shixun_challenges.each_with_index do |challenge, index|
challenge.question_score = params[:question_score][index]

@ -372,6 +372,7 @@ class ExerciseController < ApplicationController
:question_type => params[:question_type] || 1,
:question_number => @exercise.exercise_questions.count + 1,
:question_score => params[:question_type] == '5' ? 0 : params[:question_score],
:shixun_name => params[:question_type] == '5' ? params[:shixun_name] : nil,
:shixun_id => params[:shixun]
}
@exercise_questions = @exercise.exercise_questions.new option
@ -512,6 +513,7 @@ class ExerciseController < ApplicationController
end
end
if @exercise_question.question_type == 5
@exercise_question.shixun_name = params[:shixun_name].strip if !params[:shixun_name].blank?
question_score = 0
@exercise_question.exercise_shixun_challenges.each_with_index do |challenge, index|
challenge.question_score = params[:question_score][index]
@ -1508,7 +1510,8 @@ class ExerciseController < ApplicationController
:question_type => q[:question_type] || 1,
:question_number => q[:question_number],
:question_score => q[:question_score],
:shixun_id => q[:shixun_id]
:shixun_id => q[:shixun_id],
:shixun_name => q[:shixun_name]
}
exercise_bank_question = exercise_bank.exercise_bank_questions.new option

@ -28,7 +28,7 @@ class ForumsController < ApplicationController
private
def render_react
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
end
@ -163,7 +163,7 @@ end
# # id: 1 问题反馈 3 操作指南 5 技术分享
# def index
#
# render "/common/index", :layout => false
# render file: 'public/react/build/index.html', :layout => false
# end
#
# # GET /forums/1

@ -12,11 +12,12 @@ class HomeworkCommonController < ApplicationController
before_filter :find_homework, :only => [:edit,:update,:alert_anonymous_comment,:start_anonymous_comment,:stop_anonymous_comment,:destroy,:start_evaluation_set,
:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,:open_student_works,
:set_score_open,:alert_score_open_modal,:add_to_homework_bank,:publish_notice,:publish_homework,:end_notice,:end_homework,
:setting,:set_public,:homework_setting,:update_explanation,:cancel_publish, :homework_code_repeat, :review_detail,:move_to_category]
:setting,:set_public,:homework_setting,:update_explanation,:cancel_publish, :homework_code_repeat, :review_detail,:move_to_category,
:rename_modal, :rename_homework]
before_filter :teacher_of_course, :only => [:new, :create, :edit, :update, :destroy, :start_anonymous_comment, :stop_anonymous_comment, :alert_anonymous_comment,
:start_evaluation_set,:set_evaluation_attr,:score_rule_set,:alert_forbidden_anonymous_comment,:alert_open_student_works,
:open_student_works,:add_to_homework_bank,:publish_notice,:end_notice,:publish_homework,:end_homework,:update_explanation,
:cancel_publish, :move_to_category,:homework_setting]
:cancel_publish, :move_to_category,:homework_setting, :rename_homework, :rename_modal]
# before_filter :member_of_course, :only => [:index,:setting]
@ -275,6 +276,19 @@ class HomeworkCommonController < ApplicationController
@groups = paginateHelper @groups, 5
end
def rename_modal
end
def rename_homework
if params[:name].blank?
@notice = true
else
@homework.update_attributes(:name => params[:name].strip)
redirect_to homework_common_index_path(:course => @course.id, :homework_type => @homework.homework_type)
end
end
def setting
@is_new = params[:is_new].to_i if params[:is_new]
@is_empty = @homework.publish_time.nil?

@ -78,5 +78,7 @@ class Managements::SchoolsController < Managements::BaseController
@active_course_total = Course.where(is_end: false).count
@shixun_homework_total = HomeworkCommon.where(homework_type: 4).count
@other_homework_total = HomeworkCommon.where(homework_type: [1, 3]).count
@shixun_total = Shixun.count
@shixun_evaluate_total = SchoolReport.sum(:shixun_evaluate_count)
end
end

@ -2,11 +2,10 @@
class ManagementsController < ApplicationController
before_filter :require_business
before_filter :require_admin, :only => [:shixun_setting_list, :mirror_repository, :mirror_picture_shixuns, :editmd_template,
:editmd_template, :subject_level_system, :subject_setting_list, :auto_users_trial,
:evaluate_records, :identity_authentication, :identity_authentication, :professional_authentication,
:shixun_authorization, :graduation_standard, :ec_template, :codemirror_template,
:editmd_template, :subject_level_system, :subject_setting_list,
:shixun_authorization, :ec_template, :codemirror_template,
:course_guide_template, :shixun_quality_score, :tech_system, :update_notice, :setting_banner,
:training_2018]
:training_2018, :create_standard]
layout 'base_management'
include ManagementsHelper
include SortHelper
@ -32,6 +31,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
# 创建课程等级体系
@ -2023,7 +2031,7 @@ end
# @schools = School.where(:id =>user_exs.map(&:school_id))
# end
@search = params[:search] # 搜索字
@keyword = params[:keyword].blank? ? "u_name" : params[:keyword] # 根据姓名/课程名搜索
@keyword = params[:keyword].blank? ? "c_name" : params[:keyword] # 根据姓名/课程名搜索
@status = params[:status]
@school_id = params[:school_id]
@ -2044,11 +2052,13 @@ end
if params[:status] && params[:status]!=''
@courses = @courses.where(:is_end => @status.to_i)
end
if "u_name" == @keyword
if "c_name" == @keyword
@courses = @courses.where("name like ?", "%#{@search}%")
elsif "u_name" == @keyword
if @search.blank?
@courses = @courses
else
user_id = User.where("concat(lastname, firstname) like '%#{@search}%'")
# user_id = User.where("concat(lastname, firstname) like '%#{@search}%'")
@courses = @courses.joins("join users u on courses.tea_id = u.id").where("concat(u.lastname, u.firstname) like '%#{@search}%'")
end
elsif "dep_name" == @keyword
@ -2818,17 +2828,17 @@ end
else
"status = 1"
end
@users = User.where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on #{@sx_order}")
@users = User.where("#{sql}").includes(:real_name_authentication_apply, :professional_authentication_apply,
user_extensions: [:department, :school]).order("last_login_on #{@sx_order}")
@has_cer_count = User.where(:status => 1, :certification => 1).count
@reject_cer_count = User.where(:status => 1, :certification => 2).count
@deal_cer_count = ApplyAction.where(:status => 0).select("distinct user_id").count
time = Time.at(Time.now.to_i - 86400)
cer = UserDayCertification.where("created_at > '#{time}'").pluck(:user_id)
cer_ids = cer.join(",")
@trial_cer_count = cer.blank? ? 0 : User.where("status = 1 and certification != 1 and id in (#{cer_ids})").count
apply = ApplyAction.where(:container_type => "TrialAuthorization").pluck(:user_id)
apply_ids = apply.join(",")
@nonn_cer_count = apply.blank? ? 0 : User.where("status = 1 and certification = 0 and id not in (#{apply_ids}) ").count
subquery = UserDayCertification.where("created_at > ?", Time.now.ago(1.days)).select(:user_id).to_sql
@trial_cer_count = User.where("status = 1 and certification != 1 and id in (#{subquery})").count
apply_subquery = ApplyAction.where(container_type: "TrialAuthorization").select(:user_id).to_sql
@nonn_cer_count = User.where("status = 1 and certification = 0 and id not in (#{apply_subquery}) ").count
@page = (params['page'] || 1).to_i
@users_count = @users.count
@ -3308,83 +3318,82 @@ end
end
end
all_user_ids = User.where(:status => 1).pluck(:id)
users = User.where(nil)
if params[:trial] == "-1"
apply = ApplyAction.where(:container_type => "TrialAuthorization").pluck(:user_id)
apply_id = apply.blank? ? -1 : "(" + apply.join(",") + ")"
apply_user_id = User.where("status = 1 and certification = 0 and id not in #{apply_id} ").pluck(:id)
users = users.where(status: 1, certification: 0)
.joins('LEFT JOIN apply_actions ON apply_actions.user_id = users.id AND apply_actions.container_type = "TrialAuthorization"')
.where('apply_actions.user_id IS NULL')
elsif params[:trial] == "-2"
apply_user_id = all_user_ids
users = users.where(status: 1)
elsif params[:trial] == "0"
apply_user_id = ApplyAction.where(:status => 0).pluck(:user_id)
users = users.joins('LEFT JOIN apply_actions ON apply_actions.user_id = users.id').where(apply_actions: { status: 0 })
elsif params[:trial] == "3"
time = Time.at(Time.now.to_i - 86400)
user_cer = UserDayCertification.where("created_at > '#{time}'").pluck(:user_id)
cer_id = user_cer.blank? ? "(-1)" : "(" + user_cer.map{|a| a.user_id}.join(",") + ")"
apply_user_id = User.where("status = 1 and certification != 1 and id in #{cer_id} ").pluck(:id)
users = users.joins('LEFT JOIN user_day_certifications udc ON udc.user_id = users.id')
.where('users.certification != 1').where('udc.created_at > ?', Time.now.ago(1.days))
else
apply_user_id = User.where(:status => 1, :certification => params[:trial]).pluck(:id)
users = users.where(status: 1, certification: params[:trial])
end
if params[:school] == ""
s_user_id = all_user_ids
else
school_ids = School.where("name like '%#{params[:school]}%'").pluck(:id)
s_user_id = UserExtensions.where(:school_id => school_ids).pluck(:user_id)
users = users.joins('LEFT JOIN user_extensions ON user_extensions.user_id = users.id')
.joins('LEFT JOIN departments ON departments.id = user_extensions.department_id')
.joins('LEFT JOIN schools ON schools.id = user_extensions.school_id')
if params[:school].present?
users = users.where("schools.name LIKE ?", "%#{params[:school]}%")
end
if params[:department] == ""
d_user_id = all_user_ids
else
dep_ids = Department.where("name like '%#{params[:department]}%'").pluck(:id)
d_user_id = UserExtensions.where(:department_id => dep_ids).pluck(:user_id)
if params[:department].present?
users = users.where("departments.name LIKE ?", "%#{params[:department]}%")
end
ide_user_id = all_user_ids
if params[:identity] == "1" || (params[:identity] == "0" && params[:te_technical_title] == "0") || (params[:identity] == "2" && params[:pro_technical_title] == "0")
ide_user_id = UserExtensions.where("identity = #{params[:identity]}").pluck(:user_id)
users = users.where(user_extensions: { identity: params[:identity] })
elsif (params[:identity] == "0" && params[:te_technical_title] != "0") || (params[:identity] == "2" && params[:pro_technical_title] != "0")
technical_title = params[:identity] == "0" ? params[:te_technical_title] : params[:pro_technical_title]
ide_user_id = UserExtensions.where("identity = #{params[:identity]} and technical_title = '#{technical_title}'").pluck(:user_id)
users = users.where(user_extensions: { identity: params[:identity], technical_title: technical_title })
end
if params[:student_id] && params[:student_id] != ''
stu_user_id = UserExtensions.where("student_id like '%#{params[:student_id]}%'").pluck(:user_id)
else
stu_user_id = all_user_ids
if params[:student_id].present?
users = users.where('user_extensions.student_id like ?', "%#{params[:student_id]}%")
end
user_id = s_user_id & d_user_id & apply_user_id & stu_user_id & ide_user_id
sql = ""
sql =
if params[:research_condition] == "name"
"concat(lastname, firstname) like '%#{params[:research_contents]}%'"
elsif params[:research_condition] == "email"
"mail like '%#{params[:research_contents]}%'"
elsif params[:research_condition] == "phone"
"phone like '%#{params[:research_contents]}%'"
elsif params[:research_condition] == "nickname"
if params[:research_contents].present?
"nickname like '%#{params[:research_contents]}%'"
end
elsif params[:research_condition] == "login"
params[:research_contents].present? ? "login like '%#{params[:research_contents]}%'" : ""
end
if params[:research_contents].present?
keyword = "%#{params[:research_contents]}%"
if params[:research_condition] == "name"
users = users.where('concat(lastname, firstname) like ?', keyword)
elsif params[:research_condition] == "email"
users = users.where("mail like ?", keyword)
elsif params[:research_condition] == "phone"
users = users.where("phone like ?", keyword)
elsif params[:research_condition] == "nickname"
users = users.where("nickname like ?", keyword)
elsif params[:research_condition] == "login"
users = users.where("login like ?", keyword)
end
end
if params[:province].present?
users = users.where(schools: { province: params[:province] })
end
users = users.select('distinct users.*').order("last_login_on desc")
@users = User.where(:id => user_id).where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).order("last_login_on desc")
@xls_users = @users.reorder("created_on desc").limit(3000) #导出excel用户
@page = (params['page'] || 1).to_i
@users_count = @users.count
@users_count = users.count
@limit = 20
@is_remote = true
@users_pages = Paginator.new @users_count, @limit, params['page'] || 1
@offset ||= @users_pages.offset
@users = paginateHelper @users, @limit
@users = paginateHelper users.includes(:real_name_authentication_apply, :professional_authentication_apply,
user_extensions: [:department, :school]), @limit
respond_to do |format|
format.js
format.xls{
# @export_shixun_task = @export_shixun_task.all
@xls_users = users.reorder("created_on desc").limit(3000) #导出excel用户
@xls_users = @xls_users.includes(:real_name_authentication_apply, :professional_authentication_apply,
user_extensions: [:department, :school])
filename = "用户列表.xls"
send_data(user_list_xls(@xls_users), :type => 'application/octet-stream', :filename => filename_for_content_disposition(filename))
}
@ -4184,7 +4193,7 @@ end
sheet1 = book.create_worksheet :name => "users"
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
users.each do |user|
sheet1[count_row,0] = user.try(:show_real_name)
@ -4197,6 +4206,7 @@ end
sheet1[count_row,7] = format_time user.created_on
sheet1[count_row,8] = format_time user.last_login_on
sheet1[count_row,9] = user.trial_authorization
sheet1[count_row,10] = user.mail
count_row += 1
end
book.write xls_report
@ -4285,6 +4295,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
@ -4294,7 +4331,7 @@ end
count_row = 1
shixuns = Shixun.where(:id => shixun_ids).includes(discusses: [:user])
sheet1.row(0).concat(["序号", "实训ID", "实训名称", "实训作者", "作者单位", "评论数", "评论内容", "关卡", "评论者", "评论者职业",
"评论者单位", "评论时间", "社区导师是否已回复"])
"评论者单位", "评论时间", "社区导师是否已回复", "我的账号回复内容", "回复时间"])
shixuns.each_with_index do |shixun, i|
discusses = shixun.discusses.where("user_id != ?", 1)
if beginTime.present?
@ -4312,6 +4349,7 @@ end
discusses.each_with_index do |discuss, j|
user = discuss.user
content = discuss.content.gsub(/<img.*\/>/, "【图片评论】").gsub(/!\[\].+\)/, "【图片评论】")
myself_discuss = discuss.children.where(user_id: User.current.id).last
sheet1[count_row, 6] = strip_html content
sheet1[count_row, 7] = "#{discuss.position}"
sheet1[count_row, 8] = user.show_real_name
@ -4319,6 +4357,8 @@ end
sheet1[count_row, 10] = user.school_name
sheet1[count_row, 11] = format_time discuss.created_at
sheet1[count_row, 12] = discuss.children.pluck(:user_id).include?(1) ? "" : ""
sheet1[count_row, 13] = myself_discuss.try(:content)
sheet1[count_row, 14] = myself_discuss ? (format_time myself_discuss.created_at) : ""
count_row += 1
end
#count_row += 1

@ -29,7 +29,7 @@ class MemosController < ApplicationController
# 这样处理是为了 前端react显示图片所使用
def new
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
def create

@ -1,15 +1,19 @@
# encoding: utf-8
class MyshixunsController < ApplicationController
layout 'base_myshixun'
skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message]
before_filter :require_login, :except => [:training_task_status, :close_webssh, :code_runinng_message]
skip_before_filter :verify_authenticity_token, :only => [:training_task_status, :close_webssh, :code_runinng_message, :vnc]
before_filter :require_login, :except => [:training_task_status, :close_webssh, :code_runinng_message, :vnc]
before_filter :check_authentication, :except => [:training_task_status, :close_webssh, :mul_test_home, :mul_test_user,
:mul_test_myshixun, :mul_test_shixun, :mul_test_start, :code_runinng_message]
:mul_test_myshixun, :mul_test_shixun, :mul_test_start, :code_runinng_message, :vnc]
before_filter :find_myshixun, :only => [:show, :myshixun_reset, :open_webssh, :sync_reset_time, :destroy, :search_file_list, :vnc]
DCODES = %W(2 3 4 5 6 7 8 9 a b c f e f g h i j k l m n o p q r s t u v w x y z)
include ApplicationHelper
def archive
end
def forbidden
render_403
return
@ -357,7 +361,8 @@ class MyshixunsController < ApplicationController
host = Redmine::Configuration['tomcat_php']
begin
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
params = {tpiID:@myshixun.id}
shixun = @myshixun.shixun
params = {tpiID: @myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(shixun.mirror_repositories))}"}
res = uri_exec uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99")

@ -117,7 +117,7 @@ class QuestionBanksController < ApplicationController
else
@courses = User.current.courses.where("is_delete = 0 and is_end = 0").select{ |course| User.current.has_teacher_role(course)}
end
@homework_ids = params[:check_homework_bank] || params[:bank_id].split(" ")
@homework_ids = params[:check_homework_bank] || params[:bank_id].split(" ") unless params[:is_observe]
@search = params[:search]
respond_to do |format|
format.js

@ -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]
@ -850,7 +850,7 @@ class ShixunsController < ApplicationController
begin
raise "请先绑定邮箱" if User.current.mail.blank?
new_shixun = Shixun.new
new_shixun.attributes = @shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier", "homepage_show","git_url")
new_shixun.attributes = @shixun.attributes.dup.except("id","user_id","visits","gpid","status", "identifier", "homepage_show","git_url", "propaedeutics")
new_shixun.user_id = User.current.id
new_shixun.identifier = generate_identifier
new_shixun.status = 0
@ -1088,7 +1088,7 @@ class ShixunsController < ApplicationController
def shixun_discuss
if User.current.logged?
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
else
redirect_to signin_path
end
@ -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?

@ -6,7 +6,7 @@ class StatisticsController < ApplicationController
before_filter :find_rate
def index
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
# 用户活跃度(按月份的)
@ -187,7 +187,7 @@ class StatisticsController < ApplicationController
unless User.curren.admin?
render_403
end
render "/common/index", :layout => false
render file: 'public/react/build/index.html', :layout => false
end
def set_rate

@ -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
@ -584,16 +584,16 @@ class StudentWorkController < ApplicationController
@stundet_works = @stundet_works.where(:work_status => @status)
end
@stundet_works = search_work_member @stundet_works, @name
if @stundet_works.size != 0
if @order == "student_id"
@stundet_works = @stundet_works.includes(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}")
@stundet_works = @stundet_works.joins(:user => {:user_extensions => []}).order("user_extensions.student_id #{@b_sort}")
else
@stundet_works = @stundet_works.order("#{@order} #{@b_sort}")
end
end
@stundet_works = search_work_member @stundet_works, @name
@score = @b_sort == "desc" ? "asc" : "desc"
# @is_focus = params[:is_focus] ? params[:is_focus].to_i : 0
# 消息传过来的ID
@ -615,6 +615,7 @@ class StudentWorkController < ApplicationController
_index
@stundet_works = paginateHelper @stundet_works, @limit
@members = @course.members.select([:user_id, :course_group_id])
if @stundet_works.size != 0
@stundet_works = if @homework.homework_type == 1
@stundet_works.includes(:student_works_scores, [user: :user_extensions])
@ -623,7 +624,6 @@ class StudentWorkController < ApplicationController
elsif @homework.homework_type == 4
@stundet_works.includes(:student_works_scores, [myshixun: :games], [user: :user_extensions])
end
@members = @course.members.where(user_id: @stundet_works.pluck(:user_id)).select([:user_id, :course_group_id])
end
respond_to do |format|
format.js
@ -647,7 +647,7 @@ class StudentWorkController < ApplicationController
uid: "#{work.user.user_extensions.student_id}",
downloadUrl: ''
}
attachment = work.attachments.first
attachment = work.attachments.last
if attachment
o[:downloadUrl] = "https://#{Setting.host_name}/"+download_named_attachment_path(attachment.id, attachment.filename)
end

@ -3,7 +3,6 @@ class TasksController < ApplicationController
layout false
def show
# redirect_to "/react/build/index.html"
render "/common/index"
render file: 'public/react/build/index.html', :layout => false
end
end

@ -63,10 +63,9 @@ class TrainingsController < ApplicationController
return
end
@training.training_payinfo ||= begin
payinfo = TrainingPayinfo.new
payinfo.fee = @training.registration_fee # 默认值价格不对
payinfo
if @training.training_payinfo.blank?
@training.build_training_payinfo
@training.training_payinfo.fee = @training.registration_fee
end
end

@ -7034,7 +7034,8 @@ def quote_exercise_bank exercise, course
:question_type => q[:question_type] || 1,
:question_number => q[:question_number],
:question_score => q[:question_score],
:shixun_id => q[:shixun_id]
:shixun_id => q[:shixun_id],
:shixun_name => q[:shixun_name]
}
exercise_question = new_exercise.exercise_questions.new option

@ -0,0 +1,8 @@
class CnmoocUser < UserSource
private
def email_prefix
'cnmooc_'
end
end

@ -1,6 +1,7 @@
class Discuss < ActiveRecord::Base
belongs_to :user
attr_accessible :user_id, :content, :dis_id, :dis_type, :parent_id, :praise_count, :root_id, :challenge_id, :position, :reward
attr_accessible :user_id, :content, :dis_id, :dis_type, :parent_id, :praise_count, :root_id, :challenge_id,
:position, :reward, :hidden
default_scope :order => 'created_at desc'
has_many :praise_tread, as: :praise_tread_object, dependent: :destroy

@ -15,7 +15,8 @@ class Myshixun < ActiveRecord::Base
belongs_to :user
validates_uniqueness_of :shixun_id, :scope => :user_id, :message => "error"
# validates :shixun_id, :uniqueness => {:scope => :user_id, :message => "不能被重复开启"}
scope :min, lambda { select([:id, :shixun_id, :identifier, :gpid, :status, :user_id, :commit_id, :modify_time, :reset_time, :system_tip]) }
scope :min, lambda { select([:id, :shixun_id, :identifier, :gpid, :status, :user_id, :commit_id, :modify_time, :reset_time,
:system_tip, :gpid]) }
scope :finished, lambda{where(status: 1)}
def output_times

@ -26,6 +26,7 @@ class School < ActiveRecord::Base
# 报表信息
has_many :school_daily_reports
has_one :school_report
has_many :teacher_extensions, conditions: "identity = #{User::TEACHER}", class_name: 'UserExtensions'
has_many :student_extensions, conditions: "identity = #{User::STUDENT}", class_name: 'UserExtensions'
@ -80,4 +81,10 @@ class School < ActiveRecord::Base
courses.id LEFT JOIN user_extensions ON courses.tea_id=user_extensions.user_id WHERE
user_extensions.`school_id` = #{self.id}").first.try(:max_update)
end
def self.provinces
Rails.cache.fetch('china_province_cache', expires_in: 1.days) do
School.pluck('distinct province').select(&:present?)
end
end
end

@ -0,0 +1,3 @@
class SchoolDailyActiveUser < ActiveRecord::Base
belongs_to :school_daily_report
end

@ -1,3 +1,5 @@
class SchoolDailyReport < ActiveRecord::Base
belongs_to :school
has_many :school_daily_active_users, dependent: :delete_all
end

@ -0,0 +1,3 @@
class SchoolReport < ActiveRecord::Base
belongs_to :school
end

@ -57,7 +57,7 @@ class Shixun < ActiveRecord::Base
scope :visible, lambda{where(status: [2,3])}
scope :min, lambda { select([:id, :name, :gpid, :modify_time, :reset_time, :language, :propaedeutics, :status, :identifier,
:test_set_permission, :hide_code, :forbid_copy, :hidden, :webssh, :user_id, :code_hidden,
:task_pass, :exec_time, :multi_webssh]) }
:task_pass, :exec_time, :multi_webssh, :vnc]) }
scope :published, lambda{where(status: 2)}
scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) }

@ -224,6 +224,8 @@ class User < Principal
###
has_many :apply_actions, :dependent => :destroy
has_many :apply_user_authentications, :dependent => :destroy
has_one :real_name_authentication_apply, conditions: 'auth_type = 1 AND status = 0', class_name: 'ApplyUserAuthentication'
has_one :professional_authentication_apply, conditions: 'auth_type = 2 AND status = 0', class_name: 'ApplyUserAuthentication'
has_one :user_wechat
@ -269,6 +271,8 @@ class User < Principal
has_many :article_homepages, :dependent => :destroy
has_many :competition_lists, :dependent => :destroy
has_one :user_source
## end
# default_scope -> { includes(:user_extensions, :user_score) }
@ -991,12 +995,12 @@ class User < Principal
# 实名认证状态
def authentication_status
status = self.authentication ? "已认证" : (self.apply_user_authentications.where(:auth_type => 1, :status => 0).count > 0 ? "待审核" : "未认证")
authentication ? "已认证" : (real_name_authentication_apply.present? ? "待审核" : "未认证")
end
# 职业认证状态
def professional_status
status = self.professional_certification ? "已认证" : (self.apply_user_authentications.where(:auth_type => 2, :status => 0).count > 0 ? "待审核" : "未认证")
professional_certification ? "已认证" : (professional_authentication_apply.present? ? "待审核" : "未认证")
end
def logged?
@ -1115,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)
@ -1319,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(",") + ")"

@ -0,0 +1,21 @@
class UserSource < ActiveRecord::Base
belongs_to :user
def generate_email
email = rand_email
while User.exists?(mail: email) do
email = rand_email
end
email
end
private
def rand_email
email_prefix + Random.rand.to_s[2..8] + '@educoder.com'
end
def email_prefix
''
end
end

@ -0,0 +1,148 @@
class CnmoocsService
include ApplicationHelper
include GamesHelper
def get_resources_data params
resources = []
if params[:level].to_s == "1"
subjects = Subject.find_by_sql("SELECT subjects.id, subjects.name, subjects.status, COUNT(myshixuns.id) AS myshixun_member_count
FROM myshixuns, stage_shixuns, subjects WHERE myshixuns.shixun_id = stage_shixuns.shixun_id
AND stage_shixuns.subject_id = subjects.id AND `subjects`.`hidden` = 0 AND `subjects`.`status` = 2
GROUP BY subjects.id ORDER BY myshixun_member_count DESC")
subjects.each do |subject|
resources << {resourceId: subject.id, parentId: nil, resourceName: subject.name, accessType: 0, nodeType: 0,
resourceType: 2}
end
elsif params[:level].to_s == "2"
return {error: -1, messages: "请求二级及其更高目录时parentId不能为空"} if params[:parentId].blank?
stages = Stage.where(:subject_id => params[:parentId])
stages.each do |stage|
resources << {resourceId: stage.id, parentId: params[:parentId], resourceName: stage.name, accessType: 0, nodeType: 0,
resourceType: 2}
end
elsif params[:level].to_s == "3"
return {error: -1, messages: "请求二级及其更高目录时parentId不能为空"} if params[:parentId].blank?
shixun_ids = StageShixun.where(:stage_id => params[:parentId]).pluck(:shixun_id)
shixuns = Shixun.where(:id => shixun_ids)
shixuns.each do |shixun|
resources << {resourceId: shixun.id, parentId: params[:parentId], resourceName: shixun.name, accessType: 2,
nodeType: 1, resourceType: 1}
end
end
{error: 0, messages: "请求成功",
data: {resources: resources} }
end
def search_resources params
shixuns = Shixun.select([:id, :identifier, :name, :myshixuns_count, :averge_star, :challenges_count, :trainee]).
where(status: 2, hidden: 0).where("name like ?", "%#{params[:name]}%")
shixuns = shixuns.order("myshixuns_count desc")
shixun_list = shixun_data shixuns
{error: 0, messages: "请求成功",
data: shixun_list }
end
def find_user params
c_user = CnmoocUser.find_by_uuid(params[:userName])
if c_user
{error: 0, messages: "找到用户", data: { userId: c_user.user_id } }
else
{error: -1, messages: "找不到用户"}
end
end
def create_user(params)
c_user = CnmoocUser.find_by_uuid(params[:userName])
if c_user.present?
return { error: -1, messages: '用户已存在' }
end
c_user = CnmoocUser.new(uuid: params[:userName], name: params[:name])
mail = params[:email] || c_user.generate_email
name = params[:name] || "好大学_#{params[:userName]}"
login = generate_login('m')
Rails.logger.info("#######mail: #{mail} #{name}, #{login}")
create_params = {
lastname: name,
mail: mail,
mail_notification: mail,
password: OauthController::DEFAULT_PASSWORD,
certification: 1
}
user = User.new(create_params)
# login 有问题,只能这样赋值
user.login = login
ActiveRecord::Base.transaction do
user.save!
UserExtensions.create!(user_id: user.id, school_id: School.first.id, identity: 4, gender: 0)
c_user.user_id = user.id
c_user.save!
end
{ error: 0, messages: "创建成功", data: { userId: user.id } }
end
def login_educoder params
user, last_login_on = User.try_to_login(params[:mail], params[:password])
if user
self.logged_user = user
{error: 0, messages: "登录成功"}
else
{error: -1, messages: "登录失败,请检查邮箱和密码是否正确"}
end
end
def source_url(params, token)
shixun = Shixun.find_by_id(params[:resourceId])
if shixun.blank?
return { error: -1, messages: '资源不存在' }
end
{ error: 0, messages: '成功', data: {accessUrl: "#{Redmine::Configuration['educoder_domain']}/shixuns/#{shixun.identifier}/challenges?authToken=#{token.value}" }}
end
def get_students_data params
shixun = Shixun.find_by_id params[:resourceId]
return {error: -1, messages: "资源id不对请使用资源的id查找"} if shixun.blank?
myshixun = shixun.myshixuns.where(:user_id => params[:userId]).includes(:games).first
if myshixun.present?
score = myshixun.total_score
time = 0
myshixun.games.each do |game|
time += game.consumes_time_int
end
{error: 0, messages: '成功', data: {experiment: {time: time, totalTime: score * 10}}}
else
{error: -1, messages: '用户还未开始学习此资源'}
end
end
private
def shixun_data shixuns
shixun_list = []
shixuns.includes(:tag_repertoires).each do |shixun|
tag_name = shixun.tag_repertoires.first.try(:name)
level = %W(初级 中级 高级 顶级)[shixun.trainee - 1]
shixun_list << {identifier: shixun.identifier, name: shixun.name, students_count: shixun.myshixuns_count,
challenges_count: shixun.challenges_count, score_info: shixun.averge_star, level: level}
end
{resources: shixun_list}
end
# 为新创建的用户随机生成以m为前缀的用户名m表示该用户是用邮箱注册
def generate_login(login_pre)
us = UsersService.new
us.generate_user_login(login_pre)
end
end

@ -224,8 +224,11 @@
to_relate.attributes = relate.attributes.except('id', 'ec_course_achievement_method_id', 'ec_course_target_id',
'ec_course_evaluation_subitem_id', 'created_at', 'updated_at')
to_relate.ec_course_target_id = course_target_map[relate.ec_course_target_id]
to_relate.ec_course_evaluation_subitem_id = course_target_map[relate.ec_course_evaluation_subitem_id]
# 可能不存在,所以为 -1
to_relate.ec_course_evaluation_subitem_id = course_evaluation_subitem_map[relate.ec_course_evaluation_subitem_id] || -1
to_relate.save!
achievement_evaluation_relates_map[relate.id] = to_relate.id
end
end
@ -258,14 +261,16 @@
end
def copy_year_students!
students = from_year.ec_year_students.includes(:ec_student_achievements)
students = from_year.ec_year_students.includes(:ec_student_achievements, :ec_course_student_scores, :ec_student_score_targets)
students.each do |student|
to_student = to_year.ec_year_students.new
to_student.attributes = student.attributes.except('id', 'ec_year_id', 'created_at', 'updated')
to_student.attributes = student.attributes.except('id', 'ec_year_id', 'created_at', 'updated_at')
to_student.save!
copy_student_achievements!(student, to_student)
copy_course_student_scores!(student, to_student)
copy_student_score_targets!(student, to_student)
end
end
@ -280,6 +285,31 @@
end
end
def copy_course_student_scores!(student, to_student)
student.ec_course_student_scores.each do |score|
to_score = to_student.ec_course_student_scores.new
to_score.attributes = score.attributes.except('id', 'ec_year_student_id', 'ec_course_id', 'created_at', 'updated_at')
to_score.ec_course_id = course_map[score.ec_course_id]
to_score.save!
course_student_score_map[score.id] = to_score.id
end
end
def copy_student_score_targets!(student, to_student)
student.ec_student_score_targets.each do |target|
to_target = to_student.ec_student_score_targets.new
to_target.attributes = target.attributes.except('id', 'ec_course_id', 'ec_course_student_score_id',
'ec_course_target_id', 'ec_year_student_id', 'eaer_id',
'created_at', 'updated_at')
to_target.ec_course_id = course_map[target.ec_course_id]
to_target.ec_course_student_score_id = course_student_score_map[target.ec_course_student_score_id]
to_target.ec_course_target_id = course_target_map[target.ec_course_target_id]
to_target.eaer_id = achievement_evaluation_relates_map[target.eaer_id]
to_target.save!
end
end
def graduation_requirement_map
@_graduation_requirement_map ||= {}
end
@ -300,7 +330,15 @@
@_course_evaluation_subitem_map ||= {}
end
def achievement_evaluation_relates_map
@_achievement_evaluation_relates_map ||= {}
end
def course_target_map
@_course_target_map ||= {}
end
def course_student_score_map
@_course_student_score_map ||= {}
end
end

@ -56,8 +56,9 @@ class DiscussesService
# 添加评论
def create params, current_user
begin
hidden = current_user.admin? ? false : true
Discuss.create!(:dis_id => params[:shixun_id], :dis_type => "Shixun", :content => params[:content].gsub("&nbsp\;", "").strip, :user_id => current_user.id,
:praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id])
:praise_count => 0, :position => params[:position], :challenge_id => params[:challenge_id], :hidden => hidden)
# 发送手机通知
# status = Trustie::Sms.send(mobile:'18173242757', send_type:'discuss', name:'管理员')
rescue Exception => e
@ -69,8 +70,9 @@ class DiscussesService
def reply params, current_user
begin
base_dicuss params[:id]
hidden = current_user.admin? ? false : true
discuss = Discuss.create!(:content => params[:content].gsub("&nbsp\;", "").strip, :user_id => current_user.id, :parent_id => params[:id],
:root_id => @discuss.root_id || params[:id], :praise_count => 0, :challenge_id => @discuss.challenge_id,
:root_id => @discuss.root_id || params[:id], :praise_count => 0, :challenge_id => @discuss.challenge_id, :hidden => hidden,
:dis_id => @discuss.dis_id, :dis_type => @discuss.dis_type, :position => @discuss.position)
return discuss
rescue Exception => e

@ -19,6 +19,7 @@ class GamesService
shixun = Shixun.min.find(myshixun.shixun_id)
unless ((myshixun.user_id == current_user.id || current_user.business? || current_user.id == shixun.try(:user_id) ||
current_user.is_certification_teacher) && (shixun.operable?)) || current_user.admin?
Rails.logger.info("######403???")
return{:status => 403}
end
game_challenge = Challenge.min.find(game.challenge_id)
@ -31,7 +32,8 @@ class GamesService
# st判断是选择类型还是实训类型
st = game_challenge.st
game_count = myshixun.games.count
discusses_count = shixun.discusses.count
discusses_count = (current_user.admin? ? shixun.discusses.count :
shixun.discusses.where("hidden = false or user_id = :user_id", user_id: current_user.id).count)
mirror_name = myshixun.mirror_name
user = myshixun.owner
username = user.show_name
@ -44,7 +46,7 @@ class GamesService
# 高性能取上一关、下一关
prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position)
next_game = if current_user.is_certification_teacher || shixun_manager(shixun, current_user) || game.status || shixun.task_pass
next_game = if shixun.vnc || current_user.is_certification_teacher || shixun_manager(shixun, current_user) || game.status || shixun.task_pass
Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier)
end
@ -75,6 +77,29 @@ class GamesService
:record => record, :grade => grade, :prev_game => prev_game, :next_game => next_game, :username => username,
:image_url => image_url, :user_url => user_url, :praise_count => praise_count, :user_praise => user_praise, :time_limit => time_limit,
:tomcat_url => Redmine::Configuration['tomcat_php'], :is_teacher => is_teacher, :power => power, :myshixun_manager => myshixun_manager}
if shixun.vnc
begin
shixun_tomcat = Redmine::Configuration['shixun_tomcat']
service_host = Redmine::Configuration['tomcat_php']
uri = "#{shixun_tomcat}/bridge/vnc/getvnc"
params = {tpiID: myshixun.id, :containers => "#{Base64.urlsafe_encode64(container_limit(shixun.mirror_repositories))}"}
res = uri_exec uri, params
if res && res['code'].to_i != 0
raise("实训云平台繁忙繁忙等级99")
end
url = "#{service_host}" +":#{res['port']}/vnc_lite.html?password=headless"
Rails.logger.info("66666666sssssss#{url}")
container = container.merge(:vnc_url => url)
Rails.logger.info("777777666sssssss#{container}")
rescue Exception => e
Rails.logger.error(e.message)
end
end
if st == 0 && shixun.status == 2 && myshixun_manager
zip_path = Gitlab.endpoint.to_s + "/projects/" + myshixun.gpid.to_s + "/repository/archive?&private_token=" + Gitlab.private_token.to_s
container = container.merge(:zip_path => zip_path)
end
# 区分选择题和编程题st0编程题
if st == 0
@ -91,7 +116,7 @@ class GamesService
# 区分评测过未评测过,未评测过按需求取数据
sql =
if max_query_index > 0
"SELECT
"SELECT
b.code, b.actual_output, b.out_put, b.result, b.compile_success, a.is_public, a.input, a.output
FROM
(SELECT position, input, output, challenge_id, is_public FROM test_sets where challenge_id=#{game_challenge.id}) a
@ -130,7 +155,7 @@ class GamesService
Rails.logger.warn(latest_output)
output_hash = {:test_sets => test_sets}.merge(:had_test_count => had_test_count, :test_sets_count => test_sets_count,
:had_passed_testsests_error_count => had_passed_testsests_error_count)
:had_passed_testsests_error_count => had_passed_testsests_error_count)
multi_webssh = shixun.webssh == 2 && shixun.multi_webssh
result = {:tpm_modified => tpm_modified, :tpm_cases_modified => tpm_cases_modified, :hide_code => shixun.hide_code, :forbid_copy => shixun.forbid_copy,
:output_sets => output_hash, :latest_output => latest_output, :mirror_name => mirror_name, :multi_webssh => multi_webssh,
@ -371,7 +396,8 @@ class GamesService
end
if content != last_content
content_modified = 1
code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master", :commit_message => "auto commit")
code_file = @g.edit_file(@myshixun.gpid, current_user.login, :content => content, :file_path => path, :branch_name => "master",
:commit_message => (params[:evaluate] == 1 ? "commit by author" : "auto commit" ))
end
# REDO是否有读写分离的问题
if record.present?
@ -668,6 +694,7 @@ class GamesService
:evaluate_count]).find_by_identifier(params[:identifier])
# 更新评测次数
game.update_column(:evaluate_count, (game.evaluate_count.to_i + 1))
game.challenge.shixun.increment!(:evaluate_count)
# 选择题如果通关了,则不让再评测
if game.status == 2
@ -801,6 +828,7 @@ class GamesService
# 轮询获取状态
# resubmit是在file_update中生成的从game_build中传入的
def game_status params, current_user
Rails.logger.info("sec_key is #{params[:sec_key]}**1")
game = Game.find_by_identifier(params[:identifier])
resubmit_identifier = game.resubmit_identifier
# 如果没有超时并且正在评测中
@ -812,6 +840,7 @@ class GamesService
return {:running_code_status => running_code_status, :running_code_message => running_code_message}
end
Rails.logger.info("sec_key is #{params[:sec_key]}**2")
Rails.logger.info("##### resubmit_identifier is #{resubmit_identifier}")
port = params[:port]
score = 0
@ -838,6 +867,7 @@ class GamesService
end
end
Rails.logger.info("sec_key is #{params[:sec_key]}**3")
# 实训的最大评测次数,这个值是为了优化查询,每次只取最新的最新一次评测的结果集
max_query_index = game.query_index - 1
# 区分评测过未评测过,未评测过按需求取数据
@ -854,7 +884,7 @@ class GamesService
# 能进入到此处肯定是已经返回了结果也就是说outputs中肯定有了数据
Rails.logger.info("sec_key is #{params[:sec_key]}**4")
test_sets_count = qurey_test_sets.size
# had_test = Output.where(:game_id => game.id, :query_index => max_query_index)
# had_test_count = had_test.count
@ -881,6 +911,7 @@ class GamesService
web_route = game_challenge.try(:web_route)
mirror_name = shixun.mirror_name
Rails.logger.info("sec_key is #{params[:sec_key]}**5")
# 轮询结束,更新评测耗时
e_record = EvaluateRecord.where(:identifier => params[:sec_key]).first
if game_status == 0 || game_status == 2
@ -898,12 +929,14 @@ class GamesService
# 实训制作者当前拥有的金币
grade = User.where(:id => game.user_id).pluck(:grade).first
Rails.logger.info("sec_key is #{params[:sec_key]}**6")
# 高性能取上一关、下一关
prev_game = Game.prev_identifier(shixun.id, game.myshixun_id, game_challenge.position)
next_game = Game.next_game(shixun.id, game.myshixun_id, game_challenge.position).try(:identifier)
output_hash = {:test_sets => test_sets, :had_test_count => test_sets_count, :test_sets_count => test_sets_count, :had_passed_testsests_error_count => had_passed_testsests_error_count}
Rails.logger.info("sec_key is #{params[:sec_key]}**7")
return {:grade => grade, :gold => score, :experience => experience, :status => game_status, :had_done => had_done,
:position => game_challenge.position, :port => port, :power => power, :record => record,
:mirror_name => mirror_name, :picture => picture, :web_route => web_route, :latest_output => latest_output,

@ -4,7 +4,7 @@ class Management::SchoolDataContrastService
PAGE_SIZE = 20
CONTRAST_COLUMN_LIST = %w(
teacher_increase_count student_increase_count course_increase_count
shixun_increase_count active_user_count
shixun_increase_count active_user_count shixun_homework_count shixun_evaluate_count
).freeze
attr_reader :params, :sort_direction, :contrast_column
@ -56,13 +56,25 @@ class Management::SchoolDataContrastService
end
def select_columns
"schools.id school_id, schools.name school_name,"\
"(SUM(IF(date BETWEEN '#{format_date(params[:begin_date])}' AND '#{format_date(params[:end_date])}', #{contrast_column}, 0))) total,"\
"(SUM(IF(date BETWEEN '#{format_date(params[:other_begin_date])}' AND '#{format_date(params[:other_end_date])}', #{contrast_column}, 0))) other_total"\
if contrast_column != 'active_user_count'
"schools.id school_id, schools.name school_name,"\
"(SUM(IF(date BETWEEN '#{format_date(params[:begin_date])}' AND '#{format_date(params[:end_date])}', #{contrast_column}, 0))) total,"\
"(SUM(IF(date BETWEEN '#{format_date(params[:other_begin_date])}' AND '#{format_date(params[:other_end_date])}', #{contrast_column}, 0))) other_total"
else
# 活跃用户对比时处理方法不同
relations = SchoolDailyActiveUser.select('COUNT(distinct user_id)').joins(:school_daily_report)
.where('school_id = schools.id')
total_subquery = relations.where("date BETWEEN '#{format_date(params[:begin_date])}' AND '#{format_date(params[:end_date])}'").to_sql
other_total_subquery = relations.where("date BETWEEN '#{format_date(params[:other_begin_date])}' AND '#{format_date(params[:other_end_date])}'").to_sql
"schools.id school_id, schools.name school_name, (#{total_subquery}) AS total, (#{other_total_subquery}) AS other_total"
end
end
def query_report_sql(from_sql)
order_by = "(total = 0 AND other_total != 0) #{sort_direction}, (percentage != 0) #{sort_direction}, percentage #{sort_direction}"
"SELECT reports.*, (other_total - total) increase, (IF(other_total - total = 0, 0.0, round((other_total - total) / IF(total = 0, 1, total), 5))) percentage "\
"FROM (#{from_sql}) reports ORDER BY percentage #{sort_direction} LIMIT #{PAGE_SIZE} OFFSET #{offset}"
"FROM (#{from_sql}) reports ORDER BY #{order_by} LIMIT #{PAGE_SIZE} OFFSET #{offset}"
end
end

@ -6,7 +6,8 @@ class Management::SchoolDataGrowService
attr_reader :params
sort_columns :teacher_increase_count, :student_increase_count,
:course_increase_count, :shixun_increase_count, :active_user_count,
:course_increase_count, :shixun_increase_count, :uniq_active_user_count,
:shixun_homework_count, :shixun_evaluate_count,
default_by: :teacher_increase_count, default_direction: :desc
def initialize(params)
@ -14,18 +15,25 @@ class Management::SchoolDataGrowService
end
def call
reports = query_reports.group('schools.id')
reports = School.where(nil)
count = reports.count.count
reports = search_filter(reports)
count = reports.count
subquery = SchoolDailyActiveUser.select('COUNT(distinct(user_id))').joins(:school_daily_report)
.where(date_condition_sql).where("school_id is not null and school_id = schools.id").to_sql
reports = reports.joins("LEFT JOIN school_daily_reports sdr ON sdr.school_id = schools.id AND #{date_condition_sql}")
reports = reports.select(
'schools.id school_id, schools.name school_name,'\
'SUM(teacher_increase_count) teacher_increase_count,'\
'SUM(student_increase_count) student_increase_count,'\
'SUM(course_increase_count) course_increase_count,'\
'SUM(shixun_increase_count) shixun_increase_count,'\
'SUM(active_user_count) active_user_count'
)
'SUM(shixun_homework_count) shixun_homework_count,'\
'SUM(shixun_evaluate_count) shixun_evaluate_count,'\
"(#{subquery}) uniq_active_user_count,"\
'SUM(active_user_count) active_user_count').group('schools.id')
reports = custom_sort(reports, params[:sort_by], params[:sort_direction])
reports = reports.order('school_id asc').limit(PAGE_SIZE).offset(offset)
@ -35,33 +43,44 @@ class Management::SchoolDataGrowService
def grow_summary
@_grow_summary ||= begin
query_reports.select(
reports = School.joins("LEFT JOIN school_daily_reports sdr ON sdr.school_id = schools.id")
.where(date_condition_sql)
subquery = SchoolDailyActiveUser.select('COUNT(distinct user_id)')
.joins('LEFT JOIN school_daily_reports sdr ON sdr.id = school_daily_active_users.school_daily_report_id')
.where(date_condition_sql).to_sql
reports = search_filter(reports)
reports.select(
'SUM(teacher_increase_count) teacher_increase_count,'\
'SUM(student_increase_count) student_increase_count,'\
'SUM(course_increase_count) course_increase_count,'\
'SUM(shixun_increase_count) shixun_increase_count,'\
'SUM(shixun_homework_count) shixun_homework_count,'\
'SUM(shixun_evaluate_count) shixun_evaluate_count,'\
"(#{subquery}) uniq_active_user_count,"\
'SUM(active_user_count) active_user_count'
).first
end
end
private
def query_reports
date = query_date
date_condition = if date.is_a?(Range)
"sdr.date BETWEEN '#{date.min.strftime('%Y-%m-%d')}' AND '#{date.max.strftime('%Y-%m-%d')}'"
else
"sdr.date = '#{date.strftime('%Y-%m-%d')}'"
end
reports = School.joins("LEFT JOIN school_daily_reports sdr ON sdr.school_id = schools.id AND #{date_condition}")
def search_filter(relations)
keyword = params[:keyword].try(:to_s).try(:strip)
if keyword.present?
reports = reports.where("schools.name LIKE :keyword OR schools.id LIKE :keyword", keyword: "%#{keyword}%")
relations = relations.where("schools.name LIKE :keyword OR schools.id LIKE :keyword", keyword: "%#{keyword}%")
end
reports
relations
end
def date_condition_sql
date = query_date
if date.is_a?(Range)
"date BETWEEN '#{date.min.strftime('%Y-%m-%d')}' AND '#{date.max.strftime('%Y-%m-%d')}'"
else
"date = '#{date.strftime('%Y-%m-%d')}'"
end
end
def query_date
@ -86,3 +105,4 @@ class Management::SchoolDataGrowService
(params[:page].to_i.zero? ? 0 : params[:page].to_i - 1) * PAGE_SIZE
end
end
# SELECT SUM(teacher_increase_count) teacher_increase_count,SUM(student_increase_count) student_increase_count,SUM(course_increase_count) course_increase_count,SUM(shixun_increase_count) shixun_increase_count,SUM(shixun_homework_count) shixun_homework_count,SUM(shixun_evaluate_count) shixun_evaluate_count,(select count(distinct user_id) from school_daily_active_users sdau left join school_daily_reports sdr on sdr.id = sdau.school_daily_report_id where date BETWEEN '2019-06-02' AND '2019-06-03') uniq_active_user_count,SUM(active_user_count) active_user_count FROM `schools` LEFT JOIN school_daily_reports sdr ON sdr.school_id = schools.id where date BETWEEN '2019-06-02' AND '2019-06-03' LIMIT 1

@ -4,7 +4,7 @@ class Management::SchoolReportService
attr_reader :params
sort_columns :student_count, :teacher_count, :homework_count, :other_homework_count,
:course_count, :active_course_count, :nearly_course_time,
:course_count, :active_course_count, :nearly_course_time, :shixun_count, :shixun_evaluate_count,
default_by: :teacher_count, default_direction: :desc
def initialize(params)
@ -47,6 +47,12 @@ class Management::SchoolReportService
nearly_course_time_map = courses.joins(:course_activities).maximum('course_activities.updated_at')
active_course_map = courses.where(is_end: false).count
shixun_map = Shixun.joins(creator: :user_extensions).where(user_extensions: { identity: User::TEACHER, school_id: ids })
.where(fork_from: nil).group('school_id').count
reports = SchoolReport.where(school_id: ids)
evaluate_count_map = reports.each_with_object({}) { |report, obj| obj[report.school_id] = report.shixun_evaluate_count }
schools.map do |school|
{
id: school.id,
@ -58,6 +64,8 @@ class Management::SchoolReportService
course_count: course_map[school.id],
nearly_course_time: nearly_course_time_map[school.id],
active_course_count: active_course_map[school.id],
shixun_count: shixun_map.fetch(school.id, 0),
shixun_evaluate_count: evaluate_count_map.fetch(school.id, 0)
}
end
end
@ -68,16 +76,30 @@ class Management::SchoolReportService
case sort_by_column.to_s
when 'teacher_count' then
schools.joins(:teacher_extensions).select("#{base_query_column}, COUNT(*) teacher_count")
schools.joins('LEFT JOIN user_extensions ue ON ue.school_id = schools.id AND ue.identity = 0')
.select("#{base_query_column}, COUNT(*) teacher_count")
when 'student_count' then
schools.joins(:student_extensions).select("#{base_query_column}, COUNT(*) student_count")
schools.joins('LEFT JOIN user_extensions ue ON ue.school_id = schools.id AND ue.identity = 1')
.select("#{base_query_column}, COUNT(*) student_count")
when 'homework_count' then
schools.joins(courses: :shixun_homework_commons).select("#{base_query_column}, COUNT(*) homework_count")
schools.joins('LEFT JOIN courses ON courses.school_id = schools.id')
.joins('LEFT JOIN homework_commons hc ON hc.course_id = courses.id AND hc.homework_type = 4')
.select("#{base_query_column}, COUNT(*) homework_count")
when 'other_homework_count' then
schools.joins(courses: :other_homework_commons).select("#{base_query_column}, COUNT(*) other_homework_count")
schools.joins('LEFT JOIN courses ON courses.school_id = schools.id')
.joins('LEFT JOIN homework_commons hc ON hc.course_id = courses.id AND hc.homework_type IN (1, 3)')
.select("#{base_query_column}, COUNT(*) other_homework_count")
when 'course_count' then
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0')
.select("#{base_query_column}, COUNT(*) course_count")
when 'shixun_count' then
schools.joins('LEFT JOIN user_extensions ue ON ue.school_id = schools.id AND ue.identity = 0')
.joins('LEFT JOIN users ON users.id = ue.user_id')
.joins('LEFT JOIN shixuns sx ON sx.user_id = users.id AND sx.fork_from IS NULL')
.select("#{base_query_column}, COUNT(*) shixun_count")
when 'shixun_evaluate_count' then
schools.joins('LEFT JOIN school_reports ON school_reports.school_id = schools.id')
.select("#{base_query_column}, shixun_evaluate_count")
when 'nearly_course_time' then
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0')
.joins('LEFT JOIN course_activities acs ON acs.course_id = cs.id')
@ -86,7 +108,8 @@ class Management::SchoolReportService
schools.joins('LEFT JOIN courses cs ON cs.school_id = schools.id AND cs.is_delete = 0 AND cs.is_end = false')
.select("#{base_query_column}, COUNT(*) active_course_count")
else
schools.joins(:teacher_extensions).select("#{base_query_column}, COUNT(*) teacher_count")
schools.joins('LEFT JOIN user_extensions ue ON ue.school_id = schools.id AND ue.identity = 0')
.select("#{base_query_column}, COUNT(*) teacher_count")
end
end

@ -69,8 +69,17 @@ class ShixunsService
dis = Shixun.select([:id, :user_id]).find(dis_id)
dis_type = params[:container_type] # 如:"Shixun"
# 总数,分页使用
disscuss_count = Discuss.where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).count
discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).includes(:user, :praise_tread).offset(offset)
if current_user.admin?
disscuss_count = Discuss.where(:dis_id => dis_id, :dis_type => dis_type, :root_id => nil).count
discusses = Discuss.limit(LIMIT).where(:dis_id => dis_id, :dis_type => dis_type,
:root_id => nil).includes(:user, :praise_tread).offset(offset)
else
disscusses = Discuss.where("dis_id = :dis_id and dis_type = :dis_type and root_id is null and
(hidden = :hidden or user_id = :user_id)",
{dis_id: dis_id, dis_type: dis_type, hidden: false, user_id: current_user.id})
disscuss_count = disscusses.count
discusses = disscusses.limit(LIMIT).includes(:user, :praise_tread).offset(offset)
end
base_data discusses, dis, current_user
return {:children_list => @children_list, :disscuss_count => disscuss_count}
@ -142,7 +151,13 @@ class ShixunsService
:user_praise => user_praise, :admin => current_user.admin?}
# 现在没有二级回复所以查询的时候直接从root_id取
children = Discuss.where(:root_id => d.id).includes(:user).reorder("created_at asc")
children =
if current_user.admin?
Discuss.where(root_id: d.id).includes(:user).reorder("created_at asc")
else
Discuss.where("root_id = :root_id and (hidden = :hidden or user_id = :user_id)",
{root_id: d.id, hidden: false, user_id: current_user.id}).includes(:user).reorder("created_at asc")
end
@children_list << parents.merge({:children => (children.map{|child| [:content => child.content, :time => time_from_now(child.created_at), :position => child.position , :reward => child.reward,:hidden => child.hidden,
:image_url => url_to_avatar(child.user), :username => child.username, :user_id => child.user_id, :user_login => child.user.try(:login),

@ -52,7 +52,7 @@ module ZipService
members = exercise.course.members
exercise_users.each do |exercise_user|
member = members.where(:user_id => exercise_user.user_id).first
group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.name
group_name = member.try(:course_group_id).to_i == 0 ? '未分班' : member.course_group.try(:name)
export_file_name = "#{group_name}-#{exercise.course_id}-#{exercise.exercise_name}-#{exercise_user.user.user_extensions.student_id}-#{exercise_user.user.show_real_name}" + ".pdf"
out_file = export_user_exercise(exercise, exercise_user, export_file_name)
file_name = File::expand_path(out_file)

@ -9,24 +9,47 @@ class StatisticSchoolDailyReportTask
student_count = users.where(created_on: yesterday, user_extensions: { identity: User::STUDENT }).count
# 活跃用户
active_user_count = users.where(last_login_on: yesterday).count
active_user_ids = users.where(last_login_on: yesterday).pluck(:id)
active_user_count = active_user_ids.size
# 新增课堂
course_count = school.courses.where(created_at: yesterday).count
# 新增实训
shixun_count = Shixun.joins(creator: :user_extensions)
.where('user_extensions.school_id = ?', school.id)
.where(user_extensions: { identity: User::TEACHER, school_id: school.id })
.where(created_at: yesterday).count
# 新增实训作业数
shixun_homework_count = HomeworkCommon.joins(:course).where(courses: { school_id: school.id })
.where(homework_type: 4, created_at: yesterday).count
# 新增实训评测数量
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 = 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).reorder(nil).count
# 无有效数据时不记录
next if [teacher_count, student_count, course_count, shixun_count, active_user_count].all?(&:zero?)
data = [teacher_count, student_count, course_count, shixun_count, active_user_count,
shixun_homework_count, shixun_evaluate_count]
next if data.all?(&:zero?)
create_params = {
school_id: school.id, school_name: school.name, teacher_increase_count: teacher_count,
student_increase_count: student_count, course_increase_count: course_count,
shixun_homework_count: shixun_homework_count, shixun_evaluate_count: shixun_evaluate_count,
shixun_increase_count: shixun_count, active_user_count: active_user_count, date: current_date
}
SchoolDailyReport.create!(create_params)
report = SchoolDailyReport.create!(create_params)
if active_user_ids.present?
values = '(' + active_user_ids.join(", #{report.id}),(") + ", #{report.id})"
user_sql = "INSERT INTO school_daily_active_users(user_id, school_daily_report_id) VALUES#{values}"
SchoolDailyActiveUser.connection.execute(user_sql)
end
end
end

@ -0,0 +1,20 @@
class StatisticSchoolReportTask
def call
School.find_each do |school|
evaluate_count = Game.joins(:challenge)
.joins('LEFT JOIN members ON members.user_id = games.user_id')
.joins('LEFT JOIN homework_commons_shixuns hcs ON hcs.shixun_id = challenges.shixun_id')
.joins('LEFT JOIN homework_commons hc ON hcs.homework_common_id = hc.id AND hc.homework_type = 4')
.joins('LEFT JOIN courses ON hc.course_id = courses.id AND members.course_id = courses.id')
.where(courses: { school_id: school.id })
.sum(:evaluate_count)
report = SchoolReport.find_or_initialize_by_school_id(school.id)
report.school_name = school.name
report.shixun_evaluate_count = evaluate_count
report.save
end
end
end

@ -19,7 +19,7 @@
<span><%= @courses_count %></span>
</li>
<li>
<span>发布实训</span>
<span>共建实训</span>
<span><%= @shixuns_count %></span>
</li>
</ul>
@ -32,7 +32,7 @@
<li>教师</li>
<li>学生</li>
<li>课堂</li>
<li>实训</li>
<li>共建实训</li>
<li>实训报告</li>
<li>学员实战时间</li>
<!-- <li>云主机</li>-->

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.c233538b.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.6f8a3c95.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"><meta name="theme-color" content="#000000"><meta name="renderer" content="webkit"/><meta name="force-rendering" content="webkit"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><link rel="manifest" href="/manifest.json"><link rel="shortcut icon" href="/favicon.ico"><title>Educoder</title><script type="text/javascript">window.__isR=!0</script><link rel="stylesheet" href="/react/build/css/css_min_all.css"><link rel="stylesheet" href="/assets/iconfont/iconfont.css"><link href="/react/build/./static/css/main.e1b0d6a5.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="md_div" style="display:none"></div><div id="root" class="page -layout-v -fit"></div><div id="picture_display" style="display:none"></div><script type="text/javascript" src="/react/build/js/js_min_all.js"></script><script type="text/javascript" src="/assets/kindeditor/kindeditor.js"></script><script type="text/javascript" src="/react/build/js/create_kindeditor.js"></script><script type="text/javascript" src="/javascripts/educoder/edu_application.js"></script><script type="text/javascript" src="/react/build/./static/js/main.85df3a28.js"></script></body></html>

@ -49,7 +49,7 @@
<!--</span>-->
</span>
<span class="column-2 fr edu-txt-center">
<% if @major_manager && !@major_school.template_major || User.current.admin? %>
<% if @major_manager && !@major_school.template_major || User.current.admin? || User.current.business? %>
<a href="javascript:void(0);" onclick="delete_confirm_box_3('<%= ec_major_school_ec_year_path(year, :ec_major_school_id => @major_school) %>','您确定要删除吗?')" class="mr15 color-grey-c">删除</a>
<% end %>
<%#= link_to '删除', ec_major_school_ec_year_path(year, :ec_major_school_id => @major_school), method: :delete, :class => "mr15 color-grey-c", data: { confirm: '您确定要删除吗' } %>

@ -8,7 +8,7 @@
<li class="fl">
<p class="font-18 clearfix">
<span class="fl"><%= @major.name %></span>
<% if @major.schools && User.current.admin? %>
<% if @major.schools && (User.current.admin? || User.current.business?) %>
<i class="iconfont icon-youjiantou font-14 newxiajiantou fl ml20" ></i>
<ul class="edu-menu-list" id="ecmajorschools">
<% @major.schools.each do |school| %>

@ -17,7 +17,7 @@
<ul>
<% @ec_courses.each_with_index do |course, index| %>
<% course_manager = course.ec_course_users.pluck(:user_id).include?(User.current.id) %>
<% btn_text = ((@ec_major_school.template_major && User.current.admin?) || (!@ec_major_school.template_major && @template_major) || course_manager) ? "立即配置" : "查看" %>
<% btn_text = ((@ec_major_school.template_major && (User.current.admin? || User.current.business?)) || (!@ec_major_school.template_major && @template_major) || course_manager) ? "立即配置" : "查看" %>
<li class="clearfix">
<span class="column-No"><%= index + 1 %></span>
<span class="column-9"><%= course.name %></span>

@ -1,7 +1,10 @@
<%= form_for("",:url => update_exercise_question_exercise_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%>
<div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 fillin_Temp" id="poll_answers_<%= exercise_question.id %>">
<p class="fl mt15 font-16 mb10">实训题</p>
<p class="clearfix mb10" style="margin-left: 78px;"><%= exercise_question.shixun.name %></p>
<p class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">标题</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" maxlength="100" name='shixun_name' id="poll_questions_name_<%=exercise_question.id %>" placeholder="请输入实训标题"><%= exercise_question.shixun_name %></textarea>
</p>
<li class="clearfix pr mb20">
<input name="question_type" value="5" type="hidden">
<label class="panel-form-label fl"><span class="mr10">要求</span></label>

@ -106,11 +106,15 @@
//修改标题时确定按钮
function edit_poll_question(doc,id,quest_type)
{
var name = $.trim($("#poll_questions_name_" + id).val());
var title = $.trim($("#poll_questions_title_" + id).val());
var score = $.trim($("#poll_question_score_"+ id).val());
var standard_ans = $.trim($("#exercise_choice_" + id).val());
if(name===""){
notice_box("题目标题不能为空");
}
if(title.length == 0 || score.length == 0){
notice_box("题目标题/分数不能为空");
notice_box("要求/分数不能为空");
}else if(!/^[1-9][0-9]*$/.test(score)) {
notice_box("分数必须是非零开头的数字");
}else if(quest_type !=3 && quest_type !=4 && standard_ans.length == 0) {

@ -162,7 +162,7 @@
<% end %>
</div>
<% if exercise_question.question_type == 5 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<% end %>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %>

@ -140,7 +140,7 @@
<% end %>
</div>
<% if exercise_question.question_type == 5 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<% end %>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %>

@ -8,7 +8,10 @@
<input name="question_type" value="5" type="hidden">
<input name="shixun" value="<%= @shixun.id %>" type="hidden">
<input name="quest_id" id="quest_id" value="0" type="hidden">
<p class="clearfix mb10" style="margin-left: 78px;"><%= @shixun.name %></p>
<p class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">标题</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" maxlength="100" name='shixun_name' id="poll_questions_name" placeholder="请输入实训标题"><%= @shixun.name %></textarea>
</p>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">要求</span></label>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>

@ -20,7 +20,11 @@
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="clearfix">
<input class="magic-radio fl mt5 magic-checkbox_show" id="sx_<%= exercise_choice.id %>" name="<%= exercise_question %>" value="<%= exercise_choice.choice_text%>" type="radio">
<label class="fl color-grey3" for="sx_<%= exercise_choice.id %>"><%= convert_to_char((index+1).to_s)%>&nbsp;&nbsp;<%= exercise_choice.choice_text%></label>
<label class="fl color-grey3" for="sx_<%= exercise_choice.id %>">
<div class="fl">
<%= convert_to_char((index+1).to_s)%>
</div><pre class="fl ml10"><%= exercise_choice.choice_text%></pre>
</label>
</li>
<% end %>
</div>

@ -20,7 +20,11 @@
<% exercise_question.exercise_choices.reorder("choice_position").each_with_index do |exercise_choice,index| %>
<li class="clearfix">
<input class="magic-checkbox fl mt5 magic-checkbox_show" id="dx_<%= exercise_choice.id %>" value="<%= exercise_choice.choice_text%>" type="checkbox">
<label class="fl color-grey3" for="dx_<%= exercise_choice.id %>"><%= convert_to_char((index+1).to_s)%>&nbsp;&nbsp;<%= exercise_choice.choice_text%></label>
<label class="fl color-grey3" for="dx_<%= exercise_choice.id %>">
<div class="fl">
<%= convert_to_char((index+1).to_s)%>
</div><pre class="fl ml10"><%= exercise_choice.choice_text%></pre>
</label>
</li>
<% end %>
</div>

@ -16,7 +16,7 @@
</p>
<% end %>
</div>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 pt10 pb10 bor-top-greyE">
<% exercise_question.exercise_shixun_challenges.each_with_index do |exercise_challenge,index| %>

@ -256,7 +256,7 @@
<% end %>
</div>
<% if exercise_question.question_type == 5 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<% end %>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word">
<%= exercise_question.question_title.html_safe %>

@ -1,7 +1,10 @@
<%= form_for("",:url => update_exercise_question_exercise_bank_index_path(:exercise_question => exercise_question.id),:html => {:id => "update_exercise_question_#{exercise_question.id}"}) do |f|%>
<div class="user_bg_shadow bor-grey-e pl15 pr30 mb20 fillin_Temp" id="poll_answers_<%= exercise_question.id %>">
<p class="fl mt15 font-16 mb10">实训题</p>
<p class="clearfix mb10" style="margin-left: 78px;"><%= exercise_question.shixun.name %></p>
<p class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">标题</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" maxlength="100" name='shixun_name' id="poll_questions_name_<%=exercise_question.id %>" placeholder="请输入实训标题"><%= exercise_question.shixun_name %></textarea>
</p>
<li class="clearfix pr mb20">
<input name="question_type" value="5" type="hidden">
<label class="panel-form-label fl"><span class="mr10">要求</span></label>

@ -8,7 +8,10 @@
<input name="question_type" value="5" type="hidden">
<input name="shixun" value="<%= @shixun.id %>" type="hidden">
<input name="quest_id" id="quest_id" value="0" type="hidden">
<p class="clearfix mb10" style="margin-left: 78px;"><%= @shixun.name %></p>
<p class="clearfix mb10">
<label class="panel-form-label fl"><span class="mr10">标题</span></label>
<textarea class="panel-form-width2-690 fl panel-box-sizing" maxlength="100" name='shixun_name' id="poll_questions_name" placeholder="请输入实训标题"><%= @shixun.name %></textarea>
</p>
<li class="clearfix pr mb20">
<label class="panel-form-label fl"><span class="mr10">要求</span></label>
<textarea id="poll_questions_title" name="question_title" class="panel-form-width2-690 fl panel-box-sizing undis"></textarea>

@ -14,7 +14,7 @@
<a href="javascript:void(0)" onclick="exQuestionEdit(<%= exercise_question.id%>, <%= exercise_question.question_type %>);"><i data-tip-down="编辑" class="fa fa-pencil color-orange05"></i></a>
</p>
</div>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<div class="pl15 pr15 pt10 pb10 bor-top-greyE">
<% exercise_question.exercise_bank_shixun_challenges.each_with_index do |exercise_challenge,index| %>

@ -80,7 +80,7 @@
<% end %>
</div>
<% if exercise_question.question_type == 5 %>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun.name %></p>
<p class="pl15 pr15 mb10"><%= exercise_question.shixun_name %></p>
<% end %>
<div class="pl15 pr15 justify upload_img table_maxWidth break_word"><%= exercise_question.question_title.html_safe %></div>
<% case exercise_question.question_type %>

@ -32,3 +32,16 @@
</div>
</div>
</div>
<script>
function search_hw_course(url){
$.ajax({
url: url,
type: 'post',
data: {search: $("#hb_search_course_input").val(), is_observe: true},
success: function(data){
}
});
}
</script>

@ -11,7 +11,8 @@
<div class="fl task-form-100 clearfix" style="box-sizing: border-box; padding-left: 15px;">
<span class="fl mr10 mt3 color-grey3"># <%= get_hw_index(homework_common, @is_teacher, @homework_type) + 1 %></span>
<% homework_curr_status = homework_curr_time(homework_common) %>
<%= link_to homework_common.name.to_s, student_work_index_path(:homework => homework_common.id,:host=> Setting.host_course), :class => "edu-class-inner-list fl color-grey-3"%>
<%= link_to homework_common.name.to_s, student_work_index_path(:homework => homework_common.id,:host=> Setting.host_course),
:id => "homework_name_#{homework_common.id}", :class => "edu-class-inner-list fl color-grey-3"%>
<% unless homework_common.is_public %>
<i id="homework_public_<%= homework_common.id %>" class="fa fa-lock color-grey-c fl mt8 ml15 font-18"></i>
<% end %>
@ -144,6 +145,9 @@
<li>
<%= link_to "设置", student_work_index_path(:homework => homework_common.id, :tab => 4) %>
</li>
<li>
<%= link_to "重命名", rename_modal_homework_common_path(homework_common), :remote => true %>
</li>
<% if homework_common.homework_detail_manual.try(:comment_status) == 0 %>
<li>
<%= link_to '立即发布', publish_notice_homework_common_path(homework_common), :remote => true %>

@ -0,0 +1,30 @@
<div class="task-popup" style="width:460px;">
<div class=" task-popup-title clearfix task-popup-bggrey">
重命名
</div>
<div class="task_popup_con">
<%= form_for "", :url => rename_homework_homework_common_path(@homework), :remote => true, :html => {:id => "rename_shixun_homework_form"} do |f| %>
<div class="df pl20 pr20 mb20 mt10">
<span class="fl pt3">作业名称:</span>
<div class="flex1">
<input type="text" class="input-100-35 greyInput" maxlength="20" value="<%= @homework.name %>" name="name" id="rename_homework_name" placeholder="请输入作业名称"/>
<p class="lineh-20" style="height: 20px;"><span class="color-orange-tip none" id="printNotice">请输入作业名称</span></p>
</div>
</div>
<% end %>
<li class="clearfix mt10 edu-txt-center">
<a href="javascript:void(0);" class="task-btn mr20" onclick="hideModal()">取消</a>
<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="surePutIn();">确定</a>
</li>
</div>
</div>
<script>
function surePutIn(){
if($("#rename_homework_name").val() == "") {
$("#printNotice").removeClass("none");
} else {
$("#rename_shixun_homework_form").submit();
hideModal();
}
}
</script>

@ -0,0 +1,5 @@
<% if @notice %>
notice_box("作业名称不能为空");
<% else %>
$("#homework_name_<%= @homework.id %>").html(<%= @homework.name %>);
<% end %>

@ -0,0 +1,2 @@
var html = '<%= escape_javascript(render :partial => "homework_common/rename_shixun_homework") %>';
pop_box_new(html, 460, 227);

@ -9,7 +9,13 @@
<%= favicon %>
<%= javascript_heads %>
<%= heads_for_theme %>
<%= javascript_include_tag 'educoder/edu_application', 'educoder/edu_shixun','educoder/edu_shixunCommentsStar','educoder/jquery.raty' %>
<%= stylesheet_link_tag "/assets/codemirror/codemirror" %>
<%= stylesheet_link_tag '/editormd/css/editormd.min.css' %>
<!-- TODO md找替代方案 -->
<%= javascript_include_tag '/editormd/lib/marked.min.js', '/editormd/lib/prettify.min.js', '/editormd/lib/raphael.min.js', '/editormd/lib/underscore.min.js', '/editormd/lib/sequence-diagram.min.js',
'/editormd/lib/flowchart.min.js', '/editormd/lib/jquery.flowchart.min.js', '/editormd/editormd.js' %>
<%= javascript_include_tag 'educoder/edu_application', 'educoder/edu_shixun','educoder/edu_shixunCommentsStar','educoder/jquery.raty'%>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/edu-popup','css/edu-common','educoder/edu-main','educoder/edu-all', "css/edu-public", 'css/ketang', 'css/common', 'css/taskstyle', 'css/structure','scm','css/public', 'css/project','css/popup','repository','css/gantt', 'css/calendar', 'css/moduel', 'css/font-awesome', 'css/edu-tooltipster', 'educoder/magic-check','/assets/iconfont/iconfont.css' %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->

@ -24,7 +24,8 @@
<%= javascript_include_tag '/editormd/lib/marked.min.js', '/editormd/lib/prettify.min.js', '/editormd/lib/raphael.min.js', '/editormd/lib/underscore.min.js', '/editormd/lib/sequence-diagram.min.js',
'/editormd/lib/flowchart.min.js', '/editormd/lib/jquery.flowchart.min.js', '/editormd/editormd.js' %>
<%= yield :header_tags -%>
<% Rails.logger.info("########----current_user: #{User.current.id}") %>
<% Rails.logger.info("########----session: #{session[:user_id]}") %>
<script type="text/javascript"
src="/javascripts/MathJax/MathJax.js?config=TeX-AMS-MML_HTMLorMML">
</script>

@ -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>

@ -14,6 +14,7 @@
</div>
<select class="task-form-15 task-height-30 fl" style="margin:0px 0px 0px 25px;width: 11%" name="keyword" id="condition_status">
<option value="c_name">课堂名称搜索</option>
<option value="u_name">创建者姓名搜索</option>
<option value="dep_name">创建者单位搜索</option>
</select>

@ -1,54 +1,30 @@
<% if false %>
<style>
.manage_ol ol li{list-style-type: disc;}
</style>
<div class="task-popup" style="width:400px;">
<div class=" task-popup-title clearfix task-popup-bggrey">
<h3 class="fl ">耗时详情</h3>
<a href="javascript:void(0)" id="closeIcon" style="top: -48px;right: -20px;z-index: 100000;"><i class="iconfont icon-shanchudiao"></i></a>
</div>
<div class="task_popup_con manage_ol">
<ol class="pl30">
<li>总耗时:<%= @consume_time %></li>
<li>作品更新:<%= @student_work %></li>
<li>文件更新:<%= @file_update %></li>
<li>中间层总耗时:<%= @brige %></li>
<li class="ml15">pull代码<%= @git_pull %></li>
<li class="ml15">pod启动<%= @create_pod %></li>
<li class="ml15">pod执行<%= @pod_execute %></li>
<li>中间层回传:<%= @return_back %>--中间层出结果传Educoder</li>
<li>前端轮询:<%= @front_js %>--局部数据查询Js轮询</li>
<li>回调结果存储:<%= @test_cases %></li>
</ol>
</div>
</div>
<% end %>
<% if @recodes.present? %>
<div class="edu-con-bg01 mt15" id="evaluate_records_list">
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0" style="table-layout: fixed">
<thead>
<tr>
<th width="5%">序号</th>
<th width="10%">总耗时<i class="fa fa-long-arrow-down color-light-green ml5" ></i></th>
<th width="5%">ID</th>
<th width="5%">总耗时<i class="fa fa-long-arrow-down color-light-green ml5" ></i></th>
<th width="5%">作品更新</th>
<th width="5%">文件更新</th>
<th width="10%">中间层总耗时</th>
<th width="5%">pull代码</th>
<th width="5%">pod启动</th>
<th width="5%">pod执行</th>
<th width="10%">中间层回传</th>
<th width="5%">回传时间</th>
<th width="5%">前端轮询</th>
<th width="10%">回调结果存储</th>
<th width="15%">创建时间</th>
<th width="15%">实训名称</th>
<th width="5%">结果存储</th>
<th width="10%">创建时间</th>
<th width="5%">最大执行时间</th>
<th width="8%">唯一标识</th>
<th width="17%">实训名称</th>
</tr>
</thead>
<tbody>
<% @recodes.each_with_index do |record, index| %>
<% @recodes.each do |record| %>
<tr>
<td><%= index %></td>
<td><%= record.id %></td>
<td><%= record.consume_time %></td>
<td><%= record.student_work %></td>
<td><%= record.file_update %></td>
@ -60,6 +36,8 @@
<td><%= record.front_js %></td>
<td><%= record.test_cases %></td>
<td><%= format_time record.created_at %></td>
<td><%= record.shixun.try(:exec_time) %></td>
<td><%= record.shixun.try(:identifier) %></td>
<td><%= link_to record.shixun.try(:name), task_path(record.game), :target => "_blank", :title => "#{record.shixun.try(:name)}" %></td>
</tr>
<% end %>

@ -1,16 +1,18 @@
<div class="edu-back-white mt20 padding20">
<p class="clearfix"><span class="font-16 fl">毕业要求通用标准</span><span class="ml5 btn-cir btn-cir-grey mt6 fl" id="standard_count"><%= @standards.count %></span></p>
<p class="clearfix mb10"><a href="javascript:void(0)" class="fr white-btn edu-greenback-btn" id="addBtn" show="0" onclick="addStandardPanel(this);">+ 新增</a></p>
<div class="padding20 clearfix edu-back-greyf5 mb15 none" id="addStandardPanel">
<p class="clearfix df mb15">
<span class="fl color-red mt3">*</span><span class="mr15">1</span>
<textarea class="input-flex-30" name="content" placeholder=""></textarea>
</p>
<p class="edu-txt-right">
<a href="javascript:void(0);" class="task-btn mr20" onclick="cancelAdd();">取消</a>
<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="submit_data()">保存</a>
</p>
</div>
<% if User.current.admin? %>
<p class="clearfix mb10"><a href="javascript:void(0)" class="fr white-btn edu-greenback-btn" id="addBtn" show="0" onclick="addStandardPanel(this);">+ 新增</a></p>
<div class="padding20 clearfix edu-back-greyf5 mb15 none" id="addStandardPanel">
<p class="clearfix df mb15">
<span class="fl color-red mt3">*</span><span class="mr15">1</span>
<textarea class="input-flex-30" name="content" placeholder=""></textarea>
</p>
<p class="edu-txt-right">
<a href="javascript:void(0);" class="task-btn mr20" onclick="cancelAdd();">取消</a>
<a href="javascript:void(0);" class="task-btn task-btn-orange" onclick="submit_data()">保存</a>
</p>
</div>
<% end %>
<input type="hidden" name="standard_id" value="-1">
<div>
<table class="edu-pop-table interval-td interval-all edu-txt-left" cellpadding="0" cellspacing="0" style="border-bottom: none;">

@ -12,7 +12,7 @@
<div class="grow-date-container" style="width: 450px;display: <%= params[:data_type] == 'grow' ? 'block' : 'none' %>">
<%= text_field_tag :grow_date_input, params[:grow_date_input],
class: 'grow-date-input winput-220-30', placeholder: '请选择时间段',
class: 'grow-date-input winput-220-30', placeholder: '请选择时间段具体从当日5:00开始计算',
style: 'width: 400px;' %>
</div>
<div class="contrast-date-container" style="width: 450px;display: <%= params[:data_type] == 'contrast' ? 'block' : 'none' %>">
@ -26,13 +26,10 @@
<div style="float: left;">
<%= hidden_field_tag :data_type, params[:data_type] || 'grow' %>
<% if params[:data_type] == 'contrast' %>
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 contrast-btn task-btn-orange">时间对比</a>
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 grow-btn">新增数据</a>
<% else %>
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 contrast-btn">时间对比</a>
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 grow-btn task-btn-orange">新增数据</a>
<% end %>
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 contrast-btn <%= params[:data_type] == 'contrast' ? 'task-btn-orange' : '' %>"
data-tip-down="请在左侧分别选择需进行对比的两个时段,下表显示两时段选定指标两时段变化情况对比">时段对比</a>
<a href="javascript:void(0)" class="fl task-btn ml5 mt10 grow-btn <%= params[:data_type] == 'contrast' ? '' : 'task-btn-orange' %>"
data-tip-down="请在左侧选择时间段,下表显示选定时间段内各项指标数据变化情况">数据变化</a>
</div>
<%= text_field_tag :keyword, params[:keyword], placeholder: '请输入单位名称或者ID关键字进行搜索',

@ -21,8 +21,8 @@
<th width="6%">序号</th>
<th width="10%">ID</th>
<th width="20%" class="edu-txt-left">单位名称</th>
<th width="22%">时段一<br><%= "#{params[:begin_date]}至#{params[:end_date]}" %></th>
<th width="22%">时段二<br><%= "#{params[:other_begin_date]}至#{params[:other_end_date]}" %></th>
<th width="22%">时段一<br><%= "#{params[:begin_date]} 05:00至#{(Time.zone.parse(params[:end_date]) + 1.days).strftime('%Y-%m-%d')} 05:00" %></th>
<th width="22%">时段二<br><%= "#{params[:other_begin_date]} 05:00至#{(Time.zone.parse(params[:other_end_date]) + 1.days).strftime('%Y-%m-%d')} 05:00" %></th>
<th width="20%" colspan="2">
<%= sort_tag('变化情况', name: 'percentage', path: school_data_contrast_managements_path) %>
<br> 新 增 数 | 新增百分比)
@ -45,7 +45,11 @@
<td class="edu-txt-right pr20 right-border relative color-red">
+<%= increase %>
</td>
<td class="edu-txt-left pl20 color-red">+<%= percentage.round(5) %>%</td>
<% if report['total'].zero? %>
<td class="edu-txt-left pl20">-</td>
<% else %>
<td class="edu-txt-left pl20 color-red">+<%= percentage.round(5) %>%</td>
<% end %>
<% elsif increase.zero? %>
<td class="edu-txt-right pr20 right-border" style="position: relative;">
<%= increase %>

@ -1,7 +1,7 @@
<div style="background-color: #fafafa;">
统计总计:
<% if params[:grow_begin_date].present? %>
<%= params[:grow_date_input] %>
<%= params[:grow_begin_date] %> 05:00至<%= (Time.zone.parse(params[:grow_end_date]) + 1.days).strftime('%Y-%m-%d') %> 05:00
<% else %>
<%= (Time.current - 5.hour).beginning_of_day.ago(1.days).strftime('%Y-%m-%d') %> 05:00至
<%= (Time.current - 5.hour).beginning_of_day.strftime('%Y-%m-%d') %> 05:00
@ -10,7 +10,11 @@
新增学生<span class="color-red"><%= @grow_summary.student_increase_count || 0 %></span>人,
新增课堂<span class="color-red"><%= @grow_summary.course_increase_count || 0 %></span>个,
新增实训<span class="color-red"><%= @grow_summary.shixun_increase_count || 0 %></span>个,
活跃用户<span class="color-red"><%= @grow_summary.active_user_count || 0 %></span>个
新增实训作业<span class="color-red"><%= @grow_summary.shixun_homework_count || 0 %></span>个,
新增实训评测<span class="color-red"><%= @grow_summary.shixun_evaluate_count || 0 %></span>个,
活跃用户<span class="color-red">
<%= @grow_summary.uniq_active_user_count.to_i.zero? ? @grow_summary.active_user_count.to_i : @grow_summary.uniq_active_user_count.to_i %>
</span>个
</div>
<table class="edu-pop-table edu-txt-center" cellpadding="0" cellspacing="0" style="table-layout: fixed">
<thead>
@ -23,7 +27,9 @@
<th width="12%"><%= sort_tag('新增学生', name: 'student_increase_count', path: school_data_grow_managements_path) %></th>
<th width="12%"><%= sort_tag('新增课堂', name: 'course_increase_count', path: school_data_grow_managements_path) %></th>
<th width="12%"><%= sort_tag('新增实训', name: 'shixun_increase_count', path: school_data_grow_managements_path) %></th>
<th width="12%"><%= sort_tag('活跃用户', name: 'active_user_count', path: school_data_grow_managements_path) %></th>
<th width="12%"><%= sort_tag('新增实训作业', name: 'shixun_homework_count', path: school_data_grow_managements_path) %></th>
<th width="12%"><%= sort_tag('新增实训评测', name: 'shixun_evaluate_count', path: school_data_grow_managements_path) %></th>
<th width="12%"><%= sort_tag('活跃用户', name: 'uniq_active_user_count', path: school_data_grow_managements_path) %></th>
</tr>
</thead>
<tbody>
@ -36,7 +42,9 @@
<td><%= report.student_increase_count.to_i %></td>
<td><%= report.course_increase_count.to_i %></td>
<td><%= report.shixun_increase_count.to_i %></td>
<td><%= report.active_user_count.to_i %></td>
<td><%= report.shixun_homework_count.to_i %></td>
<td><%= report.shixun_evaluate_count.to_i %></td>
<td><%= report.uniq_active_user_count.to_i.zero? ? report.active_user_count.to_i : report.uniq_active_user_count.to_i %></td>
</tr>
<% end %>
</tbody>

@ -3,12 +3,17 @@
<tr>
<th width="6%">序号</th>
<th width="6%">ID</th>
<th width="14%" class="edu-txt-left">单位名称</th>
<th width="12%" class="edu-txt-left">单位名称</th>
<th width="10%"><%= sort_tag('教师总人数', name: 'teacher_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('学生总人数', name: 'student_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('课堂总数', name: 'course_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('正在进行课堂数', name: 'active_course_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('实训总数', name: 'shixun_count', path: school_report_managements_path) %></th>
<th width="12%">
<%= sort_tag('实训评测总数', name: 'shixun_evaluate_count', path: school_report_managements_path) %>
<i class="fa fa-question-circle" data-tip-down="数据更新时间为<br/>当日6点、12点、18点、24点"></i>
</th>
<th width="10%"><%= sort_tag('实训作业总数', name: 'homework_count', path: school_report_managements_path) %></th>
<th width="10%"><%= sort_tag('其它作业总数', name: 'other_homework_count', path: school_report_managements_path) %></th>
<th width="14%"><%= sort_tag('动态时间', name: 'nearly_course_time', path: school_report_managements_path) %></th>
@ -24,6 +29,8 @@
<td><%= school[:student_count].to_i %></td>
<td><%= school[:course_count].to_i %></td>
<td><%= school[:active_course_count].to_i %></td>
<td><%= school[:shixun_count].to_i %></td>
<td><%= school[:shixun_evaluate_count].to_i %></td>
<td><%= school[:homework_count].to_i %></td>
<td><%= school[:other_homework_count].to_i %></td>
<td><%= format_time school[:nearly_course_time] %></td>

@ -21,8 +21,10 @@
学生总人数<span class="color-red"><%= @student_total %></span>人,
课堂总数<span class="color-red"><%= @course_total %></span>个,
正在进行课堂总数<span class="color-red"><%= @active_course_total %></span>个,
实训总数<span class="color-red"><%= @shixun_total %></span>个,
实训评测总数<span class="color-red"><%= @shixun_evaluate_total %></span>个,
实训作业总数<span class="color-red"><%= @shixun_homework_total %></span>个,
其它作业总数<span class="color-red"><%= @other_homework_total %></span>个,
其它作业总数<span class="color-red"><%= @other_homework_total %></span>个
</div>
</div>

@ -1,11 +1,12 @@
wb = xlsx_package.workbook
wb.add_worksheet(name: '统计总表') do |sheet|
sheet.add_row %w(ID 单位名称 教师总人数 学生总人数 课堂总数 正在进行课堂数 实训作业总数 其它作业总数 动态时间)
sheet.add_row %w(ID 单位名称 教师总人数 学生总人数 课堂总数 正在进行课堂数 总实训数 实训评测总数 实训作业总数 其它作业总数 动态时间)
@schools.each do |school|
sheet.add_row([
school[:id].to_s, school[:name].to_s, (school[:teacher_count] || 0).to_s, (school[:student_count] || 0).to_s,
(school[:course_count] || 0).to_s, (school[:active_course_count] || 0).to_s, (school[:homework_count] || 0).to_s,
(school[:course_count] || 0).to_s, (school[:active_course_count] || 0).to_s,
(school[:shixun_count] || 0).to_s,(school[:shixun_evaluate_count] || 0).to_s, (school[:homework_count] || 0).to_s,
(school[:other_homework_count] || 0).to_s, format_time(school[:nearly_course_time])
])
end

@ -21,11 +21,11 @@
<span class="user_filtrate_span1">粉丝</span>
<span class="user_filtrate_span2 ml10"><%= @user_fanlist_count %></span>
</a>
<a href="<%= growth_record_user_path(@user, :tab => 3) %>" class="user_course_filtrate fl mt20 mr30 font-14" target="_blank">
<a href="<%= user_grade_user_path(@user) %>" class="user_course_filtrate fl mt20 mr30 font-14" target="_blank">
<span class="user_filtrate_span1">金币</span>
<span class="user_filtrate_span2 ml10"><%= @user.grade %></span>
</a>
<a href="<%= growth_record_user_path(@user, :tab => 2) %>" class="user_course_filtrate fl mt20 mr30 font-14" target="_blank">
<a href="<%= user_experience_user_path(@user) %>" class="user_course_filtrate fl mt20 mr30 font-14" target="_blank">
<span class="user_filtrate_span1">经验值</span>
<span class="user_filtrate_span2 ml10"><%= @user.experience %></span>
</a>

@ -19,20 +19,20 @@
<div class="fl with20 mr10">
<input type="text" name="department" class="fl task-form-100 task-height-40 panel-box-sizing" placeholder="子单位">
</div>
<select id="user_identity" name="identity" class="fl winput-240-40 mr10">
<select id="user_identity" name="identity" class="fl winput-120-40 mr10">
<option value="-1">请选择职业</option>
<option value="0">教师</option>
<option value="1">学生</option>
<option value="2">专业人士</option>
</select>
<select id="te_technical_title" name="te_technical_title" class="fl winput-240-40">
<select id="te_technical_title" name="te_technical_title" class="fl winput-200-40">
<option value="0">请选择职称</option>
<option value="教授">教授</option>
<option value="副教授">副教授</option>
<option value="讲师">讲师</option>
<option value="助教">助教</option>
</select>
<select id="pro_technical_title" name="pro_technical_title" class="fl winput-240-40 none">
<select id="pro_technical_title" name="pro_technical_title" class="fl winput-200-40 none">
<option value="0">请选择职称</option>
<option value="企业管理者">企业管理者</option>
<option value="部门管理者">部门管理者</option>
@ -41,6 +41,8 @@
<option value="助理工程师">助理工程师</option>
</select>
<%= select_tag :province, options_for_select(School.provinces.unshift(['请选择地区', ''])), class: 'fr winput-200-40'%>
<div class="cl mb15"></div>
<div class="edu-position edu-admin-select fl mr10" style="width:140px;">
<p>真实姓名搜索<i class="fa fa-caret-down ml10"></i></p>

@ -156,7 +156,7 @@
<label style="top:6px" class="color-grey-6" for="can_copy">勾选则允许认证教师复制该实训</label>
</li>
</div>
<% if Redmine::Configuration['gitlab_address'].include?("test") %>
<% if User.current.admin? %>
<div class="mb10 edu-back-white padding30-20">
<p class="color-grey-6 font-16 mb10">VNC图形化</p>
<li class="mb20">

@ -211,7 +211,7 @@
</span>
</div>
<% if Redmine::Configuration['gitlab_address'].include?("test") %>
<% if User.current.admin? %>
<div class="clearfix mt20">
<span class="color-grey-6 mt5 fl" style="min-width: 95px;">VNC图形化:</span>
<span class="fl">

@ -1,3 +1,4 @@
<div class="edu-back-white mb10">
<div class="pt30 pl20 pr20 pb40 bor-bottom-greyE clearfix">
<span class="fl font-16">配置</span>

@ -199,14 +199,11 @@
<a href="javascript:void(0);" id="status_no_limit" class="<%= @status.blank? ? 'check_on' : '' %> pl10 pr10">不限</a>
</span>
<input id="work_status_1" class="magic-checkbox fl" type="checkbox" value="0" name="status[]" <%= !@status.blank? && @status.include?('0') ? 'checked' : '' %>>
<label for="work_status_1" class="fl mr25">未提交(<%= @all_student_works.where(:work_status => 0).count %>
)</label>
<label for="work_status_1" class="fl mr25">未提交(<%= @all_student_works.where(:work_status => 0).count %>)</label>
<input id="work_status_2" class="magic-checkbox fl" type="checkbox" value="1" name="status[]" <%= !@status.blank? && @status.include?('1') ? 'checked' : '' %>>
<label for="work_status_2" class="fl mr25">按时提交(<%= student_works.where(:work_status => 1).count %>
)</label>
<label for="work_status_2" class="fl mr25">按时提交(<%= student_works.where(:work_status => 1).count %>)</label>
<input id="work_status_3" class="magic-checkbox fl" type="checkbox" value="2" name="status[]" <%= !@status.blank? && @status.include?('2') ? 'checked' : '' %>>
<label for="work_status_3" class="fl mr25">延时提交(<%= student_works.where(:work_status => 2).count %>
)</label>
<label for="work_status_3" class="fl mr25">延时提交(<%= student_works.where(:work_status => 2).count %>)</label>
</li>
<li class="clearfix">

@ -6,7 +6,7 @@
<% if params[:controller] != "welcome" && subject.status < 2 && !User.current.member_of_subject?(subject) %>
<div class="closeSquare">
<img src="/images/educoder/icon/lockclose.svg" class="mt80 mb25"/>
<p class="font-14 color-white">暂未开</p>
<p class="font-14 color-white">暂未开</p>
</div>
<% end %>
<a href="<%= subject_path(subject) %>" class="square-img" target="_blank"><%= image_tag(url_to_avatar(subject)) %></a>

@ -46,7 +46,7 @@
<p class="clearfix" id="billRemark">
<span class="grey fl">发票内容</span>
<input type="text" name="invoice_content" class="right_input"
value="<%= @training.training_payinfo.try(:invoice_content).presence || '研讨会' %>"/>
value="<%= @training.training_payinfo.try(:invoice_content).presence || '师资培训费' %>"/>
</p>
</div>
<div class="infoBar mb10">
@ -61,7 +61,7 @@
<span class="color-orange" id="percentPay">3人及以上8折优惠)</span>
<% end %>
</p>
<p class="break-word justify moneyDetail">含会议注册费、场地费、培训费、教材资料费、餐费、专家差费等</p>
<p class="break-word justify moneyDetail">含会议注册费、场地费、培训费、教材资料费、餐费、专家差费等</p>
<p class="clearfix">
<input type="hidden" name="enlistNum" value="<%= @training.training_payinfo.num || 1 %>"/>
<input type="hidden" name="enlistMoney" value="<%= @training.training_payinfo.fee || @training.registration_fee %>"/>
@ -143,10 +143,11 @@
// 2 支付宝支付
// 3 银行卡支付
// payType: <%#= @training.training_payinfo.pay_type.to_i %>,
newPayinfo: <%= @training.training_payinfo.new_record? %>,
payType: 3,
//发票抬头
//为空则代表不需要发票
invoiceTitle: '<%= @training.training_payinfo.invoice_title %>',
invoiceTitle: '<%= @training.training_payinfo.invoice_title || @training.school %>',
//税号
invoiceNo: '<%= @training.training_payinfo.invoice_no %>'
};
@ -172,9 +173,8 @@
//延迟支付,直接提交
$('#delayPayBtn').on('click', function () {
if($("#billDemand").attr("status")==2){
$(".billInput").val('');
}
if(!checkBillInfo()){ return }
alert("报名成功,请尽快支付");
$('form').submit();
});
@ -184,10 +184,8 @@
})
//立即支付
$('#payBtn').on('click', function () {
if(!checkBillInfo()){ return }
if($("#billDemand").attr("status")==2){
$(".billInput").val('');
}
var postData = $('form').serialize();
postData += '&js=true'
console.log(postData);
@ -236,15 +234,12 @@
//线下支付提交
$('#submitFormBtn').on('click', function () {
if($("#billDemand").attr("status")==2){
$(".billInput").val('');
}
if(!checkBillInfo()){ return }
$('form').submit();
});
$('#laterSubmitFormBtn').on('click', function () {
if($("#billDemand").attr("status")==2){
$(".billInput").val('');
}
if(!checkBillInfo()){ return }
$('#offline_later_pay').val('true');
$('form').submit();
});
@ -304,15 +299,17 @@
}
//页面加载时,初始化发票类型
function InitBill(userInfo){
var index=2;
$("#billDemand").html("不需要").attr("status",2);
if(userInfo.invoiceTitle != "" && userInfo.invoiceNo != ""){
index=0;
$("#billDemand").html("单位").attr("status",0);
}
if(userInfo.invoiceTitle != "" && userInfo.invoiceNo == ""){
var index=0;
$("#billDemand").html("单位").attr("status",0);
if (!userInfo.newPayinfo) {
if(userInfo.invoiceTitle == "" && userInfo.invoiceNo == ""){
index=2;
$("#billDemand").html("不需要").attr("status",2);
}
if(userInfo.invoiceTitle != "" && userInfo.invoiceNo == ""){
index=1;
$("#billDemand").html("个人").attr("status",1);
}
}
$(".billType li").removeClass("active");
$(".billType li").eq(index).addClass("active");
@ -379,36 +376,62 @@
var unit = $(".billUnit").val();
var tax = $(".taxNumber").val();
//只有选择了单位时才需要判断三个是否都已经填写
if (type == "单位" || type == "个人") {
if (unit == "") {
$(".billUnit").addClass("nullVal");
return;
} else {
$(".billUnit").removeClass("nullVal");
}
}
if (type == "单位") {
if (unit == "") {
$(".billUnit").addClass("nullVal");
return;
} else {
$(".billUnit").removeClass("nullVal");
}
if (tax == "") {
$(".taxNumber").addClass("nullVal");
return;
} else {
$(".taxNumber").removeClass("nullVal");
}
if (tax == "") {
$(".taxNumber").addClass("nullVal");
return;
} else {
$(".taxNumber").removeClass("nullVal");
}
}
//选择单位或者个人都要判断是否填写了发票内容
if (type == "单位" || type == "个人") {
var remark = $("input[name='invoice_content']").val();
if (remark == "") {
$("input[name='invoice_content']").addClass("nullVal");
return;
} else {
$("input[name='invoice_content']").removeClass("nullVal");
}
}
// if (type == "单位" || type == "个人") {
// var remark = $("input[name='invoice_content']").val();
// if (remark == "") {
// $("input[name='invoice_content']").addClass("nullVal");
// return;
// } else {
// $("input[name='invoice_content']").removeClass("nullVal");
// }
// }
$("#billDemand").html(type);
//记录选中的发票类型
$("#billDemand").attr("status",$(".billType li.active").index());
hideNav($(".billDownNav"));
}
function checkBillInfo() {
var bill = $("#billLine");
var billNav = $(".billDownNav");
var status = $("#billDemand").attr("status");
if(status == 2){
$(".billInput").val('');
}
var billUnit = $('.billUnit').val();
var taxNumber = $('.taxNumber').val();
if(status == 1 && billUnit == ''){
alert('请将发票信息填写完整');
showNav(bill, billNav, "down");
return false;
}
if(status == 0 && (billUnit == '' || taxNumber == '')){
alert('请将发票信息填写完整');
showNav(bill, billNav, "down");
return false;
}
return true;
}
function InitPhoto() {
var tmpl = '<li class="weui-uploader__file" style="background-image:url(#url#)"></li>',
$gallery = $("#gallery"), $galleryImg = $("#galleryImg"),

@ -28,7 +28,7 @@
<%= link_to '立即发布', publish_notice_exercise_path(activity), :remote => true %>
</li>
<% end %>
<% if (activity.exercise_status == 2 && activity.end_time > Time.now) || activity.exercise_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %>
<% if (activity.exercise_status == 2 && (activity.end_time.blank? || activity.end_time > Time.now)) || activity.exercise_group_settings.where("publish_time < '#{Time.now}' and end_time > '#{Time.now}'").count > 0 %>
<li>
<%= link_to '立即截止', end_notice_exercise_path(activity), :remote => true %>
</li>

@ -1,5 +1,5 @@
<% objects.each do |object| %>
<% allow_visit = object.is_public == 1 || User.current.admin? || User.current.member_of_course?(object) %>
<% allow_visit = object.is_public == 1 || User.current.admin? || 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>

@ -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>

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

Loading…
Cancel
Save