Merge branches 'dev_aliyun' and 'dev_newysm' of https://bdgit.educoder.net/Hjqreturn/educoder into dev_newysm

chromesetting
杨树明 5 years ago
commit 9abde8b9bd

@ -22,7 +22,7 @@ class CommentsController < ApplicationController
@discuss = @hack.discusses.new(reply_params)
@discuss.hidden = false
@discuss.user_id = current_user.id
@discuss.root_id = params[:parent_id]
@discuss.root_id = params[:comments][:parent_id]
@discuss.save!
rescue Exception => e
uid_logger_error("reply discuss failed : #{e.message}")

@ -54,9 +54,14 @@ class Discuss < ApplicationRecord
def send_tiding
base_attrs = {
trigger_user_id: user_id, parent_container_id: challenge_id, parent_container_type: 'Challenge',
belong_container_id: dis_id, belong_container_type: 'Shixun', viewed: 0, tiding_type: 'Comment'
belong_container_id: dis_id, belong_container_type: dis_type, viewed: 0, tiding_type: 'Comment'
}
user_id = has_parent? ? parent.user_id : Challenge.find(challenge_id).user_id
user_id =
if dis_type == 'Shixun'
has_parent? ? parent.user_id : Challenge.find(challenge_id).user_id
elsif dis_type == 'Hack'
has_parent? ? parent.user_id : Hack.find(dis_id).user_id
end
tidings.create!(base_attrs.merge(user_id: user_id))
end
end

@ -1,3 +1,6 @@
json.author do
json.partial! 'users/user', user: discuss.user
end
json.id discuss.id
json.content content_safe(discuss.content)
json.time time_from_now(discuss.created_at)

@ -69,9 +69,11 @@ Rails.application.routes.draw do
delete :delete_set
end
resources :comments do
collection do
post :reply
end
end
end
resources :hack_user_lastest_codes, path: :myproblems, param: :identifier do
member do

@ -0,0 +1,8 @@
class ModifyTaskPassForChallenges < ActiveRecord::Migration[5.2]
def change
Challenge.find_each do |challenge|
task_pass = challenge.task_pass.gsub(" ", "").gsub("rac", '\frac')
challenge.update_attribute(:task_pass, task_pass)
end
end
end

@ -14,19 +14,19 @@ namespace :excellent_course_exercise do
course = Course.find_by(id: course_id)
course.exercises.each_with_index do |exercise, index|
# if exercise.exercise_users.where(commit_status: 1).count == 0
if exercise.exercise_users.where(commit_status: 1).count == 0
# 第一个试卷的参与人数和通过人数都是传的数据,后续的随机
if index == 0
members = course.students.order("id asc").limit(participant_count)
update_exercise_user(exercise, members, pass_count)
else
new_participant_count = rand((participant_count - 423)..participant_count)
new_pass_count = rand((new_participant_count - 113)..new_participant_count)
new_participant_count = rand((participant_count - 20)..participant_count)
new_pass_count = rand((new_participant_count - 30)..new_participant_count)
members = course.students.order("id asc").limit(new_participant_count)
update_exercise_user(exercise, members, new_pass_count)
end
# end
end
end
end
@ -36,14 +36,15 @@ namespace :excellent_course_exercise do
# index < pass_count 之前的学生都是通关的,之后的未通过
members.each_with_index do |member, index|
exercise_user = exercise.exercise_users.where(user_id: member.user_id).take
if exercise_question_ids.length == 20
question_length = exercise_question_ids.length
if question_length == 20
rand_num = index < pass_count - 1 ? rand(15..20) : rand(1..10)
elsif exercise_question_ids.length == 17
elsif question_length == 17
rand_num = index < pass_count - 1 ? rand(12..17) : rand(1..9)
elsif exercise_question_ids.length == 39
elsif question_length == 39
rand_num = index < pass_count - 1 ? rand(30..39) : rand(1..18)
else
rand_num = exercise_question_ids.length
rand_num = index < pass_count - 1 ? rand((question_length-3)..question_length) : rand(1..(question_length-8))
end
if exercise_user && exercise_user.commit_status == 0

@ -0,0 +1,32 @@
# 执行示例 RAILS_ENV=production bundle exec rake migrate_course_student:student args=3835,2526,21950,1000
# args 第一个课程 course_id第二个参数是学校school_id第三个参数是部门id第四个参数是迁移数量
#
desc "同步学校的学生"
namespace :migrate_course_student do
if ENV['args']
course_id = ENV['args'].split(",")[0] # 对应课堂的id
school_id = ENV['args'].split(",")[1] # 对应学校id
department_id = ENV['args'].split(",")[2] # 对应部门id
limit = ENV['args'].split(",")[3] # 限制导入的数量
end
task :student => :environment do
course = Course.find course_id
users = User.joins(:user_extension).where(user_extensions: {school_id: school_id, department_id: department_id, identity: 1}).limit(limit)
user_ids = []
users.each do |user|
if user.student_id.present? && !course.students.exists?(user_id: user.id)
begin
CourseMember.create!(course_id: course_id, user_id: user.id, role: 4)
user_ids << user.id
rescue Exception => e
Rails.logger(e.message)
end
end
end
CourseAddStudentCreateWorksJob.perform_later(course_id, user_ids)
end
end

@ -502,7 +502,7 @@ class TPMDataset extends Component {
//上传前的操作
console.log('beforeUpload', file);
// this.props.showNotification(`文件上传中`);
const isLt400M = file.size / 1024 / 1024 <= 1;
const isLt400M = file.size / 1024 / 1024 <= 400;
if (!isLt400M) {
this.props.showNotification('文件大小必须小于等于400MB!');

@ -412,7 +412,7 @@ class TPMIndex extends Component {
<span className={"tpmbannernavstyler"}>合作者</span>
</Menu.Item>
{ this.state.is_jupyter===true?<Menu.Item key="6" className={"competitionmr50"}>
{ this.state.identity >4||this.state.identity===undefined ? "":this.state.is_jupyter===true?<Menu.Item key="6" className={"competitionmr50"}>
<span className={"tpmbannernavstyler"}>数据集</span>
</Menu.Item>:""}

Loading…
Cancel
Save