Merge remote-tracking branch 'origin/educoder' into educoder

dev_partners
杨树明 6 years ago
commit 3135f36cae

@ -3345,7 +3345,7 @@ end
end end
@users = User.where(:id => user_id).where("#{sql}").includes(:apply_actions, user_extensions: [:department, :school]).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(1000) #导出excel用户 @xls_users = @users.reorder("created_on desc").limit(3000) #导出excel用户
@page = (params['page'] || 1).to_i @page = (params['page'] || 1).to_i
@users_count = @users.count @users_count = @users.count
@limit = 20 @limit = 20
@ -4176,7 +4176,7 @@ end
sheet1 = book.create_worksheet :name => "course" sheet1 = book.create_worksheet :name => "course"
blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10 blue = Spreadsheet::Format.new :color => :blue, :weight => :bold, :size => 10
sheet1.row(0).default_format = blue sheet1.row(0).default_format = blue
sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间"]) sheet1.row(0).concat(["ID","课堂名称","成员","资源","普通作业"," 实训作业","试卷","私有","状态","创建者单位","创建者","动态时间","创建时间"])
count_row = 1 count_row = 1
courses.each do |course| courses.each do |course|
school = course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.school_name school = course.teacher.try(:user_extensions).try(:school).try(:name).blank? ? "--" : course.teacher.school_name
@ -4193,6 +4193,7 @@ end
sheet1[count_row,9] = school sheet1[count_row,9] = school
sheet1[count_row,10] = teacher_name sheet1[count_row,10] = teacher_name
sheet1[count_row,11] = format_time(course.updatetime) sheet1[count_row,11] = format_time(course.updatetime)
sheet1[count_row,12] = format_time(course.created_at)
count_row += 1 count_row += 1
end end
book.write xls_report book.write xls_report

@ -30,6 +30,17 @@ class WelcomeController < ApplicationController
require 'simple_xlsx_reader' require 'simple_xlsx_reader'
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) 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)
def local_init
LocalShixun.delete_all
LocalMirrorRepository.delete_all
LocalShixunTagRepertoire.delete_all
LocalChallenge.delete_all
LocalTestSet.delete_all
LocalChallengeTag.delete_all
render :json => {status: 0, message: "success"}
end
def shixun_to_local def shixun_to_local
identifiers = params[:identifiers].split(",") identifiers = params[:identifiers].split(",")
shixuns = Shixun.where(identifier: identifiers) shixuns = Shixun.where(identifier: identifiers)
@ -62,7 +73,7 @@ class WelcomeController < ApplicationController
if shixun.challenges.present? if shixun.challenges.present?
shixun.challenges.each do |challenge| shixun.challenges.each do |challenge|
new_challenge = LocalChallenge.new new_challenge = LocalChallenge.new
new_challenge.attributes = challenge.attributes.dup.except("id","shixun_id","user_id") new_challenge.attributes = challenge.attributes.dup.except("id","shixun_id","user_id", "test_set_score")
new_challenge.local_shixun_id = local_shixun.id new_challenge.local_shixun_id = local_shixun.id
new_challenge.save! new_challenge.save!
# 评测题,选择题暂时不考虑 # 评测题,选择题暂时不考虑
@ -98,6 +109,7 @@ class WelcomeController < ApplicationController
def local_to_shixun def local_to_shixun
ActiveRecord::Base.transaction do ActiveRecord::Base.transaction do
shixun_list = []
LocalShixun.find_each do |local_shixun| LocalShixun.find_each do |local_shixun|
identifier = generate_identifier identifier = generate_identifier
shixun = Shixun.create!(name: local_shixun.name, description: local_shixun.description, user_id: User.current.id, shixun = Shixun.create!(name: local_shixun.name, description: local_shixun.description, user_id: User.current.id,
@ -141,7 +153,7 @@ class WelcomeController < ApplicationController
if local_challenges.present? if local_challenges.present?
local_challenges.each do |local_challenge| local_challenges.each do |local_challenge|
new_challenge = Challenge.new new_challenge = Challenge.new
new_challenge.attributes = local_challenge.attributes.dup.except("id","local_shixun_id","user_id") new_challenge.attributes = local_challenge.attributes.dup.except("id","local_shixun_id","user_id", "test_set_score")
new_challenge.user_id = User.current.id new_challenge.user_id = User.current.id
new_challenge.shixun_id = shixun.id new_challenge.shixun_id = shixun.id
new_challenge.save! new_challenge.save!
@ -166,8 +178,9 @@ class WelcomeController < ApplicationController
end end
end end
end end
render :json => {status: 0, message: "success", identifier: shixun.identifier} shixun_list << shixun.identifier
end end
render :json => {status: 0, message: "success", identifier: shixun_list}
end end
end end

@ -283,6 +283,7 @@ RedmineApp::Application.routes.draw do ## oauth相关
get 'welcome/ccf' => 'welcome#ccf' get 'welcome/ccf' => 'welcome#ccf'
get 'welcome/shixun_to_local' => 'welcome#shixun_to_local' get 'welcome/shixun_to_local' => 'welcome#shixun_to_local'
get 'welcome/local_to_shixun' => 'welcome#local_to_shixun' get 'welcome/local_to_shixun' => 'welcome#local_to_shixun'
get 'welcome/local_init' => 'welcome#local_init'
# get 'competitions/home' => 'competitions#home' # get 'competitions/home' => 'competitions#home'
# get 'competitions/hn' => 'competitions#index' # get 'competitions/hn' => 'competitions#index'

@ -89,7 +89,7 @@ task :add_test_users => :environment do
(1..1000).each do |i| (1..1000).each do |i|
no = sprintf("%04d", i) no = sprintf("%04d", i)
phone = "1560731#{no}" phone = "5160731#{no}"
us = UsersService.new us = UsersService.new
user = us.register phone: phone, password: 'edu12345678' user = us.register phone: phone, password: 'edu12345678'
@ -109,7 +109,7 @@ task :add_test_users => :environment do
lastname: lastname, lastname: lastname,
nickname: '', nickname: '',
sex: 0, sex: 0,
mail: "educoder#{no}@qq.com", mail: "00educoder#{no}@qq.com",
identity: 1, identity: 1,
te_technical_title: 0, te_technical_title: 0,
pro_technical_title: 0, pro_technical_title: 0,

Loading…
Cancel
Save