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

dev_jupyter
杨树明 5 years ago
commit 80149e54ff

@ -23,9 +23,7 @@ class ApplicationController < ActionController::Base
# 所有请求必须合法签名
def check_sign
Rails.logger.info("#####################request: #{request.headers}")
#Rails.logger.info("#####################type: #{request.type}")
if !Rails.env.development? && EduSetting.get("host_name") != "https://test-newweb.educoder.net"
if !Rails.env.development?
Rails.logger.info("66666 #{params}")
# suffix = request.url.split(".").last.split("?").first
# suffix_arr = ["xls", "xlsx", "pdf", "zip"] # excel文件先注释

@ -53,7 +53,7 @@ class CollegesController < ApplicationController
homeworks = HomeworkCommon.where(:homework_type => 4, :course_id => course_ids.map(&:id))
un_shixun_work_count = homeworks.where("publish_time > '#{Time.now}' or publish_time is null").count
shixun_work_count = homeworks.size - un_shixun_work_count
student_count = StudentsForCourse.where(:course_id => course_ids.map(&:id)).count
student_count = CourseMember.where(course_id: course_ids.map(&:id), role: 4).count
myshixun_ids = StudentWork.select("myshixun_id").where("homework_common_id in (#{homeworks.map(&:id).join(',').strip == "" ? -1 : homeworks.map(&:id).join(',')}) and myshixun_id is not null")
complete_myshixun = Myshixun.select("id").where(:status => 1, :id => myshixun_ids.map(&:myshixun_id)).size
all_myshixun = Myshixun.select("id").where(:id => myshixun_ids.map(&:myshixun_id)).size
@ -105,7 +105,7 @@ class CollegesController < ApplicationController
@courses = paginate courses
course_ids = @courses.map(&:id)
@student_count = StudentsForCourse.where(course_id: course_ids).group(:course_id).count
@student_count = CourseMember.where(course_id: course_ids, role: 4).group(:course_id).count
@shixun_work_count = HomeworkCommon.where(homework_type: 4, course_id: course_ids).group(:course_id).count
@attachment_count = Attachment.where(container_id: course_ids, container_type: 'Course').group(:container_id).count
@message_count = Message.joins(:board).where(boards: { parent_id: 0, course_id: course_ids }).group('boards.course_id').count

@ -402,7 +402,7 @@ class ExercisesController < ApplicationController
if unified_setting || (course_group_ids.size == 0)
tip_exception("发布时间不能为空") if params[:publish_time].blank?
tip_exception("截止时间不能为空") if params[:end_time].blank?
tip_exception("截止时间不能早于发布时间") if params[:publish_time].to_time > params[:end_time].to_time
tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if @course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day
params_publish_time = params[:publish_time].to_time

@ -384,11 +384,11 @@ class GraduationTasksController < ApplicationController
if @task.status == 0
tip_exception("发布时间不能为空") if params[:publish_time].blank?
tip_exception("截止时间不能为空") if params[:end_time].blank?
tip_exception("发布时间不能早于当前时间") if params[:publish_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S")
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S")
tip_exception("截止时间不能早于发布时间") if params[:publish_time] > params[:end_time]
tip_exception("发布时间不能早于当前时间") if params[:publish_time].to_time <= Time.now
tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now
tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time] > strf_time(@course.end_date.end_of_day)
@course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day
@task.publish_time = params[:publish_time]
@task.end_time = params[:end_time]

@ -26,14 +26,14 @@ class HelpsController < ApplicationController
def feedback
if params[:url].blank?
content = "<p>[#{params[:question_kind]}]</p></p>#{params[:description]}"
content = "[#{params[:question_kind]}]<br>#{params[:description]}<br>"
if params[:attachment_ids]
params[:attachment_ids].each do |attachment_id|
content += "![](/api/attachments/#{attachment_id})"
content += "![](/api/attachments/#{attachment_id})<br>"
end
end
else
content = "<p>[#{params[:question_kind]}]</p><p>问题页面网址:#{params[:url]}</p>#{params[:description]}"
content = "[#{params[:question_kind]}]<br>问题页面网址:#{params[:url]}<br>#{params[:description]}"
end
ActiveRecord::Base.transaction do

@ -724,7 +724,7 @@ class PollsController < ApplicationController
if unified_setting || (course_group_ids.size == 0)
tip_exception("发布时间不能为空") if params[:publish_time].blank?
tip_exception("截止时间不能为空") if params[:end_time].blank?
tip_exception("截止时间不能早于发布时间") if params[:publish_time].to_time > params[:end_time].to_time
tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time
tip_exception("截止时间不能晚于课堂结束时间(#{@course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
@course.end_date.present? && params[:end_time].to_time > @course.end_date.end_of_day

@ -458,30 +458,19 @@ class SubjectsController < ApplicationController
end
def statistics_info
# data = Subjects::DataStatisticService.new(@subject)
# Rails.logger.info("study_count: #{data.study_count}")
# Rails.logger.info("course_study_count: #{ data.course_study_count}")
# Rails.logger.info("passed_count: #{data.passed_count}")
# Rails.logger.info("course_used_count: #{data.course_used_count}")
# Rails.logger.info("school_used_count: #{data.school_used_count}")
# data_1 = Subjects::CourseUsedInfoService.call(@subject)
# Rails.logger.info("study_count: #{data_1}")
# data_2 = Subjects::ShixunUsedInfoService.call(@subject)
# Rails.logger.info("study_count: #{data_2}")
# data_3 = Subjects::UserUsedInfoService.call(@subject)
# Rails.logger.info("study_count: #{data_3}")
@data =
if params[:type] == "shixun_info"
@subject.subject_shixun_infos
elsif params[:type] == "user_info"
@subject.subject_user_infos
else
select_sql = "id, count(subject_course_records.id) total, sum(course_count) course_count, sum(student_count) student_count, " +
"sum(choice_shixun_num) choice_shixun_num, sum(choice_shixun_frequency) choice_shixun_frequency"
@total = @subject.subject_course_records.select("#{select_sql}").first
@subject.subject_course_records
end
@data_count = @data.count
@data = paginate custom_sort(@data, params[:sort_by], params[:sort_direction])
end

@ -19,11 +19,10 @@ class Weapps::VerificationCodesController < Weapps::BaseController
return render_error('请输入正确的邮箱或手机号')
end
code = %W(0 1 2 3 4 5 6 7 8 9)
verification_code = code.sample(6).join
send_type = login =~ /^1\d{10}$/ ? 1 : 8
# 记录验证码
check_verification_code(verification_code, send_type, login)
# 发送验证码
send_code(send_type, login)
render_ok
end
@ -40,12 +39,21 @@ class Weapps::VerificationCodesController < Weapps::BaseController
return render_error('请输入正确的邮箱或手机号')
end
send_type = login =~ /^1\d{10}$/ ? 2 : 3
# 发送验证码
send_code(send_type, login)
render_ok
end
def send_code send_type, login
code = %W(0 1 2 3 4 5 6 7 8 9)
verification_code = code.sample(6).join
send_type = login =~ /^1\d{10}$/ ? 2 : 3
# 记录验证码
check_verification_code(verification_code, send_type, login)
sign = Digest::MD5.hexdigest("#{OPENKEY}#{login}")
tip_exception(501, "请求不合理") if sign != params[:smscode]
render_ok
check_verification_code(verification_code, send_type, login)
end
end

@ -188,7 +188,7 @@ module ExercisesHelper
if ex_ordered
all_user_answers = effictive_users.pluck(:answer_text)
null_stand_choice.each_with_index do |s,index|
s_choice_text = null_stand_text[index]
s_choice_text = null_stand_text[index].to_s.strip
user_count = 0
# user_count = user_count + effictive_users.where("exercise_choice_id = ? and answer_text = ?",s,s_choice_text).pluck(:user_id).uniq.size
user_count = user_count + effictive_users.select{|answer| answer.exercise_choice_id == s && answer.answer_text == s_choice_text}.size

@ -64,7 +64,7 @@ class GitService
end
def parse_return(body)
logger.info("--uri_exec: .....res is #{body}")
#logger.info("--uri_exec: .....res is #{body}")
content = JSON.parse(body)
if content["code"] != 0

@ -23,9 +23,10 @@ class ShixunSearchService < ApplicationService
if User.current.admin? || User.current.business? || !User.current.school_id
@shixuns = @shixuns.where(hidden: 0)
else
none_shixun_ids = ShixunSchool.where("school_id != #{User.current.school_id}").pluck(:shixun_id)
shixun_ids = ShixunSchool.where(school_id: User.current.school_id).pluck(:shixun_id)
shixun_ids = shixun_ids.reject(&:blank?).length == 0 ? -1 : shixun_ids.join(",")
@shixuns = @shixuns.where.not(id: none_shixun_ids).where(hidden: 0, status: 2, public: 2).or(@shixuns.where(id: User.current.shixuns))
@shixuns = @shixuns.where("use_scope = 0 or id in (#{shixun_ids})").unhidden.published.or(@shixuns.where(id: User.current.shixuns))
end
end

@ -15,11 +15,11 @@ class UpdateHomeworkPublishSettingService < ApplicationService
if params[:unified_setting] || course.course_groups_count == 0
tip_exception("发布时间不能为空") if params[:publish_time].blank?
tip_exception("截止时间不能为空") if params[:end_time].blank?
tip_exception("发布时间不能早于当前时间") if params[:publish_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S")
tip_exception("截止时间不能早于当前时间") if params[:end_time] <= Time.now.strftime("%Y-%m-%d %H:%M:%S")
tip_exception("截止时间不能早于发布时间") if params[:publish_time] > params[:end_time]
tip_exception("发布时间不能早于当前时间") if params[:publish_time].to_time <= Time.now
tip_exception("截止时间不能早于当前时间") if params[:end_time].to_time <= Time.now
tip_exception("截止时间必须晚于发布时间") if params[:publish_time].to_time >= params[:end_time].to_time
tip_exception("截止时间不能晚于课堂结束时间(#{course.end_date.end_of_day.strftime("%Y-%m-%d %H:%M")}") if
course.end_date.present? && params[:end_time] > course.end_date.end_of_day
course.end_date.present? && params[:end_time].to_time > course.end_date.end_of_day
homework.unified_setting = 1
homework.homework_group_settings.destroy_all

@ -3,4 +3,6 @@ json.message "success"
json.data do
json.subject_info @subject.subject_record
json.other_info @data
json.total_count @data_count
json.total @total
end

@ -7,6 +7,7 @@ json.admin user.admin?
json.business user.business?
json.is_teacher user.user_extension&.teacher?
json.user_identity user.identity
json.identity user.user_extension&.identity
json.tidding_count 0
json.user_phone_binded user.phone.present?
json.phone user.phone

@ -613,7 +613,6 @@ a级情片
大史纪
戴相龙
弹劾
登辉
邓笑贫
迪里夏提
地下教会

@ -0,0 +1,25 @@
class MigrateCouresMemberGroup < ActiveRecord::Migration[5.2]
def change
course_ids = [377, 657, 715, 777, 973, 1093, 1131, 1180, 1309, 1920, 2037, 2346, 2354, 2493, 2752, 2920, 3000,
3141, 3240, 3350, 3351, 3353, 3387, 3533, 3796]
courses = Course.where(id: course_ids)
courses.each do |course|
group_ids = course.course_groups.pluck(:id) + [0]
course.course_members.where.not(course_group_id: group_ids).each do |member|
if CourseGroup.where(course_id: course.id, name: member.course_group_name).exists?
new_group = CourseGroup.where(course_id: course.id, name: member.course_group_name).first
else
# position = CourseGroup.where(course_id: course.id).order("position desc").first&.position.to_i + 1
new_group = course.course_groups.create!(name: member.course_group_name)
course.exercise_group_settings.where(course_group_id: member.course_group_id).update_all(course_group_id: new_group.id)
course.attachment_group_settings.where(course_group_id: member.course_group_id).update_all(course_group_id: new_group.id)
HomeworkGroupReview.where(homework_common_id: course.homework_commons.pluck(:id)).where(course_group_id: member.course_group_id).update_all(course_group_id: new_group.id)
course.homework_group_settings.where(course_group_id: member.course_group_id).update_all(course_group_id: new_group.id)
end
member.update!(course_group_id: new_group.id)
end
end
end
end

@ -0,0 +1,14 @@
class MigrateCoureGroupPosition < ActiveRecord::Migration[5.2]
def change
course_ids = [377, 657, 715, 777, 973, 1093, 1131, 1180, 1309, 1920, 2037, 2346, 2354, 2493, 2752, 2920, 3000,
3141, 3240, 3350, 3351, 3353, 3387, 3533, 3796]
courses = Course.where(id: course_ids)
courses.each do |course|
CourseGroup.where(course_id: course.id).reorder("position ASC, CONVERT(course_groups.name USING gbk) COLLATE gbk_chinese_ci ASC").each_with_index do |group, index|
group.update!(position: index+1)
end
end
end
end
Loading…
Cancel
Save