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

dev_course
daiao 5 years ago
commit cf12521645

@ -12,5 +12,8 @@ module ControllerRescueHandler
rescue_from ActiveModel::ValidationError do |ex|
render_error(ex.model.errors.full_messages.join(','))
end
rescue_from ActiveRecord::RecordInvalid do |ex|
render_error(ex.record.errors.full_messages.join(','))
end
end
end

@ -993,7 +993,8 @@ class CoursesController < ApplicationController
normal_status(-1,"课堂暂时没有学生")
else
member_to_xlsx(@course, @all_members, @c_homeworks, @c_exercises, @c_tasks)
filename = current_user.real_name + "_" + @course.name + "_全部成绩" + Time.now.strftime('%Y%m%d_%H%M%S')
filename_ = "#{current_user.real_name}_#{@course.name}_全部成绩"
filename = Base64.urlsafe_encode64(filename_)
render xlsx: "#{format_sheet_name filename.strip.first(30)}",template: "courses/export_member_scores_excel.xlsx.axlsx",
locals: {course_info:@course_info, activity_level:@user_activity_level,
course_scores:@course_user_scores,shixun_works:@shixun_work_arrays,

@ -1,14 +1,5 @@
class Ecs::BaseController < ApplicationController
# model validation error
rescue_from ActiveRecord::RecordInvalid do |ex|
render_error(ex.record.errors.full_messages.join(','))
end
# form validation error
rescue_from ActiveModel::ValidationError do |ex|
render_error(ex.model.errors.full_messages.join(','))
end
before_action :require_login
before_action :check_user_permission!

@ -23,7 +23,6 @@ class ExercisesController < ApplicationController
before_action :commit_shixun_present,only: [:commit_shixun]
include ExportHelper
include ExercisesHelper
# require 'pdfkit'
def index
ActiveRecord::Base.transaction do
@ -43,45 +42,43 @@ class ExercisesController < ApplicationController
@exercises = @exercises_all #老师能看到全部的试卷,不管是已发布的/未发布的/已截止的/统一设置的/私有设置的(看到内容不同)
elsif @user_course_identity == Course::STUDENT # 2为课堂成员能看到统一设置的和自己班级的
@is_teacher_or = 2
# get_exercise_left_time(@exercise,current_user)
member_group_id = @current_student.first.try(:course_group_id).to_i # 成员的分班id默认为0
if member_group_id == 0 #表示是课堂的未分班成员,只能查看统一设置的试卷(已发布的/已截止的)
@member_group_id = @current_student.first.try(:course_group_id).to_i # 成员的分班id默认为0
if @member_group_id == 0 #表示是课堂的未分班成员,只能查看统一设置的试卷(已发布的/已截止的)
@exercises = member_show_exercises.exists? ? member_show_exercises.unified_setting : []
else #已分班级的成员,可以查看统一设置和单独设置(试卷是发布在该班级)试卷
# 已发布 当前用户班级分组的 试卷id
exercise_settings_ids = @course.exercise_group_settings.exercise_group_published
.where(course_group_id: member_group_id).pluck(:exercise_id).uniq
@exercises = member_show_exercises.exists? ?
member_show_exercises.unified_setting.or(member_show_exercises.where(id: exercise_settings_ids))
: []
not_exercise_ids = @course.exercise_group_settings.exercise_group_not_published.where("course_group_id = #{@member_group_id}").pluck(:exercise_id)
@exercises = member_show_exercises.where.not(id: not_exercise_ids)
# exercise_settings_ids = @course.exercise_group_settings.exercise_group_published
# .where(course_group_id: member_group_id).pluck(:exercise_id).uniq
# @exercises = member_show_exercises.exists? ?
# member_show_exercises.unified_setting.or(member_show_exercises.where(id: exercise_settings_ids))
# : []
end
else #用户未登陆或不是该课堂成员,仅显示统一设置的(已发布的/已截止的),如有公开,则不显示锁,不公开,则显示锁
@is_teacher_or = 0
@exercises = member_show_exercises.exists? ? member_show_exercises.unified_setting : []
@exercises = member_show_exercises.unified_setting
end
if @exercises.size > 0
if params[:type].present?
choose_type = params[:type].to_i
member_group_id = @current_student.first.try(:course_group_id).to_i
if @is_teacher_or == 2 && member_group_id > 0
exercise_groups_sets = @course.exercise_group_settings.where(course_group_id: member_group_id)
.exercise_group_published
exercise_settings_ids = exercise_groups_sets.pluck(:exercise_id)
exercise_ended_ids = exercise_groups_sets.exercise_group_ended.pluck(:exercise_id).uniq
if choose_type == 2
@exercises = @exercises_all.exists? ?
@exercises_all.exercise_by_status(2).unified_setting
.or(@exercises_all.where(id: (exercise_settings_ids - exercise_ended_ids).uniq))
: []
elsif choose_type == 3
@exercises = @exercises_all.exists? ?
@exercises_all.exercise_by_status(3).unified_setting
.or(@exercises_all.where(id: exercise_ended_ids))
: []
end
ex_setting_ids = []
if @is_teacher_or != 2
@exercises = @exercises.where("exercise_status = #{choose_type}")
else
@exercises = @exercises.exercise_by_status(choose_type)
case choose_type
when 1
ex_setting_ids = @course.exercise_group_settings.where("course_group_id = #{@member_group_id}").exercise_group_not_published.pluck(:exercise_id)
when 2
ex_setting_ids = @course.exercise_group_settings.where("course_group_id = #{@member_group_id}")
.where("publish_time is not null and publish_time <= ? and end_time > ?",Time.now,Time.now).pluck(:exercise_id)
when 3
ex_setting_ids = @course.exercise_group_settings.where("course_group_id = #{@member_group_id}").exercise_group_ended.pluck(:exercise_id)
end
unified_setting_ids = @exercises.unified_setting.where("exercise_status = #{choose_type}").pluck(:id)
ex_ids = (ex_setting_ids + unified_setting_ids).uniq
@exercises = @exercises.where(id: ex_ids)
end
end
@ -1302,9 +1299,11 @@ class ExercisesController < ApplicationController
respond_to do |format|
format.xlsx{
get_export_users(@exercise,@course,@export_ex_users)
exercise_export_name =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
exercise_export_name_ =
"#{current_user.real_name}_#{@course.name}_#{@exercise.exercise_name}"
exercise_export_name = Base64.urlsafe_encode64(exercise_export_name_.strip.first(30))
render xlsx: "#{exercise_export_name}",template: "exercises/exercise_lists.xlsx.axlsx",locals: {table_columns:@table_columns,exercise_users:@user_columns}
}
end
end
@ -1321,7 +1320,8 @@ class ExercisesController < ApplicationController
def export_exercise
@request_url = request.base_url
@exercise_questions = @exercise.exercise_questions.includes(:exercise_choices).order("question_number ASC")
filename = "#{@exercise.user.real_name}_#{@exercise.exercise_name}_#{Time.current.strftime('%Y%m%d_%H%M')}.pdf"
filename_ = "#{@exercise.user.real_name}_#{@exercise.exercise_name}"
filename = Base64.urlsafe_encode64(filename_.strip.first(30))
stylesheets = "#{Rails.root}/app/templates/exercise_export/exercise_export.css"
render pdf: 'exercise_export/blank_exercise', filename: filename, stylesheets: stylesheets
end

@ -134,8 +134,9 @@ class GraduationTasksController < ApplicationController
respond_to do |format|
format.xlsx{
graduation_work_to_xlsx(@work_excel,@task,current_user)
exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@task.name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
task_export_name_ = "#{current_user.real_name}_#{@course.name}_#{@task.name}"
task_export_name = Base64.urlsafe_encode64(task_export_name_.strip.first(30))
render xlsx: "#{task_export_name}",template: "graduation_tasks/tasks_list.xlsx.axlsx",locals: {table_columns:@head_cells_column, task_users:@task_cells_column}
}
end
end

@ -270,8 +270,9 @@ class GraduationTopicsController < ApplicationController
course = @course
students = course.students.joins(user: :user_extension).order("user_extensions.student_id")
graduation_topic_to_xlsx(students,course)
exercise_export_name = "#{current_user.real_name}_#{course.name}_毕设选题_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
render xlsx: "#{exercise_export_name.strip.first(30)}",template: "graduation_topics/export.xlsx.axlsx",locals: {table_columns:@topic_head_cells,topic_users:@topic_body_cells}
topic_export_name_ = "#{current_user.real_name}_#{course.name}_毕设选题_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
topic_export_name = Base64.urlsafe_encode64(topic_export_name_.strip.first(30))
render xlsx: "#{topic_export_name}",template: "graduation_topics/export.xlsx.axlsx",locals: {table_columns:@topic_head_cells,topic_users:@topic_body_cells}
rescue Exception => e
uid_logger(e.message)
missing_template

@ -206,10 +206,8 @@ class HomeworkCommonsController < ApplicationController
respond_to do |format|
format.xlsx{
student_work_to_xlsx(@work_excel,@homework)
exercise_export_name = current_user.real_name + "_" + @course.name + "_" + @homework.name + "_" + Time.now.strftime('%Y%m%d_%H%M%S')
# response.set_header("Content-Disposition","attachment; filename=#{exercise_export_name.strip.first(30)}};filename*=utf-8''#{exercise_export_name.strip.first(30)}}")
exercise_export_name = "#{current_user.real_name}_#{@course.name}_#{@homework.name}"
file_name = Base64.urlsafe_encode64(exercise_export_name.strip.first(30))
# response.setHeader['Content-Disposition'] = "attachment; filename=\"#{exercise_export_name.strip.first(30)}\""
render xlsx: "#{file_name}",template: "homework_commons/works_list.xlsx.axlsx",locals:
{table_columns: @work_head_cells,task_users: @work_cells_column}
}

@ -933,9 +933,11 @@ class PollsController < ApplicationController
else
respond_to do |format|
format.xlsx{
polls_export_name = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}_#{Time.now.strftime('%Y%m%d_%H%M%S')}"
polls_export_name_ = "#{current_user.real_name}_#{@course.name}_#{@poll.polls_name}"
polls_export_name = Base64.urlsafe_encode64(polls_export_name_.strip.first(30))
polls_user_commit = poll_commit_result(@poll,@poll_export_questions,@poll_users,@poll_commit_ids)
render xlsx: "#{polls_export_name.strip.first(30)}",template: "polls/commit_result.xlsx.axlsx",locals: {polls_user_commit:polls_user_commit}
render xlsx: "#{polls_export_name}",template: "polls/commit_result.xlsx.axlsx",locals: {polls_user_commit:polls_user_commit}
}
end
end

@ -0,0 +1,5 @@
class RepertoiresController < ApplicationController
def index
render_ok(repertoires: Repertoire.cache_data)
end
end

@ -456,9 +456,9 @@ class StudentWorksController < ApplicationController
@echart_data = student_efficiency(@homework, @work)
@myself_eff = @echart_data[:efficiency_list].find { |item| item.last == @user.id }
@myself_consume = @echart_data[:consume_list].find { |item| item.last == @user.id }
# filename = "实训报告_#{@shixun.name}_#{@use.real_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf" #下载报错 unknown nil name,下面为修改的-hs-0606
filename = "实训报告_#{@shixun&.name}_#{@use&.real_name}_#{Time.current.strftime('%Y%m%d%H%M%S')}.pdf"
filename_ = "实训报告_#{@shixun&.name}_#{@use&.real_name}"
filename = Base64.urlsafe_encode64(filename_.strip.first(30))
stylesheets = %w(shixun_work/shixun_work.css shared/codemirror.css)
render pdf: 'shixun_work/shixun_work', filename: filename, stylesheets: stylesheets
end

@ -1,21 +1,21 @@
class Users::InterestsController < Users::BaseController
skip_before_action :check_observed_user_exists!
before_action :require_login
before_action :private_user_resources!
def create
identity = params[:identity].to_s.strip
extension = observed_user.user_extension || observed_user.build_user_extension
extension = current_user.user_extension || current_user.build_user_extension
return render_error('请选择职业') unless %w(teacher student professional).include?(identity)
ActiveRecord::Base.transaction do
extension.update_column(:identity, identity)
# 兴趣
observed_user.user_interests.delete_all
current_user.user_interests.delete_all
UserInterest.bulk_insert(:user_id, :repertoire_id) do |worker|
(Repertoire.pluck(:id) & Array.wrap(params[:interest_ids]).map(&:to_i)).each do |repertoire_id|
worker.add(user_id: observed_user.id, repertoire_id: repertoire_id)
worker.add(user_id: current_user.id, repertoire_id: repertoire_id)
end
end
end

@ -9,8 +9,8 @@ class ZipsController < ApplicationController
service = BatchExportShixunReportService.new(@homework, @all_student_works)
filename = filename_for_content_disposition(service.filename)
filename_ = filename_for_content_disposition(service.filename)
filename = Base64.urlsafe_encode64(filename_)
send_file service.zip, filename: filename, type: 'application/zip'
rescue BatchExportShixunReportService::Error => ex
normal_status(-1, ex.message)
@ -20,8 +20,8 @@ class ZipsController < ApplicationController
@request_url = request.base_url
exercises = ExportExercisesService.new(@exercise,@ex_users,@request_url)
file_name = filename_for_content_disposition(exercises.filename)
file_name_ = filename_for_content_disposition(exercises.filename)
file_name = Base64.urlsafe_encode64(file_name_)
send_file exercises.ex_zip, filename: file_name, type: 'application/zip'
rescue Exception => e
normal_status(-1, e.message)

@ -723,8 +723,8 @@ module ExercisesHelper
if ex_time > 0
exercise_user = exercise.exercise_users.find_by(user_id:user.id)
time_mill = ex_time * 60 #转为秒
exercise_end_time = exercise.end_time.exists? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user&.start_at.exists? ? exercise_user.start_at.to_i : 0
exercise_end_time = exercise.end_time.present? ? exercise.end_time.to_i : 0
exercise_user_start = exercise_user&.start_at.present? ? exercise_user.start_at.to_i : 0
#用户未开始答题时即exercise_user_start为0
if exercise_user_start == 0
if (exercise_end_time - time_now_i) > time_mill

@ -65,7 +65,7 @@ module PollsHelper
poll_publish_time = ex_pb_time[:publish_time]
poll_end_time = ex_pb_time[:end_time]
current_status = 3
lock_icon = 1 #不显示锁图标
lock_icon = 0 #不显示锁图标
elsif is_teacher_or == 2
poll_users_list = poll.get_poll_exercise_users
get_poll_answers(poll_users_list) # 未答和已答的
@ -74,7 +74,7 @@ module PollsHelper
poll_publish_time = ex_pb_time[:publish_time]
poll_end_time = ex_pb_time[:end_time]
current_status = poll.check_user_votes_status(user)
lock_icon = 1 #不显示锁图标
lock_icon = 0 #不显示锁图标
else
poll_users_list = poll.get_poll_exercise_users
get_poll_answers(poll_users_list) # 未答和已答的
@ -87,6 +87,9 @@ module PollsHelper
lock_icon = 0 #显示锁图标
end
end
if (course.is_public == 1) && poll.is_public
lock_icon = 1
end
{
"publish_time":poll_publish_time,
"end_time":poll_end_time,

@ -1,6 +1,6 @@
# 学生加入课堂时创建相关任务作品
class CourseAddStudentCreateWorksJob < ApplicationJob
queue_as :course_member
queue_as :default
def perform(course_id, student_ids)
course = Course.find_by(id: course_id)

@ -1,5 +1,5 @@
class CourseDeleteStudentDeleteWorksJob < ApplicationJob
queue_as :course_member
queue_as :default
def perform(course_id, student_ids)
course = Course.find_by(id: course_id)

@ -1,6 +1,6 @@
# 毕设任务的交叉评阅分配
class GraduationTaskCrossCommentJob < ApplicationJob
queue_as :evaluation_comment
queue_as :default
def perform(graduation_task_id)
task = GraduationTask.find_by(id: graduation_task_id)

@ -1,5 +1,5 @@
class HomeworkAbsencePenaltyCalculationJob < ApplicationJob
queue_as :score
queue_as :default
def perform(homework_common_id)
homework_common = HomeworkCommon.find_by(id: homework_common_id)

@ -1,6 +1,6 @@
class HomeworkEndUpdateScoreJob < ApplicationJob
# 不允许补交的作业截止后,或者补交截止后需要重新计算一次作业成绩
queue_as :score
queue_as :default
def perform(homework_id)
homework = HomeworkCommon.find_by(id: homework_id)

@ -1,5 +1,5 @@
class HomeworkEvaluationCommentAssginJob < ApplicationJob
queue_as :evaluation_comment
queue_as :default
def get_assigned_homeworks(student_works, n, index)
student_works += student_works

@ -1,6 +1,6 @@
class HomeworkPublishUpdateWorkStatusJob < ApplicationJob
# 作业发布时更新学生(发布前已开启过实训)的作业状态和成绩
queue_as :score
queue_as :default
def perform(group_ids, homework_id)
# Do something later

@ -144,10 +144,10 @@ class Exercise < ApplicationRecord
ex_answer_user = exercise_users.find_by(user_id: user.id)
user_ex_status = get_exercise_status(user.id)
user_status = 2
if ex_answer_user.exists? && (ex_answer_user.start_at.exists? || ex_answer_user.end_at.exists?) #学生有过答题的,或者立即截止,但学生未做试卷的
if ex_answer_user.present? && (ex_answer_user.start_at.present? || ex_answer_user.end_at.present?) #学生有过答题的,或者立即截止,但学生未做试卷的
user_status = ex_answer_user.commit_status
end
if ex_answer_user.exists? && ex_answer_user.start_at.blank? && user_ex_status == 3
if ex_answer_user.present? && ex_answer_user.start_at.blank? && user_ex_status == 3
user_status = 4
end

@ -3,4 +3,23 @@ class Repertoire < ApplicationRecord
has_many :tag_repertoires, through: :sub_repertoires
has_many :user_interests, dependent: :delete_all
after_create_commit :reset_cache_data
after_update_commit :reset_cache_data
def self.cache_data
Rails.cache.fetch(data_cache_key, expires_in: 1.days) do
Repertoire.select(:id, :name).order(:created_at).as_json
end
end
def self.data_cache_key
'repertoire/cache_data'
end
private
def reset_cache_data
Rails.cache.delete(self.class.data_cache_key)
end
end

@ -14,7 +14,7 @@ class BatchExportShixunReportService
end
def filename
@_filename ||= "#{homework.name}-#{Time.now.strftime('%Y%m%d%H%M%S')}.zip"
@_filename ||= "#{homework.name}"
end
def zip

@ -10,7 +10,7 @@ class ExportExercisesService
end
def filename
exercise_export_name = "#{exercise.user.real_name}_#{exercise.exercise_name}_#{Time.now.strftime('%Y%m%d_%H%M')}"
exercise_export_name = "#{exercise.user.real_name}_#{exercise.exercise_name}"
"#{exercise_export_name.strip}.zip"
end

@ -47,7 +47,6 @@ Rails.application.routes.draw do
resource :experience_records, only: [:show]
resource :grade_records, only: [:show]
resource :watch, only: [:create, :destroy]
resource :interest, only: [:create]
end
@ -78,6 +77,7 @@ Rails.application.routes.draw do
resource :auth_attachment, only: [:update]
resource :authentication_apply, only: [:create]
resource :professional_auth_apply, only: [:create]
resource :interest, only: [:create]
end
end
end
@ -661,6 +661,8 @@ Rails.application.routes.draw do
get :export_exercises
end
end
resources :repertoires, only: [:index]
end
#git 认证回调

@ -3,7 +3,4 @@
:logfile: log/sidekiq.log
:queues:
- [default, 3]
- [score, 4]
- [evaluation_comment, 5]
- [course_member, 6]
- [notify, 100]
Loading…
Cancel
Save